Added custom core ball shader

This commit is contained in:
Blixibon 2021-04-21 14:58:51 -05:00
parent f580801a33
commit 138a25c53c
11 changed files with 1613 additions and 0 deletions

View File

@ -5,6 +5,10 @@
//=============================================================================
#include "cbase.h"
#ifdef MAPBASE
#include "proxyentity.h"
#include "materialsystem/imaterialvar.h"
#endif
class C_PropScalable : public C_BaseAnimating
{
@ -194,3 +198,56 @@ void C_PropScalable::GetRenderBounds( Vector &theMins, Vector &theMaxs )
Assert( theMins.IsValid() && theMaxs.IsValid() );
}
#ifdef MAPBASE
ConVar r_coreball_update_sphere_center( "r_coreball_update_sphere_center", "1", FCVAR_NONE, "Allows prop_coreball to update its center to the entity's origin" );
class CCoreBallUpdateMaterialProxy : public CEntityMaterialProxy
{
public:
CCoreBallUpdateMaterialProxy()
{
m_pMaterial = NULL;
m_pSphereCenter = NULL;
}
virtual ~CCoreBallUpdateMaterialProxy()
{
}
virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues )
{
m_pMaterial = pMaterial;
bool found;
m_pSphereCenter = m_pMaterial->FindVar( "$spherecenter", &found );
if( !found )
{
m_pSphereCenter = NULL;
return false;
}
return true;
}
virtual void OnBind( C_BaseEntity *pC_BaseEntity )
{
if (r_coreball_update_sphere_center.GetBool())
{
const Vector &origin = pC_BaseEntity->GetAbsOrigin();
m_pSphereCenter->SetVecValue( origin.x, origin.y, origin.z );
}
else
{
// Just continuously bind the old hacked value (TODO: Optimize so it's not just assigning the same value constantly?)
m_pSphereCenter->SetVecValue( 2688.0, 12139.0, 5170.0 );
}
}
virtual IMaterial *GetMaterial()
{
return m_pMaterial;
}
protected:
IMaterial *m_pMaterial;
IMaterialVar *m_pSphereCenter;
};
EXPOSE_INTERFACE( CCoreBallUpdateMaterialProxy, IMaterialProxy, "CoreBallUpdate" IMATERIAL_PROXY_INTERFACE_VERSION );
#endif

View File

