mirror of
https://github.com/celisej567/BCWSsrc.git
synced 2026-09-21 20:15:08 +03:00
Mapbase v3.1
- Fixed filter_damage_mod blocking all damage which doesn't match the secondary filter regardless of secondary filter mode - Fixed impulse 101 and other give-related commands leaving behind weapons with occupied slots - Fixed a crash with scripted_sound's PlaySoundOnEntity when the entity doesn't exist - Added OnSoundFinished output to ambient_generic - Added the ability to use custom models/nuggets with item_grubnugget - Fixed a crash with citizen medics healing nonexistent targets - Added "SetDistLook" and "SetDistTooFar" inputs for NPCs, allowing manual adjustment of NPC sight distance - Added keyvalue and input to env_microphone for utilizing a different audio channel - Added "SetPitchScale" input to env_microphone - Fixed info_player_view_proxy not using angles - Fixed dirt variant elite model not being recognized as elite - Made headcrab hints properly register the start of use (for hint outputs) - Made RPG use a more realistic firing rate for NPCs which aren't constrained by slow RPG animations, like soldiers - Added spawnflag for func_breakable_surf to correctly play the break sound - Added keyvalue for using cheaper warn sound code for combine_mines - Added "OnSpawnNPC" output for npc_combinedropship when it spawns a soldier, rollermine, or strider - Added signal gesture activities - Fixed stunstick not using metrocop knockout/stun code correctly - Fixed a possible crash involving a NPC's weapon being removed during alt-fire - Fixed(?) flashlight shadow filters - Added support for multiple look entities in trigger_look - Added npc_metropolice alt-firing - Fixed npc_metropolice using pistol burst firing on weapon_357 - Fixed npc_metropolice not deploying manhacks/throwing grenades in standoffs - Fixed npc_metropolice not recognizing some crouch activities correctly - Changed weapon_357 so it runs a tracer each shot from NPCs - Added SDK_ShatteredGlass, a Mapbase version of ShatteredGlass - Added "SetSpeedModifier" to NPCs, based on 1upD's shadow walker code - Made game_convar_mod much more reliable - Fixed non-mirrored npc_turret_lab refusing to die - Made npc_turret_lab use SMG1 ammo instead of AR2 ammo - Fixed block LOS brushes sometimes not working with players (and possibly similar issues) - Raised maximum renderable entities from 4096 to 16384, based on ficool2's limit research - Added SDK_ShatteredGlass, a Mapbase version of ShatteredGlass. Can display parallax corrected cubemaps from its unbroken form - Fixed VBSP breaking func_breakable_surf, etc. when using parallax corrected cubemaps - Raised maximum VBSP entities from 8192 to 65536, based on ficool2's limit research - Raised maximum VBSP worldlights from 8192 to 65536, based on ficool2's limit research - Raised maximum VBSP overlays from 512 to 8192, based on ficool2's limit research - Other misc. fixes
This commit is contained in:
159
sp/src/materialsystem/stdshaders/SDK_ShatteredGlass_ps2x.fxc
Normal file
159
sp/src/materialsystem/stdshaders/SDK_ShatteredGlass_ps2x.fxc
Normal file
@@ -0,0 +1,159 @@
|
||||
//========== 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]
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
// HDRFIXME: Need to make this work.
|
||||
|
||||
#define USE_32BIT_LIGHTMAPS_ON_360 //uncomment to use 32bit lightmaps, be sure to keep this in sync with the same #define in materialsystem/cmatlightmaps.cpp
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
|
||||
const HALF4 g_EnvmapTint : register( c0 );
|
||||
const HALF3 g_DiffuseModulation : register( c1 );
|
||||
const HALF3 g_EnvmapContrast : register( c2 );
|
||||
const HALF3 g_EnvmapSaturation : register( c3 );
|
||||
const HALF4 g_FresnelReflection : register( c4 );
|
||||
const HALF3 g_EyePos : register( c5 );
|
||||
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 );
|
||||
sampler LightmapSampler : register( s1 );
|
||||
sampler EnvmapSampler : register( s2 );
|
||||
sampler DetailSampler : register( s3 );
|
||||
sampler EnvmapMaskSampler : register( s5 );
|
||||
|
||||
sampler NormalizeSampler : register( s6 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
HALF2 baseTexCoord : TEXCOORD0;
|
||||
HALF2 detailTexCoord : TEXCOORD1;
|
||||
HALF2 lightmapTexCoord : TEXCOORD2;
|
||||
HALF2 envmapMaskTexCoord : TEXCOORD3;
|
||||
HALF4 worldPos_projPosZ : TEXCOORD4;
|
||||
HALF3 worldSpaceNormal : TEXCOORD5;
|
||||
HALF4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
bool bCubemap = CUBEMAP ? true : false;
|
||||
bool bVertexColor = VERTEXCOLOR ? true : false;
|
||||
bool bEnvmapMask = ENVMAPMASK ? true : false;
|
||||
bool bBaseAlphaEnvmapMask = BASEALPHAENVMAPMASK ? true : false;
|
||||
|
||||
HALF4 baseColor = tex2D( BaseTextureSampler, i.baseTexCoord );
|
||||
HALF4 detailColor = tex2D( DetailSampler, i.detailTexCoord );
|
||||
|
||||
HALF2 lightmapCoordinates = i.lightmapTexCoord;
|
||||
HALF3 lightmapColor = LightMapSample( LightmapSampler, lightmapCoordinates );
|
||||
|
||||
HALF3 specularFactor = 1.0f;
|
||||
if( bEnvmapMask )
|
||||
{
|
||||
specularFactor = tex2D( EnvmapMaskSampler, i.detailTexCoord ).xyz;
|
||||
}
|
||||
|
||||
if( bBaseAlphaEnvmapMask )
|
||||
{
|
||||
specularFactor *= 1.0 - baseColor.a; // this blows!
|
||||
}
|
||||
|
||||
HALF3 diffuseLighting = lightmapColor;
|
||||
diffuseLighting *= g_DiffuseModulation;
|
||||
diffuseLighting *= LIGHT_MAP_SCALE;
|
||||
|
||||
HALF3 albedo = baseColor;
|
||||
HALF alpha = 1.0f;
|
||||
|
||||
if( !bBaseAlphaEnvmapMask )
|
||||
{
|
||||
alpha *= baseColor.a;
|
||||
}
|
||||
|
||||
albedo *= detailColor;
|
||||
alpha *= detailColor.a;
|
||||
|
||||
// FIXME: seperate vertexcolor and vertexalpha?
|
||||
// vertex alpha is ignored if vertexcolor isn't set. . need to check other version.
|
||||
if( bVertexColor )
|
||||
{
|
||||
albedo *= i.vertexColor;
|
||||
alpha *= i.vertexColor.a; // not sure about this one
|
||||
}
|
||||
|
||||
HALF3 specularLighting = HALF3( 0.0f, 0.0f, 0.0f );
|
||||
if( bCubemap )
|
||||
{
|
||||
float3 worldVertToEyeVector = g_EyePos - i.worldPos_projPosZ.xyz;
|
||||
worldVertToEyeVector = NormalizeWithCubemap( NormalizeSampler, worldVertToEyeVector );
|
||||
HALF3 reflectVect = CalcReflectionVectorUnnormalized( i.worldSpaceNormal, worldVertToEyeVector );
|
||||
|
||||
// Calc Fresnel factor
|
||||
HALF3 worldSpaceNormal = NormalizeWithCubemap( NormalizeSampler, i.worldSpaceNormal );
|
||||
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;
|
||||
|
||||
specularLighting *= g_EnvmapTint;
|
||||
#if HDRTYPE == HDR_TYPE_NONE
|
||||
HALF3 specularLightingSquared = specularLighting * specularLighting;
|
||||
specularLighting = lerp( specularLighting, specularLightingSquared, g_EnvmapContrast );
|
||||
HALF3 greyScale = dot( specularLighting, HALF3( 0.299f, 0.587f, 0.114f ) );
|
||||
specularLighting = lerp( greyScale, specularLighting, g_EnvmapSaturation );
|
||||
#endif
|
||||
specularLighting *= fresnel;
|
||||
}
|
||||
|
||||
// Do it somewhat unlit
|
||||
HALF3 result = albedo*(g_OverbrightFactor.z*diffuseLighting + g_OverbrightFactor.y) + specularLighting;
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
67
sp/src/materialsystem/stdshaders/SDK_ShatteredGlass_vs20.fxc
Normal file
67
sp/src/materialsystem/stdshaders/SDK_ShatteredGlass_vs20.fxc
Normal file
@@ -0,0 +1,67 @@
|
||||
// STATIC: "ENVMAP_MASK" "0..1"
|
||||
|
||||
// DYNAMIC: "DOWATERFOG" "0..1"
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
static const int g_FogType = DOWATERFOG;
|
||||
static const bool g_UseSeparateEnvmapMask = ENVMAP_MASK;
|
||||
|
||||
const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
|
||||
const float4 cDetailTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_2 );
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float4 vNormal : NORMAL;
|
||||
float2 vBaseTexCoord : TEXCOORD0;
|
||||
float2 vLightmapTexCoord : TEXCOORD1;
|
||||
float2 vDetailTexCoord : TEXCOORD2;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
|
||||
float fog : FOG;
|
||||
#endif
|
||||
float2 baseTexCoord : TEXCOORD0;
|
||||
float2 detailTexCoord : TEXCOORD1;
|
||||
float2 lightmapTexCoord : TEXCOORD2;
|
||||
float2 envmapMaskTexCoord : TEXCOORD3;
|
||||
float4 worldPos_projPosZ : TEXCOORD4;
|
||||
float3 worldNormal : TEXCOORD5;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
float3 vObjNormal;
|
||||
DecompressVertex_Normal( v.vNormal, vObjNormal );
|
||||
|
||||
float4 projPos;
|
||||
projPos = mul( float4( v.vPos, 1 ), cModelViewProj );
|
||||
o.projPos = projPos;
|
||||
|
||||
o.worldPos_projPosZ.w = projPos.z;
|
||||
o.worldPos_projPosZ.xyz = mul( float4( v.vPos, 1 ), cModel[0] );
|
||||
o.worldNormal = mul( vObjNormal, ( float3x3 )cModel[0] );
|
||||
o.baseTexCoord.x = dot( v.vBaseTexCoord, cBaseTexCoordTransform[0] ) + cBaseTexCoordTransform[0].w;
|
||||
o.baseTexCoord.y = dot( v.vBaseTexCoord, cBaseTexCoordTransform[1] ) + cBaseTexCoordTransform[1].w;
|
||||
o.detailTexCoord.x = dot( v.vDetailTexCoord, cDetailTexCoordTransform[0] ) + cDetailTexCoordTransform[0].w;
|
||||
o.detailTexCoord.y = dot( v.vDetailTexCoord, cDetailTexCoordTransform[1] ) + cDetailTexCoordTransform[1].w;
|
||||
o.envmapMaskTexCoord.x = dot( v.vDetailTexCoord, cDetailTexCoordTransform[0] ) + cDetailTexCoordTransform[0].w;
|
||||
o.envmapMaskTexCoord.y = dot( v.vDetailTexCoord, cDetailTexCoordTransform[1] ) + cDetailTexCoordTransform[1].w;
|
||||
o.lightmapTexCoord = v.vLightmapTexCoord;
|
||||
|
||||
#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
|
||||
o.fog = CalcFixedFunctionFog( o.worldPos_projPosZ.xyz, g_FogType );
|
||||
#endif
|
||||
|
||||
o.vertexColor = cModulationColor;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
@@ -629,7 +629,7 @@ float DoFlashlightShadow( sampler DepthSampler, sampler RandomRotationSampler, f
|
||||
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( 1.0 / 2048.0, 1.0 / 2048.0 ) );
|
||||
flShadow = DoShadowNvidiaPCF5x5Gaussian( DepthSampler, vProjCoords, float2( vShadowTweaks.x, vShadowTweaks.x ) );
|
||||
#else
|
||||
flShadow = DoShadowPoisson16Sample( DepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, vShadowTweaks, true, false );
|
||||
#endif
|
||||
|
||||
@@ -59,6 +59,7 @@ $Project
|
||||
|
||||
$File "unlittwotexture_dx9.cpp"
|
||||
$File "MonitorScreen_dx9.cpp"
|
||||
$File "shatteredglass.cpp"
|
||||
}
|
||||
|
||||
//$Shaders "mapbase_dx9_20b.txt"
|
||||
|
||||
@@ -96,7 +96,7 @@ struct LightmappedGeneric_DX9_Vars_t
|
||||
|
||||
#ifdef PARALLAX_CORRECTED_CUBEMAPS
|
||||
// Parallax cubemaps
|
||||
int m_nEnvmapParallax;
|
||||
int m_nEnvmapParallax; // Needed for editor
|
||||
int m_nEnvmapParallaxObb1;
|
||||
int m_nEnvmapParallaxObb2;
|
||||
int m_nEnvmapParallaxObb3;
|
||||
|
||||
349
sp/src/materialsystem/stdshaders/shatteredglass.cpp
Normal file
349
sp/src/materialsystem/stdshaders/shatteredglass.cpp
Normal file
@@ -0,0 +1,349 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Lightmap only shader
|
||||
//
|
||||
// $Header: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
|
||||
#include "SDK_ShatteredGlass_ps20.inc"
|
||||
#include "SDK_ShatteredGlass_ps20b.inc"
|
||||
#include "SDK_ShatteredGlass_vs20.inc"
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
BEGIN_VS_SHADER( SDK_ShatteredGlass,
|
||||
"Help for SDK_ShatteredGlass" )
|
||||
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM_OVERRIDE( BASETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "Glass/glasswindowbreak070b", "unused", SHADER_PARAM_NOT_EDITABLE )
|
||||
SHADER_PARAM( DETAIL, SHADER_PARAM_TYPE_TEXTURE, "Glass/glasswindowbreak070b", "detail" )
|
||||
SHADER_PARAM( DETAILSCALE, SHADER_PARAM_TYPE_FLOAT, "1.0", "detail scale" )
|
||||
SHADER_PARAM( ENVMAP, SHADER_PARAM_TYPE_TEXTURE, "shadertest/shadertest_env", "envmap" )
|
||||
SHADER_PARAM( ENVMAPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "" )
|
||||
SHADER_PARAM( ENVMAPMASK, SHADER_PARAM_TYPE_TEXTURE, "glass/glasswindowbreak070b_mask", "envmap mask" )
|
||||
SHADER_PARAM( ENVMAPMASKFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "" )
|
||||
SHADER_PARAM( ENVMAPMASKTRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$envmapmask texcoord transform" )
|
||||
SHADER_PARAM( ENVMAPTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "envmap tint" )
|
||||
SHADER_PARAM( ENVMAPCONTRAST, SHADER_PARAM_TYPE_FLOAT, "0.0", "contrast 0 == normal 1 == color*color" )
|
||||
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()
|
||||
{
|
||||
if( !params[DETAILSCALE]->IsDefined() )
|
||||
params[DETAILSCALE]->SetFloatValue( 1.0f );
|
||||
|
||||
if( !params[ENVMAPTINT]->IsDefined() )
|
||||
params[ENVMAPTINT]->SetVecValue( 1.0f, 1.0f, 1.0f );
|
||||
|
||||
if( !params[ENVMAPCONTRAST]->IsDefined() )
|
||||
params[ENVMAPCONTRAST]->SetFloatValue( 0.0f );
|
||||
|
||||
if( !params[ENVMAPSATURATION]->IsDefined() )
|
||||
params[ENVMAPSATURATION]->SetFloatValue( 1.0f );
|
||||
|
||||
if( !params[UNLITFACTOR]->IsDefined() )
|
||||
params[UNLITFACTOR]->SetFloatValue( 0.3f );
|
||||
|
||||
if( !params[FRESNELREFLECTION]->IsDefined() )
|
||||
params[FRESNELREFLECTION]->SetFloatValue( 1.0f );
|
||||
|
||||
if( !params[ENVMAPMASKFRAME]->IsDefined() )
|
||||
params[ENVMAPMASKFRAME]->SetIntValue( 0 );
|
||||
|
||||
if( !params[ENVMAPFRAME]->IsDefined() )
|
||||
params[ENVMAPFRAME]->SetIntValue( 0 );
|
||||
|
||||
// No texture means no self-illum or env mask in base alpha
|
||||
if ( !params[BASETEXTURE]->IsDefined() )
|
||||
{
|
||||
CLEAR_FLAGS( MATERIAL_VAR_BASEALPHAENVMAPMASK );
|
||||
}
|
||||
|
||||
// If in decal mode, no debug override...
|
||||
if (IS_FLAG_SET(MATERIAL_VAR_DECAL))
|
||||
{
|
||||
SET_FLAGS( MATERIAL_VAR_NO_DEBUG_OVERRIDE );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if (params[BASETEXTURE]->IsDefined())
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
|
||||
if ( !params[BASETEXTURE]->GetTextureValue()->IsTranslucent() )
|
||||
{
|
||||
if ( IS_FLAG_SET( MATERIAL_VAR_BASEALPHAENVMAPMASK ) )
|
||||
CLEAR_FLAGS( MATERIAL_VAR_BASEALPHAENVMAPMASK );
|
||||
}
|
||||
}
|
||||
|
||||
if ( params[DETAIL]->IsDefined() )
|
||||
{
|
||||
LoadTexture( DETAIL );
|
||||
}
|
||||
|
||||
// Don't alpha test if the alpha channel is used for other purposes
|
||||
if ( IS_FLAG_SET(MATERIAL_VAR_BASEALPHAENVMAPMASK) )
|
||||
CLEAR_FLAGS( MATERIAL_VAR_ALPHATEST );
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
bool bHasVertexColor = IS_FLAG_SET(MATERIAL_VAR_VERTEXCOLOR);
|
||||
bool bHasBaseAlphaEnvmapMask = IS_FLAG_SET(MATERIAL_VAR_BASEALPHAENVMAPMASK);
|
||||
|
||||
// Base
|
||||
SHADOW_STATE
|
||||
{
|
||||
// alpha test
|
||||
pShaderShadow->EnableAlphaTest( IS_FLAG_SET(MATERIAL_VAR_ALPHATEST) );
|
||||
|
||||
// Alpha blending, enable alpha blending if the detail texture is translucent
|
||||
bool detailIsTranslucent = TextureIsTranslucent( DETAIL, false );
|
||||
if ( detailIsTranslucent )
|
||||
{
|
||||
if ( IS_FLAG_SET( MATERIAL_VAR_ADDITIVE ) )
|
||||
EnableAlphaBlending( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE );
|
||||
else
|
||||
EnableAlphaBlending( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDefaultBlendingShadowState( BASETEXTURE, true );
|
||||
}
|
||||
|
||||
pShaderShadow->EnableSRGBWrite( true );
|
||||
|
||||
// Base texture
|
||||
unsigned int flags = VERTEX_POSITION;
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true );
|
||||
|
||||
// Lightmap
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
if( g_pHardwareConfig->GetHDRType() == HDR_TYPE_NONE )
|
||||
{
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, false );
|
||||
}
|
||||
|
||||
// Detail texture
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER3, true );
|
||||
|
||||
// Envmap
|
||||
if ( bHasEnvmap )
|
||||
{
|
||||
flags |= VERTEX_NORMAL;
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
|
||||
if( g_pHardwareConfig->GetHDRType() == HDR_TYPE_NONE )
|
||||
{
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER2, true );
|
||||
}
|
||||
|
||||
if( bHasEnvmapMask )
|
||||
{
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER5, true );
|
||||
}
|
||||
}
|
||||
|
||||
// Normalizing cube map
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER6, true );
|
||||
|
||||
if ( bHasVertexColor )
|
||||
{
|
||||
flags |= VERTEX_COLOR;
|
||||
}
|
||||
|
||||
pShaderShadow->VertexShaderVertexFormat( flags, 3, 0, 0 );
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( sdk_shatteredglass_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( ENVMAP_MASK, bHasEnvmapMask );
|
||||
SET_STATIC_VERTEX_SHADER( sdk_shatteredglass_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( sdk_shatteredglass_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( VERTEXCOLOR, bHasVertexColor );
|
||||
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( sdk_shatteredglass_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( sdk_shatteredglass_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( VERTEXCOLOR, bHasVertexColor );
|
||||
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( sdk_shatteredglass_ps20 );
|
||||
}
|
||||
|
||||
DefaultFog();
|
||||
}
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, BASETEXTURETRANSFORM );
|
||||
SetVertexShaderTextureScale( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, DETAILSCALE );
|
||||
|
||||
BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME );
|
||||
pShaderAPI->BindStandardTexture( SHADER_SAMPLER1, TEXTURE_LIGHTMAP );
|
||||
BindTexture( SHADER_SAMPLER3, DETAIL );
|
||||
|
||||
if( bHasEnvmap )
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER2, ENVMAP, ENVMAPFRAME );
|
||||
if( bHasEnvmapMask )
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER5, ENVMAPMASK, ENVMAPMASKFRAME );
|
||||
}
|
||||
}
|
||||
|
||||
pShaderAPI->BindStandardTexture( SHADER_SAMPLER6, TEXTURE_NORMALIZATION_CUBEMAP_SIGNED );
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( sdk_shatteredglass_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, ( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ) );
|
||||
SET_DYNAMIC_VERTEX_SHADER( sdk_shatteredglass_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( sdk_shatteredglass_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() );
|
||||
SET_DYNAMIC_PIXEL_SHADER( sdk_shatteredglass_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( sdk_shatteredglass_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() );
|
||||
SET_DYNAMIC_PIXEL_SHADER( sdk_shatteredglass_ps20 );
|
||||
}
|
||||
|
||||
SetEnvMapTintPixelShaderDynamicState( 0, ENVMAPTINT, -1 );
|
||||
SetModulationPixelShaderDynamicState( 1 );
|
||||
SetPixelShaderConstant( 2, ENVMAPCONTRAST );
|
||||
SetPixelShaderConstant( 3, ENVMAPSATURATION );
|
||||
|
||||
// [ 0, 0 ,0, R(0) ]
|
||||
float fresnel[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
fresnel[3] = params[FRESNELREFLECTION]->GetFloatValue();
|
||||
fresnel[0] = fresnel[1] = fresnel[2] = 1.0f - fresnel[3];
|
||||
pShaderAPI->SetPixelShaderConstant( 4, fresnel );
|
||||
|
||||
float eyePos[4];
|
||||
pShaderAPI->GetWorldSpaceCameraPosition( eyePos );
|
||||
pShaderAPI->SetPixelShaderConstant( 5, eyePos, 1 );
|
||||
|
||||
pShaderAPI->SetPixelShaderFogParams( 12 );
|
||||
|
||||
float overbright[4];
|
||||
overbright[0] = OVERBRIGHT;
|
||||
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<float*>(params[ENVMAPPARALLAXOBB1]->GetVecValue());
|
||||
vecs[1] = const_cast<float*>(params[ENVMAPPARALLAXOBB2]->GetVecValue());
|
||||
vecs[2] = const_cast<float*>(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();
|
||||
}
|
||||
END_SHADER
|
||||
@@ -90,4 +90,6 @@ SDK_decalmodulate_vs20.fxc
|
||||
|
||||
SDK_unlittwotexture_ps2x.fxc
|
||||
SDK_unlittwotexture_vs20.fxc
|
||||
SDK_monitorscreen_ps2x.fxc
|
||||
SDK_monitorscreen_ps2x.fxc
|
||||
SDK_ShatteredGlass_ps2x.fxc
|
||||
SDK_ShatteredGlass_vs20.fxc
|
||||
Reference in New Issue
Block a user