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

📄 lightmappedgeneric_inc.vsh

📁 hl2 source code. Do not use it illegal.
💻 VSH
字号:
#include "macros.vsh"

;------------------------------------------------------------------------------
;	 c90-c91 = Base texture transform
;    c92-c93 = Mask texture transform
;	 c94	 = Modulation color 
;------------------------------------------------------------------------------

sub LightmappedGeneric
{
	local( $detail ) = shift;
	local( $envmap ) = shift;
	local( $envmapcameraspace ) = shift;
	local( $envmapsphere ) = shift;
	local( $vertexcolor ) = shift;

	local( $worldPos, $worldNormal, $projPos, $reflectionVector );

	&AllocateRegister( \$projPos );

	dp4 $projPos.x, $vPos, $cModelViewProj0
	dp4 $projPos.y, $vPos, $cModelViewProj1
	dp4 $projPos.z, $vPos, $cModelViewProj2
	dp4 $projPos.w, $vPos, $cModelViewProj3
	mov oPos, $projPos

	&AllocateRegister( \$worldPos );

	if( $g_fogType eq "heightfog" )
	{
		; Get the worldpos z component only since that's all we need for height fog
		dp4 $worldPos.z, $vPos, $cModel2
	}
	&CalcFog( $worldPos, $projPos );
	&FreeRegister( \$projPos );

	;------------------------------------------------------------------------------
	; Texture coordinates
	;------------------------------------------------------------------------------
	; base texcoords
	dp4 oT0.x, $vTexCoord0, c90 ; FIXME
	dp4 oT0.y, $vTexCoord0, c91 ; FIXME

	; lightmap texcoords
	mov oT1, $vTexCoord1

	if( $envmap )
	{
		&AllocateRegister( \$worldNormal );

		; Transform the position + normal to world space
		dp4 $worldPos.x, $vPos, $cModel0
		dp4 $worldPos.y, $vPos, $cModel1
		if( $g_fogType ne "heightfog" )
		{
			dp4 $worldPos.z, $vPos, $cModel2
		}

		dp3 $worldNormal.x, $vNormal, $cModel0
		dp3 $worldNormal.y, $vNormal, $cModel1
		dp3 $worldNormal.z, $vNormal, $cModel2

		if( $envmapcameraspace )
		{
			&AllocateRegister( \$reflectionVector );
			&ComputeReflectionVector( $worldPos, $worldNormal, $reflectionVector );
			; transform reflection vector into view space
			dp3 oT2.x, $reflectionVector, $cViewModel0
			dp3 oT2.y, $reflectionVector, $cViewModel1
			dp3 oT2.z, $reflectionVector, $cViewModel2
			&FreeRegister( \$reflectionVector );
		}
		elsif( $envmapsphere )
		{
			&AllocateRegister( \$reflectionVector );
			&ComputeReflectionVector( $worldPos, $worldNormal, $reflectionVector );
			&ComputeSphereMapTexCoords( $reflectionVector, "oT2" );
			&FreeRegister( \$reflectionVector );
		}
		else
		{
			&ComputeReflectionVector( $worldPos, $worldNormal, "oT2" );
		}
		; envmap mask
		dp4 oT3.x, $vTexCoord0, c92	; FIXME
		dp4 oT3.y, $vTexCoord0, c93	; FIXME

#		&FreeRegister( \$worldPos );
		&FreeRegister( \$worldNormal );
	}

	&FreeRegister( \$worldPos ); # garymcthack

	if( $detail )
	{
		dp4 oT2.x, $vTexCoord0, c94		; FIXME
		dp4 oT2.y, $vTexCoord0, c95		; FIXME
	}

	if( $vertexcolor )
	{
		; Modulation color
		mul oD0, $vColor, $cModulationColor
	}
	else
	{
		; Modulation color
		mov oD0, $cModulationColor
	}
}

⌨️ 快捷键说明

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