@ -0,0 +1,222 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
// STATIC: "CUBEMAP" "0..1"
// STATIC: "FLOWMAP" "0..1"
// STATIC: "CORECOLORTEXTURE" "0..1"
// STATIC: "REFRACT" "0..1"
// DYNAMIC: "PIXELFOGTYPE" "0..1"
// SKIP: ( $REFRACT || $CORECOLORTEXTURE ) && $CUBEMAP
#include "common_ps_fxc.h"
sampler RefractSampler : register( s2 );
sampler NormalSampler : register( s3 );
#if CUBEMAP
sampler EnvmapSampler : register( s4 );
#endif
#if FLOWMAP
sampler FlowmapSampler : register( s6 );
#endif
#if CORECOLORTEXTURE
sampler CoreColorSampler : register( s7 );
#endif
const HALF3 g_EnvmapTint : register( c0 );
const HALF3 g_RefractTint : register( c1 );
const HALF3 g_EnvmapContrast : register( c2 );
const HALF3 g_EnvmapSaturation : register( c3 );
const HALF2 g_RefractScale : register( c5 );
#if FLOWMAP
const float g_Time : register( c6 );
const float2 g_FlowScrollRate : register( c7 );
const float g_CoreColorTexCoordOffset : register( c9 );
#endif
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 )
{
// Solve using the ray equation + the sphere equation
// P = o + dt
// (x - xc)^2 + (y - yc)^2 + (z - zc)^2 = r^2
// (ox + dx * t - xc)^2 + (oy + dy * t - yc)^2 + (oz + dz * t - zc)^2 = r^2
// (ox - xc)^2 + 2 * (ox-xc) * dx * t + dx^2 * t^2 +
// (oy - yc)^2 + 2 * (oy-yc) * dy * t + dy^2 * t^2 +
// (oz - zc)^2 + 2 * (oz-zc) * dz * t + dz^2 * t^2 = r^2
// (dx^2 + dy^2 + dz^2) * t^2 + 2 * ((ox-xc)dx + (oy-yc)dy + (oz-zc)dz) t +
// (ox-xc)^2 + (oy-yc)^2 + (oz-zc)^2 - r^2 = 0
// or, t = (-b +/- sqrt( b^2 - 4ac)) / 2a
// a = DotProduct( vecRayDelta, vecRayDelta );
// b = 2 * DotProduct( vecRayOrigin - vecCenter, vecRayDelta )
// c = DotProduct(vecRayOrigin - vecCenter, vecRayOrigin - vecCenter) - flRadius * flRadius;
float3 vecSphereToRay;
vecSphereToRay = vecRayOrigin - vecSphereCenter;
float a = dot( vecRayDelta, vecRayDelta );
// This would occur in the case of a zero-length ray
// if ( a == 0.0f )
// {
// *pT1 = *pT2 = 0.0f;
// return vecSphereToRay.LengthSqr() <= flRadius * flRadius;
// }
float b = 2 * dot( vecSphereToRay, vecRayDelta );
float c = dot( vecSphereToRay, vecSphereToRay ) - flRadius * flRadius;
float flDiscrim = b * b - 4 * a * c;
// if ( flDiscrim < 0.0f )
// return 0.0f;
float hack = flDiscrim;
flDiscrim = sqrt( flDiscrim );
float oo2a = 0.5f / a;
//if( hack < 0.0f )
//{
// alpha = 0.0f;
// return 0.0f;
//}
//else
//{
// alpha = 1.0f;
// return abs( flDiscrim ) * 2 * oo2a;
//}
//replacing the if's above because if's in hlsl are bad.....
float fHackGreaterThanZero = step( 0.0f, hack );
alpha = fHackGreaterThanZero;
return (fHackGreaterThanZero * (abs( flDiscrim ) * 2 * oo2a));
// *pT1 = ( - b - flDiscrim ) * oo2a;
// *pT2 = ( - b + flDiscrim ) * oo2a;
// return true;
}
struct PS_INPUT
{
float2 vBumpTexCoord : TEXCOORD0; // dudvMapAndNormalMapTexCoord
HALF3 vWorldVertToEyeVector : TEXCOORD1;
HALF3x3 tangentSpaceTranspose : TEXCOORD2;
float3 vRefractXYW : TEXCOORD5;
float3 projNormal : TEXCOORD6;
float4 worldPos_projPosZ : TEXCOORD7;
};
float4 main( PS_INPUT i ) : COLOR
{
HALF3 result = 0.0f;
HALF blend = 1.0f;
#if FLOWMAP
// 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 ) );
float sphereAlpha;
float lengthThroughSphere = LengthThroughSphere( g_EyePos, normalize( i.worldPos_projPosZ.xyz - g_EyePos ),
g_SphereCenter, /*g_SphereRadius*/ hackRadius, sphereAlpha );
float normalizedLengthThroughSphere = lengthThroughSphere / g_SphereDiameter;
float3 hackWorldSpaceNormal = normalize( i.worldPos_projPosZ.xyz - g_SphereCenter );
float3 realFuckingNormal = abs( hackWorldSpaceNormal );
hackWorldSpaceNormal = 0.5f * ( hackWorldSpaceNormal + 1.0f );
// hackWorldSpaceNormal = abs( hackWorldSpaceNormal );
// return float4( hackWorldSpaceNormal.x, 0.0f, 0.0f, 1.0f );
i.vBumpTexCoord.xy = 0.0f;
i.vBumpTexCoord.xy = realFuckingNormal.z * tex2D( FlowmapSampler, hackWorldSpaceNormal.xy );
i.vBumpTexCoord.xy += realFuckingNormal.y * tex2D( FlowmapSampler, hackWorldSpaceNormal.xz );
i.vBumpTexCoord.xy += realFuckingNormal.x * tex2D( FlowmapSampler, hackWorldSpaceNormal.yz );
i.vBumpTexCoord.xy += g_Time * g_FlowScrollRate;
// return float4( i.vBumpTexCoord.xy, 0.0f, 0.0f );
#endif
// Load normal and expand range
HALF4 vNormalSample = tex2D( NormalSampler, i.vBumpTexCoord );
// return vNormalSample;
HALF3 tangentSpaceNormal = vNormalSample * 2.0 - 1.0;
HALF3 refractTintColor = g_RefractTint;
// Perform division by W only once
float ooW = 1.0f / i.vRefractXYW.z;
// Compute coordinates for sampling refraction
float2 vRefractTexCoordNoWarp = i.vRefractXYW.xy * ooW;
float2 vRefractTexCoord = tangentSpaceNormal.xy;
HALF scale = vNormalSample.a * g_RefractScale.x;
#if FLOWMAP
scale *= normalizedLengthThroughSphere;
#endif
vRefractTexCoord *= scale;
#if FLOWMAP
float2 hackOffset = vRefractTexCoord;
#endif
vRefractTexCoord += vRefractTexCoordNoWarp;
float3 colorWarp = tex2D( RefractSampler, vRefractTexCoord.xy );
float3 colorNoWarp = tex2D( RefractSampler, vRefractTexCoordNoWarp.xy );
colorWarp *= refractTintColor;
#if REFRACT
result = lerp( colorNoWarp, colorWarp, blend );
// return float4( 1.0f, 0.0f, 0.0f, 1.0f );
#endif
#if CUBEMAP
HALF specularFactor = vNormalSample.a;
HALF3 worldSpaceNormal = mul( i.tangentSpaceTranspose, tangentSpaceNormal );
HALF3 reflectVect = CalcReflectionVectorUnnormalized( worldSpaceNormal, i.vWorldVertToEyeVector );
HALF3 specularLighting = texCUBE( EnvmapSampler, reflectVect );
specularLighting *= specularFactor;
specularLighting *= g_EnvmapTint;
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 );
result += specularLighting;
#endif
#if CORECOLORTEXTURE && FLOWMAP
float4 coreColorTexel = tex2D( CoreColorSampler, hackOffset + float2( normalizedLengthThroughSphere, g_CoreColorTexCoordOffset ) );
HALF4 rgba = HALF4( lerp( result, coreColorTexel, coreColorTexel.a /*normalizedLengthThroughSphere*/ ), sphereAlpha );
#else
HALF4 rgba = HALF4( result, vNormalSample.a );
#endif
float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.z, i.worldPos_projPosZ.z, i.worldPos_projPosZ.w );
return FinalOutput( rgba, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_NONE );
}

