Counter Strike : Global Offensive Source Code
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
// STATIC: "HASALPHAMASK" "0..1" // STATIC: "HASSTATICTEXTURE" "0..1" // STATIC: "USEALTERNATEVIEW" "0..1"
// DYNAMIC: "SKINNING" "0..1" // DYNAMIC: "ADDSTATIC" "0..1"
#define USESTATICTEXTURE (((ADDSTATIC == 1) && (HASSTATICTEXTURE == 1)))
#include "common_vs_fxc.h"
static const bool g_bSkinning = SKINNING ? true : false;
#if ( USEALTERNATEVIEW == 1 ) const float4x4 g_CustomViewProj : register( SHADER_SPECIFIC_CONST_0 ); #endif
const float4 g_vViewportMad : register( SHADER_SPECIFIC_CONST_4 ); const float g_vIsRecursivePortalView : register( SHADER_SPECIFIC_CONST_5 );
struct VS_INPUT { float4 vPos : POSITION; float4 vNormal : NORMAL; float4 vBoneWeights : BLENDWEIGHT; float4 vBoneIndices : BLENDINDICES; float2 vMappingTexCoord : TEXCOORD0; float flDecalOffset : TEXCOORD1; // How far to move each vertex along the normal };
struct VS_OUTPUT { float4 vProjPos : POSITION; float3 vPortalTexCoord : TEXCOORD0;
#if( (HASALPHAMASK == 1) || (USESTATICTEXTURE) ) float2 vSecondaryTexCoord : TEXCOORD1; #if( (HASALPHAMASK == 1) && (USESTATICTEXTURE) ) float2 vTertiaryTexCoord : TEXCOORD2; #endif #endif
#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) float fog : FOG; #endif
float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog };
VS_OUTPUT main( const VS_INPUT v ) { VS_OUTPUT o = ( VS_OUTPUT )0; float3 worldPos; // Move the portal decal away from the base surface a bit to avoid z fighting float3 vObjNormal; DecompressVertex_Normal( v.vNormal, vObjNormal ); float4 vObjPos = v.vPos.xyzw; float flDecalOffset = 1.0f; // This offset is used in recursive portal views when using fast clipping (e.g. on the PS3). // It prevents ugly Z fighting between the portal and the surface it's on due to reduced Z precision when // a player is really really close to a portal. if ( g_vIsRecursivePortalView == 0.0f ) { flDecalOffset = v.flDecalOffset; } vObjPos.xyz += flDecalOffset * vObjNormal.xyz;
SkinPosition( g_bSkinning, vObjPos, v.vBoneWeights, v.vBoneIndices, worldPos ); float4 vTextureProjectedPos; o.vProjPos = mul( float4( worldPos, 1 ), cViewProj ); #ifdef _PS3 { // Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1] o.vProjPos.y = -o.vProjPos.y; o.vProjPos.z = 2.0f * o.vProjPos.z - o.vProjPos.w; } #endif // _PS3
#if ( USEALTERNATEVIEW == 1 ) { vTextureProjectedPos = mul( float4( worldPos, 1 ), g_CustomViewProj ); } #else { vTextureProjectedPos = o.vProjPos; } #endif #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) { o.fog = CalcFixedFunctionFog( worldPos, FOGTYPE_RANGE ); } #endif
o.worldPos_projPosZ = float4( worldPos.xyz, o.vProjPos.z ); //Screen coordinates mapped back to texture coordinates for the portal texture o.vPortalTexCoord.x = vTextureProjectedPos.x; o.vPortalTexCoord.y = -vTextureProjectedPos.y; // invert Y o.vPortalTexCoord.xy = (o.vPortalTexCoord.xy + vTextureProjectedPos.w) * 0.5f; o.vPortalTexCoord.z = vTextureProjectedPos.w; #if ( USEALTERNATEVIEW == 1 ) { o.vPortalTexCoord.xy = saturate( o.vPortalTexCoord.xy / vTextureProjectedPos.w ) * vTextureProjectedPos.w; //stretch instead of clipping. } #endif //handle non-fullscreen viewports o.vPortalTexCoord.xy = ( ( ( o.vPortalTexCoord.xy / vTextureProjectedPos.w ) * g_vViewportMad.xy ) + g_vViewportMad.zw ) * vTextureProjectedPos.w; //handle non-fullscreen viewports #if( (HASALPHAMASK == 1) || (USESTATICTEXTURE) ) { o.vSecondaryTexCoord = v.vMappingTexCoord.xy; #if( (HASALPHAMASK == 1) && (USESTATICTEXTURE) ) { o.vTertiaryTexCoord = v.vMappingTexCoord.xy; } #endif } #endif
return o; }
|