aboutsummaryrefslogtreecommitdiff
path: root/mp/src/materialsystem
diff options
context:
space:
mode:
authorJørgen P. Tjernø <[email protected]>2013-12-03 10:39:23 -0800
committerJørgen P. Tjernø <[email protected]>2013-12-03 11:57:22 -0800
commitb5dc4a85433a908d38d453e98d7d45e22e2a5fc0 (patch)
treef186094efa03e9c1144fb5c98161cf3f7b054f90 /mp/src/materialsystem
parentSpecify clobbered registers in POSIX SSE functions (diff)
downloadsource-sdk-2013-b5dc4a85433a908d38d453e98d7d45e22e2a5fc0.tar.xz
source-sdk-2013-b5dc4a85433a908d38d453e98d7d45e22e2a5fc0.zip
Line-ending fixes for most of the remaining files.
Fixes line-endings for files with extensions vcd, cc, txt, bat, fxc, inc, lst, proto, mak, mm, cfg, res, rc, def, vmt, vsh, vbsp, inl, asm, m4, vcproj, vcxproj, sln, in, java, la, manifest, am, and rad. Also fixes README, CONTRIBUTING, CONTRIBUTORS, LICENSE, CHANGES, COPYING, and gitignore. Finally, fixes executable bits.
Diffstat (limited to 'mp/src/materialsystem')
-rw-r--r--mp/src/materialsystem/stdshaders/SDK_Bloom_ps2x.fxc40
-rw-r--r--mp/src/materialsystem/stdshaders/SDK_bloomadd_ps11.fxc36
-rw-r--r--mp/src/materialsystem/stdshaders/SDK_bloomadd_ps2x.fxc46
-rw-r--r--mp/src/materialsystem/stdshaders/SDK_screenspaceeffect_vs20.fxc94
-rwxr-xr-x[-rw-r--r--]mp/src/materialsystem/stdshaders/buildhl2mpshaders.bat42
-rwxr-xr-x[-rw-r--r--]mp/src/materialsystem/stdshaders/buildsdkshaders.bat80
-rwxr-xr-x[-rw-r--r--]mp/src/materialsystem/stdshaders/buildshaders.bat418
-rwxr-xr-x[-rw-r--r--]mp/src/materialsystem/stdshaders/clean.bat64
-rwxr-xr-x[-rw-r--r--]mp/src/materialsystem/stdshaders/cleantemps.bat24
-rw-r--r--mp/src/materialsystem/stdshaders/example_model_ps20b.fxc184
-rw-r--r--mp/src/materialsystem/stdshaders/example_model_vs20.fxc182
-rw-r--r--mp/src/materialsystem/stdshaders/fxctmp9/SDK_Bloom_ps20.inc66
-rw-r--r--mp/src/materialsystem/stdshaders/fxctmp9/SDK_Bloom_ps20b.inc120
-rw-r--r--mp/src/materialsystem/stdshaders/fxctmp9/SDK_bloomadd_ps20.inc66
-rw-r--r--mp/src/materialsystem/stdshaders/fxctmp9/SDK_bloomadd_ps20b.inc66
-rw-r--r--mp/src/materialsystem/stdshaders/fxctmp9/SDK_screenspaceeffect_vs20.inc120
-rw-r--r--mp/src/materialsystem/stdshaders/fxctmp9/example_model_ps20b.inc474
-rw-r--r--mp/src/materialsystem/stdshaders/fxctmp9/example_model_vs20.inc320
-rw-r--r--mp/src/materialsystem/stdshaders/macros.vsh2786
-rw-r--r--mp/src/materialsystem/stdshaders/stdshader_dx9_20b.txt32
-rw-r--r--mp/src/materialsystem/stdshaders/stdshader_dx9_30.txt20
21 files changed, 2640 insertions, 2640 deletions
diff --git a/mp/src/materialsystem/stdshaders/SDK_Bloom_ps2x.fxc b/mp/src/materialsystem/stdshaders/SDK_Bloom_ps2x.fxc
index 82a386ae..1bad205e 100644
--- a/mp/src/materialsystem/stdshaders/SDK_Bloom_ps2x.fxc
+++ b/mp/src/materialsystem/stdshaders/SDK_Bloom_ps2x.fxc
@@ -1,21 +1,21 @@
-// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
-// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
-
-#define HDRTYPE HDR_TYPE_NONE
-#include "common_ps_fxc.h"
-
-sampler FBSampler : register( s0 );
-sampler BlurSampler : register( s1 );
-
-struct PS_INPUT
-{
- float2 texCoord : TEXCOORD0;
-};
-
-float4 main( PS_INPUT i ) : COLOR
-{
- float4 fbSample = tex2D( FBSampler, i.texCoord );
- float4 blurSample = tex2D( BlurSampler, i.texCoord );
-
- return FinalOutput( float4( fbSample + blurSample.rgb * blurSample.a * MAX_HDR_OVERBRIGHT, 1.0f ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
+// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
+// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
+
+#define HDRTYPE HDR_TYPE_NONE
+#include "common_ps_fxc.h"
+
+sampler FBSampler : register( s0 );
+sampler BlurSampler : register( s1 );
+
+struct PS_INPUT
+{
+ float2 texCoord : TEXCOORD0;
+};
+
+float4 main( PS_INPUT i ) : COLOR
+{
+ float4 fbSample = tex2D( FBSampler, i.texCoord );
+ float4 blurSample = tex2D( BlurSampler, i.texCoord );
+
+ return FinalOutput( float4( fbSample + blurSample.rgb * blurSample.a * MAX_HDR_OVERBRIGHT, 1.0f ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
} \ No newline at end of file
diff --git a/mp/src/materialsystem/stdshaders/SDK_bloomadd_ps11.fxc b/mp/src/materialsystem/stdshaders/SDK_bloomadd_ps11.fxc
index 2f573009..745c92f1 100644
--- a/mp/src/materialsystem/stdshaders/SDK_bloomadd_ps11.fxc
+++ b/mp/src/materialsystem/stdshaders/SDK_bloomadd_ps11.fxc
@@ -1,18 +1,18 @@
-//======= Copyright � 1996-2006, Valve Corporation, All rights reserved. ======
-#define CONVERT_TO_SRGB 0
-
-#include "common_ps_fxc.h"
-
-sampler TexSampler : register( s0 );
-
-struct PS_INPUT
-{
- HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate
-};
-
-float4 main( PS_INPUT i ) : COLOR
-{
- float4 result = tex2D( TexSampler, i.baseTexCoord );
- result.a = 1.0f;
- return result; //FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
-}
+//======= Copyright � 1996-2006, Valve Corporation, All rights reserved. ======
+#define CONVERT_TO_SRGB 0
+
+#include "common_ps_fxc.h"
+
+sampler TexSampler : register( s0 );
+
+struct PS_INPUT
+{
+ HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate
+};
+
+float4 main( PS_INPUT i ) : COLOR
+{
+ float4 result = tex2D( TexSampler, i.baseTexCoord );
+ result.a = 1.0f;
+ return result; //FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
+}
diff --git a/mp/src/materialsystem/stdshaders/SDK_bloomadd_ps2x.fxc b/mp/src/materialsystem/stdshaders/SDK_bloomadd_ps2x.fxc
index 9faf9ecd..aa434b4e 100644
--- a/mp/src/materialsystem/stdshaders/SDK_bloomadd_ps2x.fxc
+++ b/mp/src/materialsystem/stdshaders/SDK_bloomadd_ps2x.fxc
@@ -1,23 +1,23 @@
-//======= Copyright � 1996-2006, Valve Corporation, All rights reserved. ======
-#define CONVERT_TO_SRGB 0
-
-#include "common_ps_fxc.h"
-
-sampler TexSampler : register( s0 );
-
-struct PS_INPUT
-{
- HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate
-
-#if defined( _X360 ) //matching pixel shader inputs to vertex shader outputs to avoid shader patches
- float2 ZeroTexCoord : TEXCOORD1;
- float2 bloomTexCoord : TEXCOORD2;
-#endif
-};
-
-float4 main( PS_INPUT i ) : COLOR
-{
- float4 result = tex2D( TexSampler, i.baseTexCoord );
- result.a = 1.0f;
- return result; //FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
-}
+//======= Copyright � 1996-2006, Valve Corporation, All rights reserved. ======
+#define CONVERT_TO_SRGB 0
+
+#include "common_ps_fxc.h"
+
+sampler TexSampler : register( s0 );
+
+struct PS_INPUT
+{
+ HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate
+
+#if defined( _X360 ) //matching pixel shader inputs to vertex shader outputs to avoid shader patches
+ float2 ZeroTexCoord : TEXCOORD1;
+ float2 bloomTexCoord : TEXCOORD2;
+#endif
+};
+
+float4 main( PS_INPUT i ) : COLOR
+{
+ float4 result = tex2D( TexSampler, i.baseTexCoord );
+ result.a = 1.0f;
+ return result; //FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
+}
diff --git a/mp/src/materialsystem/stdshaders/SDK_screenspaceeffect_vs20.fxc b/mp/src/materialsystem/stdshaders/SDK_screenspaceeffect_vs20.fxc
index eec88ba2..96cb8990 100644
--- a/mp/src/materialsystem/stdshaders/SDK_screenspaceeffect_vs20.fxc
+++ b/mp/src/materialsystem/stdshaders/SDK_screenspaceeffect_vs20.fxc
@@ -1,47 +1,47 @@
-//========= Copyright � 1996-2006, Valve Corporation, All rights reserved. ============//
-
-// STATIC: "X360APPCHOOSER" "0..1" [= 0]
-
-#include "common_vs_fxc.h"
-
-struct VS_INPUT
-{
- float3 vPos : POSITION;
- float2 vBaseTexCoord : TEXCOORD0;
-
- #if X360APPCHOOSER
- float4 vColor : COLOR0;
- #endif
-};
-
-struct VS_OUTPUT
-{
- float4 projPos : POSITION;
- float2 baseTexCoord : TEXCOORD0;
- float2 ZeroTexCoord : TEXCOORD1;
- float2 bloomTexCoord : TEXCOORD2;
-
- #if X360APPCHOOSER
- float4 vColor : TEXCOORD3;
- #endif
-};
-
-float4 Texel_Sizes : register (SHADER_SPECIFIC_CONST_0);
-
-VS_OUTPUT main( const VS_INPUT v )
-{
- VS_OUTPUT o = ( VS_OUTPUT )0;
-
- o.projPos = float4( v.vPos, 1.0f );
- o.baseTexCoord = v.vBaseTexCoord;
- o.ZeroTexCoord=float2(0,0);
- o.bloomTexCoord.x=v.vBaseTexCoord.x+Texel_Sizes.z;
- o.bloomTexCoord.y=v.vBaseTexCoord.y+Texel_Sizes.w;
-
- #if X360APPCHOOSER
- o.vColor.rgba = v.vColor.rgba;
- o.projPos.xyzw = mul( float4( v.vPos.xyz, 1.0f ), cModelViewProj );
- #endif
-
- return o;
-}
+//========= Copyright � 1996-2006, Valve Corporation, All rights reserved. ============//
+
+// STATIC: "X360APPCHOOSER" "0..1" [= 0]
+
+#include "common_vs_fxc.h"
+
+struct VS_INPUT
+{
+ float3 vPos : POSITION;
+ float2 vBaseTexCoord : TEXCOORD0;
+
+ #if X360APPCHOOSER
+ float4 vColor : COLOR0;
+ #endif
+};
+
+struct VS_OUTPUT
+{
+ float4 projPos : POSITION;
+ float2 baseTexCoord : TEXCOORD0;
+ float2 ZeroTexCoord : TEXCOORD1;
+ float2 bloomTexCoord : TEXCOORD2;
+
+ #if X360APPCHOOSER
+ float4 vColor : TEXCOORD3;
+ #endif
+};
+
+float4 Texel_Sizes : register (SHADER_SPECIFIC_CONST_0);
+
+VS_OUTPUT main( const VS_INPUT v )
+{
+ VS_OUTPUT o = ( VS_OUTPUT )0;
+
+ o.projPos = float4( v.vPos, 1.0f );
+ o.baseTexCoord = v.vBaseTexCoord;
+ o.ZeroTexCoord=float2(0,0);
+ o.bloomTexCoord.x=v.vBaseTexCoord.x+Texel_Sizes.z;
+ o.bloomTexCoord.y=v.vBaseTexCoord.y+Texel_Sizes.w;
+
+ #if X360APPCHOOSER
+ o.vColor.rgba = v.vColor.rgba;
+ o.projPos.xyzw = mul( float4( v.vPos.xyz, 1.0f ), cModelViewProj );
+ #endif
+
+ return o;
+}
diff --git a/mp/src/materialsystem/stdshaders/buildhl2mpshaders.bat b/mp/src/materialsystem/stdshaders/buildhl2mpshaders.bat
index 58b0cd26..902292d3 100644..100755
--- a/mp/src/materialsystem/stdshaders/buildhl2mpshaders.bat
+++ b/mp/src/materialsystem/stdshaders/buildhl2mpshaders.bat
@@ -1,21 +1,21 @@
-@echo off
-setlocal
-
-rem ================================
-rem ==== MOD PATH CONFIGURATIONS ===
-
-rem == Set the absolute path to your mod's game directory here ==
-set GAMEDIR=%cd%\..\..\..\game\mod_hl2mp
-
-rem == Set the relative or absolute path to Source SDK Base 2013 Singleplayer\bin ==
-set SDKBINDIR=C:\SteamBetaLibrary\SteamApps\common\Source SDK Base 2013 Singleplayer\bin
-
-rem == Set the Path to your mod's root source code ==
-rem This should already be correct, accepts relative paths only!
-set SOURCEDIR=..\..
-
-rem ==== MOD PATH CONFIGURATIONS END ===
-rem ====================================
-
-
-call buildsdkshaders.bat
+@echo off
+setlocal
+
+rem ================================
+rem ==== MOD PATH CONFIGURATIONS ===
+
+rem == Set the absolute path to your mod's game directory here ==
+set GAMEDIR=%cd%\..\..\..\game\mod_hl2mp
+
+rem == Set the relative or absolute path to Source SDK Base 2013 Singleplayer\bin ==
+set SDKBINDIR=C:\SteamBetaLibrary\SteamApps\common\Source SDK Base 2013 Singleplayer\bin
+
+rem == Set the Path to your mod's root source code ==
+rem This should already be correct, accepts relative paths only!
+set SOURCEDIR=..\..
+
+rem ==== MOD PATH CONFIGURATIONS END ===
+rem ====================================
+
+
+call buildsdkshaders.bat
diff --git a/mp/src/materialsystem/stdshaders/buildsdkshaders.bat b/mp/src/materialsystem/stdshaders/buildsdkshaders.bat
index eeaa5b8c..22624938 100644..100755
--- a/mp/src/materialsystem/stdshaders/buildsdkshaders.bat
+++ b/mp/src/materialsystem/stdshaders/buildsdkshaders.bat
@@ -1,40 +1,40 @@
-@echo off
-setlocal
-
-rem Use dynamic shaders to build .inc files only
-rem set dynamic_shaders=1
-rem == Setup path to nmake.exe, from vc 2005 common tools directory ==
-call "%VS100COMNTOOLS%vsvars32.bat"
-
-
-set TTEXE=..\..\devtools\bin\timeprecise.exe
-if not exist %TTEXE% goto no_ttexe
-goto no_ttexe_end
-
-:no_ttexe
-set TTEXE=time /t
-:no_ttexe_end
-
-
-rem echo.
-rem echo ~~~~~~ buildsdkshaders %* ~~~~~~
-%TTEXE% -cur-Q
-set tt_all_start=%ERRORLEVEL%
-set tt_all_chkpt=%tt_start%
-
-set BUILD_SHADER=call buildshaders.bat
-set ARG_EXTRA=
-
-%BUILD_SHADER% stdshader_dx9_20b -game %GAMEDIR% -source %SOURCEDIR%
-%BUILD_SHADER% stdshader_dx9_30 -game %GAMEDIR% -source %SOURCEDIR% -dx9_30 -force30
-
-
-rem echo.
-if not "%dynamic_shaders%" == "1" (
- rem echo Finished full buildallshaders %*
-) else (
- rem echo Finished dynamic buildallshaders %*
-)
-
-rem %TTEXE% -diff %tt_all_start% -cur
-rem echo.
+@echo off
+setlocal
+
+rem Use dynamic shaders to build .inc files only
+rem set dynamic_shaders=1
+rem == Setup path to nmake.exe, from vc 2005 common tools directory ==
+call "%VS100COMNTOOLS%vsvars32.bat"
+
+
+set TTEXE=..\..\devtools\bin\timeprecise.exe
+if not exist %TTEXE% goto no_ttexe
+goto no_ttexe_end
+
+:no_ttexe
+set TTEXE=time /t
+:no_ttexe_end
+
+
+rem echo.
+rem echo ~~~~~~ buildsdkshaders %* ~~~~~~
+%TTEXE% -cur-Q
+set tt_all_start=%ERRORLEVEL%
+set tt_all_chkpt=%tt_start%
+
+set BUILD_SHADER=call buildshaders.bat
+set ARG_EXTRA=
+
+%BUILD_SHADER% stdshader_dx9_20b -game %GAMEDIR% -source %SOURCEDIR%
+%BUILD_SHADER% stdshader_dx9_30 -game %GAMEDIR% -source %SOURCEDIR% -dx9_30 -force30
+
+
+rem echo.
+if not "%dynamic_shaders%" == "1" (
+ rem echo Finished full buildallshaders %*
+) else (
+ rem echo Finished dynamic buildallshaders %*
+)
+
+rem %TTEXE% -diff %tt_all_start% -cur
+rem echo.
diff --git a/mp/src/materialsystem/stdshaders/buildshaders.bat b/mp/src/materialsystem/stdshaders/buildshaders.bat
index 64859912..ad9b1852 100644..100755
--- a/mp/src/materialsystem/stdshaders/buildshaders.bat
+++ b/mp/src/materialsystem/stdshaders/buildshaders.bat
@@ -1,209 +1,209 @@
-@echo off
-
-set TTEXE=..\..\devtools\bin\timeprecise.exe
-if not exist %TTEXE% goto no_ttexe
-goto no_ttexe_end
-
-:no_ttexe
-set TTEXE=time /t
-:no_ttexe_end
-
-echo.
-echo ==================== buildshaders %* ==================
-%TTEXE% -cur-Q
-set tt_start=%ERRORLEVEL%
-set tt_chkpt=%tt_start%
-
-
-REM ****************
-REM usage: buildshaders <shaderProjectName>
-REM ****************
-
-setlocal
-set arg_filename=%1
-set shadercompilecommand=shadercompile.exe
-set targetdir=shaders
-set SrcDirBase=..\..
-set shaderDir=shaders
-set SDKArgs=
-set SHADERINCPATH=vshtmp9/... fxctmp9/...
-
-
-if "%1" == "" goto usage
-set inputbase=%1
-
-set DIRECTX_SDK_VER=pc09.00
-set DIRECTX_SDK_BIN_DIR=dx9sdk\utilities
-
-if /i "%6" == "-dx9_30" goto dx_sdk_dx9_30
-goto dx_sdk_end
-:dx_sdk_dx9_30
- set DIRECTX_SDK_VER=pc09.30
- set DIRECTX_SDK_BIN_DIR=dx10sdk\utilities\dx9_30
- goto dx_sdk_end
-:dx_sdk_end
-
-if /i "%7" == "-force30" goto set_force30_arg
-goto set_force_end
-:set_force30_arg
- set DIRECTX_FORCE_MODEL=30
- goto set_force_end
-:set_force_end
-
-if /i "%2" == "-game" goto set_mod_args
-goto build_shaders
-
-REM ****************
-REM USAGE
-REM ****************
-:usage
-echo.
-echo "usage: buildshaders <shaderProjectName> [-game] [gameDir if -game was specified] [-source sourceDir]"
-echo " gameDir is where gameinfo.txt is (where it will store the compiled shaders)."
-echo " sourceDir is where the source code is (where it will find scripts and compilers)."
-echo "ex : buildshaders myshaders"
-echo "ex : buildshaders myshaders -game c:\steam\steamapps\sourcemods\mymod -source c:\mymod\src"
-goto :end
-
-REM ****************
-REM MOD ARGS - look for -game or the vproject environment variable
-REM ****************
-:set_mod_args
-
-if not exist "%SDKBINDIR%\shadercompile.exe" goto NoShaderCompile
-set ChangeToDir=%SDKBINDIR%
-
-if /i "%4" NEQ "-source" goto NoSourceDirSpecified
-set SrcDirBase=%~5
-
-REM ** use the -game parameter to tell us where to put the files
-set targetdir=%~3\shaders
-set SDKArgs=-nompi -nop4 -game "%~3"
-
-if not exist "%~3\gameinfo.txt" goto InvalidGameDirectory
-goto build_shaders
-
-REM ****************
-REM ERRORS
-REM ****************
-:InvalidGameDirectory
-echo -
-echo Error: "%~3" is not a valid game directory.
-echo (The -game directory must have a gameinfo.txt file)
-echo -
-goto end
-
-:NoSourceDirSpecified
-echo ERROR: If you specify -game on the command line, you must specify -source.
-goto usage
-goto end
-
-:NoShaderCompile
-echo -
-echo - ERROR: shadercompile.exe doesn't exist in %SDKBINDIR%
-echo -
-goto end
-
-REM ****************
-REM BUILD SHADERS
-REM ****************
-:build_shaders
-
-rem echo --------------------------------
-rem echo %inputbase%
-rem echo --------------------------------
-REM make sure that target dirs exist
-REM files will be built in these targets and copied to their final destination
-if not exist %shaderDir% mkdir %shaderDir%
-if not exist %shaderDir%\fxc mkdir %shaderDir%\fxc
-if not exist %shaderDir%\vsh mkdir %shaderDir%\vsh
-if not exist %shaderDir%\psh mkdir %shaderDir%\psh
-REM Nuke some files that we will add to later.
-if exist filelist.txt del /f /q filelist.txt
-if exist filestocopy.txt del /f /q filestocopy.txt
-if exist filelistgen.txt del /f /q filelistgen.txt
-if exist inclist.txt del /f /q inclist.txt
-if exist vcslist.txt del /f /q vcslist.txt
-
-REM ****************
-REM Generate a makefile for the shader project
-REM ****************
-perl "%SrcDirBase%\devtools\bin\updateshaders.pl" -source "%SrcDirBase%" %inputbase%
-
-
-REM ****************
-REM Run the makefile, generating minimal work/build list for fxc files, go ahead and compile vsh and psh files.
-REM ****************
-rem nmake /S /C -f makefile.%inputbase% clean > clean.txt 2>&1
-echo Building inc files, asm vcs files, and VMPI worklist for %inputbase%...
-nmake /S /C -f makefile.%inputbase%
-
-REM ****************
-REM Copy the inc files to their target
-REM ****************
-if exist "inclist.txt" (
- echo Publishing shader inc files to target...
- perl %SrcDirBase%\devtools\bin\copyshaderincfiles.pl inclist.txt
-)
-
-REM ****************
-REM Add the executables to the worklist.
-REM ****************
-if /i "%DIRECTX_SDK_VER%" == "pc09.00" (
- rem echo "Copy extra files for dx 9 std
-)
-if /i "%DIRECTX_SDK_VER%" == "pc09.30" (
- echo %SrcDirBase%\devtools\bin\d3dx9_33.dll >> filestocopy.txt
-)
-
-echo %SrcDirBase%\%DIRECTX_SDK_BIN_DIR%\dx_proxy.dll >> filestocopy.txt
-
-echo %SDKBINDIR%\shadercompile.exe >> filestocopy.txt
-echo %SDKBINDIR%\shadercompile_dll.dll >> filestocopy.txt
-echo %SDKBINDIR%\vstdlib.dll >> filestocopy.txt
-echo %SDKBINDIR%\tier0.dll >> filestocopy.txt
-
-REM ****************
-REM Cull duplicate entries in work/build list
-REM ****************
-if exist filestocopy.txt type filestocopy.txt | perl "%SrcDirBase%\devtools\bin\uniqifylist.pl" > uniquefilestocopy.txt
-if exist filelistgen.txt if not "%dynamic_shaders%" == "1" (
- echo Generating action list...
- copy filelistgen.txt filelist.txt >nul
-)
-
-REM ****************
-REM Execute distributed process on work/build list
-REM ****************
-
-set shader_path_cd=%cd%
-if exist "filelist.txt" if exist "uniquefilestocopy.txt" if not "%dynamic_shaders%" == "1" (
- echo Running distributed shader compilation...
-
- cd /D %ChangeToDir%
- echo %shadercompilecommand% %SDKArgs% -shaderpath "%shader_path_cd:/=\%" -allowdebug
- %shadercompilecommand% %SDKArgs% -shaderpath "%shader_path_cd:/=\%" -allowdebug
- cd /D %shader_path_cd%
-)
-
-REM ****************
-REM PC Shader copy
-REM Publish the generated files to the output dir using XCOPY
-REM This batch file may have been invoked standalone or slaved (master does final smart mirror copy)
-REM ****************
-:DoXCopy
-if not "%dynamic_shaders%" == "1" (
-if not exist "%targetdir%" md "%targetdir%"
-if not "%targetdir%"=="%shaderDir%" xcopy %shaderDir%\*.* "%targetdir%" /e /y
-)
-goto end
-
-REM ****************
-REM END
-REM ****************
-:end
-
-
-%TTEXE% -diff %tt_start%
-echo.
-
+@echo off
+
+set TTEXE=..\..\devtools\bin\timeprecise.exe
+if not exist %TTEXE% goto no_ttexe
+goto no_ttexe_end
+
+:no_ttexe
+set TTEXE=time /t
+:no_ttexe_end
+
+echo.
+echo ==================== buildshaders %* ==================
+%TTEXE% -cur-Q
+set tt_start=%ERRORLEVEL%
+set tt_chkpt=%tt_start%
+
+
+REM ****************
+REM usage: buildshaders <shaderProjectName>
+REM ****************
+
+setlocal
+set arg_filename=%1
+set shadercompilecommand=shadercompile.exe
+set targetdir=shaders
+set SrcDirBase=..\..
+set shaderDir=shaders
+set SDKArgs=
+set SHADERINCPATH=vshtmp9/... fxctmp9/...
+
+
+if "%1" == "" goto usage
+set inputbase=%1
+
+set DIRECTX_SDK_VER=pc09.00
+set DIRECTX_SDK_BIN_DIR=dx9sdk\utilities
+
+if /i "%6" == "-dx9_30" goto dx_sdk_dx9_30
+goto dx_sdk_end
+:dx_sdk_dx9_30
+ set DIRECTX_SDK_VER=pc09.30
+ set DIRECTX_SDK_BIN_DIR=dx10sdk\utilities\dx9_30
+ goto dx_sdk_end
+:dx_sdk_end
+
+if /i "%7" == "-force30" goto set_force30_arg
+goto set_force_end
+:set_force30_arg
+ set DIRECTX_FORCE_MODEL=30
+ goto set_force_end
+:set_force_end
+
+if /i "%2" == "-game" goto set_mod_args
+goto build_shaders
+
+REM ****************
+REM USAGE
+REM ****************
+:usage
+echo.
+echo "usage: buildshaders <shaderProjectName> [-game] [gameDir if -game was specified] [-source sourceDir]"
+echo " gameDir is where gameinfo.txt is (where it will store the compiled shaders)."
+echo " sourceDir is where the source code is (where it will find scripts and compilers)."
+echo "ex : buildshaders myshaders"
+echo "ex : buildshaders myshaders -game c:\steam\steamapps\sourcemods\mymod -source c:\mymod\src"
+goto :end
+
+REM ****************
+REM MOD ARGS - look for -game or the vproject environment variable
+REM ****************
+:set_mod_args
+
+if not exist "%SDKBINDIR%\shadercompile.exe" goto NoShaderCompile
+set ChangeToDir=%SDKBINDIR%
+
+if /i "%4" NEQ "-source" goto NoSourceDirSpecified
+set SrcDirBase=%~5
+
+REM ** use the -game parameter to tell us where to put the files
+set targetdir=%~3\shaders
+set SDKArgs=-nompi -nop4 -game "%~3"
+
+if not exist "%~3\gameinfo.txt" goto InvalidGameDirectory
+goto build_shaders
+
+REM ****************
+REM ERRORS
+REM ****************
+:InvalidGameDirectory
+echo -
+echo Error: "%~3" is not a valid game directory.
+echo (The -game directory must have a gameinfo.txt file)
+echo -
+goto end
+
+:NoSourceDirSpecified
+echo ERROR: If you specify -game on the command line, you must specify -source.
+goto usage
+goto end
+
+:NoShaderCompile
+echo -
+echo - ERROR: shadercompile.exe doesn't exist in %SDKBINDIR%
+echo -
+goto end
+
+REM ****************
+REM BUILD SHADERS
+REM ****************
+:build_shaders
+
+rem echo --------------------------------
+rem echo %inputbase%
+rem echo --------------------------------
+REM make sure that target dirs exist
+REM files will be built in these targets and copied to their final destination
+if not exist %shaderDir% mkdir %shaderDir%
+if not exist %shaderDir%\fxc mkdir %shaderDir%\fxc
+if not exist %shaderDir%\vsh mkdir %shaderDir%\vsh
+if not exist %shaderDir%\psh mkdir %shaderDir%\psh
+REM Nuke some files that we will add to later.
+if exist filelist.txt del /f /q filelist.txt
+if exist filestocopy.txt del /f /q filestocopy.txt
+if exist filelistgen.txt del /f /q filelistgen.txt
+if exist inclist.txt del /f /q inclist.txt
+if exist vcslist.txt del /f /q vcslist.txt
+
+REM ****************
+REM Generate a makefile for the shader project
+REM ****************
+perl "%SrcDirBase%\devtools\bin\updateshaders.pl" -source "%SrcDirBase%" %inputbase%
+
+
+REM ****************
+REM Run the makefile, generating minimal work/build list for fxc files, go ahead and compile vsh and psh files.
+REM ****************
+rem nmake /S /C -f makefile.%inputbase% clean > clean.txt 2>&1
+echo Building inc files, asm vcs files, and VMPI worklist for %inputbase%...
+nmake /S /C -f makefile.%inputbase%
+
+REM ****************
+REM Copy the inc files to their target
+REM ****************
+if exist "inclist.txt" (
+ echo Publishing shader inc files to target...
+ perl %SrcDirBase%\devtools\bin\copyshaderincfiles.pl inclist.txt
+)
+
+REM ****************
+REM Add the executables to the worklist.
+REM ****************
+if /i "%DIRECTX_SDK_VER%" == "pc09.00" (
+ rem echo "Copy extra files for dx 9 std
+)
+if /i "%DIRECTX_SDK_VER%" == "pc09.30" (
+ echo %SrcDirBase%\devtools\bin\d3dx9_33.dll >> filestocopy.txt
+)
+
+echo %SrcDirBase%\%DIRECTX_SDK_BIN_DIR%\dx_proxy.dll >> filestocopy.txt
+
+echo %SDKBINDIR%\shadercompile.exe >> filestocopy.txt
+echo %SDKBINDIR%\shadercompile_dll.dll >> filestocopy.txt
+echo %SDKBINDIR%\vstdlib.dll >> filestocopy.txt
+echo %SDKBINDIR%\tier0.dll >> filestocopy.txt
+
+REM ****************
+REM Cull duplicate entries in work/build list
+REM ****************
+if exist filestocopy.txt type filestocopy.txt | perl "%SrcDirBase%\devtools\bin\uniqifylist.pl" > uniquefilestocopy.txt
+if exist filelistgen.txt if not "%dynamic_shaders%" == "1" (
+ echo Generating action list...
+ copy filelistgen.txt filelist.txt >nul
+)
+
+REM ****************
+REM Execute distributed process on work/build list
+REM ****************
+
+set shader_path_cd=%cd%
+if exist "filelist.txt" if exist "uniquefilestocopy.txt" if not "%dynamic_shaders%" == "1" (
+ echo Running distributed shader compilation...
+
+ cd /D %ChangeToDir%
+ echo %shadercompilecommand% %SDKArgs% -shaderpath "%shader_path_cd:/=\%" -allowdebug
+ %shadercompilecommand% %SDKArgs% -shaderpath "%shader_path_cd:/=\%" -allowdebug
+ cd /D %shader_path_cd%
+)
+
+REM ****************
+REM PC Shader copy
+REM Publish the generated files to the output dir using XCOPY
+REM This batch file may have been invoked standalone or slaved (master does final smart mirror copy)
+REM ****************
+:DoXCopy
+if not "%dynamic_shaders%" == "1" (
+if not exist "%targetdir%" md "%targetdir%"
+if not "%targetdir%"=="%shaderDir%" xcopy %shaderDir%\*.* "%targetdir%" /e /y
+)
+goto end
+
+REM ****************
+REM END
+REM ****************
+:end
+
+
+%TTEXE% -diff %tt_start%
+echo.
+
diff --git a/mp/src/materialsystem/stdshaders/clean.bat b/mp/src/materialsystem/stdshaders/clean.bat
index eec63804..efcc57db 100644..100755
--- a/mp/src/materialsystem/stdshaders/clean.bat
+++ b/mp/src/materialsystem/stdshaders/clean.bat
@@ -1,33 +1,33 @@
-@echo off
-setlocal
-
-if /i "%1" == "-game" goto CleanGameDir
-
-rem Clean out hl2
-if exist ..\..\..\game\hl2\shaders rd /s /q ..\..\..\game\hl2\shaders
-goto CleanOtherStuff
-
-:CleanGameDir
-set __GameDir=%~2
-if not exist "%__GameDir%\gameinfo.txt" goto MissingGameInfo
-if exist "%__GameDir%\shaders" rd /s /q "%2\shaders"
-goto CleanOtherStuff
-
-:CleanOtherStuff
-if exist debug_dx9 rd /s /q debug_dx9
-
-if exist fxctmp9 rd /s /q fxctmp9
-if exist vshtmp9 rd /s /q vshtmp9
-if exist pshtmp9 rd /s /q pshtmp9
-if exist fxctmp9_tmp rd /s /q fxctmp9_tmp
-if exist vshtmp9_tmp rd /s /q vshtmp9_tmp
-if exist pshtmp9_tmp rd /s /q pshtmp9_tmp
-if exist shaders rd /s /q shaders
-goto end
-
-:MissingGameInfo
-echo Invalid -game parameter specified (no "%__GameDir%\gameinfo.txt" exists).
-goto end
-
-
+@echo off
+setlocal
+
+if /i "%1" == "-game" goto CleanGameDir
+
+rem Clean out hl2
+if exist ..\..\..\game\hl2\shaders rd /s /q ..\..\..\game\hl2\shaders
+goto CleanOtherStuff
+
+:CleanGameDir
+set __GameDir=%~2
+if not exist "%__GameDir%\gameinfo.txt" goto MissingGameInfo
+if exist "%__GameDir%\shaders" rd /s /q "%2\shaders"
+goto CleanOtherStuff
+
+:CleanOtherStuff
+if exist debug_dx9 rd /s /q debug_dx9
+
+if exist fxctmp9 rd /s /q fxctmp9
+if exist vshtmp9 rd /s /q vshtmp9
+if exist pshtmp9 rd /s /q pshtmp9
+if exist fxctmp9_tmp rd /s /q fxctmp9_tmp
+if exist vshtmp9_tmp rd /s /q vshtmp9_tmp
+if exist pshtmp9_tmp rd /s /q pshtmp9_tmp
+if exist shaders rd /s /q shaders
+goto end
+
+:MissingGameInfo
+echo Invalid -game parameter specified (no "%__GameDir%\gameinfo.txt" exists).
+goto end
+
+
:end \ No newline at end of file
diff --git a/mp/src/materialsystem/stdshaders/cleantemps.bat b/mp/src/materialsystem/stdshaders/cleantemps.bat
index 51478ee4..7055aaf3 100644..100755
--- a/mp/src/materialsystem/stdshaders/cleantemps.bat
+++ b/mp/src/materialsystem/stdshaders/cleantemps.bat
@@ -1,12 +1,12 @@
-@echo off
-setlocal
-
-if exist fxctmp9_tmp rd /s /q fxctmp9_tmp
-if exist vshtmp9_tmp rd /s /q vshtmp9_tmp
-if exist pshtmp9_tmp rd /s /q pshtmp9_tmp
-
-if exist fxctmp9_360_tmp rd /s /q fxctmp9_360_tmp
-if exist vshtmp9_360_tmp rd /s /q vshtmp9_360_tmp
-if exist pshtmp9_360_tmp rd /s /q pshtmp9_360_tmp
-
-if exist shaders rd /s /q shaders
+@echo off
+setlocal
+
+if exist fxctmp9_tmp rd /s /q fxctmp9_tmp
+if exist vshtmp9_tmp rd /s /q vshtmp9_tmp
+if exist pshtmp9_tmp rd /s /q pshtmp9_tmp
+
+if exist fxctmp9_360_tmp rd /s /q fxctmp9_360_tmp
+if exist vshtmp9_360_tmp rd /s /q vshtmp9_360_tmp
+if exist pshtmp9_360_tmp rd /s /q pshtmp9_360_tmp
+
+if exist shaders rd /s /q shaders
diff --git a/mp/src/materialsystem/stdshaders/example_model_ps20b.fxc b/mp/src/materialsystem/stdshaders/example_model_ps20b.fxc
index a7b35e44..29ed629a 100644
--- a/mp/src/materialsystem/stdshaders/example_model_ps20b.fxc
+++ b/mp/src/materialsystem/stdshaders/example_model_ps20b.fxc
@@ -1,92 +1,92 @@
-//===================== Copyright (c) Valve Corporation. All Rights Reserved. ======================
-//
-// Example pixel shader that can be applied to models
-//
-//==================================================================================================
-
-// STATIC: "CONVERT_TO_SRGB" "0..0"
-// STATIC: "FLASHLIGHT" "0..1"
-// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b]
-
-// DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1"
-// DYNAMIC: "PIXELFOGTYPE" "0..1"
-// DYNAMIC: "NUM_LIGHTS" "0..4"
-// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b]
-// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b]
-
-// SKIP: ($PIXELFOGTYPE == 0) && ($WRITEWATERFOGTODESTALPHA != 0)
-
-// We don't care about flashlight depth unless the flashlight is on
-// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 )
-
-// Flashlight shadow filter mode is irrelevant if there is no flashlight
-// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps20b]
-
-#include "common_flashlight_fxc.h"
-#include "shader_constant_register_map.h"
-
-const float4 g_DiffuseModulation : register( PSREG_DIFFUSE_MODULATION );
-const float4 g_ShadowTweaks : register( PSREG_ENVMAP_TINT__SHADOW_TWEAKS );
-const float3 cAmbientCube[6] : register( PSREG_AMBIENT_CUBE );
-const float4 g_EyePos : register( PSREG_EYEPOS_SPEC_EXPONENT );
-const float4 g_FogParams : register( PSREG_FOG_PARAMS );
-const float4 g_FlashlightAttenuationFactors : register( PSREG_FLASHLIGHT_ATTENUATION ); // On non-flashlight pass
-const float4 g_FlashlightPos_RimBoost : register( PSREG_FLASHLIGHT_POSITION_RIM_BOOST );
-const float4x4 g_FlashlightWorldToTexture : register( PSREG_FLASHLIGHT_TO_WORLD_TEXTURE );
-PixelShaderLightInfo cLightInfo[3] : register( PSREG_LIGHT_INFO_ARRAY ); // 2 registers each - 6 registers total (4th light spread across w's)
-
-#define g_FlashlightPos g_FlashlightPos_RimBoost.xyz
-
-sampler BaseTextureSampler : register( s0 ); // Base map, selfillum in alpha
-sampler ShadowDepthSampler : register( s4 ); // Flashlight shadow depth map sampler
-sampler NormalizeRandRotSampler : register( s5 ); // Normalization / RandomRotation samplers
-sampler FlashlightSampler : register( s6 ); // Flashlight cookie
-
-struct PS_INPUT
-{
- float2 baseTexCoord : TEXCOORD0;
- float4 lightAtten : TEXCOORD1;
- float3 worldNormal : TEXCOORD2;
- float3 worldPos : TEXCOORD3;
- float3 projPos : TEXCOORD4;
-};
-
-float4 main( PS_INPUT i ) : COLOR
-{
- float4 baseColor = tex2D( BaseTextureSampler, i.baseTexCoord );
-
- float3 diffuseLighting;
- if ( FLASHLIGHT != 0 )
- {
- float4 flashlightSpacePosition = mul( float4( i.worldPos, 1.0f ), g_FlashlightWorldToTexture );
-
- diffuseLighting = DoFlashlight( g_FlashlightPos, i.worldPos, flashlightSpacePosition,
- i.worldNormal, g_FlashlightAttenuationFactors.xyz,
- g_FlashlightAttenuationFactors.w, FlashlightSampler, ShadowDepthSampler,
- NormalizeRandRotSampler, FLASHLIGHTDEPTHFILTERMODE, FLASHLIGHTSHADOWS, true, i.projPos, false, g_ShadowTweaks );
- }
- else // non-flashlight path
- {
- // Summation of diffuse illumination from all local lights
- diffuseLighting = PixelShaderDoLighting( i.worldPos, i.worldNormal,
- float3( 0.0f, 0.0f, 0.0f ), false, true, i.lightAtten,
- cAmbientCube, NormalizeRandRotSampler, NUM_LIGHTS, cLightInfo, true,
-
- // These are dummy parameters:
- false, 1.0f,
- false, BaseTextureSampler );
- }
-
- float3 result = baseColor.rgb * g_DiffuseModulation.rgb * diffuseLighting;
- float alpha = g_DiffuseModulation.a * baseColor.a;
-
- float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.z, i.worldPos.z, i.projPos.z );
-
-#if WRITEWATERFOGTODESTALPHA && ( PIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT )
- alpha = fogFactor;
-#endif
-
- bool bWriteDepthToAlpha = ( WRITE_DEPTH_TO_DESTALPHA != 0 ) && ( WRITEWATERFOGTODESTALPHA == 0 );
-
- return FinalOutput( float4( result, alpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, bWriteDepthToAlpha, i.projPos.z );
-}
+//===================== Copyright (c) Valve Corporation. All Rights Reserved. ======================
+//
+// Example pixel shader that can be applied to models
+//
+//==================================================================================================
+
+// STATIC: "CONVERT_TO_SRGB" "0..0"
+// STATIC: "FLASHLIGHT" "0..1"
+// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b]
+
+// DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1"
+// DYNAMIC: "PIXELFOGTYPE" "0..1"
+// DYNAMIC: "NUM_LIGHTS" "0..4"
+// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b]
+// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b]
+
+// SKIP: ($PIXELFOGTYPE == 0) && ($WRITEWATERFOGTODESTALPHA != 0)
+
+// We don't care about flashlight depth unless the flashlight is on
+// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 )
+
+// Flashlight shadow filter mode is irrelevant if there is no flashlight
+// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps20b]
+
+#include "common_flashlight_fxc.h"
+#include "shader_constant_register_map.h"
+
+const float4 g_DiffuseModulation : register( PSREG_DIFFUSE_MODULATION );
+const float4 g_ShadowTweaks : register( PSREG_ENVMAP_TINT__SHADOW_TWEAKS );
+const float3 cAmbientCube[6] : register( PSREG_AMBIENT_CUBE );
+const float4 g_EyePos : register( PSREG_EYEPOS_SPEC_EXPONENT );
+const float4 g_FogParams : register( PSREG_FOG_PARAMS );
+const float4 g_FlashlightAttenuationFactors : register( PSREG_FLASHLIGHT_ATTENUATION ); // On non-flashlight pass
+const float4 g_FlashlightPos_RimBoost : register( PSREG_FLASHLIGHT_POSITION_RIM_BOOST );
+const float4x4 g_FlashlightWorldToTexture : register( PSREG_FLASHLIGHT_TO_WORLD_TEXTURE );
+PixelShaderLightInfo cLightInfo[3] : register( PSREG_LIGHT_INFO_ARRAY ); // 2 registers each - 6 registers total (4th light spread across w's)
+
+#define g_FlashlightPos g_FlashlightPos_RimBoost.xyz
+
+sampler BaseTextureSampler : register( s0 ); // Base map, selfillum in alpha
+sampler ShadowDepthSampler : register( s4 ); // Flashlight shadow depth map sampler
+sampler NormalizeRandRotSampler : register( s5 ); // Normalization / RandomRotation samplers
+sampler FlashlightSampler : register( s6 ); // Flashlight cookie
+
+struct PS_INPUT
+{
+ float2 baseTexCoord : TEXCOORD0;
+ float4 lightAtten : TEXCOORD1;
+ float3 worldNormal : TEXCOORD2;
+ float3 worldPos : TEXCOORD3;
+ float3 projPos : TEXCOORD4;
+};
+
+float4 main( PS_INPUT i ) : COLOR
+{
+ float4 baseColor = tex2D( BaseTextureSampler, i.baseTexCoord );
+
+ float3 diffuseLighting;
+ if ( FLASHLIGHT != 0 )
+ {
+ float4 flashlightSpacePosition = mul( float4( i.worldPos, 1.0f ), g_FlashlightWorldToTexture );
+
+ diffuseLighting = DoFlashlight( g_FlashlightPos, i.worldPos, flashlightSpacePosition,
+ i.worldNormal, g_FlashlightAttenuationFactors.xyz,
+ g_FlashlightAttenuationFactors.w, FlashlightSampler, ShadowDepthSampler,
+ NormalizeRandRotSampler, FLASHLIGHTDEPTHFILTERMODE, FLASHLIGHTSHADOWS, true, i.projPos, false, g_ShadowTweaks );
+ }
+ else // non-flashlight path
+ {
+ // Summation of diffuse illumination from all local lights
+ diffuseLighting = PixelShaderDoLighting( i.worldPos, i.worldNormal,
+ float3( 0.0f, 0.0f, 0.0f ), false, true, i.lightAtten,
+ cAmbientCube, NormalizeRandRotSampler, NUM_LIGHTS, cLightInfo, true,
+
+ // These are dummy parameters:
+ false, 1.0f,
+ false, BaseTextureSampler );
+ }
+
+ float3 result = baseColor.rgb * g_DiffuseModulation.rgb * diffuseLighting;
+ float alpha = g_DiffuseModulation.a * baseColor.a;
+
+ float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.z, i.worldPos.z, i.projPos.z );
+
+#if WRITEWATERFOGTODESTALPHA && ( PIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT )
+ alpha = fogFactor;
+#endif
+
+ bool bWriteDepthToAlpha = ( WRITE_DEPTH_TO_DESTALPHA != 0 ) && ( WRITEWATERFOGTODESTALPHA == 0 );
+
+ return FinalOutput( float4( result, alpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, bWriteDepthToAlpha, i.projPos.z );
+}
diff --git a/mp/src/materialsystem/stdshaders/example_model_vs20.fxc b/mp/src/materialsystem/stdshaders/example_model_vs20.fxc
index 877c84e2..6248f2b4 100644
--- a/mp/src/materialsystem/stdshaders/example_model_vs20.fxc
+++ b/mp/src/materialsystem/stdshaders/example_model_vs20.fxc
@@ -1,91 +1,91 @@
-//===================== Copyright (c) Valve Corporation. All Rights Reserved. ======================
-//
-// Example vertex shader that can be applied to models
-//
-//==================================================================================================
-
-// DYNAMIC: "COMPRESSED_VERTS" "0..1"
-// DYNAMIC: "DOWATERFOG" "0..1"
-// DYNAMIC: "SKINNING" "0..1"
-// DYNAMIC: "LIGHTING_PREVIEW" "0..1"
-// DYNAMIC: "NUM_LIGHTS" "0..4"
-
-#include "common_vs_fxc.h"
-
-static const bool g_bSkinning = SKINNING ? true : false;
-static const int g_FogType = DOWATERFOG;
-
-const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
-
-//-----------------------------------------------------------------------------
-// Input vertex format
-//-----------------------------------------------------------------------------
-struct VS_INPUT
-{
- // This is all of the stuff that we ever use.
- float4 vPos : POSITION;
- float4 vBoneWeights : BLENDWEIGHT;
- float4 vBoneIndices : BLENDINDICES;
- float4 vNormal : NORMAL;
- float2 vTexCoord0 : TEXCOORD0;
-};
-
-struct VS_OUTPUT
-{
- // Stuff that isn't seen by the pixel shader
- float4 projPosSetup : POSITION;
- float fog : FOG;
- // Stuff that is seen by the pixel shader
- float2 baseTexCoord : TEXCOORD0;
- float4 lightAtten : TEXCOORD1;
- float3 worldNormal : TEXCOORD2;
- float3 worldPos : TEXCOORD3;
- float3 projPos : TEXCOORD4;
-};
-
-//-----------------------------------------------------------------------------
-// Main shader entry point
-//-----------------------------------------------------------------------------
-VS_OUTPUT main( const VS_INPUT v )
-{
- VS_OUTPUT o = ( VS_OUTPUT )0;
-
- float3 vNormal;
- DecompressVertex_Normal( v.vNormal, vNormal );
-
- float3 worldNormal, worldPos;
- SkinPositionAndNormal( g_bSkinning, v.vPos, vNormal, v.vBoneWeights, v.vBoneIndices, worldPos, worldNormal );
-
- // Transform into projection space
- float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
- o.projPosSetup = vProjPos;
- vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ );
-
- o.projPos = vProjPos.xyz;
- o.fog = CalcFog( worldPos, vProjPos.xyz, g_FogType );
-
- // Needed for water fog alpha and diffuse lighting
- o.worldPos = worldPos;
- o.worldNormal = normalize( worldNormal );
-
- // Scalar attenuations for four lights
- o.lightAtten.xyz = float4(0,0,0,0);
- #if ( NUM_LIGHTS > 0 )
- o.lightAtten.x = GetVertexAttenForLight( worldPos, 0, false );
- #endif
- #if ( NUM_LIGHTS > 1 )
- o.lightAtten.y = GetVertexAttenForLight( worldPos, 1, false );
- #endif
- #if ( NUM_LIGHTS > 2 )
- o.lightAtten.z = GetVertexAttenForLight( worldPos, 2, false );
- #endif
- #if ( NUM_LIGHTS > 3 )
- o.lightAtten.w = GetVertexAttenForLight( worldPos, 3, false );
- #endif
-
- // Base texture coordinate transform
- o.baseTexCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] );
- o.baseTexCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] );
-
- return o;
-}
+//===================== Copyright (c) Valve Corporation. All Rights Reserved. ======================
+//
+// Example vertex shader that can be applied to models
+//
+//==================================================================================================
+
+// DYNAMIC: "COMPRESSED_VERTS" "0..1"
+// DYNAMIC: "DOWATERFOG" "0..1"
+// DYNAMIC: "SKINNING" "0..1"
+// DYNAMIC: "LIGHTING_PREVIEW" "0..1"
+// DYNAMIC: "NUM_LIGHTS" "0..4"
+
+#include "common_vs_fxc.h"
+
+static const bool g_bSkinning = SKINNING ? true : false;
+static const int g_FogType = DOWATERFOG;
+
+const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
+
+//-----------------------------------------------------------------------------
+// Input vertex format
+//-----------------------------------------------------------------------------
+struct VS_INPUT
+{
+ // This is all of the stuff that we ever use.
+ float4 vPos : POSITION;
+ float4 vBoneWeights : BLENDWEIGHT;
+ float4 vBoneIndices : BLENDINDICES;
+ float4 vNormal : NORMAL;
+ float2 vTexCoord0 : TEXCOORD0;
+};
+
+struct VS_OUTPUT
+{
+ // Stuff that isn't seen by the pixel shader
+ float4 projPosSetup : POSITION;
+ float fog : FOG;
+ // Stuff that is seen by the pixel shader
+ float2 baseTexCoord : TEXCOORD0;
+ float4 lightAtten : TEXCOORD1;
+ float3 worldNormal : TEXCOORD2;
+ float3 worldPos : TEXCOORD3;
+ float3 projPos : TEXCOORD4;
+};
+
+//-----------------------------------------------------------------------------
+// Main shader entry point
+//-----------------------------------------------------------------------------
+VS_OUTPUT main( const VS_INPUT v )
+{
+ VS_OUTPUT o = ( VS_OUTPUT )0;
+
+ float3 vNormal;
+ DecompressVertex_Normal( v.vNormal, vNormal );
+
+ float3 worldNormal, worldPos;
+ SkinPositionAndNormal( g_bSkinning, v.vPos, vNormal, v.vBoneWeights, v.vBoneIndices, worldPos, worldNormal );
+
+ // Transform into projection space
+ float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
+ o.projPosSetup = vProjPos;
+ vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ );
+
+ o.projPos = vProjPos.xyz;
+ o.fog = CalcFog( worldPos, vProjPos.xyz, g_FogType );
+
+ // Needed for water fog alpha and diffuse lighting
+ o.worldPos = worldPos;
+ o.worldNormal = normalize( worldNormal );
+
+ // Scalar attenuations for four lights
+ o.lightAtten.xyz = float4(0,0,0,0);
+ #if ( NUM_LIGHTS > 0 )
+ o.lightAtten.x = GetVertexAttenForLight( worldPos, 0, false );
+ #endif
+ #if ( NUM_LIGHTS > 1 )
+ o.lightAtten.y = GetVertexAttenForLight( worldPos, 1, false );
+ #endif
+ #if ( NUM_LIGHTS > 2 )
+ o.lightAtten.z = GetVertexAttenForLight( worldPos, 2, false );
+ #endif
+ #if ( NUM_LIGHTS > 3 )
+ o.lightAtten.w = GetVertexAttenForLight( worldPos, 3, false );
+ #endif
+
+ // Base texture coordinate transform
+ o.baseTexCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] );
+ o.baseTexCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] );
+
+ return o;
+}
diff --git a/mp/src/materialsystem/stdshaders/fxctmp9/SDK_Bloom_ps20.inc b/mp/src/materialsystem/stdshaders/fxctmp9/SDK_Bloom_ps20.inc
index 12871d11..afbca75f 100644
--- a/mp/src/materialsystem/stdshaders/fxctmp9/SDK_Bloom_ps20.inc
+++ b/mp/src/materialsystem/stdshaders/fxctmp9/SDK_Bloom_ps20.inc
@@ -1,33 +1,33 @@
-#include "shaderlib/cshader.h"
-class sdk_bloom_ps20_Static_Index
-{
-public:
- sdk_bloom_ps20_Static_Index( )
- {
- }
- int GetIndex()
- {
- // Asserts to make sure that we aren't using any skipped combinations.
- // Asserts to make sure that we are setting all of the combination vars.
-#ifdef _DEBUG
-#endif // _DEBUG
- return 0;
- }
-};
-#define shaderStaticTest_sdk_bloom_ps20 0
-class sdk_bloom_ps20_Dynamic_Index
-{
-public:
- sdk_bloom_ps20_Dynamic_Index()
- {
- }
- int GetIndex()
- {
- // Asserts to make sure that we aren't using any skipped combinations.
- // Asserts to make sure that we are setting all of the combination vars.
-#ifdef _DEBUG
-#endif // _DEBUG
- return 0;
- }
-};
-#define shaderDynamicTest_sdk_bloom_ps20 0
+#include "shaderlib/cshader.h"
+class sdk_bloom_ps20_Static_Index
+{
+public:
+ sdk_bloom_ps20_Static_Index( )
+ {
+ }
+ int GetIndex()
+ {
+ // Asserts to make sure that we aren't using any skipped combinations.
+ // Asserts to make sure that we are setting all of the combination vars.
+#ifdef _DEBUG
+#endif // _DEBUG
+ return 0;
+ }
+};
+#define shaderStaticTest_sdk_bloom_ps20 0
+class sdk_bloom_ps20_Dynamic_Index
+{
+public:
+ sdk_bloom_ps20_Dynamic_Index()
+ {
+ }
+ int GetIndex()
+ {
+ // Asserts to make sure that we aren't using any skipped combinations.
+ // Asserts to make sure that we are setting all of the combination vars.
+#ifdef _DEBUG
+#endif // _DEBUG
+ return 0;
+ }
+};
+#define shaderDynamicTest_sdk_bloom_ps20 0
diff --git a/mp/src/materialsystem/stdshaders/fxctmp9/SDK_Bloom_ps20b.inc b/mp/src/materialsystem/stdshaders/fxctmp9/SDK_Bloom_ps20b.inc
index 591af10a..169870ee 100644
--- a/mp/src/materialsystem/stdshaders/fxctmp9/SDK_Bloom_ps20b.inc
+++ b/mp/src/materialsystem/stdshaders/fxctmp9/SDK_Bloom_ps20b.inc
@@ -1,60 +1,60 @@
-#include "shaderlib/cshader.h"
-class sdk_bloom_ps20b_Static_Index
-{
-private:
- int m_nCONVERT_TO_SRGB;
-#ifdef _DEBUG
- bool m_bCONVERT_TO_SRGB;
-#endif
-public:
- void SetCONVERT_TO_SRGB( int i )
- {
- Assert( i >= 0 && i <= 1 );
- m_nCONVERT_TO_SRGB = i;
-#ifdef _DEBUG
- m_bCONVERT_TO_SRGB = true;
-#endif
- }
- void SetCONVERT_TO_SRGB( bool i )
- {
- m_nCONVERT_TO_SRGB = i ? 1 : 0;
-#ifdef _DEBUG
- m_bCONVERT_TO_SRGB = true;
-#endif
- }
-public:
- sdk_bloom_ps20b_Static_Index( )
- {
-#ifdef _DEBUG
- m_bCONVERT_TO_SRGB = true;
-#endif // _DEBUG
- m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion();
- }
- int GetIndex()
- {
- // Asserts to make sure that we aren't using any skipped combinations.
- // Asserts to make sure that we are setting all of the combination vars.
-#ifdef _DEBUG
- bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB;
- Assert( bAllStaticVarsDefined );
-#endif // _DEBUG
- return ( 1 * m_nCONVERT_TO_SRGB ) + 0;
- }
-};
-#define shaderStaticTest_sdk_bloom_ps20b 0
-class sdk_bloom_ps20b_Dynamic_Index
-{
-public:
- sdk_bloom_ps20b_Dynamic_Index()
- {
- }
- int GetIndex()
- {
- // Asserts to make sure that we aren't using any skipped combinations.
- // Asserts to make sure that we are setting all of the combination vars.
-#ifdef _DEBUG
-#endif // _DEBUG
- return 0;
- }
-};
-#define shaderDynamicTest_sdk_bloom_ps20b 0
+#include "shaderlib/cshader.h"
+class sdk_bloom_ps20b_Static_Index
+{
+private:
+ int m_nCONVERT_TO_SRGB;
+#ifdef _DEBUG
+ bool m_bCONVERT_TO_SRGB;
+#endif
+public:
+ void SetCONVERT_TO_SRGB( int i )
+ {
+ Assert( i >= 0 && i <= 1 );
+ m_nCONVERT_TO_SRGB = i;
+#ifdef _DEBUG
+ m_bCONVERT_TO_SRGB = true;
+#endif
+ }
+ void SetCONVERT_TO_SRGB( bool i )
+ {
+ m_nCONVERT_TO_SRGB = i ? 1 : 0;
+#ifdef _DEBUG
+ m_bCONVERT_TO_SRGB = true;
+#endif
+ }
+public:
+ sdk_bloom_ps20b_Static_Index( )
+ {
+#ifdef _DEBUG
+ m_bCONVERT_TO_SRGB = true;
+#endif // _DEBUG
+ m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion();
+ }
+ int GetIndex()
+ {
+ // Asserts to make sure that we aren't using any skipped combinations.
+ // Asserts to make sure that we are setting all of the combination vars.
+#ifdef _DEBUG
+ bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB;
+ Assert( bAllStaticVarsDefined );
+#endif // _DEBUG
+ return ( 1 * m_nCONVERT_TO_SRGB ) + 0;
+ }
+};
+#define shaderStaticTest_sdk_bloom_ps20b 0
+class sdk_bloom_ps20b_Dynamic_Index
+{
+public:
+ sdk_bloom_ps20b_Dynamic_Index()
+ {
+ }
+ int GetIndex()
+ {
+ // Asserts to make sure that we aren't using any skipped combinations.
+ // Asserts to make sure that we are setting all of the combination vars.
+#ifdef _DEBUG
+#endif // _DEBUG
+ return 0;
+ }
+};
+#define shaderDynamicTest_sdk_bloom_ps20b 0
diff --git a/mp/src/materialsystem/stdshaders/fxctmp9/SDK_bloomadd_ps20.inc b/mp/src/materialsystem/stdshaders/fxctmp9/SDK_bloomadd_ps20.inc
index 672569d4..c0643ebe 100644
--- a/mp/src/materialsystem/stdshaders/fxctmp9/SDK_bloomadd_ps20.inc
+++ b/mp/src/materialsystem/stdshaders/fxctmp9/SDK_bloomadd_ps20.inc
@@ -1,33 +1,33 @@
-#include "shaderlib/cshader.h"
-class sdk_bloomadd_ps20_Static_Index
-{
-public:
- sdk_bloomadd_ps20_Static_Index( )
- {
- }
- int GetIndex()
- {
- // Asserts to make sure that we aren't using any skipped combinations.
- // Asserts to make sure that we are setting all of the combination vars.
-#ifdef _DEBUG
-#endif // _DEBUG
- return 0;
- }
-};
-#define shaderStaticTest_sdk_bloomadd_ps20 0
-class sdk_bloomadd_ps20_Dynamic_Index
-{
-public:
- sdk_bloomadd_ps20_Dynamic_Index()
- {
- }
- int GetIndex()
- {
- // Asserts to make sure that we aren't using any skipped combinations.
- // Asserts to make sure that we are setting all of the combination vars.
-#ifdef _DEBUG
-#endif // _DEBUG
- return 0;
- }
-};
-#define shaderDynamicTest_sdk_bloomadd_ps20 0
+#include "shaderlib/cshader.h"
+class sdk_bloomadd_ps20_Static_Index
+{
+public:
+ sdk_bloomadd_ps20_Static_Index( )
+ {
+ }
+ int GetIndex()
+ {
+ // Asserts to make sure that we aren't using any skipped combinations.
+ // Asserts to make sure that we are setting all of the combination vars.
+#ifdef _DEBUG
+#endif // _DEBUG
+ return 0;
+ }
+};
+#define shaderStaticTest_sdk_bloomadd_ps20 0
+class sdk_bloomadd_ps20_Dynamic_Index
+{
+public:
+ sdk_bloomadd_ps20_Dynamic_Index()
+ {
+ }
+ int GetIndex()
+ {
+ // Asserts to make sure that we aren't using any skipped combinations.
+ // Asserts to make sure that we are setting all of the combination vars.
+#ifdef _DEBUG
+#endif // _DEBUG
+ return 0;
+ }
+};
+#define shaderDynamicTest_sdk_bloomadd_ps20 0
diff --git a/mp/src/materialsystem/stdshaders/fxctmp9/SDK_bloomadd_ps20b.inc b/mp/src/materialsystem/stdshaders/fxctmp9/SDK_bloomadd_ps20b.inc
index 645e9f46..861e517b 100644
--- a/mp/src/materialsystem/stdshaders/fxctmp9/SDK_bloomadd_ps20b.inc
+++ b/mp/src/materialsystem/stdshaders/fxctmp9/SDK_bloomadd_ps20b.inc
@@ -1,33 +1,33 @@
-#include "shaderlib/cshader.h"
-class sdk_bloomadd_ps20b_Static_Index
-{
-public:
- sdk_bloomadd_ps20b_Static_Index( )
- {
- }
- int GetIndex()
- {
- // Asserts to make sure that we aren't using any skipped combinations.
- // Asserts to make sure that we are setting all of the combination vars.
-#ifdef _DEBUG
-#endif // _DEBUG
- return 0;
- }
-};
-#define shaderStaticTest_sdk_bloomadd_ps20b 0
-class sdk_bloomadd_ps20b_Dynamic_Index
-{
-public:
- sdk_bloomadd_ps20b_Dynamic_Index()
- {
- }
- int GetIndex()
- {
- // Asserts to make sure that we aren't using any skipped combinations.
- // Asserts to make sure that we are setting all of the combination vars.
-#ifdef _DEBUG
-#endif // _DEBUG
- return 0;
- }
-};
-#define shaderDynamicTest_sdk_bloomadd_ps20b 0
+#include "shaderlib/cshader.h"
+class sdk_bloomadd_ps20b_Static_Index
+{
+public:
+ sdk_bloomadd_ps20b_Static_Index( )
+ {
+ }
+ int GetIndex()
+ {
+ // Asserts to make sure that we aren't using any skipped combinations.
+ // Asserts to make sure that we are setting all of the combination vars.
+#ifdef _DEBUG
+#endif // _DEBUG
+ return 0;
+ }
+};
+#define shaderStaticTest_sdk_bloomadd_ps20b 0
+class sdk_bloomadd_ps20b_Dynamic_Index
+{
+public:
+ sdk_bloomadd_ps20b_Dynamic_Index()
+ {
+ }
+ int GetIndex()
+ {
+ // Asserts to make sure that we aren't using any skipped combinations.
+ // Asserts to make sure that we are setting all of the combination vars.
+#ifdef _DEBUG
+#endif // _DEBUG
+ return 0;
+ }
+};
+#define shaderDynamicTest_sdk_bloomadd_ps20b 0
diff --git a/mp/src/materialsystem/stdshaders/fxctmp9/SDK_screenspaceeffect_vs20.inc b/mp/src/materialsystem/stdshaders/fxctmp9/SDK_screenspaceeffect_vs20.inc
index c37985c8..607c12cd 100644
--- a/mp/src/materialsystem/stdshaders/fxctmp9/SDK_screenspaceeffect_vs20.inc
+++ b/mp/src/materialsystem/stdshaders/fxctmp9/SDK_screenspaceeffect_vs20.inc
@@ -1,60 +1,60 @@
-#include "shaderlib/cshader.h"
-class sdk_screenspaceeffect_vs20_Static_Index
-{
-private:
- int m_nX360APPCHOOSER;
-#ifdef _DEBUG
- bool m_bX360APPCHOOSER;
-#endif
-public:
- void SetX360APPCHOOSER( int i )
- {
- Assert( i >= 0 && i <= 1 );
- m_nX360APPCHOOSER = i;
-#ifdef _DEBUG
- m_bX360APPCHOOSER = true;
-#endif
- }
- void SetX360APPCHOOSER( bool i )
- {
- m_nX360APPCHOOSER = i ? 1 : 0;
-#ifdef _DEBUG
- m_bX360APPCHOOSER = true;
-#endif
- }
-public:
- sdk_screenspaceeffect_vs20_Static_Index( )
- {
-#ifdef _DEBUG
- m_bX360APPCHOOSER = true;
-#endif // _DEBUG
- m_nX360APPCHOOSER = 0;
- }
- int GetIndex()
- {
- // Asserts to make sure that we aren't using any skipped combinations.
- // Asserts to make sure that we are setting all of the combination vars.
-#ifdef _DEBUG
- bool bAllStaticVarsDefined = m_bX360APPCHOOSER;
- Assert( bAllStaticVarsDefined );
-#endif // _DEBUG
- return ( 1 * m_nX360APPCHOOSER ) + 0;
- }
-};
-#define shaderStaticTest_sdk_screenspaceeffect_vs20 0
-class sdk_screenspaceeffect_vs20_Dynamic_Index
-{
-public:
- sdk_screenspaceeffect_vs20_Dynamic_Index()
- {
- }
- int GetIndex()
- {
- // Asserts to make sure that we aren't using any skipped combinations.
- // Asserts to make sure that we are setting all of the combination vars.
-#ifdef _DEBUG
-#endif // _DEBUG
- return 0;
- }
-};
-#define shaderDynamicTest_sdk_screenspaceeffect_vs20 0
+#include "shaderlib/cshader.h"
+class sdk_screenspaceeffect_vs20_Static_Index
+{
+private:
+ int m_nX360APPCHOOSER;
+#ifdef _DEBUG
+ bool m_bX360APPCHOOSER;
+#endif
+public:
+ void SetX360APPCHOOSER( int i )
+ {
+ Assert( i >= 0 && i <= 1 );
+ m_nX360APPCHOOSER = i;
+#ifdef _DEBUG
+ m_bX360APPCHOOSER = true;
+#endif
+ }
+ void SetX360APPCHOOSER( bool i )
+ {
+ m_nX360APPCHOOSER = i ? 1 : 0;
+#ifdef _DEBUG
+ m_bX360APPCHOOSER = true;
+#endif
+ }
+public:
+ sdk_screenspaceeffect_vs20_Static_Index( )
+ {
+#ifdef _DEBUG
+ m_bX360APPCHOOSER = true;
+#endif // _DEBUG
+ m_nX360APPCHOOSER = 0;
+ }
+ int GetIndex()
+ {
+ // Asserts to make sure that we aren't using any skipped combinations.
+ // Asserts to make sure that we are setting all of the combination vars.
+#ifdef _DEBUG
+ bool bAllStaticVarsDefined = m_bX360APPCHOOSER;
+ Assert( bAllStaticVarsDefined );
+#endif // _DEBUG
+ return ( 1 * m_nX360APPCHOOSER ) + 0;
+ }
+};
+#define shaderStaticTest_sdk_screenspaceeffect_vs20 0
+class sdk_screenspaceeffect_vs20_Dynamic_Index
+{
+public:
+ sdk_screenspaceeffect_vs20_Dynamic_Index()
+ {
+ }
+ int GetIndex()
+ {
+ // Asserts to make sure that we aren't using any skipped combinations.
+ // Asserts to make sure that we are setting all of the combination vars.
+#ifdef _DEBUG
+#endif // _DEBUG
+ return 0;
+ }
+};
+#define shaderDynamicTest_sdk_screenspaceeffect_vs20 0
diff --git a/mp/src/materialsystem/stdshaders/fxctmp9/example_model_ps20b.inc b/mp/src/materialsystem/stdshaders/fxctmp9/example_model_ps20b.inc
index 018f7b63..1d9a37a2 100644
--- a/mp/src/materialsystem/stdshaders/fxctmp9/example_model_ps20b.inc
+++ b/mp/src/materialsystem/stdshaders/fxctmp9/example_model_ps20b.inc
@@ -1,237 +1,237 @@
-#include "shaderlib/cshader.h"
-class example_model_ps20b_Static_Index
-{
-private:
- int m_nCONVERT_TO_SRGB;
-#ifdef _DEBUG
- bool m_bCONVERT_TO_SRGB;
-#endif
-public:
- void SetCONVERT_TO_SRGB( int i )
- {
- Assert( i >= 0 && i <= 0 );
- m_nCONVERT_TO_SRGB = i;
-#ifdef _DEBUG
- m_bCONVERT_TO_SRGB = true;
-#endif
- }
- void SetCONVERT_TO_SRGB( bool i )
- {
- m_nCONVERT_TO_SRGB = i ? 1 : 0;
-#ifdef _DEBUG
- m_bCONVERT_TO_SRGB = true;
-#endif
- }
-private:
- int m_nFLASHLIGHT;
-#ifdef _DEBUG
- bool m_bFLASHLIGHT;
-#endif
-public:
- void SetFLASHLIGHT( int i )
- {
- Assert( i >= 0 && i <= 1 );
- m_nFLASHLIGHT = i;
-#ifdef _DEBUG
- m_bFLASHLIGHT = true;
-#endif
- }
- void SetFLASHLIGHT( bool i )
- {
- m_nFLASHLIGHT = i ? 1 : 0;
-#ifdef _DEBUG
- m_bFLASHLIGHT = true;
-#endif
- }
-private:
- int m_nFLASHLIGHTDEPTHFILTERMODE;
-#ifdef _DEBUG
- bool m_bFLASHLIGHTDEPTHFILTERMODE;
-#endif
-public:
- void SetFLASHLIGHTDEPTHFILTERMODE( int i )
- {
- Assert( i >= 0 && i <= 2 );
- m_nFLASHLIGHTDEPTHFILTERMODE = i;
-#ifdef _DEBUG
- m_bFLASHLIGHTDEPTHFILTERMODE = true;
-#endif
- }
- void SetFLASHLIGHTDEPTHFILTERMODE( bool i )
- {
- m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0;
-#ifdef _DEBUG
- m_bFLASHLIGHTDEPTHFILTERMODE = true;
-#endif
- }
-public:
- example_model_ps20b_Static_Index( )
- {
-#ifdef _DEBUG
- m_bCONVERT_TO_SRGB = false;
-#endif // _DEBUG
- m_nCONVERT_TO_SRGB = 0;
-#ifdef _DEBUG
- m_bFLASHLIGHT = false;
-#endif // _DEBUG
- m_nFLASHLIGHT = 0;
-#ifdef _DEBUG
- m_bFLASHLIGHTDEPTHFILTERMODE = false;
-#endif // _DEBUG
- m_nFLASHLIGHTDEPTHFILTERMODE = 0;
- }
- int GetIndex()
- {
- // Asserts to make sure that we aren't using any skipped combinations.
- // Asserts to make sure that we are setting all of the combination vars.
-#ifdef _DEBUG
- bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bFLASHLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE;
- Assert( bAllStaticVarsDefined );
-#endif // _DEBUG
- return ( 80 * m_nCONVERT_TO_SRGB ) + ( 80 * m_nFLASHLIGHT ) + ( 160 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0;
- }
-};
-#define shaderStaticTest_example_model_ps20b psh_forgot_to_set_static_CONVERT_TO_SRGB + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0
-class example_model_ps20b_Dynamic_Index
-{
-private:
- int m_nWRITEWATERFOGTODESTALPHA;
-#ifdef _DEBUG
- bool m_bWRITEWATERFOGTODESTALPHA;
-#endif
-public:
- void SetWRITEWATERFOGTODESTALPHA( int i )
- {
- Assert( i >= 0 && i <= 1 );
- m_nWRITEWATERFOGTODESTALPHA = i;
-#ifdef _DEBUG
- m_bWRITEWATERFOGTODESTALPHA = true;
-#endif
- }
- void SetWRITEWATERFOGTODESTALPHA( bool i )
- {
- m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0;
-#ifdef _DEBUG
- m_bWRITEWATERFOGTODESTALPHA = true;
-#endif
- }
-private:
- int m_nPIXELFOGTYPE;
-#ifdef _DEBUG
- bool m_bPIXELFOGTYPE;
-#endif
-public:
- void SetPIXELFOGTYPE( int i )
- {
- Assert( i >= 0 && i <= 1 );
- m_nPIXELFOGTYPE = i;
-#ifdef _DEBUG
- m_bPIXELFOGTYPE = true;
-#endif
- }
- void SetPIXELFOGTYPE( bool i )
- {
- m_nPIXELFOGTYPE = i ? 1 : 0;
-#ifdef _DEBUG
- m_bPIXELFOGTYPE = true;
-#endif
- }
-private:
- int m_nNUM_LIGHTS;
-#ifdef _DEBUG
- bool m_bNUM_LIGHTS;
-#endif
-public:
- void SetNUM_LIGHTS( int i )
- {
- Assert( i >= 0 && i <= 4 );
- m_nNUM_LIGHTS = i;
-#ifdef _DEBUG
- m_bNUM_LIGHTS = true;
-#endif
- }
- void SetNUM_LIGHTS( bool i )
- {
- m_nNUM_LIGHTS = i ? 1 : 0;
-#ifdef _DEBUG
- m_bNUM_LIGHTS = true;
-#endif
- }
-private:
- int m_nWRITE_DEPTH_TO_DESTALPHA;
-#ifdef _DEBUG
- bool m_bWRITE_DEPTH_TO_DESTALPHA;
-#endif
-public:
- void SetWRITE_DEPTH_TO_DESTALPHA( int i )
- {
- Assert( i >= 0 && i <= 1 );
- m_nWRITE_DEPTH_TO_DESTALPHA = i;
-#ifdef _DEBUG
- m_bWRITE_DEPTH_TO_DESTALPHA = true;
-#endif
- }
- void SetWRITE_DEPTH_TO_DESTALPHA( bool i )
- {
- m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0;
-#ifdef _DEBUG
- m_bWRITE_DEPTH_TO_DESTALPHA = true;
-#endif
- }
-private:
- int m_nFLASHLIGHTSHADOWS;
-#ifdef _DEBUG
- bool m_bFLASHLIGHTSHADOWS;
-#endif
-public:
- void SetFLASHLIGHTSHADOWS( int i )
- {
- Assert( i >= 0 && i <= 1 );
- m_nFLASHLIGHTSHADOWS = i;
-#ifdef _DEBUG
- m_bFLASHLIGHTSHADOWS = true;
-#endif
- }
- void SetFLASHLIGHTSHADOWS( bool i )
- {
- m_nFLASHLIGHTSHADOWS = i ? 1 : 0;
-#ifdef _DEBUG
- m_bFLASHLIGHTSHADOWS = true;
-#endif
- }
-public:
- example_model_ps20b_Dynamic_Index()
- {
-#ifdef _DEBUG
- m_bWRITEWATERFOGTODESTALPHA = false;
-#endif // _DEBUG
- m_nWRITEWATERFOGTODESTALPHA = 0;
-#ifdef _DEBUG
- m_bPIXELFOGTYPE = false;
-#endif // _DEBUG
- m_nPIXELFOGTYPE = 0;
-#ifdef _DEBUG
- m_bNUM_LIGHTS = false;
-#endif // _DEBUG
- m_nNUM_LIGHTS = 0;
-#ifdef _DEBUG
- m_bWRITE_DEPTH_TO_DESTALPHA = false;
-#endif // _DEBUG
- m_nWRITE_DEPTH_TO_DESTALPHA = 0;
-#ifdef _DEBUG
- m_bFLASHLIGHTSHADOWS = false;
-#endif // _DEBUG
- m_nFLASHLIGHTSHADOWS = 0;
- }
- int GetIndex()
- {
- // Asserts to make sure that we aren't using any skipped combinations.
- // Asserts to make sure that we are setting all of the combination vars.
-#ifdef _DEBUG
- bool bAllDynamicVarsDefined = m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bNUM_LIGHTS && m_bWRITE_DEPTH_TO_DESTALPHA && m_bFLASHLIGHTSHADOWS;
- Assert( bAllDynamicVarsDefined );
-#endif // _DEBUG
- return ( 1 * m_nWRITEWATERFOGTODESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + ( 4 * m_nNUM_LIGHTS ) + ( 20 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 40 * m_nFLASHLIGHTSHADOWS ) + 0;
- }
-};
-#define shaderDynamicTest_example_model_ps20b psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0
+#include "shaderlib/cshader.h"
+class example_model_ps20b_Static_Index
+{
+private:
+ int m_nCONVERT_TO_SRGB;
+#ifdef _DEBUG
+ bool m_bCONVERT_TO_SRGB;
+#endif
+public:
+ void SetCONVERT_TO_SRGB( int i )
+ {
+ Assert( i >= 0 && i <= 0 );
+ m_nCONVERT_TO_SRGB = i;
+#ifdef _DEBUG
+ m_bCONVERT_TO_SRGB = true;
+#endif
+ }
+ void SetCONVERT_TO_SRGB( bool i )
+ {
+ m_nCONVERT_TO_SRGB = i ? 1 : 0;
+#ifdef _DEBUG
+ m_bCONVERT_TO_SRGB = true;
+#endif
+ }
+private:
+ int m_nFLASHLIGHT;
+#ifdef _DEBUG
+ bool m_bFLASHLIGHT;
+#endif
+public:
+ void SetFLASHLIGHT( int i )
+ {
+ Assert( i >= 0 && i <= 1 );
+ m_nFLASHLIGHT = i;
+#ifdef _DEBUG
+ m_bFLASHLIGHT = true;
+#endif
+ }
+ void SetFLASHLIGHT( bool i )
+ {
+ m_nFLASHLIGHT = i ? 1 : 0;
+#ifdef _DEBUG
+ m_bFLASHLIGHT = true;
+#endif
+ }
+private:
+ int m_nFLASHLIGHTDEPTHFILTERMODE;
+#ifdef _DEBUG
+ bool m_bFLASHLIGHTDEPTHFILTERMODE;
+#endif
+public:
+ void SetFLASHLIGHTDEPTHFILTERMODE( int i )
+ {
+ Assert( i >= 0 && i <= 2 );
+ m_nFLASHLIGHTDEPTHFILTERMODE = i;
+#ifdef _DEBUG
+ m_bFLASHLIGHTDEPTHFILTERMODE = true;
+#endif
+ }
+ void SetFLASHLIGHTDEPTHFILTERMODE( bool i )
+ {
+ m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0;
+#ifdef _DEBUG
+ m_bFLASHLIGHTDEPTHFILTERMODE = true;
+#endif
+ }
+public:
+ example_model_ps20b_Static_Index( )
+ {
+#ifdef _DEBUG
+ m_bCONVERT_TO_SRGB = false;
+#endif // _DEBUG
+ m_nCONVERT_TO_SRGB = 0;
+#ifdef _DEBUG
+ m_bFLASHLIGHT = false;
+#endif // _DEBUG
+ m_nFLASHLIGHT = 0;
+#ifdef _DEBUG
+ m_bFLASHLIGHTDEPTHFILTERMODE = false;
+#endif // _DEBUG
+ m_nFLASHLIGHTDEPTHFILTERMODE = 0;
+ }
+ int GetIndex()
+ {
+ // Asserts to make sure that we aren't using any skipped combinations.
+ // Asserts to make sure that we are setting all of the combination vars.
+#ifdef _DEBUG
+ bool bAllStaticVarsDefined = m_bCONVERT_TO_SRGB && m_bFLASHLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE;
+ Assert( bAllStaticVarsDefined );
+#endif // _DEBUG
+ return ( 80 * m_nCONVERT_TO_SRGB ) + ( 80 * m_nFLASHLIGHT ) + ( 160 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0;
+ }
+};
+#define shaderStaticTest_example_model_ps20b psh_forgot_to_set_static_CONVERT_TO_SRGB + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0
+class example_model_ps20b_Dynamic_Index
+{
+private:
+ int m_nWRITEWATERFOGTODESTALPHA;
+#ifdef _DEBUG
+ bool m_bWRITEWATERFOGTODESTALPHA;
+#endif
+public:
+ void SetWRITEWATERFOGTODESTALPHA( int i )
+ {
+ Assert( i >= 0 && i <= 1 );
+ m_nWRITEWATERFOGTODESTALPHA = i;
+#ifdef _DEBUG
+ m_bWRITEWATERFOGTODESTALPHA = true;
+#endif
+ }
+ void SetWRITEWATERFOGTODESTALPHA( bool i )
+ {
+ m_nWRITEWATERFOGTODESTALPHA = i ? 1 : 0;
+#ifdef _DEBUG
+ m_bWRITEWATERFOGTODESTALPHA = true;
+#endif
+ }
+private:
+ int m_nPIXELFOGTYPE;
+#ifdef _DEBUG
+ bool m_bPIXELFOGTYPE;
+#endif
+public:
+ void SetPIXELFOGTYPE( int i )
+ {
+ Assert( i >= 0 && i <= 1 );
+ m_nPIXELFOGTYPE = i;
+#ifdef _DEBUG
+ m_bPIXELFOGTYPE = true;
+#endif
+ }
+ void SetPIXELFOGTYPE( bool i )
+ {
+ m_nPIXELFOGTYPE = i ? 1 : 0;
+#ifdef _DEBUG
+ m_bPIXELFOGTYPE = true;
+#endif
+ }
+private:
+ int m_nNUM_LIGHTS;
+#ifdef _DEBUG
+ bool m_bNUM_LIGHTS;
+#endif
+public:
+ void SetNUM_LIGHTS( int i )
+ {
+ Assert( i >= 0 && i <= 4 );
+ m_nNUM_LIGHTS = i;
+#ifdef _DEBUG
+ m_bNUM_LIGHTS = true;
+#endif
+ }
+ void SetNUM_LIGHTS( bool i )
+ {
+ m_nNUM_LIGHTS = i ? 1 : 0;
+#ifdef _DEBUG
+ m_bNUM_LIGHTS = true;
+#endif
+ }
+private:
+ int m_nWRITE_DEPTH_TO_DESTALPHA;
+#ifdef _DEBUG
+ bool m_bWRITE_DEPTH_TO_DESTALPHA;
+#endif
+public:
+ void SetWRITE_DEPTH_TO_DESTALPHA( int i )
+ {
+ Assert( i >= 0 && i <= 1 );
+ m_nWRITE_DEPTH_TO_DESTALPHA = i;
+#ifdef _DEBUG
+ m_bWRITE_DEPTH_TO_DESTALPHA = true;
+#endif
+ }
+ void SetWRITE_DEPTH_TO_DESTALPHA( bool i )
+ {
+ m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0;
+#ifdef _DEBUG
+ m_bWRITE_DEPTH_TO_DESTALPHA = true;
+#endif
+ }
+private:
+ int m_nFLASHLIGHTSHADOWS;
+#ifdef _DEBUG
+ bool m_bFLASHLIGHTSHADOWS;
+#endif
+public:
+ void SetFLASHLIGHTSHADOWS( int i )
+ {
+ Assert( i >= 0 && i <= 1 );
+ m_nFLASHLIGHTSHADOWS = i;
+#ifdef _DEBUG
+ m_bFLASHLIGHTSHADOWS = true;
+#endif
+ }
+ void SetFLASHLIGHTSHADOWS( bool i )
+ {
+ m_nFLASHLIGHTSHADOWS = i ? 1 : 0;
+#ifdef _DEBUG
+ m_bFLASHLIGHTSHADOWS = true;
+#endif
+ }
+public:
+ example_model_ps20b_Dynamic_Index()
+ {
+#ifdef _DEBUG
+ m_bWRITEWATERFOGTODESTALPHA = false;
+#endif // _DEBUG
+ m_nWRITEWATERFOGTODESTALPHA = 0;
+#ifdef _DEBUG
+ m_bPIXELFOGTYPE = false;
+#endif // _DEBUG
+ m_nPIXELFOGTYPE = 0;
+#ifdef _DEBUG
+ m_bNUM_LIGHTS = false;
+#endif // _DEBUG
+ m_nNUM_LIGHTS = 0;
+#ifdef _DEBUG
+ m_bWRITE_DEPTH_TO_DESTALPHA = false;
+#endif // _DEBUG
+ m_nWRITE_DEPTH_TO_DESTALPHA = 0;
+#ifdef _DEBUG
+ m_bFLASHLIGHTSHADOWS = false;
+#endif // _DEBUG
+ m_nFLASHLIGHTSHADOWS = 0;
+ }
+ int GetIndex()
+ {
+ // Asserts to make sure that we aren't using any skipped combinations.
+ // Asserts to make sure that we are setting all of the combination vars.
+#ifdef _DEBUG
+ bool bAllDynamicVarsDefined = m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bNUM_LIGHTS && m_bWRITE_DEPTH_TO_DESTALPHA && m_bFLASHLIGHTSHADOWS;
+ Assert( bAllDynamicVarsDefined );
+#endif // _DEBUG
+ return ( 1 * m_nWRITEWATERFOGTODESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + ( 4 * m_nNUM_LIGHTS ) + ( 20 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 40 * m_nFLASHLIGHTSHADOWS ) + 0;
+ }
+};
+#define shaderDynamicTest_example_model_ps20b psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_NUM_LIGHTS + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0
diff --git a/mp/src/materialsystem/stdshaders/fxctmp9/example_model_vs20.inc b/mp/src/materialsystem/stdshaders/fxctmp9/example_model_vs20.inc
index a8dbd23f..fcd08eb2 100644
--- a/mp/src/materialsystem/stdshaders/fxctmp9/example_model_vs20.inc
+++ b/mp/src/materialsystem/stdshaders/fxctmp9/example_model_vs20.inc
@@ -1,160 +1,160 @@
-#include "shaderlib/cshader.h"
-class example_model_vs20_Static_Index
-{
-public:
- example_model_vs20_Static_Index( )
- {
- }
- int GetIndex()
- {
- // Asserts to make sure that we aren't using any skipped combinations.
- // Asserts to make sure that we are setting all of the combination vars.
-#ifdef _DEBUG
-#endif // _DEBUG
- return 0;
- }
-};
-#define shaderStaticTest_example_model_vs20 0
-class example_model_vs20_Dynamic_Index
-{
-private:
- int m_nCOMPRESSED_VERTS;
-#ifdef _DEBUG
- bool m_bCOMPRESSED_VERTS;
-#endif
-public:
- void SetCOMPRESSED_VERTS( int i )
- {
- Assert( i >= 0 && i <= 1 );
- m_nCOMPRESSED_VERTS = i;
-#ifdef _DEBUG
- m_bCOMPRESSED_VERTS = true;
-#endif
- }
- void SetCOMPRESSED_VERTS( bool i )
- {
- m_nCOMPRESSED_VERTS = i ? 1 : 0;
-#ifdef _DEBUG
- m_bCOMPRESSED_VERTS = true;
-#endif
- }
-private:
- int m_nDOWATERFOG;
-#ifdef _DEBUG
- bool m_bDOWATERFOG;
-#endif
-public:
- void SetDOWATERFOG( int i )
- {
- Assert( i >= 0 && i <= 1 );
- m_nDOWATERFOG = i;
-#ifdef _DEBUG
- m_bDOWATERFOG = true;
-#endif
- }
- void SetDOWATERFOG( bool i )
- {
- m_nDOWATERFOG = i ? 1 : 0;
-#ifdef _DEBUG
- m_bDOWATERFOG = true;
-#endif
- }
-private:
- int m_nSKINNING;
-#ifdef _DEBUG
- bool m_bSKINNING;
-#endif
-public:
- void SetSKINNING( int i )
- {
- Assert( i >= 0 && i <= 1 );
- m_nSKINNING = i;
-#ifdef _DEBUG
- m_bSKINNING = true;
-#endif
- }
- void SetSKINNING( bool i )
- {
- m_nSKINNING = i ? 1 : 0;
-#ifdef _DEBUG
- m_bSKINNING = true;
-#endif
- }
-private:
- int m_nLIGHTING_PREVIEW;
-#ifdef _DEBUG
- bool m_bLIGHTING_PREVIEW;
-#endif
-public:
- void SetLIGHTING_PREVIEW( int i )
- {
- Assert( i >= 0 && i <= 1 );
- m_nLIGHTING_PREVIEW = i;
-#ifdef _DEBUG
- m_bLIGHTING_PREVIEW = true;
-#endif
- }
- void SetLIGHTING_PREVIEW( bool i )
- {
- m_nLIGHTING_PREVIEW = i ? 1 : 0;
-#ifdef _DEBUG
- m_bLIGHTING_PREVIEW = true;
-#endif
- }
-private:
- int m_nNUM_LIGHTS;
-#ifdef _DEBUG
- bool m_bNUM_LIGHTS;
-#endif
-public:
- void SetNUM_LIGHTS( int i )
- {
- Assert( i >= 0 && i <= 4 );
- m_nNUM_LIGHTS = i;
-#ifdef _DEBUG
- m_bNUM_LIGHTS = true;
-#endif
- }
- void SetNUM_LIGHTS( bool i )
- {
- m_nNUM_LIGHTS = i ? 1 : 0;
-#ifdef _DEBUG
- m_bNUM_LIGHTS = true;
-#endif
- }
-public:
- example_model_vs20_Dynamic_Index()
- {
-#ifdef _DEBUG
- m_bCOMPRESSED_VERTS = false;
-#endif // _DEBUG
- m_nCOMPRESSED_VERTS = 0;
-#ifdef _DEBUG
- m_bDOWATERFOG = false;
-#endif // _DEBUG
- m_nDOWATERFOG = 0;
-#ifdef _DEBUG
- m_bSKINNING = false;
-#endif // _DEBUG
- m_nSKINNING = 0;
-#ifdef _DEBUG
- m_bLIGHTING_PREVIEW = false;
-#endif // _DEBUG
- m_nLIGHTING_PREVIEW = 0;
-#ifdef _DEBUG
- m_bNUM_LIGHTS = false;
-#endif // _DEBUG
- m_nNUM_LIGHTS = 0;
- }
- int GetIndex()
- {
- // Asserts to make sure that we aren't using any skipped combinations.
- // Asserts to make sure that we are setting all of the combination vars.
-#ifdef _DEBUG
- bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bLIGHTING_PREVIEW && m_bNUM_LIGHTS;
- Assert( bAllDynamicVarsDefined );
-#endif // _DEBUG
- return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nLIGHTING_PREVIEW ) + ( 16 * m_nNUM_LIGHTS ) + 0;
- }
-};
-#define shaderDynamicTest_example_model_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0
+#include "shaderlib/cshader.h"
+class example_model_vs20_Static_Index
+{
+public:
+ example_model_vs20_Static_Index( )
+ {
+ }
+ int GetIndex()
+ {
+ // Asserts to make sure that we aren't using any skipped combinations.
+ // Asserts to make sure that we are setting all of the combination vars.
+#ifdef _DEBUG
+#endif // _DEBUG
+ return 0;
+ }
+};
+#define shaderStaticTest_example_model_vs20 0
+class example_model_vs20_Dynamic_Index
+{
+private:
+ int m_nCOMPRESSED_VERTS;
+#ifdef _DEBUG
+ bool m_bCOMPRESSED_VERTS;
+#endif
+public:
+ void SetCOMPRESSED_VERTS( int i )
+ {
+ Assert( i >= 0 && i <= 1 );
+ m_nCOMPRESSED_VERTS = i;
+#ifdef _DEBUG
+ m_bCOMPRESSED_VERTS = true;
+#endif
+ }
+ void SetCOMPRESSED_VERTS( bool i )
+ {
+ m_nCOMPRESSED_VERTS = i ? 1 : 0;
+#ifdef _DEBUG
+ m_bCOMPRESSED_VERTS = true;
+#endif
+ }
+private:
+ int m_nDOWATERFOG;
+#ifdef _DEBUG
+ bool m_bDOWATERFOG;
+#endif
+public:
+ void SetDOWATERFOG( int i )
+ {
+ Assert( i >= 0 && i <= 1 );
+ m_nDOWATERFOG = i;
+#ifdef _DEBUG
+ m_bDOWATERFOG = true;
+#endif
+ }
+ void SetDOWATERFOG( bool i )
+ {
+ m_nDOWATERFOG = i ? 1 : 0;
+#ifdef _DEBUG
+ m_bDOWATERFOG = true;
+#endif
+ }
+private:
+ int m_nSKINNING;
+#ifdef _DEBUG
+ bool m_bSKINNING;
+#endif
+public:
+ void SetSKINNING( int i )
+ {
+ Assert( i >= 0 && i <= 1 );
+ m_nSKINNING = i;
+#ifdef _DEBUG
+ m_bSKINNING = true;
+#endif
+ }
+ void SetSKINNING( bool i )
+ {
+ m_nSKINNING = i ? 1 : 0;
+#ifdef _DEBUG
+ m_bSKINNING = true;
+#endif
+ }
+private:
+ int m_nLIGHTING_PREVIEW;
+#ifdef _DEBUG
+ bool m_bLIGHTING_PREVIEW;
+#endif
+public:
+ void SetLIGHTING_PREVIEW( int i )
+ {
+ Assert( i >= 0 && i <= 1 );
+ m_nLIGHTING_PREVIEW = i;
+#ifdef _DEBUG
+ m_bLIGHTING_PREVIEW = true;
+#endif
+ }
+ void SetLIGHTING_PREVIEW( bool i )
+ {
+ m_nLIGHTING_PREVIEW = i ? 1 : 0;
+#ifdef _DEBUG
+ m_bLIGHTING_PREVIEW = true;
+#endif
+ }
+private:
+ int m_nNUM_LIGHTS;
+#ifdef _DEBUG
+ bool m_bNUM_LIGHTS;
+#endif
+public:
+ void SetNUM_LIGHTS( int i )
+ {
+ Assert( i >= 0 && i <= 4 );
+ m_nNUM_LIGHTS = i;
+#ifdef _DEBUG
+ m_bNUM_LIGHTS = true;
+#endif
+ }
+ void SetNUM_LIGHTS( bool i )
+ {
+ m_nNUM_LIGHTS = i ? 1 : 0;
+#ifdef _DEBUG
+ m_bNUM_LIGHTS = true;
+#endif
+ }
+public:
+ example_model_vs20_Dynamic_Index()
+ {
+#ifdef _DEBUG
+ m_bCOMPRESSED_VERTS = false;
+#endif // _DEBUG
+ m_nCOMPRESSED_VERTS = 0;
+#ifdef _DEBUG
+ m_bDOWATERFOG = false;
+#endif // _DEBUG
+ m_nDOWATERFOG = 0;
+#ifdef _DEBUG
+ m_bSKINNING = false;
+#endif // _DEBUG
+ m_nSKINNING = 0;
+#ifdef _DEBUG
+ m_bLIGHTING_PREVIEW = false;
+#endif // _DEBUG
+ m_nLIGHTING_PREVIEW = 0;
+#ifdef _DEBUG
+ m_bNUM_LIGHTS = false;
+#endif // _DEBUG
+ m_nNUM_LIGHTS = 0;
+ }
+ int GetIndex()
+ {
+ // Asserts to make sure that we aren't using any skipped combinations.
+ // Asserts to make sure that we are setting all of the combination vars.
+#ifdef _DEBUG
+ bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bLIGHTING_PREVIEW && m_bNUM_LIGHTS;
+ Assert( bAllDynamicVarsDefined );
+#endif // _DEBUG
+ return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nLIGHTING_PREVIEW ) + ( 16 * m_nNUM_LIGHTS ) + 0;
+ }
+};
+#define shaderDynamicTest_example_model_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0
diff --git a/mp/src/materialsystem/stdshaders/macros.vsh b/mp/src/materialsystem/stdshaders/macros.vsh
index 9b19f777..d1116e52 100644
--- a/mp/src/materialsystem/stdshaders/macros.vsh
+++ b/mp/src/materialsystem/stdshaders/macros.vsh
@@ -1,1393 +1,1393 @@
-;------------------------------------
-; RULES FOR AUTHORING VERTEX SHADERS:
-;------------------------------------
-; - never use "def" . . .set constants in code instead. . our constant shadowing will break otherwise.
-; (same goes for pixel shaders)
-; - use cN notation instead of c[N] notation. .makes grepping for registers easier.
-; The only exception is c[a0.x+blah] where you have no choice.
-$g_NumRegisters = 12;
-
-; NOTE: These must match the same values in vsh_prep.pl!
-$vPos = "v0";
-$vBoneWeights = "v1";
-$vBoneIndices = "v2";
-$vNormal = "v3";
-$vColor = "v5";
-$vSpecular = "v6";
-$vTexCoord0 = "v7";
-$vTexCoord1 = "v8";
-$vTexCoord2 = "v9";
-$vTexCoord3 = "v10";
-$vTangentS = "v11";
-$vTangentT = "v12";
-$vUserData = "v14";
-
-if( $g_dx9 )
-{
- if( $g_usesPos )
- {
- dcl_position $vPos;
- }
-
- if( $g_usesBoneWeights )
- {
- dcl_blendweight $vBoneWeights;
- }
- if( $g_usesBoneIndices )
- {
- dcl_blendindices $vBoneIndices;
- }
- if( $g_usesNormal )
- {
- dcl_normal $vNormal;
- }
- if( $g_usesColor )
- {
- dcl_color0 $vColor;
- }
- if( $g_usesSpecular )
- {
- dcl_color1 $vSpecular;
- }
- if( $g_usesTexCoord0 )
- {
- dcl_texcoord0 $vTexCoord0;
- }
- if( $g_usesTexCoord1 )
- {
- dcl_texcoord1 $vTexCoord1;
- }
- if( $g_usesTexCoord2 )
- {
- dcl_texcoord2 $vTexCoord2;
- }
- if( $g_usesTexCoord3 )
- {
- dcl_texcoord3 $vTexCoord3;
- }
- if( $g_usesTangentS )
- {
- dcl_tangent $vTangentS;
- }
- if( $g_usesTangentT )
- {
- dcl_binormal0 $vTangentT;
- }
- if( $g_usesUserData )
- {
- dcl_tangent $vUserData;
- }
-}
-
-# NOTE: These should match g_LightCombinations in vertexshaderdx8.cpp!
-# NOTE: Leave this on single lines or shit might blow up.
-@g_staticLightTypeArray = ( "none", "static", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "static", "static", "static", "static", "static", "static", "static", "static", "static", "static" );
-@g_ambientLightTypeArray = ( "none", "none", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient" );
-@g_localLightType1Array = ( "none", "none", "none", "spot", "point", "directional", "spot", "spot", "spot", "point", "point", "directional", "none", "spot", "point", "directional", "spot", "spot", "spot", "point", "point", "directional" );
-@g_localLightType2Array = ( "none", "none", "none", "none", "none", "none", "spot", "point", "directional", "point", "directional", "directional", "none", "none", "none", "none", "spot", "point", "directional", "point", "directional", "directional" );
-
-$cConstants0 = "c0";
-$cZero = "c0.x";
-$cOne = "c0.y";
-$cTwo = "c0.z";
-$cHalf = "c0.w";
-
-$cConstants1 = "c1";
-$cOOGamma = "c1.x"; # 1/2.2
-$cOtherOverbrightFactor = "c1.y"; # overbright
-$cOneThird = "c1.z"; # 1/3
-$cOverbrightFactor = "c1.w"; # 1/overbright
-
-$cEyePos = "c2";
-$cWaterZ = "c2.w";
-$cEyePosWaterZ = "c2";
-
-$cLightIndex = "c3";
-$cLight0Offset = "c3.x"; # 27
-$cLight1Offset = "c3.y"; # 32
-$cColorToIntScale = "c3.z"; # matrix array offset = 3.0f * 255.0f + 0.01 (epsilon ensures floor yields desired result)
-$cModel0Index = "c3.w"; # base for start of skinning matrices
-
-; NOTE: These must match the same values in vsh_prep.pl!
-$cModelViewProj0 = "c4";
-$cModelViewProj1 = "c5";
-$cModelViewProj2 = "c6";
-$cModelViewProj3 = "c7";
-
-$cViewProj0 = "c8";
-$cViewProj1 = "c9";
-$cViewProj2 = "c10";
-$cViewProj3 = "c11";
-
-; currently unused
-; c12, c13
-
-$SHADER_SPECIFIC_CONST_10 = "c14";
-$SHADER_SPECIFIC_CONST_11 = "c15";
-
-$cFogParams = "c16";
-$cFogEndOverFogRange = "c16.x";
-$cFogOne = "c16.y";
-$cFogMaxDensity = "c16.z";
-$cOOFogRange = "c16.w"; # (1/(fogEnd-fogStart))
-
-$cViewModel0 = "c17";
-$cViewModel1 = "c18";
-$cViewModel2 = "c19";
-$cViewModel3 = "c20";
-
-$cAmbientColorPosX = "c21";
-$cAmbientColorNegX = "c22";
-$cAmbientColorPosY = "c23";
-$cAmbientColorNegY = "c24";
-$cAmbientColorPosZ = "c25";
-$cAmbientColorNegZ = "c26";
-
-$cAmbientColorPosXOffset = "21";
-$cAmbientColorPosYOffset = "23";
-$cAmbientColorPosZOffset = "25";
-
-$cLight0DiffColor = "c27";
-$cLight0Dir = "c28";
-$cLight0Pos = "c29";
-$cLight0SpotParams = "c30"; # [ exponent, stopdot, stopdot2, 1 / (stopdot - stopdot2)
-$cLight0Atten = "c31"; # [ constant, linear, quadratic, 0.0f ]
-
-$cLight1DiffColor = "c32";
-$cLight1Dir = "c33";
-$cLight1Pos = "c34";
-$cLight1SpotParams = "c35"; # [ exponent, stopdot, stopdot2, 1 / (stopdot - stopdot2)
-$cLight1Atten = "c36"; # [ constant, linear, quadratic, 0.0f ]
-
-$cModulationColor = "c37";
-
-$SHADER_SPECIFIC_CONST_0 = "c38";
-$SHADER_SPECIFIC_CONST_1 = "c39";
-$SHADER_SPECIFIC_CONST_2 = "c40";
-$SHADER_SPECIFIC_CONST_3 = "c41";
-$SHADER_SPECIFIC_CONST_4 = "c42";
-$SHADER_SPECIFIC_CONST_5 = "c43";
-$SHADER_SPECIFIC_CONST_6 = "c44";
-$SHADER_SPECIFIC_CONST_7 = "c45";
-$SHADER_SPECIFIC_CONST_8 = "c46";
-$SHADER_SPECIFIC_CONST_9 = "c47";
-; $SHADER_SPECIFIC_CONST_10 is c14
-; $SHADER_SPECIFIC_CONST_11 is c15
-
-; There are 16 model matrices for skinning
-; NOTE: These must match the same values in vsh_prep.pl!
-$cModel0 = "c48";
-$cModel1 = "c49";
-$cModel2 = "c50";
-
-sub OutputUsedRegisters
-{
- local( $i );
- ; USED REGISTERS
- for( $i = 0; $i < $g_NumRegisters; $i++ )
- {
- if( $g_allocated[$i] )
- {
- ; $g_allocatedname[$i] = r$i
- }
- }
- ;
-}
-
-sub AllocateRegister
-{
- local( *reg ) = shift;
- local( $regname ) = shift;
- local( $i );
- for( $i = 0; $i < $g_NumRegisters; $i++ )
- {
- if( !$g_allocated[$i] )
- {
- $g_allocated[$i] = 1;
- $g_allocatedname[$i] = $regname;
- ; AllocateRegister $regname = r$i
- $reg = "r$i";
- &OutputUsedRegisters();
- return;
- }
- }
- ; Out of registers allocating $regname!
- $reg = "rERROR_OUT_OF_REGISTERS";
- &OutputUsedRegisters();
-}
-
-; pass in a reference to a var that contains a register. . ie \$var where var will constain "r1", etc
-sub FreeRegister
-{
- local( *reg ) = shift;
- local( $regname ) = shift;
- ; FreeRegister $regname = $reg
- if( $reg =~ m/rERROR_DEALLOCATED/ )
- {
- ; $regname already deallocated
- ; $reg = "rALREADY_DEALLOCATED";
- &OutputUsedRegisters();
- return;
- }
-; if( $regname ne g_allocatedname[$reg] )
-; {
-; ; Error freeing $reg
-; mov compileerror, freed unallocated register $regname
-; }
-
- if( ( $reg =~ m/r(.*)/ ) )
- {
- $g_allocated[$1] = 0;
- }
- $reg = "rERROR_DEALLOCATED";
- &OutputUsedRegisters();
-}
-
-sub CheckUnfreedRegisters()
-{
- local( $i );
- for( $i = 0; $i < $g_NumRegisters; $i++ )
- {
- if( $g_allocated[$i] )
- {
- print "ERROR: r$i allocated to $g_allocatedname[$i] at end of program\n";
- $g_allocated[$i] = 0;
- }
- }
-}
-
-sub Normalize
-{
- local( $r ) = shift;
- dp3 $r.w, $r, $r
- rsq $r.w, $r.w
- mul $r, $r, $r.w
-}
-
-sub Cross
-{
- local( $result ) = shift;
- local( $a ) = shift;
- local( $b ) = shift;
-
- mul $result.xyz, $a.yzx, $b.zxy
- mad $result.xyz, -$b.yzx, $a.zxy, $result
-}
-
-sub RangeFog
-{
- local( $projPos ) = shift;
-
- ;------------------------------
- ; Regular range fog
- ;------------------------------
-
- ; oFog.x = 1.0f = no fog
- ; oFog.x = 0.0f = full fog
- ; compute fog factor f = (fog_end - dist)*(1/(fog_end-fog_start))
- ; this is == to: (fog_end/(fog_end-fog_start) - dist/(fog_end-fog_start)
- ; which can be expressed with a single mad instruction!
-
- ; Compute |projPos|
- local( $tmp );
- &AllocateRegister( \$tmp );
- dp3 $tmp.x, $projPos.xyw, $projPos.xyw
- rsq $tmp.x, $tmp.x
- rcp $tmp.x, $tmp.x
-
- if( $g_dx9 )
- {
- mad $tmp, -$tmp.x, $cOOFogRange, $cFogEndOverFogRange
- min $tmp, $tmp, $cOne
- max oFog, $tmp.x, $cFogMaxDensity
- }
- else
- {
- mad $tmp, -$tmp.x, $cOOFogRange, $cFogEndOverFogRange
- min $tmp, $tmp, $cOne
- max oFog.x, $tmp.x, $cFogMaxDensity
- }
- &FreeRegister( \$tmp );
-}
-
-sub DepthFog
-{
- local( $projPos ) = shift;
- local( $dest ) = shift;
-
- if ( $dest eq "" )
- {
- $dest = "oFog";
- }
-
- ;------------------------------
- ; Regular range fog
- ;------------------------------
-
- ; oFog.x = 1.0f = no fog
- ; oFog.x = 0.0f = full fog
- ; compute fog factor f = (fog_end - dist)*(1/(fog_end-fog_start))
- ; this is == to: (fog_end/(fog_end-fog_start) - dist/(fog_end-fog_start)
- ; which can be expressed with a single mad instruction!
-
- ; Compute |projPos|
- local( $tmp );
- &AllocateRegister( \$tmp );
-
- if( $g_dx9 )
- {
- mad $tmp, -$projPos.w, $cOOFogRange, $cFogEndOverFogRange
- min $tmp, $tmp, $cOne
- max $dest, $tmp.x, $cFogMaxDensity
- }
- else
- {
- mad $tmp, -$projPos.w, $cOOFogRange, $cFogEndOverFogRange
- min $tmp, $tmp, $cOne
- max $dest.x, $tmp.x, $cFogMaxDensity
- }
-
- &FreeRegister( \$tmp );
-}
-
-sub WaterRangeFog
-{
- ; oFog.x = 1.0f = no fog
- ; oFog.x = 0.0f = full fog
-
- ; only $worldPos.z is used out of worldPos
- local( $worldPos ) = shift;
- local( $projPos ) = shift;
-
- local( $tmp );
- &AllocateRegister( \$tmp );
-
- ; This is simple similar triangles. Imagine a line passing from the point directly vertically
- ; and another line passing from the point to the eye position.
- ; Let d = total distance from point to the eye
- ; Let h = vertical distance from the point to the eye
- ; Let hw = vertical distance from the point to the water surface
- ; Let dw = distance from the point to a point on the water surface that lies along the ray from point to eye
- ; Therefore d/h = dw/hw by similar triangles, or dw = d * hw / h.
- ; d = |projPos|, h = eyepos.z - worldPos.z, hw = waterheight.z - worldPos.z, dw = what we solve for
-
- ; Now, tmp.x = hw, and tmp.y = h
- add $tmp.xy, $cEyePosWaterZ.wz, -$worldPos.z
-
- ; if $tmp.x < 0, then set it to 0
- ; This is the equivalent of moving the vert to the water surface if it's above the water surface
- max $tmp.x, $tmp.x, $cZero
-
- ; Compute 1 / |projPos| = 1/d
- dp3 $tmp.z, $projPos.xyw, $projPos.xyw
- rsq $tmp.z, $tmp.z
-
- ; Now we have h/d
- mul $tmp.z, $tmp.z, $tmp.y
-
- ; Now we have d/h
- rcp $tmp.w, $tmp.z
-
- ; We finally have d * hw / h
- ; $tmp.w is now the distance that we see through water.
- mul $tmp.w, $tmp.x, $tmp.w
-
- if( $g_dx9 )
- {
- mad $tmp, -$tmp.w, $cOOFogRange, $cFogOne
- min $tmp, $tmp, $cOne
- max oFog, $tmp.x, $cFogMaxDensity
- }
- else
- {
- mad $tmp, -$tmp.w, $cOOFogRange, $cFogOne
- min $tmp, $tmp, $cOne
- max oFog.x, $tmp.x, $cFogMaxDensity
- }
-
- &FreeRegister( \$tmp );
-}
-
-sub WaterDepthFog
-{
- ; oFog.x = 1.0f = no fog
- ; oFog.x = 0.0f = full fog
-
- ; only $worldPos.z is used out of worldPos
- local( $worldPos ) = shift;
- local( $projPos ) = shift;
- local( $dest ) = shift;
-
- if ( $dest eq "" )
- {
- $dest = "oFog";
- }
-
- local( $tmp );
- &AllocateRegister( \$tmp );
-
- ; This is simple similar triangles. Imagine a line passing from the point directly vertically
- ; and another line passing from the point to the eye position.
- ; Let d = total distance from point to the eye
- ; Let h = vertical distance from the point to the eye
- ; Let hw = vertical distance from the point to the water surface
- ; Let dw = distance from the point to a point on the water surface that lies along the ray from point to eye
- ; Therefore d/h = dw/hw by similar triangles, or dw = d * hw / h.
- ; d = projPos.w, h = eyepos.z - worldPos.z, hw = waterheight.z - worldPos.z, dw = what we solve for
-
- ; Now, tmp.x = hw, and tmp.y = h
- add $tmp.xy, $cEyePosWaterZ.wz, -$worldPos.z
-
- ; if $tmp.x < 0, then set it to 0
- ; This is the equivalent of moving the vert to the water surface if it's above the water surface
- max $tmp.x, $tmp.x, $cZero
-
- ; Now we have 1/h
- rcp $tmp.z, $tmp.y
-
- ; Now we have d/h
- mul $tmp.w, $projPos.w, $tmp.z
-
- ; We finally have d * hw / h
- ; $tmp.w is now the distance that we see through water.
- mul $tmp.w, $tmp.x, $tmp.w
-
- if( $g_dx9 )
- {
- mad $tmp, -$tmp.w, $cOOFogRange, $cFogOne
- min $tmp, $tmp, $cOne
- max $dest, $tmp.x, $cZero
- }
- else
- {
- mad $tmp, -$tmp.w, $cOOFogRange, $cFogOne
- min $tmp, $tmp, $cOne
- max $dest.x, $tmp.x, $cZero
- }
-
- &FreeRegister( \$tmp );
-}
-
-
-;------------------------------------------------------------------------------
-; Main fogging routine
-;------------------------------------------------------------------------------
-sub CalcFog
-{
- if( !defined $DOWATERFOG )
- {
- die "CalcFog called without using \$DOWATERFOG\n";
- }
- my $fogType;
- if( $DOWATERFOG == 0 )
- {
- $fogType = "rangefog";
- }
- else
- {
- $fogType = "heightfog";
- }
-
-# print "\$fogType = $fogType\n";
-
- ; CalcFog
- local( $worldPos ) = shift;
- local( $projPos ) = shift;
- local( $dest ) = shift;
-
- if ( $dest eq "" )
- {
- $dest = "oFog";
- }
-
- if( $fogType eq "rangefog" )
- {
- &DepthFog( $projPos, $dest );
- }
- elsif( $fogType eq "heightfog" )
- {
- &WaterDepthFog( $worldPos, $projPos, $dest );
- }
- else
- {
- die;
- }
-}
-
-sub CalcRangeFog
-{
- ; CalcFog
- local( $worldPos ) = shift;
- local( $projPos ) = shift;
-
- if( $DOWATERFOG == 0 )
- {
- &RangeFog( $projPos );
- }
- elsif( $DOWATERFOG == 1 )
- {
- &WaterRangeFog( $worldPos, $projPos );
- }
- else
- {
- die;
- }
-}
-
-sub GammaToLinear
-{
- local( $gamma ) = shift;
- local( $linear ) = shift;
-
- local( $tmp );
- &AllocateRegister( \$tmp );
-
- ; Is rcp more expensive than just storing 2.2 somewhere and doing a mov?
- rcp $gamma.w, $cOOGamma ; $gamma.w = 2.2
- lit $linear.z, $gamma.zzzw ; r0.z = linear blue
- lit $tmp.z, $gamma.yyyw ; r2.z = linear green
- mov $linear.y, $tmp.z ; r0.y = linear green
- lit $tmp.z, $gamma.xxxw ; r2.z = linear red
- mov $linear.x, $tmp.z ; r0.x = linear red
-
- &FreeRegister( \$tmp );
-}
-
-sub LinearToGamma
-{
- local( $linear ) = shift;
- local( $gamma ) = shift;
-
- local( $tmp );
- &AllocateRegister( \$tmp );
-
- mov $linear.w, $cOOGamma ; $linear.w = 1.0/2.2
- lit $gamma.z, $linear.zzzw ; r0.z = gamma blue
- lit $tmp.z, $linear.yyyw ; r2.z = gamma green
- mov $gamma.y, $tmp.z ; r0.y = gamma green
- lit $tmp.z, $linear.xxxw ; r2.z = gamma red
- mov $gamma.x, $tmp.z ; r0.x = gamma red
-
- &FreeRegister( \$tmp );
-}
-
-sub ComputeReflectionVector
-{
- local( $worldPos ) = shift;
- local( $worldNormal ) = shift;
- local( $reflectionVector ) = shift;
-
- local( $vertToEye ); &AllocateRegister( \$vertToEye );
- local( $tmp ); &AllocateRegister( \$tmp );
-
- ; compute reflection vector r = 2 * (n dot v) n - v
- sub $vertToEye.xyz, $cEyePos.xyz, $worldPos ; $tmp1 = v = c - p
- dp3 $tmp, $worldNormal, $vertToEye ; $tmp = n dot v
- mul $tmp.xyz, $tmp.xyz, $worldNormal ; $tmp = (n dot v ) n
- mad $reflectionVector.xyz, $tmp, $cTwo, -$vertToEye
-
- &FreeRegister( \$vertToEye );
- &FreeRegister( \$tmp );
-}
-
-sub ComputeSphereMapTexCoords
-{
- local( $reflectionVector ) = shift;
- local( $sphereMapTexCoords ) = shift;
-
- local( $tmp ); &AllocateRegister( \$tmp );
-
- ; transform reflection vector into view space
- dp3 $tmp.x, $reflectionVector, $cViewModel0
- dp3 $tmp.y, $reflectionVector, $cViewModel1
- dp3 $tmp.z, $reflectionVector, $cViewModel2
-
- ; generate <rx ry rz+1>
- add $tmp.z, $tmp.z, $cOne
-
- ; find 1 / the length of r2
- dp3 $tmp.w, $tmp, $tmp
- rsq $tmp.w, $tmp.w
-
- ; r1 = r2/|r2| + 1
- mad $tmp.xy, $tmp.w, $tmp, $cOne
- mul $sphereMapTexCoords.xy, $tmp.xy, $cHalf
-
- &FreeRegister( \$tmp );
-}
-
-sub SkinPosition
-{
-# print "\$SKINNING = $SKINNING\n";
- local( $worldPos ) = shift;
-
- if( !defined $SKINNING )
- {
- die "using \$SKINNING without defining.\n";
- }
-
- if( $SKINNING == 0 )
- {
- ;
- ; 0 bone skinning (4 instructions)
- ;
- ; Transform position into world space
- ; position
- dp4 $worldPos.x, $vPos, $cModel0
- dp4 $worldPos.y, $vPos, $cModel1
- dp4 $worldPos.z, $vPos, $cModel2
- mov $worldPos.w, $cOne
- }
- else
- {
- ;
- ; 3 bone skinning (19 instructions)
- ;
- local( $boneIndices );
- local( $blendedMatrix0 );
- local( $blendedMatrix1 );
- local( $blendedMatrix2 );
- local( $localPos );
- &AllocateRegister( \$boneIndices );
- &AllocateRegister( \$blendedMatrix0 );
- &AllocateRegister( \$blendedMatrix1 );
- &AllocateRegister( \$blendedMatrix2 );
-
- ; Transform position into world space using all bones
- ; denormalize d3dcolor to matrix index
- mad $boneIndices, $vBoneIndices, $cColorToIntScale, $cModel0Index
- if ( $g_x360 )
- {
- mov $boneIndices, $boneIndices.zyxw
- }
-
- ; r11 = boneindices at this point
- ; first matrix
- mov a0.x, $boneIndices.z
- mul $blendedMatrix0, $vBoneWeights.x, c[a0.x]
- mul $blendedMatrix1, $vBoneWeights.x, c[a0.x+1]
- mul $blendedMatrix2, $vBoneWeights.x, c[a0.x+2]
- ; second matrix
- mov a0.x, $boneIndices.y
- mad $blendedMatrix0, $vBoneWeights.y, c[a0.x], $blendedMatrix0
- mad $blendedMatrix1, $vBoneWeights.y, c[a0.x+1], $blendedMatrix1
- mad $blendedMatrix2, $vBoneWeights.y, c[a0.x+2], $blendedMatrix2
-
- ; Calculate third weight
- ; compute 1-(weight1+weight2) to calculate weight2
- ; Use $boneIndices.w as a temp since we aren't using it for anything.
- add $boneIndices.w, $vBoneWeights.x, $vBoneWeights.y
- sub $boneIndices.w, $cOne, $boneIndices.w
-
- ; third matrix
- mov a0.x, $boneIndices.x
- mad $blendedMatrix0, $boneIndices.w, c[a0.x], $blendedMatrix0
- mad $blendedMatrix1, $boneIndices.w, c[a0.x+1], $blendedMatrix1
- mad $blendedMatrix2, $boneIndices.w, c[a0.x+2], $blendedMatrix2
-
- dp4 $worldPos.x, $vPos, $blendedMatrix0
- dp4 $worldPos.y, $vPos, $blendedMatrix1
- dp4 $worldPos.z, $vPos, $blendedMatrix2
- mov $worldPos.w, $cOne
-
- &FreeRegister( \$boneIndices );
- &FreeRegister( \$blendedMatrix0 );
- &FreeRegister( \$blendedMatrix1 );
- &FreeRegister( \$blendedMatrix2 );
- }
-}
-
-
-sub SkinPositionAndNormal
-{
-# print "\$SKINNING = $SKINNING\n";
- local( $worldPos ) = shift;
- local( $worldNormal ) = shift;
-
- if( !defined $SKINNING )
- {
- die "using \$SKINNING without defining.\n";
- }
-
- if( $SKINNING == 0 )
- {
- ;
- ; 0 bone skinning (13 instructions)
- ;
- ; Transform position + normal + tangentS + tangentT into world space
- ; position
- dp4 $worldPos.x, $vPos, $cModel0
- dp4 $worldPos.y, $vPos, $cModel1
- dp4 $worldPos.z, $vPos, $cModel2
- mov $worldPos.w, $cOne
- ; normal
- dp3 $worldNormal.x, $vNormal, $cModel0
- dp3 $worldNormal.y, $vNormal, $cModel1
- dp3 $worldNormal.z, $vNormal, $cModel2
- }
- else
- {
- local( $boneIndices );
- local( $blendedMatrix0 );
- local( $blendedMatrix1 );
- local( $blendedMatrix2 );
- local( $localPos );
- local( $localNormal );
- local( $normalLength );
- local( $ooNormalLength );
- &AllocateRegister( \$boneIndices );
- &AllocateRegister( \$blendedMatrix0 );
- &AllocateRegister( \$blendedMatrix1 );
- &AllocateRegister( \$blendedMatrix2 );
-
- ; Transform position into world space using all bones
- ; denormalize d3dcolor to matrix index
- mad $boneIndices, $vBoneIndices, $cColorToIntScale, $cModel0Index
- if ( $g_x360 )
- {
- mov $boneIndices, $boneIndices.zyxw
- }
-
- ; r11 = boneindices at this point
- ; first matrix
- mov a0.x, $boneIndices.z
- mul $blendedMatrix0, $vBoneWeights.x, c[a0.x]
- mul $blendedMatrix1, $vBoneWeights.x, c[a0.x+1]
- mul $blendedMatrix2, $vBoneWeights.x, c[a0.x+2]
- ; second matrix
- mov a0.x, $boneIndices.y
- mad $blendedMatrix0, $vBoneWeights.y, c[a0.x], $blendedMatrix0
- mad $blendedMatrix1, $vBoneWeights.y, c[a0.x+1], $blendedMatrix1
- mad $blendedMatrix2, $vBoneWeights.y, c[a0.x+2], $blendedMatrix2
-
- ; Calculate third weight
- ; compute 1-(weight1+weight2) to calculate weight2
- ; Use $boneIndices.w as a temp since we aren't using it for anything.
- add $boneIndices.w, $vBoneWeights.x, $vBoneWeights.y
- sub $boneIndices.w, $cOne, $boneIndices.w
-
- ; third matrix
- mov a0.x, $boneIndices.x
- mad $blendedMatrix0, $boneIndices.w, c[a0.x], $blendedMatrix0
- mad $blendedMatrix1, $boneIndices.w, c[a0.x+1], $blendedMatrix1
- mad $blendedMatrix2, $boneIndices.w, c[a0.x+2], $blendedMatrix2
-
- dp4 $worldPos.x, $vPos, $blendedMatrix0
- dp4 $worldPos.y, $vPos, $blendedMatrix1
- dp4 $worldPos.z, $vPos, $blendedMatrix2
- mov $worldPos.w, $cOne
-
- ; normal
- dp3 $worldNormal.x, $vNormal, $blendedMatrix0
- dp3 $worldNormal.y, $vNormal, $blendedMatrix1
- dp3 $worldNormal.z, $vNormal, $blendedMatrix2
-
- &FreeRegister( \$boneIndices );
- &FreeRegister( \$blendedMatrix0 );
- &FreeRegister( \$blendedMatrix1 );
- &FreeRegister( \$blendedMatrix2 );
- }
-}
-
-sub SkinPositionNormalAndTangentSpace
-{
-# print "\$SKINNING = $SKINNING\n";
- local( $worldPos ) = shift;
- local( $worldNormal ) = shift;
- local( $worldTangentS ) = shift;
- local( $worldTangentT ) = shift;
- local( $userData );
- local( $localPos );
- local( $localNormal );
- local( $normalLength );
- local( $ooNormalLength );
-
- if( !defined $SKINNING )
- {
- die "using \$SKINNING without defining.\n";
- }
-
-# X360TBD: needed for compressed vertex format
-# if ( $g_x360 )
-# {
-# &AllocateRegister( \$userData );
-# ; remap compressed range [0..1] to [-1..1]
-# mad $userData, $vUserData, $cTwo, -$cOne
-# }
-
- if( $SKINNING == 0 )
- {
- ;
- ; 0 bone skinning (13 instructions)
- ;
- ; Transform position + normal + tangentS + tangentT into world space
- dp4 $worldPos.x, $vPos, $cModel0
- dp4 $worldPos.y, $vPos, $cModel1
- dp4 $worldPos.z, $vPos, $cModel2
- mov $worldPos.w, $cOne
-
- ; normal
- dp3 $worldNormal.x, $vNormal, $cModel0
- dp3 $worldNormal.y, $vNormal, $cModel1
- dp3 $worldNormal.z, $vNormal, $cModel2
-
-# X360TBD: needed for compressed vertex format
-# if ( $g_x360 )
-# {
-# ; tangents
-# dp3 $worldTangentS.x, $userData, $cModel0
-# dp3 $worldTangentS.y, $userData, $cModel1
-# dp3 $worldTangentS.z, $userData, $cModel2
-#
-# ; calculate tangent t via cross( N, S ) * S[3]
-# &Cross( $worldTangentT, $worldNormal, $worldTangentS );
-# mul $worldTangentT.xyz, $userData.w, $worldTangentT.xyz
-# }
-# else
- {
- ; tangents
- dp3 $worldTangentS.x, $vUserData, $cModel0
- dp3 $worldTangentS.y, $vUserData, $cModel1
- dp3 $worldTangentS.z, $vUserData, $cModel2
-
- ; calculate tangent t via cross( N, S ) * S[3]
- &Cross( $worldTangentT, $worldNormal, $worldTangentS );
- mul $worldTangentT.xyz, $vUserData.w, $worldTangentT.xyz
- }
- }
- else
- {
- local( $boneIndices );
- local( $blendedMatrix0 );
- local( $blendedMatrix1 );
- local( $blendedMatrix2 );
- &AllocateRegister( \$boneIndices );
- &AllocateRegister( \$blendedMatrix0 );
- &AllocateRegister( \$blendedMatrix1 );
- &AllocateRegister( \$blendedMatrix2 );
-
- ; Transform position into world space using all bones
- ; denormalize d3dcolor to matrix index
- mad $boneIndices, $vBoneIndices, $cColorToIntScale, $cModel0Index
- if ( $g_x360 )
- {
- mov $boneIndices, $boneIndices.zyxw
- }
-
- ; r11 = boneindices at this point
- ; first matrix
- mov a0.x, $boneIndices.z
- mul $blendedMatrix0, $vBoneWeights.x, c[a0.x]
- mul $blendedMatrix1, $vBoneWeights.x, c[a0.x+1]
- mul $blendedMatrix2, $vBoneWeights.x, c[a0.x+2]
- ; second matrix
- mov a0.x, $boneIndices.y
- mad $blendedMatrix0, $vBoneWeights.y, c[a0.x], $blendedMatrix0
- mad $blendedMatrix1, $vBoneWeights.y, c[a0.x+1], $blendedMatrix1
- mad $blendedMatrix2, $vBoneWeights.y, c[a0.x+2], $blendedMatrix2
-
- ; Calculate third weight
- ; compute 1-(weight1+weight2) to calculate weight2
- ; Use $boneIndices.w as a temp since we aren't using it for anything.
- add $boneIndices.w, $vBoneWeights.x, $vBoneWeights.y
- sub $boneIndices.w, $cOne, $boneIndices.w
-
- ; third matrix
- mov a0.x, $boneIndices.x
- mad $blendedMatrix0, $boneIndices.w, c[a0.x], $blendedMatrix0
- mad $blendedMatrix1, $boneIndices.w, c[a0.x+1], $blendedMatrix1
- mad $blendedMatrix2, $boneIndices.w, c[a0.x+2], $blendedMatrix2
-
- ; position
- dp4 $worldPos.x, $vPos, $blendedMatrix0
- dp4 $worldPos.y, $vPos, $blendedMatrix1
- dp4 $worldPos.z, $vPos, $blendedMatrix2
- mov $worldPos.w, $cOne
-
- ; normal
- dp3 $worldNormal.x, $vNormal, $blendedMatrix0
- dp3 $worldNormal.y, $vNormal, $blendedMatrix1
- dp3 $worldNormal.z, $vNormal, $blendedMatrix2
-
-# X360TBD: needed for compressed vertex format
-# if ( $g_x360 )
-# {
-# ; tangents
-# dp3 $worldTangentS.x, $userData, $blendedMatrix0
-# dp3 $worldTangentS.y, $userData, $blendedMatrix1
-# dp3 $worldTangentS.z, $userData, $blendedMatrix2
-#
-# ; calculate tangent t via cross( N, S ) * S[3]
-# &Cross( $worldTangentT, $worldNormal, $worldTangentS );
-# mul $worldTangentT.xyz, $userData.w, $worldTangentT.xyz
-# }
-# else
- {
- ; tangents
- dp3 $worldTangentS.x, $vUserData, $blendedMatrix0
- dp3 $worldTangentS.y, $vUserData, $blendedMatrix1
- dp3 $worldTangentS.z, $vUserData, $blendedMatrix2
-
- ; calculate tangent t via cross( N, S ) * S[3]
- &Cross( $worldTangentT, $worldNormal, $worldTangentS );
- mul $worldTangentT.xyz, $vUserData.w, $worldTangentT.xyz
- }
-
- &FreeRegister( \$boneIndices );
- &FreeRegister( \$blendedMatrix0 );
- &FreeRegister( \$blendedMatrix1 );
- &FreeRegister( \$blendedMatrix2 );
- }
-
-# X360TBD: needed for compressed vertex format
-# if ( $g_x360 )
-# {
-# &FreeRegister( \$userData );
-# }
-}
-
-sub ColorClamp
-{
- ; ColorClamp; stomps $color.w
- local( $color ) = shift;
- local( $dst ) = shift;
-
- ; Get the max of RGB and stick it in W
- max $color.w, $color.x, $color.y
- max $color.w, $color.w, $color.z
-
- ; get the greater of one and the max color.
- max $color.w, $color.w, $cOne
-
- rcp $color.w, $color.w
- mul $dst.xyz, $color.w, $color.xyz
-}
-
-sub AmbientLight
-{
- local( $worldNormal ) = shift;
- local( $linearColor ) = shift;
- local( $add ) = shift;
-
- ; Ambient lighting
- &AllocateRegister( \$nSquared );
- &AllocateRegister( \$isNegative );
-
- mul $nSquared.xyz, $worldNormal.xyz, $worldNormal.xyz ; compute n times n
- slt $isNegative.xyz, $worldNormal.xyz, $cZero ; Figure out whether each component is >0
- mov a0.x, $isNegative.x
- if( $add )
- {
- mad $linearColor.xyz, $nSquared.x, c[a0.x + $cAmbientColorPosXOffset], $linearColor ; $linearColor = normal[0]*normal[0] * box color of appropriate x side
- }
- else
- {
- mul $linearColor.xyz, $nSquared.x, c[a0.x + $cAmbientColorPosXOffset] ; $linearColor = normal[0]*normal[0] * box color of appropriate x side
- }
- mov a0.x, $isNegative.y
- mad $linearColor.xyz, $nSquared.y, c[a0.x + $cAmbientColorPosYOffset], $linearColor
- mov a0.x, $isNegative.z
- mad $linearColor.xyz, $nSquared.z, c[a0.x + $cAmbientColorPosZOffset], $linearColor
-
- &FreeRegister( \$isNegative );
- &FreeRegister( \$nSquared );
-}
-
-sub DirectionalLight
-{
- local( $worldNormal ) = shift;
- local( $linearColor ) = shift;
- local( $add ) = shift;
-
- &AllocateRegister( \$nDotL ); # FIXME: This only needs to be a scalar
-
- ; NOTE: Gotta use -l here, since light direction = -l
- ; DIRECTIONAL LIGHT
- ; compute n dot l
- dp3 $nDotL.x, -c[a0.x + 1], $worldNormal
-
- if ( $HALF_LAMBERT == 0 )
- {
- ; lambert
- max $nDotL.x, $nDotL.x, c0.x ; Clamp to zero
- }
- elsif ( $HALF_LAMBERT == 1 )
- {
- ; half-lambert
- mad $nDotL.x, $nDotL.x, $cHalf, $cHalf ; dot = (dot * 0.5 + 0.5)^2
- mul $nDotL.x, $nDotL.x, $nDotL.x
- }
- else
- {
- die "\$HALF_LAMBERT is hosed\n";
- }
-
- if( $add )
- {
- mad $linearColor.xyz, c[a0.x], $nDotL.x, $linearColor
- }
- else
- {
- mul $linearColor.xyz, c[a0.x], $nDotL.x
- }
-
- &FreeRegister( \$nDotL );
-}
-
-sub PointLight
-{
- local( $worldPos ) = shift;
- local( $worldNormal ) = shift;
- local( $linearColor ) = shift;
- local( $add ) = shift;
-
- local( $lightDir );
- &AllocateRegister( \$lightDir );
-
- ; POINT LIGHT
- ; compute light direction
- sub $lightDir, c[a0.x+2], $worldPos
-
- local( $lightDistSquared );
- local( $ooLightDist );
- &AllocateRegister( \$lightDistSquared );
- &AllocateRegister( \$ooLightDist );
-
- ; normalize light direction, maintain temporaries for attenuation
- dp3 $lightDistSquared, $lightDir, $lightDir
- rsq $ooLightDist, $lightDistSquared.x
- mul $lightDir, $lightDir, $ooLightDist.x
-
- local( $attenuationFactors );
- &AllocateRegister( \$attenuationFactors );
-
- ; compute attenuation amount (r2 = 'd*d d*d d*d d*d', r3 = '1/d 1/d 1/d 1/d')
- dst $attenuationFactors, $lightDistSquared, $ooLightDist ; r4 = ( 1, d, d*d, 1/d )
- &FreeRegister( \$lightDistSquared );
- &FreeRegister( \$ooLightDist );
- local( $attenuation );
- &AllocateRegister( \$attenuation );
- dp3 $attenuation, $attenuationFactors, c[a0.x+4] ; r3 = atten0 + d * atten1 + d*d * atten2
-
- rcp $lightDir.w, $attenuation ; $lightDir.w = 1 / (atten0 + d * atten1 + d*d * atten2)
-
- &FreeRegister( \$attenuationFactors );
- &FreeRegister( \$attenuation );
-
- local( $tmp );
- &AllocateRegister( \$tmp ); # FIXME : really only needs to be a scalar
-
- ; compute n dot l, fold in distance attenutation
- dp3 $tmp.x, $lightDir, $worldNormal
-
- if ( $HALF_LAMBERT == 0 )
- {
- ; lambert
- max $tmp.x, $tmp.x, c0.x ; Clamp to zero
- }
- elsif ( $HALF_LAMBERT == 1 )
- {
- ; half-lambert
- mad $tmp.x, $tmp.x, $cHalf, $cHalf ; dot = (dot * 0.5 + 0.5)^2
- mul $tmp.x, $tmp.x, $tmp.x
- }
- else
- {
- die "\$HALF_LAMBERT is hosed\n";
- }
-
- mul $tmp.x, $tmp.x, $lightDir.w
- if( $add )
- {
- mad $linearColor.xyz, c[a0.x], $tmp.x, $linearColor
- }
- else
- {
- mul $linearColor.xyz, c[a0.x], $tmp.x
- }
-
- &FreeRegister( \$lightDir );
- &FreeRegister( \$tmp ); # FIXME : really only needs to be a scalar
-}
-
-sub SpotLight
-{
- local( $worldPos ) = shift;
- local( $worldNormal ) = shift;
- local( $linearColor ) = shift;
- local( $add ) = shift;
-
- local( $lightDir );
- &AllocateRegister( \$lightDir );
-
- ; SPOTLIGHT
- ; compute light direction
- sub $lightDir, c[a0.x+2], $worldPos
-
- local( $lightDistSquared );
- local( $ooLightDist );
- &AllocateRegister( \$lightDistSquared );
- &AllocateRegister( \$ooLightDist );
-
- ; normalize light direction, maintain temporaries for attenuation
- dp3 $lightDistSquared, $lightDir, $lightDir
- rsq $ooLightDist, $lightDistSquared.x
- mul $lightDir, $lightDir, $ooLightDist.x
-
- local( $attenuationFactors );
- &AllocateRegister( \$attenuationFactors );
-
- ; compute attenuation amount (r2 = 'd*d d*d d*d d*d', r3 = '1/d 1/d 1/d 1/d')
- dst $attenuationFactors, $lightDistSquared, $ooLightDist ; r4 = ( 1, d, d*d, 1/d )
-
- &FreeRegister( \$lightDistSquared );
- &FreeRegister( \$ooLightDist );
- local( $attenuation ); &AllocateRegister( \$attenuation );
-
- dp3 $attenuation, $attenuationFactors, c[a0.x+4] ; r3 = atten0 + d * atten1 + d*d * atten2
- rcp $lightDir.w, $attenuation ; r1.w = 1 / (atten0 + d * atten1 + d*d * atten2)
-
- &FreeRegister( \$attenuationFactors );
- &FreeRegister( \$attenuation );
-
- local( $litSrc ); &AllocateRegister( \$litSrc );
- local( $tmp ); &AllocateRegister( \$tmp ); # FIXME - only needs to be scalar
-
- ; compute n dot l
- dp3 $litSrc.x, $worldNormal, $lightDir
-
- if ( $HALF_LAMBERT == 0 )
- {
- ; lambert
- max $litSrc.x, $litSrc.x, c0.x ; Clamp to zero
- }
- elsif ( $HALF_LAMBERT == 1 )
- {
- ; half-lambert
- mad $litSrc.x, $litSrc.x, $cHalf, $cHalf ; dot = (dot * 0.5 + 0.5) ^ 2
- mul $litSrc.x, $litSrc.x, $litSrc.x
- }
- else
- {
- die "\$HALF_LAMBERT is hosed\n";
- }
-
- ; compute angular attenuation
- dp3 $tmp.x, c[a0.x+1], -$lightDir ; dot = -delta * spot direction
- sub $litSrc.y, $tmp.x, c[a0.x+3].z ; r2.y = dot - stopdot2
- &FreeRegister( \$tmp );
- mul $litSrc.y, $litSrc.y, c[a0.x+3].w ; r2.y = (dot - stopdot2) / (stopdot - stopdot2)
- mov $litSrc.w, c[a0.x+3].x ; r2.w = exponent
- local( $litDst ); &AllocateRegister( \$litDst );
- lit $litDst, $litSrc ; r3.y = N dot L or 0, whichever is bigger
- &FreeRegister( \$litSrc );
- ; r3.z = pow((dot - stopdot2) / (stopdot - stopdot2), exponent)
- min $litDst.z, $litDst.z, $cOne ; clamp pow() to 1
-
- local( $tmp1 ); &AllocateRegister( \$tmp1 );
- local( $tmp2 ); &AllocateRegister( \$tmp2 ); # FIXME - could be scalar
-
- ; fold in distance attenutation with other factors
- mul $tmp1, c[a0.x], $lightDir.w
- mul $tmp2.x, $litDst.y, $litDst.z
- if( $add )
- {
- mad $linearColor.xyz, $tmp1, $tmp2.x, $linearColor
- }
- else
- {
- mul $linearColor.xyz, $tmp1, $tmp2.x
- }
-
- &FreeRegister( \$lightDir );
- &FreeRegister( \$litDst );
- &FreeRegister( \$tmp1 );
- &FreeRegister( \$tmp2 );
-}
-
-sub DoLight
-{
- local( $lightType ) = shift;
- local( $worldPos ) = shift;
- local( $worldNormal ) = shift;
- local( $linearColor ) = shift;
- local( $add ) = shift;
-
- if( $lightType eq "spot" )
- {
- &SpotLight( $worldPos, $worldNormal, $linearColor, $add );
- }
- elsif( $lightType eq "point" )
- {
- &PointLight( $worldPos, $worldNormal, $linearColor, $add );
- }
- elsif( $lightType eq "directional" )
- {
- &DirectionalLight( $worldNormal, $linearColor, $add );
- }
- else
- {
- die "don't know about light type \"$lightType\"\n";
- }
-}
-
-sub DoLighting
-{
- if( !defined $LIGHT_COMBO )
- {
- die "DoLighting called without using \$LIGHT_COMBO\n";
- }
- if ( !defined $HALF_LAMBERT )
- {
- die "DoLighting called without using \$HALF_LAMBERT\n";
- }
-
- my $staticLightType = $g_staticLightTypeArray[$LIGHT_COMBO];
- my $ambientLightType = $g_ambientLightTypeArray[$LIGHT_COMBO];
- my $localLightType1 = $g_localLightType1Array[$LIGHT_COMBO];
- my $localLightType2 = $g_localLightType2Array[$LIGHT_COMBO];
-
-# print "\$staticLightType = $staticLightType\n";
-# print "\$ambientLightType = $ambientLightType\n";
-# print "\$localLightType1 = $localLightType1\n";
-# print "\$localLightType2 = $localLightType2\n";
-
- local( $worldPos ) = shift;
- local( $worldNormal ) = shift;
-
- ; special case for no lighting
- if( $staticLightType eq "none" && $ambientLightType eq "none" &&
- $localLightType1 eq "none" && $localLightType2 eq "none" )
- {
- ; Have to write something here since debug d3d runtime will barf otherwise.
- mov oD0, $cOne
- return;
- }
-
- ; special case for static lighting only
- ; Don't need to bother converting to linear space in this case.
- if( $staticLightType eq "static" && $ambientLightType eq "none" &&
- $localLightType1 eq "none" && $localLightType2 eq "none" )
- {
- mov oD0, $vSpecular
- return;
- }
-
- alloc $linearColor
- alloc $gammaColor
-
- local( $add ) = 0;
- if( $staticLightType eq "static" )
- {
- ; The static lighting comes in in gamma space and has also been premultiplied by $cOverbrightFactor
- ; need to get it into
- ; linear space so that we can do adds.
- rcp $gammaColor.w, $cOverbrightFactor
- mul $gammaColor.xyz, $vSpecular, $gammaColor.w
- &GammaToLinear( $gammaColor, $linearColor );
- $add = 1;
- }
-
- if( $ambientLightType eq "ambient" )
- {
- &AmbientLight( $worldNormal, $linearColor, $add );
- $add = 1;
- }
-
- if( $localLightType1 ne "none" )
- {
- mov a0.x, $cLight0Offset
- &DoLight( $localLightType1, $worldPos, $worldNormal, $linearColor, $add );
- $add = 1;
- }
-
- if( $localLightType2 ne "none" )
- {
- mov a0.x, $cLight1Offset
- &DoLight( $localLightType2, $worldPos, $worldNormal, $linearColor, $add );
- $add = 1;
- }
-
- ;------------------------------------------------------------------------------
- ; Output color (gamma correction)
- ;------------------------------------------------------------------------------
-
- &LinearToGamma( $linearColor, $gammaColor );
- if( 0 )
- {
- mul oD0.xyz, $gammaColor.xyz, $cOverbrightFactor
- }
- else
- {
- mul $gammaColor.xyz, $gammaColor.xyz, $cOverbrightFactor
- &ColorClamp( $gammaColor, "oD0" );
- }
-
-; mov oD0.xyz, $linearColor
- mov oD0.w, $cOne ; make sure all components are defined
-
- free $linearColor
- free $gammaColor
-}
-
-sub DoDynamicLightingToLinear
-{
- local( $worldPos ) = shift;
- local( $worldNormal ) = shift;
- local( $linearColor ) = shift;
-
- if( !defined $LIGHT_COMBO )
- {
- die "DoLighting called without using \$LIGHT_COMBO\n";
- }
- if ( !defined $HALF_LAMBERT )
- {
- die "DoLighting called without using \$HALF_LAMBERT\n";
- }
-
- my $staticLightType = $g_staticLightTypeArray[$LIGHT_COMBO];
- my $ambientLightType = $g_ambientLightTypeArray[$LIGHT_COMBO];
- my $localLightType1 = $g_localLightType1Array[$LIGHT_COMBO];
- my $localLightType2 = $g_localLightType2Array[$LIGHT_COMBO];
-
- # No lights at all. . note that we don't even consider static lighting here.
- if( $ambientLightType eq "none" &&
- $localLightType1 eq "none" && $localLightType2 eq "none" )
- {
- mov $linearColor, $cZero
- return;
- }
-
- local( $add ) = 0;
- if( $ambientLightType eq "ambient" )
- {
- &AmbientLight( $worldNormal, $linearColor, $add );
- $add = 1;
- }
-
- if( $localLightType1 ne "none" )
- {
- mov a0.x, $cLight0Offset
- &DoLight( $localLightType1, $worldPos, $worldNormal, $linearColor, $add );
- $add = 1;
- }
-
- if( $localLightType2 ne "none" )
- {
- mov a0.x, $cLight1Offset
- &DoLight( $localLightType2, $worldPos, $worldNormal, $linearColor, $add );
- $add = 1;
- }
-}
-
-sub NotImplementedYet
-{
- &AllocateRegister( \$projPos );
- dp4 $projPos.x, $worldPos, $cViewProj0
- dp4 $projPos.y, $worldPos, $cViewProj1
- dp4 $projPos.z, $worldPos, $cViewProj2
- dp4 $projPos.w, $worldPos, $cViewProj3
- mov oPos, $projPos
- &FreeRegister( \$projPos );
- exit;
-}
+;------------------------------------
+; RULES FOR AUTHORING VERTEX SHADERS:
+;------------------------------------
+; - never use "def" . . .set constants in code instead. . our constant shadowing will break otherwise.
+; (same goes for pixel shaders)
+; - use cN notation instead of c[N] notation. .makes grepping for registers easier.
+; The only exception is c[a0.x+blah] where you have no choice.
+$g_NumRegisters = 12;
+
+; NOTE: These must match the same values in vsh_prep.pl!
+$vPos = "v0";
+$vBoneWeights = "v1";
+$vBoneIndices = "v2";
+$vNormal = "v3";
+$vColor = "v5";
+$vSpecular = "v6";
+$vTexCoord0 = "v7";
+$vTexCoord1 = "v8";
+$vTexCoord2 = "v9";
+$vTexCoord3 = "v10";
+$vTangentS = "v11";
+$vTangentT = "v12";
+$vUserData = "v14";
+
+if( $g_dx9 )
+{
+ if( $g_usesPos )
+ {
+ dcl_position $vPos;
+ }
+
+ if( $g_usesBoneWeights )
+ {
+ dcl_blendweight $vBoneWeights;
+ }
+ if( $g_usesBoneIndices )
+ {
+ dcl_blendindices $vBoneIndices;
+ }
+ if( $g_usesNormal )
+ {
+ dcl_normal $vNormal;
+ }
+ if( $g_usesColor )
+ {
+ dcl_color0 $vColor;
+ }
+ if( $g_usesSpecular )
+ {
+ dcl_color1 $vSpecular;
+ }
+ if( $g_usesTexCoord0 )
+ {
+ dcl_texcoord0 $vTexCoord0;
+ }
+ if( $g_usesTexCoord1 )
+ {
+ dcl_texcoord1 $vTexCoord1;
+ }
+ if( $g_usesTexCoord2 )
+ {
+ dcl_texcoord2 $vTexCoord2;
+ }
+ if( $g_usesTexCoord3 )
+ {
+ dcl_texcoord3 $vTexCoord3;
+ }
+ if( $g_usesTangentS )
+ {
+ dcl_tangent $vTangentS;
+ }
+ if( $g_usesTangentT )
+ {
+ dcl_binormal0 $vTangentT;
+ }
+ if( $g_usesUserData )
+ {
+ dcl_tangent $vUserData;
+ }
+}
+
+# NOTE: These should match g_LightCombinations in vertexshaderdx8.cpp!
+# NOTE: Leave this on single lines or shit might blow up.
+@g_staticLightTypeArray = ( "none", "static", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "static", "static", "static", "static", "static", "static", "static", "static", "static", "static" );
+@g_ambientLightTypeArray = ( "none", "none", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient", "ambient" );
+@g_localLightType1Array = ( "none", "none", "none", "spot", "point", "directional", "spot", "spot", "spot", "point", "point", "directional", "none", "spot", "point", "directional", "spot", "spot", "spot", "point", "point", "directional" );
+@g_localLightType2Array = ( "none", "none", "none", "none", "none", "none", "spot", "point", "directional", "point", "directional", "directional", "none", "none", "none", "none", "spot", "point", "directional", "point", "directional", "directional" );
+
+$cConstants0 = "c0";
+$cZero = "c0.x";
+$cOne = "c0.y";
+$cTwo = "c0.z";
+$cHalf = "c0.w";
+
+$cConstants1 = "c1";
+$cOOGamma = "c1.x"; # 1/2.2
+$cOtherOverbrightFactor = "c1.y"; # overbright
+$cOneThird = "c1.z"; # 1/3
+$cOverbrightFactor = "c1.w"; # 1/overbright
+
+$cEyePos = "c2";
+$cWaterZ = "c2.w";
+$cEyePosWaterZ = "c2";
+
+$cLightIndex = "c3";
+$cLight0Offset = "c3.x"; # 27
+$cLight1Offset = "c3.y"; # 32
+$cColorToIntScale = "c3.z"; # matrix array offset = 3.0f * 255.0f + 0.01 (epsilon ensures floor yields desired result)
+$cModel0Index = "c3.w"; # base for start of skinning matrices
+
+; NOTE: These must match the same values in vsh_prep.pl!
+$cModelViewProj0 = "c4";
+$cModelViewProj1 = "c5";
+$cModelViewProj2 = "c6";
+$cModelViewProj3 = "c7";
+
+$cViewProj0 = "c8";
+$cViewProj1 = "c9";
+$cViewProj2 = "c10";
+$cViewProj3 = "c11";
+
+; currently unused
+; c12, c13
+
+$SHADER_SPECIFIC_CONST_10 = "c14";
+$SHADER_SPECIFIC_CONST_11 = "c15";
+
+$cFogParams = "c16";
+$cFogEndOverFogRange = "c16.x";
+$cFogOne = "c16.y";
+$cFogMaxDensity = "c16.z";
+$cOOFogRange = "c16.w"; # (1/(fogEnd-fogStart))
+
+$cViewModel0 = "c17";
+$cViewModel1 = "c18";
+$cViewModel2 = "c19";
+$cViewModel3 = "c20";
+
+$cAmbientColorPosX = "c21";
+$cAmbientColorNegX = "c22";
+$cAmbientColorPosY = "c23";
+$cAmbientColorNegY = "c24";
+$cAmbientColorPosZ = "c25";
+$cAmbientColorNegZ = "c26";
+
+$cAmbientColorPosXOffset = "21";
+$cAmbientColorPosYOffset = "23";
+$cAmbientColorPosZOffset = "25";
+
+$cLight0DiffColor = "c27";
+$cLight0Dir = "c28";
+$cLight0Pos = "c29";
+$cLight0SpotParams = "c30"; # [ exponent, stopdot, stopdot2, 1 / (stopdot - stopdot2)
+$cLight0Atten = "c31"; # [ constant, linear, quadratic, 0.0f ]
+
+$cLight1DiffColor = "c32";
+$cLight1Dir = "c33";
+$cLight1Pos = "c34";
+$cLight1SpotParams = "c35"; # [ exponent, stopdot, stopdot2, 1 / (stopdot - stopdot2)
+$cLight1Atten = "c36"; # [ constant, linear, quadratic, 0.0f ]
+
+$cModulationColor = "c37";
+
+$SHADER_SPECIFIC_CONST_0 = "c38";
+$SHADER_SPECIFIC_CONST_1 = "c39";
+$SHADER_SPECIFIC_CONST_2 = "c40";
+$SHADER_SPECIFIC_CONST_3 = "c41";
+$SHADER_SPECIFIC_CONST_4 = "c42";
+$SHADER_SPECIFIC_CONST_5 = "c43";
+$SHADER_SPECIFIC_CONST_6 = "c44";
+$SHADER_SPECIFIC_CONST_7 = "c45";
+$SHADER_SPECIFIC_CONST_8 = "c46";
+$SHADER_SPECIFIC_CONST_9 = "c47";
+; $SHADER_SPECIFIC_CONST_10 is c14
+; $SHADER_SPECIFIC_CONST_11 is c15
+
+; There are 16 model matrices for skinning
+; NOTE: These must match the same values in vsh_prep.pl!
+$cModel0 = "c48";
+$cModel1 = "c49";
+$cModel2 = "c50";
+
+sub OutputUsedRegisters
+{
+ local( $i );
+ ; USED REGISTERS
+ for( $i = 0; $i < $g_NumRegisters; $i++ )
+ {
+ if( $g_allocated[$i] )
+ {
+ ; $g_allocatedname[$i] = r$i
+ }
+ }
+ ;
+}
+
+sub AllocateRegister
+{
+ local( *reg ) = shift;
+ local( $regname ) = shift;
+ local( $i );
+ for( $i = 0; $i < $g_NumRegisters; $i++ )
+ {
+ if( !$g_allocated[$i] )
+ {
+ $g_allocated[$i] = 1;
+ $g_allocatedname[$i] = $regname;
+ ; AllocateRegister $regname = r$i
+ $reg = "r$i";
+ &OutputUsedRegisters();
+ return;
+ }
+ }
+ ; Out of registers allocating $regname!
+ $reg = "rERROR_OUT_OF_REGISTERS";
+ &OutputUsedRegisters();
+}
+
+; pass in a reference to a var that contains a register. . ie \$var where var will constain "r1", etc
+sub FreeRegister
+{
+ local( *reg ) = shift;
+ local( $regname ) = shift;
+ ; FreeRegister $regname = $reg
+ if( $reg =~ m/rERROR_DEALLOCATED/ )
+ {
+ ; $regname already deallocated
+ ; $reg = "rALREADY_DEALLOCATED";
+ &OutputUsedRegisters();
+ return;
+ }
+; if( $regname ne g_allocatedname[$reg] )
+; {
+; ; Error freeing $reg
+; mov compileerror, freed unallocated register $regname
+; }
+
+ if( ( $reg =~ m/r(.*)/ ) )
+ {
+ $g_allocated[$1] = 0;
+ }
+ $reg = "rERROR_DEALLOCATED";
+ &OutputUsedRegisters();
+}
+
+sub CheckUnfreedRegisters()
+{
+ local( $i );
+ for( $i = 0; $i < $g_NumRegisters; $i++ )
+ {
+ if( $g_allocated[$i] )
+ {
+ print "ERROR: r$i allocated to $g_allocatedname[$i] at end of program\n";
+ $g_allocated[$i] = 0;
+ }
+ }
+}
+
+sub Normalize
+{
+ local( $r ) = shift;
+ dp3 $r.w, $r, $r
+ rsq $r.w, $r.w
+ mul $r, $r, $r.w
+}
+
+sub Cross
+{
+ local( $result ) = shift;
+ local( $a ) = shift;
+ local( $b ) = shift;
+
+ mul $result.xyz, $a.yzx, $b.zxy
+ mad $result.xyz, -$b.yzx, $a.zxy, $result
+}
+
+sub RangeFog
+{
+ local( $projPos ) = shift;
+
+ ;------------------------------
+ ; Regular range fog
+ ;------------------------------
+
+ ; oFog.x = 1.0f = no fog
+ ; oFog.x = 0.0f = full fog
+ ; compute fog factor f = (fog_end - dist)*(1/(fog_end-fog_start))
+ ; this is == to: (fog_end/(fog_end-fog_start) - dist/(fog_end-fog_start)
+ ; which can be expressed with a single mad instruction!
+
+ ; Compute |projPos|
+ local( $tmp );
+ &AllocateRegister( \$tmp );
+ dp3 $tmp.x, $projPos.xyw, $projPos.xyw
+ rsq $tmp.x, $tmp.x
+ rcp $tmp.x, $tmp.x
+
+ if( $g_dx9 )
+ {
+ mad $tmp, -$tmp.x, $cOOFogRange, $cFogEndOverFogRange
+ min $tmp, $tmp, $cOne
+ max oFog, $tmp.x, $cFogMaxDensity
+ }
+ else
+ {
+ mad $tmp, -$tmp.x, $cOOFogRange, $cFogEndOverFogRange
+ min $tmp, $tmp, $cOne
+ max oFog.x, $tmp.x, $cFogMaxDensity
+ }
+ &FreeRegister( \$tmp );
+}
+
+sub DepthFog
+{
+ local( $projPos ) = shift;
+ local( $dest ) = shift;
+
+ if ( $dest eq "" )
+ {
+ $dest = "oFog";
+ }
+
+ ;------------------------------
+ ; Regular range fog
+ ;------------------------------
+
+ ; oFog.x = 1.0f = no fog
+ ; oFog.x = 0.0f = full fog
+ ; compute fog factor f = (fog_end - dist)*(1/(fog_end-fog_start))
+ ; this is == to: (fog_end/(fog_end-fog_start) - dist/(fog_end-fog_start)
+ ; which can be expressed with a single mad instruction!
+
+ ; Compute |projPos|
+ local( $tmp );
+ &AllocateRegister( \$tmp );
+
+ if( $g_dx9 )
+ {
+ mad $tmp, -$projPos.w, $cOOFogRange, $cFogEndOverFogRange
+ min $tmp, $tmp, $cOne
+ max $dest, $tmp.x, $cFogMaxDensity
+ }
+ else
+ {
+ mad $tmp, -$projPos.w, $cOOFogRange, $cFogEndOverFogRange
+ min $tmp, $tmp, $cOne
+ max $dest.x, $tmp.x, $cFogMaxDensity
+ }
+
+ &FreeRegister( \$tmp );
+}
+
+sub WaterRangeFog
+{
+ ; oFog.x = 1.0f = no fog
+ ; oFog.x = 0.0f = full fog
+
+ ; only $worldPos.z is used out of worldPos
+ local( $worldPos ) = shift;
+ local( $projPos ) = shift;
+
+ local( $tmp );
+ &AllocateRegister( \$tmp );
+
+ ; This is simple similar triangles. Imagine a line passing from the point directly vertically
+ ; and another line passing from the point to the eye position.
+ ; Let d = total distance from point to the eye
+ ; Let h = vertical distance from the point to the eye
+ ; Let hw = vertical distance from the point to the water surface
+ ; Let dw = distance from the point to a point on the water surface that lies along the ray from point to eye
+ ; Therefore d/h = dw/hw by similar triangles, or dw = d * hw / h.
+ ; d = |projPos|, h = eyepos.z - worldPos.z, hw = waterheight.z - worldPos.z, dw = what we solve for
+
+ ; Now, tmp.x = hw, and tmp.y = h
+ add $tmp.xy, $cEyePosWaterZ.wz, -$worldPos.z
+
+ ; if $tmp.x < 0, then set it to 0
+ ; This is the equivalent of moving the vert to the water surface if it's above the water surface
+ max $tmp.x, $tmp.x, $cZero
+
+ ; Compute 1 / |projPos| = 1/d
+ dp3 $tmp.z, $projPos.xyw, $projPos.xyw
+ rsq $tmp.z, $tmp.z
+
+ ; Now we have h/d
+ mul $tmp.z, $tmp.z, $tmp.y
+
+ ; Now we have d/h
+ rcp $tmp.w, $tmp.z
+
+ ; We finally have d * hw / h
+ ; $tmp.w is now the distance that we see through water.
+ mul $tmp.w, $tmp.x, $tmp.w
+
+ if( $g_dx9 )
+ {
+ mad $tmp, -$tmp.w, $cOOFogRange, $cFogOne
+ min $tmp, $tmp, $cOne
+ max oFog, $tmp.x, $cFogMaxDensity
+ }
+ else
+ {
+ mad $tmp, -$tmp.w, $cOOFogRange, $cFogOne
+ min $tmp, $tmp, $cOne
+ max oFog.x, $tmp.x, $cFogMaxDensity
+ }
+
+ &FreeRegister( \$tmp );
+}
+
+sub WaterDepthFog
+{
+ ; oFog.x = 1.0f = no fog
+ ; oFog.x = 0.0f = full fog
+
+ ; only $worldPos.z is used out of worldPos
+ local( $worldPos ) = shift;
+ local( $projPos ) = shift;
+ local( $dest ) = shift;
+
+ if ( $dest eq "" )
+ {
+ $dest = "oFog";
+ }
+
+ local( $tmp );
+ &AllocateRegister( \$tmp );
+
+ ; This is simple similar triangles. Imagine a line passing from the point directly vertically
+ ; and another line passing from the point to the eye position.
+ ; Let d = total distance from point to the eye
+ ; Let h = vertical distance from the point to the eye
+ ; Let hw = vertical distance from the point to the water surface
+ ; Let dw = distance from the point to a point on the water surface that lies along the ray from point to eye
+ ; Therefore d/h = dw/hw by similar triangles, or dw = d * hw / h.
+ ; d = projPos.w, h = eyepos.z - worldPos.z, hw = waterheight.z - worldPos.z, dw = what we solve for
+
+ ; Now, tmp.x = hw, and tmp.y = h
+ add $tmp.xy, $cEyePosWaterZ.wz, -$worldPos.z
+
+ ; if $tmp.x < 0, then set it to 0
+ ; This is the equivalent of moving the vert to the water surface if it's above the water surface
+ max $tmp.x, $tmp.x, $cZero
+
+ ; Now we have 1/h
+ rcp $tmp.z, $tmp.y
+
+ ; Now we have d/h
+ mul $tmp.w, $projPos.w, $tmp.z
+
+ ; We finally have d * hw / h
+ ; $tmp.w is now the distance that we see through water.
+ mul $tmp.w, $tmp.x, $tmp.w
+
+ if( $g_dx9 )
+ {
+ mad $tmp, -$tmp.w, $cOOFogRange, $cFogOne
+ min $tmp, $tmp, $cOne
+ max $dest, $tmp.x, $cZero
+ }
+ else
+ {
+ mad $tmp, -$tmp.w, $cOOFogRange, $cFogOne
+ min $tmp, $tmp, $cOne
+ max $dest.x, $tmp.x, $cZero
+ }
+
+ &FreeRegister( \$tmp );
+}
+
+
+;------------------------------------------------------------------------------
+; Main fogging routine
+;------------------------------------------------------------------------------
+sub CalcFog
+{
+ if( !defined $DOWATERFOG )
+ {
+ die "CalcFog called without using \$DOWATERFOG\n";
+ }
+ my $fogType;
+ if( $DOWATERFOG == 0 )
+ {
+ $fogType = "rangefog";
+ }
+ else
+ {
+ $fogType = "heightfog";
+ }
+
+# print "\$fogType = $fogType\n";
+
+ ; CalcFog
+ local( $worldPos ) = shift;
+ local( $projPos ) = shift;
+ local( $dest ) = shift;
+
+ if ( $dest eq "" )
+ {
+ $dest = "oFog";
+ }
+
+ if( $fogType eq "rangefog" )
+ {
+ &DepthFog( $projPos, $dest );
+ }
+ elsif( $fogType eq "heightfog" )
+ {
+ &WaterDepthFog( $worldPos, $projPos, $dest );
+ }
+ else
+ {
+ die;
+ }
+}
+
+sub CalcRangeFog
+{
+ ; CalcFog
+ local( $worldPos ) = shift;
+ local( $projPos ) = shift;
+
+ if( $DOWATERFOG == 0 )
+ {
+ &RangeFog( $projPos );
+ }
+ elsif( $DOWATERFOG == 1 )
+ {
+ &WaterRangeFog( $worldPos, $projPos );
+ }
+ else
+ {
+ die;
+ }
+}
+
+sub GammaToLinear
+{
+ local( $gamma ) = shift;
+ local( $linear ) = shift;
+
+ local( $tmp );
+ &AllocateRegister( \$tmp );
+
+ ; Is rcp more expensive than just storing 2.2 somewhere and doing a mov?
+ rcp $gamma.w, $cOOGamma ; $gamma.w = 2.2
+ lit $linear.z, $gamma.zzzw ; r0.z = linear blue
+ lit $tmp.z, $gamma.yyyw ; r2.z = linear green
+ mov $linear.y, $tmp.z ; r0.y = linear green
+ lit $tmp.z, $gamma.xxxw ; r2.z = linear red
+ mov $linear.x, $tmp.z ; r0.x = linear red
+
+ &FreeRegister( \$tmp );
+}
+
+sub LinearToGamma
+{
+ local( $linear ) = shift;
+ local( $gamma ) = shift;
+
+ local( $tmp );
+ &AllocateRegister( \$tmp );
+
+ mov $linear.w, $cOOGamma ; $linear.w = 1.0/2.2
+ lit $gamma.z, $linear.zzzw ; r0.z = gamma blue
+ lit $tmp.z, $linear.yyyw ; r2.z = gamma green
+ mov $gamma.y, $tmp.z ; r0.y = gamma green
+ lit $tmp.z, $linear.xxxw ; r2.z = gamma red
+ mov $gamma.x, $tmp.z ; r0.x = gamma red
+
+ &FreeRegister( \$tmp );
+}
+
+sub ComputeReflectionVector
+{
+ local( $worldPos ) = shift;
+ local( $worldNormal ) = shift;
+ local( $reflectionVector ) = shift;
+
+ local( $vertToEye ); &AllocateRegister( \$vertToEye );
+ local( $tmp ); &AllocateRegister( \$tmp );
+
+ ; compute reflection vector r = 2 * (n dot v) n - v
+ sub $vertToEye.xyz, $cEyePos.xyz, $worldPos ; $tmp1 = v = c - p
+ dp3 $tmp, $worldNormal, $vertToEye ; $tmp = n dot v
+ mul $tmp.xyz, $tmp.xyz, $worldNormal ; $tmp = (n dot v ) n
+ mad $reflectionVector.xyz, $tmp, $cTwo, -$vertToEye
+
+ &FreeRegister( \$vertToEye );
+ &FreeRegister( \$tmp );
+}
+
+sub ComputeSphereMapTexCoords
+{
+ local( $reflectionVector ) = shift;
+ local( $sphereMapTexCoords ) = shift;
+
+ local( $tmp ); &AllocateRegister( \$tmp );
+
+ ; transform reflection vector into view space
+ dp3 $tmp.x, $reflectionVector, $cViewModel0
+ dp3 $tmp.y, $reflectionVector, $cViewModel1
+ dp3 $tmp.z, $reflectionVector, $cViewModel2
+
+ ; generate <rx ry rz+1>
+ add $tmp.z, $tmp.z, $cOne
+
+ ; find 1 / the length of r2
+ dp3 $tmp.w, $tmp, $tmp
+ rsq $tmp.w, $tmp.w
+
+ ; r1 = r2/|r2| + 1
+ mad $tmp.xy, $tmp.w, $tmp, $cOne
+ mul $sphereMapTexCoords.xy, $tmp.xy, $cHalf
+
+ &FreeRegister( \$tmp );
+}
+
+sub SkinPosition
+{
+# print "\$SKINNING = $SKINNING\n";
+ local( $worldPos ) = shift;
+
+ if( !defined $SKINNING )
+ {
+ die "using \$SKINNING without defining.\n";
+ }
+
+ if( $SKINNING == 0 )
+ {
+ ;
+ ; 0 bone skinning (4 instructions)
+ ;
+ ; Transform position into world space
+ ; position
+ dp4 $worldPos.x, $vPos, $cModel0
+ dp4 $worldPos.y, $vPos, $cModel1
+ dp4 $worldPos.z, $vPos, $cModel2
+ mov $worldPos.w, $cOne
+ }
+ else
+ {
+ ;
+ ; 3 bone skinning (19 instructions)
+ ;
+ local( $boneIndices );
+ local( $blendedMatrix0 );
+ local( $blendedMatrix1 );
+ local( $blendedMatrix2 );
+ local( $localPos );
+ &AllocateRegister( \$boneIndices );
+ &AllocateRegister( \$blendedMatrix0 );
+ &AllocateRegister( \$blendedMatrix1 );
+ &AllocateRegister( \$blendedMatrix2 );
+
+ ; Transform position into world space using all bones
+ ; denormalize d3dcolor to matrix index
+ mad $boneIndices, $vBoneIndices, $cColorToIntScale, $cModel0Index
+ if ( $g_x360 )
+ {
+ mov $boneIndices, $boneIndices.zyxw
+ }
+
+ ; r11 = boneindices at this point
+ ; first matrix
+ mov a0.x, $boneIndices.z
+ mul $blendedMatrix0, $vBoneWeights.x, c[a0.x]
+ mul $blendedMatrix1, $vBoneWeights.x, c[a0.x+1]
+ mul $blendedMatrix2, $vBoneWeights.x, c[a0.x+2]
+ ; second matrix
+ mov a0.x, $boneIndices.y
+ mad $blendedMatrix0, $vBoneWeights.y, c[a0.x], $blendedMatrix0
+ mad $blendedMatrix1, $vBoneWeights.y, c[a0.x+1], $blendedMatrix1
+ mad $blendedMatrix2, $vBoneWeights.y, c[a0.x+2], $blendedMatrix2
+
+ ; Calculate third weight
+ ; compute 1-(weight1+weight2) to calculate weight2
+ ; Use $boneIndices.w as a temp since we aren't using it for anything.
+ add $boneIndices.w, $vBoneWeights.x, $vBoneWeights.y
+ sub $boneIndices.w, $cOne, $boneIndices.w
+
+ ; third matrix
+ mov a0.x, $boneIndices.x
+ mad $blendedMatrix0, $boneIndices.w, c[a0.x], $blendedMatrix0
+ mad $blendedMatrix1, $boneIndices.w, c[a0.x+1], $blendedMatrix1
+ mad $blendedMatrix2, $boneIndices.w, c[a0.x+2], $blendedMatrix2
+
+ dp4 $worldPos.x, $vPos, $blendedMatrix0
+ dp4 $worldPos.y, $vPos, $blendedMatrix1
+ dp4 $worldPos.z, $vPos, $blendedMatrix2
+ mov $worldPos.w, $cOne
+
+ &FreeRegister( \$boneIndices );
+ &FreeRegister( \$blendedMatrix0 );
+ &FreeRegister( \$blendedMatrix1 );
+ &FreeRegister( \$blendedMatrix2 );
+ }
+}
+
+
+sub SkinPositionAndNormal
+{
+# print "\$SKINNING = $SKINNING\n";
+ local( $worldPos ) = shift;
+ local( $worldNormal ) = shift;
+
+ if( !defined $SKINNING )
+ {
+ die "using \$SKINNING without defining.\n";
+ }
+
+ if( $SKINNING == 0 )
+ {
+ ;
+ ; 0 bone skinning (13 instructions)
+ ;
+ ; Transform position + normal + tangentS + tangentT into world space
+ ; position
+ dp4 $worldPos.x, $vPos, $cModel0
+ dp4 $worldPos.y, $vPos, $cModel1
+ dp4 $worldPos.z, $vPos, $cModel2
+ mov $worldPos.w, $cOne
+ ; normal
+ dp3 $worldNormal.x, $vNormal, $cModel0
+ dp3 $worldNormal.y, $vNormal, $cModel1
+ dp3 $worldNormal.z, $vNormal, $cModel2
+ }
+ else
+ {
+ local( $boneIndices );
+ local( $blendedMatrix0 );
+ local( $blendedMatrix1 );
+ local( $blendedMatrix2 );
+ local( $localPos );
+ local( $localNormal );
+ local( $normalLength );
+ local( $ooNormalLength );
+ &AllocateRegister( \$boneIndices );
+ &AllocateRegister( \$blendedMatrix0 );
+ &AllocateRegister( \$blendedMatrix1 );
+ &AllocateRegister( \$blendedMatrix2 );
+
+ ; Transform position into world space using all bones
+ ; denormalize d3dcolor to matrix index
+ mad $boneIndices, $vBoneIndices, $cColorToIntScale, $cModel0Index
+ if ( $g_x360 )
+ {
+ mov $boneIndices, $boneIndices.zyxw
+ }
+
+ ; r11 = boneindices at this point
+ ; first matrix
+ mov a0.x, $boneIndices.z
+ mul $blendedMatrix0, $vBoneWeights.x, c[a0.x]
+ mul $blendedMatrix1, $vBoneWeights.x, c[a0.x+1]
+ mul $blendedMatrix2, $vBoneWeights.x, c[a0.x+2]
+ ; second matrix
+ mov a0.x, $boneIndices.y
+ mad $blendedMatrix0, $vBoneWeights.y, c[a0.x], $blendedMatrix0
+ mad $blendedMatrix1, $vBoneWeights.y, c[a0.x+1], $blendedMatrix1
+ mad $blendedMatrix2, $vBoneWeights.y, c[a0.x+2], $blendedMatrix2
+
+ ; Calculate third weight
+ ; compute 1-(weight1+weight2) to calculate weight2
+ ; Use $boneIndices.w as a temp since we aren't using it for anything.
+ add $boneIndices.w, $vBoneWeights.x, $vBoneWeights.y
+ sub $boneIndices.w, $cOne, $boneIndices.w
+
+ ; third matrix
+ mov a0.x, $boneIndices.x
+ mad $blendedMatrix0, $boneIndices.w, c[a0.x], $blendedMatrix0
+ mad $blendedMatrix1, $boneIndices.w, c[a0.x+1], $blendedMatrix1
+ mad $blendedMatrix2, $boneIndices.w, c[a0.x+2], $blendedMatrix2
+
+ dp4 $worldPos.x, $vPos, $blendedMatrix0
+ dp4 $worldPos.y, $vPos, $blendedMatrix1
+ dp4 $worldPos.z, $vPos, $blendedMatrix2
+ mov $worldPos.w, $cOne
+
+ ; normal
+ dp3 $worldNormal.x, $vNormal, $blendedMatrix0
+ dp3 $worldNormal.y, $vNormal, $blendedMatrix1
+ dp3 $worldNormal.z, $vNormal, $blendedMatrix2
+
+ &FreeRegister( \$boneIndices );
+ &FreeRegister( \$blendedMatrix0 );
+ &FreeRegister( \$blendedMatrix1 );
+ &FreeRegister( \$blendedMatrix2 );
+ }
+}
+
+sub SkinPositionNormalAndTangentSpace
+{
+# print "\$SKINNING = $SKINNING\n";
+ local( $worldPos ) = shift;
+ local( $worldNormal ) = shift;
+ local( $worldTangentS ) = shift;
+ local( $worldTangentT ) = shift;
+ local( $userData );
+ local( $localPos );
+ local( $localNormal );
+ local( $normalLength );
+ local( $ooNormalLength );
+
+ if( !defined $SKINNING )
+ {
+ die "using \$SKINNING without defining.\n";
+ }
+
+# X360TBD: needed for compressed vertex format
+# if ( $g_x360 )
+# {
+# &AllocateRegister( \$userData );
+# ; remap compressed range [0..1] to [-1..1]
+# mad $userData, $vUserData, $cTwo, -$cOne
+# }
+
+ if( $SKINNING == 0 )
+ {
+ ;
+ ; 0 bone skinning (13 instructions)
+ ;
+ ; Transform position + normal + tangentS + tangentT into world space
+ dp4 $worldPos.x, $vPos, $cModel0
+ dp4 $worldPos.y, $vPos, $cModel1
+ dp4 $worldPos.z, $vPos, $cModel2
+ mov $worldPos.w, $cOne
+
+ ; normal
+ dp3 $worldNormal.x, $vNormal, $cModel0
+ dp3 $worldNormal.y, $vNormal, $cModel1
+ dp3 $worldNormal.z, $vNormal, $cModel2
+
+# X360TBD: needed for compressed vertex format
+# if ( $g_x360 )
+# {
+# ; tangents
+# dp3 $worldTangentS.x, $userData, $cModel0
+# dp3 $worldTangentS.y, $userData, $cModel1
+# dp3 $worldTangentS.z, $userData, $cModel2
+#
+# ; calculate tangent t via cross( N, S ) * S[3]
+# &Cross( $worldTangentT, $worldNormal, $worldTangentS );
+# mul $worldTangentT.xyz, $userData.w, $worldTangentT.xyz
+# }
+# else
+ {
+ ; tangents
+ dp3 $worldTangentS.x, $vUserData, $cModel0
+ dp3 $worldTangentS.y, $vUserData, $cModel1
+ dp3 $worldTangentS.z, $vUserData, $cModel2
+
+ ; calculate tangent t via cross( N, S ) * S[3]
+ &Cross( $worldTangentT, $worldNormal, $worldTangentS );
+ mul $worldTangentT.xyz, $vUserData.w, $worldTangentT.xyz
+ }
+ }
+ else
+ {
+ local( $boneIndices );
+ local( $blendedMatrix0 );
+ local( $blendedMatrix1 );
+ local( $blendedMatrix2 );
+ &AllocateRegister( \$boneIndices );
+ &AllocateRegister( \$blendedMatrix0 );
+ &AllocateRegister( \$blendedMatrix1 );
+ &AllocateRegister( \$blendedMatrix2 );
+
+ ; Transform position into world space using all bones
+ ; denormalize d3dcolor to matrix index
+ mad $boneIndices, $vBoneIndices, $cColorToIntScale, $cModel0Index
+ if ( $g_x360 )
+ {
+ mov $boneIndices, $boneIndices.zyxw
+ }
+
+ ; r11 = boneindices at this point
+ ; first matrix
+ mov a0.x, $boneIndices.z
+ mul $blendedMatrix0, $vBoneWeights.x, c[a0.x]
+ mul $blendedMatrix1, $vBoneWeights.x, c[a0.x+1]
+ mul $blendedMatrix2, $vBoneWeights.x, c[a0.x+2]
+ ; second matrix
+ mov a0.x, $boneIndices.y
+ mad $blendedMatrix0, $vBoneWeights.y, c[a0.x], $blendedMatrix0
+ mad $blendedMatrix1, $vBoneWeights.y, c[a0.x+1], $blendedMatrix1
+ mad $blendedMatrix2, $vBoneWeights.y, c[a0.x+2], $blendedMatrix2
+
+ ; Calculate third weight
+ ; compute 1-(weight1+weight2) to calculate weight2
+ ; Use $boneIndices.w as a temp since we aren't using it for anything.
+ add $boneIndices.w, $vBoneWeights.x, $vBoneWeights.y
+ sub $boneIndices.w, $cOne, $boneIndices.w
+
+ ; third matrix
+ mov a0.x, $boneIndices.x
+ mad $blendedMatrix0, $boneIndices.w, c[a0.x], $blendedMatrix0
+ mad $blendedMatrix1, $boneIndices.w, c[a0.x+1], $blendedMatrix1
+ mad $blendedMatrix2, $boneIndices.w, c[a0.x+2], $blendedMatrix2
+
+ ; position
+ dp4 $worldPos.x, $vPos, $blendedMatrix0
+ dp4 $worldPos.y, $vPos, $blendedMatrix1
+ dp4 $worldPos.z, $vPos, $blendedMatrix2
+ mov $worldPos.w, $cOne
+
+ ; normal
+ dp3 $worldNormal.x, $vNormal, $blendedMatrix0
+ dp3 $worldNormal.y, $vNormal, $blendedMatrix1
+ dp3 $worldNormal.z, $vNormal, $blendedMatrix2
+
+# X360TBD: needed for compressed vertex format
+# if ( $g_x360 )
+# {
+# ; tangents
+# dp3 $worldTangentS.x, $userData, $blendedMatrix0
+# dp3 $worldTangentS.y, $userData, $blendedMatrix1
+# dp3 $worldTangentS.z, $userData, $blendedMatrix2
+#
+# ; calculate tangent t via cross( N, S ) * S[3]
+# &Cross( $worldTangentT, $worldNormal, $worldTangentS );
+# mul $worldTangentT.xyz, $userData.w, $worldTangentT.xyz
+# }
+# else
+ {
+ ; tangents
+ dp3 $worldTangentS.x, $vUserData, $blendedMatrix0
+ dp3 $worldTangentS.y, $vUserData, $blendedMatrix1
+ dp3 $worldTangentS.z, $vUserData, $blendedMatrix2
+
+ ; calculate tangent t via cross( N, S ) * S[3]
+ &Cross( $worldTangentT, $worldNormal, $worldTangentS );
+ mul $worldTangentT.xyz, $vUserData.w, $worldTangentT.xyz
+ }
+
+ &FreeRegister( \$boneIndices );
+ &FreeRegister( \$blendedMatrix0 );
+ &FreeRegister( \$blendedMatrix1 );
+ &FreeRegister( \$blendedMatrix2 );
+ }
+
+# X360TBD: needed for compressed vertex format
+# if ( $g_x360 )
+# {
+# &FreeRegister( \$userData );
+# }
+}
+
+sub ColorClamp
+{
+ ; ColorClamp; stomps $color.w
+ local( $color ) = shift;
+ local( $dst ) = shift;
+
+ ; Get the max of RGB and stick it in W
+ max $color.w, $color.x, $color.y
+ max $color.w, $color.w, $color.z
+
+ ; get the greater of one and the max color.
+ max $color.w, $color.w, $cOne
+
+ rcp $color.w, $color.w
+ mul $dst.xyz, $color.w, $color.xyz
+}
+
+sub AmbientLight
+{
+ local( $worldNormal ) = shift;
+ local( $linearColor ) = shift;
+ local( $add ) = shift;
+
+ ; Ambient lighting
+ &AllocateRegister( \$nSquared );
+ &AllocateRegister( \$isNegative );
+
+ mul $nSquared.xyz, $worldNormal.xyz, $worldNormal.xyz ; compute n times n
+ slt $isNegative.xyz, $worldNormal.xyz, $cZero ; Figure out whether each component is >0
+ mov a0.x, $isNegative.x
+ if( $add )
+ {
+ mad $linearColor.xyz, $nSquared.x, c[a0.x + $cAmbientColorPosXOffset], $linearColor ; $linearColor = normal[0]*normal[0] * box color of appropriate x side
+ }
+ else
+ {
+ mul $linearColor.xyz, $nSquared.x, c[a0.x + $cAmbientColorPosXOffset] ; $linearColor = normal[0]*normal[0] * box color of appropriate x side
+ }
+ mov a0.x, $isNegative.y
+ mad $linearColor.xyz, $nSquared.y, c[a0.x + $cAmbientColorPosYOffset], $linearColor
+ mov a0.x, $isNegative.z
+ mad $linearColor.xyz, $nSquared.z, c[a0.x + $cAmbientColorPosZOffset], $linearColor
+
+ &FreeRegister( \$isNegative );
+ &FreeRegister( \$nSquared );
+}
+
+sub DirectionalLight
+{
+ local( $worldNormal ) = shift;
+ local( $linearColor ) = shift;
+ local( $add ) = shift;
+
+ &AllocateRegister( \$nDotL ); # FIXME: This only needs to be a scalar
+
+ ; NOTE: Gotta use -l here, since light direction = -l
+ ; DIRECTIONAL LIGHT
+ ; compute n dot l
+ dp3 $nDotL.x, -c[a0.x + 1], $worldNormal
+
+ if ( $HALF_LAMBERT == 0 )
+ {
+ ; lambert
+ max $nDotL.x, $nDotL.x, c0.x ; Clamp to zero
+ }
+ elsif ( $HALF_LAMBERT == 1 )
+ {
+ ; half-lambert
+ mad $nDotL.x, $nDotL.x, $cHalf, $cHalf ; dot = (dot * 0.5 + 0.5)^2
+ mul $nDotL.x, $nDotL.x, $nDotL.x
+ }
+ else
+ {
+ die "\$HALF_LAMBERT is hosed\n";
+ }
+
+ if( $add )
+ {
+ mad $linearColor.xyz, c[a0.x], $nDotL.x, $linearColor
+ }
+ else
+ {
+ mul $linearColor.xyz, c[a0.x], $nDotL.x
+ }
+
+ &FreeRegister( \$nDotL );
+}
+
+sub PointLight
+{
+ local( $worldPos ) = shift;
+ local( $worldNormal ) = shift;
+ local( $linearColor ) = shift;
+ local( $add ) = shift;
+
+ local( $lightDir );
+ &AllocateRegister( \$lightDir );
+
+ ; POINT LIGHT
+ ; compute light direction
+ sub $lightDir, c[a0.x+2], $worldPos
+
+ local( $lightDistSquared );
+ local( $ooLightDist );
+ &AllocateRegister( \$lightDistSquared );
+ &AllocateRegister( \$ooLightDist );
+
+ ; normalize light direction, maintain temporaries for attenuation
+ dp3 $lightDistSquared, $lightDir, $lightDir
+ rsq $ooLightDist, $lightDistSquared.x
+ mul $lightDir, $lightDir, $ooLightDist.x
+
+ local( $attenuationFactors );
+ &AllocateRegister( \$attenuationFactors );
+
+ ; compute attenuation amount (r2 = 'd*d d*d d*d d*d', r3 = '1/d 1/d 1/d 1/d')
+ dst $attenuationFactors, $lightDistSquared, $ooLightDist ; r4 = ( 1, d, d*d, 1/d )
+ &FreeRegister( \$lightDistSquared );
+ &FreeRegister( \$ooLightDist );
+ local( $attenuation );
+ &AllocateRegister( \$attenuation );
+ dp3 $attenuation, $attenuationFactors, c[a0.x+4] ; r3 = atten0 + d * atten1 + d*d * atten2
+
+ rcp $lightDir.w, $attenuation ; $lightDir.w = 1 / (atten0 + d * atten1 + d*d * atten2)
+
+ &FreeRegister( \$attenuationFactors );
+ &FreeRegister( \$attenuation );
+
+ local( $tmp );
+ &AllocateRegister( \$tmp ); # FIXME : really only needs to be a scalar
+
+ ; compute n dot l, fold in distance attenutation
+ dp3 $tmp.x, $lightDir, $worldNormal
+
+ if ( $HALF_LAMBERT == 0 )
+ {
+ ; lambert
+ max $tmp.x, $tmp.x, c0.x ; Clamp to zero
+ }
+ elsif ( $HALF_LAMBERT == 1 )
+ {
+ ; half-lambert
+ mad $tmp.x, $tmp.x, $cHalf, $cHalf ; dot = (dot * 0.5 + 0.5)^2
+ mul $tmp.x, $tmp.x, $tmp.x
+ }
+ else
+ {
+ die "\$HALF_LAMBERT is hosed\n";
+ }
+
+ mul $tmp.x, $tmp.x, $lightDir.w
+ if( $add )
+ {
+ mad $linearColor.xyz, c[a0.x], $tmp.x, $linearColor
+ }
+ else
+ {
+ mul $linearColor.xyz, c[a0.x], $tmp.x
+ }
+
+ &FreeRegister( \$lightDir );
+ &FreeRegister( \$tmp ); # FIXME : really only needs to be a scalar
+}
+
+sub SpotLight
+{
+ local( $worldPos ) = shift;
+ local( $worldNormal ) = shift;
+ local( $linearColor ) = shift;
+ local( $add ) = shift;
+
+ local( $lightDir );
+ &AllocateRegister( \$lightDir );
+
+ ; SPOTLIGHT
+ ; compute light direction
+ sub $lightDir, c[a0.x+2], $worldPos
+
+ local( $lightDistSquared );
+ local( $ooLightDist );
+ &AllocateRegister( \$lightDistSquared );
+ &AllocateRegister( \$ooLightDist );
+
+ ; normalize light direction, maintain temporaries for attenuation
+ dp3 $lightDistSquared, $lightDir, $lightDir
+ rsq $ooLightDist, $lightDistSquared.x
+ mul $lightDir, $lightDir, $ooLightDist.x
+
+ local( $attenuationFactors );
+ &AllocateRegister( \$attenuationFactors );
+
+ ; compute attenuation amount (r2 = 'd*d d*d d*d d*d', r3 = '1/d 1/d 1/d 1/d')
+ dst $attenuationFactors, $lightDistSquared, $ooLightDist ; r4 = ( 1, d, d*d, 1/d )
+
+ &FreeRegister( \$lightDistSquared );
+ &FreeRegister( \$ooLightDist );
+ local( $attenuation ); &AllocateRegister( \$attenuation );
+
+ dp3 $attenuation, $attenuationFactors, c[a0.x+4] ; r3 = atten0 + d * atten1 + d*d * atten2
+ rcp $lightDir.w, $attenuation ; r1.w = 1 / (atten0 + d * atten1 + d*d * atten2)
+
+ &FreeRegister( \$attenuationFactors );
+ &FreeRegister( \$attenuation );
+
+ local( $litSrc ); &AllocateRegister( \$litSrc );
+ local( $tmp ); &AllocateRegister( \$tmp ); # FIXME - only needs to be scalar
+
+ ; compute n dot l
+ dp3 $litSrc.x, $worldNormal, $lightDir
+
+ if ( $HALF_LAMBERT == 0 )
+ {
+ ; lambert
+ max $litSrc.x, $litSrc.x, c0.x ; Clamp to zero
+ }
+ elsif ( $HALF_LAMBERT == 1 )
+ {
+ ; half-lambert
+ mad $litSrc.x, $litSrc.x, $cHalf, $cHalf ; dot = (dot * 0.5 + 0.5) ^ 2
+ mul $litSrc.x, $litSrc.x, $litSrc.x
+ }
+ else
+ {
+ die "\$HALF_LAMBERT is hosed\n";
+ }
+
+ ; compute angular attenuation
+ dp3 $tmp.x, c[a0.x+1], -$lightDir ; dot = -delta * spot direction
+ sub $litSrc.y, $tmp.x, c[a0.x+3].z ; r2.y = dot - stopdot2
+ &FreeRegister( \$tmp );
+ mul $litSrc.y, $litSrc.y, c[a0.x+3].w ; r2.y = (dot - stopdot2) / (stopdot - stopdot2)
+ mov $litSrc.w, c[a0.x+3].x ; r2.w = exponent
+ local( $litDst ); &AllocateRegister( \$litDst );
+ lit $litDst, $litSrc ; r3.y = N dot L or 0, whichever is bigger
+ &FreeRegister( \$litSrc );
+ ; r3.z = pow((dot - stopdot2) / (stopdot - stopdot2), exponent)
+ min $litDst.z, $litDst.z, $cOne ; clamp pow() to 1
+
+ local( $tmp1 ); &AllocateRegister( \$tmp1 );
+ local( $tmp2 ); &AllocateRegister( \$tmp2 ); # FIXME - could be scalar
+
+ ; fold in distance attenutation with other factors
+ mul $tmp1, c[a0.x], $lightDir.w
+ mul $tmp2.x, $litDst.y, $litDst.z
+ if( $add )
+ {
+ mad $linearColor.xyz, $tmp1, $tmp2.x, $linearColor
+ }
+ else
+ {
+ mul $linearColor.xyz, $tmp1, $tmp2.x
+ }
+
+ &FreeRegister( \$lightDir );
+ &FreeRegister( \$litDst );
+ &FreeRegister( \$tmp1 );
+ &FreeRegister( \$tmp2 );
+}
+
+sub DoLight
+{
+ local( $lightType ) = shift;
+ local( $worldPos ) = shift;
+ local( $worldNormal ) = shift;
+ local( $linearColor ) = shift;
+ local( $add ) = shift;
+
+ if( $lightType eq "spot" )
+ {
+ &SpotLight( $worldPos, $worldNormal, $linearColor, $add );
+ }
+ elsif( $lightType eq "point" )
+ {
+ &PointLight( $worldPos, $worldNormal, $linearColor, $add );
+ }
+ elsif( $lightType eq "directional" )
+ {
+ &DirectionalLight( $worldNormal, $linearColor, $add );
+ }
+ else
+ {
+ die "don't know about light type \"$lightType\"\n";
+ }
+}
+
+sub DoLighting
+{
+ if( !defined $LIGHT_COMBO )
+ {
+ die "DoLighting called without using \$LIGHT_COMBO\n";
+ }
+ if ( !defined $HALF_LAMBERT )
+ {
+ die "DoLighting called without using \$HALF_LAMBERT\n";
+ }
+
+ my $staticLightType = $g_staticLightTypeArray[$LIGHT_COMBO];
+ my $ambientLightType = $g_ambientLightTypeArray[$LIGHT_COMBO];
+ my $localLightType1 = $g_localLightType1Array[$LIGHT_COMBO];
+ my $localLightType2 = $g_localLightType2Array[$LIGHT_COMBO];
+
+# print "\$staticLightType = $staticLightType\n";
+# print "\$ambientLightType = $ambientLightType\n";
+# print "\$localLightType1 = $localLightType1\n";
+# print "\$localLightType2 = $localLightType2\n";
+
+ local( $worldPos ) = shift;
+ local( $worldNormal ) = shift;
+
+ ; special case for no lighting
+ if( $staticLightType eq "none" && $ambientLightType eq "none" &&
+ $localLightType1 eq "none" && $localLightType2 eq "none" )
+ {
+ ; Have to write something here since debug d3d runtime will barf otherwise.
+ mov oD0, $cOne
+ return;
+ }
+
+ ; special case for static lighting only
+ ; Don't need to bother converting to linear space in this case.
+ if( $staticLightType eq "static" && $ambientLightType eq "none" &&
+ $localLightType1 eq "none" && $localLightType2 eq "none" )
+ {
+ mov oD0, $vSpecular
+ return;
+ }
+
+ alloc $linearColor
+ alloc $gammaColor
+
+ local( $add ) = 0;
+ if( $staticLightType eq "static" )
+ {
+ ; The static lighting comes in in gamma space and has also been premultiplied by $cOverbrightFactor
+ ; need to get it into
+ ; linear space so that we can do adds.
+ rcp $gammaColor.w, $cOverbrightFactor
+ mul $gammaColor.xyz, $vSpecular, $gammaColor.w
+ &GammaToLinear( $gammaColor, $linearColor );
+ $add = 1;
+ }
+
+ if( $ambientLightType eq "ambient" )
+ {
+ &AmbientLight( $worldNormal, $linearColor, $add );
+ $add = 1;
+ }
+
+ if( $localLightType1 ne "none" )
+ {
+ mov a0.x, $cLight0Offset
+ &DoLight( $localLightType1, $worldPos, $worldNormal, $linearColor, $add );
+ $add = 1;
+ }
+
+ if( $localLightType2 ne "none" )
+ {
+ mov a0.x, $cLight1Offset
+ &DoLight( $localLightType2, $worldPos, $worldNormal, $linearColor, $add );
+ $add = 1;
+ }
+
+ ;------------------------------------------------------------------------------
+ ; Output color (gamma correction)
+ ;------------------------------------------------------------------------------
+
+ &LinearToGamma( $linearColor, $gammaColor );
+ if( 0 )
+ {
+ mul oD0.xyz, $gammaColor.xyz, $cOverbrightFactor
+ }
+ else
+ {
+ mul $gammaColor.xyz, $gammaColor.xyz, $cOverbrightFactor
+ &ColorClamp( $gammaColor, "oD0" );
+ }
+
+; mov oD0.xyz, $linearColor
+ mov oD0.w, $cOne ; make sure all components are defined
+
+ free $linearColor
+ free $gammaColor
+}
+
+sub DoDynamicLightingToLinear
+{
+ local( $worldPos ) = shift;
+ local( $worldNormal ) = shift;
+ local( $linearColor ) = shift;
+
+ if( !defined $LIGHT_COMBO )
+ {
+ die "DoLighting called without using \$LIGHT_COMBO\n";
+ }
+ if ( !defined $HALF_LAMBERT )
+ {
+ die "DoLighting called without using \$HALF_LAMBERT\n";
+ }
+
+ my $staticLightType = $g_staticLightTypeArray[$LIGHT_COMBO];
+ my $ambientLightType = $g_ambientLightTypeArray[$LIGHT_COMBO];
+ my $localLightType1 = $g_localLightType1Array[$LIGHT_COMBO];
+ my $localLightType2 = $g_localLightType2Array[$LIGHT_COMBO];
+
+ # No lights at all. . note that we don't even consider static lighting here.
+ if( $ambientLightType eq "none" &&
+ $localLightType1 eq "none" && $localLightType2 eq "none" )
+ {
+ mov $linearColor, $cZero
+ return;
+ }
+
+ local( $add ) = 0;
+ if( $ambientLightType eq "ambient" )
+ {
+ &AmbientLight( $worldNormal, $linearColor, $add );
+ $add = 1;
+ }
+
+ if( $localLightType1 ne "none" )
+ {
+ mov a0.x, $cLight0Offset
+ &DoLight( $localLightType1, $worldPos, $worldNormal, $linearColor, $add );
+ $add = 1;
+ }
+
+ if( $localLightType2 ne "none" )
+ {
+ mov a0.x, $cLight1Offset
+ &DoLight( $localLightType2, $worldPos, $worldNormal, $linearColor, $add );
+ $add = 1;
+ }
+}
+
+sub NotImplementedYet
+{
+ &AllocateRegister( \$projPos );
+ dp4 $projPos.x, $worldPos, $cViewProj0
+ dp4 $projPos.y, $worldPos, $cViewProj1
+ dp4 $projPos.z, $worldPos, $cViewProj2
+ dp4 $projPos.w, $worldPos, $cViewProj3
+ mov oPos, $projPos
+ &FreeRegister( \$projPos );
+ exit;
+}
diff --git a/mp/src/materialsystem/stdshaders/stdshader_dx9_20b.txt b/mp/src/materialsystem/stdshaders/stdshader_dx9_20b.txt
index 8ebd79dd..a24577ec 100644
--- a/mp/src/materialsystem/stdshaders/stdshader_dx9_20b.txt
+++ b/mp/src/materialsystem/stdshaders/stdshader_dx9_20b.txt
@@ -1,16 +1,16 @@
-//
-// Standard shaders collection
-//
-// These shaders are compiled as the following shader models:
-// _ps20.vcs
-// _ps20b.vcs
-// _vs20.vcs
-//
-
-example_model_ps20b.fxc
-example_model_vs20.fxc
-
-SDK_Bloom_ps2x.fxc
-SDK_screenspaceeffect_vs20.fxc
-
-SDK_bloomadd_ps2x.fxc
+//
+// Standard shaders collection
+//
+// These shaders are compiled as the following shader models:
+// _ps20.vcs
+// _ps20b.vcs
+// _vs20.vcs
+//
+
+example_model_ps20b.fxc
+example_model_vs20.fxc
+
+SDK_Bloom_ps2x.fxc
+SDK_screenspaceeffect_vs20.fxc
+
+SDK_bloomadd_ps2x.fxc
diff --git a/mp/src/materialsystem/stdshaders/stdshader_dx9_30.txt b/mp/src/materialsystem/stdshaders/stdshader_dx9_30.txt
index 5a09a37b..071b6a1a 100644
--- a/mp/src/materialsystem/stdshaders/stdshader_dx9_30.txt
+++ b/mp/src/materialsystem/stdshaders/stdshader_dx9_30.txt
@@ -1,10 +1,10 @@
-//
-// vs 3.0 ps 3.0 shaders collection
-//
-// These shaders are forced to compile as shader model 3.0
-// using the new compiler.
-// _ps30.vcs
-// _vs30.vcs
-//
-
-// There are no examples of such shaders in the SDK, but add yours here.
+//
+// vs 3.0 ps 3.0 shaders collection
+//
+// These shaders are forced to compile as shader model 3.0
+// using the new compiler.
+// _ps30.vcs
+// _vs30.vcs
+//
+
+// There are no examples of such shaders in the SDK, but add yours here.