View File

@ -0,0 +1,103 @@
// STATIC: "MODEL" "0..1"
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
// DYNAMIC: "SKINNING" "0..1"
#include "common_vs_fxc.h"
static const bool g_bSkinning = SKINNING ? true : false;
static const bool g_bModel = MODEL ? true : false;
const float4 cBumpTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_1 );
struct VS_INPUT
{
float4 vPos : POSITION;
float4 vBoneWeights : BLENDWEIGHT;
float4 vBoneIndices : BLENDINDICES;
float4 vNormal : NORMAL;
float4 vBaseTexCoord : TEXCOORD0;
#if !MODEL
float3 vTangentS : TANGENT;
float3 vTangentT : BINORMAL0;
#else
float4 vUserData : TANGENT;
#endif
};
struct VS_OUTPUT
{
float4 vProjPos_POSITION : POSITION;
float vFog : FOG;
float2 vBumpTexCoord : TEXCOORD0;
float3 vTangentEyeVect : TEXCOORD1;
float3x3 tangentSpaceTranspose : TEXCOORD2;
float3 vRefractXYW : TEXCOORD5;
float4 projNormal_screenCoordW : TEXCOORD6;
float4 worldPos_projPosZ : TEXCOORD7;
float4 fogFactorW : COLOR1;
};
VS_OUTPUT main( const VS_INPUT v )
{
VS_OUTPUT o = ( VS_OUTPUT )0;
float3 worldNormal, worldPos, worldTangentS, worldTangentT;
float3 vObjNormal;
#if MODEL
float4 vObjTangent;
DecompressVertex_NormalTangent( v.vNormal, v.vUserData, vObjNormal, vObjTangent );
SkinPositionNormalAndTangentSpace(
g_bSkinning,
v.vPos, vObjNormal, vObjTangent,
v.vBoneWeights, v.vBoneIndices,
worldPos, worldNormal, worldTangentS, worldTangentT );
#else
DecompressVertex_Normal( v.vNormal, vObjNormal );
worldPos = mul( v.vPos, cModel[0] );
worldTangentS = mul( v.vTangentS, ( const float3x3 )cModel[0] );
worldTangentT = mul( v.vTangentT, ( const float3x3 )cModel[0] );
worldNormal = mul( vObjNormal, ( float3x3 )cModel[0] );
#endif
// Projected position
float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
o.vProjPos_POSITION = vProjPos;
o.projNormal_screenCoordW.xyz = mul( worldNormal, cViewProj );
o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z );
// Map projected position to the refraction texture
float2 vRefractPos;
vRefractPos.x = vProjPos.x;
vRefractPos.y = -vProjPos.y; // invert Y
vRefractPos = (vRefractPos + vProjPos.w) * 0.5f;
// Refraction transform
o.vRefractXYW = float3(vRefractPos.x, vRefractPos.y, vProjPos.w);
// Compute fog based on the position
float3 vWorldPos = mul( v.vPos, cModel[0] );
o.fogFactorW = o.vFog = CalcFog( vWorldPos, vProjPos, FOGTYPE_RANGE );
// Eye vector
float3 vWorldEyeVect = cEyePos - vWorldPos;
// Transform to the tangent space
o.vTangentEyeVect.x = dot( vWorldEyeVect, worldTangentS );
o.vTangentEyeVect.y = dot( vWorldEyeVect, worldTangentT );
o.vTangentEyeVect.z = dot( vWorldEyeVect, worldNormal );
// Tranform bump coordinates
o.vBumpTexCoord.x = dot( v.vBaseTexCoord, cBumpTexCoordTransform[0] );
o.vBumpTexCoord.y = dot( v.vBaseTexCoord, cBumpTexCoordTransform[1] );
o.tangentSpaceTranspose[0] = worldTangentS;
o.tangentSpaceTranspose[1] = worldTangentT;
o.tangentSpaceTranspose[2] = worldNormal;
return o;
}

