⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teeth_vs20.fxc

📁 hl2 source code. Do not use it illegal.
💻 FXC
字号:
//	STATIC: "LIGHT_COMBO"			"0..21"
//	STATIC: "FOG_TYPE"				"0..1"
//	STATIC: "NUM_BONES"				"0..3"
//	STATIC: "BUMPMAP"				"0..1"

//#define USE_CONDITIONALS

#include "common_vs_fxc.h"

static const int g_LightCombo		= LIGHT_COMBO;
static const int g_FogType			= FOG_TYPE;
#ifdef USE_CONDITIONALS
const bool g_bZeroBones : register( b0 );
const bool g_bOneBone   : register( b1 );
const bool g_bTwoBones  : register( b2 );
#else
static const int g_NumBones			= NUM_BONES;
#endif
static const bool g_bBumpmap		 = BUMPMAP ? true : false;

static const int g_StaticLightType = g_StaticLightTypeArray[g_LightCombo];
static const int g_AmbientLightType = g_AmbientLightTypeArray[g_LightCombo];
static const int g_LocalLightType0 = g_LocalLightType0Array[g_LightCombo];
static const int g_LocalLightType1 = g_LocalLightType1Array[g_LightCombo];

const float4 cTeethLighting						:  register( c20 );
const float4 cBaseTexCoordTransform[2]			:  register( c90 );
const float4 cBumpTexCoordTransform[2]			:  register( c92 );
const float4 cEnvmapMaskTexCoordTransform[2]	:  register( c94 );

struct VS_INPUT
{
	// This is all of the stuff that we ever use.
	float4 vPos				: POSITION;
	float4 vBoneWeights		: BLENDWEIGHT;
	float4 vBoneIndices		: BLENDINDICES;
	float3 vNormal			: NORMAL;
	float4 vColor			: COLOR0;
	float3 vSpecular		: COLOR1;
	// make these float2's and stick the [n n 0 1] in the dot math.
	float4 vTexCoord0		: TEXCOORD0;
	float4 vTexCoord1		: TEXCOORD1;
	float4 vTexCoord2		: TEXCOORD2;
	float4 vTexCoord3		: TEXCOORD3;
	float3 vTangentS		: TANGENT;
	float3 vTangentT		: BINORMAL;
	float4 vUserData		: TANGENT;
};

struct VS_OUTPUT
{
    float4 projPos					: POSITION;	
	float  fog						: FOG;
	float2 baseTexCoord				: TEXCOORD0;
	float2 bumpTexCoord				: TEXCOORD1;
	// bump mapping and a separate envmap mask texture are mutually exclusive.
	float2 envmapMaskTexCoord		: TEXCOORD2;
	float3 worldVertToEyeVector				: TEXCOORD3;
	float3x3 tangentSpaceTranspose	: TEXCOORD4;
	float4 color1					: COLOR0;
	float3 color2					: COLOR1;
	float3 color3					: TEXCOORD7;
};

VS_OUTPUT main( const VS_INPUT v )
{
	VS_OUTPUT o = ( VS_OUTPUT )0;

	float3 worldNormal, worldPos, worldTangentS, worldTangentT;
	SkinPositionNormalAndTangentSpace( 
#ifdef USE_CONDITIONALS
		g_bZeroBones, g_bOneBone, g_bTwoBones,
#else
		g_NumBones, 
#endif
		v.vPos, v.vNormal, v.vUserData,
		v.vBoneWeights, v.vBoneIndices,
		worldPos, worldNormal, worldTangentS, worldTangentT );

	float4 projPos = mul( float4( worldPos, 1 ), cViewProj );
	o.projPos = projPos;
	o.fog = CalcFog( worldPos, projPos, g_FogType );
	o.worldVertToEyeVector = VSHADER_VECT_SCALE * (cEyePos - worldPos);

	float flTeethDarkening = dot( cTeethLighting.xyz, worldNormal );
	flTeethDarkening = max( 0.0f, flTeethDarkening );
	flTeethDarkening *= cTeethLighting.w;

	if( g_bBumpmap )
	{
		float3 gammaColorNormal;
		// hack - need 3 baked lighting values for static props (vSpecular)
		DoBumpedLighting( worldPos, worldNormal, worldTangentS, worldTangentT,
			v.vSpecular, v.vSpecular, v.vSpecular, v.vSpecular,
			g_StaticLightType, g_AmbientLightType, g_LocalLightType0, g_LocalLightType1,
			flTeethDarkening, o.color1.xyz, o.color2.xyz, o.color3.xyz, gammaColorNormal );
	}
	else
	{
		o.color1.xyz = DoLighting( worldPos, worldNormal, v.vSpecular,
			g_StaticLightType, g_AmbientLightType, g_LocalLightType0, g_LocalLightType1, flTeethDarkening );
	}

	o.baseTexCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] );
	o.baseTexCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] );
	o.bumpTexCoord.x = dot( v.vTexCoord0, cBumpTexCoordTransform[0] );
	o.bumpTexCoord.y = dot( v.vTexCoord0, cBumpTexCoordTransform[1] );
	o.envmapMaskTexCoord.x = dot( v.vTexCoord0, cEnvmapMaskTexCoordTransform[0] );
	o.envmapMaskTexCoord.y = dot( v.vTexCoord0, cEnvmapMaskTexCoordTransform[1] );
	if( g_bBumpmap )
	{
		o.tangentSpaceTranspose[0] = worldTangentS;
		o.tangentSpaceTranspose[1] = worldTangentT;
		o.tangentSpaceTranspose[2] = worldNormal;
	}
	return o;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -