From cbb5010c64512ffc5402d36527563e8421c96009 Mon Sep 17 00:00:00 2001 From: "ALLEN-PC\\acj30" Date: Tue, 17 Jun 2025 12:26:53 -0500 Subject: [PATCH] Merge Mapbase shaders with TF2 SDK shaders --- src/createshadersprojects.bat | 2 +- src/createshadersprojects_hl2.bat | 2 +- .../stdshaders/BaseVSShader.cpp | 8 + src/materialsystem/stdshaders/BaseVSShader.h | 8 + src/materialsystem/stdshaders/BlurFilterY.cpp | 2 +- ...seTimesLightmapAlphaBlendSelfIllum_dx9.cpp | 3 + .../stdshaders/DecalModulate_dx9.cpp | 190 +++-- .../stdshaders/Engine_Post_dx9.cpp | 537 +++++++++++-- .../stdshaders/Engine_Post_ps2x.fxc | 667 ++++++++-------- .../stdshaders/ShatteredGlass_ps2x.fxc | 41 +- .../stdshaders/WorldVertexTransition_vs20.fxc | 2 +- .../stdshaders/blurgaussian_3x3_ps2x.fxc | 22 + .../stdshaders/buildmapbaseshaders.bat | 14 + .../buildmapbaseshaders_dynamic.bat | 5 + .../stdshaders/common_flashlight_fxc.h | 219 ++++-- src/materialsystem/stdshaders/common_ps_fxc.h | 28 +- .../stdshaders/common_splinerope_fxc.h | 26 + src/materialsystem/stdshaders/core_dx9.cpp | 9 + src/materialsystem/stdshaders/core_ps2x.fxc | 16 +- .../stdshaders/decalmodulate_ps2x.fxc | 88 ++- .../stdshaders/decalmodulate_vs20.fxc | 155 ++++ .../stdshaders/depth_of_field_ps20b.fxc | 137 ++++ .../stdshaders/depth_of_field_vs20.fxc | 29 + .../stdshaders/depthoffield_dx9.cpp | 280 +++++++ src/materialsystem/stdshaders/depthwrite.cpp | 16 + .../stdshaders/eye_refract_helper.cpp | 2 +- .../stdshaders/flashlight_ps2x.fxc | 9 +- .../stdshaders/include/Bloom_ps20b.inc | 62 +- .../stdshaders/include/BlurFilter_ps20b.inc | 85 +- .../stdshaders/include/BlurFilter_vs20.inc | 31 +- .../include/ShatteredGlass_ps20b.inc | 263 +++---- .../include/ShatteredGlass_vs20.inc | 81 +- .../include/WorldTwoTextureBlend_ps20b.inc | 377 +++------ .../stdshaders/include/bloomadd_ps20b.inc | 37 +- .../include/cloak_blended_pass_ps20b.inc | 85 +- .../include/cloak_blended_pass_ps30.inc | 85 +- .../include/cloak_blended_pass_vs20.inc | 103 +-- .../include/cloak_blended_pass_vs30.inc | 125 +-- .../stdshaders/include/core_ps20b.inc | 182 ++--- .../stdshaders/include/core_vs20.inc | 103 +-- .../include/decalmodulate_ps20b.inc | 77 +- .../stdshaders/include/decalmodulate_ps30.inc | 77 +- .../stdshaders/include/decalmodulate_vs20.inc | 124 +++ .../stdshaders/include/decalmodulate_vs30.inc | 137 ++++ .../stdshaders/include/depthwrite_ps20b.inc | 78 +- .../stdshaders/include/depthwrite_ps30.inc | 78 +- .../stdshaders/include/depthwrite_vs20.inc | 147 ++-- .../stdshaders/include/depthwrite_vs30.inc | 169 ++-- .../emissive_scroll_blended_pass_ps20b.inc | 62 +- .../emissive_scroll_blended_pass_ps30.inc | 62 +- .../emissive_scroll_blended_pass_vs20.inc | 78 +- .../emissive_scroll_blended_pass_vs30.inc | 100 +-- .../stdshaders/include/engine_post_ps20b.inc | 348 +++++---- .../stdshaders/include/eyeglint_ps20b.inc | 28 +- .../stdshaders/include/eyeglint_vs20.inc | 31 +- .../stdshaders/include/flashlight_ps20b.inc | 254 +++--- .../flesh_interior_blended_pass_ps20b.inc | 62 +- .../flesh_interior_blended_pass_vs20.inc | 214 ++--- .../lightmappedgeneric_flashlight_ps20b.inc | 242 ++++++ .../lightmappedgeneric_flashlight_ps30.inc | 242 ++++++ .../lightmappedgeneric_flashlight_vs20.inc | 175 ++--- .../lightmappedgeneric_flashlight_vs30.inc | 143 ++++ .../include/lightmappedgeneric_ps20b.inc | 38 +- .../include/lightmappedgeneric_ps30.inc | 555 +++++++++++++ .../include/lightmappedgeneric_vs20.inc | 21 +- .../include/lightmappedgeneric_vs30.inc | 226 ++++++ .../include/lightmappedreflective_ps20b.inc | 198 ++--- .../include/lightmappedreflective_vs20.inc | 56 +- .../include/monitorscreen_ps20b.inc | 143 ++-- .../include/screenspaceeffect_vs20.inc | 56 +- .../stdshaders/include/skin_ps20b.inc | 34 +- .../stdshaders/include/skin_ps30.inc | 34 +- .../stdshaders/include/splinerope_ps20.inc | 137 ++++ .../stdshaders/include/splinerope_ps20b.inc | 104 +++ .../stdshaders/include/splinerope_vs20.inc | 54 ++ .../stdshaders/include/unlitgeneric_ps20b.inc | 62 +- .../stdshaders/include/unlitgeneric_vs20.inc | 125 +-- .../include/unlittwotexture_ps20b.inc | 153 ++-- .../include/unlittwotexture_vs20.inc | 100 +-- ...vertexlit_and_unlit_generic_bump_ps20b.inc | 23 +- .../vertexlit_and_unlit_generic_bump_ps30.inc | 23 +- .../vertexlit_and_unlit_generic_ps20b.inc | 26 +- .../vertexlit_and_unlit_generic_ps30.inc | 29 +- .../stdshaders/include/vortwarp_ps20b.inc | 340 +++----- .../stdshaders/include/vortwarp_ps30.inc | 340 +++----- .../stdshaders/include/vortwarp_vs20.inc | 172 ++-- .../stdshaders/include/vortwarp_vs30.inc | 149 ++-- .../include/windowimposter_ps20b.inc | 22 +- .../include/windowimposter_vs20.inc | 22 +- .../stdshaders/lightmappedgeneric_dx9.cpp | 35 + .../lightmappedgeneric_dx9_helper.cpp | 733 +++++++++++++++++- .../lightmappedgeneric_dx9_helper.h | 50 ++ .../lightmappedgeneric_flashlight_ps2x.fxc | 330 ++++++++ .../lightmappedgeneric_flashlight_vs20.fxc | 41 +- .../stdshaders/lightmappedgeneric_ps2_3_x.h | 102 ++- .../stdshaders/lightmappedgeneric_ps2x.fxc | 21 +- .../stdshaders/lightmappedgeneric_vs20.fxc | 32 +- .../stdshaders/mapbase_sdk_stubs.cpp | 1 + .../stdshaders/mapbaseshaders_dx9_20b.txt | 121 +++ .../stdshaders/mapbaseshaders_dx9_30.txt | 41 + .../stdshaders/monitorscreen_ps2x.fxc | 8 +- .../stdshaders/refract_dx9_helper.cpp | 13 + .../stdshaders/shatteredglass.cpp | 65 ++ .../stdshaders/skin_dx9_helper.cpp | 61 +- src/materialsystem/stdshaders/skin_ps20b.fxc | 73 +- src/materialsystem/stdshaders/spline_fxc.h | 19 + src/materialsystem/stdshaders/splinerope.cpp | 169 ++++ .../stdshaders/splinerope_ps2x.fxc | 52 ++ .../stdshaders/splinerope_vs20.fxc | 78 ++ .../stdshaders/stdshader_dx9_30.txt | 2 + .../stdshaders/stdshader_dx9_inc.vpc | 8 +- src/materialsystem/stdshaders/teeth.cpp | 13 +- .../stdshaders/teeth_bump_vs20.fxc | 6 +- .../stdshaders/unlitgeneric_dx9.cpp | 51 ++ .../stdshaders/unlittwotexture_dx9.cpp | 6 + .../stdshaders/unlittwotexture_ps2x.fxc | 45 +- .../stdshaders/unlittwotexture_vs20.fxc | 39 +- .../vertexlit_and_unlit_generic_bump_ps2x.fxc | 22 + .../vertexlit_and_unlit_generic_bump_vs20.fxc | 4 +- .../vertexlit_and_unlit_generic_ps2x.fxc | 31 +- .../vertexlit_and_unlit_generic_vs20.fxc | 26 +- .../stdshaders/vertexlitgeneric_dx9.cpp | 20 + .../vertexlitgeneric_dx9_helper.cpp | 114 ++- .../stdshaders/vertexlitgeneric_dx9_helper.h | 15 + src/materialsystem/stdshaders/water.cpp | 13 + .../stdshaders/windowimposter_dx90.cpp | 78 +- .../stdshaders/windowimposter_ps2x.fxc | 37 +- .../stdshaders/windowimposter_vs20.fxc | 20 +- .../stdshaders/worldtwotextureblend.cpp | 3 + .../stdshaders/worldvertextransition.cpp | 39 + 130 files changed, 8661 insertions(+), 4282 deletions(-) create mode 100644 src/materialsystem/stdshaders/blurgaussian_3x3_ps2x.fxc create mode 100644 src/materialsystem/stdshaders/buildmapbaseshaders.bat create mode 100644 src/materialsystem/stdshaders/buildmapbaseshaders_dynamic.bat create mode 100644 src/materialsystem/stdshaders/common_splinerope_fxc.h create mode 100644 src/materialsystem/stdshaders/decalmodulate_vs20.fxc create mode 100644 src/materialsystem/stdshaders/depth_of_field_ps20b.fxc create mode 100644 src/materialsystem/stdshaders/depth_of_field_vs20.fxc create mode 100644 src/materialsystem/stdshaders/depthoffield_dx9.cpp create mode 100644 src/materialsystem/stdshaders/include/decalmodulate_vs20.inc create mode 100644 src/materialsystem/stdshaders/include/decalmodulate_vs30.inc create mode 100644 src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_ps20b.inc create mode 100644 src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_ps30.inc create mode 100644 src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_vs30.inc create mode 100644 src/materialsystem/stdshaders/include/lightmappedgeneric_ps30.inc create mode 100644 src/materialsystem/stdshaders/include/lightmappedgeneric_vs30.inc create mode 100644 src/materialsystem/stdshaders/include/splinerope_ps20.inc create mode 100644 src/materialsystem/stdshaders/include/splinerope_ps20b.inc create mode 100644 src/materialsystem/stdshaders/include/splinerope_vs20.inc create mode 100644 src/materialsystem/stdshaders/lightmappedgeneric_flashlight_ps2x.fxc create mode 100644 src/materialsystem/stdshaders/mapbaseshaders_dx9_20b.txt create mode 100644 src/materialsystem/stdshaders/mapbaseshaders_dx9_30.txt create mode 100644 src/materialsystem/stdshaders/spline_fxc.h create mode 100644 src/materialsystem/stdshaders/splinerope.cpp create mode 100644 src/materialsystem/stdshaders/splinerope_ps2x.fxc create mode 100644 src/materialsystem/stdshaders/splinerope_vs20.fxc diff --git a/src/createshadersprojects.bat b/src/createshadersprojects.bat index 3b55e13f..62b3a04f 100644 --- a/src/createshadersprojects.bat +++ b/src/createshadersprojects.bat @@ -1 +1 @@ -devtools\bin\vpc.exe /hl2mp /tf +shaders /mksln shaders.sln +devtools\bin\vpc.exe /hl2mp /tf /define:SOURCESDK +shaders /mksln shaders.sln diff --git a/src/createshadersprojects_hl2.bat b/src/createshadersprojects_hl2.bat index 43569ae5..ed7f1e75 100644 --- a/src/createshadersprojects_hl2.bat +++ b/src/createshadersprojects_hl2.bat @@ -1 +1 @@ -devtools\bin\vpc.exe /hl2 /episodic +shaders /mksln shaders.sln +devtools\bin\vpc.exe /hl2 /episodic /define:SOURCESDK +shaders /mksln shaders.sln diff --git a/src/materialsystem/stdshaders/BaseVSShader.cpp b/src/materialsystem/stdshaders/BaseVSShader.cpp index 184d2ea0..8cb6a4ac 100644 --- a/src/materialsystem/stdshaders/BaseVSShader.cpp +++ b/src/materialsystem/stdshaders/BaseVSShader.cpp @@ -49,6 +49,14 @@ static ConVar mat_fullbright( "mat_fullbright","0", FCVAR_CHEAT ); +#ifdef MAPBASE +// This constant should change with each Mapbase update +ConVar mapbase_version_shaders( "mapbase_version_shaders", MAPBASE_VERSION, FCVAR_NONE, "The version of Mapbase currently being used in this mod's game_shader_dx9.dll" ); + +ConVar mat_specular_disable_on_missing( "mat_specular_disable_on_missing", "1", FCVAR_ARCHIVE, "Disables specular reflections on a material when the envmap cannot be found." ); +#endif + + // These functions are to be called from the shaders. //----------------------------------------------------------------------------- diff --git a/src/materialsystem/stdshaders/BaseVSShader.h b/src/materialsystem/stdshaders/BaseVSShader.h index 860c6876..523c9ef2 100644 --- a/src/materialsystem/stdshaders/BaseVSShader.h +++ b/src/materialsystem/stdshaders/BaseVSShader.h @@ -25,6 +25,11 @@ #define SUPPORT_DX8 1 #define SUPPORT_DX7 1 #endif + +#ifdef MAPBASE +extern ConVar mat_specular_disable_on_missing; +#endif + //----------------------------------------------------------------------------- // Helper macro for vertex shaders //----------------------------------------------------------------------------- @@ -297,6 +302,9 @@ public: int m_nFlashlightTextureFrameVar; int m_nBaseTexture2Var; int m_nBaseTexture2FrameVar; +#ifdef MAPBASE + int m_nBaseTexture2TransformVar; +#endif int m_nBumpmap2Var; int m_nBumpmap2Frame; int m_nBump2Transform; diff --git a/src/materialsystem/stdshaders/BlurFilterY.cpp b/src/materialsystem/stdshaders/BlurFilterY.cpp index 57db29c0..f252fea5 100644 --- a/src/materialsystem/stdshaders/BlurFilterY.cpp +++ b/src/materialsystem/stdshaders/BlurFilterY.cpp @@ -85,7 +85,7 @@ BEGIN_VS_SHADER_FLAGS( BlurFilterY, "Help for BlurFilterY", SHADER_NOT_EDITABLE // The temp buffer is 1/4 back buffer size ITexture *src_texture = params[BASETEXTURE]->GetTextureValue(); - int height = src_texture->GetActualWidth(); + int height = src_texture->GetActualHeight(); float dY = 1.0f / height; // dY *= 0.4; float v[4]; diff --git a/src/materialsystem/stdshaders/DecalBaseTimesLightmapAlphaBlendSelfIllum_dx9.cpp b/src/materialsystem/stdshaders/DecalBaseTimesLightmapAlphaBlendSelfIllum_dx9.cpp index da99062c..ad57b243 100644 --- a/src/materialsystem/stdshaders/DecalBaseTimesLightmapAlphaBlendSelfIllum_dx9.cpp +++ b/src/materialsystem/stdshaders/DecalBaseTimesLightmapAlphaBlendSelfIllum_dx9.cpp @@ -176,6 +176,9 @@ BEGIN_VS_SHADER( DecalBaseTimesLightmapAlphaBlendSelfIllum_DX9, "" ) SET_STATIC_VERTEX_SHADER_COMBO( BUMPMASK, false ); #ifdef _X360 SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, 0 ); +#endif +#ifdef MAPBASE + SET_STATIC_VERTEX_SHADER_COMBO( BASETEXTURETRANSFORM2, false ); #endif SET_STATIC_VERTEX_SHADER( lightmappedgeneric_vs20 ); diff --git a/src/materialsystem/stdshaders/DecalModulate_dx9.cpp b/src/materialsystem/stdshaders/DecalModulate_dx9.cpp index 8e90c056..9fd3d313 100644 --- a/src/materialsystem/stdshaders/DecalModulate_dx9.cpp +++ b/src/materialsystem/stdshaders/DecalModulate_dx9.cpp @@ -9,12 +9,12 @@ #include "BaseVSShader.h" #include "cpp_shader_constant_register_map.h" -#include "VertexLit_and_unlit_Generic_vs20.inc" +#include "decalmodulate_vs20.inc" #include "decalmodulate_ps20.inc" #include "decalmodulate_ps20b.inc" #ifndef _X360 -#include "vertexlit_and_unlit_generic_vs30.inc" +#include "decalmodulate_vs30.inc" #include "decalmodulate_ps30.inc" #endif @@ -25,10 +25,18 @@ DEFINE_FALLBACK_SHADER( DecalModulate, DecalModulate_DX9 ) extern ConVar r_flashlight_version2; +#ifdef MAPBASE +ConVar mat_decalmodulate_flashdraw( "mat_decalmodulate_flashdraw", "0" ); +#endif + BEGIN_VS_SHADER( DecalModulate_dx9, "Help for DecalModulate_dx9" ) BEGIN_SHADER_PARAMS +#ifdef MAPBASE + SHADER_PARAM( FOGEXPONENT, SHADER_PARAM_TYPE_FLOAT, "0.4", "exponent to tweak fog fade" ) + SHADER_PARAM( FOGSCALE, SHADER_PARAM_TYPE_FLOAT, "1.0", "scale to tweak fog fade" ) +#endif END_SHADER_PARAMS SHADER_FALLBACK @@ -40,6 +48,18 @@ BEGIN_VS_SHADER( DecalModulate_dx9, SHADER_INIT_PARAMS() { +#ifdef MAPBASE + if( !params[ FOGEXPONENT ]->IsDefined() ) + { + params[ FOGEXPONENT ]->SetFloatValue( 0.4f ); + } + + if( !params[ FOGSCALE ]->IsDefined() ) + { + params[ FOGSCALE ]->SetFloatValue( 1.0f ); + } +#endif + SET_FLAGS( MATERIAL_VAR_NO_DEBUG_OVERRIDE ); #ifndef _X360 @@ -59,6 +79,14 @@ BEGIN_VS_SHADER( DecalModulate_dx9, SHADER_DRAW { +#ifdef MAPBASE + // It is now believed the decals not appearing is a sorting issue. + // The flashlight part is transparent and overlaid on top of the decal. + // When a fix is found, this flashlight code could be removed. + bool bHasFlashlight = UsingFlashlight( params ); + if (bHasFlashlight && !mat_decalmodulate_flashdraw.GetBool()) + return; +#endif SHADOW_STATE { pShaderShadow->EnableAlphaTest( true ); @@ -79,28 +107,47 @@ BEGIN_VS_SHADER( DecalModulate_dx9, pShaderShadow->DisableFogGammaCorrection( true ); //fog should stay exactly middle grey FogToGrey(); +#ifdef MAPBASE + int userDataSize = 0; + int nShadowFilterMode = 0; + if ( bHasFlashlight ) + { + pShaderShadow->EnableTexture( SHADER_SAMPLER8, true ); // Depth texture + pShaderShadow->SetShadowDepthFiltering( SHADER_SAMPLER8 ); + pShaderShadow->EnableTexture( SHADER_SAMPLER6, true ); // Noise map + pShaderShadow->EnableTexture( SHADER_SAMPLER7, true ); // Flashlight cookie + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER7, true ); + userDataSize = 4; // tangent S + + if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + nShadowFilterMode = g_pHardwareConfig->GetShadowFilterMode(); // Based upon vendor and device dependent formats + } + } +#endif + + bool bHasVertexAlpha = IS_FLAG_SET( MATERIAL_VAR_VERTEXCOLOR ) && IS_FLAG_SET( MATERIAL_VAR_VERTEXALPHA ); + #ifndef _X360 if ( !g_pHardwareConfig->HasFastVertexTextures() ) #endif { - bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); - - DECLARE_STATIC_VERTEX_SHADER( vertexlit_and_unlit_generic_vs20 ); - SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, false ); - SET_STATIC_VERTEX_SHADER_COMBO( CUBEMAP, false ); - SET_STATIC_VERTEX_SHADER_COMBO( HALFLAMBERT, false ); - SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, false ); - SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS_BASE, false ); - SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS_DETAIL, false ); - SET_STATIC_VERTEX_SHADER_COMBO( SEPARATE_DETAIL_UVS, false ); - SET_STATIC_VERTEX_SHADER_COMBO( USE_STATIC_CONTROL_FLOW, bUseStaticControlFlow ); - SET_STATIC_VERTEX_SHADER_COMBO( DONT_GAMMA_CONVERT_VERTEX_COLOR, 0 ); - SET_STATIC_VERTEX_SHADER_COMBO( TREESWAY, 0 ); - SET_STATIC_VERTEX_SHADER( vertexlit_and_unlit_generic_vs20 ); + DECLARE_STATIC_VERTEX_SHADER( decalmodulate_vs20 ); + SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, bHasVertexAlpha ); + SET_STATIC_VERTEX_SHADER_COMBO( LIGHTING_PREVIEW, false ); +#ifdef MAPBASE + SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); +#endif + SET_STATIC_VERTEX_SHADER( decalmodulate_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { DECLARE_STATIC_PIXEL_SHADER( decalmodulate_ps20b ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( VERTEXALPHA, bHasVertexAlpha ); + SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); + SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); +#endif SET_STATIC_PIXEL_SHADER( decalmodulate_ps20b ); } else @@ -112,33 +159,38 @@ BEGIN_VS_SHADER( DecalModulate_dx9, #ifndef _X360 else { - DECLARE_STATIC_VERTEX_SHADER( vertexlit_and_unlit_generic_vs30 ); - SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, false ); - SET_STATIC_VERTEX_SHADER_COMBO( CUBEMAP, false ); - SET_STATIC_VERTEX_SHADER_COMBO( HALFLAMBERT, false ); - SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, false ); - SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS_BASE, false ); - SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS_DETAIL, false ); - SET_STATIC_VERTEX_SHADER_COMBO( SEPARATE_DETAIL_UVS, false ); - SET_STATIC_VERTEX_SHADER_COMBO( DECAL, true ); - SET_STATIC_VERTEX_SHADER_COMBO( DONT_GAMMA_CONVERT_VERTEX_COLOR, 0 ); - SET_STATIC_VERTEX_SHADER_COMBO( TREESWAY, 0 ); - SET_STATIC_VERTEX_SHADER( vertexlit_and_unlit_generic_vs30 ); + DECLARE_STATIC_VERTEX_SHADER( decalmodulate_vs30 ); + SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, bHasVertexAlpha ); + SET_STATIC_VERTEX_SHADER_COMBO( LIGHTING_PREVIEW, false ); +#ifdef MAPBASE + SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); +#endif + SET_STATIC_VERTEX_SHADER( decalmodulate_vs30 ); DECLARE_STATIC_PIXEL_SHADER( decalmodulate_ps30 ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( VERTEXALPHA, bHasVertexAlpha ); + SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bHasFlashlight ); + SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); +#endif SET_STATIC_PIXEL_SHADER( decalmodulate_ps30 ); } #endif // Set stream format (note that this shader supports compression) unsigned int flags = VERTEX_POSITION | VERTEX_FORMAT_COMPRESSED; + + if ( bHasVertexAlpha ) + { + flags |= VERTEX_COLOR; + } + #ifndef _X360 // The VS30 shader offsets decals along the normal (for morphed geom) flags |= g_pHardwareConfig->HasFastVertexTextures() ? VERTEX_NORMAL : 0; #endif int pTexCoordDim[3] = { 2, 0, 3 }; int nTexCoordCount = 1; - int userDataSize = 0; #ifndef _X360 if ( g_pHardwareConfig->HasFastVertexTextures() ) @@ -151,12 +203,50 @@ BEGIN_VS_SHADER( DecalModulate_dx9, } DYNAMIC_STATE { +#ifdef MAPBASE // This fixes blood decals, etc. not showing up under flashlights. + //bHasFlashlight = pShaderAPI->InFlashlightMode(); + bool bFlashlightShadows = false; + if ( bHasFlashlight ) + { + VMatrix worldToTexture; + ITexture *pFlashlightDepthTexture; + FlashlightState_t state = pShaderAPI->GetFlashlightStateEx( worldToTexture, &pFlashlightDepthTexture ); + bFlashlightShadows = state.m_bEnableShadows && ( pFlashlightDepthTexture != NULL ); + + if( pFlashlightDepthTexture && g_pConfig->ShadowDepthTexture() && state.m_bEnableShadows ) + { + BindTexture( SHADER_SAMPLER8, pFlashlightDepthTexture, 0 ); + pShaderAPI->BindStandardTexture( SHADER_SAMPLER6, TEXTURE_SHADOW_NOISE_2D ); + } + + SetFlashLightColorFromState( state, pShaderAPI, 28 ); + + Assert( state.m_pSpotlightTexture && state.m_nSpotlightTextureFrame >= 0 ); + BindTexture( SHADER_SAMPLER7, state.m_pSpotlightTexture, state.m_nSpotlightTextureFrame ); + + float atten_pos[8]; + atten_pos[0] = state.m_fConstantAtten; // Set the flashlight attenuation factors + atten_pos[1] = state.m_fLinearAtten; + atten_pos[2] = state.m_fQuadraticAtten; + atten_pos[3] = state.m_FarZ; + atten_pos[4] = state.m_vecLightOrigin[0]; // Set the flashlight origin + atten_pos[5] = state.m_vecLightOrigin[1]; + atten_pos[6] = state.m_vecLightOrigin[2]; + atten_pos[7] = 1.0f; + pShaderAPI->SetPixelShaderConstant( 22, atten_pos, 2 ); + + pShaderAPI->SetPixelShaderConstant( 24, worldToTexture.Base(), 4 ); + } + + //if ( pShaderAPI->InFlashlightMode() && mat_decalmodulate_noflashdraw.GetBool() ) +#else if ( pShaderAPI->InFlashlightMode() && ( !IsX360() && ( r_flashlight_version2.GetInt() == 0 ) ) ) { // Don't draw anything for the flashlight pass Draw( false ); return; } +#endif BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME ); @@ -166,9 +256,6 @@ BEGIN_VS_SHADER( DecalModulate_dx9, transformation[1].Init( 0.0f, 1.0f, 0.0f, 0.0f ); pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, transformation[0].Base(), 2 ); - MaterialFogMode_t fogType = s_pShaderAPI->GetSceneFogMode(); - int fogIndex = ( fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ) ? 1 : 0; - pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS ); float vEyePos_SpecExponent[4]; @@ -176,25 +263,32 @@ BEGIN_VS_SHADER( DecalModulate_dx9, vEyePos_SpecExponent[3] = 0.0f; pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 ); + // fog tweaks + float fConsts[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + fConsts[0] = params[ FOGEXPONENT ]->GetFloatValue(); + fConsts[1] = params[ FOGSCALE ]->GetFloatValue(); + pShaderAPI->SetPixelShaderConstant( 0, fConsts ); + + MaterialFogMode_t fogType = s_pShaderAPI->GetSceneFogMode(); + #ifndef _X360 if ( !g_pHardwareConfig->HasFastVertexTextures() ) #endif { - DECLARE_DYNAMIC_VERTEX_SHADER( vertexlit_and_unlit_generic_vs20 ); - SET_DYNAMIC_VERTEX_SHADER_COMBO( DYNAMIC_LIGHT, 0 ); // Use simplest possible vertex lighting, since ps is so simple - SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT_VERTEX, 0 ); // - SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT_LIGHTMAP, 0); // - SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogIndex ); + DECLARE_DYNAMIC_VERTEX_SHADER( decalmodulate_vs20 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, 0 ); - SET_DYNAMIC_VERTEX_SHADER_COMBO( LIGHTING_PREVIEW, 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); - SET_DYNAMIC_VERTEX_SHADER_COMBO( NUM_LIGHTS, 0 ); - SET_DYNAMIC_VERTEX_SHADER( vertexlit_and_unlit_generic_vs20 ); +// SET_DYNAMIC_VERTEX_SHADER_COMBO( TESSELLATION, 0 ); // JasonM TODO: set this appropriately when we care about decals on subds + SET_DYNAMIC_VERTEX_SHADER( decalmodulate_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { DECLARE_DYNAMIC_PIXEL_SHADER( decalmodulate_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo1( true ) ); +#ifdef MAPBASE + SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows ); +#endif SET_DYNAMIC_PIXEL_SHADER( decalmodulate_ps20b ); } else @@ -209,19 +303,19 @@ BEGIN_VS_SHADER( DecalModulate_dx9, { SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, SHADER_VERTEXTEXTURE_SAMPLER0 ); - DECLARE_DYNAMIC_VERTEX_SHADER( vertexlit_and_unlit_generic_vs30 ); - SET_DYNAMIC_VERTEX_SHADER_COMBO( DYNAMIC_LIGHT, 0 ); // Use simplest possible vertex lighting, since ps is so simple - SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT_VERTEX, 0 ); // - SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT_LIGHTMAP, 0); // - SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogIndex ); + DECLARE_DYNAMIC_VERTEX_SHADER( decalmodulate_vs30 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); - SET_DYNAMIC_VERTEX_SHADER_COMBO( LIGHTING_PREVIEW, 0 ); - SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); - SET_DYNAMIC_VERTEX_SHADER( vertexlit_and_unlit_generic_vs30 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() ); +// SET_DYNAMIC_VERTEX_SHADER_COMBO( TESSELLATION, 0 ); // JasonM TODO: set this appropriately when we care about decals on subds + SET_DYNAMIC_VERTEX_SHADER( decalmodulate_vs30 ); DECLARE_DYNAMIC_PIXEL_SHADER( decalmodulate_ps30 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo1( true ) ); +#ifdef MAPBASE + SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows ); +#endif SET_DYNAMIC_PIXEL_SHADER( decalmodulate_ps30 ); bool bUnusedTexCoords[3] = { false, false, !pShaderAPI->IsHWMorphingEnabled() }; diff --git a/src/materialsystem/stdshaders/Engine_Post_dx9.cpp b/src/materialsystem/stdshaders/Engine_Post_dx9.cpp index 66a290f7..20663918 100644 --- a/src/materialsystem/stdshaders/Engine_Post_dx9.cpp +++ b/src/materialsystem/stdshaders/Engine_Post_dx9.cpp @@ -8,11 +8,20 @@ #include "BaseVSShader.h" #include "screenspaceeffect_vs20.inc" -#include "engine_post_ps20.inc" #include "engine_post_ps20b.inc" -#include "../materialsystem_global.h" +// NOTE: This has to be the last file included! +#include "tier0/memdbgon.h" +ConVar mat_screen_blur_override( "mat_screen_blur_override", "-1.0" ); +ConVar mat_depth_blur_focal_distance_override( "mat_depth_blur_focal_distance_override", "-1.0" ); +ConVar mat_depth_blur_strength_override( "mat_depth_blur_strength_override", "-1.0" ); +ConVar mat_grain_scale_override( "mat_grain_scale_override", "-1.0" ); +ConVar mat_local_contrast_scale_override( "mat_local_contrast_scale_override", "0.0" ); +ConVar mat_local_contrast_midtone_mask_override( "mat_local_contrast_midtone_mask_override", "-1.0" ); +ConVar mat_local_contrast_vignette_start_override( "mat_local_contrast_vignette_start_override", "-1.0" ); +ConVar mat_local_contrast_vignette_end_override( "mat_local_contrast_vignette_end_override", "-1.0" ); +ConVar mat_local_contrast_edge_scale_override( "mat_local_contrast_edge_scale_override", "-1000.0" ); DEFINE_FALLBACK_SHADER( Engine_Post, Engine_Post_dx9 ) BEGIN_VS_SHADER_FLAGS( Engine_Post_dx9, "Engine post-processing effects (software anti-aliasing, bloom, color-correction", SHADER_NOT_EDITABLE ) @@ -23,30 +32,210 @@ BEGIN_VS_SHADER_FLAGS( Engine_Post_dx9, "Engine post-processing effects (softwar SHADER_PARAM( AAINTERNAL2, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "Internal anti-aliasing values set via material proxy" ) SHADER_PARAM( AAINTERNAL3, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "Internal anti-aliasing values set via material proxy" ) SHADER_PARAM( BLOOMENABLE, SHADER_PARAM_TYPE_BOOL, "1", "Enable bloom" ) + SHADER_PARAM( BLOOMAMOUNT, SHADER_PARAM_TYPE_FLOAT, "1.0", "Bloom scale factor" ) + SHADER_PARAM( SCREENEFFECTTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "used for paint or vomit screen effect" ) + SHADER_PARAM( DEPTHBLURENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Inexpensive depth-of-field substitute" ) + + SHADER_PARAM( ALLOWVIGNETTE, SHADER_PARAM_TYPE_BOOL, "0", "Allow vignette" ) + SHADER_PARAM( VIGNETTEENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable vignette" ) + SHADER_PARAM( INTERNAL_VIGNETTETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "dev/vignette", "" ) + + SHADER_PARAM( ALLOWNOISE, SHADER_PARAM_TYPE_BOOL, "0", "Allow noise" ) + SHADER_PARAM( NOISEENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable noise" ) + SHADER_PARAM( NOISESCALE, SHADER_PARAM_TYPE_FLOAT, "0", "Noise scale" ) + SHADER_PARAM( NOISETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Noise texture" ) + + SHADER_PARAM( ALLOWLOCALCONTRAST, SHADER_PARAM_TYPE_BOOL, "0", "Enable local contrast enhancement" ) + SHADER_PARAM( LOCALCONTRASTENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable local contrast enhancement" ) + SHADER_PARAM( LOCALCONTRASTSCALE, SHADER_PARAM_TYPE_FLOAT, "0", "Local contrast scale" ) + SHADER_PARAM( LOCALCONTRASTMIDTONEMASK, SHADER_PARAM_TYPE_FLOAT, "0", "Local contrast midtone mask" ) + SHADER_PARAM( LOCALCONTRASTVIGNETTESTART, SHADER_PARAM_TYPE_BOOL, "0", "Enable local contrast enhancement" ) + SHADER_PARAM( LOCALCONTRASTVIGNETTEEND, SHADER_PARAM_TYPE_FLOAT, "0", "Local contrast scale" ) + SHADER_PARAM( LOCALCONTRASTEDGESCALE, SHADER_PARAM_TYPE_FLOAT, "0", "Local contrast midtone mask" ) + + SHADER_PARAM( BLURREDVIGNETTEENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable blurred vignette" ) + SHADER_PARAM( BLURREDVIGNETTESCALE, SHADER_PARAM_TYPE_FLOAT, "0", "blurred vignette strength" ) + SHADER_PARAM( FADETOBLACKSCALE, SHADER_PARAM_TYPE_FLOAT, "0", "fade strength" ) + + SHADER_PARAM( DEPTHBLURFOCALDISTANCE, SHADER_PARAM_TYPE_FLOAT, "0", "Distance in dest-alpha space [0,1] of focal plane." ) + SHADER_PARAM( DEPTHBLURSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0", "Strength of depth-blur effect" ) + SHADER_PARAM( SCREENBLURSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0", "Full-screen blur factor" ) + + SHADER_PARAM( VOMITCOLOR1, SHADER_PARAM_TYPE_VEC3, "[0 0 0 0]", "1st vomit blend color" ) + SHADER_PARAM( VOMITCOLOR2, SHADER_PARAM_TYPE_VEC3, "[0 0 0 0]", "2st vomit blend color" ) + SHADER_PARAM( VOMITREFRACTSCALE, SHADER_PARAM_TYPE_FLOAT, "0.15", "vomit refract strength" ) + SHADER_PARAM( VOMITENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable vomit refract" ) + + SHADER_PARAM( FADECOLOR, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "viewfade color" ) + SHADER_PARAM( FADE, SHADER_PARAM_TYPE_INTEGER, "0", "fade type. 0 = off, 1 = lerp, 2 = modulate" ) + + SHADER_PARAM( TV_GAMMA, SHADER_PARAM_TYPE_INTEGER, "0", "0 default, 1 used for laying off 360 movies" ) + SHADER_PARAM( DESATURATEENABLE, SHADER_PARAM_TYPE_INTEGER, "0", "Desaturate with math, turns off color correction" ) + SHADER_PARAM( DESATURATION, SHADER_PARAM_TYPE_FLOAT, "0", "Desaturation Amount" ) + + // Tool color correction setup + SHADER_PARAM( TOOLMODE, SHADER_PARAM_TYPE_BOOL, "1", "tool mode" ) + SHADER_PARAM( TOOLCOLORCORRECTION, SHADER_PARAM_TYPE_FLOAT, "1", "tool color correction override" ) + SHADER_PARAM( WEIGHT_DEFAULT, SHADER_PARAM_TYPE_FLOAT, "1", "weight default" ) + SHADER_PARAM( WEIGHT0, SHADER_PARAM_TYPE_FLOAT, "1", "weight0" ) + SHADER_PARAM( WEIGHT1, SHADER_PARAM_TYPE_FLOAT, "1", "weight1" ) + SHADER_PARAM( WEIGHT2, SHADER_PARAM_TYPE_FLOAT, "1", "weight2" ) + SHADER_PARAM( WEIGHT3, SHADER_PARAM_TYPE_FLOAT, "1", "weight3" ) + SHADER_PARAM( NUM_LOOKUPS, SHADER_PARAM_TYPE_FLOAT, "0", "num_lookups" ) + SHADER_PARAM( TOOLTIME, SHADER_PARAM_TYPE_FLOAT, "0", "tooltime" ) END_SHADER_PARAMS SHADER_INIT_PARAMS() { - if( !params[ AAENABLE ]->IsDefined() ) + if ( !params[ INTERNAL_VIGNETTETEXTURE ]->IsDefined() ) + { + params[ INTERNAL_VIGNETTETEXTURE ]->SetStringValue( "dev/vignette" ); + } + if ( !params[ AAENABLE ]->IsDefined() ) { params[ AAENABLE ]->SetIntValue( 0 ); } - if( !params[ AAINTERNAL1 ]->IsDefined() ) + if ( !params[ AAINTERNAL1 ]->IsDefined() ) { params[ AAINTERNAL1 ]->SetVecValue( 0, 0, 0, 0 ); } - if( !params[ AAINTERNAL2 ]->IsDefined() ) + if ( !params[ AAINTERNAL2 ]->IsDefined() ) { params[ AAINTERNAL2 ]->SetVecValue( 0, 0, 0, 0 ); } - if( !params[ AAINTERNAL3 ]->IsDefined() ) + if ( !params[ AAINTERNAL3 ]->IsDefined() ) { params[ AAINTERNAL3 ]->SetVecValue( 0, 0, 0, 0 ); } - if( !params[ BLOOMENABLE ]->IsDefined() ) + if ( !params[ BLOOMENABLE ]->IsDefined() ) { params[ BLOOMENABLE ]->SetIntValue( 1 ); } + if ( !params[ BLOOMAMOUNT ]->IsDefined() ) + { + params[ BLOOMAMOUNT ]->SetFloatValue( 1.0f ); + } + if ( !params[ DEPTHBLURENABLE ]->IsDefined() ) + { + params[ DEPTHBLURENABLE ]->SetIntValue( 0 ); + } + if ( !params[ ALLOWNOISE ]->IsDefined() ) + { + params[ ALLOWNOISE ]->SetIntValue( 1 ); + } + if ( !params[ NOISESCALE ]->IsDefined() ) + { + params[ NOISESCALE ]->SetFloatValue( 1.0f ); + } + if ( !params[ NOISEENABLE ]->IsDefined() ) + { + params[ NOISEENABLE ]->SetIntValue( 0 ); + } + if ( !params[ ALLOWVIGNETTE ]->IsDefined() ) + { + params[ ALLOWVIGNETTE ]->SetIntValue( 1 ); + } + if ( !params[ VIGNETTEENABLE ]->IsDefined() ) + { + params[ VIGNETTEENABLE ]->SetIntValue( 0 ); + } + if ( !params[ ALLOWLOCALCONTRAST ]->IsDefined() ) + { + params[ ALLOWLOCALCONTRAST ]->SetIntValue( 1 ); + } + if ( !params[ LOCALCONTRASTSCALE ]->IsDefined() ) + { + params[ LOCALCONTRASTSCALE ]->SetFloatValue( 1.0f ); + } + if ( !params[ LOCALCONTRASTMIDTONEMASK ]->IsDefined() ) + { + params[ LOCALCONTRASTMIDTONEMASK ]->SetFloatValue( 1000.0f ); + } + if ( !params[ LOCALCONTRASTENABLE ]->IsDefined() ) + { + params[ LOCALCONTRASTENABLE ]->SetIntValue( 0 ); + } + if ( !params[ LOCALCONTRASTVIGNETTESTART ]->IsDefined() ) + { + params[ LOCALCONTRASTVIGNETTESTART ]->SetFloatValue( 0.7f ); + } + if ( !params[ LOCALCONTRASTVIGNETTEEND ]->IsDefined() ) + { + params[ LOCALCONTRASTVIGNETTEEND ]->SetFloatValue( 1.0f ); + } + if ( !params[ LOCALCONTRASTEDGESCALE ]->IsDefined() ) + { + params[ LOCALCONTRASTEDGESCALE ]->SetFloatValue( 0.0f ); + } + if ( !params[ BLURREDVIGNETTEENABLE ]->IsDefined() ) + { + params[ BLURREDVIGNETTEENABLE ]->SetIntValue( 0 ); + } + if ( !params[ BLURREDVIGNETTESCALE ]->IsDefined() ) + { + params[ BLURREDVIGNETTESCALE ]->SetFloatValue( 0.0f ); + } + if ( !params[ FADETOBLACKSCALE ]->IsDefined() ) + { + params[ FADETOBLACKSCALE ]->SetFloatValue( 0.0f ); + } + if ( !params[ DEPTHBLURFOCALDISTANCE ]->IsDefined() ) + { + params[ DEPTHBLURFOCALDISTANCE ]->SetFloatValue( 0.0f ); + } + if ( !params[ DEPTHBLURSTRENGTH ]->IsDefined() ) + { + params[ DEPTHBLURSTRENGTH ]->SetFloatValue( 0.0f ); + } + if ( !params[ SCREENBLURSTRENGTH ]->IsDefined() ) + { + params[ SCREENBLURSTRENGTH ]->SetFloatValue( 0.0f ); + } + if ( !params[ TOOLMODE ]->IsDefined() ) + { + params[ TOOLMODE ]->SetIntValue( 0 ); + } + if ( !params[ TOOLCOLORCORRECTION ]->IsDefined() ) + { + params[ TOOLCOLORCORRECTION ]->SetFloatValue( 0.0f ); + } + if ( !params[ VOMITENABLE ]->IsDefined() ) + { + params[ VOMITENABLE ]->SetIntValue( 0 ); + } + if ( !params[ VOMITREFRACTSCALE ]->IsDefined() ) + { + params[ VOMITREFRACTSCALE ]->SetFloatValue( 0.15f ); + } + if ( !params[ VOMITCOLOR1 ]->IsDefined() ) + { + params[ VOMITCOLOR1 ]->SetVecValue( 1.0, 1.0, 0.0 ); + } + if ( !params[ VOMITCOLOR2 ]->IsDefined() ) + { + params[ VOMITCOLOR2 ]->SetVecValue( 0.0, 1.0, 0.0 ); + } + if ( !params[ FADE ]->IsDefined() ) + { + params[ FADE ]->SetIntValue( 0 ); + } + if ( !params[ FADECOLOR ]->IsDefined() ) + { + params[ FADECOLOR ]->SetVecValue( 0.0f, 0.0f, 0.0f, 0.0f ); + } + if ( !params[ TV_GAMMA ]->IsDefined() ) + { + params[ TV_GAMMA ]->SetIntValue( 0 ); + } + if ( !params[ DESATURATEENABLE ]->IsDefined() ) + { + params[ DESATURATEENABLE ]->SetIntValue( 0 ); + } + if ( !params[ DESATURATION ]->IsDefined() ) + { + params[ DESATURATION ]->SetFloatValue( 0.0f ); + } + SET_FLAGS2( MATERIAL_VAR2_NEEDS_FULL_FRAME_BUFFER_TEXTURE ); } @@ -62,14 +251,33 @@ BEGIN_VS_SHADER_FLAGS( Engine_Post_dx9, "Engine post-processing effects (softwar { LoadTexture( BASETEXTURE ); } + if ( params[FBTEXTURE]->IsDefined() ) { LoadTexture( FBTEXTURE ); } + + if ( params[SCREENEFFECTTEXTURE]->IsDefined() ) + { + LoadTexture( SCREENEFFECTTEXTURE ); + } + + if ( params[NOISETEXTURE]->IsDefined() ) + { + LoadTexture( NOISETEXTURE ); + } + + if ( params[INTERNAL_VIGNETTETEXTURE]->IsDefined() ) + { + LoadTexture( INTERNAL_VIGNETTETEXTURE ); + } } SHADER_DRAW { + bool bToolMode = params[TOOLMODE]->GetIntValue() != 0; + bool bDepthBlurEnable = params[ DEPTHBLURENABLE ]->GetIntValue() != 0; + SHADOW_STATE { // This shader uses opaque blending, but needs to match the behaviour of bloom_add/screen_spacegeneral, @@ -83,25 +291,16 @@ BEGIN_VS_SHADER_FLAGS( Engine_Post_dx9, "Engine post-processing effects (softwar // one; gamma colours more closely match luminance perception. The color-correction process // has always taken gamma-space values as input anyway). - // On OpenGL OSX, we MUST do sRGB reads from the bloom and full framebuffer textures AND sRGB - // writes on the way out to the framebuffer. Hence, our colors are linear in the shader. - // Given this, we use the LINEAR_INPUTS combo to convert to sRGB for the purposes of color - // correction, since that is how the color correction textures are authored. - bool bLinearInput = IsOSX() && g_pHardwareConfig->CanDoSRGBReadFromRTs(); - bool bLinearOutput = IsOSX() && !g_pHardwareConfig->FakeSRGBWrite() && g_pHardwareConfig->CanDoSRGBReadFromRTs(); - - bool bForceSRGBReadsAndWrites = IsOSX() && g_pHardwareConfig->CanDoSRGBReadFromRTs(); - pShaderShadow->EnableBlending( false ); // The (sRGB) bloom texture is bound to sampler 0 pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); - pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, bForceSRGBReadsAndWrites ); - pShaderShadow->EnableSRGBWrite( bForceSRGBReadsAndWrites ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, false ); + pShaderShadow->EnableSRGBWrite( false ); // The (sRGB) full framebuffer texture is bound to sampler 1: pShaderShadow->EnableTexture( SHADER_SAMPLER1, true ); - pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, bForceSRGBReadsAndWrites ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, false ); // Up to 4 (sRGB) color-correction lookup textures are bound to samplers 2-5: pShaderShadow->EnableTexture( SHADER_SAMPLER2, true ); @@ -113,6 +312,20 @@ BEGIN_VS_SHADER_FLAGS( Engine_Post_dx9, "Engine post-processing effects (softwar pShaderShadow->EnableSRGBRead( SHADER_SAMPLER4, false ); pShaderShadow->EnableSRGBRead( SHADER_SAMPLER5, false ); + // Noise + pShaderShadow->EnableTexture( SHADER_SAMPLER6, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER6, false ); + + // Vignette + pShaderShadow->EnableTexture( SHADER_SAMPLER7, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER7, false ); + + // Screen effect texture + pShaderShadow->EnableTexture( SHADER_SAMPLER8, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER8, false ); + + pShaderShadow->EnableSRGBWrite( false ); + int format = VERTEX_POSITION; int numTexCoords = 1; int * pTexCoordDimensions = NULL; @@ -121,31 +334,73 @@ BEGIN_VS_SHADER_FLAGS( Engine_Post_dx9, "Engine post-processing effects (softwar DECLARE_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 ); SET_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 ); - - if( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // GL always goes the ps2b way for this shader, even on "ps20" parts - { - DECLARE_STATIC_PIXEL_SHADER( engine_post_ps20b ); - SET_STATIC_PIXEL_SHADER_COMBO( LINEAR_INPUT, bLinearInput ); - SET_STATIC_PIXEL_SHADER_COMBO( LINEAR_OUTPUT, bLinearOutput ); - SET_STATIC_PIXEL_SHADER( engine_post_ps20b ); - } - else - { - DECLARE_STATIC_PIXEL_SHADER( engine_post_ps20 ); - SET_STATIC_PIXEL_SHADER( engine_post_ps20 ); - } + + DECLARE_STATIC_PIXEL_SHADER( engine_post_ps20b ); + SET_STATIC_PIXEL_SHADER_COMBO( TOOL_MODE, bToolMode ); + SET_STATIC_PIXEL_SHADER_COMBO( DEPTH_BLUR_ENABLE, bDepthBlurEnable ); + SET_STATIC_PIXEL_SHADER( engine_post_ps20b ); } DYNAMIC_STATE { BindTexture( SHADER_SAMPLER0, BASETEXTURE, -1 ); + // FIXME: need to set FBTEXTURE to be point-sampled (will speed up this shader significantly on 360) // and assert that it's set to SHADER_TEXWRAPMODE_CLAMP (since the shader will sample offscreen) BindTexture( SHADER_SAMPLER1, FBTEXTURE, -1 ); - ShaderColorCorrectionInfo_t ccInfo; - pShaderAPI->GetCurrentColorCorrection( &ccInfo ); - int colCorrectNumLookups = ccInfo.m_nLookupCount; - for( int i = 0; i < colCorrectNumLookups; i++ ) + ShaderColorCorrectionInfo_t ccInfo = { false, 0, 1.0f, { 1.0f, 1.0f, 1.0f, 1.0f } }; + + float flTime; + if ( bToolMode ) + { + flTime = params[TOOLTIME]->GetFloatValue(); + } + else + { + flTime = pShaderAPI->CurrentTime(); + } + + // PC, ps20b has a desaturation control that overrides color correction + bool bDesaturateEnable = bToolMode && ( params[DESATURATEENABLE]->GetIntValue() != 0 ) && g_pHardwareConfig->SupportsPixelShaders_2_b(); + + float vPsConst16[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + vPsConst16[0] = params[ DESATURATION ]->GetFloatValue(); + vPsConst16[1] = ( params[FADE]->GetIntValue() == 2 ) ? 1.0f : 0.0f; // Enable lerping to ( color * fadecolor ) for FADE_COLOR=2 + pShaderAPI->SetPixelShaderConstant( 16, vPsConst16, 1 ); + + if ( params[FADE]->GetIntValue() == 0 ) + { + // Not fading, so set the constant to cause nothing to change about the pixel color + float vConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + pShaderAPI->SetPixelShaderConstant( 15, vConst ); + } + else + { + pShaderAPI->SetPixelShaderConstant( 15, params[ FADECOLOR ]->GetVecValue(), 1 ); + } + + if ( !bDesaturateEnable ) // set up color correction + { + bool bToolColorCorrection = params[TOOLCOLORCORRECTION]->GetIntValue() != 0; + if ( bToolColorCorrection ) + { + ccInfo.m_bIsEnabled = true; + + ccInfo.m_nLookupCount = (int) params[NUM_LOOKUPS]->GetFloatValue(); + ccInfo.m_flDefaultWeight = params[WEIGHT_DEFAULT]->GetFloatValue(); + ccInfo.m_pLookupWeights[0] = params[WEIGHT0]->GetFloatValue(); + ccInfo.m_pLookupWeights[1] = params[WEIGHT1]->GetFloatValue(); + ccInfo.m_pLookupWeights[2] = params[WEIGHT2]->GetFloatValue(); + ccInfo.m_pLookupWeights[3] = params[WEIGHT3]->GetFloatValue(); + } + else + { + pShaderAPI->GetCurrentColorCorrection( &ccInfo ); + } + } + + int colCorrectNumLookups = MIN( ccInfo.m_nLookupCount, 3 ); + for ( int i = 0; i < colCorrectNumLookups; i++ ) { pShaderAPI->BindStandardTexture( (Sampler_t)(SHADER_SAMPLER2 + i), (StandardTextureId_t)(TEXTURE_COLOR_CORRECTION_VOLUME_0 + i) ); } @@ -160,6 +415,7 @@ BEGIN_VS_SHADER_FLAGS( Engine_Post_dx9, "Engine post-processing effects (softwar float dY = 1.0f / height; float offsets[4] = { +dX, 0, +dY, -dX }; pShaderAPI->SetPixelShaderConstant( 0, &offsets[0], 1 ); + // Upload AA tweakables: // x - strength (this can be used to toggle the AA off, or to weaken it where pathological cases are showing) // y - reduction of 1-pixel-line blurring (blurring of 1-pixel lines causes issues, so it's tunable) @@ -170,6 +426,7 @@ BEGIN_VS_SHADER_FLAGS( Engine_Post_dx9, "Engine post-processing effects (softwar params[ AAINTERNAL3 ]->GetVecValue()[0], params[ AAINTERNAL3 ]->GetVecValue()[1] }; pShaderAPI->SetPixelShaderConstant( 1, &tweakables[0], 1 ); + // Upload AA UV transform (converts bloom texture UVs to framebuffer texture UVs) // NOTE: we swap the order of the z and w components since 'wz' is an allowed ps20 swizzle, but 'zw' is not: float uvTrans[4] = { params[ AAINTERNAL2 ]->GetVecValue()[0], @@ -182,42 +439,194 @@ BEGIN_VS_SHADER_FLAGS( Engine_Post_dx9, "Engine post-processing effects (softwar pShaderAPI->SetPixelShaderConstant( 3, &ccInfo.m_flDefaultWeight ); pShaderAPI->SetPixelShaderConstant( 4, ccInfo.m_pLookupWeights ); - int aaEnabled = ( params[ AAINTERNAL1 ]->GetVecValue()[0] == 0.0f ) ? 0 : 1; - int aaReduceOnePixelLineBlur = ( params[ AAINTERNAL1 ]->GetVecValue()[1] == 0.0f ) ? 0 : 1; - int aaQualityMode = (int)params[ AAINTERNAL1 ]->GetVecValue()[2]; -// int aaDebugMode = (int)params[ AAINTERNAL1 ]->GetVecValue()[3]; - int bloomEnabled = ( params[ BLOOMENABLE ]->GetIntValue() == 0 ) ? 0 : 1; - int colCorrectEnabled = ccInfo.m_bIsEnabled; + int aaEnabled = 0; + int bloomEnabled = ( params[ BLOOMENABLE ]->GetIntValue() == 0 ) ? 0 : 1; + int colCorrectEnabled = ccInfo.m_bIsEnabled; float flBloomFactor = bloomEnabled ? 1.0f : 0.0f; - float bloomConstant[4] = { flBloomFactor, flBloomFactor, flBloomFactor, flBloomFactor }; + flBloomFactor *= params[BLOOMAMOUNT]->GetFloatValue(); + float bloomConstant[4] = + { + flBloomFactor, + params[ SCREENBLURSTRENGTH ]->GetFloatValue(), + params[ DEPTHBLURFOCALDISTANCE ]->GetFloatValue(), + params[ DEPTHBLURSTRENGTH ]->GetFloatValue() + }; + + if ( mat_screen_blur_override.GetFloat() >= 0.0f ) + { + bloomConstant[1] = mat_screen_blur_override.GetFloat(); + } + if ( mat_depth_blur_focal_distance_override.GetFloat() >= 0.0f ) + { + bloomConstant[2] = mat_depth_blur_focal_distance_override.GetFloat(); + } + if ( mat_depth_blur_strength_override.GetFloat() >= 0.0f ) + { + bloomConstant[3] = mat_depth_blur_strength_override.GetFloat(); + } + pShaderAPI->SetPixelShaderConstant( 5, bloomConstant ); + // Vignette + bool bVignetteEnable = ( params[ VIGNETTEENABLE ]->GetIntValue() != 0 ) && ( params[ ALLOWVIGNETTE ]->GetIntValue() != 0 ); + if ( bVignetteEnable ) + { + BindTexture( SHADER_SAMPLER7, INTERNAL_VIGNETTETEXTURE ); + } + + // Noise + bool bNoiseEnable = ( params[ NOISEENABLE ]->GetIntValue() != 0 ) && ( params[ ALLOWNOISE ]->GetIntValue() != 0 ); + + int nFbTextureHeight = params[FBTEXTURE]->GetTextureValue()->GetActualHeight(); + if ( nFbTextureHeight < 720 ) + { + // Disable noise at low resolutions + bNoiseEnable = false; + } + + if ( bNoiseEnable ) + { + BindTexture( SHADER_SAMPLER6, NOISETEXTURE ); + + // Noise scale + float vPsConst6[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + vPsConst6[0] = params[ NOISESCALE ]->GetFloatValue(); + if ( mat_grain_scale_override.GetFloat() != -1.0f ) + { + vPsConst6[0] = mat_grain_scale_override.GetFloat(); + } + + if ( vPsConst6[0] <= 0.0f ) + { + bNoiseEnable = false; + } + + pShaderAPI->SetPixelShaderConstant( 6, vPsConst6 ); + + // Time % 1000 for scrolling + float vPsConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + vPsConst[0] = flTime; + vPsConst[0] -= (float)( (int)( vPsConst[0] / 1000.0f ) ) * 1000.0f; + pShaderAPI->SetPixelShaderConstant( 7, vPsConst, 1 ); + } + + // Local Contrast + bool bLocalContrastEnable = ( params[ LOCALCONTRASTENABLE ]->GetIntValue() != 0 ) && ( params[ ALLOWLOCALCONTRAST ]->GetIntValue() != 0 ); + bool bBlurredVignetteEnable = ( bLocalContrastEnable ) && ( params[ BLURREDVIGNETTEENABLE ]->GetIntValue() != 0 ); + + if ( bLocalContrastEnable ) + { + // Contrast scale + float vPsConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + vPsConst[0] = params[ LOCALCONTRASTSCALE ]->GetFloatValue(); + if ( mat_local_contrast_scale_override.GetFloat() != 0.0f ) + { + vPsConst[0] = mat_local_contrast_scale_override.GetFloat(); + } + vPsConst[1] = params[ LOCALCONTRASTMIDTONEMASK ]->GetFloatValue(); + if ( mat_local_contrast_midtone_mask_override.GetFloat() >= 0.0f ) + { + vPsConst[1] = mat_local_contrast_midtone_mask_override.GetFloat(); + } + vPsConst[2] = params[ BLURREDVIGNETTESCALE ]->GetFloatValue(); + pShaderAPI->SetPixelShaderConstant( 8, vPsConst, 1 ); + + vPsConst[0] = params[ LOCALCONTRASTVIGNETTESTART ]->GetFloatValue(); + if ( mat_local_contrast_vignette_start_override.GetFloat() >= 0.0f ) + { + vPsConst[0] = mat_local_contrast_vignette_start_override.GetFloat(); + } + vPsConst[1] = params[ LOCALCONTRASTVIGNETTEEND ]->GetFloatValue(); + if ( mat_local_contrast_vignette_end_override.GetFloat() >= 0.0f ) + { + vPsConst[1] = mat_local_contrast_vignette_end_override.GetFloat(); + } + vPsConst[2] = params[ LOCALCONTRASTEDGESCALE ]->GetFloatValue(); + if ( mat_local_contrast_edge_scale_override.GetFloat() >= -1.0f ) + { + vPsConst[2] = mat_local_contrast_edge_scale_override.GetFloat(); + } + pShaderAPI->SetPixelShaderConstant( 9, vPsConst, 1 ); + } + + // fade to black + float vPsConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + vPsConst[0] = params[ FADETOBLACKSCALE ]->GetFloatValue(); + pShaderAPI->SetPixelShaderConstant( 10, vPsConst, 1 ); + + bool bVomitEnable = ( params[ VOMITENABLE ]->GetIntValue() != 0 ); + if ( bVomitEnable ) + { + BindTexture( SHADER_SAMPLER8, SCREENEFFECTTEXTURE ); + + params[ VOMITCOLOR1 ]->GetVecValue( vPsConst, 3 ); + vPsConst[3] = params[ VOMITREFRACTSCALE ]->GetFloatValue(); + pShaderAPI->SetPixelShaderConstant( 11, vPsConst, 1 ); + params[ VOMITCOLOR2 ]->GetVecValue( vPsConst, 3 ); + vPsConst[3] = 0.0f; + pShaderAPI->SetPixelShaderConstant( 12, vPsConst, 1 ); + + // Get viewport and render target dimensions and set shader constant to do a 2D mad + ShaderViewport_t vp; + pShaderAPI->GetViewports( &vp, 1 ); + int nViewportX = vp.m_nTopLeftX; + int nViewportY = vp.m_nTopLeftY; + int nViewportWidth = vp.m_nWidth; + int nViewportHeight = vp.m_nHeight; + + int nRtWidth, nRtHeight; + ITexture *pRenderTarget = pShaderAPI->GetRenderTargetEx( 0 ); + if( pRenderTarget != nullptr ) + { + nRtWidth = pRenderTarget->GetActualWidth(); + nRtHeight = pRenderTarget->GetActualHeight(); + } + else + { + pShaderAPI->GetBackBufferDimensions( nRtWidth, nRtHeight ); + } + + float vViewportMad[4]; + + // screen->viewport transform + vViewportMad[0] = ( float )nRtWidth / ( float )nViewportWidth; + vViewportMad[1] = ( float )nRtHeight / ( float )nViewportHeight; + vViewportMad[2] = -( float )nViewportX / ( float )nViewportWidth; + vViewportMad[3] = -( float )nViewportY / ( float )nViewportHeight; + pShaderAPI->SetPixelShaderConstant( 13, vViewportMad, 1 ); + + // viewport->screen transform + vViewportMad[0] = ( float )nViewportWidth / ( float )nRtWidth; + vViewportMad[1] = ( float )nViewportHeight / ( float )nRtHeight; + vViewportMad[2] = ( float )nViewportX / ( float )nRtWidth; + vViewportMad[3] = ( float )nViewportY / ( float )nRtHeight; + pShaderAPI->SetPixelShaderConstant( 14, vViewportMad, 1 ); + } + if ( !colCorrectEnabled ) { colCorrectNumLookups = 0; } - - if( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // GL always goes the ps2b way for this shader, even on "ps20" parts - { - DECLARE_DYNAMIC_PIXEL_SHADER( engine_post_ps20b ); - SET_DYNAMIC_PIXEL_SHADER_COMBO( AA_ENABLE, aaEnabled ); - SET_DYNAMIC_PIXEL_SHADER_COMBO( AA_QUALITY_MODE, aaQualityMode ); - SET_DYNAMIC_PIXEL_SHADER_COMBO( AA_REDUCE_ONE_PIXEL_LINE_BLUR, aaReduceOnePixelLineBlur ); -// SET_DYNAMIC_PIXEL_SHADER_COMBO( AA_DEBUG_MODE, aaDebugMode ); - SET_DYNAMIC_PIXEL_SHADER_COMBO( COL_CORRECT_NUM_LOOKUPS, colCorrectNumLookups ); - SET_DYNAMIC_PIXEL_SHADER( engine_post_ps20b ); - } - else - { - DECLARE_DYNAMIC_PIXEL_SHADER( engine_post_ps20 ); - SET_DYNAMIC_PIXEL_SHADER_COMBO( AA_ENABLE, aaEnabled ); - SET_DYNAMIC_PIXEL_SHADER_COMBO( AA_QUALITY_MODE, 0 ); // Only enough instruction slots in ps2b - SET_DYNAMIC_PIXEL_SHADER_COMBO( AA_REDUCE_ONE_PIXEL_LINE_BLUR, 0 ); -// SET_DYNAMIC_PIXEL_SHADER_COMBO( AA_DEBUG_MODE, aaDebugMode ); - SET_DYNAMIC_PIXEL_SHADER_COMBO( COL_CORRECT_NUM_LOOKUPS, colCorrectNumLookups ); - SET_DYNAMIC_PIXEL_SHADER( engine_post_ps20 ); - } + + bool bConvertFromLinear = ( g_pHardwareConfig->GetHDRType() == HDR_TYPE_FLOAT ); + + // JasonM - double check this if the SFM needs to use the engine post FX clip in main + bool bConvertToLinear = bToolMode && bConvertFromLinear && ( g_pHardwareConfig->GetHDRType() == HDR_TYPE_FLOAT ); + + DECLARE_DYNAMIC_PIXEL_SHADER( engine_post_ps20b ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( AA_ENABLE, aaEnabled ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( COL_CORRECT_NUM_LOOKUPS, colCorrectNumLookups ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( CONVERT_FROM_LINEAR, bConvertFromLinear ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( CONVERT_TO_LINEAR, bConvertToLinear ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( NOISE_ENABLE, bNoiseEnable ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( VIGNETTE_ENABLE, bVignetteEnable ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( LOCAL_CONTRAST_ENABLE, bLocalContrastEnable ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( BLURRED_VIGNETTE_ENABLE, bBlurredVignetteEnable ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( VOMIT_ENABLE, bVomitEnable ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( TV_GAMMA, params[TV_GAMMA]->GetIntValue() && bToolMode ? 1 : 0 ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( DESATURATEENABLE, bDesaturateEnable ); + SET_DYNAMIC_PIXEL_SHADER( engine_post_ps20b ); DECLARE_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 ); SET_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 ); diff --git a/src/materialsystem/stdshaders/Engine_Post_ps2x.fxc b/src/materialsystem/stdshaders/Engine_Post_ps2x.fxc index 7845c6cf..e7d53ba0 100644 --- a/src/materialsystem/stdshaders/Engine_Post_ps2x.fxc +++ b/src/materialsystem/stdshaders/Engine_Post_ps2x.fxc @@ -1,118 +1,107 @@ -// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] -// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] -// STATIC: "LINEAR_INPUT" "0..1" [ps20b] -// STATIC: "LINEAR_OUTPUT" "0..1" [ps20b] +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// -// DYNAMIC: "AA_ENABLE" "0..1" -// rem DYNAMIC: "AA_DEBUG_MODE" "0..3" -#define AA_DEBUG_MODE 0 -// DYNAMIC: "AA_QUALITY_MODE" "0..0" [ps20] -// DYNAMIC: "AA_QUALITY_MODE" "0..1" [ps20b] -// DYNAMIC: "AA_QUALITY_MODE" "0..1" [ps30] -// DYNAMIC: "AA_REDUCE_ONE_PIXEL_LINE_BLUR" "0..0" [ps20] -// DYNAMIC: "AA_REDUCE_ONE_PIXEL_LINE_BLUR" "0..1" [ps20b] -// DYNAMIC: "AA_REDUCE_ONE_PIXEL_LINE_BLUR" "0..1" [ps30] -// DYNAMIC: "COL_CORRECT_NUM_LOOKUPS" "0..4" +// FIXMEL4DTOMAINMERGE +// Need to re-enable bloom and disable other L4D-only features in here and the cpp file. + +// STATIC: "TOOL_MODE" "0..1" +// STATIC: "DEPTH_BLUR_ENABLE" "0..1" + +// DYNAMIC: "AA_ENABLE" "0..0" [PC] +// DYNAMIC: "AA_ENABLE" "0..1" [XBOX] + +// DYNAMIC: "COL_CORRECT_NUM_LOOKUPS" "0..3" + +// DYNAMIC: "CONVERT_FROM_LINEAR" "0..1" [ps20b] [ps30] [PC] +// DYNAMIC: "CONVERT_TO_LINEAR" "0..1" [ps20b] [ps30] [PC] +// DYNAMIC: "CONVERT_FROM_LINEAR" "0..0" [ps20b] [XBOX] +// DYNAMIC: "CONVERT_TO_LINEAR" "0..0" [ps20b] [XBOX] +// SKIP: ( $CONVERT_FROM_LINEAR == 0 ) && ( $CONVERT_TO_LINEAR == 1 ) +// SKIP: ( $TOOL_MODE == 0 ) && ( $CONVERT_TO_LINEAR == 1 ) + +// DYNAMIC: "NOISE_ENABLE" "0..1" [ps20b] [ps30] +// DYNAMIC: "VIGNETTE_ENABLE" "0..1" [ps20b] [ps30] +// DYNAMIC: "LOCAL_CONTRAST_ENABLE" "0..1" [ps20b] [ps30] +// DYNAMIC: "BLURRED_VIGNETTE_ENABLE" "0..1" [ps20b] [ps30] +// DYNAMIC: "VOMIT_ENABLE" "0..1" +// SKIP: ( $LOCAL_CONTRAST_ENABLE == 0 ) && ( $BLURRED_VIGNETTE_ENABLE == 1 ) + +// DYNAMIC: "TV_GAMMA" "0..1" [ps20b] [PC] +// DYNAMIC: "DESATURATEENABLE" "0..1" [ps20b] [PC] +// SKIP: ( $TOOL_MODE == 0 ) && $TV_GAMMA +// SKIP: ( $TOOL_MODE == 0 ) && $DESATURATEENABLE -#define HDRTYPE HDR_TYPE_NONE #include "common_ps_fxc.h" - -#if !(defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0)) -// Only allow debug modes and high-quality mode if in ps2b or higher (not enough instruction slots in ps20) -#undef AA_DEBUG_MODE -#define AA_DEBUG_MODE 0 -#endif - - -/* - * Engine_Post combines bloom (the final simple addition) with software anti-aliasing - * and colour-correction. Combining them has these benefits: - * (a) saves fillrate+bandwidth (big on PC) - * (b) saves calls to UpdateScreenEffectTexture (big on 360) - * (c) reduces quantization errors caused by multiple passes - * (d) improves AA quality (it works better on sRGB values than linear) - * - * - * Software AA Summary - * ------------------- - * - * This AA process works by sampling neighbour pixels (4 or 8 of them): - * - * 5-tap filter: # 9-tap filter: ### - * (AA_QUALITY_MODE 0) ### (AA_QUALITY_MODE 1) ### - * # ### - * - * It then figures out which of these neighbours are 'unlike' the centre pixel. - * This is based on RGB distance, weighted by the maximum luminance of the samples - * (so the difference between 0.1 and 0.2 is the same as between 0.5 and 1.0). - * This detects high-contrast edges in both dark and bright scenes. - * - * It then counts how many 'unlike' samples there are. Some example cases for 5-tap: - * - * O # # # # # - * OOO OOO #OO OOO #O# #O# - * O O O # O # - * Zero One TwoA TwoB Three Four - * - * We then blend towards the average of the unlike neighbours, based on how many - * unlike neighbours there are. The key case is 'TwoA' - this detects stairstep pixels - * on non-axis-aligned edges. In that case, we blend the output colour towards the - * average of the unlike samples by 33%. This yields a 3-pixel transition (0->33->66->100) - * where before there was a 1-pixel transition (0->100). - * - * The 9-tap filter (which works the same as 5-tap, just with more samples and different - * weights) has two advantages over the 5-tap filter: - * - it can differentiate between stairsteps on 45-degree edges and near-horizontal edges - * (so the 5-tap version smudges 45-degree edges more than you want, e.g. chain-link fences) - * - it blurs less texture detail, by virtue of averaging out noise over more samples - * - * One problem case that both filters have to consider is one-pixel-thick lines (this is - * case 'TwoB' above). Sometimes you do want to soften these lines (for slivers of brightly-lit - * geometry in a dark area, e.g. a window frame), but sometimes you do NOT want to soften them - * (for thin geometry which is alternating between 1-pixel and 2-pixel thickness, e.g. cables, - * and also where 1-pixel lines appear in textures, e.g. roof tiles). So, blurring of 1-pixel - * lines is tunable (it defaults to half-blurred as a compromise between the want/don't cases), - * in the 'AA_REDUCE_ONE_PIXEL_LINE_BLUR' section below. Case TwoB is differentiated from TwoA by - * computing the centroid of the unlike samples (the centroid will be at zero for case TwoB, - * but not for TwoA). - * - */ - sampler BaseTextureSampler : register( s0 ); sampler FBTextureSampler : register( s1 ); sampler ColorCorrectionVolumeTexture0 : register( s2 ); sampler ColorCorrectionVolumeTexture1 : register( s3 ); sampler ColorCorrectionVolumeTexture2 : register( s4 ); sampler ColorCorrectionVolumeTexture3 : register( s5 ); +sampler NoiseSampler : register( s6 ); +sampler VignetteSampler : register( s7 ); +sampler ScreenEffectSampler : register( s8 ); // used for vomit/paint screen particle effects float4 psTapOffs_Packed : register( c0 ); // psTapOffs_packed contains 1-pixel offsets: ( +dX, 0, +dY, -dX ) float4 tweakables : register( c1 ); // (x - AA strength/unused) (y - reduction of 1-pixel-line blur) // (z - edge threshold multipler) (w - tap offset multiplier) float4 uvTransform : register( c2 ); // Transform BaseTexture UVs for use with the FBTexture - + float ColorCorrectionDefaultWeight : register( c3 ); float4 ColorCorrectionVolumeWeights : register( c4 ); -float BloomFactor : register( c5 ); + +// Bloom & Depth Blur parameters +// x: bloom amount; multiply bloom downscale buffer by this value and add to base color +// y: bloom lerp amount; lerp between base color and blurred bloom buffer with this factor (allows for color bleeding in dark areas) +// z: depth blur focal plane distance. Value is in dest alpha space [0,1], not world units. +// w: depth blur scale value; scale distance from focal plane by this amount +float4 BloomParameters : register( c5 ); +#define g_flBloomAmount ( BloomParameters.x ) +#define g_flBloomLerpFactor ( BloomParameters.y ) +#define g_flDepthBlurFocalDistance ( BloomParameters.z ) +#define g_flDepthBlurScale ( BloomParameters.w ) + +float g_flNoiseScalar : register( c6 ); +float g_flTime : register( c7 ); +float4 g_vLocalContrastParams : register( c8 ); +#define g_flLocalContrastStrength g_vLocalContrastParams.x +#define g_flLocalContrastMidToneMask g_vLocalContrastParams.y +#define g_flBlurredVignetteStrength g_vLocalContrastParams.z + +float4 g_vLocalContrastVignetteParams : register( c9 ); +#define g_flLocalContrastVignetteStart g_vLocalContrastVignetteParams.x +#define g_flLocalContrastVignetteEnd g_vLocalContrastVignetteParams.y +#define g_flLocalContrastEdgeStrength g_vLocalContrastVignetteParams.z + +float g_flFadeToBlackStrength : register( c10 ); + +float4 g_vVomitColor[2] : register( c11 ); +#define g_flVomitRefractStrength g_vVomitColor[0].a + +float4 g_vViewportTransform : register( c13 ); +float4 g_vInvViewportTransform : register( c14 ); + +float4 g_vViewFadeColor : register( c15 ); + +float2 g_c16 : register( c16 ); +#define g_flDesaturation g_c16.x +#define g_flFadeMode2 g_c16.y + +float Luminance( float3 cColor ) +{ + float3 tmpv = { 0.2125, 0.7154, 0.0721 }; + float flLuminance = dot( cColor.rgb, tmpv.rgb ); + return flLuminance; +} float4 GetBloomColor( float2 bloomUV ) { - #if ( LINEAR_INPUT == 1 ) - { - // In this case, which is only used on OpenGL, we want sRGB data from this tex2D. - // Hence, we have to undo the sRGB conversion that we are forced to apply by OpenGL - return LinearToGamma( tex2D( BaseTextureSampler, bloomUV ) ); - } - #else - { - return tex2D( BaseTextureSampler, bloomUV ); - } - #endif + return tex2D( BaseTextureSampler, bloomUV ); } -float4 PerformColorCorrection( float4 outColor, float2 fbTexCoord ) +float4 PerformColorCorrection( float4 outColor ) { - #if ( COL_CORRECT_NUM_LOOKUPS > 0 ) + if (COL_CORRECT_NUM_LOOKUPS > 0) { // NOTE: This code requires the color correction texture to be 32 units to be correct. // This code will cause (0,0,0) to be read from 0.5f/32 @@ -121,254 +110,30 @@ float4 PerformColorCorrection( float4 outColor, float2 fbTexCoord ) outColor.rgb = outColor.rgb * ColorCorrectionDefaultWeight; outColor.rgb += tex3D( ColorCorrectionVolumeTexture0, offsetOutColor.rgb ) * ColorCorrectionVolumeWeights.x; - #if ( COL_CORRECT_NUM_LOOKUPS > 1 ) + if (COL_CORRECT_NUM_LOOKUPS > 1) { outColor.rgb += tex3D( ColorCorrectionVolumeTexture1, offsetOutColor.rgb ) * ColorCorrectionVolumeWeights.y; - #if ( COL_CORRECT_NUM_LOOKUPS > 2 ) + if (COL_CORRECT_NUM_LOOKUPS > 2) { outColor.rgb += tex3D( ColorCorrectionVolumeTexture2, offsetOutColor.rgb ) * ColorCorrectionVolumeWeights.z; - #if ( COL_CORRECT_NUM_LOOKUPS > 3 ) + if (COL_CORRECT_NUM_LOOKUPS > 3) { outColor.rgb += tex3D( ColorCorrectionVolumeTexture3, offsetOutColor.rgb ) * ColorCorrectionVolumeWeights.w; } - #endif } - #endif } - #endif } - #endif return outColor; } -float3 PerformAA( float3 baseColor, float2 fbTexCoord, out float3 unlike, out float unlikeSum, out float lerpFactor ) +float3 PerformVomitBlend( float3 vRefractParams, float3 vFullResColor, float3 vBlurredColor ) { - float3 a, b, c, d, e, f, g, h; - float3 dA, dB, dC, dD, dE, dF, dG, dH; - float4 deltas, deltas2; - float4 weights, weights2; - float4 lumS; - float maxLumS; - - // Set FAST_DELTAS to '1' to use Manhattan distance (in colour-space) rather than Euclidean distance: - const int FAST_DELTAS = 1; -#if AA_QUALITY_MODE == 0 - const float COLOUR_DELTA_BASE = (FAST_DELTAS == 0) ? 0.11f : 0.5f; - const float COLOUR_DELTA_CONTRAST = 100; - // Scaling down colour deltas (DELTA_SCALE) reduces the over-blurring of 45-degree edges - // by the 5-tap filter. Conversely, increasing it smooths stairsteps more strongly. - const float DELTA_SCALE = 0.75f; -#else // AA_QUALITY_MODE == 0 - const float COLOUR_DELTA_BASE = (FAST_DELTAS == 0) ? 0.24f : 0.65f; - const float COLOUR_DELTA_CONTRAST = 100; - const float DELTA_SCALE = 1.0f; -#endif // AA_QUALITY_MODE == 0 - const float MAX_LERP_FACTOR = 0.66f; - const float SQRT3 = 1.73205080757f; - float onePixelLineBlurReduction = tweakables.y; - - - // psTapOffs_packed contains 1-pixel offsets: ( +dX, 0, +dY, -dX ) - float4 texelDelta = psTapOffs_Packed*tweakables.w; - - // Allowed ps20 swizzles: - // .xyzw on (+dX,0,+dY,-dX) gives: (+dX, 0) & (-dX, 0) (former with 'add', latter with 'sub') - // .yzxw on (+dX,0,+dY,-dX) gives: ( 0,+dY) & ( 0,-dY) - // .wzyx on (+dX,0,+dY,-dX) gives: (-dX,+dY) & (+dX,-dY) - // .zxyw on (not used) - // NOTE: These don't give us (+dX,+dY) and (-dX,-dY), we need to copy +dY: ( +dX, 0, +dY, -dX ) -> ( +dX, +dY, +dY, -dX ) - // NOTE: tex2D() can't swizzle the source register in ps2x, so we have no - // choice but to add each float2 offset to fbTexCoord one at a time :o/ - a = tex2D( FBTextureSampler, fbTexCoord + texelDelta.yz ).rgb; // ( 0,+1) - b = tex2D( FBTextureSampler, fbTexCoord + texelDelta.xy ).rgb; // (+1, 0) - c = tex2D( FBTextureSampler, fbTexCoord - texelDelta.yz ).rgb; // ( 0,-1) - d = tex2D( FBTextureSampler, fbTexCoord - texelDelta.xy ).rgb; // (-1, 0) -#if AA_QUALITY_MODE == 1 - // 9-tap method (do diagonal neighbours too) - e = tex2D( FBTextureSampler, fbTexCoord + texelDelta.wz ).rgb; // (-1,+1) - f = tex2D( FBTextureSampler, fbTexCoord - texelDelta.wz ).rgb; // (+1,-1) - texelDelta.y = texelDelta.z; // Can't quite get all 8 sample offsets from a single float4 with the allowed swizzles! :o/ - g = tex2D( FBTextureSampler, fbTexCoord + texelDelta.xy ).rgb; // (+1,+1) - h = tex2D( FBTextureSampler, fbTexCoord - texelDelta.xy ).rgb; // (-1,-1) -#endif // AA_QUALITY_MODE == 1 - - // Compute the like<-->unlike weights - dA = a - baseColor; - dB = b - baseColor; - dC = c - baseColor; - dD = d - baseColor; -#if AA_QUALITY_MODE == 1 - dE = e - baseColor; - dF = f - baseColor; - dG = g - baseColor; - dH = h - baseColor; -#endif // AA_QUALITY_MODE == 1 - #if ( FAST_DELTAS == 0 ) - { - // Colour-space Euclidean distance - deltas = float4( dot(dA, dA), dot(dB, dB), dot(dC, dC), dot(dD, dD) ); - deltas = DELTA_SCALE*DELTA_SCALE*(deltas / 3); - deltas = sqrt(deltas); - } - #else - { - // Colour-space Manhattan distance - // OPT: to avoid the 'abs', try dividing colours by maxLumS then dotprodding w/ baseColor - deltas.x = dot( abs( dA ), 1 ); - deltas.y = dot( abs( dB ), 1 ); - deltas.z = dot( abs( dC ), 1 ); - deltas.w = dot( abs( dD ), 1 ); - deltas *= DELTA_SCALE; - } - #endif - - weights = deltas; -#if AA_QUALITY_MODE == 1 - #if ( FAST_DELTAS == 0 ) - { - deltas2 = float4( dot(dE, dE), dot(dF, dF), dot(dG, dG), dot(dH, dH) ); - deltas2 = DELTA_SCALE*DELTA_SCALE*(deltas2 / 3); - deltas2 = sqrt(deltas2); - } - #else - { - deltas2.x = dot( abs( dE ), 1); - deltas2.y = dot( abs( dF ), 1); - deltas2.z = dot( abs( dG ), 1); - deltas2.w = dot( abs( dH ), 1); - deltas2 *= DELTA_SCALE; - } - #endif - - weights2 = deltas2; -#endif // AA_QUALITY_MODE == 1 - - // Adjust weights relative to maximum sample luminance (local, relative contrast: 0.1 Vs 0.2 is the same as 0.5 Vs 1.0) - lumS = float4( dot(a, a), dot(b, b), dot(c, c), dot(d, d) ); - lumS.xy = max( lumS.xy, lumS.wz ); - lumS.x = max( lumS.x, lumS.y ); - maxLumS = max( lumS.x, dot( baseColor, baseColor ) ); -#if AA_QUALITY_MODE == 1 - lumS = float4( dot(e, e), dot(f, f), dot(g, g), dot(h, h) ); - lumS.xy = max( lumS.xy, lumS.wz ); - lumS.x = max( lumS.x, lumS.y ); - maxLumS = max( lumS.x, maxLumS ); -#endif // AA_QUALITY_MODE == 1 - float lumScale = 1.0f / sqrt( maxLumS ); - weights *= lumScale; -#if AA_QUALITY_MODE == 1 - weights2 *= lumScale; -#endif // AA_QUALITY_MODE == 1 - - // Contrast-adjust weights such that only large contrast differences are taken into account - // (pushes weights to 0.0 for 'like' neighbours and to 1.0 for 'unlike' neighbours) - float colourDeltaBase = tweakables.z*COLOUR_DELTA_BASE; - weights = saturate(colourDeltaBase + COLOUR_DELTA_CONTRAST*(weights - colourDeltaBase)); -#if AA_QUALITY_MODE == 1 - weights2 = saturate(colourDeltaBase + COLOUR_DELTA_CONTRAST*(weights2 - colourDeltaBase)); -#endif // AA_QUALITY_MODE == 1 - - // Determine the average 'unlike' colour - unlikeSum = dot(weights, 1); - unlike = weights.x*a + weights.y*b + weights.z*c + weights.w*d; -#if AA_QUALITY_MODE == 1 - unlikeSum += dot(weights2, 1); - unlike += weights2.x*e + weights2.y*f + weights2.z*g + weights2.w*h; -#endif // AA_QUALITY_MODE == 1 - // NOTE: this can cause div-by-zero, but lerpFactor ends up at zero in that case so it doesn't matter - unlike = unlike / unlikeSum; - - -#if AA_REDUCE_ONE_PIXEL_LINE_BLUR - // Reduce lerpFactor for 1-pixel-thick lines - otherwise you lose texture detail, and it looks - // really weird where geometry (e.g. cables) alternates between being 1 and 2 pixels thick. - // [ The "*2" below is because the values here were tuned to reduce blurring one 1-pixel lines - // by about half (which is a good compromise between the bad cases at either end). So you - // want the controlling convar to default to 0.5 ] - const float ONE_PIXEL_LINE_BIAS_BASE = 0.4f; - const float ONE_PIXEL_LINE_BIAS_CONTRAST = 16.0f; - float2 unlikeCentroid = 0; - unlikeCentroid.x += dot( 1-weights, float4( 0, +1, 0, -1 ) ); // This 2x4 matrix is the transpose of - unlikeCentroid.y += dot( 1-weights, float4( +1, 0, -1, 0 ) ); // the neighbour sample texel offsets -#if AA_QUALITY_MODE == 0 - unlikeCentroid /= 4 - unlikeSum; -#else // AA_QUALITY_MODE == 0 - unlikeCentroid.x += dot( 1-weights2, float4( -1, +1, +1, -1 ) ); - unlikeCentroid.y += dot( 1-weights2, float4( +1, -1, +1, -1 ) ); - unlikeCentroid /= 8 - unlikeSum; -#endif // AA_QUALITY_MODE == 0 - float onePixelLineBias = 1 - saturate( length(unlikeCentroid) ); // OPTIMIZE: try using distSquared, remove this sqrt - onePixelLineBias = onePixelLineBlurReduction*saturate(ONE_PIXEL_LINE_BIAS_BASE + ONE_PIXEL_LINE_BIAS_CONTRAST*(onePixelLineBias - ONE_PIXEL_LINE_BIAS_BASE)); -#if AA_QUALITY_MODE == 0 - unlikeSum -= 2*onePixelLineBias*0.4f*saturate( 3 - unlikeSum ); // The 'min' thing avoids this affecting lone/pair pixels -#else // AA_QUALITY_MODE == 0 - unlikeSum -= 2*onePixelLineBias*1.9f*saturate( 7 - unlikeSum ); -#endif // AA_QUALITY_MODE == 0 -#endif // AA_REDUCE_ONE_PIXEL_LINE_BLUR - - - // Compute the lerp factor we use to blend between 'baseColor' and 'unlike'. - // We want to lerp 'stairstep' pixels (which have 2 unlike neighbours) - // 33% towards the 'unlike' colour, such that these hard, 1-pixel transitions - // (0% -> 100%) become soft, 3-pixel transitions (0% -> 33% -> 66% -> 100%). - float strengthMultiplier = tweakables.x; - #if ( AA_QUALITY_MODE == 0 ) - { - lerpFactor = saturate( strengthMultiplier*DELTA_SCALE*( (unlikeSum - 1) / 3 ) ); - // Uncomment the following to blend slightly across vertical/horizontal edges (better for 45-degree edges, worse for 90-degree edges) - //lerpFactor = saturate( strengthMultiplier*DELTA_SCALE*( unlikeSum / 6 ) ); - } - #else // AA_QUALITY_MODE != 0 - { - lerpFactor = saturate( strengthMultiplier*DELTA_SCALE*( (unlikeSum - 3) / 3 ) ); - } - #endif - - // Clamp the blend factor so that lone dot pixels aren't blurred into oblivion - lerpFactor = min( lerpFactor, MAX_LERP_FACTOR ); - baseColor = lerp( baseColor, unlike, lerpFactor ); - - return baseColor; -} - -float4 GenerateAADebugColor( float4 outColor, float3 unlike, float unlikeSum, float lerpFactor ) -{ - #if ( AA_DEBUG_MODE == 1 ) - { - // Debug: Visualize the number of 'unlike' samples - outColor.rgb = 0; - if ( AA_QUALITY_MODE == 0 ) - { - if (unlikeSum >= 0.95f) outColor.rgb = float3(1,0,0); - if (unlikeSum >= 1.95f) outColor.rgb = float3(0,1,0); - if (unlikeSum >= 2.95f) outColor.rgb = float3(0,0,1); - } - else - { - if (unlikeSum >= 2.95f) outColor.rgb = float3(1,0,0); - if (unlikeSum >= 3.95f) outColor.rgb = float3(0,1,0); - if (unlikeSum >= 4.95f) outColor.rgb = float3(0,0,1); - } - // Don't sRGB-write - } - #elif ( AA_DEBUG_MODE == 2 ) - { - // Debug: Visualize the strength of lerpFactor - outColor.rgb = 0; - outColor.g = lerpFactor; - // Don't sRGB-write - } - #elif ( AA_DEBUG_MODE == 3 ) - { - // Debug: Visualize the 'unlike' colour that we blend towards - outColor.rgb = lerp( 0, unlike, saturate(5*lerpFactor) ); - // Do sRGB-write (if it's enabled) - outColor = FinalOutput( outColor, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE ); - } - #endif - - return outColor; + float3 vVomitColor = lerp( g_vVomitColor[0].rgb, g_vVomitColor[1].rgb, vRefractParams.z ); // vomit tint + + vFullResColor.rgb *= lerp( float3( 1, 1, 1 ), vVomitColor, vRefractParams.z ); // vomit tint full-res buffer + vFullResColor.rgb = lerp ( vFullResColor.rgb, vVomitColor.rgb * vBlurredColor.rgb, vRefractParams.z ); + return vFullResColor.rgb; } float2 PerformUVTransform( float2 bloomUVs ) @@ -377,26 +142,67 @@ float2 PerformUVTransform( float2 bloomUVs ) return bloomUVs*uvTransform.wz + uvTransform.xy; } +// Apply TV Gamma for movie layoff specific to 360 TV movie playback path +float3 SrgbGammaToTvGamma( float3 cInput ) +{ + float3 cLinear = SrgbGammaToLinear( cInput ); + return pow( cLinear, 1.0f / 2.5f ); +} + + struct PS_INPUT { float2 baseTexCoord : TEXCOORD0; - -#if defined( _X360 ) //avoid a shader patch on 360 due to pixel shader inputs being fewer than vertex shader outputs - float2 ZeroTexCoord : TEXCOORD1; - float2 bloomTexCoord : TEXCOORD2; -#endif }; float4 main( PS_INPUT i ) : COLOR { - float2 fbTexCoord = PerformUVTransform( i.baseTexCoord ); - float3 baseColor = tex2D( FBTextureSampler, fbTexCoord ).rgb; - - #if ( LINEAR_INPUT == 1 ) + float4 fbTexCoord = 0; + #if !defined( SHADER_MODEL_PS_2_0 ) { - // In this case, which is only used on OpenGL, we want sRGB data from this tex2D. - // Hence, we have to undo the sRGB conversion that we are forced to apply by OpenGL - baseColor = LinearToGamma( baseColor ); + fbTexCoord.xy = PerformUVTransform( i.baseTexCoord ); + fbTexCoord.zw = i.baseTexCoord; + } + #else + { + fbTexCoord.xy = PerformUVTransform( i.baseTexCoord ); + } + #endif + + float4 cBloomBlurredLum = GetBloomColor( i.baseTexCoord ); // bloom color and blurred luminance in alpha + float4 vVomitRefractParams; + #if ( VOMIT_ENABLE == 1 ) + { + // perturb texture coordinate + vVomitRefractParams = tex2D( ScreenEffectSampler, i.baseTexCoord ); + fbTexCoord = fbTexCoord + g_flVomitRefractStrength * ( vVomitRefractParams.xyxy - 0.5 ); + + #if !defined( SHADER_MODEL_PS_2_0 ) + { + // screen coords -> viewport coords + float4 vNormalizedTexCoord = g_vViewportTransform.xyxy * fbTexCoord + g_vViewportTransform.zwzw; + // mirrored repeat texcoord math doesn't fit into 2.0 + vNormalizedTexCoord = min( 2.0 - vNormalizedTexCoord, abs( vNormalizedTexCoord ) ); + // viewport coords -> screen coords + fbTexCoord = g_vInvViewportTransform.xyxy * vNormalizedTexCoord + g_vInvViewportTransform.zwzw; + + cBloomBlurredLum = GetBloomColor( fbTexCoord.zw ); // fetch again with perturbed texcoords + } + #else + { + cBloomBlurredLum = GetBloomColor( fbTexCoord.xy ); // fetch again with perturbed texcoords + } + #endif + } + #endif + + float4 rawColor = tex2D( FBTextureSampler, fbTexCoord.xy ).rgba; + float3 baseColor = rawColor.rgb; + float depthValue = rawColor.a; + + #if ( CONVERT_FROM_LINEAR == 1 ) + { + baseColor.rgb = SrgbLinearToGamma( baseColor.rgb ); } #endif @@ -404,30 +210,185 @@ float4 main( PS_INPUT i ) : COLOR #if ( AA_ENABLE == 1 ) { - float unlikeSum, lerpFactor; - float3 unlike; + float3 up; + float3 dn; + float3 lf; + float3 rt; + float3 uplf; + float3 uprt; + float3 dnlf; + float3 dnrt; - outColor.rgb = PerformAA( outColor.rgb, fbTexCoord, unlike, unlikeSum, lerpFactor ); + // psTapOffs_packed contains 1-pixel offsets: ( +dX, 0, +dY, -dX ) + float4 texelDelta = psTapOffs_Packed.xyzw; + dn = tex2D( FBTextureSampler, fbTexCoord.xy + texelDelta.yz ).rgb; // ( 0,+1) + rt = tex2D( FBTextureSampler, fbTexCoord.xy + texelDelta.xy ).rgb; // (+1, 0) + up = tex2D( FBTextureSampler, fbTexCoord.xy - texelDelta.yz ).rgb; // ( 0,-1) + lf = tex2D( FBTextureSampler, fbTexCoord.xy - texelDelta.xy ).rgb; // (-1, 0) + dnlf = tex2D( FBTextureSampler, fbTexCoord.xy + texelDelta.wz ).rgb; // (-1,+1) + uprt = tex2D( FBTextureSampler, fbTexCoord.xy - texelDelta.wz ).rgb; // (+1,-1) + texelDelta.y = texelDelta.z; // Can't quite get all 8 sample offsets from a single float4 with the allowed swizzles! + uplf = tex2D( FBTextureSampler, fbTexCoord.xy + texelDelta.xy ).rgb; // (+1,+1) + dnrt = tex2D( FBTextureSampler, fbTexCoord.xy - texelDelta.xy ).rgb; // (-1,-1) - #if ( AA_DEBUG_MODE > 0 ) - { - return GenerateAADebugColor( outColor, unlike, unlikeSum, lerpFactor ); - } + // Generate the edge mask + float flBaseLum = Luminance( baseColor.rgb ); + float flEdge = saturate( abs( Luminance( dn.rgb ) - flBaseLum ) - 0.1 ); + flEdge += saturate( abs( Luminance( up.rgb ) - flBaseLum ) - 0.1 ); + flEdge += saturate( abs( Luminance( lf.rgb ) - flBaseLum ) - 0.1 ); + flEdge += saturate( abs( Luminance( rt.rgb ) - flBaseLum ) - 0.1 ); + flEdge *= 5.0; + + // Average full 3x3 neighborhood of pixels giving more weight to the center sample + float3 vBlurColor = ( baseColor.rgb * 4.0f ) + up.rgb + dn.rgb + lf.rgb + rt.rgb + dnrt.rgb + uprt.rgb + dnlf.rgb + uplf.rgb; + vBlurColor.rgb *= 0.0833333; // 1.0 / 12.0 + + // Lerp between crisp and blurry pixel based on edge mask + outColor.rgb = lerp( baseColor.rgb, vBlurColor.rgb, saturate( flEdge ) ); + } + #endif + + #if ( VOMIT_ENABLE == 1 ) + { + outColor.rgb = PerformVomitBlend( vVomitRefractParams.xyz, outColor.rgb, cBloomBlurredLum.aaa ); + } + #endif + + #if ( LOCAL_CONTRAST_ENABLE == 1 ) + { + float fMask = 1.0; + + // Extract midtones and limit contrast enhancement there + // TODO: This can probably go away for perf. + //float fBrightness = dot( outColor.rgb, float3( 0.3, 0.59, 0.11 ) ); + // bell-shaped mask + //fMask = smoothstep( 0.5 - g_flLocalContrastMidToneMask, 0.5, fBrightness ); + //fMask *= smoothstep( 0.5 + g_flLocalContrastMidToneMask, 0.5, fBrightness ); + + //fMask = smoothstep( 1.0, 0.5, fBrightness ); + + /* + // unsharp mask on luminance only + // This is the technically correct way, going to YUV, applying contrast to Y, and converting back to RGB + float3 outColorYUV; + outColorYUV.x = dot( outColor.rgb, float3( 0.299, 0.587, 0.114 ) ); + outColorYUV.y = dot( outColor.rgb, float3( -0.14713, -0.28886, 0.436 ) ); + outColorYUV.z = dot( outColor.rgb, float3( 0.615, -0.51499, -0.10001 ) ); + outColorYUV.x = outColorYUV.x + g_flLocalContrastStrength * fMask * ( outColorYUV.x - cBloomBlurredLum.aaa ); + outColor.r = dot( outColorYUV.xyz, float3( 1.0, 0.0, 1.13983 ) ); + outColor.g = dot( outColorYUV.xyz, float3( 1.0, -0.39465, -0.58060 ) ); + outColor.b = dot( outColorYUV.xyz, float3( 1.0, 2.03211, 0.0 ) ); + */ + + // This applies the delta contrast derived from the luminance to all color channels. The difference to the + // correct way is imperceptible. + float fLuminance = dot( outColor.rgb, float3( 0.299, 0.587, 0.114 ) ); + float fContrastLum = fLuminance + g_flLocalContrastStrength * ( fLuminance - cBloomBlurredLum.a ); + + // Mask off pixels that got very bright, to control super-contrast + //fMask = 1.0 - smoothstep( 0.3, 1.0, fContrastLum ); + + float2 vCenterDir = ( 2.0 * i.baseTexCoord.xy ) - 1.0; + float fMyVignette = smoothstep( g_flLocalContrastVignetteStart, g_flLocalContrastVignetteEnd, length( vCenterDir ) ); + float fMyVignette2 = fMyVignette; + fMyVignette = lerp( g_flLocalContrastStrength, g_flLocalContrastEdgeStrength, fMyVignette ); + + fMask = fMyVignette; + + // If the mask is positive, only brighten pixels. If the mask is negative, don't let it get less than -1.0. + //outColor.rgb += fMask * ( fLuminance - cBloomBlurredLum.aaa ); + outColor.rgb += max( fMask * ( fLuminance - cBloomBlurredLum.aaa ), -1.0 + step( 0.0, fMask ) ); // Selective clamp to positive adds 4 instructions + + #if ( BLURRED_VIGNETTE_ENABLE == 1 ) + outColor.rgb = lerp( outColor.rgb, cBloomBlurredLum.aaa, fMyVignette2 * g_flBlurredVignetteStrength ); #endif } #endif - float4 bloomColor = BloomFactor * GetBloomColor( i.baseTexCoord ); - outColor.rgb += bloomColor.rgb; - outColor = PerformColorCorrection( outColor, fbTexCoord ); - outColor = FinalOutput( outColor, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE ); - - // Go to linear since we're forced to do an sRGB write on OpenGL in ps2b - #if ( LINEAR_OUTPUT == 1 ) + // Composite bloom and full-screen + depth blur effects + #if ( DEPTH_BLUR_ENABLE ) { - outColor = GammaToLinear( outColor ); + float blurFactor = g_flBloomLerpFactor + abs( depthValue - g_flDepthBlurFocalDistance ) * g_flDepthBlurScale; + blurFactor = clamp( blurFactor, 0, 1 ); + outColor.rgb = lerp( outColor.rgb, cBloomBlurredLum.rgb, blurFactor ); + outColor.rgb += g_flBloomAmount * cBloomBlurredLum.rgb; + } + #else + { + outColor.rgb += g_flBloomAmount * cBloomBlurredLum.rgb; } #endif - return outColor; + // Used to be FADE_TYPE 0..2 combo + float3 vFadeDestColor = lerp( g_vViewFadeColor.rgb, g_vViewFadeColor.rgb * outColor.rgb, g_flFadeMode2 ); + outColor.rgb = lerp( outColor.rgb, vFadeDestColor.rgb, g_vViewFadeColor.a ); + + #if ( DESATURATEENABLE ) + { + float flLum = saturate( dot( outColor.rgb, float3( 0.3f, 0.59f, 0.11f) ) ); + outColor.rgb = lerp( saturate( outColor.rgb ), flLum.xxx, saturate( g_flDesaturation ) ); + } + #else + { + outColor = PerformColorCorrection( outColor ); // Color correction + } + #endif + + // Vignette + #if ( VIGNETTE_ENABLE == 1 ) + { + // Vignette + float2 vUv = i.baseTexCoord.xy; + //float2 vTmp = ( vUv.xy * 2.0 ) - 1.0; + float flVignette; + + //flVignette = 1.0 - pow( abs( vTmp.x ), 6.0f ); + //flVignette *= 1.0 - pow( abs( vTmp.y ), 6.0f ); + //flVignette = 1.0 - ( 1.0 - flVignette ) * ( ( saturate( ( 1.0 - vUv.y ) - 0.3 ) / 0.7 ) ); + + // This tex2D solves the 3 lines of math above + flVignette = tex2D( VignetteSampler, vUv.xy ).r; // Red is for the PC + flVignette = saturate( flVignette * 0.55 + 0.46 ); + + outColor.rgb *= flVignette; + } + #endif + + // Noise + #if ( NOISE_ENABLE == 1 ) + { + // Additive Noise + float2 vUv0 = i.baseTexCoord.xy * 10.0 + g_flTime; + float2 vUv1 = i.baseTexCoord.yx * 20.0 - g_flTime; + float2 vNoiseTexelUv; + vNoiseTexelUv.x = tex2D( NoiseSampler, vUv0.xy ).g; + vNoiseTexelUv.y = tex2D( NoiseSampler, vUv1.xy ).g; + float flNoiseTexel = tex2D( NoiseSampler, vNoiseTexelUv.xy ).g; + + float3 vTmp = { 0.2125f, 0.7154f, 0.0721f }; + float flLuminance = saturate( dot( outColor.rgb, vTmp.rgb ) ); + + float flNoiseScalar = 0.2f + 0.8f * ( saturate( pow( 1.0 - flLuminance, 12.0 ) ) ); + outColor.rgb += ( ( flNoiseTexel * 0.3f ) - 0.15f ) * g_flNoiseScalar * flNoiseScalar; + } + #endif + + // Fade to black + outColor.rgb = lerp( outColor.rgb, 0.0, g_flFadeToBlackStrength ); + + #if TV_GAMMA + { + // Used for SFM to record movies in native TV gamma space + outColor.rgb = SrgbGammaToTvGamma( outColor.rgb ); + } + #endif + + #if ( CONVERT_TO_LINEAR == 1 ) + { + // If we have a float back buffer, we want to remain in linear space after this shader + outColor.rgb = SrgbGammaToLinear( outColor.rgb ); + } + #endif + + return FinalOutput( outColor, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE ); } diff --git a/src/materialsystem/stdshaders/ShatteredGlass_ps2x.fxc b/src/materialsystem/stdshaders/ShatteredGlass_ps2x.fxc index c0df0444..85d55107 100644 --- a/src/materialsystem/stdshaders/ShatteredGlass_ps2x.fxc +++ b/src/materialsystem/stdshaders/ShatteredGlass_ps2x.fxc @@ -1,13 +1,18 @@ -// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] -// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// + // STATIC: "CUBEMAP" "0..1" // STATIC: "VERTEXCOLOR" "0..1" // STATIC: "ENVMAPMASK" "0..1" // STATIC: "BASEALPHAENVMAPMASK" "0..1" // STATIC: "HDRTYPE" "0..2" +// STATIC: "PARALLAXCORRECT" "0..1" + +// DYNAMIC: "PIXELFOGTYPE" "0..1" + +// SKIP: $PARALLAXCORRECT && !$CUBEMAP +// SKIP: $PARALLAXCORRECT [ps20] -// DYNAMIC: "HDRENABLED" "0..1" -// DYNAMIC: "PIXELFOGTYPE" "0..1" +#include "common_ps_fxc.h" // HDRFIXME: Need to make this work. @@ -26,6 +31,12 @@ const HALF3 g_OverbrightFactor : register( c6 ); const HALF4 g_FogParams : register( c12 ); +// Parallax cubemaps +#if (PARALLAXCORRECT) +const float3 cubemapPos : register(c7); +const float4x4 obbMatrix : register(c8); //through c11 +#endif + // CENTROID: TEXCOORD2 sampler BaseTextureSampler : register( s0 ); @@ -45,7 +56,6 @@ struct PS_INPUT HALF4 worldPos_projPosZ : TEXCOORD4; HALF3 worldSpaceNormal : TEXCOORD5; HALF4 vertexColor : COLOR; - HALF4 fogFactorW : COLOR1; }; float4 main( PS_INPUT i ) : COLOR @@ -107,6 +117,25 @@ float4 main( PS_INPUT i ) : COLOR HALF fresnel = 1.0 - dot( worldSpaceNormal, worldVertToEyeVector ); fresnel = pow( fresnel, 5.0 ); fresnel = fresnel * g_FresnelReflection.b + g_FresnelReflection.a; + + //Parallax correction (2_0b and beyond) + //Adapted from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ +#if !(defined(SHADER_MODEL_PS_1_1) || defined(SHADER_MODEL_PS_1_4) || defined(SHADER_MODEL_PS_2_0)) +#if (PARALLAXCORRECT) + float3 worldPos = i.worldPos_projPosZ.xyz; + float3 positionLS = mul(float4(worldPos, 1), obbMatrix); + float3 rayLS = mul(reflectVect, (float3x3) obbMatrix); + + float3 firstPlaneIntersect = (float3(1.0f, 1.0f, 1.0f) - positionLS) / rayLS; + float3 secondPlaneIntersect = (-positionLS) / rayLS; + float3 furthestPlane = max(firstPlaneIntersect, secondPlaneIntersect); + float distance = min(furthestPlane.x, min(furthestPlane.y, furthestPlane.z)); + + // Use distance in WS directly to recover intersection + float3 intersectPositionWS = worldPos + reflectVect * distance; + reflectVect = intersectPositionWS - cubemapPos; +#endif +#endif specularLighting = texCUBE( EnvmapSampler, reflectVect ); specularLighting *= specularFactor; @@ -124,7 +153,7 @@ float4 main( PS_INPUT i ) : COLOR // Do it somewhat unlit HALF3 result = albedo*(g_OverbrightFactor.z*diffuseLighting + g_OverbrightFactor.y) + specularLighting; - float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.z, i.worldPos_projPosZ.z, i.worldPos_projPosZ.w ); + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); return FinalOutput( HALF4( result, alpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR ); } diff --git a/src/materialsystem/stdshaders/WorldVertexTransition_vs20.fxc b/src/materialsystem/stdshaders/WorldVertexTransition_vs20.fxc index 5f18ca81..f5d88b1e 100644 --- a/src/materialsystem/stdshaders/WorldVertexTransition_vs20.fxc +++ b/src/materialsystem/stdshaders/WorldVertexTransition_vs20.fxc @@ -39,7 +39,7 @@ VS_OUTPUT main( const VS_INPUT v ) float2 texCoord; worldPos = mul( v.vPos, cModel[0] ); float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj ); - o.projPos = projPos; + o.projPos = vProjPos; vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); o.fogFactorW = CalcFog( worldPos, vProjPos, g_FogType ); #if !defined( _X360 ) diff --git a/src/materialsystem/stdshaders/blurgaussian_3x3_ps2x.fxc b/src/materialsystem/stdshaders/blurgaussian_3x3_ps2x.fxc new file mode 100644 index 00000000..5dbf655e --- /dev/null +++ b/src/materialsystem/stdshaders/blurgaussian_3x3_ps2x.fxc @@ -0,0 +1,22 @@ +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// + +sampler g_texSampler : register( s0 ); + +struct PS_INPUT +{ + float2 uv : TEXCOORD0; +}; + +float2 g_vPsTapOffsets[2] : register( c0 ); + +float4 main( PS_INPUT i ) : COLOR +{ + float4 cOut; + + cOut = 0.25 * tex2D( g_texSampler, i.uv + g_vPsTapOffsets[0] ); + cOut += 0.25 * tex2D( g_texSampler, i.uv - g_vPsTapOffsets[0] ); + cOut += 0.25 * tex2D( g_texSampler, i.uv + g_vPsTapOffsets[1] ); + cOut += 0.25 * tex2D( g_texSampler, i.uv - g_vPsTapOffsets[1] ); + + return cOut; +} diff --git a/src/materialsystem/stdshaders/buildmapbaseshaders.bat b/src/materialsystem/stdshaders/buildmapbaseshaders.bat new file mode 100644 index 00000000..fb559b03 --- /dev/null +++ b/src/materialsystem/stdshaders/buildmapbaseshaders.bat @@ -0,0 +1,14 @@ +@echo off +setlocal + +set BUILD_SHADER=call buildshaders.bat + +set SOURCE_DIR="..\..\" + +rem Change me to your mod's name! +set GAME_DIR="..\..\..\game\mod_tf" + +%BUILD_SHADER% mapbaseshaders_dx9_20b -game %GAME_DIR% -source %SOURCE_DIR% +%BUILD_SHADER% mapbaseshaders_dx9_30 -game %GAME_DIR% -source %SOURCE_DIR% -force30 + +pause diff --git a/src/materialsystem/stdshaders/buildmapbaseshaders_dynamic.bat b/src/materialsystem/stdshaders/buildmapbaseshaders_dynamic.bat new file mode 100644 index 00000000..6f8dd9b2 --- /dev/null +++ b/src/materialsystem/stdshaders/buildmapbaseshaders_dynamic.bat @@ -0,0 +1,5 @@ +rem This is for if you are using dynamic shader compilation, and just want the .incs to build. + +set dynamic_shaders=1 +call buildmapbaseshaders.bat +set dynamic_shaders= diff --git a/src/materialsystem/stdshaders/common_flashlight_fxc.h b/src/materialsystem/stdshaders/common_flashlight_fxc.h index 098f1848..9c77889c 100644 --- a/src/materialsystem/stdshaders/common_flashlight_fxc.h +++ b/src/materialsystem/stdshaders/common_flashlight_fxc.h @@ -10,6 +10,9 @@ #include "common_ps_fxc.h" +#if defined(SHADER_MODEL_PS_3_0) +//#define NEW_SHADOW_FILTERS // Comment if you want to enable retail shadow filter. +#endif // JasonM - TODO: remove this simpleton version float DoShadow( sampler DepthSampler, float4 texCoord ) @@ -100,12 +103,16 @@ float DoShadowNvidiaCheap( sampler DepthSampler, const float4 shadowMapPos ) return dot(vTaps, float4(0.25, 0.25, 0.25, 0.25)); } +#if defined( NEW_SHADOW_FILTERS ) +float DoShadowNvidiaPCF3x3Box( sampler DepthSampler, const float3 shadowMapPos ) +#else float DoShadowNvidiaPCF3x3Box( sampler DepthSampler, const float4 shadowMapPos ) +#endif { - float fTexelEpsilon = 1.0f / 1024.0f; + float fTexelEpsilon = 1.0f / 512.0f; - float ooW = 1.0f / shadowMapPos.w; // 1 / w - float3 shadowMapCenter_objDepth = shadowMapPos.xyz * ooW; // Do both projections at once + //float ooW = 1.0f; //1.0f / shadowMapPos.w; // 1 / w + float3 shadowMapCenter_objDepth = shadowMapPos.xyz; // * ooW; // Do both projections at once float2 shadowMapCenter = shadowMapCenter_objDepth.xy; // Center of shadow filter float objDepth = shadowMapCenter_objDepth.z; // Object depth in shadow space @@ -138,61 +145,80 @@ float DoShadowNvidiaPCF3x3Box( sampler DepthSampler, const float4 shadowMapPos ) // 4 20 33 20 4 // 1 4 7 4 1 // +#if defined( NEW_SHADOW_FILTERS ) +float DoShadowNvidiaPCF5x5Gaussian( sampler DepthSampler, const float3 shadowMapPos, const float2 vShadowTweaks ) +#else float DoShadowNvidiaPCF5x5Gaussian( sampler DepthSampler, const float4 shadowMapPos ) +#endif { - float fEpsilon = 1.0f / 512.0f; - float fTwoEpsilon = 2.0f * fEpsilon; +#if defined( NEW_SHADOW_FILTERS ) + float fEpsilonX = vShadowTweaks.x; + float fTwoEpsilonX = 2.0f * fEpsilonX; + float fEpsilonY = vShadowTweaks.y; + float fTwoEpsilonY = 2.0f * fEpsilonY; +#else + float fEpsilonX = 1.0 / 512.0; + float fTwoEpsilonX = 2.0f * fEpsilonX; + float fEpsilonY = fEpsilonX; + float fTwoEpsilonY = fTwoEpsilonX; +#endif +#if defined( NEW_SHADOW_FILTERS ) + // I guess we don't need this one. + // float ooW = 1.0f / shadowMapPos.w; // 1 / w + float3 shadowMapCenter_objDepth = shadowMapPos; // Do both projections at once +#else float ooW = 1.0f / shadowMapPos.w; // 1 / w float3 shadowMapCenter_objDepth = shadowMapPos.xyz * ooW; // Do both projections at once +#endif float2 shadowMapCenter = shadowMapCenter_objDepth.xy; // Center of shadow filter float objDepth = shadowMapCenter_objDepth.z; // Object depth in shadow space float4 vOneTaps; - vOneTaps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilon, fTwoEpsilon ), objDepth, 1 ) ).x; - vOneTaps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilon, fTwoEpsilon ), objDepth, 1 ) ).x; - vOneTaps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilon, -fTwoEpsilon ), objDepth, 1 ) ).x; - vOneTaps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilon, -fTwoEpsilon ), objDepth, 1 ) ).x; + vOneTaps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilonX, fTwoEpsilonY ), objDepth, 1 ) ).x; + vOneTaps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilonX, fTwoEpsilonY ), objDepth, 1 ) ).x; + vOneTaps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilonX, -fTwoEpsilonY ), objDepth, 1 ) ).x; + vOneTaps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilonX, -fTwoEpsilonY ), objDepth, 1 ) ).x; float flOneTaps = dot( vOneTaps, float4(1.0f / 331.0f, 1.0f / 331.0f, 1.0f / 331.0f, 1.0f / 331.0f)); float4 vSevenTaps; - vSevenTaps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilon, 0 ), objDepth, 1 ) ).x; - vSevenTaps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilon, 0 ), objDepth, 1 ) ).x; - vSevenTaps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fTwoEpsilon ), objDepth, 1 ) ).x; - vSevenTaps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fTwoEpsilon ), objDepth, 1 ) ).x; + vSevenTaps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilonX, 0 ), objDepth, 1 ) ).x; + vSevenTaps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilonX, 0 ), objDepth, 1 ) ).x; + vSevenTaps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, fTwoEpsilonY ), objDepth, 1 ) ).x; + vSevenTaps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fTwoEpsilonY ), objDepth, 1 ) ).x; float flSevenTaps = dot( vSevenTaps, float4( 7.0f / 331.0f, 7.0f / 331.0f, 7.0f / 331.0f, 7.0f / 331.0f ) ); float4 vFourTapsA, vFourTapsB; - vFourTapsA.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilon, fEpsilon ), objDepth, 1 ) ).x; - vFourTapsA.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilon, fTwoEpsilon ), objDepth, 1 ) ).x; - vFourTapsA.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilon, fTwoEpsilon ), objDepth, 1 ) ).x; - vFourTapsA.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilon, fEpsilon ), objDepth, 1 ) ).x; - vFourTapsB.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilon, -fEpsilon ), objDepth, 1 ) ).x; - vFourTapsB.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilon, -fTwoEpsilon ), objDepth, 1 ) ).x; - vFourTapsB.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilon, -fTwoEpsilon ), objDepth, 1 ) ).x; - vFourTapsB.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilon, -fEpsilon ), objDepth, 1 ) ).x; + vFourTapsA.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilonX, fEpsilonY ), objDepth, 1 ) ).x; + vFourTapsA.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilonX, fTwoEpsilonY ), objDepth, 1 ) ).x; + vFourTapsA.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilonX, fTwoEpsilonY ), objDepth, 1 ) ).x; + vFourTapsA.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilonX, fEpsilonY ), objDepth, 1 ) ).x; + vFourTapsB.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilonX, -fEpsilonY ), objDepth, 1 ) ).x; + vFourTapsB.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilonX, -fTwoEpsilonY ), objDepth, 1 ) ).x; + vFourTapsB.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilonX, -fTwoEpsilonY ), objDepth, 1 ) ).x; + vFourTapsB.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilonX, -fEpsilonY ), objDepth, 1 ) ).x; float flFourTapsA = dot( vFourTapsA, float4( 4.0f / 331.0f, 4.0f / 331.0f, 4.0f / 331.0f, 4.0f / 331.0f ) ); float flFourTapsB = dot( vFourTapsB, float4( 4.0f / 331.0f, 4.0f / 331.0f, 4.0f / 331.0f, 4.0f / 331.0f ) ); float4 v20Taps; - v20Taps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilon, fEpsilon ), objDepth, 1 ) ).x; - v20Taps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilon, fEpsilon ), objDepth, 1 ) ).x; - v20Taps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilon, -fEpsilon ), objDepth, 1 ) ).x; - v20Taps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilon, -fEpsilon ), objDepth, 1 ) ).x; + v20Taps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilonX, fEpsilonY ), objDepth, 1 ) ).x; + v20Taps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilonX, fEpsilonY ), objDepth, 1 ) ).x; + v20Taps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilonX, -fEpsilonY ), objDepth, 1 ) ).x; + v20Taps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilonX, -fEpsilonY ), objDepth, 1 ) ).x; float fl20Taps = dot( v20Taps, float4(20.0f / 331.0f, 20.0f / 331.0f, 20.0f / 331.0f, 20.0f / 331.0f)); float4 v33Taps; - v33Taps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilon, 0 ), objDepth, 1 ) ).x; - v33Taps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilon, 0 ), objDepth, 1 ) ).x; - v33Taps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fEpsilon ), objDepth, 1 ) ).x; - v33Taps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fEpsilon ), objDepth, 1 ) ).x; + v33Taps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilonX, 0 ), objDepth, 1 ) ).x; + v33Taps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilonX, 0 ), objDepth, 1 ) ).x; + v33Taps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, fEpsilonY ), objDepth, 1 ) ).x; + v33Taps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fEpsilonY ), objDepth, 1 ) ).x; float fl33Taps = dot( v33Taps, float4(33.0f / 331.0f, 33.0f / 331.0f, 33.0f / 331.0f, 33.0f / 331.0f)); float flCenterTap = tex2Dproj( DepthSampler, float4( shadowMapCenter, objDepth, 1 ) ).x * (55.0f / 331.0f); // Sum all 25 Taps - return flOneTaps + flSevenTaps + +flFourTapsA + flFourTapsB + fl20Taps + fl33Taps + flCenterTap; + return flOneTaps + flSevenTaps + flFourTapsA + flFourTapsB + fl20Taps + fl33Taps + flCenterTap; } @@ -601,7 +627,12 @@ float DoFlashlightShadow( sampler DepthSampler, sampler RandomRotationSampler, f #if !defined( _X360 ) //PC if( nShadowLevel == NVIDIA_PCF_POISSON ) +#if defined( NEW_SHADOW_FILTERS ) && defined( SHADER_MODEL_PS_3_0 ) + // Let's replace noise filter with gaussian blur, like in Portal 2. + flShadow = DoShadowNvidiaPCF5x5Gaussian( DepthSampler, vProjCoords, float2( vShadowTweaks.x, vShadowTweaks.x ) ); +#else flShadow = DoShadowPoisson16Sample( DepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, vShadowTweaks, true, false ); +#endif else if( nShadowLevel == ATI_NOPCF ) flShadow = DoShadowPoisson16Sample( DepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, vShadowTweaks, false, false ); else if( nShadowLevel == ATI_NO_PCF_FETCH4 ) @@ -660,6 +691,12 @@ void DoSpecularFlashlight( float3 flashlightPos, float3 worldPos, float4 flashli { float3 vProjCoords = flashlightSpacePosition.xyz / flashlightSpacePosition.w; float3 flashlightColor = float3(1,1,1); + + // Blixibon - Fix for flashlight textures without Clamp S/T +#if defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) + clip( vProjCoords.xyz ); + clip( 1-vProjCoords.xyz ); +#endif #if ( defined( _X360 ) ) @@ -691,6 +728,7 @@ void DoSpecularFlashlight( float3 flashlightPos, float3 worldPos, float4 flashli #if defined(SHADER_MODEL_PS_2_0) || defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) + flashlightColor *= flashlightSpacePosition.w > 0; flashlightColor *= cFlashlightColor.xyz; // Flashlight color #endif @@ -702,7 +740,7 @@ void DoSpecularFlashlight( float3 flashlightPos, float3 worldPos, float4 flashli float endFalloffFactor = RemapValClamped( dist, farZ, 0.6f * farZ, 0.0f, 1.0f ); // Attenuation for light and to fade out shadow over distance - float fAtten = saturate( dot( attenuationFactors, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) ); + float fAtten = saturate( endFalloffFactor * dot( attenuationFactors, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) ); // Shadowing and coloring terms #if (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0)) @@ -722,7 +760,9 @@ void DoSpecularFlashlight( float3 flashlightPos, float3 worldPos, float4 flashli diffuseLighting *= saturate( dot( L.xyz, worldNormal.xyz ) ); // Lambertian (not Half-Lambert) term #endif diffuseLighting *= flashlightColor; - diffuseLighting *= endFalloffFactor; + + // Blixibon - Now calculating endFalloffFactor directly from fAtten + //diffuseLighting *= endFalloffFactor; // Specular term (masked by diffuse) specularLighting = diffuseLighting * SpecularLight ( worldNormal, L, fSpecularExponent, vEyeDir, bDoSpecularWarp, specularWarpSampler, fFresnel ); @@ -734,29 +774,28 @@ float3 DoFlashlight( float3 flashlightPos, float3 worldPos, float4 flashlightSpa sampler RandomRotationSampler, int nShadowLevel, bool bDoShadows, bool bAllowHighQuality, const float2 vScreenPos, bool bClip, float4 vShadowTweaks = float4(3/1024.0f, 0.0005f, 0.0f, 0.0f), bool bHasNormal = true ) { - float3 vProjCoords = flashlightSpacePosition.xyz / flashlightSpacePosition.w; - float3 flashlightColor = float3(1,1,1); - -#if ( defined( _X360 ) ) - - float3 ltz = vProjCoords.xyz < float3( 0.0f, 0.0f, 0.0f ); - float3 gto = vProjCoords.xyz > float3( 1.0f, 1.0f, 1.0f ); - - [branch] - if ( dot(ltz + gto, float3(1,1,1)) > 0 ) + if ( flashlightSpacePosition.w < 0 ) { - if ( bClip ) - { - clip(-1); - } return float3(0,0,0); } else { - flashlightColor = tex2D( FlashlightSampler, vProjCoords ); + float3 vProjCoords = flashlightSpacePosition.xyz / flashlightSpacePosition.w; + float3 flashlightColor = float3(1,1,1); + + // Blixibon - Fix for flashlight textures without Clamp S/T +#if defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) + clip( vProjCoords.xyz ); + clip( 1-vProjCoords.xyz ); +#endif + +#if ( defined( _X360 ) ) + + float3 ltz = vProjCoords.xyz < float3( 0.0f, 0.0f, 0.0f ); + float3 gto = vProjCoords.xyz > float3( 1.0f, 1.0f, 1.0f ); [branch] - if ( dot(flashlightColor.xyz, float3(1,1,1)) <= 0 ) + if ( dot(ltz + gto, float3(1,1,1)) > 0 ) { if ( bClip ) { @@ -764,58 +803,74 @@ float3 DoFlashlight( float3 flashlightPos, float3 worldPos, float4 flashlightSpa } return float3(0,0,0); } - } + else + { + flashlightColor = tex2D( FlashlightSampler, vProjCoords ); + + [branch] + if ( dot(flashlightColor.xyz, float3(1,1,1)) <= 0 ) + { + if ( bClip ) + { + clip(-1); + } + return float3(0,0,0); + } + } #else - flashlightColor = tex2D( FlashlightSampler, vProjCoords ); + flashlightColor = tex2D( FlashlightSampler, vProjCoords ); #endif #if defined(SHADER_MODEL_PS_2_0) || defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) - flashlightColor *= cFlashlightColor.xyz; // Flashlight color + flashlightColor *= cFlashlightColor.xyz; // Flashlight color #endif - float3 delta = flashlightPos - worldPos; - float3 L = normalize( delta ); - float distSquared = dot( delta, delta ); - float dist = sqrt( distSquared ); + float3 delta = flashlightPos - worldPos; + float3 L = normalize( delta ); + float distSquared = dot( delta, delta ); + float dist = sqrt( distSquared ); - float endFalloffFactor = RemapValClamped( dist, farZ, 0.6f * farZ, 0.0f, 1.0f ); + float endFalloffFactor = RemapValClamped( dist, farZ, 0.6f * farZ, 0.0f, 1.0f ); - // Attenuation for light and to fade out shadow over distance - float fAtten = saturate( dot( attenuationFactors, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) ); + // Attenuation for light and to fade out shadow over distance + float fAtten = saturate( endFalloffFactor * dot( attenuationFactors, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) ); - // Shadowing and coloring terms + // Shadowing and coloring terms #if (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0)) - if ( bDoShadows ) - { - float flShadow = DoFlashlightShadow( FlashlightDepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, nShadowLevel, vShadowTweaks, bAllowHighQuality ); - float flAttenuated = lerp( flShadow, 1.0f, vShadowTweaks.y ); // Blend between fully attenuated and not attenuated - flShadow = saturate( lerp( flAttenuated, flShadow, fAtten ) ); // Blend between shadow and above, according to light attenuation - flashlightColor *= flShadow; // Shadow term - } + if ( bDoShadows ) + { + float flShadow = DoFlashlightShadow( FlashlightDepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, nShadowLevel, vShadowTweaks, bAllowHighQuality ); + float flAttenuated = lerp( flShadow, 1.0f, vShadowTweaks.y ); // Blend between fully attenuated and not attenuated + flShadow = saturate( lerp( flAttenuated, flShadow, fAtten ) ); // Blend between shadow and above, according to light attenuation + flashlightColor *= flShadow; // Shadow term + } #endif - float3 diffuseLighting = fAtten; + float3 diffuseLighting = fAtten; - float flLDotWorldNormal; - if ( bHasNormal ) - { - flLDotWorldNormal = dot( L.xyz, worldNormal.xyz ); - } - else - { - flLDotWorldNormal = 1.0f; - } + float flLDotWorldNormal; + if ( bHasNormal ) + { + flLDotWorldNormal = dot( L.xyz, worldNormal.xyz ); + } + else + { + flLDotWorldNormal = 1.0f; + } #if defined(SHADER_MODEL_PS_2_0) || defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) - diffuseLighting *= saturate( flLDotWorldNormal + flFlashlightNoLambertValue ); // Lambertian term + diffuseLighting *= saturate( flLDotWorldNormal + flFlashlightNoLambertValue ); // Lambertian term #else - diffuseLighting *= saturate( flLDotWorldNormal ); // Lambertian (not Half-Lambert) term + diffuseLighting *= saturate( flLDotWorldNormal ); // Lambertian (not Half-Lambert) term #endif - diffuseLighting *= flashlightColor; - diffuseLighting *= endFalloffFactor; + diffuseLighting *= flashlightColor; + + // Blixibon - Now calculating endFalloffFactor directly from fAtten + //diffuseLighting *= endFalloffFactor; - return diffuseLighting; + return diffuseLighting; + } } -#endif //#ifndef COMMON_FLASHLIGHT_FXC_H_ +#endif //#ifndef COMMON_FLASHLIGHT_FXC_H_ \ No newline at end of file diff --git a/src/materialsystem/stdshaders/common_ps_fxc.h b/src/materialsystem/stdshaders/common_ps_fxc.h index ee18040b..9a6a6798 100644 --- a/src/materialsystem/stdshaders/common_ps_fxc.h +++ b/src/materialsystem/stdshaders/common_ps_fxc.h @@ -193,7 +193,7 @@ float4 DecompressNormal( sampler NormalSampler, float2 tc, int nDecompressionMod HALF3 NormalizeWithCubemap( sampler normalizeSampler, HALF3 input ) { // return texCUBE( normalizeSampler, input ) * 2.0f - 1.0f; - return texCUBE( normalizeSampler, input ); + return texCUBE( normalizeSampler, input ).xyz; } /* @@ -210,8 +210,17 @@ HALF4 EnvReflect( sampler envmapSampler, } */ +// Vectorized smoothstep for doing three smoothsteps at once. Used by uberlight +float3 smoothstep3( float3 edge0, float3 edge1, float3 OneOverWidth, float3 x ) +{ + x = saturate((x - edge0) * OneOverWidth); // Scale, bias and saturate x to the range of zero to one + return x*x*(3-2*x); // Evaluate polynomial +} + float CalcWaterFogAlpha( const float flWaterZ, const float flEyePosZ, const float flWorldPosZ, const float flProjPosZ, const float flFogOORange ) { +#if 0 + // This version is what you use if you want a line-integral throught he water for water fog. // float flDepthFromWater = flWaterZ - flWorldPosZ + 2.0f; // hackity hack . .this is for the DF_FUDGE_UP in view_scene.cpp float flDepthFromWater = flWaterZ - flWorldPosZ; @@ -227,6 +236,13 @@ float CalcWaterFogAlpha( const float flWaterZ, const float flEyePosZ, const floa // $tmp.w is now the distance that we see through water. return saturate(f * flProjPosZ * flFogOORange); +#else + // This version is simply using the depth of the water to determine fog factor, + // which is cheaper than doing the line integral and also fixes some problems with having + // a hard line on the shore when the water surface is viewed tangentially. + // hackity hack . .the 2.0 is for the DF_FUDGE_UP in view_scene.cpp + return saturate( ( flWaterZ - flWorldPosZ - 2.0f ) * flFogOORange ); +#endif } float CalcRangeFog( const float flProjPosZ, const float flFogStartOverRange, const float flFogMaxDensity, const float flFogOORange ) @@ -283,23 +299,25 @@ float CalcPixelFogFactor( int iPIXELFOGTYPE, const float4 fogParams, const float float3 BlendPixelFog( const float3 vShaderColor, float pixelFogFactor, const float3 vFogColor, const int iPIXELFOGTYPE ) { + float3 flRet = 0; if( iPIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE || iPIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE_RADIAL ) //either range fog or no fog depending on fog parameters and whether this is ps20 or ps2b { # if !(defined(SHADER_MODEL_PS_1_1) || defined(SHADER_MODEL_PS_1_4) || defined(SHADER_MODEL_PS_2_0)) //Minimum requirement of ps2b pixelFogFactor = saturate( pixelFogFactor ); - return lerp( vShaderColor.rgb, vFogColor.rgb, pixelFogFactor * pixelFogFactor ); //squaring the factor will get the middle range mixing closer to hardware fog + flRet = lerp( vShaderColor.rgb, vFogColor.rgb, pixelFogFactor * pixelFogFactor ); //squaring the factor will get the middle range mixing closer to hardware fog # else - return vShaderColor; + flRet = vShaderColor; # endif } else if( iPIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT ) { - return lerp( vShaderColor.rgb, vFogColor.rgb, saturate( pixelFogFactor ) ); + flRet = lerp( vShaderColor.rgb, vFogColor.rgb, saturate( pixelFogFactor ) ); } else if( iPIXELFOGTYPE == PIXEL_FOG_TYPE_NONE ) { - return vShaderColor; + flRet = vShaderColor; } + return flRet; } diff --git a/src/materialsystem/stdshaders/common_splinerope_fxc.h b/src/materialsystem/stdshaders/common_splinerope_fxc.h new file mode 100644 index 00000000..0893d1d2 --- /dev/null +++ b/src/materialsystem/stdshaders/common_splinerope_fxc.h @@ -0,0 +1,26 @@ +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// + +#ifdef PIXELSHADER + #define VS_OUTPUT PS_INPUT +#endif + +struct VS_OUTPUT +{ +#ifndef PIXELSHADER + float4 projPos : POSITION; +#endif + + float2 texCoord : TEXCOORD0; + float4 worldPos_projPosZ : TEXCOORD1; + float4 argbcolor : COLOR; + +#ifndef PIXELSHADER + #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) + float fog : FOG; + #endif +#endif +}; + +#ifdef PIXELSHADER + #undef VS_OUTPUT +#endif diff --git a/src/materialsystem/stdshaders/core_dx9.cpp b/src/materialsystem/stdshaders/core_dx9.cpp index 4be8f3c9..4a1abda7 100644 --- a/src/materialsystem/stdshaders/core_dx9.cpp +++ b/src/materialsystem/stdshaders/core_dx9.cpp @@ -37,6 +37,10 @@ BEGIN_VS_SHADER( Core_DX90, SHADER_PARAM( CORECOLORTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "" ); SHADER_PARAM( CORECOLORTEXTUREFRAME, SHADER_PARAM_TYPE_INTEGER, "", "" ); SHADER_PARAM( FLOWMAPTEXCOORDOFFSET, SHADER_PARAM_TYPE_FLOAT, "0.0", "" ); +#ifdef MAPBASE + SHADER_PARAM( SPHERECENTER, SHADER_PARAM_TYPE_VEC3, "2688.0, 12139.0, 5170.0", "The sphere's worldspace center (was previously hardcoded)" ); + SHADER_PARAM( SPHERERADIUS, SHADER_PARAM_TYPE_FLOAT, "215.0", "The sphere's worldspace radius (was previously hardcoded)" ); +#endif END_SHADER_PARAMS SHADER_INIT_PARAMS() { @@ -285,6 +289,11 @@ BEGIN_VS_SHADER( Core_DX90, SetPixelShaderConstant( 9, FLOWMAPTEXCOORDOFFSET ); } + +#ifdef MAPBASE + SetPixelShaderConstant( 12, SPHERECENTER ); + SetPixelShaderConstant( 15, SPHERERADIUS ); +#endif } Draw(); } diff --git a/src/materialsystem/stdshaders/core_ps2x.fxc b/src/materialsystem/stdshaders/core_ps2x.fxc index 9591aa88..63ac00f4 100644 --- a/src/materialsystem/stdshaders/core_ps2x.fxc +++ b/src/materialsystem/stdshaders/core_ps2x.fxc @@ -4,7 +4,7 @@ // //============================================================================= -// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] +// STATIC: "CONVERT_TO_SRGB" "0..0" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] // TEMPTEMP: New shader compiler cannot currently compile with CONVERT_TO_SRGB // STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] // STATIC: "CUBEMAP" "0..1" // STATIC: "FLOWMAP" "0..1" @@ -45,6 +45,10 @@ const float g_CoreColorTexCoordOffset : register( c9 ); const float3 g_EyePos : register( c8 ); const float4 g_FogParams : register( c11 ); + +const float3 g_SphereCenter : register( c12 ); +const float3 g_SphereRadius : register( c15 ); + float LengthThroughSphere( float3 vecRayOrigin, float3 vecRayDelta, float3 vecSphereCenter, float flRadius, out float alpha ) { @@ -125,10 +129,12 @@ float4 main( PS_INPUT i ) : COLOR HALF blend = 1.0f; #if FLOWMAP - // hack - float3 g_SphereCenter = { 2688.0f, 12139.0f, 5170.0f }; - float g_SphereDiameter = 430.0f; - float g_SphereRadius = g_SphereDiameter * 0.5f; + // Mapbase tries to un-hack some of this code + //float3 g_SphereCenter = { 2688.0f, 12139.0f, 5170.0f }; + //float g_SphereDiameter = 430.0f; + //float g_SphereRadius = g_SphereDiameter * 0.5f; + + float g_SphereDiameter = g_SphereRadius * 2.0f; float3 tmp = i.worldPos_projPosZ.xyz - g_SphereCenter; float hackRadius = 1.05f * sqrt( dot( tmp, tmp ) ); diff --git a/src/materialsystem/stdshaders/decalmodulate_ps2x.fxc b/src/materialsystem/stdshaders/decalmodulate_ps2x.fxc index 02a0d1ea..1e6f04f5 100644 --- a/src/materialsystem/stdshaders/decalmodulate_ps2x.fxc +++ b/src/materialsystem/stdshaders/decalmodulate_ps2x.fxc @@ -1,32 +1,53 @@ -//======= Copyright � 1996-2006, Valve Corporation, All rights reserved. ====== +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// +// paired with "vertexlit_and_unlit_generic_vs##" -// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] -// STATIC: "CONVERT_TO_SRGB" "0..1" [ps30][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] -// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +// STATIC: "VERTEXALPHA" "0..1" +// STATIC: "FLASHLIGHT" "0..1" +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps30] [PC] -// DYNAMIC: "PIXELFOGTYPE" "0..2" +// DYNAMIC: "PIXELFOGTYPE" "0..2" +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps30] [PC] + +// We don't care about flashlight depth unless the flashlight is on +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps20b] +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps30] + +// Flashlight shadow filter mode is irrelevant if there is no flashlight +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps20b] +// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps30] #include "common_ps_fxc.h" +#include "common_flashlight_fxc.h" #include "shader_constant_register_map.h" sampler TexSampler : register( s0 ); +sampler RandRotSampler : register( s6 ); // RandomRotation sampler +sampler FlashlightSampler : register( s7 ); +sampler ShadowDepthSampler : register( s8 ); // Flashlight shadow depth map sampler + const float4 g_FogParams : register( PSREG_FOG_PARAMS ); const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT ); +const float4 g_FogTweakParams : register( c0 ); +#define g_fFogExponentTweak g_FogTweakParams.x +#define g_fFogScaleTweak g_FogTweakParams.y + +const float4 g_FlashlightAttenuationFactors : register( c22 ); +const float3 g_FlashlightPos : register( c23 ); +const float4x4 g_FlashlightWorldToTexture : register( c24 ); // through c27 struct PS_INPUT { HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate - float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog - float4 fogFactorW : COLOR1; + float4 worldPos_projPosZ : TEXCOORD1; // Necessary for pixel fog + + float4 color : COLOR1; -#if defined( _X360 ) //matching pixel shader inputs to vertex shader outputs to avoid shader patches - HALF2 detailTexCoord : TEXCOORD1; - float4 color : TEXCOORD2; - float3 worldVertToEyeVector : TEXCOORD3; - float3 worldSpaceNormal : TEXCOORD4; - float4 vProjPos : TEXCOORD6; +#if FLASHLIGHT + float4 vProjPos : TEXCOORD2; #endif }; @@ -34,12 +55,47 @@ float4 main( PS_INPUT i ) : COLOR { float4 result = tex2D( TexSampler, i.baseTexCoord ); - float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); - + // Blend towards grey based on alpha + float flFactor = 1.0; +#if VERTEXALPHA + flFactor *= i.color.w; +#endif + +#if FLASHLIGHT + //if( bFlashlight ) + { + int nShadowSampleLevel = 0; + bool bDoShadows = false; + float2 vProjPos = float2(0, 0); +// On ps_2_b, we can do shadow mapping +#if ( FLASHLIGHTSHADOWS && (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0) ) ) + nShadowSampleLevel = FLASHLIGHTDEPTHFILTERMODE; + bDoShadows = FLASHLIGHTSHADOWS; + vProjPos = i.vProjPos.xy / i.vProjPos.w; // Screen-space position for shadow map noise +#endif + + float4 flashlightSpacePosition = mul( float4( i.worldPos_projPosZ.xyz, 1.0f ), g_FlashlightWorldToTexture ); + + float3 flashlightColor = DoFlashlight( g_FlashlightPos, i.worldPos_projPosZ.xyz, flashlightSpacePosition, + float3( 0.0f, 0.0f, 1.0f ), g_FlashlightAttenuationFactors.xyz, + g_FlashlightAttenuationFactors.w, FlashlightSampler, ShadowDepthSampler, + RandRotSampler, nShadowSampleLevel, bDoShadows, false, vProjPos, false, float4(3/1024.0f, 0.0005f, 0.0f, 0.0f), false ); + + flFactor *= (flashlightColor.x + flashlightColor.y + flashlightColor.z); + + //result.xyz *= flashlightColor.xyz; + + //result.a *= (flashlightColor.x * flashlightColor.y * flashlightColor.z); + } +#endif + + result.xyz = lerp( float3( 0.5, 0.5, 0.5 ), result.xyz, flFactor ); + // Since we're blending with a mod2x, we need to compensate with this hack // NOTE: If the fog color (not fog density) is extremely dark, this can makes some decals seem // a little transparent, but it's better than not doing this - fogFactor = pow( saturate( fogFactor ), 0.4f ); + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); + fogFactor = pow( saturate( g_fFogScaleTweak * fogFactor ), g_fFogExponentTweak ); return FinalOutput( result, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_NONE ); } diff --git a/src/materialsystem/stdshaders/decalmodulate_vs20.fxc b/src/materialsystem/stdshaders/decalmodulate_vs20.fxc new file mode 100644 index 00000000..0deb56b4 --- /dev/null +++ b/src/materialsystem/stdshaders/decalmodulate_vs20.fxc @@ -0,0 +1,155 @@ +// based on vertexlit_and_unlit_generic_vs20.fxc +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// + +// STATIC: "VERTEXCOLOR" "0..1" +// STATIC: "LIGHTING_PREVIEW" "0..1" [PC] +// STATIC: "LIGHTING_PREVIEW" "0..0" [XBOX] +// STATIC: "FLASHLIGHT" "0..1" + +// DYNAMIC: "DOWATERFOG" "0..1" +// DYNAMIC: "COMPRESSED_VERTS" "0..1" +// DYNAMIC: "SKINNING" "0..0" [vs20] +// DYNAMIC: "SKINNING" "0..1" [vs30] + +// DYNAMIC: "MORPHING" "0..1" [vs30] + +#include "common_vs_fxc.h" + +static const bool g_bSkinning = SKINNING ? true : false; +static const int g_FogType = DOWATERFOG; +static const bool g_bVertexColor = VERTEXCOLOR ? true : false; +#if ( defined( SHADER_MODEL_VS_3_0 ) && MORPHING ) + #define DECALOFFSET 1 +#else + #define DECALOFFSET 0 +#endif + +const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); + +#ifdef SHADER_MODEL_VS_3_0 +// NOTE: cMorphTargetTextureDim.xy = target dimensions, +// cMorphTargetTextureDim.z = 4tuples/morph +const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_10 ); +const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_11 ); +sampler2D morphSampler : register( s0 ); +#endif + +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; + float4 vColor : COLOR0; + float3 vSpecular : COLOR1; + // make these float2's and stick the [n n 0 1] in the dot math. + float4 vTexCoord0 : TEXCOORD0; + float4 vTexCoord1 : TEXCOORD1; + float4 vTexCoord2 : TEXCOORD2; + float4 vTexCoord3 : TEXCOORD3; + + // Position and normal/tangent deltas + float3 vPosFlex : POSITION1; + float3 vNormalFlex : NORMAL1; +#ifdef SHADER_MODEL_VS_3_0 + float vVertexID : POSITION2; +#endif +}; + + +struct VS_OUTPUT +{ + float4 projPos : POSITION; // Projection-space position +#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) + float fog : FOG; +#endif + + HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate + float4 worldPos_ProjPosZ : TEXCOORD1; + float4 color : COLOR1; // Vertex color (from lighting or unlit) + +#if FLASHLIGHT + float4 vProjPos : TEXCOORD2; +#endif +}; + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o = ( VS_OUTPUT )0; + + float4 vPosition = v.vPos; + float3 vNormal = 0; + if ( LIGHTING_PREVIEW || DECALOFFSET ) + { + // The vertex only contains valid normals if they are actually needed (fetching them when absent makes D3D complain) + DecompressVertex_Normal( v.vNormal, vNormal ); + } + +#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING + ApplyMorph( v.vPosFlex, v.vNormalFlex, vPosition.xyz, vNormal ); +#else + ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, + v.vVertexID, v.vTexCoord2, vPosition.xyz, vNormal ); +#endif + + // Perform skinning + float3 worldNormal, worldPos; + SkinPositionAndNormal( + g_bSkinning, + vPosition, vNormal, + v.vBoneWeights, v.vBoneIndices, + worldPos, worldNormal ); + + if ( !g_bVertexColor ) + { + worldNormal = normalize( worldNormal ); + } + +#if defined( SHADER_MODEL_VS_3_0 ) && MORPHING + // Avoid z precision errors + worldPos += worldNormal * 0.05f * v.vTexCoord2.z; +#endif + + // Transform into projection space + float4 projPos = mul( float4( worldPos, 1 ), cViewProj ); + o.projPos = projPos; + +#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) + o.fog = CalcFog( worldPos, projPos, g_FogType ); +#endif + +#if FLASHLIGHT + // Transform into projection space + projPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); + + o.vProjPos = projPos; +#endif + + o.worldPos_ProjPosZ.xyz = worldPos.xyz; + o.worldPos_ProjPosZ.w = projPos.z; + + if ( g_bVertexColor ) + { + // Assume that this is unlitgeneric if you are using vertex color. + o.color.rgb = GammaToLinear( v.vColor.rgb ); + o.color.a = v.vColor.a; + } + else + { + o.color = float4( 1.0f, 1.0f, 1.0f, 1.0f ); + } + + // Base texture coordinates + o.baseTexCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] ); + o.baseTexCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] ); + +#if LIGHTING_PREVIEW + float dot=0.5+0.5*worldNormal*float3(0.7071,0.7071,0); + o.color.xyz=float3(dot,dot,dot); +#endif + + return o; +} + + diff --git a/src/materialsystem/stdshaders/depth_of_field_ps20b.fxc b/src/materialsystem/stdshaders/depth_of_field_ps20b.fxc new file mode 100644 index 00000000..6eb5cb70 --- /dev/null +++ b/src/materialsystem/stdshaders/depth_of_field_ps20b.fxc @@ -0,0 +1,137 @@ +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// + +// DYNAMIC: "QUALITY" "0..3" + +// Includes ======================================================================================= +#include "common_ps_fxc.h" + +// Texture Samplers =============================================================================== +sampler g_tFullFB : register( s0 ); +sampler g_tSmallFB : register( s1 ); + +// Shaders Constants and Globals ================================================================== +float4 g_vDists : register( c0 ); +#define g_flNearBlurDist g_vDists.x +#define g_flNearFocusDist g_vDists.y +#define g_flFarFocusDist g_vDists.z +#define g_flFarBlurDist g_vDists.w + +float3 g_vBlurAmounts : register( c1 ); +#define g_flMaxBlurRadius g_vBlurAmounts.x +#define g_flNearBlurStrength g_vBlurAmounts.y +#define g_flFarBlurStrength g_vBlurAmounts.z + +float3 g_vNearFarDists : register( c2 ); +#define g_flNearPlaneDist g_vNearFarDists.x +#define g_flFarPlaneDist g_vNearFarDists.y +#define g_flDepthConv g_vNearFarDists.z + +float4 g_vMagicConsts : register( c3 ); + +#if ( QUALITY == 0 ) + #define NUM_SAMPLES 8 // These must match the C code +#elif ( QUALITY == 1 ) + #define NUM_SAMPLES 16 +#elif ( QUALITY == 2 ) + #define NUM_SAMPLES 16 +#elif ( QUALITY == 3 ) + #define NUM_SAMPLES 32 +#endif + +float4 g_vPoisson[ NUM_SAMPLES/2 ] : register( c4 ); + +// Interpolated values ============================================================================ +struct PS_INPUT +{ + float2 vUv0 : TEXCOORD0; +}; + +float DestAlphaDepthToViewSpaceDepth( float flDepth ) +{ + return g_flDepthConv * flDepth + g_flNearPlaneDist; +} + +// returns blur radius from depth as a fraction of max_blur. +float BlurAmountFromDepth( float flDestAlphaDepth ) +{ + /* + dist = DestAlphaDepthToViewSpaceDepth( flDestAlphaDepth ); + float flBlur = max( g_flNearBlurStrength * saturate( (flDestAlphaDepth - g_flNearFocusDist) / ( g_flNearBlurDist - g_flNearFocusDist ) ), + g_flFarBlurStrength * saturate( (flDestAlphaDepth - g_flFarFocusDist) / ( g_flFarBlurDist - g_flFarFocusDist ) ) ); + */ + + // A more optimized version that concatenates the math above and the one in DestAlphaDepthToViewSpaceDepth to a single muladd + float flBlur = max( g_flNearBlurStrength * saturate( g_vMagicConsts.x * flDestAlphaDepth + g_vMagicConsts.y ), + g_flFarBlurStrength * saturate( g_vMagicConsts.z * flDestAlphaDepth + g_vMagicConsts.w ) ); + return flBlur; +} + +float BlurRadiusFromDepth( float flDepth ) +{ + return g_flMaxBlurRadius * BlurAmountFromDepth( flDepth ); +} + +float4 ComputeTap( float flCenterDepth, float flCenterBlurRadius, float2 vUV, float2 vPoisson ) +{ + float4 cTapSmall; + float4 cTap; + float2 vPoissonUV = vUV.xy + flCenterBlurRadius * vPoisson.xy; + + cTapSmall = tex2D( g_tSmallFB, vPoissonUV.xy ); + cTap = tex2D( g_tFullFB, vPoissonUV.xy ); + + float flTapBlur = BlurAmountFromDepth( cTap.a ); // Maybe 50/50 mix between low and high here? + + cTap = lerp( cTap, cTapSmall, saturate( 2.2 * flTapBlur ) ); // TODO: tweak blur amount. + float flLerpedTapBlur = BlurAmountFromDepth( cTap.a ); + + float weight = ( cTap.a >= flCenterDepth ) ? 1.0 : ( flLerpedTapBlur*flLerpedTapBlur ); + return float4( cTap.rgb, 1 ) * weight; +} + +float4 ComputeTapHQ( float flCenterDepth, float flCenterBlurRadius, float2 vUV, float2 vPoisson ) +{ + float4 cTap; + + cTap = tex2D( g_tFullFB, vUV.xy + flCenterBlurRadius * vPoisson.xy ); + float flTapBlur = BlurAmountFromDepth( cTap.a ); + float weight = ( cTap.a >= flCenterDepth ) ? 1.0 : ( flTapBlur * flTapBlur ); + return float4( cTap.rgb, 1 ) * weight; +} + +// Main =========================================================================================== +float4 main( PS_INPUT i ) : COLOR +{ + // TODO: BETTER DOWNSAMPLE THAT TAKES DEPTH INTO ACCOUNT? + + float4 cOut = { 0, 0, 0, 0 }; + float4 cCenterTap = tex2D( g_tFullFB, i.vUv0 ); + float flCenterBlurRadius = BlurRadiusFromDepth( cCenterTap.a ); // circle of confusion radius for current pixel + cCenterTap.a -= 0.001; // z-bias to avoid strange banding artifact on almost orthogonal walls + +#if ( QUALITY < 2 ) + // ATI's Ruby1-style algorithm + for ( int t = 0; t < NUM_SAMPLES/2; t++ ) + { + cOut.rgba += ComputeTap( cCenterTap.a, flCenterBlurRadius, i.vUv0, g_vPoisson[t].xy ); + cOut.rgba += ComputeTap( cCenterTap.a, flCenterBlurRadius, i.vUv0, g_vPoisson[t].wz ); + } +#else + // Less fancy, with less fetches per tap and less math. Needs more samples to look smooth. + cOut = cCenterTap; + cOut.a = 1.0; // Use the center sample we just fetched + for ( int t = 0; t < NUM_SAMPLES/2; t++ ) + { + cOut.rgba += ComputeTapHQ( cCenterTap.a, flCenterBlurRadius, i.vUv0, g_vPoisson[t].xy ); + cOut.rgba += ComputeTapHQ( cCenterTap.a, flCenterBlurRadius, i.vUv0, g_vPoisson[t].wz ); + } +#endif + //cOut.rgb = cOut.a / float(NUM_SAMPLES+1); + //cOut = lerp( tex2D( g_tFullFB, i.vUv0 ), tex2D( g_tSmallFB, i.vUv0 ).aaaa, 0.5 ); + if ( cOut.a > 0.0 ) + cOut.rgba /= cOut.a; + else + cOut.rgba = cCenterTap.rgba; + + return cOut; +} diff --git a/src/materialsystem/stdshaders/depth_of_field_vs20.fxc b/src/materialsystem/stdshaders/depth_of_field_vs20.fxc new file mode 100644 index 00000000..37382c7d --- /dev/null +++ b/src/materialsystem/stdshaders/depth_of_field_vs20.fxc @@ -0,0 +1,29 @@ +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// + +// Includes ======================================================================================= +#include "common_vs_fxc.h" + +// Input values =================================================================================== +struct VS_INPUT +{ + float3 vPos : POSITION; + float2 vBaseTexCoord : TEXCOORD0; +}; + +// Interpolated values ============================================================================ +struct VS_OUTPUT +{ + float4 projPos : POSITION; + float2 vUv0 : TEXCOORD0; +}; + +// Main =========================================================================================== +VS_OUTPUT main( const VS_INPUT i ) +{ + VS_OUTPUT o; + + o.projPos.xyzw = float4( i.vPos.xyz, 1.0f ); + o.vUv0.xy = i.vBaseTexCoord.xy; + + return o; +} diff --git a/src/materialsystem/stdshaders/depthoffield_dx9.cpp b/src/materialsystem/stdshaders/depthoffield_dx9.cpp new file mode 100644 index 00000000..69650e74 --- /dev/null +++ b/src/materialsystem/stdshaders/depthoffield_dx9.cpp @@ -0,0 +1,280 @@ +//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======// +// +// Purpose: Depth of field material +// +//===========================================================================// + +#include "BaseVSShader.h" +#include "depth_of_field_vs20.inc" +#include "depth_of_field_ps20b.inc" +#include "convar.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +ConVar mat_dof_max_blur_radius( "mat_dof_max_blur_radius", "50" ); +ConVar mat_dof_quality( "mat_dof_quality", "3" ); +ConVar mat_dof_constant( "mat_dof_constant", "512" ); + +// 8 samples +static const float s_flPoissonConstsQuality0[16] = { + 0.0, 0.0, + 0.527837, -0.085868, + -0.040088, 0.536087, + -0.670445, -0.179949, + -0.419418, -0.616039, + 0.440453, -0.639399, + -0.757088, 0.349334, + 0.574619, 0.685879 +}; + +// 16 samples +static const float s_flPoissonConstsQuality1[32] = { + 0.0747, -0.8341, + -0.9138, 0.3251, + 0.8667, -0.3029, + -0.4642, 0.2187, + -0.1505, 0.7320, + 0.7310, -0.6786, + 0.2859, -0.3254, + -0.1311, -0.2292, + 0.3518, 0.6470, + -0.7485, -0.6307, + 0.1687, 0.1873, + -0.3604, -0.7483, + -0.5658, -0.1521, + 0.7102, 0.0536, + -0.6056, 0.7747, + 0.7793, 0.6194 +}; + +// 32 samples +static const float s_flPoissonConstsQuality2[64] = { + 0.0854f, -0.0644f, + 0.8744f, 0.1665f, + 0.2329f, 0.3995f, + -0.7804f, 0.5482f, + -0.4577f, 0.7647f, + -0.1936f, 0.5564f, + 0.4205f, -0.5768f, + -0.0304f, -0.9050f, + -0.5215f, 0.1854f, + 0.3161f, -0.2954f, + 0.0666f, -0.5564f, + -0.2137f, -0.0072f, + -0.4112f, -0.3311f, + 0.6438f, -0.2484f, + -0.9055f, -0.0360f, + 0.8323f, 0.5268f, + 0.5592f, 0.3459f, + -0.6797f, -0.5201f, + -0.4325f, -0.8857f, + 0.8768f, -0.4197f, + 0.3090f, -0.8646f, + 0.5034f, 0.8603f, + 0.3752f, 0.0627f, + -0.0161f, 0.2627f, + 0.0969f, 0.7054f, + -0.2291f, -0.6595f, + -0.5887f, -0.1100f, + 0.7048f, -0.6528f, + -0.8438f, 0.2706f, + -0.5061f, 0.4653f, + -0.1245f, -0.3302f, + -0.1801f, 0.8486f +}; + +DEFINE_FALLBACK_SHADER( DepthOfField, DepthOfField_dx9 ) +BEGIN_VS_SHADER_FLAGS( DepthOfField_dx9, "Depth of Field", SHADER_NOT_EDITABLE ) + BEGIN_SHADER_PARAMS + SHADER_PARAM( SMALLFB, SHADER_PARAM_TYPE_TEXTURE, "_rt_SmallFB1", "Downsampled backbuffer" ) + SHADER_PARAM( NEARPLANE, SHADER_PARAM_TYPE_FLOAT, "0", "Near plane depth" ) + SHADER_PARAM( FARPLANE, SHADER_PARAM_TYPE_FLOAT, "0", "Far plane depth" ) + SHADER_PARAM( NEARBLURDEPTH, SHADER_PARAM_TYPE_FLOAT, "0", "Near blur plane depth" ) + SHADER_PARAM( NEARFOCUSDEPTH, SHADER_PARAM_TYPE_FLOAT, "0", "Near focus plane depth" ) + SHADER_PARAM( FARFOCUSDEPTH, SHADER_PARAM_TYPE_FLOAT, "0", "Far focus plane depth" ) + SHADER_PARAM( FARBLURDEPTH, SHADER_PARAM_TYPE_FLOAT, "0", "Far blur plane depth" ) + SHADER_PARAM( NEARBLURRADIUS, SHADER_PARAM_TYPE_FLOAT, "0", "Max near blur radius" ) + SHADER_PARAM( FARBLURRADIUS, SHADER_PARAM_TYPE_FLOAT, "0", "Max far blur radius" ) + SHADER_PARAM( QUALITY, SHADER_PARAM_TYPE_INTEGER, "0", "Quality level. Selects different algorithms." ) + END_SHADER_PARAMS + + SHADER_INIT_PARAMS() + { + SET_PARAM_STRING_IF_NOT_DEFINED( SMALLFB, "_rt_SmallFB1" ); + SET_PARAM_FLOAT_IF_NOT_DEFINED( NEARPLANE, 0.0f ); + SET_PARAM_FLOAT_IF_NOT_DEFINED( FARPLANE, 0.0f ); + SET_PARAM_FLOAT_IF_NOT_DEFINED( NEARBLURDEPTH, 0.0f ); + SET_PARAM_FLOAT_IF_NOT_DEFINED( NEARFOCUSDEPTH, 0.0f ); + SET_PARAM_FLOAT_IF_NOT_DEFINED( FARFOCUSDEPTH, 0.0f ); + SET_PARAM_FLOAT_IF_NOT_DEFINED( FARBLURDEPTH, 0.0f ); + SET_PARAM_FLOAT_IF_NOT_DEFINED( NEARBLURRADIUS, 0.0f ); + SET_PARAM_FLOAT_IF_NOT_DEFINED( FARBLURRADIUS, 0.0f ); + SET_PARAM_INT_IF_NOT_DEFINED( QUALITY, 0 ); + } + + SHADER_FALLBACK + { + if ( g_pHardwareConfig->GetDXSupportLevel() < 92 ) + { + return "Wireframe"; + } + + return 0; + } + + SHADER_INIT + { + if ( params[BASETEXTURE]->IsDefined() ) + { + LoadTexture( BASETEXTURE ); + } + if ( params[SMALLFB]->IsDefined() ) + { + LoadTexture( SMALLFB ); + } + } + + SHADER_DRAW + { + SHADOW_STATE + { + pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 ); + + pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, false ); + pShaderShadow->EnableTexture( SHADER_SAMPLER1, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, false ); + pShaderShadow->EnableSRGBWrite( false ); + + DECLARE_STATIC_VERTEX_SHADER( depth_of_field_vs20 ); + SET_STATIC_VERTEX_SHADER( depth_of_field_vs20 ); + + if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_STATIC_PIXEL_SHADER( depth_of_field_ps20b ); + SET_STATIC_PIXEL_SHADER( depth_of_field_ps20b ); + } + else + { + Assert( !"No ps_2_b. This shouldn't be happening" ); + } + + pShaderShadow->EnableDepthWrites( false ); + pShaderShadow->EnableAlphaWrites( false ); + } + + DYNAMIC_STATE + { + DECLARE_DYNAMIC_VERTEX_SHADER( depth_of_field_vs20 ); + SET_DYNAMIC_VERTEX_SHADER( depth_of_field_vs20 ); + + // Bind textures + BindTexture( SHADER_SAMPLER0, BASETEXTURE ); + BindTexture( SHADER_SAMPLER1, SMALLFB ); + + // near blur = blur of stuff in front of focus range + // far blur = blur of stuff behind focus range + + // C0: set near/far blur and focus distances + // x = near blur distance + // y = near focus distance + // z = far focus distance + // w = far blur distance + // C1: + // x = blur radius for near blur (in pixels) + // y = blur radius for far blur (in pixels) + // TODO: Specifying this stuff in pixels makes blurs look smaller on high backbuffer resolutions. + // This might be a problem for tweaking these values. + float vConst[16] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + + vConst[0] = params[NEARBLURDEPTH]->GetFloatValue(); + vConst[1] = params[NEARFOCUSDEPTH]->GetFloatValue(); + vConst[2] = params[FARFOCUSDEPTH]->GetFloatValue(); + vConst[3] = params[FARBLURDEPTH]->GetFloatValue();; + // max blur radius will need to be set based on quality level and screen res + vConst[4] = mat_dof_max_blur_radius.GetFloat(); + vConst[5] = MIN( params[NEARBLURRADIUS]->GetFloatValue(), vConst[4] ) / vConst[4]; // near and far blur radius as fraction of max radius + vConst[6] = MIN( params[FARBLURRADIUS]->GetFloatValue(), vConst[4] ) / vConst[4]; + + vConst[8] = params[NEARPLANE]->GetFloatValue(); + vConst[9] = params[FARPLANE]->GetFloatValue(); + + vConst[10] = mat_dof_constant.GetFloat() * ( vConst[9] - vConst[8] ) / vConst[9]; + + vConst[12] = vConst[10] / ( vConst[0] - vConst[1] ); + vConst[13] = ( vConst[8] - vConst[1] ) / ( vConst[0] - vConst[1] ); + vConst[14] = vConst[10] / ( vConst[3] - vConst[2] ); + vConst[15] = ( vConst[8] - vConst[2] ) / ( vConst[3] - vConst[2] ); + + pShaderAPI->SetPixelShaderConstant( 0, vConst, 4 ); + + // set up poisson sample location constants pre-divided by screen res + int nNumPoissonSamples = 0; + const float *pPoissonSrc = NULL; + switch ( params[QUALITY]->GetIntValue() ) + { + case 0: + // NOTE: These must match the shader + nNumPoissonSamples = 8; + pPoissonSrc = s_flPoissonConstsQuality0; + break; + + case 1: + case 2: + nNumPoissonSamples = 16; + pPoissonSrc = s_flPoissonConstsQuality1; + break; + + case 3: + nNumPoissonSamples = 32; + pPoissonSrc = s_flPoissonConstsQuality2; + break; + + default: + Warning( "Invalid mat_dof_quality value. Resetting to 0.\n" ); + mat_dof_quality.SetValue( 0 ); + nNumPoissonSamples = 8; + pPoissonSrc = s_flPoissonConstsQuality0; + break; + } + + float vPoissonConst[64]; // temp table + + // Get texture dimensions + ITexture *pTex = params[BASETEXTURE]->GetTextureValue(); + Assert( pTex ); + float flInvTexWidth = 1.0f / static_cast( pTex->GetActualWidth() ); + float flInvTexHeight = 1.0f / static_cast( pTex->GetActualHeight() ); + + for ( int i = 0; i < nNumPoissonSamples; i++ ) + { + vPoissonConst[ 2*i ] = pPoissonSrc[ 2*i ] * flInvTexWidth; + vPoissonConst[ 2*i+1 ] = pPoissonSrc[ 2*i+1 ] * flInvTexHeight; + } + + // swizzle every other 2-tuple so that I can use the free .wz swizzle in the shader + for ( int i = 1; i < nNumPoissonSamples; i += 2) + { + float t = vPoissonConst[ 2*i ]; + vPoissonConst[ 2*i ] = vPoissonConst[ 2*i+1 ]; + vPoissonConst[ 2*i+1 ] = t; + } + + pShaderAPI->SetPixelShaderConstant( 4, vPoissonConst, nNumPoissonSamples / 2 ); + + if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_DYNAMIC_PIXEL_SHADER( depth_of_field_ps20b ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( QUALITY, params[QUALITY]->GetIntValue() ); + SET_DYNAMIC_PIXEL_SHADER( depth_of_field_ps20b ); + } + else + { + Assert( !"No ps_2_b. This shouldn't be happening" ); + } + } + + Draw(); + } +END_SHADER diff --git a/src/materialsystem/stdshaders/depthwrite.cpp b/src/materialsystem/stdshaders/depthwrite.cpp index 93e324a9..6e904ca4 100644 --- a/src/materialsystem/stdshaders/depthwrite.cpp +++ b/src/materialsystem/stdshaders/depthwrite.cpp @@ -40,6 +40,9 @@ BEGIN_VS_SHADER_FLAGS( DepthWrite, "Help for Depth Write", SHADER_NOT_EDITABLE ) SHADER_PARAM( TREESWAYSPEEDLERPSTART, SHADER_PARAM_TYPE_FLOAT, "3", "" ); SHADER_PARAM( TREESWAYSPEEDLERPEND, SHADER_PARAM_TYPE_FLOAT, "6", "" ); SHADER_PARAM( TREESWAYSTATIC, SHADER_PARAM_TYPE_BOOL, "0", "" ); +#ifdef MAPBASE + SHADER_PARAM( TREESWAYSTATICVALUES, SHADER_PARAM_TYPE_VEC2, "[0.5 0.5]", "" ); +#endif END_SHADER_PARAMS SHADER_INIT_PARAMS() @@ -228,7 +231,20 @@ BEGIN_VS_SHADER_FLAGS( DepthWrite, "Help for Depth Write", SHADER_NOT_EDITABLE ) flParams[ 0 ] = pShaderAPI->CurrentTime(); +#ifdef MAPBASE + Vector windDir; + if (params[TREESWAYSTATIC]->GetIntValue() == 0) + { + windDir = pShaderAPI->GetVectorRenderingParameter( VECTOR_RENDERPARM_WIND_DIRECTION ); + } + else + { + // Use a static value instead of the env_wind value. + params[TREESWAYSTATICVALUES]->GetVecValue( windDir.Base(), 2); + } +#else Vector windDir = IsBoolSet( TREESWAYSTATIC, params ) ? Vector( 0.5f, 0.5f, 0 ) : pShaderAPI->GetVectorRenderingParameter( VECTOR_RENDERPARM_WIND_DIRECTION ); +#endif flParams[ 1 ] = windDir.x; flParams[ 2 ] = windDir.y; diff --git a/src/materialsystem/stdshaders/eye_refract_helper.cpp b/src/materialsystem/stdshaders/eye_refract_helper.cpp index 1e621396..f8a959e9 100644 --- a/src/materialsystem/stdshaders/eye_refract_helper.cpp +++ b/src/materialsystem/stdshaders/eye_refract_helper.cpp @@ -439,7 +439,7 @@ void Draw_Eyes_Refract_Internal( CBaseVSShader *pShader, IMaterialVar** params, { params[info.m_nEntityOrigin]->GetVecValue( timeVec, 3 ); } - pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, timeVec, 1 ); + pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_5, timeVec, 1 ); } } pShader->Draw(); diff --git a/src/materialsystem/stdshaders/flashlight_ps2x.fxc b/src/materialsystem/stdshaders/flashlight_ps2x.fxc index 8ac860cb..0e9d5d9f 100644 --- a/src/materialsystem/stdshaders/flashlight_ps2x.fxc +++ b/src/materialsystem/stdshaders/flashlight_ps2x.fxc @@ -13,10 +13,12 @@ // STATIC: "DETAILTEXTURE" "0..1" // STATIC: "DETAIL_BLEND_MODE" "0..1" // STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b] [PC] +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps30] // STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX] // DYNAMIC: "PIXELFOGTYPE" "0..1" // DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b] +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps30] // SKIP: !$WORLDVERTEXTRANSITION && $NORMALMAP2 // SKIP: !$NORMALMAP && $NORMALMAP2 @@ -31,6 +33,7 @@ const float4 g_FogParams : register( PSREG_FOG_PARAMS ); const float4 g_EyePos : register( PSREG_EYEPOS_SPEC_EXPONENT ); const float4 g_FlashlightAttenuation : register( PSREG_FLASHLIGHT_ATTENUATION ); const float4 g_DetailConstants : register( c0 ); +const float3 g_FlashLightPos : register( PSREG_FRESNEL_SPEC_PARAMS ); sampler SpotSampler : register( s0 ); sampler BaseTextureSampler : register( s1 ); @@ -175,7 +178,7 @@ float4 main( PS_INPUT i ) : COLOR spotColor.rgb *= cFlashlightColor.rgb; // Compute per-pixel distance attenuation - float3 delta = g_EyePos.xyz - i.worldPos_worldTransition.xyz; + float3 delta = g_FlashLightPos - i.worldPos_worldTransition.xyz; float distSquared = dot( delta, delta ); float dist = sqrt( distSquared ); float farZ = g_FlashlightAttenuation.w; @@ -189,7 +192,7 @@ float4 main( PS_INPUT i ) : COLOR spotColor *= flShadow; #endif -#if WORLDVERTEXTRANSITION +#if WORLDVERTEXTRANSITION && !defined( SHADER_MODEL_PS_2_0 ) baseColor.xyz = lerp( baseColor2.xyz, baseColor.xyz, lerpAlpha ); #endif @@ -232,4 +235,4 @@ float4 main( PS_INPUT i ) : COLOR } #endif -} +} \ No newline at end of file diff --git a/src/materialsystem/stdshaders/include/Bloom_ps20b.inc b/src/materialsystem/stdshaders/include/Bloom_ps20b.inc index 093fe212..0c285e30 100644 --- a/src/materialsystem/stdshaders/include/Bloom_ps20b.inc +++ b/src/materialsystem/stdshaders/include/Bloom_ps20b.inc @@ -1,60 +1,50 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class bloom_ps20b_Static_Index { -private: - int m_nCONVERT_TO_SRGB; -#ifdef _DEBUG - bool m_bCONVERT_TO_SRGB; -#endif + unsigned int m_nCONVERT_TO_SRGB : 2; 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 ) + + bloom_ps20b_Static_Index( ) { - m_nCONVERT_TO_SRGB = i ? 1 : 0; -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); } -public: - bloom_ps20b_Static_Index( ) + + int GetIndex() const { -#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_bloom_ps20b 0 + +#define shaderStaticTest_bloom_ps20b 1 + + class bloom_ps20b_Dynamic_Index { public: - bloom_ps20b_Dynamic_Index() + bloom_ps20b_Dynamic_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_bloom_ps20b 0 + +#define shaderDynamicTest_bloom_ps20b 1 + diff --git a/src/materialsystem/stdshaders/include/BlurFilter_ps20b.inc b/src/materialsystem/stdshaders/include/BlurFilter_ps20b.inc index 7ec87ea5..17c30a30 100644 --- a/src/materialsystem/stdshaders/include/BlurFilter_ps20b.inc +++ b/src/materialsystem/stdshaders/include/BlurFilter_ps20b.inc @@ -1,85 +1,68 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class blurfilter_ps20b_Static_Index { -private: - int m_nCONVERT_TO_SRGB; + unsigned int m_nCONVERT_TO_SRGB : 2; + unsigned int m_nAPPROX_SRGB_ADAPTER : 2; #ifdef _DEBUG - bool m_bCONVERT_TO_SRGB; -#endif + bool m_bAPPROX_SRGB_ADAPTER : 1; +#endif // _DEBUG 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 - } -private: - int m_nAPPROX_SRGB_ADAPTER; -#ifdef _DEBUG - bool m_bAPPROX_SRGB_ADAPTER; -#endif -public: + void SetAPPROX_SRGB_ADAPTER( int i ) { Assert( i >= 0 && i <= 1 ); m_nAPPROX_SRGB_ADAPTER = i; #ifdef _DEBUG m_bAPPROX_SRGB_ADAPTER = true; -#endif +#endif // _DEBUG } - void SetAPPROX_SRGB_ADAPTER( bool i ) + + blurfilter_ps20b_Static_Index( ) { - m_nAPPROX_SRGB_ADAPTER = i ? 1 : 0; -#ifdef _DEBUG - m_bAPPROX_SRGB_ADAPTER = true; -#endif - } -public: - blurfilter_ps20b_Static_Index( ) - { -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif // _DEBUG - m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nAPPROX_SRGB_ADAPTER = 0; #ifdef _DEBUG m_bAPPROX_SRGB_ADAPTER = false; -#endif // _DEBUG - m_nAPPROX_SRGB_ADAPTER = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bAPPROX_SRGB_ADAPTER; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bAPPROX_SRGB_ADAPTER ); return ( 1 * m_nCONVERT_TO_SRGB ) + ( 2 * m_nAPPROX_SRGB_ADAPTER ) + 0; } }; -#define shaderStaticTest_blurfilter_ps20b psh_forgot_to_set_static_APPROX_SRGB_ADAPTER + 0 + +#define shaderStaticTest_blurfilter_ps20b psh_forgot_to_set_static_APPROX_SRGB_ADAPTER + + class blurfilter_ps20b_Dynamic_Index { public: - blurfilter_ps20b_Dynamic_Index() + blurfilter_ps20b_Dynamic_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_blurfilter_ps20b 0 + +#define shaderDynamicTest_blurfilter_ps20b 1 + diff --git a/src/materialsystem/stdshaders/include/BlurFilter_vs20.inc b/src/materialsystem/stdshaders/include/BlurFilter_vs20.inc index 933c5b79..c25bebde 100644 --- a/src/materialsystem/stdshaders/include/BlurFilter_vs20.inc +++ b/src/materialsystem/stdshaders/include/BlurFilter_vs20.inc @@ -1,33 +1,36 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class blurfilter_vs20_Static_Index { public: - blurfilter_vs20_Static_Index( ) + blurfilter_vs20_Static_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_blurfilter_vs20 0 + +#define shaderStaticTest_blurfilter_vs20 1 + + class blurfilter_vs20_Dynamic_Index { public: - blurfilter_vs20_Dynamic_Index() + blurfilter_vs20_Dynamic_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_blurfilter_vs20 0 + +#define shaderDynamicTest_blurfilter_vs20 1 + diff --git a/src/materialsystem/stdshaders/include/ShatteredGlass_ps20b.inc b/src/materialsystem/stdshaders/include/ShatteredGlass_ps20b.inc index 7b2df391..fef93447 100644 --- a/src/materialsystem/stdshaders/include/ShatteredGlass_ps20b.inc +++ b/src/materialsystem/stdshaders/include/ShatteredGlass_ps20b.inc @@ -1,32 +1,38 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// $PARALLAXCORRECT && !$CUBEMAP +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class shatteredglass_ps20b_Static_Index { -private: - int m_nCONVERT_TO_SRGB; + unsigned int m_nCUBEMAP : 2; + unsigned int m_nVERTEXCOLOR : 2; + unsigned int m_nENVMAPMASK : 2; + unsigned int m_nBASEALPHAENVMAPMASK : 2; + unsigned int m_nHDRTYPE : 2; + unsigned int m_nPARALLAXCORRECT : 2; #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 - } -private: - int m_nCUBEMAP; -#ifdef _DEBUG - bool m_bCUBEMAP; -#endif + bool m_bCUBEMAP : 1; + bool m_bVERTEXCOLOR : 1; + bool m_bENVMAPMASK : 1; + bool m_bBASEALPHAENVMAPMASK : 1; + bool m_bHDRTYPE : 1; + bool m_bPARALLAXCORRECT : 1; +#endif // _DEBUG public: void SetCUBEMAP( int i ) { @@ -34,167 +40,89 @@ public: m_nCUBEMAP = i; #ifdef _DEBUG m_bCUBEMAP = true; -#endif +#endif // _DEBUG } - void SetCUBEMAP( bool i ) - { - m_nCUBEMAP = i ? 1 : 0; -#ifdef _DEBUG - m_bCUBEMAP = true; -#endif - } -private: - int m_nVERTEXCOLOR; -#ifdef _DEBUG - bool m_bVERTEXCOLOR; -#endif -public: + void SetVERTEXCOLOR( int i ) { Assert( i >= 0 && i <= 1 ); m_nVERTEXCOLOR = i; #ifdef _DEBUG m_bVERTEXCOLOR = true; -#endif +#endif // _DEBUG } - void SetVERTEXCOLOR( bool i ) - { - m_nVERTEXCOLOR = i ? 1 : 0; -#ifdef _DEBUG - m_bVERTEXCOLOR = true; -#endif - } -private: - int m_nENVMAPMASK; -#ifdef _DEBUG - bool m_bENVMAPMASK; -#endif -public: + void SetENVMAPMASK( int i ) { Assert( i >= 0 && i <= 1 ); m_nENVMAPMASK = i; #ifdef _DEBUG m_bENVMAPMASK = true; -#endif +#endif // _DEBUG } - void SetENVMAPMASK( bool i ) - { - m_nENVMAPMASK = i ? 1 : 0; -#ifdef _DEBUG - m_bENVMAPMASK = true; -#endif - } -private: - int m_nBASEALPHAENVMAPMASK; -#ifdef _DEBUG - bool m_bBASEALPHAENVMAPMASK; -#endif -public: + void SetBASEALPHAENVMAPMASK( int i ) { Assert( i >= 0 && i <= 1 ); m_nBASEALPHAENVMAPMASK = i; #ifdef _DEBUG m_bBASEALPHAENVMAPMASK = true; -#endif +#endif // _DEBUG } - void SetBASEALPHAENVMAPMASK( bool i ) - { - m_nBASEALPHAENVMAPMASK = i ? 1 : 0; -#ifdef _DEBUG - m_bBASEALPHAENVMAPMASK = true; -#endif - } -private: - int m_nHDRTYPE; -#ifdef _DEBUG - bool m_bHDRTYPE; -#endif -public: + void SetHDRTYPE( int i ) { Assert( i >= 0 && i <= 2 ); m_nHDRTYPE = i; #ifdef _DEBUG m_bHDRTYPE = true; -#endif +#endif // _DEBUG } - void SetHDRTYPE( bool i ) - { - m_nHDRTYPE = i ? 1 : 0; -#ifdef _DEBUG - m_bHDRTYPE = true; -#endif - } -public: - shatteredglass_ps20b_Static_Index( ) - { -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif // _DEBUG - m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); -#ifdef _DEBUG - m_bCUBEMAP = false; -#endif // _DEBUG - m_nCUBEMAP = 0; -#ifdef _DEBUG - m_bVERTEXCOLOR = false; -#endif // _DEBUG - m_nVERTEXCOLOR = 0; -#ifdef _DEBUG - m_bENVMAPMASK = false; -#endif // _DEBUG - m_nENVMAPMASK = 0; -#ifdef _DEBUG - m_bBASEALPHAENVMAPMASK = false; -#endif // _DEBUG - m_nBASEALPHAENVMAPMASK = 0; -#ifdef _DEBUG - m_bHDRTYPE = false; -#endif // _DEBUG - m_nHDRTYPE = 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_bCUBEMAP && m_bVERTEXCOLOR && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bHDRTYPE; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG - return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nCUBEMAP ) + ( 16 * m_nVERTEXCOLOR ) + ( 32 * m_nENVMAPMASK ) + ( 64 * m_nBASEALPHAENVMAPMASK ) + ( 128 * m_nHDRTYPE ) + 0; - } -}; -#define shaderStaticTest_shatteredglass_ps20b psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_HDRTYPE + 0 -class shatteredglass_ps20b_Dynamic_Index -{ -private: - int m_nHDRENABLED; -#ifdef _DEBUG - bool m_bHDRENABLED; -#endif -public: - void SetHDRENABLED( int i ) + + void SetPARALLAXCORRECT( int i ) { Assert( i >= 0 && i <= 1 ); - m_nHDRENABLED = i; + m_nPARALLAXCORRECT = i; #ifdef _DEBUG - m_bHDRENABLED = true; -#endif + m_bPARALLAXCORRECT = true; +#endif // _DEBUG } - void SetHDRENABLED( bool i ) + + shatteredglass_ps20b_Static_Index( ) { - m_nHDRENABLED = i ? 1 : 0; + m_nCUBEMAP = 0; + m_nVERTEXCOLOR = 0; + m_nENVMAPMASK = 0; + m_nBASEALPHAENVMAPMASK = 0; + m_nHDRTYPE = 0; + m_nPARALLAXCORRECT = 0; #ifdef _DEBUG - m_bHDRENABLED = true; -#endif + m_bCUBEMAP = false; + m_bVERTEXCOLOR = false; + m_bENVMAPMASK = false; + m_bBASEALPHAENVMAPMASK = false; + m_bHDRTYPE = false; + m_bPARALLAXCORRECT = false; +#endif // _DEBUG } -private: - int m_nPIXELFOGTYPE; + + int GetIndex() const + { + Assert( m_bCUBEMAP && m_bVERTEXCOLOR && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bHDRTYPE && m_bPARALLAXCORRECT ); + AssertMsg( !( m_nPARALLAXCORRECT && !m_nCUBEMAP ), "Invalid combo combination ( PARALLAXCORRECT && !CUBEMAP )" ); + return ( 2 * m_nCUBEMAP ) + ( 4 * m_nVERTEXCOLOR ) + ( 8 * m_nENVMAPMASK ) + ( 16 * m_nBASEALPHAENVMAPMASK ) + ( 32 * m_nHDRTYPE ) + ( 96 * m_nPARALLAXCORRECT ) + 0; + } +}; + +#define shaderStaticTest_shatteredglass_ps20b psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_HDRTYPE + psh_forgot_to_set_static_PARALLAXCORRECT + + +class shatteredglass_ps20b_Dynamic_Index +{ + unsigned int m_nPIXELFOGTYPE : 2; #ifdef _DEBUG - bool m_bPIXELFOGTYPE; -#endif + bool m_bPIXELFOGTYPE : 1; +#endif // _DEBUG public: void SetPIXELFOGTYPE( int i ) { @@ -202,36 +130,23 @@ public: m_nPIXELFOGTYPE = i; #ifdef _DEBUG m_bPIXELFOGTYPE = true; -#endif +#endif // _DEBUG } - void SetPIXELFOGTYPE( bool i ) + + shatteredglass_ps20b_Dynamic_Index( ) { - m_nPIXELFOGTYPE = i ? 1 : 0; -#ifdef _DEBUG - m_bPIXELFOGTYPE = true; -#endif - } -public: - shatteredglass_ps20b_Dynamic_Index() - { -#ifdef _DEBUG - m_bHDRENABLED = false; -#endif // _DEBUG - m_nHDRENABLED = 0; + m_nPIXELFOGTYPE = 0; #ifdef _DEBUG m_bPIXELFOGTYPE = false; -#endif // _DEBUG - m_nPIXELFOGTYPE = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bHDRENABLED && m_bPIXELFOGTYPE; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG - return ( 1 * m_nHDRENABLED ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + Assert( m_bPIXELFOGTYPE ); + return ( 1 * m_nPIXELFOGTYPE ) + 0; } }; -#define shaderDynamicTest_shatteredglass_ps20b psh_forgot_to_set_dynamic_HDRENABLED + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 + +#define shaderDynamicTest_shatteredglass_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + diff --git a/src/materialsystem/stdshaders/include/ShatteredGlass_vs20.inc b/src/materialsystem/stdshaders/include/ShatteredGlass_vs20.inc index adc1b4b0..0cf57995 100644 --- a/src/materialsystem/stdshaders/include/ShatteredGlass_vs20.inc +++ b/src/materialsystem/stdshaders/include/ShatteredGlass_vs20.inc @@ -1,11 +1,14 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class shatteredglass_vs20_Static_Index { -private: - int m_nENVMAP_MASK; + unsigned int m_nENVMAP_MASK : 2; #ifdef _DEBUG - bool m_bENVMAP_MASK; -#endif + bool m_bENVMAP_MASK : 1; +#endif // _DEBUG public: void SetENVMAP_MASK( int i ) { @@ -13,42 +16,33 @@ public: m_nENVMAP_MASK = i; #ifdef _DEBUG m_bENVMAP_MASK = true; -#endif +#endif // _DEBUG } - void SetENVMAP_MASK( bool i ) - { - m_nENVMAP_MASK = i ? 1 : 0; -#ifdef _DEBUG - m_bENVMAP_MASK = true; -#endif - } -public: - shatteredglass_vs20_Static_Index( ) + + shatteredglass_vs20_Static_Index( ) { + m_nENVMAP_MASK = 0; #ifdef _DEBUG m_bENVMAP_MASK = false; -#endif // _DEBUG - m_nENVMAP_MASK = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bENVMAP_MASK; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bENVMAP_MASK ); return ( 2 * m_nENVMAP_MASK ) + 0; } }; -#define shaderStaticTest_shatteredglass_vs20 vsh_forgot_to_set_static_ENVMAP_MASK + 0 + +#define shaderStaticTest_shatteredglass_vs20 vsh_forgot_to_set_static_ENVMAP_MASK + + class shatteredglass_vs20_Dynamic_Index { -private: - int m_nDOWATERFOG; + unsigned int m_nDOWATERFOG : 2; #ifdef _DEBUG - bool m_bDOWATERFOG; -#endif + bool m_bDOWATERFOG : 1; +#endif // _DEBUG public: void SetDOWATERFOG( int i ) { @@ -56,32 +50,23 @@ public: m_nDOWATERFOG = i; #ifdef _DEBUG m_bDOWATERFOG = true; -#endif +#endif // _DEBUG } - void SetDOWATERFOG( bool i ) - { - m_nDOWATERFOG = i ? 1 : 0; -#ifdef _DEBUG - m_bDOWATERFOG = true; -#endif - } -public: - shatteredglass_vs20_Dynamic_Index() + + shatteredglass_vs20_Dynamic_Index( ) { + m_nDOWATERFOG = 0; #ifdef _DEBUG m_bDOWATERFOG = false; -#endif // _DEBUG - m_nDOWATERFOG = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bDOWATERFOG; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bDOWATERFOG ); return ( 1 * m_nDOWATERFOG ) + 0; } }; -#define shaderDynamicTest_shatteredglass_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 + +#define shaderDynamicTest_shatteredglass_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + diff --git a/src/materialsystem/stdshaders/include/WorldTwoTextureBlend_ps20b.inc b/src/materialsystem/stdshaders/include/WorldTwoTextureBlend_ps20b.inc index b9d095ea..88122900 100644 --- a/src/materialsystem/stdshaders/include/WorldTwoTextureBlend_ps20b.inc +++ b/src/materialsystem/stdshaders/include/WorldTwoTextureBlend_ps20b.inc @@ -1,279 +1,189 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// $DETAILTEXTURE && ( $BUMPMAP && !$DETAIL_ALPHA_MASK_BASE_TEXTURE ) +// !$BUMPMAP && $DIFFUSEBUMPMAP +// $VERTEXCOLOR && $BUMPMAP +// FLASHLIGHT && $SELFILLUM +// FLASHLIGHT && $DETAIL_ALPHA_MASK_BASE_TEXTURE +// FLASHLIGHT && ($BUMPMAP || $DIFFUSEBUMPMAP) +// ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class worldtwotextureblend_ps20b_Static_Index { -private: - int m_nCONVERT_TO_SRGB; + unsigned int m_nCONVERT_TO_SRGB : 2; + unsigned int m_nDETAILTEXTURE : 2; + unsigned int m_nBUMPMAP : 2; + unsigned int m_nVERTEXCOLOR : 2; + unsigned int m_nSELFILLUM : 2; + unsigned int m_nDIFFUSEBUMPMAP : 2; + unsigned int m_nDETAIL_ALPHA_MASK_BASE_TEXTURE : 2; + unsigned int m_nFLASHLIGHT : 2; + unsigned int m_nSEAMLESS : 2; + unsigned int m_nFLASHLIGHTDEPTHFILTERMODE : 2; #ifdef _DEBUG - bool m_bCONVERT_TO_SRGB; -#endif + bool m_bDETAILTEXTURE : 1; + bool m_bBUMPMAP : 1; + bool m_bVERTEXCOLOR : 1; + bool m_bSELFILLUM : 1; + bool m_bDIFFUSEBUMPMAP : 1; + bool m_bDETAIL_ALPHA_MASK_BASE_TEXTURE : 1; + bool m_bFLASHLIGHT : 1; + bool m_bSEAMLESS : 1; + bool m_bFLASHLIGHTDEPTHFILTERMODE : 1; +#endif // _DEBUG 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 - } -private: - int m_nDETAILTEXTURE; -#ifdef _DEBUG - bool m_bDETAILTEXTURE; -#endif -public: + void SetDETAILTEXTURE( int i ) { Assert( i >= 0 && i <= 1 ); m_nDETAILTEXTURE = i; #ifdef _DEBUG m_bDETAILTEXTURE = true; -#endif +#endif // _DEBUG } - void SetDETAILTEXTURE( bool i ) - { - m_nDETAILTEXTURE = i ? 1 : 0; -#ifdef _DEBUG - m_bDETAILTEXTURE = true; -#endif - } -private: - int m_nBUMPMAP; -#ifdef _DEBUG - bool m_bBUMPMAP; -#endif -public: + void SetBUMPMAP( int i ) { Assert( i >= 0 && i <= 1 ); m_nBUMPMAP = i; #ifdef _DEBUG m_bBUMPMAP = true; -#endif +#endif // _DEBUG } - void SetBUMPMAP( bool i ) - { - m_nBUMPMAP = i ? 1 : 0; -#ifdef _DEBUG - m_bBUMPMAP = true; -#endif - } -private: - int m_nVERTEXCOLOR; -#ifdef _DEBUG - bool m_bVERTEXCOLOR; -#endif -public: + void SetVERTEXCOLOR( int i ) { Assert( i >= 0 && i <= 1 ); m_nVERTEXCOLOR = i; #ifdef _DEBUG m_bVERTEXCOLOR = true; -#endif +#endif // _DEBUG } - void SetVERTEXCOLOR( bool i ) - { - m_nVERTEXCOLOR = i ? 1 : 0; -#ifdef _DEBUG - m_bVERTEXCOLOR = true; -#endif - } -private: - int m_nSELFILLUM; -#ifdef _DEBUG - bool m_bSELFILLUM; -#endif -public: + void SetSELFILLUM( int i ) { Assert( i >= 0 && i <= 1 ); m_nSELFILLUM = i; #ifdef _DEBUG m_bSELFILLUM = true; -#endif +#endif // _DEBUG } - void SetSELFILLUM( bool i ) - { - m_nSELFILLUM = i ? 1 : 0; -#ifdef _DEBUG - m_bSELFILLUM = true; -#endif - } -private: - int m_nDIFFUSEBUMPMAP; -#ifdef _DEBUG - bool m_bDIFFUSEBUMPMAP; -#endif -public: + void SetDIFFUSEBUMPMAP( int i ) { Assert( i >= 0 && i <= 1 ); m_nDIFFUSEBUMPMAP = i; #ifdef _DEBUG m_bDIFFUSEBUMPMAP = true; -#endif +#endif // _DEBUG } - void SetDIFFUSEBUMPMAP( bool i ) - { - m_nDIFFUSEBUMPMAP = i ? 1 : 0; -#ifdef _DEBUG - m_bDIFFUSEBUMPMAP = true; -#endif - } -private: - int m_nDETAIL_ALPHA_MASK_BASE_TEXTURE; -#ifdef _DEBUG - bool m_bDETAIL_ALPHA_MASK_BASE_TEXTURE; -#endif -public: + void SetDETAIL_ALPHA_MASK_BASE_TEXTURE( int i ) { Assert( i >= 0 && i <= 1 ); m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = i; #ifdef _DEBUG m_bDETAIL_ALPHA_MASK_BASE_TEXTURE = true; -#endif +#endif // _DEBUG } - void SetDETAIL_ALPHA_MASK_BASE_TEXTURE( bool i ) - { - m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = i ? 1 : 0; -#ifdef _DEBUG - m_bDETAIL_ALPHA_MASK_BASE_TEXTURE = 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 +#endif // _DEBUG } - void SetFLASHLIGHT( bool i ) - { - m_nFLASHLIGHT = i ? 1 : 0; -#ifdef _DEBUG - m_bFLASHLIGHT = true; -#endif - } -private: - int m_nSEAMLESS; -#ifdef _DEBUG - bool m_bSEAMLESS; -#endif -public: + void SetSEAMLESS( int i ) { Assert( i >= 0 && i <= 1 ); m_nSEAMLESS = i; #ifdef _DEBUG m_bSEAMLESS = true; -#endif +#endif // _DEBUG } - void SetSEAMLESS( bool i ) - { - m_nSEAMLESS = i ? 1 : 0; -#ifdef _DEBUG - m_bSEAMLESS = 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 +#endif // _DEBUG } - void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) + + worldtwotextureblend_ps20b_Static_Index( ) { - m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; -#ifdef _DEBUG - m_bFLASHLIGHTDEPTHFILTERMODE = true; -#endif - } -public: - worldtwotextureblend_ps20b_Static_Index( ) - { -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif // _DEBUG - m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nDETAILTEXTURE = 0; + m_nBUMPMAP = 0; + m_nVERTEXCOLOR = 0; + m_nSELFILLUM = 0; + m_nDIFFUSEBUMPMAP = 0; + m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = 0; + m_nFLASHLIGHT = 0; + m_nSEAMLESS = 0; + m_nFLASHLIGHTDEPTHFILTERMODE = 0; #ifdef _DEBUG m_bDETAILTEXTURE = false; -#endif // _DEBUG - m_nDETAILTEXTURE = 0; -#ifdef _DEBUG m_bBUMPMAP = false; -#endif // _DEBUG - m_nBUMPMAP = 0; -#ifdef _DEBUG m_bVERTEXCOLOR = false; -#endif // _DEBUG - m_nVERTEXCOLOR = 0; -#ifdef _DEBUG m_bSELFILLUM = false; -#endif // _DEBUG - m_nSELFILLUM = 0; -#ifdef _DEBUG m_bDIFFUSEBUMPMAP = false; -#endif // _DEBUG - m_nDIFFUSEBUMPMAP = 0; -#ifdef _DEBUG m_bDETAIL_ALPHA_MASK_BASE_TEXTURE = false; -#endif // _DEBUG - m_nDETAIL_ALPHA_MASK_BASE_TEXTURE = 0; -#ifdef _DEBUG m_bFLASHLIGHT = false; -#endif // _DEBUG - m_nFLASHLIGHT = 0; -#ifdef _DEBUG m_bSEAMLESS = false; -#endif // _DEBUG - m_nSEAMLESS = 0; -#ifdef _DEBUG m_bFLASHLIGHTDEPTHFILTERMODE = false; -#endif // _DEBUG - m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bDETAILTEXTURE && m_bBUMPMAP && m_bVERTEXCOLOR && m_bSELFILLUM && m_bDIFFUSEBUMPMAP && m_bDETAIL_ALPHA_MASK_BASE_TEXTURE && m_bFLASHLIGHT && m_bSEAMLESS && m_bFLASHLIGHTDEPTHFILTERMODE; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG - return ( 16 * m_nCONVERT_TO_SRGB ) + ( 32 * m_nDETAILTEXTURE ) + ( 64 * m_nBUMPMAP ) + ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nSELFILLUM ) + ( 512 * m_nDIFFUSEBUMPMAP ) + ( 1024 * m_nDETAIL_ALPHA_MASK_BASE_TEXTURE ) + ( 2048 * m_nFLASHLIGHT ) + ( 4096 * m_nSEAMLESS ) + ( 8192 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; + Assert( m_bDETAILTEXTURE && m_bBUMPMAP && m_bVERTEXCOLOR && m_bSELFILLUM && m_bDIFFUSEBUMPMAP && m_bDETAIL_ALPHA_MASK_BASE_TEXTURE && m_bFLASHLIGHT && m_bSEAMLESS && m_bFLASHLIGHTDEPTHFILTERMODE ); + AssertMsg( !( m_nDETAILTEXTURE && ( m_nBUMPMAP && !m_nDETAIL_ALPHA_MASK_BASE_TEXTURE ) ), "Invalid combo combination ( DETAILTEXTURE && ( BUMPMAP && !DETAIL_ALPHA_MASK_BASE_TEXTURE ) )" ); + AssertMsg( !( !m_nBUMPMAP && m_nDIFFUSEBUMPMAP ), "Invalid combo combination ( !BUMPMAP && DIFFUSEBUMPMAP )" ); + AssertMsg( !( m_nVERTEXCOLOR && m_nBUMPMAP ), "Invalid combo combination ( VERTEXCOLOR && BUMPMAP )" ); + return ( 24 * m_nCONVERT_TO_SRGB ) + ( 48 * m_nDETAILTEXTURE ) + ( 96 * m_nBUMPMAP ) + ( 192 * m_nVERTEXCOLOR ) + ( 384 * m_nSELFILLUM ) + ( 768 * m_nDIFFUSEBUMPMAP ) + ( 1536 * m_nDETAIL_ALPHA_MASK_BASE_TEXTURE ) + ( 3072 * m_nFLASHLIGHT ) + ( 6144 * m_nSEAMLESS ) + ( 12288 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; } }; -#define shaderStaticTest_worldtwotextureblend_ps20b psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_BUMPMAP + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_DIFFUSEBUMPMAP + psh_forgot_to_set_static_DETAIL_ALPHA_MASK_BASE_TEXTURE + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 + +#define shaderStaticTest_worldtwotextureblend_ps20b psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_BUMPMAP + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_DIFFUSEBUMPMAP + psh_forgot_to_set_static_DETAIL_ALPHA_MASK_BASE_TEXTURE + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + + class worldtwotextureblend_ps20b_Dynamic_Index { -private: - int m_nWRITEWATERFOGTODESTALPHA; + unsigned int m_nWRITEWATERFOGTODESTALPHA : 2; + unsigned int m_nPIXELFOGTYPE : 2; + unsigned int m_nWRITE_DEPTH_TO_DESTALPHA : 2; + unsigned int m_nFLASHLIGHTSHADOWS : 2; #ifdef _DEBUG - bool m_bWRITEWATERFOGTODESTALPHA; -#endif + bool m_bWRITEWATERFOGTODESTALPHA : 1; + bool m_bPIXELFOGTYPE : 1; + bool m_bWRITE_DEPTH_TO_DESTALPHA : 1; + bool m_bFLASHLIGHTSHADOWS : 1; +#endif // _DEBUG public: void SetWRITEWATERFOGTODESTALPHA( int i ) { @@ -281,107 +191,58 @@ public: m_nWRITEWATERFOGTODESTALPHA = i; #ifdef _DEBUG m_bWRITEWATERFOGTODESTALPHA = true; -#endif +#endif // _DEBUG } - 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 ); + Assert( i >= 0 && i <= 2 ); m_nPIXELFOGTYPE = i; #ifdef _DEBUG m_bPIXELFOGTYPE = true; -#endif +#endif // _DEBUG } - void SetPIXELFOGTYPE( bool i ) - { - m_nPIXELFOGTYPE = i ? 1 : 0; -#ifdef _DEBUG - m_bPIXELFOGTYPE = 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 +#endif // _DEBUG } - 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 +#endif // _DEBUG } - void SetFLASHLIGHTSHADOWS( bool i ) - { - m_nFLASHLIGHTSHADOWS = i ? 1 : 0; -#ifdef _DEBUG - m_bFLASHLIGHTSHADOWS = true; -#endif - } -public: - worldtwotextureblend_ps20b_Dynamic_Index() + + worldtwotextureblend_ps20b_Dynamic_Index( ) { + m_nWRITEWATERFOGTODESTALPHA = 0; + m_nPIXELFOGTYPE = 0; + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + m_nFLASHLIGHTSHADOWS = 0; #ifdef _DEBUG m_bWRITEWATERFOGTODESTALPHA = false; -#endif // _DEBUG - m_nWRITEWATERFOGTODESTALPHA = 0; -#ifdef _DEBUG m_bPIXELFOGTYPE = false; -#endif // _DEBUG - m_nPIXELFOGTYPE = 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; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bWRITE_DEPTH_TO_DESTALPHA && m_bFLASHLIGHTSHADOWS; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG - return ( 1 * m_nWRITEWATERFOGTODESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + ( 4 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 8 * m_nFLASHLIGHTSHADOWS ) + 0; + Assert( m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA && m_bFLASHLIGHTSHADOWS ); + AssertMsg( !( 1 && ( 1 && ( ( m_nPIXELFOGTYPE != 1 ) && m_nWRITEWATERFOGTODESTALPHA ) ) ), "Invalid combo combination ( 1 && ( 1 && ( ( PIXELFOGTYPE != 1 ) && WRITEWATERFOGTODESTALPHA ) ) )" ); + AssertMsg( !( 1 && ( 1 && ( ( m_nPIXELFOGTYPE != 1 ) && m_nWRITEWATERFOGTODESTALPHA ) ) ), "Invalid combo combination ( 1 && ( 1 && ( ( PIXELFOGTYPE != 1 ) && WRITEWATERFOGTODESTALPHA ) ) )" ); + return ( 1 * m_nWRITEWATERFOGTODESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + ( 6 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 12 * m_nFLASHLIGHTSHADOWS ) + 0; } }; -#define shaderDynamicTest_worldtwotextureblend_ps20b psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 + +#define shaderDynamicTest_worldtwotextureblend_ps20b psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + diff --git a/src/materialsystem/stdshaders/include/bloomadd_ps20b.inc b/src/materialsystem/stdshaders/include/bloomadd_ps20b.inc index 686a62eb..7fe6a444 100644 --- a/src/materialsystem/stdshaders/include/bloomadd_ps20b.inc +++ b/src/materialsystem/stdshaders/include/bloomadd_ps20b.inc @@ -1,33 +1,42 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class bloomadd_ps20b_Static_Index { public: - bloomadd_ps20b_Static_Index( ) + bloomadd_ps20b_Static_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_bloomadd_ps20b 0 + +#define shaderStaticTest_bloomadd_ps20b 1 + + class bloomadd_ps20b_Dynamic_Index { public: - bloomadd_ps20b_Dynamic_Index() + bloomadd_ps20b_Dynamic_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_bloomadd_ps20b 0 + +#define shaderDynamicTest_bloomadd_ps20b 1 + diff --git a/src/materialsystem/stdshaders/include/cloak_blended_pass_ps20b.inc b/src/materialsystem/stdshaders/include/cloak_blended_pass_ps20b.inc index 0508a0c1..43654e19 100644 --- a/src/materialsystem/stdshaders/include/cloak_blended_pass_ps20b.inc +++ b/src/materialsystem/stdshaders/include/cloak_blended_pass_ps20b.inc @@ -1,85 +1,68 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class cloak_blended_pass_ps20b_Static_Index { -private: - int m_nCONVERT_TO_SRGB; + unsigned int m_nCONVERT_TO_SRGB : 2; + unsigned int m_nBUMPMAP : 2; #ifdef _DEBUG - bool m_bCONVERT_TO_SRGB; -#endif + bool m_bBUMPMAP : 1; +#endif // _DEBUG 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 - } -private: - int m_nBUMPMAP; -#ifdef _DEBUG - bool m_bBUMPMAP; -#endif -public: + void SetBUMPMAP( int i ) { Assert( i >= 0 && i <= 1 ); m_nBUMPMAP = i; #ifdef _DEBUG m_bBUMPMAP = true; -#endif +#endif // _DEBUG } - void SetBUMPMAP( bool i ) + + cloak_blended_pass_ps20b_Static_Index( ) { - m_nBUMPMAP = i ? 1 : 0; -#ifdef _DEBUG - m_bBUMPMAP = true; -#endif - } -public: - cloak_blended_pass_ps20b_Static_Index( ) - { -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif // _DEBUG - m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nBUMPMAP = 0; #ifdef _DEBUG m_bBUMPMAP = false; -#endif // _DEBUG - m_nBUMPMAP = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bBUMPMAP; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bBUMPMAP ); return ( 1 * m_nCONVERT_TO_SRGB ) + ( 2 * m_nBUMPMAP ) + 0; } }; -#define shaderStaticTest_cloak_blended_pass_ps20b psh_forgot_to_set_static_BUMPMAP + 0 + +#define shaderStaticTest_cloak_blended_pass_ps20b psh_forgot_to_set_static_BUMPMAP + + class cloak_blended_pass_ps20b_Dynamic_Index { public: - cloak_blended_pass_ps20b_Dynamic_Index() + cloak_blended_pass_ps20b_Dynamic_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_cloak_blended_pass_ps20b 0 + +#define shaderDynamicTest_cloak_blended_pass_ps20b 1 + diff --git a/src/materialsystem/stdshaders/include/cloak_blended_pass_ps30.inc b/src/materialsystem/stdshaders/include/cloak_blended_pass_ps30.inc index acfd3546..cffb46c9 100644 --- a/src/materialsystem/stdshaders/include/cloak_blended_pass_ps30.inc +++ b/src/materialsystem/stdshaders/include/cloak_blended_pass_ps30.inc @@ -1,85 +1,68 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class cloak_blended_pass_ps30_Static_Index { -private: - int m_nCONVERT_TO_SRGB; + unsigned int m_nCONVERT_TO_SRGB : 2; + unsigned int m_nBUMPMAP : 2; #ifdef _DEBUG - bool m_bCONVERT_TO_SRGB; -#endif + bool m_bBUMPMAP : 1; +#endif // _DEBUG 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 - } -private: - int m_nBUMPMAP; -#ifdef _DEBUG - bool m_bBUMPMAP; -#endif -public: + void SetBUMPMAP( int i ) { Assert( i >= 0 && i <= 1 ); m_nBUMPMAP = i; #ifdef _DEBUG m_bBUMPMAP = true; -#endif +#endif // _DEBUG } - void SetBUMPMAP( bool i ) + + cloak_blended_pass_ps30_Static_Index( ) { - m_nBUMPMAP = i ? 1 : 0; -#ifdef _DEBUG - m_bBUMPMAP = true; -#endif - } -public: - cloak_blended_pass_ps30_Static_Index( ) - { -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif // _DEBUG - m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nBUMPMAP = 0; #ifdef _DEBUG m_bBUMPMAP = false; -#endif // _DEBUG - m_nBUMPMAP = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bBUMPMAP; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bBUMPMAP ); return ( 1 * m_nCONVERT_TO_SRGB ) + ( 2 * m_nBUMPMAP ) + 0; } }; -#define shaderStaticTest_cloak_blended_pass_ps30 psh_forgot_to_set_static_BUMPMAP + 0 + +#define shaderStaticTest_cloak_blended_pass_ps30 psh_forgot_to_set_static_BUMPMAP + + class cloak_blended_pass_ps30_Dynamic_Index { public: - cloak_blended_pass_ps30_Dynamic_Index() + cloak_blended_pass_ps30_Dynamic_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_cloak_blended_pass_ps30 0 + +#define shaderDynamicTest_cloak_blended_pass_ps30 1 + diff --git a/src/materialsystem/stdshaders/include/cloak_blended_pass_vs20.inc b/src/materialsystem/stdshaders/include/cloak_blended_pass_vs20.inc index 6f6f504a..217d6b4c 100644 --- a/src/materialsystem/stdshaders/include/cloak_blended_pass_vs20.inc +++ b/src/materialsystem/stdshaders/include/cloak_blended_pass_vs20.inc @@ -1,11 +1,14 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class cloak_blended_pass_vs20_Static_Index { -private: - int m_nBUMPMAP; + unsigned int m_nBUMPMAP : 2; #ifdef _DEBUG - bool m_bBUMPMAP; -#endif + bool m_bBUMPMAP : 1; +#endif // _DEBUG public: void SetBUMPMAP( int i ) { @@ -13,42 +16,35 @@ public: m_nBUMPMAP = i; #ifdef _DEBUG m_bBUMPMAP = true; -#endif +#endif // _DEBUG } - void SetBUMPMAP( bool i ) - { - m_nBUMPMAP = i ? 1 : 0; -#ifdef _DEBUG - m_bBUMPMAP = true; -#endif - } -public: - cloak_blended_pass_vs20_Static_Index( ) + + cloak_blended_pass_vs20_Static_Index( ) { + m_nBUMPMAP = 0; #ifdef _DEBUG m_bBUMPMAP = false; -#endif // _DEBUG - m_nBUMPMAP = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bBUMPMAP; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bBUMPMAP ); return ( 4 * m_nBUMPMAP ) + 0; } }; -#define shaderStaticTest_cloak_blended_pass_vs20 vsh_forgot_to_set_static_BUMPMAP + 0 + +#define shaderStaticTest_cloak_blended_pass_vs20 vsh_forgot_to_set_static_BUMPMAP + + class cloak_blended_pass_vs20_Dynamic_Index { -private: - int m_nCOMPRESSED_VERTS; + unsigned int m_nCOMPRESSED_VERTS : 2; + unsigned int m_nSKINNING : 2; #ifdef _DEBUG - bool m_bCOMPRESSED_VERTS; -#endif + bool m_bCOMPRESSED_VERTS : 1; + bool m_bSKINNING : 1; +#endif // _DEBUG public: void SetCOMPRESSED_VERTS( int i ) { @@ -56,57 +52,34 @@ public: m_nCOMPRESSED_VERTS = i; #ifdef _DEBUG m_bCOMPRESSED_VERTS = true; -#endif +#endif // _DEBUG } - void SetCOMPRESSED_VERTS( bool i ) - { - m_nCOMPRESSED_VERTS = i ? 1 : 0; -#ifdef _DEBUG - m_bCOMPRESSED_VERTS = 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 +#endif // _DEBUG } - void SetSKINNING( bool i ) - { - m_nSKINNING = i ? 1 : 0; -#ifdef _DEBUG - m_bSKINNING = true; -#endif - } -public: - cloak_blended_pass_vs20_Dynamic_Index() + + cloak_blended_pass_vs20_Dynamic_Index( ) { + m_nCOMPRESSED_VERTS = 0; + m_nSKINNING = 0; #ifdef _DEBUG m_bCOMPRESSED_VERTS = false; -#endif // _DEBUG - m_nCOMPRESSED_VERTS = 0; -#ifdef _DEBUG m_bSKINNING = false; -#endif // _DEBUG - m_nSKINNING = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bSKINNING; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bCOMPRESSED_VERTS && m_bSKINNING ); return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + 0; } }; -#define shaderDynamicTest_cloak_blended_pass_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0 + +#define shaderDynamicTest_cloak_blended_pass_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + diff --git a/src/materialsystem/stdshaders/include/cloak_blended_pass_vs30.inc b/src/materialsystem/stdshaders/include/cloak_blended_pass_vs30.inc index bd94090b..aa619020 100644 --- a/src/materialsystem/stdshaders/include/cloak_blended_pass_vs30.inc +++ b/src/materialsystem/stdshaders/include/cloak_blended_pass_vs30.inc @@ -1,11 +1,14 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class cloak_blended_pass_vs30_Static_Index { -private: - int m_nBUMPMAP; + unsigned int m_nBUMPMAP : 2; #ifdef _DEBUG - bool m_bBUMPMAP; -#endif + bool m_bBUMPMAP : 1; +#endif // _DEBUG public: void SetBUMPMAP( int i ) { @@ -13,42 +16,37 @@ public: m_nBUMPMAP = i; #ifdef _DEBUG m_bBUMPMAP = true; -#endif +#endif // _DEBUG } - void SetBUMPMAP( bool i ) - { - m_nBUMPMAP = i ? 1 : 0; -#ifdef _DEBUG - m_bBUMPMAP = true; -#endif - } -public: - cloak_blended_pass_vs30_Static_Index( ) + + cloak_blended_pass_vs30_Static_Index( ) { + m_nBUMPMAP = 0; #ifdef _DEBUG m_bBUMPMAP = false; -#endif // _DEBUG - m_nBUMPMAP = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bBUMPMAP; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bBUMPMAP ); return ( 8 * m_nBUMPMAP ) + 0; } }; -#define shaderStaticTest_cloak_blended_pass_vs30 vsh_forgot_to_set_static_BUMPMAP + 0 + +#define shaderStaticTest_cloak_blended_pass_vs30 vsh_forgot_to_set_static_BUMPMAP + + class cloak_blended_pass_vs30_Dynamic_Index { -private: - int m_nCOMPRESSED_VERTS; + unsigned int m_nCOMPRESSED_VERTS : 2; + unsigned int m_nSKINNING : 2; + unsigned int m_nMORPHING : 2; #ifdef _DEBUG - bool m_bCOMPRESSED_VERTS; -#endif + bool m_bCOMPRESSED_VERTS : 1; + bool m_bSKINNING : 1; + bool m_bMORPHING : 1; +#endif // _DEBUG public: void SetCOMPRESSED_VERTS( int i ) { @@ -56,82 +54,45 @@ public: m_nCOMPRESSED_VERTS = i; #ifdef _DEBUG m_bCOMPRESSED_VERTS = true; -#endif +#endif // _DEBUG } - void SetCOMPRESSED_VERTS( bool i ) - { - m_nCOMPRESSED_VERTS = i ? 1 : 0; -#ifdef _DEBUG - m_bCOMPRESSED_VERTS = 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 +#endif // _DEBUG } - void SetSKINNING( bool i ) - { - m_nSKINNING = i ? 1 : 0; -#ifdef _DEBUG - m_bSKINNING = true; -#endif - } -private: - int m_nMORPHING; -#ifdef _DEBUG - bool m_bMORPHING; -#endif -public: + void SetMORPHING( int i ) { Assert( i >= 0 && i <= 1 ); m_nMORPHING = i; #ifdef _DEBUG m_bMORPHING = true; -#endif +#endif // _DEBUG } - void SetMORPHING( bool i ) - { - m_nMORPHING = i ? 1 : 0; -#ifdef _DEBUG - m_bMORPHING = true; -#endif - } -public: - cloak_blended_pass_vs30_Dynamic_Index() + + cloak_blended_pass_vs30_Dynamic_Index( ) { + m_nCOMPRESSED_VERTS = 0; + m_nSKINNING = 0; + m_nMORPHING = 0; #ifdef _DEBUG m_bCOMPRESSED_VERTS = false; -#endif // _DEBUG - m_nCOMPRESSED_VERTS = 0; -#ifdef _DEBUG m_bSKINNING = false; -#endif // _DEBUG - m_nSKINNING = 0; -#ifdef _DEBUG m_bMORPHING = false; -#endif // _DEBUG - m_nMORPHING = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bSKINNING && m_bMORPHING; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bCOMPRESSED_VERTS && m_bSKINNING && m_bMORPHING ); return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nMORPHING ) + 0; } }; -#define shaderDynamicTest_cloak_blended_pass_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 + +#define shaderDynamicTest_cloak_blended_pass_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + diff --git a/src/materialsystem/stdshaders/include/core_ps20b.inc b/src/materialsystem/stdshaders/include/core_ps20b.inc index b90999f6..051900d8 100644 --- a/src/materialsystem/stdshaders/include/core_ps20b.inc +++ b/src/materialsystem/stdshaders/include/core_ps20b.inc @@ -1,154 +1,103 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// ( $REFRACT || $CORECOLORTEXTURE ) && $CUBEMAP +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class core_ps20b_Static_Index { -private: - int m_nCONVERT_TO_SRGB; + unsigned int m_nCONVERT_TO_SRGB : 1; + unsigned int m_nCUBEMAP : 2; + unsigned int m_nFLOWMAP : 2; + unsigned int m_nCORECOLORTEXTURE : 2; + unsigned int m_nREFRACT : 2; #ifdef _DEBUG - bool m_bCONVERT_TO_SRGB; -#endif + bool m_bCUBEMAP : 1; + bool m_bFLOWMAP : 1; + bool m_bCORECOLORTEXTURE : 1; + bool m_bREFRACT : 1; +#endif // _DEBUG public: void SetCONVERT_TO_SRGB( int i ) { - Assert( i >= 0 && i <= 1 ); + 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_nCUBEMAP; -#ifdef _DEBUG - bool m_bCUBEMAP; -#endif -public: + void SetCUBEMAP( int i ) { Assert( i >= 0 && i <= 1 ); m_nCUBEMAP = i; #ifdef _DEBUG m_bCUBEMAP = true; -#endif +#endif // _DEBUG } - void SetCUBEMAP( bool i ) - { - m_nCUBEMAP = i ? 1 : 0; -#ifdef _DEBUG - m_bCUBEMAP = true; -#endif - } -private: - int m_nFLOWMAP; -#ifdef _DEBUG - bool m_bFLOWMAP; -#endif -public: + void SetFLOWMAP( int i ) { Assert( i >= 0 && i <= 1 ); m_nFLOWMAP = i; #ifdef _DEBUG m_bFLOWMAP = true; -#endif +#endif // _DEBUG } - void SetFLOWMAP( bool i ) - { - m_nFLOWMAP = i ? 1 : 0; -#ifdef _DEBUG - m_bFLOWMAP = true; -#endif - } -private: - int m_nCORECOLORTEXTURE; -#ifdef _DEBUG - bool m_bCORECOLORTEXTURE; -#endif -public: + void SetCORECOLORTEXTURE( int i ) { Assert( i >= 0 && i <= 1 ); m_nCORECOLORTEXTURE = i; #ifdef _DEBUG m_bCORECOLORTEXTURE = true; -#endif +#endif // _DEBUG } - void SetCORECOLORTEXTURE( bool i ) - { - m_nCORECOLORTEXTURE = i ? 1 : 0; -#ifdef _DEBUG - m_bCORECOLORTEXTURE = true; -#endif - } -private: - int m_nREFRACT; -#ifdef _DEBUG - bool m_bREFRACT; -#endif -public: + void SetREFRACT( int i ) { Assert( i >= 0 && i <= 1 ); m_nREFRACT = i; #ifdef _DEBUG m_bREFRACT = true; -#endif +#endif // _DEBUG } - void SetREFRACT( bool i ) + + core_ps20b_Static_Index( ) { - m_nREFRACT = i ? 1 : 0; -#ifdef _DEBUG - m_bREFRACT = true; -#endif - } -public: - core_ps20b_Static_Index( ) - { -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif // _DEBUG - m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nCUBEMAP = 0; + m_nFLOWMAP = 0; + m_nCORECOLORTEXTURE = 0; + m_nREFRACT = 0; #ifdef _DEBUG m_bCUBEMAP = false; -#endif // _DEBUG - m_nCUBEMAP = 0; -#ifdef _DEBUG m_bFLOWMAP = false; -#endif // _DEBUG - m_nFLOWMAP = 0; -#ifdef _DEBUG m_bCORECOLORTEXTURE = false; -#endif // _DEBUG - m_nCORECOLORTEXTURE = 0; -#ifdef _DEBUG m_bREFRACT = false; -#endif // _DEBUG - m_nREFRACT = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bCUBEMAP && m_bFLOWMAP && m_bCORECOLORTEXTURE && m_bREFRACT; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG - return ( 2 * m_nCONVERT_TO_SRGB ) + ( 4 * m_nCUBEMAP ) + ( 8 * m_nFLOWMAP ) + ( 16 * m_nCORECOLORTEXTURE ) + ( 32 * m_nREFRACT ) + 0; + Assert( m_bCUBEMAP && m_bFLOWMAP && m_bCORECOLORTEXTURE && m_bREFRACT ); + AssertMsg( !( ( m_nREFRACT || m_nCORECOLORTEXTURE ) && m_nCUBEMAP ), "Invalid combo combination ( ( REFRACT || CORECOLORTEXTURE ) && CUBEMAP )" ); + return ( 2 * m_nCONVERT_TO_SRGB ) + ( 2 * m_nCUBEMAP ) + ( 4 * m_nFLOWMAP ) + ( 8 * m_nCORECOLORTEXTURE ) + ( 16 * m_nREFRACT ) + 0; } }; -#define shaderStaticTest_core_ps20b psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_FLOWMAP + psh_forgot_to_set_static_CORECOLORTEXTURE + psh_forgot_to_set_static_REFRACT + 0 + +#define shaderStaticTest_core_ps20b psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_FLOWMAP + psh_forgot_to_set_static_CORECOLORTEXTURE + psh_forgot_to_set_static_REFRACT + + class core_ps20b_Dynamic_Index { -private: - int m_nPIXELFOGTYPE; + unsigned int m_nPIXELFOGTYPE : 2; #ifdef _DEBUG - bool m_bPIXELFOGTYPE; -#endif + bool m_bPIXELFOGTYPE : 1; +#endif // _DEBUG public: void SetPIXELFOGTYPE( int i ) { @@ -156,32 +105,23 @@ public: m_nPIXELFOGTYPE = i; #ifdef _DEBUG m_bPIXELFOGTYPE = true; -#endif +#endif // _DEBUG } - void SetPIXELFOGTYPE( bool i ) - { - m_nPIXELFOGTYPE = i ? 1 : 0; -#ifdef _DEBUG - m_bPIXELFOGTYPE = true; -#endif - } -public: - core_ps20b_Dynamic_Index() + + core_ps20b_Dynamic_Index( ) { + m_nPIXELFOGTYPE = 0; #ifdef _DEBUG m_bPIXELFOGTYPE = false; -#endif // _DEBUG - m_nPIXELFOGTYPE = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bPIXELFOGTYPE; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bPIXELFOGTYPE ); return ( 1 * m_nPIXELFOGTYPE ) + 0; } }; -#define shaderDynamicTest_core_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 + +#define shaderDynamicTest_core_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + diff --git a/src/materialsystem/stdshaders/include/core_vs20.inc b/src/materialsystem/stdshaders/include/core_vs20.inc index 5cbf35fc..3eea822c 100644 --- a/src/materialsystem/stdshaders/include/core_vs20.inc +++ b/src/materialsystem/stdshaders/include/core_vs20.inc @@ -1,11 +1,14 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class core_vs20_Static_Index { -private: - int m_nMODEL; + unsigned int m_nMODEL : 2; #ifdef _DEBUG - bool m_bMODEL; -#endif + bool m_bMODEL : 1; +#endif // _DEBUG public: void SetMODEL( int i ) { @@ -13,42 +16,35 @@ public: m_nMODEL = i; #ifdef _DEBUG m_bMODEL = true; -#endif +#endif // _DEBUG } - void SetMODEL( bool i ) - { - m_nMODEL = i ? 1 : 0; -#ifdef _DEBUG - m_bMODEL = true; -#endif - } -public: - core_vs20_Static_Index( ) + + core_vs20_Static_Index( ) { + m_nMODEL = 0; #ifdef _DEBUG m_bMODEL = false; -#endif // _DEBUG - m_nMODEL = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bMODEL; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bMODEL ); return ( 4 * m_nMODEL ) + 0; } }; -#define shaderStaticTest_core_vs20 vsh_forgot_to_set_static_MODEL + 0 + +#define shaderStaticTest_core_vs20 vsh_forgot_to_set_static_MODEL + + class core_vs20_Dynamic_Index { -private: - int m_nCOMPRESSED_VERTS; + unsigned int m_nCOMPRESSED_VERTS : 2; + unsigned int m_nSKINNING : 2; #ifdef _DEBUG - bool m_bCOMPRESSED_VERTS; -#endif + bool m_bCOMPRESSED_VERTS : 1; + bool m_bSKINNING : 1; +#endif // _DEBUG public: void SetCOMPRESSED_VERTS( int i ) { @@ -56,57 +52,34 @@ public: m_nCOMPRESSED_VERTS = i; #ifdef _DEBUG m_bCOMPRESSED_VERTS = true; -#endif +#endif // _DEBUG } - void SetCOMPRESSED_VERTS( bool i ) - { - m_nCOMPRESSED_VERTS = i ? 1 : 0; -#ifdef _DEBUG - m_bCOMPRESSED_VERTS = 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 +#endif // _DEBUG } - void SetSKINNING( bool i ) - { - m_nSKINNING = i ? 1 : 0; -#ifdef _DEBUG - m_bSKINNING = true; -#endif - } -public: - core_vs20_Dynamic_Index() + + core_vs20_Dynamic_Index( ) { + m_nCOMPRESSED_VERTS = 0; + m_nSKINNING = 0; #ifdef _DEBUG m_bCOMPRESSED_VERTS = false; -#endif // _DEBUG - m_nCOMPRESSED_VERTS = 0; -#ifdef _DEBUG m_bSKINNING = false; -#endif // _DEBUG - m_nSKINNING = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bSKINNING; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bCOMPRESSED_VERTS && m_bSKINNING ); return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + 0; } }; -#define shaderDynamicTest_core_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0 + +#define shaderDynamicTest_core_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + diff --git a/src/materialsystem/stdshaders/include/decalmodulate_ps20b.inc b/src/materialsystem/stdshaders/include/decalmodulate_ps20b.inc index 73d60e78..d1c0b18d 100644 --- a/src/materialsystem/stdshaders/include/decalmodulate_ps20b.inc +++ b/src/materialsystem/stdshaders/include/decalmodulate_ps20b.inc @@ -1,4 +1,13 @@ // ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) +// ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW // defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED // defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA // defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 @@ -18,33 +27,72 @@ #include "shaderlib/cshader.h" class decalmodulate_ps20b_Static_Index { - unsigned int m_nCONVERT_TO_SRGB : 2; + unsigned int m_nVERTEXALPHA : 2; + unsigned int m_nFLASHLIGHT : 2; + unsigned int m_nFLASHLIGHTDEPTHFILTERMODE : 2; +#ifdef _DEBUG + bool m_bVERTEXALPHA : 1; + bool m_bFLASHLIGHT : 1; + bool m_bFLASHLIGHTDEPTHFILTERMODE : 1; +#endif // _DEBUG public: - void SetCONVERT_TO_SRGB( int i ) + void SetVERTEXALPHA( int i ) { Assert( i >= 0 && i <= 1 ); - m_nCONVERT_TO_SRGB = i; + m_nVERTEXALPHA = i; +#ifdef _DEBUG + m_bVERTEXALPHA = true; +#endif // _DEBUG + } + + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif // _DEBUG + } + + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif // _DEBUG } decalmodulate_ps20b_Static_Index( ) { - m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nVERTEXALPHA = 0; + m_nFLASHLIGHT = 0; + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bVERTEXALPHA = false; + m_bFLASHLIGHT = false; + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG } int GetIndex() const { - return ( 3 * m_nCONVERT_TO_SRGB ) + 0; + Assert( m_bVERTEXALPHA && m_bFLASHLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE ); + AssertMsg( !( ( m_nFLASHLIGHT == 0 ) && ( m_nFLASHLIGHTDEPTHFILTERMODE != 0 ) ), "Invalid combo combination ( ( FLASHLIGHT == 0 ) && ( FLASHLIGHTDEPTHFILTERMODE != 0 ) )" ); + return ( 6 * m_nVERTEXALPHA ) + ( 12 * m_nFLASHLIGHT ) + ( 24 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; } }; -#define shaderStaticTest_decalmodulate_ps20b 1 +#define shaderStaticTest_decalmodulate_ps20b psh_forgot_to_set_static_VERTEXALPHA + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE class decalmodulate_ps20b_Dynamic_Index { unsigned int m_nPIXELFOGTYPE : 2; + unsigned int m_nFLASHLIGHTSHADOWS : 2; #ifdef _DEBUG bool m_bPIXELFOGTYPE : 1; + bool m_bFLASHLIGHTSHADOWS : 1; #endif // _DEBUG public: void SetPIXELFOGTYPE( int i ) @@ -56,20 +104,31 @@ public: #endif // _DEBUG } + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif // _DEBUG + } + decalmodulate_ps20b_Dynamic_Index( ) { m_nPIXELFOGTYPE = 0; + m_nFLASHLIGHTSHADOWS = 0; #ifdef _DEBUG m_bPIXELFOGTYPE = false; + m_bFLASHLIGHTSHADOWS = false; #endif // _DEBUG } int GetIndex() const { - Assert( m_bPIXELFOGTYPE ); - return ( 1 * m_nPIXELFOGTYPE ) + 0; + Assert( m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS ); + return ( 1 * m_nPIXELFOGTYPE ) + ( 3 * m_nFLASHLIGHTSHADOWS ) + 0; } }; -#define shaderDynamicTest_decalmodulate_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE +#define shaderDynamicTest_decalmodulate_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS diff --git a/src/materialsystem/stdshaders/include/decalmodulate_ps30.inc b/src/materialsystem/stdshaders/include/decalmodulate_ps30.inc index f7454b1f..fd980dfd 100644 --- a/src/materialsystem/stdshaders/include/decalmodulate_ps30.inc +++ b/src/materialsystem/stdshaders/include/decalmodulate_ps30.inc @@ -1,4 +1,13 @@ // ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) +// ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW // defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED // defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA // defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 @@ -18,33 +27,72 @@ #include "shaderlib/cshader.h" class decalmodulate_ps30_Static_Index { - unsigned int m_nCONVERT_TO_SRGB : 2; + unsigned int m_nVERTEXALPHA : 2; + unsigned int m_nFLASHLIGHT : 2; + unsigned int m_nFLASHLIGHTDEPTHFILTERMODE : 2; +#ifdef _DEBUG + bool m_bVERTEXALPHA : 1; + bool m_bFLASHLIGHT : 1; + bool m_bFLASHLIGHTDEPTHFILTERMODE : 1; +#endif // _DEBUG public: - void SetCONVERT_TO_SRGB( int i ) + void SetVERTEXALPHA( int i ) { Assert( i >= 0 && i <= 1 ); - m_nCONVERT_TO_SRGB = i; + m_nVERTEXALPHA = i; +#ifdef _DEBUG + m_bVERTEXALPHA = true; +#endif // _DEBUG + } + + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif // _DEBUG + } + + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif // _DEBUG } decalmodulate_ps30_Static_Index( ) { - m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nVERTEXALPHA = 0; + m_nFLASHLIGHT = 0; + m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#ifdef _DEBUG + m_bVERTEXALPHA = false; + m_bFLASHLIGHT = false; + m_bFLASHLIGHTDEPTHFILTERMODE = false; +#endif // _DEBUG } int GetIndex() const { - return ( 3 * m_nCONVERT_TO_SRGB ) + 0; + Assert( m_bVERTEXALPHA && m_bFLASHLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE ); + AssertMsg( !( ( m_nFLASHLIGHT == 0 ) && ( m_nFLASHLIGHTDEPTHFILTERMODE != 0 ) ), "Invalid combo combination ( ( FLASHLIGHT == 0 ) && ( FLASHLIGHTDEPTHFILTERMODE != 0 ) )" ); + return ( 6 * m_nVERTEXALPHA ) + ( 12 * m_nFLASHLIGHT ) + ( 24 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; } }; -#define shaderStaticTest_decalmodulate_ps30 1 +#define shaderStaticTest_decalmodulate_ps30 psh_forgot_to_set_static_VERTEXALPHA + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE class decalmodulate_ps30_Dynamic_Index { unsigned int m_nPIXELFOGTYPE : 2; + unsigned int m_nFLASHLIGHTSHADOWS : 2; #ifdef _DEBUG bool m_bPIXELFOGTYPE : 1; + bool m_bFLASHLIGHTSHADOWS : 1; #endif // _DEBUG public: void SetPIXELFOGTYPE( int i ) @@ -56,20 +104,31 @@ public: #endif // _DEBUG } + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif // _DEBUG + } + decalmodulate_ps30_Dynamic_Index( ) { m_nPIXELFOGTYPE = 0; + m_nFLASHLIGHTSHADOWS = 0; #ifdef _DEBUG m_bPIXELFOGTYPE = false; + m_bFLASHLIGHTSHADOWS = false; #endif // _DEBUG } int GetIndex() const { - Assert( m_bPIXELFOGTYPE ); - return ( 1 * m_nPIXELFOGTYPE ) + 0; + Assert( m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS ); + return ( 1 * m_nPIXELFOGTYPE ) + ( 3 * m_nFLASHLIGHTSHADOWS ) + 0; } }; -#define shaderDynamicTest_decalmodulate_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE +#define shaderDynamicTest_decalmodulate_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS diff --git a/src/materialsystem/stdshaders/include/decalmodulate_vs20.inc b/src/materialsystem/stdshaders/include/decalmodulate_vs20.inc new file mode 100644 index 00000000..0eb6aa68 --- /dev/null +++ b/src/materialsystem/stdshaders/include/decalmodulate_vs20.inc @@ -0,0 +1,124 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once +#include "shaderlib/cshader.h" +class decalmodulate_vs20_Static_Index +{ + unsigned int m_nVERTEXCOLOR : 2; + unsigned int m_nLIGHTING_PREVIEW : 2; + unsigned int m_nFLASHLIGHT : 2; +#ifdef _DEBUG + bool m_bVERTEXCOLOR : 1; + bool m_bLIGHTING_PREVIEW : 1; + bool m_bFLASHLIGHT : 1; +#endif // _DEBUG +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif // _DEBUG + } + + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif // _DEBUG + } + + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif // _DEBUG + } + + decalmodulate_vs20_Static_Index( ) + { + m_nVERTEXCOLOR = 0; + m_nLIGHTING_PREVIEW = 0; + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; + m_bLIGHTING_PREVIEW = false; + m_bFLASHLIGHT = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bVERTEXCOLOR && m_bLIGHTING_PREVIEW && m_bFLASHLIGHT ); + return ( 4 * m_nVERTEXCOLOR ) + ( 8 * m_nLIGHTING_PREVIEW ) + ( 16 * m_nFLASHLIGHT ) + 0; + } +}; + +#define shaderStaticTest_decalmodulate_vs20 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_LIGHTING_PREVIEW + vsh_forgot_to_set_static_FLASHLIGHT + + +class decalmodulate_vs20_Dynamic_Index +{ + unsigned int m_nDOWATERFOG : 2; + unsigned int m_nCOMPRESSED_VERTS : 2; + unsigned int m_nSKINNING : 1; +#ifdef _DEBUG + bool m_bDOWATERFOG : 1; + bool m_bCOMPRESSED_VERTS : 1; + bool m_bSKINNING : 1; +#endif // _DEBUG +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif // _DEBUG + } + + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif // _DEBUG + } + + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif // _DEBUG + } + + decalmodulate_vs20_Dynamic_Index( ) + { + m_nDOWATERFOG = 0; + m_nCOMPRESSED_VERTS = 0; + m_nSKINNING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; + m_bCOMPRESSED_VERTS = false; + m_bSKINNING = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bDOWATERFOG && m_bCOMPRESSED_VERTS && m_bSKINNING ); + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nCOMPRESSED_VERTS ) + ( 4 * m_nSKINNING ) + 0; + } +}; + +#define shaderDynamicTest_decalmodulate_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + diff --git a/src/materialsystem/stdshaders/include/decalmodulate_vs30.inc b/src/materialsystem/stdshaders/include/decalmodulate_vs30.inc new file mode 100644 index 00000000..695580d6 --- /dev/null +++ b/src/materialsystem/stdshaders/include/decalmodulate_vs30.inc @@ -0,0 +1,137 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once +#include "shaderlib/cshader.h" +class decalmodulate_vs30_Static_Index +{ + unsigned int m_nVERTEXCOLOR : 2; + unsigned int m_nLIGHTING_PREVIEW : 2; + unsigned int m_nFLASHLIGHT : 2; +#ifdef _DEBUG + bool m_bVERTEXCOLOR : 1; + bool m_bLIGHTING_PREVIEW : 1; + bool m_bFLASHLIGHT : 1; +#endif // _DEBUG +public: + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif // _DEBUG + } + + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif // _DEBUG + } + + void SetFLASHLIGHT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHT = i; +#ifdef _DEBUG + m_bFLASHLIGHT = true; +#endif // _DEBUG + } + + decalmodulate_vs30_Static_Index( ) + { + m_nVERTEXCOLOR = 0; + m_nLIGHTING_PREVIEW = 0; + m_nFLASHLIGHT = 0; +#ifdef _DEBUG + m_bVERTEXCOLOR = false; + m_bLIGHTING_PREVIEW = false; + m_bFLASHLIGHT = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bVERTEXCOLOR && m_bLIGHTING_PREVIEW && m_bFLASHLIGHT ); + return ( 16 * m_nVERTEXCOLOR ) + ( 32 * m_nLIGHTING_PREVIEW ) + ( 64 * m_nFLASHLIGHT ) + 0; + } +}; + +#define shaderStaticTest_decalmodulate_vs30 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_LIGHTING_PREVIEW + vsh_forgot_to_set_static_FLASHLIGHT + + +class decalmodulate_vs30_Dynamic_Index +{ + unsigned int m_nDOWATERFOG : 2; + unsigned int m_nCOMPRESSED_VERTS : 2; + unsigned int m_nSKINNING : 2; + unsigned int m_nMORPHING : 2; +#ifdef _DEBUG + bool m_bDOWATERFOG : 1; + bool m_bCOMPRESSED_VERTS : 1; + bool m_bSKINNING : 1; + bool m_bMORPHING : 1; +#endif // _DEBUG +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif // _DEBUG + } + + void SetCOMPRESSED_VERTS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOMPRESSED_VERTS = i; +#ifdef _DEBUG + m_bCOMPRESSED_VERTS = true; +#endif // _DEBUG + } + + void SetSKINNING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSKINNING = i; +#ifdef _DEBUG + m_bSKINNING = true; +#endif // _DEBUG + } + + void SetMORPHING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMORPHING = i; +#ifdef _DEBUG + m_bMORPHING = true; +#endif // _DEBUG + } + + decalmodulate_vs30_Dynamic_Index( ) + { + m_nDOWATERFOG = 0; + m_nCOMPRESSED_VERTS = 0; + m_nSKINNING = 0; + m_nMORPHING = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; + m_bCOMPRESSED_VERTS = false; + m_bSKINNING = false; + m_bMORPHING = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bDOWATERFOG && m_bCOMPRESSED_VERTS && m_bSKINNING && m_bMORPHING ); + return ( 1 * m_nDOWATERFOG ) + ( 2 * m_nCOMPRESSED_VERTS ) + ( 4 * m_nSKINNING ) + ( 8 * m_nMORPHING ) + 0; + } +}; + +#define shaderDynamicTest_decalmodulate_vs30 vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + diff --git a/src/materialsystem/stdshaders/include/depthwrite_ps20b.inc b/src/materialsystem/stdshaders/include/depthwrite_ps20b.inc index a3d0bf44..f5ba9a8f 100644 --- a/src/materialsystem/stdshaders/include/depthwrite_ps20b.inc +++ b/src/materialsystem/stdshaders/include/depthwrite_ps20b.inc @@ -1,11 +1,11 @@ +#pragma once #include "shaderlib/cshader.h" class depthwrite_ps20b_Static_Index { -private: - int m_nCOLOR_DEPTH; + unsigned int m_nCOLOR_DEPTH : 2; #ifdef _DEBUG - bool m_bCOLOR_DEPTH; -#endif + bool m_bCOLOR_DEPTH : 1; +#endif // _DEBUG public: void SetCOLOR_DEPTH( int i ) { @@ -13,42 +13,33 @@ public: m_nCOLOR_DEPTH = i; #ifdef _DEBUG m_bCOLOR_DEPTH = true; -#endif +#endif // _DEBUG } - void SetCOLOR_DEPTH( bool i ) - { - m_nCOLOR_DEPTH = i ? 1 : 0; -#ifdef _DEBUG - m_bCOLOR_DEPTH = true; -#endif - } -public: - depthwrite_ps20b_Static_Index( ) + + depthwrite_ps20b_Static_Index( ) { + m_nCOLOR_DEPTH = 0; #ifdef _DEBUG m_bCOLOR_DEPTH = false; -#endif // _DEBUG - m_nCOLOR_DEPTH = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bCOLOR_DEPTH; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bCOLOR_DEPTH ); return ( 2 * m_nCOLOR_DEPTH ) + 0; } }; -#define shaderStaticTest_depthwrite_ps20b psh_forgot_to_set_static_COLOR_DEPTH + 0 + +#define shaderStaticTest_depthwrite_ps20b psh_forgot_to_set_static_COLOR_DEPTH + + class depthwrite_ps20b_Dynamic_Index { -private: - int m_nALPHACLIP; + unsigned int m_nALPHACLIP : 2; #ifdef _DEBUG - bool m_bALPHACLIP; -#endif + bool m_bALPHACLIP : 1; +#endif // _DEBUG public: void SetALPHACLIP( int i ) { @@ -56,32 +47,23 @@ public: m_nALPHACLIP = i; #ifdef _DEBUG m_bALPHACLIP = true; -#endif +#endif // _DEBUG } - void SetALPHACLIP( bool i ) - { - m_nALPHACLIP = i ? 1 : 0; -#ifdef _DEBUG - m_bALPHACLIP = true; -#endif - } -public: - depthwrite_ps20b_Dynamic_Index() + + depthwrite_ps20b_Dynamic_Index( ) { + m_nALPHACLIP = 0; #ifdef _DEBUG m_bALPHACLIP = false; -#endif // _DEBUG - m_nALPHACLIP = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bALPHACLIP; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bALPHACLIP ); return ( 1 * m_nALPHACLIP ) + 0; } }; -#define shaderDynamicTest_depthwrite_ps20b psh_forgot_to_set_dynamic_ALPHACLIP + 0 + +#define shaderDynamicTest_depthwrite_ps20b psh_forgot_to_set_dynamic_ALPHACLIP + diff --git a/src/materialsystem/stdshaders/include/depthwrite_ps30.inc b/src/materialsystem/stdshaders/include/depthwrite_ps30.inc index af6d03c2..be982767 100644 --- a/src/materialsystem/stdshaders/include/depthwrite_ps30.inc +++ b/src/materialsystem/stdshaders/include/depthwrite_ps30.inc @@ -1,11 +1,11 @@ +#pragma once #include "shaderlib/cshader.h" class depthwrite_ps30_Static_Index { -private: - int m_nCOLOR_DEPTH; + unsigned int m_nCOLOR_DEPTH : 2; #ifdef _DEBUG - bool m_bCOLOR_DEPTH; -#endif + bool m_bCOLOR_DEPTH : 1; +#endif // _DEBUG public: void SetCOLOR_DEPTH( int i ) { @@ -13,42 +13,33 @@ public: m_nCOLOR_DEPTH = i; #ifdef _DEBUG m_bCOLOR_DEPTH = true; -#endif +#endif // _DEBUG } - void SetCOLOR_DEPTH( bool i ) - { - m_nCOLOR_DEPTH = i ? 1 : 0; -#ifdef _DEBUG - m_bCOLOR_DEPTH = true; -#endif - } -public: - depthwrite_ps30_Static_Index( ) + + depthwrite_ps30_Static_Index( ) { + m_nCOLOR_DEPTH = 0; #ifdef _DEBUG m_bCOLOR_DEPTH = false; -#endif // _DEBUG - m_nCOLOR_DEPTH = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bCOLOR_DEPTH; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bCOLOR_DEPTH ); return ( 2 * m_nCOLOR_DEPTH ) + 0; } }; -#define shaderStaticTest_depthwrite_ps30 psh_forgot_to_set_static_COLOR_DEPTH + 0 + +#define shaderStaticTest_depthwrite_ps30 psh_forgot_to_set_static_COLOR_DEPTH + + class depthwrite_ps30_Dynamic_Index { -private: - int m_nALPHACLIP; + unsigned int m_nALPHACLIP : 2; #ifdef _DEBUG - bool m_bALPHACLIP; -#endif + bool m_bALPHACLIP : 1; +#endif // _DEBUG public: void SetALPHACLIP( int i ) { @@ -56,32 +47,23 @@ public: m_nALPHACLIP = i; #ifdef _DEBUG m_bALPHACLIP = true; -#endif +#endif // _DEBUG } - void SetALPHACLIP( bool i ) - { - m_nALPHACLIP = i ? 1 : 0; -#ifdef _DEBUG - m_bALPHACLIP = true; -#endif - } -public: - depthwrite_ps30_Dynamic_Index() + + depthwrite_ps30_Dynamic_Index( ) { + m_nALPHACLIP = 0; #ifdef _DEBUG m_bALPHACLIP = false; -#endif // _DEBUG - m_nALPHACLIP = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bALPHACLIP; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bALPHACLIP ); return ( 1 * m_nALPHACLIP ) + 0; } }; -#define shaderDynamicTest_depthwrite_ps30 psh_forgot_to_set_dynamic_ALPHACLIP + 0 + +#define shaderDynamicTest_depthwrite_ps30 psh_forgot_to_set_dynamic_ALPHACLIP + diff --git a/src/materialsystem/stdshaders/include/depthwrite_vs20.inc b/src/materialsystem/stdshaders/include/depthwrite_vs20.inc index 7b78dcf5..fae5633f 100644 --- a/src/materialsystem/stdshaders/include/depthwrite_vs20.inc +++ b/src/materialsystem/stdshaders/include/depthwrite_vs20.inc @@ -1,11 +1,18 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class depthwrite_vs20_Static_Index { -private: - int m_nONLY_PROJECT_POSITION; + unsigned int m_nONLY_PROJECT_POSITION : 1; + unsigned int m_nCOLOR_DEPTH : 2; + unsigned int m_nTREESWAY : 2; #ifdef _DEBUG - bool m_bONLY_PROJECT_POSITION; -#endif + bool m_bONLY_PROJECT_POSITION : 1; + bool m_bCOLOR_DEPTH : 1; + bool m_bTREESWAY : 1; +#endif // _DEBUG public: void SetONLY_PROJECT_POSITION( int i ) { @@ -13,92 +20,57 @@ public: m_nONLY_PROJECT_POSITION = i; #ifdef _DEBUG m_bONLY_PROJECT_POSITION = true; -#endif +#endif // _DEBUG } - void SetONLY_PROJECT_POSITION( bool i ) - { - m_nONLY_PROJECT_POSITION = i ? 1 : 0; -#ifdef _DEBUG - m_bONLY_PROJECT_POSITION = true; -#endif - } -private: - int m_nCOLOR_DEPTH; -#ifdef _DEBUG - bool m_bCOLOR_DEPTH; -#endif -public: + void SetCOLOR_DEPTH( int i ) { Assert( i >= 0 && i <= 1 ); m_nCOLOR_DEPTH = i; #ifdef _DEBUG m_bCOLOR_DEPTH = true; -#endif +#endif // _DEBUG } - void SetCOLOR_DEPTH( bool i ) - { - m_nCOLOR_DEPTH = i ? 1 : 0; -#ifdef _DEBUG - m_bCOLOR_DEPTH = true; -#endif - } -private: - int m_nTREESWAY; -#ifdef _DEBUG - bool m_bTREESWAY; -#endif -public: + void SetTREESWAY( int i ) { Assert( i >= 0 && i <= 2 ); m_nTREESWAY = i; #ifdef _DEBUG m_bTREESWAY = true; -#endif +#endif // _DEBUG } - void SetTREESWAY( bool i ) - { - m_nTREESWAY = i ? 1 : 0; -#ifdef _DEBUG - m_bTREESWAY = true; -#endif - } -public: - depthwrite_vs20_Static_Index( ) + + depthwrite_vs20_Static_Index( ) { + m_nONLY_PROJECT_POSITION = 0; + m_nCOLOR_DEPTH = 0; + m_nTREESWAY = 0; #ifdef _DEBUG m_bONLY_PROJECT_POSITION = false; -#endif // _DEBUG - m_nONLY_PROJECT_POSITION = 0; -#ifdef _DEBUG m_bCOLOR_DEPTH = false; -#endif // _DEBUG - m_nCOLOR_DEPTH = 0; -#ifdef _DEBUG m_bTREESWAY = false; -#endif // _DEBUG - m_nTREESWAY = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH && m_bTREESWAY; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH && m_bTREESWAY ); return ( 4 * m_nONLY_PROJECT_POSITION ) + ( 4 * m_nCOLOR_DEPTH ) + ( 8 * m_nTREESWAY ) + 0; } }; -#define shaderStaticTest_depthwrite_vs20 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + vsh_forgot_to_set_static_TREESWAY + 0 + +#define shaderStaticTest_depthwrite_vs20 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + vsh_forgot_to_set_static_TREESWAY + + class depthwrite_vs20_Dynamic_Index { -private: - int m_nCOMPRESSED_VERTS; + unsigned int m_nCOMPRESSED_VERTS : 2; + unsigned int m_nSKINNING : 2; #ifdef _DEBUG - bool m_bCOMPRESSED_VERTS; -#endif + bool m_bCOMPRESSED_VERTS : 1; + bool m_bSKINNING : 1; +#endif // _DEBUG public: void SetCOMPRESSED_VERTS( int i ) { @@ -106,57 +78,34 @@ public: m_nCOMPRESSED_VERTS = i; #ifdef _DEBUG m_bCOMPRESSED_VERTS = true; -#endif +#endif // _DEBUG } - void SetCOMPRESSED_VERTS( bool i ) - { - m_nCOMPRESSED_VERTS = i ? 1 : 0; -#ifdef _DEBUG - m_bCOMPRESSED_VERTS = 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 +#endif // _DEBUG } - void SetSKINNING( bool i ) - { - m_nSKINNING = i ? 1 : 0; -#ifdef _DEBUG - m_bSKINNING = true; -#endif - } -public: - depthwrite_vs20_Dynamic_Index() + + depthwrite_vs20_Dynamic_Index( ) { + m_nCOMPRESSED_VERTS = 0; + m_nSKINNING = 0; #ifdef _DEBUG m_bCOMPRESSED_VERTS = false; -#endif // _DEBUG - m_nCOMPRESSED_VERTS = 0; -#ifdef _DEBUG m_bSKINNING = false; -#endif // _DEBUG - m_nSKINNING = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bSKINNING; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bCOMPRESSED_VERTS && m_bSKINNING ); return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + 0; } }; -#define shaderDynamicTest_depthwrite_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0 + +#define shaderDynamicTest_depthwrite_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + diff --git a/src/materialsystem/stdshaders/include/depthwrite_vs30.inc b/src/materialsystem/stdshaders/include/depthwrite_vs30.inc index cc6929cf..42a5d7e9 100644 --- a/src/materialsystem/stdshaders/include/depthwrite_vs30.inc +++ b/src/materialsystem/stdshaders/include/depthwrite_vs30.inc @@ -1,11 +1,18 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class depthwrite_vs30_Static_Index { -private: - int m_nONLY_PROJECT_POSITION; + unsigned int m_nONLY_PROJECT_POSITION : 1; + unsigned int m_nCOLOR_DEPTH : 2; + unsigned int m_nTREESWAY : 2; #ifdef _DEBUG - bool m_bONLY_PROJECT_POSITION; -#endif + bool m_bONLY_PROJECT_POSITION : 1; + bool m_bCOLOR_DEPTH : 1; + bool m_bTREESWAY : 1; +#endif // _DEBUG public: void SetONLY_PROJECT_POSITION( int i ) { @@ -13,92 +20,59 @@ public: m_nONLY_PROJECT_POSITION = i; #ifdef _DEBUG m_bONLY_PROJECT_POSITION = true; -#endif +#endif // _DEBUG } - void SetONLY_PROJECT_POSITION( bool i ) - { - m_nONLY_PROJECT_POSITION = i ? 1 : 0; -#ifdef _DEBUG - m_bONLY_PROJECT_POSITION = true; -#endif - } -private: - int m_nCOLOR_DEPTH; -#ifdef _DEBUG - bool m_bCOLOR_DEPTH; -#endif -public: + void SetCOLOR_DEPTH( int i ) { Assert( i >= 0 && i <= 1 ); m_nCOLOR_DEPTH = i; #ifdef _DEBUG m_bCOLOR_DEPTH = true; -#endif +#endif // _DEBUG } - void SetCOLOR_DEPTH( bool i ) - { - m_nCOLOR_DEPTH = i ? 1 : 0; -#ifdef _DEBUG - m_bCOLOR_DEPTH = true; -#endif - } -private: - int m_nTREESWAY; -#ifdef _DEBUG - bool m_bTREESWAY; -#endif -public: + void SetTREESWAY( int i ) { Assert( i >= 0 && i <= 2 ); m_nTREESWAY = i; #ifdef _DEBUG m_bTREESWAY = true; -#endif +#endif // _DEBUG } - void SetTREESWAY( bool i ) - { - m_nTREESWAY = i ? 1 : 0; -#ifdef _DEBUG - m_bTREESWAY = true; -#endif - } -public: - depthwrite_vs30_Static_Index( ) + + depthwrite_vs30_Static_Index( ) { + m_nONLY_PROJECT_POSITION = 0; + m_nCOLOR_DEPTH = 0; + m_nTREESWAY = 0; #ifdef _DEBUG m_bONLY_PROJECT_POSITION = false; -#endif // _DEBUG - m_nONLY_PROJECT_POSITION = 0; -#ifdef _DEBUG m_bCOLOR_DEPTH = false; -#endif // _DEBUG - m_nCOLOR_DEPTH = 0; -#ifdef _DEBUG m_bTREESWAY = false; -#endif // _DEBUG - m_nTREESWAY = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH && m_bTREESWAY; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH && m_bTREESWAY ); return ( 8 * m_nONLY_PROJECT_POSITION ) + ( 8 * m_nCOLOR_DEPTH ) + ( 16 * m_nTREESWAY ) + 0; } }; -#define shaderStaticTest_depthwrite_vs30 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + vsh_forgot_to_set_static_TREESWAY + 0 + +#define shaderStaticTest_depthwrite_vs30 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + vsh_forgot_to_set_static_TREESWAY + + class depthwrite_vs30_Dynamic_Index { -private: - int m_nCOMPRESSED_VERTS; + unsigned int m_nCOMPRESSED_VERTS : 2; + unsigned int m_nSKINNING : 2; + unsigned int m_nMORPHING : 2; #ifdef _DEBUG - bool m_bCOMPRESSED_VERTS; -#endif + bool m_bCOMPRESSED_VERTS : 1; + bool m_bSKINNING : 1; + bool m_bMORPHING : 1; +#endif // _DEBUG public: void SetCOMPRESSED_VERTS( int i ) { @@ -106,82 +80,45 @@ public: m_nCOMPRESSED_VERTS = i; #ifdef _DEBUG m_bCOMPRESSED_VERTS = true; -#endif +#endif // _DEBUG } - void SetCOMPRESSED_VERTS( bool i ) - { - m_nCOMPRESSED_VERTS = i ? 1 : 0; -#ifdef _DEBUG - m_bCOMPRESSED_VERTS = 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 +#endif // _DEBUG } - void SetSKINNING( bool i ) - { - m_nSKINNING = i ? 1 : 0; -#ifdef _DEBUG - m_bSKINNING = true; -#endif - } -private: - int m_nMORPHING; -#ifdef _DEBUG - bool m_bMORPHING; -#endif -public: + void SetMORPHING( int i ) { Assert( i >= 0 && i <= 1 ); m_nMORPHING = i; #ifdef _DEBUG m_bMORPHING = true; -#endif +#endif // _DEBUG } - void SetMORPHING( bool i ) - { - m_nMORPHING = i ? 1 : 0; -#ifdef _DEBUG - m_bMORPHING = true; -#endif - } -public: - depthwrite_vs30_Dynamic_Index() + + depthwrite_vs30_Dynamic_Index( ) { + m_nCOMPRESSED_VERTS = 0; + m_nSKINNING = 0; + m_nMORPHING = 0; #ifdef _DEBUG m_bCOMPRESSED_VERTS = false; -#endif // _DEBUG - m_nCOMPRESSED_VERTS = 0; -#ifdef _DEBUG m_bSKINNING = false; -#endif // _DEBUG - m_nSKINNING = 0; -#ifdef _DEBUG m_bMORPHING = false; -#endif // _DEBUG - m_nMORPHING = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bSKINNING && m_bMORPHING; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bCOMPRESSED_VERTS && m_bSKINNING && m_bMORPHING ); return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nMORPHING ) + 0; } }; -#define shaderDynamicTest_depthwrite_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 + +#define shaderDynamicTest_depthwrite_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + diff --git a/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_ps20b.inc b/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_ps20b.inc index a2989a3f..3286579e 100644 --- a/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_ps20b.inc +++ b/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_ps20b.inc @@ -1,60 +1,50 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class emissive_scroll_blended_pass_ps20b_Static_Index { -private: - int m_nCONVERT_TO_SRGB; -#ifdef _DEBUG - bool m_bCONVERT_TO_SRGB; -#endif + unsigned int m_nCONVERT_TO_SRGB : 2; 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 ) + + emissive_scroll_blended_pass_ps20b_Static_Index( ) { - m_nCONVERT_TO_SRGB = i ? 1 : 0; -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); } -public: - emissive_scroll_blended_pass_ps20b_Static_Index( ) + + int GetIndex() const { -#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_emissive_scroll_blended_pass_ps20b 0 + +#define shaderStaticTest_emissive_scroll_blended_pass_ps20b 1 + + class emissive_scroll_blended_pass_ps20b_Dynamic_Index { public: - emissive_scroll_blended_pass_ps20b_Dynamic_Index() + emissive_scroll_blended_pass_ps20b_Dynamic_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_emissive_scroll_blended_pass_ps20b 0 + +#define shaderDynamicTest_emissive_scroll_blended_pass_ps20b 1 + diff --git a/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_ps30.inc b/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_ps30.inc index 83384e4d..6fddd8e0 100644 --- a/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_ps30.inc +++ b/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_ps30.inc @@ -1,60 +1,50 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class emissive_scroll_blended_pass_ps30_Static_Index { -private: - int m_nCONVERT_TO_SRGB; -#ifdef _DEBUG - bool m_bCONVERT_TO_SRGB; -#endif + unsigned int m_nCONVERT_TO_SRGB : 2; 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 ) + + emissive_scroll_blended_pass_ps30_Static_Index( ) { - m_nCONVERT_TO_SRGB = i ? 1 : 0; -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); } -public: - emissive_scroll_blended_pass_ps30_Static_Index( ) + + int GetIndex() const { -#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_emissive_scroll_blended_pass_ps30 0 + +#define shaderStaticTest_emissive_scroll_blended_pass_ps30 1 + + class emissive_scroll_blended_pass_ps30_Dynamic_Index { public: - emissive_scroll_blended_pass_ps30_Dynamic_Index() + emissive_scroll_blended_pass_ps30_Dynamic_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_emissive_scroll_blended_pass_ps30 0 + +#define shaderDynamicTest_emissive_scroll_blended_pass_ps30 1 + diff --git a/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_vs20.inc b/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_vs20.inc index c29b0b19..f832fc87 100644 --- a/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_vs20.inc +++ b/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_vs20.inc @@ -1,27 +1,32 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class emissive_scroll_blended_pass_vs20_Static_Index { public: - emissive_scroll_blended_pass_vs20_Static_Index( ) + emissive_scroll_blended_pass_vs20_Static_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_emissive_scroll_blended_pass_vs20 0 + +#define shaderStaticTest_emissive_scroll_blended_pass_vs20 1 + + class emissive_scroll_blended_pass_vs20_Dynamic_Index { -private: - int m_nCOMPRESSED_VERTS; + unsigned int m_nCOMPRESSED_VERTS : 2; + unsigned int m_nSKINNING : 2; #ifdef _DEBUG - bool m_bCOMPRESSED_VERTS; -#endif + bool m_bCOMPRESSED_VERTS : 1; + bool m_bSKINNING : 1; +#endif // _DEBUG public: void SetCOMPRESSED_VERTS( int i ) { @@ -29,57 +34,34 @@ public: m_nCOMPRESSED_VERTS = i; #ifdef _DEBUG m_bCOMPRESSED_VERTS = true; -#endif +#endif // _DEBUG } - void SetCOMPRESSED_VERTS( bool i ) - { - m_nCOMPRESSED_VERTS = i ? 1 : 0; -#ifdef _DEBUG - m_bCOMPRESSED_VERTS = 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 +#endif // _DEBUG } - void SetSKINNING( bool i ) - { - m_nSKINNING = i ? 1 : 0; -#ifdef _DEBUG - m_bSKINNING = true; -#endif - } -public: - emissive_scroll_blended_pass_vs20_Dynamic_Index() + + emissive_scroll_blended_pass_vs20_Dynamic_Index( ) { + m_nCOMPRESSED_VERTS = 0; + m_nSKINNING = 0; #ifdef _DEBUG m_bCOMPRESSED_VERTS = false; -#endif // _DEBUG - m_nCOMPRESSED_VERTS = 0; -#ifdef _DEBUG m_bSKINNING = false; -#endif // _DEBUG - m_nSKINNING = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bSKINNING; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bCOMPRESSED_VERTS && m_bSKINNING ); return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + 0; } }; -#define shaderDynamicTest_emissive_scroll_blended_pass_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0 + +#define shaderDynamicTest_emissive_scroll_blended_pass_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + diff --git a/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_vs30.inc b/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_vs30.inc index 464117df..0db85b4b 100644 --- a/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_vs30.inc +++ b/src/materialsystem/stdshaders/include/emissive_scroll_blended_pass_vs30.inc @@ -1,27 +1,34 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class emissive_scroll_blended_pass_vs30_Static_Index { public: - emissive_scroll_blended_pass_vs30_Static_Index( ) + emissive_scroll_blended_pass_vs30_Static_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_emissive_scroll_blended_pass_vs30 0 + +#define shaderStaticTest_emissive_scroll_blended_pass_vs30 1 + + class emissive_scroll_blended_pass_vs30_Dynamic_Index { -private: - int m_nCOMPRESSED_VERTS; + unsigned int m_nCOMPRESSED_VERTS : 2; + unsigned int m_nSKINNING : 2; + unsigned int m_nMORPHING : 2; #ifdef _DEBUG - bool m_bCOMPRESSED_VERTS; -#endif + bool m_bCOMPRESSED_VERTS : 1; + bool m_bSKINNING : 1; + bool m_bMORPHING : 1; +#endif // _DEBUG public: void SetCOMPRESSED_VERTS( int i ) { @@ -29,82 +36,45 @@ public: m_nCOMPRESSED_VERTS = i; #ifdef _DEBUG m_bCOMPRESSED_VERTS = true; -#endif +#endif // _DEBUG } - void SetCOMPRESSED_VERTS( bool i ) - { - m_nCOMPRESSED_VERTS = i ? 1 : 0; -#ifdef _DEBUG - m_bCOMPRESSED_VERTS = 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 +#endif // _DEBUG } - void SetSKINNING( bool i ) - { - m_nSKINNING = i ? 1 : 0; -#ifdef _DEBUG - m_bSKINNING = true; -#endif - } -private: - int m_nMORPHING; -#ifdef _DEBUG - bool m_bMORPHING; -#endif -public: + void SetMORPHING( int i ) { Assert( i >= 0 && i <= 1 ); m_nMORPHING = i; #ifdef _DEBUG m_bMORPHING = true; -#endif +#endif // _DEBUG } - void SetMORPHING( bool i ) - { - m_nMORPHING = i ? 1 : 0; -#ifdef _DEBUG - m_bMORPHING = true; -#endif - } -public: - emissive_scroll_blended_pass_vs30_Dynamic_Index() + + emissive_scroll_blended_pass_vs30_Dynamic_Index( ) { + m_nCOMPRESSED_VERTS = 0; + m_nSKINNING = 0; + m_nMORPHING = 0; #ifdef _DEBUG m_bCOMPRESSED_VERTS = false; -#endif // _DEBUG - m_nCOMPRESSED_VERTS = 0; -#ifdef _DEBUG m_bSKINNING = false; -#endif // _DEBUG - m_nSKINNING = 0; -#ifdef _DEBUG m_bMORPHING = false; -#endif // _DEBUG - m_nMORPHING = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bSKINNING && m_bMORPHING; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bCOMPRESSED_VERTS && m_bSKINNING && m_bMORPHING ); return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nMORPHING ) + 0; } }; -#define shaderDynamicTest_emissive_scroll_blended_pass_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 + +#define shaderDynamicTest_emissive_scroll_blended_pass_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + diff --git a/src/materialsystem/stdshaders/include/engine_post_ps20b.inc b/src/materialsystem/stdshaders/include/engine_post_ps20b.inc index 47609c14..db62ade3 100644 --- a/src/materialsystem/stdshaders/include/engine_post_ps20b.inc +++ b/src/materialsystem/stdshaders/include/engine_post_ps20b.inc @@ -1,212 +1,228 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// ( $CONVERT_FROM_LINEAR == 0 ) && ( $CONVERT_TO_LINEAR == 1 ) +// ( $TOOL_MODE == 0 ) && ( $CONVERT_TO_LINEAR == 1 ) +// ( $LOCAL_CONTRAST_ENABLE == 0 ) && ( $BLURRED_VIGNETTE_ENABLE == 1 ) +// ( $TOOL_MODE == 0 ) && $TV_GAMMA +// ( $TOOL_MODE == 0 ) && $DESATURATEENABLE +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class engine_post_ps20b_Static_Index { -private: - int m_nCONVERT_TO_SRGB; + unsigned int m_nTOOL_MODE : 2; + unsigned int m_nDEPTH_BLUR_ENABLE : 2; #ifdef _DEBUG - bool m_bCONVERT_TO_SRGB; -#endif + bool m_bTOOL_MODE : 1; + bool m_bDEPTH_BLUR_ENABLE : 1; +#endif // _DEBUG public: - void SetCONVERT_TO_SRGB( int i ) + void SetTOOL_MODE( int i ) { Assert( i >= 0 && i <= 1 ); - m_nCONVERT_TO_SRGB = i; + m_nTOOL_MODE = i; #ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif + m_bTOOL_MODE = true; +#endif // _DEBUG } - void SetCONVERT_TO_SRGB( bool i ) - { - m_nCONVERT_TO_SRGB = i ? 1 : 0; -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif - } -private: - int m_nLINEAR_INPUT; -#ifdef _DEBUG - bool m_bLINEAR_INPUT; -#endif -public: - void SetLINEAR_INPUT( int i ) + + void SetDEPTH_BLUR_ENABLE( int i ) { Assert( i >= 0 && i <= 1 ); - m_nLINEAR_INPUT = i; + m_nDEPTH_BLUR_ENABLE = i; #ifdef _DEBUG - m_bLINEAR_INPUT = true; -#endif + m_bDEPTH_BLUR_ENABLE = true; +#endif // _DEBUG } - void SetLINEAR_INPUT( bool i ) + + engine_post_ps20b_Static_Index( ) { - m_nLINEAR_INPUT = i ? 1 : 0; + m_nTOOL_MODE = 0; + m_nDEPTH_BLUR_ENABLE = 0; #ifdef _DEBUG - m_bLINEAR_INPUT = true; -#endif + m_bTOOL_MODE = false; + m_bDEPTH_BLUR_ENABLE = false; +#endif // _DEBUG } -private: - int m_nLINEAR_OUTPUT; -#ifdef _DEBUG - bool m_bLINEAR_OUTPUT; -#endif -public: - void SetLINEAR_OUTPUT( int i ) + + int GetIndex() const { - Assert( i >= 0 && i <= 1 ); - m_nLINEAR_OUTPUT = i; -#ifdef _DEBUG - m_bLINEAR_OUTPUT = true; -#endif - } - void SetLINEAR_OUTPUT( bool i ) - { - m_nLINEAR_OUTPUT = i ? 1 : 0; -#ifdef _DEBUG - m_bLINEAR_OUTPUT = true; -#endif - } -public: - engine_post_ps20b_Static_Index( ) - { -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif // _DEBUG - m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); -#ifdef _DEBUG - m_bLINEAR_INPUT = false; -#endif // _DEBUG - m_nLINEAR_INPUT = 0; -#ifdef _DEBUG - m_bLINEAR_OUTPUT = false; -#endif // _DEBUG - m_nLINEAR_OUTPUT = 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_bLINEAR_INPUT && m_bLINEAR_OUTPUT; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG - return ( 40 * m_nCONVERT_TO_SRGB ) + ( 80 * m_nLINEAR_INPUT ) + ( 160 * m_nLINEAR_OUTPUT ) + 0; + Assert( m_bTOOL_MODE && m_bDEPTH_BLUR_ENABLE ); + return ( 2048 * m_nTOOL_MODE ) + ( 4096 * m_nDEPTH_BLUR_ENABLE ) + 0; } }; -#define shaderStaticTest_engine_post_ps20b psh_forgot_to_set_static_LINEAR_INPUT + psh_forgot_to_set_static_LINEAR_OUTPUT + 0 + +#define shaderStaticTest_engine_post_ps20b psh_forgot_to_set_static_TOOL_MODE + psh_forgot_to_set_static_DEPTH_BLUR_ENABLE + + class engine_post_ps20b_Dynamic_Index { -private: - int m_nAA_ENABLE; + unsigned int m_nAA_ENABLE : 1; + unsigned int m_nCOL_CORRECT_NUM_LOOKUPS : 3; + unsigned int m_nCONVERT_FROM_LINEAR : 2; + unsigned int m_nCONVERT_TO_LINEAR : 2; + unsigned int m_nNOISE_ENABLE : 2; + unsigned int m_nVIGNETTE_ENABLE : 2; + unsigned int m_nLOCAL_CONTRAST_ENABLE : 2; + unsigned int m_nBLURRED_VIGNETTE_ENABLE : 2; + unsigned int m_nVOMIT_ENABLE : 2; + unsigned int m_nTV_GAMMA : 2; + unsigned int m_nDESATURATEENABLE : 2; #ifdef _DEBUG - bool m_bAA_ENABLE; -#endif + bool m_bAA_ENABLE : 1; + bool m_bCOL_CORRECT_NUM_LOOKUPS : 1; + bool m_bCONVERT_FROM_LINEAR : 1; + bool m_bCONVERT_TO_LINEAR : 1; + bool m_bNOISE_ENABLE : 1; + bool m_bVIGNETTE_ENABLE : 1; + bool m_bLOCAL_CONTRAST_ENABLE : 1; + bool m_bBLURRED_VIGNETTE_ENABLE : 1; + bool m_bVOMIT_ENABLE : 1; + bool m_bTV_GAMMA : 1; + bool m_bDESATURATEENABLE : 1; +#endif // _DEBUG public: void SetAA_ENABLE( int i ) { - Assert( i >= 0 && i <= 1 ); + Assert( i >= 0 && i <= 0 ); m_nAA_ENABLE = i; #ifdef _DEBUG m_bAA_ENABLE = true; -#endif +#endif // _DEBUG } - void SetAA_ENABLE( bool i ) - { - m_nAA_ENABLE = i ? 1 : 0; -#ifdef _DEBUG - m_bAA_ENABLE = true; -#endif - } -private: - int m_nAA_QUALITY_MODE; -#ifdef _DEBUG - bool m_bAA_QUALITY_MODE; -#endif -public: - void SetAA_QUALITY_MODE( int i ) - { - Assert( i >= 0 && i <= 1 ); - m_nAA_QUALITY_MODE = i; -#ifdef _DEBUG - m_bAA_QUALITY_MODE = true; -#endif - } - void SetAA_QUALITY_MODE( bool i ) - { - m_nAA_QUALITY_MODE = i ? 1 : 0; -#ifdef _DEBUG - m_bAA_QUALITY_MODE = true; -#endif - } -private: - int m_nAA_REDUCE_ONE_PIXEL_LINE_BLUR; -#ifdef _DEBUG - bool m_bAA_REDUCE_ONE_PIXEL_LINE_BLUR; -#endif -public: - void SetAA_REDUCE_ONE_PIXEL_LINE_BLUR( int i ) - { - Assert( i >= 0 && i <= 1 ); - m_nAA_REDUCE_ONE_PIXEL_LINE_BLUR = i; -#ifdef _DEBUG - m_bAA_REDUCE_ONE_PIXEL_LINE_BLUR = true; -#endif - } - void SetAA_REDUCE_ONE_PIXEL_LINE_BLUR( bool i ) - { - m_nAA_REDUCE_ONE_PIXEL_LINE_BLUR = i ? 1 : 0; -#ifdef _DEBUG - m_bAA_REDUCE_ONE_PIXEL_LINE_BLUR = true; -#endif - } -private: - int m_nCOL_CORRECT_NUM_LOOKUPS; -#ifdef _DEBUG - bool m_bCOL_CORRECT_NUM_LOOKUPS; -#endif -public: + void SetCOL_CORRECT_NUM_LOOKUPS( int i ) { - Assert( i >= 0 && i <= 4 ); + Assert( i >= 0 && i <= 3 ); m_nCOL_CORRECT_NUM_LOOKUPS = i; #ifdef _DEBUG m_bCOL_CORRECT_NUM_LOOKUPS = true; -#endif +#endif // _DEBUG } - void SetCOL_CORRECT_NUM_LOOKUPS( bool i ) + + void SetCONVERT_FROM_LINEAR( int i ) { - m_nCOL_CORRECT_NUM_LOOKUPS = i ? 1 : 0; + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_FROM_LINEAR = i; #ifdef _DEBUG - m_bCOL_CORRECT_NUM_LOOKUPS = true; -#endif + m_bCONVERT_FROM_LINEAR = true; +#endif // _DEBUG } -public: - engine_post_ps20b_Dynamic_Index() + + void SetCONVERT_TO_LINEAR( int i ) { + Assert( i >= 0 && i <= 1 ); + m_nCONVERT_TO_LINEAR = i; +#ifdef _DEBUG + m_bCONVERT_TO_LINEAR = true; +#endif // _DEBUG + } + + void SetNOISE_ENABLE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNOISE_ENABLE = i; +#ifdef _DEBUG + m_bNOISE_ENABLE = true; +#endif // _DEBUG + } + + void SetVIGNETTE_ENABLE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVIGNETTE_ENABLE = i; +#ifdef _DEBUG + m_bVIGNETTE_ENABLE = true; +#endif // _DEBUG + } + + void SetLOCAL_CONTRAST_ENABLE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLOCAL_CONTRAST_ENABLE = i; +#ifdef _DEBUG + m_bLOCAL_CONTRAST_ENABLE = true; +#endif // _DEBUG + } + + void SetBLURRED_VIGNETTE_ENABLE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBLURRED_VIGNETTE_ENABLE = i; +#ifdef _DEBUG + m_bBLURRED_VIGNETTE_ENABLE = true; +#endif // _DEBUG + } + + void SetVOMIT_ENABLE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVOMIT_ENABLE = i; +#ifdef _DEBUG + m_bVOMIT_ENABLE = true; +#endif // _DEBUG + } + + void SetTV_GAMMA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nTV_GAMMA = i; +#ifdef _DEBUG + m_bTV_GAMMA = true; +#endif // _DEBUG + } + + void SetDESATURATEENABLE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDESATURATEENABLE = i; +#ifdef _DEBUG + m_bDESATURATEENABLE = true; +#endif // _DEBUG + } + + engine_post_ps20b_Dynamic_Index( ) + { + m_nAA_ENABLE = 0; + m_nCOL_CORRECT_NUM_LOOKUPS = 0; + m_nCONVERT_FROM_LINEAR = 0; + m_nCONVERT_TO_LINEAR = 0; + m_nNOISE_ENABLE = 0; + m_nVIGNETTE_ENABLE = 0; + m_nLOCAL_CONTRAST_ENABLE = 0; + m_nBLURRED_VIGNETTE_ENABLE = 0; + m_nVOMIT_ENABLE = 0; + m_nTV_GAMMA = 0; + m_nDESATURATEENABLE = 0; #ifdef _DEBUG m_bAA_ENABLE = false; -#endif // _DEBUG - m_nAA_ENABLE = 0; -#ifdef _DEBUG - m_bAA_QUALITY_MODE = false; -#endif // _DEBUG - m_nAA_QUALITY_MODE = 0; -#ifdef _DEBUG - m_bAA_REDUCE_ONE_PIXEL_LINE_BLUR = false; -#endif // _DEBUG - m_nAA_REDUCE_ONE_PIXEL_LINE_BLUR = 0; -#ifdef _DEBUG m_bCOL_CORRECT_NUM_LOOKUPS = false; -#endif // _DEBUG - m_nCOL_CORRECT_NUM_LOOKUPS = 0; + m_bCONVERT_FROM_LINEAR = false; + m_bCONVERT_TO_LINEAR = false; + m_bNOISE_ENABLE = false; + m_bVIGNETTE_ENABLE = false; + m_bLOCAL_CONTRAST_ENABLE = false; + m_bBLURRED_VIGNETTE_ENABLE = false; + m_bVOMIT_ENABLE = false; + m_bTV_GAMMA = false; + m_bDESATURATEENABLE = false; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bAA_ENABLE && m_bAA_QUALITY_MODE && m_bAA_REDUCE_ONE_PIXEL_LINE_BLUR && m_bCOL_CORRECT_NUM_LOOKUPS; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG - return ( 1 * m_nAA_ENABLE ) + ( 2 * m_nAA_QUALITY_MODE ) + ( 4 * m_nAA_REDUCE_ONE_PIXEL_LINE_BLUR ) + ( 8 * m_nCOL_CORRECT_NUM_LOOKUPS ) + 0; + Assert( m_bAA_ENABLE && m_bCOL_CORRECT_NUM_LOOKUPS && m_bCONVERT_FROM_LINEAR && m_bCONVERT_TO_LINEAR && m_bNOISE_ENABLE && m_bVIGNETTE_ENABLE && m_bLOCAL_CONTRAST_ENABLE && m_bBLURRED_VIGNETTE_ENABLE && m_bVOMIT_ENABLE && m_bTV_GAMMA && m_bDESATURATEENABLE ); + AssertMsg( !( ( m_nCONVERT_FROM_LINEAR == 0 ) && ( m_nCONVERT_TO_LINEAR == 1 ) ), "Invalid combo combination ( ( CONVERT_FROM_LINEAR == 0 ) && ( CONVERT_TO_LINEAR == 1 ) )" ); + AssertMsg( !( ( m_nLOCAL_CONTRAST_ENABLE == 0 ) && ( m_nBLURRED_VIGNETTE_ENABLE == 1 ) ), "Invalid combo combination ( ( LOCAL_CONTRAST_ENABLE == 0 ) && ( BLURRED_VIGNETTE_ENABLE == 1 ) )" ); + return ( 1 * m_nAA_ENABLE ) + ( 1 * m_nCOL_CORRECT_NUM_LOOKUPS ) + ( 4 * m_nCONVERT_FROM_LINEAR ) + ( 8 * m_nCONVERT_TO_LINEAR ) + ( 16 * m_nNOISE_ENABLE ) + ( 32 * m_nVIGNETTE_ENABLE ) + ( 64 * m_nLOCAL_CONTRAST_ENABLE ) + ( 128 * m_nBLURRED_VIGNETTE_ENABLE ) + ( 256 * m_nVOMIT_ENABLE ) + ( 512 * m_nTV_GAMMA ) + ( 1024 * m_nDESATURATEENABLE ) + 0; } }; -#define shaderDynamicTest_engine_post_ps20b psh_forgot_to_set_dynamic_AA_ENABLE + psh_forgot_to_set_dynamic_AA_QUALITY_MODE + psh_forgot_to_set_dynamic_AA_REDUCE_ONE_PIXEL_LINE_BLUR + psh_forgot_to_set_dynamic_COL_CORRECT_NUM_LOOKUPS + 0 + +#define shaderDynamicTest_engine_post_ps20b psh_forgot_to_set_dynamic_AA_ENABLE + psh_forgot_to_set_dynamic_COL_CORRECT_NUM_LOOKUPS + psh_forgot_to_set_dynamic_CONVERT_FROM_LINEAR + psh_forgot_to_set_dynamic_CONVERT_TO_LINEAR + psh_forgot_to_set_dynamic_NOISE_ENABLE + psh_forgot_to_set_dynamic_VIGNETTE_ENABLE + psh_forgot_to_set_dynamic_LOCAL_CONTRAST_ENABLE + psh_forgot_to_set_dynamic_BLURRED_VIGNETTE_ENABLE + psh_forgot_to_set_dynamic_VOMIT_ENABLE + psh_forgot_to_set_dynamic_TV_GAMMA + psh_forgot_to_set_dynamic_DESATURATEENABLE + diff --git a/src/materialsystem/stdshaders/include/eyeglint_ps20b.inc b/src/materialsystem/stdshaders/include/eyeglint_ps20b.inc index e58e1188..98ed64a6 100644 --- a/src/materialsystem/stdshaders/include/eyeglint_ps20b.inc +++ b/src/materialsystem/stdshaders/include/eyeglint_ps20b.inc @@ -1,33 +1,33 @@ +#pragma once #include "shaderlib/cshader.h" class eyeglint_ps20b_Static_Index { public: - eyeglint_ps20b_Static_Index( ) + eyeglint_ps20b_Static_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_eyeglint_ps20b 0 + +#define shaderStaticTest_eyeglint_ps20b 1 + + class eyeglint_ps20b_Dynamic_Index { public: - eyeglint_ps20b_Dynamic_Index() + eyeglint_ps20b_Dynamic_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_eyeglint_ps20b 0 + +#define shaderDynamicTest_eyeglint_ps20b 1 + diff --git a/src/materialsystem/stdshaders/include/eyeglint_vs20.inc b/src/materialsystem/stdshaders/include/eyeglint_vs20.inc index 675f39c1..2ed0dd81 100644 --- a/src/materialsystem/stdshaders/include/eyeglint_vs20.inc +++ b/src/materialsystem/stdshaders/include/eyeglint_vs20.inc @@ -1,33 +1,36 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class eyeglint_vs20_Static_Index { public: - eyeglint_vs20_Static_Index( ) + eyeglint_vs20_Static_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_eyeglint_vs20 0 + +#define shaderStaticTest_eyeglint_vs20 1 + + class eyeglint_vs20_Dynamic_Index { public: - eyeglint_vs20_Dynamic_Index() + eyeglint_vs20_Dynamic_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_eyeglint_vs20 0 + +#define shaderDynamicTest_eyeglint_vs20 1 + diff --git a/src/materialsystem/stdshaders/include/flashlight_ps20b.inc b/src/materialsystem/stdshaders/include/flashlight_ps20b.inc index 36d7c00e..dd4d01ab 100644 --- a/src/materialsystem/stdshaders/include/flashlight_ps20b.inc +++ b/src/materialsystem/stdshaders/include/flashlight_ps20b.inc @@ -1,11 +1,42 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// !$WORLDVERTEXTRANSITION && $NORMALMAP2 +// !$NORMALMAP && $NORMALMAP2 +// !$DETAILTEXTURE && ( $DETAIL_BLEND_MODE != 0 ) +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class flashlight_ps20b_Static_Index { -private: - int m_nNORMALMAP; + unsigned int m_nNORMALMAP : 2; + unsigned int m_nNORMALMAP2 : 2; + unsigned int m_nWORLDVERTEXTRANSITION : 2; + unsigned int m_nSEAMLESS : 2; + unsigned int m_nDETAILTEXTURE : 2; + unsigned int m_nDETAIL_BLEND_MODE : 2; + unsigned int m_nFLASHLIGHTDEPTHFILTERMODE : 2; #ifdef _DEBUG - bool m_bNORMALMAP; -#endif + bool m_bNORMALMAP : 1; + bool m_bNORMALMAP2 : 1; + bool m_bWORLDVERTEXTRANSITION : 1; + bool m_bSEAMLESS : 1; + bool m_bDETAILTEXTURE : 1; + bool m_bDETAIL_BLEND_MODE : 1; + bool m_bFLASHLIGHTDEPTHFILTERMODE : 1; +#endif // _DEBUG public: void SetNORMALMAP( int i ) { @@ -13,192 +44,104 @@ public: m_nNORMALMAP = i; #ifdef _DEBUG m_bNORMALMAP = true; -#endif +#endif // _DEBUG } - void SetNORMALMAP( bool i ) - { - m_nNORMALMAP = i ? 1 : 0; -#ifdef _DEBUG - m_bNORMALMAP = true; -#endif - } -private: - int m_nNORMALMAP2; -#ifdef _DEBUG - bool m_bNORMALMAP2; -#endif -public: + void SetNORMALMAP2( int i ) { Assert( i >= 0 && i <= 1 ); m_nNORMALMAP2 = i; #ifdef _DEBUG m_bNORMALMAP2 = true; -#endif +#endif // _DEBUG } - void SetNORMALMAP2( bool i ) - { - m_nNORMALMAP2 = i ? 1 : 0; -#ifdef _DEBUG - m_bNORMALMAP2 = true; -#endif - } -private: - int m_nWORLDVERTEXTRANSITION; -#ifdef _DEBUG - bool m_bWORLDVERTEXTRANSITION; -#endif -public: + void SetWORLDVERTEXTRANSITION( int i ) { Assert( i >= 0 && i <= 1 ); m_nWORLDVERTEXTRANSITION = i; #ifdef _DEBUG m_bWORLDVERTEXTRANSITION = true; -#endif +#endif // _DEBUG } - void SetWORLDVERTEXTRANSITION( bool i ) - { - m_nWORLDVERTEXTRANSITION = i ? 1 : 0; -#ifdef _DEBUG - m_bWORLDVERTEXTRANSITION = true; -#endif - } -private: - int m_nSEAMLESS; -#ifdef _DEBUG - bool m_bSEAMLESS; -#endif -public: + void SetSEAMLESS( int i ) { Assert( i >= 0 && i <= 1 ); m_nSEAMLESS = i; #ifdef _DEBUG m_bSEAMLESS = true; -#endif +#endif // _DEBUG } - void SetSEAMLESS( bool i ) - { - m_nSEAMLESS = i ? 1 : 0; -#ifdef _DEBUG - m_bSEAMLESS = true; -#endif - } -private: - int m_nDETAILTEXTURE; -#ifdef _DEBUG - bool m_bDETAILTEXTURE; -#endif -public: + void SetDETAILTEXTURE( int i ) { Assert( i >= 0 && i <= 1 ); m_nDETAILTEXTURE = i; #ifdef _DEBUG m_bDETAILTEXTURE = true; -#endif +#endif // _DEBUG } - void SetDETAILTEXTURE( bool i ) - { - m_nDETAILTEXTURE = i ? 1 : 0; -#ifdef _DEBUG - m_bDETAILTEXTURE = true; -#endif - } -private: - int m_nDETAIL_BLEND_MODE; -#ifdef _DEBUG - bool m_bDETAIL_BLEND_MODE; -#endif -public: + void SetDETAIL_BLEND_MODE( int i ) { Assert( i >= 0 && i <= 1 ); m_nDETAIL_BLEND_MODE = i; #ifdef _DEBUG m_bDETAIL_BLEND_MODE = true; -#endif +#endif // _DEBUG } - void SetDETAIL_BLEND_MODE( bool i ) - { - m_nDETAIL_BLEND_MODE = i ? 1 : 0; -#ifdef _DEBUG - m_bDETAIL_BLEND_MODE = 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 +#endif // _DEBUG } - void SetFLASHLIGHTDEPTHFILTERMODE( bool i ) - { - m_nFLASHLIGHTDEPTHFILTERMODE = i ? 1 : 0; -#ifdef _DEBUG - m_bFLASHLIGHTDEPTHFILTERMODE = true; -#endif - } -public: - flashlight_ps20b_Static_Index( ) + + flashlight_ps20b_Static_Index( ) { + m_nNORMALMAP = 0; + m_nNORMALMAP2 = 0; + m_nWORLDVERTEXTRANSITION = 0; + m_nSEAMLESS = 0; + m_nDETAILTEXTURE = 0; + m_nDETAIL_BLEND_MODE = 0; + m_nFLASHLIGHTDEPTHFILTERMODE = 0; #ifdef _DEBUG m_bNORMALMAP = false; -#endif // _DEBUG - m_nNORMALMAP = 0; -#ifdef _DEBUG m_bNORMALMAP2 = false; -#endif // _DEBUG - m_nNORMALMAP2 = 0; -#ifdef _DEBUG m_bWORLDVERTEXTRANSITION = false; -#endif // _DEBUG - m_nWORLDVERTEXTRANSITION = 0; -#ifdef _DEBUG m_bSEAMLESS = false; -#endif // _DEBUG - m_nSEAMLESS = 0; -#ifdef _DEBUG m_bDETAILTEXTURE = false; -#endif // _DEBUG - m_nDETAILTEXTURE = 0; -#ifdef _DEBUG m_bDETAIL_BLEND_MODE = false; -#endif // _DEBUG - m_nDETAIL_BLEND_MODE = 0; -#ifdef _DEBUG m_bFLASHLIGHTDEPTHFILTERMODE = false; -#endif // _DEBUG - m_nFLASHLIGHTDEPTHFILTERMODE = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE ); + AssertMsg( !( !m_nWORLDVERTEXTRANSITION && m_nNORMALMAP2 ), "Invalid combo combination ( !WORLDVERTEXTRANSITION && NORMALMAP2 )" ); + AssertMsg( !( !m_nNORMALMAP && m_nNORMALMAP2 ), "Invalid combo combination ( !NORMALMAP && NORMALMAP2 )" ); + AssertMsg( !( !m_nDETAILTEXTURE && ( m_nDETAIL_BLEND_MODE != 0 ) ), "Invalid combo combination ( !DETAILTEXTURE && ( DETAIL_BLEND_MODE != 0 ) )" ); return ( 4 * m_nNORMALMAP ) + ( 12 * m_nNORMALMAP2 ) + ( 24 * m_nWORLDVERTEXTRANSITION ) + ( 48 * m_nSEAMLESS ) + ( 96 * m_nDETAILTEXTURE ) + ( 192 * m_nDETAIL_BLEND_MODE ) + ( 384 * m_nFLASHLIGHTDEPTHFILTERMODE ) + 0; } }; -#define shaderStaticTest_flashlight_ps20b psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + 0 + +#define shaderStaticTest_flashlight_ps20b psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + + class flashlight_ps20b_Dynamic_Index { -private: - int m_nPIXELFOGTYPE; + unsigned int m_nPIXELFOGTYPE : 2; + unsigned int m_nFLASHLIGHTSHADOWS : 2; #ifdef _DEBUG - bool m_bPIXELFOGTYPE; -#endif + bool m_bPIXELFOGTYPE : 1; + bool m_bFLASHLIGHTSHADOWS : 1; +#endif // _DEBUG public: void SetPIXELFOGTYPE( int i ) { @@ -206,57 +149,34 @@ public: m_nPIXELFOGTYPE = i; #ifdef _DEBUG m_bPIXELFOGTYPE = true; -#endif +#endif // _DEBUG } - void SetPIXELFOGTYPE( bool i ) - { - m_nPIXELFOGTYPE = i ? 1 : 0; -#ifdef _DEBUG - m_bPIXELFOGTYPE = 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 +#endif // _DEBUG } - void SetFLASHLIGHTSHADOWS( bool i ) - { - m_nFLASHLIGHTSHADOWS = i ? 1 : 0; -#ifdef _DEBUG - m_bFLASHLIGHTSHADOWS = true; -#endif - } -public: - flashlight_ps20b_Dynamic_Index() + + flashlight_ps20b_Dynamic_Index( ) { + m_nPIXELFOGTYPE = 0; + m_nFLASHLIGHTSHADOWS = 0; #ifdef _DEBUG m_bPIXELFOGTYPE = false; -#endif // _DEBUG - m_nPIXELFOGTYPE = 0; -#ifdef _DEBUG m_bFLASHLIGHTSHADOWS = false; -#endif // _DEBUG - m_nFLASHLIGHTSHADOWS = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS ); return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; } }; -#define shaderDynamicTest_flashlight_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + 0 + +#define shaderDynamicTest_flashlight_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + diff --git a/src/materialsystem/stdshaders/include/flesh_interior_blended_pass_ps20b.inc b/src/materialsystem/stdshaders/include/flesh_interior_blended_pass_ps20b.inc index ae707c02..353b2016 100644 --- a/src/materialsystem/stdshaders/include/flesh_interior_blended_pass_ps20b.inc +++ b/src/materialsystem/stdshaders/include/flesh_interior_blended_pass_ps20b.inc @@ -1,60 +1,50 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class flesh_interior_blended_pass_ps20b_Static_Index { -private: - int m_nCONVERT_TO_SRGB; -#ifdef _DEBUG - bool m_bCONVERT_TO_SRGB; -#endif + unsigned int m_nCONVERT_TO_SRGB : 2; 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 ) + + flesh_interior_blended_pass_ps20b_Static_Index( ) { - m_nCONVERT_TO_SRGB = i ? 1 : 0; -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); } -public: - flesh_interior_blended_pass_ps20b_Static_Index( ) + + int GetIndex() const { -#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_flesh_interior_blended_pass_ps20b 0 + +#define shaderStaticTest_flesh_interior_blended_pass_ps20b 1 + + class flesh_interior_blended_pass_ps20b_Dynamic_Index { public: - flesh_interior_blended_pass_ps20b_Dynamic_Index() + flesh_interior_blended_pass_ps20b_Dynamic_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_flesh_interior_blended_pass_ps20b 0 + +#define shaderDynamicTest_flesh_interior_blended_pass_ps20b 1 + diff --git a/src/materialsystem/stdshaders/include/flesh_interior_blended_pass_vs20.inc b/src/materialsystem/stdshaders/include/flesh_interior_blended_pass_vs20.inc index 2b7143e7..b51bb13d 100644 --- a/src/materialsystem/stdshaders/include/flesh_interior_blended_pass_vs20.inc +++ b/src/materialsystem/stdshaders/include/flesh_interior_blended_pass_vs20.inc @@ -1,11 +1,17 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// $USE_STATIC_CONTROL_FLOW && ( $NUM_LIGHTS > 0 ) +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class flesh_interior_blended_pass_vs20_Static_Index { -private: - int m_nHALFLAMBERT; + unsigned int m_nHALFLAMBERT : 2; + unsigned int m_nUSE_STATIC_CONTROL_FLOW : 2; #ifdef _DEBUG - bool m_bHALFLAMBERT; -#endif + bool m_bHALFLAMBERT : 1; + bool m_bUSE_STATIC_CONTROL_FLOW : 1; +#endif // _DEBUG public: void SetHALFLAMBERT( int i ) { @@ -13,67 +19,54 @@ public: m_nHALFLAMBERT = i; #ifdef _DEBUG m_bHALFLAMBERT = true; -#endif +#endif // _DEBUG } - void SetHALFLAMBERT( bool i ) - { - m_nHALFLAMBERT = i ? 1 : 0; -#ifdef _DEBUG - m_bHALFLAMBERT = true; -#endif - } -private: - int m_nUSE_STATIC_CONTROL_FLOW; -#ifdef _DEBUG - bool m_bUSE_STATIC_CONTROL_FLOW; -#endif -public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) { Assert( i >= 0 && i <= 1 ); m_nUSE_STATIC_CONTROL_FLOW = i; #ifdef _DEBUG m_bUSE_STATIC_CONTROL_FLOW = true; -#endif +#endif // _DEBUG } - void SetUSE_STATIC_CONTROL_FLOW( bool i ) - { - m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; -#ifdef _DEBUG - m_bUSE_STATIC_CONTROL_FLOW = true; -#endif - } -public: - flesh_interior_blended_pass_vs20_Static_Index( ) + + flesh_interior_blended_pass_vs20_Static_Index( ) { + m_nHALFLAMBERT = 0; + m_nUSE_STATIC_CONTROL_FLOW = 0; #ifdef _DEBUG m_bHALFLAMBERT = false; -#endif // _DEBUG - m_nHALFLAMBERT = 0; -#ifdef _DEBUG m_bUSE_STATIC_CONTROL_FLOW = false; -#endif // _DEBUG - m_nUSE_STATIC_CONTROL_FLOW = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bHALFLAMBERT && m_bUSE_STATIC_CONTROL_FLOW; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bHALFLAMBERT && m_bUSE_STATIC_CONTROL_FLOW ); return ( 96 * m_nHALFLAMBERT ) + ( 192 * m_nUSE_STATIC_CONTROL_FLOW ) + 0; } }; -#define shaderStaticTest_flesh_interior_blended_pass_vs20 vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + 0 + +#define shaderStaticTest_flesh_interior_blended_pass_vs20 vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + + class flesh_interior_blended_pass_vs20_Dynamic_Index { -private: - int m_nCOMPRESSED_VERTS; + unsigned int m_nCOMPRESSED_VERTS : 2; + unsigned int m_nSKINNING : 2; + unsigned int m_nDOWATERFOG : 2; + unsigned int m_nDYNAMIC_LIGHT : 2; + unsigned int m_nSTATIC_LIGHT : 2; + unsigned int m_nNUM_LIGHTS : 2; #ifdef _DEBUG - bool m_bCOMPRESSED_VERTS; -#endif + bool m_bCOMPRESSED_VERTS : 1; + bool m_bSKINNING : 1; + bool m_bDOWATERFOG : 1; + bool m_bDYNAMIC_LIGHT : 1; + bool m_bSTATIC_LIGHT : 1; + bool m_bNUM_LIGHTS : 1; +#endif // _DEBUG public: void SetCOMPRESSED_VERTS( int i ) { @@ -81,157 +74,78 @@ public: m_nCOMPRESSED_VERTS = i; #ifdef _DEBUG m_bCOMPRESSED_VERTS = true; -#endif +#endif // _DEBUG } - void SetCOMPRESSED_VERTS( bool i ) - { - m_nCOMPRESSED_VERTS = i ? 1 : 0; -#ifdef _DEBUG - m_bCOMPRESSED_VERTS = 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 +#endif // _DEBUG } - void SetSKINNING( bool i ) - { - m_nSKINNING = i ? 1 : 0; -#ifdef _DEBUG - m_bSKINNING = 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 +#endif // _DEBUG } - void SetDOWATERFOG( bool i ) - { - m_nDOWATERFOG = i ? 1 : 0; -#ifdef _DEBUG - m_bDOWATERFOG = true; -#endif - } -private: - int m_nDYNAMIC_LIGHT; -#ifdef _DEBUG - bool m_bDYNAMIC_LIGHT; -#endif -public: + void SetDYNAMIC_LIGHT( int i ) { Assert( i >= 0 && i <= 1 ); m_nDYNAMIC_LIGHT = i; #ifdef _DEBUG m_bDYNAMIC_LIGHT = true; -#endif +#endif // _DEBUG } - void SetDYNAMIC_LIGHT( bool i ) - { - m_nDYNAMIC_LIGHT = i ? 1 : 0; -#ifdef _DEBUG - m_bDYNAMIC_LIGHT = true; -#endif - } -private: - int m_nSTATIC_LIGHT; -#ifdef _DEBUG - bool m_bSTATIC_LIGHT; -#endif -public: + void SetSTATIC_LIGHT( int i ) { Assert( i >= 0 && i <= 1 ); m_nSTATIC_LIGHT = i; #ifdef _DEBUG m_bSTATIC_LIGHT = true; -#endif +#endif // _DEBUG } - void SetSTATIC_LIGHT( bool i ) - { - m_nSTATIC_LIGHT = i ? 1 : 0; -#ifdef _DEBUG - m_bSTATIC_LIGHT = true; -#endif - } -private: - int m_nNUM_LIGHTS; -#ifdef _DEBUG - bool m_bNUM_LIGHTS; -#endif -public: + void SetNUM_LIGHTS( int i ) { Assert( i >= 0 && i <= 2 ); m_nNUM_LIGHTS = i; #ifdef _DEBUG m_bNUM_LIGHTS = true; -#endif +#endif // _DEBUG } - void SetNUM_LIGHTS( bool i ) - { - m_nNUM_LIGHTS = i ? 1 : 0; -#ifdef _DEBUG - m_bNUM_LIGHTS = true; -#endif - } -public: - flesh_interior_blended_pass_vs20_Dynamic_Index() + + flesh_interior_blended_pass_vs20_Dynamic_Index( ) { + m_nCOMPRESSED_VERTS = 0; + m_nSKINNING = 0; + m_nDOWATERFOG = 0; + m_nDYNAMIC_LIGHT = 0; + m_nSTATIC_LIGHT = 0; + m_nNUM_LIGHTS = 0; #ifdef _DEBUG m_bCOMPRESSED_VERTS = false; -#endif // _DEBUG - m_nCOMPRESSED_VERTS = 0; -#ifdef _DEBUG m_bSKINNING = false; -#endif // _DEBUG - m_nSKINNING = 0; -#ifdef _DEBUG m_bDOWATERFOG = false; -#endif // _DEBUG - m_nDOWATERFOG = 0; -#ifdef _DEBUG m_bDYNAMIC_LIGHT = false; -#endif // _DEBUG - m_nDYNAMIC_LIGHT = 0; -#ifdef _DEBUG m_bSTATIC_LIGHT = false; -#endif // _DEBUG - m_nSTATIC_LIGHT = 0; -#ifdef _DEBUG m_bNUM_LIGHTS = false; -#endif // _DEBUG - m_nNUM_LIGHTS = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bSKINNING && m_bDOWATERFOG && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bNUM_LIGHTS; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bCOMPRESSED_VERTS && m_bSKINNING && m_bDOWATERFOG && m_bDYNAMIC_LIGHT && m_bSTATIC_LIGHT && m_bNUM_LIGHTS ); return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + ( 4 * m_nDOWATERFOG ) + ( 8 * m_nDYNAMIC_LIGHT ) + ( 16 * m_nSTATIC_LIGHT ) + ( 32 * m_nNUM_LIGHTS ) + 0; } }; -#define shaderDynamicTest_flesh_interior_blended_pass_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_NUM_LIGHTS + 0 + +#define shaderDynamicTest_flesh_interior_blended_pass_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_DYNAMIC_LIGHT + vsh_forgot_to_set_dynamic_STATIC_LIGHT + vsh_forgot_to_set_dynamic_NUM_LIGHTS + diff --git a/src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_ps20b.inc b/src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_ps20b.inc new file mode 100644 index 00000000..88213196 --- /dev/null +++ b/src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_ps20b.inc @@ -0,0 +1,242 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// !$WORLDVERTEXTRANSITION && $NORMALMAP2 +// !$NORMALMAP && $NORMALMAP2 +// !$DETAILTEXTURE && ( $DETAIL_BLEND_MODE != 0 ) +// !$PHONG && $PHONGMASK +// $BASETEXTURETRANSFORM2 && !$WORLDVERTEXTRANSITION +// $BASETEXTURETRANSFORM2 && $SEAMLESS +// $BASETEXTURETRANSFORM2 && $PHONG +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once +#include "shaderlib/cshader.h" +class lightmappedgeneric_flashlight_ps20b_Static_Index +{ + unsigned int m_nNORMALMAP : 2; + unsigned int m_nNORMALMAP2 : 2; + unsigned int m_nWORLDVERTEXTRANSITION : 2; + unsigned int m_nFANCY_BLENDING : 2; + unsigned int m_nSEAMLESS : 2; + unsigned int m_nDETAILTEXTURE : 2; + unsigned int m_nDETAIL_BLEND_MODE : 2; + unsigned int m_nFLASHLIGHTDEPTHFILTERMODE : 2; + unsigned int m_nPHONG : 2; + unsigned int m_nPHONGMASK : 3; + unsigned int m_nBASETEXTURETRANSFORM2 : 2; +#ifdef _DEBUG + bool m_bNORMALMAP : 1; + bool m_bNORMALMAP2 : 1; + bool m_bWORLDVERTEXTRANSITION : 1; + bool m_bFANCY_BLENDING : 1; + bool m_bSEAMLESS : 1; + bool m_bDETAILTEXTURE : 1; + bool m_bDETAIL_BLEND_MODE : 1; + bool m_bFLASHLIGHTDEPTHFILTERMODE : 1; + bool m_bPHONG : 1; + bool m_bPHONGMASK : 1; + bool m_bBASETEXTURETRANSFORM2 : 1; +#endif // _DEBUG +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif // _DEBUG + } + + void SetNORMALMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP2 = i; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif // _DEBUG + } + + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif // _DEBUG + } + + void SetFANCY_BLENDING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFANCY_BLENDING = i; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif // _DEBUG + } + + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif // _DEBUG + } + + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif // _DEBUG + } + + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif // _DEBUG + } + + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif // _DEBUG + } + + void SetPHONG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG = i; +#ifdef _DEBUG + m_bPHONG = true; +#endif // _DEBUG + } + + void SetPHONGMASK( int i ) + { + Assert( i >= 0 && i <= 3 ); + m_nPHONGMASK = i; +#ifdef _DEBUG + m_bPHONGMASK = true; +#endif // _DEBUG + } + + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif // _DEBUG + } + + lightmappedgeneric_flashlight_ps20b_Static_Index( ) + { + m_nNORMALMAP = 0; + m_nNORMALMAP2 = 0; + m_nWORLDVERTEXTRANSITION = 0; + m_nFANCY_BLENDING = 0; + m_nSEAMLESS = 0; + m_nDETAILTEXTURE = 0; + m_nDETAIL_BLEND_MODE = 0; + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + m_nPHONG = 0; + m_nPHONGMASK = 0; + m_nBASETEXTURETRANSFORM2 = 0; +#ifdef _DEBUG + m_bNORMALMAP = false; + m_bNORMALMAP2 = false; + m_bWORLDVERTEXTRANSITION = false; + m_bFANCY_BLENDING = false; + m_bSEAMLESS = false; + m_bDETAILTEXTURE = false; + m_bDETAIL_BLEND_MODE = false; + m_bFLASHLIGHTDEPTHFILTERMODE = false; + m_bPHONG = false; + m_bPHONGMASK = false; + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bFANCY_BLENDING && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE && m_bPHONG && m_bPHONGMASK && m_bBASETEXTURETRANSFORM2 ); + AssertMsg( !( !m_nWORLDVERTEXTRANSITION && m_nNORMALMAP2 ), "Invalid combo combination ( !WORLDVERTEXTRANSITION && NORMALMAP2 )" ); + AssertMsg( !( !m_nNORMALMAP && m_nNORMALMAP2 ), "Invalid combo combination ( !NORMALMAP && NORMALMAP2 )" ); + AssertMsg( !( !m_nDETAILTEXTURE && ( m_nDETAIL_BLEND_MODE != 0 ) ), "Invalid combo combination ( !DETAILTEXTURE && ( DETAIL_BLEND_MODE != 0 ) )" ); + AssertMsg( !( !m_nPHONG && m_nPHONGMASK ), "Invalid combo combination ( !PHONG && PHONGMASK )" ); + AssertMsg( !( m_nBASETEXTURETRANSFORM2 && !m_nWORLDVERTEXTRANSITION ), "Invalid combo combination ( BASETEXTURETRANSFORM2 && !WORLDVERTEXTRANSITION )" ); + AssertMsg( !( m_nBASETEXTURETRANSFORM2 && m_nSEAMLESS ), "Invalid combo combination ( BASETEXTURETRANSFORM2 && SEAMLESS )" ); + AssertMsg( !( m_nBASETEXTURETRANSFORM2 && m_nPHONG ), "Invalid combo combination ( BASETEXTURETRANSFORM2 && PHONG )" ); + return ( 4 * m_nNORMALMAP ) + ( 12 * m_nNORMALMAP2 ) + ( 24 * m_nWORLDVERTEXTRANSITION ) + ( 48 * m_nFANCY_BLENDING ) + ( 96 * m_nSEAMLESS ) + ( 192 * m_nDETAILTEXTURE ) + ( 384 * m_nDETAIL_BLEND_MODE ) + ( 768 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 2304 * m_nPHONG ) + ( 4608 * m_nPHONGMASK ) + ( 18432 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; + +#define shaderStaticTest_lightmappedgeneric_flashlight_ps20b psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_FANCY_BLENDING + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_PHONG + psh_forgot_to_set_static_PHONGMASK + psh_forgot_to_set_static_BASETEXTURETRANSFORM2 + + +class lightmappedgeneric_flashlight_ps20b_Dynamic_Index +{ + unsigned int m_nPIXELFOGTYPE : 2; + unsigned int m_nFLASHLIGHTSHADOWS : 2; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE : 1; + bool m_bFLASHLIGHTSHADOWS : 1; +#endif // _DEBUG +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif // _DEBUG + } + + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif // _DEBUG + } + + lightmappedgeneric_flashlight_ps20b_Dynamic_Index( ) + { + m_nPIXELFOGTYPE = 0; + m_nFLASHLIGHTSHADOWS = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS ); + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; + +#define shaderDynamicTest_lightmappedgeneric_flashlight_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + diff --git a/src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_ps30.inc b/src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_ps30.inc new file mode 100644 index 00000000..738c129d --- /dev/null +++ b/src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_ps30.inc @@ -0,0 +1,242 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// !$WORLDVERTEXTRANSITION && $NORMALMAP2 +// !$NORMALMAP && $NORMALMAP2 +// !$DETAILTEXTURE && ( $DETAIL_BLEND_MODE != 0 ) +// !$PHONG && $PHONGMASK +// $BASETEXTURETRANSFORM2 && !$WORLDVERTEXTRANSITION +// $BASETEXTURETRANSFORM2 && $SEAMLESS +// $BASETEXTURETRANSFORM2 && $PHONG +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once +#include "shaderlib/cshader.h" +class lightmappedgeneric_flashlight_ps30_Static_Index +{ + unsigned int m_nNORMALMAP : 2; + unsigned int m_nNORMALMAP2 : 2; + unsigned int m_nWORLDVERTEXTRANSITION : 2; + unsigned int m_nFANCY_BLENDING : 2; + unsigned int m_nSEAMLESS : 2; + unsigned int m_nDETAILTEXTURE : 2; + unsigned int m_nDETAIL_BLEND_MODE : 2; + unsigned int m_nFLASHLIGHTDEPTHFILTERMODE : 2; + unsigned int m_nPHONG : 2; + unsigned int m_nPHONGMASK : 3; + unsigned int m_nBASETEXTURETRANSFORM2 : 2; +#ifdef _DEBUG + bool m_bNORMALMAP : 1; + bool m_bNORMALMAP2 : 1; + bool m_bWORLDVERTEXTRANSITION : 1; + bool m_bFANCY_BLENDING : 1; + bool m_bSEAMLESS : 1; + bool m_bDETAILTEXTURE : 1; + bool m_bDETAIL_BLEND_MODE : 1; + bool m_bFLASHLIGHTDEPTHFILTERMODE : 1; + bool m_bPHONG : 1; + bool m_bPHONGMASK : 1; + bool m_bBASETEXTURETRANSFORM2 : 1; +#endif // _DEBUG +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif // _DEBUG + } + + void SetNORMALMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP2 = i; +#ifdef _DEBUG + m_bNORMALMAP2 = true; +#endif // _DEBUG + } + + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif // _DEBUG + } + + void SetFANCY_BLENDING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFANCY_BLENDING = i; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif // _DEBUG + } + + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif // _DEBUG + } + + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif // _DEBUG + } + + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif // _DEBUG + } + + void SetFLASHLIGHTDEPTHFILTERMODE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nFLASHLIGHTDEPTHFILTERMODE = i; +#ifdef _DEBUG + m_bFLASHLIGHTDEPTHFILTERMODE = true; +#endif // _DEBUG + } + + void SetPHONG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG = i; +#ifdef _DEBUG + m_bPHONG = true; +#endif // _DEBUG + } + + void SetPHONGMASK( int i ) + { + Assert( i >= 0 && i <= 3 ); + m_nPHONGMASK = i; +#ifdef _DEBUG + m_bPHONGMASK = true; +#endif // _DEBUG + } + + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif // _DEBUG + } + + lightmappedgeneric_flashlight_ps30_Static_Index( ) + { + m_nNORMALMAP = 0; + m_nNORMALMAP2 = 0; + m_nWORLDVERTEXTRANSITION = 0; + m_nFANCY_BLENDING = 0; + m_nSEAMLESS = 0; + m_nDETAILTEXTURE = 0; + m_nDETAIL_BLEND_MODE = 0; + m_nFLASHLIGHTDEPTHFILTERMODE = 0; + m_nPHONG = 0; + m_nPHONGMASK = 0; + m_nBASETEXTURETRANSFORM2 = 0; +#ifdef _DEBUG + m_bNORMALMAP = false; + m_bNORMALMAP2 = false; + m_bWORLDVERTEXTRANSITION = false; + m_bFANCY_BLENDING = false; + m_bSEAMLESS = false; + m_bDETAILTEXTURE = false; + m_bDETAIL_BLEND_MODE = false; + m_bFLASHLIGHTDEPTHFILTERMODE = false; + m_bPHONG = false; + m_bPHONGMASK = false; + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bNORMALMAP && m_bNORMALMAP2 && m_bWORLDVERTEXTRANSITION && m_bFANCY_BLENDING && m_bSEAMLESS && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE && m_bPHONG && m_bPHONGMASK && m_bBASETEXTURETRANSFORM2 ); + AssertMsg( !( !m_nWORLDVERTEXTRANSITION && m_nNORMALMAP2 ), "Invalid combo combination ( !WORLDVERTEXTRANSITION && NORMALMAP2 )" ); + AssertMsg( !( !m_nNORMALMAP && m_nNORMALMAP2 ), "Invalid combo combination ( !NORMALMAP && NORMALMAP2 )" ); + AssertMsg( !( !m_nDETAILTEXTURE && ( m_nDETAIL_BLEND_MODE != 0 ) ), "Invalid combo combination ( !DETAILTEXTURE && ( DETAIL_BLEND_MODE != 0 ) )" ); + AssertMsg( !( !m_nPHONG && m_nPHONGMASK ), "Invalid combo combination ( !PHONG && PHONGMASK )" ); + AssertMsg( !( m_nBASETEXTURETRANSFORM2 && !m_nWORLDVERTEXTRANSITION ), "Invalid combo combination ( BASETEXTURETRANSFORM2 && !WORLDVERTEXTRANSITION )" ); + AssertMsg( !( m_nBASETEXTURETRANSFORM2 && m_nSEAMLESS ), "Invalid combo combination ( BASETEXTURETRANSFORM2 && SEAMLESS )" ); + AssertMsg( !( m_nBASETEXTURETRANSFORM2 && m_nPHONG ), "Invalid combo combination ( BASETEXTURETRANSFORM2 && PHONG )" ); + return ( 4 * m_nNORMALMAP ) + ( 12 * m_nNORMALMAP2 ) + ( 24 * m_nWORLDVERTEXTRANSITION ) + ( 48 * m_nFANCY_BLENDING ) + ( 96 * m_nSEAMLESS ) + ( 192 * m_nDETAILTEXTURE ) + ( 384 * m_nDETAIL_BLEND_MODE ) + ( 768 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 2304 * m_nPHONG ) + ( 4608 * m_nPHONGMASK ) + ( 18432 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; + +#define shaderStaticTest_lightmappedgeneric_flashlight_ps30 psh_forgot_to_set_static_NORMALMAP + psh_forgot_to_set_static_NORMALMAP2 + psh_forgot_to_set_static_WORLDVERTEXTRANSITION + psh_forgot_to_set_static_FANCY_BLENDING + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_PHONG + psh_forgot_to_set_static_PHONGMASK + psh_forgot_to_set_static_BASETEXTURETRANSFORM2 + + +class lightmappedgeneric_flashlight_ps30_Dynamic_Index +{ + unsigned int m_nPIXELFOGTYPE : 2; + unsigned int m_nFLASHLIGHTSHADOWS : 2; +#ifdef _DEBUG + bool m_bPIXELFOGTYPE : 1; + bool m_bFLASHLIGHTSHADOWS : 1; +#endif // _DEBUG +public: + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif // _DEBUG + } + + void SetFLASHLIGHTSHADOWS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFLASHLIGHTSHADOWS = i; +#ifdef _DEBUG + m_bFLASHLIGHTSHADOWS = true; +#endif // _DEBUG + } + + lightmappedgeneric_flashlight_ps30_Dynamic_Index( ) + { + m_nPIXELFOGTYPE = 0; + m_nFLASHLIGHTSHADOWS = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; + m_bFLASHLIGHTSHADOWS = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bPIXELFOGTYPE && m_bFLASHLIGHTSHADOWS ); + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nFLASHLIGHTSHADOWS ) + 0; + } +}; + +#define shaderDynamicTest_lightmappedgeneric_flashlight_ps30 psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_FLASHLIGHTSHADOWS + diff --git a/src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_vs20.inc b/src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_vs20.inc index f472301d..7dc04c03 100644 --- a/src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_vs20.inc +++ b/src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_vs20.inc @@ -1,11 +1,27 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// $BASETEXTURETRANSFORM2 && !$WORLDVERTEXTRANSITION +// $BASETEXTURETRANSFORM2 && $SEAMLESS +// $BASETEXTURETRANSFORM2 && $PHONG +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class lightmappedgeneric_flashlight_vs20_Static_Index { -private: - int m_nNORMALMAP; + unsigned int m_nNORMALMAP : 2; + unsigned int m_nWORLDVERTEXTRANSITION : 2; + unsigned int m_nSEAMLESS : 2; + unsigned int m_nDETAIL : 2; + unsigned int m_nPHONG : 2; + unsigned int m_nBASETEXTURETRANSFORM2 : 2; #ifdef _DEBUG - bool m_bNORMALMAP; -#endif + bool m_bNORMALMAP : 1; + bool m_bWORLDVERTEXTRANSITION : 1; + bool m_bSEAMLESS : 1; + bool m_bDETAIL : 1; + bool m_bPHONG : 1; + bool m_bBASETEXTURETRANSFORM2 : 1; +#endif // _DEBUG public: void SetNORMALMAP( int i ) { @@ -13,117 +29,91 @@ public: m_nNORMALMAP = i; #ifdef _DEBUG m_bNORMALMAP = true; -#endif +#endif // _DEBUG } - void SetNORMALMAP( bool i ) - { - m_nNORMALMAP = i ? 1 : 0; -#ifdef _DEBUG - m_bNORMALMAP = true; -#endif - } -private: - int m_nWORLDVERTEXTRANSITION; -#ifdef _DEBUG - bool m_bWORLDVERTEXTRANSITION; -#endif -public: + void SetWORLDVERTEXTRANSITION( int i ) { Assert( i >= 0 && i <= 1 ); m_nWORLDVERTEXTRANSITION = i; #ifdef _DEBUG m_bWORLDVERTEXTRANSITION = true; -#endif +#endif // _DEBUG } - void SetWORLDVERTEXTRANSITION( bool i ) - { - m_nWORLDVERTEXTRANSITION = i ? 1 : 0; -#ifdef _DEBUG - m_bWORLDVERTEXTRANSITION = true; -#endif - } -private: - int m_nSEAMLESS; -#ifdef _DEBUG - bool m_bSEAMLESS; -#endif -public: + void SetSEAMLESS( int i ) { Assert( i >= 0 && i <= 1 ); m_nSEAMLESS = i; #ifdef _DEBUG m_bSEAMLESS = true; -#endif +#endif // _DEBUG } - void SetSEAMLESS( bool i ) - { - m_nSEAMLESS = i ? 1 : 0; -#ifdef _DEBUG - m_bSEAMLESS = true; -#endif - } -private: - int m_nDETAIL; -#ifdef _DEBUG - bool m_bDETAIL; -#endif -public: + void SetDETAIL( int i ) { Assert( i >= 0 && i <= 1 ); m_nDETAIL = i; #ifdef _DEBUG m_bDETAIL = true; -#endif +#endif // _DEBUG } - void SetDETAIL( bool i ) + + void SetPHONG( int i ) { - m_nDETAIL = i ? 1 : 0; + Assert( i >= 0 && i <= 1 ); + m_nPHONG = i; #ifdef _DEBUG - m_bDETAIL = true; -#endif + m_bPHONG = true; +#endif // _DEBUG } -public: - lightmappedgeneric_flashlight_vs20_Static_Index( ) + + void SetBASETEXTURETRANSFORM2( int i ) { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif // _DEBUG + } + + lightmappedgeneric_flashlight_vs20_Static_Index( ) + { + m_nNORMALMAP = 0; + m_nWORLDVERTEXTRANSITION = 0; + m_nSEAMLESS = 0; + m_nDETAIL = 0; + m_nPHONG = 0; + m_nBASETEXTURETRANSFORM2 = 0; #ifdef _DEBUG m_bNORMALMAP = false; -#endif // _DEBUG - m_nNORMALMAP = 0; -#ifdef _DEBUG m_bWORLDVERTEXTRANSITION = false; -#endif // _DEBUG - m_nWORLDVERTEXTRANSITION = 0; -#ifdef _DEBUG m_bSEAMLESS = false; -#endif // _DEBUG - m_nSEAMLESS = 0; -#ifdef _DEBUG m_bDETAIL = false; -#endif // _DEBUG - m_nDETAIL = 0; + m_bPHONG = false; + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bNORMALMAP && m_bWORLDVERTEXTRANSITION && m_bSEAMLESS && m_bDETAIL; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG - return ( 2 * m_nNORMALMAP ) + ( 4 * m_nWORLDVERTEXTRANSITION ) + ( 8 * m_nSEAMLESS ) + ( 16 * m_nDETAIL ) + 0; + Assert( m_bNORMALMAP && m_bWORLDVERTEXTRANSITION && m_bSEAMLESS && m_bDETAIL && m_bPHONG && m_bBASETEXTURETRANSFORM2 ); + AssertMsg( !( m_nBASETEXTURETRANSFORM2 && !m_nWORLDVERTEXTRANSITION ), "Invalid combo combination ( BASETEXTURETRANSFORM2 && !WORLDVERTEXTRANSITION )" ); + AssertMsg( !( m_nBASETEXTURETRANSFORM2 && m_nSEAMLESS ), "Invalid combo combination ( BASETEXTURETRANSFORM2 && SEAMLESS )" ); + AssertMsg( !( m_nBASETEXTURETRANSFORM2 && m_nPHONG ), "Invalid combo combination ( BASETEXTURETRANSFORM2 && PHONG )" ); + return ( 2 * m_nNORMALMAP ) + ( 4 * m_nWORLDVERTEXTRANSITION ) + ( 8 * m_nSEAMLESS ) + ( 16 * m_nDETAIL ) + ( 32 * m_nPHONG ) + ( 64 * m_nBASETEXTURETRANSFORM2 ) + 0; } }; -#define shaderStaticTest_lightmappedgeneric_flashlight_vs20 vsh_forgot_to_set_static_NORMALMAP + vsh_forgot_to_set_static_WORLDVERTEXTRANSITION + vsh_forgot_to_set_static_SEAMLESS + vsh_forgot_to_set_static_DETAIL + 0 + +#define shaderStaticTest_lightmappedgeneric_flashlight_vs20 vsh_forgot_to_set_static_NORMALMAP + vsh_forgot_to_set_static_WORLDVERTEXTRANSITION + vsh_forgot_to_set_static_SEAMLESS + vsh_forgot_to_set_static_DETAIL + vsh_forgot_to_set_static_PHONG + vsh_forgot_to_set_static_BASETEXTURETRANSFORM2 + + class lightmappedgeneric_flashlight_vs20_Dynamic_Index { -private: - int m_nDOWATERFOG; + unsigned int m_nDOWATERFOG : 2; #ifdef _DEBUG - bool m_bDOWATERFOG; -#endif + bool m_bDOWATERFOG : 1; +#endif // _DEBUG public: void SetDOWATERFOG( int i ) { @@ -131,32 +121,23 @@ public: m_nDOWATERFOG = i; #ifdef _DEBUG m_bDOWATERFOG = true; -#endif +#endif // _DEBUG } - void SetDOWATERFOG( bool i ) - { - m_nDOWATERFOG = i ? 1 : 0; -#ifdef _DEBUG - m_bDOWATERFOG = true; -#endif - } -public: - lightmappedgeneric_flashlight_vs20_Dynamic_Index() + + lightmappedgeneric_flashlight_vs20_Dynamic_Index( ) { + m_nDOWATERFOG = 0; #ifdef _DEBUG m_bDOWATERFOG = false; -#endif // _DEBUG - m_nDOWATERFOG = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bDOWATERFOG; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bDOWATERFOG ); return ( 1 * m_nDOWATERFOG ) + 0; } }; -#define shaderDynamicTest_lightmappedgeneric_flashlight_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + 0 + +#define shaderDynamicTest_lightmappedgeneric_flashlight_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + diff --git a/src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_vs30.inc b/src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_vs30.inc new file mode 100644 index 00000000..5785ee87 --- /dev/null +++ b/src/materialsystem/stdshaders/include/lightmappedgeneric_flashlight_vs30.inc @@ -0,0 +1,143 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// $BASETEXTURETRANSFORM2 && !$WORLDVERTEXTRANSITION +// $BASETEXTURETRANSFORM2 && $SEAMLESS +// $BASETEXTURETRANSFORM2 && $PHONG +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once +#include "shaderlib/cshader.h" +class lightmappedgeneric_flashlight_vs30_Static_Index +{ + unsigned int m_nNORMALMAP : 2; + unsigned int m_nWORLDVERTEXTRANSITION : 2; + unsigned int m_nSEAMLESS : 2; + unsigned int m_nDETAIL : 2; + unsigned int m_nPHONG : 2; + unsigned int m_nBASETEXTURETRANSFORM2 : 2; +#ifdef _DEBUG + bool m_bNORMALMAP : 1; + bool m_bWORLDVERTEXTRANSITION : 1; + bool m_bSEAMLESS : 1; + bool m_bDETAIL : 1; + bool m_bPHONG : 1; + bool m_bBASETEXTURETRANSFORM2 : 1; +#endif // _DEBUG +public: + void SetNORMALMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAP = i; +#ifdef _DEBUG + m_bNORMALMAP = true; +#endif // _DEBUG + } + + void SetWORLDVERTEXTRANSITION( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWORLDVERTEXTRANSITION = i; +#ifdef _DEBUG + m_bWORLDVERTEXTRANSITION = true; +#endif // _DEBUG + } + + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif // _DEBUG + } + + void SetDETAIL( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAIL = i; +#ifdef _DEBUG + m_bDETAIL = true; +#endif // _DEBUG + } + + void SetPHONG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG = i; +#ifdef _DEBUG + m_bPHONG = true; +#endif // _DEBUG + } + + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif // _DEBUG + } + + lightmappedgeneric_flashlight_vs30_Static_Index( ) + { + m_nNORMALMAP = 0; + m_nWORLDVERTEXTRANSITION = 0; + m_nSEAMLESS = 0; + m_nDETAIL = 0; + m_nPHONG = 0; + m_nBASETEXTURETRANSFORM2 = 0; +#ifdef _DEBUG + m_bNORMALMAP = false; + m_bWORLDVERTEXTRANSITION = false; + m_bSEAMLESS = false; + m_bDETAIL = false; + m_bPHONG = false; + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bNORMALMAP && m_bWORLDVERTEXTRANSITION && m_bSEAMLESS && m_bDETAIL && m_bPHONG && m_bBASETEXTURETRANSFORM2 ); + AssertMsg( !( m_nBASETEXTURETRANSFORM2 && !m_nWORLDVERTEXTRANSITION ), "Invalid combo combination ( BASETEXTURETRANSFORM2 && !WORLDVERTEXTRANSITION )" ); + AssertMsg( !( m_nBASETEXTURETRANSFORM2 && m_nSEAMLESS ), "Invalid combo combination ( BASETEXTURETRANSFORM2 && SEAMLESS )" ); + AssertMsg( !( m_nBASETEXTURETRANSFORM2 && m_nPHONG ), "Invalid combo combination ( BASETEXTURETRANSFORM2 && PHONG )" ); + return ( 2 * m_nNORMALMAP ) + ( 4 * m_nWORLDVERTEXTRANSITION ) + ( 8 * m_nSEAMLESS ) + ( 16 * m_nDETAIL ) + ( 32 * m_nPHONG ) + ( 64 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; + +#define shaderStaticTest_lightmappedgeneric_flashlight_vs30 vsh_forgot_to_set_static_NORMALMAP + vsh_forgot_to_set_static_WORLDVERTEXTRANSITION + vsh_forgot_to_set_static_SEAMLESS + vsh_forgot_to_set_static_DETAIL + vsh_forgot_to_set_static_PHONG + vsh_forgot_to_set_static_BASETEXTURETRANSFORM2 + + +class lightmappedgeneric_flashlight_vs30_Dynamic_Index +{ + unsigned int m_nDOWATERFOG : 2; +#ifdef _DEBUG + bool m_bDOWATERFOG : 1; +#endif // _DEBUG +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif // _DEBUG + } + + lightmappedgeneric_flashlight_vs30_Dynamic_Index( ) + { + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bDOWATERFOG ); + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; + +#define shaderDynamicTest_lightmappedgeneric_flashlight_vs30 vsh_forgot_to_set_dynamic_DOWATERFOG + diff --git a/src/materialsystem/stdshaders/include/lightmappedgeneric_ps20b.inc b/src/materialsystem/stdshaders/include/lightmappedgeneric_ps20b.inc index f74df2c1..8f42d7f6 100644 --- a/src/materialsystem/stdshaders/include/lightmappedgeneric_ps20b.inc +++ b/src/materialsystem/stdshaders/include/lightmappedgeneric_ps20b.inc @@ -15,6 +15,9 @@ // ($DETAIL_BLEND_MODE == 2 ) || ($DETAIL_BLEND_MODE == 3 ) || ($DETAIL_BLEND_MODE == 4 ) // ($DETAIL_BLEND_MODE == 5 ) || ($DETAIL_BLEND_MODE == 6 ) || ($DETAIL_BLEND_MODE == 7 ) // ($DETAIL_BLEND_MODE == 8 ) || ($DETAIL_BLEND_MODE == 9 ) +// ($PARALLAXCORRECT) && ( !$CUBEMAP ) +// ($PARALLAXCORRECT) && ( $LIGHTING_PREVIEW) +// ($PARALLAXCORRECT) && ( $OUTLINE || $SOFTEDGES) // $BUMPMAP2 && $WARPLIGHTING // $WARPLIGHTING && $DETAILTEXTURE // $ENVMAPMASK && $BUMPMAP @@ -26,6 +29,7 @@ // !$FASTPATH && $FASTPATHENVMAPTINT // !$BUMPMAP && $DIFFUSEBUMPMAP // !$BUMPMAP && $BUMPMAP2 +// !$BUMPMAP2 && $BUMPMASK // $ENVMAPMASK && $BUMPMAP2 // $BASETEXTURENOENVMAP && ( !$BASETEXTURE2 || !$CUBEMAP ) // $BASETEXTURE2NOENVMAP && ( !$BASETEXTURE2 || !$CUBEMAP ) @@ -39,6 +43,8 @@ // !$BUMPMAP && ($NORMAL_DECODE_MODE == 2) // !$BUMPMAP && ($NORMALMASK_DECODE_MODE == 1) // !$BUMPMAP && ($NORMALMASK_DECODE_MODE == 2) +// $FANCY_BLENDING && $BUMPMAP && $DETAILTEXTURE +// (!$FANCY_BLENDING) && $MASKEDBLENDING // defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED // defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA // defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 @@ -75,12 +81,13 @@ class lightmappedgeneric_ps20b_Static_Index unsigned int m_nFANCY_BLENDING : 2; unsigned int m_nRELIEF_MAPPING : 1; unsigned int m_nSEAMLESS : 2; - unsigned int m_nOUTLINE : 2; - unsigned int m_nSOFTEDGES : 2; + unsigned int m_nOUTLINE : 1; + unsigned int m_nSOFTEDGES : 1; unsigned int m_nBUMPMASK : 2; unsigned int m_nNORMAL_DECODE_MODE : 1; unsigned int m_nNORMALMASK_DECODE_MODE : 1; unsigned int m_nDETAIL_BLEND_MODE : 4; + unsigned int m_nPARALLAXCORRECT : 2; #ifdef _DEBUG bool m_bMASKEDBLENDING : 1; bool m_bBASETEXTURE2 : 1; @@ -105,6 +112,7 @@ class lightmappedgeneric_ps20b_Static_Index bool m_bNORMAL_DECODE_MODE : 1; bool m_bNORMALMASK_DECODE_MODE : 1; bool m_bDETAIL_BLEND_MODE : 1; + bool m_bPARALLAXCORRECT : 1; #endif // _DEBUG public: void SetMASKEDBLENDING( int i ) @@ -262,7 +270,7 @@ public: void SetOUTLINE( int i ) { - Assert( i >= 0 && i <= 1 ); + Assert( i >= 0 && i <= 0 ); m_nOUTLINE = i; #ifdef _DEBUG m_bOUTLINE = true; @@ -271,7 +279,7 @@ public: void SetSOFTEDGES( int i ) { - Assert( i >= 0 && i <= 1 ); + Assert( i >= 0 && i <= 0 ); m_nSOFTEDGES = i; #ifdef _DEBUG m_bSOFTEDGES = true; @@ -314,6 +322,15 @@ public: #endif // _DEBUG } + void SetPARALLAXCORRECT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPARALLAXCORRECT = i; +#ifdef _DEBUG + m_bPARALLAXCORRECT = true; +#endif // _DEBUG + } + lightmappedgeneric_ps20b_Static_Index( ) { m_nMASKEDBLENDING = 0; @@ -339,6 +356,7 @@ public: m_nNORMAL_DECODE_MODE = 0; m_nNORMALMASK_DECODE_MODE = 0; m_nDETAIL_BLEND_MODE = 0; + m_nPARALLAXCORRECT = 0; #ifdef _DEBUG m_bMASKEDBLENDING = false; m_bBASETEXTURE2 = false; @@ -363,12 +381,13 @@ public: m_bNORMAL_DECODE_MODE = false; m_bNORMALMASK_DECODE_MODE = false; m_bDETAIL_BLEND_MODE = false; + m_bPARALLAXCORRECT = false; #endif // _DEBUG } int GetIndex() const { - Assert( m_bMASKEDBLENDING && m_bBASETEXTURE2 && m_bDETAILTEXTURE && m_bBUMPMAP && m_bBUMPMAP2 && m_bCUBEMAP && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bNORMALMAPALPHAENVMAPMASK && m_bDIFFUSEBUMPMAP && m_bBASETEXTURENOENVMAP && m_bBASETEXTURE2NOENVMAP && m_bWARPLIGHTING && m_bFANCY_BLENDING && m_bRELIEF_MAPPING && m_bSEAMLESS && m_bOUTLINE && m_bSOFTEDGES && m_bBUMPMASK && m_bNORMAL_DECODE_MODE && m_bNORMALMASK_DECODE_MODE && m_bDETAIL_BLEND_MODE ); + Assert( m_bMASKEDBLENDING && m_bBASETEXTURE2 && m_bDETAILTEXTURE && m_bBUMPMAP && m_bBUMPMAP2 && m_bCUBEMAP && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bNORMALMAPALPHAENVMAPMASK && m_bDIFFUSEBUMPMAP && m_bBASETEXTURENOENVMAP && m_bBASETEXTURE2NOENVMAP && m_bWARPLIGHTING && m_bFANCY_BLENDING && m_bRELIEF_MAPPING && m_bSEAMLESS && m_bOUTLINE && m_bSOFTEDGES && m_bBUMPMASK && m_bNORMAL_DECODE_MODE && m_bNORMALMASK_DECODE_MODE && m_bDETAIL_BLEND_MODE && m_bPARALLAXCORRECT ); AssertMsg( !( m_nSEAMLESS && m_nRELIEF_MAPPING ), "Invalid combo combination ( SEAMLESS && RELIEF_MAPPING )" ); AssertMsg( !( !m_nDETAILTEXTURE && ( m_nDETAIL_BLEND_MODE != 0 ) ), "Invalid combo combination ( !DETAILTEXTURE && ( DETAIL_BLEND_MODE != 0 ) )" ); AssertMsg( !( m_nSEAMLESS && ( m_nOUTLINE || m_nSOFTEDGES ) ), "Invalid combo combination ( SEAMLESS && ( OUTLINE || SOFTEDGES ) )" ); @@ -383,6 +402,8 @@ public: AssertMsg( !( ( m_nDETAIL_BLEND_MODE == 2 ) || ( ( m_nDETAIL_BLEND_MODE == 3 ) || ( m_nDETAIL_BLEND_MODE == 4 ) ) ), "Invalid combo combination ( ( DETAIL_BLEND_MODE == 2 ) || ( ( DETAIL_BLEND_MODE == 3 ) || ( DETAIL_BLEND_MODE == 4 ) ) )" ); AssertMsg( !( ( m_nDETAIL_BLEND_MODE == 5 ) || ( ( m_nDETAIL_BLEND_MODE == 6 ) || ( m_nDETAIL_BLEND_MODE == 7 ) ) ), "Invalid combo combination ( ( DETAIL_BLEND_MODE == 5 ) || ( ( DETAIL_BLEND_MODE == 6 ) || ( DETAIL_BLEND_MODE == 7 ) ) )" ); AssertMsg( !( ( m_nDETAIL_BLEND_MODE == 8 ) || ( m_nDETAIL_BLEND_MODE == 9 ) ), "Invalid combo combination ( ( DETAIL_BLEND_MODE == 8 ) || ( DETAIL_BLEND_MODE == 9 ) )" ); + AssertMsg( !( m_nPARALLAXCORRECT && !m_nCUBEMAP ), "Invalid combo combination ( PARALLAXCORRECT && !CUBEMAP )" ); + AssertMsg( !( m_nPARALLAXCORRECT && ( m_nOUTLINE || m_nSOFTEDGES ) ), "Invalid combo combination ( PARALLAXCORRECT && ( OUTLINE || SOFTEDGES ) )" ); AssertMsg( !( m_nBUMPMAP2 && m_nWARPLIGHTING ), "Invalid combo combination ( BUMPMAP2 && WARPLIGHTING )" ); AssertMsg( !( m_nWARPLIGHTING && m_nDETAILTEXTURE ), "Invalid combo combination ( WARPLIGHTING && DETAILTEXTURE )" ); AssertMsg( !( m_nENVMAPMASK && m_nBUMPMAP ), "Invalid combo combination ( ENVMAPMASK && BUMPMAP )" ); @@ -392,6 +413,7 @@ public: AssertMsg( !( m_nBASEALPHAENVMAPMASK && m_nSELFILLUM ), "Invalid combo combination ( BASEALPHAENVMAPMASK && SELFILLUM )" ); AssertMsg( !( !m_nBUMPMAP && m_nDIFFUSEBUMPMAP ), "Invalid combo combination ( !BUMPMAP && DIFFUSEBUMPMAP )" ); AssertMsg( !( !m_nBUMPMAP && m_nBUMPMAP2 ), "Invalid combo combination ( !BUMPMAP && BUMPMAP2 )" ); + AssertMsg( !( !m_nBUMPMAP2 && m_nBUMPMASK ), "Invalid combo combination ( !BUMPMAP2 && BUMPMASK )" ); AssertMsg( !( m_nENVMAPMASK && m_nBUMPMAP2 ), "Invalid combo combination ( ENVMAPMASK && BUMPMAP2 )" ); AssertMsg( !( m_nBASETEXTURENOENVMAP && ( !m_nBASETEXTURE2 || !m_nCUBEMAP ) ), "Invalid combo combination ( BASETEXTURENOENVMAP && ( !BASETEXTURE2 || !CUBEMAP ) )" ); AssertMsg( !( m_nBASETEXTURE2NOENVMAP && ( !m_nBASETEXTURE2 || !m_nCUBEMAP ) ), "Invalid combo combination ( BASETEXTURE2NOENVMAP && ( !BASETEXTURE2 || !CUBEMAP ) )" ); @@ -404,11 +426,13 @@ public: AssertMsg( !( !m_nBUMPMAP && ( m_nNORMAL_DECODE_MODE == 2 ) ), "Invalid combo combination ( !BUMPMAP && ( NORMAL_DECODE_MODE == 2 ) )" ); AssertMsg( !( !m_nBUMPMAP && ( m_nNORMALMASK_DECODE_MODE == 1 ) ), "Invalid combo combination ( !BUMPMAP && ( NORMALMASK_DECODE_MODE == 1 ) )" ); AssertMsg( !( !m_nBUMPMAP && ( m_nNORMALMASK_DECODE_MODE == 2 ) ), "Invalid combo combination ( !BUMPMAP && ( NORMALMASK_DECODE_MODE == 2 ) )" ); - return ( 288 * m_nMASKEDBLENDING ) + ( 576 * m_nBASETEXTURE2 ) + ( 1152 * m_nDETAILTEXTURE ) + ( 2304 * m_nBUMPMAP ) + ( 6912 * m_nBUMPMAP2 ) + ( 13824 * m_nCUBEMAP ) + ( 27648 * m_nENVMAPMASK ) + ( 55296 * m_nBASEALPHAENVMAPMASK ) + ( 110592 * m_nSELFILLUM ) + ( 221184 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 442368 * m_nDIFFUSEBUMPMAP ) + ( 884736 * m_nBASETEXTURENOENVMAP ) + ( 1769472 * m_nBASETEXTURE2NOENVMAP ) + ( 3538944 * m_nWARPLIGHTING ) + ( 7077888 * m_nFANCY_BLENDING ) + ( 14155776 * m_nRELIEF_MAPPING ) + ( 14155776 * m_nSEAMLESS ) + ( 28311552 * m_nOUTLINE ) + ( 56623104 * m_nSOFTEDGES ) + ( 113246208 * m_nBUMPMASK ) + ( 226492416 * m_nNORMAL_DECODE_MODE ) + ( 226492416 * m_nNORMALMASK_DECODE_MODE ) + ( 226492416 * m_nDETAIL_BLEND_MODE ) + 0; + AssertMsg( !( m_nFANCY_BLENDING && ( m_nBUMPMAP && m_nDETAILTEXTURE ) ), "Invalid combo combination ( FANCY_BLENDING && ( BUMPMAP && DETAILTEXTURE ) )" ); + AssertMsg( !( !m_nFANCY_BLENDING && m_nMASKEDBLENDING ), "Invalid combo combination ( !FANCY_BLENDING && MASKEDBLENDING )" ); + return ( 288 * m_nMASKEDBLENDING ) + ( 576 * m_nBASETEXTURE2 ) + ( 1152 * m_nDETAILTEXTURE ) + ( 2304 * m_nBUMPMAP ) + ( 6912 * m_nBUMPMAP2 ) + ( 13824 * m_nCUBEMAP ) + ( 27648 * m_nENVMAPMASK ) + ( 55296 * m_nBASEALPHAENVMAPMASK ) + ( 110592 * m_nSELFILLUM ) + ( 221184 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 442368 * m_nDIFFUSEBUMPMAP ) + ( 884736 * m_nBASETEXTURENOENVMAP ) + ( 1769472 * m_nBASETEXTURE2NOENVMAP ) + ( 3538944 * m_nWARPLIGHTING ) + ( 7077888 * m_nFANCY_BLENDING ) + ( 14155776 * m_nRELIEF_MAPPING ) + ( 14155776 * m_nSEAMLESS ) + ( 28311552 * m_nOUTLINE ) + ( 28311552 * m_nSOFTEDGES ) + ( 28311552 * m_nBUMPMASK ) + ( 56623104 * m_nNORMAL_DECODE_MODE ) + ( 56623104 * m_nNORMALMASK_DECODE_MODE ) + ( 56623104 * m_nDETAIL_BLEND_MODE ) + ( 679477248 * m_nPARALLAXCORRECT ) + 0; } }; -#define shaderStaticTest_lightmappedgeneric_ps20b psh_forgot_to_set_static_MASKEDBLENDING + psh_forgot_to_set_static_BASETEXTURE2 + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_BUMPMAP + psh_forgot_to_set_static_BUMPMAP2 + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_DIFFUSEBUMPMAP + psh_forgot_to_set_static_BASETEXTURENOENVMAP + psh_forgot_to_set_static_BASETEXTURE2NOENVMAP + psh_forgot_to_set_static_WARPLIGHTING + psh_forgot_to_set_static_FANCY_BLENDING + psh_forgot_to_set_static_RELIEF_MAPPING + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_OUTLINE + psh_forgot_to_set_static_SOFTEDGES + psh_forgot_to_set_static_BUMPMASK + psh_forgot_to_set_static_NORMAL_DECODE_MODE + psh_forgot_to_set_static_NORMALMASK_DECODE_MODE + psh_forgot_to_set_static_DETAIL_BLEND_MODE +#define shaderStaticTest_lightmappedgeneric_ps20b psh_forgot_to_set_static_MASKEDBLENDING + psh_forgot_to_set_static_BASETEXTURE2 + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_BUMPMAP + psh_forgot_to_set_static_BUMPMAP2 + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_DIFFUSEBUMPMAP + psh_forgot_to_set_static_BASETEXTURENOENVMAP + psh_forgot_to_set_static_BASETEXTURE2NOENVMAP + psh_forgot_to_set_static_WARPLIGHTING + psh_forgot_to_set_static_FANCY_BLENDING + psh_forgot_to_set_static_RELIEF_MAPPING + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_OUTLINE + psh_forgot_to_set_static_SOFTEDGES + psh_forgot_to_set_static_BUMPMASK + psh_forgot_to_set_static_NORMAL_DECODE_MODE + psh_forgot_to_set_static_NORMALMASK_DECODE_MODE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_PARALLAXCORRECT class lightmappedgeneric_ps20b_Dynamic_Index diff --git a/src/materialsystem/stdshaders/include/lightmappedgeneric_ps30.inc b/src/materialsystem/stdshaders/include/lightmappedgeneric_ps30.inc new file mode 100644 index 00000000..7b5da783 --- /dev/null +++ b/src/materialsystem/stdshaders/include/lightmappedgeneric_ps30.inc @@ -0,0 +1,555 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// $SEAMLESS && $RELIEF_MAPPING +// (! $DETAILTEXTURE) && ( $DETAIL_BLEND_MODE != 0 ) +// $SEAMLESS && ( $OUTLINE || $SOFTEDGES) +// $BASETEXTURE2 && ( $OUTLINE || $SOFTEDGES) +// $BUMPMAP2 && ( $OUTLINE || $SOFTEDGES) +// $SELFILLUM && ( $OUTLINE || $SOFTEDGES) +// $MASKEDBLENDING && ( $OUTLINE || $SOFTEDGES) +// $FANCY_BLENDING && ( $OUTLINE || $SOFTEDGES) +// $LIGHTING_PREVIEW && ( $OUTLINE || $SOFTEDGES) +// ($FASTPATH == 0) && ( $OUTLINE || $SOFTEDGES) +// ($DETAILTEXTURE && $BUMPMAP) && ( $OUTLINE || $SOFTEDGES) +// ($WARPLIGHTING) && ( $OUTLINE || $SOFTEDGES) +// ($BUMPMAP) && ( $OUTLINE || $SOFTEDGES) +// ($DETAIL_BLEND_MODE == 2 ) || ($DETAIL_BLEND_MODE == 3 ) || ($DETAIL_BLEND_MODE == 4 ) +// ($DETAIL_BLEND_MODE == 5 ) || ($DETAIL_BLEND_MODE == 6 ) || ($DETAIL_BLEND_MODE == 7 ) +// ($DETAIL_BLEND_MODE == 8 ) || ($DETAIL_BLEND_MODE == 9 ) +// ($PARALLAXCORRECT) && ( !$CUBEMAP ) +// ($PARALLAXCORRECT) && ( $LIGHTING_PREVIEW) +// ($PARALLAXCORRECT) && ( $OUTLINE || $SOFTEDGES) +// $BUMPMAP2 && $WARPLIGHTING +// $WARPLIGHTING && $DETAILTEXTURE +// $ENVMAPMASK && $BUMPMAP +// $NORMALMAPALPHAENVMAPMASK && $BASEALPHAENVMAPMASK +// $NORMALMAPALPHAENVMAPMASK && $ENVMAPMASK +// $BASEALPHAENVMAPMASK && $ENVMAPMASK +// $BASEALPHAENVMAPMASK && $SELFILLUM +// !$FASTPATH && $FASTPATHENVMAPCONTRAST +// !$FASTPATH && $FASTPATHENVMAPTINT +// !$BUMPMAP && $DIFFUSEBUMPMAP +// !$BUMPMAP && $BUMPMAP2 +// !$BUMPMAP2 && $BUMPMASK +// $ENVMAPMASK && $BUMPMAP2 +// $BASETEXTURENOENVMAP && ( !$BASETEXTURE2 || !$CUBEMAP ) +// $BASETEXTURE2NOENVMAP && ( !$BASETEXTURE2 || !$CUBEMAP ) +// $BASEALPHAENVMAPMASK && $BUMPMAP +// $PARALLAXMAP && $DETAILTEXTURE +// $SEAMLESS && $RELIEF_MAPPING +// $SEAMLESS && $DETAILTEXTURE +// $SEAMLESS && $MASKEDBLENDING +// $BUMPMASK && ( $SEAMLESS || $DETAILTEXTURE || $SELFILLUM || $BASETEXTURENOENVMAP || $BASETEXTURE2 ) +// !$BUMPMAP && ($NORMAL_DECODE_MODE == 1) +// !$BUMPMAP && ($NORMAL_DECODE_MODE == 2) +// !$BUMPMAP && ($NORMALMASK_DECODE_MODE == 1) +// !$BUMPMAP && ($NORMALMASK_DECODE_MODE == 2) +// $FANCY_BLENDING && $BUMPMAP && $DETAILTEXTURE +// (!$FANCY_BLENDING) && $MASKEDBLENDING +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once +#include "shaderlib/cshader.h" +class lightmappedgeneric_ps30_Static_Index +{ + unsigned int m_nMASKEDBLENDING : 2; + unsigned int m_nBASETEXTURE2 : 2; + unsigned int m_nDETAILTEXTURE : 2; + unsigned int m_nBUMPMAP : 2; + unsigned int m_nBUMPMAP2 : 2; + unsigned int m_nCUBEMAP : 2; + unsigned int m_nENVMAPMASK : 2; + unsigned int m_nBASEALPHAENVMAPMASK : 2; + unsigned int m_nSELFILLUM : 2; + unsigned int m_nNORMALMAPALPHAENVMAPMASK : 2; + unsigned int m_nDIFFUSEBUMPMAP : 2; + unsigned int m_nBASETEXTURENOENVMAP : 2; + unsigned int m_nBASETEXTURE2NOENVMAP : 2; + unsigned int m_nWARPLIGHTING : 2; + unsigned int m_nFANCY_BLENDING : 2; + unsigned int m_nRELIEF_MAPPING : 1; + unsigned int m_nSEAMLESS : 2; + unsigned int m_nOUTLINE : 1; + unsigned int m_nSOFTEDGES : 1; + unsigned int m_nBUMPMASK : 2; + unsigned int m_nNORMAL_DECODE_MODE : 1; + unsigned int m_nNORMALMASK_DECODE_MODE : 1; + unsigned int m_nDETAIL_BLEND_MODE : 4; + unsigned int m_nPARALLAXCORRECT : 2; +#ifdef _DEBUG + bool m_bMASKEDBLENDING : 1; + bool m_bBASETEXTURE2 : 1; + bool m_bDETAILTEXTURE : 1; + bool m_bBUMPMAP : 1; + bool m_bBUMPMAP2 : 1; + bool m_bCUBEMAP : 1; + bool m_bENVMAPMASK : 1; + bool m_bBASEALPHAENVMAPMASK : 1; + bool m_bSELFILLUM : 1; + bool m_bNORMALMAPALPHAENVMAPMASK : 1; + bool m_bDIFFUSEBUMPMAP : 1; + bool m_bBASETEXTURENOENVMAP : 1; + bool m_bBASETEXTURE2NOENVMAP : 1; + bool m_bWARPLIGHTING : 1; + bool m_bFANCY_BLENDING : 1; + bool m_bRELIEF_MAPPING : 1; + bool m_bSEAMLESS : 1; + bool m_bOUTLINE : 1; + bool m_bSOFTEDGES : 1; + bool m_bBUMPMASK : 1; + bool m_bNORMAL_DECODE_MODE : 1; + bool m_bNORMALMASK_DECODE_MODE : 1; + bool m_bDETAIL_BLEND_MODE : 1; + bool m_bPARALLAXCORRECT : 1; +#endif // _DEBUG +public: + void SetMASKEDBLENDING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nMASKEDBLENDING = i; +#ifdef _DEBUG + m_bMASKEDBLENDING = true; +#endif // _DEBUG + } + + void SetBASETEXTURE2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE2 = i; +#ifdef _DEBUG + m_bBASETEXTURE2 = true; +#endif // _DEBUG + } + + void SetDETAILTEXTURE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDETAILTEXTURE = i; +#ifdef _DEBUG + m_bDETAILTEXTURE = true; +#endif // _DEBUG + } + + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif // _DEBUG + } + + void SetBUMPMAP2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP2 = i; +#ifdef _DEBUG + m_bBUMPMAP2 = true; +#endif // _DEBUG + } + + void SetCUBEMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCUBEMAP = i; +#ifdef _DEBUG + m_bCUBEMAP = true; +#endif // _DEBUG + } + + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif // _DEBUG + } + + void SetBASEALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASEALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bBASEALPHAENVMAPMASK = true; +#endif // _DEBUG + } + + void SetSELFILLUM( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSELFILLUM = i; +#ifdef _DEBUG + m_bSELFILLUM = true; +#endif // _DEBUG + } + + void SetNORMALMAPALPHAENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nNORMALMAPALPHAENVMAPMASK = i; +#ifdef _DEBUG + m_bNORMALMAPALPHAENVMAPMASK = true; +#endif // _DEBUG + } + + void SetDIFFUSEBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSEBUMPMAP = i; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif // _DEBUG + } + + void SetBASETEXTURENOENVMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURENOENVMAP = i; +#ifdef _DEBUG + m_bBASETEXTURENOENVMAP = true; +#endif // _DEBUG + } + + void SetBASETEXTURE2NOENVMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURE2NOENVMAP = i; +#ifdef _DEBUG + m_bBASETEXTURE2NOENVMAP = true; +#endif // _DEBUG + } + + void SetWARPLIGHTING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWARPLIGHTING = i; +#ifdef _DEBUG + m_bWARPLIGHTING = true; +#endif // _DEBUG + } + + void SetFANCY_BLENDING( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFANCY_BLENDING = i; +#ifdef _DEBUG + m_bFANCY_BLENDING = true; +#endif // _DEBUG + } + + void SetRELIEF_MAPPING( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nRELIEF_MAPPING = i; +#ifdef _DEBUG + m_bRELIEF_MAPPING = true; +#endif // _DEBUG + } + + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif // _DEBUG + } + + void SetOUTLINE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nOUTLINE = i; +#ifdef _DEBUG + m_bOUTLINE = true; +#endif // _DEBUG + } + + void SetSOFTEDGES( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nSOFTEDGES = i; +#ifdef _DEBUG + m_bSOFTEDGES = true; +#endif // _DEBUG + } + + void SetBUMPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMASK = i; +#ifdef _DEBUG + m_bBUMPMASK = true; +#endif // _DEBUG + } + + void SetNORMAL_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMAL_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMAL_DECODE_MODE = true; +#endif // _DEBUG + } + + void SetNORMALMASK_DECODE_MODE( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nNORMALMASK_DECODE_MODE = i; +#ifdef _DEBUG + m_bNORMALMASK_DECODE_MODE = true; +#endif // _DEBUG + } + + void SetDETAIL_BLEND_MODE( int i ) + { + Assert( i >= 0 && i <= 11 ); + m_nDETAIL_BLEND_MODE = i; +#ifdef _DEBUG + m_bDETAIL_BLEND_MODE = true; +#endif // _DEBUG + } + + void SetPARALLAXCORRECT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPARALLAXCORRECT = i; +#ifdef _DEBUG + m_bPARALLAXCORRECT = true; +#endif // _DEBUG + } + + lightmappedgeneric_ps30_Static_Index( ) + { + m_nMASKEDBLENDING = 0; + m_nBASETEXTURE2 = 0; + m_nDETAILTEXTURE = 0; + m_nBUMPMAP = 0; + m_nBUMPMAP2 = 0; + m_nCUBEMAP = 0; + m_nENVMAPMASK = 0; + m_nBASEALPHAENVMAPMASK = 0; + m_nSELFILLUM = 0; + m_nNORMALMAPALPHAENVMAPMASK = 0; + m_nDIFFUSEBUMPMAP = 0; + m_nBASETEXTURENOENVMAP = 0; + m_nBASETEXTURE2NOENVMAP = 0; + m_nWARPLIGHTING = 0; + m_nFANCY_BLENDING = 0; + m_nRELIEF_MAPPING = 0; + m_nSEAMLESS = 0; + m_nOUTLINE = 0; + m_nSOFTEDGES = 0; + m_nBUMPMASK = 0; + m_nNORMAL_DECODE_MODE = 0; + m_nNORMALMASK_DECODE_MODE = 0; + m_nDETAIL_BLEND_MODE = 0; + m_nPARALLAXCORRECT = 0; +#ifdef _DEBUG + m_bMASKEDBLENDING = false; + m_bBASETEXTURE2 = false; + m_bDETAILTEXTURE = false; + m_bBUMPMAP = false; + m_bBUMPMAP2 = false; + m_bCUBEMAP = false; + m_bENVMAPMASK = false; + m_bBASEALPHAENVMAPMASK = false; + m_bSELFILLUM = false; + m_bNORMALMAPALPHAENVMAPMASK = false; + m_bDIFFUSEBUMPMAP = false; + m_bBASETEXTURENOENVMAP = false; + m_bBASETEXTURE2NOENVMAP = false; + m_bWARPLIGHTING = false; + m_bFANCY_BLENDING = false; + m_bRELIEF_MAPPING = false; + m_bSEAMLESS = false; + m_bOUTLINE = false; + m_bSOFTEDGES = false; + m_bBUMPMASK = false; + m_bNORMAL_DECODE_MODE = false; + m_bNORMALMASK_DECODE_MODE = false; + m_bDETAIL_BLEND_MODE = false; + m_bPARALLAXCORRECT = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bMASKEDBLENDING && m_bBASETEXTURE2 && m_bDETAILTEXTURE && m_bBUMPMAP && m_bBUMPMAP2 && m_bCUBEMAP && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bNORMALMAPALPHAENVMAPMASK && m_bDIFFUSEBUMPMAP && m_bBASETEXTURENOENVMAP && m_bBASETEXTURE2NOENVMAP && m_bWARPLIGHTING && m_bFANCY_BLENDING && m_bRELIEF_MAPPING && m_bSEAMLESS && m_bOUTLINE && m_bSOFTEDGES && m_bBUMPMASK && m_bNORMAL_DECODE_MODE && m_bNORMALMASK_DECODE_MODE && m_bDETAIL_BLEND_MODE && m_bPARALLAXCORRECT ); + AssertMsg( !( m_nSEAMLESS && m_nRELIEF_MAPPING ), "Invalid combo combination ( SEAMLESS && RELIEF_MAPPING )" ); + AssertMsg( !( !m_nDETAILTEXTURE && ( m_nDETAIL_BLEND_MODE != 0 ) ), "Invalid combo combination ( !DETAILTEXTURE && ( DETAIL_BLEND_MODE != 0 ) )" ); + AssertMsg( !( m_nSEAMLESS && ( m_nOUTLINE || m_nSOFTEDGES ) ), "Invalid combo combination ( SEAMLESS && ( OUTLINE || SOFTEDGES ) )" ); + AssertMsg( !( m_nBASETEXTURE2 && ( m_nOUTLINE || m_nSOFTEDGES ) ), "Invalid combo combination ( BASETEXTURE2 && ( OUTLINE || SOFTEDGES ) )" ); + AssertMsg( !( m_nBUMPMAP2 && ( m_nOUTLINE || m_nSOFTEDGES ) ), "Invalid combo combination ( BUMPMAP2 && ( OUTLINE || SOFTEDGES ) )" ); + AssertMsg( !( m_nSELFILLUM && ( m_nOUTLINE || m_nSOFTEDGES ) ), "Invalid combo combination ( SELFILLUM && ( OUTLINE || SOFTEDGES ) )" ); + AssertMsg( !( m_nMASKEDBLENDING && ( m_nOUTLINE || m_nSOFTEDGES ) ), "Invalid combo combination ( MASKEDBLENDING && ( OUTLINE || SOFTEDGES ) )" ); + AssertMsg( !( m_nFANCY_BLENDING && ( m_nOUTLINE || m_nSOFTEDGES ) ), "Invalid combo combination ( FANCY_BLENDING && ( OUTLINE || SOFTEDGES ) )" ); + AssertMsg( !( ( m_nDETAILTEXTURE && m_nBUMPMAP ) && ( m_nOUTLINE || m_nSOFTEDGES ) ), "Invalid combo combination ( ( DETAILTEXTURE && BUMPMAP ) && ( OUTLINE || SOFTEDGES ) )" ); + AssertMsg( !( m_nWARPLIGHTING && ( m_nOUTLINE || m_nSOFTEDGES ) ), "Invalid combo combination ( WARPLIGHTING && ( OUTLINE || SOFTEDGES ) )" ); + AssertMsg( !( m_nBUMPMAP && ( m_nOUTLINE || m_nSOFTEDGES ) ), "Invalid combo combination ( BUMPMAP && ( OUTLINE || SOFTEDGES ) )" ); + AssertMsg( !( ( m_nDETAIL_BLEND_MODE == 2 ) || ( ( m_nDETAIL_BLEND_MODE == 3 ) || ( m_nDETAIL_BLEND_MODE == 4 ) ) ), "Invalid combo combination ( ( DETAIL_BLEND_MODE == 2 ) || ( ( DETAIL_BLEND_MODE == 3 ) || ( DETAIL_BLEND_MODE == 4 ) ) )" ); + AssertMsg( !( ( m_nDETAIL_BLEND_MODE == 5 ) || ( ( m_nDETAIL_BLEND_MODE == 6 ) || ( m_nDETAIL_BLEND_MODE == 7 ) ) ), "Invalid combo combination ( ( DETAIL_BLEND_MODE == 5 ) || ( ( DETAIL_BLEND_MODE == 6 ) || ( DETAIL_BLEND_MODE == 7 ) ) )" ); + AssertMsg( !( ( m_nDETAIL_BLEND_MODE == 8 ) || ( m_nDETAIL_BLEND_MODE == 9 ) ), "Invalid combo combination ( ( DETAIL_BLEND_MODE == 8 ) || ( DETAIL_BLEND_MODE == 9 ) )" ); + AssertMsg( !( m_nPARALLAXCORRECT && !m_nCUBEMAP ), "Invalid combo combination ( PARALLAXCORRECT && !CUBEMAP )" ); + AssertMsg( !( m_nPARALLAXCORRECT && ( m_nOUTLINE || m_nSOFTEDGES ) ), "Invalid combo combination ( PARALLAXCORRECT && ( OUTLINE || SOFTEDGES ) )" ); + AssertMsg( !( m_nBUMPMAP2 && m_nWARPLIGHTING ), "Invalid combo combination ( BUMPMAP2 && WARPLIGHTING )" ); + AssertMsg( !( m_nWARPLIGHTING && m_nDETAILTEXTURE ), "Invalid combo combination ( WARPLIGHTING && DETAILTEXTURE )" ); + AssertMsg( !( m_nENVMAPMASK && m_nBUMPMAP ), "Invalid combo combination ( ENVMAPMASK && BUMPMAP )" ); + AssertMsg( !( m_nNORMALMAPALPHAENVMAPMASK && m_nBASEALPHAENVMAPMASK ), "Invalid combo combination ( NORMALMAPALPHAENVMAPMASK && BASEALPHAENVMAPMASK )" ); + AssertMsg( !( m_nNORMALMAPALPHAENVMAPMASK && m_nENVMAPMASK ), "Invalid combo combination ( NORMALMAPALPHAENVMAPMASK && ENVMAPMASK )" ); + AssertMsg( !( m_nBASEALPHAENVMAPMASK && m_nENVMAPMASK ), "Invalid combo combination ( BASEALPHAENVMAPMASK && ENVMAPMASK )" ); + AssertMsg( !( m_nBASEALPHAENVMAPMASK && m_nSELFILLUM ), "Invalid combo combination ( BASEALPHAENVMAPMASK && SELFILLUM )" ); + AssertMsg( !( !m_nBUMPMAP && m_nDIFFUSEBUMPMAP ), "Invalid combo combination ( !BUMPMAP && DIFFUSEBUMPMAP )" ); + AssertMsg( !( !m_nBUMPMAP && m_nBUMPMAP2 ), "Invalid combo combination ( !BUMPMAP && BUMPMAP2 )" ); + AssertMsg( !( !m_nBUMPMAP2 && m_nBUMPMASK ), "Invalid combo combination ( !BUMPMAP2 && BUMPMASK )" ); + AssertMsg( !( m_nENVMAPMASK && m_nBUMPMAP2 ), "Invalid combo combination ( ENVMAPMASK && BUMPMAP2 )" ); + AssertMsg( !( m_nBASETEXTURENOENVMAP && ( !m_nBASETEXTURE2 || !m_nCUBEMAP ) ), "Invalid combo combination ( BASETEXTURENOENVMAP && ( !BASETEXTURE2 || !CUBEMAP ) )" ); + AssertMsg( !( m_nBASETEXTURE2NOENVMAP && ( !m_nBASETEXTURE2 || !m_nCUBEMAP ) ), "Invalid combo combination ( BASETEXTURE2NOENVMAP && ( !BASETEXTURE2 || !CUBEMAP ) )" ); + AssertMsg( !( m_nBASEALPHAENVMAPMASK && m_nBUMPMAP ), "Invalid combo combination ( BASEALPHAENVMAPMASK && BUMPMAP )" ); + AssertMsg( !( m_nSEAMLESS && m_nRELIEF_MAPPING ), "Invalid combo combination ( SEAMLESS && RELIEF_MAPPING )" ); + AssertMsg( !( m_nSEAMLESS && m_nDETAILTEXTURE ), "Invalid combo combination ( SEAMLESS && DETAILTEXTURE )" ); + AssertMsg( !( m_nSEAMLESS && m_nMASKEDBLENDING ), "Invalid combo combination ( SEAMLESS && MASKEDBLENDING )" ); + AssertMsg( !( m_nBUMPMASK && ( m_nSEAMLESS || ( m_nDETAILTEXTURE || ( m_nSELFILLUM || ( m_nBASETEXTURENOENVMAP || m_nBASETEXTURE2 ) ) ) ) ), "Invalid combo combination ( BUMPMASK && ( SEAMLESS || ( DETAILTEXTURE || ( SELFILLUM || ( BASETEXTURENOENVMAP || BASETEXTURE2 ) ) ) ) )" ); + AssertMsg( !( !m_nBUMPMAP && ( m_nNORMAL_DECODE_MODE == 1 ) ), "Invalid combo combination ( !BUMPMAP && ( NORMAL_DECODE_MODE == 1 ) )" ); + AssertMsg( !( !m_nBUMPMAP && ( m_nNORMAL_DECODE_MODE == 2 ) ), "Invalid combo combination ( !BUMPMAP && ( NORMAL_DECODE_MODE == 2 ) )" ); + AssertMsg( !( !m_nBUMPMAP && ( m_nNORMALMASK_DECODE_MODE == 1 ) ), "Invalid combo combination ( !BUMPMAP && ( NORMALMASK_DECODE_MODE == 1 ) )" ); + AssertMsg( !( !m_nBUMPMAP && ( m_nNORMALMASK_DECODE_MODE == 2 ) ), "Invalid combo combination ( !BUMPMAP && ( NORMALMASK_DECODE_MODE == 2 ) )" ); + AssertMsg( !( m_nFANCY_BLENDING && ( m_nBUMPMAP && m_nDETAILTEXTURE ) ), "Invalid combo combination ( FANCY_BLENDING && ( BUMPMAP && DETAILTEXTURE ) )" ); + AssertMsg( !( !m_nFANCY_BLENDING && m_nMASKEDBLENDING ), "Invalid combo combination ( !FANCY_BLENDING && MASKEDBLENDING )" ); + return ( 288 * m_nMASKEDBLENDING ) + ( 576 * m_nBASETEXTURE2 ) + ( 1152 * m_nDETAILTEXTURE ) + ( 2304 * m_nBUMPMAP ) + ( 6912 * m_nBUMPMAP2 ) + ( 13824 * m_nCUBEMAP ) + ( 27648 * m_nENVMAPMASK ) + ( 55296 * m_nBASEALPHAENVMAPMASK ) + ( 110592 * m_nSELFILLUM ) + ( 221184 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 442368 * m_nDIFFUSEBUMPMAP ) + ( 884736 * m_nBASETEXTURENOENVMAP ) + ( 1769472 * m_nBASETEXTURE2NOENVMAP ) + ( 3538944 * m_nWARPLIGHTING ) + ( 7077888 * m_nFANCY_BLENDING ) + ( 14155776 * m_nRELIEF_MAPPING ) + ( 14155776 * m_nSEAMLESS ) + ( 28311552 * m_nOUTLINE ) + ( 28311552 * m_nSOFTEDGES ) + ( 28311552 * m_nBUMPMASK ) + ( 56623104 * m_nNORMAL_DECODE_MODE ) + ( 56623104 * m_nNORMALMASK_DECODE_MODE ) + ( 56623104 * m_nDETAIL_BLEND_MODE ) + ( 679477248 * m_nPARALLAXCORRECT ) + 0; + } +}; + +#define shaderStaticTest_lightmappedgeneric_ps30 psh_forgot_to_set_static_MASKEDBLENDING + psh_forgot_to_set_static_BASETEXTURE2 + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_BUMPMAP + psh_forgot_to_set_static_BUMPMAP2 + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_DIFFUSEBUMPMAP + psh_forgot_to_set_static_BASETEXTURENOENVMAP + psh_forgot_to_set_static_BASETEXTURE2NOENVMAP + psh_forgot_to_set_static_WARPLIGHTING + psh_forgot_to_set_static_FANCY_BLENDING + psh_forgot_to_set_static_RELIEF_MAPPING + psh_forgot_to_set_static_SEAMLESS + psh_forgot_to_set_static_OUTLINE + psh_forgot_to_set_static_SOFTEDGES + psh_forgot_to_set_static_BUMPMASK + psh_forgot_to_set_static_NORMAL_DECODE_MODE + psh_forgot_to_set_static_NORMALMASK_DECODE_MODE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_PARALLAXCORRECT + + +class lightmappedgeneric_ps30_Dynamic_Index +{ + unsigned int m_nFASTPATHENVMAPCONTRAST : 2; + unsigned int m_nFASTPATH : 2; + unsigned int m_nWRITEWATERFOGTODESTALPHA : 2; + unsigned int m_nPIXELFOGTYPE : 2; + unsigned int m_nLIGHTING_PREVIEW : 2; + unsigned int m_nWRITE_DEPTH_TO_DESTALPHA : 2; + unsigned int m_nBICUBIC_LIGHTMAP : 2; +#ifdef _DEBUG + bool m_bFASTPATHENVMAPCONTRAST : 1; + bool m_bFASTPATH : 1; + bool m_bWRITEWATERFOGTODESTALPHA : 1; + bool m_bPIXELFOGTYPE : 1; + bool m_bLIGHTING_PREVIEW : 1; + bool m_bWRITE_DEPTH_TO_DESTALPHA : 1; + bool m_bBICUBIC_LIGHTMAP : 1; +#endif // _DEBUG +public: + void SetFASTPATHENVMAPCONTRAST( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATHENVMAPCONTRAST = i; +#ifdef _DEBUG + m_bFASTPATHENVMAPCONTRAST = true; +#endif // _DEBUG + } + + void SetFASTPATH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATH = i; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif // _DEBUG + } + + void SetWRITEWATERFOGTODESTALPHA( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nWRITEWATERFOGTODESTALPHA = i; +#ifdef _DEBUG + m_bWRITEWATERFOGTODESTALPHA = true; +#endif // _DEBUG + } + + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif // _DEBUG + } + + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif // _DEBUG + } + + 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 // _DEBUG + } + + void SetBICUBIC_LIGHTMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBICUBIC_LIGHTMAP = i; +#ifdef _DEBUG + m_bBICUBIC_LIGHTMAP = true; +#endif // _DEBUG + } + + lightmappedgeneric_ps30_Dynamic_Index( ) + { + m_nFASTPATHENVMAPCONTRAST = 0; + m_nFASTPATH = 0; + m_nWRITEWATERFOGTODESTALPHA = 0; + m_nPIXELFOGTYPE = 0; + m_nLIGHTING_PREVIEW = 0; + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + m_nBICUBIC_LIGHTMAP = 0; +#ifdef _DEBUG + m_bFASTPATHENVMAPCONTRAST = false; + m_bFASTPATH = false; + m_bWRITEWATERFOGTODESTALPHA = false; + m_bPIXELFOGTYPE = false; + m_bLIGHTING_PREVIEW = false; + m_bWRITE_DEPTH_TO_DESTALPHA = false; + m_bBICUBIC_LIGHTMAP = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bFASTPATHENVMAPCONTRAST && m_bFASTPATH && m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bLIGHTING_PREVIEW && m_bWRITE_DEPTH_TO_DESTALPHA && m_bBICUBIC_LIGHTMAP ); + AssertMsg( !( !m_nFASTPATH && m_nFASTPATHENVMAPCONTRAST ), "Invalid combo combination ( !FASTPATH && FASTPATHENVMAPCONTRAST )" ); + AssertMsg( !( 1 && ( 1 && ( ( m_nPIXELFOGTYPE != 1 ) && m_nWRITEWATERFOGTODESTALPHA ) ) ), "Invalid combo combination ( 1 && ( 1 && ( ( PIXELFOGTYPE != 1 ) && WRITEWATERFOGTODESTALPHA ) ) )" ); + AssertMsg( !( 1 && ( 1 && ( m_nLIGHTING_PREVIEW && m_nFASTPATHENVMAPCONTRAST ) ) ), "Invalid combo combination ( 1 && ( 1 && ( LIGHTING_PREVIEW && FASTPATHENVMAPCONTRAST ) ) )" ); + AssertMsg( !( 1 && ( 1 && ( m_nLIGHTING_PREVIEW && m_nFASTPATH ) ) ), "Invalid combo combination ( 1 && ( 1 && ( LIGHTING_PREVIEW && FASTPATH ) ) )" ); + AssertMsg( !( 1 && ( 1 && ( ( m_nPIXELFOGTYPE != 1 ) && m_nWRITEWATERFOGTODESTALPHA ) ) ), "Invalid combo combination ( 1 && ( 1 && ( ( PIXELFOGTYPE != 1 ) && WRITEWATERFOGTODESTALPHA ) ) )" ); + AssertMsg( !( 1 && ( 1 && ( m_nLIGHTING_PREVIEW && m_nFASTPATHENVMAPCONTRAST ) ) ), "Invalid combo combination ( 1 && ( 1 && ( LIGHTING_PREVIEW && FASTPATHENVMAPCONTRAST ) ) )" ); + AssertMsg( !( 1 && ( 1 && ( m_nLIGHTING_PREVIEW && m_nFASTPATH ) ) ), "Invalid combo combination ( 1 && ( 1 && ( LIGHTING_PREVIEW && FASTPATH ) ) )" ); + return ( 1 * m_nFASTPATHENVMAPCONTRAST ) + ( 2 * m_nFASTPATH ) + ( 4 * m_nWRITEWATERFOGTODESTALPHA ) + ( 8 * m_nPIXELFOGTYPE ) + ( 24 * m_nLIGHTING_PREVIEW ) + ( 72 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 144 * m_nBICUBIC_LIGHTMAP ) + 0; + } +}; + +#define shaderDynamicTest_lightmappedgeneric_ps30 psh_forgot_to_set_dynamic_FASTPATHENVMAPCONTRAST + psh_forgot_to_set_dynamic_FASTPATH + psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_LIGHTING_PREVIEW + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_BICUBIC_LIGHTMAP + diff --git a/src/materialsystem/stdshaders/include/lightmappedgeneric_vs20.inc b/src/materialsystem/stdshaders/include/lightmappedgeneric_vs20.inc index 0cb09f33..00ade72e 100644 --- a/src/materialsystem/stdshaders/include/lightmappedgeneric_vs20.inc +++ b/src/materialsystem/stdshaders/include/lightmappedgeneric_vs20.inc @@ -1,4 +1,5 @@ // ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// $SEAMLESS && $BASETEXTURETRANSFORM2 // !$BUMPMAP && $DIFFUSEBUMPMAP // $SEAMLESS && $RELIEF_MAPPING // $BUMPMASK && $RELIEF_MAPPING @@ -18,6 +19,7 @@ class lightmappedgeneric_vs20_Static_Index unsigned int m_nRELIEF_MAPPING : 1; unsigned int m_nSEAMLESS : 2; unsigned int m_nBUMPMASK : 2; + unsigned int m_nBASETEXTURETRANSFORM2 : 2; #ifdef _DEBUG bool m_bENVMAP_MASK : 1; bool m_bTANGENTSPACE : 1; @@ -28,6 +30,7 @@ class lightmappedgeneric_vs20_Static_Index bool m_bRELIEF_MAPPING : 1; bool m_bSEAMLESS : 1; bool m_bBUMPMASK : 1; + bool m_bBASETEXTURETRANSFORM2 : 1; #endif // _DEBUG public: void SetENVMAP_MASK( int i ) @@ -111,6 +114,15 @@ public: #endif // _DEBUG } + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif // _DEBUG + } + lightmappedgeneric_vs20_Static_Index( ) { m_nENVMAP_MASK = 0; @@ -122,6 +134,7 @@ public: m_nRELIEF_MAPPING = 0; m_nSEAMLESS = 0; m_nBUMPMASK = 0; + m_nBASETEXTURETRANSFORM2 = 0; #ifdef _DEBUG m_bENVMAP_MASK = false; m_bTANGENTSPACE = false; @@ -132,21 +145,23 @@ public: m_bRELIEF_MAPPING = false; m_bSEAMLESS = false; m_bBUMPMASK = false; + m_bBASETEXTURETRANSFORM2 = false; #endif // _DEBUG } int GetIndex() const { - Assert( m_bENVMAP_MASK && m_bTANGENTSPACE && m_bBUMPMAP && m_bDIFFUSEBUMPMAP && m_bVERTEXCOLOR && m_bVERTEXALPHATEXBLENDFACTOR && m_bRELIEF_MAPPING && m_bSEAMLESS && m_bBUMPMASK ); + Assert( m_bENVMAP_MASK && m_bTANGENTSPACE && m_bBUMPMAP && m_bDIFFUSEBUMPMAP && m_bVERTEXCOLOR && m_bVERTEXALPHATEXBLENDFACTOR && m_bRELIEF_MAPPING && m_bSEAMLESS && m_bBUMPMASK && m_bBASETEXTURETRANSFORM2 ); + AssertMsg( !( m_nSEAMLESS && m_nBASETEXTURETRANSFORM2 ), "Invalid combo combination ( SEAMLESS && BASETEXTURETRANSFORM2 )" ); AssertMsg( !( !m_nBUMPMAP && m_nDIFFUSEBUMPMAP ), "Invalid combo combination ( !BUMPMAP && DIFFUSEBUMPMAP )" ); AssertMsg( !( m_nSEAMLESS && m_nRELIEF_MAPPING ), "Invalid combo combination ( SEAMLESS && RELIEF_MAPPING )" ); AssertMsg( !( m_nBUMPMASK && m_nRELIEF_MAPPING ), "Invalid combo combination ( BUMPMASK && RELIEF_MAPPING )" ); AssertMsg( !( m_nBUMPMASK && m_nSEAMLESS ), "Invalid combo combination ( BUMPMASK && SEAMLESS )" ); - return ( 8 * m_nENVMAP_MASK ) + ( 16 * m_nTANGENTSPACE ) + ( 32 * m_nBUMPMAP ) + ( 64 * m_nDIFFUSEBUMPMAP ) + ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nVERTEXALPHATEXBLENDFACTOR ) + ( 512 * m_nRELIEF_MAPPING ) + ( 512 * m_nSEAMLESS ) + ( 1024 * m_nBUMPMASK ) + 0; + return ( 8 * m_nENVMAP_MASK ) + ( 16 * m_nTANGENTSPACE ) + ( 32 * m_nBUMPMAP ) + ( 64 * m_nDIFFUSEBUMPMAP ) + ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nVERTEXALPHATEXBLENDFACTOR ) + ( 512 * m_nRELIEF_MAPPING ) + ( 512 * m_nSEAMLESS ) + ( 1024 * m_nBUMPMASK ) + ( 2048 * m_nBASETEXTURETRANSFORM2 ) + 0; } }; -#define shaderStaticTest_lightmappedgeneric_vs20 vsh_forgot_to_set_static_ENVMAP_MASK + vsh_forgot_to_set_static_TANGENTSPACE + vsh_forgot_to_set_static_BUMPMAP + vsh_forgot_to_set_static_DIFFUSEBUMPMAP + vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_VERTEXALPHATEXBLENDFACTOR + vsh_forgot_to_set_static_RELIEF_MAPPING + vsh_forgot_to_set_static_SEAMLESS + vsh_forgot_to_set_static_BUMPMASK +#define shaderStaticTest_lightmappedgeneric_vs20 vsh_forgot_to_set_static_ENVMAP_MASK + vsh_forgot_to_set_static_TANGENTSPACE + vsh_forgot_to_set_static_BUMPMAP + vsh_forgot_to_set_static_DIFFUSEBUMPMAP + vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_VERTEXALPHATEXBLENDFACTOR + vsh_forgot_to_set_static_RELIEF_MAPPING + vsh_forgot_to_set_static_SEAMLESS + vsh_forgot_to_set_static_BUMPMASK + vsh_forgot_to_set_static_BASETEXTURETRANSFORM2 class lightmappedgeneric_vs20_Dynamic_Index diff --git a/src/materialsystem/stdshaders/include/lightmappedgeneric_vs30.inc b/src/materialsystem/stdshaders/include/lightmappedgeneric_vs30.inc new file mode 100644 index 00000000..d7cd293b --- /dev/null +++ b/src/materialsystem/stdshaders/include/lightmappedgeneric_vs30.inc @@ -0,0 +1,226 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// $SEAMLESS && $BASETEXTURETRANSFORM2 +// !$BUMPMAP && $DIFFUSEBUMPMAP +// $SEAMLESS && $RELIEF_MAPPING +// $BUMPMASK && $RELIEF_MAPPING +// $BUMPMASK && $SEAMLESS +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once +#include "shaderlib/cshader.h" +class lightmappedgeneric_vs30_Static_Index +{ + unsigned int m_nENVMAP_MASK : 2; + unsigned int m_nTANGENTSPACE : 2; + unsigned int m_nBUMPMAP : 2; + unsigned int m_nDIFFUSEBUMPMAP : 2; + unsigned int m_nVERTEXCOLOR : 2; + unsigned int m_nVERTEXALPHATEXBLENDFACTOR : 2; + unsigned int m_nRELIEF_MAPPING : 1; + unsigned int m_nSEAMLESS : 2; + unsigned int m_nBUMPMASK : 2; + unsigned int m_nBASETEXTURETRANSFORM2 : 2; +#ifdef _DEBUG + bool m_bENVMAP_MASK : 1; + bool m_bTANGENTSPACE : 1; + bool m_bBUMPMAP : 1; + bool m_bDIFFUSEBUMPMAP : 1; + bool m_bVERTEXCOLOR : 1; + bool m_bVERTEXALPHATEXBLENDFACTOR : 1; + bool m_bRELIEF_MAPPING : 1; + bool m_bSEAMLESS : 1; + bool m_bBUMPMASK : 1; + bool m_bBASETEXTURETRANSFORM2 : 1; +#endif // _DEBUG +public: + void SetENVMAP_MASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAP_MASK = i; +#ifdef _DEBUG + m_bENVMAP_MASK = true; +#endif // _DEBUG + } + + void SetTANGENTSPACE( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nTANGENTSPACE = i; +#ifdef _DEBUG + m_bTANGENTSPACE = true; +#endif // _DEBUG + } + + void SetBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMAP = i; +#ifdef _DEBUG + m_bBUMPMAP = true; +#endif // _DEBUG + } + + void SetDIFFUSEBUMPMAP( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDIFFUSEBUMPMAP = i; +#ifdef _DEBUG + m_bDIFFUSEBUMPMAP = true; +#endif // _DEBUG + } + + void SetVERTEXCOLOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXCOLOR = i; +#ifdef _DEBUG + m_bVERTEXCOLOR = true; +#endif // _DEBUG + } + + void SetVERTEXALPHATEXBLENDFACTOR( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nVERTEXALPHATEXBLENDFACTOR = i; +#ifdef _DEBUG + m_bVERTEXALPHATEXBLENDFACTOR = true; +#endif // _DEBUG + } + + void SetRELIEF_MAPPING( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nRELIEF_MAPPING = i; +#ifdef _DEBUG + m_bRELIEF_MAPPING = true; +#endif // _DEBUG + } + + void SetSEAMLESS( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSEAMLESS = i; +#ifdef _DEBUG + m_bSEAMLESS = true; +#endif // _DEBUG + } + + void SetBUMPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBUMPMASK = i; +#ifdef _DEBUG + m_bBUMPMASK = true; +#endif // _DEBUG + } + + void SetBASETEXTURETRANSFORM2( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nBASETEXTURETRANSFORM2 = i; +#ifdef _DEBUG + m_bBASETEXTURETRANSFORM2 = true; +#endif // _DEBUG + } + + lightmappedgeneric_vs30_Static_Index( ) + { + m_nENVMAP_MASK = 0; + m_nTANGENTSPACE = 0; + m_nBUMPMAP = 0; + m_nDIFFUSEBUMPMAP = 0; + m_nVERTEXCOLOR = 0; + m_nVERTEXALPHATEXBLENDFACTOR = 0; + m_nRELIEF_MAPPING = 0; + m_nSEAMLESS = 0; + m_nBUMPMASK = 0; + m_nBASETEXTURETRANSFORM2 = 0; +#ifdef _DEBUG + m_bENVMAP_MASK = false; + m_bTANGENTSPACE = false; + m_bBUMPMAP = false; + m_bDIFFUSEBUMPMAP = false; + m_bVERTEXCOLOR = false; + m_bVERTEXALPHATEXBLENDFACTOR = false; + m_bRELIEF_MAPPING = false; + m_bSEAMLESS = false; + m_bBUMPMASK = false; + m_bBASETEXTURETRANSFORM2 = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bENVMAP_MASK && m_bTANGENTSPACE && m_bBUMPMAP && m_bDIFFUSEBUMPMAP && m_bVERTEXCOLOR && m_bVERTEXALPHATEXBLENDFACTOR && m_bRELIEF_MAPPING && m_bSEAMLESS && m_bBUMPMASK && m_bBASETEXTURETRANSFORM2 ); + AssertMsg( !( m_nSEAMLESS && m_nBASETEXTURETRANSFORM2 ), "Invalid combo combination ( SEAMLESS && BASETEXTURETRANSFORM2 )" ); + AssertMsg( !( !m_nBUMPMAP && m_nDIFFUSEBUMPMAP ), "Invalid combo combination ( !BUMPMAP && DIFFUSEBUMPMAP )" ); + AssertMsg( !( m_nSEAMLESS && m_nRELIEF_MAPPING ), "Invalid combo combination ( SEAMLESS && RELIEF_MAPPING )" ); + AssertMsg( !( m_nBUMPMASK && m_nRELIEF_MAPPING ), "Invalid combo combination ( BUMPMASK && RELIEF_MAPPING )" ); + AssertMsg( !( m_nBUMPMASK && m_nSEAMLESS ), "Invalid combo combination ( BUMPMASK && SEAMLESS )" ); + return ( 8 * m_nENVMAP_MASK ) + ( 16 * m_nTANGENTSPACE ) + ( 32 * m_nBUMPMAP ) + ( 64 * m_nDIFFUSEBUMPMAP ) + ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nVERTEXALPHATEXBLENDFACTOR ) + ( 512 * m_nRELIEF_MAPPING ) + ( 512 * m_nSEAMLESS ) + ( 1024 * m_nBUMPMASK ) + ( 2048 * m_nBASETEXTURETRANSFORM2 ) + 0; + } +}; + +#define shaderStaticTest_lightmappedgeneric_vs30 vsh_forgot_to_set_static_ENVMAP_MASK + vsh_forgot_to_set_static_TANGENTSPACE + vsh_forgot_to_set_static_BUMPMAP + vsh_forgot_to_set_static_DIFFUSEBUMPMAP + vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_VERTEXALPHATEXBLENDFACTOR + vsh_forgot_to_set_static_RELIEF_MAPPING + vsh_forgot_to_set_static_SEAMLESS + vsh_forgot_to_set_static_BUMPMASK + vsh_forgot_to_set_static_BASETEXTURETRANSFORM2 + + +class lightmappedgeneric_vs30_Dynamic_Index +{ + unsigned int m_nFASTPATH : 2; + unsigned int m_nDOWATERFOG : 2; + unsigned int m_nLIGHTING_PREVIEW : 2; +#ifdef _DEBUG + bool m_bFASTPATH : 1; + bool m_bDOWATERFOG : 1; + bool m_bLIGHTING_PREVIEW : 1; +#endif // _DEBUG +public: + void SetFASTPATH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nFASTPATH = i; +#ifdef _DEBUG + m_bFASTPATH = true; +#endif // _DEBUG + } + + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif // _DEBUG + } + + void SetLIGHTING_PREVIEW( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nLIGHTING_PREVIEW = i; +#ifdef _DEBUG + m_bLIGHTING_PREVIEW = true; +#endif // _DEBUG + } + + lightmappedgeneric_vs30_Dynamic_Index( ) + { + m_nFASTPATH = 0; + m_nDOWATERFOG = 0; + m_nLIGHTING_PREVIEW = 0; +#ifdef _DEBUG + m_bFASTPATH = false; + m_bDOWATERFOG = false; + m_bLIGHTING_PREVIEW = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bFASTPATH && m_bDOWATERFOG && m_bLIGHTING_PREVIEW ); + AssertMsg( !( 1 && ( 1 && ( m_nLIGHTING_PREVIEW && m_nFASTPATH ) ) ), "Invalid combo combination ( 1 && ( 1 && ( LIGHTING_PREVIEW && FASTPATH ) ) )" ); + return ( 1 * m_nFASTPATH ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nLIGHTING_PREVIEW ) + 0; + } +}; + +#define shaderDynamicTest_lightmappedgeneric_vs30 vsh_forgot_to_set_dynamic_FASTPATH + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_LIGHTING_PREVIEW + diff --git a/src/materialsystem/stdshaders/include/lightmappedreflective_ps20b.inc b/src/materialsystem/stdshaders/include/lightmappedreflective_ps20b.inc index defa755a..edf73cca 100644 --- a/src/materialsystem/stdshaders/include/lightmappedreflective_ps20b.inc +++ b/src/materialsystem/stdshaders/include/lightmappedreflective_ps20b.inc @@ -1,154 +1,103 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class lightmappedreflective_ps20b_Static_Index { -private: - int m_nCONVERT_TO_SRGB; + unsigned int m_nCONVERT_TO_SRGB : 2; + unsigned int m_nBASETEXTURE : 2; + unsigned int m_nREFLECT : 2; + unsigned int m_nREFRACT : 2; + unsigned int m_nENVMAPMASK : 2; #ifdef _DEBUG - bool m_bCONVERT_TO_SRGB; -#endif + bool m_bBASETEXTURE : 1; + bool m_bREFLECT : 1; + bool m_bREFRACT : 1; + bool m_bENVMAPMASK : 1; +#endif // _DEBUG 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 - } -private: - int m_nBASETEXTURE; -#ifdef _DEBUG - bool m_bBASETEXTURE; -#endif -public: + void SetBASETEXTURE( int i ) { Assert( i >= 0 && i <= 1 ); m_nBASETEXTURE = i; #ifdef _DEBUG m_bBASETEXTURE = true; -#endif +#endif // _DEBUG } - void SetBASETEXTURE( bool i ) - { - m_nBASETEXTURE = i ? 1 : 0; -#ifdef _DEBUG - m_bBASETEXTURE = true; -#endif - } -private: - int m_nREFLECT; -#ifdef _DEBUG - bool m_bREFLECT; -#endif -public: + void SetREFLECT( int i ) { Assert( i >= 0 && i <= 1 ); m_nREFLECT = i; #ifdef _DEBUG m_bREFLECT = true; -#endif +#endif // _DEBUG } - void SetREFLECT( bool i ) - { - m_nREFLECT = i ? 1 : 0; -#ifdef _DEBUG - m_bREFLECT = true; -#endif - } -private: - int m_nREFRACT; -#ifdef _DEBUG - bool m_bREFRACT; -#endif -public: + void SetREFRACT( int i ) { Assert( i >= 0 && i <= 1 ); m_nREFRACT = i; #ifdef _DEBUG m_bREFRACT = true; -#endif +#endif // _DEBUG } - void SetREFRACT( bool i ) - { - m_nREFRACT = i ? 1 : 0; -#ifdef _DEBUG - m_bREFRACT = true; -#endif - } -private: - int m_nENVMAPMASK; -#ifdef _DEBUG - bool m_bENVMAPMASK; -#endif -public: + void SetENVMAPMASK( int i ) { Assert( i >= 0 && i <= 1 ); m_nENVMAPMASK = i; #ifdef _DEBUG m_bENVMAPMASK = true; -#endif +#endif // _DEBUG } - void SetENVMAPMASK( bool i ) + + lightmappedreflective_ps20b_Static_Index( ) { - m_nENVMAPMASK = i ? 1 : 0; -#ifdef _DEBUG - m_bENVMAPMASK = true; -#endif - } -public: - lightmappedreflective_ps20b_Static_Index( ) - { -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif // _DEBUG - m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nBASETEXTURE = 0; + m_nREFLECT = 0; + m_nREFRACT = 0; + m_nENVMAPMASK = 0; #ifdef _DEBUG m_bBASETEXTURE = false; -#endif // _DEBUG - m_nBASETEXTURE = 0; -#ifdef _DEBUG m_bREFLECT = false; -#endif // _DEBUG - m_nREFLECT = 0; -#ifdef _DEBUG m_bREFRACT = false; -#endif // _DEBUG - m_nREFRACT = 0; -#ifdef _DEBUG m_bENVMAPMASK = false; -#endif // _DEBUG - m_nENVMAPMASK = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bBASETEXTURE && m_bREFLECT && m_bREFRACT && m_bENVMAPMASK; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bBASETEXTURE && m_bREFLECT && m_bREFRACT && m_bENVMAPMASK ); return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nBASETEXTURE ) + ( 16 * m_nREFLECT ) + ( 32 * m_nREFRACT ) + ( 64 * m_nENVMAPMASK ) + 0; } }; -#define shaderStaticTest_lightmappedreflective_ps20b psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_REFLECT + psh_forgot_to_set_static_REFRACT + psh_forgot_to_set_static_ENVMAPMASK + 0 + +#define shaderStaticTest_lightmappedreflective_ps20b psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_REFLECT + psh_forgot_to_set_static_REFRACT + psh_forgot_to_set_static_ENVMAPMASK + + class lightmappedreflective_ps20b_Dynamic_Index { -private: - int m_nPIXELFOGTYPE; + unsigned int m_nPIXELFOGTYPE : 2; + unsigned int m_nWRITE_DEPTH_TO_DESTALPHA : 2; #ifdef _DEBUG - bool m_bPIXELFOGTYPE; -#endif + bool m_bPIXELFOGTYPE : 1; + bool m_bWRITE_DEPTH_TO_DESTALPHA : 1; +#endif // _DEBUG public: void SetPIXELFOGTYPE( int i ) { @@ -156,57 +105,34 @@ public: m_nPIXELFOGTYPE = i; #ifdef _DEBUG m_bPIXELFOGTYPE = true; -#endif +#endif // _DEBUG } - void SetPIXELFOGTYPE( bool i ) - { - m_nPIXELFOGTYPE = i ? 1 : 0; -#ifdef _DEBUG - m_bPIXELFOGTYPE = 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 +#endif // _DEBUG } - void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) - { - m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; -#ifdef _DEBUG - m_bWRITE_DEPTH_TO_DESTALPHA = true; -#endif - } -public: - lightmappedreflective_ps20b_Dynamic_Index() + + lightmappedreflective_ps20b_Dynamic_Index( ) { + m_nPIXELFOGTYPE = 0; + m_nWRITE_DEPTH_TO_DESTALPHA = 0; #ifdef _DEBUG m_bPIXELFOGTYPE = false; -#endif // _DEBUG - m_nPIXELFOGTYPE = 0; -#ifdef _DEBUG m_bWRITE_DEPTH_TO_DESTALPHA = false; -#endif // _DEBUG - m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA ); return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; } }; -#define shaderDynamicTest_lightmappedreflective_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 + +#define shaderDynamicTest_lightmappedreflective_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + diff --git a/src/materialsystem/stdshaders/include/lightmappedreflective_vs20.inc b/src/materialsystem/stdshaders/include/lightmappedreflective_vs20.inc index 5e8df646..2fec2899 100644 --- a/src/materialsystem/stdshaders/include/lightmappedreflective_vs20.inc +++ b/src/materialsystem/stdshaders/include/lightmappedreflective_vs20.inc @@ -1,11 +1,14 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class lightmappedreflective_vs20_Static_Index { -private: - int m_nBASETEXTURE; + unsigned int m_nBASETEXTURE : 2; #ifdef _DEBUG - bool m_bBASETEXTURE; -#endif + bool m_bBASETEXTURE : 1; +#endif // _DEBUG public: void SetBASETEXTURE( int i ) { @@ -13,48 +16,39 @@ public: m_nBASETEXTURE = i; #ifdef _DEBUG m_bBASETEXTURE = true; -#endif +#endif // _DEBUG } - void SetBASETEXTURE( bool i ) - { - m_nBASETEXTURE = i ? 1 : 0; -#ifdef _DEBUG - m_bBASETEXTURE = true; -#endif - } -public: - lightmappedreflective_vs20_Static_Index( ) + + lightmappedreflective_vs20_Static_Index( ) { + m_nBASETEXTURE = 0; #ifdef _DEBUG m_bBASETEXTURE = false; -#endif // _DEBUG - m_nBASETEXTURE = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bBASETEXTURE; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bBASETEXTURE ); return ( 1 * m_nBASETEXTURE ) + 0; } }; -#define shaderStaticTest_lightmappedreflective_vs20 vsh_forgot_to_set_static_BASETEXTURE + 0 + +#define shaderStaticTest_lightmappedreflective_vs20 vsh_forgot_to_set_static_BASETEXTURE + + class lightmappedreflective_vs20_Dynamic_Index { public: - lightmappedreflective_vs20_Dynamic_Index() + lightmappedreflective_vs20_Dynamic_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_lightmappedreflective_vs20 0 + +#define shaderDynamicTest_lightmappedreflective_vs20 1 + diff --git a/src/materialsystem/stdshaders/include/monitorscreen_ps20b.inc b/src/materialsystem/stdshaders/include/monitorscreen_ps20b.inc index 04e589fc..024893ff 100644 --- a/src/materialsystem/stdshaders/include/monitorscreen_ps20b.inc +++ b/src/materialsystem/stdshaders/include/monitorscreen_ps20b.inc @@ -1,32 +1,27 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class monitorscreen_ps20b_Static_Index { -private: - int m_nCONVERT_TO_SRGB; + unsigned int m_nTEXTURE2 : 2; #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 - } -private: - int m_nTEXTURE2; -#ifdef _DEBUG - bool m_bTEXTURE2; -#endif + bool m_bTEXTURE2 : 1; +#endif // _DEBUG public: void SetTEXTURE2( int i ) { @@ -34,46 +29,35 @@ public: m_nTEXTURE2 = i; #ifdef _DEBUG m_bTEXTURE2 = true; -#endif +#endif // _DEBUG } - void SetTEXTURE2( bool i ) + + monitorscreen_ps20b_Static_Index( ) { - m_nTEXTURE2 = i ? 1 : 0; -#ifdef _DEBUG - m_bTEXTURE2 = true; -#endif - } -public: - monitorscreen_ps20b_Static_Index( ) - { -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif // _DEBUG - m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nTEXTURE2 = 0; #ifdef _DEBUG m_bTEXTURE2 = false; -#endif // _DEBUG - m_nTEXTURE2 = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bTEXTURE2; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG - return ( 4 * m_nCONVERT_TO_SRGB ) + ( 8 * m_nTEXTURE2 ) + 0; + Assert( m_bTEXTURE2 ); + return ( 4 * m_nTEXTURE2 ) + 0; } }; -#define shaderStaticTest_monitorscreen_ps20b psh_forgot_to_set_static_TEXTURE2 + 0 + +#define shaderStaticTest_monitorscreen_ps20b psh_forgot_to_set_static_TEXTURE2 + + class monitorscreen_ps20b_Dynamic_Index { -private: - int m_nPIXELFOGTYPE; + unsigned int m_nPIXELFOGTYPE : 2; + unsigned int m_nWRITE_DEPTH_TO_DESTALPHA : 2; #ifdef _DEBUG - bool m_bPIXELFOGTYPE; -#endif + bool m_bPIXELFOGTYPE : 1; + bool m_bWRITE_DEPTH_TO_DESTALPHA : 1; +#endif // _DEBUG public: void SetPIXELFOGTYPE( int i ) { @@ -81,57 +65,34 @@ public: m_nPIXELFOGTYPE = i; #ifdef _DEBUG m_bPIXELFOGTYPE = true; -#endif +#endif // _DEBUG } - void SetPIXELFOGTYPE( bool i ) - { - m_nPIXELFOGTYPE = i ? 1 : 0; -#ifdef _DEBUG - m_bPIXELFOGTYPE = 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 +#endif // _DEBUG } - void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) - { - m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; -#ifdef _DEBUG - m_bWRITE_DEPTH_TO_DESTALPHA = true; -#endif - } -public: - monitorscreen_ps20b_Dynamic_Index() + + monitorscreen_ps20b_Dynamic_Index( ) { + m_nPIXELFOGTYPE = 0; + m_nWRITE_DEPTH_TO_DESTALPHA = 0; #ifdef _DEBUG m_bPIXELFOGTYPE = false; -#endif // _DEBUG - m_nPIXELFOGTYPE = 0; -#ifdef _DEBUG m_bWRITE_DEPTH_TO_DESTALPHA = false; -#endif // _DEBUG - m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA ); return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; } }; -#define shaderDynamicTest_monitorscreen_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 + +#define shaderDynamicTest_monitorscreen_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + diff --git a/src/materialsystem/stdshaders/include/screenspaceeffect_vs20.inc b/src/materialsystem/stdshaders/include/screenspaceeffect_vs20.inc index 3ed87f49..dae5ccba 100644 --- a/src/materialsystem/stdshaders/include/screenspaceeffect_vs20.inc +++ b/src/materialsystem/stdshaders/include/screenspaceeffect_vs20.inc @@ -1,60 +1,44 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class screenspaceeffect_vs20_Static_Index { -private: - int m_nX360APPCHOOSER; -#ifdef _DEBUG - bool m_bX360APPCHOOSER; -#endif + unsigned int m_nX360APPCHOOSER : 2; public: void SetX360APPCHOOSER( int i ) { Assert( i >= 0 && i <= 1 ); m_nX360APPCHOOSER = i; -#ifdef _DEBUG - m_bX360APPCHOOSER = true; -#endif } - void SetX360APPCHOOSER( bool i ) + + screenspaceeffect_vs20_Static_Index( ) { - m_nX360APPCHOOSER = i ? 1 : 0; -#ifdef _DEBUG - m_bX360APPCHOOSER = true; -#endif + m_nX360APPCHOOSER = 0; } -public: - screenspaceeffect_vs20_Static_Index( ) + + int GetIndex() const { -#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_screenspaceeffect_vs20 0 + +#define shaderStaticTest_screenspaceeffect_vs20 1 + + class screenspaceeffect_vs20_Dynamic_Index { public: - screenspaceeffect_vs20_Dynamic_Index() + screenspaceeffect_vs20_Dynamic_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_screenspaceeffect_vs20 0 + +#define shaderDynamicTest_screenspaceeffect_vs20 1 + diff --git a/src/materialsystem/stdshaders/include/skin_ps20b.inc b/src/materialsystem/stdshaders/include/skin_ps20b.inc index 4a8df009..3a465dd0 100644 --- a/src/materialsystem/stdshaders/include/skin_ps20b.inc +++ b/src/materialsystem/stdshaders/include/skin_ps20b.inc @@ -7,6 +7,7 @@ // ( $FLASHLIGHT == 1 ) && ( $SELFILLUMFRESNEL == 1 ) // ( $FLASHLIGHT == 1 ) && ( $SELFILLUM == 1 ) // ( $BLENDTINTBYBASEALPHA ) && ( $SELFILLUM ) +// $ENVMAPMASK && !$CUBEMAP // $FASTPATH_NOBUMP && ( $RIMLIGHT || $DETAILTEXTURE || $PHONGWARPTEXTURE || $SELFILLUM || $BLENDTINTBYBASEALPHA ) // defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED // defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA @@ -41,6 +42,8 @@ class skin_ps20b_Static_Index unsigned int m_nFLASHLIGHTDEPTHFILTERMODE : 2; unsigned int m_nFASTPATH_NOBUMP : 2; unsigned int m_nBLENDTINTBYBASEALPHA : 2; + unsigned int m_nPHONG_HALFLAMBERT : 2; + unsigned int m_nENVMAPMASK : 2; #ifdef _DEBUG bool m_bCONVERT_TO_SRGB : 1; bool m_bCUBEMAP : 1; @@ -56,6 +59,8 @@ class skin_ps20b_Static_Index bool m_bFLASHLIGHTDEPTHFILTERMODE : 1; bool m_bFASTPATH_NOBUMP : 1; bool m_bBLENDTINTBYBASEALPHA : 1; + bool m_bPHONG_HALFLAMBERT : 1; + bool m_bENVMAPMASK : 1; #endif // _DEBUG public: void SetCONVERT_TO_SRGB( int i ) @@ -184,6 +189,24 @@ public: #endif // _DEBUG } + void SetPHONG_HALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG_HALFLAMBERT = i; +#ifdef _DEBUG + m_bPHONG_HALFLAMBERT = true; +#endif // _DEBUG + } + + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif // _DEBUG + } + skin_ps20b_Static_Index( ) { m_nCONVERT_TO_SRGB = 0; @@ -200,6 +223,8 @@ public: m_nFLASHLIGHTDEPTHFILTERMODE = 0; m_nFASTPATH_NOBUMP = 0; m_nBLENDTINTBYBASEALPHA = 0; + m_nPHONG_HALFLAMBERT = 0; + m_nENVMAPMASK = 0; #ifdef _DEBUG m_bCONVERT_TO_SRGB = false; m_bCUBEMAP = false; @@ -215,24 +240,27 @@ public: m_bFLASHLIGHTDEPTHFILTERMODE = false; m_bFASTPATH_NOBUMP = false; m_bBLENDTINTBYBASEALPHA = false; + m_bPHONG_HALFLAMBERT = false; + m_bENVMAPMASK = false; #endif // _DEBUG } int GetIndex() const { - Assert( m_bCONVERT_TO_SRGB && m_bCUBEMAP && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE && m_bPHONGWARPTEXTURE && m_bWRINKLEMAP && m_bDETAIL_BLEND_MODE && m_bDETAILTEXTURE && m_bRIMLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE && m_bFASTPATH_NOBUMP && m_bBLENDTINTBYBASEALPHA ); + Assert( m_bCONVERT_TO_SRGB && m_bCUBEMAP && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE && m_bPHONGWARPTEXTURE && m_bWRINKLEMAP && m_bDETAIL_BLEND_MODE && m_bDETAILTEXTURE && m_bRIMLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE && m_bFASTPATH_NOBUMP && m_bBLENDTINTBYBASEALPHA && m_bPHONG_HALFLAMBERT && m_bENVMAPMASK ); AssertMsg( !( !m_nDETAILTEXTURE && ( m_nDETAIL_BLEND_MODE != 0 ) ), "Invalid combo combination ( !DETAILTEXTURE && ( DETAIL_BLEND_MODE != 0 ) )" ); AssertMsg( !( ( m_nFLASHLIGHT == 0 ) && ( m_nFLASHLIGHTDEPTHFILTERMODE != 0 ) ), "Invalid combo combination ( ( FLASHLIGHT == 0 ) && ( FLASHLIGHTDEPTHFILTERMODE != 0 ) )" ); AssertMsg( !( ( m_nSELFILLUM == 0 ) && ( m_nSELFILLUMFRESNEL == 1 ) ), "Invalid combo combination ( ( SELFILLUM == 0 ) && ( SELFILLUMFRESNEL == 1 ) )" ); AssertMsg( !( ( m_nFLASHLIGHT == 1 ) && ( m_nSELFILLUMFRESNEL == 1 ) ), "Invalid combo combination ( ( FLASHLIGHT == 1 ) && ( SELFILLUMFRESNEL == 1 ) )" ); AssertMsg( !( ( m_nFLASHLIGHT == 1 ) && ( m_nSELFILLUM == 1 ) ), "Invalid combo combination ( ( FLASHLIGHT == 1 ) && ( SELFILLUM == 1 ) )" ); AssertMsg( !( m_nBLENDTINTBYBASEALPHA && m_nSELFILLUM ), "Invalid combo combination ( BLENDTINTBYBASEALPHA && SELFILLUM )" ); + AssertMsg( !( m_nENVMAPMASK && !m_nCUBEMAP ), "Invalid combo combination ( ENVMAPMASK && !CUBEMAP )" ); AssertMsg( !( m_nFASTPATH_NOBUMP && ( m_nRIMLIGHT || ( m_nDETAILTEXTURE || ( m_nPHONGWARPTEXTURE || ( m_nSELFILLUM || m_nBLENDTINTBYBASEALPHA ) ) ) ) ), "Invalid combo combination ( FASTPATH_NOBUMP && ( RIMLIGHT || ( DETAILTEXTURE || ( PHONGWARPTEXTURE || ( SELFILLUM || BLENDTINTBYBASEALPHA ) ) ) ) )" ); - return ( 240 * m_nCONVERT_TO_SRGB ) + ( 240 * m_nCUBEMAP ) + ( 480 * m_nSELFILLUM ) + ( 960 * m_nSELFILLUMFRESNEL ) + ( 1920 * m_nFLASHLIGHT ) + ( 3840 * m_nLIGHTWARPTEXTURE ) + ( 7680 * m_nPHONGWARPTEXTURE ) + ( 15360 * m_nWRINKLEMAP ) + ( 30720 * m_nDETAIL_BLEND_MODE ) + ( 215040 * m_nDETAILTEXTURE ) + ( 430080 * m_nRIMLIGHT ) + ( 860160 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 2580480 * m_nFASTPATH_NOBUMP ) + ( 5160960 * m_nBLENDTINTBYBASEALPHA ) + 0; + return ( 240 * m_nCONVERT_TO_SRGB ) + ( 240 * m_nCUBEMAP ) + ( 480 * m_nSELFILLUM ) + ( 960 * m_nSELFILLUMFRESNEL ) + ( 1920 * m_nFLASHLIGHT ) + ( 3840 * m_nLIGHTWARPTEXTURE ) + ( 7680 * m_nPHONGWARPTEXTURE ) + ( 15360 * m_nWRINKLEMAP ) + ( 30720 * m_nDETAIL_BLEND_MODE ) + ( 215040 * m_nDETAILTEXTURE ) + ( 430080 * m_nRIMLIGHT ) + ( 860160 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 2580480 * m_nFASTPATH_NOBUMP ) + ( 5160960 * m_nBLENDTINTBYBASEALPHA ) + ( 10321920 * m_nPHONG_HALFLAMBERT ) + ( 20643840 * m_nENVMAPMASK ) + 0; } }; -#define shaderStaticTest_skin_ps20b psh_forgot_to_set_static_CONVERT_TO_SRGB + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_PHONGWARPTEXTURE + psh_forgot_to_set_static_WRINKLEMAP + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_RIMLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_FASTPATH_NOBUMP + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA +#define shaderStaticTest_skin_ps20b psh_forgot_to_set_static_CONVERT_TO_SRGB + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_PHONGWARPTEXTURE + psh_forgot_to_set_static_WRINKLEMAP + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_RIMLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_FASTPATH_NOBUMP + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_PHONG_HALFLAMBERT + psh_forgot_to_set_static_ENVMAPMASK class skin_ps20b_Dynamic_Index diff --git a/src/materialsystem/stdshaders/include/skin_ps30.inc b/src/materialsystem/stdshaders/include/skin_ps30.inc index bb8e2858..2456e1ce 100644 --- a/src/materialsystem/stdshaders/include/skin_ps30.inc +++ b/src/materialsystem/stdshaders/include/skin_ps30.inc @@ -7,6 +7,7 @@ // ( $FLASHLIGHT == 1 ) && ( $SELFILLUMFRESNEL == 1 ) // ( $FLASHLIGHT == 1 ) && ( $SELFILLUM == 1 ) // ( $BLENDTINTBYBASEALPHA ) && ( $SELFILLUM ) +// $ENVMAPMASK && !$CUBEMAP // $FASTPATH_NOBUMP && ( $RIMLIGHT || $DETAILTEXTURE || $PHONGWARPTEXTURE || $SELFILLUM || $BLENDTINTBYBASEALPHA ) // defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED // defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA @@ -41,6 +42,8 @@ class skin_ps30_Static_Index unsigned int m_nFLASHLIGHTDEPTHFILTERMODE : 2; unsigned int m_nFASTPATH_NOBUMP : 2; unsigned int m_nBLENDTINTBYBASEALPHA : 2; + unsigned int m_nPHONG_HALFLAMBERT : 2; + unsigned int m_nENVMAPMASK : 2; #ifdef _DEBUG bool m_bCONVERT_TO_SRGB : 1; bool m_bCUBEMAP : 1; @@ -56,6 +59,8 @@ class skin_ps30_Static_Index bool m_bFLASHLIGHTDEPTHFILTERMODE : 1; bool m_bFASTPATH_NOBUMP : 1; bool m_bBLENDTINTBYBASEALPHA : 1; + bool m_bPHONG_HALFLAMBERT : 1; + bool m_bENVMAPMASK : 1; #endif // _DEBUG public: void SetCONVERT_TO_SRGB( int i ) @@ -184,6 +189,24 @@ public: #endif // _DEBUG } + void SetPHONG_HALFLAMBERT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPHONG_HALFLAMBERT = i; +#ifdef _DEBUG + m_bPHONG_HALFLAMBERT = true; +#endif // _DEBUG + } + + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif // _DEBUG + } + skin_ps30_Static_Index( ) { m_nCONVERT_TO_SRGB = 0; @@ -200,6 +223,8 @@ public: m_nFLASHLIGHTDEPTHFILTERMODE = 0; m_nFASTPATH_NOBUMP = 0; m_nBLENDTINTBYBASEALPHA = 0; + m_nPHONG_HALFLAMBERT = 0; + m_nENVMAPMASK = 0; #ifdef _DEBUG m_bCONVERT_TO_SRGB = false; m_bCUBEMAP = false; @@ -215,24 +240,27 @@ public: m_bFLASHLIGHTDEPTHFILTERMODE = false; m_bFASTPATH_NOBUMP = false; m_bBLENDTINTBYBASEALPHA = false; + m_bPHONG_HALFLAMBERT = false; + m_bENVMAPMASK = false; #endif // _DEBUG } int GetIndex() const { - Assert( m_bCONVERT_TO_SRGB && m_bCUBEMAP && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE && m_bPHONGWARPTEXTURE && m_bWRINKLEMAP && m_bDETAIL_BLEND_MODE && m_bDETAILTEXTURE && m_bRIMLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE && m_bFASTPATH_NOBUMP && m_bBLENDTINTBYBASEALPHA ); + Assert( m_bCONVERT_TO_SRGB && m_bCUBEMAP && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bFLASHLIGHT && m_bLIGHTWARPTEXTURE && m_bPHONGWARPTEXTURE && m_bWRINKLEMAP && m_bDETAIL_BLEND_MODE && m_bDETAILTEXTURE && m_bRIMLIGHT && m_bFLASHLIGHTDEPTHFILTERMODE && m_bFASTPATH_NOBUMP && m_bBLENDTINTBYBASEALPHA && m_bPHONG_HALFLAMBERT && m_bENVMAPMASK ); AssertMsg( !( !m_nDETAILTEXTURE && ( m_nDETAIL_BLEND_MODE != 0 ) ), "Invalid combo combination ( !DETAILTEXTURE && ( DETAIL_BLEND_MODE != 0 ) )" ); AssertMsg( !( ( m_nFLASHLIGHT == 0 ) && ( m_nFLASHLIGHTDEPTHFILTERMODE != 0 ) ), "Invalid combo combination ( ( FLASHLIGHT == 0 ) && ( FLASHLIGHTDEPTHFILTERMODE != 0 ) )" ); AssertMsg( !( ( m_nSELFILLUM == 0 ) && ( m_nSELFILLUMFRESNEL == 1 ) ), "Invalid combo combination ( ( SELFILLUM == 0 ) && ( SELFILLUMFRESNEL == 1 ) )" ); AssertMsg( !( ( m_nFLASHLIGHT == 1 ) && ( m_nSELFILLUMFRESNEL == 1 ) ), "Invalid combo combination ( ( FLASHLIGHT == 1 ) && ( SELFILLUMFRESNEL == 1 ) )" ); AssertMsg( !( ( m_nFLASHLIGHT == 1 ) && ( m_nSELFILLUM == 1 ) ), "Invalid combo combination ( ( FLASHLIGHT == 1 ) && ( SELFILLUM == 1 ) )" ); AssertMsg( !( m_nBLENDTINTBYBASEALPHA && m_nSELFILLUM ), "Invalid combo combination ( BLENDTINTBYBASEALPHA && SELFILLUM )" ); + AssertMsg( !( m_nENVMAPMASK && !m_nCUBEMAP ), "Invalid combo combination ( ENVMAPMASK && !CUBEMAP )" ); AssertMsg( !( m_nFASTPATH_NOBUMP && ( m_nRIMLIGHT || ( m_nDETAILTEXTURE || ( m_nPHONGWARPTEXTURE || ( m_nSELFILLUM || m_nBLENDTINTBYBASEALPHA ) ) ) ) ), "Invalid combo combination ( FASTPATH_NOBUMP && ( RIMLIGHT || ( DETAILTEXTURE || ( PHONGWARPTEXTURE || ( SELFILLUM || BLENDTINTBYBASEALPHA ) ) ) ) )" ); - return ( 240 * m_nCONVERT_TO_SRGB ) + ( 240 * m_nCUBEMAP ) + ( 480 * m_nSELFILLUM ) + ( 960 * m_nSELFILLUMFRESNEL ) + ( 1920 * m_nFLASHLIGHT ) + ( 3840 * m_nLIGHTWARPTEXTURE ) + ( 7680 * m_nPHONGWARPTEXTURE ) + ( 15360 * m_nWRINKLEMAP ) + ( 30720 * m_nDETAIL_BLEND_MODE ) + ( 215040 * m_nDETAILTEXTURE ) + ( 430080 * m_nRIMLIGHT ) + ( 860160 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 2580480 * m_nFASTPATH_NOBUMP ) + ( 5160960 * m_nBLENDTINTBYBASEALPHA ) + 0; + return ( 240 * m_nCONVERT_TO_SRGB ) + ( 240 * m_nCUBEMAP ) + ( 480 * m_nSELFILLUM ) + ( 960 * m_nSELFILLUMFRESNEL ) + ( 1920 * m_nFLASHLIGHT ) + ( 3840 * m_nLIGHTWARPTEXTURE ) + ( 7680 * m_nPHONGWARPTEXTURE ) + ( 15360 * m_nWRINKLEMAP ) + ( 30720 * m_nDETAIL_BLEND_MODE ) + ( 215040 * m_nDETAILTEXTURE ) + ( 430080 * m_nRIMLIGHT ) + ( 860160 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 2580480 * m_nFASTPATH_NOBUMP ) + ( 5160960 * m_nBLENDTINTBYBASEALPHA ) + ( 10321920 * m_nPHONG_HALFLAMBERT ) + ( 20643840 * m_nENVMAPMASK ) + 0; } }; -#define shaderStaticTest_skin_ps30 psh_forgot_to_set_static_CONVERT_TO_SRGB + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_PHONGWARPTEXTURE + psh_forgot_to_set_static_WRINKLEMAP + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_RIMLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_FASTPATH_NOBUMP + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA +#define shaderStaticTest_skin_ps30 psh_forgot_to_set_static_CONVERT_TO_SRGB + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_PHONGWARPTEXTURE + psh_forgot_to_set_static_WRINKLEMAP + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_RIMLIGHT + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_FASTPATH_NOBUMP + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_PHONG_HALFLAMBERT + psh_forgot_to_set_static_ENVMAPMASK class skin_ps30_Dynamic_Index diff --git a/src/materialsystem/stdshaders/include/splinerope_ps20.inc b/src/materialsystem/stdshaders/include/splinerope_ps20.inc new file mode 100644 index 00000000..8271beda --- /dev/null +++ b/src/materialsystem/stdshaders/include/splinerope_ps20.inc @@ -0,0 +1,137 @@ +#include "shaderlib/cshader.h" +class splinerope_ps20_Static_Index +{ +private: + int m_nSHADER_SRGB_READ; +#ifdef _DEBUG + bool m_bSHADER_SRGB_READ; +#endif +public: + void SetSHADER_SRGB_READ( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nSHADER_SRGB_READ = i; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } + void SetSHADER_SRGB_READ( bool i ) + { + m_nSHADER_SRGB_READ = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif + } +private: + int m_nSHADOWDEPTH; +#ifdef _DEBUG + bool m_bSHADOWDEPTH; +#endif +public: + void SetSHADOWDEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSHADOWDEPTH = i; +#ifdef _DEBUG + m_bSHADOWDEPTH = true; +#endif + } + void SetSHADOWDEPTH( bool i ) + { + m_nSHADOWDEPTH = i ? 1 : 0; +#ifdef _DEBUG + m_bSHADOWDEPTH = true; +#endif + } +public: + splinerope_ps20_Static_Index( ) + { +#ifdef _DEBUG + m_bSHADER_SRGB_READ = false; +#endif // _DEBUG + m_nSHADER_SRGB_READ = 0; +#ifdef _DEBUG + m_bSHADOWDEPTH = false; +#endif // _DEBUG + m_nSHADOWDEPTH = 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_bSHADER_SRGB_READ && m_bSHADOWDEPTH; + Assert( bAllStaticVarsDefined ); +#endif // _DEBUG + return ( 2 * m_nSHADER_SRGB_READ ) + ( 2 * m_nSHADOWDEPTH ) + 0; + } +}; +#define shaderStaticTest_splinerope_ps20 psh_forgot_to_set_static_SHADER_SRGB_READ + psh_forgot_to_set_static_SHADOWDEPTH + 0 +class splinerope_ps20_Dynamic_Index +{ +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 <= 0 ); + 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_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 + } +public: + splinerope_ps20_Dynamic_Index() + { +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; +#endif // _DEBUG + m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#ifdef _DEBUG + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + m_nPIXELFOGTYPE = 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_bWRITE_DEPTH_TO_DESTALPHA && m_bPIXELFOGTYPE; + Assert( bAllDynamicVarsDefined ); +#endif // _DEBUG + return ( 1 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 1 * m_nPIXELFOGTYPE ) + 0; + } +}; +#define shaderDynamicTest_splinerope_ps20 psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0 diff --git a/src/materialsystem/stdshaders/include/splinerope_ps20b.inc b/src/materialsystem/stdshaders/include/splinerope_ps20b.inc new file mode 100644 index 00000000..19022b1d --- /dev/null +++ b/src/materialsystem/stdshaders/include/splinerope_ps20b.inc @@ -0,0 +1,104 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once +#include "shaderlib/cshader.h" +class splinerope_ps20b_Static_Index +{ + unsigned int m_nSHADER_SRGB_READ : 1; + unsigned int m_nSHADOWDEPTH : 2; +#ifdef _DEBUG + bool m_bSHADER_SRGB_READ : 1; + bool m_bSHADOWDEPTH : 1; +#endif // _DEBUG +public: + void SetSHADER_SRGB_READ( int i ) + { + Assert( i >= 0 && i <= 0 ); + m_nSHADER_SRGB_READ = i; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = true; +#endif // _DEBUG + } + + void SetSHADOWDEPTH( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nSHADOWDEPTH = i; +#ifdef _DEBUG + m_bSHADOWDEPTH = true; +#endif // _DEBUG + } + + splinerope_ps20b_Static_Index( ) + { + m_nSHADER_SRGB_READ = 0; + m_nSHADOWDEPTH = 0; +#ifdef _DEBUG + m_bSHADER_SRGB_READ = false; + m_bSHADOWDEPTH = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bSHADER_SRGB_READ && m_bSHADOWDEPTH ); + return ( 6 * m_nSHADER_SRGB_READ ) + ( 6 * m_nSHADOWDEPTH ) + 0; + } +}; + +#define shaderStaticTest_splinerope_ps20b psh_forgot_to_set_static_SHADER_SRGB_READ + psh_forgot_to_set_static_SHADOWDEPTH + + +class splinerope_ps20b_Dynamic_Index +{ + unsigned int m_nWRITE_DEPTH_TO_DESTALPHA : 2; + unsigned int m_nPIXELFOGTYPE : 2; +#ifdef _DEBUG + bool m_bWRITE_DEPTH_TO_DESTALPHA : 1; + bool m_bPIXELFOGTYPE : 1; +#endif // _DEBUG +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 // _DEBUG + } + + void SetPIXELFOGTYPE( int i ) + { + Assert( i >= 0 && i <= 2 ); + m_nPIXELFOGTYPE = i; +#ifdef _DEBUG + m_bPIXELFOGTYPE = true; +#endif // _DEBUG + } + + splinerope_ps20b_Dynamic_Index( ) + { + m_nWRITE_DEPTH_TO_DESTALPHA = 0; + m_nPIXELFOGTYPE = 0; +#ifdef _DEBUG + m_bWRITE_DEPTH_TO_DESTALPHA = false; + m_bPIXELFOGTYPE = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bWRITE_DEPTH_TO_DESTALPHA && m_bPIXELFOGTYPE ); + return ( 1 * m_nWRITE_DEPTH_TO_DESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + 0; + } +}; + +#define shaderDynamicTest_splinerope_ps20b psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + diff --git a/src/materialsystem/stdshaders/include/splinerope_vs20.inc b/src/materialsystem/stdshaders/include/splinerope_vs20.inc new file mode 100644 index 00000000..9fdbf00d --- /dev/null +++ b/src/materialsystem/stdshaders/include/splinerope_vs20.inc @@ -0,0 +1,54 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once +#include "shaderlib/cshader.h" +class splinerope_vs20_Static_Index +{ +public: + splinerope_vs20_Static_Index( ) + { + } + + int GetIndex() const + { + return 0; + } +}; + +#define shaderStaticTest_splinerope_vs20 1 + + +class splinerope_vs20_Dynamic_Index +{ + unsigned int m_nDOWATERFOG : 2; +#ifdef _DEBUG + bool m_bDOWATERFOG : 1; +#endif // _DEBUG +public: + void SetDOWATERFOG( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nDOWATERFOG = i; +#ifdef _DEBUG + m_bDOWATERFOG = true; +#endif // _DEBUG + } + + splinerope_vs20_Dynamic_Index( ) + { + m_nDOWATERFOG = 0; +#ifdef _DEBUG + m_bDOWATERFOG = false; +#endif // _DEBUG + } + + int GetIndex() const + { + Assert( m_bDOWATERFOG ); + return ( 1 * m_nDOWATERFOG ) + 0; + } +}; + +#define shaderDynamicTest_splinerope_vs20 vsh_forgot_to_set_dynamic_DOWATERFOG + diff --git a/src/materialsystem/stdshaders/include/unlitgeneric_ps20b.inc b/src/materialsystem/stdshaders/include/unlitgeneric_ps20b.inc index 06d56ee5..2f30804e 100644 --- a/src/materialsystem/stdshaders/include/unlitgeneric_ps20b.inc +++ b/src/materialsystem/stdshaders/include/unlitgeneric_ps20b.inc @@ -1,60 +1,50 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class unlitgeneric_ps20b_Static_Index { -private: - int m_nCONVERT_TO_SRGB; -#ifdef _DEBUG - bool m_bCONVERT_TO_SRGB; -#endif + unsigned int m_nCONVERT_TO_SRGB : 2; 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 ) + + unlitgeneric_ps20b_Static_Index( ) { - m_nCONVERT_TO_SRGB = i ? 1 : 0; -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); } -public: - unlitgeneric_ps20b_Static_Index( ) + + int GetIndex() const { -#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_unlitgeneric_ps20b 0 + +#define shaderStaticTest_unlitgeneric_ps20b 1 + + class unlitgeneric_ps20b_Dynamic_Index { public: - unlitgeneric_ps20b_Dynamic_Index() + unlitgeneric_ps20b_Dynamic_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_unlitgeneric_ps20b 0 + +#define shaderDynamicTest_unlitgeneric_ps20b 1 + diff --git a/src/materialsystem/stdshaders/include/unlitgeneric_vs20.inc b/src/materialsystem/stdshaders/include/unlitgeneric_vs20.inc index 91115294..0d5e6f32 100644 --- a/src/materialsystem/stdshaders/include/unlitgeneric_vs20.inc +++ b/src/materialsystem/stdshaders/include/unlitgeneric_vs20.inc @@ -1,11 +1,14 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class unlitgeneric_vs20_Static_Index { -private: - int m_nVERTEXCOLOR; + unsigned int m_nVERTEXCOLOR : 2; #ifdef _DEBUG - bool m_bVERTEXCOLOR; -#endif + bool m_bVERTEXCOLOR : 1; +#endif // _DEBUG public: void SetVERTEXCOLOR( int i ) { @@ -13,42 +16,37 @@ public: m_nVERTEXCOLOR = i; #ifdef _DEBUG m_bVERTEXCOLOR = true; -#endif +#endif // _DEBUG } - void SetVERTEXCOLOR( bool i ) - { - m_nVERTEXCOLOR = i ? 1 : 0; -#ifdef _DEBUG - m_bVERTEXCOLOR = true; -#endif - } -public: - unlitgeneric_vs20_Static_Index( ) + + unlitgeneric_vs20_Static_Index( ) { + m_nVERTEXCOLOR = 0; #ifdef _DEBUG m_bVERTEXCOLOR = false; -#endif // _DEBUG - m_nVERTEXCOLOR = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bVERTEXCOLOR; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bVERTEXCOLOR ); return ( 8 * m_nVERTEXCOLOR ) + 0; } }; -#define shaderStaticTest_unlitgeneric_vs20 vsh_forgot_to_set_static_VERTEXCOLOR + 0 + +#define shaderStaticTest_unlitgeneric_vs20 vsh_forgot_to_set_static_VERTEXCOLOR + + class unlitgeneric_vs20_Dynamic_Index { -private: - int m_nCOMPRESSED_VERTS; + unsigned int m_nCOMPRESSED_VERTS : 2; + unsigned int m_nDOWATERFOG : 2; + unsigned int m_nSKINNING : 2; #ifdef _DEBUG - bool m_bCOMPRESSED_VERTS; -#endif + bool m_bCOMPRESSED_VERTS : 1; + bool m_bDOWATERFOG : 1; + bool m_bSKINNING : 1; +#endif // _DEBUG public: void SetCOMPRESSED_VERTS( int i ) { @@ -56,82 +54,45 @@ public: m_nCOMPRESSED_VERTS = i; #ifdef _DEBUG m_bCOMPRESSED_VERTS = true; -#endif +#endif // _DEBUG } - 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 +#endif // _DEBUG } - 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 +#endif // _DEBUG } - void SetSKINNING( bool i ) - { - m_nSKINNING = i ? 1 : 0; -#ifdef _DEBUG - m_bSKINNING = true; -#endif - } -public: - unlitgeneric_vs20_Dynamic_Index() + + unlitgeneric_vs20_Dynamic_Index( ) { + m_nCOMPRESSED_VERTS = 0; + m_nDOWATERFOG = 0; + m_nSKINNING = 0; #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; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING ); return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + 0; } }; -#define shaderDynamicTest_unlitgeneric_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + 0 + +#define shaderDynamicTest_unlitgeneric_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + diff --git a/src/materialsystem/stdshaders/include/unlittwotexture_ps20b.inc b/src/materialsystem/stdshaders/include/unlittwotexture_ps20b.inc index 4e40dcc3..46d3eddd 100644 --- a/src/materialsystem/stdshaders/include/unlittwotexture_ps20b.inc +++ b/src/materialsystem/stdshaders/include/unlittwotexture_ps20b.inc @@ -1,54 +1,63 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class unlittwotexture_ps20b_Static_Index { -private: - int m_nCONVERT_TO_SRGB; + unsigned int m_nTRANSLUCENT : 2; #ifdef _DEBUG - bool m_bCONVERT_TO_SRGB; -#endif + bool m_bTRANSLUCENT : 1; +#endif // _DEBUG public: - void SetCONVERT_TO_SRGB( int i ) + void SetTRANSLUCENT( int i ) { Assert( i >= 0 && i <= 1 ); - m_nCONVERT_TO_SRGB = i; + m_nTRANSLUCENT = i; #ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif + m_bTRANSLUCENT = true; +#endif // _DEBUG } - void SetCONVERT_TO_SRGB( bool i ) + + unlittwotexture_ps20b_Static_Index( ) { - m_nCONVERT_TO_SRGB = i ? 1 : 0; + m_nTRANSLUCENT = 0; #ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif + m_bTRANSLUCENT = false; +#endif // _DEBUG } -public: - unlittwotexture_ps20b_Static_Index( ) + + int GetIndex() const { -#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 ( 12 * m_nCONVERT_TO_SRGB ) + 0; + Assert( m_bTRANSLUCENT ); + return ( 4 * m_nTRANSLUCENT ) + 0; } }; -#define shaderStaticTest_unlittwotexture_ps20b 0 + +#define shaderStaticTest_unlittwotexture_ps20b psh_forgot_to_set_static_TRANSLUCENT + + class unlittwotexture_ps20b_Dynamic_Index { -private: - int m_nPIXELFOGTYPE; + unsigned int m_nPIXELFOGTYPE : 2; + unsigned int m_nWRITE_DEPTH_TO_DESTALPHA : 2; #ifdef _DEBUG - bool m_bPIXELFOGTYPE; -#endif + bool m_bPIXELFOGTYPE : 1; + bool m_bWRITE_DEPTH_TO_DESTALPHA : 1; +#endif // _DEBUG public: void SetPIXELFOGTYPE( int i ) { @@ -56,82 +65,34 @@ public: m_nPIXELFOGTYPE = i; #ifdef _DEBUG m_bPIXELFOGTYPE = true; -#endif +#endif // _DEBUG } - void SetPIXELFOGTYPE( bool i ) - { - m_nPIXELFOGTYPE = i ? 1 : 0; -#ifdef _DEBUG - m_bPIXELFOGTYPE = true; -#endif - } -private: - int m_nLIGHTING_PREVIEW; -#ifdef _DEBUG - bool m_bLIGHTING_PREVIEW; -#endif -public: - void SetLIGHTING_PREVIEW( int i ) - { - Assert( i >= 0 && i <= 2 ); - 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_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 +#endif // _DEBUG } - void SetWRITE_DEPTH_TO_DESTALPHA( bool i ) - { - m_nWRITE_DEPTH_TO_DESTALPHA = i ? 1 : 0; -#ifdef _DEBUG - m_bWRITE_DEPTH_TO_DESTALPHA = true; -#endif - } -public: - unlittwotexture_ps20b_Dynamic_Index() + + unlittwotexture_ps20b_Dynamic_Index( ) { + m_nPIXELFOGTYPE = 0; + m_nWRITE_DEPTH_TO_DESTALPHA = 0; #ifdef _DEBUG m_bPIXELFOGTYPE = false; -#endif // _DEBUG - m_nPIXELFOGTYPE = 0; -#ifdef _DEBUG - m_bLIGHTING_PREVIEW = false; -#endif // _DEBUG - m_nLIGHTING_PREVIEW = 0; -#ifdef _DEBUG m_bWRITE_DEPTH_TO_DESTALPHA = false; -#endif // _DEBUG - m_nWRITE_DEPTH_TO_DESTALPHA = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bPIXELFOGTYPE && m_bLIGHTING_PREVIEW && m_bWRITE_DEPTH_TO_DESTALPHA; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG - return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nLIGHTING_PREVIEW ) + ( 6 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; + Assert( m_bPIXELFOGTYPE && m_bWRITE_DEPTH_TO_DESTALPHA ); + return ( 1 * m_nPIXELFOGTYPE ) + ( 2 * m_nWRITE_DEPTH_TO_DESTALPHA ) + 0; } }; -#define shaderDynamicTest_unlittwotexture_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_LIGHTING_PREVIEW + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + 0 + +#define shaderDynamicTest_unlittwotexture_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WRITE_DEPTH_TO_DESTALPHA + diff --git a/src/materialsystem/stdshaders/include/unlittwotexture_vs20.inc b/src/materialsystem/stdshaders/include/unlittwotexture_vs20.inc index a0da0403..37582343 100644 --- a/src/materialsystem/stdshaders/include/unlittwotexture_vs20.inc +++ b/src/materialsystem/stdshaders/include/unlittwotexture_vs20.inc @@ -1,27 +1,34 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class unlittwotexture_vs20_Static_Index { public: - unlittwotexture_vs20_Static_Index( ) + unlittwotexture_vs20_Static_Index( ) { } - int GetIndex() + + int GetIndex() const { - // 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_unlittwotexture_vs20 0 + +#define shaderStaticTest_unlittwotexture_vs20 1 + + class unlittwotexture_vs20_Dynamic_Index { -private: - int m_nCOMPRESSED_VERTS; + unsigned int m_nCOMPRESSED_VERTS : 2; + unsigned int m_nDOWATERFOG : 2; + unsigned int m_nSKINNING : 2; #ifdef _DEBUG - bool m_bCOMPRESSED_VERTS; -#endif + bool m_bCOMPRESSED_VERTS : 1; + bool m_bDOWATERFOG : 1; + bool m_bSKINNING : 1; +#endif // _DEBUG public: void SetCOMPRESSED_VERTS( int i ) { @@ -29,82 +36,45 @@ public: m_nCOMPRESSED_VERTS = i; #ifdef _DEBUG m_bCOMPRESSED_VERTS = true; -#endif +#endif // _DEBUG } - 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 +#endif // _DEBUG } - 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 +#endif // _DEBUG } - void SetSKINNING( bool i ) - { - m_nSKINNING = i ? 1 : 0; -#ifdef _DEBUG - m_bSKINNING = true; -#endif - } -public: - unlittwotexture_vs20_Dynamic_Index() + + unlittwotexture_vs20_Dynamic_Index( ) { + m_nCOMPRESSED_VERTS = 0; + m_nDOWATERFOG = 0; + m_nSKINNING = 0; #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; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING ); return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + 0; } }; -#define shaderDynamicTest_unlittwotexture_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + 0 + +#define shaderDynamicTest_unlittwotexture_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + diff --git a/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_bump_ps20b.inc b/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_bump_ps20b.inc index aa99ddec..46bc2427 100644 --- a/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_bump_ps20b.inc +++ b/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_bump_ps20b.inc @@ -14,6 +14,8 @@ // ($BLENDTINTBYBASEALPHA) && ($SELFILLUM) // $FLASHLIGHT && $CUBEMAP // $NORMALMAPALPHAENVMAPMASK && !$CUBEMAP +// $NORMALMAPALPHAENVMAPMASK && $ENVMAPMASK +// $ENVMAPMASK && !$CUBEMAP // defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED // defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA // defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 @@ -45,6 +47,7 @@ class vertexlit_and_unlit_generic_bump_ps20b_Static_Index unsigned int m_nDETAIL_BLEND_MODE : 3; unsigned int m_nFLASHLIGHTDEPTHFILTERMODE : 2; unsigned int m_nBLENDTINTBYBASEALPHA : 2; + unsigned int m_nENVMAPMASK : 2; #ifdef _DEBUG bool m_bCUBEMAP : 1; bool m_bDIFFUSELIGHTING : 1; @@ -58,6 +61,7 @@ class vertexlit_and_unlit_generic_bump_ps20b_Static_Index bool m_bDETAIL_BLEND_MODE : 1; bool m_bFLASHLIGHTDEPTHFILTERMODE : 1; bool m_bBLENDTINTBYBASEALPHA : 1; + bool m_bENVMAPMASK : 1; #endif // _DEBUG public: void SetCUBEMAP( int i ) @@ -168,6 +172,15 @@ public: #endif // _DEBUG } + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif // _DEBUG + } + vertexlit_and_unlit_generic_bump_ps20b_Static_Index( ) { m_nCUBEMAP = 0; @@ -182,6 +195,7 @@ public: m_nDETAIL_BLEND_MODE = 0; m_nFLASHLIGHTDEPTHFILTERMODE = 0; m_nBLENDTINTBYBASEALPHA = 0; + m_nENVMAPMASK = 0; #ifdef _DEBUG m_bCUBEMAP = false; m_bDIFFUSELIGHTING = false; @@ -195,12 +209,13 @@ public: m_bDETAIL_BLEND_MODE = false; m_bFLASHLIGHTDEPTHFILTERMODE = false; m_bBLENDTINTBYBASEALPHA = false; + m_bENVMAPMASK = false; #endif // _DEBUG } int GetIndex() const { - Assert( m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bLIGHTWARPTEXTURE && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bNORMALMAPALPHAENVMAPMASK && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE && m_bBLENDTINTBYBASEALPHA ); + Assert( m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bLIGHTWARPTEXTURE && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bNORMALMAPALPHAENVMAPMASK && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE && m_bBLENDTINTBYBASEALPHA && m_bENVMAPMASK ); AssertMsg( !( ( m_nFLASHLIGHT == 0 ) && ( m_nFLASHLIGHTDEPTHFILTERMODE != 0 ) ), "Invalid combo combination ( ( FLASHLIGHT == 0 ) && ( FLASHLIGHTDEPTHFILTERMODE != 0 ) )" ); AssertMsg( !( !m_nDETAILTEXTURE && ( m_nDETAIL_BLEND_MODE != 0 ) ), "Invalid combo combination ( !DETAILTEXTURE && ( DETAIL_BLEND_MODE != 0 ) )" ); AssertMsg( !( ( m_nFLASHLIGHT == 1 ) && ( m_nLIGHTWARPTEXTURE == 1 ) ), "Invalid combo combination ( ( FLASHLIGHT == 1 ) && ( LIGHTWARPTEXTURE == 1 ) )" ); @@ -214,11 +229,13 @@ public: AssertMsg( !( m_nBLENDTINTBYBASEALPHA && m_nSELFILLUM ), "Invalid combo combination ( BLENDTINTBYBASEALPHA && SELFILLUM )" ); AssertMsg( !( m_nFLASHLIGHT && m_nCUBEMAP ), "Invalid combo combination ( FLASHLIGHT && CUBEMAP )" ); AssertMsg( !( m_nNORMALMAPALPHAENVMAPMASK && !m_nCUBEMAP ), "Invalid combo combination ( NORMALMAPALPHAENVMAPMASK && !CUBEMAP )" ); - return ( 60 * m_nCUBEMAP ) + ( 120 * m_nDIFFUSELIGHTING ) + ( 240 * m_nLIGHTWARPTEXTURE ) + ( 480 * m_nSELFILLUM ) + ( 960 * m_nSELFILLUMFRESNEL ) + ( 1920 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 3840 * m_nHALFLAMBERT ) + ( 7680 * m_nFLASHLIGHT ) + ( 15360 * m_nDETAILTEXTURE ) + ( 30720 * m_nDETAIL_BLEND_MODE ) + ( 215040 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 645120 * m_nBLENDTINTBYBASEALPHA ) + 0; + AssertMsg( !( m_nNORMALMAPALPHAENVMAPMASK && m_nENVMAPMASK ), "Invalid combo combination ( NORMALMAPALPHAENVMAPMASK && ENVMAPMASK )" ); + AssertMsg( !( m_nENVMAPMASK && !m_nCUBEMAP ), "Invalid combo combination ( ENVMAPMASK && !CUBEMAP )" ); + return ( 60 * m_nCUBEMAP ) + ( 120 * m_nDIFFUSELIGHTING ) + ( 240 * m_nLIGHTWARPTEXTURE ) + ( 480 * m_nSELFILLUM ) + ( 960 * m_nSELFILLUMFRESNEL ) + ( 1920 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 3840 * m_nHALFLAMBERT ) + ( 7680 * m_nFLASHLIGHT ) + ( 15360 * m_nDETAILTEXTURE ) + ( 30720 * m_nDETAIL_BLEND_MODE ) + ( 215040 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 645120 * m_nBLENDTINTBYBASEALPHA ) + ( 1290240 * m_nENVMAPMASK ) + 0; } }; -#define shaderStaticTest_vertexlit_and_unlit_generic_bump_ps20b psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_HALFLAMBERT + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA +#define shaderStaticTest_vertexlit_and_unlit_generic_bump_ps20b psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_HALFLAMBERT + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_ENVMAPMASK class vertexlit_and_unlit_generic_bump_ps20b_Dynamic_Index diff --git a/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_bump_ps30.inc b/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_bump_ps30.inc index 7af41e7b..9dbc053e 100644 --- a/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_bump_ps30.inc +++ b/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_bump_ps30.inc @@ -14,6 +14,8 @@ // ($BLENDTINTBYBASEALPHA) && ($SELFILLUM) // $FLASHLIGHT && $CUBEMAP // $NORMALMAPALPHAENVMAPMASK && !$CUBEMAP +// $NORMALMAPALPHAENVMAPMASK && $ENVMAPMASK +// $ENVMAPMASK && !$CUBEMAP // defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED // defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA // defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 @@ -45,6 +47,7 @@ class vertexlit_and_unlit_generic_bump_ps30_Static_Index unsigned int m_nDETAIL_BLEND_MODE : 3; unsigned int m_nFLASHLIGHTDEPTHFILTERMODE : 2; unsigned int m_nBLENDTINTBYBASEALPHA : 2; + unsigned int m_nENVMAPMASK : 2; #ifdef _DEBUG bool m_bCUBEMAP : 1; bool m_bDIFFUSELIGHTING : 1; @@ -58,6 +61,7 @@ class vertexlit_and_unlit_generic_bump_ps30_Static_Index bool m_bDETAIL_BLEND_MODE : 1; bool m_bFLASHLIGHTDEPTHFILTERMODE : 1; bool m_bBLENDTINTBYBASEALPHA : 1; + bool m_bENVMAPMASK : 1; #endif // _DEBUG public: void SetCUBEMAP( int i ) @@ -168,6 +172,15 @@ public: #endif // _DEBUG } + void SetENVMAPMASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nENVMAPMASK = i; +#ifdef _DEBUG + m_bENVMAPMASK = true; +#endif // _DEBUG + } + vertexlit_and_unlit_generic_bump_ps30_Static_Index( ) { m_nCUBEMAP = 0; @@ -182,6 +195,7 @@ public: m_nDETAIL_BLEND_MODE = 0; m_nFLASHLIGHTDEPTHFILTERMODE = 0; m_nBLENDTINTBYBASEALPHA = 0; + m_nENVMAPMASK = 0; #ifdef _DEBUG m_bCUBEMAP = false; m_bDIFFUSELIGHTING = false; @@ -195,12 +209,13 @@ public: m_bDETAIL_BLEND_MODE = false; m_bFLASHLIGHTDEPTHFILTERMODE = false; m_bBLENDTINTBYBASEALPHA = false; + m_bENVMAPMASK = false; #endif // _DEBUG } int GetIndex() const { - Assert( m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bLIGHTWARPTEXTURE && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bNORMALMAPALPHAENVMAPMASK && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE && m_bBLENDTINTBYBASEALPHA ); + Assert( m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bLIGHTWARPTEXTURE && m_bSELFILLUM && m_bSELFILLUMFRESNEL && m_bNORMALMAPALPHAENVMAPMASK && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bDETAILTEXTURE && m_bDETAIL_BLEND_MODE && m_bFLASHLIGHTDEPTHFILTERMODE && m_bBLENDTINTBYBASEALPHA && m_bENVMAPMASK ); AssertMsg( !( ( m_nFLASHLIGHT == 0 ) && ( m_nFLASHLIGHTDEPTHFILTERMODE != 0 ) ), "Invalid combo combination ( ( FLASHLIGHT == 0 ) && ( FLASHLIGHTDEPTHFILTERMODE != 0 ) )" ); AssertMsg( !( !m_nDETAILTEXTURE && ( m_nDETAIL_BLEND_MODE != 0 ) ), "Invalid combo combination ( !DETAILTEXTURE && ( DETAIL_BLEND_MODE != 0 ) )" ); AssertMsg( !( ( m_nFLASHLIGHT == 1 ) && ( m_nLIGHTWARPTEXTURE == 1 ) ), "Invalid combo combination ( ( FLASHLIGHT == 1 ) && ( LIGHTWARPTEXTURE == 1 ) )" ); @@ -214,11 +229,13 @@ public: AssertMsg( !( m_nBLENDTINTBYBASEALPHA && m_nSELFILLUM ), "Invalid combo combination ( BLENDTINTBYBASEALPHA && SELFILLUM )" ); AssertMsg( !( m_nFLASHLIGHT && m_nCUBEMAP ), "Invalid combo combination ( FLASHLIGHT && CUBEMAP )" ); AssertMsg( !( m_nNORMALMAPALPHAENVMAPMASK && !m_nCUBEMAP ), "Invalid combo combination ( NORMALMAPALPHAENVMAPMASK && !CUBEMAP )" ); - return ( 60 * m_nCUBEMAP ) + ( 120 * m_nDIFFUSELIGHTING ) + ( 240 * m_nLIGHTWARPTEXTURE ) + ( 480 * m_nSELFILLUM ) + ( 960 * m_nSELFILLUMFRESNEL ) + ( 1920 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 3840 * m_nHALFLAMBERT ) + ( 7680 * m_nFLASHLIGHT ) + ( 15360 * m_nDETAILTEXTURE ) + ( 30720 * m_nDETAIL_BLEND_MODE ) + ( 215040 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 645120 * m_nBLENDTINTBYBASEALPHA ) + 0; + AssertMsg( !( m_nNORMALMAPALPHAENVMAPMASK && m_nENVMAPMASK ), "Invalid combo combination ( NORMALMAPALPHAENVMAPMASK && ENVMAPMASK )" ); + AssertMsg( !( m_nENVMAPMASK && !m_nCUBEMAP ), "Invalid combo combination ( ENVMAPMASK && !CUBEMAP )" ); + return ( 60 * m_nCUBEMAP ) + ( 120 * m_nDIFFUSELIGHTING ) + ( 240 * m_nLIGHTWARPTEXTURE ) + ( 480 * m_nSELFILLUM ) + ( 960 * m_nSELFILLUMFRESNEL ) + ( 1920 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 3840 * m_nHALFLAMBERT ) + ( 7680 * m_nFLASHLIGHT ) + ( 15360 * m_nDETAILTEXTURE ) + ( 30720 * m_nDETAIL_BLEND_MODE ) + ( 215040 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 645120 * m_nBLENDTINTBYBASEALPHA ) + ( 1290240 * m_nENVMAPMASK ) + 0; } }; -#define shaderStaticTest_vertexlit_and_unlit_generic_bump_ps30 psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_HALFLAMBERT + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA +#define shaderStaticTest_vertexlit_and_unlit_generic_bump_ps30 psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_LIGHTWARPTEXTURE + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_SELFILLUMFRESNEL + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_HALFLAMBERT + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_ENVMAPMASK class vertexlit_and_unlit_generic_bump_ps30_Dynamic_Index diff --git a/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_ps20b.inc b/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_ps20b.inc index b1b6a8b9..cae88a01 100644 --- a/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_ps20b.inc +++ b/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_ps20b.inc @@ -10,9 +10,11 @@ // $BASEALPHAENVMAPMASK && ($SEAMLESS_BASE || $SEAMLESS_DETAIL) // ($DISTANCEALPHA == 0) && ($DISTANCEALPHAFROMDETAIL || $SOFT_MASK || $OUTLINE || $OUTER_GLOW) // ($DETAILTEXTURE == 0) && ($DISTANCEALPHAFROMDETAIL) +// ( $CUBEMAP == 0 ) && ( ( $ENVMAPFRESNEL == 1 ) || ( $BASEALPHAENVMAPMASK == 1 ) ) +// ( $CUBEMAP == 0 ) && ( $ENVMAPMASK == 1 ) && ( $SELFILLUM_ENVMAPMASK_ALPHA == 0 ) // ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) // ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) -// ($DISTANCEALPHA) && ($ENVMAPMASK || $BASEALPHAENVMAPMASK || $SELFILLUM || $SELFILLUM_ENVMAPMASK_ALPHA ) +// ($DISTANCEALPHA) && ($ENVMAPMASK || $BASEALPHAENVMAPMASK || $SELFILLUM || $SELFILLUM_ENVMAPMASK_ALPHA || $ENVMAPFRESNEL) // ($DISTANCEALPHA) && ($SEAMLESS_BASE || $SEAMLESS_DETAIL || $CUBEMAP || $LIGHTING_PREVIEW ) // ($DISTANCEALPHA) && ($WRITEWATERFOGTODESTALPHA || $FLASHLIGHT || $FLASHLIGHTSHADOWS || $SRGB_INPUT_ADAPTER ) // $SEAMLESS_BASE && $SRGB_INPUT_ADAPTER @@ -61,7 +63,6 @@ class vertexlit_and_unlit_generic_ps20b_Static_Index unsigned int m_nDEPTHBLEND : 2; unsigned int m_nBLENDTINTBYBASEALPHA : 2; unsigned int m_nSRGB_INPUT_ADAPTER : 2; - unsigned int m_nCUBEMAP_SPHERE_LEGACY : 2; #ifdef _DEBUG bool m_bDETAILTEXTURE : 1; bool m_bCUBEMAP : 1; @@ -84,7 +85,6 @@ class vertexlit_and_unlit_generic_ps20b_Static_Index bool m_bDEPTHBLEND : 1; bool m_bBLENDTINTBYBASEALPHA : 1; bool m_bSRGB_INPUT_ADAPTER : 1; - bool m_bCUBEMAP_SPHERE_LEGACY : 1; #endif // _DEBUG public: void SetDETAILTEXTURE( int i ) @@ -276,15 +276,6 @@ public: #endif // _DEBUG } - void SetCUBEMAP_SPHERE_LEGACY( int i ) - { - Assert( i >= 0 && i <= 1 ); - m_nCUBEMAP_SPHERE_LEGACY = i; -#ifdef _DEBUG - m_bCUBEMAP_SPHERE_LEGACY = true; -#endif // _DEBUG - } - vertexlit_and_unlit_generic_ps20b_Static_Index( ) { m_nDETAILTEXTURE = 0; @@ -308,7 +299,6 @@ public: m_nDEPTHBLEND = 0; m_nBLENDTINTBYBASEALPHA = 0; m_nSRGB_INPUT_ADAPTER = 0; - m_nCUBEMAP_SPHERE_LEGACY = 0; #ifdef _DEBUG m_bDETAILTEXTURE = false; m_bCUBEMAP = false; @@ -331,13 +321,12 @@ public: m_bDEPTHBLEND = false; m_bBLENDTINTBYBASEALPHA = false; m_bSRGB_INPUT_ADAPTER = false; - m_bCUBEMAP_SPHERE_LEGACY = false; #endif // _DEBUG } int GetIndex() const { - Assert( m_bDETAILTEXTURE && m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bVERTEXCOLOR && m_bFLASHLIGHT && m_bSELFILLUM_ENVMAPMASK_ALPHA && m_bDETAIL_BLEND_MODE && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bDISTANCEALPHA && m_bDISTANCEALPHAFROMDETAIL && m_bSOFT_MASK && m_bOUTLINE && m_bOUTER_GLOW && m_bFLASHLIGHTDEPTHFILTERMODE && m_bDEPTHBLEND && m_bBLENDTINTBYBASEALPHA && m_bSRGB_INPUT_ADAPTER && m_bCUBEMAP_SPHERE_LEGACY ); + Assert( m_bDETAILTEXTURE && m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bVERTEXCOLOR && m_bFLASHLIGHT && m_bSELFILLUM_ENVMAPMASK_ALPHA && m_bDETAIL_BLEND_MODE && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bDISTANCEALPHA && m_bDISTANCEALPHAFROMDETAIL && m_bSOFT_MASK && m_bOUTLINE && m_bOUTER_GLOW && m_bFLASHLIGHTDEPTHFILTERMODE && m_bDEPTHBLEND && m_bBLENDTINTBYBASEALPHA && m_bSRGB_INPUT_ADAPTER ); AssertMsg( !( ( m_nDETAILTEXTURE == 0 ) && ( m_nDETAIL_BLEND_MODE != 0 ) ), "Invalid combo combination ( ( DETAILTEXTURE == 0 ) && ( DETAIL_BLEND_MODE != 0 ) )" ); AssertMsg( !( ( m_nDETAILTEXTURE == 0 ) && m_nSEAMLESS_DETAIL ), "Invalid combo combination ( ( DETAILTEXTURE == 0 ) && SEAMLESS_DETAIL )" ); AssertMsg( !( ( m_nENVMAPMASK || m_nSELFILLUM_ENVMAPMASK_ALPHA ) && ( m_nSEAMLESS_BASE || m_nSEAMLESS_DETAIL ) ), "Invalid combo combination ( ( ENVMAPMASK || SELFILLUM_ENVMAPMASK_ALPHA ) && ( SEAMLESS_BASE || SEAMLESS_DETAIL ) )" ); @@ -348,18 +337,17 @@ public: AssertMsg( !( m_nBASEALPHAENVMAPMASK && ( m_nSEAMLESS_BASE || m_nSEAMLESS_DETAIL ) ), "Invalid combo combination ( BASEALPHAENVMAPMASK && ( SEAMLESS_BASE || SEAMLESS_DETAIL ) )" ); AssertMsg( !( ( m_nDISTANCEALPHA == 0 ) && ( m_nDISTANCEALPHAFROMDETAIL || ( m_nSOFT_MASK || ( m_nOUTLINE || m_nOUTER_GLOW ) ) ) ), "Invalid combo combination ( ( DISTANCEALPHA == 0 ) && ( DISTANCEALPHAFROMDETAIL || ( SOFT_MASK || ( OUTLINE || OUTER_GLOW ) ) ) )" ); AssertMsg( !( ( m_nDETAILTEXTURE == 0 ) && m_nDISTANCEALPHAFROMDETAIL ), "Invalid combo combination ( ( DETAILTEXTURE == 0 ) && DISTANCEALPHAFROMDETAIL )" ); + AssertMsg( !( ( m_nCUBEMAP == 0 ) && ( ( m_nENVMAPMASK == 1 ) && ( m_nSELFILLUM_ENVMAPMASK_ALPHA == 0 ) ) ), "Invalid combo combination ( ( CUBEMAP == 0 ) && ( ( ENVMAPMASK == 1 ) && ( SELFILLUM_ENVMAPMASK_ALPHA == 0 ) ) )" ); AssertMsg( !( ( m_nFLASHLIGHT == 0 ) && ( m_nFLASHLIGHTDEPTHFILTERMODE != 0 ) ), "Invalid combo combination ( ( FLASHLIGHT == 0 ) && ( FLASHLIGHTDEPTHFILTERMODE != 0 ) )" ); - AssertMsg( !( m_nDISTANCEALPHA && ( m_nENVMAPMASK || ( m_nBASEALPHAENVMAPMASK || ( m_nSELFILLUM || m_nSELFILLUM_ENVMAPMASK_ALPHA ) ) ) ), "Invalid combo combination ( DISTANCEALPHA && ( ENVMAPMASK || ( BASEALPHAENVMAPMASK || ( SELFILLUM || SELFILLUM_ENVMAPMASK_ALPHA ) ) ) )" ); AssertMsg( !( m_nSEAMLESS_BASE && m_nSRGB_INPUT_ADAPTER ), "Invalid combo combination ( SEAMLESS_BASE && SRGB_INPUT_ADAPTER )" ); AssertMsg( !( m_nSEAMLESS_BASE && m_nBLENDTINTBYBASEALPHA ), "Invalid combo combination ( SEAMLESS_BASE && BLENDTINTBYBASEALPHA )" ); AssertMsg( !( m_nBLENDTINTBYBASEALPHA && ( m_nSELFILLUM || ( ( m_nDISTANCEALPHA && ( m_nDISTANCEALPHAFROMDETAIL == 0 ) ) || m_nBASEALPHAENVMAPMASK ) ) ), "Invalid combo combination ( BLENDTINTBYBASEALPHA && ( SELFILLUM || ( ( DISTANCEALPHA && ( DISTANCEALPHAFROMDETAIL == 0 ) ) || BASEALPHAENVMAPMASK ) ) )" ); AssertMsg( !( m_nFLASHLIGHT && m_nCUBEMAP ), "Invalid combo combination ( FLASHLIGHT && CUBEMAP )" ); - AssertMsg( !( m_nCUBEMAP_SPHERE_LEGACY && ( m_nCUBEMAP == 0 ) ), "Invalid combo combination ( CUBEMAP_SPHERE_LEGACY && ( CUBEMAP == 0 ) )" ); - return ( 72 * m_nDETAILTEXTURE ) + ( 144 * m_nCUBEMAP ) + ( 288 * m_nDIFFUSELIGHTING ) + ( 576 * m_nENVMAPMASK ) + ( 1152 * m_nBASEALPHAENVMAPMASK ) + ( 2304 * m_nSELFILLUM ) + ( 4608 * m_nVERTEXCOLOR ) + ( 9216 * m_nFLASHLIGHT ) + ( 18432 * m_nSELFILLUM_ENVMAPMASK_ALPHA ) + ( 36864 * m_nDETAIL_BLEND_MODE ) + ( 368640 * m_nSEAMLESS_BASE ) + ( 737280 * m_nSEAMLESS_DETAIL ) + ( 1474560 * m_nDISTANCEALPHA ) + ( 2949120 * m_nDISTANCEALPHAFROMDETAIL ) + ( 5898240 * m_nSOFT_MASK ) + ( 11796480 * m_nOUTLINE ) + ( 23592960 * m_nOUTER_GLOW ) + ( 47185920 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 141557760 * m_nDEPTHBLEND ) + ( 283115520 * m_nBLENDTINTBYBASEALPHA ) + ( 566231040 * m_nSRGB_INPUT_ADAPTER ) + ( 1132462080 * m_nCUBEMAP_SPHERE_LEGACY ) + 0; + return ( 72 * m_nDETAILTEXTURE ) + ( 144 * m_nCUBEMAP ) + ( 288 * m_nDIFFUSELIGHTING ) + ( 576 * m_nENVMAPMASK ) + ( 1152 * m_nBASEALPHAENVMAPMASK ) + ( 2304 * m_nSELFILLUM ) + ( 4608 * m_nVERTEXCOLOR ) + ( 9216 * m_nFLASHLIGHT ) + ( 18432 * m_nSELFILLUM_ENVMAPMASK_ALPHA ) + ( 36864 * m_nDETAIL_BLEND_MODE ) + ( 368640 * m_nSEAMLESS_BASE ) + ( 737280 * m_nSEAMLESS_DETAIL ) + ( 1474560 * m_nDISTANCEALPHA ) + ( 2949120 * m_nDISTANCEALPHAFROMDETAIL ) + ( 5898240 * m_nSOFT_MASK ) + ( 11796480 * m_nOUTLINE ) + ( 23592960 * m_nOUTER_GLOW ) + ( 47185920 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 141557760 * m_nDEPTHBLEND ) + ( 283115520 * m_nBLENDTINTBYBASEALPHA ) + ( 566231040 * m_nSRGB_INPUT_ADAPTER ) + 0; } }; -#define shaderStaticTest_vertexlit_and_unlit_generic_ps20b psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SELFILLUM_ENVMAPMASK_ALPHA + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_SEAMLESS_BASE + psh_forgot_to_set_static_SEAMLESS_DETAIL + psh_forgot_to_set_static_DISTANCEALPHA + psh_forgot_to_set_static_DISTANCEALPHAFROMDETAIL + psh_forgot_to_set_static_SOFT_MASK + psh_forgot_to_set_static_OUTLINE + psh_forgot_to_set_static_OUTER_GLOW + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_DEPTHBLEND + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_SRGB_INPUT_ADAPTER + psh_forgot_to_set_static_CUBEMAP_SPHERE_LEGACY +#define shaderStaticTest_vertexlit_and_unlit_generic_ps20b psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SELFILLUM_ENVMAPMASK_ALPHA + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_SEAMLESS_BASE + psh_forgot_to_set_static_SEAMLESS_DETAIL + psh_forgot_to_set_static_DISTANCEALPHA + psh_forgot_to_set_static_DISTANCEALPHAFROMDETAIL + psh_forgot_to_set_static_SOFT_MASK + psh_forgot_to_set_static_OUTLINE + psh_forgot_to_set_static_OUTER_GLOW + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_DEPTHBLEND + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_SRGB_INPUT_ADAPTER class vertexlit_and_unlit_generic_ps20b_Dynamic_Index diff --git a/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_ps30.inc b/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_ps30.inc index ad2d3917..7a01cea1 100644 --- a/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_ps30.inc +++ b/src/materialsystem/stdshaders/include/vertexlit_and_unlit_generic_ps30.inc @@ -10,9 +10,11 @@ // $BASEALPHAENVMAPMASK && ($SEAMLESS_BASE || $SEAMLESS_DETAIL) // ($DISTANCEALPHA == 0) && ($DISTANCEALPHAFROMDETAIL || $SOFT_MASK || $OUTLINE || $OUTER_GLOW) // ($DETAILTEXTURE == 0) && ($DISTANCEALPHAFROMDETAIL) +// ( $CUBEMAP == 0 ) && ( ( $ENVMAPFRESNEL == 1 ) || ( $BASEALPHAENVMAPMASK == 1 ) ) +// ( $CUBEMAP == 0 ) && ( $ENVMAPMASK == 1 ) && ( $SELFILLUM_ENVMAPMASK_ALPHA == 0 ) // ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) // ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) -// ($DISTANCEALPHA) && ($ENVMAPMASK || $BASEALPHAENVMAPMASK || $SELFILLUM || $SELFILLUM_ENVMAPMASK_ALPHA ) +// ($DISTANCEALPHA) && ($ENVMAPMASK || $BASEALPHAENVMAPMASK || $SELFILLUM || $SELFILLUM_ENVMAPMASK_ALPHA || $ENVMAPFRESNEL) // ($DISTANCEALPHA) && ($SEAMLESS_BASE || $SEAMLESS_DETAIL || $CUBEMAP || $LIGHTING_PREVIEW ) // ($DISTANCEALPHA) && ($WRITEWATERFOGTODESTALPHA || $FLASHLIGHT || $FLASHLIGHTSHADOWS || $SRGB_INPUT_ADAPTER ) // $SEAMLESS_BASE && $SRGB_INPUT_ADAPTER @@ -60,7 +62,7 @@ class vertexlit_and_unlit_generic_ps30_Static_Index unsigned int m_nFLASHLIGHTDEPTHFILTERMODE : 2; unsigned int m_nDEPTHBLEND : 2; unsigned int m_nBLENDTINTBYBASEALPHA : 2; - unsigned int m_nCUBEMAP_SPHERE_LEGACY : 2; + unsigned int m_nENVMAPFRESNEL : 2; #ifdef _DEBUG bool m_bDETAILTEXTURE : 1; bool m_bCUBEMAP : 1; @@ -82,7 +84,7 @@ class vertexlit_and_unlit_generic_ps30_Static_Index bool m_bFLASHLIGHTDEPTHFILTERMODE : 1; bool m_bDEPTHBLEND : 1; bool m_bBLENDTINTBYBASEALPHA : 1; - bool m_bCUBEMAP_SPHERE_LEGACY : 1; + bool m_bENVMAPFRESNEL : 1; #endif // _DEBUG public: void SetDETAILTEXTURE( int i ) @@ -265,12 +267,12 @@ public: #endif // _DEBUG } - void SetCUBEMAP_SPHERE_LEGACY( int i ) + void SetENVMAPFRESNEL( int i ) { Assert( i >= 0 && i <= 1 ); - m_nCUBEMAP_SPHERE_LEGACY = i; + m_nENVMAPFRESNEL = i; #ifdef _DEBUG - m_bCUBEMAP_SPHERE_LEGACY = true; + m_bENVMAPFRESNEL = true; #endif // _DEBUG } @@ -296,7 +298,7 @@ public: m_nFLASHLIGHTDEPTHFILTERMODE = 0; m_nDEPTHBLEND = 0; m_nBLENDTINTBYBASEALPHA = 0; - m_nCUBEMAP_SPHERE_LEGACY = 0; + m_nENVMAPFRESNEL = 0; #ifdef _DEBUG m_bDETAILTEXTURE = false; m_bCUBEMAP = false; @@ -318,13 +320,13 @@ public: m_bFLASHLIGHTDEPTHFILTERMODE = false; m_bDEPTHBLEND = false; m_bBLENDTINTBYBASEALPHA = false; - m_bCUBEMAP_SPHERE_LEGACY = false; + m_bENVMAPFRESNEL = false; #endif // _DEBUG } int GetIndex() const { - Assert( m_bDETAILTEXTURE && m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bVERTEXCOLOR && m_bFLASHLIGHT && m_bSELFILLUM_ENVMAPMASK_ALPHA && m_bDETAIL_BLEND_MODE && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bDISTANCEALPHA && m_bDISTANCEALPHAFROMDETAIL && m_bSOFT_MASK && m_bOUTLINE && m_bOUTER_GLOW && m_bFLASHLIGHTDEPTHFILTERMODE && m_bDEPTHBLEND && m_bBLENDTINTBYBASEALPHA && m_bCUBEMAP_SPHERE_LEGACY ); + Assert( m_bDETAILTEXTURE && m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bENVMAPMASK && m_bBASEALPHAENVMAPMASK && m_bSELFILLUM && m_bVERTEXCOLOR && m_bFLASHLIGHT && m_bSELFILLUM_ENVMAPMASK_ALPHA && m_bDETAIL_BLEND_MODE && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bDISTANCEALPHA && m_bDISTANCEALPHAFROMDETAIL && m_bSOFT_MASK && m_bOUTLINE && m_bOUTER_GLOW && m_bFLASHLIGHTDEPTHFILTERMODE && m_bDEPTHBLEND && m_bBLENDTINTBYBASEALPHA && m_bENVMAPFRESNEL ); AssertMsg( !( ( m_nDETAILTEXTURE == 0 ) && ( m_nDETAIL_BLEND_MODE != 0 ) ), "Invalid combo combination ( ( DETAILTEXTURE == 0 ) && ( DETAIL_BLEND_MODE != 0 ) )" ); AssertMsg( !( ( m_nDETAILTEXTURE == 0 ) && m_nSEAMLESS_DETAIL ), "Invalid combo combination ( ( DETAILTEXTURE == 0 ) && SEAMLESS_DETAIL )" ); AssertMsg( !( ( m_nENVMAPMASK || m_nSELFILLUM_ENVMAPMASK_ALPHA ) && ( m_nSEAMLESS_BASE || m_nSEAMLESS_DETAIL ) ), "Invalid combo combination ( ( ENVMAPMASK || SELFILLUM_ENVMAPMASK_ALPHA ) && ( SEAMLESS_BASE || SEAMLESS_DETAIL ) )" ); @@ -335,17 +337,18 @@ public: AssertMsg( !( m_nBASEALPHAENVMAPMASK && ( m_nSEAMLESS_BASE || m_nSEAMLESS_DETAIL ) ), "Invalid combo combination ( BASEALPHAENVMAPMASK && ( SEAMLESS_BASE || SEAMLESS_DETAIL ) )" ); AssertMsg( !( ( m_nDISTANCEALPHA == 0 ) && ( m_nDISTANCEALPHAFROMDETAIL || ( m_nSOFT_MASK || ( m_nOUTLINE || m_nOUTER_GLOW ) ) ) ), "Invalid combo combination ( ( DISTANCEALPHA == 0 ) && ( DISTANCEALPHAFROMDETAIL || ( SOFT_MASK || ( OUTLINE || OUTER_GLOW ) ) ) )" ); AssertMsg( !( ( m_nDETAILTEXTURE == 0 ) && m_nDISTANCEALPHAFROMDETAIL ), "Invalid combo combination ( ( DETAILTEXTURE == 0 ) && DISTANCEALPHAFROMDETAIL )" ); + AssertMsg( !( ( m_nCUBEMAP == 0 ) && ( ( m_nENVMAPFRESNEL == 1 ) || ( m_nBASEALPHAENVMAPMASK == 1 ) ) ), "Invalid combo combination ( ( CUBEMAP == 0 ) && ( ( ENVMAPFRESNEL == 1 ) || ( BASEALPHAENVMAPMASK == 1 ) ) )" ); + AssertMsg( !( ( m_nCUBEMAP == 0 ) && ( ( m_nENVMAPMASK == 1 ) && ( m_nSELFILLUM_ENVMAPMASK_ALPHA == 0 ) ) ), "Invalid combo combination ( ( CUBEMAP == 0 ) && ( ( ENVMAPMASK == 1 ) && ( SELFILLUM_ENVMAPMASK_ALPHA == 0 ) ) )" ); AssertMsg( !( ( m_nFLASHLIGHT == 0 ) && ( m_nFLASHLIGHTDEPTHFILTERMODE != 0 ) ), "Invalid combo combination ( ( FLASHLIGHT == 0 ) && ( FLASHLIGHTDEPTHFILTERMODE != 0 ) )" ); - AssertMsg( !( m_nDISTANCEALPHA && ( m_nENVMAPMASK || ( m_nBASEALPHAENVMAPMASK || ( m_nSELFILLUM || m_nSELFILLUM_ENVMAPMASK_ALPHA ) ) ) ), "Invalid combo combination ( DISTANCEALPHA && ( ENVMAPMASK || ( BASEALPHAENVMAPMASK || ( SELFILLUM || SELFILLUM_ENVMAPMASK_ALPHA ) ) ) )" ); + AssertMsg( !( m_nDISTANCEALPHA && ( m_nENVMAPMASK || ( m_nBASEALPHAENVMAPMASK || ( m_nSELFILLUM || ( m_nSELFILLUM_ENVMAPMASK_ALPHA || m_nENVMAPFRESNEL ) ) ) ) ), "Invalid combo combination ( DISTANCEALPHA && ( ENVMAPMASK || ( BASEALPHAENVMAPMASK || ( SELFILLUM || ( SELFILLUM_ENVMAPMASK_ALPHA || ENVMAPFRESNEL ) ) ) ) )" ); AssertMsg( !( m_nSEAMLESS_BASE && m_nBLENDTINTBYBASEALPHA ), "Invalid combo combination ( SEAMLESS_BASE && BLENDTINTBYBASEALPHA )" ); AssertMsg( !( m_nBLENDTINTBYBASEALPHA && ( m_nSELFILLUM || ( ( m_nDISTANCEALPHA && ( m_nDISTANCEALPHAFROMDETAIL == 0 ) ) || m_nBASEALPHAENVMAPMASK ) ) ), "Invalid combo combination ( BLENDTINTBYBASEALPHA && ( SELFILLUM || ( ( DISTANCEALPHA && ( DISTANCEALPHAFROMDETAIL == 0 ) ) || BASEALPHAENVMAPMASK ) ) )" ); AssertMsg( !( m_nFLASHLIGHT && m_nCUBEMAP ), "Invalid combo combination ( FLASHLIGHT && CUBEMAP )" ); - AssertMsg( !( m_nCUBEMAP_SPHERE_LEGACY && ( m_nCUBEMAP == 0 ) ), "Invalid combo combination ( CUBEMAP_SPHERE_LEGACY && ( CUBEMAP == 0 ) )" ); - return ( 72 * m_nDETAILTEXTURE ) + ( 144 * m_nCUBEMAP ) + ( 288 * m_nDIFFUSELIGHTING ) + ( 576 * m_nENVMAPMASK ) + ( 1152 * m_nBASEALPHAENVMAPMASK ) + ( 2304 * m_nSELFILLUM ) + ( 4608 * m_nVERTEXCOLOR ) + ( 9216 * m_nFLASHLIGHT ) + ( 18432 * m_nSELFILLUM_ENVMAPMASK_ALPHA ) + ( 36864 * m_nDETAIL_BLEND_MODE ) + ( 368640 * m_nSEAMLESS_BASE ) + ( 737280 * m_nSEAMLESS_DETAIL ) + ( 1474560 * m_nDISTANCEALPHA ) + ( 2949120 * m_nDISTANCEALPHAFROMDETAIL ) + ( 5898240 * m_nSOFT_MASK ) + ( 11796480 * m_nOUTLINE ) + ( 23592960 * m_nOUTER_GLOW ) + ( 47185920 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 141557760 * m_nDEPTHBLEND ) + ( 283115520 * m_nBLENDTINTBYBASEALPHA ) + ( 566231040 * m_nCUBEMAP_SPHERE_LEGACY ) + 0; + return ( 72 * m_nDETAILTEXTURE ) + ( 144 * m_nCUBEMAP ) + ( 288 * m_nDIFFUSELIGHTING ) + ( 576 * m_nENVMAPMASK ) + ( 1152 * m_nBASEALPHAENVMAPMASK ) + ( 2304 * m_nSELFILLUM ) + ( 4608 * m_nVERTEXCOLOR ) + ( 9216 * m_nFLASHLIGHT ) + ( 18432 * m_nSELFILLUM_ENVMAPMASK_ALPHA ) + ( 36864 * m_nDETAIL_BLEND_MODE ) + ( 368640 * m_nSEAMLESS_BASE ) + ( 737280 * m_nSEAMLESS_DETAIL ) + ( 1474560 * m_nDISTANCEALPHA ) + ( 2949120 * m_nDISTANCEALPHAFROMDETAIL ) + ( 5898240 * m_nSOFT_MASK ) + ( 11796480 * m_nOUTLINE ) + ( 23592960 * m_nOUTER_GLOW ) + ( 47185920 * m_nFLASHLIGHTDEPTHFILTERMODE ) + ( 141557760 * m_nDEPTHBLEND ) + ( 283115520 * m_nBLENDTINTBYBASEALPHA ) + ( 566231040 * m_nENVMAPFRESNEL ) + 0; } }; -#define shaderStaticTest_vertexlit_and_unlit_generic_ps30 psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SELFILLUM_ENVMAPMASK_ALPHA + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_SEAMLESS_BASE + psh_forgot_to_set_static_SEAMLESS_DETAIL + psh_forgot_to_set_static_DISTANCEALPHA + psh_forgot_to_set_static_DISTANCEALPHAFROMDETAIL + psh_forgot_to_set_static_SOFT_MASK + psh_forgot_to_set_static_OUTLINE + psh_forgot_to_set_static_OUTER_GLOW + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_DEPTHBLEND + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_CUBEMAP_SPHERE_LEGACY +#define shaderStaticTest_vertexlit_and_unlit_generic_ps30 psh_forgot_to_set_static_DETAILTEXTURE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_ENVMAPMASK + psh_forgot_to_set_static_BASEALPHAENVMAPMASK + psh_forgot_to_set_static_SELFILLUM + psh_forgot_to_set_static_VERTEXCOLOR + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_SELFILLUM_ENVMAPMASK_ALPHA + psh_forgot_to_set_static_DETAIL_BLEND_MODE + psh_forgot_to_set_static_SEAMLESS_BASE + psh_forgot_to_set_static_SEAMLESS_DETAIL + psh_forgot_to_set_static_DISTANCEALPHA + psh_forgot_to_set_static_DISTANCEALPHAFROMDETAIL + psh_forgot_to_set_static_SOFT_MASK + psh_forgot_to_set_static_OUTLINE + psh_forgot_to_set_static_OUTER_GLOW + psh_forgot_to_set_static_FLASHLIGHTDEPTHFILTERMODE + psh_forgot_to_set_static_DEPTHBLEND + psh_forgot_to_set_static_BLENDTINTBYBASEALPHA + psh_forgot_to_set_static_ENVMAPFRESNEL class vertexlit_and_unlit_generic_ps30_Dynamic_Index diff --git a/src/materialsystem/stdshaders/include/vortwarp_ps20b.inc b/src/materialsystem/stdshaders/include/vortwarp_ps20b.inc index 1e79f667..12677e36 100644 --- a/src/materialsystem/stdshaders/include/vortwarp_ps20b.inc +++ b/src/materialsystem/stdshaders/include/vortwarp_ps20b.inc @@ -1,229 +1,156 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// ( $FLASHLIGHT != 0 ) && ( $NUM_LIGHTS > 0 ) +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class vortwarp_ps20b_Static_Index { -private: - int m_nCONVERT_TO_SRGB; + unsigned int m_nCONVERT_TO_SRGB : 2; + unsigned int m_nBASETEXTURE : 2; + unsigned int m_nCUBEMAP : 2; + unsigned int m_nDIFFUSELIGHTING : 2; + unsigned int m_nNORMALMAPALPHAENVMAPMASK : 2; + unsigned int m_nHALFLAMBERT : 2; + unsigned int m_nFLASHLIGHT : 2; + unsigned int m_nTRANSLUCENT : 2; #ifdef _DEBUG - bool m_bCONVERT_TO_SRGB; -#endif + bool m_bBASETEXTURE : 1; + bool m_bCUBEMAP : 1; + bool m_bDIFFUSELIGHTING : 1; + bool m_bNORMALMAPALPHAENVMAPMASK : 1; + bool m_bHALFLAMBERT : 1; + bool m_bFLASHLIGHT : 1; + bool m_bTRANSLUCENT : 1; +#endif // _DEBUG 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 - } -private: - int m_nBASETEXTURE; -#ifdef _DEBUG - bool m_bBASETEXTURE; -#endif -public: + void SetBASETEXTURE( int i ) { Assert( i >= 0 && i <= 1 ); m_nBASETEXTURE = i; #ifdef _DEBUG m_bBASETEXTURE = true; -#endif +#endif // _DEBUG } - void SetBASETEXTURE( bool i ) - { - m_nBASETEXTURE = i ? 1 : 0; -#ifdef _DEBUG - m_bBASETEXTURE = true; -#endif - } -private: - int m_nCUBEMAP; -#ifdef _DEBUG - bool m_bCUBEMAP; -#endif -public: + void SetCUBEMAP( int i ) { Assert( i >= 0 && i <= 1 ); m_nCUBEMAP = i; #ifdef _DEBUG m_bCUBEMAP = true; -#endif +#endif // _DEBUG } - void SetCUBEMAP( bool i ) - { - m_nCUBEMAP = i ? 1 : 0; -#ifdef _DEBUG - m_bCUBEMAP = true; -#endif - } -private: - int m_nDIFFUSELIGHTING; -#ifdef _DEBUG - bool m_bDIFFUSELIGHTING; -#endif -public: + void SetDIFFUSELIGHTING( int i ) { Assert( i >= 0 && i <= 1 ); m_nDIFFUSELIGHTING = i; #ifdef _DEBUG m_bDIFFUSELIGHTING = true; -#endif +#endif // _DEBUG } - void SetDIFFUSELIGHTING( bool i ) - { - m_nDIFFUSELIGHTING = i ? 1 : 0; -#ifdef _DEBUG - m_bDIFFUSELIGHTING = true; -#endif - } -private: - int m_nNORMALMAPALPHAENVMAPMASK; -#ifdef _DEBUG - bool m_bNORMALMAPALPHAENVMAPMASK; -#endif -public: + void SetNORMALMAPALPHAENVMAPMASK( int i ) { Assert( i >= 0 && i <= 1 ); m_nNORMALMAPALPHAENVMAPMASK = i; #ifdef _DEBUG m_bNORMALMAPALPHAENVMAPMASK = true; -#endif +#endif // _DEBUG } - void SetNORMALMAPALPHAENVMAPMASK( bool i ) - { - m_nNORMALMAPALPHAENVMAPMASK = i ? 1 : 0; -#ifdef _DEBUG - m_bNORMALMAPALPHAENVMAPMASK = true; -#endif - } -private: - int m_nHALFLAMBERT; -#ifdef _DEBUG - bool m_bHALFLAMBERT; -#endif -public: + void SetHALFLAMBERT( int i ) { Assert( i >= 0 && i <= 1 ); m_nHALFLAMBERT = i; #ifdef _DEBUG m_bHALFLAMBERT = true; -#endif +#endif // _DEBUG } - void SetHALFLAMBERT( bool i ) - { - m_nHALFLAMBERT = i ? 1 : 0; -#ifdef _DEBUG - m_bHALFLAMBERT = 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 +#endif // _DEBUG } - void SetFLASHLIGHT( bool i ) - { - m_nFLASHLIGHT = i ? 1 : 0; -#ifdef _DEBUG - m_bFLASHLIGHT = true; -#endif - } -private: - int m_nTRANSLUCENT; -#ifdef _DEBUG - bool m_bTRANSLUCENT; -#endif -public: + void SetTRANSLUCENT( int i ) { Assert( i >= 0 && i <= 1 ); m_nTRANSLUCENT = i; #ifdef _DEBUG m_bTRANSLUCENT = true; -#endif +#endif // _DEBUG } - void SetTRANSLUCENT( bool i ) + + vortwarp_ps20b_Static_Index( ) { - m_nTRANSLUCENT = i ? 1 : 0; -#ifdef _DEBUG - m_bTRANSLUCENT = true; -#endif - } -public: - vortwarp_ps20b_Static_Index( ) - { -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif // _DEBUG - m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nBASETEXTURE = 0; + m_nCUBEMAP = 0; + m_nDIFFUSELIGHTING = 0; + m_nNORMALMAPALPHAENVMAPMASK = 0; + m_nHALFLAMBERT = 0; + m_nFLASHLIGHT = 0; + m_nTRANSLUCENT = 0; #ifdef _DEBUG m_bBASETEXTURE = false; -#endif // _DEBUG - m_nBASETEXTURE = 0; -#ifdef _DEBUG m_bCUBEMAP = false; -#endif // _DEBUG - m_nCUBEMAP = 0; -#ifdef _DEBUG m_bDIFFUSELIGHTING = false; -#endif // _DEBUG - m_nDIFFUSELIGHTING = 0; -#ifdef _DEBUG m_bNORMALMAPALPHAENVMAPMASK = false; -#endif // _DEBUG - m_nNORMALMAPALPHAENVMAPMASK = 0; -#ifdef _DEBUG m_bHALFLAMBERT = false; -#endif // _DEBUG - m_nHALFLAMBERT = 0; -#ifdef _DEBUG m_bFLASHLIGHT = false; -#endif // _DEBUG - m_nFLASHLIGHT = 0; -#ifdef _DEBUG m_bTRANSLUCENT = false; -#endif // _DEBUG - m_nTRANSLUCENT = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bBASETEXTURE && m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bNORMALMAPALPHAENVMAPMASK && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bTRANSLUCENT; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bBASETEXTURE && m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bNORMALMAPALPHAENVMAPMASK && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bTRANSLUCENT ); return ( 80 * m_nCONVERT_TO_SRGB ) + ( 160 * m_nBASETEXTURE ) + ( 320 * m_nCUBEMAP ) + ( 640 * m_nDIFFUSELIGHTING ) + ( 1280 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 2560 * m_nHALFLAMBERT ) + ( 5120 * m_nFLASHLIGHT ) + ( 10240 * m_nTRANSLUCENT ) + 0; } }; -#define shaderStaticTest_vortwarp_ps20b psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_HALFLAMBERT + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_TRANSLUCENT + 0 + +#define shaderStaticTest_vortwarp_ps20b psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_HALFLAMBERT + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_TRANSLUCENT + + class vortwarp_ps20b_Dynamic_Index { -private: - int m_nWRITEWATERFOGTODESTALPHA; + unsigned int m_nWRITEWATERFOGTODESTALPHA : 2; + unsigned int m_nPIXELFOGTYPE : 2; + unsigned int m_nWARPINGIN : 2; + unsigned int m_nAMBIENT_LIGHT : 2; + unsigned int m_nNUM_LIGHTS : 3; #ifdef _DEBUG - bool m_bWRITEWATERFOGTODESTALPHA; -#endif + bool m_bWRITEWATERFOGTODESTALPHA : 1; + bool m_bPIXELFOGTYPE : 1; + bool m_bWARPINGIN : 1; + bool m_bAMBIENT_LIGHT : 1; + bool m_bNUM_LIGHTS : 1; +#endif // _DEBUG public: void SetWRITEWATERFOGTODESTALPHA( int i ) { @@ -231,132 +158,69 @@ public: m_nWRITEWATERFOGTODESTALPHA = i; #ifdef _DEBUG m_bWRITEWATERFOGTODESTALPHA = true; -#endif +#endif // _DEBUG } - 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 +#endif // _DEBUG } - void SetPIXELFOGTYPE( bool i ) - { - m_nPIXELFOGTYPE = i ? 1 : 0; -#ifdef _DEBUG - m_bPIXELFOGTYPE = true; -#endif - } -private: - int m_nWARPINGIN; -#ifdef _DEBUG - bool m_bWARPINGIN; -#endif -public: + void SetWARPINGIN( int i ) { Assert( i >= 0 && i <= 1 ); m_nWARPINGIN = i; #ifdef _DEBUG m_bWARPINGIN = true; -#endif +#endif // _DEBUG } - void SetWARPINGIN( bool i ) - { - m_nWARPINGIN = i ? 1 : 0; -#ifdef _DEBUG - m_bWARPINGIN = true; -#endif - } -private: - int m_nAMBIENT_LIGHT; -#ifdef _DEBUG - bool m_bAMBIENT_LIGHT; -#endif -public: + void SetAMBIENT_LIGHT( int i ) { Assert( i >= 0 && i <= 1 ); m_nAMBIENT_LIGHT = i; #ifdef _DEBUG m_bAMBIENT_LIGHT = true; -#endif +#endif // _DEBUG } - void SetAMBIENT_LIGHT( bool i ) - { - m_nAMBIENT_LIGHT = i ? 1 : 0; -#ifdef _DEBUG - m_bAMBIENT_LIGHT = 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 +#endif // _DEBUG } - void SetNUM_LIGHTS( bool i ) - { - m_nNUM_LIGHTS = i ? 1 : 0; -#ifdef _DEBUG - m_bNUM_LIGHTS = true; -#endif - } -public: - vortwarp_ps20b_Dynamic_Index() + + vortwarp_ps20b_Dynamic_Index( ) { + m_nWRITEWATERFOGTODESTALPHA = 0; + m_nPIXELFOGTYPE = 0; + m_nWARPINGIN = 0; + m_nAMBIENT_LIGHT = 0; + m_nNUM_LIGHTS = 0; #ifdef _DEBUG m_bWRITEWATERFOGTODESTALPHA = false; -#endif // _DEBUG - m_nWRITEWATERFOGTODESTALPHA = 0; -#ifdef _DEBUG m_bPIXELFOGTYPE = false; -#endif // _DEBUG - m_nPIXELFOGTYPE = 0; -#ifdef _DEBUG m_bWARPINGIN = false; -#endif // _DEBUG - m_nWARPINGIN = 0; -#ifdef _DEBUG m_bAMBIENT_LIGHT = false; -#endif // _DEBUG - m_nAMBIENT_LIGHT = 0; -#ifdef _DEBUG m_bNUM_LIGHTS = false; -#endif // _DEBUG - m_nNUM_LIGHTS = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bWARPINGIN && m_bAMBIENT_LIGHT && m_bNUM_LIGHTS; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bWARPINGIN && m_bAMBIENT_LIGHT && m_bNUM_LIGHTS ); + AssertMsg( !( 1 && ( 1 && ( ( m_nPIXELFOGTYPE != 1 ) && m_nWRITEWATERFOGTODESTALPHA ) ) ), "Invalid combo combination ( 1 && ( 1 && ( ( PIXELFOGTYPE != 1 ) && WRITEWATERFOGTODESTALPHA ) ) )" ); + AssertMsg( !( 1 && ( 1 && ( ( m_nPIXELFOGTYPE != 1 ) && m_nWRITEWATERFOGTODESTALPHA ) ) ), "Invalid combo combination ( 1 && ( 1 && ( ( PIXELFOGTYPE != 1 ) && WRITEWATERFOGTODESTALPHA ) ) )" ); return ( 1 * m_nWRITEWATERFOGTODESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + ( 4 * m_nWARPINGIN ) + ( 8 * m_nAMBIENT_LIGHT ) + ( 16 * m_nNUM_LIGHTS ) + 0; } }; -#define shaderDynamicTest_vortwarp_ps20b psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WARPINGIN + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_NUM_LIGHTS + 0 + +#define shaderDynamicTest_vortwarp_ps20b psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WARPINGIN + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_NUM_LIGHTS + diff --git a/src/materialsystem/stdshaders/include/vortwarp_ps30.inc b/src/materialsystem/stdshaders/include/vortwarp_ps30.inc index df00fc65..9bfccb2f 100644 --- a/src/materialsystem/stdshaders/include/vortwarp_ps30.inc +++ b/src/materialsystem/stdshaders/include/vortwarp_ps30.inc @@ -1,229 +1,156 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// ( $FLASHLIGHT != 0 ) && ( $NUM_LIGHTS > 0 ) +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW +// defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED +// defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA +// defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0 +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT +// defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH +// ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW + +#pragma once #include "shaderlib/cshader.h" class vortwarp_ps30_Static_Index { -private: - int m_nCONVERT_TO_SRGB; + unsigned int m_nCONVERT_TO_SRGB : 2; + unsigned int m_nBASETEXTURE : 2; + unsigned int m_nCUBEMAP : 2; + unsigned int m_nDIFFUSELIGHTING : 2; + unsigned int m_nNORMALMAPALPHAENVMAPMASK : 2; + unsigned int m_nHALFLAMBERT : 2; + unsigned int m_nFLASHLIGHT : 2; + unsigned int m_nTRANSLUCENT : 2; #ifdef _DEBUG - bool m_bCONVERT_TO_SRGB; -#endif + bool m_bBASETEXTURE : 1; + bool m_bCUBEMAP : 1; + bool m_bDIFFUSELIGHTING : 1; + bool m_bNORMALMAPALPHAENVMAPMASK : 1; + bool m_bHALFLAMBERT : 1; + bool m_bFLASHLIGHT : 1; + bool m_bTRANSLUCENT : 1; +#endif // _DEBUG 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 - } -private: - int m_nBASETEXTURE; -#ifdef _DEBUG - bool m_bBASETEXTURE; -#endif -public: + void SetBASETEXTURE( int i ) { Assert( i >= 0 && i <= 1 ); m_nBASETEXTURE = i; #ifdef _DEBUG m_bBASETEXTURE = true; -#endif +#endif // _DEBUG } - void SetBASETEXTURE( bool i ) - { - m_nBASETEXTURE = i ? 1 : 0; -#ifdef _DEBUG - m_bBASETEXTURE = true; -#endif - } -private: - int m_nCUBEMAP; -#ifdef _DEBUG - bool m_bCUBEMAP; -#endif -public: + void SetCUBEMAP( int i ) { Assert( i >= 0 && i <= 1 ); m_nCUBEMAP = i; #ifdef _DEBUG m_bCUBEMAP = true; -#endif +#endif // _DEBUG } - void SetCUBEMAP( bool i ) - { - m_nCUBEMAP = i ? 1 : 0; -#ifdef _DEBUG - m_bCUBEMAP = true; -#endif - } -private: - int m_nDIFFUSELIGHTING; -#ifdef _DEBUG - bool m_bDIFFUSELIGHTING; -#endif -public: + void SetDIFFUSELIGHTING( int i ) { Assert( i >= 0 && i <= 1 ); m_nDIFFUSELIGHTING = i; #ifdef _DEBUG m_bDIFFUSELIGHTING = true; -#endif +#endif // _DEBUG } - void SetDIFFUSELIGHTING( bool i ) - { - m_nDIFFUSELIGHTING = i ? 1 : 0; -#ifdef _DEBUG - m_bDIFFUSELIGHTING = true; -#endif - } -private: - int m_nNORMALMAPALPHAENVMAPMASK; -#ifdef _DEBUG - bool m_bNORMALMAPALPHAENVMAPMASK; -#endif -public: + void SetNORMALMAPALPHAENVMAPMASK( int i ) { Assert( i >= 0 && i <= 1 ); m_nNORMALMAPALPHAENVMAPMASK = i; #ifdef _DEBUG m_bNORMALMAPALPHAENVMAPMASK = true; -#endif +#endif // _DEBUG } - void SetNORMALMAPALPHAENVMAPMASK( bool i ) - { - m_nNORMALMAPALPHAENVMAPMASK = i ? 1 : 0; -#ifdef _DEBUG - m_bNORMALMAPALPHAENVMAPMASK = true; -#endif - } -private: - int m_nHALFLAMBERT; -#ifdef _DEBUG - bool m_bHALFLAMBERT; -#endif -public: + void SetHALFLAMBERT( int i ) { Assert( i >= 0 && i <= 1 ); m_nHALFLAMBERT = i; #ifdef _DEBUG m_bHALFLAMBERT = true; -#endif +#endif // _DEBUG } - void SetHALFLAMBERT( bool i ) - { - m_nHALFLAMBERT = i ? 1 : 0; -#ifdef _DEBUG - m_bHALFLAMBERT = 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 +#endif // _DEBUG } - void SetFLASHLIGHT( bool i ) - { - m_nFLASHLIGHT = i ? 1 : 0; -#ifdef _DEBUG - m_bFLASHLIGHT = true; -#endif - } -private: - int m_nTRANSLUCENT; -#ifdef _DEBUG - bool m_bTRANSLUCENT; -#endif -public: + void SetTRANSLUCENT( int i ) { Assert( i >= 0 && i <= 1 ); m_nTRANSLUCENT = i; #ifdef _DEBUG m_bTRANSLUCENT = true; -#endif +#endif // _DEBUG } - void SetTRANSLUCENT( bool i ) + + vortwarp_ps30_Static_Index( ) { - m_nTRANSLUCENT = i ? 1 : 0; -#ifdef _DEBUG - m_bTRANSLUCENT = true; -#endif - } -public: - vortwarp_ps30_Static_Index( ) - { -#ifdef _DEBUG - m_bCONVERT_TO_SRGB = true; -#endif // _DEBUG - m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); + m_nBASETEXTURE = 0; + m_nCUBEMAP = 0; + m_nDIFFUSELIGHTING = 0; + m_nNORMALMAPALPHAENVMAPMASK = 0; + m_nHALFLAMBERT = 0; + m_nFLASHLIGHT = 0; + m_nTRANSLUCENT = 0; #ifdef _DEBUG m_bBASETEXTURE = false; -#endif // _DEBUG - m_nBASETEXTURE = 0; -#ifdef _DEBUG m_bCUBEMAP = false; -#endif // _DEBUG - m_nCUBEMAP = 0; -#ifdef _DEBUG m_bDIFFUSELIGHTING = false; -#endif // _DEBUG - m_nDIFFUSELIGHTING = 0; -#ifdef _DEBUG m_bNORMALMAPALPHAENVMAPMASK = false; -#endif // _DEBUG - m_nNORMALMAPALPHAENVMAPMASK = 0; -#ifdef _DEBUG m_bHALFLAMBERT = false; -#endif // _DEBUG - m_nHALFLAMBERT = 0; -#ifdef _DEBUG m_bFLASHLIGHT = false; -#endif // _DEBUG - m_nFLASHLIGHT = 0; -#ifdef _DEBUG m_bTRANSLUCENT = false; -#endif // _DEBUG - m_nTRANSLUCENT = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bBASETEXTURE && m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bNORMALMAPALPHAENVMAPMASK && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bTRANSLUCENT; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bBASETEXTURE && m_bCUBEMAP && m_bDIFFUSELIGHTING && m_bNORMALMAPALPHAENVMAPMASK && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bTRANSLUCENT ); return ( 80 * m_nCONVERT_TO_SRGB ) + ( 160 * m_nBASETEXTURE ) + ( 320 * m_nCUBEMAP ) + ( 640 * m_nDIFFUSELIGHTING ) + ( 1280 * m_nNORMALMAPALPHAENVMAPMASK ) + ( 2560 * m_nHALFLAMBERT ) + ( 5120 * m_nFLASHLIGHT ) + ( 10240 * m_nTRANSLUCENT ) + 0; } }; -#define shaderStaticTest_vortwarp_ps30 psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_HALFLAMBERT + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_TRANSLUCENT + 0 + +#define shaderStaticTest_vortwarp_ps30 psh_forgot_to_set_static_BASETEXTURE + psh_forgot_to_set_static_CUBEMAP + psh_forgot_to_set_static_DIFFUSELIGHTING + psh_forgot_to_set_static_NORMALMAPALPHAENVMAPMASK + psh_forgot_to_set_static_HALFLAMBERT + psh_forgot_to_set_static_FLASHLIGHT + psh_forgot_to_set_static_TRANSLUCENT + + class vortwarp_ps30_Dynamic_Index { -private: - int m_nWRITEWATERFOGTODESTALPHA; + unsigned int m_nWRITEWATERFOGTODESTALPHA : 2; + unsigned int m_nPIXELFOGTYPE : 2; + unsigned int m_nWARPINGIN : 2; + unsigned int m_nAMBIENT_LIGHT : 2; + unsigned int m_nNUM_LIGHTS : 3; #ifdef _DEBUG - bool m_bWRITEWATERFOGTODESTALPHA; -#endif + bool m_bWRITEWATERFOGTODESTALPHA : 1; + bool m_bPIXELFOGTYPE : 1; + bool m_bWARPINGIN : 1; + bool m_bAMBIENT_LIGHT : 1; + bool m_bNUM_LIGHTS : 1; +#endif // _DEBUG public: void SetWRITEWATERFOGTODESTALPHA( int i ) { @@ -231,132 +158,69 @@ public: m_nWRITEWATERFOGTODESTALPHA = i; #ifdef _DEBUG m_bWRITEWATERFOGTODESTALPHA = true; -#endif +#endif // _DEBUG } - 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 +#endif // _DEBUG } - void SetPIXELFOGTYPE( bool i ) - { - m_nPIXELFOGTYPE = i ? 1 : 0; -#ifdef _DEBUG - m_bPIXELFOGTYPE = true; -#endif - } -private: - int m_nWARPINGIN; -#ifdef _DEBUG - bool m_bWARPINGIN; -#endif -public: + void SetWARPINGIN( int i ) { Assert( i >= 0 && i <= 1 ); m_nWARPINGIN = i; #ifdef _DEBUG m_bWARPINGIN = true; -#endif +#endif // _DEBUG } - void SetWARPINGIN( bool i ) - { - m_nWARPINGIN = i ? 1 : 0; -#ifdef _DEBUG - m_bWARPINGIN = true; -#endif - } -private: - int m_nAMBIENT_LIGHT; -#ifdef _DEBUG - bool m_bAMBIENT_LIGHT; -#endif -public: + void SetAMBIENT_LIGHT( int i ) { Assert( i >= 0 && i <= 1 ); m_nAMBIENT_LIGHT = i; #ifdef _DEBUG m_bAMBIENT_LIGHT = true; -#endif +#endif // _DEBUG } - void SetAMBIENT_LIGHT( bool i ) - { - m_nAMBIENT_LIGHT = i ? 1 : 0; -#ifdef _DEBUG - m_bAMBIENT_LIGHT = 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 +#endif // _DEBUG } - void SetNUM_LIGHTS( bool i ) - { - m_nNUM_LIGHTS = i ? 1 : 0; -#ifdef _DEBUG - m_bNUM_LIGHTS = true; -#endif - } -public: - vortwarp_ps30_Dynamic_Index() + + vortwarp_ps30_Dynamic_Index( ) { + m_nWRITEWATERFOGTODESTALPHA = 0; + m_nPIXELFOGTYPE = 0; + m_nWARPINGIN = 0; + m_nAMBIENT_LIGHT = 0; + m_nNUM_LIGHTS = 0; #ifdef _DEBUG m_bWRITEWATERFOGTODESTALPHA = false; -#endif // _DEBUG - m_nWRITEWATERFOGTODESTALPHA = 0; -#ifdef _DEBUG m_bPIXELFOGTYPE = false; -#endif // _DEBUG - m_nPIXELFOGTYPE = 0; -#ifdef _DEBUG m_bWARPINGIN = false; -#endif // _DEBUG - m_nWARPINGIN = 0; -#ifdef _DEBUG m_bAMBIENT_LIGHT = false; -#endif // _DEBUG - m_nAMBIENT_LIGHT = 0; -#ifdef _DEBUG m_bNUM_LIGHTS = false; -#endif // _DEBUG - m_nNUM_LIGHTS = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bWARPINGIN && m_bAMBIENT_LIGHT && m_bNUM_LIGHTS; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bWRITEWATERFOGTODESTALPHA && m_bPIXELFOGTYPE && m_bWARPINGIN && m_bAMBIENT_LIGHT && m_bNUM_LIGHTS ); + AssertMsg( !( 1 && ( 1 && ( ( m_nPIXELFOGTYPE != 1 ) && m_nWRITEWATERFOGTODESTALPHA ) ) ), "Invalid combo combination ( 1 && ( 1 && ( ( PIXELFOGTYPE != 1 ) && WRITEWATERFOGTODESTALPHA ) ) )" ); + AssertMsg( !( 1 && ( 1 && ( ( m_nPIXELFOGTYPE != 1 ) && m_nWRITEWATERFOGTODESTALPHA ) ) ), "Invalid combo combination ( 1 && ( 1 && ( ( PIXELFOGTYPE != 1 ) && WRITEWATERFOGTODESTALPHA ) ) )" ); return ( 1 * m_nWRITEWATERFOGTODESTALPHA ) + ( 2 * m_nPIXELFOGTYPE ) + ( 4 * m_nWARPINGIN ) + ( 8 * m_nAMBIENT_LIGHT ) + ( 16 * m_nNUM_LIGHTS ) + 0; } }; -#define shaderDynamicTest_vortwarp_ps30 psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WARPINGIN + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_NUM_LIGHTS + 0 + +#define shaderDynamicTest_vortwarp_ps30 psh_forgot_to_set_dynamic_WRITEWATERFOGTODESTALPHA + psh_forgot_to_set_dynamic_PIXELFOGTYPE + psh_forgot_to_set_dynamic_WARPINGIN + psh_forgot_to_set_dynamic_AMBIENT_LIGHT + psh_forgot_to_set_dynamic_NUM_LIGHTS + diff --git a/src/materialsystem/stdshaders/include/vortwarp_vs20.inc b/src/materialsystem/stdshaders/include/vortwarp_vs20.inc index 1c45cab0..ae6ac643 100644 --- a/src/materialsystem/stdshaders/include/vortwarp_vs20.inc +++ b/src/materialsystem/stdshaders/include/vortwarp_vs20.inc @@ -1,11 +1,18 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// $USE_STATIC_CONTROL_FLOW && ( $NUM_LIGHTS > 0 ) +// $DOWATERFOG +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class vortwarp_vs20_Static_Index { -private: - int m_nHALFLAMBERT; + unsigned int m_nHALFLAMBERT : 2; + unsigned int m_nUSE_STATIC_CONTROL_FLOW : 2; #ifdef _DEBUG - bool m_bHALFLAMBERT; -#endif + bool m_bHALFLAMBERT : 1; + bool m_bUSE_STATIC_CONTROL_FLOW : 1; +#endif // _DEBUG public: void SetHALFLAMBERT( int i ) { @@ -13,67 +20,50 @@ public: m_nHALFLAMBERT = i; #ifdef _DEBUG m_bHALFLAMBERT = true; -#endif +#endif // _DEBUG } - void SetHALFLAMBERT( bool i ) - { - m_nHALFLAMBERT = i ? 1 : 0; -#ifdef _DEBUG - m_bHALFLAMBERT = true; -#endif - } -private: - int m_nUSE_STATIC_CONTROL_FLOW; -#ifdef _DEBUG - bool m_bUSE_STATIC_CONTROL_FLOW; -#endif -public: + void SetUSE_STATIC_CONTROL_FLOW( int i ) { Assert( i >= 0 && i <= 1 ); m_nUSE_STATIC_CONTROL_FLOW = i; #ifdef _DEBUG m_bUSE_STATIC_CONTROL_FLOW = true; -#endif +#endif // _DEBUG } - void SetUSE_STATIC_CONTROL_FLOW( bool i ) - { - m_nUSE_STATIC_CONTROL_FLOW = i ? 1 : 0; -#ifdef _DEBUG - m_bUSE_STATIC_CONTROL_FLOW = true; -#endif - } -public: - vortwarp_vs20_Static_Index( ) + + vortwarp_vs20_Static_Index( ) { + m_nHALFLAMBERT = 0; + m_nUSE_STATIC_CONTROL_FLOW = 0; #ifdef _DEBUG m_bHALFLAMBERT = false; -#endif // _DEBUG - m_nHALFLAMBERT = 0; -#ifdef _DEBUG m_bUSE_STATIC_CONTROL_FLOW = false; -#endif // _DEBUG - m_nUSE_STATIC_CONTROL_FLOW = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bHALFLAMBERT && m_bUSE_STATIC_CONTROL_FLOW; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bHALFLAMBERT && m_bUSE_STATIC_CONTROL_FLOW ); return ( 24 * m_nHALFLAMBERT ) + ( 48 * m_nUSE_STATIC_CONTROL_FLOW ) + 0; } }; -#define shaderStaticTest_vortwarp_vs20 vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + 0 + +#define shaderStaticTest_vortwarp_vs20 vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + + class vortwarp_vs20_Dynamic_Index { -private: - int m_nCOMPRESSED_VERTS; + unsigned int m_nCOMPRESSED_VERTS : 2; + unsigned int m_nDOWATERFOG : 2; + unsigned int m_nSKINNING : 2; + unsigned int m_nNUM_LIGHTS : 2; #ifdef _DEBUG - bool m_bCOMPRESSED_VERTS; -#endif + bool m_bCOMPRESSED_VERTS : 1; + bool m_bDOWATERFOG : 1; + bool m_bSKINNING : 1; + bool m_bNUM_LIGHTS : 1; +#endif // _DEBUG public: void SetCOMPRESSED_VERTS( int i ) { @@ -81,107 +71,57 @@ public: m_nCOMPRESSED_VERTS = i; #ifdef _DEBUG m_bCOMPRESSED_VERTS = true; -#endif +#endif // _DEBUG } - 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 +#endif // _DEBUG } - 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 +#endif // _DEBUG } - void SetSKINNING( bool i ) - { - m_nSKINNING = i ? 1 : 0; -#ifdef _DEBUG - m_bSKINNING = true; -#endif - } -private: - int m_nNUM_LIGHTS; -#ifdef _DEBUG - bool m_bNUM_LIGHTS; -#endif -public: + void SetNUM_LIGHTS( int i ) { Assert( i >= 0 && i <= 2 ); m_nNUM_LIGHTS = i; #ifdef _DEBUG m_bNUM_LIGHTS = true; -#endif +#endif // _DEBUG } - void SetNUM_LIGHTS( bool i ) - { - m_nNUM_LIGHTS = i ? 1 : 0; -#ifdef _DEBUG - m_bNUM_LIGHTS = true; -#endif - } -public: - vortwarp_vs20_Dynamic_Index() + + vortwarp_vs20_Dynamic_Index( ) { + m_nCOMPRESSED_VERTS = 0; + m_nDOWATERFOG = 0; + m_nSKINNING = 0; + m_nNUM_LIGHTS = 0; #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_bNUM_LIGHTS = false; -#endif // _DEBUG - m_nNUM_LIGHTS = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bNUM_LIGHTS; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bNUM_LIGHTS ); + AssertMsg( !m_nDOWATERFOG, "Invalid combo combination DOWATERFOG" ); return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nNUM_LIGHTS ) + 0; } }; -#define shaderDynamicTest_vortwarp_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_NUM_LIGHTS + 0 + +#define shaderDynamicTest_vortwarp_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_NUM_LIGHTS + diff --git a/src/materialsystem/stdshaders/include/vortwarp_vs30.inc b/src/materialsystem/stdshaders/include/vortwarp_vs30.inc index c92406a4..8aa6100b 100644 --- a/src/materialsystem/stdshaders/include/vortwarp_vs30.inc +++ b/src/materialsystem/stdshaders/include/vortwarp_vs30.inc @@ -1,11 +1,15 @@ +// ALL SKIP STATEMENTS THAT AFFECT THIS SHADER!!! +// $DOWATERFOG +// defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH + +#pragma once #include "shaderlib/cshader.h" class vortwarp_vs30_Static_Index { -private: - int m_nHALFLAMBERT; + unsigned int m_nHALFLAMBERT : 2; #ifdef _DEBUG - bool m_bHALFLAMBERT; -#endif + bool m_bHALFLAMBERT : 1; +#endif // _DEBUG public: void SetHALFLAMBERT( int i ) { @@ -13,42 +17,39 @@ public: m_nHALFLAMBERT = i; #ifdef _DEBUG m_bHALFLAMBERT = true; -#endif +#endif // _DEBUG } - void SetHALFLAMBERT( bool i ) - { - m_nHALFLAMBERT = i ? 1 : 0; -#ifdef _DEBUG - m_bHALFLAMBERT = true; -#endif - } -public: - vortwarp_vs30_Static_Index( ) + + vortwarp_vs30_Static_Index( ) { + m_nHALFLAMBERT = 0; #ifdef _DEBUG m_bHALFLAMBERT = false; -#endif // _DEBUG - m_nHALFLAMBERT = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bHALFLAMBERT; - Assert( bAllStaticVarsDefined ); -#endif // _DEBUG + Assert( m_bHALFLAMBERT ); return ( 16 * m_nHALFLAMBERT ) + 0; } }; -#define shaderStaticTest_vortwarp_vs30 vsh_forgot_to_set_static_HALFLAMBERT + 0 + +#define shaderStaticTest_vortwarp_vs30 vsh_forgot_to_set_static_HALFLAMBERT + + class vortwarp_vs30_Dynamic_Index { -private: - int m_nCOMPRESSED_VERTS; + unsigned int m_nCOMPRESSED_VERTS : 2; + unsigned int m_nDOWATERFOG : 2; + unsigned int m_nSKINNING : 2; + unsigned int m_nMORPHING : 2; #ifdef _DEBUG - bool m_bCOMPRESSED_VERTS; -#endif + bool m_bCOMPRESSED_VERTS : 1; + bool m_bDOWATERFOG : 1; + bool m_bSKINNING : 1; + bool m_bMORPHING : 1; +#endif // _DEBUG public: void SetCOMPRESSED_VERTS( int i ) { @@ -56,107 +57,57 @@ public: m_nCOMPRESSED_VERTS = i; #ifdef _DEBUG m_bCOMPRESSED_VERTS = true; -#endif +#endif // _DEBUG } - 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 +#endif // _DEBUG } - 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 +#endif // _DEBUG } - void SetSKINNING( bool i ) - { - m_nSKINNING = i ? 1 : 0; -#ifdef _DEBUG - m_bSKINNING = true; -#endif - } -private: - int m_nMORPHING; -#ifdef _DEBUG - bool m_bMORPHING; -#endif -public: + void SetMORPHING( int i ) { Assert( i >= 0 && i <= 1 ); m_nMORPHING = i; #ifdef _DEBUG m_bMORPHING = true; -#endif +#endif // _DEBUG } - void SetMORPHING( bool i ) - { - m_nMORPHING = i ? 1 : 0; -#ifdef _DEBUG - m_bMORPHING = true; -#endif - } -public: - vortwarp_vs30_Dynamic_Index() + + vortwarp_vs30_Dynamic_Index( ) { + m_nCOMPRESSED_VERTS = 0; + m_nDOWATERFOG = 0; + m_nSKINNING = 0; + m_nMORPHING = 0; #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_bMORPHING = false; -#endif // _DEBUG - m_nMORPHING = 0; +#endif // _DEBUG } - int GetIndex() + + int GetIndex() const { - // 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_bMORPHING; - Assert( bAllDynamicVarsDefined ); -#endif // _DEBUG + Assert( m_bCOMPRESSED_VERTS && m_bDOWATERFOG && m_bSKINNING && m_bMORPHING ); + AssertMsg( !m_nDOWATERFOG, "Invalid combo combination DOWATERFOG" ); return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nDOWATERFOG ) + ( 4 * m_nSKINNING ) + ( 8 * m_nMORPHING ) + 0; } }; -#define shaderDynamicTest_vortwarp_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + 0 + +#define shaderDynamicTest_vortwarp_vs30 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_DOWATERFOG + vsh_forgot_to_set_dynamic_SKINNING + vsh_forgot_to_set_dynamic_MORPHING + diff --git a/src/materialsystem/stdshaders/include/windowimposter_ps20b.inc b/src/materialsystem/stdshaders/include/windowimposter_ps20b.inc index 1241b6ed..b73bfc83 100644 --- a/src/materialsystem/stdshaders/include/windowimposter_ps20b.inc +++ b/src/materialsystem/stdshaders/include/windowimposter_ps20b.inc @@ -18,8 +18,21 @@ #include "shaderlib/cshader.h" class windowimposter_ps20b_Static_Index { + unsigned int m_nPARALLAXCORRECT : 2; unsigned int m_nCONVERT_TO_SRGB : 2; +#ifdef _DEBUG + bool m_bPARALLAXCORRECT : 1; +#endif // _DEBUG public: + void SetPARALLAXCORRECT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPARALLAXCORRECT = i; +#ifdef _DEBUG + m_bPARALLAXCORRECT = true; +#endif // _DEBUG + } + void SetCONVERT_TO_SRGB( int i ) { Assert( i >= 0 && i <= 1 ); @@ -28,16 +41,21 @@ public: windowimposter_ps20b_Static_Index( ) { + m_nPARALLAXCORRECT = 0; m_nCONVERT_TO_SRGB = g_pHardwareConfig->NeedsShaderSRGBConversion(); +#ifdef _DEBUG + m_bPARALLAXCORRECT = false; +#endif // _DEBUG } int GetIndex() const { - return ( 3 * m_nCONVERT_TO_SRGB ) + 0; + Assert( m_bPARALLAXCORRECT ); + return ( 3 * m_nPARALLAXCORRECT ) + ( 6 * m_nCONVERT_TO_SRGB ) + 0; } }; -#define shaderStaticTest_windowimposter_ps20b 1 +#define shaderStaticTest_windowimposter_ps20b psh_forgot_to_set_static_PARALLAXCORRECT class windowimposter_ps20b_Dynamic_Index diff --git a/src/materialsystem/stdshaders/include/windowimposter_vs20.inc b/src/materialsystem/stdshaders/include/windowimposter_vs20.inc index b0cf52f1..5b78e71e 100644 --- a/src/materialsystem/stdshaders/include/windowimposter_vs20.inc +++ b/src/materialsystem/stdshaders/include/windowimposter_vs20.inc @@ -5,18 +5,36 @@ #include "shaderlib/cshader.h" class windowimposter_vs20_Static_Index { + unsigned int m_nPARALLAXCORRECT : 2; +#ifdef _DEBUG + bool m_bPARALLAXCORRECT : 1; +#endif // _DEBUG public: + void SetPARALLAXCORRECT( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nPARALLAXCORRECT = i; +#ifdef _DEBUG + m_bPARALLAXCORRECT = true; +#endif // _DEBUG + } + windowimposter_vs20_Static_Index( ) { + m_nPARALLAXCORRECT = 0; +#ifdef _DEBUG + m_bPARALLAXCORRECT = false; +#endif // _DEBUG } int GetIndex() const { - return 0; + Assert( m_bPARALLAXCORRECT ); + return ( 2 * m_nPARALLAXCORRECT ) + 0; } }; -#define shaderStaticTest_windowimposter_vs20 1 +#define shaderStaticTest_windowimposter_vs20 vsh_forgot_to_set_static_PARALLAXCORRECT class windowimposter_vs20_Dynamic_Index diff --git a/src/materialsystem/stdshaders/lightmappedgeneric_dx9.cpp b/src/materialsystem/stdshaders/lightmappedgeneric_dx9.cpp index bac124a8..7b768d18 100644 --- a/src/materialsystem/stdshaders/lightmappedgeneric_dx9.cpp +++ b/src/materialsystem/stdshaders/lightmappedgeneric_dx9.cpp @@ -49,6 +49,10 @@ BEGIN_VS_SHADER( LightmappedGeneric, SHADER_PARAM( BUMPMASK, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader3_normal", "bump map" ) SHADER_PARAM( BASETEXTURE2, SHADER_PARAM_TYPE_TEXTURE, "shadertest/lightmappedtexture", "Blended texture" ) SHADER_PARAM( FRAME2, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $basetexture2" ) +#ifdef MAPBASE + // This needs to be a SHADER_PARAM_TYPE_STRING so it isn't considered "defined" by default. + SHADER_PARAM( BASETEXTURETRANSFORM2, SHADER_PARAM_TYPE_STRING, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$basetexture2 texcoord transform" ) +#endif SHADER_PARAM( BASETEXTURENOENVMAP, SHADER_PARAM_TYPE_BOOL, "0", "" ) SHADER_PARAM( BASETEXTURE2NOENVMAP, SHADER_PARAM_TYPE_BOOL, "0", "" ) SHADER_PARAM( DETAIL_ALPHA_MASK_BASE_TEXTURE, SHADER_PARAM_TYPE_BOOL, "0", @@ -73,6 +77,20 @@ BEGIN_VS_SHADER( LightmappedGeneric, SHADER_PARAM( OUTLINESTART1, SHADER_PARAM_TYPE_FLOAT, "0.0", "inner start value for outline") SHADER_PARAM( OUTLINEEND0, SHADER_PARAM_TYPE_FLOAT, "0.0", "inner end value for outline") SHADER_PARAM( OUTLINEEND1, SHADER_PARAM_TYPE_FLOAT, "0.0", "outer end value for outline") + + SHADER_PARAM( PHONG, SHADER_PARAM_TYPE_BOOL, "0", "enables phong lighting" ) + SHADER_PARAM( PHONGBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "Phong overbrightening factor (specular mask channel should be authored to account for this)" ) + SHADER_PARAM( PHONGFRESNELRANGES, SHADER_PARAM_TYPE_VEC3, "[0 0.5 1]", "Parameters for remapping fresnel output" ) + SHADER_PARAM( PHONGEXPONENT, SHADER_PARAM_TYPE_FLOAT, "5.0", "Phong exponent for local specular lights" ) + +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps + SHADER_PARAM( ENVMAPPARALLAX, SHADER_PARAM_TYPE_BOOL, "0", "Enables parallax correction code for env_cubemaps" ) + SHADER_PARAM( ENVMAPPARALLAXOBB1, SHADER_PARAM_TYPE_VEC4, "[1 0 0 0]", "The first line of the parallax correction OBB matrix" ) + SHADER_PARAM( ENVMAPPARALLAXOBB2, SHADER_PARAM_TYPE_VEC4, "[0 1 0 0]", "The second line of the parallax correction OBB matrix" ) + SHADER_PARAM( ENVMAPPARALLAXOBB3, SHADER_PARAM_TYPE_VEC4, "[0 0 1 0]", "The third line of the parallax correction OBB matrix" ) + SHADER_PARAM( ENVMAPORIGIN, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "The world space position of the env_cubemap being corrected" ) +#endif END_SHADER_PARAMS void SetupVars( LightmappedGeneric_DX9_Vars_t& info ) @@ -111,6 +129,9 @@ END_SHADER_PARAMS info.m_nBumpMask = BUMPMASK; info.m_nBaseTexture2 = BASETEXTURE2; info.m_nBaseTexture2Frame = FRAME2; +#ifdef MAPBASE + info.m_nBaseTexture2Transform = BASETEXTURETRANSFORM2; +#endif info.m_nBaseTextureNoEnvmap = BASETEXTURENOENVMAP; info.m_nBaseTexture2NoEnvmap = BASETEXTURE2NOENVMAP; info.m_nDetailAlphaMaskBaseTexture = DETAIL_ALPHA_MASK_BASE_TEXTURE; @@ -134,6 +155,20 @@ END_SHADER_PARAMS info.m_nOutlineStart1 = OUTLINESTART1; info.m_nOutlineEnd0 = OUTLINEEND0; info.m_nOutlineEnd1 = OUTLINEEND1; + + info.m_nPhong = PHONG; + info.m_nPhongBoost = PHONGBOOST; + info.m_nPhongFresnelRanges = PHONGFRESNELRANGES; + info.m_nPhongExponent = PHONGEXPONENT; + +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps + info.m_nEnvmapParallax = ENVMAPPARALLAX; + info.m_nEnvmapParallaxObb1 = ENVMAPPARALLAXOBB1; + info.m_nEnvmapParallaxObb2 = ENVMAPPARALLAXOBB2; + info.m_nEnvmapParallaxObb3 = ENVMAPPARALLAXOBB3; + info.m_nEnvmapOrigin = ENVMAPORIGIN; +#endif } SHADER_FALLBACK diff --git a/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.cpp b/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.cpp index b878dbf4..8e816e87 100644 --- a/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.cpp +++ b/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.cpp @@ -9,10 +9,19 @@ #include "lightmappedgeneric_dx9_helper.h" #include "BaseVSShader.h" #include "commandbuilder.h" +#include "cpp_shader_constant_register_map.h" #include "convar.h" #include "lightmappedgeneric_ps20.inc" #include "lightmappedgeneric_vs20.inc" #include "lightmappedgeneric_ps20b.inc" +#include "lightmappedgeneric_ps30.inc" +#include "lightmappedgeneric_vs30.inc" + +#include "lightmappedgeneric_flashlight_vs20.inc" +#include "lightmappedgeneric_flashlight_vs30.inc" +//#include "lightmappedgeneric_flashlight_ps20.inc" +#include "lightmappedgeneric_flashlight_ps20b.inc" +#include "lightmappedgeneric_flashlight_ps30.inc" #include "tier0/memdbgon.h" @@ -21,6 +30,11 @@ ConVar mat_disable_fancy_blending( "mat_disable_fancy_blending", "0" ); ConVar mat_fullbright( "mat_fullbright","0", FCVAR_CHEAT ); ConVar my_mat_fullbright( "mat_fullbright","0", FCVAR_CHEAT ); +ConVar mat_enable_lightmapped_phong( "mat_enable_lightmapped_phong", "1", FCVAR_ARCHIVE, "If 1, allow phong on world brushes. If 0, disallow. mat_force_lightmapped_phong does not work if this value is 0." ); +ConVar mat_force_lightmapped_phong( "mat_force_lightmapped_phong", "0", FCVAR_CHEAT, "Forces the use of phong on all LightmappedAdv textures, regardless of setting in VMT." ); +ConVar mat_force_lightmapped_phong_boost( "mat_force_lightmapped_phong_boost", "5.0", FCVAR_CHEAT ); +ConVar mat_force_lightmapped_phong_exp( "mat_force_lightmapped_phong_exp", "50.0", FCVAR_CHEAT ); + ConVar r_lightmap_bicubic( "r_lightmap_bicubic", "0", FCVAR_NONE, "Enable bi-cubic (high quality) lightmap sampling." ); extern ConVar r_flashlight_version2; @@ -167,6 +181,9 @@ void InitParamsLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** pa if( !g_pConfig->UseSpecular() && params[info.m_nEnvmap]->IsDefined() && params[info.m_nBaseTexture]->IsDefined() ) { params[info.m_nEnvmap]->SetUndefined(); +#ifdef PARALLAX_CORRECTED_CUBEMAPS + params[info.m_nEnvmapParallax]->SetUndefined(); +#endif } if( !params[info.m_nBaseTextureNoEnvmap]->IsDefined() ) @@ -188,8 +205,61 @@ void InitParamsLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** pa InitFloatParam( info.m_nEdgeSoftnessStart, params, 0.5 ); InitFloatParam( info.m_nEdgeSoftnessEnd, params, 0.5 ); InitFloatParam( info.m_nOutlineAlpha, params, 1.0 ); + + if ( !params[info.m_nPhong]->IsDefined() || !mat_enable_lightmapped_phong.GetBool() ) + { + params[info.m_nPhong]->SetIntValue( 0 ); + } + if ( !params[info.m_nPhongBoost]->IsDefined() ) + { + params[info.m_nPhongBoost]->SetFloatValue( 1.0 ); + } + if ( !params[info.m_nPhongFresnelRanges]->IsDefined() ) + { + params[info.m_nPhongFresnelRanges]->SetVecValue( 0.0, 0.5, 1.0 ); + } + if ( !params[info.m_nPhongExponent]->IsDefined() ) + { + params[info.m_nPhongExponent]->SetFloatValue( 5.0 ); + } + + if ( params[info.m_nPhong]->GetIntValue() && mat_enable_lightmapped_phong.GetBool() ) + { + if ( pShader->CanUseEditorMaterials() ) + { + params[info.m_nPhong]->SetIntValue( 0 ); + } + else if ( !params[info.m_nEnvmapMaskTransform]->MatrixIsIdentity() ) + { + Warning( "Warning! material %s: $envmapmasktransform and $phong are mutually exclusive. Disabling phong..\n", pMaterialName ); + params[info.m_nPhong]->SetIntValue( 0 ); + } + } + else if ( mat_force_lightmapped_phong.GetBool() && mat_enable_lightmapped_phong.GetBool() && + params[info.m_nEnvmapMaskTransform]->MatrixIsIdentity() ) + { + params[info.m_nPhong]->SetIntValue( 1 ); + params[info.m_nPhongBoost]->SetFloatValue( mat_force_lightmapped_phong_boost.GetFloat() ); + params[info.m_nPhongFresnelRanges]->SetVecValue( 0.0, 0.5, 1.0 ); + params[info.m_nPhongExponent]->SetFloatValue( mat_force_lightmapped_phong_exp.GetFloat() ); + } } +#ifdef MAPBASE +// Created for the missing cubemap solution below +void LoadLightmappedGenericEnvmap( CBaseVSShader *pShader, IMaterialVar** params, LightmappedGeneric_DX9_Vars_t &info ) +{ + if ( !IS_FLAG_SET(MATERIAL_VAR_ENVMAPSPHERE) ) + { + pShader->LoadCubeMap( info.m_nEnvmap, g_pHardwareConfig->GetHDRType() == HDR_TYPE_NONE ? TEXTUREFLAGS_SRGB : 0 ); + } + else + { + pShader->LoadTexture( info.m_nEnvmap ); + } +} +#endif + void InitLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, LightmappedGeneric_DX9_Vars_t &info ) { if ( g_pConfig->UseBumpmapping() && params[info.m_nBumpmap]->IsDefined() ) @@ -252,6 +322,20 @@ void InitLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, if (params[info.m_nEnvmap]->IsDefined()) { +#ifdef MAPBASE + LoadLightmappedGenericEnvmap( pShader, params, info ); + + if (mat_specular_disable_on_missing.GetBool()) + { + // Revert to defaultcubemap when the envmap texture is missing + // (should be equivalent to toolsblack in Mapbase) + if (params[info.m_nEnvmap]->GetTextureValue()->IsError()) + { + params[info.m_nEnvmap]->SetStringValue( "engine/defaultcubemap" ); + LoadLightmappedGenericEnvmap( pShader, params, info ); + } + } +#else if ( !IS_FLAG_SET(MATERIAL_VAR_ENVMAPSPHERE) ) { pShader->LoadCubeMap( info.m_nEnvmap, g_pHardwareConfig->GetHDRType() == HDR_TYPE_NONE ? TEXTUREFLAGS_SRGB : 0 ); @@ -260,6 +344,7 @@ void InitLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, { pShader->LoadTexture( info.m_nEnvmap ); } +#endif if ( !g_pHardwareConfig->SupportsCubeMaps() ) { @@ -280,6 +365,412 @@ void InitLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, SET_FLAGS2( MATERIAL_VAR2_NEEDS_TANGENT_SPACES ); } +void DrawLightmappedGenericFlashlight_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI, + IShaderShadow* pShaderShadow, LightmappedGenericFlashlight_DX9_Vars_t &vars ) +{ + Assert( vars.m_bLightmappedGeneric ); + + bool bBump2 = vars.m_bWorldVertexTransition && vars.m_bBump && vars.m_nBumpmap2Var != -1 && params[vars.m_nBumpmap2Var]->IsTexture(); + bool bSeamless = vars.m_fSeamlessScale != 0.0; + bool bDetail = (vars.m_nDetailVar != -1) && params[vars.m_nDetailVar]->IsDefined() && (vars.m_nDetailScale != -1); + bool bPhong = (vars.m_nPhong != -1) && (params[vars.m_nPhong]->GetIntValue() != 0); +#ifdef MAPBASE + bool hasBaseTextureTransform2 = (vars.m_nBaseTexture2TransformVar != -1) && params[vars.m_nBaseTexture2TransformVar]->IsDefined() && params[vars.m_nBaseTexture2Var]->IsTexture(); + bool bHasBlendModulateTexture = + (vars.m_nBlendModulateTexture != -1) && + (params[vars.m_nBlendModulateTexture]->IsTexture()); +#endif + + int nDetailBlendMode = 0; + if ( bDetail ) + { + nDetailBlendMode = GetIntParam( vars.m_nDetailTextureCombineMode, params ); + nDetailBlendMode = nDetailBlendMode > 1 ? 1 : nDetailBlendMode; + } + + PhongMaskVariant_t nPhongMaskVariant = PHONGMASK_NONE; + if ( bPhong ) + { + if ( IS_FLAG_SET(MATERIAL_VAR_BASEALPHAENVMAPMASK) ) + { + nPhongMaskVariant = PHONGMASK_BASEALPHA; + } + else if ( IS_FLAG_SET(MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK) ) + { + nPhongMaskVariant = PHONGMASK_NORMALALPHA; + } + else if ( params[vars.m_nPhongMask]->IsDefined() ) + { + nPhongMaskVariant = PHONGMASK_STANDALONE; + } + } + + if( pShaderShadow ) + { + pShader->SetInitialShadowState(); + pShaderShadow->EnableDepthWrites( false ); + pShaderShadow->EnableAlphaWrites( false ); + + // Alpha blend + pShader->SetAdditiveBlendingShadowState( BASETEXTURE, true ); + + // Alpha test + pShaderShadow->EnableAlphaTest( IS_FLAG_SET( MATERIAL_VAR_ALPHATEST ) ); + if ( vars.m_nAlphaTestReference != -1 && params[vars.m_nAlphaTestReference]->GetFloatValue() > 0.0f ) + { + pShaderShadow->AlphaFunc( SHADER_ALPHAFUNC_GEQUAL, params[vars.m_nAlphaTestReference]->GetFloatValue() ); + } + + // Spot sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true ); + + // Base sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER1, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, true ); + + // Normalizing cubemap sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER2, true ); + + // Normalizing cubemap sampler2 or normal map sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER3, true ); + + // RandomRotation sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER5, true ); + + // Flashlight depth sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER7, true ); + pShaderShadow->SetShadowDepthFiltering( SHADER_SAMPLER7 ); + + if( vars.m_bWorldVertexTransition ) + { + // $basetexture2 + pShaderShadow->EnableTexture( SHADER_SAMPLER4, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER4, true ); + } + if( bBump2 ) + { + // Normalmap2 sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER6, true ); + } + if( bDetail ) + { + pShaderShadow->EnableTexture( SHADER_SAMPLER8, true ); // detail sampler + if ( nDetailBlendMode != 0 ) //Not Mod2X + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER8, true ); + } + if( nPhongMaskVariant == PHONGMASK_STANDALONE ) + { + // phong mask sampler + pShaderShadow->EnableTexture( SHADER_SAMPLER9, true ); + } + +#ifdef MAPBASE + if ( bHasBlendModulateTexture ) + { + pShaderShadow->EnableTexture( SHADER_SAMPLER10, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER10, false ); + } +#endif + + pShaderShadow->EnableSRGBWrite( true ); + + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + DECLARE_STATIC_VERTEX_SHADER( lightmappedgeneric_flashlight_vs30 ); + SET_STATIC_VERTEX_SHADER_COMBO( WORLDVERTEXTRANSITION, vars.m_bWorldVertexTransition ); + SET_STATIC_VERTEX_SHADER_COMBO( NORMALMAP, vars.m_bBump ); + SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS, bSeamless ); + SET_STATIC_VERTEX_SHADER_COMBO( DETAIL, bDetail ); + SET_STATIC_VERTEX_SHADER_COMBO( PHONG, bPhong ); +#ifdef MAPBASE + SET_STATIC_VERTEX_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_VERTEX_SHADER( lightmappedgeneric_flashlight_vs30 ); + } + else + { + DECLARE_STATIC_VERTEX_SHADER( lightmappedgeneric_flashlight_vs20 ); + SET_STATIC_VERTEX_SHADER_COMBO( WORLDVERTEXTRANSITION, vars.m_bWorldVertexTransition ); + SET_STATIC_VERTEX_SHADER_COMBO( NORMALMAP, vars.m_bBump ); + SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS, bSeamless ); + SET_STATIC_VERTEX_SHADER_COMBO( DETAIL, bDetail ); + SET_STATIC_VERTEX_SHADER_COMBO( PHONG, bPhong ); +#ifdef MAPBASE + SET_STATIC_VERTEX_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_VERTEX_SHADER( lightmappedgeneric_flashlight_vs20 ); + } + + unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL; + if( vars.m_bBump ) + { + flags |= VERTEX_TANGENT_S | VERTEX_TANGENT_T; + } + int numTexCoords = 1; + if( vars.m_bWorldVertexTransition ) + { + flags |= VERTEX_COLOR; + numTexCoords = 2; // need lightmap texcoords to get alpha. + } + pShaderShadow->VertexShaderVertexFormat( flags, numTexCoords, 0, 0 ); + + int nBumpMapVariant = 0; + if ( vars.m_bBump ) + { + nBumpMapVariant = ( vars.m_bSSBump ) ? 2 : 1; + } + + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + DECLARE_STATIC_PIXEL_SHADER( lightmappedgeneric_flashlight_ps30 ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAP, nBumpMapVariant ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAP2, bBump2 ); + SET_STATIC_PIXEL_SHADER_COMBO( WORLDVERTEXTRANSITION, vars.m_bWorldVertexTransition ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( FANCY_BLENDING, bHasBlendModulateTexture ); +#endif + SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS, bSeamless ); + SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, bDetail ); + SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); + SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, g_pHardwareConfig->GetShadowFilterMode() ); + SET_STATIC_PIXEL_SHADER_COMBO( PHONG, bPhong ); + SET_STATIC_PIXEL_SHADER_COMBO( PHONGMASK, nPhongMaskVariant ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_PIXEL_SHADER( lightmappedgeneric_flashlight_ps30 ); + } + else if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_STATIC_PIXEL_SHADER( lightmappedgeneric_flashlight_ps20b ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAP, nBumpMapVariant ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAP2, bBump2 ); + SET_STATIC_PIXEL_SHADER_COMBO( WORLDVERTEXTRANSITION, vars.m_bWorldVertexTransition ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( FANCY_BLENDING, bHasBlendModulateTexture ); +#endif + SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS, bSeamless ); + SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, bDetail ); + SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); + SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, g_pHardwareConfig->GetShadowFilterMode() ); + SET_STATIC_PIXEL_SHADER_COMBO( PHONG, bPhong ); + SET_STATIC_PIXEL_SHADER_COMBO( PHONGMASK, nPhongMaskVariant ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_PIXEL_SHADER( lightmappedgeneric_flashlight_ps20b ); + } + else + { + /*DECLARE_STATIC_PIXEL_SHADER( lightmappedgeneric_flashlight_ps20 ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAP, nBumpMapVariant ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAP2, bBump2 ); + SET_STATIC_PIXEL_SHADER_COMBO( WORLDVERTEXTRANSITION, vars.m_bWorldVertexTransition ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( FANCY_BLENDING, bHasBlendModulateTexture ); +#endif + SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS, bSeamless ); + SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, bDetail ); + SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_PIXEL_SHADER( lightmappedgeneric_flashlight_ps20 );*/ + } + pShader->FogToBlack(); + } + else + { + VMatrix worldToTexture; + ITexture *pFlashlightDepthTexture; + FlashlightState_t flashlightState = pShaderAPI->GetFlashlightStateEx( worldToTexture, &pFlashlightDepthTexture ); + + /*if ( pFlashlightDepthTexture == NULL ) + { + const int iFlashlightShadowIndex = ( flashlightState.m_nShadowQuality >> 16 ) - 1; + + if ( iFlashlightShadowIndex >= 0 + && iFlashlightShadowIndex <= ( INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_LAST - INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST ) ) + { + pFlashlightDepthTexture = (ITexture*)pShaderAPI->GetIntRenderingParameter( INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST + iFlashlightShadowIndex ); + } + }*/ + + SetFlashLightColorFromState( flashlightState, pShaderAPI ); + + pShader->BindTexture( SHADER_SAMPLER0, flashlightState.m_pSpotlightTexture, flashlightState.m_nSpotlightTextureFrame ); + + if( pFlashlightDepthTexture && g_pConfig->ShadowDepthTexture() && flashlightState.m_bEnableShadows ) + { + pShader->BindTexture( SHADER_SAMPLER7, pFlashlightDepthTexture, 0 ); + pShaderAPI->BindStandardTexture( SHADER_SAMPLER5, TEXTURE_SHADOW_NOISE_2D ); + + // Tweaks associated with a given flashlight + float tweaks[4]; + tweaks[0] = ShadowFilterFromState( flashlightState ); + tweaks[1] = ShadowAttenFromState( flashlightState ); + pShader->HashShadow2DJitter( flashlightState.m_flShadowJitterSeed, &tweaks[2], &tweaks[3] ); + pShaderAPI->SetPixelShaderConstant( PSREG_ENVMAP_TINT__SHADOW_TWEAKS, tweaks, 1 ); + + // Dimensions of screen, used for screen-space noise map sampling + float vScreenScale[4] = {1280.0f / 32.0f, 720.0f / 32.0f, 0, 0}; + int nWidth, nHeight; + pShaderAPI->GetBackBufferDimensions( nWidth, nHeight ); + vScreenScale[0] = (float) nWidth / 32.0f; + vScreenScale[1] = (float) nHeight / 32.0f; + pShaderAPI->SetPixelShaderConstant( PSREG_FLASHLIGHT_SCREEN_SCALE, vScreenScale, 1 ); + } + + if( params[BASETEXTURE]->IsTexture() && mat_fullbright.GetInt() != 2 ) + { + pShader->BindTexture( SHADER_SAMPLER1, BASETEXTURE, FRAME ); + } + else + { + pShaderAPI->BindStandardTexture( SHADER_SAMPLER1, TEXTURE_GREY ); + } + if( vars.m_bWorldVertexTransition ) + { + Assert( vars.m_nBaseTexture2Var >= 0 && vars.m_nBaseTexture2FrameVar >= 0 ); + pShader->BindTexture( SHADER_SAMPLER4, vars.m_nBaseTexture2Var, vars.m_nBaseTexture2FrameVar ); + } + pShaderAPI->BindStandardTexture( SHADER_SAMPLER2, TEXTURE_NORMALIZATION_CUBEMAP ); + if( vars.m_bBump ) + { + pShader->BindTexture( SHADER_SAMPLER3, vars.m_nBumpmapVar, vars.m_nBumpmapFrame ); + } + else + { + pShaderAPI->BindStandardTexture( SHADER_SAMPLER3, TEXTURE_NORMALIZATION_CUBEMAP ); + } + + if( bDetail ) + { + pShader->BindTexture( SHADER_SAMPLER8, vars.m_nDetailVar ); + } + + if( bBump2 ) + { + pShader->BindTexture( SHADER_SAMPLER6, vars.m_nBumpmap2Var, vars.m_nBumpmap2Frame ); + } + + if( nPhongMaskVariant == PHONGMASK_STANDALONE ) + { + pShader->BindTexture( SHADER_SAMPLER9, vars.m_nPhongMask, vars.m_nPhongMaskFrame ); + } + +#ifdef MAPBASE + if ( bHasBlendModulateTexture ) + { + pShader->BindTexture( SHADER_SAMPLER10, vars.m_nBlendModulateTexture ); + } +#endif + + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + DECLARE_DYNAMIC_VERTEX_SHADER( lightmappedgeneric_flashlight_vs30 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_VERTEX_SHADER( lightmappedgeneric_flashlight_vs30 ); + } + else + { + DECLARE_DYNAMIC_VERTEX_SHADER( lightmappedgeneric_flashlight_vs20 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_VERTEX_SHADER( lightmappedgeneric_flashlight_vs20 ); + } + + if ( bSeamless ) + { + float const0[4]={ vars.m_fSeamlessScale,0,0,0}; + pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, const0 ); + } + + if ( bDetail ) + { + float vDetailConstants[4] = {1,1,1,1}; + + if ( vars.m_nDetailTint != -1 ) + { + params[vars.m_nDetailTint]->GetVecValue( vDetailConstants, 3 ); + } + + if ( vars.m_nDetailTextureBlendFactor != -1 ) + { + vDetailConstants[3] = params[vars.m_nDetailTextureBlendFactor]->GetFloatValue(); + } + + pShaderAPI->SetPixelShaderConstant( 0, vDetailConstants, 1 ); + } + + if ( bPhong ) + { + float vEyePos[4]; + pShaderAPI->GetWorldSpaceCameraPosition( vEyePos ); + vEyePos[3] = 0.0f; + pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_10, vEyePos ); + } + +#ifdef MAPBASE + else if ( hasBaseTextureTransform2 ) + { + pShader->SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_10, vars.m_nBaseTexture2TransformVar ); + } +#endif + + pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS ); + + float vEyePos_SpecExponent[4]; + pShaderAPI->GetWorldSpaceCameraPosition( vEyePos_SpecExponent ); + vEyePos_SpecExponent[3] = params[vars.m_nPhongExponent]->GetFloatValue(); + pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 ); + + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + DECLARE_DYNAMIC_PIXEL_SHADER( lightmappedgeneric_flashlight_ps30 ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, flashlightState.m_bEnableShadows ); + SET_DYNAMIC_PIXEL_SHADER( lightmappedgeneric_flashlight_ps30 ); + } + else if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_DYNAMIC_PIXEL_SHADER( lightmappedgeneric_flashlight_ps20b ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, flashlightState.m_bEnableShadows ); + SET_DYNAMIC_PIXEL_SHADER( lightmappedgeneric_flashlight_ps20b ); + } + else + { + /*DECLARE_DYNAMIC_PIXEL_SHADER( lightmappedgeneric_flashlight_ps20 ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); + SET_DYNAMIC_PIXEL_SHADER( lightmappedgeneric_flashlight_ps20 );*/ + } + + float atten[4]; // Set the flashlight attenuation factors + atten[0] = flashlightState.m_fConstantAtten; + atten[1] = flashlightState.m_fLinearAtten; + atten[2] = flashlightState.m_fQuadraticAtten; + atten[3] = flashlightState.m_FarZ; + /*atten[3] = flashlightState.m_FarZAtten;*/ + pShaderAPI->SetPixelShaderConstant( PSREG_FLASHLIGHT_ATTENUATION, atten, 1 ); + + float lightPos[4]; + lightPos[0] = flashlightState.m_vecLightOrigin[0]; + lightPos[1] = flashlightState.m_vecLightOrigin[1]; + lightPos[2] = flashlightState.m_vecLightOrigin[2]; + lightPos[3] = 1.0f; + pShaderAPI->SetPixelShaderConstant( 1, lightPos, 1 ); + + float specParams[4]; + params[vars.m_nPhongFresnelRanges]->GetVecValue( specParams, 3 ); + specParams[3] = params[vars.m_nPhongBoost]->GetFloatValue(); + pShaderAPI->SetPixelShaderConstant( PSREG_FRESNEL_SPEC_PARAMS, specParams, 1 ); + + pShader->SetFlashlightVertexShaderConstants( vars.m_bBump, vars.m_nBumpTransform, bDetail, vars.m_nDetailScale, bSeamless ? false : true ); + } + pShader->Draw(); +} + void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** params, bool hasFlashlight, IShaderDynamicAPI *pShaderAPI, IShaderShadow* pShaderShadow, LightmappedGeneric_DX9_Vars_t &info, @@ -306,6 +797,9 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** bool hasBump = ( params[info.m_nBumpmap]->IsTexture() ) && ( !g_pHardwareConfig->PreferReducedFillrate() ); bool hasSSBump = hasBump && (info.m_nSelfShadowedBumpFlag != -1) && ( params[info.m_nSelfShadowedBumpFlag]->GetIntValue() ); bool hasBaseTexture2 = hasBaseTexture && params[info.m_nBaseTexture2]->IsTexture(); +#ifdef MAPBASE + bool hasBaseTextureTransform2 = (info.m_nBaseTexture2Transform != -1) && params[info.m_nBaseTexture2Transform]->IsDefined() && hasBaseTexture2; +#endif bool hasLightWarpTexture = params[info.m_nLightWarpTexture]->IsTexture(); bool hasBump2 = hasBump && params[info.m_nBumpmap2]->IsTexture(); bool hasDetailTexture = params[info.m_nDetail]->IsTexture(); @@ -316,11 +810,15 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** (info.m_nBlendModulateTexture != -1) && (params[info.m_nBlendModulateTexture]->IsTexture() ); bool hasNormalMapAlphaEnvmapMask = IS_FLAG_SET( MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK ); +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps + bool hasParallaxCorrection = params[info.m_nEnvmapParallax]->GetIntValue() > 0; +#endif if ( hasFlashlight && !IsX360() ) { // !!speed!! do this in the caller so we don't build struct every time - CBaseVSShader::DrawFlashlight_dx90_Vars_t vars; + LightmappedGenericFlashlight_DX9_Vars_t vars; vars.m_bBump = hasBump; vars.m_nBumpmapVar = info.m_nBumpmap; vars.m_nBumpmapFrame = info.m_nBumpFrame; @@ -331,6 +829,9 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** vars.m_bWorldVertexTransition = hasBaseTexture2; vars.m_nBaseTexture2Var = info.m_nBaseTexture2; vars.m_nBaseTexture2FrameVar = info.m_nBaseTexture2Frame; +#ifdef MAPBASE + vars.m_nBaseTexture2TransformVar = info.m_nBaseTexture2Transform; +#endif vars.m_nBumpmap2Var = info.m_nBumpmap2; vars.m_nBumpmap2Frame = info.m_nBumpFrame2; vars.m_nBump2Transform = info.m_nBumpTransform2; @@ -346,7 +847,19 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** vars.m_fSeamlessScale = params[info.m_nSeamlessMappingScale]->GetFloatValue(); else vars.m_fSeamlessScale = 0.0; - pShader->DrawFlashlight_dx90( params, pShaderAPI, pShaderShadow, vars ); + + vars.m_nPhong = info.m_nPhong; + vars.m_nPhongBoost = info.m_nPhongBoost; + vars.m_nPhongFresnelRanges = info.m_nPhongFresnelRanges; + vars.m_nPhongExponent = info.m_nPhongExponent; + vars.m_nPhongMask = info.m_nEnvmapMask; + vars.m_nPhongMaskFrame = info.m_nEnvmapMaskFrame; + +#ifdef MAPBASE + vars.m_nBlendModulateTexture = info.m_nBlendModulateTexture; +#endif + + DrawLightmappedGenericFlashlight_DX9_Internal( pShader, params, pShaderAPI, pShaderShadow, vars ); return; } @@ -531,24 +1044,87 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** bool bMaskedBlending=( (info.m_nMaskedBlending != -1) && (params[info.m_nMaskedBlending]->GetIntValue() != 0) ); - DECLARE_STATIC_VERTEX_SHADER( lightmappedgeneric_vs20 ); - SET_STATIC_VERTEX_SHADER_COMBO( ENVMAP_MASK, hasEnvmapMask ); - SET_STATIC_VERTEX_SHADER_COMBO( TANGENTSPACE, params[info.m_nEnvmap]->IsTexture() ); - SET_STATIC_VERTEX_SHADER_COMBO( BUMPMAP, hasBump ); - SET_STATIC_VERTEX_SHADER_COMBO( DIFFUSEBUMPMAP, hasDiffuseBumpmap ); - SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, IS_FLAG_SET( MATERIAL_VAR_VERTEXCOLOR ) ); - SET_STATIC_VERTEX_SHADER_COMBO( VERTEXALPHATEXBLENDFACTOR, hasBaseTexture2 || hasBump2 ); - SET_STATIC_VERTEX_SHADER_COMBO( BUMPMASK, hasBumpMask ); - - bool bReliefMapping = false; //( bumpmap_variant == 2 ) && ( ! bSeamlessMapping ); - SET_STATIC_VERTEX_SHADER_COMBO( RELIEF_MAPPING, false );//bReliefMapping ); - SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS, bSeamlessMapping ); + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + DECLARE_STATIC_VERTEX_SHADER( lightmappedgeneric_vs30 ); + SET_STATIC_VERTEX_SHADER_COMBO( ENVMAP_MASK, hasEnvmapMask ); + SET_STATIC_VERTEX_SHADER_COMBO( TANGENTSPACE, params[info.m_nEnvmap]->IsTexture() ); // // GSTRINGMIGRATION params[info.m_nEnvmap]->IsTexture() ); + SET_STATIC_VERTEX_SHADER_COMBO( BUMPMAP, hasBump ); + SET_STATIC_VERTEX_SHADER_COMBO( DIFFUSEBUMPMAP, hasDiffuseBumpmap ); + SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, IS_FLAG_SET( MATERIAL_VAR_VERTEXCOLOR ) ); + SET_STATIC_VERTEX_SHADER_COMBO( VERTEXALPHATEXBLENDFACTOR, hasBaseTexture2 || hasBump2 ); + SET_STATIC_VERTEX_SHADER_COMBO( BUMPMASK, hasBumpMask ); + SET_STATIC_VERTEX_SHADER_COMBO( RELIEF_MAPPING, false );//bReliefMapping ); + SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS, bSeamlessMapping ); #ifdef _X360 - SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, hasFlashlight); + SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, hasFlashlight); #endif - SET_STATIC_VERTEX_SHADER( lightmappedgeneric_vs20 ); +#ifdef MAPBASE + SET_STATIC_VERTEX_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_VERTEX_SHADER( lightmappedgeneric_vs30 ); + } + else + { + DECLARE_STATIC_VERTEX_SHADER( lightmappedgeneric_vs20 ); + SET_STATIC_VERTEX_SHADER_COMBO( ENVMAP_MASK, hasEnvmapMask ); + SET_STATIC_VERTEX_SHADER_COMBO( TANGENTSPACE, params[info.m_nEnvmap]->IsTexture() ); + SET_STATIC_VERTEX_SHADER_COMBO( BUMPMAP, hasBump ); + SET_STATIC_VERTEX_SHADER_COMBO( DIFFUSEBUMPMAP, hasDiffuseBumpmap ); + SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, IS_FLAG_SET( MATERIAL_VAR_VERTEXCOLOR ) ); + SET_STATIC_VERTEX_SHADER_COMBO( VERTEXALPHATEXBLENDFACTOR, hasBaseTexture2 || hasBump2 ); + SET_STATIC_VERTEX_SHADER_COMBO( BUMPMASK, hasBumpMask ); - if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + //bool bReliefMapping = false; //( bumpmap_variant == 2 ) && ( ! bSeamlessMapping ); + SET_STATIC_VERTEX_SHADER_COMBO( RELIEF_MAPPING, false );//bReliefMapping ); + SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS, bSeamlessMapping ); +#ifdef _X360 + SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, hasFlashlight ); +#endif +#ifdef MAPBASE + SET_STATIC_VERTEX_SHADER_COMBO( BASETEXTURETRANSFORM2, hasBaseTextureTransform2 ); +#endif + SET_STATIC_VERTEX_SHADER( lightmappedgeneric_vs20 ); + } + + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + DECLARE_STATIC_PIXEL_SHADER( lightmappedgeneric_ps30 ); + SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURE2, hasBaseTexture2 ); + SET_STATIC_PIXEL_SHADER_COMBO( DETAILTEXTURE, hasDetailTexture ); + SET_STATIC_PIXEL_SHADER_COMBO( BUMPMAP, bumpmap_variant ); + SET_STATIC_PIXEL_SHADER_COMBO( BUMPMAP2, hasBump2 ); + SET_STATIC_PIXEL_SHADER_COMBO( BUMPMASK, hasBumpMask ); + SET_STATIC_PIXEL_SHADER_COMBO( DIFFUSEBUMPMAP, hasDiffuseBumpmap ); + SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, hasEnvmap ); + SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, hasEnvmapMask ); + SET_STATIC_PIXEL_SHADER_COMBO( BASEALPHAENVMAPMASK, hasBaseAlphaEnvmapMask ); + SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUM, hasSelfIllum ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAPALPHAENVMAPMASK, hasNormalMapAlphaEnvmapMask ); + SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURENOENVMAP, params[info.m_nBaseTextureNoEnvmap]->GetIntValue() ); + SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURE2NOENVMAP, params[info.m_nBaseTexture2NoEnvmap]->GetIntValue() ); + SET_STATIC_PIXEL_SHADER_COMBO( WARPLIGHTING, hasLightWarpTexture ); + SET_STATIC_PIXEL_SHADER_COMBO( FANCY_BLENDING, bHasBlendModulateTexture ); + SET_STATIC_PIXEL_SHADER_COMBO( MASKEDBLENDING, bMaskedBlending); + SET_STATIC_PIXEL_SHADER_COMBO( RELIEF_MAPPING, false );//bReliefMapping ); + SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS, bSeamlessMapping ); + SET_STATIC_PIXEL_SHADER_COMBO( OUTLINE, bHasOutline ); + SET_STATIC_PIXEL_SHADER_COMBO( SOFTEDGES, bHasSoftEdges ); + SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMAL_DECODE_MODE, (int) NORMAL_DECODE_NONE ); + SET_STATIC_PIXEL_SHADER_COMBO( NORMALMASK_DECODE_MODE, (int) NORMAL_DECODE_NONE ); +#ifdef _X360 + SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, hasFlashlight); +#endif +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps enabled for 2_0b and onwards + SET_STATIC_PIXEL_SHADER_COMBO( PARALLAXCORRECT, hasParallaxCorrection ); +#else + SET_STATIC_PIXEL_SHADER_COMBO( PARALLAXCORRECT, false ); +#endif + SET_STATIC_PIXEL_SHADER( lightmappedgeneric_ps30 ); + } + else if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { DECLARE_STATIC_PIXEL_SHADER( lightmappedgeneric_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( BASETEXTURE2, hasBaseTexture2 ); @@ -567,7 +1143,7 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** SET_STATIC_PIXEL_SHADER_COMBO( WARPLIGHTING, hasLightWarpTexture ); SET_STATIC_PIXEL_SHADER_COMBO( FANCY_BLENDING, bHasBlendModulateTexture ); SET_STATIC_PIXEL_SHADER_COMBO( MASKEDBLENDING, bMaskedBlending); - SET_STATIC_PIXEL_SHADER_COMBO( RELIEF_MAPPING, bReliefMapping ); + SET_STATIC_PIXEL_SHADER_COMBO( RELIEF_MAPPING, false ); SET_STATIC_PIXEL_SHADER_COMBO( SEAMLESS, bSeamlessMapping ); SET_STATIC_PIXEL_SHADER_COMBO( OUTLINE, bHasOutline ); SET_STATIC_PIXEL_SHADER_COMBO( SOFTEDGES, bHasSoftEdges ); @@ -576,6 +1152,12 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** SET_STATIC_PIXEL_SHADER_COMBO( NORMALMASK_DECODE_MODE, (int) NORMAL_DECODE_NONE ); #ifdef _X360 SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHT, hasFlashlight); +#endif +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps enabled for 2_0b and onwards + SET_STATIC_PIXEL_SHADER_COMBO( PARALLAXCORRECT, hasParallaxCorrection ); +#else + SET_STATIC_PIXEL_SHADER_COMBO( PARALLAXCORRECT, false ); #endif SET_STATIC_PIXEL_SHADER( lightmappedgeneric_ps20b ); } @@ -635,6 +1217,9 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** // for the texture transform. bool bHasTextureTransform = !( params[info.m_nBaseTextureTransform]->MatrixIsIdentity() && +#ifdef MAPBASE + (!hasBaseTextureTransform2 || params[info.m_nBaseTexture2Transform]->MatrixIsIdentity()) && +#endif params[info.m_nBumpTransform]->MatrixIsIdentity() && params[info.m_nBumpTransform2]->MatrixIsIdentity() && params[info.m_nEnvmapMaskTransform]->MatrixIsIdentity() ); @@ -673,6 +1258,12 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** { pContextData->m_SemiStaticCmdsOut.SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_4, info.m_nBumpTransform2 ); } +#ifdef MAPBASE + if ( hasBaseTextureTransform2 ) + { + pContextData->m_SemiStaticCmdsOut.SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_8, info.m_nBaseTexture2Transform ); + } +#endif } pContextData->m_SemiStaticCmdsOut.SetEnvMapTintPixelShaderDynamicState( 0, info.m_nEnvmapTint ); // set up shader modulation color @@ -710,10 +1301,14 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** float fresnelReflection = params[info.m_nFresnelReflection]->GetFloatValue(); bool hasEnvmap = params[info.m_nEnvmap]->IsTexture(); +#ifdef MAPBASE + bool bEditorBlend = (hasBaseTexture2 && pShader->UsingEditor( params )); // Mapbase - For fixing editor blending +#endif + pContextData->m_bPixelShaderFastPath = true; bool bUsingContrast = hasEnvmap && ( (envmapContrast != 0.0f) && (envmapContrast != 1.0f) ) && (envmapSaturation != 1.0f); bool bUsingFresnel = hasEnvmap && (fresnelReflection != 1.0f); - bool bUsingSelfIllumTint = IS_FLAG_SET(MATERIAL_VAR_SELFILLUM) && (selfIllumTintVal[0] != 1.0f || selfIllumTintVal[1] != 1.0f || selfIllumTintVal[2] != 1.0f); + bool bUsingSelfIllumTint = IS_FLAG_SET(MATERIAL_VAR_SELFILLUM) && (selfIllumTintVal[0] != 1.0f || selfIllumTintVal[1] != 1.0f || selfIllumTintVal[2] != 1.0f); if ( bUsingContrast || bUsingFresnel || bUsingSelfIllumTint || !g_pConfig->bShowSpecular ) { pContextData->m_bPixelShaderFastPath = false; @@ -860,6 +1455,59 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** pContextData->m_SemiStaticCmdsOut.BindTexture( pShader, SHADER_SAMPLER3, info.m_nBlendModulateTexture, -1 ); } +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps + if (hasParallaxCorrection) + { + float envMapOrigin[4] = {0,0,0,0}; + params[info.m_nEnvmapOrigin]->GetVecValue( envMapOrigin, 3 ); +#ifdef MAPBASE + envMapOrigin[3] = bEditorBlend ? 1.0f : 0.0f; +#endif + pContextData->m_SemiStaticCmdsOut.SetPixelShaderConstant( 21, envMapOrigin ); + + float* vecs[3]; + vecs[0] = const_cast(params[info.m_nEnvmapParallaxObb1]->GetVecValue()); + vecs[1] = const_cast(params[info.m_nEnvmapParallaxObb2]->GetVecValue()); + vecs[2] = const_cast(params[info.m_nEnvmapParallaxObb3]->GetVecValue()); + float matrix[4][4]; + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 4; j++) + { + matrix[i][j] = vecs[i][j]; + } + } + matrix[3][0] = matrix[3][1] = matrix[3][2] = 0; + matrix[3][3] = 1; + pContextData->m_SemiStaticCmdsOut.SetPixelShaderConstant( 22, &matrix[0][0], 4 ); + } +#endif + +#ifdef MAPBASE + // Hammer apparently has a bug that causes the vertex blend to get swapped. + // Hammer uses a special internal shader to nullify this, but it doesn't work with custom shaders. + // Downfall got around this by swapping around the base textures in the DLL code when drawn by the editor. + // Doing it here in the shader itself allows us to retain other properties, like FANCY_BLENDING. + else + { + // TODO: This is inefficient use of a constant; Something should be done about this in the future + static const float editorBlend[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; + static const float regularBlend[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + pContextData->m_SemiStaticCmdsOut.SetPixelShaderConstant( 21, (bEditorBlend ? editorBlend : regularBlend), 1 ); + /* + if (bEditorBlend) + { + pContextData->m_SemiStaticCmdsOut.SetPixelShaderConstant( 35, 1.0f ); + } + else + { + pContextData->m_SemiStaticCmdsOut.SetPixelShaderConstant( 35, 0.0f ); + } + */ + } +#endif + pContextData->m_SemiStaticCmdsOut.End(); } } @@ -888,14 +1536,28 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** } MaterialFogMode_t fogType = pShaderAPI->GetSceneFogMode(); - DECLARE_DYNAMIC_VERTEX_SHADER( lightmappedgeneric_vs20 ); - SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); - SET_DYNAMIC_VERTEX_SHADER_COMBO( FASTPATH, bVertexShaderFastPath ); - SET_DYNAMIC_VERTEX_SHADER_COMBO( - LIGHTING_PREVIEW, - (nFixedLightingMode)?1:0 - ); - SET_DYNAMIC_VERTEX_SHADER_CMD( DynamicCmdsOut, lightmappedgeneric_vs20 ); + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + DECLARE_DYNAMIC_VERTEX_SHADER( lightmappedgeneric_vs30 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( FASTPATH, bVertexShaderFastPath ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( + LIGHTING_PREVIEW, + (nFixedLightingMode)?1:0 + ); + SET_DYNAMIC_VERTEX_SHADER_CMD( DynamicCmdsOut, lightmappedgeneric_vs30 ); + } + else + { + DECLARE_DYNAMIC_VERTEX_SHADER( lightmappedgeneric_vs20 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( FASTPATH, bVertexShaderFastPath ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( + LIGHTING_PREVIEW, + (nFixedLightingMode)?1:0 + ); + SET_DYNAMIC_VERTEX_SHADER_CMD( DynamicCmdsOut, lightmappedgeneric_vs20 ); + } bool bPixelShaderFastPath = pContextData->m_bPixelShaderFastPath; if( nFixedLightingMode !=0 ) @@ -918,7 +1580,22 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** } float envmapContrast = params[info.m_nEnvmapContrast]->GetFloatValue(); - if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + if ( g_pHardwareConfig->SupportsShaderModel_3_0() ) + { + DECLARE_DYNAMIC_PIXEL_SHADER( lightmappedgeneric_ps30 ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( FASTPATH, bPixelShaderFastPath || pContextData->m_bPixelShaderForceFastPathBecauseOutline ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( FASTPATHENVMAPCONTRAST, bPixelShaderFastPath && envmapContrast == 1.0f ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo1( true ) ); + + // Don't write fog to alpha if we're using translucency + SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bWriteDepthToAlpha ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITEWATERFOGTODESTALPHA, bWriteWaterFogToAlpha ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( LIGHTING_PREVIEW, nFixedLightingMode ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( BICUBIC_LIGHTMAP, r_lightmap_bicubic.GetBool() ? 1 : 0 ); + + SET_DYNAMIC_PIXEL_SHADER_CMD( DynamicCmdsOut, lightmappedgeneric_ps30 ); + } + else if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { DECLARE_DYNAMIC_PIXEL_SHADER( lightmappedgeneric_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( FASTPATH, bPixelShaderFastPath || pContextData->m_bPixelShaderForceFastPathBecauseOutline ); diff --git a/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.h b/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.h index 00375b9f..0223099b 100644 --- a/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.h +++ b/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.h @@ -62,6 +62,9 @@ struct LightmappedGeneric_DX9_Vars_t int m_nBumpMask; int m_nBaseTexture2; int m_nBaseTexture2Frame; +#ifdef MAPBASE + int m_nBaseTexture2Transform; +#endif int m_nBaseTextureNoEnvmap; int m_nBaseTexture2NoEnvmap; int m_nDetailAlphaMaskBaseTexture; @@ -87,8 +90,55 @@ struct LightmappedGeneric_DX9_Vars_t int m_nOutlineEnd0; int m_nOutlineEnd1; + int m_nPhong; + int m_nPhongBoost; + int m_nPhongFresnelRanges; + int m_nPhongExponent; + +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps + int m_nEnvmapParallax; // Needed for editor + int m_nEnvmapParallaxObb1; + int m_nEnvmapParallaxObb2; + int m_nEnvmapParallaxObb3; + int m_nEnvmapOrigin; +#endif }; +enum PhongMaskVariant_t +{ + PHONGMASK_NONE, + PHONGMASK_BASEALPHA, + PHONGMASK_NORMALALPHA, + PHONGMASK_STANDALONE, +}; + + +struct LightmappedGenericFlashlight_DX9_Vars_t : public CBaseVSShader::DrawFlashlight_dx90_Vars_t +{ + LightmappedGenericFlashlight_DX9_Vars_t() + : m_nPhong( -1 ) + , m_nPhongBoost( -1 ) + , m_nPhongFresnelRanges( -1 ) + , m_nPhongExponent( -1 ) + , m_nPhongMask( -1 ) + , m_nPhongMaskFrame( -1 ) + { + } + int m_nPhong; + int m_nPhongBoost; + int m_nPhongFresnelRanges; + int m_nPhongExponent; + int m_nPhongMask; + int m_nPhongMaskFrame; + +#ifdef MAPBASE + // Fix for displacements not showing $blendmodulatetexture under a flashlight + int m_nBlendModulateTexture; +#endif +}; + + void InitParamsLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, LightmappedGeneric_DX9_Vars_t &info ); void InitLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, LightmappedGeneric_DX9_Vars_t &info ); void DrawLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, diff --git a/src/materialsystem/stdshaders/lightmappedgeneric_flashlight_ps2x.fxc b/src/materialsystem/stdshaders/lightmappedgeneric_flashlight_ps2x.fxc new file mode 100644 index 00000000..d8e7e885 --- /dev/null +++ b/src/materialsystem/stdshaders/lightmappedgeneric_flashlight_ps2x.fxc @@ -0,0 +1,330 @@ +//====== Copyright c 1996-2004, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + + + +// STATIC: "NORMALMAP" "0..2" +// STATIC: "NORMALMAP2" "0..1" +// STATIC: "WORLDVERTEXTRANSITION" "0..1" +// STATIC: "FANCY_BLENDING" "0..1" +// STATIC: "SEAMLESS" "0..1" +// STATIC: "DETAILTEXTURE" "0..1" +// STATIC: "DETAIL_BLEND_MODE" "0..1" +// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps20b] [ps30] [PC] +// STATIC: "PHONG" "0..1" [ps20b] [ps30] +// STATIC: "PHONGMASK" "0..3" [ps20b] [ps30] +// STATIC: "BASETEXTURETRANSFORM2" "0..1" + +// DYNAMIC: "PIXELFOGTYPE" "0..1" +// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b] [ps30] + +// SKIP: !$WORLDVERTEXTRANSITION && $NORMALMAP2 +// SKIP: !$NORMALMAP && $NORMALMAP2 +// SKIP: !$DETAILTEXTURE && ( $DETAIL_BLEND_MODE != 0 ) +// SKIP: !$PHONG && $PHONGMASK +// SKIP: $BASETEXTURETRANSFORM2 && !$WORLDVERTEXTRANSITION +// SKIP: $BASETEXTURETRANSFORM2 && $SEAMLESS +// SKIP: $BASETEXTURETRANSFORM2 && $PHONG + +#include "shader_constant_register_map.h" +#include "common_flashlight_fxc.h" +#include "common_lightmappedgeneric_fxc.h" + +const float4 g_vShadowTweaks : register( PSREG_ENVMAP_TINT__SHADOW_TWEAKS ); +const float4 g_FogParams : register( PSREG_FOG_PARAMS ); +const float4 g_EyePos : register( PSREG_EYEPOS_SPEC_EXPONENT ); +const float4 g_FlashlightAttenuation : register( PSREG_FLASHLIGHT_ATTENUATION ); +const float4 g_DetailConstants : register( c0 ); +const float4 g_FlashlightPos : register( c1 ); +const float4 g_FresnelSpecParams : register( PSREG_FRESNEL_SPEC_PARAMS ); + +#define g_SpecularExponent g_EyePos.w +#define g_FresnelRanges g_FresnelSpecParams.xyz +#define g_SpecularBoost g_FresnelSpecParams.w + +#define PHONGMASK_BASEALPHA 1 +#define PHONGMASK_NORMALALPHA 2 +#define PHONGMASK_STANDALONE 3 + +sampler SpotSampler : register( s0 ); +sampler BaseTextureSampler : register( s1 ); +sampler NormalizingCubemapSampler : register( s2 ); + +// use a normalizing cube map here if we aren't normal mapping +sampler BumpMapSampler : register( s3 ); +sampler BaseTextureSampler2 : register( s4 ); + +#ifdef WORLDVERTEXTRANSITION +sampler NormalMap2Sampler : register( s6 ); +#endif + +#if DETAILTEXTURE +sampler DetailSampler : register( s8 ); +#endif + +#if FLASHLIGHTSHADOWS && ( defined( SHADER_MODEL_PS_2_B ) || defined( SHADER_MODEL_PS_3_0 ) ) +sampler RandomRotationSampler : register( s5 ); // Random rotation sampler +sampler FlashlightDepthSampler : register( s7 ); +#endif + +#if PHONGMASK == PHONGMASK_STANDALONE +sampler PhongMaskSampler : register( s9 ); +#endif + +#if FANCY_BLENDING +sampler BlendModulationSampler : register( s10 ); +#endif + +struct PS_INPUT +{ + float4 spotTexCoord : TEXCOORD0; +#if SEAMLESS + float3 SeamlessTexCoord : TEXCOORD1; +#else +#if BASETEXTURETRANSFORM2 + // Blixibon - Using two extra floats for $basetexturetransform2 + float4 baseTexCoord : TEXCOORD1; +#else + float2 baseTexCoord : TEXCOORD1; +#endif +#endif +#if NORMALMAP +#if PHONG + float4 tangentPosToLightVector : TEXCOORD2; + float4 normalMapTexCoord : TEXCOORD3; +#else + float3 tangentPosToLightVector : TEXCOORD2; + float2 normalMapTexCoord : TEXCOORD3; +#endif +#else + float3 worldPosToLightVector : TEXCOORD2; + float3 normal : TEXCOORD3; +#endif + + float2 detailCoords : TEXCOORD4; + float4 worldPos_worldTransition : TEXCOORD5; + float3 projPos : TEXCOORD6; + float4 fogFactorW : TEXCOORD7; +}; + + + +float4 SampleNormal( sampler s, PS_INPUT i ) +{ +#if SEAMLESS + float4 szy=tex2D( s, i.SeamlessTexCoord.zy ); + float4 sxz=tex2D( s, i.SeamlessTexCoord.xz ); + float4 syx=tex2D( s, i.SeamlessTexCoord.xy ); + return i.fogFactorW.r*szy + i.fogFactorW.g*sxz + i.fogFactorW.b*syx; +#else +#if NORMALMAP + return tex2D( s, i.normalMapTexCoord.xy); +#else + return float4(0,0,1,1); +#endif +#endif + +} + +float4 main( PS_INPUT i ) : COLOR +{ + bool bBase2 = WORLDVERTEXTRANSITION ? true : false; + bool bBump = (NORMALMAP != 0) ? true : false; + + // Do spot stuff early since we can bail out + float3 spotColor = float3(0,0,0); + float3 vProjCoords = i.spotTexCoord.xyz / i.spotTexCoord.w; + +#if ( defined( _X360 ) ) + + float3 ltz = vProjCoords.xyz < float3( 0.0f, 0.0f, 0.0f ); + float3 gto = vProjCoords.xyz > float3( 1.0f, 1.0f, 1.0f ); + + [branch] + if ( dot(ltz + gto, float3(1,1,1)) > 0 ) + { + clip (-1); + return float4(0,0,0,0); + } + else + { + spotColor = tex2D( SpotSampler, vProjCoords ); + + [branch] + if ( dot(spotColor.xyz, float3(1,1,1)) <= 0 ) + { + clip(-1); + return float4(0,0,0,0); + } + else + { +#else + clip( vProjCoords.xyz ); +#if defined( SHADER_MODEL_PS_2_B ) || defined( SHADER_MODEL_PS_3_0 ) + clip( 1-vProjCoords.xyz ); +#endif + spotColor = tex2D( SpotSampler, vProjCoords ); +#endif + + float4 baseColor = 0.0f; + float4 baseColor2 = 0.0f; + float4 vNormal = float4(0, 0, 1, 1); + float3 baseTexCoords = float3(0,0,0); + +#if SEAMLESS + baseTexCoords = i.SeamlessTexCoord.xyz; +#else + baseTexCoords.xy = i.baseTexCoord.xy; +#endif + +#if BASETEXTURETRANSFORM2 + // Blixibon - Simpler version of GetBaseTextureAndNormal() that supports $basetexturetransform2 + // (This is duplicated in the original shader, but make this its own function in common_lightmappedgeneric_fxc.h if this becomes more widespread) + baseColor = tex2D( BaseTextureSampler, baseTexCoords.xy ); + baseColor2 = tex2D( BaseTextureSampler2, i.baseTexCoord.wz ); + if ( bBump ) + { + vNormal = tex2D( BumpMapSampler, baseTexCoords.xy ); + } +#else + GetBaseTextureAndNormal( BaseTextureSampler, BaseTextureSampler2, BumpMapSampler, bBase2, bBump, baseTexCoords, i.fogFactorW.xyz, baseColor, baseColor2, vNormal ); +#endif + +#if WORLDVERTEXTRANSITION + float lerpAlpha = i.worldPos_worldTransition.a; + + // Blixibon +#if (PIXELFOGTYPE != PIXEL_FOG_TYPE_HEIGHT) && (FANCY_BLENDING) + float4 modt=tex2D(BlendModulationSampler,baseTexCoords); + + float minb=saturate(modt.g-modt.r); + float maxb=saturate(modt.g+modt.r); + lerpAlpha=smoothstep(minb,maxb,lerpAlpha); +#endif + +#endif + +#if ( NORMALMAP == 0 ) + vNormal.xyz = normalize( i.normal.xyz ); +#endif + +#if ( NORMALMAP == 1 ) + vNormal.xyz = vNormal.xyz * 2.0f - 1.0f; // signed + +# if NORMALMAP2 + float3 normal2 = SampleNormal( NormalMap2Sampler, i ) * 2.0f - 1.0f; + vNormal.xyz = lerp( vNormal.xyz, normal2, lerpAlpha ); +# endif +#endif + +// ssbump +#if ( NORMALMAP == 2 ) + +# if NORMALMAP2 + float3 normal2 = SampleNormal( NormalMap2Sampler, i ); + vNormal.xyz = lerp( vNormal.xyz, normal2, lerpAlpha ); +# endif +#else + // Normalize normal after all of the lerps above (including the tri/bilinear texel fetches) + vNormal.xyz = normalize( vNormal.xyz ); +#endif + + spotColor.rgb *= cFlashlightColor.rgb; + + // Compute per-pixel distance attenuation + float3 delta = g_FlashlightPos.xyz - i.worldPos_worldTransition.xyz; + float distSquared = dot( delta, delta ); + float dist = sqrt( distSquared ); + float farZ = g_FlashlightAttenuation.w; + float endFalloffFactor = RemapValClamped( dist, farZ, 0.6f * farZ, 0.0f, 1.0f ); + float flAtten = saturate(endFalloffFactor * dot( g_FlashlightAttenuation.xyz, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) ); + +#if FLASHLIGHTSHADOWS && ( defined( SHADER_MODEL_PS_2_B ) || defined( SHADER_MODEL_PS_3_0 ) ) + float flShadow = DoFlashlightShadow( FlashlightDepthSampler, RandomRotationSampler, vProjCoords, i.projPos.xy / i.projPos.z, FLASHLIGHTDEPTHFILTERMODE, g_vShadowTweaks, false ); + float flAttenuated = lerp( flShadow, 1.0f, g_vShadowTweaks.y ); // Blend between fully attenuated and not attenuated + flShadow = saturate(lerp( flAttenuated, flShadow, flAtten )); // Blend between shadow and above, according to light attenuation + spotColor *= flShadow; +#endif + +#if WORLDVERTEXTRANSITION && !defined( SHADER_MODEL_PS_2_0 ) + baseColor = lerp( baseColor, baseColor2, lerpAlpha ); +#endif + +#if PHONG + float3 vSpecMask = 1; + +# if PHONGMASK == PHONGMASK_BASEALPHA + vSpecMask = baseColor.a; +# elif PHONGMASK == PHONGMASK_NORMALALPHA + vSpecMask = vNormal.a; +# elif PHONGMASK == PHONGMASK_STANDALONE + vSpecMask = tex2D( PhongMaskSampler, baseTexCoords ).rgb; +# endif +#endif + +#if DETAILTEXTURE + float4 detailColor = float4( g_DetailConstants.xyz, 1.0f ) * tex2D( DetailSampler, i.detailCoords ); + float4 vBase = TextureCombine( float4(baseColor.xyz, 1.0f), detailColor, DETAIL_BLEND_MODE, g_DetailConstants.w ); + baseColor.xyz = vBase.xyz; +#endif + +#if NORMALMAP == 0 + float3 worldPosToLightVector = texCUBE( NormalizingCubemapSampler, i.worldPosToLightVector ) * 2.0f - 1.0f; + float nDotL = dot( worldPosToLightVector, vNormal.xyz ); +#endif + +#if NORMALMAP == 1 + // flashlightfixme: wrap this! + float3 tangentPosToLightVector = texCUBE( NormalizingCubemapSampler, i.tangentPosToLightVector.xyz ) * 2.0f - 1.0f; + float nDotL = dot( tangentPosToLightVector, vNormal.xyz ); +#endif + +#if NORMALMAP == 2 + float3 tangentPosToLightVector = texCUBE( NormalizingCubemapSampler, i.tangentPosToLightVector.xyz ) * 2.0f - 1.0f; + + float nDotL = + vNormal.x*dot( tangentPosToLightVector, bumpBasis[0]) + + vNormal.y*dot( tangentPosToLightVector, bumpBasis[1]) + + vNormal.z*dot( tangentPosToLightVector, bumpBasis[2]); +#endif + + float3 outColor; +#if PHONG == 0 + outColor = spotColor * baseColor.xyz * saturate( nDotL ); + outColor *= flAtten; +#else + outColor = spotColor * baseColor.xyz * flAtten; + + // Not using normalizing cubemap here because of pixelated specular appearance. =/ +# if NORMALMAP == 0 + float3 posToLight = normalize( i.worldPosToLightVector ); + float3 posToEye = normalize( g_EyePos.xyz - i.worldPos_worldTransition.xyz); +# else + float3 posToLight = normalize( i.tangentPosToLightVector.xyz ); + float3 posToEye = normalize( float3(i.tangentPosToLightVector.w, i.normalMapTexCoord.zw) ); + +# if NORMALMAP == 2 + vNormal.xyz = bumpBasis[0]*vNormal.x + bumpBasis[1]*vNormal.y + bumpBasis[2]*vNormal.z; + vNormal.xyz = normalize( vNormal.xyz ); +# endif +# endif + + float fFresnel = Fresnel( vNormal.xyz, posToEye, g_FresnelRanges ); + float3 specularColor = outColor * SpecularLight( vNormal.xyz, posToLight, g_SpecularExponent, posToEye, false, SpotSampler, fFresnel ); + outColor *= saturate( nDotL ); + outColor += specularColor * fFresnel * vSpecMask * g_SpecularBoost; +#endif + + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.z, i.worldPos_worldTransition.z, i.projPos.z ); + return FinalOutput( float4(outColor, baseColor.a) , fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR ); + + // so we can jump over all of the above +#if ( defined( _X360 ) ) + } + } +#endif + +} \ No newline at end of file diff --git a/src/materialsystem/stdshaders/lightmappedgeneric_flashlight_vs20.fxc b/src/materialsystem/stdshaders/lightmappedgeneric_flashlight_vs20.fxc index 7d23bb95..f8bc1487 100644 --- a/src/materialsystem/stdshaders/lightmappedgeneric_flashlight_vs20.fxc +++ b/src/materialsystem/stdshaders/lightmappedgeneric_flashlight_vs20.fxc @@ -1,4 +1,4 @@ -//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. ======= +//====== Copyright � 1996-2004, Valve Corporation, All rights reserved. ======= // // Purpose: // @@ -8,8 +8,14 @@ // STATIC: "WORLDVERTEXTRANSITION" "0..1" // STATIC: "SEAMLESS" "0..1" // STATIC: "DETAIL" "0..1" +// STATIC: "PHONG" "0..1" +// STATIC: "BASETEXTURETRANSFORM2" "0..1" // DYNAMIC: "DOWATERFOG" "0..1" +// SKIP: $BASETEXTURETRANSFORM2 && !$WORLDVERTEXTRANSITION +// SKIP: $BASETEXTURETRANSFORM2 && $SEAMLESS +// SKIP: $BASETEXTURETRANSFORM2 && $PHONG + #include "common_vs_fxc.h" const float3 g_FlashlightPos : register( SHADER_SPECIFIC_CONST_0 ); @@ -22,6 +28,11 @@ const float4 SeamlessScale : register( SHADER_SPECIFIC_CONST_6 ); #endif const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_6 ); const float4 cNormalMapOrDetailTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_8 ); +#if PHONG +const float3 g_EyePos : register( SHADER_SPECIFIC_CONST_10 ); +#elif BASETEXTURETRANSFORM2 +const float4 cBaseTexCoordTransform2[2] : register( SHADER_SPECIFIC_CONST_10 ); // Blixibon - Support for $basetexturetransform2 +#endif static const int g_FogType = DOWATERFOG; @@ -51,13 +62,23 @@ struct VS_OUTPUT #if SEAMLESS float3 SeamlessTexCoord : TEXCOORD1; +#else +#if BASETEXTURETRANSFORM2 + // Blixibon - Using two extra floats for $basetexturetransform2 + float4 baseTexCoord : TEXCOORD1; #else float2 baseTexCoord : TEXCOORD1; #endif +#endif #if NORMALMAP +#if PHONG + float4 tangentPosToLightVector : TEXCOORD2; + float4 normalMapTexCoord : TEXCOORD3; +#else float3 tangentPosToLightVector : TEXCOORD2; float2 normalMapTexCoord : TEXCOORD3; +#endif #else float3 worldPosToLightVector : TEXCOORD2; float3 normal : TEXCOORD3; @@ -131,6 +152,10 @@ VS_OUTPUT main( const VS_INPUT v ) #if (SEAMLESS == 0 ) o.baseTexCoord.x = dot( v.vBaseTexCoord, cBaseTexCoordTransform[0] ) + cBaseTexCoordTransform[0].w; o.baseTexCoord.y = dot( v.vBaseTexCoord, cBaseTexCoordTransform[1] ) + cBaseTexCoordTransform[1].w; +#if BASETEXTURETRANSFORM2 + o.baseTexCoord.w = dot( v.vBaseTexCoord, cBaseTexCoordTransform2[0] ) + cBaseTexCoordTransform2[0].w; + o.baseTexCoord.z = dot( v.vBaseTexCoord, cBaseTexCoordTransform2[1] ) + cBaseTexCoordTransform2[1].w; +#endif #endif #endif @@ -146,9 +171,9 @@ VS_OUTPUT main( const VS_INPUT v ) #else #if SEAMLESS - o.normalMapTexCoord = v.vBaseTexCoord; + o.normalMapTexCoord.xy = v.vBaseTexCoord; #else - o.normalMapTexCoord = o.baseTexCoord; + o.normalMapTexCoord.xy = o.baseTexCoord.xy; // Blixibon - Had to change this to .xy because BASETEXTURETRANSFORM2 makes this float4 #endif #endif @@ -156,6 +181,14 @@ VS_OUTPUT main( const VS_INPUT v ) o.tangentPosToLightVector.x = dot( worldPosToLightVector, worldTangentS ); o.tangentPosToLightVector.y = dot( worldPosToLightVector, worldTangentT ); o.tangentPosToLightVector.z = dot( worldPosToLightVector, worldNormal ); + +#if PHONG + float3 worldPosToEyeVector = g_EyePos - worldPos; + o.tangentPosToLightVector.w = dot( worldPosToEyeVector, worldTangentS ); + o.normalMapTexCoord.z = dot( worldPosToEyeVector, worldTangentT ); + o.normalMapTexCoord.w = dot( worldPosToEyeVector, worldNormal ); +#endif + #else o.worldPosToLightVector = worldPosToLightVector; o.normal = worldNormal; @@ -181,4 +214,4 @@ VS_OUTPUT main( const VS_INPUT v ) #endif return o; -} +} \ No newline at end of file diff --git a/src/materialsystem/stdshaders/lightmappedgeneric_ps2_3_x.h b/src/materialsystem/stdshaders/lightmappedgeneric_ps2_3_x.h index ccb687ea..e0b51180 100644 --- a/src/materialsystem/stdshaders/lightmappedgeneric_ps2_3_x.h +++ b/src/materialsystem/stdshaders/lightmappedgeneric_ps2_3_x.h @@ -10,6 +10,7 @@ // SKIP: !$FASTPATH && $FASTPATHENVMAPTINT // SKIP: !$BUMPMAP && $DIFFUSEBUMPMAP // SKIP: !$BUMPMAP && $BUMPMAP2 +// SKIP: !$BUMPMAP2 && $BUMPMASK // SKIP: $ENVMAPMASK && $BUMPMAP2 // SKIP: $BASETEXTURENOENVMAP && ( !$BASETEXTURE2 || !$CUBEMAP ) // SKIP: $BASETEXTURE2NOENVMAP && ( !$BASETEXTURE2 || !$CUBEMAP ) @@ -28,6 +29,11 @@ // 360 compiler fails on some combo in this family. Content doesn't use blendmode 10 anyway // SKIP: $FASTPATH && $PIXELFOGTYPE && $BASETEXTURE2 && $DETAILTEXTURE && $CUBEMAP && ($DETAIL_BLEND_MODE == 10 ) [XBOX] +// Too many instructions to do this all at once: +// SKIP: $FANCY_BLENDING && $BUMPMAP && $DETAILTEXTURE + +// SKIP: (!$FANCY_BLENDING) && $MASKEDBLENDING + // debug : // NOSKIP: $DETAILTEXTURE // NOSKIP: $CUBEMAP @@ -101,6 +107,20 @@ const float3 g_FlashlightPos : register( c14 ); const float4x4 g_FlashlightWorldToTexture : register( c15 ); // through c18 const float4 g_ShadowTweaks : register( c19 ); +#if PARALLAXCORRECT +// Parallax cubemaps +const float4 cubemapPos : register(c21); +const float4x4 obbMatrix : register(c22); //through c25 +#define g_BlendInverted cubemapPos.w +#else +// Blixibon - Hammer apparently has a bug that causes the vertex blend to get swapped. +// Hammer uses a special internal shader to nullify this, but it doesn't work with custom shaders. +// Downfall got around this by swapping around the base textures in the DLL code when drawn by the editor. +// Doing it here in the shader itself allows us to retain other properties, like FANCY_BLENDING. +// TODO: This may be inefficent usage of a constant +const HALF g_BlendInverted : register(c21); +#endif + sampler BaseTextureSampler : register( s0 ); sampler LightmapSampler : register( s1 ); @@ -158,7 +178,7 @@ struct PS_INPUT float3 SeamlessTexCoord : TEXCOORD0; // zy xz float4 detailOrBumpAndEnvmapMaskTexCoord : TEXCOORD1; // envmap mask #else - HALF2 baseTexCoord : TEXCOORD0; + HALF4 baseTexCoord : TEXCOORD0; // Blixibon - Was HALF2, using two extra floats for $basetexturetransform2 // detail textures and bumpmaps are mutually exclusive so that we have enough texcoords. #if ( RELIEF_MAPPING == 0 ) HALF4 detailOrBumpAndEnvmapMaskTexCoord : TEXCOORD1; @@ -207,12 +227,26 @@ HALF4 main( PS_INPUT i ) : COLOR #if SEAMLESS baseTexCoords = i.SeamlessTexCoord.xyz; -#else - baseTexCoords.xy = i.baseTexCoord.xy; -#endif + // Now only used with seamless due to $basetexturetransform2 fix (see below) GetBaseTextureAndNormal( BaseTextureSampler, BaseTextureSampler2, BumpmapSampler, bBaseTexture2, bBumpmap || bNormalMapAlphaEnvmapMask, baseTexCoords, i.vertexColor.rgb, baseColor, baseColor2, vNormal ); +#else + baseTexCoords.xy = i.baseTexCoord.xy; + + // Blixibon - Simpler version of GetBaseTextureAndNormal() that supports $basetexturetransform2 + // (make this its own function in common_lightmappedgeneric_fxc.h if this becomes more widespread) + // + // Original behavior in DX9 was for $basetexturetransform to influence $basetexture2, so + // the vertex shader copies the coords from $basetexturetransform unless $basetexturetransform2 + // is explicitly defined. + baseColor = tex2D( BaseTextureSampler, baseTexCoords.xy ); + baseColor2 = tex2D( BaseTextureSampler2, i.baseTexCoord.wz ); + if ( bBumpmap || bNormalMapAlphaEnvmapMask ) + { + vNormal = tex2D( BumpmapSampler, baseTexCoords.xy ); + } +#endif #if BUMPMAP == 1 // not ssbump vNormal.xyz = vNormal.xyz * 2.0f - 1.0f; // make signed if we're not ssbump @@ -311,26 +345,31 @@ HALF4 main( PS_INPUT i ) : COLOR #if MASKEDBLENDING float blendfactor=0.5; #else + float blendfactor=i.vertexBlendX_fogFactorW.r; + + // See g_BlendInverted's declaration for more info on this + if (g_BlendInverted > 0.0) + { + blendfactor=1.0f-blendfactor; + } + #endif if( bBaseTexture2 ) { #if (SELFILLUM == 0) && (PIXELFOGTYPE != PIXEL_FOG_TYPE_HEIGHT) && (FANCY_BLENDING) - float4 modt=tex2D(BlendModulationSampler,i.lightmapTexCoord3.zw); + float4 modt=tex2D(BlendModulationSampler,baseTexCoords); #if MASKEDBLENDING - // FXC is unable to optimize this, despite blendfactor=0.5 above - //float minb=modt.g-modt.r; - //float maxb=modt.g+modt.r; - //blendfactor=smoothstep(minb,maxb,blendfactor); - blendfactor=modt.g; + float minb=modt.g-modt.r; + float maxb=modt.g+modt.r; #else - float minb=saturate(modt.g-modt.r); - float maxb=saturate(modt.g+modt.r); + float minb=max(0,modt.g-modt.r); + float maxb=min(1,modt.g+modt.r); +#endif blendfactor=smoothstep(minb,maxb,blendfactor); #endif -#endif - baseColor.rgb = lerp( baseColor, baseColor2.rgb, blendfactor ); + baseColor.rgb = lerp( baseColor.rgb, baseColor2.rgb, blendfactor ); blendedAlpha = lerp( baseColor.a, baseColor2.a, blendfactor ); } @@ -414,7 +453,7 @@ HALF4 main( PS_INPUT i ) : COLOR albedo *= baseColor; if( !bBaseAlphaEnvmapMask && !bSelfIllum ) { - alpha *= baseColor.a; + alpha *= blendedAlpha; // Blixibon - Replaced baseColor.a with blendedAlpha } if( bDetailTexture ) @@ -424,7 +463,7 @@ HALF4 main( PS_INPUT i ) : COLOR // The vertex color contains the modulation color + vertex color combined #if ( SEAMLESS == 0 ) - albedo.xyz *= i.vertexColor; + albedo.xyz *= i.vertexColor.xyz; #endif alpha *= i.vertexColor.a * g_flAlpha2; // not sure about this one @@ -447,9 +486,9 @@ HALF4 main( PS_INPUT i ) : COLOR vNormal.xyz = normalize( bumpBasis[0]*vNormal.x + bumpBasis[1]*vNormal.y + bumpBasis[2]*vNormal.z); #else float3 dp; - dp.x = saturate( dot( vNormal, bumpBasis[0] ) ); - dp.y = saturate( dot( vNormal, bumpBasis[1] ) ); - dp.z = saturate( dot( vNormal, bumpBasis[2] ) ); + dp.x = saturate( dot( vNormal.xyz, bumpBasis[0] ) ); + dp.y = saturate( dot( vNormal.xyz, bumpBasis[1] ) ); + dp.z = saturate( dot( vNormal.xyz, bumpBasis[2] ) ); dp *= dp; #if ( DETAIL_BLEND_MODE == TCOMBINE_SSBUMP_BUMP ) @@ -476,7 +515,7 @@ HALF4 main( PS_INPUT i ) : COLOR #endif #if CUBEMAP || LIGHTING_PREVIEW || ( defined( _X360 ) && FLASHLIGHT ) - float3 worldSpaceNormal = mul( vNormal, i.tangentSpaceTranspose ); + float3 worldSpaceNormal = mul( vNormal.xyz, i.tangentSpaceTranspose ); #endif float3 diffuseComponent = albedo.xyz * diffuseLighting; @@ -514,8 +553,8 @@ HALF4 main( PS_INPUT i ) : COLOR if( bSelfIllum ) { - float3 selfIllumComponent = g_SelfIllumTint * albedo.xyz; - diffuseComponent = lerp( diffuseComponent, selfIllumComponent, baseColor.a ); + float3 selfIllumComponent = g_SelfIllumTint.xyz * albedo.xyz; + diffuseComponent = lerp( diffuseComponent, selfIllumComponent, blendedAlpha ); // Blixibon - Replaced baseColor.a with blendedAlpha } HALF3 specularLighting = HALF3( 0.0f, 0.0f, 0.0f ); @@ -531,10 +570,27 @@ HALF4 main( PS_INPUT i ) : COLOR fresnel = pow( fresnel, 5.0 ); fresnel = fresnel * g_OneMinusFresnelReflection + g_FresnelReflection; +#if PARALLAXCORRECT + //Parallax correction (2_0b and beyond) + //Adapted from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ + float3 worldPos = i.worldPos_projPosZ.xyz; + float3 positionLS = mul(float4(worldPos, 1), obbMatrix); + float3 rayLS = mul(reflectVect, (float3x3) obbMatrix); + + float3 firstPlaneIntersect = (float3(1.0f, 1.0f, 1.0f) - positionLS) / rayLS; + float3 secondPlaneIntersect = (-positionLS) / rayLS; + float3 furthestPlane = max(firstPlaneIntersect, secondPlaneIntersect); + float distance = min(furthestPlane.x, min(furthestPlane.y, furthestPlane.z)); + + // Use distance in WS directly to recover intersection + float3 intersectPositionWS = worldPos + reflectVect * distance; + reflectVect = intersectPositionWS - cubemapPos; +#endif + specularLighting = ENV_MAP_SCALE * texCUBE( EnvmapSampler, reflectVect ); specularLighting *= specularFactor; - specularLighting *= g_EnvmapTint; + specularLighting *= g_EnvmapTint.rgb; #if FANCY_BLENDING == 0 HALF3 specularLightingSquared = specularLighting * specularLighting; specularLighting = lerp( specularLighting, specularLightingSquared, g_EnvmapContrast ); diff --git a/src/materialsystem/stdshaders/lightmappedgeneric_ps2x.fxc b/src/materialsystem/stdshaders/lightmappedgeneric_ps2x.fxc index 7ea2e5b9..17c1ab66 100644 --- a/src/materialsystem/stdshaders/lightmappedgeneric_ps2x.fxc +++ b/src/materialsystem/stdshaders/lightmappedgeneric_ps2x.fxc @@ -13,17 +13,18 @@ // STATIC: "BASETEXTURE2NOENVMAP" "0..1" // STATIC: "WARPLIGHTING" "0..1" // STATIC: "FANCY_BLENDING" "0..1" -// STATIC: "RELIEF_MAPPING" "0..0" [ps20b] +// STATIC: "RELIEF_MAPPING" "0..0" [ps20b] [ps30] // STATIC: "SEAMLESS" "0..1" -// STATIC: "OUTLINE" "0..1" -// STATIC: "SOFTEDGES" "0..1" +// STATIC: "OUTLINE" "0..0" +// STATIC: "SOFTEDGES" "0..0" // STATIC: "BUMPMASK" "0..1" // STATIC: "NORMAL_DECODE_MODE" "0..0" [XBOX] // STATIC: "NORMAL_DECODE_MODE" "0..0" [PC] // STATIC: "NORMALMASK_DECODE_MODE" "0..0" [XBOX] // STATIC: "NORMALMASK_DECODE_MODE" "0..0" [PC] // STATIC: "DETAIL_BLEND_MODE" "0..11" -// STATIC: "FLASHLIGHT" "0..1" [ps20b] [XBOX] +// STATIC: "FLASHLIGHT" "0..1" [ps20b] [ps30] [XBOX] +// STATIC: "PARALLAXCORRECT" "0..1" [ps20b] [ps30] // DYNAMIC: "FASTPATHENVMAPCONTRAST" "0..1" // DYNAMIC: "FASTPATH" "0..1" @@ -31,11 +32,11 @@ // DYNAMIC: "PIXELFOGTYPE" "0..2" // DYNAMIC: "LIGHTING_PREVIEW" "0..2" [PC] // DYNAMIC: "LIGHTING_PREVIEW" "0..0" [XBOX] -// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC] -// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX] -// DYNAMIC: "BICUBIC_LIGHTMAP" "0..1" [ps20b] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [ps30] [PC] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [ps30] [XBOX] +// DYNAMIC: "BICUBIC_LIGHTMAP" "0..1" [ps20b] [ps30] -// SKIP: $SEAMLESS && $RELIEF_MAPPING [ps20b] +// SKIP: $SEAMLESS && $RELIEF_MAPPING [ps20b] [ps30] // SKIP: (! $DETAILTEXTURE) && ( $DETAIL_BLEND_MODE != 0 ) @@ -56,5 +57,9 @@ // SKIP ($DETAIL_BLEND_MODE == 10 ) && ($BUMPMAP == 0 ) // SKIP ($DETAIL_BLEND_MODE == 11 ) && ($BUMPMAP != 0 ) +// SKIP: ($PARALLAXCORRECT) && ( !$CUBEMAP ) +// SKIP: ($PARALLAXCORRECT) && ( $LIGHTING_PREVIEW) +// SKIP: ($PARALLAXCORRECT) && ( $OUTLINE || $SOFTEDGES) + #include "lightmappedgeneric_ps2_3_x.h" diff --git a/src/materialsystem/stdshaders/lightmappedgeneric_vs20.fxc b/src/materialsystem/stdshaders/lightmappedgeneric_vs20.fxc index 362eb668..5fa871a1 100644 --- a/src/materialsystem/stdshaders/lightmappedgeneric_vs20.fxc +++ b/src/materialsystem/stdshaders/lightmappedgeneric_vs20.fxc @@ -8,12 +8,15 @@ // STATIC: "SEAMLESS" "0..1" // STATIC: "BUMPMASK" "0..1" // STATIC: "FLASHLIGHT" "0..1" [XBOX] +// STATIC: "BASETEXTURETRANSFORM2" "0..1" // DYNAMIC: "FASTPATH" "0..1" // DYNAMIC: "DOWATERFOG" "0..1" // DYNAMIC: "LIGHTING_PREVIEW" "0..1" [PC] // DYNAMIC: "LIGHTING_PREVIEW" "0..0" [XBOX] +// SKIP: $SEAMLESS && $BASETEXTURETRANSFORM2 + // This should not be a combo since I'm a moron with the tangent space and the flashlight. // SKIP: !$BUMPMAP && $DIFFUSEBUMPMAP // SKIP: $SEAMLESS && $RELIEF_MAPPING @@ -36,6 +39,9 @@ const float4 SeamlessScale : register( SHADER_SPECIFIC_CONST_0 ); #define SEAMLESS_SCALE (SeamlessScale.x) #else const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); +#if BASETEXTURETRANSFORM2 +const float4 cBaseTexCoordTransform2[2] : register( SHADER_SPECIFIC_CONST_8 ); // Blixibon - Support for $basetexturetransform2 +#endif const float4 cDetailOrBumpTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_2 ); #endif // This should be identity if we are bump mapping, otherwise we'll screw up the lightmapTexCoordOffset. @@ -58,7 +64,7 @@ struct VS_INPUT struct VS_OUTPUT { float4 projPos : POSITION; -#if !defined( _X360 ) +#if !defined( _X360 ) && !defined(SHADER_MODEL_VS_3_0) float fog : FOG; #endif @@ -66,7 +72,7 @@ struct VS_OUTPUT float3 SeamlessTexCoord : TEXCOORD0; // x y z float4 detailOrBumpAndEnvmapMaskTexCoord : TEXCOORD1; // envmap mask #else - float2 baseTexCoord : TEXCOORD0; + float4 baseTexCoord : TEXCOORD0; // Blixibon - Was float2, now using two extra floats for $basetexturetransform2 // detail textures and bumpmaps are mutually exclusive so that we have enough texcoords. #if RELIEF_MAPPING float3 TangentSpaceViewRay : TEXCOORD1; @@ -86,12 +92,10 @@ struct VS_OUTPUT float4 vertexBlendX_fogFactorW : COLOR1; // Extra iterators on 360, used in flashlight combo -#if defined( _X360 ) -#if FLASHLIGHT +#if defined( _X360 ) && FLASHLIGHT float4 flashlightSpacePos : TEXCOORD8; float4 vProjPos : TEXCOORD9; #endif -#endif }; @@ -143,11 +147,19 @@ VS_OUTPUT main( const VS_INPUT v ) if (FASTPATH) { o.baseTexCoord.xy = v.vBaseTexCoord; + o.baseTexCoord.wz = v.vBaseTexCoord; } else { o.baseTexCoord.x = dot( v.vBaseTexCoord, cBaseTexCoordTransform[0] ) + cBaseTexCoordTransform[0].w; o.baseTexCoord.y = dot( v.vBaseTexCoord, cBaseTexCoordTransform[1] ) + cBaseTexCoordTransform[1].w; +#if BASETEXTURETRANSFORM2 + o.baseTexCoord.w = dot( v.vBaseTexCoord, cBaseTexCoordTransform2[0] ) + cBaseTexCoordTransform2[0].w; + o.baseTexCoord.z = dot( v.vBaseTexCoord, cBaseTexCoordTransform2[1] ) + cBaseTexCoordTransform2[1].w; +#else + o.baseTexCoord.w = o.baseTexCoord.x; + o.baseTexCoord.z = o.baseTexCoord.y; +#endif } #if ( RELIEF_MAPPING == 0 ) { @@ -206,7 +218,7 @@ VS_OUTPUT main( const VS_INPUT v ) #endif o.vertexBlendX_fogFactorW = CalcFog( worldPos, vProjPos, g_FogType ); -#if !defined( _X360 ) +#if !defined( _X360 ) && !defined(SHADER_MODEL_VS_3_0) o.fog = o.vertexBlendX_fogFactorW; #endif @@ -238,11 +250,9 @@ VS_OUTPUT main( const VS_INPUT v ) #endif // On 360, we have extra iterators and can fold the flashlight into this shader -#if defined( _X360 ) - #if FLASHLIGHT - o.flashlightSpacePos = mul( float4( worldPos, 1.0f ), g_FlashlightWorldToTexture ); - o.vProjPos = vProjPos; - #endif +#if defined( _X360 ) && FLASHLIGHT + o.flashlightSpacePos = mul( float4( worldPos, 1.0f ), g_FlashlightWorldToTexture ); + o.vProjPos = vProjPos; #endif if ( g_bVertexAlphaTexBlendFactor ) diff --git a/src/materialsystem/stdshaders/mapbase_sdk_stubs.cpp b/src/materialsystem/stdshaders/mapbase_sdk_stubs.cpp index 68094330..673f5d79 100644 --- a/src/materialsystem/stdshaders/mapbase_sdk_stubs.cpp +++ b/src/materialsystem/stdshaders/mapbase_sdk_stubs.cpp @@ -39,3 +39,4 @@ SHADER_SDK_LEGACY_STUB( SDK_UnlitTwoTexture, "UnlitTwoTexture" ) SHADER_SDK_LEGACY_STUB( SDK_MonitorScreen, "MonitorScreen" ) SHADER_SDK_LEGACY_STUB( SDK_ShatteredGlass, "ShatteredGlass" ) SHADER_SDK_LEGACY_STUB( SDK_WindowImposter, "WindowImposter" ) +SHADER_SDK_LEGACY_STUB( SDK_Engine_Post, "Engine_Post" ) diff --git a/src/materialsystem/stdshaders/mapbaseshaders_dx9_20b.txt b/src/materialsystem/stdshaders/mapbaseshaders_dx9_20b.txt new file mode 100644 index 00000000..207330ec --- /dev/null +++ b/src/materialsystem/stdshaders/mapbaseshaders_dx9_20b.txt @@ -0,0 +1,121 @@ +// +// New shaders collection +// +// These shaders are compiled as shader model 2.0/2.0b +// using the new compiler. +// _ps20.vcs +// _ps20b.vcs +// _vs20.vcs +// + +Bloom_ps2x.fxc + +bloomadd_ps11.fxc +bloomadd_ps2x.fxc + +BlurFilter_ps2x.fxc +BlurFilter_vs20.fxc + +cable_ps2x.fxc +cable_vs20.fxc + +cloak_blended_pass_ps2x.fxc +cloak_blended_pass_vs20.fxc + +// NOTE: This is BROKEN at base level right now +// See hack in core_ps2x.fxc +core_ps2x.fxc +core_vs20.fxc + +decalmodulate_ps2x.fxc +decalmodulate_vs20.fxc + +depthwrite_ps2x.fxc +depthwrite_vs20.fxc + +emissive_scroll_blended_pass_ps2x.fxc +emissive_scroll_blended_pass_vs20.fxc + +Engine_Post_ps2x.fxc + +eye_refract_ps2x.fxc +eye_refract_vs20.fxc + +eyes_ps2x.fxc +Eyes_vs20.fxc + +eyes_flashlight_ps2x.fxc +eyes_flashlight_vs20.fxc + +eyeglint_vs20.fxc +eyeglint_ps2x.fxc + +flashlight_ps11.fxc +flashlight_ps2x.fxc + +flesh_interior_blended_pass_ps2x.fxc +flesh_interior_blended_pass_vs20.fxc + +lightmappedgeneric_decal_ps2x.fxc +lightmappedgeneric_decal_vs20.fxc +lightmappedgeneric_flashlight_ps2x.fxc +lightmappedgeneric_flashlight_vs11.fxc +lightmappedgeneric_flashlight_vs20.fxc +lightmappedgeneric_ps2x.fxc +lightmappedgeneric_vs20.fxc + +lightmappedreflective_ps2x.fxc +lightmappedreflective_vs20.fxc + +monitorscreen_ps2x.fxc + +refract_ps2x.fxc +Refract_vs20.fxc + +screenspaceeffect_vs11.fxc +screenspaceeffect_vs20.fxc + +ShatteredGlass_ps2x.fxc +ShatteredGlass_vs20.fxc + +skin_ps20b.fxc +skin_vs20.fxc + +sprite_ps2x.fxc +sprite_vs20.fxc + +splinerope_ps2x.fxc +splinerope_vs20.fxc + +teeth_ps2x.fxc +teeth_vs20.fxc +teeth_bump_ps2x.fxc +teeth_bump_vs20.fxc +teeth_flashlight_ps2x.fxc +teeth_flashlight_vs20.fxc + +unlitgeneric_ps2x.fxc +unlitgeneric_vs20.fxc + +unlittwotexture_ps2x.fxc +unlittwotexture_vs20.fxc + +vertexlit_and_unlit_generic_bump_ps2x.fxc +vertexlit_and_unlit_generic_bump_vs20.fxc + +vertexlit_and_unlit_generic_ps2x.fxc +vertexlit_and_unlit_generic_vs20.fxc + +vortwarp_ps2x.fxc +vortwarp_vs20.fxc + +water_ps2x.fxc +Water_vs20.fxc + +WaterCheap_ps2x.fxc +WaterCheap_vs20.fxc + +windowimposter_ps2x.fxc +windowimposter_vs20.fxc + +worldtwotextureblend_ps2x.fxc diff --git a/src/materialsystem/stdshaders/mapbaseshaders_dx9_30.txt b/src/materialsystem/stdshaders/mapbaseshaders_dx9_30.txt new file mode 100644 index 00000000..6abd06d6 --- /dev/null +++ b/src/materialsystem/stdshaders/mapbaseshaders_dx9_30.txt @@ -0,0 +1,41 @@ +// +// 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 +// + +cloak_blended_pass_vs20.fxc +cloak_blended_pass_ps2x.fxc +decalmodulate_ps2x.fxc +decalmodulate_vs20.fxc +emissive_scroll_blended_pass_vs20.fxc +emissive_scroll_blended_pass_ps2x.fxc +eye_refract_vs20.fxc +eye_refract_ps2x.fxc +Eyes_vs20.fxc +eyes_ps2x.fxc +eyes_flashlight_vs20.fxc +eyes_flashlight_ps2x.fxc +lightmappedgeneric_ps2x.fxc +lightmappedgeneric_vs20.fxc +lightmappedgeneric_flashlight_vs20.fxc +lightmappedgeneric_flashlight_ps2x.fxc +skin_vs20.fxc +skin_ps20b.fxc +teeth_vs20.fxc +teeth_ps2x.fxc +teeth_bump_vs20.fxc +teeth_bump_ps2x.fxc +teeth_flashlight_vs20.fxc +teeth_flashlight_ps2x.fxc +vertexlit_and_unlit_generic_vs20.fxc +vertexlit_and_unlit_generic_ps2x.fxc +vertexlit_and_unlit_generic_bump_vs20.fxc +vertexlit_and_unlit_generic_bump_ps2x.fxc +vortwarp_vs20.fxc +vortwarp_ps2x.fxc +depthwrite_ps2x.fxc +depthwrite_vs20.fxc \ No newline at end of file diff --git a/src/materialsystem/stdshaders/monitorscreen_ps2x.fxc b/src/materialsystem/stdshaders/monitorscreen_ps2x.fxc index 2387e75d..204ceac1 100644 --- a/src/materialsystem/stdshaders/monitorscreen_ps2x.fxc +++ b/src/materialsystem/stdshaders/monitorscreen_ps2x.fxc @@ -1,6 +1,8 @@ -// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] -// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// +//paired with unlittwotexture_vs20 + // STATIC: "TEXTURE2" "0..1" + // DYNAMIC: "PIXELFOGTYPE" "0..1" // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC] // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX] @@ -48,6 +50,6 @@ float4 main( PS_INPUT i ) : COLOR resultColor.rgb = lerp( tempColor.rgb, resultColor.rgb, g_Saturation.rgb ); // blend between color and greyscale resultColor.rgb = resultColor.rgb * g_Tint.rgb; // tint - float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.z, i.worldPos_projPosZ.z, i.worldPos_projPosZ.w ); + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); return FinalOutput( resultColor, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_NONE, (WRITE_DEPTH_TO_DESTALPHA != 0), i.worldPos_projPosZ.w ); } diff --git a/src/materialsystem/stdshaders/refract_dx9_helper.cpp b/src/materialsystem/stdshaders/refract_dx9_helper.cpp index c6847f5e..3a0de0e0 100644 --- a/src/materialsystem/stdshaders/refract_dx9_helper.cpp +++ b/src/materialsystem/stdshaders/refract_dx9_helper.cpp @@ -76,6 +76,19 @@ void InitRefract_DX9( CBaseVSShader *pShader, IMaterialVar** params, Refract_DX9 if( params[info.m_nEnvmap]->IsDefined() ) { pShader->LoadCubeMap( info.m_nEnvmap, TEXTUREFLAGS_SRGB ); + +#ifdef MAPBASE + if (mat_specular_disable_on_missing.GetBool()) + { + // Revert to defaultcubemap when the envmap texture is missing + // (should be equivalent to toolsblack in Mapbase) + if (!IS_FLAG_SET( MATERIAL_VAR_MODEL ) && params[info.m_nEnvmap]->GetTextureValue()->IsError()) + { + params[info.m_nEnvmap]->SetStringValue( "engine/defaultcubemap" ); + pShader->LoadCubeMap( info.m_nEnvmap, TEXTUREFLAGS_SRGB ); + } + } +#endif } if( params[info.m_nRefractTintTexture]->IsDefined() ) { diff --git a/src/materialsystem/stdshaders/shatteredglass.cpp b/src/materialsystem/stdshaders/shatteredglass.cpp index 88fee048..b96bd332 100644 --- a/src/materialsystem/stdshaders/shatteredglass.cpp +++ b/src/materialsystem/stdshaders/shatteredglass.cpp @@ -29,6 +29,14 @@ BEGIN_VS_SHADER( ShatteredGlass, SHADER_PARAM( ENVMAPSATURATION, SHADER_PARAM_TYPE_FLOAT, "1.0", "saturation 0 == greyscale 1 == normal" ) SHADER_PARAM( FRESNELREFLECTION, SHADER_PARAM_TYPE_FLOAT, "1.0", "1.0 == mirror, 0.0 == water" ) SHADER_PARAM( UNLITFACTOR, SHADER_PARAM_TYPE_FLOAT, "0.7", "0.0 == multiply by lightmap, 1.0 == multiply by 1" ) +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps + SHADER_PARAM( ENVMAPPARALLAX, SHADER_PARAM_TYPE_BOOL, "0", "Enables parallax correction code for env_cubemaps" ) + SHADER_PARAM( ENVMAPPARALLAXOBB1, SHADER_PARAM_TYPE_VEC4, "[1 0 0 0]", "The first line of the parallax correction OBB matrix" ) + SHADER_PARAM( ENVMAPPARALLAXOBB2, SHADER_PARAM_TYPE_VEC4, "[0 1 0 0]", "The second line of the parallax correction OBB matrix" ) + SHADER_PARAM( ENVMAPPARALLAXOBB3, SHADER_PARAM_TYPE_VEC4, "[0 0 1 0]", "The third line of the parallax correction OBB matrix" ) + SHADER_PARAM( ENVMAPORIGIN, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "The world space position of the env_cubemap being corrected" ) +#endif END_SHADER_PARAMS SHADER_INIT_PARAMS() @@ -106,6 +114,19 @@ BEGIN_VS_SHADER( ShatteredGlass, if (params[ENVMAP]->IsDefined()) { LoadCubeMap( ENVMAP ); +#ifdef MAPBASE + if (mat_specular_disable_on_missing.GetBool()) + { + // Revert to defaultcubemap when the envmap texture is missing + // (should be equivalent to toolsblack in Mapbase) + if (params[ENVMAP]->GetTextureValue()->IsError()) + { + params[ENVMAP]->SetStringValue( "engine/defaultcubemap" ); + LoadCubeMap( ENVMAP ); + } + } +#endif + if ( params[ENVMAPMASK]->IsDefined() ) { LoadTexture( ENVMAPMASK, g_pHardwareConfig->GetHDRType() == HDR_TYPE_NONE ? TEXTUREFLAGS_SRGB : 0 ); @@ -117,9 +138,17 @@ BEGIN_VS_SHADER( ShatteredGlass, { bool bHasEnvmapMask = false; bool bHasEnvmap = false; +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps + bool hasParallaxCorrection = false; +#endif if ( params[ENVMAP]->IsTexture() ) { bHasEnvmap = true; +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps + hasParallaxCorrection = params[ENVMAPPARALLAX]->GetIntValue() > 0; +#endif if ( params[ENVMAPMASK]->IsTexture() ) { bHasEnvmapMask = true; @@ -208,6 +237,12 @@ BEGIN_VS_SHADER( ShatteredGlass, SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, bHasEnvmapMask ); SET_STATIC_PIXEL_SHADER_COMBO( BASEALPHAENVMAPMASK, bHasBaseAlphaEnvmapMask ); SET_STATIC_PIXEL_SHADER_COMBO( HDRTYPE, g_pHardwareConfig->GetHDRType() ); +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps enabled for 2_0b and onwards + SET_STATIC_PIXEL_SHADER_COMBO( PARALLAXCORRECT, hasParallaxCorrection ); +#else + SET_STATIC_PIXEL_SHADER_COMBO( PARALLAXCORRECT, false ); +#endif SET_STATIC_PIXEL_SHADER( shatteredglass_ps20b ); } else @@ -218,6 +253,10 @@ BEGIN_VS_SHADER( ShatteredGlass, SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, bHasEnvmapMask ); SET_STATIC_PIXEL_SHADER_COMBO( BASEALPHAENVMAPMASK, bHasBaseAlphaEnvmapMask ); SET_STATIC_PIXEL_SHADER_COMBO( HDRTYPE, g_pHardwareConfig->GetHDRType() ); +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps + //SET_STATIC_PIXEL_SHADER_COMBO( PARALLAXCORRECT, 0 ); // No parallax cubemaps with ps_2_0 :( +#endif SET_STATIC_PIXEL_SHADER( shatteredglass_ps20 ); } @@ -257,7 +296,9 @@ BEGIN_VS_SHADER( ShatteredGlass, if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { DECLARE_DYNAMIC_PIXEL_SHADER( shatteredglass_ps20b ); +#ifndef MAPBASE SET_DYNAMIC_PIXEL_SHADER_COMBO( HDRENABLED, IsHDREnabled() ); +#endif SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER( shatteredglass_ps20b ); } @@ -291,6 +332,30 @@ BEGIN_VS_SHADER( ShatteredGlass, overbright[1] = params[UNLITFACTOR]->GetFloatValue(); overbright[2] = overbright[3] = 1.0f - params[UNLITFACTOR]->GetFloatValue(); pShaderAPI->SetPixelShaderConstant( 6, overbright ); + +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps + if (hasParallaxCorrection) + { + pShaderAPI->SetPixelShaderConstant( 7, params[ENVMAPORIGIN]->GetVecValue() ); + + float* vecs[3]; + vecs[0] = const_cast(params[ENVMAPPARALLAXOBB1]->GetVecValue()); + vecs[1] = const_cast(params[ENVMAPPARALLAXOBB2]->GetVecValue()); + vecs[2] = const_cast(params[ENVMAPPARALLAXOBB3]->GetVecValue()); + float matrix[4][4]; + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 4; j++) + { + matrix[i][j] = vecs[i][j]; + } + } + matrix[3][0] = matrix[3][1] = matrix[3][2] = 0; + matrix[3][3] = 1; + pShaderAPI->SetPixelShaderConstant( 8, &matrix[0][0], 4 ); + } +#endif } Draw(); } diff --git a/src/materialsystem/stdshaders/skin_dx9_helper.cpp b/src/materialsystem/stdshaders/skin_dx9_helper.cpp index 9812d11b..a5297d10 100644 --- a/src/materialsystem/stdshaders/skin_dx9_helper.cpp +++ b/src/materialsystem/stdshaders/skin_dx9_helper.cpp @@ -115,6 +115,10 @@ void InitParamsSkin_DX9( CBaseVSShader *pShader, IMaterialVar** params, const ch { params[info.m_nEnvmapFresnel]->SetFloatValue( 0 ); } + +#ifdef MAPBASE + InitIntParam( info.m_nPhongDisableHalfLambert, params, 0 ); +#endif } //----------------------------------------------------------------------------- @@ -207,6 +211,19 @@ void InitSkin_DX9( CBaseVSShader *pShader, IMaterialVar** params, VertexLitGener pShader->LoadCubeMap( info.m_nEnvmap, g_pHardwareConfig->GetHDRType() == HDR_TYPE_NONE ? TEXTUREFLAGS_SRGB : 0 ); } +#ifdef MAPBASE + // This is crashing for currently unknown reasons. + // As a result, $envmapmask support is not yet functional. + /* + if ( info.m_nEnvmapMask != -1 && params[info.m_nEnvmapMask]->IsDefined() ) + { + pShader->LoadTexture( info.m_nEnvmapMask ); + + CLEAR_FLAGS( MATERIAL_VAR_BASEALPHAENVMAPMASK ); + } + */ +#endif + if ( bHasSelfIllumMask ) { pShader->LoadTexture( info.m_nSelfIllumMask ); @@ -254,6 +271,10 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad bool bHasPhongWarp = (info.m_nPhongWarpTexture != -1) && params[info.m_nPhongWarpTexture]->IsTexture(); bool bHasNormalMapAlphaEnvmapMask = IS_FLAG_SET( MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK ); +#ifdef MAPBASE + bool bHasEnvmapMask = (!bHasFlashlight || IsX360()) && info.m_nEnvmapMask != -1 && params[info.m_nEnvmapMask]->IsTexture(); +#endif + #if !defined( _X360 ) bool bIsDecal = IS_FLAG_SET( MATERIAL_VAR_DECAL ); #endif @@ -270,6 +291,15 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad float flTintReplacementAmount = GetFloatParam( info.m_nTintReplacesBaseColor, params ); +#ifdef MAPBASE + // This option was ported from Alien Swarm for Source 2013's "skin shader" implementation. + // Original comment from Alien Swarm SDK: + // "This is to allow phong materials to disable half lambert. Half lambert has always been forced on in phong, + // so the only safe way to allow artists to disable half lambert is to create this param that disables the + // default behavior of forcing half lambert on." + bool bPhongHalfLambert = IS_PARAM_DEFINED( info.m_nPhongDisableHalfLambert ) ? (params[info.m_nPhongDisableHalfLambert]->GetIntValue() == 0) : true; +#endif + float flPhongExponentFactor = ( info.m_nPhongExponentFactor != -1 ) ? GetFloatParam( info.m_nPhongExponentFactor, params ) : 0.0f; const bool bHasPhongExponentFactor = flPhongExponentFactor != 0.0f; @@ -421,6 +451,13 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad pShaderShadow->EnableTexture( SHADER_SAMPLER14, true ); } +#ifdef MAPBASE + if ( bHasEnvmapMask ) + { + pShaderShadow->EnableTexture( SHADER_SAMPLER15, true ); + } +#endif + if( bHasVertexColor || bHasVertexAlpha ) { flags |= VERTEX_COLOR; @@ -447,7 +484,7 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad #ifndef _X360 - if ( !g_pHardwareConfig->HasFastVertexTextures() ) + if ( !g_pHardwareConfig->SupportsShaderModel_3_0() ) #endif { bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); @@ -472,13 +509,20 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad SET_STATIC_PIXEL_SHADER_COMBO( CONVERT_TO_SRGB, 0 ); SET_STATIC_PIXEL_SHADER_COMBO( FASTPATH_NOBUMP, pContextData->m_bFastPath ); SET_STATIC_PIXEL_SHADER_COMBO( BLENDTINTBYBASEALPHA, bBlendTintByBaseAlpha ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( PHONG_HALFLAMBERT, bPhongHalfLambert ); + SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, bHasEnvmapMask ); +#endif SET_STATIC_PIXEL_SHADER( skin_ps20b ); } #ifndef _X360 else { + const bool bFastVertexTextures = g_pHardwareConfig->HasFastVertexTextures(); + // The vertex shader uses the vertex id stream - SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); + if ( bFastVertexTextures ) + SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID ); DECLARE_STATIC_VERTEX_SHADER( skin_vs30 ); SET_STATIC_VERTEX_SHADER_COMBO( DECAL, bIsDecal ); @@ -499,6 +543,10 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad SET_STATIC_PIXEL_SHADER_COMBO( CONVERT_TO_SRGB, 0 ); SET_STATIC_PIXEL_SHADER_COMBO( FASTPATH_NOBUMP, pContextData->m_bFastPath ); SET_STATIC_PIXEL_SHADER_COMBO( BLENDTINTBYBASEALPHA, bBlendTintByBaseAlpha ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( PHONG_HALFLAMBERT, bPhongHalfLambert ); + SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, bHasEnvmapMask ); +#endif SET_STATIC_PIXEL_SHADER( skin_ps30 ); } #endif @@ -597,6 +645,13 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad } } +#ifdef MAPBASE + if ( bHasEnvmapMask ) + { + pContextData->m_SemiStaticCmdsOut.BindTexture( pShader, SHADER_SAMPLER15, info.m_nEnvmapMask, info.m_nEnvmapMaskFrame ); + } +#endif + if ( hasDetailTexture ) { pShader->BindTexture( SHADER_SAMPLER13, info.m_nDetail, info.m_nDetailFrame ); @@ -711,10 +766,12 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad pShader->SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, info.m_nBaseTextureTransform ); +#ifndef MAPBASE // See below if( bHasBump ) { pShader->SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, info.m_nBumpTransform ); } +#endif if ( hasDetailTexture ) { diff --git a/src/materialsystem/stdshaders/skin_ps20b.fxc b/src/materialsystem/stdshaders/skin_ps20b.fxc index d1759c83..471318e6 100644 --- a/src/materialsystem/stdshaders/skin_ps20b.fxc +++ b/src/materialsystem/stdshaders/skin_ps20b.fxc @@ -15,6 +15,8 @@ // STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX] // STATIC: "FASTPATH_NOBUMP" "0..1" // STATIC: "BLENDTINTBYBASEALPHA" "0..1" +// STATIC: "PHONG_HALFLAMBERT" "0..1" +// STATIC: "ENVMAPMASK" "0..1" // DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1" // DYNAMIC: "PIXELFOGTYPE" "0..2" @@ -48,6 +50,8 @@ // BlendTintByBaseAlpha and self illum and are opposing meanings for alpha channel // SKIP: ( $BLENDTINTBYBASEALPHA ) && ( $SELFILLUM ) +// SKIP: $ENVMAPMASK && !$CUBEMAP + // fastpath means: // no bumpmap // basealphaenvmapmask (not inverted) @@ -124,6 +128,10 @@ sampler DetailSampler : register( s13 ); // detail texture sampler SelfIllumMaskSampler : register( s14 ); // selfillummask +#if ENVMAPMASK +sampler EnvmapMaskSampler : register( s15 ); +#endif + struct PS_INPUT { float4 baseTexCoordDetailTexCoord : TEXCOORD0; // xy=base zw=detail @@ -148,6 +156,7 @@ float4 main( PS_INPUT i ) : COLOR bool bSelfIllum = SELFILLUM ? true : false; bool bDoRimLighting = RIMLIGHT ? true : false; bool bCubemap = CUBEMAP ? true : false; + bool bEnvmapMask = ENVMAPMASK ? true : false; bool bBlendTintByBaseAlpha = BLENDTINTBYBASEALPHA ? true : false; int nNumLights = NUM_LIGHTS; @@ -172,7 +181,7 @@ float4 main( PS_INPUT i ) : COLOR float4 stretchColor = tex2D( StretchSampler, i.baseTexCoordDetailTexCoord.xy ); // Apply wrinkle blend to only RGB. Alpha comes from the base texture - baseColor.rgb = flTextureAmount * baseColor + flWrinkleAmount * wrinkleColor + flStretchAmount * stretchColor; + baseColor.rgb = flTextureAmount * baseColor.rgb + flWrinkleAmount * wrinkleColor.rgb + flStretchAmount * stretchColor.rgb; #endif #if DETAILTEXTURE @@ -186,8 +195,19 @@ float4 main( PS_INPUT i ) : COLOR float3 vRimAmbientCubeColor = PixelShaderAmbientLight(vEyeDir, cAmbientCube); float3 worldSpaceNormal, tangentSpaceNormal; + +#if ENVMAPMASK + float3 fSpecMask = float3( 1.0f, 1.0f, 1.0f ); +#else float fSpecMask = 1.0f; +#endif + +#if !DETAILTEXTURE + // Blixibon - $bumpmap transform support + float4 normalTexel = tex2D( NormalMapSampler, i.baseTexCoordDetailTexCoord.zw ); +#else float4 normalTexel = tex2D( NormalMapSampler, i.baseTexCoordDetailTexCoord.xy ); +#endif #if WRINKLEMAP float4 wrinkleNormal = tex2D( NormalWrinkleSampler, i.baseTexCoordDetailTexCoord.xy ); @@ -195,14 +215,27 @@ float4 main( PS_INPUT i ) : COLOR normalTexel = flTextureAmount * normalTexel + flWrinkleAmount * wrinkleNormal + flStretchAmount * stretchNormal; #endif -#if (FASTPATH_NOBUMP == 0 ) +#if (FASTPATH_NOBUMP == 0) tangentSpaceNormal = lerp( 2.0f * normalTexel.xyz - 1.0f, float3(0, 0, 1), g_fBaseMapAlphaPhongMask ); - fSpecMask = lerp( normalTexel.a, baseColor.a, g_fBaseMapAlphaPhongMask ); #else tangentSpaceNormal = float3(0, 0, 1); - fSpecMask = baseColor.a; #endif + #if ENVMAPMASK + { + float4 envmapMaskTexel = tex2D( EnvmapMaskSampler, i.baseTexCoordDetailTexCoord.xy ); + fSpecMask = lerp( envmapMaskTexel.xyz, baseColor.aaa, g_fBaseMapAlphaPhongMask ); + } + #else + { +#if (FASTPATH_NOBUMP == 0 ) + fSpecMask = lerp( normalTexel.a, baseColor.a, g_fBaseMapAlphaPhongMask ); +#else + fSpecMask = baseColor.a; +#endif + } + #endif + // We need a normal if we're doing any lighting worldSpaceNormal = normalize( mul( i.tangentSpaceTranspose, tangentSpaceNormal ) ); @@ -219,7 +252,7 @@ float4 main( PS_INPUT i ) : COLOR // Summation of diffuse illumination from all local lights diffuseLighting = PixelShaderDoLighting( vWorldPos, worldSpaceNormal, float3( 0.0f, 0.0f, 0.0f ), false, true, vLightAtten, - cAmbientCube, NormalizeRandRotSampler, nNumLights, cLightInfo, true, + cAmbientCube, NormalizeRandRotSampler, nNumLights, cLightInfo, PHONG_HALFLAMBERT, // These parameters aren't passed by generic shaders: false, 1.0f, @@ -227,18 +260,30 @@ float4 main( PS_INPUT i ) : COLOR if( bCubemap ) { - // Mask is either normal map alpha or base map alpha + if ( bEnvmapMask ) + { + float3 fEnvMapMask = lerp( baseColor.aaa, fSpecMask, g_EnvmapTint_ShadowTweaks.w ); + envMapColor = (ENV_MAP_SCALE * + lerp(1, fFresnelRanges, g_EnvMapFresnel.x) * + lerp(fEnvMapMask, float3(1,1,1)-fEnvMapMask, g_fInvertPhongMask)) * + texCUBE( EnvmapSampler, vReflect ).xyz * + g_EnvmapTint_ShadowTweaks.xyz; + } + else + { + // Mask is either normal map alpha or base map alpha #if ( SELFILLUMFRESNEL == 1 ) // This is to match the 2.0 version of vertexlitgeneric - float fEnvMapMask = lerp( baseColor.a, g_fInvertPhongMask, g_EnvmapTint_ShadowTweaks.w ); + float fEnvMapMask = lerp( baseColor.a, g_fInvertPhongMask, g_EnvmapTint_ShadowTweaks.w ); #else - float fEnvMapMask = lerp( baseColor.a, fSpecMask, g_EnvmapTint_ShadowTweaks.w ); + float fEnvMapMask = lerp( baseColor.a, fSpecMask, g_EnvmapTint_ShadowTweaks.w ); #endif - envMapColor = (ENV_MAP_SCALE * - lerp(1, fFresnelRanges, g_EnvMapFresnel.x) * - lerp(fEnvMapMask, 1-fEnvMapMask, g_fInvertPhongMask)) * - texCUBE( EnvmapSampler, vReflect ) * - g_EnvmapTint_ShadowTweaks.xyz; + envMapColor = (ENV_MAP_SCALE * + lerp(1, fFresnelRanges, g_EnvMapFresnel.x) * + lerp(fEnvMapMask, 1-fEnvMapMask, g_fInvertPhongMask)) * + texCUBE( EnvmapSampler, vReflect ).xyz * + g_EnvmapTint_ShadowTweaks.xyz; + } } } @@ -335,7 +380,7 @@ float4 main( PS_INPUT i ) : COLOR float flSelfIllumFresnel = ( pow( saturate( dot( vVertexNormal.xyz, vEyeDir.xyz ) ), g_SelfIllumScaleBiasExpBrightness.z ) * g_SelfIllumScaleBiasExpBrightness.x ) + g_SelfIllumScaleBiasExpBrightness.y; diffuseComponent = lerp( diffuseComponent, g_SelfIllumTint_and_DetailBlendFactor.rgb * albedo * g_SelfIllumScaleBiasExpBrightness.w, baseColor.a * saturate( flSelfIllumFresnel ) ); #else - float3 vSelfIllumMask = tex2D( SelfIllumMaskSampler, i.baseTexCoordDetailTexCoord.xy ); + float3 vSelfIllumMask = tex2D( SelfIllumMaskSampler, i.baseTexCoordDetailTexCoord.xy ).xyz; vSelfIllumMask = lerp( baseColor.aaa, vSelfIllumMask, g_SelfIllumMaskControl ); diffuseComponent = lerp( diffuseComponent, g_SelfIllumTint_and_DetailBlendFactor.rgb * albedo, vSelfIllumMask ); #endif diff --git a/src/materialsystem/stdshaders/spline_fxc.h b/src/materialsystem/stdshaders/spline_fxc.h new file mode 100644 index 00000000..bc9fb428 --- /dev/null +++ b/src/materialsystem/stdshaders/spline_fxc.h @@ -0,0 +1,19 @@ +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// + +// derivative of catmull rom spline courtesy of calc +float4 DCatmullRomSpline ( float4 a, float4 b, float4 c, float4 d, float t ) +{ + return 0.5 *( c - a + t * ( 2 * a - 5 * b + 4 * c - d + t * (3 * b - a - 3 * c + d ) ) + + t * ( 2 * a - 5 * b + 4 * c - d + 2 * ( t * ( 3 * b - a - 3 * c + d ) ) ) ); +} + +float3 DCatmullRomSpline3 ( float3 a, float3 b, float3 c, float3 d, float t ) +{ + return 0.5 *( c - a + t * ( 2 * a - 5 * b + 4 * c - d + t * (3 * b - a - 3 * c + d ) ) + + t * ( 2 * a - 5 * b + 4 * c - d + 2 * ( t * ( 3 * b - a - 3 * c + d ) ) ) ); +} + +float4 CatmullRomSpline( float4 a, float4 b, float4 c, float4 d, float t ) +{ + return b + 0.5 * t * ( c - a + t * ( 2 * a - 5 * b + 4 * c - d + t * ( -a + 3 * b -3 * c + d ) ) ); +} diff --git a/src/materialsystem/stdshaders/splinerope.cpp b/src/materialsystem/stdshaders/splinerope.cpp new file mode 100644 index 00000000..103b740b --- /dev/null +++ b/src/materialsystem/stdshaders/splinerope.cpp @@ -0,0 +1,169 @@ +//===== Copyright © 1996-2008, Valve Corporation, All rights reserved. ======// + +#include "BaseVSShader.h" +#include "convar.h" + +#include "splinerope_ps20.inc" +#include "splinerope_ps20b.inc" +#include "splinerope_vs20.inc" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +static ConVar rope_min_pixel_diameter( "rope_min_pixel_diameter", "2.0", FCVAR_CHEAT ); + +DEFINE_FALLBACK_SHADER( Cable, Cable_DX9 ) + +BEGIN_VS_SHADER( Cable_DX9, "Help for SplineRope" ) + BEGIN_SHADER_PARAMS + SHADER_PARAM( SHADERSRGBREAD360, SHADER_PARAM_TYPE_BOOL, "0", "Simulate srgb read in shader code") + SHADER_PARAM( SHADOWDEPTH, SHADER_PARAM_TYPE_INTEGER, "0", "writing to a shadow depth buffer" ) + SHADER_PARAM( BUMPMAP, SHADER_PARAM_TYPE_TEXTURE, "cable/cablenormalmap", "normal map" ) + END_SHADER_PARAMS + + SHADER_INIT_PARAMS() + { + // srgb read 360 + InitIntParam( SHADERSRGBREAD360, params, 0 ); + InitIntParam( SHADOWDEPTH, params, 0 ); + if ( !params[BUMPMAP]->IsDefined() ) + { + params[BUMPMAP]->SetStringValue( "cable/cablenormalmap" ); + } + SET_FLAGS2( MATERIAL_VAR2_IS_SPRITECARD ); // What's this for? + } + + SHADER_FALLBACK + { + return 0; + } + + SHADER_INIT + { + SET_FLAGS2( MATERIAL_VAR2_LIGHTING_VERTEX_LIT ); + LoadTexture( BASETEXTURE ); + LoadBumpMap( BUMPMAP ); + } + + SHADER_DRAW + { + bool bShaderSrgbRead = ( IsX360() && params[SHADERSRGBREAD360]->GetIntValue() ); + bool bShadowDepth = ( params[SHADOWDEPTH]->GetIntValue() != 0 ); + SHADOW_STATE + { + // draw back-facing because of yaw spin + pShaderShadow->EnableCulling( false ); + + if ( bShadowDepth ) + { + // don't write color and alpha since we only interested in depth for shadow maps. + pShaderShadow->EnableColorWrites( false ); + pShaderShadow->EnableAlphaWrites( false ); + + // polyoffset for shadow maps. + pShaderShadow->EnablePolyOffset( SHADER_POLYOFFSET_SHADOW_BIAS ); + } + else + { + // We need to write to dest alpha for depth feathering. + pShaderShadow->EnableAlphaWrites( true ); + + // base texture + pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, !bShaderSrgbRead ); + + // normal map + pShaderShadow->EnableTexture( SHADER_SAMPLER1, true ); + + pShaderShadow->EnableSRGBWrite( true ); + + FogToFogColor(); + } + + static int s_TexCoordSize[]={ 4, // (worldspace xyz) (radius (diameter?) of spline at this point) for first control point + 4, // (worldspace xyz) (radius of spline at this point) for second control point + 4, // (worldspace xyz) (radius of spline at this point) for third control point + 4, // (worldspace xyz) (radius of spline at this point) for fourth control point + }; + + unsigned int flags = VERTEX_POSITION | VERTEX_COLOR; + + int numTexCoords = 4; + pShaderShadow->VertexShaderVertexFormat( flags, numTexCoords, s_TexCoordSize, 0 ); + + DECLARE_STATIC_VERTEX_SHADER( splinerope_vs20 ); + SET_STATIC_VERTEX_SHADER( splinerope_vs20 ); + + if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_STATIC_PIXEL_SHADER( splinerope_ps20b ); + SET_STATIC_PIXEL_SHADER_COMBO( SHADER_SRGB_READ, bShaderSrgbRead ); + SET_STATIC_PIXEL_SHADER_COMBO( SHADOWDEPTH, bShadowDepth ); + SET_STATIC_PIXEL_SHADER( splinerope_ps20b ); + } + else + { + DECLARE_STATIC_PIXEL_SHADER( splinerope_ps20 ); + SET_STATIC_PIXEL_SHADER_COMBO( SHADER_SRGB_READ, bShaderSrgbRead ); + SET_STATIC_PIXEL_SHADER_COMBO( SHADOWDEPTH, bShadowDepth ); + SET_STATIC_PIXEL_SHADER( splinerope_ps20 ); + } + } + DYNAMIC_STATE + { + // We need these only when screen-orienting, which we are always in this shader. + LoadModelViewMatrixIntoVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0 ); + LoadProjectionMatrixIntoVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_3 ); + + // Get viewport and render target dimensions and set shader constant to do a 2D mad + ShaderViewport_t viewport; + pShaderAPI->GetViewports( &viewport, 1 ); + + float c7[4]={ 0.0f, 0.0f, 0.0f, 0.0f }; + if ( !g_pHardwareConfig->IsAAEnabled() ) + { + float flMinPixelDiameter = rope_min_pixel_diameter.GetFloat() / ( float )viewport.m_nWidth; + c7[0]= c7[1] = c7[2] = c7[3] = flMinPixelDiameter; + } + pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, c7, 1 ); + + // bind base texture + BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME ); + + // normal map + BindTexture( SHADER_SAMPLER1, BUMPMAP ); + + if ( !bShadowDepth ) + { + pShaderAPI->SetPixelShaderFogParams( 0 ); + + float vEyePos[4]; + pShaderAPI->GetWorldSpaceCameraPosition( vEyePos ); + vEyePos[3] = 0.0f; + pShaderAPI->SetPixelShaderConstant( 1, vEyePos, 1 ); + } + + DECLARE_DYNAMIC_VERTEX_SHADER( splinerope_vs20 ); + SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_VERTEX_SHADER( splinerope_vs20 ); + + if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) + { + DECLARE_DYNAMIC_PIXEL_SHADER( splinerope_ps20b ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, pShaderAPI->ShouldWriteDepthToDestAlpha() ); + //SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo1( true ) ); + SET_DYNAMIC_PIXEL_SHADER( splinerope_ps20b ); + } + else + { + DECLARE_DYNAMIC_PIXEL_SHADER( splinerope_ps20 ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, 0 ); + //SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); + SET_DYNAMIC_PIXEL_SHADER( splinerope_ps20 ); + } + } + Draw( ); + } +END_SHADER diff --git a/src/materialsystem/stdshaders/splinerope_ps2x.fxc b/src/materialsystem/stdshaders/splinerope_ps2x.fxc new file mode 100644 index 00000000..bb90fcfd --- /dev/null +++ b/src/materialsystem/stdshaders/splinerope_ps2x.fxc @@ -0,0 +1,52 @@ +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// + +// STATIC: "SHADER_SRGB_READ" "0..1" [XBOX] +// STATIC: "SHADER_SRGB_READ" "0..0" [PC] +// STATIC: "SHADOWDEPTH" "0..1" +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX] +// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20] +// DYNAMIC: "PIXELFOGTYPE" "0..2" + +#include "common_ps_fxc.h" + +float4 g_FogParams : register( c0 ); +float3 g_EyePos : register( c1 ); + +// VS_OUTPUT in a common file. +#define PIXELSHADER +#include "common_splinerope_fxc.h" + +sampler BaseTextureSampler : register( s0 ); +sampler NormalSampler : register( s1 ); + +float4 main( PS_INPUT i ) : COLOR +{ + #if ( SHADOWDEPTH == 0 ) + { + float3 vNormalMapDir = tex2D( NormalSampler, i.texCoord.xy ); // Get the 3-vector from the normal map + float4 textureColor = tex2D( BaseTextureSampler, i.texCoord.xy ); + + //Expand compacted vectors + vNormalMapDir = ( vNormalMapDir - 0.5 ) * 2.0; + float3 vLightDir = float3( 0.0f, 0.0f, 1.0f ); + + float lightDirDotNormalMap = dot( vNormalMapDir, vLightDir ); //normalMap dot dirLightDir + + // do half-lambert on the dot + lightDirDotNormalMap = lightDirDotNormalMap * 0.5 + 0.5; + lightDirDotNormalMap = lightDirDotNormalMap * lightDirDotNormalMap; + + float4 resultColor; + resultColor.xyz = lightDirDotNormalMap * ( textureColor.rgb * i.argbcolor.rgb ); + resultColor.a = textureColor.a * i.argbcolor.a; + + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); + return FinalOutput( resultColor, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, (WRITE_DEPTH_TO_DESTALPHA != 0), i.worldPos_projPosZ.w ); + } + #else + { + return float4( 0.0f, 0.0f, 0.0f, 1.0f ); + } + #endif +} diff --git a/src/materialsystem/stdshaders/splinerope_vs20.fxc b/src/materialsystem/stdshaders/splinerope_vs20.fxc new file mode 100644 index 00000000..bc79c57b --- /dev/null +++ b/src/materialsystem/stdshaders/splinerope_vs20.fxc @@ -0,0 +1,78 @@ +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// +// DYNAMIC: "DOWATERFOG" "0..1" + +#include "common_vs_fxc.h" +#include "spline_fxc.h" + +const float4x3 cModelView : register(SHADER_SPECIFIC_CONST_0); +const float4x4 cProj : register(SHADER_SPECIFIC_CONST_3); +const float g_MinPixelSize : register(SHADER_SPECIFIC_CONST_7); + +struct VS_INPUT +{ + // This is all of the stuff that we ever use. + float4 vTint : COLOR; + float4 vParms : POSITION; // T V side_id + float4 vSplinePt0 : TEXCOORD0; // x y z rad + float4 vSplinePt1 : TEXCOORD1; // x y z rad + float4 vSplinePt2 : TEXCOORD2; // x y z rad + float4 vSplinePt3 : TEXCOORD3; // x y z rad +}; + +// VS_OUTPUT in a common file. +#include "common_splinerope_fxc.h" + +#define P0 (v.vSplinePt0) +#define P1 (v.vSplinePt1) +#define P2 (v.vSplinePt2) +#define P3 (v.vSplinePt3) + +VS_OUTPUT main( const VS_INPUT v ) +{ + VS_OUTPUT o; + + // posrad.xyz is worldspace position and posrad.w is worldspace diameter. + float4 posrad = CatmullRomSpline( P0, P1, P2, P3, v.vParms.x ); + + // calculate projected position here so that we can figure out how much to bloat the diameter to avoid aliasing of the sort where you skip pixels in a segment. + { + // PERF FIXME!! This could be simplified quite a bit if this ever becomes a bottleneck. I feel dirty. + // Get the view-space position for two points that are posrad.w units away from each other horizontally. + float3 viewPos1 = mul4x3( float4( posrad.xyz, 1.0f ), cModelView ); + float3 viewPos2 = viewPos1 + float3( posrad.w, 0.0f, 0.0f ); + + // Project both points. + float4 projPos1 = mul( float4( viewPos1, 1.0f ), cProj ); + float4 projPos2 = mul( float4( viewPos2, 1.0f ), cProj ); + + // Get the distance of the two points from each other in normalized screen space. + float projectedDiameterInPixels = abs( ( projPos1.x / projPos1.w ) - ( projPos2.x / projPos2.w ) ); + + // Compare the distance between the two points to the minimum allowed to keep from skipping pixels and causing aliasing. + if ( projectedDiameterInPixels < g_MinPixelSize ) + { + // Scale the radius in world space so that it is bigger than the required pixel size in screen space. + posrad.w *= ( g_MinPixelSize / projectedDiameterInPixels ); + } + } + + float3 v2p = float3( 0, 0, 1 ); + v2p = posrad.xyz - cEyePos; // screen aligned + + float3 tangent = DCatmullRomSpline3( P0, P1, P2, P3, v.vParms.x ); + float3 ofs = normalize( cross( v2p, normalize( tangent ) ) ); + posrad.xyz += ofs * ( posrad.w * ( v.vParms.z - .5 ) ); + o.projPos = mul( float4(posrad.xyz, 1.0f), cViewProj ); + o.worldPos_projPosZ.xyz = posrad.xyz; + o.worldPos_projPosZ.w = o.projPos.z; + o.texCoord.xy = float2( 1.0f - v.vParms.z, v.vParms.y ); + o.argbcolor = float4( v.vTint.rgb, v.vTint.a ); + + #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) + { + o.fog = CalcFog( posrad.xyz, o.worldPos_projPosZ, DOWATERFOG ); + } + #endif + + return o; +} diff --git a/src/materialsystem/stdshaders/stdshader_dx9_30.txt b/src/materialsystem/stdshaders/stdshader_dx9_30.txt index b23b9fc8..c4542ac4 100644 --- a/src/materialsystem/stdshaders/stdshader_dx9_30.txt +++ b/src/materialsystem/stdshaders/stdshader_dx9_30.txt @@ -22,6 +22,8 @@ Eyes_vs20.fxc eyes_ps2x.fxc eyes_flashlight_vs20.fxc eyes_flashlight_ps2x.fxc +lightmappedgeneric_ps2x.fxc +lightmappedgeneric_vs20.fxc morphaccumulate_vs30.fxc morphaccumulate_ps30.fxc morphweight_vs30.fxc diff --git a/src/materialsystem/stdshaders/stdshader_dx9_inc.vpc b/src/materialsystem/stdshaders/stdshader_dx9_inc.vpc index 929d5e35..7d42ffde 100644 --- a/src/materialsystem/stdshaders/stdshader_dx9_inc.vpc +++ b/src/materialsystem/stdshaders/stdshader_dx9_inc.vpc @@ -39,6 +39,9 @@ $Configuration $AdditionalIncludeDirectories "$BASE;..\..\dx9sdk\include" [$WINDOWS] $PreprocessorDefinitions "$BASE;STDSHADER_DX9_DLL_EXPORT;FAST_MATERIALVAR_ACCESS" $PreprocessorDefinitions "$BASE;USE_ACTUAL_DX" [($WINDOWS||$X360) && !$GL] + + // https://developer.valvesoftware.com/wiki/Parallax_Corrected_Cubemaps + $PreprocessorDefinitions "$BASE;PARALLAX_CORRECTED_CUBEMAPS" [$MAPBASE] } $Linker @@ -61,7 +64,7 @@ $Project $File "BlurFilterX.cpp" $File "BlurFilterY.cpp" $File "BufferClearObeyStencil_dx9.cpp" - $File "cable_dx9.cpp" + $File "cable_dx9.cpp" [!$MAPBASE] $File "cloak.cpp" $File "cloak_blended_pass_helper.cpp" $File "cloak_dx9_helper.cpp" @@ -158,6 +161,9 @@ $Project $File "writez_dx9.cpp" $File "writestencil_dx9.cpp" + $File "splinerope.cpp" [$MAPBASE] + $File "mapbase_sdk_stubs.cpp" [$MAPBASE] + $Folder "Remove me when VAC2 is out" [$WINDOWS && !$SOURCESDK] { $File "$SRCDIR\tier1\checksum_crc.cpp" diff --git a/src/materialsystem/stdshaders/teeth.cpp b/src/materialsystem/stdshaders/teeth.cpp index 372ce163..8875cb9a 100644 --- a/src/materialsystem/stdshaders/teeth.cpp +++ b/src/materialsystem/stdshaders/teeth.cpp @@ -222,7 +222,10 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) float vEyePos_SpecExponent[4]; pShaderAPI->GetWorldSpaceCameraPosition( vEyePos_SpecExponent ); - vEyePos_SpecExponent[3] = 0.0f; + if (g_pHardwareConfig->HasFastVertexTextures() || g_pHardwareConfig->SupportsPixelShaders_2_b()) + vEyePos_SpecExponent[3] = params[PHONGEXPONENT]->GetFloatValue(); + else + vEyePos_SpecExponent[3] = 0.0f; pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 ); if ( hasBump ) @@ -244,10 +247,6 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) // ps_2_b version which does Phong if ( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { - vEyePos_SpecExponent[3] = params[PHONGEXPONENT]->GetFloatValue(); - - pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 ); - DECLARE_DYNAMIC_PIXEL_SHADER( teeth_bump_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo1( true ) ); SET_DYNAMIC_PIXEL_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights ); @@ -277,10 +276,6 @@ BEGIN_VS_SHADER( Teeth_DX9, "Help for Teeth_DX9" ) SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); SET_DYNAMIC_VERTEX_SHADER( teeth_bump_vs30 ); - Vector4D vSpecExponent; - vSpecExponent[3] = params[PHONGEXPONENT]->GetFloatValue(); - pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vSpecExponent.Base(), 1 ); - DECLARE_DYNAMIC_PIXEL_SHADER( teeth_bump_ps30 ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo1( true ) ); SET_DYNAMIC_PIXEL_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights ); diff --git a/src/materialsystem/stdshaders/teeth_bump_vs20.fxc b/src/materialsystem/stdshaders/teeth_bump_vs20.fxc index 1ccbe4e9..740cd35c 100644 --- a/src/materialsystem/stdshaders/teeth_bump_vs20.fxc +++ b/src/materialsystem/stdshaders/teeth_bump_vs20.fxc @@ -55,7 +55,7 @@ struct VS_INPUT struct VS_OUTPUT { float4 projPos : POSITION; -#if !defined( _X360 ) +#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) && !INTRO float fog : FOG; #endif float2 baseTexCoord : TEXCOORD0; @@ -105,8 +105,8 @@ VS_OUTPUT main( const VS_INPUT v ) o.projPos = vProjPos; vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); - o.worldPos_projPosZ = float4( worldPos, vProjPos.z ); -#if !defined( _X360 ) + o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z ); +#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) && !INTRO // Set fixed-function fog factor o.fog = CalcFog( worldPos, vProjPos, g_FogType ); #endif diff --git a/src/materialsystem/stdshaders/unlitgeneric_dx9.cpp b/src/materialsystem/stdshaders/unlitgeneric_dx9.cpp index b57474a8..c580f22a 100644 --- a/src/materialsystem/stdshaders/unlitgeneric_dx9.cpp +++ b/src/materialsystem/stdshaders/unlitgeneric_dx9.cpp @@ -78,6 +78,32 @@ BEGIN_VS_SHADER( UnlitGeneric, "Help for UnlitGeneric" ) SHADER_PARAM( DEPTHBLENDSCALE, SHADER_PARAM_TYPE_FLOAT, "50.0", "Amplify or reduce DEPTHBLEND fading. Lower values make harder edges." ) SHADER_PARAM( RECEIVEFLASHLIGHT, SHADER_PARAM_TYPE_INTEGER, "0", "Forces this material to receive flashlights." ) +#ifdef MAPBASE + SHADER_PARAM( ALLOWDIFFUSEMODULATION, SHADER_PARAM_TYPE_BOOL, "1", "Allow per-instance color modulation" ) + + SHADER_PARAM( ENVMAPFRESNELMINMAXEXP, SHADER_PARAM_TYPE_VEC3, "[0.0 1.0 2.0]", "Min/max fresnel range and exponent for vertexlitgeneric" ) + SHADER_PARAM( BASEALPHAENVMAPMASKMINMAXEXP, SHADER_PARAM_TYPE_VEC3, "[1.0 0.0 1.0]", "" ) +#endif + + // vertexlitgeneric tree sway animation control (on unlitgeneric) + SHADER_PARAM( TREESWAY, SHADER_PARAM_TYPE_INTEGER, "0", "" ) + SHADER_PARAM( TREESWAYHEIGHT, SHADER_PARAM_TYPE_FLOAT, "1000", "" ) + SHADER_PARAM( TREESWAYSTARTHEIGHT, SHADER_PARAM_TYPE_FLOAT, "0.2", "" ) + SHADER_PARAM( TREESWAYRADIUS, SHADER_PARAM_TYPE_FLOAT, "300", "" ) + SHADER_PARAM( TREESWAYSTARTRADIUS, SHADER_PARAM_TYPE_FLOAT, "0.1", "" ) + SHADER_PARAM( TREESWAYSPEED, SHADER_PARAM_TYPE_FLOAT, "1", "" ) + SHADER_PARAM( TREESWAYSPEEDHIGHWINDMULTIPLIER, SHADER_PARAM_TYPE_FLOAT, "2", "" ) + SHADER_PARAM( TREESWAYSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "10", "" ) + SHADER_PARAM( TREESWAYSCRUMBLESPEED, SHADER_PARAM_TYPE_FLOAT, "0.1", "" ) + SHADER_PARAM( TREESWAYSCRUMBLESTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0.1", "" ) + SHADER_PARAM( TREESWAYSCRUMBLEFREQUENCY, SHADER_PARAM_TYPE_FLOAT, "0.1", "" ) + SHADER_PARAM( TREESWAYFALLOFFEXP, SHADER_PARAM_TYPE_FLOAT, "1.5", "" ) + SHADER_PARAM( TREESWAYSCRUMBLEFALLOFFEXP, SHADER_PARAM_TYPE_FLOAT, "1.0", "" ) + SHADER_PARAM( TREESWAYSPEEDLERPSTART, SHADER_PARAM_TYPE_FLOAT, "3", "" ) + SHADER_PARAM( TREESWAYSPEEDLERPEND, SHADER_PARAM_TYPE_FLOAT, "6", "" ) + SHADER_PARAM( TREESWAYSTATIC, SHADER_PARAM_TYPE_BOOL, "0", "" ) + SHADER_PARAM( TREESWAYSTATICVALUES, SHADER_PARAM_TYPE_VEC2, "[0.5 0.5]", "" ) + END_SHADER_PARAMS void SetupVars( VertexLitGeneric_DX9_Vars_t& info ) @@ -157,6 +183,31 @@ BEGIN_VS_SHADER( UnlitGeneric, "Help for UnlitGeneric" ) info.m_nDepthBlend = DEPTHBLEND; info.m_nDepthBlendScale = DEPTHBLENDSCALE; info.m_nReceiveFlashlight = RECEIVEFLASHLIGHT; + +#ifdef MAPBASE + info.m_nAllowDiffuseModulation = ALLOWDIFFUSEMODULATION; + + info.m_nEnvMapFresnelMinMaxExp = ENVMAPFRESNELMINMAXEXP; + info.m_nBaseAlphaEnvMapMaskMinMaxExp = BASEALPHAENVMAPMASKMINMAXEXP; +#endif + + info.m_nTreeSway = TREESWAY; + info.m_nTreeSwayHeight = TREESWAYHEIGHT; + info.m_nTreeSwayStartHeight = TREESWAYSTARTHEIGHT; + info.m_nTreeSwayRadius = TREESWAYRADIUS; + info.m_nTreeSwayStartRadius = TREESWAYSTARTRADIUS; + info.m_nTreeSwaySpeed = TREESWAYSPEED; + info.m_nTreeSwaySpeedHighWindMultiplier = TREESWAYSPEEDHIGHWINDMULTIPLIER; + info.m_nTreeSwayStrength = TREESWAYSTRENGTH; + info.m_nTreeSwayScrumbleSpeed = TREESWAYSCRUMBLESPEED; + info.m_nTreeSwayScrumbleStrength = TREESWAYSCRUMBLESTRENGTH; + info.m_nTreeSwayScrumbleFrequency = TREESWAYSCRUMBLEFREQUENCY; + info.m_nTreeSwayFalloffExp = TREESWAYFALLOFFEXP; + info.m_nTreeSwayScrumbleFalloffExp = TREESWAYSCRUMBLEFALLOFFEXP; + info.m_nTreeSwaySpeedLerpStart = TREESWAYSPEEDLERPSTART; + info.m_nTreeSwaySpeedLerpEnd = TREESWAYSPEEDLERPEND; + info.m_nTreeSwayStatic = TREESWAYSTATIC; + info.m_nTreeSwayStaticValues = TREESWAYSTATICVALUES; } SHADER_INIT_PARAMS() diff --git a/src/materialsystem/stdshaders/unlittwotexture_dx9.cpp b/src/materialsystem/stdshaders/unlittwotexture_dx9.cpp index a966a8b7..b69672cc 100644 --- a/src/materialsystem/stdshaders/unlittwotexture_dx9.cpp +++ b/src/materialsystem/stdshaders/unlittwotexture_dx9.cpp @@ -191,12 +191,16 @@ BEGIN_VS_SHADER( UnlitTwoTexture_DX9, "Help for UnlitTwoTexture_DX9" ) } pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize ); + // If this is set, blend with the alpha channels of the textures and modulation color + bool bTranslucent = IsAlphaModulating() || IS_FLAG_SET( MATERIAL_VAR_TRANSLUCENT ) || TextureIsTranslucent( BASETEXTURE, true ) || TextureIsTranslucent( TEXTURE2, true ); + DECLARE_STATIC_VERTEX_SHADER( unlittwotexture_vs20 ); SET_STATIC_VERTEX_SHADER( unlittwotexture_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { DECLARE_STATIC_PIXEL_SHADER( unlittwotexture_ps20b ); + SET_STATIC_PIXEL_SHADER_COMBO( TRANSLUCENT, bTranslucent ); SET_STATIC_PIXEL_SHADER( unlittwotexture_ps20b ); } else @@ -239,8 +243,10 @@ BEGIN_VS_SHADER( UnlitTwoTexture_DX9, "Help for UnlitTwoTexture_DX9" ) DECLARE_DYNAMIC_PIXEL_SHADER( unlittwotexture_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() ); SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bFullyOpaque && pShaderAPI->ShouldWriteDepthToDestAlpha() ); +#ifndef MAPBASE SET_DYNAMIC_PIXEL_SHADER_COMBO( LIGHTING_PREVIEW, pShaderAPI->GetIntRenderingParameter(INT_RENDERPARM_ENABLE_FIXED_LIGHTING) ); +#endif SET_DYNAMIC_PIXEL_SHADER( unlittwotexture_ps20b ); } else diff --git a/src/materialsystem/stdshaders/unlittwotexture_ps2x.fxc b/src/materialsystem/stdshaders/unlittwotexture_ps2x.fxc index 365bd254..4df0de86 100644 --- a/src/materialsystem/stdshaders/unlittwotexture_ps2x.fxc +++ b/src/materialsystem/stdshaders/unlittwotexture_ps2x.fxc @@ -1,14 +1,13 @@ +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// + +// STATIC: "TRANSLUCENT" "0..1" + // DYNAMIC: "PIXELFOGTYPE" "0..1" -// DYNAMIC: "LIGHTING_PREVIEW" "0..2" [PC] -// DYNAMIC: "LIGHTING_PREVIEW" "0..0" [XBOX] // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC] // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX] -// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] -// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] - #if defined( SHADER_MODEL_PS_2_0 ) -# define WRITE_DEPTH_TO_DESTALPHA 0 + #define WRITE_DEPTH_TO_DESTALPHA 0 #endif #include "common_ps_fxc.h" @@ -37,40 +36,24 @@ struct PS_INPUT HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate HALF2 baseTexCoord2 : TEXCOORD1; // Base texture coordinate float4 worldPos_projPosZ : TEXCOORD7; // Necessary for water fog dest alpha - float4 fogFactorW : COLOR1; #if defined( _X360 ) //matching pixel shader inputs to vertex shader outputs to avoid shader patches float4 vColor : COLOR0; #endif }; -#if LIGHTING_PREVIEW == 2 -LPREVIEW_PS_OUT main( PS_INPUT i ) : COLOR -#else float4 main( PS_INPUT i ) : COLOR -#endif { + float4 baseColor = tex2D( BaseTextureSampler, i.baseTexCoord.xy ); + float4 baseColor2 = tex2D( BaseTextureSampler2, i.baseTexCoord2.xy ); + float4 result = baseColor * baseColor2 * g_DiffuseModulation; -#if LIGHTING_PREVIEW -# if LIGHTING_PREVIEW == 1 - return FinalOutput( float4( 0.0f, 0.0f, 0.0f, 1.0f ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR ); -# else - LPREVIEW_PS_OUT ret; - float alpha = 1.0f; - ret.flags=float4(1,1,1,1); - ret.color=float4( 0.0f, 0.0f, 0.0f, alpha ); - ret.normal=float4( 0.0f, 0.0f, 1.0f, 1.0f ); - ret.position=float4( i.worldPos_projPosZ.xyz, alpha ); - return FinalOutput( ret, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE ); + // This material can only get a non-opaque alpha if the material is marked as translucent +# if ( TRANSLUCENT == 0 ) + result.a = 1.0f; # endif -#else - HALF4 baseColor = tex2D( BaseTextureSampler, i.baseTexCoord.xy ); - HALF4 baseColor2 = tex2D( BaseTextureSampler2, i.baseTexCoord2.xy ); - HALF4 result = baseColor * baseColor2 * g_DiffuseModulation; - float alpha = 1.0f; - - float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.z, i.worldPos_projPosZ.z, i.worldPos_projPosZ.w ); - return FinalOutput( float4( result.rgb, alpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, (WRITE_DEPTH_TO_DESTALPHA != 0), i.worldPos_projPosZ.w ); -#endif + + float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w ); + return FinalOutput( result, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, (WRITE_DEPTH_TO_DESTALPHA != 0), i.worldPos_projPosZ.w ); } diff --git a/src/materialsystem/stdshaders/unlittwotexture_vs20.fxc b/src/materialsystem/stdshaders/unlittwotexture_vs20.fxc index ea1f9406..fc35f587 100644 --- a/src/materialsystem/stdshaders/unlittwotexture_vs20.fxc +++ b/src/materialsystem/stdshaders/unlittwotexture_vs20.fxc @@ -1,3 +1,5 @@ +//========== Copyright (c) Valve Corporation, All rights reserved. ==========// + // DYNAMIC: "COMPRESSED_VERTS" "0..1" // DYNAMIC: "DOWATERFOG" "0..1" // DYNAMIC: "SKINNING" "0..1" @@ -7,8 +9,8 @@ static const bool g_bSkinning = SKINNING ? true : false; static const int g_FogType = DOWATERFOG; -const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); -const float4 cBaseTexCoordTransform2[2] : register( SHADER_SPECIFIC_CONST_2 ); +const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); // 0 & 1 +const float4 cBaseTexCoordTransform2[2] : register( SHADER_SPECIFIC_CONST_2 ); // 2 & 3 struct VS_INPUT { @@ -22,7 +24,7 @@ struct VS_INPUT struct VS_OUTPUT { float4 projPos : POSITION; // Projection-space position -#if !defined( _X360 ) +#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) float fog : FOG; #endif HALF2 baseTexCoord : TEXCOORD0; // Base texture coordinate @@ -30,7 +32,6 @@ struct VS_OUTPUT float4 worldPos_projPosZ : TEXCOORD7; // Necessary for water fog dest alpha float4 vColor : COLOR0; - float4 fogFactorW : COLOR1; }; VS_OUTPUT main( const VS_INPUT v ) @@ -41,30 +42,22 @@ VS_OUTPUT main( const VS_INPUT v ) // Perform skinning float3 worldNormal, worldPos; - SkinPosition( - g_bSkinning, - vPosition, - v.vBoneWeights, v.vBoneIndices, - worldPos ); + SkinPosition( g_bSkinning, vPosition, v.vBoneWeights, v.vBoneIndices, worldPos ); // Transform into projection space - float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj ); - o.projPos = vProjPos; - vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ ); - o.fogFactorW.w = CalcFog( worldPos, vProjPos, g_FogType ); -#if !defined( _X360 ) - o.fog = o.fogFactorW.w; -#endif + float4 projPos = mul( float4( worldPos, 1 ), cViewProj ); + o.projPos = projPos; + +#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) + o.fog = CalcFog( worldPos, projPos, g_FogType ); +#endif + // Needed for water fog alpha; - // FIXME: we shouldn't have to compute this all thie time. - o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z ); + o.worldPos_projPosZ = float4( worldPos.xyz, o.projPos.z ); // FIXME: we shouldn't have to compute this all thie time. - // Base texture coordinates - o.baseTexCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] ); + o.baseTexCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] ); // Base texture coordinates o.baseTexCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] ); - - // Base texture coordinates - o.baseTexCoord2.x = dot( v.vTexCoord0, cBaseTexCoordTransform2[0] ); + o.baseTexCoord2.x = dot( v.vTexCoord0, cBaseTexCoordTransform2[0] ); // Secondary texture coordinates o.baseTexCoord2.y = dot( v.vTexCoord0, cBaseTexCoordTransform2[1] ); o.vColor = cModulationColor; diff --git a/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_bump_ps2x.fxc b/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_bump_ps2x.fxc index c25b9841..980f3b8b 100644 --- a/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_bump_ps2x.fxc +++ b/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_bump_ps2x.fxc @@ -14,6 +14,7 @@ // STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps30] [PC] // STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX] // STATIC: "BLENDTINTBYBASEALPHA" "0..1" +// STATIC: "ENVMAPMASK" "0..1" // DYNAMIC: "PIXELFOGTYPE" "0..2" // DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1" [ps20] @@ -61,6 +62,8 @@ // Meaningless combinations // SKIP: $NORMALMAPALPHAENVMAPMASK && !$CUBEMAP +// SKIP: $NORMALMAPALPHAENVMAPMASK && $ENVMAPMASK +// SKIP: $ENVMAPMASK && !$CUBEMAP #include "common_flashlight_fxc.h" #include "common_vertexlitgeneric_dx9.h" @@ -143,6 +146,7 @@ float4 main( PS_INPUT i ) : COLOR bool bAmbientLight = AMBIENT_LIGHT ? true : false; bool bDetailTexture = DETAILTEXTURE ? true : false; bool bBlendTintByBaseAlpha = BLENDTINTBYBASEALPHA ? true : false; + bool bEnvmapMask = ENVMAPMASK ? true : false; int nNumLights = NUM_LIGHTS; #if ((defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0))) @@ -162,12 +166,30 @@ float4 main( PS_INPUT i ) : COLOR baseColor = TextureCombine( baseColor, detailColor, DETAIL_BLEND_MODE, g_DetailBlendFactor ); #endif +#if ENVMAPMASK + // Blixibon - $bumpmap + $envmapmask + float3 specularFactor = 1.0f; +#else float specularFactor = 1.0f; +#endif + +#if !DETAILTEXTURE + // Blixibon - $bumpmap transform support + float4 normalTexel = tex2D( BumpmapSampler, i.detailTexCoord_atten3.xy ); +#else float4 normalTexel = tex2D( BumpmapSampler, i.baseTexCoord2_tangentSpaceVertToEyeVectorXY.xy ); +#endif float3 tangentSpaceNormal = normalTexel * 2.0f - 1.0f; if ( bNormalMapAlphaEnvmapMask ) + { specularFactor = normalTexel.a; + } + else if( bEnvmapMask ) + { + float4 envmapMaskTexel = tex2D( EnvmapMaskSampler, i.baseTexCoord2_tangentSpaceVertToEyeVectorXY.xy ); + specularFactor *= envmapMaskTexel.xyz; + } float3 diffuseLighting = float3( 1.0f, 1.0f, 1.0f ); diff --git a/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_bump_vs20.fxc b/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_bump_vs20.fxc index 628ecd93..b30258ee 100644 --- a/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_bump_vs20.fxc +++ b/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_bump_vs20.fxc @@ -23,7 +23,7 @@ const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); const float4 cDetailTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_4 ); // 4 & 5 const float4x4 g_FlashlightWorldToTexture : register( SHADER_SPECIFIC_CONST_6 ); // 6, 7, 8, 9 -#ifdef SHADER_MODEL_VS_3_0 +#if defined( SHADER_MODEL_VS_3_0 ) // NOTE: cMorphTargetTextureDim.xy = target dimensions, // cMorphTargetTextureDim.z = 4tuples/morph const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_10 ); @@ -57,7 +57,7 @@ struct VS_INPUT // Position and normal/tangent deltas float3 vPosFlex : POSITION1; float3 vNormalFlex : NORMAL1; -#ifdef SHADER_MODEL_VS_3_0 +#if defined( SHADER_MODEL_VS_3_0 ) float vVertexID : POSITION2; #endif }; diff --git a/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_ps2x.fxc b/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_ps2x.fxc index a559961e..f261573b 100644 --- a/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_ps2x.fxc +++ b/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_ps2x.fxc @@ -23,8 +23,8 @@ // STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX] // STATIC: "DEPTHBLEND" "0..1" [ps20b] [ps30] // STATIC: "BLENDTINTBYBASEALPHA" "0..1" +// STATIC: "ENVMAPFRESNEL" "0..1" [ps30] // STATIC: "SRGB_INPUT_ADAPTER" "0..1" [ps20b] -// STATIC: "CUBEMAP_SPHERE_LEGACY" "0..1" // DYNAMIC: "PIXELFOGTYPE" "0..2" // DYNAMIC: "LIGHTING_PREVIEW" "0..2" [PC] @@ -50,6 +50,10 @@ // SKIP: ($DISTANCEALPHA == 0) && ($DISTANCEALPHAFROMDETAIL || $SOFT_MASK || $OUTLINE || $OUTER_GLOW) // SKIP: ($DETAILTEXTURE == 0) && ($DISTANCEALPHAFROMDETAIL) +// envmap stuff is meaningless if we're not using a cubemap +// SKIP: ( $CUBEMAP == 0 ) && ( ( $ENVMAPFRESNEL == 1 ) || ( $BASEALPHAENVMAPMASK == 1 ) ) +// SKIP: ( $CUBEMAP == 0 ) && ( $ENVMAPMASK == 1 ) && ( $SELFILLUM_ENVMAPMASK_ALPHA == 0 ) + // We don't care about flashlight depth unless the flashlight is on // SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps20b] // SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps30] @@ -59,7 +63,7 @@ // SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps30] // DISTANCEALPHA-related skips -// SKIP: ($DISTANCEALPHA) && ($ENVMAPMASK || $BASEALPHAENVMAPMASK || $SELFILLUM || $SELFILLUM_ENVMAPMASK_ALPHA ) +// SKIP: ($DISTANCEALPHA) && ($ENVMAPMASK || $BASEALPHAENVMAPMASK || $SELFILLUM || $SELFILLUM_ENVMAPMASK_ALPHA || $ENVMAPFRESNEL) // SKIP: ($DISTANCEALPHA) && ($SEAMLESS_BASE || $SEAMLESS_DETAIL || $CUBEMAP || $LIGHTING_PREVIEW ) // SKIP: ($DISTANCEALPHA) && ($WRITEWATERFOGTODESTALPHA || $FLASHLIGHT || $FLASHLIGHTSHADOWS || $SRGB_INPUT_ADAPTER ) @@ -89,6 +93,12 @@ const float4 g_SelfIllumTint_and_BlendFactor : register( c4 ); const float4 g_ShaderControls : register( c12 ); const float4 g_DepthFeatheringConstants : register( c13 ); +const float4 g_FresnelConstants : register( c14 ); +#define g_flFresnelBias g_FresnelConstants.x +#define g_flFresnelScale g_FresnelConstants.y +#define g_flFresnelExp g_FresnelConstants.z +#define g_flBaseAlphaEnvMapMaskExp g_FresnelConstants.w + const float4 g_EyePos : register( c20 ); const float4 g_FogParams : register( c21 ); @@ -159,6 +169,8 @@ const float4 g_GlowColor : register( c6 ); const float4 g_DistanceAlphaParams : register( c7 ); #define SOFT_MASK_MAX g_DistanceAlphaParams.x #define SOFT_MASK_MIN g_DistanceAlphaParams.y +#define g_flBaseAlphaEnvMapMaskBias g_DistanceAlphaParams.z +#define g_flBaseAlphaEnvMapMaskScale g_DistanceAlphaParams.w const float4 g_OutlineColor : register( c8 ); #define OUTLINE_COLOR g_OutlineColor @@ -330,17 +342,26 @@ float4 main( PS_INPUT i ) : COLOR float3 specularFactor = 1.0f; float4 envmapMaskTexel; - if( bEnvmapMask ) + #if ( ENVMAPMASK ) { envmapMaskTexel = tex2D( EnvmapMaskSampler, i.baseTexCoord.xy ); specularFactor *= envmapMaskTexel.xyz; } + #endif - if( bBaseAlphaEnvmapMask ) + if ( bBaseAlphaEnvmapMask ) { - specularFactor *= 1.0 - baseColor.a; // this blows! + specularFactor *= saturate( g_flBaseAlphaEnvMapMaskScale * pow( baseColor.a, g_flBaseAlphaEnvMapMaskExp ) + g_flBaseAlphaEnvMapMaskBias ); } + #if ( ENVMAPFRESNEL ) + { + float flFresnel = 1-saturate( dot( normalize( i.worldSpaceNormal.xyz ), normalize( i.worldVertToEyeVector.xyz ) ) ); + flFresnel = g_flFresnelScale * pow( flFresnel, g_flFresnelExp ) + g_flFresnelBias; + specularFactor *= flFresnel; + } + #endif + float3 diffuseLighting = float3( 1.0f, 1.0f, 1.0f ); if( bDiffuseLighting || bVertexColor ) { diff --git a/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_vs20.fxc b/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_vs20.fxc index 3060cbad..edeef8f6 100644 --- a/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_vs20.fxc +++ b/src/materialsystem/stdshaders/vertexlit_and_unlit_generic_vs20.fxc @@ -56,7 +56,7 @@ const float4 cDetailTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_4 ); const float4x4 g_FlashlightWorldToTexture : register( SHADER_SPECIFIC_CONST_6 ); // 6, 7, 8, 9 #endif -#ifdef SHADER_MODEL_VS_3_0 +#if defined( SHADER_MODEL_VS_3_0 ) // NOTE: cMorphTargetTextureDim.xy = target dimensions, // cMorphTargetTextureDim.z = 4tuples/morph const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_10 ); @@ -110,7 +110,7 @@ struct VS_INPUT // Position and normal/tangent deltas float3 vPosFlex : POSITION1; float3 vNormalFlex : NORMAL1; -#ifdef SHADER_MODEL_VS_3_0 +#if defined( SHADER_MODEL_VS_3_0 ) float vVertexID : POSITION2; #endif }; @@ -135,7 +135,7 @@ struct VS_OUTPUT #endif float4 color : TEXCOORD2; // Vertex color (from lighting or unlit) -#if CUBEMAP || _X360 +#if 1 //CUBEMAP || _X360 float3 worldVertToEyeVector : TEXCOORD3; // Necessary for cubemaps #endif @@ -184,7 +184,7 @@ VS_OUTPUT main( const VS_INPUT v ) ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, v.vVertexID, v.vTexCoord2, vPosition.xyz, vNormal ); #endif - + #if ( TREESWAY ) { vPosition.xyz = ComputeTreeSway( vPosition.xyz, g_flTime ) + 0; @@ -225,7 +225,7 @@ VS_OUTPUT main( const VS_INPUT v ) o.worldPos_ProjPosZ.w = vProjPos.z; // Needed for cubemaps -#if CUBEMAP +#if 1 //CUBEMAP o.worldVertToEyeVector.xyz = VSHADER_VECT_SCALE * (cEyePos - worldPos); #endif @@ -266,10 +266,18 @@ VS_OUTPUT main( const VS_INPUT v ) // that scale works. More smartness could allow 3d xform. o.SeamlessDetailTexCoord.xyz = (SEAMLESS_SCALE*cDetailTexCoordTransform[0].x) * v.vPos.xyz; #else - // Detail texture coordinates - // FIXME: This shouldn't have to be computed all the time. - o.detailTexCoord.x = dot( v.vTexCoord0, cDetailTexCoordTransform[0] ); - o.detailTexCoord.y = dot( v.vTexCoord0, cDetailTexCoordTransform[1] ); + #if ( TREESWAY ) + { + o.detailTexCoord.xy = v.vTexCoord0; + } + #else + { + // Detail texture coordinates + // FIXME: This shouldn't have to be computed all the time. + o.detailTexCoord.x = dot( v.vTexCoord0, cDetailTexCoordTransform[0] ); + o.detailTexCoord.y = dot( v.vTexCoord0, cDetailTexCoordTransform[1] ); + } + #endif #endif #if SEPARATE_DETAIL_UVS diff --git a/src/materialsystem/stdshaders/vertexlitgeneric_dx9.cpp b/src/materialsystem/stdshaders/vertexlitgeneric_dx9.cpp index b412756e..58077e16 100644 --- a/src/materialsystem/stdshaders/vertexlitgeneric_dx9.cpp +++ b/src/materialsystem/stdshaders/vertexlitgeneric_dx9.cpp @@ -137,6 +137,15 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) SHADER_PARAM( BLENDTINTBYBASEALPHA, SHADER_PARAM_TYPE_BOOL, "0", "Use the base alpha to blend in the $color modulation") SHADER_PARAM( BLENDTINTCOLOROVERBASE, SHADER_PARAM_TYPE_FLOAT, "0", "blend between tint acting as a multiplication versus a replace" ) +#ifdef MAPBASE + SHADER_PARAM( ALLOWDIFFUSEMODULATION, SHADER_PARAM_TYPE_BOOL, "1", "Allow per-instance color modulation" ) + + SHADER_PARAM( ENVMAPFRESNELMINMAXEXP, SHADER_PARAM_TYPE_VEC3, "[0.0 1.0 2.0]", "Min/max fresnel range and exponent for vertexlitgeneric" ) + SHADER_PARAM( BASEALPHAENVMAPMASKMINMAXEXP, SHADER_PARAM_TYPE_VEC3, "[1.0 0.0 1.0]", "" ) + + SHADER_PARAM( PHONGDISABLEHALFLAMBERT, SHADER_PARAM_TYPE_BOOL, "0", "Disable half lambert for phong" ) +#endif + // vertexlitgeneric tree sway animation control SHADER_PARAM( TREESWAY, SHADER_PARAM_TYPE_INTEGER, "0", "" ); SHADER_PARAM( TREESWAYHEIGHT, SHADER_PARAM_TYPE_FLOAT, "1000", "" ); @@ -154,6 +163,7 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) SHADER_PARAM( TREESWAYSPEEDLERPSTART, SHADER_PARAM_TYPE_FLOAT, "3", "" ); SHADER_PARAM( TREESWAYSPEEDLERPEND, SHADER_PARAM_TYPE_FLOAT, "6", "" ); SHADER_PARAM( TREESWAYSTATIC, SHADER_PARAM_TYPE_BOOL, "0", "" ); + SHADER_PARAM( TREESWAYSTATICVALUES, SHADER_PARAM_TYPE_VEC2, "[0.5 0.5]", "" ); END_SHADER_PARAMS @@ -233,6 +243,15 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) info.m_nBlendTintByBaseAlpha = BLENDTINTBYBASEALPHA; info.m_nTintReplacesBaseColor = BLENDTINTCOLOROVERBASE; +#ifdef MAPBASE + info.m_nAllowDiffuseModulation = ALLOWDIFFUSEMODULATION; + + info.m_nEnvMapFresnelMinMaxExp = ENVMAPFRESNELMINMAXEXP; + info.m_nBaseAlphaEnvMapMaskMinMaxExp = BASEALPHAENVMAPMASKMINMAXEXP; + + info.m_nPhongDisableHalfLambert = PHONGDISABLEHALFLAMBERT; +#endif + info.m_nTreeSway = TREESWAY; info.m_nTreeSwayHeight = TREESWAYHEIGHT; info.m_nTreeSwayStartHeight = TREESWAYSTARTHEIGHT; @@ -249,6 +268,7 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" ) info.m_nTreeSwaySpeedLerpStart = TREESWAYSPEEDLERPSTART; info.m_nTreeSwaySpeedLerpEnd = TREESWAYSPEEDLERPEND; info.m_nTreeSwayStatic = TREESWAYSTATIC; + info.m_nTreeSwayStaticValues = TREESWAYSTATICVALUES; } // Cloak Pass diff --git a/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.cpp b/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.cpp index 0349b243..888d5879 100644 --- a/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.cpp +++ b/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.cpp @@ -194,6 +194,7 @@ void InitParamsVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** para CLEAR_FLAGS( MATERIAL_VAR_BASEALPHAENVMAPMASK ); } +#ifndef MAPBASE if ( IS_FLAG_SET( MATERIAL_VAR_BASEALPHAENVMAPMASK ) && info.m_nBumpmap != -1 && params[info.m_nBumpmap]->IsDefined() && !hasNormalMapAlphaEnvmapMask ) { @@ -210,6 +211,7 @@ void InitParamsVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** para params[info.m_nEnvmap]->SetUndefined(); } } +#endif // If mat_specular 0, then get rid of envmap if ( !g_pConfig->UseSpecular() && info.m_nEnvmap != -1 && params[info.m_nEnvmap]->IsDefined() && params[info.m_nBaseTexture]->IsDefined() ) @@ -225,6 +227,21 @@ void InitParamsVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** para InitIntParam( info.m_nDepthBlend, params, 0 ); InitFloatParam( info.m_nDepthBlendScale, params, 50.0f ); +#ifdef MAPBASE + InitIntParam( info.m_nAllowDiffuseModulation, params, 1 ); + + if ( ( info.m_nEnvMapFresnelMinMaxExp != -1 ) && !params[info.m_nEnvMapFresnelMinMaxExp]->IsDefined() ) + { + params[info.m_nEnvMapFresnelMinMaxExp]->SetVecValue( 0.0f, 1.0f, 2.0f, 0.0f ); + } + if ( ( info.m_nBaseAlphaEnvMapMaskMinMaxExp != -1 ) && !params[info.m_nBaseAlphaEnvMapMaskMinMaxExp]->IsDefined() ) + { + // Default to min: 1 max: 0 exp: 1 so that we default to the legacy behavior for basealphaenvmapmask, which is 1-baseColor.a + // These default values translate to a scale of -1, bias of 1 and exponent 1 in the shader. + params[info.m_nBaseAlphaEnvMapMaskMinMaxExp]->SetVecValue( 1.0f, 0.0f, 1.0f, 0.0f ); + } +#endif + InitIntParam( info.m_nTreeSway, params, 0 ); InitFloatParam( info.m_nTreeSwayHeight, params, 1000.0f ); InitFloatParam( info.m_nTreeSwayStartHeight, params, 0.1f ); @@ -465,18 +482,33 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial bool bHasSelfIllum = (!bHasFlashlight || IsX360() ) && IS_FLAG_SET( MATERIAL_VAR_SELFILLUM ); bool bHasEnvmapMask = (!bHasFlashlight || IsX360() ) && info.m_nEnvmapMask != -1 && params[info.m_nEnvmapMask]->IsTexture(); bool bHasSelfIllumFresnel = ( !IsTextureSet( info.m_nDetail, params ) ) && ( bHasSelfIllum ) && ( info.m_nSelfIllumFresnel != -1 ) && ( params[info.m_nSelfIllumFresnel]->GetIntValue() != 0 ); +#ifdef MAPBASE + bool bHasEnvMapFresnel = bHasEnvmap && IsBoolSet( info.m_nEnvmapFresnel, params ); +#endif bool bHasSelfIllumMask = bHasSelfIllum && IsTextureSet( info.m_nSelfIllumMask, params ); bool hasSelfIllumInEnvMapMask = ( info.m_nSelfIllumEnvMapMask_Alpha != -1 ) && ( params[info.m_nSelfIllumEnvMapMask_Alpha]->GetFloatValue() != 0.0 ) ; +#ifdef MAPBASE + if (!bHasEnvmap) + { + bHasEnvmapMask = hasSelfIllumInEnvMapMask; + } +#endif + if ( pShader->IsSnapshotting() ) { /*^*/ // printf("\t\t[2] snapshotting...\n"); +#ifdef MAPBASE + bool hasBaseAlphaEnvmapMask = bHasEnvmap && IS_FLAG_SET( MATERIAL_VAR_BASEALPHAENVMAPMASK ); + bool hasNormalMapAlphaEnvmapMask = bHasEnvmap && IS_FLAG_SET( MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK ); +#else bool hasBaseAlphaEnvmapMask = IS_FLAG_SET( MATERIAL_VAR_BASEALPHAENVMAPMASK ); bool hasNormalMapAlphaEnvmapMask = IS_FLAG_SET( MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK ); +#endif if ( info.m_nVertexAlphaTest != -1 && params[info.m_nVertexAlphaTest]->GetIntValue() > 0 ) @@ -721,6 +753,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); SET_STATIC_PIXEL_SHADER_COMBO( BLENDTINTBYBASEALPHA, bBlendTintByBaseAlpha ); + SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, bHasEnvmapMask ); SET_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_bump_ps20b ); } else // ps_2_0 @@ -765,6 +798,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial SET_STATIC_PIXEL_SHADER_COMBO( DETAIL_BLEND_MODE, nDetailBlendMode ); SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); SET_STATIC_PIXEL_SHADER_COMBO( BLENDTINTBYBASEALPHA, bBlendTintByBaseAlpha ); + SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, bHasEnvmapMask ); SET_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_bump_ps30 ); } #endif @@ -811,7 +845,9 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial DECLARE_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUM_ENVMAPMASK_ALPHA, ( hasSelfIllumInEnvMapMask && ( bHasEnvmapMask ) ) ); SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap ); +#ifndef MAPBASE SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP_SPHERE_LEGACY, bHasLegacyEnvSphereMap ); +#endif SET_STATIC_PIXEL_SHADER_COMBO( DIFFUSELIGHTING, hasDiffuseLighting ); SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, bHasEnvmapMask ); SET_STATIC_PIXEL_SHADER_COMBO( BASEALPHAENVMAPMASK, hasBaseAlphaEnvmapMask ); @@ -880,7 +916,9 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial DECLARE_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_ps30 ); SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUM_ENVMAPMASK_ALPHA, ( hasSelfIllumInEnvMapMask && ( bHasEnvmapMask ) ) ); SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap ); +#ifndef MAPBASE SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP_SPHERE_LEGACY, bHasLegacyEnvSphereMap ); +#endif SET_STATIC_PIXEL_SHADER_COMBO( DIFFUSELIGHTING, hasDiffuseLighting ); SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPMASK, bHasEnvmapMask ); SET_STATIC_PIXEL_SHADER_COMBO( BASEALPHAENVMAPMASK, hasBaseAlphaEnvmapMask ); @@ -899,6 +937,9 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode ); SET_STATIC_PIXEL_SHADER_COMBO( DEPTHBLEND, bDoDepthBlend ); SET_STATIC_PIXEL_SHADER_COMBO( BLENDTINTBYBASEALPHA, bBlendTintByBaseAlpha ); +#ifdef MAPBASE + SET_STATIC_PIXEL_SHADER_COMBO( ENVMAPFRESNEL, bHasEnvMapFresnel ); +#endif SET_STATIC_PIXEL_SHADER( vertexlit_and_unlit_generic_ps30 ); } #endif @@ -992,6 +1033,18 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial pContextData->m_SemiStaticCmdsOut.SetPixelShaderConstant4( 10, 1, 1, 1, 1 ); } } +#ifdef MAPBASE + else if ( bHasEnvmapMask && info.m_nEnvmapMaskTransform != -1 ) + { + // Use $envmapmasktransform when there is no detail texture taking up this space + pContextData->m_SemiStaticCmdsOut.SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_4, info.m_nEnvmapMaskTransform ); + } + else if ( bHasBump && info.m_nBumpTransform != -1 ) + { + // Use $bumptransform when there is no detail texture taking up this space + pContextData->m_SemiStaticCmdsOut.SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_4, info.m_nBumpTransform ); + } +#endif if ( bDistanceAlpha ) { float flSoftStart = GetFloatParam( info.m_nEdgeSoftnessStart, params ); @@ -1063,9 +1116,26 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial { params[info.m_nOutlineColor]->GetVecValue( flConsts+12, 3 ); } +#ifdef MAPBASE + if ( info.m_nBaseAlphaEnvMapMaskMinMaxExp != -1 ) + { + flConsts[10] = params[ info.m_nBaseAlphaEnvMapMaskMinMaxExp ]->GetVecValue()[0]; + flConsts[11] = params[ info.m_nBaseAlphaEnvMapMaskMinMaxExp ]->GetVecValue()[1] - flConsts[10]; + } +#endif pContextData->m_SemiStaticCmdsOut.SetPixelShaderConstant( 5, flConsts, 5 ); } +#ifdef MAPBASE + else if ( info.m_nBaseAlphaEnvMapMaskMinMaxExp != -1 ) + { + float flConsts[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + + flConsts[2] = params[ info.m_nBaseAlphaEnvMapMaskMinMaxExp ]->GetVecValue()[0]; + flConsts[3] = params[ info.m_nBaseAlphaEnvMapMaskMinMaxExp ]->GetVecValue()[1] - flConsts[2]; + pContextData->m_SemiStaticCmdsOut.SetPixelShaderConstant( 7, flConsts, 1 ); + } +#endif if ( !g_pConfig->m_bFastNoBump ) { if ( bHasBump ) @@ -1105,6 +1175,29 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial pContextData->m_SemiStaticCmdsOut.BindTexture( pShader, SHADER_SAMPLER4, info.m_nEnvmapMask, info.m_nEnvmapMaskFrame ); } +#ifdef MAPBASE + if ( bHasEnvMapFresnel ) + { + float flConsts[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + params[ info.m_nEnvMapFresnelMinMaxExp ]->GetVecValue( flConsts, 3 ); + flConsts[1] -= flConsts[0]; // convert max fresnel into scale factor + + if ( info.m_nBaseAlphaEnvMapMaskMinMaxExp != -1 ) + { + flConsts[3] = params[ info.m_nBaseAlphaEnvMapMaskMinMaxExp ]->GetVecValue()[2]; // basealphaenvmapmask exponent in w + } + + pContextData->m_SemiStaticCmdsOut.SetPixelShaderConstant( 14, flConsts, 1 ); + } + else if ( info.m_nBaseAlphaEnvMapMaskMinMaxExp != -1 ) + { + // still need to set exponent for basealphaenvmapmask + float flConsts[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + flConsts[3] = params[ info.m_nBaseAlphaEnvMapMaskMinMaxExp ]->GetVecValue()[2]; // basealphaenvmapmask exponent in w + pContextData->m_SemiStaticCmdsOut.SetPixelShaderConstant( 14, flConsts, 1 ); + } +#endif + if ( bHasSelfIllumFresnel && (!bHasFlashlight || IsX360() ) ) { float vConstScaleBiasExp[4] = { 1.0f, 0.0f, 1.0f, 0.0f }; @@ -1447,14 +1540,29 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial #endif } - if ( ( info.m_nHDRColorScale != -1 ) && pShader->IsHDREnabled() ) +#ifdef MAPBASE + // material can choose to support per-instance modulation via $allowdiffusemodulation + bool bAllowDiffuseModulation = (info.m_nAllowDiffuseModulation == -1) ? true : (params[info.m_nAllowDiffuseModulation]->GetIntValue() != 0); + + if (bAllowDiffuseModulation) +#endif { - pShader->SetModulationPixelShaderDynamicState_LinearColorSpace_LinearScale( 1, params[info.m_nHDRColorScale]->GetFloatValue() ); + if ( ( info.m_nHDRColorScale != -1 ) && pShader->IsHDREnabled() ) + { + pShader->SetModulationPixelShaderDynamicState_LinearColorSpace_LinearScale( 1, params[info.m_nHDRColorScale]->GetFloatValue() ); + } + else + { + pShader->SetModulationPixelShaderDynamicState_LinearColorSpace( 1 ); + } } +#ifdef MAPBASE else { - pShader->SetModulationPixelShaderDynamicState_LinearColorSpace( 1 ); + float color[4] = { 1.0, 1.0, 1.0, 1.0 }; + pShaderAPI->SetPixelShaderConstant( 1, color ); } +#endif float eyePos[4]; pShaderAPI->GetWorldSpaceCameraPosition( eyePos ); diff --git a/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.h b/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.h index 0279b331..207f72c2 100644 --- a/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.h +++ b/src/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.h @@ -133,6 +133,20 @@ struct VertexLitGeneric_DX9_Vars_t int m_nTintReplacesBaseColor; +#ifdef MAPBASE + // Parameters ported from Alien Swarm SDK shaders. + + // Utility param for disabling tinting on certain materials. + int m_nAllowDiffuseModulation; + + // $envmapfresnel on non-phong materials. + int m_nEnvMapFresnelMinMaxExp; + int m_nBaseAlphaEnvMapMaskMinMaxExp; + + // Disables $halflambert on phong materials. See bPhongHalfLambert in DrawSkin_DX9_Internal() for more info. + int m_nPhongDisableHalfLambert; +#endif + int m_nTreeSway; int m_nTreeSwayHeight; int m_nTreeSwayStartHeight; @@ -149,6 +163,7 @@ struct VertexLitGeneric_DX9_Vars_t int m_nTreeSwaySpeedLerpStart; int m_nTreeSwaySpeedLerpEnd; int m_nTreeSwayStatic; + int m_nTreeSwayStaticValues; }; void InitParamsVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, bool bVertexLitGeneric, VertexLitGeneric_DX9_Vars_t &info ); diff --git a/src/materialsystem/stdshaders/water.cpp b/src/materialsystem/stdshaders/water.cpp index c7070039..f2547106 100644 --- a/src/materialsystem/stdshaders/water.cpp +++ b/src/materialsystem/stdshaders/water.cpp @@ -151,6 +151,19 @@ BEGIN_VS_SHADER( Water_DX90, if ( params[ENVMAP]->IsDefined() ) { LoadCubeMap( ENVMAP, TEXTUREFLAGS_SRGB ); + +#ifdef MAPBASE + if (mat_specular_disable_on_missing.GetBool()) + { + // Revert to defaultcubemap when the envmap texture is missing + // (should be equivalent to toolsblack in Mapbase) + if (params[ENVMAP]->GetTextureValue()->IsError()) + { + params[ENVMAP]->SetStringValue( "engine/defaultcubemap" ); + LoadCubeMap( ENVMAP, TEXTUREFLAGS_SRGB ); + } + } +#endif } if ( params[NORMALMAP]->IsDefined() ) { diff --git a/src/materialsystem/stdshaders/windowimposter_dx90.cpp b/src/materialsystem/stdshaders/windowimposter_dx90.cpp index dc333895..ac918023 100644 --- a/src/materialsystem/stdshaders/windowimposter_dx90.cpp +++ b/src/materialsystem/stdshaders/windowimposter_dx90.cpp @@ -23,11 +23,28 @@ BEGIN_VS_SHADER( WindowImposter_DX90, BEGIN_SHADER_PARAMS SHADER_PARAM( ENVMAP, SHADER_PARAM_TYPE_TEXTURE, "shadertest/shadertest_env", "envmap" ) + +#ifdef MAPBASE + SHADER_PARAM( ENVMAPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "" ) +#endif + +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps + SHADER_PARAM( ENVMAPPARALLAX, SHADER_PARAM_TYPE_BOOL, "0", "Enables parallax correction code for env_cubemaps" ) + SHADER_PARAM( ENVMAPPARALLAXOBB1, SHADER_PARAM_TYPE_VEC4, "[1 0 0 0]", "The first line of the parallax correction OBB matrix" ) + SHADER_PARAM( ENVMAPPARALLAXOBB2, SHADER_PARAM_TYPE_VEC4, "[0 1 0 0]", "The second line of the parallax correction OBB matrix" ) + SHADER_PARAM( ENVMAPPARALLAXOBB3, SHADER_PARAM_TYPE_VEC4, "[0 0 1 0]", "The third line of the parallax correction OBB matrix" ) + SHADER_PARAM( ENVMAPORIGIN, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "The world space position of the env_cubemap being corrected" ) +#endif END_SHADER_PARAMS // Set up anything that is necessary to make decisions in SHADER_FALLBACK. SHADER_INIT_PARAMS() { +#ifdef MAPBASE + if( !params[ENVMAPFRAME]->IsDefined() ) + params[ENVMAPFRAME]->SetIntValue( 0 ); +#endif } SHADER_FALLBACK @@ -41,10 +58,29 @@ BEGIN_VS_SHADER( WindowImposter_DX90, SHADER_INIT { LoadCubeMap( ENVMAP ); +#ifdef MAPBASE + if (mat_specular_disable_on_missing.GetBool()) + { + // Revert to defaultcubemap when the envmap texture is missing + // (should be equivalent to toolsblack in Mapbase) + if (params[ENVMAP]->GetTextureValue()->IsError()) + { + params[ENVMAP]->SetStringValue( "engine/defaultcubemap" ); + LoadCubeMap( ENVMAP ); + } + } +#endif } SHADER_DRAW { +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps + bool hasParallaxCorrection = params[ENVMAPPARALLAX]->GetIntValue() > 0; +#else + bool hasParallaxCorrection = false; +#endif + SHADOW_STATE { if( g_pHardwareConfig->GetHDRType() != HDR_TYPE_NONE ) @@ -53,20 +89,32 @@ BEGIN_VS_SHADER( WindowImposter_DX90, pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); DECLARE_STATIC_VERTEX_SHADER( windowimposter_vs20 ); + SET_STATIC_VERTEX_SHADER_COMBO( PARALLAXCORRECT, hasParallaxCorrection ); // Parallax cubemaps enabled for 2_0b and onwards SET_STATIC_VERTEX_SHADER( windowimposter_vs20 ); if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) { DECLARE_STATIC_PIXEL_SHADER( windowimposter_ps20b ); + SET_STATIC_PIXEL_SHADER_COMBO( PARALLAXCORRECT, hasParallaxCorrection ); // Parallax cubemaps enabled for 2_0b and onwards SET_STATIC_PIXEL_SHADER( windowimposter_ps20b ); } else { DECLARE_STATIC_PIXEL_SHADER( windowimposter_ps20 ); + //SET_STATIC_PIXEL_SHADER_COMBO( PARALLAXCORRECT, 0 ); // No parallax cubemaps with ps_2_0 :( SET_STATIC_PIXEL_SHADER( windowimposter_ps20 ); } - pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 ); + unsigned int flags = VERTEX_POSITION; + int nTexCoordCount = 2; + + if (hasParallaxCorrection) + { + flags |= VERTEX_NORMAL; + nTexCoordCount++; + } + + pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, 0, 0 ); pShaderShadow->EnableBlending( true ); pShaderShadow->BlendFunc( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA ); pShaderShadow->EnableDepthWrites( false ); @@ -98,7 +146,35 @@ BEGIN_VS_SHADER( WindowImposter_DX90, vEyePos_SpecExponent[3] = 0.0f; pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 ); +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps + if (hasParallaxCorrection) + { + pShaderAPI->SetPixelShaderConstant( 0, params[ENVMAPORIGIN]->GetVecValue() ); + + float* vecs[3]; + vecs[0] = const_cast(params[ENVMAPPARALLAXOBB1]->GetVecValue()); + vecs[1] = const_cast(params[ENVMAPPARALLAXOBB2]->GetVecValue()); + vecs[2] = const_cast(params[ENVMAPPARALLAXOBB3]->GetVecValue()); + float matrix[4][4]; + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 4; j++) + { + matrix[i][j] = vecs[i][j]; + } + } + matrix[3][0] = matrix[3][1] = matrix[3][2] = 0; + matrix[3][3] = 1; + pShaderAPI->SetPixelShaderConstant( 1, &matrix[0][0], 4 ); + } +#endif + +#ifdef MAPBASE + BindTexture( SHADER_SAMPLER0, ENVMAP, ENVMAPFRAME ); +#else BindTexture( SHADER_SAMPLER0, ENVMAP, -1 ); +#endif SetModulationVertexShaderDynamicState(); } Draw(); diff --git a/src/materialsystem/stdshaders/windowimposter_ps2x.fxc b/src/materialsystem/stdshaders/windowimposter_ps2x.fxc index 0c153d4e..c6f41314 100644 --- a/src/materialsystem/stdshaders/windowimposter_ps2x.fxc +++ b/src/materialsystem/stdshaders/windowimposter_ps2x.fxc @@ -4,8 +4,10 @@ // //============================================================================= +// STATIC: "PARALLAXCORRECT" "0..1" // DYNAMIC: "PIXELFOGTYPE" "0..2" +// SKIP: $PARALLAXCORRECT [ps20] // STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC] // STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX] @@ -17,18 +19,49 @@ sampler EnvmapSampler : register( s0 ); const float4 g_FogParams : register( PSREG_FOG_PARAMS ); const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT ); +#if PARALLAXCORRECT +// Parallax cubemaps +const float3 cubemapPos : register(c0); +const float4x4 obbMatrix : register(c1); //through c4 +#endif + struct PS_INPUT { float3 eyeToVertVector : TEXCOORD0; float4 vertexColor : COLOR; - float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog + float4 worldPos_projPosZ : TEXCOORD1; // Necessary for pixel fog + +#if PARALLAXCORRECT + float3 worldSpaceNormal : TEXCOORD2; +#endif }; float4 main( PS_INPUT i ) : COLOR { +#if PARALLAXCORRECT + float3 reflectVect = CalcReflectionVectorUnnormalized( i.worldSpaceNormal, g_EyePos_SpecExponent.xyz - i.worldPos_projPosZ.xyz ); //i.eyeToVertVector; //CalcReflectionVectorUnnormalized( i.worldSpaceNormal, i.eyeToVertVector ); + + //Parallax correction (2_0b and beyond) + //Adapted from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ + float3 worldPos = i.worldPos_projPosZ.xyz; + float3 positionLS = mul(float4(worldPos, 1), obbMatrix); + float3 rayLS = mul(reflectVect, (float3x3) obbMatrix); + + float3 firstPlaneIntersect = (float3(1.0f, 1.0f, 1.0f) - positionLS) / rayLS; + float3 secondPlaneIntersect = (-positionLS) / rayLS; + float3 furthestPlane = max(firstPlaneIntersect, secondPlaneIntersect); + float distance = min(furthestPlane.x, min(furthestPlane.y, furthestPlane.z)); + + // Use distance in WS directly to recover intersection + float3 intersectPositionWS = worldPos + reflectVect * distance; + reflectVect = intersectPositionWS - cubemapPos; +#else + float3 reflectVect = i.eyeToVertVector; +#endif + HALF4 color; - color.xyz = ENV_MAP_SCALE * texCUBE( EnvmapSampler, i.eyeToVertVector ); + color.xyz = ENV_MAP_SCALE * texCUBE( EnvmapSampler, reflectVect ); color.a = 1.0f; color *= i.vertexColor; diff --git a/src/materialsystem/stdshaders/windowimposter_vs20.fxc b/src/materialsystem/stdshaders/windowimposter_vs20.fxc index d9d3d041..b923516e 100644 --- a/src/materialsystem/stdshaders/windowimposter_vs20.fxc +++ b/src/materialsystem/stdshaders/windowimposter_vs20.fxc @@ -1,10 +1,11 @@ -// DYNAMIC: "DOWATERFOG" "0..1" - //====== Copyright © 1996-2004, Valve Corporation, All rights reserved. ======= // // Purpose: // //============================================================================= +// STATIC: "PARALLAXCORRECT" "0..1" + +// DYNAMIC: "DOWATERFOG" "0..1" #include "common_vs_fxc.h" @@ -13,6 +14,9 @@ static const int g_FogType = DOWATERFOG; struct VS_INPUT { float3 vPos : POSITION; +#if PARALLAXCORRECT + float4 vNormal : NORMAL; +#endif }; struct VS_OUTPUT @@ -24,7 +28,11 @@ struct VS_OUTPUT float3 eyeToVertVector : TEXCOORD0; float4 vertexColor : COLOR; - float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog + float4 worldPos_projPosZ : TEXCOORD1; // Necessary for pixel fog + +#if PARALLAXCORRECT + float3 worldNormal : TEXCOORD2; +#endif }; VS_OUTPUT main( const VS_INPUT v ) @@ -39,6 +47,12 @@ VS_OUTPUT main( const VS_INPUT v ) #if !defined( _X360 ) o.fog = CalcFog( worldPos, o.projPos, g_FogType ); #endif + +#if PARALLAXCORRECT + float3 vObjNormal; + DecompressVertex_Normal( v.vNormal, vObjNormal ); + o.worldNormal = mul( vObjNormal, ( float3x3 )cModel[0] ); +#endif o.vertexColor = cModulationColor; return o; } diff --git a/src/materialsystem/stdshaders/worldtwotextureblend.cpp b/src/materialsystem/stdshaders/worldtwotextureblend.cpp index adfc7bb2..f0794b80 100644 --- a/src/materialsystem/stdshaders/worldtwotextureblend.cpp +++ b/src/materialsystem/stdshaders/worldtwotextureblend.cpp @@ -258,6 +258,9 @@ END_SHADER_PARAMS SET_STATIC_VERTEX_SHADER_COMBO( SEAMLESS, bSeamlessMapping ); //( bumpmap_variant == 2 )?1:0); #ifdef _X360 SET_STATIC_VERTEX_SHADER_COMBO( FLASHLIGHT, hasFlashlight ); +#endif +#ifdef MAPBASE + SET_STATIC_VERTEX_SHADER_COMBO( BASETEXTURETRANSFORM2, false ); #endif SET_STATIC_VERTEX_SHADER( lightmappedgeneric_vs20 ); diff --git a/src/materialsystem/stdshaders/worldvertextransition.cpp b/src/materialsystem/stdshaders/worldvertextransition.cpp index e7d6a9ab..748b2bc0 100644 --- a/src/materialsystem/stdshaders/worldvertextransition.cpp +++ b/src/materialsystem/stdshaders/worldvertextransition.cpp @@ -50,6 +50,10 @@ BEGIN_VS_SHADER( WorldVertexTransition_DX9, "Help for WorldVertexTransition" ) SHADER_PARAM( BUMPMASK, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader1_normal", "bump map" ) SHADER_PARAM( BASETEXTURE2, SHADER_PARAM_TYPE_TEXTURE, "shadertest/detail", "detail texture" ) SHADER_PARAM( FRAME2, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $basetexture2" ) +#ifdef MAPBASE + // This needs to be a SHADER_PARAM_TYPE_STRING so it isn't considered "defined" by default. + SHADER_PARAM( BASETEXTURETRANSFORM2, SHADER_PARAM_TYPE_STRING, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$basetexture2 texcoord transform" ) +#endif SHADER_PARAM( BASETEXTURENOENVMAP, SHADER_PARAM_TYPE_BOOL, "0", "" ) SHADER_PARAM( BASETEXTURE2NOENVMAP, SHADER_PARAM_TYPE_BOOL, "0", "" ) SHADER_PARAM( DETAIL_ALPHA_MASK_BASE_TEXTURE, SHADER_PARAM_TYPE_BOOL, "0", @@ -61,6 +65,20 @@ BEGIN_VS_SHADER( WorldVertexTransition_DX9, "Help for WorldVertexTransition" ) SHADER_PARAM( MASKEDBLENDING, SHADER_PARAM_TYPE_INTEGER, "0", "blend using texture with no vertex alpha. For using texture blending on non-displacements" ) SHADER_PARAM( SSBUMP, SHADER_PARAM_TYPE_INTEGER, "0", "whether or not to use alternate bumpmap format with height" ) SHADER_PARAM( SEAMLESS_SCALE, SHADER_PARAM_TYPE_FLOAT, "0", "Scale factor for 'seamless' texture mapping. 0 means to use ordinary mapping" ) + + SHADER_PARAM( PHONG, SHADER_PARAM_TYPE_BOOL, "0", "enables phong lighting" ) + SHADER_PARAM( PHONGBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "Phong overbrightening factor (specular mask channel should be authored to account for this)" ) + SHADER_PARAM( PHONGFRESNELRANGES, SHADER_PARAM_TYPE_VEC3, "[0 0.5 1]", "Parameters for remapping fresnel output" ) + SHADER_PARAM( PHONGEXPONENT, SHADER_PARAM_TYPE_FLOAT, "5.0", "Phong exponent for local specular lights" ) + +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps + SHADER_PARAM( ENVMAPPARALLAX, SHADER_PARAM_TYPE_BOOL, "0", "Enables parallax correction code for env_cubemaps" ) + SHADER_PARAM( ENVMAPPARALLAXOBB1, SHADER_PARAM_TYPE_VEC4, "[1 0 0 0]", "The first line of the parallax correction OBB matrix" ) + SHADER_PARAM( ENVMAPPARALLAXOBB2, SHADER_PARAM_TYPE_VEC4, "[0 1 0 0]", "The second line of the parallax correction OBB matrix" ) + SHADER_PARAM( ENVMAPPARALLAXOBB3, SHADER_PARAM_TYPE_VEC4, "[0 0 1 0]", "The third line of the parallax correction OBB matrix" ) + SHADER_PARAM( ENVMAPORIGIN, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "The world space position of the env_cubemap being corrected" ) +#endif END_SHADER_PARAMS void SetupVars( WorldVertexTransitionEditor_DX8_Vars_t& info ) @@ -70,7 +88,11 @@ BEGIN_VS_SHADER( WorldVertexTransition_DX9, "Help for WorldVertexTransition" ) info.m_nBaseTextureTransformVar = BASETEXTURETRANSFORM; info.m_nBaseTexture2Var = BASETEXTURE2; info.m_nBaseTexture2FrameVar = FRAME2; +#ifdef MAPBASE + info.m_nBaseTexture2TransformVar = BASETEXTURETRANSFORM2; +#else info.m_nBaseTexture2TransformVar = BASETEXTURETRANSFORM; // FIXME!!!! +#endif } void SetupVars( LightmappedGeneric_DX9_Vars_t& info ) @@ -105,6 +127,9 @@ BEGIN_VS_SHADER( WorldVertexTransition_DX9, "Help for WorldVertexTransition" ) info.m_nBumpFrame2 = BUMPFRAME2; info.m_nBaseTexture2 = BASETEXTURE2; info.m_nBaseTexture2Frame = FRAME2; +#ifdef MAPBASE + info.m_nBaseTexture2Transform = BASETEXTURETRANSFORM2; +#endif info.m_nBumpTransform2 = BUMPTRANSFORM2; info.m_nBumpMask = BUMPMASK; info.m_nBaseTextureNoEnvmap = BASETEXTURENOENVMAP; @@ -119,6 +144,20 @@ BEGIN_VS_SHADER( WorldVertexTransition_DX9, "Help for WorldVertexTransition" ) info.m_nSelfShadowedBumpFlag = SSBUMP; info.m_nSeamlessMappingScale = SEAMLESS_SCALE; info.m_nAlphaTestReference = -1; + + info.m_nPhong = PHONG; + info.m_nPhongBoost = PHONGBOOST; + info.m_nPhongFresnelRanges = PHONGFRESNELRANGES; + info.m_nPhongExponent = PHONGEXPONENT; + +#ifdef PARALLAX_CORRECTED_CUBEMAPS + // Parallax cubemaps + info.m_nEnvmapParallax = ENVMAPPARALLAX; + info.m_nEnvmapParallaxObb1 = ENVMAPPARALLAXOBB1; + info.m_nEnvmapParallaxObb2 = ENVMAPPARALLAXOBB2; + info.m_nEnvmapParallaxObb3 = ENVMAPPARALLAXOBB3; + info.m_nEnvmapOrigin = ENVMAPORIGIN; +#endif } SHADER_FALLBACK