View File

@ -0,0 +1,307 @@
//========= Copyright © 1996-2006, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "BaseVSShader.h"
#include "SDK_core_vs20.inc"
#include "SDK_core_ps20.inc"
#include "SDK_core_ps20b.inc"
#define MAXBLUR 1
DEFINE_FALLBACK_SHADER( SDK_Core, SDK_Core_DX90 )
BEGIN_VS_SHADER( SDK_Core_DX90,
"Help for Core" )
BEGIN_SHADER_PARAMS
SHADER_PARAM_OVERRIDE( COLOR, SHADER_PARAM_TYPE_COLOR, "{255 255 255}", "unused", SHADER_PARAM_NOT_EDITABLE )
SHADER_PARAM_OVERRIDE( ALPHA, SHADER_PARAM_TYPE_FLOAT, "1.0", "unused", SHADER_PARAM_NOT_EDITABLE )
SHADER_PARAM( REFRACTAMOUNT, SHADER_PARAM_TYPE_FLOAT, "2", "" )
SHADER_PARAM( REFRACTTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "refraction tint" )
SHADER_PARAM( NORMALMAP, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader1_normal", "normal map" )
SHADER_PARAM( BUMPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $bumpmap" )
SHADER_PARAM( BUMPTRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$bumpmap texcoord transform" )
SHADER_PARAM( TIME, SHADER_PARAM_TYPE_FLOAT, "0.0f", "" )
SHADER_PARAM( ENVMAP, SHADER_PARAM_TYPE_TEXTURE, "shadertest/shadertest_env", "envmap" )
SHADER_PARAM( ENVMAPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "envmap frame number" )
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( FLOWMAP, SHADER_PARAM_TYPE_TEXTURE, "", "flowmap" )
SHADER_PARAM( FLOWMAPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $flowmap" )
SHADER_PARAM( FLOWMAPSCROLLRATE, SHADER_PARAM_TYPE_VEC2, "[0 0", "2D rate to scroll $flowmap" )
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()
{
SET_FLAGS2( MATERIAL_VAR2_NEEDS_TANGENT_SPACES );
SET_FLAGS( MATERIAL_VAR_TRANSLUCENT );
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[ENVMAPFRAME]->IsDefined() )
{
params[ENVMAPFRAME]->SetIntValue( 0 );
}
if( !params[BASETEXTURE]->IsDefined() )
{
SET_FLAGS2( MATERIAL_VAR2_NEEDS_POWER_OF_TWO_FRAME_BUFFER_TEXTURE );
}
}
SHADER_FALLBACK
{
if( g_pHardwareConfig->GetDXSupportLevel() < 90 )
return "Core_dx90";
return 0;
}
SHADER_INIT
{
if (params[BASETEXTURE]->IsDefined() )
{
LoadTexture( BASETEXTURE );
}
if (params[NORMALMAP]->IsDefined() )
{
LoadBumpMap( NORMALMAP );
}
if ( params[ENVMAP]->IsDefined() )
{
LoadCubeMap( ENVMAP );
}
if ( params[FLOWMAP]->IsDefined() )
{
LoadTexture( FLOWMAP );
}
if ( params[CORECOLORTEXTURE]->IsDefined() )
{
LoadTexture( CORECOLORTEXTURE );
}
}
inline void DrawPass( IMaterialVar **params, IShaderShadow* pShaderShadow,
IShaderDynamicAPI* pShaderAPI, int nPass, VertexCompressionType_t vertexCompression )
{
bool bIsModel = IS_FLAG_SET( MATERIAL_VAR_MODEL );
bool bHasEnvmap = params[ENVMAP]->IsTexture();
bool bHasFlowmap = params[FLOWMAP]->IsTexture();
bool bHasCoreColorTexture = params[CORECOLORTEXTURE]->IsTexture();
SHADOW_STATE
{
SetInitialShadowState( );
if( nPass == 0 )
{
// Alpha test: FIXME: shouldn't this be handled in Shader_t::SetInitialShadowState
pShaderShadow->EnableAlphaTest( IS_FLAG_SET(MATERIAL_VAR_ALPHATEST) );
}
else
{
pShaderShadow->DepthFunc( SHADER_DEPTHFUNC_EQUAL );
EnableAlphaBlending( SHADER_BLEND_ONE, SHADER_BLEND_ONE );
}
// If envmap is not specified, the alpha channel is the translucency
// (If envmap *is* specified, alpha channel is the reflection amount)
if ( params[NORMALMAP]->IsTexture() && !bHasEnvmap )
{
SetDefaultBlendingShadowState( NORMALMAP, false );
}
// source render target that contains the image that we are warping.
pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
if( g_pHardwareConfig->GetHDRType() == HDR_TYPE_INTEGER )
{
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER2, true );
}
// normal map
pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
if( bHasEnvmap )
{
// envmap
pShaderShadow->EnableTexture( SHADER_SAMPLER4, true );
if( g_pHardwareConfig->GetHDRType() == HDR_TYPE_INTEGER )
{
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER4, true );
}
}
if( bHasFlowmap )
{
pShaderShadow->EnableTexture( SHADER_SAMPLER6, true );
}
if( bHasCoreColorTexture )
{
pShaderShadow->EnableTexture( SHADER_SAMPLER7, true );
}
if( g_pHardwareConfig->GetHDRType() != HDR_TYPE_NONE )
{
pShaderShadow->EnableSRGBWrite( true );
}
unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL;
int userDataSize = 0;
int nTexCoordCount = 1;
if( bIsModel )
{
userDataSize = 4;
}
else
{
flags |= VERTEX_TANGENT_S | VERTEX_TANGENT_T;
}
// This shader supports compressed vertices, so OR in that flag:
flags |= VERTEX_FORMAT_COMPRESSED;
pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize );
DECLARE_STATIC_VERTEX_SHADER( sdk_core_vs20 );
SET_STATIC_VERTEX_SHADER_COMBO( MODEL, bIsModel );
SET_STATIC_VERTEX_SHADER( sdk_core_vs20 );
if ( g_pHardwareConfig->SupportsPixelShaders_2_b() )
{
DECLARE_STATIC_PIXEL_SHADER( sdk_core_ps20b );
SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap && ( nPass == 1 ) );
SET_STATIC_PIXEL_SHADER_COMBO( FLOWMAP, bHasFlowmap );
SET_STATIC_PIXEL_SHADER_COMBO( CORECOLORTEXTURE, bHasCoreColorTexture && ( nPass == 0 ) );
SET_STATIC_PIXEL_SHADER_COMBO( REFRACT, nPass == 0 );
SET_STATIC_PIXEL_SHADER( sdk_core_ps20b );
}
else
{
DECLARE_STATIC_PIXEL_SHADER( sdk_core_ps20 );
SET_STATIC_PIXEL_SHADER_COMBO( CUBEMAP, bHasEnvmap && ( nPass == 1 ) );
SET_STATIC_PIXEL_SHADER_COMBO( FLOWMAP, bHasFlowmap );
SET_STATIC_PIXEL_SHADER_COMBO( CORECOLORTEXTURE, bHasCoreColorTexture && ( nPass == 0 ) );
SET_STATIC_PIXEL_SHADER_COMBO( REFRACT, nPass == 0 );
SET_STATIC_PIXEL_SHADER( sdk_core_ps20 );
}
DefaultFog();
}
DYNAMIC_STATE
{
pShaderAPI->SetDefaultState();
if ( params[BASETEXTURE]->IsTexture() )
{
BindTexture( SHADER_SAMPLER2, BASETEXTURE, FRAME );
}
else
{
pShaderAPI->BindStandardTexture( SHADER_SAMPLER2, TEXTURE_FRAME_BUFFER_FULL_TEXTURE_0 );
}
BindTexture( SHADER_SAMPLER3, NORMALMAP, BUMPFRAME );
if( bHasEnvmap )
{
BindTexture( SHADER_SAMPLER4, ENVMAP, ENVMAPFRAME );
}
if( bHasFlowmap )
{
BindTexture( SHADER_SAMPLER6, FLOWMAP, FLOWMAPFRAME );
}
if( bHasCoreColorTexture )
{
BindTexture( SHADER_SAMPLER7, CORECOLORTEXTURE, CORECOLORTEXTUREFRAME );
}
DECLARE_DYNAMIC_VERTEX_SHADER( sdk_core_vs20 );
SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 );
SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
SET_DYNAMIC_VERTEX_SHADER( sdk_core_vs20 );
if ( g_pHardwareConfig->SupportsPixelShaders_2_b() )
{
DECLARE_DYNAMIC_PIXEL_SHADER( sdk_core_ps20b );
SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() );
SET_DYNAMIC_PIXEL_SHADER( sdk_core_ps20b );
}
else
{
DECLARE_DYNAMIC_PIXEL_SHADER( sdk_core_ps20 );
SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() );
SET_DYNAMIC_PIXEL_SHADER( sdk_core_ps20 );
}
SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, BUMPTRANSFORM );
if( g_pHardwareConfig->GetHDRType() == HDR_TYPE_NONE )
{
SetPixelShaderConstant( 0, ENVMAPTINT );
SetPixelShaderConstant( 1, REFRACTTINT );
}
else
{
SetPixelShaderConstantGammaToLinear( 0, ENVMAPTINT );
SetPixelShaderConstantGammaToLinear( 1, REFRACTTINT );
}
SetPixelShaderConstant( 2, ENVMAPCONTRAST );
SetPixelShaderConstant( 3, ENVMAPSATURATION );
float c5[4] = { params[REFRACTAMOUNT]->GetFloatValue(),
params[REFRACTAMOUNT]->GetFloatValue(), 0.0f, 0.0f };
pShaderAPI->SetPixelShaderConstant( 5, c5, 1 );
float eyePos[4];
s_pShaderAPI->GetWorldSpaceCameraPosition( eyePos );
s_pShaderAPI->SetPixelShaderConstant( 8, eyePos, 1 );
pShaderAPI->SetPixelShaderFogParams( 11 );
if( bHasFlowmap )
{
float curTime = pShaderAPI->CurrentTime();
float timeVec[4] = { curTime, curTime, curTime, curTime };
pShaderAPI->SetPixelShaderConstant( 6, timeVec, 1 );
SetPixelShaderConstant( 7, FLOWMAPSCROLLRATE );
SetPixelShaderConstant( 9, FLOWMAPTEXCOORDOFFSET );
}
#ifdef MAPBASE
SetPixelShaderConstant( 12, SPHERECENTER );
SetPixelShaderConstant( 15, SPHERERADIUS );
#endif
}
Draw();
}
SHADER_DRAW
{
DrawPass( params, pShaderShadow, pShaderAPI, 0, vertexCompression );
DrawPass( params, pShaderShadow, pShaderAPI, 1, vertexCompression );
}
END_SHADER

View File

@ -0,0 +1,162 @@
#include "shaderlib/cshader.h"
class sdk_core_ps20_Static_Index
{
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
}
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
}
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
}
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
}
void SetREFRACT( bool i )
{
m_nREFRACT = i ? 1 : 0;
#ifdef _DEBUG
m_bREFRACT = true;
#endif
}
public:
sdk_core_ps20_Static_Index( )
{
#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;
}
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_bCUBEMAP && m_bFLOWMAP && m_bCORECOLORTEXTURE && m_bREFRACT;
Assert( bAllStaticVarsDefined );
#endif // _DEBUG
return ( 2 * m_nCUBEMAP ) + ( 4 * m_nFLOWMAP ) + ( 8 * m_nCORECOLORTEXTURE ) + ( 16 * m_nREFRACT ) + 0;
}
};
#define shaderStaticTest_sdk_core_ps20 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
class sdk_core_ps20_Dynamic_Index
{
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:
sdk_core_ps20_Dynamic_Index()
{
#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_bPIXELFOGTYPE;
Assert( bAllDynamicVarsDefined );
#endif // _DEBUG
return ( 1 * m_nPIXELFOGTYPE ) + 0;
}
};
#define shaderDynamicTest_sdk_core_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0

View File

@ -0,0 +1,187 @@
#include "shaderlib/cshader.h"
class sdk_core_ps20b_Static_Index
{
private:
int m_nCONVERT_TO_SRGB;
#ifdef _DEBUG
bool m_bCONVERT_TO_SRGB;
#endif
public:
void SetCONVERT_TO_SRGB( int i )
{
Assert( i >= 0 && i <= 1 );
m_nCONVERT_TO_SRGB = i;
#ifdef _DEBUG
m_bCONVERT_TO_SRGB = true;
#endif
}
void SetCONVERT_TO_SRGB( bool i )
{
m_nCONVERT_TO_SRGB = i ? 1 : 0;
#ifdef _DEBUG
m_bCONVERT_TO_SRGB = true;
#endif
}
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
}
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
}
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
}
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
}
void SetREFRACT( bool i )
{
m_nREFRACT = i ? 1 : 0;
#ifdef _DEBUG
m_bREFRACT = true;
#endif
}
public:
sdk_core_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_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;
}
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_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;
}
};
#define shaderStaticTest_sdk_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
class sdk_core_ps20b_Dynamic_Index
{
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:
sdk_core_ps20b_Dynamic_Index()
{
#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_bPIXELFOGTYPE;
Assert( bAllDynamicVarsDefined );
#endif // _DEBUG
return ( 1 * m_nPIXELFOGTYPE ) + 0;
}
};
#define shaderDynamicTest_sdk_core_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0

View File

@ -0,0 +1,112 @@
#include "shaderlib/cshader.h"
class sdk_core_vs20_Static_Index
{
private:
int m_nMODEL;
#ifdef _DEBUG
bool m_bMODEL;
#endif
public:
void SetMODEL( int i )
{
Assert( i >= 0 && i <= 1 );
m_nMODEL = i;
#ifdef _DEBUG
m_bMODEL = true;
#endif
}
void SetMODEL( bool i )
{
m_nMODEL = i ? 1 : 0;
#ifdef _DEBUG
m_bMODEL = true;
#endif
}
public:
sdk_core_vs20_Static_Index( )
{
#ifdef _DEBUG
m_bMODEL = false;
#endif // _DEBUG
m_nMODEL = 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_bMODEL;
Assert( bAllStaticVarsDefined );
#endif // _DEBUG
return ( 4 * m_nMODEL ) + 0;
}
};
#define shaderStaticTest_sdk_core_vs20 vsh_forgot_to_set_static_MODEL + 0
class sdk_core_vs20_Dynamic_Index
{
private:
int m_nCOMPRESSED_VERTS;
#ifdef _DEBUG
bool m_bCOMPRESSED_VERTS;
#endif
public:
void SetCOMPRESSED_VERTS( int i )
{
Assert( i >= 0 && i <= 1 );
m_nCOMPRESSED_VERTS = i;
#ifdef _DEBUG
m_bCOMPRESSED_VERTS = true;
#endif
}
void SetCOMPRESSED_VERTS( bool i )
{
m_nCOMPRESSED_VERTS = i ? 1 : 0;
#ifdef _DEBUG
m_bCOMPRESSED_VERTS = true;
#endif
}
private:
int m_nSKINNING;
#ifdef _DEBUG
bool m_bSKINNING;
#endif
public:
void SetSKINNING( int i )
{
Assert( i >= 0 && i <= 1 );
m_nSKINNING = i;
#ifdef _DEBUG
m_bSKINNING = true;
#endif
}
void SetSKINNING( bool i )
{
m_nSKINNING = i ? 1 : 0;
#ifdef _DEBUG
m_bSKINNING = true;
#endif
}
public:
sdk_core_vs20_Dynamic_Index()
{
#ifdef _DEBUG
m_bCOMPRESSED_VERTS = false;
#endif // _DEBUG
m_nCOMPRESSED_VERTS = 0;
#ifdef _DEBUG
m_bSKINNING = false;
#endif // _DEBUG
m_nSKINNING = 0;
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING;
Assert( bAllDynamicVarsDefined );
#endif // _DEBUG
return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + 0;
}
};
#define shaderDynamicTest_sdk_core_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0

View File

@ -0,0 +1,162 @@
#include "shaderlib/cshader.h"
class sdk_core_ps20_Static_Index
{
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
}
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
}
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
}
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
}
void SetREFRACT( bool i )
{
m_nREFRACT = i ? 1 : 0;
#ifdef _DEBUG
m_bREFRACT = true;
#endif
}
public:
sdk_core_ps20_Static_Index( )
{
#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;
}
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_bCUBEMAP && m_bFLOWMAP && m_bCORECOLORTEXTURE && m_bREFRACT;
Assert( bAllStaticVarsDefined );
#endif // _DEBUG
return ( 2 * m_nCUBEMAP ) + ( 4 * m_nFLOWMAP ) + ( 8 * m_nCORECOLORTEXTURE ) + ( 16 * m_nREFRACT ) + 0;
}
};
#define shaderStaticTest_sdk_core_ps20 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
class sdk_core_ps20_Dynamic_Index
{
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:
sdk_core_ps20_Dynamic_Index()
{
#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_bPIXELFOGTYPE;
Assert( bAllDynamicVarsDefined );
#endif // _DEBUG
return ( 1 * m_nPIXELFOGTYPE ) + 0;
}
};
#define shaderDynamicTest_sdk_core_ps20 psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0

View File

@ -0,0 +1,187 @@
#include "shaderlib/cshader.h"
class sdk_core_ps20b_Static_Index
{
private:
int m_nCONVERT_TO_SRGB;
#ifdef _DEBUG
bool m_bCONVERT_TO_SRGB;
#endif
public:
void SetCONVERT_TO_SRGB( int i )
{
Assert( i >= 0 && i <= 1 );
m_nCONVERT_TO_SRGB = i;
#ifdef _DEBUG
m_bCONVERT_TO_SRGB = true;
#endif
}
void SetCONVERT_TO_SRGB( bool i )
{
m_nCONVERT_TO_SRGB = i ? 1 : 0;
#ifdef _DEBUG
m_bCONVERT_TO_SRGB = true;
#endif
}
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
}
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
}
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
}
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
}
void SetREFRACT( bool i )
{
m_nREFRACT = i ? 1 : 0;
#ifdef _DEBUG
m_bREFRACT = true;
#endif
}
public:
sdk_core_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_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;
}
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_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;
}
};
#define shaderStaticTest_sdk_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
class sdk_core_ps20b_Dynamic_Index
{
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:
sdk_core_ps20b_Dynamic_Index()
{
#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_bPIXELFOGTYPE;
Assert( bAllDynamicVarsDefined );
#endif // _DEBUG
return ( 1 * m_nPIXELFOGTYPE ) + 0;
}
};
#define shaderDynamicTest_sdk_core_ps20b psh_forgot_to_set_dynamic_PIXELFOGTYPE + 0

View File

@ -0,0 +1,112 @@
#include "shaderlib/cshader.h"
class sdk_core_vs20_Static_Index
{
private:
int m_nMODEL;
#ifdef _DEBUG
bool m_bMODEL;
#endif
public:
void SetMODEL( int i )
{
Assert( i >= 0 && i <= 1 );
m_nMODEL = i;
#ifdef _DEBUG
m_bMODEL = true;
#endif
}
void SetMODEL( bool i )
{
m_nMODEL = i ? 1 : 0;
#ifdef _DEBUG
m_bMODEL = true;
#endif
}
public:
sdk_core_vs20_Static_Index( )
{
#ifdef _DEBUG
m_bMODEL = false;
#endif // _DEBUG
m_nMODEL = 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_bMODEL;
Assert( bAllStaticVarsDefined );
#endif // _DEBUG
return ( 4 * m_nMODEL ) + 0;
}
};
#define shaderStaticTest_sdk_core_vs20 vsh_forgot_to_set_static_MODEL + 0
class sdk_core_vs20_Dynamic_Index
{
private:
int m_nCOMPRESSED_VERTS;
#ifdef _DEBUG
bool m_bCOMPRESSED_VERTS;
#endif
public:
void SetCOMPRESSED_VERTS( int i )
{
Assert( i >= 0 && i <= 1 );
m_nCOMPRESSED_VERTS = i;
#ifdef _DEBUG
m_bCOMPRESSED_VERTS = true;
#endif
}
void SetCOMPRESSED_VERTS( bool i )
{
m_nCOMPRESSED_VERTS = i ? 1 : 0;
#ifdef _DEBUG
m_bCOMPRESSED_VERTS = true;
#endif
}
private:
int m_nSKINNING;
#ifdef _DEBUG
bool m_bSKINNING;
#endif
public:
void SetSKINNING( int i )
{
Assert( i >= 0 && i <= 1 );
m_nSKINNING = i;
#ifdef _DEBUG
m_bSKINNING = true;
#endif
}
void SetSKINNING( bool i )
{
m_nSKINNING = i ? 1 : 0;
#ifdef _DEBUG
m_bSKINNING = true;
#endif
}
public:
sdk_core_vs20_Dynamic_Index()
{
#ifdef _DEBUG
m_bCOMPRESSED_VERTS = false;
#endif // _DEBUG
m_nCOMPRESSED_VERTS = 0;
#ifdef _DEBUG
m_bSKINNING = false;
#endif // _DEBUG
m_nSKINNING = 0;
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
bool bAllDynamicVarsDefined = m_bCOMPRESSED_VERTS && m_bSKINNING;
Assert( bAllDynamicVarsDefined );
#endif // _DEBUG
return ( 1 * m_nCOMPRESSED_VERTS ) + ( 2 * m_nSKINNING ) + 0;
}
};
#define shaderDynamicTest_sdk_core_vs20 vsh_forgot_to_set_dynamic_COMPRESSED_VERTS + vsh_forgot_to_set_dynamic_SKINNING + 0

View File

@ -64,6 +64,8 @@ $Project
$File "engine_post_dx9.cpp"
$File "depthoffield_dx9.cpp"
$File "core_dx9.cpp"
}
//$Shaders "mapbase_dx9_20b.txt"