initial
This commit is contained in:
103
materialsystem/stdshaders/AccumBuff4Sample.cpp
Normal file
103
materialsystem/stdshaders/AccumBuff4Sample.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
//========= Copyright (c) 1996-2005, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "common_hlsl_cpp_consts.h"
|
||||
#include "screenspaceeffect_vs20.inc"
|
||||
#include "accumbuff4sample_ps20.inc"
|
||||
#include "accumbuff4sample_ps20b.inc"
|
||||
#include "convar.h"
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( accumbuff4sample, "Help for AccumBuff4Sample", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
|
||||
// Four textures to sample
|
||||
SHADER_PARAM( TEXTURE0, SHADER_PARAM_TYPE_TEXTURE, "", "" )
|
||||
SHADER_PARAM( TEXTURE1, SHADER_PARAM_TYPE_TEXTURE, "", "" )
|
||||
SHADER_PARAM( TEXTURE2, SHADER_PARAM_TYPE_TEXTURE, "", "" )
|
||||
SHADER_PARAM( TEXTURE3, SHADER_PARAM_TYPE_TEXTURE, "", "" )
|
||||
|
||||
// Corresponding weights for the four input textures
|
||||
SHADER_PARAM( WEIGHTS, SHADER_PARAM_TYPE_VEC4, "", "Weight for Samples" )
|
||||
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
LoadTexture( TEXTURE0 );
|
||||
LoadTexture( TEXTURE1 );
|
||||
LoadTexture( TEXTURE2 );
|
||||
LoadTexture( TEXTURE3 );
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableDepthTest( false );
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
pShaderShadow->EnableBlending( false );
|
||||
pShaderShadow->EnableCulling( false );
|
||||
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
|
||||
int fmt = VERTEX_POSITION;
|
||||
pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( accumbuff4sample_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER( accumbuff4sample_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( accumbuff4sample_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER( accumbuff4sample_ps20 );
|
||||
}
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, TEXTURE0, -1 );
|
||||
BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, TEXTURE1, -1 );
|
||||
BindTexture( SHADER_SAMPLER2, TEXTURE_BINDFLAGS_NONE, TEXTURE2, -1 );
|
||||
BindTexture( SHADER_SAMPLER3, TEXTURE_BINDFLAGS_NONE, TEXTURE3, -1 );
|
||||
|
||||
SetPixelShaderConstant( 0, WEIGHTS );
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( accumbuff4sample_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( accumbuff4sample_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( accumbuff4sample_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( accumbuff4sample_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
27
materialsystem/stdshaders/AccumBuff4Sample_ps2x.fxc
Normal file
27
materialsystem/stdshaders/AccumBuff4Sample_ps2x.fxc
Normal file
@@ -0,0 +1,27 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler TexSampler0 : register( s0 );
|
||||
sampler TexSampler1 : register( s1 );
|
||||
sampler TexSampler2 : register( s2 );
|
||||
sampler TexSampler3 : register( s3 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
const float4 weights : register( c0 );
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
// Just sample the four input textures
|
||||
float4 sample0 = tex2D( TexSampler0, i.texCoord );
|
||||
float4 sample1 = tex2D( TexSampler1, i.texCoord );
|
||||
float4 sample2 = tex2D( TexSampler2, i.texCoord );
|
||||
float4 sample3 = tex2D( TexSampler3, i.texCoord );
|
||||
|
||||
// Compute weighted average and return
|
||||
return weights.x * sample0 + weights.y * sample1 + weights.z * sample2 + weights.w * sample3;
|
||||
}
|
||||
1204
materialsystem/stdshaders/BaseVSShader.cpp
Normal file
1204
materialsystem/stdshaders/BaseVSShader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
412
materialsystem/stdshaders/BaseVSShader.h
Normal file
412
materialsystem/stdshaders/BaseVSShader.h
Normal file
@@ -0,0 +1,412 @@
|
||||
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
// This is what all vs/ps (dx8+) shaders inherit from.
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef BASEVSSHADER_H
|
||||
#define BASEVSSHADER_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "cpp_shader_constant_register_map.h"
|
||||
#include "shaderlib/cshader.h"
|
||||
#include "shaderlib/BaseShader.h"
|
||||
#include "shaderapifast.h"
|
||||
#include "convar.h"
|
||||
#include <renderparm.h>
|
||||
|
||||
|
||||
// Texture combining modes for combining base and detail/basetexture2
|
||||
// Matches what's in common_ps_fxc.h
|
||||
#define DETAIL_BLEND_MODE_RGB_EQUALS_BASE_x_DETAILx2 0 // Original mode (Mod2x)
|
||||
#define DETAIL_BLEND_MODE_RGB_ADDITIVE 1 // Base.rgb+detail.rgb*fblend
|
||||
#define DETAIL_BLEND_MODE_DETAIL_OVER_BASE 2
|
||||
#define DETAIL_BLEND_MODE_FADE 3 // Straight fade between base and detail.
|
||||
#define DETAIL_BLEND_MODE_BASE_OVER_DETAIL 4 // Use base alpha for blend over detail
|
||||
#define DETAIL_BLEND_MODE_RGB_ADDITIVE_SELFILLUM 5 // Add detail color post lighting
|
||||
#define DETAIL_BLEND_MODE_RGB_ADDITIVE_SELFILLUM_THRESHOLD_FADE 6
|
||||
#define DETAIL_BLEND_MODE_MOD2X_SELECT_TWO_PATTERNS 7 // Use alpha channel of base to select between mod2x channels in r+a of detail
|
||||
#define DETAIL_BLEND_MODE_MULTIPLY 8
|
||||
#define DETAIL_BLEND_MODE_MASK_BASE_BY_DETAIL_ALPHA 9 // Use alpha channel of detail to mask base
|
||||
#define DETAIL_BLEND_MODE_SSBUMP_BUMP 10 // Use detail to modulate lighting as an ssbump
|
||||
#define DETAIL_BLEND_MODE_SSBUMP_NOBUMP 11 // Detail is an ssbump but use it as an albedo. shader does the magic here - no user needs to specify mode 11
|
||||
#define DETAIL_BLEND_MODE_NONE 12 // There is no detail texture
|
||||
|
||||
// Texture combining modes for combining base and decal texture
|
||||
#define DECAL_BLEND_MODE_DECAL_ALPHA 0 // Original mode ( = decalRGB*decalA + baseRGB*(1-decalA))
|
||||
#define DECAL_BLEND_MODE_RGB_MOD1X 1 // baseRGB * decalRGB
|
||||
#define DECAL_BLEND_MODE_NONE 2 // There is no decal texture
|
||||
|
||||
// We force aniso on certain textures for the consoles only
|
||||
#if defined( _GAMECONSOLE )
|
||||
#define ANISOTROPIC_OVERRIDE TEXTUREFLAGS_ANISOTROPIC
|
||||
#else
|
||||
#define ANISOTROPIC_OVERRIDE 0
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helper macro for vertex shaders
|
||||
//-----------------------------------------------------------------------------
|
||||
#define BEGIN_VS_SHADER_FLAGS(_name, _help, _flags) __BEGIN_SHADER_INTERNAL( CBaseVSShader, _name, _help, _flags )
|
||||
#define BEGIN_VS_SHADER(_name,_help) __BEGIN_SHADER_INTERNAL( CBaseVSShader, _name, _help, 0 )
|
||||
|
||||
|
||||
// useful parameter initialization macro
|
||||
#define INIT_FLOAT_PARM( parm, value ) \
|
||||
if ( !params[(parm)]->IsDefined() ) \
|
||||
{ \
|
||||
params[(parm)]->SetFloatValue( (value) ); \
|
||||
}
|
||||
|
||||
// useful pixel shader declaration macro for ps20/20b c++ code
|
||||
#define SET_STATIC_PS2X_PIXEL_SHADER_NO_COMBOS( basename ) \
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) \
|
||||
{ \
|
||||
DECLARE_STATIC_PIXEL_SHADER( basename##_ps20b ); \
|
||||
SET_STATIC_PIXEL_SHADER( basename##_ps20b ); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
DECLARE_STATIC_PIXEL_SHADER( basename##_ps20 ); \
|
||||
SET_STATIC_PIXEL_SHADER( basename##_ps20 ); \
|
||||
}
|
||||
|
||||
#define SET_DYNAMIC_PS2X_PIXEL_SHADER_NO_COMBOS( basename ) \
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) \
|
||||
{ \
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( basename##_ps20b ); \
|
||||
SET_DYNAMIC_PIXEL_SHADER( basename##_ps20b ); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( basename##_ps20 ); \
|
||||
SET_DYNAMIC_PIXEL_SHADER( basename##_ps20 ); \
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Base class for shaders, contains helper methods.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBaseVSShader : public CBaseShader
|
||||
{
|
||||
public:
|
||||
// Loads bump lightmap coordinates into the pixel shader
|
||||
void LoadBumpLightmapCoordinateAxes_PixelShader( int pixelReg );
|
||||
|
||||
// Loads bump lightmap coordinates into the vertex shader
|
||||
void LoadBumpLightmapCoordinateAxes_VertexShader( int vertexReg );
|
||||
|
||||
// Pixel and vertex shader constants....
|
||||
void SetPixelShaderConstant( int pixelReg, int constantVar );
|
||||
|
||||
// Pixel and vertex shader constants....
|
||||
void SetPixelShaderConstantGammaToLinear( int pixelReg, int constantVar );
|
||||
|
||||
// This version will put constantVar into x,y,z, and constantVar2 into the w
|
||||
void SetPixelShaderConstant( int pixelReg, int constantVar, int constantVar2 );
|
||||
void SetPixelShaderConstantGammaToLinear( int pixelReg, int constantVar, int constantVar2 );
|
||||
|
||||
// Helpers for setting constants that need to be converted to linear space (from gamma space).
|
||||
void SetVertexShaderConstantGammaToLinear( int var, float const* pVec, int numConst = 1, bool bForce = false );
|
||||
void SetPixelShaderConstantGammaToLinear( int var, float const* pVec, int numConst = 1, bool bForce = false );
|
||||
|
||||
void SetVertexShaderConstant( int vertexReg, int constantVar );
|
||||
|
||||
// set rgb components of constant from a color parm and give an explicit w value
|
||||
void SetPixelShaderConstant_W( int pixelReg, int constantVar, float fWValue );
|
||||
|
||||
// GR - fix for const/lerp issues
|
||||
void SetPixelShaderConstantFudge( int pixelReg, int constantVar );
|
||||
|
||||
// Sets vertex shader texture transforms
|
||||
void SetVertexShaderTextureTranslation( int vertexReg, int translationVar );
|
||||
void SetVertexShaderTextureScale( int vertexReg, int scaleVar );
|
||||
void SetVertexShaderTextureTransform( int vertexReg, int transformVar );
|
||||
void SetVertexShaderTextureScaledTransform( int vertexReg,
|
||||
int transformVar, int scaleVar );
|
||||
|
||||
// Set pixel shader texture transforms
|
||||
void SetPixelShaderTextureTranslation( int pixelReg, int translationVar );
|
||||
void SetPixelShaderTextureScale( int pixelReg, int scaleVar );
|
||||
void SetPixelShaderTextureTransform( int pixelReg, int transformVar );
|
||||
void SetPixelShaderTextureScaledTransform( int pixelReg,
|
||||
int transformVar, int scaleVar );
|
||||
|
||||
// Moves a matrix into vertex shader constants
|
||||
void SetVertexShaderMatrix3x4( int vertexReg, int matrixVar );
|
||||
void SetVertexShaderMatrix4x4( int vertexReg, int matrixVar );
|
||||
|
||||
// Loads the view matrix into vertex shader constants
|
||||
void LoadViewMatrixIntoVertexShaderConstant( int vertexReg );
|
||||
|
||||
// Loads the projection matrix into vertex shader constants
|
||||
void LoadProjectionMatrixIntoVertexShaderConstant( int vertexReg );
|
||||
|
||||
// Loads the model->view matrix into vertex shader constants
|
||||
void LoadModelViewMatrixIntoVertexShaderConstant( int vertexReg );
|
||||
|
||||
// Helpers for dealing with envmaptint
|
||||
void SetEnvMapTintPixelShaderDynamicState( int pixelReg, int tintVar, int alphaVar, bool bConvertFromGammaToLinear = false );
|
||||
|
||||
// Helper methods for pixel shader overbrighting
|
||||
void EnablePixelShaderOverbright( int reg, bool bEnable, bool bDivideByTwo );
|
||||
|
||||
// Sets up hw morphing state for the vertex shader
|
||||
void SetHWMorphVertexShaderState( int nDimConst, int nSubrectConst, VertexTextureSampler_t morphSampler );
|
||||
|
||||
BlendType_t EvaluateBlendRequirements( int textureVar, bool isBaseTexture, int detailTextureVar = -1 );
|
||||
|
||||
// Helper for setting up flashlight constants
|
||||
void SetFlashlightVertexShaderConstants( bool bBump, int bumpTransformVar, bool bDetail, int detailScaleVar, bool bSetTextureTransforms );
|
||||
|
||||
struct DrawFlashlight_dx90_Vars_t
|
||||
{
|
||||
DrawFlashlight_dx90_Vars_t()
|
||||
{
|
||||
// set all ints to -1
|
||||
memset( this, 0xFF, sizeof(DrawFlashlight_dx90_Vars_t) );
|
||||
// set all bools to a default value.
|
||||
m_bBump = false;
|
||||
m_bLightmappedGeneric = false;
|
||||
m_bWorldVertexTransition = false;
|
||||
m_bTeeth = false;
|
||||
m_bSSBump = false;
|
||||
m_fSeamlessScale = 0.0;
|
||||
}
|
||||
bool m_bBump;
|
||||
bool m_bLightmappedGeneric;
|
||||
bool m_bWorldVertexTransition;
|
||||
bool m_bTeeth;
|
||||
int m_nBumpmapVar;
|
||||
int m_nBumpmapFrame;
|
||||
int m_nBumpTransform;
|
||||
int m_nFlashlightTextureVar;
|
||||
int m_nFlashlightTextureFrameVar;
|
||||
int m_nBaseTexture2Var;
|
||||
int m_nBaseTexture2FrameVar;
|
||||
int m_nBumpmapVar2;
|
||||
int m_nBumpmapFrame2;
|
||||
int m_nBumpTransform2;
|
||||
int m_nDetailVar;
|
||||
int m_nDetailScale;
|
||||
int m_nDetailTextureCombineMode;
|
||||
int m_nDetailTextureBlendFactor;
|
||||
int m_nDetailTint;
|
||||
int m_nDetailVar2;
|
||||
int m_nDetailScale2;
|
||||
int m_nDetailTextureBlendFactor2;
|
||||
int m_nDetailTint2;
|
||||
int m_nTeethForwardVar;
|
||||
int m_nTeethIllumFactorVar;
|
||||
int m_nAlphaTestReference;
|
||||
bool m_bSSBump;
|
||||
float m_fSeamlessScale; // 0.0 = not seamless
|
||||
int m_nLayerTint1;
|
||||
int m_nLayerTint2;
|
||||
};
|
||||
void DrawFlashlight_dx90( IMaterialVar** params,
|
||||
IShaderDynamicAPI *pShaderAPI, IShaderShadow* pShaderShadow, DrawFlashlight_dx90_Vars_t &vars );
|
||||
|
||||
void HashShadow2DJitter( const float fJitterSeed, float *fU, float* fV );
|
||||
|
||||
//Alpha tested materials can end up leaving garbage in the dest alpha buffer if they write depth.
|
||||
//This pass fills in the areas that passed the alpha test with depth in dest alpha
|
||||
//by writing only equal depth pixels and only if we should be writing depth to dest alpha
|
||||
void DrawEqualDepthToDestAlpha( void );
|
||||
|
||||
private:
|
||||
// Converts a color + alpha into a vector4
|
||||
void ColorVarsToVector( int colorVar, int alphaVar, Vector4D &color );
|
||||
};
|
||||
|
||||
FORCEINLINE bool IsSRGBDetailTexture( int nMode )
|
||||
{
|
||||
return ( nMode == DETAIL_BLEND_MODE_DETAIL_OVER_BASE ) ||
|
||||
( nMode == DETAIL_BLEND_MODE_FADE ) ||
|
||||
( nMode == DETAIL_BLEND_MODE_BASE_OVER_DETAIL );
|
||||
}
|
||||
|
||||
FORCEINLINE bool IsSRGBDecalTexture( int nMode )
|
||||
{
|
||||
return (nMode == DECAL_BLEND_MODE_DECAL_ALPHA);
|
||||
}
|
||||
|
||||
FORCEINLINE char * GetFlashlightTextureFilename()
|
||||
{
|
||||
//if ( !IsX360() && ( g_pHardwareConfig->SupportsBorderColor() ) )
|
||||
//{
|
||||
// return "effects/flashlight001_border";
|
||||
//}
|
||||
//else
|
||||
{
|
||||
return "effects/flashlight001";
|
||||
}
|
||||
}
|
||||
|
||||
extern ConVar r_flashlightbrightness;
|
||||
|
||||
FORCEINLINE void SetFlashLightColorFromState( FlashlightState_t const &state, IShaderDynamicAPI *pShaderAPI, bool bSinglePassFlashlight, int nPSRegister=28, bool bFlashlightNoLambert=false )
|
||||
{
|
||||
// Old code
|
||||
//float flToneMapScale = ( ShaderApiFast( pShaderAPI )->GetToneMappingScaleLinear() ).x;
|
||||
//float flFlashlightScale = 1.0f / flToneMapScale;
|
||||
|
||||
// Fix to old code to keep flashlight from ever getting brighter than 1.0
|
||||
//float flToneMapScale = ( ShaderApiFast( pShaderAPI )->GetToneMappingScaleLinear() ).x;
|
||||
//if ( flToneMapScale < 1.0f )
|
||||
// flToneMapScale = 1.0f;
|
||||
//float flFlashlightScale = 1.0f / flToneMapScale;
|
||||
|
||||
float flFlashlightScale = r_flashlightbrightness.GetFloat();
|
||||
|
||||
if ( !g_pHardwareConfig->GetHDREnabled() )
|
||||
{
|
||||
// Non-HDR path requires 2.0 flashlight
|
||||
flFlashlightScale = 2.0f;
|
||||
}
|
||||
|
||||
// DX10 hardware and single pass flashlight require a hack scalar since the flashlight is added in linear space
|
||||
if ( ( g_pHardwareConfig->UsesSRGBCorrectBlending() ) || ( bSinglePassFlashlight ) )
|
||||
{
|
||||
flFlashlightScale *= 2.5f; // Magic number that works well on the 360 and NVIDIA 8800
|
||||
}
|
||||
|
||||
flFlashlightScale *= state.m_fBrightnessScale;
|
||||
|
||||
// Generate pixel shader constant
|
||||
float const *pFlashlightColor = state.m_Color;
|
||||
float vPsConst[4] = { flFlashlightScale * pFlashlightColor[0], flFlashlightScale * pFlashlightColor[1], flFlashlightScale * pFlashlightColor[2], pFlashlightColor[3] };
|
||||
vPsConst[3] = bFlashlightNoLambert ? 2.0f : 0.0f; // This will be added to N.L before saturate to force a 1.0 N.L term
|
||||
|
||||
// Red flashlight for testing
|
||||
//vPsConst[0] = 0.5f; vPsConst[1] = 0.0f; vPsConst[2] = 0.0f;
|
||||
|
||||
ShaderApiFast( pShaderAPI )->SetPixelShaderConstant( nPSRegister, ( float * )vPsConst );
|
||||
}
|
||||
|
||||
FORCEINLINE float ShadowAttenFromState( FlashlightState_t const &state )
|
||||
{
|
||||
// DX10 requires some hackery due to sRGB/blend ordering change from DX9, which makes the shadows too light
|
||||
if ( g_pHardwareConfig->UsesSRGBCorrectBlending() )
|
||||
return state.m_flShadowAtten * 0.1f; // magic number
|
||||
|
||||
return state.m_flShadowAtten;
|
||||
}
|
||||
|
||||
FORCEINLINE float ShadowFilterFromState( FlashlightState_t const &state )
|
||||
{
|
||||
// We developed shadow maps at 1024, so we expect the penumbra size to have been tuned relative to that
|
||||
return state.m_flShadowFilterSize / 1024.0f;
|
||||
}
|
||||
|
||||
|
||||
FORCEINLINE void SetupUberlightFromState( IShaderDynamicAPI *pShaderAPI, FlashlightState_t const &state )
|
||||
{
|
||||
// Bail if we can't do ps30 or we don't even want an uberlight
|
||||
if ( !g_pHardwareConfig->HasFastVertexTextures() || !state.m_bUberlight || !pShaderAPI )
|
||||
return;
|
||||
|
||||
UberlightState_t u = state.m_uberlightState;
|
||||
|
||||
// Set uberlight shader parameters as function of user controls from UberlightState_t
|
||||
Vector4D vSmoothEdge0 = Vector4D( 0.0f, u.m_fCutOn - u.m_fNearEdge, u.m_fCutOff, 0.0f );
|
||||
Vector4D vSmoothEdge1 = Vector4D( 0.0f, u.m_fCutOn, u.m_fCutOff + u.m_fFarEdge, 0.0f );
|
||||
Vector4D vSmoothOneOverW = Vector4D( 0.0f, 1.0f / u.m_fNearEdge, 1.0f / u.m_fFarEdge, 0.0f );
|
||||
Vector4D vShearRound = Vector4D( u.m_fShearx, u.m_fSheary, 2.0f / u.m_fRoundness, -u.m_fRoundness / 2.0f );
|
||||
Vector4D vaAbB = Vector4D( u.m_fWidth, u.m_fWidth + u.m_fWedge, u.m_fHeight, u.m_fHeight + u.m_fHedge );
|
||||
|
||||
ShaderApiFast( pShaderAPI )->SetPixelShaderConstant( PSREG_UBERLIGHT_SMOOTH_EDGE_0, vSmoothEdge0.Base(), 1 );
|
||||
ShaderApiFast( pShaderAPI )->SetPixelShaderConstant( PSREG_UBERLIGHT_SMOOTH_EDGE_1, vSmoothEdge1.Base(), 1 );
|
||||
ShaderApiFast( pShaderAPI )->SetPixelShaderConstant( PSREG_UBERLIGHT_SMOOTH_EDGE_OOW, vSmoothOneOverW.Base(), 1 );
|
||||
ShaderApiFast( pShaderAPI )->SetPixelShaderConstant( PSREG_UBERLIGHT_SHEAR_ROUND, vShearRound.Base(), 1 );
|
||||
ShaderApiFast( pShaderAPI )->SetPixelShaderConstant( PSREG_UBERLIGHT_AABB, vaAbB.Base(), 1 );
|
||||
|
||||
QAngle angles;
|
||||
QuaternionAngles( state.m_quatOrientation, angles );
|
||||
|
||||
// World to Light's View matrix
|
||||
matrix3x4_t viewMatrix, viewMatrixInverse;
|
||||
AngleMatrix( angles, state.m_vecLightOrigin, viewMatrixInverse );
|
||||
MatrixInvert( viewMatrixInverse, viewMatrix );
|
||||
ShaderApiFast( pShaderAPI )->SetPixelShaderConstant( PSREG_UBERLIGHT_WORLD_TO_LIGHT, viewMatrix.Base(), 4 );
|
||||
}
|
||||
|
||||
|
||||
// convenient material variable access functions for helpers to use.
|
||||
FORCEINLINE bool IsTextureSet( int nVar, IMaterialVar **params )
|
||||
{
|
||||
return ( nVar != -1 ) && ( params[nVar]->IsTexture() );
|
||||
}
|
||||
|
||||
FORCEINLINE bool IsBoolSet( int nVar, IMaterialVar **params )
|
||||
{
|
||||
return ( nVar != -1 ) && ( params[nVar]->GetIntValue() );
|
||||
}
|
||||
|
||||
FORCEINLINE int GetIntParam( int nVar, IMaterialVar **params, int nDefaultValue = 0 )
|
||||
{
|
||||
return ( nVar != -1 ) ? ( params[nVar]->GetIntValue() ) : nDefaultValue;
|
||||
}
|
||||
|
||||
FORCEINLINE float GetFloatParam( int nVar, IMaterialVar **params, float flDefaultValue = 0.0 )
|
||||
{
|
||||
return ( nVar != -1 ) ? ( params[nVar]->GetFloatValue() ) : flDefaultValue;
|
||||
}
|
||||
|
||||
FORCEINLINE void InitFloatParam( int nIndex, IMaterialVar **params, float flValue )
|
||||
{
|
||||
if ( (nIndex != -1) && !params[nIndex]->IsDefined() )
|
||||
{
|
||||
params[nIndex]->SetFloatValue( flValue );
|
||||
}
|
||||
}
|
||||
|
||||
FORCEINLINE void InitIntParam( int nIndex, IMaterialVar **params, int nValue )
|
||||
{
|
||||
if ( (nIndex != -1) && !params[nIndex]->IsDefined() )
|
||||
{
|
||||
params[nIndex]->SetIntValue( nValue );
|
||||
}
|
||||
}
|
||||
|
||||
FORCEINLINE void InitVecParam( int nIndex, IMaterialVar **params, float x, float y )
|
||||
{
|
||||
if ( (nIndex != -1) && !params[nIndex]->IsDefined() )
|
||||
{
|
||||
params[nIndex]->SetVecValue( x, y );
|
||||
}
|
||||
}
|
||||
|
||||
FORCEINLINE void InitVecParam( int nIndex, IMaterialVar **params, float x, float y, float z )
|
||||
{
|
||||
if ( (nIndex != -1) && !params[nIndex]->IsDefined() )
|
||||
{
|
||||
params[nIndex]->SetVecValue( x, y, z );
|
||||
}
|
||||
}
|
||||
|
||||
FORCEINLINE void InitVecParam( int nIndex, IMaterialVar **params, float x, float y, float z, float w )
|
||||
{
|
||||
if ( (nIndex != -1) && !params[nIndex]->IsDefined() )
|
||||
{
|
||||
params[nIndex]->SetVecValue( x, y, z, w );
|
||||
}
|
||||
}
|
||||
|
||||
// Did we launch with -tools
|
||||
bool ToolsEnabled();
|
||||
|
||||
class ConVar;
|
||||
|
||||
#ifdef _DEBUG
|
||||
extern ConVar mat_envmaptintoverride;
|
||||
extern ConVar mat_envmaptintscale;
|
||||
#endif
|
||||
|
||||
|
||||
#endif // BASEVSSHADER_H
|
||||
163
materialsystem/stdshaders/Blob_dx9.cpp
Normal file
163
materialsystem/stdshaders/Blob_dx9.cpp
Normal file
@@ -0,0 +1,163 @@
|
||||
//========= Copyright © 1996-2007, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Blob shader
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "Blob_helper.h"
|
||||
#include "cpp_shader_constant_register_map.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DEFINE_FALLBACK_SHADER( Blob, Blob_dx9 )
|
||||
|
||||
BEGIN_VS_SHADER( Blob_dx9, "Blob" )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( BACKSURFACE, SHADER_PARAM_TYPE_BOOL, "0.0", "specify that this is the back surface of the blob" )
|
||||
|
||||
SHADER_PARAM( NORMALMAP, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader1_normal", "normal map" )
|
||||
SHADER_PARAM( SPECMASKTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "specular reflection mask" )
|
||||
SHADER_PARAM( LIGHTWARPTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "1D ramp texture for tinting scalar diffuse term" )
|
||||
SHADER_PARAM( FRESNELWARPTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "1D ramp texture for controlling fresnel falloff" )
|
||||
SHADER_PARAM( OPACITYTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "1D ramp texture for controlling fresnel falloff" )
|
||||
|
||||
SHADER_PARAM( UVSCALE, SHADER_PARAM_TYPE_FLOAT, "0.02", "uv projection scale" )
|
||||
SHADER_PARAM( BUMPSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "1.0", "bump map strength" )
|
||||
SHADER_PARAM( FRESNELBUMPSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "1.0", "bump map strength for fresnel" )
|
||||
SHADER_PARAM( TRANSLUCENTFRESNELMINMAXEXP, SHADER_PARAM_TYPE_VEC3, "[0.8 1.0 1.0]", "fresnel params" )
|
||||
|
||||
SHADER_PARAM( INTERIOR, SHADER_PARAM_TYPE_BOOL, "1", "Enable interior layer" )
|
||||
SHADER_PARAM( INTERIORFOGSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0.06", "fog strength (scales with thickness of the interior volume)" )
|
||||
SHADER_PARAM( INTERIORFOGLIMIT, SHADER_PARAM_TYPE_FLOAT, "0.8", "fog opacity beyond the range of destination alpha depth (in low-precision depth mode)" )
|
||||
SHADER_PARAM( INTERIORFOGNORMALBOOST, SHADER_PARAM_TYPE_FLOAT, "0.0", "degree to boost interior thickness/fog by 'side-on'ness of vertex normals to the camera" )
|
||||
SHADER_PARAM( INTERIORBACKGROUNDBOOST, SHADER_PARAM_TYPE_FLOAT, "7", "boosts the brightness of bright background pixels" )
|
||||
SHADER_PARAM( INTERIORAMBIENTSCALE, SHADER_PARAM_TYPE_FLOAT, "0.3", "scales ambient light in the interior volume" );
|
||||
SHADER_PARAM( INTERIORBACKLIGHTSCALE, SHADER_PARAM_TYPE_FLOAT, "0.3", "scales backlighting in the interior volume" );
|
||||
SHADER_PARAM( INTERIORCOLOR, SHADER_PARAM_TYPE_VEC3, "[0.7 0.5 0.45]", "tints light in the interior volume" )
|
||||
SHADER_PARAM( INTERIORREFRACTSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0.015", "strength of bumped refract of the background seen through the interior" )
|
||||
SHADER_PARAM( INTERIORREFRACTBLUR, SHADER_PARAM_TYPE_FLOAT, "0.2", "strength of blur applied to the background seen through the interior" )
|
||||
|
||||
SHADER_PARAM( DIFFUSEBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "" )
|
||||
SHADER_PARAM( PHONGEXPONENT, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular exponent" )
|
||||
SHADER_PARAM( PHONGBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular boost" )
|
||||
SHADER_PARAM( PHONGEXPONENT2, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular exponent" )
|
||||
SHADER_PARAM( PHONGBOOST2, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular boost" )
|
||||
SHADER_PARAM( RIMLIGHTEXPONENT, SHADER_PARAM_TYPE_FLOAT, "1.0", "rim light exponent" )
|
||||
SHADER_PARAM( RIMLIGHTBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "rim light boost" )
|
||||
SHADER_PARAM( BASECOLORTINT, SHADER_PARAM_TYPE_VEC3, "[1.0 1.0 1.0]", "base texture tint" )
|
||||
|
||||
SHADER_PARAM( SELFILLUMFRESNEL, SHADER_PARAM_TYPE_BOOL, "0", "enable self illum fresnel term" )
|
||||
SHADER_PARAM( SELFILLUMFRESNELMINMAXEXP, SHADER_PARAM_TYPE_VEC3, "[0.7 0.5 0.45]", "min max exponent" )
|
||||
SHADER_PARAM( SELFILLUMTINT, SHADER_PARAM_TYPE_VEC3, "[0.7 0.5 0.45]", "selfillum color tint" )
|
||||
|
||||
SHADER_PARAM( UVPROJOFFSET, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "Center for UV projection" )
|
||||
SHADER_PARAM( BBMIN, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "" )
|
||||
SHADER_PARAM( BBMAX, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "" )
|
||||
|
||||
SHADER_PARAM( ARMATURE, SHADER_PARAM_TYPE_BOOL, "0", "armature" )
|
||||
SHADER_PARAM( ARMCOLOR, SHADER_PARAM_TYPE_VEC3, "[1 1 1]", "arm color" )
|
||||
SHADER_PARAM( ARMWIDEN, SHADER_PARAM_TYPE_BOOL, "0", "widen arms at end instead of taper" )
|
||||
SHADER_PARAM( ARMWIDTHEXP, SHADER_PARAM_TYPE_FLOAT, "1", "" )
|
||||
SHADER_PARAM( ARMWIDTHSCALE, SHADER_PARAM_TYPE_FLOAT, "1", "" )
|
||||
SHADER_PARAM( ARMWIDTHBIAS, SHADER_PARAM_TYPE_FLOAT, "0", "" )
|
||||
SHADER_PARAM( ANIMATEARMPULSES, SHADER_PARAM_TYPE_BOOL, "1", "" )
|
||||
|
||||
SHADER_PARAM( GLOWSCALE, SHADER_PARAM_TYPE_FLOAT, "4", "Scale value applied to self-illum vertex colours" )
|
||||
SHADER_PARAM( PULSE, SHADER_PARAM_TYPE_BOOL, "1", "" )
|
||||
SHADER_PARAM( CONTACTSHADOWS, SHADER_PARAM_TYPE_BOOL, "1", "" )
|
||||
|
||||
SHADER_PARAM( VOLUMETEXTURETEST, SHADER_PARAM_TYPE_BOOL, "0", "" )
|
||||
SHADER_PARAM( BUMPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "" )
|
||||
|
||||
END_SHADER_PARAMS
|
||||
|
||||
void SetupVarsBlob( BlobVars_t &info )
|
||||
{
|
||||
info.m_nBackSurface = BACKSURFACE;
|
||||
info.m_nBaseTexture = BASETEXTURE;
|
||||
info.m_nNormalMap = NORMALMAP;
|
||||
info.m_nSpecMap = SPECMASKTEXTURE;
|
||||
info.m_nLightWarpTexture = LIGHTWARPTEXTURE;
|
||||
info.m_nFresnelWarpTexture = FRESNELWARPTEXTURE;
|
||||
info.m_nOpacityTexture = OPACITYTEXTURE;
|
||||
info.m_nBumpStrength = BUMPSTRENGTH;
|
||||
info.m_nFresnelBumpStrength = FRESNELBUMPSTRENGTH;
|
||||
info.m_nUVScale = UVSCALE;
|
||||
|
||||
info.m_nInteriorEnable = INTERIOR;
|
||||
info.m_nInteriorFogStrength = INTERIORFOGSTRENGTH;
|
||||
info.m_nInteriorFogLimit = INTERIORFOGLIMIT;
|
||||
info.m_nInteriorFogNormalBoost = INTERIORFOGNORMALBOOST;
|
||||
info.m_nInteriorBackgroundBoost = INTERIORBACKGROUNDBOOST;
|
||||
info.m_nInteriorAmbientScale = INTERIORAMBIENTSCALE;
|
||||
info.m_nInteriorBackLightScale = INTERIORBACKLIGHTSCALE;
|
||||
info.m_nInteriorColor = INTERIORCOLOR;
|
||||
info.m_nInteriorRefractStrength = INTERIORREFRACTSTRENGTH;
|
||||
info.m_nInteriorRefractBlur = INTERIORREFRACTBLUR;
|
||||
|
||||
info.m_nFresnelParams = TRANSLUCENTFRESNELMINMAXEXP;
|
||||
info.m_nDiffuseScale = DIFFUSEBOOST;
|
||||
info.m_nSpecExp = PHONGEXPONENT;
|
||||
info.m_nSpecScale = PHONGBOOST;
|
||||
info.m_nSpecExp2 = PHONGEXPONENT2;
|
||||
info.m_nSpecScale2 = PHONGBOOST2;
|
||||
info.m_nRimLightExp = RIMLIGHTEXPONENT;
|
||||
info.m_nRimLightScale = RIMLIGHTBOOST;
|
||||
info.m_nBaseColorTint = BASECOLORTINT;
|
||||
info.m_nSelfIllumFresnelEnable = SELFILLUMFRESNEL;
|
||||
info.m_nSelfIllumFresnelParams = SELFILLUMFRESNELMINMAXEXP;
|
||||
info.m_nSelfIllumTint = SELFILLUMTINT;
|
||||
info.m_nUVProjOffset = UVPROJOFFSET;
|
||||
info.m_nBBMin = BBMIN;
|
||||
info.m_nBBMax = BBMAX;
|
||||
info.m_nArmature = ARMATURE;
|
||||
info.m_nFlashlightTexture = FLASHLIGHTTEXTURE;
|
||||
info.m_nFlashlightTextureFrame = FLASHLIGHTTEXTUREFRAME;
|
||||
info.m_nArmColorTint = ARMCOLOR;
|
||||
info.m_nArmWiden = ARMWIDEN;
|
||||
info.m_nArmWidthExp = ARMWIDTHEXP;
|
||||
info.m_nArmWidthScale = ARMWIDTHSCALE;
|
||||
info.m_nArmWidthBias = ARMWIDTHBIAS;
|
||||
info.m_nAnimateArmPulses = ANIMATEARMPULSES;
|
||||
info.m_nVolumeTex = VOLUMETEXTURETEST;
|
||||
info.m_nBumpFrame = BUMPFRAME;
|
||||
info.m_nGlowScale = GLOWSCALE;
|
||||
info.m_nPulse = PULSE;
|
||||
info.m_nContactShadows = CONTACTSHADOWS;
|
||||
}
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
BlobVars_t info;
|
||||
SetupVarsBlob( info );
|
||||
InitParamsBlob( this, params, pMaterialName, info );
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
// TODO: Reasonable fallback
|
||||
if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
|
||||
{
|
||||
return "Wireframe";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
BlobVars_t info;
|
||||
SetupVarsBlob( info );
|
||||
InitBlob( this, params, info );
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
BlobVars_t info;
|
||||
SetupVarsBlob( info );
|
||||
DrawBlob( this, params, pShaderAPI, pShaderShadow, info, vertexCompression );
|
||||
}
|
||||
|
||||
END_SHADER
|
||||
648
materialsystem/stdshaders/Blob_helper.cpp
Normal file
648
materialsystem/stdshaders/Blob_helper.cpp
Normal file
@@ -0,0 +1,648 @@
|
||||
//========= Copyright © 1996-2007, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "Blob_helper.h"
|
||||
#include "cpp_shader_constant_register_map.h"
|
||||
/*
|
||||
#include "mathlib/VMatrix.h"
|
||||
#include "convar.h"
|
||||
*/
|
||||
|
||||
// Auto generated inc files
|
||||
#include "blob_vs30.inc"
|
||||
#include "blob_ps30.inc"
|
||||
#include "blob_arm_vs20.inc"
|
||||
#include "blob_arm_ps20b.inc"
|
||||
|
||||
|
||||
void InitParamsBlob( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, BlobVars_t &info )
|
||||
{
|
||||
// Set material parameter default values
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nBackSurface, kDefaultBackSurface );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nUVScale, kDefaultUVScale );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nBumpStrength, kDefaultBumpStrength );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nFresnelBumpStrength, kDefaultFresnelBumpStrength );
|
||||
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nInteriorEnable, kDefaultInteriorEnable );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorFogStrength, kDefaultInteriorFogStrength );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorFogLimit, kDefaultInteriorFogLimit );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorFogNormalBoost, kDefaultInteriorFogNormalBoost );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorBackgroundBoost, kDefaultInteriorBackgroundBoost );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorAmbientScale, kDefaultInteriorAmbientScale );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorBackLightScale, kDefaultInteriorBackLightScale );
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nInteriorColor, kDefaultInteriorColor, 3 );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorRefractStrength, kDefaultInteriorRefractStrength );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorRefractBlur, kDefaultInteriorRefractBlur );
|
||||
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nFresnelParams, kDefaultFresnelParams, 3 );
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nBaseColorTint, kDefaultBaseColorTint, 3 );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nDiffuseScale, kDefaultDiffuseScale );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nSpecExp, kDefaultSpecExp );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nSpecScale, kDefaultSpecScale );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nSpecExp2, kDefaultSpecExp );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nSpecScale2, kDefaultSpecScale );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nRimLightExp, kDefaultRimLightExp );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nRimLightScale, kDefaultRimLightScale );
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nSelfIllumFresnelEnable, kDefaultSelfIllumFresnelEnable );
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nSelfIllumFresnelParams, kDefaultSelfIllumFresnelParams, 3 );
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nSelfIllumTint, kDefaultSelfIllumTint, 3 );
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nUVProjOffset, kDefaultUVProjOffset, 3 );
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nBBMin, kDefaultBB, 3 );
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nBBMax, kDefaultBB, 3 );
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nArmature, kDefaultArmature );
|
||||
|
||||
// FLASHLIGHTFIXME: Do ShaderAPI::BindFlashlightTexture
|
||||
Assert( info.m_nFlashlightTexture >= 0 );
|
||||
if ( g_pHardwareConfig->SupportsBorderColor() )
|
||||
{
|
||||
params[info.m_nFlashlightTexture]->SetStringValue( "effects/flashlight_border" );
|
||||
}
|
||||
else
|
||||
{
|
||||
params[info.m_nFlashlightTexture]->SetStringValue( "effects/flashlight001" );
|
||||
}
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nFlashlightTextureFrame, 0 );
|
||||
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nArmColorTint, kDefaultArmColorTint, 3 );
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nArmWiden, kDefaultArmWiden );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nArmWidthExp, kDefaultArmWidthExp );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nArmWidthScale, kDefaultArmWidthScale );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nArmWidthBias, kDefaultArmWidthBias );
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nAnimateArmPulses, kDefaultAnimateArmPulses );
|
||||
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nVolumeTex, kDefaultVolumeTex );
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nBumpFrame, kDefaultBumpFrame )
|
||||
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nGlowScale, kDefaultGlowScale );
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nPulse, kDefaultPulse );
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nContactShadows, kDefaultContactShadows );
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nPulse ) && params[info.m_nPulse]->GetIntValue() &&
|
||||
IS_PARAM_DEFINED( info.m_nContactShadows ) && params[info.m_nContactShadows]->GetIntValue() )
|
||||
{
|
||||
Warning( "ERROR: material (%s) has invalid settings - contactShadows and pulse cannot both be set to 1\n", pMaterialName );
|
||||
params[info.m_nContactShadows]->SetIntValue( 0 );
|
||||
}
|
||||
|
||||
// Set material flags
|
||||
SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING );
|
||||
SET_FLAGS2( MATERIAL_VAR2_LIGHTING_VERTEX_LIT );
|
||||
|
||||
//SET_FLAGS2( MATERIAL_VAR2_NEEDS_TANGENT_SPACES );
|
||||
//SET_FLAGS( MATERIAL_VAR_TRANSLUCENT );
|
||||
|
||||
// This flag is turned off even though the shader needs the full framebuffer texture.
|
||||
// The blob client code kicks off updating the framebuffer texture explicitly once it's done with drawing the innards.
|
||||
|
||||
if ( params[info.m_nInteriorEnable]->IsDefined() && params[info.m_nInteriorEnable]->GetIntValue() != 0 )
|
||||
{
|
||||
SET_FLAGS2( MATERIAL_VAR2_NEEDS_FULL_FRAME_BUFFER_TEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
void InitBlob( CBaseVSShader *pShader, IMaterialVar** params, BlobVars_t &info )
|
||||
{
|
||||
// Load textures
|
||||
if ( (info.m_nBaseTexture != -1) && params[info.m_nBaseTexture]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nBaseTexture, TEXTUREFLAGS_SRGB );
|
||||
}
|
||||
|
||||
if ( (info.m_nNormalMap != -1) && params[info.m_nNormalMap]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nNormalMap );
|
||||
}
|
||||
|
||||
if ( (info.m_nSpecMap != -1) && params[info.m_nSpecMap]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nSpecMap );
|
||||
}
|
||||
|
||||
if ( (info.m_nLightWarpTexture != -1) && params[info.m_nLightWarpTexture]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nLightWarpTexture, TEXTUREFLAGS_SRGB );
|
||||
}
|
||||
|
||||
if ( (info.m_nFresnelWarpTexture != -1) && params[info.m_nFresnelWarpTexture]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nFresnelWarpTexture );
|
||||
}
|
||||
|
||||
if ( (info.m_nOpacityTexture != -1) && params[info.m_nOpacityTexture]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nOpacityTexture );
|
||||
}
|
||||
|
||||
if ( (info.m_nFlashlightTexture != -1) && params[info.m_nFlashlightTexture]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nFlashlightTexture, TEXTUREFLAGS_SRGB );
|
||||
}
|
||||
}
|
||||
|
||||
void DrawBlob( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI,
|
||||
IShaderShadow* pShaderShadow, BlobVars_t &info, VertexCompressionType_t vertexCompression )
|
||||
{
|
||||
if ( (info.m_nArmature != -1) && ( params[info.m_nArmature]->GetIntValue() > 0 ) )
|
||||
{
|
||||
DrawArmature( pShader, params, pShaderAPI, pShaderShadow, info, vertexCompression, 0 );
|
||||
DrawArmature( pShader, params, pShaderAPI, pShaderShadow, info, vertexCompression, 1 );
|
||||
return;
|
||||
}
|
||||
|
||||
bool bHasFlashlight = pShader->UsingFlashlight( params );
|
||||
bool bBackSurface = (info.m_nBackSurface != -1) && ( params[info.m_nBackSurface]->GetIntValue() > 0 );
|
||||
bool bLightWarp = (info.m_nLightWarpTexture != -1) && params[info.m_nLightWarpTexture]->IsDefined();
|
||||
bool bFresnelWarp = (info.m_nFresnelWarpTexture != -1) && params[info.m_nFresnelWarpTexture]->IsDefined();
|
||||
bool bOpacityTexture = (info.m_nOpacityTexture != -1) && params[info.m_nOpacityTexture]->IsDefined();
|
||||
bool bInteriorLayer = (info.m_nInteriorEnable != -1) && ( params[info.m_nInteriorEnable]->GetIntValue() > 0 );
|
||||
bool bSelfIllumFresnel = (info.m_nSelfIllumFresnelEnable != -1) && ( params[info.m_nSelfIllumFresnelEnable]->GetIntValue() > 0 );
|
||||
bool bVolumeTex = (info.m_nVolumeTex != -1) && ( params[info.m_nVolumeTex]->GetIntValue() > 0 );
|
||||
bool bContactShadows = (info.m_nContactShadows != -1) && ( params[info.m_nContactShadows]->GetIntValue() > 0 );
|
||||
bool bPulse = (info.m_nPulse != -1) && ( params[info.m_nPulse]->GetIntValue() > 0 );
|
||||
|
||||
SHADOW_STATE
|
||||
{
|
||||
// Set stream format (note that this shader supports compression)
|
||||
unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL;
|
||||
int nTexCoordCount = 1;
|
||||
int userDataSize = 0;
|
||||
int texCoordDims[4] = { 4, 4, 4, 4 };
|
||||
pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, texCoordDims, userDataSize );
|
||||
|
||||
ShadowFilterMode_t nShadowFilterMode = SHADOWFILTERMODE_DEFAULT;
|
||||
if ( bHasFlashlight )
|
||||
{
|
||||
nShadowFilterMode = g_pHardwareConfig->GetShadowFilterMode( false /* bForceLowQuality */, true /* bPS30 */ ); // Based upon vendor and device dependent formats
|
||||
}
|
||||
|
||||
// Vertex Shader
|
||||
DECLARE_STATIC_VERTEX_SHADER( blob_vs30 );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( CONTACT_SHADOW, bContactShadows ); // only do contact shadows on outer shell (which has interior layer enabled)
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( VOLUME_TEXTURE, bVolumeTex );
|
||||
SET_STATIC_VERTEX_SHADER( blob_vs30 );
|
||||
|
||||
// Pixel Shader
|
||||
if( /* g_pHardwareConfig->SupportsPixelShaders_3_0() */ true )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( blob_ps30 );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( BACK_SURFACE, bBackSurface );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( LIGHT_WARP, bLightWarp );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( FRESNEL_WARP, bFresnelWarp );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( OPACITY_TEXTURE, bOpacityTexture );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( INTERIOR_LAYER, bInteriorLayer );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( HIGH_PRECISION_DEPTH, (g_pHardwareConfig->GetHDRType() == HDR_TYPE_FLOAT) ? true : false );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( SELF_ILLUM_FRESNEL, bSelfIllumFresnel );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( CONTACT_SHADOW, bContactShadows ); // only do contact shadows on outer shell (which has interior layer enabled)
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( SELF_ILLUM_PULSE, bPulse );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( VOLUME_TEXTURE, bVolumeTex );
|
||||
SET_STATIC_PIXEL_SHADER( blob_ps30 );
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( !"No ps_3_0" );
|
||||
}
|
||||
|
||||
// Textures
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); //[sRGB] Base
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true ); // Bump
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, false );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER2, true ); //[sRGB] Backbuffer
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER2, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER3, true ); // Spec mask
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER3, false );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER4, true ); //[sRGB] Light warp
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER4, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER5, true ); // Fresnel warp // TODO: Could be in alpha of lightwarp
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER5, false );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER6, true ); // Opacity
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER6, false );
|
||||
|
||||
if( bHasFlashlight )
|
||||
{
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER7, true ); // Shadow depth map
|
||||
//pShaderShadow->SetShadowDepthFiltering( SHADER_SAMPLER7 );
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER7, false );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER8, true ); // Noise map
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER8, false );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER9, true ); //[sRGB] Flashlight cookie
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER9, true );
|
||||
}
|
||||
|
||||
pShaderShadow->EnableSRGBWrite( true );
|
||||
|
||||
/*
|
||||
// Blending
|
||||
pShader->EnableAlphaBlending( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
|
||||
pShaderShadow->EnableAlphaWrites( false );
|
||||
*/
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
|
||||
// Per-instance state
|
||||
pShader->PI_BeginCommandBuffer();
|
||||
pShader->PI_SetVertexShaderAmbientLightCube();
|
||||
pShader->PI_SetPixelShaderAmbientLightCube( PSREG_AMBIENT_CUBE );
|
||||
pShader->PI_SetPixelShaderLocalLighting( PSREG_LIGHT_INFO_ARRAY );
|
||||
pShader->PI_EndCommandBuffer();
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
///////////////////////
|
||||
// VERTEX SHADER SETUP
|
||||
///////////////////////
|
||||
|
||||
// Set Vertex Shader Combos
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( blob_vs30 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
|
||||
SET_DYNAMIC_VERTEX_SHADER( blob_vs30 );
|
||||
|
||||
LightState_t lightState = { 0, false, false };
|
||||
pShaderAPI->GetDX9LightState( &lightState );
|
||||
|
||||
// VS constants
|
||||
float flConsts[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
flConsts[0] = IS_PARAM_DEFINED( info.m_nUVScale ) ? params[info.m_nUVScale]->GetFloatValue() : kDefaultUVScale;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, flConsts );
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nUVProjOffset ) )
|
||||
params[info.m_nUVProjOffset]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultUVProjOffset, sizeof( kDefaultUVProjOffset ) );
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, flConsts );
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nBBMin ) )
|
||||
params[info.m_nBBMin]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultBB, sizeof( kDefaultBB ) );
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, flConsts );
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nBBMax ) )
|
||||
params[info.m_nBBMax]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultBB, sizeof( kDefaultBB ) );
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_3, flConsts );
|
||||
|
||||
//////////////////////
|
||||
// PIXEL SHADER SETUP
|
||||
//////////////////////
|
||||
|
||||
// Bind textures
|
||||
pShader->BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_SRGBREAD, BASETEXTURE );
|
||||
pShader->BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, info.m_nNormalMap, info.m_nBumpFrame );
|
||||
pShaderAPI->BindStandardTexture( SHADER_SAMPLER2, TEXTURE_BINDFLAGS_SRGBREAD, TEXTURE_FRAME_BUFFER_FULL_TEXTURE_0 ); // Refraction Map
|
||||
|
||||
if ( (info.m_nSpecMap != -1) && params[info.m_nSpecMap]->IsDefined() )
|
||||
{
|
||||
pShader->BindTexture( SHADER_SAMPLER3, TEXTURE_BINDFLAGS_NONE, info.m_nSpecMap );
|
||||
}
|
||||
else
|
||||
{
|
||||
pShaderAPI->BindStandardTexture( SHADER_SAMPLER3, TEXTURE_BINDFLAGS_NONE, TEXTURE_WHITE );
|
||||
}
|
||||
|
||||
if ( bLightWarp )
|
||||
{
|
||||
pShader->BindTexture( SHADER_SAMPLER4, TEXTURE_BINDFLAGS_SRGBREAD, info.m_nLightWarpTexture );
|
||||
}
|
||||
|
||||
if ( bFresnelWarp )
|
||||
{
|
||||
pShader->BindTexture( SHADER_SAMPLER5, TEXTURE_BINDFLAGS_NONE, info.m_nFresnelWarpTexture );
|
||||
}
|
||||
|
||||
if ( bOpacityTexture )
|
||||
{
|
||||
pShader->BindTexture( SHADER_SAMPLER6, TEXTURE_BINDFLAGS_NONE, info.m_nOpacityTexture );
|
||||
}
|
||||
|
||||
// flashlightfixme: put this in common code.
|
||||
bool bFlashlightShadows = false;
|
||||
if( bHasFlashlight )
|
||||
{
|
||||
Assert( info.m_nFlashlightTexture >= 0 && info.m_nFlashlightTextureFrame >= 0 );
|
||||
pShader->BindTexture( SHADER_SAMPLER9, TEXTURE_BINDFLAGS_SRGBREAD, info.m_nFlashlightTexture, info.m_nFlashlightTextureFrame );
|
||||
VMatrix worldToTexture;
|
||||
ITexture *pFlashlightDepthTexture;
|
||||
FlashlightState_t state = pShaderAPI->GetFlashlightStateEx( worldToTexture, &pFlashlightDepthTexture );
|
||||
bFlashlightShadows = state.m_bEnableShadows;
|
||||
|
||||
SetFlashLightColorFromState( state, pShaderAPI, PSREG_FLASHLIGHT_COLOR );
|
||||
|
||||
if( pFlashlightDepthTexture && g_pConfig->ShadowDepthTexture() && state.m_bEnableShadows )
|
||||
{
|
||||
pShader->BindTexture( SHADER_SAMPLER7, TEXTURE_BINDFLAGS_SHADOWDEPTH, pFlashlightDepthTexture );
|
||||
pShaderAPI->BindStandardTexture( SHADER_SAMPLER8, TEXTURE_BINDFLAGS_NONE, TEXTURE_SHADOW_NOISE_2D );
|
||||
}
|
||||
|
||||
float atten[4], pos[4], tweaks[4];
|
||||
|
||||
atten[0] = state.m_fConstantAtten; // Set the flashlight attenuation factors
|
||||
atten[1] = state.m_fLinearAtten;
|
||||
atten[2] = state.m_fQuadraticAtten;
|
||||
atten[3] = state.m_FarZAtten;
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_FLASHLIGHT_ATTENUATION, atten, 1 );
|
||||
|
||||
pos[0] = state.m_vecLightOrigin[0]; // Set the flashlight origin
|
||||
pos[1] = state.m_vecLightOrigin[1];
|
||||
pos[2] = state.m_vecLightOrigin[2];
|
||||
pos[3] = state.m_FarZ;
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_FLASHLIGHT_POSITION_RIM_BOOST, pos, 1 ); // steps on rim boost
|
||||
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_FLASHLIGHT_TO_WORLD_TEXTURE, worldToTexture.Base(), 4 );
|
||||
|
||||
// Tweaks associated with a given flashlight
|
||||
tweaks[0] = ShadowFilterFromState( state );
|
||||
tweaks[1] = ShadowAttenFromState( state );
|
||||
pShader->HashShadow2DJitter( state.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 );
|
||||
|
||||
int nTexWidth, nTexHeight;
|
||||
pShaderAPI->GetStandardTextureDimensions( &nTexWidth, &nTexHeight, TEXTURE_SHADOW_NOISE_2D );
|
||||
|
||||
vScreenScale[0] = (float) nWidth / nTexWidth;
|
||||
vScreenScale[1] = (float) nHeight / nTexHeight;
|
||||
|
||||
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_FLASHLIGHT_SCREEN_SCALE, vScreenScale, 1 );
|
||||
|
||||
if ( IsX360() )
|
||||
{
|
||||
pShaderAPI->SetBooleanPixelShaderConstant( 0, &state.m_nShadowQuality, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
flConsts[0] = IS_PARAM_DEFINED( info.m_nBumpStrength ) ? params[info.m_nBumpStrength]->GetFloatValue() : kDefaultBumpStrength;
|
||||
flConsts[1] = (g_pHardwareConfig->GetHDRType() == HDR_TYPE_FLOAT) ? 8192.0f : 192.0f; // destalpha dest scale factor. TODO: put this in its own const and call shaderAPI method to set
|
||||
flConsts[2] = IS_PARAM_DEFINED( info.m_nInteriorFogStrength ) ? params[info.m_nInteriorFogStrength]->GetFloatValue() : kDefaultInteriorFogStrength;
|
||||
flConsts[3] = IS_PARAM_DEFINED( info.m_nInteriorRefractStrength ) ? params[info.m_nInteriorRefractStrength]->GetFloatValue() : kDefaultInteriorRefractStrength;
|
||||
pShaderAPI->SetPixelShaderConstant( 0, flConsts, 1 );
|
||||
|
||||
Assert( IS_PARAM_DEFINED( info.m_nFresnelParams ) );
|
||||
if ( IS_PARAM_DEFINED( info.m_nFresnelParams ) )
|
||||
params[info.m_nFresnelParams]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultFresnelParams, sizeof( kDefaultFresnelParams ) );
|
||||
flConsts[3] = params[info.m_nInteriorBackgroundBoost]->GetFloatValue();
|
||||
pShaderAPI->SetPixelShaderConstant( 1, flConsts, 1 );
|
||||
|
||||
flConsts[0] = IS_PARAM_DEFINED( info.m_nRimLightExp ) ? params[info.m_nRimLightExp]->GetFloatValue() : kDefaultRimLightExp;
|
||||
flConsts[1] = IS_PARAM_DEFINED( info.m_nRimLightScale ) ? params[info.m_nRimLightScale]->GetFloatValue() : kDefaultRimLightScale;
|
||||
flConsts[2] = IS_PARAM_DEFINED( info.m_nSpecScale ) ? params[info.m_nSpecScale]->GetFloatValue() : kDefaultSpecScale;
|
||||
flConsts[3] = IS_PARAM_DEFINED( info.m_nSpecExp2 ) ? params[info.m_nSpecExp2]->GetFloatValue() : kDefaultSpecExp;
|
||||
pShaderAPI->SetPixelShaderConstant( 3, flConsts, 1 );
|
||||
|
||||
flConsts[0] = IS_PARAM_DEFINED( info.m_nSpecScale2 ) ? params[info.m_nSpecScale2]->GetFloatValue() : kDefaultSpecScale;
|
||||
flConsts[1] = IS_PARAM_DEFINED( info.m_nFresnelBumpStrength ) ? params[info.m_nFresnelBumpStrength]->GetFloatValue() : kDefaultFresnelBumpStrength;
|
||||
flConsts[2] = IS_PARAM_DEFINED( info.m_nDiffuseScale ) ? params[info.m_nDiffuseScale]->GetFloatValue() : kDefaultDiffuseScale;
|
||||
flConsts[3] = IS_PARAM_DEFINED( info.m_nInteriorAmbientScale ) ? params[info.m_nInteriorAmbientScale]->GetFloatValue() : kDefaultInteriorAmbientScale;
|
||||
pShaderAPI->SetPixelShaderConstant( 10, flConsts, 1 );
|
||||
|
||||
pShaderAPI->GetWorldSpaceCameraPosition( flConsts );
|
||||
flConsts[3] = IS_PARAM_DEFINED( info.m_nSpecExp ) ? params[info.m_nSpecExp]->GetFloatValue() : kDefaultSpecExp;
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, flConsts, 1 );
|
||||
|
||||
// Depth alpha [ TODO: support fog ]
|
||||
bool bWriteDepthToAlpha = pShaderAPI->ShouldWriteDepthToDestAlpha();
|
||||
flConsts[0] = bWriteDepthToAlpha ? 1.0f : 0.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_FOG_PARAMS, flConsts, 1 );
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nBaseColorTint ) )
|
||||
params[info.m_nBaseColorTint]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultBaseColorTint, sizeof( kDefaultBaseColorTint ) );
|
||||
flConsts[3] = IS_PARAM_DEFINED( info.m_nInteriorBackLightScale ) ? params[info.m_nInteriorBackLightScale]->GetFloatValue() : kDefaultInteriorBackLightScale;
|
||||
pShaderAPI->SetPixelShaderConstant( 19, flConsts, 1 );
|
||||
|
||||
if( bSelfIllumFresnel )
|
||||
{
|
||||
if ( IS_PARAM_DEFINED( info.m_nSelfIllumFresnelParams ) )
|
||||
params[info.m_nSelfIllumFresnelParams]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultSelfIllumFresnelParams, sizeof( kDefaultSelfIllumFresnelParams ) );
|
||||
float flMin = flConsts[0];
|
||||
float flMax = flConsts[1];
|
||||
float flExp = flConsts[2];
|
||||
|
||||
flConsts[1] = ( flMax != 0.0f ) ? ( flMin / flMax ) : 0.0f; // Bias
|
||||
flConsts[0] = 1.0f - flConsts[1]; // Scale
|
||||
flConsts[2] = flExp; // Exp
|
||||
flConsts[3] = flMax; // Brightness
|
||||
pShaderAPI->SetPixelShaderConstant( 26, flConsts, 1 );
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nSelfIllumTint ) )
|
||||
params[info.m_nSelfIllumTint]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultSelfIllumTint, sizeof( kDefaultSelfIllumTint ) );
|
||||
pShaderAPI->SetPixelShaderConstant( 27, flConsts, 1 );
|
||||
}
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nInteriorColor ) )
|
||||
params[info.m_nInteriorColor]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultInteriorColor, sizeof( kDefaultInteriorColor ) );
|
||||
flConsts[3] = params[info.m_nInteriorRefractBlur]->GetFloatValue();
|
||||
pShaderAPI->SetPixelShaderConstant( 32, flConsts, 1 );
|
||||
|
||||
float mView[16];
|
||||
pShaderAPI->GetMatrix( MATERIAL_VIEW, mView );
|
||||
pShaderAPI->SetPixelShaderConstant( 33, mView, 3 );
|
||||
|
||||
flConsts[0] = IS_PARAM_DEFINED( info.m_nInteriorFogLimit ) ? params[info.m_nInteriorFogLimit]->GetFloatValue() : kDefaultInteriorFogLimit;
|
||||
flConsts[0] = 1.0f - flConsts[0];
|
||||
flConsts[1] = params[info.m_nInteriorFogNormalBoost]->GetFloatValue();
|
||||
flConsts[2] = params[info.m_nGlowScale]->GetFloatValue();
|
||||
pShaderAPI->SetPixelShaderConstant( 36, flConsts, 1 );
|
||||
|
||||
// Set Pixel Shader Combos
|
||||
if( /*g_pHardwareConfig->SupportsPixelShaders_2_b()*/ true )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( blob_ps30 );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bHasFlashlight );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows );
|
||||
SET_DYNAMIC_PIXEL_SHADER( blob_ps30 );
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( !"No ps_3_0" );
|
||||
}
|
||||
}
|
||||
pShader->Draw();
|
||||
}
|
||||
|
||||
void DrawArmature( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI,
|
||||
IShaderShadow* pShaderShadow, BlobVars_t &info, VertexCompressionType_t vertexCompression, int nPassIdx )
|
||||
{
|
||||
Assert( nPassIdx >= 0 && nPassIdx < 2 );
|
||||
|
||||
bool bSelfIllumFresnel = (info.m_nSelfIllumFresnelEnable != -1) && ( params[info.m_nSelfIllumFresnelEnable]->GetIntValue() > 0 );
|
||||
bool bArmWiden = (info.m_nArmWiden != -1) && ( params[info.m_nArmWiden]->GetIntValue() > 0 );
|
||||
bool bNormalMap = (info.m_nNormalMap != -1) && params[info.m_nNormalMap]->IsDefined();
|
||||
bool bBaseMap = params[BASETEXTURE]->IsDefined();
|
||||
bool bAnimatedPulses = (info.m_nAnimateArmPulses != -1) && ( params[info.m_nAnimateArmPulses]->GetIntValue() > 0 );
|
||||
|
||||
SHADOW_STATE
|
||||
{
|
||||
if ( nPassIdx != 0 )
|
||||
{
|
||||
// Reset shadow state manually since we're drawing from two materials
|
||||
pShader->SetInitialShadowState();
|
||||
}
|
||||
|
||||
// Set stream format (note that this shader supports compression)
|
||||
unsigned int flags = VERTEX_COLOR;
|
||||
int nTexCoordCount = 5;
|
||||
int userDataSize = 0;
|
||||
int texCoordDims[5] = { 4, 4, 4, 4, 4 };
|
||||
pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, texCoordDims, userDataSize );
|
||||
|
||||
// Vertex Shader
|
||||
DECLARE_STATIC_VERTEX_SHADER( blob_arm_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( WIDEN_TIPS, bArmWiden );
|
||||
SET_STATIC_VERTEX_SHADER( blob_arm_vs20 );
|
||||
|
||||
// Pixel Shader
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( blob_arm_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( SELF_ILLUM_FRESNEL, bSelfIllumFresnel );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( PRE_PASS, ( nPassIdx == 0 ) );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( NORMALMAP, bNormalMap );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( MOVING_PULSES, bAnimatedPulses );
|
||||
SET_STATIC_PIXEL_SHADER( blob_arm_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( !"No ps_2_b" );
|
||||
}
|
||||
|
||||
// Textures
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); // Base
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true ); // Bump
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, false ); // Not sRGB
|
||||
pShaderShadow->EnableSRGBWrite( true );
|
||||
|
||||
pShaderShadow->EnableAlphaToCoverage( nPassIdx == 0 );
|
||||
pShaderShadow->EnableAlphaTest( nPassIdx == 0 );
|
||||
pShaderShadow->AlphaFunc( SHADER_ALPHAFUNC_GEQUAL, 0.5f );
|
||||
pShaderShadow->EnableColorWrites( nPassIdx > 0 );
|
||||
|
||||
if ( nPassIdx != 0 )
|
||||
{
|
||||
pShaderShadow->DepthFunc( SHADER_DEPTHFUNC_EQUAL );
|
||||
}
|
||||
|
||||
// Blending
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
|
||||
// Per-instance state
|
||||
pShader->PI_BeginCommandBuffer();
|
||||
pShader->PI_SetVertexShaderAmbientLightCube();
|
||||
pShader->PI_SetPixelShaderAmbientLightCube( PSREG_AMBIENT_CUBE );
|
||||
pShader->PI_SetPixelShaderLocalLighting( PSREG_LIGHT_INFO_ARRAY );
|
||||
pShader->PI_EndCommandBuffer();
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
if ( nPassIdx != 0 )
|
||||
{
|
||||
// Reset render state manually since we're drawing from two materials
|
||||
pShaderAPI->SetDefaultState();
|
||||
}
|
||||
|
||||
// Set Vertex Shader Combos
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( blob_arm_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
|
||||
SET_DYNAMIC_VERTEX_SHADER( blob_arm_vs20 );
|
||||
|
||||
LightState_t lightState = { 0, false, false };
|
||||
pShaderAPI->GetDX9LightState( &lightState );
|
||||
|
||||
// VS constants
|
||||
float flConsts[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
flConsts[0] = IS_PARAM_DEFINED( info.m_nArmWidthExp ) ? params[info.m_nArmWidthExp]->GetFloatValue() : kDefaultArmWidthExp;
|
||||
flConsts[1] = IS_PARAM_DEFINED( info.m_nArmWidthScale ) ? params[info.m_nArmWidthScale]->GetFloatValue() : kDefaultArmWidthScale;
|
||||
flConsts[2] = IS_PARAM_DEFINED( info.m_nArmWidthBias ) ? params[info.m_nArmWidthBias]->GetFloatValue() : kDefaultArmWidthBias;
|
||||
flConsts[3] = IS_PARAM_DEFINED( info.m_nUVScale ) ? params[info.m_nUVScale]->GetFloatValue() : kDefaultUVScale;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, flConsts );
|
||||
|
||||
pShaderAPI->GetWorldSpaceCameraPosition( flConsts );
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, flConsts );
|
||||
|
||||
// Set Pixel Shader Combos
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( blob_arm_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( blob_arm_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( !"No ps_2_b" );
|
||||
}
|
||||
|
||||
// Bind textures
|
||||
if ( bBaseMap )
|
||||
{
|
||||
pShader->BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_SRGBREAD, BASETEXTURE );
|
||||
}
|
||||
else
|
||||
{
|
||||
pShaderAPI->BindStandardTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_SRGBREAD, TEXTURE_WHITE );
|
||||
}
|
||||
|
||||
if ( bNormalMap )
|
||||
{
|
||||
pShader->BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, info.m_nNormalMap );
|
||||
}
|
||||
|
||||
pShaderAPI->GetWorldSpaceCameraPosition( flConsts );
|
||||
flConsts[3] = IS_PARAM_DEFINED( info.m_nSpecExp ) ? params[info.m_nSpecExp]->GetFloatValue() : kDefaultSpecExp;
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, flConsts, 1 );
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nArmColorTint ) )
|
||||
params[info.m_nArmColorTint ]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultArmColorTint, sizeof( kDefaultArmColorTint ) );
|
||||
pShaderAPI->SetPixelShaderConstant( 19, flConsts, 1 );
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nSelfIllumTint ) )
|
||||
params[info.m_nSelfIllumTint]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultSelfIllumTint, sizeof( flConsts ) );
|
||||
|
||||
if( bSelfIllumFresnel )
|
||||
{
|
||||
if ( IS_PARAM_DEFINED( info.m_nSelfIllumFresnelParams ) )
|
||||
params[info.m_nSelfIllumFresnelParams]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultSelfIllumTint, sizeof( flConsts ) );
|
||||
float flMin = flConsts[0];
|
||||
float flMax = flConsts[1];
|
||||
float flExp = flConsts[2];
|
||||
|
||||
flConsts[1] = ( flMax != 0.0f ) ? ( flMin / flMax ) : 0.0f; // Bias
|
||||
flConsts[0] = 1.0f - flConsts[1]; // Scale
|
||||
flConsts[2] = flExp; // Exp
|
||||
flConsts[3] = flMax; // Brightness
|
||||
pShaderAPI->SetPixelShaderConstant( 26, flConsts, 1 );
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nSelfIllumTint ) )
|
||||
params[info.m_nSelfIllumTint]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultSelfIllumTint, sizeof( flConsts ) );
|
||||
pShaderAPI->SetPixelShaderConstant( 27, flConsts, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
pShader->Draw();
|
||||
}
|
||||
133
materialsystem/stdshaders/Blob_helper.h
Normal file
133
materialsystem/stdshaders/Blob_helper.h
Normal file
@@ -0,0 +1,133 @@
|
||||
//========= Copyright © 1996-2007, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#ifndef BLOB_HELPER_H
|
||||
#define BLOB_HELPER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBaseVSShader;
|
||||
class IMaterialVar;
|
||||
class IShaderDynamicAPI;
|
||||
class IShaderShadow;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Struct to hold shader param indices
|
||||
//-----------------------------------------------------------------------------
|
||||
struct BlobVars_t
|
||||
{
|
||||
BlobVars_t()
|
||||
{
|
||||
memset( this, 0xFF, sizeof( BlobVars_t ) );
|
||||
}
|
||||
|
||||
int m_nBackSurface;
|
||||
int m_nBumpStrength;
|
||||
int m_nFresnelBumpStrength;
|
||||
int m_nNormalMap;
|
||||
int m_nBaseTexture;
|
||||
int m_nLightWarpTexture;
|
||||
int m_nFresnelWarpTexture;
|
||||
int m_nOpacityTexture;
|
||||
int m_nSpecMap;
|
||||
int m_nUVScale;
|
||||
|
||||
int m_nInteriorEnable;
|
||||
int m_nInteriorFogStrength;
|
||||
int m_nInteriorFogLimit;
|
||||
int m_nInteriorFogNormalBoost;
|
||||
int m_nInteriorBackgroundBoost;
|
||||
int m_nInteriorAmbientScale;
|
||||
int m_nInteriorBackLightScale;
|
||||
int m_nInteriorColor;
|
||||
int m_nInteriorRefractStrength;
|
||||
int m_nInteriorRefractBlur;
|
||||
|
||||
int m_nFresnelParams;
|
||||
int m_nDiffuseScale;
|
||||
int m_nSpecExp;
|
||||
int m_nSpecScale;
|
||||
int m_nSpecExp2;
|
||||
int m_nSpecScale2;
|
||||
int m_nRimLightExp;
|
||||
int m_nRimLightScale;
|
||||
int m_nBaseColorTint;
|
||||
int m_nSelfIllumFresnelEnable;
|
||||
int m_nSelfIllumFresnelParams;
|
||||
int m_nSelfIllumTint;
|
||||
int m_nUVProjOffset;
|
||||
int m_nBBMin;
|
||||
int m_nBBMax;
|
||||
int m_nArmature;
|
||||
int m_nFlashlightTexture;
|
||||
int m_nFlashlightTextureFrame;
|
||||
int m_nArmColorTint;
|
||||
int m_nArmWiden;
|
||||
int m_nArmWidthExp;
|
||||
int m_nArmWidthScale;
|
||||
int m_nArmWidthBias;
|
||||
int m_nAnimateArmPulses;
|
||||
int m_nVolumeTex;
|
||||
int m_nBumpFrame;
|
||||
int m_nGlowScale;
|
||||
int m_nPulse;
|
||||
int m_nContactShadows;
|
||||
};
|
||||
|
||||
// default shader param values
|
||||
static const int kDefaultBackSurface = 0;
|
||||
static const float kDefaultBumpStrength = 1.0f;
|
||||
static const float kDefaultFresnelBumpStrength = 1.0f;
|
||||
static const float kDefaultUVScale = 0.02f;
|
||||
|
||||
static const int kDefaultInteriorEnable = 1;
|
||||
static const float kDefaultInteriorFogStrength = 0.06f;
|
||||
static const float kDefaultInteriorFogLimit = 0.8f;
|
||||
static const float kDefaultInteriorFogNormalBoost = 0.0f;
|
||||
static const float kDefaultInteriorBackgroundBoost = 0.0f;
|
||||
static const float kDefaultInteriorAmbientScale = 0.3f;
|
||||
static const float kDefaultInteriorBackLightScale = 0.3f;
|
||||
static const float kDefaultInteriorColor[3] = { 0.5f, 0.5f, 0.5f };
|
||||
static const float kDefaultInteriorRefractStrength = 0.015f;
|
||||
static const float kDefaultInteriorRefractBlur = 0.2f;
|
||||
|
||||
static const float kDefaultFresnelParams[3] = { 0.0f, 0.5f, 2.0f };
|
||||
static const float kDefaultBaseColorTint[3] = { 1.0f, 1.0f, 1.0f };
|
||||
static const float kDefaultDiffuseScale = 1.0f;
|
||||
static const float kDefaultSpecExp = 1.0f;
|
||||
static const float kDefaultSpecScale = 1.0f;
|
||||
static const float kDefaultRimLightExp = 10.0f;
|
||||
static const float kDefaultRimLightScale = 1.0f;
|
||||
static const int kDefaultSelfIllumFresnelEnable = 0;
|
||||
static const float kDefaultSelfIllumFresnelParams[3] = { 0.0f, 1.0f, 1.0f };
|
||||
static const float kDefaultSelfIllumTint[3] = { 1.0f, 1.0f, 1.0f };
|
||||
static const float kDefaultUVProjOffset[3] = { 0.0f, 0.0f, 0.0f };
|
||||
static const float kDefaultBB[3] = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
static const int kDefaultArmature = 0;
|
||||
static const float kDefaultArmColorTint[3] = { 1.0f, 1.0f, 1.0f };
|
||||
static const int kDefaultArmWiden = 0;
|
||||
static const float kDefaultArmWidthExp = 1.0f;
|
||||
static const float kDefaultArmWidthScale = 1.0f;
|
||||
static const float kDefaultArmWidthBias = 0.0f;
|
||||
static const int kDefaultAnimateArmPulses = 1;
|
||||
|
||||
static const int kDefaultVolumeTex = 0;
|
||||
static const int kDefaultBumpFrame = 0;
|
||||
static const float kDefaultGlowScale = 1.0f;
|
||||
static const int kDefaultPulse = 0;
|
||||
static const int kDefaultContactShadows = 0;
|
||||
|
||||
void InitParamsBlob( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, BlobVars_t &info );
|
||||
void InitBlob( CBaseVSShader *pShader, IMaterialVar** params, BlobVars_t &info );
|
||||
void DrawBlob( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI,
|
||||
IShaderShadow* pShaderShadow, BlobVars_t &info, VertexCompressionType_t vertexCompression );
|
||||
void DrawArmature( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI,
|
||||
IShaderShadow* pShaderShadow, BlobVars_t &info, VertexCompressionType_t vertexCompression, int nPassIdx );
|
||||
|
||||
#endif // BLOB_HELPER_H
|
||||
88
materialsystem/stdshaders/Bloom.cpp
Normal file
88
materialsystem/stdshaders/Bloom.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
|
||||
#include "screenspaceeffect_vs20.inc"
|
||||
#include "Bloom_ps20.inc"
|
||||
#include "Bloom_ps20b.inc"
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( Bloom, "Help for Bloom", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( FBTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_FullFrameFB", "" )
|
||||
SHADER_PARAM( BLURTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_SmallHDR0", "" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if( params[FBTEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( FBTEXTURE );
|
||||
}
|
||||
if( params[BLURTEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( BLURTEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
int fmt = VERTEX_POSITION;
|
||||
pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
|
||||
|
||||
// Pre-cache shaders
|
||||
DECLARE_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( bloom_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER( bloom_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( bloom_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER( bloom_ps20 );
|
||||
}
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, FBTEXTURE, -1 );
|
||||
BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, BLURTEXTURE, -1 );
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( bloom_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( bloom_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( bloom_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( bloom_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
19
materialsystem/stdshaders/Bloom_ps2x.fxc
Normal file
19
materialsystem/stdshaders/Bloom_ps2x.fxc
Normal file
@@ -0,0 +1,19 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler FBSampler : register( s0 );
|
||||
sampler BlurSampler : register( s1 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4 fbSample = tex2D( FBSampler, i.texCoord );
|
||||
float4 blurSample = tex2D( BlurSampler, i.texCoord );
|
||||
|
||||
return FinalOutput( float4( fbSample + blurSample.rgb * blurSample.a * MAX_HDR_OVERBRIGHT, 1.0f ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
138
materialsystem/stdshaders/BlurFilterX.cpp
Normal file
138
materialsystem/stdshaders/BlurFilterX.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "BlurFilter_vs20.inc"
|
||||
#include "BlurFilter_ps20.inc"
|
||||
#include "BlurFilter_ps20b.inc"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( BlurFilterX, "Help for BlurFilterX", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( KERNEL, SHADER_PARAM_TYPE_INTEGER, "0", "Kernel type" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
if ( !( params[ KERNEL ]->IsDefined() ) )
|
||||
{
|
||||
params[ KERNEL ]->SetIntValue( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if( params[BASETEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
// Render targets are pegged as sRGB on POSIX, so just force these reads and writes
|
||||
bool bForceSRGBReadAndWrite = false;
|
||||
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
|
||||
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, bForceSRGBReadAndWrite );
|
||||
pShaderShadow->EnableSRGBWrite( bForceSRGBReadAndWrite );
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( blurfilter_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( KERNEL, params[ KERNEL ]->GetIntValue() ? 1 : 0 );
|
||||
SET_STATIC_VERTEX_SHADER( blurfilter_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( KERNEL, params[ KERNEL ]->GetIntValue() );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( CLEAR_COLOR, false );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( APPROX_SRGB_ADAPTER, bForceSRGBReadAndWrite && ( params[ KERNEL ]->GetIntValue() != 0 ) );
|
||||
SET_STATIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( KERNEL, params[ KERNEL ]->GetIntValue() );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( CLEAR_COLOR, false );
|
||||
SET_STATIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
}
|
||||
|
||||
if ( IS_FLAG_SET( MATERIAL_VAR_ADDITIVE ) )
|
||||
EnableAlphaBlending( SHADER_BLEND_ONE, SHADER_BLEND_ONE );
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, bForceSRGBReadAndWrite ? TEXTURE_BINDFLAGS_SRGBREAD : TEXTURE_BINDFLAGS_NONE, BASETEXTURE, -1 );
|
||||
|
||||
float v[4];
|
||||
|
||||
// The temp buffer is 1/4 back buffer size
|
||||
ITexture *src_texture = params[BASETEXTURE]->GetTextureValue();
|
||||
int width = src_texture->GetActualWidth();
|
||||
float dX = 1.0f / width;
|
||||
|
||||
// Tap offsets
|
||||
v[0] = 1.3366f * dX;
|
||||
v[1] = 0.0f;
|
||||
v[2] = 0;
|
||||
v[3] = 0;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, v, 1 );
|
||||
v[0] = 3.4295f * dX;
|
||||
v[1] = 0.0f;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, v, 1 );
|
||||
v[0] = 5.4264f * dX;
|
||||
v[1] = 0.0f;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, v, 1 );
|
||||
|
||||
v[0] = 7.4359f * dX;
|
||||
v[1] = 0.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( 0, v, 1 );
|
||||
v[0] = 9.4436f * dX;
|
||||
v[1] = 0.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( 1, v, 1 );
|
||||
v[0] = 11.4401f * dX;
|
||||
v[1] = 0.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( 2, v, 1 );
|
||||
|
||||
v[0] = v[1] = v[2] = v[3] = 1.0;
|
||||
pShaderAPI->SetPixelShaderConstant( 3, v, 1 );
|
||||
|
||||
v[0] = v[1] = v[2] = v[3] = 0.0;
|
||||
v[0] = dX;
|
||||
pShaderAPI->SetPixelShaderConstant( 4, v, 1 );
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( blurfilter_ps20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( blurfilter_ps20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
158
materialsystem/stdshaders/BlurFilterY.cpp
Normal file
158
materialsystem/stdshaders/BlurFilterY.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "BlurFilter_vs20.inc"
|
||||
#include "BlurFilter_ps20.inc"
|
||||
#include "BlurFilter_ps20b.inc"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( BlurFilterY, "Help for BlurFilterY", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( BLOOMAMOUNT, SHADER_PARAM_TYPE_FLOAT, "1.0", "" )
|
||||
SHADER_PARAM( FRAMETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_SmallHDR0", "" )
|
||||
SHADER_PARAM( KERNEL, SHADER_PARAM_TYPE_INTEGER, "0", "Kernel type" )
|
||||
SHADER_PARAM( ENABLECLEARCOLOR, SHADER_PARAM_TYPE_BOOL, "0", "clear RGB channels to a solid color" )
|
||||
SHADER_PARAM( CLEARCOLOR, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "clear color" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
if ( !( params[BLOOMAMOUNT]->IsDefined() ) )
|
||||
{
|
||||
params[BLOOMAMOUNT]->SetFloatValue(1.0);
|
||||
}
|
||||
|
||||
if ( !( params[ KERNEL ]->IsDefined() ) )
|
||||
{
|
||||
params[ KERNEL ]->SetIntValue( 0 );
|
||||
}
|
||||
|
||||
if ( !( params[ ENABLECLEARCOLOR ]->IsDefined() ) )
|
||||
{
|
||||
params[ ENABLECLEARCOLOR ]->SetIntValue( 0 );
|
||||
}
|
||||
|
||||
if ( !( params[ CLEARCOLOR ]->IsDefined() ) )
|
||||
{
|
||||
params[ CLEARCOLOR ]->SetVecValue( 0.0f, 0.0f, 0.0f );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if ( params[BASETEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
// Render targets are pegged as sRGB on POSIX, so just force these reads and writes
|
||||
bool bForceSRGBReadAndWrite = false;
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
|
||||
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, bForceSRGBReadAndWrite );
|
||||
pShaderShadow->EnableSRGBWrite( bForceSRGBReadAndWrite );
|
||||
DECLARE_STATIC_VERTEX_SHADER( blurfilter_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( KERNEL, params[ KERNEL ]->GetIntValue() ? 1 : 0 );
|
||||
SET_STATIC_VERTEX_SHADER( blurfilter_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( KERNEL, params[ KERNEL ]->GetIntValue() );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( CLEAR_COLOR, params[ ENABLECLEARCOLOR ]->GetIntValue() );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( APPROX_SRGB_ADAPTER, bForceSRGBReadAndWrite && ( params[ KERNEL ]->GetIntValue() != 0 ) && ( params[ ENABLECLEARCOLOR ]->GetIntValue() == 0 ) );
|
||||
SET_STATIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( KERNEL, params[ KERNEL ]->GetIntValue() );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( CLEAR_COLOR, params[ ENABLECLEARCOLOR ]->GetIntValue() );
|
||||
SET_STATIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
}
|
||||
|
||||
if ( IS_FLAG_SET( MATERIAL_VAR_ADDITIVE ) )
|
||||
EnableAlphaBlending( SHADER_BLEND_ONE, SHADER_BLEND_ONE );
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, bForceSRGBReadAndWrite ? TEXTURE_BINDFLAGS_SRGBREAD : TEXTURE_BINDFLAGS_NONE, BASETEXTURE, -1 );
|
||||
|
||||
// The temp buffer is 1/4 back buffer size
|
||||
ITexture *src_texture = params[BASETEXTURE]->GetTextureValue();
|
||||
int height = src_texture->GetActualHeight();
|
||||
float dY = 1.0f / height;
|
||||
// dY *= 0.4;
|
||||
float v[4];
|
||||
|
||||
// Tap offsets
|
||||
v[0] = 0.0f;
|
||||
v[1] = 1.3366f * dY;
|
||||
v[2] = 0;
|
||||
v[3] = 0;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, v, 1 );
|
||||
v[0] = 0.0f;
|
||||
v[1] = 3.4295f * dY;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, v, 1 );
|
||||
v[0] = 0.0f;
|
||||
v[1] = 5.4264f * dY;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, v, 1 );
|
||||
|
||||
v[0] = 0.0f;
|
||||
v[1] = 7.4359f * dY;
|
||||
pShaderAPI->SetPixelShaderConstant( 0, v, 1 );
|
||||
v[0] = 0.0f;
|
||||
v[1] = 9.4436f * dY;
|
||||
pShaderAPI->SetPixelShaderConstant( 1, v, 1 );
|
||||
v[0] = 0.0f;
|
||||
v[1] = 11.4401f * dY;
|
||||
pShaderAPI->SetPixelShaderConstant( 2, v, 1 );
|
||||
|
||||
v[0] = v[1] = v[2] = params[BLOOMAMOUNT]->GetFloatValue();
|
||||
pShaderAPI->SetPixelShaderConstant( 3, v, 1 );
|
||||
|
||||
v[0] = v[1] = v[2] = v[3] = 0.0;
|
||||
v[1] = dY;
|
||||
pShaderAPI->SetPixelShaderConstant( 4, v, 1 );
|
||||
|
||||
params[CLEARCOLOR]->GetVecValue( v, 3 );
|
||||
v[3] = 0.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( 5, v, 1 );
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( blurfilter_ps20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( blurfilter_ps20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
158
materialsystem/stdshaders/BlurFilter_ps2x.fxc
Normal file
158
materialsystem/stdshaders/BlurFilter_ps2x.fxc
Normal file
@@ -0,0 +1,158 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// STATIC: "KERNEL" "0..4"
|
||||
// STATIC: "CLEAR_COLOR" "0..1"
|
||||
// STATIC: "APPROX_SRGB_ADAPTER" "0..1" [ps20b] [PC]
|
||||
// STATIC: "APPROX_SRGB_ADAPTER" "0..0" [ps20b] [CONSOLE]
|
||||
|
||||
// We only support our approximate sRGB adapter on the Gaussian kernels
|
||||
// SKIP: ( $APPROX_SRGB_ADAPTER == 1 ) && ( $KERNEL == 0 ) [ps20b] [PC]
|
||||
|
||||
// Don't bother with our approximate sRGB adapter if we're clearing
|
||||
// SKIP: ( $APPROX_SRGB_ADAPTER == 1 ) && ( $CLEAR_COLOR == 1 ) [ps20b] [PC]
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler TexSampler : register( s0 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 coordTap0 : TEXCOORD0;
|
||||
#if ( KERNEL == 0 ) // Original kernel that has a '+' plus shape
|
||||
float2 coordTap1 : TEXCOORD1;
|
||||
float2 coordTap2 : TEXCOORD2;
|
||||
float2 coordTap3 : TEXCOORD3;
|
||||
float2 coordTap1Neg : TEXCOORD4;
|
||||
float2 coordTap2Neg : TEXCOORD5;
|
||||
float2 coordTap3Neg : TEXCOORD6;
|
||||
#endif
|
||||
};
|
||||
|
||||
float2 g_vPsTapOffset[3] : register( c0 );
|
||||
float3 g_vScaleFactor : register( c3 );
|
||||
|
||||
float2 g_vUvOffsetToNeighborPixel : register( c4 );
|
||||
float3 g_vClearColor : register( c5 );
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
#if ( KERNEL == 0 ) // Original kernel that has a '+' plus shape (used for bloom?)
|
||||
{
|
||||
float4 s0, s1, s2, s3, s4, s5, s6, color;
|
||||
|
||||
// Sample taps with coordinates from VS
|
||||
s0 = saturate( tex2D( TexSampler, i.coordTap0 ) );
|
||||
s1 = saturate( tex2D( TexSampler, i.coordTap1 ) );
|
||||
s2 = saturate( tex2D( TexSampler, i.coordTap2 ) );
|
||||
s3 = saturate( tex2D( TexSampler, i.coordTap3 ) );
|
||||
s4 = saturate( tex2D( TexSampler, i.coordTap1Neg ) );
|
||||
s5 = saturate( tex2D( TexSampler, i.coordTap2Neg ) );
|
||||
s6 = saturate( tex2D( TexSampler, i.coordTap3Neg ) );
|
||||
|
||||
color = s0 * 0.2013f;
|
||||
color += ( s1 + s4 ) * 0.2185f;
|
||||
color += ( s2 + s5 ) * 0.0821f;
|
||||
color += ( s3 + s6 ) * 0.0461f;
|
||||
|
||||
// Compute tex coords for other taps
|
||||
float2 coordTap4 = i.coordTap0 + g_vPsTapOffset[0];
|
||||
float2 coordTap5 = i.coordTap0 + g_vPsTapOffset[1];
|
||||
float2 coordTap6 = i.coordTap0 + g_vPsTapOffset[2];
|
||||
float2 coordTap4Neg = i.coordTap0 - g_vPsTapOffset[0];
|
||||
float2 coordTap5Neg = i.coordTap0 - g_vPsTapOffset[1];
|
||||
float2 coordTap6Neg = i.coordTap0 - g_vPsTapOffset[2];
|
||||
|
||||
// Sample the taps
|
||||
s1 = saturate( tex2D( TexSampler, coordTap4 ) );
|
||||
s2 = saturate( tex2D( TexSampler, coordTap5 ) );
|
||||
s3 = saturate( tex2D( TexSampler, coordTap6 ) );
|
||||
s4 = saturate( tex2D( TexSampler, coordTap4Neg ) );
|
||||
s5 = saturate( tex2D( TexSampler, coordTap5Neg ) );
|
||||
s6 = saturate( tex2D( TexSampler, coordTap6Neg ) );
|
||||
|
||||
color += ( s1 + s4 ) * 0.0262f;
|
||||
color += ( s2 + s5 ) * 0.0162f;
|
||||
color += ( s3 + s6 ) * 0.0102f;
|
||||
#if ( CLEAR_COLOR == 1 )
|
||||
{
|
||||
color.rgb = g_vClearColor.rgb;
|
||||
}
|
||||
#else
|
||||
{
|
||||
color.xyz *= g_vScaleFactor.xyz;
|
||||
}
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
#else // Gaussian kernel
|
||||
{
|
||||
#if ( KERNEL == 1 )
|
||||
// Gaussian kernel 7 pixels wide
|
||||
int kNumSamples = 5;
|
||||
float vKernel[5] = { 0.004433f, 0.296042f, 0.399050f, 0.296042f, 0.004433f };
|
||||
float vUvOffset[5] = { -3.000000f, -1.182425f, 0.000000f, 1.182425f, 3.000000f };
|
||||
#elif ( KERNEL == 2 )
|
||||
// Gaussian kernel 9 pixels wide
|
||||
int kNumSamples = 5;
|
||||
float vKernel[5] = { 0.019827f, 0.320561f, 0.319224f, 0.320561f, 0.019827f };
|
||||
float vUvOffset[5] = { -3.096215f, -1.276878f, 0.000000f, 1.276878f, 3.096215f };
|
||||
#elif ( KERNEL == 3 )
|
||||
// Gaussian kernel 13 pixels wide
|
||||
int kNumSamples = 7;
|
||||
float vKernel[7] = { 0.004487f, 0.069185f, 0.312325f, 0.228005f, 0.312325f, 0.069185f, 0.004487f };
|
||||
float vUvOffset[7] = { -5.142349f, -3.241796f, -1.379942f, 0.000000f, 1.379942f, 3.241796f, 5.142349f };
|
||||
#elif ( KERNEL == 4 )
|
||||
// Gaussian kernel 25 pixels wide
|
||||
int kNumSamples = 13;
|
||||
float vKernel[13] = { 0.000534f, 0.003733f, 0.018004f, 0.059928f, 0.137740f, 0.218677f, 0.122765f, 0.218677f, 0.137740f, 0.059928f, 0.018004f, 0.003733f, 0.000534f };
|
||||
float vUvOffset[13] = { -11.251852f, -9.289172f, -7.329586f, -5.372686f, -3.417910f, -1.464557f, 0.000000f, 1.464557f, 3.417910f, 5.372686f, 7.329586f, 9.289172f, 11.251852f };
|
||||
#endif
|
||||
|
||||
float2 vStartUv = i.coordTap0.xy;
|
||||
|
||||
float4 cColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
for ( int j = 0; j < kNumSamples; j++ )
|
||||
{
|
||||
// Calculate uv
|
||||
float2 vUvTmp = vStartUv.xy + ( vUvOffset[j].xx * g_vUvOffsetToNeighborPixel.xy );
|
||||
|
||||
// Sample pixel
|
||||
float4 cSample = tex2D( TexSampler, vUvTmp.xy );
|
||||
|
||||
#if ( APPROX_SRGB_ADAPTER )
|
||||
{
|
||||
cSample.rgb = max( cSample.rgb, float3( 0.00001f, 0.00001f, 0.00001f ) ); // rsqrt doesn't like inputs of zero
|
||||
|
||||
float3 ooSQRT; //
|
||||
ooSQRT.r = rsqrt( cSample.r ); //
|
||||
ooSQRT.g = rsqrt( cSample.g ); // Approximate linear-to-sRGB conversion
|
||||
ooSQRT.b = rsqrt( cSample.b ); //
|
||||
cSample.rgb *= ooSQRT.rgb; //
|
||||
}
|
||||
#endif
|
||||
|
||||
// Weight the sample
|
||||
cColor.rgba += vKernel[j] * cSample;
|
||||
}
|
||||
|
||||
#if ( CLEAR_COLOR == 1 )
|
||||
{
|
||||
cColor.rgb = g_vClearColor.rgb;
|
||||
}
|
||||
#else
|
||||
{
|
||||
cColor.rgb = cColor.rgb * g_vScaleFactor.rgb;
|
||||
|
||||
#if ( APPROX_SRGB_ADAPTER )
|
||||
{
|
||||
cColor.rgb *= cColor.rgb; // Approximate sRGB-to-linear conversion
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
return cColor.rgba;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
52
materialsystem/stdshaders/BlurFilter_vs20.fxc
Normal file
52
materialsystem/stdshaders/BlurFilter_vs20.fxc
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
// STATIC: "KERNEL" "0..1"
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vBaseTexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float2 coordTap0 : TEXCOORD0;
|
||||
#if ( KERNEL == 0 ) // Original kernel that has a '+' plus shape
|
||||
float2 coordTap1 : TEXCOORD1;
|
||||
float2 coordTap2 : TEXCOORD2;
|
||||
float2 coordTap3 : TEXCOORD3;
|
||||
float2 coordTap1Neg : TEXCOORD4;
|
||||
float2 coordTap2Neg : TEXCOORD5;
|
||||
float2 coordTap3Neg : TEXCOORD6;
|
||||
#endif
|
||||
};
|
||||
|
||||
float2 vsTapOffs[3] : register ( SHADER_SPECIFIC_CONST_0 );
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
o.projPos = float4( v.vPos, 1.0f );
|
||||
|
||||
#ifdef _PS3
|
||||
// Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
|
||||
o.projPos.y = -o.projPos.y;
|
||||
o.projPos.z = 2.0f * o.projPos.z - o.projPos.w;
|
||||
#endif // _PS3
|
||||
|
||||
o.coordTap0.xy = v.vBaseTexCoord.xy;
|
||||
#if ( KERNEL == 0 ) // Original kernel
|
||||
o.coordTap1 = v.vBaseTexCoord + vsTapOffs[0];
|
||||
o.coordTap2 = v.vBaseTexCoord + vsTapOffs[1];
|
||||
o.coordTap3 = v.vBaseTexCoord + vsTapOffs[2];
|
||||
o.coordTap1Neg = v.vBaseTexCoord - vsTapOffs[0];
|
||||
o.coordTap2Neg = v.vBaseTexCoord - vsTapOffs[1];
|
||||
o.coordTap3Neg = v.vBaseTexCoord - vsTapOffs[2];
|
||||
#endif
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
110
materialsystem/stdshaders/BufferClearObeyStencil_dx9.cpp
Normal file
110
materialsystem/stdshaders/BufferClearObeyStencil_dx9.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
//========= Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Clears color/depth, but obeys stencil while doing so
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
|
||||
#include "bufferclearobeystencil_vs20.inc"
|
||||
#include "bufferclearobeystencil_ps20.inc"
|
||||
#include "bufferclearobeystencil_ps20b.inc"
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DEFINE_FALLBACK_SHADER( BufferClearObeyStencil, BufferClearObeyStencil_DX9 )
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( BufferClearObeyStencil_DX9, "", SHADER_NOT_EDITABLE )
|
||||
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( CLEARCOLOR, SHADER_PARAM_TYPE_INTEGER, "1", "activates clearing of color" )
|
||||
SHADER_PARAM( CLEARALPHA, SHADER_PARAM_TYPE_INTEGER, "-1", "activates clearing of alpha. -1 == copy CLEARCOLOR setting" )
|
||||
SHADER_PARAM( CLEARDEPTH, SHADER_PARAM_TYPE_INTEGER, "1", "activates clearing of depth" )
|
||||
SHADER_PARAM( RELOADZCULL, SHADER_PARAM_TYPE_INTEGER, "0", "special shader to reload Zcull memory on ps3" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if ( !params[CLEARALPHA]->IsDefined() )
|
||||
{
|
||||
params[CLEARALPHA]->SetIntValue( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
bool bEnableColorWrites = params[CLEARCOLOR]->GetIntValue() != 0;
|
||||
bool bEnableAlphaWrites = (params[CLEARALPHA]->GetIntValue() >= 0) ? (params[CLEARALPHA]->GetIntValue() != 0) : bEnableColorWrites;
|
||||
|
||||
bool bUsesColor = bEnableColorWrites || bEnableAlphaWrites;
|
||||
bool bReloadZcull = ( IsPS3() && params[RELOADZCULL]->GetIntValue() != 0 ) ? true : false;
|
||||
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->DepthFunc( bReloadZcull ? SHADER_DEPTHFUNC_NEARER : SHADER_DEPTHFUNC_ALWAYS );
|
||||
bool bEnableDepthWrites = params[CLEARDEPTH]->GetIntValue() != 0;
|
||||
pShaderShadow->EnableDepthWrites( bEnableDepthWrites );
|
||||
|
||||
pShaderShadow->EnableColorWrites( bEnableColorWrites );
|
||||
pShaderShadow->EnableAlphaWrites( bEnableAlphaWrites );
|
||||
|
||||
pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION|VERTEX_COLOR, 1, NULL, 0 );
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( bufferclearobeystencil_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( USESCOLOR, bUsesColor );
|
||||
SET_STATIC_VERTEX_SHADER( bufferclearobeystencil_vs20 );
|
||||
|
||||
//avoid setting a pixel shader when only doing depth/stencil operations, as recommended by PIX
|
||||
if( bUsesColor || g_pHardwareConfig->PlatformRequiresNonNullPixelShaders() )
|
||||
{
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( bufferclearobeystencil_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( RELOADZCULL, bReloadZcull );
|
||||
SET_STATIC_PIXEL_SHADER( bufferclearobeystencil_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( bufferclearobeystencil_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( RELOADZCULL, bReloadZcull );
|
||||
SET_STATIC_PIXEL_SHADER( bufferclearobeystencil_ps20 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( bufferclearobeystencil_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( bufferclearobeystencil_vs20 );
|
||||
|
||||
//avoid setting a pixel shader when only doing depth/stencil operations, as recommended by PIX
|
||||
if( bUsesColor || g_pHardwareConfig->PlatformRequiresNonNullPixelShaders() )
|
||||
{
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( bufferclearobeystencil_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( bufferclearobeystencil_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( bufferclearobeystencil_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( bufferclearobeystencil_ps20 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Draw( );
|
||||
}
|
||||
|
||||
END_SHADER
|
||||
21
materialsystem/stdshaders/DebugDrawDepth_ps2x.fxc
Normal file
21
materialsystem/stdshaders/DebugDrawDepth_ps2x.fxc
Normal file
@@ -0,0 +1,21 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float3 zValue : TEXCOORD0;
|
||||
};
|
||||
|
||||
const float3 g_ZFilter : register( c1 );
|
||||
const float3 g_ModulationColor : register( c2 );
|
||||
|
||||
float4_color_return_type main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float z = dot( i.zValue, g_ZFilter );
|
||||
z = saturate( z );
|
||||
float4 color = float4( z, z, z, 1.0f );
|
||||
color.rgb *= g_ModulationColor;
|
||||
return FinalOutput( color, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
46
materialsystem/stdshaders/DebugDrawDepth_vs20.fxc
Normal file
46
materialsystem/stdshaders/DebugDrawDepth_vs20.fxc
Normal file
@@ -0,0 +1,46 @@
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
static const bool g_bSkinning = SKINNING ? true : false;
|
||||
|
||||
const float2 cDepthFactor : register( SHADER_SPECIFIC_CONST_0 );
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION;
|
||||
float4 vBoneWeights : BLENDWEIGHT;
|
||||
float4 vBoneIndices : BLENDINDICES;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float2 zValue : TEXCOORD0;
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
float3 worldPos;
|
||||
SkinPosition( g_bSkinning, v.vPos, v.vBoneWeights, v.vBoneIndices, worldPos );
|
||||
float4 projPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
o.projPos = projPos;
|
||||
|
||||
o.zValue.x = (o.projPos.z - cDepthFactor.y) / cDepthFactor.x;
|
||||
o.zValue.y = (o.projPos.w - cDepthFactor.y) / cDepthFactor.x;
|
||||
|
||||
#ifdef _PS3
|
||||
// Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
|
||||
o.projPos.y = -o.projPos.y;
|
||||
o.projPos.z = 2.0f * o.projPos.z - o.projPos.w;
|
||||
#endif // _PS3
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
89
materialsystem/stdshaders/DebugDrawEnvmapMask.cpp
Normal file
89
materialsystem/stdshaders/DebugDrawEnvmapMask.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "debugdrawenvmapmask_vs20.inc"
|
||||
#include "debugdrawenvmapmask_ps20.inc"
|
||||
#include "debugdrawenvmapmask_ps20b.inc"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( DebugDrawEnvmapMask, "Help for DebugDrawEnvmapMask", SHADER_NOT_EDITABLE )
|
||||
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( SHOWALPHA, SHADER_PARAM_TYPE_INTEGER, "0", "" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING );
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
|
||||
// Set stream format (note that this shader supports compression)
|
||||
unsigned int flags = VERTEX_POSITION | VERTEX_FORMAT_COMPRESSED;
|
||||
int nTexCoordCount = 1;
|
||||
int userDataSize = 0;
|
||||
pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize );
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( debugdrawenvmapmask_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( debugdrawenvmapmask_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( debugdrawenvmapmask_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER( debugdrawenvmapmask_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( debugdrawenvmapmask_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER( debugdrawenvmapmask_ps20 );
|
||||
}
|
||||
}
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
int numBones = s_pShaderAPI->GetCurrentNumBones();
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( debugdrawenvmapmask_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, numBones > 0 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
|
||||
SET_DYNAMIC_VERTEX_SHADER( debugdrawenvmapmask_vs20 );
|
||||
|
||||
bool bShowAlpha = params[SHOWALPHA]->GetIntValue() ? true : false;
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( debugdrawenvmapmask_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( SHOWALPHA, bShowAlpha );
|
||||
SET_DYNAMIC_PIXEL_SHADER( debugdrawenvmapmask_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( debugdrawenvmapmask_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( SHOWALPHA, bShowAlpha );
|
||||
SET_DYNAMIC_PIXEL_SHADER( debugdrawenvmapmask_ps20 );
|
||||
}
|
||||
|
||||
BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, BASETEXTURE, FRAME );
|
||||
SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, BASETEXTURETRANSFORM );
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
24
materialsystem/stdshaders/DebugDrawEnvmapMask_ps2x.fxc
Normal file
24
materialsystem/stdshaders/DebugDrawEnvmapMask_ps2x.fxc
Normal file
@@ -0,0 +1,24 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// DYNAMIC: "SHOWALPHA" "0..1"
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler BaseTextureSampler : register( s0 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float2 baseTexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4_color_return_type main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4 baseColor = tex2D( BaseTextureSampler, i.baseTexCoord );
|
||||
#if SHOWALPHA
|
||||
float4 result = float4( baseColor.a, baseColor.a, baseColor.a, 1.0f );
|
||||
#else
|
||||
float4 result = float4( baseColor.rgb, 1.0f );
|
||||
#endif
|
||||
return FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
46
materialsystem/stdshaders/DebugDrawEnvmapMask_vs20.fxc
Normal file
46
materialsystem/stdshaders/DebugDrawEnvmapMask_vs20.fxc
Normal file
@@ -0,0 +1,46 @@
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
static const bool g_bSkinning = SKINNING ? true : false;
|
||||
|
||||
const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION;
|
||||
float4 vBoneWeights : BLENDWEIGHT;
|
||||
float4 vBoneIndices : BLENDINDICES;
|
||||
float4 vTexCoord0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float2 baseTexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
float3 worldPos;
|
||||
SkinPosition( g_bSkinning, v.vPos, v.vBoneWeights, v.vBoneIndices, worldPos );
|
||||
float4 projPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
o.projPos = projPos;
|
||||
o.baseTexCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] );
|
||||
o.baseTexCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] );
|
||||
|
||||
#ifdef _PS3
|
||||
// Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
|
||||
o.projPos.y = -o.projPos.y;
|
||||
o.projPos.z = 2.0f * o.projPos.z - o.projPos.w;
|
||||
#endif // _PS3
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
115
materialsystem/stdshaders/DebugTextureView.cpp
Normal file
115
materialsystem/stdshaders/DebugTextureView.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
//========= Copyright (c) 1996-2007, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "shaderlib/cshader.h"
|
||||
|
||||
#include "debugtextureview_vs20.inc"
|
||||
#include "debugtextureview_ps20.inc"
|
||||
#include "debugtextureview_ps20b.inc"
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
DEFINE_FALLBACK_SHADER( DebugTextureView, DebugTextureView_dx9 )
|
||||
BEGIN_VS_SHADER( DebugTextureView_dx9, "Help for DebugTextureView" )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( SHOWALPHA, SHADER_PARAM_TYPE_BOOL, "0", "" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if ( params[BASETEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableAlphaTest( true );
|
||||
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
|
||||
// Set stream format (note that this shader supports compression)
|
||||
unsigned int flags = VERTEX_POSITION | VERTEX_FORMAT_COMPRESSED;
|
||||
int nTexCoordCount = 1;
|
||||
int userDataSize = 0;
|
||||
pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize );
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( debugtextureview_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( debugtextureview_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( debugtextureview_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( SHOWALPHA, params[SHOWALPHA]->GetIntValue() != 0 );
|
||||
SET_STATIC_PIXEL_SHADER( debugtextureview_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( debugtextureview_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( SHOWALPHA, params[SHOWALPHA]->GetIntValue() != 0 );
|
||||
SET_STATIC_PIXEL_SHADER( debugtextureview_ps20 );
|
||||
}
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, BASETEXTURE, FRAME );
|
||||
//pShaderAPI->BindStandardTexture( SHADER_SAMPLER1, TEXTURE_LIGHTMAP );
|
||||
|
||||
ITexture *pTexture = params[BASETEXTURE]->GetTextureValue();
|
||||
|
||||
float cPsConst0[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
if ( ( pTexture->GetImageFormat() == IMAGE_FORMAT_RGBA16161616F ) ||
|
||||
( pTexture->GetImageFormat() == IMAGE_FORMAT_RGBA16161616 ) ||
|
||||
( pTexture->GetImageFormat() == IMAGE_FORMAT_RGB323232F ) ||
|
||||
( pTexture->GetImageFormat() == IMAGE_FORMAT_RGBA32323232F ) )
|
||||
{
|
||||
if ( pTexture->IsCubeMap() )
|
||||
cPsConst0[0] = 1.0f;
|
||||
else
|
||||
cPsConst0[1] = 1.0f;
|
||||
}
|
||||
|
||||
if ( pTexture->IsVolumeTexture() )
|
||||
{
|
||||
int nSlices = pTexture->GetMappingDepth();
|
||||
int nDesiredSlice = int( Plat_FloatTime() ) % nSlices;
|
||||
|
||||
cPsConst0[2] = float( nDesiredSlice * 2 + 1 ) / ( nSlices * 2 );
|
||||
}
|
||||
|
||||
pShaderAPI->SetPixelShaderConstant( 0, cPsConst0 );
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( debugtextureview_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
|
||||
SET_DYNAMIC_VERTEX_SHADER( debugtextureview_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( debugtextureview_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( ISCUBEMAP, pTexture->IsCubeMap() );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( ISVOLUME, pTexture->IsVolumeTexture() );
|
||||
SET_DYNAMIC_PIXEL_SHADER( debugtextureview_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( debugtextureview_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( ISCUBEMAP, pTexture->IsCubeMap() );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( ISVOLUME, pTexture->IsVolumeTexture() );
|
||||
SET_DYNAMIC_PIXEL_SHADER( debugtextureview_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
98
materialsystem/stdshaders/DebugTextureView_ps2x.fxc
Normal file
98
materialsystem/stdshaders/DebugTextureView_ps2x.fxc
Normal file
@@ -0,0 +1,98 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// STATIC: "SHOWALPHA" "0..1"
|
||||
// DYNAMIC: "ISCUBEMAP" "0..1"
|
||||
// DYNAMIC: "ISVOLUME" "0..1"
|
||||
|
||||
// SKIP: $ISCUBEMAP && $ISVOLUME
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
#if ISVOLUME
|
||||
sampler3D g_tSampler : register( s0 );
|
||||
#elif ISCUBEMAP
|
||||
samplerCUBE g_tSampler : register( s0 );
|
||||
#else // ISCUBEMAP
|
||||
sampler g_tSampler : register( s0 );
|
||||
#endif // !ISCUBEMAP
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
const float4 g_vConst0 : register( c0 );
|
||||
#define g_flIsHdrCube g_vConst0.x
|
||||
#define g_flIsHdr2D g_vConst0.y
|
||||
#define g_flSliceCoord g_vConst0.z
|
||||
|
||||
|
||||
float4_color_return_type main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4 result = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
#if !ISCUBEMAP
|
||||
|
||||
#if ISVOLUME
|
||||
float4 sample = tex3D( g_tSampler, float3( i.texCoord, g_flSliceCoord ) );
|
||||
#else
|
||||
float4 sample = tex2D( g_tSampler, i.texCoord );
|
||||
#endif
|
||||
|
||||
result.rgb = sample.rgb;
|
||||
#if SHOWALPHA
|
||||
result.rgb = sample.a;
|
||||
#endif
|
||||
|
||||
if ( g_flIsHdr2D )
|
||||
result.rgb *= MAX_HDR_OVERBRIGHT;
|
||||
|
||||
#else // ISCUBEMAP
|
||||
bool bNoDataForThisPixel = false;
|
||||
float3 vec = float3( 0, 0, 0 );
|
||||
float x = i.texCoord.x;
|
||||
float y = i.texCoord.y;
|
||||
float x2 = frac( ( i.texCoord.x ) * 3.0f ) * 2.0f - 1.0f;
|
||||
float y2 = frac( ( i.texCoord.y ) * 4.0f ) * 2.0f - 1.0f;
|
||||
if ( ( x >= 0.3333f ) && ( x <= 0.6666f ) ) //Center row
|
||||
{
|
||||
if ( y >= 0.75f )
|
||||
vec = float3( x2, 1.0, y2 );
|
||||
else if ( y >= 0.5f )
|
||||
vec = float3( x2, y2, -1.0 );
|
||||
else if ( y >= 0.25f )
|
||||
vec = float3( x2, -1.0, -y2 );
|
||||
else if ( y >= 0.0f )
|
||||
vec = float3( x2, -y2, 1.0 );
|
||||
}
|
||||
else if ( ( y >= 0.25f ) && ( y <= 0.5f ) )
|
||||
{
|
||||
if ( x <= 0.3333f )
|
||||
vec = float3( -1.0f, -x2, -y2 );
|
||||
else if (x >= 0.6666f)
|
||||
vec = float3( 1.0f, x2, -y2 );
|
||||
else
|
||||
bNoDataForThisPixel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bNoDataForThisPixel = true;
|
||||
}
|
||||
|
||||
float4 cBase = texCUBE( g_tSampler, vec );
|
||||
#if SHOWALPHA
|
||||
cBase.rgb = cBase.a;
|
||||
#endif
|
||||
|
||||
if ( g_flIsHdrCube )
|
||||
cBase.rgb *= ENV_MAP_SCALE;
|
||||
|
||||
if ( bNoDataForThisPixel == true )
|
||||
cBase.rgb = float3( 0.9f, 0.4f, 0.15f );
|
||||
|
||||
result.rgb = cBase.rgb;
|
||||
result.a = 1.0f; // - bNoDataForThisPixel;
|
||||
#endif // ISCUBEMAP
|
||||
|
||||
return FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
30
materialsystem/stdshaders/DebugTextureView_vs20.fxc
Normal file
30
materialsystem/stdshaders/DebugTextureView_vs20.fxc
Normal file
@@ -0,0 +1,30 @@
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION;
|
||||
float4 vTexCoord0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vUv0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT i )
|
||||
{
|
||||
VS_OUTPUT o;
|
||||
o.vProjPos.xyzw = mul( i.vPos.xyzw, cModelViewProj );
|
||||
o.vUv0.xy = i.vTexCoord0.xy;
|
||||
|
||||
#ifdef _PS3
|
||||
// Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
|
||||
o.vProjPos.y = -o.vProjPos.y;
|
||||
o.vProjPos.z = 2.0f * o.vProjPos.z - o.vProjPos.w;
|
||||
#endif // _PS3
|
||||
|
||||
return o;
|
||||
}
|
||||
245
materialsystem/stdshaders/DecalModulate_dx9.cpp
Normal file
245
materialsystem/stdshaders/DecalModulate_dx9.cpp
Normal file
@@ -0,0 +1,245 @@
|
||||
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Header: $
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "cpp_shader_constant_register_map.h"
|
||||
|
||||
#include "decalmodulate_vs20.inc"
|
||||
#include "decalmodulate_ps20.inc"
|
||||
#include "decalmodulate_ps20b.inc"
|
||||
|
||||
#if !defined( _X360 ) && !defined( _PS3 )
|
||||
#include "decalmodulate_vs30.inc"
|
||||
#include "decalmodulate_ps30.inc"
|
||||
#endif
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DEFINE_FALLBACK_SHADER( DecalModulate, DecalModulate_DX9 )
|
||||
|
||||
BEGIN_VS_SHADER( DecalModulate_dx9,
|
||||
"Help for DecalModulate_dx9" )
|
||||
|
||||
BEGIN_SHADER_PARAMS
|
||||
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" )
|
||||
SHADER_PARAM( FOGFADESTART, SHADER_PARAM_TYPE_FLOAT, "0", "fog amount at which to start fading decal" )
|
||||
SHADER_PARAM( FOGFADEEND, SHADER_PARAM_TYPE_FLOAT, "0", "fog amount at which to end fading decal" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
if( !params[ FOGEXPONENT ]->IsDefined() )
|
||||
{
|
||||
params[ FOGEXPONENT ]->SetFloatValue( 0.4f );
|
||||
}
|
||||
|
||||
if( !params[ FOGSCALE ]->IsDefined() )
|
||||
{
|
||||
params[ FOGSCALE ]->SetFloatValue( 1.0f );
|
||||
}
|
||||
|
||||
if( !params[ FOGFADESTART]->IsDefined() )
|
||||
{
|
||||
params[ FOGFADESTART ]->SetFloatValue( 0 );
|
||||
}
|
||||
if( !params[ FOGFADEEND ]->IsDefined() )
|
||||
{
|
||||
params[ FOGFADEEND ]->SetFloatValue( 0.0f );
|
||||
}
|
||||
|
||||
SET_FLAGS( MATERIAL_VAR_NO_DEBUG_OVERRIDE );
|
||||
|
||||
#if !defined( _X360 ) && !defined( _PS3 )
|
||||
if ( g_pHardwareConfig->HasFastVertexTextures() )
|
||||
{
|
||||
// The vertex shader uses the vertex id stream
|
||||
SET_FLAGS2( MATERIAL_VAR2_USES_VERTEXID );
|
||||
SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableAlphaTest( true );
|
||||
pShaderShadow->AlphaFunc( SHADER_ALPHAFUNC_GREATER, 0.0f );
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnablePolyOffset( SHADER_POLYOFFSET_DECAL );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
|
||||
// Be sure not to write to dest alpha
|
||||
pShaderShadow->EnableAlphaWrites( false );
|
||||
|
||||
// SRGB conversions hose the blend on some hardware, so keep we everything in gamma space
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, false );
|
||||
pShaderShadow->EnableSRGBWrite( false );
|
||||
|
||||
pShaderShadow->EnableBlending( true );
|
||||
pShaderShadow->BlendFunc( SHADER_BLEND_DST_COLOR, SHADER_BLEND_SRC_COLOR );
|
||||
pShaderShadow->DisableFogGammaCorrection( true ); //fog should stay exactly middle grey
|
||||
FogToGrey();
|
||||
|
||||
int nLightingPreviewMode = IS_FLAG2_SET( MATERIAL_VAR2_USE_GBUFFER0 ) + 2 * IS_FLAG2_SET( MATERIAL_VAR2_USE_GBUFFER1 );
|
||||
|
||||
bool bHasVertexAlpha = IS_FLAG_SET( MATERIAL_VAR_VERTEXCOLOR ) && IS_FLAG_SET( MATERIAL_VAR_VERTEXALPHA );
|
||||
|
||||
bool bHasFogFade = ( params[FOGFADEEND]->GetFloatValue() > 0.0f );
|
||||
|
||||
#if !defined( _X360 ) && !defined( _PS3 )
|
||||
if ( !g_pHardwareConfig->HasFastVertexTextures() )
|
||||
#endif
|
||||
{
|
||||
DECLARE_STATIC_VERTEX_SHADER( decalmodulate_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, bHasVertexAlpha );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( LIGHTING_PREVIEW, nLightingPreviewMode != 0 );
|
||||
SET_STATIC_VERTEX_SHADER( decalmodulate_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( decalmodulate_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( VERTEXALPHA, bHasVertexAlpha );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( FOGFADE, bHasFogFade );
|
||||
SET_STATIC_PIXEL_SHADER( decalmodulate_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( decalmodulate_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( VERTEXALPHA, bHasVertexAlpha );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( FOGFADE, bHasFogFade );
|
||||
SET_STATIC_PIXEL_SHADER( decalmodulate_ps20 );
|
||||
}
|
||||
}
|
||||
#if !defined( _X360 ) && !defined( _PS3 )
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_VERTEX_SHADER( decalmodulate_vs30 );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( VERTEXCOLOR, bHasVertexAlpha );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( LIGHTING_PREVIEW, nLightingPreviewMode != 0 );
|
||||
SET_STATIC_VERTEX_SHADER( decalmodulate_vs30 );
|
||||
|
||||
DECLARE_STATIC_PIXEL_SHADER( decalmodulate_ps30 );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( VERTEXALPHA, bHasVertexAlpha );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( FOGFADE, bHasFogFade );
|
||||
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;
|
||||
}
|
||||
|
||||
#if !defined( _X360 ) && !defined( _PS3 )
|
||||
// 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;
|
||||
|
||||
#if !defined( _X360 ) && !defined( _PS3 )
|
||||
if ( g_pHardwareConfig->HasFastVertexTextures() )
|
||||
{
|
||||
nTexCoordCount = 3;
|
||||
}
|
||||
#endif
|
||||
|
||||
pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, pTexCoordDim, userDataSize );
|
||||
}
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
if ( pShaderAPI->InFlashlightMode() && !( IsX360() || IsPS3() ) )
|
||||
{
|
||||
// Don't draw anything for the flashlight pass
|
||||
Draw( false );
|
||||
return;
|
||||
}
|
||||
|
||||
BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, BASETEXTURE, FRAME );
|
||||
|
||||
// Set an identity base texture transformation
|
||||
Vector4D transformation[2];
|
||||
transformation[0].Init( 1.0f, 0.0f, 0.0f, 0.0f );
|
||||
transformation[1].Init( 0.0f, 1.0f, 0.0f, 0.0f );
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, transformation[0].Base(), 2 );
|
||||
|
||||
pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS );
|
||||
|
||||
float vEyePos_SpecExponent[4];
|
||||
pShaderAPI->GetWorldSpaceCameraPosition( vEyePos_SpecExponent );
|
||||
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();
|
||||
fConsts[2] = params[ FOGFADESTART ]->GetFloatValue();
|
||||
fConsts[3] = params[ FOGFADEEND ]->GetFloatValue();
|
||||
pShaderAPI->SetPixelShaderConstant( 0, fConsts );
|
||||
|
||||
#if !defined( _X360 ) && !defined( _PS3 )
|
||||
if ( !g_pHardwareConfig->HasFastVertexTextures() )
|
||||
#endif
|
||||
{
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( decalmodulate_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, 0 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
|
||||
// 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( decalmodulate_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( decalmodulate_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( decalmodulate_ps20 );
|
||||
}
|
||||
}
|
||||
#if !defined( _X360 ) && !defined( _PS3 )
|
||||
else
|
||||
{
|
||||
SetHWMorphVertexShaderState( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, SHADER_VERTEXTEXTURE_SAMPLER0 );
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( decalmodulate_vs30 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
|
||||
// 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( decalmodulate_ps30 );
|
||||
|
||||
bool bUnusedTexCoords[3] = { false, false, !pShaderAPI->IsHWMorphingEnabled() };
|
||||
pShaderAPI->MarkUnusedVertexFields( 0, 3, bUnusedTexCoords );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Draw( );
|
||||
}
|
||||
END_SHADER
|
||||
280
materialsystem/stdshaders/DepthOfField_dx9.cpp
Normal file
280
materialsystem/stdshaders/DepthOfField_dx9.cpp
Normal file
@@ -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", "10" );
|
||||
ConVar mat_dof_quality( "mat_dof_quality", "0" );
|
||||
|
||||
// 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, TEXTURE_BINDFLAGS_NONE, BASETEXTURE );
|
||||
BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, 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 qulity 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();
|
||||
|
||||
// 8192 is the magic number for HDR mode 3 (see FLOAT_RENDERPARM_DEST_ALPHA_DEPTH_SCALE in shaderapidx8.cpp)
|
||||
vConst[10] = 8192.0f * ( 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<float>( pTex->GetActualWidth() );
|
||||
float flInvTexHeight = 1.0f / static_cast<float>( 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
|
||||
107
materialsystem/stdshaders/Downsample.cpp
Normal file
107
materialsystem/stdshaders/Downsample.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "common_hlsl_cpp_consts.h"
|
||||
|
||||
#include "Downsample_ps20.inc"
|
||||
#include "Downsample_ps20b.inc"
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( Downsample, "Help for Downsample", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
bool bForceSRGBReadAndWrite = false;
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
|
||||
// Render targets are pegged as sRGB on togl OSX, so just force these reads and writes
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, bForceSRGBReadAndWrite );
|
||||
pShaderShadow->EnableSRGBWrite( bForceSRGBReadAndWrite );
|
||||
|
||||
int fmt = VERTEX_POSITION;
|
||||
pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
|
||||
|
||||
pShaderShadow->SetVertexShader( "Downsample_vs20", 0 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( downsample_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER( downsample_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( downsample_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER( downsample_ps20 );
|
||||
}
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, bForceSRGBReadAndWrite ? TEXTURE_BINDFLAGS_SRGBREAD : TEXTURE_BINDFLAGS_NONE, BASETEXTURE, -1 );
|
||||
|
||||
int width, height;
|
||||
pShaderAPI->GetBackBufferDimensions( width, height );
|
||||
|
||||
float v[4];
|
||||
float dX = 1.0f / width;
|
||||
float dY = 1.0f / height;
|
||||
|
||||
v[0] = -dX;
|
||||
v[1] = -dY;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, v, 1 );
|
||||
v[0] = -dX;
|
||||
v[1] = dY;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, v, 1 );
|
||||
v[0] = dX;
|
||||
v[1] = -dY;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, v, 1 );
|
||||
v[0] = dX;
|
||||
v[1] = dY;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_3, v, 1 );
|
||||
|
||||
// Setup luminance threshold (all values are scaled down by max luminance)
|
||||
// v[0] = 1.0f / MAX_HDR_OVERBRIGHT;
|
||||
v[0] = 0.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( 0, v, 1 );
|
||||
|
||||
pShaderAPI->SetVertexShaderIndex( 0 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( downsample_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( downsample_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( downsample_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( downsample_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
89
materialsystem/stdshaders/Downsample_nohdr_ps2x.fxc
Normal file
89
materialsystem/stdshaders/Downsample_nohdr_ps2x.fxc
Normal file
@@ -0,0 +1,89 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// STATIC: "BLOOMTYPE" "0..1"
|
||||
// STATIC: "PS3REGCOUNT48" "0..0"
|
||||
// STATIC: "SRGB_INPUT_ADAPTER" "0..1" [ps20b] [PC]
|
||||
// STATIC: "SRGB_INPUT_ADAPTER" "0..0" [CONSOLE]
|
||||
|
||||
// DYNAMIC: "FLOAT_BACK_BUFFER" "0..1" [ps20b] [ps30] [PC]
|
||||
// DYNAMIC: "FLOAT_BACK_BUFFER" "0..0" [ps20b] [CONSOLE]
|
||||
|
||||
// SKIP: ( $FLOAT_BACK_BUFFER == 1 ) && ( $SRGB_INPUT_ADAPTER == 1 )
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler TexSampler : register( s0 );
|
||||
float4 params : register( c0 );
|
||||
float4 params2 : register( c1 );
|
||||
#define g_flBloomExp params2.x
|
||||
#define g_flBloomSaturation params2.y
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 coordTap0 : TEXCOORD0;
|
||||
float2 coordTap1 : TEXCOORD1;
|
||||
float2 coordTap2 : TEXCOORD2;
|
||||
float2 coordTap3 : TEXCOORD3;
|
||||
};
|
||||
|
||||
float4 Shape( float4 cColor )
|
||||
{
|
||||
#if ( BLOOMTYPE == 0 )
|
||||
{
|
||||
float flLum = dot( cColor.xyz, params.xyz );
|
||||
cColor.rgb = pow( cColor.xyz, params.w ) * flLum;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ( BLOOMTYPE == 1 )
|
||||
{
|
||||
float flScale = 1.55f; // Color scale
|
||||
float flBias = -0.09f; // Color bias
|
||||
float flBrightnessClamp = 0.59f; // After scale and bias, clamp RGB values brighter than this
|
||||
float flExp = g_flBloomExp;
|
||||
cColor.rgb = pow( saturate( min( flBrightnessClamp, ( cColor.rgb * flScale ) + flBias ) ), flExp );
|
||||
}
|
||||
#endif
|
||||
|
||||
return cColor;
|
||||
}
|
||||
|
||||
float4_color_return_type main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
// Sample 4 taps
|
||||
float4 s0 = tex2D( TexSampler, i.coordTap0 );
|
||||
float4 s1 = tex2D( TexSampler, i.coordTap1 );
|
||||
float4 s2 = tex2D( TexSampler, i.coordTap2 );
|
||||
float4 s3 = tex2D( TexSampler, i.coordTap3 );
|
||||
|
||||
#if ( ( SRGB_INPUT_ADAPTER == 1 ) || ( FLOAT_BACK_BUFFER == 1 ) )
|
||||
{
|
||||
s0.rgb = SrgbLinearToGamma( saturate( s0.rgb ) );
|
||||
s1.rgb = SrgbLinearToGamma( saturate( s1.rgb ) );
|
||||
s2.rgb = SrgbLinearToGamma( saturate( s2.rgb ) );
|
||||
s3.rgb = SrgbLinearToGamma( saturate( s3.rgb ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
float4 avgColor = ( s0 + s1 + s2 + s3 ) * 0.25f;
|
||||
|
||||
float fAvgLuminance = dot( avgColor.rgb, float3( 0.299, 0.587, 0.114 ) );
|
||||
avgColor = Shape( avgColor );
|
||||
|
||||
// Saturation
|
||||
#if ( BLOOMTYPE == 1 )
|
||||
{
|
||||
avgColor.rgb = lerp( dot( params.rgb, avgColor.rgb ), avgColor.rgb, g_flBloomSaturation );
|
||||
}
|
||||
#endif
|
||||
|
||||
avgColor.a = fAvgLuminance;
|
||||
|
||||
#if ( SRGB_INPUT_ADAPTER == 1 )
|
||||
{
|
||||
avgColor.rgb = SrgbGammaToLinear( saturate( avgColor.rgb ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
return FinalOutput( avgColor, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
30
materialsystem/stdshaders/Downsample_ps2x.fxc
Normal file
30
materialsystem/stdshaders/Downsample_ps2x.fxc
Normal file
@@ -0,0 +1,30 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler TexSampler : register( s0 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 coordTap0 : TEXCOORD0;
|
||||
float2 coordTap1 : TEXCOORD1;
|
||||
float2 coordTap2 : TEXCOORD2;
|
||||
float2 coordTap3 : TEXCOORD3;
|
||||
};
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4 s0, s1, s2, s3;
|
||||
|
||||
// Sample 4 taps
|
||||
s0 = tex2D( TexSampler, i.coordTap0 );
|
||||
s1 = tex2D( TexSampler, i.coordTap1 );
|
||||
s2 = tex2D( TexSampler, i.coordTap2 );
|
||||
s3 = tex2D( TexSampler, i.coordTap3 );
|
||||
|
||||
// store grayscale version of buffer in alpha
|
||||
float4 vResult = ( s0 + s1 + s2 + s3 ) * 0.25f;
|
||||
vResult.a = dot( float3( 0.3f, 0.59f, 0.11f ), vResult.rgb );
|
||||
|
||||
return vResult;
|
||||
}
|
||||
40
materialsystem/stdshaders/Downsample_vs20.fxc
Normal file
40
materialsystem/stdshaders/Downsample_vs20.fxc
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vBaseTexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float2 coordTap0 : TEXCOORD0;
|
||||
float2 coordTap1 : TEXCOORD1;
|
||||
float2 coordTap2 : TEXCOORD2;
|
||||
float2 coordTap3 : TEXCOORD3;
|
||||
};
|
||||
|
||||
float2 vsTapOffs[4] : register ( SHADER_SPECIFIC_CONST_0 );
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
o.projPos = float4( v.vPos, 1.0f );
|
||||
|
||||
#ifdef _PS3
|
||||
// Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
|
||||
o.projPos.y = -o.projPos.y;
|
||||
o.projPos.z = 2.0f * o.projPos.z - o.projPos.w;
|
||||
#endif // _PS3
|
||||
|
||||
o.coordTap0 = v.vBaseTexCoord + vsTapOffs[0];
|
||||
o.coordTap1 = v.vBaseTexCoord + vsTapOffs[1];
|
||||
o.coordTap2 = v.vBaseTexCoord + vsTapOffs[2];
|
||||
o.coordTap3 = v.vBaseTexCoord + vsTapOffs[3];
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
825
materialsystem/stdshaders/Engine_Post_dx9.cpp
Normal file
825
materialsystem/stdshaders/Engine_Post_dx9.cpp
Normal file
@@ -0,0 +1,825 @@
|
||||
//========= Copyright (c) 1996-2007, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
|
||||
#if !defined( _GAMECONSOLE )
|
||||
#include "engine_post_vs30.inc"
|
||||
#include "engine_post_ps30.inc"
|
||||
#endif
|
||||
|
||||
#include "engine_post_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", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
|
||||
ConVar mat_depth_blur_focal_distance_override( "mat_depth_blur_focal_distance_override", "-1.0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
|
||||
ConVar mat_depth_blur_strength_override( "mat_depth_blur_strength_override", "-1.0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
|
||||
ConVar mat_grain_scale_override( "mat_grain_scale_override", "-1.0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
|
||||
ConVar mat_local_contrast_scale_override( "mat_local_contrast_scale_override", "0.0", FCVAR_CHEAT );
|
||||
ConVar mat_local_contrast_midtone_mask_override( "mat_local_contrast_midtone_mask_override", "-1.0", FCVAR_CHEAT );
|
||||
ConVar mat_local_contrast_vignette_start_override( "mat_local_contrast_vignette_start_override", "-1.0", FCVAR_CHEAT );
|
||||
ConVar mat_local_contrast_vignette_end_override( "mat_local_contrast_vignette_end_override", "-1.0", FCVAR_CHEAT );
|
||||
ConVar mat_local_contrast_edge_scale_override( "mat_local_contrast_edge_scale_override", "-1000.0", FCVAR_CHEAT );
|
||||
ConVar mat_vignette_enable( "mat_vignette_enable", "1", FCVAR_REPLICATED );
|
||||
ConVar mat_noise_enable( "mat_noise_enable", "0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
|
||||
|
||||
|
||||
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 )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( FBTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_FullFrameFB", "Full framebuffer texture" )
|
||||
SHADER_PARAM( AAENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable software anti-aliasing" )
|
||||
SHADER_PARAM( FXAAINTERNALC, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "Internal fxaa Console values set via material proxy" )
|
||||
SHADER_PARAM( FXAAINTERNALQ, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "Internal fxaa Quality values set via material proxy" )
|
||||
SHADER_PARAM( AAINTERNAL1, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "Internal anti-aliasing values set via material proxy" )
|
||||
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[ INTERNAL_VIGNETTETEXTURE ]->IsDefined() )
|
||||
{
|
||||
params[ INTERNAL_VIGNETTETEXTURE ]->SetStringValue( "dev/vignette" );
|
||||
}
|
||||
if ( !params[ AAENABLE ]->IsDefined() )
|
||||
{
|
||||
params[ AAENABLE ]->SetIntValue( 0 );
|
||||
}
|
||||
if ( !params[ FXAAINTERNALC ]->IsDefined() )
|
||||
{
|
||||
params[ FXAAINTERNALC ]->SetVecValue( 0, 0, 0, 0 );
|
||||
}
|
||||
if ( !params[ FXAAINTERNALQ ]->IsDefined() )
|
||||
{
|
||||
params[ FXAAINTERNALQ ]->SetVecValue( 0, 0, 0, 0 );
|
||||
}
|
||||
if ( !params[ AAINTERNAL1 ]->IsDefined() )
|
||||
{
|
||||
params[ AAINTERNAL1 ]->SetVecValue( 0, 0, 0, 0 );
|
||||
}
|
||||
if ( !params[ AAINTERNAL2 ]->IsDefined() )
|
||||
{
|
||||
params[ AAINTERNAL2 ]->SetVecValue( 0, 0, 0, 0 );
|
||||
}
|
||||
if ( !params[ AAINTERNAL3 ]->IsDefined() )
|
||||
{
|
||||
params[ AAINTERNAL3 ]->SetVecValue( 0, 0, 0, 0 );
|
||||
}
|
||||
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 );
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
// This shader should not be *used* unless we're >= DX9 (bloomadd.vmt/screenspace_general_dx8 should be used for DX8)
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if ( params[BASETEXTURE]->IsDefined() )
|
||||
{
|
||||
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 bSFM = ( ToolsEnabled() && IsPlatformWindowsPC() && g_pHardwareConfig->SupportsPixelShaders_3_0() ) ? true : false;
|
||||
bSFM;
|
||||
bool bToolMode = params[TOOLMODE]->GetIntValue() != 0;
|
||||
bool bDepthBlurEnable = params[ DEPTHBLURENABLE ]->GetIntValue() != 0;
|
||||
bool bForceSRGBReadsAndWrites = false;
|
||||
|
||||
SHADOW_STATE
|
||||
{
|
||||
// This shader uses opaque blending, but needs to match the behaviour of bloom_add/screen_spacegeneral,
|
||||
// which uses additive blending (and is used when bloom is enabled but col-correction and AA are not).
|
||||
// BUT!
|
||||
// Hardware sRGB blending is incorrect (on pre-DX10 cards, sRGB values are added directly).
|
||||
// SO...
|
||||
// When doing the bloom addition in the pixel shader, we need to emulate that incorrect
|
||||
// behaviour - by turning sRGB read OFF for the FB texture and by turning sRGB write OFF
|
||||
// (which is fine, since the AA process works better on an sRGB framebuffer than a linear
|
||||
// one; gamma colours more closely match luminance perception. The color-correction process
|
||||
// has always taken gamma-space values as input anyway).
|
||||
|
||||
// On OpenGL, 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 = false;
|
||||
bool bLinearOutput = false;
|
||||
|
||||
|
||||
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 );
|
||||
|
||||
// The (sRGB) full framebuffer texture is bound to sampler 1:
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, bForceSRGBReadsAndWrites );
|
||||
|
||||
// Up to 4 (sRGB) color-correction lookup textures are bound to samplers 2-5:
|
||||
int nLookupCount = MIN( (int) params[NUM_LOOKUPS]->GetFloatValue(), 3 );
|
||||
for( int i = 0 ; i < nLookupCount; i++ )
|
||||
{
|
||||
pShaderShadow->EnableTexture( ( Sampler_t ) ( SHADER_SAMPLER2 + i ), true );
|
||||
pShaderShadow->EnableSRGBRead( ( Sampler_t ) ( SHADER_SAMPLER2 + i ), 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 );
|
||||
|
||||
int format = VERTEX_POSITION;
|
||||
int numTexCoords = 1;
|
||||
int * pTexCoordDimensions = NULL;
|
||||
int userDataSize = 0;
|
||||
pShaderShadow->VertexShaderVertexFormat( format, numTexCoords, pTexCoordDimensions, userDataSize );
|
||||
|
||||
#if !defined( _GAMECONSOLE )
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_3_0() )
|
||||
{
|
||||
DECLARE_STATIC_VERTEX_SHADER( engine_post_vs30 );
|
||||
SET_STATIC_VERTEX_SHADER( engine_post_vs30 );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
DECLARE_STATIC_VERTEX_SHADER( engine_post_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( engine_post_vs20 );
|
||||
}
|
||||
|
||||
#if !defined( _GAMECONSOLE )
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_3_0() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( engine_post_ps30 );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( TOOL_MODE, bToolMode );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( DEPTH_BLUR_ENABLE, bDepthBlurEnable );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( LINEAR_INPUT, bLinearInput );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( LINEAR_OUTPUT, bLinearOutput );
|
||||
SET_STATIC_PIXEL_SHADER( engine_post_ps30 );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
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_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_COMBO( TOOL_MODE, bToolMode );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( DEPTH_BLUR_ENABLE, bDepthBlurEnable );
|
||||
SET_STATIC_PIXEL_SHADER( engine_post_ps20 );
|
||||
}
|
||||
}
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, bForceSRGBReadsAndWrites ? TEXTURE_BINDFLAGS_SRGBREAD : TEXTURE_BINDFLAGS_NONE, 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, bForceSRGBReadsAndWrites ? TEXTURE_BINDFLAGS_SRGBREAD : TEXTURE_BINDFLAGS_NONE, FBTEXTURE, -1 );
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
// ps20b has a desaturation control that overrides color correction, only used by the SFM (tools mode on Windows)
|
||||
bool bDesaturateEnable = bToolMode && ( params[DESATURATEENABLE]->GetIntValue() != 0 ) && g_pHardwareConfig->SupportsPixelShaders_2_b() && IsPlatformWindows();
|
||||
|
||||
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 )
|
||||
{
|
||||
float vPsConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
vPsConst[0] = params[DESATURATION]->GetFloatValue();
|
||||
pShaderAPI->SetPixelShaderConstant( 16, vPsConst, 1 );
|
||||
}
|
||||
else // 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 );
|
||||
if ( colCorrectNumLookups )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < colCorrectNumLookups; i++ )
|
||||
{
|
||||
StandardTextureId_t id = (StandardTextureId_t)(TEXTURE_COLOR_CORRECTION_VOLUME_0 + i);
|
||||
|
||||
bool bIsTextureValid = pShaderAPI->IsStandardTextureHandleValid( id );
|
||||
if ( !bIsTextureValid )
|
||||
{
|
||||
// Texture isn't valid - give up now (and set the COL_CORRECT_NUM_LOOKUPS combo appropriately) otherwise GL mode will be unhappy
|
||||
break;
|
||||
}
|
||||
|
||||
pShaderAPI->BindStandardTexture( (Sampler_t)(SHADER_SAMPLER2 + i), TEXTURE_BINDFLAGS_NONE, id );
|
||||
}
|
||||
colCorrectNumLookups = i;
|
||||
}
|
||||
|
||||
// Upload 1-pixel X&Y offsets [ (+dX,0,+dY,-dX) is chosen to work with the allowed ps20 swizzles ]
|
||||
// The shader will sample in a cross (up/down/left/right from the current sample), for 5-tap
|
||||
// (quality 0) mode and add another 4 samples in a diagonal cross, for 9-tap (quality 1) mode
|
||||
ITexture * pTarget = params[FBTEXTURE]->GetTextureValue();
|
||||
int width = pTarget->GetActualWidth();
|
||||
int height = pTarget->GetActualHeight();
|
||||
float dX = 1.0f / width;
|
||||
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)
|
||||
// z - edge threshold multiplier (default 1.0, < 1.0 => more edges softened, > 1.0 => fewer edges softened)
|
||||
// w - tap offset multiplier (default 1.0, < 1.0 => sharper image, > 1.0 => blurrier image)
|
||||
float tweakables[4] = { params[ AAINTERNAL1 ]->GetVecValue()[0],
|
||||
params[ AAINTERNAL1 ]->GetVecValue()[1],
|
||||
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)
|
||||
float uvTrans[4] = { params[ AAINTERNAL2 ]->GetVecValue()[0],
|
||||
params[ AAINTERNAL2 ]->GetVecValue()[1],
|
||||
params[ AAINTERNAL2 ]->GetVecValue()[2],
|
||||
params[ AAINTERNAL2 ]->GetVecValue()[3] };
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, &uvTrans[0], 1 );
|
||||
|
||||
|
||||
// Upload FXAA constants
|
||||
// ensure indexes match those in engine_post_ps2x.fxc
|
||||
// refer to fxaa3_11_fxc.h for parameter documentation
|
||||
|
||||
//
|
||||
// FXAA Console
|
||||
//
|
||||
|
||||
float uvTrans_UpperLeftLowerRight[4] = { -0.5f*dX, -0.5f*dY, 0.5f*dX, 0.5f*dY };
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, &uvTrans_UpperLeftLowerRight[0], 1 );
|
||||
|
||||
float N = params[ FXAAINTERNALC ]->GetVecValue()[0];
|
||||
float fxaaConsoleRcpFrameOpt[4] = { -N*dX, -N*dY, N*dX, N*dY };
|
||||
pShaderAPI->SetPixelShaderConstant( 17, &fxaaConsoleRcpFrameOpt[0], 1 );
|
||||
|
||||
float fxaaConsoleRcpFrameOpt2[4] = { -2.0f*dX, -2.0f*dY, 2.0f*dX, 2.0f*dY };
|
||||
pShaderAPI->SetPixelShaderConstant( 18, &fxaaConsoleRcpFrameOpt2[0], 1 );
|
||||
|
||||
float fxaaConsole360RcpFrameOpt2[4] = { 8.0f*dX, 8.0f*dY, -4.0f*dX, -4.0f*dY };
|
||||
pShaderAPI->SetPixelShaderConstant( 19, &fxaaConsole360RcpFrameOpt2[0], 1 );
|
||||
|
||||
float fxaaConsoleEdge[4] = { 0.0f,
|
||||
params[ FXAAINTERNALC ]->GetVecValue()[1],
|
||||
params[ FXAAINTERNALC ]->GetVecValue()[2],
|
||||
params[ FXAAINTERNALC ]->GetVecValue()[3] };
|
||||
pShaderAPI->SetPixelShaderConstant( 20, &fxaaConsoleEdge[0], 1 );
|
||||
|
||||
float fxaaConsole360ConstDir[4] = { 1.0f, -1.0f, 0.25f, -0.25f };
|
||||
pShaderAPI->SetPixelShaderConstant( 21, &fxaaConsole360ConstDir[0], 1 );
|
||||
|
||||
//
|
||||
// FXAA Quality
|
||||
//
|
||||
|
||||
float fxaaQualityRcpFrame[4] = { dX, dY, 0.5f*dX, 0.5f*dY };
|
||||
pShaderAPI->SetPixelShaderConstant( 22, &fxaaQualityRcpFrame[0], 1 );
|
||||
|
||||
float fxaaQualitySubpixEdge[4] = { params[ FXAAINTERNALQ ]->GetVecValue()[0],
|
||||
params[ FXAAINTERNALQ ]->GetVecValue()[1],
|
||||
params[ FXAAINTERNALQ ]->GetVecValue()[2],
|
||||
params[ FXAAINTERNALQ ]->GetVecValue()[3] };
|
||||
pShaderAPI->SetPixelShaderConstant( 23, &fxaaQualitySubpixEdge[0], 1 );
|
||||
|
||||
|
||||
// Upload color-correction weights:
|
||||
pShaderAPI->SetPixelShaderConstant( 3, &ccInfo.m_flDefaultWeight );
|
||||
pShaderAPI->SetPixelShaderConstant( 4, ccInfo.m_pLookupWeights );
|
||||
|
||||
int aaEnabled = false;
|
||||
if ( IsGameConsole() || ( g_pHardwareConfig->SupportsPixelShaders_3_0() && !bSFM ) )
|
||||
{
|
||||
aaEnabled = ( params[ AAINTERNAL1 ]->GetVecValue()[0] != 0.0f ) ? 1 : 0;
|
||||
}
|
||||
|
||||
int bloomEnabled = ( params[ BLOOMENABLE ]->GetIntValue() == 0 ) ? 0 : 1;
|
||||
int colCorrectEnabled = ccInfo.m_bIsEnabled;
|
||||
|
||||
float flBloomFactor = bloomEnabled ? 1.0f : 0.0f;
|
||||
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();
|
||||
}
|
||||
#ifdef _X360
|
||||
bloomConstant[3] = 0.0f; // Depth blur is currently broken on X360 because we're not writing out the depth scale properly
|
||||
#else // !_X360
|
||||
if ( mat_depth_blur_strength_override.GetFloat() >= 0.0f )
|
||||
{
|
||||
bloomConstant[3] = mat_depth_blur_strength_override.GetFloat();
|
||||
}
|
||||
#endif // _X360
|
||||
|
||||
pShaderAPI->SetPixelShaderConstant( 5, bloomConstant );
|
||||
|
||||
// Vignette
|
||||
bool bVignetteEnable = false;
|
||||
if ( mat_vignette_enable.GetInt() )
|
||||
{
|
||||
bVignetteEnable = ( params[ VIGNETTEENABLE ]->GetIntValue() != 0 ) && ( params[ ALLOWVIGNETTE ]->GetIntValue() != 0 );
|
||||
}
|
||||
if ( bVignetteEnable )
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER7, TEXTURE_BINDFLAGS_NONE, INTERNAL_VIGNETTETEXTURE );
|
||||
}
|
||||
|
||||
// Noise
|
||||
bool bNoiseEnable = false;
|
||||
if ( mat_noise_enable.GetInt() )
|
||||
{
|
||||
bNoiseEnable = false; //( params[ NOISEENABLE ]->GetIntValue() != 0 ) && ( params[ ALLOWNOISE ]->GetIntValue() != 0 );
|
||||
}
|
||||
|
||||
int nFbTextureHeight = params[FBTEXTURE]->GetTextureValue()->GetActualHeight();
|
||||
if ( nFbTextureHeight < 720 )
|
||||
{
|
||||
// Disable noise at low resolutions
|
||||
bNoiseEnable = false;
|
||||
}
|
||||
|
||||
// Be even more draconian about disabling noise at low resolutions on Mac
|
||||
if ( ( nFbTextureHeight < 1024 ) )
|
||||
{
|
||||
bNoiseEnable = false;
|
||||
}
|
||||
|
||||
if ( bNoiseEnable )
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER6, TEXTURE_BINDFLAGS_NONE, 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 ( IsX360() )
|
||||
{
|
||||
vPsConst6[0] *= 0.15f;
|
||||
}
|
||||
|
||||
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 bFadeToBlackEnable = vPsConst[0] > 0.0f;
|
||||
|
||||
bool bVomitEnable = false; //( params[ VOMITENABLE ]->GetIntValue() != 0 );
|
||||
if ( bVomitEnable )
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER8, TEXTURE_BINDFLAGS_NONE, 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
|
||||
int nViewportX, nViewportY, nViewportWidth, nViewportHeight;
|
||||
pShaderAPI->GetCurrentViewport( nViewportX, nViewportY, nViewportWidth, nViewportHeight );
|
||||
|
||||
int nRtWidth, nRtHeight;
|
||||
pShaderAPI->GetCurrentRenderTargetDimensions( 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;
|
||||
}
|
||||
|
||||
bool bConvertFromLinear = bToolMode && ( 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 );
|
||||
|
||||
int nFadeType = clamp( params[FADE]->GetIntValue(), 0, 2 );
|
||||
|
||||
#if !defined( _GAMECONSOLE )
|
||||
if ( g_pHardwareConfig->SupportsPixelShaders_3_0() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( engine_post_ps30 );
|
||||
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 ); // Always zero in Portal 2
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( VIGNETTE_ENABLE, bVignetteEnable ); // Always zero in Portal 2
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( LOCAL_CONTRAST_ENABLE, bLocalContrastEnable ); // Always zero in Portal 2
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( BLURRED_VIGNETTE_ENABLE, bBlurredVignetteEnable ); // Always zero in Portal 2
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( VOMIT_ENABLE, bVomitEnable );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( FADE_TO_BLACK, bFadeToBlackEnable );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( FADE_TYPE, nFadeType );
|
||||
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_ps30 );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if ( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
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 ); // Always zero in Portal 2
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( VIGNETTE_ENABLE, bVignetteEnable ); // Always zero in Portal 2
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( LOCAL_CONTRAST_ENABLE, bLocalContrastEnable ); // Always zero in Portal 2
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( BLURRED_VIGNETTE_ENABLE, bBlurredVignetteEnable ); // Always zero in Portal 2
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( VOMIT_ENABLE, bVomitEnable );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( FADE_TO_BLACK, bFadeToBlackEnable );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( FADE_TYPE, nFadeType );
|
||||
#if !defined( _X360 ) && !defined( _PS3 )
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( TV_GAMMA, params[TV_GAMMA]->GetIntValue() && bToolMode ? 1 : 0 );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( DESATURATEENABLE, bDesaturateEnable );
|
||||
#endif
|
||||
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( COL_CORRECT_NUM_LOOKUPS, colCorrectNumLookups );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( VOMIT_ENABLE, bVomitEnable );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( FADE_TO_BLACK, bFadeToBlackEnable );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( FADE_TYPE, nFadeType );
|
||||
SET_DYNAMIC_PIXEL_SHADER( engine_post_ps20 );
|
||||
}
|
||||
|
||||
#if !defined( _GAMECONSOLE )
|
||||
if ( g_pHardwareConfig->SupportsPixelShaders_3_0() )
|
||||
{
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( engine_post_vs30 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( engine_post_vs30 );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( engine_post_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( engine_post_vs20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
569
materialsystem/stdshaders/Engine_Post_ps2x.fxc
Normal file
569
materialsystem/stdshaders/Engine_Post_ps2x.fxc
Normal file
@@ -0,0 +1,569 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// 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"
|
||||
// STATIC: "LINEAR_INPUT" "0..1" [ps20b] [ps30] [PC]
|
||||
// STATIC: "LINEAR_INPUT" "0..0" [ps20b] [CONSOLE]
|
||||
// STATIC: "LINEAR_OUTPUT" "0..1" [ps20b] [ps30] [PC]
|
||||
// STATIC: "LINEAR_OUTPUT" "0..0" [ps20b] [CONSOLE]
|
||||
|
||||
// DYNAMIC: "AA_ENABLE" "0..0" [ps20] [ps20b] [PC]
|
||||
// DYNAMIC: "AA_ENABLE" "0..1" [ps30] [PC]
|
||||
// DYNAMIC: "AA_ENABLE" "0..1" [CONSOLE]
|
||||
|
||||
// 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] [CONSOLE]
|
||||
// DYNAMIC: "CONVERT_TO_LINEAR" "0..0" [ps20b] [CONSOLE]
|
||||
// SKIP: ( $CONVERT_FROM_LINEAR == 0 ) && ( $CONVERT_TO_LINEAR == 1 )
|
||||
// SKIP: ( $TOOL_MODE == 0 ) && ( $CONVERT_FROM_LINEAR == 1 )
|
||||
// SKIP: ( $TOOL_MODE == 0 ) && ( $CONVERT_TO_LINEAR == 1 )
|
||||
|
||||
// These are similar but mutually exclusive, the former for SFM PC and the latter for Mac
|
||||
// SKIP: ( $CONVERT_FROM_LINEAR == 1 ) && ( $LINEAR_INPUT == 1 )
|
||||
// SKIP: ( $CONVERT_TO_LINEAR == 1 ) && ( $LINEAR_OUTPUT == 1 )
|
||||
|
||||
// DYNAMIC: "FADE_TO_BLACK" "0..1"
|
||||
// DYNAMIC: "FADE_TYPE" "0..2"
|
||||
|
||||
// These two are enabled for PC, but only used in special cases
|
||||
// DYNAMIC: "NOISE_ENABLE" "0..0" [ps20b] [ps30] [PC]
|
||||
// DYNAMIC: "VIGNETTE_ENABLE" "0..1" [ps20b] [ps30] [PC]
|
||||
// DYNAMIC: "NOISE_ENABLE" "0..0" [ps20b] [CONSOLE]
|
||||
// DYNAMIC: "VIGNETTE_ENABLE" "0..1" [ps20b] [CONSOLE]
|
||||
|
||||
// None of these effects are utilized by Portal 2, so they're always zero:
|
||||
// DYNAMIC: "LOCAL_CONTRAST_ENABLE" "0..1" [ps20b] [ps30]
|
||||
// DYNAMIC: "BLURRED_VIGNETTE_ENABLE" "0..1" [ps20b] [ps30]
|
||||
|
||||
// DYNAMIC: "VOMIT_ENABLE" "0..0"
|
||||
// SKIP: ( $LOCAL_CONTRAST_ENABLE == 0 ) && ( $BLURRED_VIGNETTE_ENABLE == 1 )
|
||||
|
||||
// DYNAMIC: "TV_GAMMA" "0..1" [ps20b] [ps30] [PC]
|
||||
// DYNAMIC: "DESATURATEENABLE" "0..1" [ps20b] [ps30] [PC]
|
||||
// SKIP: ( $TOOL_MODE == 0 ) && $TV_GAMMA
|
||||
// SKIP: ( $TOOL_MODE == 0 ) && $DESATURATEENABLE
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
#define FXAA_ENABLE 1
|
||||
|
||||
#include "fxaa3_11_fxc.h"
|
||||
|
||||
|
||||
sampler BaseTextureSampler : register( s0 );
|
||||
sampler FBTextureSampler : register( s1 );
|
||||
sampler3D ColorCorrectionVolumeTexture0 : register( s2 );
|
||||
sampler3D ColorCorrectionVolumeTexture1 : register( s3 );
|
||||
sampler3D ColorCorrectionVolumeTexture2 : register( s4 );
|
||||
sampler3D 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 );
|
||||
|
||||
// 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 );
|
||||
|
||||
float g_flDesaturation : register( c16 );
|
||||
|
||||
// FXAA consts
|
||||
float4 g_fxaaConsoleRcpFrameOpt : register( c17 );
|
||||
float4 g_fxaaConsoleRcpFrameOpt2 : register( c18 );
|
||||
float4 g_fxaaConsole360RcpFrameOpt2 : register( c19 );
|
||||
float4 g_fxaaConsoleEdge : register( c20 );
|
||||
float4 g_fxaaConsole360ConstDir : register( c21 );
|
||||
float4 g_fxaaQualityRcpFrame : register( c22 );
|
||||
float4 g_fxaaQualitySubpixEdge : register( c23 );
|
||||
|
||||
|
||||
HALF Luminance( HALF3 cColor )
|
||||
{
|
||||
HALF3 tmpv = { 0.2125f, 0.7154f, 0.0721f };
|
||||
HALF flLuminance = dot( cColor.rgb, tmpv.rgb );
|
||||
return flLuminance;
|
||||
}
|
||||
|
||||
|
||||
HALF LuminanceLinear( HALF3 cColor )
|
||||
{
|
||||
// Alternate formula for calculating luminance for linear RGB space (Widely used in color hue and saturation computations)
|
||||
HALF3 tmpv = { 0.3086f, 0.6094f, 0.0820f };
|
||||
HALF flLuminance = dot( cColor.rgb, tmpv.rgb );
|
||||
return flLuminance;
|
||||
}
|
||||
|
||||
|
||||
HALF4 GetBloomColor( float2 bloomUV )
|
||||
{
|
||||
HALF4 vBloomSample = tex2D( BaseTextureSampler, 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
|
||||
vBloomSample.rgb = SrgbLinearToGamma( vBloomSample.rgb );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined( _X360 )
|
||||
{
|
||||
#if defined( CSTRIKE15 )
|
||||
{
|
||||
// [mariod] - no pwl space for CS:GO
|
||||
}
|
||||
#else
|
||||
{
|
||||
// Since bloom is added in gamma space, the 360's PWL gamma space requires an artificial
|
||||
// dim factor to match the look of the PC and PS3. 0.5 works best for portal2
|
||||
vBloomSample.rgb *= 0.5f;
|
||||
vBloomSample.rgb = SrgbLinearToGamma( vBloomSample.rgb );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// Scale bloom by 50% for all platforms
|
||||
vBloomSample.rgb *= 0.5f;
|
||||
|
||||
return vBloomSample.rgba;
|
||||
}
|
||||
|
||||
HALF4 PerformColorCorrection( HALF4 outColor )
|
||||
{
|
||||
#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
|
||||
// and (1,1,1) to be read from 31.5f/32
|
||||
HALF4 offsetOutColor = outColor * (HALF)(31.0f / 32.0f) + (HALF)(0.5f / 32.0f);
|
||||
|
||||
outColor.rgb = outColor.rgb * (HALF)ColorCorrectionDefaultWeight;
|
||||
#if ( defined( _PS3 ) )
|
||||
{
|
||||
outColor.rgb += h3tex3D( ColorCorrectionVolumeTexture0, offsetOutColor.rgb ).rgb * (HALF3)ColorCorrectionVolumeWeights.xxx;
|
||||
}
|
||||
#else
|
||||
{
|
||||
outColor.rgb += tex3D( ColorCorrectionVolumeTexture0, offsetOutColor.rgb ).rgb * ColorCorrectionVolumeWeights.xxx;
|
||||
}
|
||||
#endif
|
||||
if ( COL_CORRECT_NUM_LOOKUPS > 1 )
|
||||
{
|
||||
outColor.rgb += tex3D( ColorCorrectionVolumeTexture1, offsetOutColor.rgb ).rgb * ColorCorrectionVolumeWeights.yyy;
|
||||
if ( COL_CORRECT_NUM_LOOKUPS > 2 )
|
||||
{
|
||||
outColor.rgb += tex3D( ColorCorrectionVolumeTexture2, offsetOutColor.rgb ).rgb * ColorCorrectionVolumeWeights.zzz;
|
||||
if ( COL_CORRECT_NUM_LOOKUPS > 3 )
|
||||
{
|
||||
outColor.rgb += tex3D( ColorCorrectionVolumeTexture3, offsetOutColor.rgb ).rgb * ColorCorrectionVolumeWeights.www;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return outColor;
|
||||
}
|
||||
|
||||
float3 PerformVomitBlend( float3 vRefractParams, float3 vFullResColor, float3 vBlurredColor )
|
||||
{
|
||||
|
||||
#ifdef _PS3
|
||||
// Compensate for gamma badness. Turns out that the particle system rendering for the vomit effect
|
||||
// is blending is gamma space on ps3. Doing this to somewhat compensate for this.
|
||||
// Would do a sqrt here, but it introduces a lot of banding artifacts.
|
||||
vRefractParams.z = saturate( vRefractParams.z * 2.0f );
|
||||
#endif
|
||||
|
||||
float3 vVomitColor = lerp( g_vVomitColor[0].rgb, g_vVomitColor[1].rgb, vRefractParams.z ); // vomit tint
|
||||
|
||||
|
||||
// Get the luminance of the color buffer.
|
||||
float vFullResLum = dot( vFullResColor, float3( 0.3, 0.59, 0.11 ) );
|
||||
|
||||
// Tint color buffer with vomit color.
|
||||
vFullResColor.rgb = lerp( vFullResColor, vFullResLum * vVomitColor, saturate( 1.0f * vRefractParams.z ) ); // vomit tint full-res buffer
|
||||
|
||||
// blend to the solid vomit color so that the color is more apparent.
|
||||
vFullResColor.rgb = lerp( vFullResColor, vVomitColor, 1.0f * vRefractParams.z ); // vomit tint full-res buffer
|
||||
|
||||
// blend in blurred backbuffer.
|
||||
vFullResColor.rgb = lerp ( vFullResColor.rgb, vVomitColor.rgb * vBlurredColor.rgb, saturate( 1.0f * vRefractParams.z ) );
|
||||
return vFullResColor.rgb;
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
{
|
||||
float4 bloombaseCoords : TEXCOORD0;
|
||||
float4 fxaaCoords : TEXCOORD1;
|
||||
};
|
||||
|
||||
float4_color_return_type main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
// float4 fbTexCoord = float4( i.bloomCoords, i.baseCoords );
|
||||
float4 fbTexCoord = i.bloombaseCoords;
|
||||
|
||||
HALF4 cBloomBlurredLum = GetBloomColor( i.bloombaseCoords.zw ); // bloom color and blurred luminance in alpha
|
||||
|
||||
float4 vVomitRefractParams;
|
||||
#if ( VOMIT_ENABLE == 1 )
|
||||
{
|
||||
// perturb texture coordinate
|
||||
vVomitRefractParams = tex2D( ScreenEffectSampler, i.bloombaseCoords.zw );
|
||||
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
|
||||
|
||||
#if ( defined( _PS3 ) )
|
||||
HALF4 rawColor = h4tex2D( FBTextureSampler, fbTexCoord.xy ).rgba;
|
||||
#else
|
||||
HALF4 rawColor = tex2D( FBTextureSampler, fbTexCoord.xy ).rgba;
|
||||
#endif
|
||||
|
||||
HALF3 baseColor = rawColor.rgb;
|
||||
float depthValue = rawColor.a;
|
||||
|
||||
#if ( CONVERT_FROM_LINEAR == 1 )
|
||||
{
|
||||
baseColor.rgb = SrgbLinearToGamma( baseColor.rgb );
|
||||
}
|
||||
#endif
|
||||
|
||||
HALF4 outColor = HALF4( baseColor, 1 );
|
||||
|
||||
// In this case, which is only used on OpenGL, we have linear inputs.
|
||||
// This means we converted to sRGB prior to accessing the color correction textures.
|
||||
#if ( LINEAR_INPUT )
|
||||
{
|
||||
outColor.rgb = SrgbLinearToGamma( saturate( outColor.rgb ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ( AA_ENABLE == 1 )
|
||||
{
|
||||
half3 aaRGB;
|
||||
|
||||
#if ( FXAA_ENABLE == 1 )
|
||||
{
|
||||
// FXAA for all platforms if using software AA
|
||||
|
||||
//
|
||||
// args - compute in shader where necessary for now, use shader constants when working
|
||||
// see fxaa3_11_fxc.h for documentation on arguments
|
||||
//
|
||||
|
||||
//
|
||||
FxaaFloat2 pos = fbTexCoord.xy;
|
||||
|
||||
//
|
||||
FxaaFloat4 fxaaConsolePosPos = i.fxaaCoords;
|
||||
|
||||
// tex = FBTextureSampler
|
||||
// fxaaConsole360TexExpBiasNegOne - FIXME: just use tex and do the biasing in shader for now
|
||||
// fxaaConsole360TexExpBiasNegTwo - "
|
||||
|
||||
// do FXAA
|
||||
aaRGB = FxaaPixelShader( pos,
|
||||
fxaaConsolePosPos,
|
||||
FBTextureSampler, FBTextureSampler, FBTextureSampler,
|
||||
g_fxaaQualityRcpFrame,
|
||||
g_fxaaConsoleRcpFrameOpt,
|
||||
g_fxaaConsoleRcpFrameOpt2,
|
||||
g_fxaaConsole360RcpFrameOpt2,
|
||||
g_fxaaQualitySubpixEdge.x, // QualitySubpix
|
||||
g_fxaaQualitySubpixEdge.z, // QualityEdgeThreshold
|
||||
g_fxaaQualitySubpixEdge.w, // QualityEdgeThresholdMin
|
||||
g_fxaaConsoleEdge.y, // ConsoleEdgeSharpness
|
||||
g_fxaaConsoleEdge.z, // ConsoleEdgeThreshold,
|
||||
g_fxaaConsoleEdge.w, // ConsoleThresholdMin,
|
||||
g_fxaaConsole360ConstDir );
|
||||
}
|
||||
#else
|
||||
{
|
||||
// TODO: put old code back here?
|
||||
aaRGB = ouColor.rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
outColor.rgb = aaRGB;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ( VOMIT_ENABLE == 1 )
|
||||
{
|
||||
outColor.rgb = PerformVomitBlend( vVomitRefractParams.xyz, outColor.rgb, cBloomBlurredLum.aaa );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ( LOCAL_CONTRAST_ENABLE == 1 )
|
||||
{
|
||||
HALF 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.
|
||||
HALF fLuminance = dot( outColor.rgb, HALF3( 0.299, 0.587, 0.114 ) );
|
||||
HALF fContrastLum = fLuminance + (HALF)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 );
|
||||
|
||||
HALF2 vCenterDir = ( (HALF)2.0f * (HALF2)i.bloombaseCoords.zw ) - (HALF)1.0f;
|
||||
HALF fMyVignette = smoothstep( (HALF)g_flLocalContrastVignetteStart, (HALF)g_flLocalContrastVignetteEnd, length( vCenterDir ) );
|
||||
HALF fMyVignette2 = fMyVignette;
|
||||
fMyVignette = lerp( (HALF)g_flLocalContrastStrength, (HALF)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 ), (HALF)-1.0f + step( (HALF)0.0f, fMask ) ); // Selective clamp to positive adds 4 instructions
|
||||
|
||||
#if ( BLURRED_VIGNETTE_ENABLE == 1 )
|
||||
outColor.rgb = lerp( outColor.rgb, cBloomBlurredLum.aaa, fMyVignette2 * (HALF)g_flBlurredVignetteStrength );
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// Composite bloom and full-screen + depth blur effects
|
||||
#if ( DEPTH_BLUR_ENABLE )
|
||||
{
|
||||
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 += (HALF)g_flBloomAmount * (HALF3)cBloomBlurredLum.rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ( FADE_TYPE == 1 )
|
||||
{
|
||||
outColor.rgb = lerp( outColor.rgb, (HALF3)g_vViewFadeColor.rgb, (HALF3)g_vViewFadeColor.aaa );
|
||||
}
|
||||
#elif ( FADE_TYPE == 2 )
|
||||
{
|
||||
outColor.rgb = lerp( outColor.rgb, (HALF3)g_vViewFadeColor.rgb * outColor.rgb, (HALF3)g_vViewFadeColor.aaa );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ( DESATURATEENABLE )
|
||||
{
|
||||
float flLum = saturate( dot( outColor.rgb, HALF3( 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.bloombaseCoords.zw;
|
||||
float2 vTmp = ( vUv.xy * 2.0 ) - 1.0;
|
||||
float flVignette;
|
||||
|
||||
#if ( defined( _X360 ) ) && ( !defined( CSTRIKE15 ) )
|
||||
{
|
||||
// Make title safe and deal with different gamma space
|
||||
flVignette = 1.0 - pow( abs( vTmp.x ), 4.0f );
|
||||
flVignette *= 1.0 - pow( abs( vTmp.y ), 4.0f );
|
||||
flVignette = 1.0 - ( 1.0 - flVignette ) * ( ( saturate( ( 1.0 - vUv.y ) - 0.1 ) / 0.9 ) );
|
||||
|
||||
// This tex2D solves the 3 lines of math above
|
||||
//flVignette = tex2D( VignetteSampler, vUv.xy ).g; // Green is for the 360
|
||||
//flVignette = saturate( flVignette * 0.75 + 0.26 );
|
||||
}
|
||||
#else
|
||||
{
|
||||
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 );
|
||||
}
|
||||
#endif
|
||||
|
||||
// Artificially lighten the vignette. We may have to tune this differently for the 360.
|
||||
//outColor.rgb *= ( flVignette * 0.75 ) + 0.25;
|
||||
outColor.rgb *= ( flVignette * 0.33 ) + 0.67;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Noise
|
||||
#if ( NOISE_ENABLE == 1 )
|
||||
{
|
||||
// Additive Noise
|
||||
float2 vUv0 = i.bloombaseCoords.zw * 10.0 + g_flTime;
|
||||
float2 vUv1 = i.bloombaseCoords.wz * 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;
|
||||
|
||||
HALF3 vTmp = { 0.2125f, 0.7154f, 0.0721f };
|
||||
float flLuminance = saturate( dot( outColor.rgb, vTmp.rgb ) );
|
||||
|
||||
#if defined( _X360 ) && !defined( CSTRIKE15 )
|
||||
{
|
||||
// 360
|
||||
float flNoiseScalar = 0.2f + 1.0f * ( saturate( pow( 1.0 - flLuminance, 64.0 ) ) );
|
||||
outColor.rgb += ( ( flNoiseTexel * 0.3f ) - 0.15f ) * g_flNoiseScalar * flNoiseScalar;
|
||||
}
|
||||
#else
|
||||
{
|
||||
// PC
|
||||
float flNoiseScalar = 0.2f + 0.8f * ( saturate( pow( 1.0 - flLuminance, 12.0 ) ) );
|
||||
outColor.rgb += ( ( flNoiseTexel * 0.3f ) - 0.15f ) * g_flNoiseScalar * flNoiseScalar;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ( FADE_TO_BLACK )
|
||||
{
|
||||
// Fade to black
|
||||
outColor.rgb = lerp( outColor.rgb, (HALF3)0.0f, (HALF)g_flFadeToBlackStrength );
|
||||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
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 )
|
||||
{
|
||||
outColor.rgb = SrgbGammaToLinear( outColor.rgb );
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Debug code for evaluating gamma spaces from the framebuffer to the TV
|
||||
outColor.rgba = 0;
|
||||
float flTmp = saturate( i.bloombaseCoords.z * 1.2 - 0.1 );
|
||||
if ( ( flTmp <= 0.0f ) || ( flTmp >= 1.0f ) )
|
||||
flTmp = 0.5f;
|
||||
#if defined( _X360 )
|
||||
outColor.rgb = X360LinearToGamma( flTmp );
|
||||
#else
|
||||
outColor.rgb = SrgbLinearToGamma( flTmp );
|
||||
#endif
|
||||
//*/
|
||||
|
||||
return outColor;
|
||||
}
|
||||
|
||||
141
materialsystem/stdshaders/Eyes_vs20.fxc
Normal file
141
materialsystem/stdshaders/Eyes_vs20.fxc
Normal file
@@ -0,0 +1,141 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
// $SHADER_SPECIFIC_CONST_0 = eyeball origin
|
||||
// $SHADER_SPECIFIC_CONST_1 = eyeball up * 0.5
|
||||
// $SHADER_SPECIFIC_CONST_2 = iris projection U
|
||||
// $SHADER_SPECIFIC_CONST_3 = iris projection V
|
||||
// $SHADER_SPECIFIC_CONST_4 = glint projection U
|
||||
// $SHADER_SPECIFIC_CONST_5 = glint projection V
|
||||
//===========================================================================//
|
||||
|
||||
// STATIC: "HALFLAMBERT" "0..1"
|
||||
// STATIC: "FLATTEN_STATIC_CONTROL_FLOW" "0..1" [vs20] [PC]
|
||||
// STATIC: "FLATTEN_STATIC_CONTROL_FLOW" "0..0" [CONSOLE]
|
||||
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
#include "common_fog_vs_fxc.h"
|
||||
// DYNAMIC: "DYNAMIC_LIGHT" "0..1"
|
||||
// DYNAMIC: "STATIC_LIGHT" "0..1"
|
||||
|
||||
// DYNAMIC: "MORPHING" "0..0" [ = false ]
|
||||
// DYNAMIC: "NUM_LIGHTS" "0..2" [vs20] [PC]
|
||||
// DYNAMIC: "NUM_LIGHTS" "0..0" [vs20] [CONSOLE]
|
||||
|
||||
// If using static control flow on Direct3D, we should use the NUM_LIGHTS=0 combo
|
||||
// SKIP: ( $FLATTEN_STATIC_CONTROL_FLOW == 0 )&& ( $NUM_LIGHTS > 0 ) [vs20] [PC]
|
||||
|
||||
#include "vortwarp_vs20_helper.h"
|
||||
|
||||
static const int g_bSkinning = SKINNING ? true : false;
|
||||
static const int g_FogType = DOWATERFOG;
|
||||
static const bool g_bHalfLambert = HALFLAMBERT ? true : false;
|
||||
|
||||
const float3 cEyeOrigin : register( SHADER_SPECIFIC_CONST_0 );
|
||||
const float3 cHalfEyeballUp : register( SHADER_SPECIFIC_CONST_1 );
|
||||
const float4 cIrisProjectionU : register( SHADER_SPECIFIC_CONST_2 );
|
||||
const float4 cIrisProjectionV : register( SHADER_SPECIFIC_CONST_3 );
|
||||
const float4 cGlintProjectionU : register( SHADER_SPECIFIC_CONST_4 );
|
||||
const float4 cGlintProjectionV : register( SHADER_SPECIFIC_CONST_5 );
|
||||
|
||||
#ifdef SHADER_MODEL_VS_3_0
|
||||
// NOTE: cMorphTargetTextureDim.xy = target dimensions,
|
||||
// cMorphTargetTextureDim.z = 4tuples/morph
|
||||
const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_7 );
|
||||
const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_8 );
|
||||
|
||||
sampler2D morphSampler : register( s0 );
|
||||
#endif
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION; // Position
|
||||
float4 vBoneWeights : BLENDWEIGHT; // Skin weights
|
||||
float4 vBoneIndices : BLENDINDICES; // Skin indices
|
||||
float4 vTexCoord0 : TEXCOORD0; // Base (sclera) texture coordinates
|
||||
|
||||
float3 vPosFlex : POSITION1; // Delta positions for flexing
|
||||
#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; // Fixed-function fog factor
|
||||
#endif
|
||||
float2 baseTC : TEXCOORD0; // Base texture coordinate
|
||||
float2 irisTC : TEXCOORD1; // Iris texture coordinates
|
||||
float2 glintTC : TEXCOORD2; // Glint texture coordinates
|
||||
float3 vColor : TEXCOORD3; // Vertex-lit color
|
||||
|
||||
float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = (VS_OUTPUT)0;
|
||||
|
||||
bool bDynamicLight = DYNAMIC_LIGHT ? true : false;
|
||||
bool bStaticLight = STATIC_LIGHT ? true : false;
|
||||
|
||||
float4 vPosition = v.vPos;
|
||||
float3 dummy = v.vPos.xyz; // dummy values that can't be optimized out
|
||||
|
||||
#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING
|
||||
ApplyMorph( v.vPosFlex, vPosition.xyz );
|
||||
#else
|
||||
ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, v.vVertexID, dummy, vPosition.xyz );
|
||||
#endif
|
||||
|
||||
// Transform the position and dummy normal (not doing the dummy normal causes invariance issues with the flashlight!)
|
||||
float3 worldNormal, worldPos;
|
||||
SkinPositionAndNormal(
|
||||
g_bSkinning,
|
||||
vPosition, dummy,
|
||||
v.vBoneWeights, v.vBoneIndices,
|
||||
worldPos, worldNormal );
|
||||
|
||||
// Transform into projection space
|
||||
o.projPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
|
||||
#ifdef _PS3
|
||||
// Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
|
||||
o.projPos.y = -o.projPos.y;
|
||||
o.projPos.z = 2.0f * o.projPos.z - o.projPos.w;
|
||||
#endif // _PS3
|
||||
|
||||
o.worldPos_projPosZ = float4( worldPos.xyz, o.projPos.z );
|
||||
|
||||
#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
|
||||
o.fog = CalcFixedFunctionFog( worldPos, g_FogType );
|
||||
#endif
|
||||
|
||||
// Normal = (Pos - Eye origin) - just step on dummy normal created above
|
||||
worldNormal = worldPos - cEyeOrigin;
|
||||
|
||||
// Normal -= 0.5f * (Normal dot Eye Up) * Eye Up
|
||||
float normalDotUp = -dot( worldNormal, cHalfEyeballUp) * 0.5f;
|
||||
worldNormal = normalize(normalDotUp * cHalfEyeballUp + worldNormal);
|
||||
|
||||
// Vertex lighting
|
||||
#if ( ( FLATTEN_STATIC_CONTROL_FLOW == 0 ) || defined ( SHADER_MODEL_VS_3_0 ) )
|
||||
o.vColor = DoLighting( worldPos, worldNormal, float3(0.0f, 0.0f, 0.0f), bStaticLight, bDynamicLight, g_bHalfLambert );
|
||||
#else
|
||||
o.vColor = DoLightingUnrolled( worldPos, worldNormal, float3(0.0f, 0.0f, 0.0f), bStaticLight, bDynamicLight, g_bHalfLambert, NUM_LIGHTS );
|
||||
#endif
|
||||
|
||||
// Texture 0 is the base texture
|
||||
// Texture 1 is a planar projection used for the iris
|
||||
// Texture 2 is a planar projection used for the glint
|
||||
o.baseTC = v.vTexCoord0.xy;
|
||||
o.irisTC.x = dot( cIrisProjectionU, float4(worldPos, 1) );
|
||||
o.irisTC.y = dot( cIrisProjectionV, float4(worldPos, 1) );
|
||||
o.glintTC.x = dot( cGlintProjectionU, float4(worldPos, 1) );
|
||||
o.glintTC.y = dot( cGlintProjectionV, float4(worldPos, 1) );
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
81
materialsystem/stdshaders/HDRCombineTo16Bit.cpp
Normal file
81
materialsystem/stdshaders/HDRCombineTo16Bit.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
//========= Copyright © 1996-2004, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "common_hlsl_cpp_consts.h"
|
||||
#include "HDRCombineTo16Bit_ps20.inc"
|
||||
#include "HDRCombineTo16Bit_ps20b.inc"
|
||||
#include "HDRCombineTo16Bit_vs20.inc"
|
||||
#include "convar.h"
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( HDRCombineTo16Bit, "Help for HDRCombineTo16Bit", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( SOURCEMRTRENDERTARGET, SHADER_PARAM_TYPE_TEXTURE, "", "" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
LoadTexture( SOURCEMRTRENDERTARGET );
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableAlphaWrites( false );
|
||||
pShaderShadow->EnableDepthTest( false );
|
||||
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
int fmt = VERTEX_POSITION;
|
||||
pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( hdrcombineto16bit_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( hdrcombineto16bit_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( hdrcombineto16bit_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER( hdrcombineto16bit_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( hdrcombineto16bit_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER( hdrcombineto16bit_ps20 );
|
||||
}
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, SOURCEMRTRENDERTARGET, -1 );
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( hdrcombineto16bit_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( hdrcombineto16bit_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( hdrcombineto16bit_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( hdrcombineto16bit_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( hdrcombineto16bit_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( hdrcombineto16bit_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
23
materialsystem/stdshaders/HDRCombineTo16Bit_ps2x.fxc
Normal file
23
materialsystem/stdshaders/HDRCombineTo16Bit_ps2x.fxc
Normal file
@@ -0,0 +1,23 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler LowSampler : register( s0 );
|
||||
sampler HiSampler : register( s1 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4 lowColor = tex2D( LowSampler, i.texCoord );
|
||||
float3 hiColor = tex2D( HiSampler, i.texCoord );
|
||||
|
||||
lowColor.rgb = GammaToLinear( lowColor.rgb );
|
||||
hiColor.rgb = GammaToLinear( hiColor.rgb );
|
||||
|
||||
float4 result = float4( ( 1.0f / MAX_HDR_OVERBRIGHT ) * max( lowColor.xyz, hiColor.xyz * MAX_HDR_OVERBRIGHT ), lowColor.a );
|
||||
return FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
24
materialsystem/stdshaders/HDRCombineTo16Bit_vs20.fxc
Normal file
24
materialsystem/stdshaders/HDRCombineTo16Bit_vs20.fxc
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vBaseTexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
o.projPos = float4( v.vPos, 1.0f );
|
||||
o.texCoord = v.vBaseTexCoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
79
materialsystem/stdshaders/HDRSelectRange.cpp
Normal file
79
materialsystem/stdshaders/HDRSelectRange.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
//========= Copyright © 1996-2004, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "common_hlsl_cpp_consts.h"
|
||||
|
||||
#include "HDRSelectRange_ps20.inc"
|
||||
#include "HDRSelectRange_ps20b.inc"
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( HDRSelectRange, "Help for HDRSelectRange", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( SOURCEMRTRENDERTARGET, SHADER_PARAM_TYPE_TEXTURE, "", "" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
LoadTexture( SOURCEMRTRENDERTARGET );
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableAlphaWrites( false );
|
||||
pShaderShadow->EnableDepthTest( false );
|
||||
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
int fmt = VERTEX_POSITION;
|
||||
pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
|
||||
|
||||
pShaderShadow->SetVertexShader( "HDRSelectRange_vs20", 0 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( hdrselectrange_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER( hdrselectrange_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( hdrselectrange_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER( hdrselectrange_ps20 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, SOURCEMRTRENDERTARGET, -1 );
|
||||
pShaderAPI->SetVertexShaderIndex( 0 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( hdrselectrange_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( hdrselectrange_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( hdrselectrange_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( hdrselectrange_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
42
materialsystem/stdshaders/HDRSelectRange_ps2x.fxc
Normal file
42
materialsystem/stdshaders/HDRSelectRange_ps2x.fxc
Normal file
@@ -0,0 +1,42 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler LowSampler : register( s0 );
|
||||
sampler HiSampler : register( s1 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct MYHDR_PS_OUTPUT
|
||||
{
|
||||
float4 color[2] : COLOR0;
|
||||
};
|
||||
|
||||
MYHDR_PS_OUTPUT main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float3 lowColor = GammaToLinear( tex2D( LowSampler, i.texCoord ) );
|
||||
float3 hiColor = GammaToLinear( tex2D( HiSampler, i.texCoord ) );
|
||||
|
||||
float4 lowOut;
|
||||
lowOut.a = 1.0f;
|
||||
float4 hiOut;
|
||||
hiOut.a = 1.0f;
|
||||
|
||||
float3 hdrColor = max( lowColor, hiColor * MAX_HDR_OVERBRIGHT );
|
||||
|
||||
float fMax = max( hdrColor.b, max( hdrColor.r, hdrColor.g ) );
|
||||
|
||||
float blendFactor = saturate( ( fMax - 0.9f ) * 10.0f );
|
||||
|
||||
blendFactor = 1.0f;
|
||||
|
||||
lowOut.rgb = LinearToGamma( lowColor * ( 1.0f - blendFactor ) );
|
||||
hiOut.rgb = LinearToGamma( hiColor * ( blendFactor ) );
|
||||
MYHDR_PS_OUTPUT output;
|
||||
output.color[0] = lowOut;
|
||||
output.color[1] = hiOut;
|
||||
return output;
|
||||
}
|
||||
24
materialsystem/stdshaders/HDRSelectRange_vs20.fxc
Normal file
24
materialsystem/stdshaders/HDRSelectRange_vs20.fxc
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vBaseTexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
o.projPos = float4( v.vPos, 1.0f );
|
||||
o.texCoord = v.vBaseTexCoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
139
materialsystem/stdshaders/IceSurface_dx9.cpp
Normal file
139
materialsystem/stdshaders/IceSurface_dx9.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
//========= Copyright © 1996-2007, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Ice surface shader (for the ice gun)
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "IceSurface_helper.h"
|
||||
#include "cpp_shader_constant_register_map.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DEFINE_FALLBACK_SHADER( IceSurface, IceSurface_dx9 )
|
||||
|
||||
BEGIN_VS_SHADER( IceSurface_dx9, "IceSurface" )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( BACKSURFACE, SHADER_PARAM_TYPE_BOOL, "0.0", "specify that this is the back surface of the ice" )
|
||||
|
||||
SHADER_PARAM( NORMALMAP, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader1_normal", "normal map" )
|
||||
SHADER_PARAM( SPECMASKTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "specular reflection mask" )
|
||||
SHADER_PARAM( LIGHTWARPTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "1D ramp texture for tinting scalar diffuse term" )
|
||||
SHADER_PARAM( FRESNELWARPTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "1D ramp texture for controlling fresnel falloff" )
|
||||
SHADER_PARAM( OPACITYTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "1D ramp texture for controlling fresnel falloff" )
|
||||
SHADER_PARAM( ENVMAP, SHADER_PARAM_TYPE_TEXTURE, "", "environment map" )
|
||||
|
||||
SHADER_PARAM( UVSCALE, SHADER_PARAM_TYPE_FLOAT, "0.02", "uv projection scale" )
|
||||
SHADER_PARAM( BUMPSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "1.0", "bump map strength" )
|
||||
SHADER_PARAM( FRESNELBUMPSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "1.0", "bump map strength for fresnel" )
|
||||
SHADER_PARAM( TRANSLUCENTFRESNELMINMAXEXP, SHADER_PARAM_TYPE_VEC3, "[0.8 1.0 1.0]", "fresnel params" )
|
||||
|
||||
SHADER_PARAM( INTERIOR, SHADER_PARAM_TYPE_BOOL, "1", "Enable interior layer" )
|
||||
SHADER_PARAM( INTERIORFOGSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0.06", "fog strength (scales with thickness of the interior volume)" )
|
||||
SHADER_PARAM( INTERIORFOGLIMIT, SHADER_PARAM_TYPE_FLOAT, "0.8", "fog opacity beyond the range of destination alpha depth (in low-precision depth mode)" )
|
||||
SHADER_PARAM( INTERIORFOGNORMALBOOST, SHADER_PARAM_TYPE_FLOAT, "0.0", "degree to boost interior thickness/fog by 'side-on'ness of vertex normals to the camera" )
|
||||
SHADER_PARAM( INTERIORBACKGROUNDBOOST, SHADER_PARAM_TYPE_FLOAT, "7", "boosts the brightness of bright background pixels" )
|
||||
SHADER_PARAM( INTERIORAMBIENTSCALE, SHADER_PARAM_TYPE_FLOAT, "0.3", "scales ambient light in the interior volume" );
|
||||
SHADER_PARAM( INTERIORBACKLIGHTSCALE, SHADER_PARAM_TYPE_FLOAT, "0.3", "scales backlighting in the interior volume" );
|
||||
SHADER_PARAM( INTERIORCOLOR, SHADER_PARAM_TYPE_VEC3, "[0.7 0.5 0.45]", "tints light in the interior volume" )
|
||||
SHADER_PARAM( INTERIORREFRACTSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0.015", "strength of bumped refract of the background seen through the interior" )
|
||||
SHADER_PARAM( INTERIORREFRACTBLUR, SHADER_PARAM_TYPE_FLOAT, "0.2", "strength of blur applied to the background seen through the interior" )
|
||||
|
||||
SHADER_PARAM( DIFFUSESCALE, SHADER_PARAM_TYPE_FLOAT, "1.0", "" )
|
||||
SHADER_PARAM( PHONGEXPONENT, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular exponent" )
|
||||
SHADER_PARAM( PHONGBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular boost" )
|
||||
SHADER_PARAM( PHONGEXPONENT2, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular exponent" )
|
||||
SHADER_PARAM( PHONGBOOST2, SHADER_PARAM_TYPE_FLOAT, "1.0", "specular boost" )
|
||||
SHADER_PARAM( RIMLIGHTEXPONENT, SHADER_PARAM_TYPE_FLOAT, "1.0", "rim light exponent" )
|
||||
SHADER_PARAM( RIMLIGHTBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "rim light boost" )
|
||||
SHADER_PARAM( BASECOLORTINT, SHADER_PARAM_TYPE_VEC3, "[1.0 1.0 1.0]", "base texture tint" )
|
||||
SHADER_PARAM( ENVMAPTINT, SHADER_PARAM_TYPE_VEC3, "[1.0 1.0 1.0]", "tints the environment reflection" )
|
||||
|
||||
SHADER_PARAM( UVPROJOFFSET, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "Center for UV projection" )
|
||||
SHADER_PARAM( BBMIN, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "" )
|
||||
SHADER_PARAM( BBMAX, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "" )
|
||||
|
||||
SHADER_PARAM( CONTACTSHADOWS, SHADER_PARAM_TYPE_BOOL, "1", "" )
|
||||
|
||||
SHADER_PARAM( BUMPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "" )
|
||||
|
||||
END_SHADER_PARAMS
|
||||
|
||||
void SetupVarsIceSurface( IceSurfaceVars_t &info )
|
||||
{
|
||||
info.m_nBackSurface = BACKSURFACE;
|
||||
info.m_nBaseTexture = BASETEXTURE;
|
||||
info.m_nNormalMap = NORMALMAP;
|
||||
info.m_nSpecMap = SPECMASKTEXTURE;
|
||||
info.m_nLightWarpTexture = LIGHTWARPTEXTURE;
|
||||
info.m_nFresnelWarpTexture = FRESNELWARPTEXTURE;
|
||||
info.m_nOpacityTexture = OPACITYTEXTURE;
|
||||
info.m_nEnvMap = ENVMAP;
|
||||
info.m_nBumpStrength = BUMPSTRENGTH;
|
||||
info.m_nFresnelBumpStrength = FRESNELBUMPSTRENGTH;
|
||||
info.m_nUVScale = UVSCALE;
|
||||
|
||||
info.m_nInteriorEnable = INTERIOR;
|
||||
info.m_nInteriorFogStrength = INTERIORFOGSTRENGTH;
|
||||
info.m_nInteriorFogLimit = INTERIORFOGLIMIT;
|
||||
info.m_nInteriorFogNormalBoost = INTERIORFOGNORMALBOOST;
|
||||
info.m_nInteriorBackgroundBoost = INTERIORBACKGROUNDBOOST;
|
||||
info.m_nInteriorAmbientScale = INTERIORAMBIENTSCALE;
|
||||
info.m_nInteriorBackLightScale = INTERIORBACKLIGHTSCALE;
|
||||
info.m_nInteriorColor = INTERIORCOLOR;
|
||||
info.m_nInteriorRefractStrength = INTERIORREFRACTSTRENGTH;
|
||||
info.m_nInteriorRefractBlur = INTERIORREFRACTBLUR;
|
||||
|
||||
info.m_nFresnelParams = TRANSLUCENTFRESNELMINMAXEXP;
|
||||
info.m_nDiffuseScale = DIFFUSESCALE;
|
||||
info.m_nSpecExp = PHONGEXPONENT;
|
||||
info.m_nSpecScale = PHONGBOOST;
|
||||
info.m_nSpecExp2 = PHONGEXPONENT2;
|
||||
info.m_nSpecScale2 = PHONGBOOST2;
|
||||
info.m_nRimLightExp = RIMLIGHTEXPONENT;
|
||||
info.m_nRimLightScale = RIMLIGHTBOOST;
|
||||
info.m_nBaseColorTint = BASECOLORTINT;
|
||||
info.m_nEnvMapTint = ENVMAPTINT;
|
||||
info.m_nUVProjOffset = UVPROJOFFSET;
|
||||
info.m_nBBMin = BBMIN;
|
||||
info.m_nBBMax = BBMAX;
|
||||
info.m_nFlashlightTexture = FLASHLIGHTTEXTURE;
|
||||
info.m_nFlashlightTextureFrame = FLASHLIGHTTEXTUREFRAME;
|
||||
info.m_nBumpFrame = BUMPFRAME;
|
||||
info.m_nContactShadows = CONTACTSHADOWS;
|
||||
}
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
IceSurfaceVars_t info;
|
||||
SetupVarsIceSurface( info );
|
||||
InitParamsIceSurface( this, params, pMaterialName, info );
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
// TODO: Reasonable fallback
|
||||
if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
|
||||
{
|
||||
return "Wireframe";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
IceSurfaceVars_t info;
|
||||
SetupVarsIceSurface( info );
|
||||
InitIceSurface( this, params, info );
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
IceSurfaceVars_t info;
|
||||
SetupVarsIceSurface( info );
|
||||
DrawIceSurface( this, params, pShaderAPI, pShaderShadow, info, vertexCompression );
|
||||
}
|
||||
|
||||
END_SHADER
|
||||
430
materialsystem/stdshaders/IceSurface_helper.cpp
Normal file
430
materialsystem/stdshaders/IceSurface_helper.cpp
Normal file
@@ -0,0 +1,430 @@
|
||||
//========= Copyright © 1996-2007, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "IceSurface_helper.h"
|
||||
#include "cpp_shader_constant_register_map.h"
|
||||
/*
|
||||
#include "mathlib/VMatrix.h"
|
||||
#include "convar.h"
|
||||
*/
|
||||
|
||||
// Auto generated inc files
|
||||
#include "icesurface_vs30.inc"
|
||||
#include "icesurface_ps30.inc"
|
||||
|
||||
|
||||
void InitParamsIceSurface( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, IceSurfaceVars_t &info )
|
||||
{
|
||||
// Set material parameter default values
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nBackSurface, kDefaultBackSurface );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nUVScale, kDefaultUVScale );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nBumpStrength, kDefaultBumpStrength );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nFresnelBumpStrength, kDefaultFresnelBumpStrength );
|
||||
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nInteriorEnable, kDefaultInteriorEnable );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorFogStrength, kDefaultInteriorFogStrength );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorFogLimit, kDefaultInteriorFogLimit );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorFogNormalBoost, kDefaultInteriorFogNormalBoost );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorBackgroundBoost, kDefaultInteriorBackgroundBoost );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorAmbientScale, kDefaultInteriorAmbientScale );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorBackLightScale, kDefaultInteriorBackLightScale );
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nInteriorColor, kDefaultInteriorColor, 3 );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorRefractStrength, kDefaultInteriorRefractStrength );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nInteriorRefractBlur, kDefaultInteriorRefractBlur );
|
||||
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nFresnelParams, kDefaultFresnelParams, 3 );
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nBaseColorTint, kDefaultBaseColorTint, 3 );
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nEnvMapTint, kDefaultEnvMapTint, 3 );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nDiffuseScale, kDefaultDiffuseScale );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nSpecExp, kDefaultSpecExp );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nSpecScale, kDefaultSpecScale );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nSpecExp2, kDefaultSpecExp );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nSpecScale2, kDefaultSpecScale );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nRimLightExp, kDefaultRimLightExp );
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nRimLightScale, kDefaultRimLightScale );
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nUVProjOffset, kDefaultUVProjOffset, 3 );
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nBBMin, kDefaultBB, 3 );
|
||||
SET_PARAM_VEC_IF_NOT_DEFINED( info.m_nBBMax, kDefaultBB, 3 );
|
||||
|
||||
// FLASHLIGHTFIXME: Do ShaderAPI::BindFlashlightTexture
|
||||
Assert( info.m_nFlashlightTexture >= 0 );
|
||||
if ( g_pHardwareConfig->SupportsBorderColor() )
|
||||
{
|
||||
params[info.m_nFlashlightTexture]->SetStringValue( "effects/flashlight_border" );
|
||||
}
|
||||
else
|
||||
{
|
||||
params[info.m_nFlashlightTexture]->SetStringValue( "effects/flashlight001" );
|
||||
}
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nFlashlightTextureFrame, 0 );
|
||||
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nBumpFrame, kDefaultBumpFrame )
|
||||
|
||||
SET_PARAM_INT_IF_NOT_DEFINED( info.m_nContactShadows, kDefaultContactShadows );
|
||||
|
||||
// Set material flags
|
||||
SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING );
|
||||
SET_FLAGS2( MATERIAL_VAR2_LIGHTING_VERTEX_LIT );
|
||||
|
||||
if ( params[info.m_nInteriorEnable]->IsDefined() && params[info.m_nInteriorEnable]->GetIntValue() != 0 )
|
||||
{
|
||||
SET_FLAGS2( MATERIAL_VAR2_NEEDS_FULL_FRAME_BUFFER_TEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
void InitIceSurface( CBaseVSShader *pShader, IMaterialVar** params, IceSurfaceVars_t &info )
|
||||
{
|
||||
// Load textures
|
||||
if ( (info.m_nBaseTexture != -1) && params[info.m_nBaseTexture]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nBaseTexture );
|
||||
}
|
||||
|
||||
if ( (info.m_nNormalMap != -1) && params[info.m_nNormalMap]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nNormalMap );
|
||||
}
|
||||
|
||||
if ( (info.m_nSpecMap != -1) && params[info.m_nSpecMap]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nSpecMap );
|
||||
}
|
||||
|
||||
if ( (info.m_nLightWarpTexture != -1) && params[info.m_nLightWarpTexture]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nLightWarpTexture );
|
||||
}
|
||||
|
||||
if ( (info.m_nFresnelWarpTexture != -1) && params[info.m_nFresnelWarpTexture]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nFresnelWarpTexture );
|
||||
}
|
||||
|
||||
if ( (info.m_nOpacityTexture != -1) && params[info.m_nOpacityTexture]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nOpacityTexture );
|
||||
}
|
||||
|
||||
if ( (info.m_nEnvMap != -1) && params[info.m_nEnvMap]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nEnvMap );
|
||||
}
|
||||
|
||||
if ( (info.m_nFlashlightTexture != -1) && params[info.m_nFlashlightTexture]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nFlashlightTexture, TEXTUREFLAGS_SRGB );
|
||||
}
|
||||
}
|
||||
|
||||
void DrawIceSurface( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI,
|
||||
IShaderShadow* pShaderShadow, IceSurfaceVars_t &info, VertexCompressionType_t vertexCompression )
|
||||
{
|
||||
bool bHasFlashlight = pShader->UsingFlashlight( params );
|
||||
bool bBackSurface = (info.m_nBackSurface != -1) && ( params[info.m_nBackSurface]->GetIntValue() > 0 );
|
||||
bool bLightWarp = (info.m_nLightWarpTexture != -1) && params[info.m_nLightWarpTexture]->IsDefined();
|
||||
bool bFresnelWarp = (info.m_nFresnelWarpTexture != -1) && params[info.m_nFresnelWarpTexture]->IsDefined();
|
||||
bool bOpacityTexture = (info.m_nOpacityTexture != -1) && params[info.m_nOpacityTexture]->IsDefined();
|
||||
bool bInteriorLayer = (info.m_nInteriorEnable != -1) && ( params[info.m_nInteriorEnable]->GetIntValue() > 0 );
|
||||
bool bContactShadows = (info.m_nContactShadows != -1) && ( params[info.m_nContactShadows]->GetIntValue() > 0 );
|
||||
bool bSpecMap = (info.m_nSpecMap != -1) && params[info.m_nSpecMap]->IsDefined();
|
||||
bool bEnvMap = (info.m_nEnvMap != -1) && params[info.m_nEnvMap]->IsDefined();
|
||||
|
||||
SHADOW_STATE
|
||||
{
|
||||
// Set stream format (note that this shader supports compression)
|
||||
unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL;
|
||||
int nTexCoordCount = 1;
|
||||
int userDataSize = 0;
|
||||
int texCoordDims[4] = { 4, 4, 4, 4 };
|
||||
pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, texCoordDims, userDataSize );
|
||||
|
||||
ShadowFilterMode_t nShadowFilterMode = SHADOWFILTERMODE_DEFAULT;
|
||||
if ( bHasFlashlight )
|
||||
{
|
||||
nShadowFilterMode = g_pHardwareConfig->GetShadowFilterMode( false /* bForceLowQuality */, true /* bPS30 */ ); // Based upon vendor and device dependent formats
|
||||
}
|
||||
|
||||
// Vertex Shader
|
||||
DECLARE_STATIC_VERTEX_SHADER( icesurface_vs30 );
|
||||
SET_STATIC_VERTEX_SHADER( icesurface_vs30 );
|
||||
|
||||
// Pixel Shader
|
||||
if( /* g_pHardwareConfig->SupportsPixelShaders_3_0() */ true )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( icesurface_ps30 );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( BACK_SURFACE, bBackSurface );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( LIGHT_WARP, bLightWarp );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( FRESNEL_WARP, bFresnelWarp );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( OPACITY_TEXTURE, bOpacityTexture );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( INTERIOR_LAYER, bInteriorLayer );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( HIGH_PRECISION_DEPTH, (g_pHardwareConfig->GetHDRType() == HDR_TYPE_FLOAT) ? true : false );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( FLASHLIGHTDEPTHFILTERMODE, nShadowFilterMode );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( CONTACT_SHADOW, bContactShadows ); // only do contact shadows on outer shell (which has interior layer enabled)
|
||||
SET_STATIC_PIXEL_SHADER( icesurface_ps30 );
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( !"No ps_3_0" );
|
||||
}
|
||||
|
||||
// Textures
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); //[sRGB] Base
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true ); // Bump
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, false );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER2, true ); //[sRGB] Backbuffer
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER2, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER3, true ); // Spec mask
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER3, false );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER4, true ); //[sRGB] Light warp
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER4, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER5, true ); // Fresnel warp // TODO: Could be in alpha of lightwarp
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER5, false );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER6, true ); // Opacity
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER6, false );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER7, true ); //[sRGB] Envmap
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER7, true );
|
||||
|
||||
if( bHasFlashlight )
|
||||
{
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER8, true ); // Shadow depth map
|
||||
//pShaderShadow->SetShadowDepthFiltering( SHADER_SAMPLER8 );
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER8, false );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER9, true ); // Noise map
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER9, false );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER10, true ); //[sRGB] Flashlight cookie
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER10, true );
|
||||
}
|
||||
|
||||
pShaderShadow->EnableSRGBWrite( true );
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
|
||||
// Per-instance state
|
||||
pShader->PI_BeginCommandBuffer();
|
||||
pShader->PI_SetVertexShaderAmbientLightCube();
|
||||
pShader->PI_SetPixelShaderAmbientLightCube( PSREG_AMBIENT_CUBE );
|
||||
pShader->PI_SetPixelShaderLocalLighting( PSREG_LIGHT_INFO_ARRAY );
|
||||
pShader->PI_EndCommandBuffer();
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
///////////////////////
|
||||
// VERTEX SHADER SETUP
|
||||
///////////////////////
|
||||
|
||||
// Set Vertex Shader Combos
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( icesurface_vs30 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
|
||||
SET_DYNAMIC_VERTEX_SHADER( icesurface_vs30 );
|
||||
|
||||
LightState_t lightState = { 0, false, false };
|
||||
pShaderAPI->GetDX9LightState( &lightState );
|
||||
|
||||
// VS constants
|
||||
float flConsts[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
flConsts[0] = IS_PARAM_DEFINED( info.m_nUVScale ) ? params[info.m_nUVScale]->GetFloatValue() : kDefaultUVScale;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, flConsts );
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nUVProjOffset ) )
|
||||
params[info.m_nUVProjOffset]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultUVProjOffset, sizeof( kDefaultUVProjOffset ) );
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, flConsts );
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nBBMin ) )
|
||||
params[info.m_nBBMin]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultBB, sizeof( kDefaultBB ) );
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, flConsts );
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nBBMax ) )
|
||||
params[info.m_nBBMax]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultBB, sizeof( kDefaultBB ) );
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_3, flConsts );
|
||||
|
||||
//////////////////////
|
||||
// PIXEL SHADER SETUP
|
||||
//////////////////////
|
||||
|
||||
// Bind textures
|
||||
pShader->BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_SRGBREAD, BASETEXTURE );
|
||||
pShader->BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, info.m_nNormalMap, info.m_nBumpFrame );
|
||||
pShaderAPI->BindStandardTexture( SHADER_SAMPLER2, TEXTURE_BINDFLAGS_SRGBREAD, TEXTURE_FRAME_BUFFER_FULL_TEXTURE_0 ); // Refraction Map
|
||||
|
||||
if ( bSpecMap )
|
||||
{
|
||||
pShader->BindTexture( SHADER_SAMPLER3, TEXTURE_BINDFLAGS_NONE, info.m_nSpecMap );
|
||||
}
|
||||
else
|
||||
{
|
||||
pShaderAPI->BindStandardTexture( SHADER_SAMPLER3, TEXTURE_BINDFLAGS_NONE, TEXTURE_WHITE );
|
||||
}
|
||||
|
||||
if ( bLightWarp )
|
||||
{
|
||||
pShader->BindTexture( SHADER_SAMPLER4, TEXTURE_BINDFLAGS_SRGBREAD, info.m_nLightWarpTexture );
|
||||
}
|
||||
|
||||
if ( bFresnelWarp )
|
||||
{
|
||||
pShader->BindTexture( SHADER_SAMPLER5, TEXTURE_BINDFLAGS_NONE, info.m_nFresnelWarpTexture );
|
||||
}
|
||||
|
||||
if ( bOpacityTexture )
|
||||
{
|
||||
pShader->BindTexture( SHADER_SAMPLER6, TEXTURE_BINDFLAGS_NONE, info.m_nOpacityTexture );
|
||||
}
|
||||
|
||||
if ( bEnvMap )
|
||||
{
|
||||
pShader->BindTexture( SHADER_SAMPLER7, TEXTURE_BINDFLAGS_SRGBREAD, info.m_nEnvMap );
|
||||
}
|
||||
else
|
||||
{
|
||||
pShaderAPI->BindStandardTexture( SHADER_SAMPLER7, TEXTURE_BINDFLAGS_NONE, TEXTURE_BLACK );
|
||||
}
|
||||
|
||||
// flashlightfixme: put this in common code.
|
||||
bool bFlashlightShadows = false;
|
||||
if( bHasFlashlight )
|
||||
{
|
||||
Assert( info.m_nFlashlightTexture >= 0 && info.m_nFlashlightTextureFrame >= 0 );
|
||||
pShader->BindTexture( SHADER_SAMPLER10, TEXTURE_BINDFLAGS_SRGBREAD, info.m_nFlashlightTexture, info.m_nFlashlightTextureFrame );
|
||||
VMatrix worldToTexture;
|
||||
ITexture *pFlashlightDepthTexture;
|
||||
FlashlightState_t state = pShaderAPI->GetFlashlightStateEx( worldToTexture, &pFlashlightDepthTexture );
|
||||
bFlashlightShadows = state.m_bEnableShadows && ( pFlashlightDepthTexture != NULL );
|
||||
|
||||
SetFlashLightColorFromState( state, pShaderAPI, PSREG_FLASHLIGHT_COLOR );
|
||||
|
||||
if( pFlashlightDepthTexture && g_pConfig->ShadowDepthTexture() && state.m_bEnableShadows )
|
||||
{
|
||||
pShader->BindTexture( SHADER_SAMPLER8, TEXTURE_BINDFLAGS_SHADOWDEPTH, pFlashlightDepthTexture );
|
||||
pShaderAPI->BindStandardTexture( SHADER_SAMPLER9, TEXTURE_BINDFLAGS_NONE, TEXTURE_SHADOW_NOISE_2D );
|
||||
}
|
||||
|
||||
float atten[4], pos[4], tweaks[4];
|
||||
|
||||
atten[0] = state.m_fConstantAtten; // Set the flashlight attenuation factors
|
||||
atten[1] = state.m_fLinearAtten;
|
||||
atten[2] = state.m_fQuadraticAtten;
|
||||
atten[3] = state.m_FarZAtten;
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_FLASHLIGHT_ATTENUATION, atten, 1 );
|
||||
|
||||
pos[0] = state.m_vecLightOrigin[0]; // Set the flashlight origin
|
||||
pos[1] = state.m_vecLightOrigin[1];
|
||||
pos[2] = state.m_vecLightOrigin[2];
|
||||
pos[3] = state.m_FarZ;
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_FLASHLIGHT_POSITION_RIM_BOOST, pos, 1 ); // steps on rim boost
|
||||
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_FLASHLIGHT_TO_WORLD_TEXTURE, worldToTexture.Base(), 4 );
|
||||
|
||||
// Tweaks associated with a given flashlight
|
||||
tweaks[0] = ShadowFilterFromState( state );
|
||||
tweaks[1] = ShadowAttenFromState( state );
|
||||
pShader->HashShadow2DJitter( state.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 );
|
||||
|
||||
int nTexWidth, nTexHeight;
|
||||
pShaderAPI->GetStandardTextureDimensions( &nTexWidth, &nTexHeight, TEXTURE_SHADOW_NOISE_2D );
|
||||
|
||||
vScreenScale[0] = (float) nWidth / nTexWidth;
|
||||
vScreenScale[1] = (float) nHeight / nTexHeight;
|
||||
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_FLASHLIGHT_SCREEN_SCALE, vScreenScale, 1 );
|
||||
|
||||
if ( IsX360() )
|
||||
{
|
||||
pShaderAPI->SetBooleanPixelShaderConstant( 0, &state.m_nShadowQuality, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
flConsts[0] = IS_PARAM_DEFINED( info.m_nBumpStrength ) ? params[info.m_nBumpStrength]->GetFloatValue() : kDefaultBumpStrength;
|
||||
flConsts[1] = (g_pHardwareConfig->GetHDRType() == HDR_TYPE_FLOAT) ? 8192.0f : 192.0f; // destalpha dest scale factor. TODO: put this in its own const and call shaderAPI method to set
|
||||
flConsts[2] = IS_PARAM_DEFINED( info.m_nInteriorFogStrength ) ? params[info.m_nInteriorFogStrength]->GetFloatValue() : kDefaultInteriorFogStrength;
|
||||
flConsts[3] = IS_PARAM_DEFINED( info.m_nInteriorRefractStrength ) ? params[info.m_nInteriorRefractStrength]->GetFloatValue() : kDefaultInteriorRefractStrength;
|
||||
pShaderAPI->SetPixelShaderConstant( 0, flConsts, 1 );
|
||||
|
||||
Assert( IS_PARAM_DEFINED( info.m_nFresnelParams ) );
|
||||
if ( IS_PARAM_DEFINED( info.m_nFresnelParams ) )
|
||||
params[info.m_nFresnelParams]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultFresnelParams, sizeof( kDefaultFresnelParams ) );
|
||||
flConsts[3] = params[info.m_nInteriorBackgroundBoost]->GetFloatValue();
|
||||
pShaderAPI->SetPixelShaderConstant( 1, flConsts, 1 );
|
||||
|
||||
flConsts[0] = IS_PARAM_DEFINED( info.m_nRimLightExp ) ? params[info.m_nRimLightExp]->GetFloatValue() : kDefaultRimLightExp;
|
||||
flConsts[1] = IS_PARAM_DEFINED( info.m_nRimLightScale ) ? params[info.m_nRimLightScale]->GetFloatValue() : kDefaultRimLightScale;
|
||||
flConsts[2] = IS_PARAM_DEFINED( info.m_nSpecScale ) ? params[info.m_nSpecScale]->GetFloatValue() : kDefaultSpecScale;
|
||||
flConsts[3] = IS_PARAM_DEFINED( info.m_nSpecExp2 ) ? params[info.m_nSpecExp2]->GetFloatValue() : kDefaultSpecExp;
|
||||
pShaderAPI->SetPixelShaderConstant( 3, flConsts, 1 );
|
||||
|
||||
flConsts[0] = IS_PARAM_DEFINED( info.m_nSpecScale2 ) ? params[info.m_nSpecScale2]->GetFloatValue() : kDefaultSpecScale;
|
||||
flConsts[1] = IS_PARAM_DEFINED( info.m_nFresnelBumpStrength ) ? params[info.m_nFresnelBumpStrength]->GetFloatValue() : kDefaultFresnelBumpStrength;
|
||||
flConsts[2] = IS_PARAM_DEFINED( info.m_nDiffuseScale ) ? params[info.m_nDiffuseScale]->GetFloatValue() : kDefaultDiffuseScale;
|
||||
flConsts[3] = IS_PARAM_DEFINED( info.m_nInteriorAmbientScale ) ? params[info.m_nInteriorAmbientScale]->GetFloatValue() : kDefaultInteriorAmbientScale;
|
||||
pShaderAPI->SetPixelShaderConstant( 10, flConsts, 1 );
|
||||
|
||||
pShaderAPI->GetWorldSpaceCameraPosition( flConsts );
|
||||
flConsts[3] = IS_PARAM_DEFINED( info.m_nSpecExp ) ? params[info.m_nSpecExp]->GetFloatValue() : kDefaultSpecExp;
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, flConsts, 1 );
|
||||
|
||||
// Depth alpha [ TODO: support fog ]
|
||||
bool bWriteDepthToAlpha = pShaderAPI->ShouldWriteDepthToDestAlpha();
|
||||
flConsts[0] = bWriteDepthToAlpha ? 1.0f : 0.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_FOG_PARAMS, flConsts, 1 );
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nBaseColorTint ) )
|
||||
params[info.m_nBaseColorTint]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultBaseColorTint, sizeof( kDefaultBaseColorTint ) );
|
||||
flConsts[3] = IS_PARAM_DEFINED( info.m_nInteriorBackLightScale ) ? params[info.m_nInteriorBackLightScale]->GetFloatValue() : kDefaultInteriorBackLightScale;
|
||||
pShaderAPI->SetPixelShaderConstant( 19, flConsts, 1 );
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nInteriorColor ) )
|
||||
params[info.m_nInteriorColor]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultInteriorColor, sizeof( kDefaultInteriorColor ) );
|
||||
flConsts[3] = params[info.m_nInteriorRefractBlur]->GetFloatValue();
|
||||
pShaderAPI->SetPixelShaderConstant( 32, flConsts, 1 );
|
||||
|
||||
float mView[16];
|
||||
pShaderAPI->GetMatrix( MATERIAL_VIEW, mView );
|
||||
pShaderAPI->SetPixelShaderConstant( 33, mView, 3 );
|
||||
|
||||
flConsts[0] = IS_PARAM_DEFINED( info.m_nInteriorFogLimit ) ? params[info.m_nInteriorFogLimit]->GetFloatValue() : kDefaultInteriorFogLimit;
|
||||
flConsts[0] = 1.0f - flConsts[0];
|
||||
flConsts[1] = params[info.m_nInteriorFogNormalBoost]->GetFloatValue();
|
||||
pShaderAPI->SetPixelShaderConstant( 36, flConsts, 1 );
|
||||
|
||||
if ( IS_PARAM_DEFINED( info.m_nEnvMapTint ) )
|
||||
params[info.m_nEnvMapTint]->GetVecValue( flConsts, 3 );
|
||||
else
|
||||
memcpy( flConsts, kDefaultEnvMapTint, sizeof( kDefaultEnvMapTint ) );
|
||||
pShaderAPI->SetPixelShaderConstant( 37, flConsts, 1 );
|
||||
|
||||
// Set Pixel Shader Combos
|
||||
if( /*g_pHardwareConfig->SupportsPixelShaders_2_b()*/ true )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( icesurface_ps30 );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( NUM_LIGHTS, lightState.m_nNumLights );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHT, bHasFlashlight );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows );
|
||||
SET_DYNAMIC_PIXEL_SHADER( icesurface_ps30 );
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( !"No ps_3_0" );
|
||||
}
|
||||
}
|
||||
|
||||
pShader->Draw();
|
||||
}
|
||||
107
materialsystem/stdshaders/IceSurface_helper.h
Normal file
107
materialsystem/stdshaders/IceSurface_helper.h
Normal file
@@ -0,0 +1,107 @@
|
||||
//========= Copyright (c) 1996-2007, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#ifndef ICESURFACE_HELPER_H
|
||||
#define ICESURFACE_HELPER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBaseVSShader;
|
||||
class IMaterialVar;
|
||||
class IShaderDynamicAPI;
|
||||
class IShaderShadow;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Struct to hold shader param indices
|
||||
//-----------------------------------------------------------------------------
|
||||
struct IceSurfaceVars_t
|
||||
{
|
||||
IceSurfaceVars_t()
|
||||
{
|
||||
memset( this, 0xFF, sizeof( IceSurfaceVars_t ) );
|
||||
}
|
||||
|
||||
int m_nBackSurface;
|
||||
int m_nBumpStrength;
|
||||
int m_nFresnelBumpStrength;
|
||||
int m_nNormalMap;
|
||||
int m_nBaseTexture;
|
||||
int m_nLightWarpTexture;
|
||||
int m_nFresnelWarpTexture;
|
||||
int m_nOpacityTexture;
|
||||
int m_nSpecMap;
|
||||
int m_nUVScale;
|
||||
int m_nEnvMap;
|
||||
|
||||
int m_nInteriorEnable;
|
||||
int m_nInteriorFogStrength;
|
||||
int m_nInteriorFogLimit;
|
||||
int m_nInteriorFogNormalBoost;
|
||||
int m_nInteriorBackgroundBoost;
|
||||
int m_nInteriorAmbientScale;
|
||||
int m_nInteriorBackLightScale;
|
||||
int m_nInteriorColor;
|
||||
int m_nInteriorRefractStrength;
|
||||
int m_nInteriorRefractBlur;
|
||||
|
||||
int m_nFresnelParams;
|
||||
int m_nDiffuseScale;
|
||||
int m_nSpecExp;
|
||||
int m_nSpecScale;
|
||||
int m_nSpecExp2;
|
||||
int m_nSpecScale2;
|
||||
int m_nRimLightExp;
|
||||
int m_nRimLightScale;
|
||||
int m_nBaseColorTint;
|
||||
int m_nEnvMapTint;
|
||||
int m_nUVProjOffset;
|
||||
int m_nBBMin;
|
||||
int m_nBBMax;
|
||||
int m_nFlashlightTexture;
|
||||
int m_nFlashlightTextureFrame;
|
||||
int m_nBumpFrame;
|
||||
int m_nContactShadows;
|
||||
};
|
||||
|
||||
// default shader param values
|
||||
static const int kDefaultBackSurface = 0;
|
||||
static const float kDefaultBumpStrength = 1.0f;
|
||||
static const float kDefaultFresnelBumpStrength = 1.0f;
|
||||
static const float kDefaultUVScale = 0.02f;
|
||||
|
||||
static const int kDefaultInteriorEnable = 1;
|
||||
static const float kDefaultInteriorFogStrength = 0.06f;
|
||||
static const float kDefaultInteriorFogLimit = 0.8f;
|
||||
static const float kDefaultInteriorFogNormalBoost = 0.0f;
|
||||
static const float kDefaultInteriorBackgroundBoost = 0.0f;
|
||||
static const float kDefaultInteriorAmbientScale = 0.3f;
|
||||
static const float kDefaultInteriorBackLightScale = 0.3f;
|
||||
static const float kDefaultInteriorColor[3] = { 0.5f, 0.5f, 0.5f };
|
||||
static const float kDefaultInteriorRefractStrength = 0.015f;
|
||||
static const float kDefaultInteriorRefractBlur = 0.2f;
|
||||
|
||||
static const float kDefaultFresnelParams[3] = { 0.0f, 0.5f, 2.0f };
|
||||
static const float kDefaultBaseColorTint[3] = { 1.0f, 1.0f, 1.0f };
|
||||
static const float kDefaultEnvMapTint[3] = { 1.0f, 1.0f, 1.0f };
|
||||
static const float kDefaultDiffuseScale = 1.0f;
|
||||
static const float kDefaultSpecExp = 1.0f;
|
||||
static const float kDefaultSpecScale = 1.0f;
|
||||
static const float kDefaultRimLightExp = 10.0f;
|
||||
static const float kDefaultRimLightScale = 1.0f;
|
||||
static const float kDefaultUVProjOffset[3] = { 0.0f, 0.0f, 0.0f };
|
||||
static const float kDefaultBB[3] = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
static const int kDefaultBumpFrame = 0;
|
||||
static const int kDefaultContactShadows = 0;
|
||||
|
||||
void InitParamsIceSurface( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, IceSurfaceVars_t &info );
|
||||
void InitIceSurface( CBaseVSShader *pShader, IMaterialVar** params, IceSurfaceVars_t &info );
|
||||
void DrawIceSurface( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI,
|
||||
IShaderShadow* pShaderShadow, IceSurfaceVars_t &info, VertexCompressionType_t vertexCompression );
|
||||
|
||||
#endif // ICESURFACE_HELPER_H
|
||||
537
materialsystem/stdshaders/IceSurface_ps30.fxc
Normal file
537
materialsystem/stdshaders/IceSurface_ps30.fxc
Normal file
@@ -0,0 +1,537 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// STATIC: "BACK_SURFACE" "0..1"
|
||||
// STATIC: "LIGHT_WARP" "0..1"
|
||||
// STATIC: "FRESNEL_WARP" "0..1"
|
||||
// STATIC: "HIGH_PRECISION_DEPTH" "0..1"
|
||||
// STATIC: "INTERIOR_LAYER" "0..1"
|
||||
// STATIC: "OPACITY_TEXTURE" "0..1"
|
||||
// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..3" [ps20b] [PC]
|
||||
// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps30] [PC]
|
||||
// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX]
|
||||
// STATIC: "CONTACT_SHADOW" "0..1"
|
||||
// DYNAMIC: "NUM_LIGHTS" "0..4" [ps20b]
|
||||
// DYNAMIC: "NUM_LIGHTS" "0..4" [ps30]
|
||||
// DYNAMIC: "FLASHLIGHT" "0..1"
|
||||
// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1"
|
||||
|
||||
// For now, 'BACK_SURFACE' is a dead-simple path (just writes depth into dest alpha), so skip all non-HW-config combos:
|
||||
// SKIP: ( $BACK_SURFACE == 1 ) && ( $LIGHT_WARP > 0 )
|
||||
// SKIP: ( $BACK_SURFACE == 1 ) && ( $FRESNEL_WARP > 0 )
|
||||
// SKIP: ( $BACK_SURFACE == 1 ) && ( $INTERIOR_LAYER > 0 )
|
||||
// SKIP: ( $BACK_SURFACE == 1 ) && ( $OPACITY_TEXTURE > 0 )
|
||||
// SKIP: ( $BACK_SURFACE == 1 ) && ( $CONTACT_SHADOW > 0 )
|
||||
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "shader_constant_register_map.h"
|
||||
|
||||
// SAMPLERS
|
||||
sampler g_tBase : register( s0 );
|
||||
sampler g_tBump : register( s1 );
|
||||
sampler g_tScreen : register( s2 );
|
||||
sampler g_tSpecMask : register( s3 );
|
||||
sampler g_tLightWarp : register( s4 );
|
||||
sampler g_tFresnelWarp : register( s5 );
|
||||
sampler g_tOpacity : register( s6 );
|
||||
sampler g_tEnvironment : register( s7 );
|
||||
sampler g_tShadowDepth : register( s8 ); // Flashlight shadow depth map sampler
|
||||
sampler g_tNormalizeRandRot : register( s9 ); // Normalization / RandomRotation samplers
|
||||
sampler g_tFlashlightCookie : register( s10 ); // Flashlight cookie
|
||||
|
||||
// SHADER CONSTANTS
|
||||
const float4 g_vMisc : register( c0 );
|
||||
#define g_flBumpStrength g_vMisc.x
|
||||
#define g_flDepthScale g_vMisc.y
|
||||
#define g_flInnerFogStrength g_vMisc.z
|
||||
#define g_flRefractStrength g_vMisc.w
|
||||
|
||||
const float4 g_vTranslucentFresnelParams_InteriorBoost : register( c1 );
|
||||
#define g_vTranslucentFresnelParams g_vTranslucentFresnelParams_InteriorBoost.xyz
|
||||
#define g_flInteriorBoost g_vTranslucentFresnelParams_InteriorBoost.w
|
||||
|
||||
const float4 g_vMisc2 : register( c3 );
|
||||
#define g_flRimLightExp g_vMisc2.x
|
||||
#define g_flRimLightScale g_vMisc2.y
|
||||
#define g_flSpecScale g_vMisc2.z
|
||||
#define g_flSpecExp2 g_vMisc2.w
|
||||
|
||||
const float4 g_vMisc3 : register( c10 );
|
||||
#define g_flSpecScale2 g_vMisc3.x
|
||||
#define g_flFresnelBumpStrength g_vMisc3.y
|
||||
#define g_flDiffuseScale g_vMisc3.z
|
||||
#define g_flInteriorLightScale g_vMisc3.w
|
||||
|
||||
const float4 g_vEyePos_SpecExp : register( PSREG_EYEPOS_SPEC_EXPONENT );
|
||||
#define g_vEyePos g_vEyePos_SpecExp.xyz
|
||||
#define g_flSpecExp g_vEyePos_SpecExp.w
|
||||
|
||||
const float4 g_ShaderControls : register( c12 );
|
||||
#define g_fWriteDepthToAlpha g_ShaderControls.x
|
||||
|
||||
const float4 g_vBaseTint_InteriorBackLightScale : register( c19 );
|
||||
#define g_cBaseTint g_vBaseTint_InteriorBackLightScale.rgb
|
||||
#define g_flInteriorBackLightScale g_vBaseTint_InteriorBackLightScale.w
|
||||
|
||||
// TODO: pass in FOV so that we can account for it properly
|
||||
#define g_flHalfWindowWidth 1 /* tan(fov/2) */
|
||||
|
||||
const float4 g_vInteriorColor_RefractBlur : register( c32 );
|
||||
#define g_cInteriorColor g_vInteriorColor_RefractBlur.rgb
|
||||
#define g_flRefractBlur g_vInteriorColor_RefractBlur.w
|
||||
|
||||
// TODO: unify this across pixel shaders (declare the constants in common_ps_fxc.h, as is already done for vertex shader ambient)
|
||||
const float3 cAmbientCube[6] : register( PSREG_AMBIENT_CUBE );
|
||||
|
||||
const PixelShaderLightInfo g_sLightInfo[3] : register( PSREG_LIGHT_INFO_ARRAY ); // 2 registers each - 6 registers total
|
||||
|
||||
const float4 g_vFlashlightAttenuationFactors_FarZ : register( PSREG_FLASHLIGHT_ATTENUATION );
|
||||
#define g_vFlashlightAttenuationFactors g_vFlashlightAttenuationFactors_FarZ.xyz
|
||||
#define g_flFlashlightFarZ g_vFlashlightAttenuationFactors_FarZ.w
|
||||
const float4 g_vFlashlightPos_RimBoost : register( PSREG_FLASHLIGHT_POSITION_RIM_BOOST );
|
||||
#define g_vFlashlightPos g_vFlashlightPos_RimBoost.xyz
|
||||
const float4x4 g_mFlashlightWorldToTexture : register( PSREG_FLASHLIGHT_TO_WORLD_TEXTURE );
|
||||
const float4 g_vShadowTweaks : register( PSREG_ENVMAP_TINT__SHADOW_TWEAKS );
|
||||
|
||||
const float3x3 g_mView : register( c33 );
|
||||
|
||||
const float4 g_vMisc4 : register( c36 );
|
||||
#define g_flLimitFogAtten g_vMisc4.x
|
||||
#define g_flFogNormalBoost g_vMisc4.y
|
||||
//#define UNUSED g_vMisc4.z
|
||||
//#define UNUSED g_vMisc4.w
|
||||
|
||||
const float4 g_cEnvMapTint : register( c37 );
|
||||
//#define UNUSED g_cEnvMapTint.w
|
||||
|
||||
// COMBO-DERIVED CONSTANTS
|
||||
static const bool bLightWarp = LIGHT_WARP ? true : false;
|
||||
static const bool bFlashLight = FLASHLIGHT ? true : false;
|
||||
|
||||
|
||||
// INPUT STRUCT
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 vWorldNormal : TEXCOORD0; // w is proj. z coord (for depth stuff)
|
||||
float4 vClosestSurfaceDir : TEXCOORD1; // Used if CONTACT_SHADOW is on
|
||||
float4 vWorldPos : TEXCOORD2; // w is proj. w coord
|
||||
float4 vUV0 : TEXCOORD3;
|
||||
float4 vUV1 : TEXCOORD4;
|
||||
float4 vLightAtten : TEXCOORD5;
|
||||
float3 vLightCube : TEXCOORD6;
|
||||
};
|
||||
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float Luminance( const float3 colour )
|
||||
{
|
||||
return dot( colour, float3( 0.3, 0.59, 0.11 ) );
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float3 ComputeTextureBlendWeights( float3 vWorldNormal )
|
||||
{
|
||||
float3 vBlendWeights = max( ( abs( vWorldNormal.xyz ) - 0.2 ) * 7.0, 0.0 );
|
||||
vBlendWeights /= dot( vBlendWeights, float3(1, 1, 1) ); // normalize
|
||||
return vBlendWeights;
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float4 BlendedTexFetch( sampler s, float2 vUV0, float2 vUV1, float2 vUV2, float3 vBlendWeights )
|
||||
{
|
||||
float4 vFetch0 = tex2D( s, vUV0 );
|
||||
float4 vFetch1 = tex2D( s, vUV1 );
|
||||
float4 vFetch2 = tex2D( s, vUV2 );
|
||||
return vBlendWeights.x * vFetch0 + vBlendWeights.y * vFetch1 + vBlendWeights.z * vFetch2;
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float3 BumpedToWorldNormal( float3 vBumpedNormal,
|
||||
float3 vVertexNormal, // should be normalized
|
||||
float3 vTangentDir )
|
||||
{
|
||||
float3x3 mTanToWorld;
|
||||
mTanToWorld[2] = vVertexNormal;
|
||||
mTanToWorld[0] = vTangentDir - dot( vTangentDir, vVertexNormal ) * vVertexNormal;
|
||||
mTanToWorld[0] = normalize( mTanToWorld[0] );
|
||||
mTanToWorld[1] = cross( mTanToWorld[0], mTanToWorld[2] );
|
||||
return normalize( mul( vBumpedNormal, mTanToWorld ) );
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
void BlendedTexFetchNormal( sampler s, float2 vUV0, float2 vUV1, float2 vUV2, float3 vBlendWeights, float3 vWorldNormal,
|
||||
// Function outputs:
|
||||
out float2 vBumpedTSNormal, out float3 vBumpedWorldNormal, out float3 vFresnelWorldNormal )
|
||||
{
|
||||
float3 vNormalTS1 = 2.0 * tex2D( g_tBump, vUV0 ) - 1.0;
|
||||
float3 vNormalTS2 = 2.0 * tex2D( g_tBump, vUV1 ) - 1.0;
|
||||
float3 vNormalTS3 = 2.0 * tex2D( g_tBump, vUV2 ) - 1.0;
|
||||
vBumpedTSNormal = vBlendWeights.x * vNormalTS1.xy + vBlendWeights.y * vNormalTS2.xy + vBlendWeights.z * vNormalTS3.xy;
|
||||
|
||||
float3 vBumpedNormal1 = BumpedToWorldNormal( vNormalTS1, vWorldNormal, float3( 0, 1, 0 ) );
|
||||
float3 vBumpedNormal2 = BumpedToWorldNormal( vNormalTS2, vWorldNormal, float3( 1, 0, 0 ) );
|
||||
float3 vBumpedNormal3 = BumpedToWorldNormal( vNormalTS3, vWorldNormal, float3( 1, 0, 0 ) );
|
||||
vBumpedWorldNormal = vBlendWeights.x * vBumpedNormal1 + vBlendWeights.y * vBumpedNormal2 + vBlendWeights.z * vBumpedNormal3;
|
||||
|
||||
// Apply bump strength in world space (this is cheaper because we have to do it twice, for normal and fresnel bumpstrength)
|
||||
float3 vBumpStrengthDir = vBumpedWorldNormal - dot( vBumpedWorldNormal, vWorldNormal ) * vWorldNormal;
|
||||
vFresnelWorldNormal = normalize( vBumpedWorldNormal + ( g_flFresnelBumpStrength - 1.0 ) * vBumpStrengthDir );
|
||||
vBumpedWorldNormal = normalize( vBumpedWorldNormal + ( g_flBumpStrength - 1.0 ) * vBumpStrengthDir );
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
void ComputeOpacityAndFresnel( float2 vUV0, float2 vUV1, float2 vUV2, float3 vBlendWeights,
|
||||
float3 vEyeDir, float3 vWorldNormal,
|
||||
// Function outputs:
|
||||
out float flSkinOpacity, out float flFresnel )
|
||||
{
|
||||
flSkinOpacity = 1;
|
||||
#if OPACITY_TEXTURE == 1
|
||||
flSkinOpacity = BlendedTexFetch( g_tOpacity, vUV0, vUV1, vUV2, vBlendWeights );
|
||||
#endif
|
||||
|
||||
flFresnel = saturate( 1.0 - dot( vEyeDir.xyz, vWorldNormal.xyz ) );
|
||||
#if FRESNEL_WARP == 1
|
||||
float fTranslucentFresnel = tex1D( g_tFresnelWarp, flFresnel );
|
||||
#else
|
||||
float fTranslucentFresnel = lerp( g_vTranslucentFresnelParams.x, g_vTranslucentFresnelParams.y, pow( flFresnel, g_vTranslucentFresnelParams.z ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float3 CubeAverage( void )
|
||||
{
|
||||
// FIXME: Pass this average light color in as a const
|
||||
float3 cAvgLight = 0.0;
|
||||
for( int j = 0; j < 6; j++ ) cAvgLight += cAmbientCube[j] / 6.0;
|
||||
return cAvgLight;
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float3 IceAmbientLight( float3 vVertexAmbient, float3 vEyeDir, float3 vWorldNormal, float flFresnel,
|
||||
// Function outputs:
|
||||
out float3 cAmbient, out float3 cAvgAmbient )
|
||||
{
|
||||
// Ambient lighting now comes from VS
|
||||
cAmbient = vVertexAmbient;
|
||||
|
||||
// TODO: Replace lambert diffuse with pixelshader-ambient term of full lighting env.
|
||||
//cAmbient = PixelShaderAmbientLight( vBumpedWorldNormal, cAmbientCube );
|
||||
|
||||
// TODO: Ambient sheen on the outer layer
|
||||
//float3 cAmbientSheen = PixelShaderAmbientLight( reflect( -vEyeDir, vBumpedWorldNormal ), cAmbientCube );
|
||||
//cAmbient = lerp( cAmbient, cAmbientSheen, flFresnel );
|
||||
|
||||
cAvgAmbient = CubeAverage();
|
||||
|
||||
return cAmbient;
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
void IceDynamicLight( float3 vWorldPos, float3 vEyeDir, float3 vBumpedWorldNormal, float4 vLightAtten, float flFresnel,
|
||||
// Function outputs:
|
||||
out float3 cDiffuse, out float3 cSpec, out float3 cSpec2, out float3 cRim )
|
||||
{
|
||||
cDiffuse = cSpec = cSpec2 = cRim = 0;
|
||||
|
||||
for ( int l = 0; l < NUM_LIGHTS; l++ )
|
||||
{
|
||||
cDiffuse.rgb += vLightAtten[l] * PixelShaderGetLightColor( g_sLightInfo, l ) *
|
||||
DiffuseTerm( true, vBumpedWorldNormal, PixelShaderGetLightVector( vWorldPos, g_sLightInfo, l ),
|
||||
bLightWarp, g_tLightWarp );
|
||||
|
||||
// spec 1
|
||||
float3 cCurrSpec, cCurrRim;
|
||||
bool bYesRimLight = true;
|
||||
SpecularAndRimTerms( vBumpedWorldNormal, PixelShaderGetLightVector( vWorldPos, g_sLightInfo, l ), g_flSpecExp, vEyeDir,
|
||||
false, g_tBump, 1.0, // dummy spec warp sampler & fresnel
|
||||
PixelShaderGetLightColor( g_sLightInfo, l ),
|
||||
bYesRimLight, g_flRimLightExp,
|
||||
cCurrSpec, cCurrRim );
|
||||
cSpec += vLightAtten[l] * cCurrSpec;
|
||||
cRim += vLightAtten[l] * cCurrRim;
|
||||
|
||||
// spec 2
|
||||
float3 cCurrSpec2, cDummy;
|
||||
bool bNoRimLight = false;
|
||||
SpecularAndRimTerms( vBumpedWorldNormal, PixelShaderGetLightVector( vWorldPos, g_sLightInfo, l ), g_flSpecExp2, vEyeDir,
|
||||
false, g_tBump, 1.0, // dummy spec warp sampler & fresnel
|
||||
PixelShaderGetLightColor( g_sLightInfo, l ),
|
||||
bNoRimLight, g_flRimLightExp,
|
||||
cCurrSpec2, cDummy );
|
||||
cSpec2 += vLightAtten[l] * cCurrSpec2;
|
||||
// FIXME: no rim2 term?
|
||||
}
|
||||
|
||||
cRim *= flFresnel * flFresnel * flFresnel * flFresnel;
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
void IceFlashlight( float3 vWorldPos, float3 vEyeDir, float3 vWorldNormal, float2 vScreenPos, float flSpecularExponent,
|
||||
// Function outputs:
|
||||
out float3 cOutFlashlightDiffuse, out float3 cOutFlashlightSpec, out float3 cOutFlashlightColor )
|
||||
{
|
||||
float3 delta = g_vFlashlightPos - vWorldPos;
|
||||
float3 vLightVec = normalize( delta );
|
||||
float distSquared = dot( delta, delta );
|
||||
float dist = sqrt( distSquared );
|
||||
|
||||
// Attenuation for light and to fade out shadow over distance
|
||||
float fAtten = saturate( dot( g_vFlashlightAttenuationFactors, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) );
|
||||
float endFalloffFactor = RemapValClamped( dist, g_flFlashlightFarZ, 0.6f * g_flFlashlightFarZ, 0.0f, 1.0f );
|
||||
|
||||
// Project into flashlight texture
|
||||
float4 flashlightSpacePosition = mul( float4( vWorldPos, 1.0f ), g_mFlashlightWorldToTexture ); // TODO: this can be moved to VS
|
||||
float3 vProjCoords = flashlightSpacePosition.xyz / flashlightSpacePosition.w;
|
||||
|
||||
// Flashlight colour
|
||||
cOutFlashlightColor = tex2D( g_tFlashlightCookie, vProjCoords );
|
||||
#if defined(SHADER_MODEL_PS_2_0) || defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0)
|
||||
cOutFlashlightColor *= cFlashlightColor.xyz;
|
||||
#endif
|
||||
cOutFlashlightColor *= endFalloffFactor * fAtten;
|
||||
|
||||
// Flashlight shadow
|
||||
#if (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0))
|
||||
if ( FLASHLIGHTSHADOWS )
|
||||
{
|
||||
float flShadow = DoFlashlightShadow( g_tShadowDepth, g_tNormalizeRandRot, vProjCoords, vScreenPos,
|
||||
FLASHLIGHTDEPTHFILTERMODE, g_vShadowTweaks );
|
||||
float flAttenuated = lerp( flShadow, 1.0f, g_vShadowTweaks.y ); // Blend between fully attenuated and not attenuated
|
||||
flShadow = saturate( lerp( flAttenuated, flShadow, fAtten ) ); // Blend between shadow and above, according to light attenuation
|
||||
cOutFlashlightColor *= flShadow; // Shadow term
|
||||
}
|
||||
#endif
|
||||
|
||||
// Flashlight diffuse term
|
||||
cOutFlashlightDiffuse = cOutFlashlightColor * DiffuseTerm( true, vWorldNormal, vLightVec, bLightWarp, g_tLightWarp );
|
||||
|
||||
// Flashlight specular term
|
||||
float3 cDummy;
|
||||
SpecularAndRimTerms( vWorldNormal, vLightVec, flSpecularExponent, -vEyeDir,
|
||||
false, g_tBump, 1.0, // dummy spec warp sampler & fresnel
|
||||
cOutFlashlightColor,
|
||||
false, g_flRimLightExp,
|
||||
cOutFlashlightSpec, cDummy );
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float4 SampleBackgroundBlurred( float2 vBumpedTSNormal, float3 vWorldNormal, float2 vScreenPos, float flCamDist )
|
||||
{
|
||||
static const float2 vPoissonOffset[8] = { float2( 0.3475f, 0.0042f ), float2( 0.8806f, 0.3430f ),
|
||||
float2( -0.0041f, -0.6197f ), float2( 0.0472f, 0.4964f ),
|
||||
float2( -0.3730f, 0.0874f ), float2( -0.9217f, -0.3177f ),
|
||||
float2( -0.6289f, 0.7388f ), float2( 0.5744f, -0.7741f ) };
|
||||
// TODO: get framebuffer res from constants
|
||||
float2 vScreenRes = float2( 1600, 1200 );
|
||||
float2 g_vInvScreenRes = 1.0 / vScreenRes;
|
||||
|
||||
// Project world-space blur radius into screen space.
|
||||
float flBlurRadius = g_flRefractBlur * ( vScreenRes.x / ( flCamDist * g_flHalfWindowWidth ) );
|
||||
|
||||
// Bumped refract
|
||||
float flRefractStrength = 80.0 * g_flRefractStrength / ( flCamDist * g_flHalfWindowWidth );
|
||||
float2 vBackgroundUV = flRefractStrength * vBumpedTSNormal + vScreenPos;
|
||||
/* // This gives the ice a more crystal-bally refractive look, which looks cool up-close, but looks weird when
|
||||
// it pulls foreground pixels in. It could work well if the innards were rendered into their own texture.
|
||||
float3 vOffset = mul( g_mView, normalize( -vWorldNormal ) );
|
||||
float2 vBackgroundUV = 0.07 * vOffset.xy + 0.03 * vBumpedTSNormal + vScreenPos; */
|
||||
|
||||
float4 cOut = 0;
|
||||
for( int i = 0; i < 8; i++ )
|
||||
{
|
||||
cOut += 1.0/8.0 * tex2D( g_tScreen, vBackgroundUV + flBlurRadius * g_vInvScreenRes.xy * vPoissonOffset[i] );
|
||||
}
|
||||
return cOut;
|
||||
}
|
||||
|
||||
float3 IceInterior( float3 vWorldNormal, float2 vBumpedTSNormal, float3 vEyeDir,
|
||||
float2 vScreenPos, float flPixelDepth, float flCamDist, float3 cAvgAmbient, float3 cFlashlightColor )
|
||||
{
|
||||
float3 cInterior = 0;
|
||||
|
||||
// Sample the background (TODO: and inner ice geometry?)
|
||||
float4 cBackground = SampleBackgroundBlurred( vBumpedTSNormal, vWorldNormal, vScreenPos, flCamDist );
|
||||
// Boost bright background pixels
|
||||
float flLuminance = Luminance( cBackground.rgb );
|
||||
cBackground.rgb *= 1.0 + g_flInteriorBoost * flLuminance * flLuminance;
|
||||
|
||||
// Fake refract-like vector without any total internal reflection crappiness
|
||||
float3 vRefract = normalize( -( vEyeDir + vWorldNormal ) );
|
||||
|
||||
// Interior lighting through ambient cube
|
||||
float3 interiorColor = g_cInteriorColor;
|
||||
float3 cBackLight = PixelShaderAmbientLight( vRefract, cAmbientCube );
|
||||
float3 cAvgLight = cAvgAmbient + ( 0.6 * cFlashlightColor );
|
||||
cBackLight = max( g_flInteriorLightScale * cAvgLight, g_flInteriorBackLightScale * cBackLight );
|
||||
|
||||
// Get eye ray travel distance through the ice
|
||||
float flBackgroundDepth = cBackground.a * g_flDepthScale;
|
||||
float flDistThroughIce = flBackgroundDepth - flPixelDepth;
|
||||
#if HIGH_PRECISION_DEPTH == 0
|
||||
// Fade to constant interior fogginess as we run against the low-precision destalpha depth limit
|
||||
flDistThroughIce = lerp( flDistThroughIce, g_flDepthScale, saturate( cBackground.a*cBackground.a*cBackground.a ) );
|
||||
#endif
|
||||
|
||||
// Modify thickness based on normals (assume edge-on ice is thicker w.r.t the camera)
|
||||
// TODO: this gives a bit of depth variation based on normals - draw ice back surfaces into depth to improve this
|
||||
float facing = saturate( dot( vEyeDir, vWorldNormal ) ) - 1;
|
||||
float flFogNormalBoost = g_flFogNormalBoost;
|
||||
flDistThroughIce *= 1 + flFogNormalBoost*facing*facing;
|
||||
//facing = lerp( 1, (facing+1), 0.1f*g_flFogNormalBoost );
|
||||
//flDistThroughIce /= facing*facing;
|
||||
|
||||
// So that ice in dark areas doesn't glow, reduce thickness based on ambient/backlight luminance
|
||||
float flBackLightLuminance = Luminance( cBackLight );
|
||||
flDistThroughIce *= flBackLightLuminance;
|
||||
|
||||
// TODO: add a depth-based colour warp
|
||||
//interiorColor = saturate( interiorColor - 0.4f*( 1 - facing));
|
||||
//interiorColor = saturate( interiorColor + max(-0.3f, (facing-1) ) );
|
||||
//interiorColor = lerp( interiorColor, float3(0,0,0.2), 0.7f*(1-facing));
|
||||
|
||||
// Compute the opacity ('fog') of the ice interior volume, based on its thickness
|
||||
float flFogAtten = pow( 2.0, -flDistThroughIce * g_flInnerFogStrength ); // exponential falloff
|
||||
//float flFogAtten = saturate( 0.5 - 0.011 * flDistThroughIce ); // linear falloff
|
||||
|
||||
// TODO: add a depth-based colour warp
|
||||
//interiorColor = saturate( interiorColor - 0.5*( 1 - flFogAtten)*(1-flFogAtten) );
|
||||
|
||||
// Composite the fog interior lighting/fog over the background
|
||||
cBackLight *= interiorColor;
|
||||
cInterior = lerp( cBackLight, cBackground.rgb, flFogAtten );
|
||||
|
||||
//float flInScattering = flDistThroughIce * 0.002;
|
||||
//cInterior.rgb += flInScattering * i.vLightCube.rgb;
|
||||
|
||||
return cInterior;
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float IceContactShadow( float3 vWorldNormal, float4 vClosestSurfaceDir )
|
||||
{
|
||||
// contact darkening for ice regions that touch a surface
|
||||
float3 vSurfaceDir = normalize( vClosestSurfaceDir.xyz ) * vClosestSurfaceDir.w;
|
||||
float flContactShadow = saturate( 0.8 * ( 1.0 - dot( vSurfaceDir, vWorldNormal ) ) + 0.2 );
|
||||
flContactShadow = lerp ( 0.3, 1.0, flContactShadow * flContactShadow * flContactShadow );
|
||||
return flContactShadow;
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float3 noise( float3 coord )
|
||||
{
|
||||
coord.z *= 50.0;
|
||||
float zfrac = frac( coord.z );
|
||||
float2 zhash = float2( coord.z, 1 + coord.z );
|
||||
zhash -= frac( zhash );
|
||||
zhash = ( zhash * zhash );
|
||||
zhash -= 31.0 * floor( zhash / 31.0 );
|
||||
zhash = ( zhash * zhash );
|
||||
zhash -= 31.0 * floor( zhash / 31.0 );
|
||||
zhash *= 1.0/31.0;
|
||||
float3 c0 = tex2D( g_tBase, float4( coord.xy + float2( 0, zhash.x ), 0, 0 ) ).rgb;
|
||||
float3 c1 = tex2D( g_tBase, float4( coord.xy + float2( 0, zhash.y ), 0, 0 ) ).rgb;
|
||||
|
||||
float3 rslt = lerp( c0, c1, zfrac );
|
||||
return rslt;
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4 cOut = { 0, 0, 0, 1 };
|
||||
|
||||
// Set up misc camera variables
|
||||
float flPixelDepth = i.vWorldNormal.w;
|
||||
float2 vScreenPos = i.vUV1.wz / i.vWorldPos.w;
|
||||
float3 vEyeDir = g_vEyePos.xyz - i.vWorldPos.xyz;
|
||||
float flCamDist = length( vEyeDir );
|
||||
vEyeDir /= flCamDist;
|
||||
|
||||
|
||||
// For now, 'BACK_SURFACE' is a dead-simple path (just writes depth into dest alpha)
|
||||
#if ( BACK_SURFACE == 1 )
|
||||
cOut = tex2D( g_tScreen, vScreenPos );
|
||||
return FinalOutput( cOut, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR, g_fWriteDepthToAlpha, flPixelDepth );
|
||||
#endif
|
||||
|
||||
|
||||
// Blend weights for 3 blended planar projections
|
||||
float3 vWorldNormal = normalize( i.vWorldNormal.xyz );
|
||||
float3 vBlendWeights = ComputeTextureBlendWeights( vWorldNormal );
|
||||
|
||||
// Base+spec maps
|
||||
// FIXME: the outer layer doesn't really need a base texture - it's just frost, so, it just needs opacity
|
||||
float4 cBase = BlendedTexFetch( g_tBase, i.vUV0.xy, i.vUV0.wz, i.vUV1.xy, vBlendWeights );
|
||||
float flSpecMask = BlendedTexFetch( g_tSpecMask, i.vUV0.xy, i.vUV0.wz, i.vUV1.xy, vBlendWeights );
|
||||
// Use base tex alpha channel as a tint mask
|
||||
cBase.rgb = lerp( cBase.rgb, Luminance( cBase.rgb ) * g_cBaseTint.rgb, cBase.a );
|
||||
|
||||
// Normal mapping
|
||||
float3 vBumpedWorldNormal, vFresnelWorldNormal;
|
||||
float2 vBumpedTSNormal;
|
||||
BlendedTexFetchNormal( g_tBump, i.vUV0.xy, i.vUV0.zw, i.vUV1.xy, vBlendWeights, vWorldNormal,
|
||||
vBumpedTSNormal, vBumpedWorldNormal, vFresnelWorldNormal );
|
||||
|
||||
// Opacity and fresnel
|
||||
float flSkinOpacity, flFresnel;
|
||||
ComputeOpacityAndFresnel( i.vUV0.xy, i.vUV0.wz, i.vUV1.xy, vBlendWeights, vEyeDir, vFresnelWorldNormal,
|
||||
flSkinOpacity, flFresnel );
|
||||
|
||||
// Ambient light
|
||||
float3 cAmbient, cAvgAmbient;
|
||||
IceAmbientLight( i.vLightCube, vEyeDir, vBumpedWorldNormal, flFresnel,
|
||||
cAmbient, cAvgAmbient );
|
||||
|
||||
// Dynamic lights
|
||||
float3 cDiffuse, cSpec, cSpec2, cRim;
|
||||
IceDynamicLight( i.vWorldPos.xyz, vEyeDir, vBumpedWorldNormal, i.vLightAtten, flFresnel,
|
||||
cDiffuse, cSpec, cSpec2, cRim );
|
||||
|
||||
// Environment reflection
|
||||
float3 vViewDirReflected = reflect( -vEyeDir, vBumpedWorldNormal );
|
||||
float3 cEnvironment = flFresnel * g_cEnvMapTint * texCUBE( g_tEnvironment, vViewDirReflected );
|
||||
// Reduce envmap strength a little based on average ambient light, so it's not too shiny indoors
|
||||
cEnvironment *= saturate( 4*Luminance( cAvgAmbient ) ); // TODO: expose this as a materialvar
|
||||
|
||||
// Flashlight
|
||||
float3 cFlashlightColor = 0;
|
||||
#if FLASHLIGHT == 1
|
||||
float3 cFlashlightDiffuse, cFlashlightSpec;
|
||||
IceFlashlight( i.vWorldPos.xyz, vEyeDir, vBumpedWorldNormal, vScreenPos, g_flSpecExp2,
|
||||
cFlashlightDiffuse, cFlashlightSpec, cFlashlightColor );
|
||||
cDiffuse.rgb += cFlashlightDiffuse;
|
||||
cSpec2 += cFlashlightSpec;
|
||||
#endif
|
||||
|
||||
// Scale light terms
|
||||
cDiffuse *= g_flDiffuseScale;
|
||||
cSpec *= g_flSpecScale;
|
||||
cSpec2 *= g_flSpecScale2;
|
||||
cRim *= g_flRimLightScale;
|
||||
// FIXME: expose this as a materialvar (or I guess tweak actual scene lights)
|
||||
cDiffuse.rgb *= float3(0.8,0.85,1.0);
|
||||
|
||||
#if ( INTERIOR_LAYER == 0 )
|
||||
// Outer layer only
|
||||
cOut.rgb = cBase.rgb * ( cAmbient.rgb + cDiffuse.rgb ) + flSpecMask * ( cSpec + cSpec2 ) + cRim + cEnvironment;
|
||||
#else
|
||||
// Outer layer blended over inner/background colour
|
||||
float3 cExterior = cBase.rgb * ( cAmbient.rgb + cDiffuse.rgb ) + flSpecMask * ( cSpec2 + cRim );
|
||||
float3 cInterior = IceInterior( vWorldNormal, vBumpedTSNormal, vEyeDir,
|
||||
vScreenPos, flPixelDepth, flCamDist, cAvgAmbient, cFlashlightColor );
|
||||
// Inner layer is meant to be smooth, glassy ice, so give it unmasked envmap and spec
|
||||
cInterior.rgb += cSpec + cEnvironment;
|
||||
cOut.rgb = lerp( cInterior.rgb, cExterior, flSkinOpacity );
|
||||
#endif
|
||||
|
||||
#if CONTACT_SHADOW == 1
|
||||
cOut.rgb *= IceContactShadow( vWorldNormal, i.vClosestSurfaceDir );
|
||||
#endif
|
||||
|
||||
// TODO: Support fog
|
||||
cOut.a = 1;
|
||||
return FinalOutput( cOut, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR, g_fWriteDepthToAlpha, flPixelDepth );
|
||||
}
|
||||
113
materialsystem/stdshaders/IceSurface_vs30.fxc
Normal file
113
materialsystem/stdshaders/IceSurface_vs30.fxc
Normal file
@@ -0,0 +1,113 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
// Globals
|
||||
const float g_flUVScale : register( SHADER_SPECIFIC_CONST_0 );
|
||||
const float3 g_vUVProjOffset : register( SHADER_SPECIFIC_CONST_1 );
|
||||
const float3 g_vBBMin : register( SHADER_SPECIFIC_CONST_2 );
|
||||
const float3 g_vBBMax : register( SHADER_SPECIFIC_CONST_3 );
|
||||
|
||||
// Structs
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION; // Position
|
||||
float4 vNormal : NORMAL; // Normal
|
||||
float4 vBoneWeights : BLENDWEIGHT; // Skin weights
|
||||
float4 vBoneIndices : BLENDINDICES; // Skin indices
|
||||
float4 vClosestSurfaceDir : TEXCOORD0;
|
||||
float4 vTangent : TANGENT;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPosition : POSITION; // Projection-space position
|
||||
float4 vWorldNormal : TEXCOORD0; // w is proj. z coord (for depth stuff)
|
||||
float4 vClosestSurfaceDir : TEXCOORD1;
|
||||
float4 vWorldPos : TEXCOORD2; // w is proj. w coord
|
||||
float4 vUV0 : TEXCOORD3;
|
||||
float4 vUV1 : TEXCOORD4;
|
||||
float4 vLightAtten : TEXCOORD5;
|
||||
float3 vAmbient : TEXCOORD6;
|
||||
};
|
||||
|
||||
float3 CubeUV( float3 vWorldPosition, float3 vWorldNormal, float3 vUVSpacePos )
|
||||
{
|
||||
// Generate texcoords for a cubemap wrapped around the ice sculpture's bounding box
|
||||
float3 vDir = normalize( lerp( normalize( vUVSpacePos.xyz ), vWorldNormal.xyz, 0.5 ) );
|
||||
float3 tMins = ( g_vBBMin - vWorldPosition ) / vDir;
|
||||
float3 tMaxs = ( g_vBBMax - vWorldPosition ) / vDir;
|
||||
tMaxs = max( tMaxs, tMins ); // weed out negative t's per axis
|
||||
float t = min( tMaxs.x, min( tMaxs.y, tMaxs.z ) );
|
||||
float3 vIntersectionPos = vWorldPosition + t * vDir;
|
||||
// transform into unit cube
|
||||
float3 vCubeUV = vIntersectionPos;
|
||||
vCubeUV -= 0.5*( g_vBBMax + g_vBBMin );
|
||||
vCubeUV /= 0.5*( g_vBBMax - g_vBBMin );
|
||||
vCubeUV = normalize( vCubeUV );
|
||||
return vCubeUV;
|
||||
}
|
||||
|
||||
|
||||
// Main
|
||||
VS_OUTPUT main( const VS_INPUT i )
|
||||
{
|
||||
VS_OUTPUT o;
|
||||
|
||||
float4 vObjPosition = i.vPos;
|
||||
float4 vObjTangent = i.vTangent;
|
||||
float3 vObjNormal;
|
||||
DecompressVertex_Normal( i.vNormal, vObjNormal );
|
||||
|
||||
// Transform the position and normal
|
||||
float3 vWorldPosition = { 0.0f, 0.0f, 0.0f };
|
||||
float3 vWorldNormal = { 0.0f, 0.0f, 0.0f };
|
||||
float3 vWorldTangent = { 0.0f, 0.0f, 0.0f };
|
||||
float3 vWorldBinormal = { 0.0f, 0.0f, 0.0f };
|
||||
SkinPositionNormalAndTangentSpace( SKINNING ? true : false,
|
||||
vObjPosition, vObjNormal.xyz, vObjTangent.xyzw,
|
||||
i.vBoneWeights, i.vBoneIndices,
|
||||
vWorldPosition, vWorldNormal, vWorldTangent, vWorldBinormal );
|
||||
vWorldNormal.xyz = normalize( vWorldNormal.xyz );
|
||||
|
||||
o.vWorldNormal.xyz = vWorldNormal.xyz;
|
||||
o.vWorldPos.xyz = vWorldPosition.xyz;
|
||||
|
||||
// Transform into projection space
|
||||
float4 vProjPosition = mul( float4( vWorldPosition, 1.0f ), cViewProj );
|
||||
o.vProjPosition = vProjPosition;
|
||||
o.vWorldNormal.w = vProjPosition.z;
|
||||
o.vWorldPos.w = vProjPosition.w;
|
||||
|
||||
// Seamless texturing UV projections
|
||||
float3 vUVSpacePos = vWorldPosition.xyz - g_vUVProjOffset.xyz;
|
||||
o.vUV0.xy = g_flUVScale * vUVSpacePos.yz;
|
||||
o.vUV0.wz = g_flUVScale * vUVSpacePos.xz;
|
||||
o.vUV1.xy = g_flUVScale * vUVSpacePos.xy;
|
||||
|
||||
// Cubemap UV gen
|
||||
//o.vCubeUVW.xyz = CubeUV( vWorldPosition, vWorldNormal, vUVSpacePos );
|
||||
|
||||
// Screen-space texcoord
|
||||
float2 vScreenPos = float2( 0.5, -0.5 ) * vProjPosition.xy + 0.5 * vProjPosition.w;
|
||||
o.vUV1.wz = vScreenPos;
|
||||
|
||||
// Dynamic light attenuation factors
|
||||
o.vLightAtten.x = GetVertexAttenForLight( vWorldPosition, 0, true );
|
||||
o.vLightAtten.y = GetVertexAttenForLight( vWorldPosition, 1, true );
|
||||
o.vLightAtten.z = GetVertexAttenForLight( vWorldPosition, 2, true );
|
||||
o.vLightAtten.w = GetVertexAttenForLight( vWorldPosition, 3, true );
|
||||
|
||||
// Ambient light
|
||||
o.vAmbient = AmbientLight( vWorldNormal );
|
||||
|
||||
// Closest surface's direction and distance, for contact shadowing
|
||||
o.vClosestSurfaceDir.xyz = i.vClosestSurfaceDir.xyz;
|
||||
o.vClosestSurfaceDir.w = length( i.vClosestSurfaceDir.xyz );
|
||||
|
||||
return o;
|
||||
}
|
||||
337
materialsystem/stdshaders/IntroScreenSpaceEffect_ps2x.fxc
Normal file
337
materialsystem/stdshaders/IntroScreenSpaceEffect_ps2x.fxc
Normal file
@@ -0,0 +1,337 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// DYNAMIC: "MODE" "0..9"
|
||||
|
||||
// STATIC: "LINEAR_TO_SRGB" "0..1" [ps20b]
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
const float g_Alpha : register( c0 );
|
||||
|
||||
sampler BaseTextureSampler : register( s0 );
|
||||
sampler BaseTextureSampler2 : register( s1 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 baseTexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
float3 RGBtoHSV( in float3 rgb )
|
||||
{
|
||||
float3 hsv;
|
||||
float fmin, fmax, delta;
|
||||
fmin = min( min( rgb.r, rgb.g ), rgb.b );
|
||||
fmax = max( max( rgb.r, rgb.g) , rgb.b );
|
||||
hsv.b = fmax; // v
|
||||
delta = fmax - fmin;
|
||||
// if( fmax != 0 )
|
||||
{
|
||||
hsv.g = delta / fmax; // s
|
||||
if( rgb.r == fmax )
|
||||
hsv.r = ( rgb.g - rgb.b ) / delta; // between yellow & magenta
|
||||
else if( rgb.g == fmax )
|
||||
hsv.r = 2 + ( rgb.b - rgb.r ) / delta; // between cyan & yellow
|
||||
else
|
||||
hsv.r = 4 + ( rgb.r - rgb.g ) / delta; // between magenta & cyan
|
||||
hsv.r *= 60; // degrees
|
||||
if( hsv.r < 0 )
|
||||
hsv.r += 360;
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// // r = g = b = 0 // s = 0, v is undefined
|
||||
// hsv.g = 0;
|
||||
// hsv.r = -1;
|
||||
// }
|
||||
return hsv;
|
||||
}
|
||||
|
||||
float3 HSVtoRGB( in float3 hsv )
|
||||
{
|
||||
int i;
|
||||
float3 rgb;
|
||||
float h = hsv.r;
|
||||
float s = hsv.g;
|
||||
float v = hsv.b;
|
||||
float f, p, q, t;
|
||||
if( s == 0 )
|
||||
{
|
||||
// achromatic (grey)
|
||||
rgb.rgb = v;
|
||||
}
|
||||
else
|
||||
{
|
||||
h /= 60; // sector 0 to 5
|
||||
i = floor( h );
|
||||
f = h - i; // factorial part of h
|
||||
p = v * ( 1 - s );
|
||||
q = v * ( 1 - s * f );
|
||||
t = v * ( 1 - s * ( 1 - f ) );
|
||||
if( i == 0 )
|
||||
{
|
||||
rgb.r = v;
|
||||
rgb.g = t;
|
||||
rgb.b = p;
|
||||
}
|
||||
else if( i == 1 )
|
||||
{
|
||||
rgb.r = q;
|
||||
rgb.g = v;
|
||||
rgb.b = p;
|
||||
}
|
||||
else if( i == 2 )
|
||||
{
|
||||
rgb.r = p;
|
||||
rgb.g = v;
|
||||
rgb.b = t;
|
||||
}
|
||||
else if( i == 3 )
|
||||
{
|
||||
rgb.r = p;
|
||||
rgb.g = q;
|
||||
rgb.b = v;
|
||||
}
|
||||
else if( i == 4 )
|
||||
{
|
||||
rgb.r = t;
|
||||
rgb.g = p;
|
||||
rgb.b = v;
|
||||
}
|
||||
else // if( i == 5 )
|
||||
{
|
||||
rgb.r = v;
|
||||
rgb.g = p;
|
||||
rgb.b = q;
|
||||
}
|
||||
}
|
||||
return rgb;
|
||||
}
|
||||
|
||||
// We have to run through this input converter on OpenGL if the
|
||||
// rest of the shader code is expecting sRGB values
|
||||
float3 SampleTexture( sampler texSampler, float2 tc )
|
||||
{
|
||||
float3 c = tex2D( texSampler, tc ).xyz;
|
||||
|
||||
#if ( LINEAR_TO_SRGB )
|
||||
{
|
||||
c = LinearToGamma( c );
|
||||
}
|
||||
#endif
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
// We have to run through this output converter on OpenGL if we
|
||||
// expect to be writing out sRGB values (since sRGB will be forced on)
|
||||
float3 OutputColor( float3 result )
|
||||
{
|
||||
#if ( LINEAR_TO_SRGB )
|
||||
{
|
||||
return GammaToLinear( result );
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float3 result;
|
||||
#if MODE == 0
|
||||
// negative greyscale of scene * gman
|
||||
float3 scene = SampleTexture( BaseTextureSampler, i.baseTexCoord );
|
||||
float3 gman = SampleTexture( BaseTextureSampler2, i.baseTexCoord );
|
||||
|
||||
float scale = 1.0f / 3.0f;
|
||||
scene.xyz = dot( float3( scale, scale, scale), scene.xyz );
|
||||
scene = float3( 1, 1, 1 ) - scene;
|
||||
|
||||
return FinalOutput( float4( OutputColor( scene * gman ), g_Alpha ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
#endif
|
||||
|
||||
#if MODE == 1
|
||||
float3 scene = SampleTexture( BaseTextureSampler, i.baseTexCoord );
|
||||
float3 gman = SampleTexture( BaseTextureSampler2, i.baseTexCoord );
|
||||
float scale = 1.0f / 3.0f;
|
||||
scene.xyz = dot( float3( scale, scale, scale ), scene.xyz );
|
||||
|
||||
float gmanLum = dot( float3( scale, scale, scale ), gman );
|
||||
if( gmanLum < 0.3 )
|
||||
{
|
||||
result = OutputColor( float3( 1, 1, 1 ) - gman );
|
||||
return FinalOutput( float4( result, g_Alpha ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
else
|
||||
{
|
||||
result = OutputColor( ( float3( 1, 1, 1 ) - gman ) * scene );
|
||||
return FinalOutput( float4( result, g_Alpha ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MODE == 2
|
||||
float3 scene = SampleTexture( BaseTextureSampler, i.baseTexCoord );
|
||||
float3 gman = SampleTexture( BaseTextureSampler2, i.baseTexCoord );
|
||||
|
||||
float startRamp = .2;
|
||||
float endRamp = .5;
|
||||
|
||||
float scale = 1.0f / 3.0f;
|
||||
float gmanLum = dot( float3( scale, scale, scale ), gman );
|
||||
float sceneLum = dot( float3( scale, scale, scale ), scene );
|
||||
|
||||
float blend = ( gmanLum - startRamp ) * ( 1.0f / ( endRamp - startRamp ) );
|
||||
blend = saturate( blend );
|
||||
|
||||
// return gmanLum * ( 1.0f - blend ) + scene * blend;
|
||||
|
||||
result = OutputColor( min( gmanLum.xxx, scene ) );
|
||||
return FinalOutput( float4( result, g_Alpha ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
#endif
|
||||
|
||||
#if MODE == 3
|
||||
float3 scene = SampleTexture( BaseTextureSampler, i.baseTexCoord );
|
||||
float3 gman = SampleTexture( BaseTextureSampler2, i.baseTexCoord );
|
||||
float scale = 1.0f / 3.0f;
|
||||
float gmanLum = dot( float3( scale, scale, scale ), gman );
|
||||
float sceneLum = dot( float3( scale, scale, scale ), scene );
|
||||
|
||||
float a = 0.0f;
|
||||
float b = 0.4f;
|
||||
float c = 0.7f;
|
||||
float d = 1.0f;
|
||||
|
||||
float blend;
|
||||
if( gmanLum < b )
|
||||
{
|
||||
blend = ( gmanLum - a ) / ( b - a );
|
||||
}
|
||||
else if( gmanLum > c )
|
||||
{
|
||||
blend = 1.0f - ( ( gmanLum - c) / ( d - c ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
blend = 1.0f;
|
||||
}
|
||||
|
||||
blend = saturate( blend );
|
||||
|
||||
result = OutputColor( gmanLum.xxx * ( float3( 1, 1, 1 ) - blend.xxx ) + scene * blend.xxx );
|
||||
return FinalOutput( float4( result, g_Alpha ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
#endif
|
||||
|
||||
#if MODE == 4
|
||||
float3 scene = SampleTexture( BaseTextureSampler, i.baseTexCoord );
|
||||
float3 gman = SampleTexture( BaseTextureSampler2, i.baseTexCoord );
|
||||
float scale = 1.0f / 3.0f;
|
||||
float gmanLum = dot( float3( scale, scale, scale ), gman );
|
||||
float sceneLum = dot( float3( scale, scale, scale ), scene );
|
||||
|
||||
float a = 0.0f;
|
||||
float b = 0.4f;
|
||||
float c = 0.7f;
|
||||
float d = 1.0f;
|
||||
|
||||
float blend;
|
||||
if( gmanLum < b )
|
||||
{
|
||||
blend = ( gmanLum - a ) / ( b - a );
|
||||
}
|
||||
else if( gmanLum > c )
|
||||
{
|
||||
blend = 1.0f - ( ( gmanLum - c) / ( d - c ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
blend = 1.0f;
|
||||
}
|
||||
|
||||
blend = saturate( blend );
|
||||
|
||||
result = OutputColor( gman * ( float3( 1, 1, 1 ) - blend.xxx ) + scene * blend.xxx );
|
||||
return FinalOutput( float4( result, g_Alpha ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
#endif
|
||||
|
||||
#if MODE == 5
|
||||
float3 scene = SampleTexture( BaseTextureSampler, i.baseTexCoord );
|
||||
float3 gman = SampleTexture( BaseTextureSampler2, i.baseTexCoord );
|
||||
float scale = 1.0f / 3.0f;
|
||||
// float sceneLum = dot( float3( scale, scale, scale ), scene );
|
||||
float sceneLum = scene.r;
|
||||
|
||||
if( sceneLum > 0.0f )
|
||||
{
|
||||
return FinalOutput( float4( OutputColor( scene ), g_Alpha ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
else
|
||||
{
|
||||
float3 hsv = RGBtoHSV( gman );
|
||||
|
||||
// float blend = saturate( hsv.b - .5 );
|
||||
float blend = hsv.b - .5;
|
||||
|
||||
hsv.b *= 1.0f + blend;
|
||||
hsv.g *= 1.0f - blend;
|
||||
return FinalOutput( float4( OutputColor( HSVtoRGB( hsv ) ), g_Alpha ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MODE == 6
|
||||
float3 scene = SampleTexture( BaseTextureSampler, i.baseTexCoord );
|
||||
float3 gman = SampleTexture( BaseTextureSampler2, i.baseTexCoord );
|
||||
return FinalOutput( float4( OutputColor( scene + gman ), g_Alpha ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
#endif
|
||||
|
||||
#if MODE == 7
|
||||
float3 scene = SampleTexture( BaseTextureSampler, i.baseTexCoord );
|
||||
return FinalOutput( float4( OutputColor( scene ), g_Alpha ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
#endif
|
||||
|
||||
#if MODE == 8
|
||||
float3 gman = SampleTexture( BaseTextureSampler2, i.baseTexCoord );
|
||||
return FinalOutput( float4( OutputColor( gman ), g_Alpha ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
#endif
|
||||
|
||||
#if MODE == 9
|
||||
// Fetch textures
|
||||
float3 cLayer1 = SampleTexture( BaseTextureSampler, i.baseTexCoord.xy );
|
||||
float3 cLayer2 = SampleTexture( BaseTextureSampler2, i.baseTexCoord.xy );
|
||||
|
||||
/*
|
||||
// Put colors roughly back into gamma space
|
||||
float3 cGammaLayer1 = pow( cLayer1, 0.454545f );
|
||||
float3 cGammaLayer2 = pow( cLayer2, 0.454545f );
|
||||
|
||||
// Brightness
|
||||
//float flLayer1Brightness = saturate( dot( cGammaLayer1.rgb, float3( 0.3f, 0.59f, 0.11f ) ) );
|
||||
//float flLayer2Brightness = saturate( dot( cGammaLayer2.rgb, float3( 0.3f, 0.59f, 0.11f ) ) );
|
||||
float flLayer1Brightness = saturate( dot( cGammaLayer1.rgb, float3( 0.333f, 0.334f, 0.333f ) ) );
|
||||
float flLayer2Brightness = saturate( dot( cGammaLayer2.rgb, float3( 0.333f, 0.334f, 0.333f ) ) );
|
||||
|
||||
// Blend layers in rough gamma space
|
||||
float3 cGammaOverlayResult;
|
||||
if ( flLayer1Brightness < 0.5f )
|
||||
{
|
||||
cGammaOverlayResult.rgb = ( 2.0f * cGammaLayer1.rgb * cGammaLayer2.rgb );
|
||||
}
|
||||
else
|
||||
{
|
||||
cGammaOverlayResult.rgb = ( 1.0f - ( 2.0f * ( 1.0f - cGammaLayer1.rgb ) * ( 1.0f - cGammaLayer2.rgb ) ) );
|
||||
}
|
||||
|
||||
// Convert back to linear space
|
||||
float3 cLinearOverlayResult = pow( cGammaOverlayResult.rgb, 2.2f );
|
||||
//*/
|
||||
|
||||
float flLayer1Brightness = saturate( dot( cLayer1.rgb, float3( 0.333f, 0.334f, 0.333f ) ) );
|
||||
float flLayer2Brightness = saturate( dot( cLayer2.rgb, float3( 0.333f, 0.334f, 0.333f ) ) );
|
||||
|
||||
// Modify layer 1 to be more contrasty
|
||||
cLayer1.rgb = saturate( cLayer1.rgb * cLayer1.rgb * 2.0f );
|
||||
float3 cLinearOverlayResult = cLayer1.rgb + cLayer2.rgb * saturate( 1.0f - flLayer1Brightness * 2.0f );
|
||||
|
||||
// Tonemap, fog, etc.
|
||||
return FinalOutput( float4( OutputColor( cLinearOverlayResult.rgb ), g_Alpha ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
#endif
|
||||
}
|
||||
182
materialsystem/stdshaders/MonitorScreen_dx9.cpp
Normal file
182
materialsystem/stdshaders/MonitorScreen_dx9.cpp
Normal file
@@ -0,0 +1,182 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "unlittwotexture_vs20.inc"
|
||||
#include "monitorscreen_ps20.inc"
|
||||
#include "monitorscreen_ps20b.inc"
|
||||
#include "cpp_shader_constant_register_map.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DEFINE_FALLBACK_SHADER( MonitorScreen, MonitorScreen_DX9 )
|
||||
|
||||
BEGIN_VS_SHADER( MonitorScreen_DX9,
|
||||
"This is a shader that does a contrast/saturation version of base times lightmap." )
|
||||
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( CONTRAST, SHADER_PARAM_TYPE_FLOAT, "0.0", "contrast 0 == normal 1 == color*color" )
|
||||
SHADER_PARAM( SATURATION, SHADER_PARAM_TYPE_FLOAT, "1.0", "saturation 0 == greyscale 1 == normal" )
|
||||
SHADER_PARAM( TINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "monitor tint" )
|
||||
SHADER_PARAM( TEXTURE2, SHADER_PARAM_TYPE_TEXTURE, "shadertest/lightmappedtexture", "second texture" )
|
||||
SHADER_PARAM( FRAME2, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $texture2" )
|
||||
SHADER_PARAM( TEXTURE2TRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$texture2 texcoord transform" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
// Set up anything that is necessary to make decisions in SHADER_FALLBACK.
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING );
|
||||
if( !params[CONTRAST]->IsDefined() )
|
||||
{
|
||||
params[CONTRAST]->SetFloatValue( 0.0f );
|
||||
}
|
||||
if( !params[SATURATION]->IsDefined() )
|
||||
{
|
||||
params[SATURATION]->SetFloatValue( 1.0f );
|
||||
}
|
||||
if( !params[TINT]->IsDefined() )
|
||||
{
|
||||
params[TINT]->SetVecValue( 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
if (!IS_FLAG_DEFINED( MATERIAL_VAR_MODEL ))
|
||||
{
|
||||
CLEAR_FLAGS( MATERIAL_VAR_MODEL );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
if( params && !params[BASETEXTURE]->IsDefined() )
|
||||
return "LightmappedGeneric";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if (params[BASETEXTURE]->IsDefined())
|
||||
{
|
||||
LoadTexture( BASETEXTURE, TEXTUREFLAGS_SRGB );
|
||||
}
|
||||
if (params[TEXTURE2]->IsDefined())
|
||||
{
|
||||
LoadTexture( TEXTURE2, TEXTUREFLAGS_SRGB );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
bool bHasTexture2 = params[TEXTURE2]->IsTexture();
|
||||
BlendType_t nBlendType = EvaluateBlendRequirements( BASETEXTURE, true );
|
||||
bool bFullyOpaque = (nBlendType != BT_BLENDADD) && (nBlendType != BT_BLEND) && !IS_FLAG_SET(MATERIAL_VAR_ALPHATEST); //dest alpha is free for special use
|
||||
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true );
|
||||
if ( bHasTexture2 )
|
||||
{
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, true );
|
||||
}
|
||||
|
||||
pShaderShadow->EnableSRGBWrite( true );
|
||||
|
||||
// Either we've got a constant modulation
|
||||
bool isTranslucent = IsAlphaModulating();
|
||||
|
||||
// Or we've got a texture alpha on either texture
|
||||
isTranslucent = isTranslucent || TextureIsTranslucent( BASETEXTURE, true ) ||
|
||||
TextureIsTranslucent( TEXTURE2, true );
|
||||
|
||||
if ( isTranslucent )
|
||||
{
|
||||
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
|
||||
{
|
||||
if ( IS_FLAG_SET(MATERIAL_VAR_ADDITIVE) )
|
||||
EnableAlphaBlending( SHADER_BLEND_ONE, SHADER_BLEND_ONE );
|
||||
else
|
||||
DisableAlphaBlending( );
|
||||
}
|
||||
|
||||
// Set stream format (note that this shader supports compression)
|
||||
unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL | VERTEX_FORMAT_COMPRESSED;
|
||||
int nTexCoordCount = 1;
|
||||
int userDataSize = 0;
|
||||
pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize );
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( unlittwotexture_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( unlittwotexture_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( monitorscreen_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( TEXTURE2, (bHasTexture2)?(1):(0) );
|
||||
SET_STATIC_PIXEL_SHADER( monitorscreen_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( monitorscreen_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( TEXTURE2, (bHasTexture2)?(1):(0) );
|
||||
SET_STATIC_PIXEL_SHADER( monitorscreen_ps20 );
|
||||
}
|
||||
|
||||
DefaultFog();
|
||||
|
||||
pShaderShadow->EnableAlphaWrites( bFullyOpaque );
|
||||
PI_BeginCommandBuffer();
|
||||
PI_SetModulationVertexShaderDynamicState();
|
||||
PI_EndCommandBuffer();
|
||||
}
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_SRGBREAD, BASETEXTURE, FRAME );
|
||||
if( bHasTexture2 )
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_SRGBREAD, TEXTURE2, FRAME2 );
|
||||
SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, TEXTURE2TRANSFORM );
|
||||
}
|
||||
SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, BASETEXTURETRANSFORM );
|
||||
SetPixelShaderConstant( 1, CONTRAST );
|
||||
SetPixelShaderConstant( 2, SATURATION );
|
||||
SetPixelShaderConstant( 3, TINT );
|
||||
|
||||
pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS );
|
||||
|
||||
float vEyePos_SpecExponent[4];
|
||||
pShaderAPI->GetWorldSpaceCameraPosition( vEyePos_SpecExponent );
|
||||
vEyePos_SpecExponent[3] = 0.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 );
|
||||
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( unlittwotexture_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( WORLD_NORMAL, 0 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( unlittwotexture_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( monitorscreen_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bFullyOpaque && pShaderAPI->ShouldWriteDepthToDestAlpha() );
|
||||
SET_DYNAMIC_PIXEL_SHADER( monitorscreen_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( monitorscreen_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( monitorscreen_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
160
materialsystem/stdshaders/Refract_vs20.fxc
Normal file
160
materialsystem/stdshaders/Refract_vs20.fxc
Normal file
@@ -0,0 +1,160 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
// STATIC: "MODEL" "0..1"
|
||||
// STATIC: "COLORMODULATE" "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[4] : register( SHADER_SPECIFIC_CONST_1 );
|
||||
|
||||
const float g_flTime : register( SHADER_SPECIFIC_CONST_5 );
|
||||
|
||||
const float4 g_vViewportMad : register( SHADER_SPECIFIC_CONST_6 );
|
||||
|
||||
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
|
||||
#if COLORMODULATE
|
||||
float4 vColor : COLOR0;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos_POSITION : POSITION;
|
||||
#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
|
||||
float fog : FOG;
|
||||
#endif
|
||||
float4 vBumpTexCoord : TEXCOORD0;
|
||||
float3 vTangentEyeVect : TEXCOORD1;
|
||||
float3 vWorldNormal : TEXCOORD2;
|
||||
float3 vWorldTangent : TEXCOORD3;
|
||||
float3 vWorldBinormal : TEXCOORD4;
|
||||
float3 vRefractXYW : TEXCOORD5;
|
||||
float3 vWorldViewVector : TEXCOORD6;
|
||||
#if COLORMODULATE
|
||||
float4 vColor : COLOR0;
|
||||
#endif
|
||||
|
||||
float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
#if COLORMODULATE
|
||||
o.vColor = v.vColor;
|
||||
#endif
|
||||
|
||||
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 = mul4x3( v.vPos, cModel[0] );
|
||||
worldTangentS = mul3x3( v.vTangentS, ( const float3x3 )cModel[0] );
|
||||
worldTangentT = mul3x3( v.vTangentT, ( const float3x3 )cModel[0] );
|
||||
worldNormal = mul3x3( vObjNormal, ( float3x3 )cModel[0] );
|
||||
#endif
|
||||
|
||||
// Normalize vectors
|
||||
worldNormal.xyz = normalize( worldNormal.xyz );
|
||||
worldTangentS.xyz = normalize( worldTangentS.xyz );
|
||||
worldTangentT.xyz = normalize( worldTangentT.xyz );
|
||||
|
||||
// World normal
|
||||
o.vWorldNormal.xyz = normalize( worldNormal.xyz );
|
||||
|
||||
// Projected position
|
||||
float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
|
||||
o.vProjPos_POSITION = vProjPos;
|
||||
o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z );
|
||||
//o.projNormal.xyz = mul( worldNormal, cViewProj );
|
||||
|
||||
|
||||
#ifdef _PS3
|
||||
// Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
|
||||
o.vProjPos_POSITION.y = -o.vProjPos_POSITION.y;
|
||||
o.vProjPos_POSITION.z = 2.0f * o.vProjPos_POSITION.z - o.vProjPos_POSITION.w;
|
||||
#endif // _PS3
|
||||
|
||||
// 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;
|
||||
|
||||
// Adjust for current viewport
|
||||
#if defined( _X360 ) || defined( _PS3 )
|
||||
{
|
||||
vRefractPos.xy = ( ( ( vRefractPos.xy / vProjPos.w ) * g_vViewportMad.xy ) + g_vViewportMad.zw ) * vProjPos.w;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Refraction transform
|
||||
o.vRefractXYW = float3(vRefractPos.x, vRefractPos.y, vProjPos.w);
|
||||
|
||||
// Compute fog based on the position
|
||||
float3 vWorldPos = mul4x3( v.vPos, cModel[0] );
|
||||
|
||||
#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
|
||||
o.fog = CalcFixedFunctionFog( vWorldPos, FOGTYPE_RANGE );
|
||||
#endif
|
||||
|
||||
// Eye vector
|
||||
float3 vWorldEyeVect = normalize( cEyePos - vWorldPos );
|
||||
o.vWorldViewVector.xyz = -vWorldEyeVect.xyz;
|
||||
|
||||
// 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] );
|
||||
|
||||
// Tranform bump coordinates (note wz, not zw)
|
||||
o.vBumpTexCoord.w = dot( v.vBaseTexCoord, cBumpTexCoordTransform[2] );
|
||||
o.vBumpTexCoord.z = dot( v.vBaseTexCoord, cBumpTexCoordTransform[3] );
|
||||
|
||||
|
||||
// Tangent space transform
|
||||
o.vWorldNormal.xyz = worldNormal.xyz;
|
||||
o.vWorldTangent.xyz = worldTangentS.xyz;
|
||||
o.vWorldBinormal.xyz = worldTangentT.xyz;
|
||||
|
||||
return o;
|
||||
}
|
||||
29
materialsystem/stdshaders/ScreenSpaceEffect.vsh
Normal file
29
materialsystem/stdshaders/ScreenSpaceEffect.vsh
Normal file
@@ -0,0 +1,29 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Constants specified by the app
|
||||
; c0 = (0, 1, 2, 0.5)
|
||||
; c1 = (1/2.2, 3, 255, overbright factor)
|
||||
; c2 = camera position *in world space*
|
||||
; c4-c7 = modelViewProj matrix (transpose)
|
||||
; c8-c11 = ViewProj matrix (transpose)
|
||||
; c12-c15 = model->view matrix (transpose)
|
||||
; c16 = [fogStart, fogEnd, fogRange, 1.0/fogRange]
|
||||
; $SHADER_SPECIFIC_CONST_0-$SHADER_SPECIFIC_CONST_1 = Base texture transform
|
||||
; $SHADER_SPECIFIC_CONST_2-$SHADER_SPECIFIC_CONST_3 = Mask texture transform
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; No vertex blending required. Input vertex data is in screen space
|
||||
;------------------------------------------------------------------------------
|
||||
mov oPos.xyz, $vPos.xyz
|
||||
mov oPos.w, $cOne
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Pass any and all texture coordinates through
|
||||
;------------------------------------------------------------------------------
|
||||
mov oT0, $vTexCoord0
|
||||
43
materialsystem/stdshaders/SetZ.cpp
Normal file
43
materialsystem/stdshaders/SetZ.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Naively sets the depth buffer values without testing the old values and without writing to alpha or color
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "shaderlib/CShader.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DEFINE_FALLBACK_SHADER( SetZ, SetZ_DX6 )
|
||||
|
||||
BEGIN_SHADER_FLAGS( SetZ_DX6, "Help for SetZ_DX6", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableColorWrites( false );
|
||||
pShaderShadow->EnableAlphaWrites( false );
|
||||
pShaderShadow->DepthFunc( SHADER_DEPTHFUNC_ALWAYS );
|
||||
|
||||
pShaderShadow->DrawFlags( SHADER_DRAW_POSITION );
|
||||
}
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
|
||||
22
materialsystem/stdshaders/ShadowModel.psh
Normal file
22
materialsystem/stdshaders/ShadowModel.psh
Normal file
@@ -0,0 +1,22 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
def c0,1.0f, 1.0f, 1.0f, 1.0f
|
||||
|
||||
tex t0 ; shadow color
|
||||
texkill t1 ; Clip
|
||||
texkill t2
|
||||
texkill t3 ; backface cull
|
||||
|
||||
; Darkening equation, compute a color = (shadow color * shadow alpha + 1- shadow alpha)
|
||||
;sub r1, t0, v0.a ; r1 = shadow alpha
|
||||
lrp r0.rgb, t0.a, v0, c0 + ; r0.rgb = (shadow color * shadow alpha + 1 - shadow alpha)
|
||||
mov r0.a, c0.a ; r0.a = 1
|
||||
|
||||
85
materialsystem/stdshaders/ShadowModel.vsh
Normal file
85
materialsystem/stdshaders/ShadowModel.vsh
Normal file
@@ -0,0 +1,85 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
# DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Constants specified by the app
|
||||
; $SHADER_SPECIFIC_CONST_0-$SHADER_SPECIFIC_CONST_2 = Shadow texture matrix
|
||||
; $SHADER_SPECIFIC_CONST_3 = Tex origin
|
||||
; $SHADER_SPECIFIC_CONST_4 = Tex Scale
|
||||
; $SHADER_SPECIFIC_CONST_5 = [Shadow falloff offset, 1/Shadow distance, Shadow scale, 0 ]
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending (whacks r1-r7, positions in r7, normals in r8)
|
||||
;------------------------------------------------------------------------------
|
||||
&AllocateRegister( \$worldPos );
|
||||
&AllocateRegister( \$worldNormal );
|
||||
&SkinPositionAndNormal( $worldPos, $worldNormal );
|
||||
|
||||
; Transform the position from world to view space
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
dp4 $projPos.x, $worldPos, $cViewProj0
|
||||
dp4 $projPos.y, $worldPos, $cViewProj1
|
||||
dp4 $projPos.z, $worldPos, $cViewProj2
|
||||
dp4 $projPos.w, $worldPos, $cViewProj3
|
||||
mov oPos, $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Transform position into texture space (from 0 to 1)
|
||||
;------------------------------------------------------------------------------
|
||||
&AllocateRegister( \$texturePos );
|
||||
dp4 $texturePos.x, $worldPos, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 $texturePos.y, $worldPos, $SHADER_SPECIFIC_CONST_1
|
||||
dp4 $texturePos.z, $worldPos, $SHADER_SPECIFIC_CONST_2
|
||||
&FreeRegister( \$worldPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Figure out the shadow fade amount
|
||||
;------------------------------------------------------------------------------
|
||||
&AllocateRegister( \$shadowFade );
|
||||
sub $shadowFade, $texturePos.z, $SHADER_SPECIFIC_CONST_5.x
|
||||
mul $shadowFade, $shadowFade, $SHADER_SPECIFIC_CONST_5.y
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Offset it into the texture
|
||||
;------------------------------------------------------------------------------
|
||||
&AllocateRegister( \$actualTextureCoord );
|
||||
mul $actualTextureCoord.xyz, $SHADER_SPECIFIC_CONST_4, $texturePos
|
||||
add oT0.xyz, $actualTextureCoord, $SHADER_SPECIFIC_CONST_3
|
||||
;mov oT0.xyz, $texturePos
|
||||
&FreeRegister( \$actualTextureCoord );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; We're doing clipping by using texkill
|
||||
;------------------------------------------------------------------------------
|
||||
mov oT1.xyz, $texturePos ; also clips when shadow z < 0 !
|
||||
sub oT2.xyz, $cOne, $texturePos
|
||||
sub oT2.z, $cOne, $shadowFade.z ; clips when shadow z > shadow distance
|
||||
&FreeRegister( \$texturePos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; We're doing backface culling by using texkill also (wow yucky)
|
||||
;------------------------------------------------------------------------------
|
||||
; Transform z component of normal in texture space
|
||||
; If it's negative, then don't draw the pixel
|
||||
dp3 oT3, $worldNormal, -$SHADER_SPECIFIC_CONST_2
|
||||
&FreeRegister( \$worldNormal );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Shadow color, falloff
|
||||
;------------------------------------------------------------------------------
|
||||
mov oD0, $cModulationColor
|
||||
mul oD0.w, $shadowFade.x, $SHADER_SPECIFIC_CONST_5.z
|
||||
&FreeRegister( \$shadowFade );
|
||||
|
||||
127
materialsystem/stdshaders/ShatteredGlass_ps2x.fxc
Normal file
127
materialsystem/stdshaders/ShatteredGlass_ps2x.fxc
Normal file
@@ -0,0 +1,127 @@
|
||||
//========== 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"
|
||||
|
||||
#include "common_fog_ps_fxc.h"
|
||||
|
||||
// HDRFIXME: Need to make this work.
|
||||
|
||||
// Turning off 32bit lightmaps on Portal 2 to save shader perf. --Thorsten
|
||||
//#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 float4 g_EnvmapTint : register( c0 );
|
||||
const float3 g_DiffuseModulation : register( c1 );
|
||||
const float3 g_EnvmapContrast : register( c2 );
|
||||
const float3 g_EnvmapSaturation : register( c3 );
|
||||
const float4 g_FresnelReflection : register( c4 );
|
||||
const float3 g_EyePos : register( c5 );
|
||||
const float3 g_OverbrightFactor : register( c6 );
|
||||
|
||||
const float4 g_FogParams : register( c12 );
|
||||
|
||||
sampler BaseTextureSampler : register( s0 );
|
||||
sampler LightmapSampler : register( s1 );
|
||||
samplerCUBE EnvmapSampler : register( s2 );
|
||||
sampler DetailSampler : register( s3 );
|
||||
sampler EnvmapMaskSampler : register( s5 );
|
||||
|
||||
samplerCUBE NormalizeSampler : register( s6 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 baseTexCoord : TEXCOORD0;
|
||||
float2 detailTexCoord : TEXCOORD1;
|
||||
float2 lightmapTexCoord : TEXCOORD2_centroid;
|
||||
float2 envmapMaskTexCoord : TEXCOORD3;
|
||||
float4 worldPos_projPosZ : TEXCOORD4;
|
||||
float3 worldSpaceNormal : TEXCOORD5;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
float4_color_return_type 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;
|
||||
|
||||
float4 baseColor = tex2D( BaseTextureSampler, i.baseTexCoord );
|
||||
float4 detailColor = tex2D( DetailSampler, i.detailTexCoord );
|
||||
|
||||
float2 lightmapCoordinates = i.lightmapTexCoord;
|
||||
float3 lightmapColor = LightMapSample( LightmapSampler, lightmapCoordinates ).rgb;
|
||||
|
||||
float3 specularFactor = 1.0f;
|
||||
if( bEnvmapMask )
|
||||
{
|
||||
specularFactor = tex2D( EnvmapMaskSampler, i.detailTexCoord ).xyz;
|
||||
}
|
||||
|
||||
if( bBaseAlphaEnvmapMask )
|
||||
{
|
||||
specularFactor *= 1.0 - baseColor.a; // this blows!
|
||||
}
|
||||
|
||||
float3 diffuseLighting = lightmapColor;
|
||||
diffuseLighting *= g_DiffuseModulation;
|
||||
diffuseLighting *= LIGHT_MAP_SCALE;
|
||||
|
||||
float3 albedo = baseColor.rgb;
|
||||
float alpha = 1.0f;
|
||||
|
||||
if( !bBaseAlphaEnvmapMask )
|
||||
{
|
||||
alpha *= baseColor.a;
|
||||
}
|
||||
|
||||
albedo *= detailColor.rgb;
|
||||
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.rgb;
|
||||
alpha *= i.vertexColor.a; // not sure about this one
|
||||
}
|
||||
|
||||
float3 specularLighting = float3( 0.0f, 0.0f, 0.0f );
|
||||
if( bCubemap )
|
||||
{
|
||||
float3 worldVertToEyeVector = g_EyePos - i.worldPos_projPosZ.xyz;
|
||||
worldVertToEyeVector = NormalizeWithCubemap( NormalizeSampler, worldVertToEyeVector );
|
||||
float3 reflectVect = CalcReflectionVectorUnnormalized( i.worldSpaceNormal, worldVertToEyeVector );
|
||||
|
||||
// Calc Fresnel factor
|
||||
float3 worldSpaceNormal = NormalizeWithCubemap( NormalizeSampler, i.worldSpaceNormal );
|
||||
float fresnel = 1.0 - dot( worldSpaceNormal, worldVertToEyeVector );
|
||||
fresnel = pow( fresnel, 5.0 );
|
||||
fresnel = fresnel * g_FresnelReflection.b + g_FresnelReflection.a;
|
||||
|
||||
specularLighting = texCUBE( EnvmapSampler, reflectVect ).rgb;
|
||||
specularLighting *= specularFactor;
|
||||
|
||||
specularLighting *= g_EnvmapTint.rgb;
|
||||
#if HDRTYPE == HDR_TYPE_NONE
|
||||
float3 specularLightingSquared = specularLighting * specularLighting;
|
||||
specularLighting = lerp( specularLighting, specularLightingSquared, g_EnvmapContrast );
|
||||
float3 greyScale = dot( specularLighting, float3( 0.299f, 0.587f, 0.114f ) );
|
||||
specularLighting = lerp( greyScale, specularLighting, g_EnvmapSaturation );
|
||||
#endif
|
||||
specularLighting *= fresnel;
|
||||
}
|
||||
|
||||
// Do it somewhat unlit
|
||||
float3 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( float4( result, alpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR );
|
||||
}
|
||||
|
||||
72
materialsystem/stdshaders/ShatteredGlass_vs20.fxc
Normal file
72
materialsystem/stdshaders/ShatteredGlass_vs20.fxc
Normal file
@@ -0,0 +1,72 @@
|
||||
#include "common_fog_vs_fxc.h"
|
||||
// STATIC: "ENVMAP_MASK" "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;
|
||||
|
||||
#ifdef _PS3
|
||||
// Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
|
||||
o.projPos.y = -o.projPos.y;
|
||||
o.projPos.z = 2.0f * o.projPos.z - o.projPos.w;
|
||||
#endif // _PS3
|
||||
|
||||
o.worldPos_projPosZ.w = projPos.z;
|
||||
o.worldPos_projPosZ.xyz = mul4x3( float4( v.vPos, 1 ), cModel[0] );
|
||||
o.worldNormal = mul3x3( vObjNormal, ( float3x3 )cModel[0] );
|
||||
o.baseTexCoord.x = dot( v.vBaseTexCoord, cBaseTexCoordTransform[0].xy ) + cBaseTexCoordTransform[0].w;
|
||||
o.baseTexCoord.y = dot( v.vBaseTexCoord, cBaseTexCoordTransform[1].xy ) + cBaseTexCoordTransform[1].w;
|
||||
o.detailTexCoord.x = dot( v.vDetailTexCoord, cDetailTexCoordTransform[0].xy ) + cDetailTexCoordTransform[0].w;
|
||||
o.detailTexCoord.y = dot( v.vDetailTexCoord, cDetailTexCoordTransform[1].xy ) + cDetailTexCoordTransform[1].w;
|
||||
o.envmapMaskTexCoord.x = dot( v.vDetailTexCoord, cDetailTexCoordTransform[0].xy ) + cDetailTexCoordTransform[0].w;
|
||||
o.envmapMaskTexCoord.y = dot( v.vDetailTexCoord, cDetailTexCoordTransform[1].xy ) + 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;
|
||||
}
|
||||
|
||||
|
||||
102
materialsystem/stdshaders/TreeLeaf.cpp
Normal file
102
materialsystem/stdshaders/TreeLeaf.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Header: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
|
||||
#include "treeleaf_ps20.inc"
|
||||
#include "treeleaf_ps20b.inc"
|
||||
#include "treeleaf_vs20.inc"
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( TreeLeaf, "Help for TreeLeaf", SHADER_NOT_EDITABLE )
|
||||
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( LEAFCENTER, SHADER_PARAM_TYPE_VEC3, "[0 0 0]", "Center of leaf cluster for lighting" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
SET_FLAGS2( MATERIAL_VAR2_LIGHTING_VERTEX_LIT );
|
||||
|
||||
if ( params[BASETEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
|
||||
pShaderShadow->EnableAlphaTest( true );
|
||||
pShaderShadow->AlphaFunc( SHADER_ALPHAFUNC_GREATER, 0.5f );
|
||||
|
||||
unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL;
|
||||
int numTexCoords = 1;
|
||||
pShaderShadow->VertexShaderVertexFormat( flags, numTexCoords, 0, 0 );
|
||||
|
||||
bool bFlattenStaticControlFlow = !g_pHardwareConfig->SupportsStaticControlFlow();
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( treeleaf_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( HALFLAMBERT, true );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( FLATTEN_STATIC_CONTROL_FLOW, bFlattenStaticControlFlow );
|
||||
SET_STATIC_VERTEX_SHADER( treeleaf_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( treeleaf_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER( treeleaf_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( treeleaf_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER( treeleaf_ps20 );
|
||||
}
|
||||
|
||||
// we are writing linear values from this shader.
|
||||
// This is kinda wrong. We are writing linear or gamma depending on "IsHDREnabled" below.
|
||||
// The COLOR really decides if we are gamma or linear.
|
||||
pShaderShadow->EnableSRGBWrite( false );
|
||||
}
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, BASETEXTURE, FRAME );
|
||||
|
||||
// We need the view matrix
|
||||
LoadViewMatrixIntoVertexShaderConstant( VERTEX_SHADER_VIEWMODEL );
|
||||
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, params[ LEAFCENTER ]->GetVecValue() );
|
||||
|
||||
LightState_t lightState = {0, false, false};
|
||||
pShaderAPI->GetDX9LightState( &lightState );
|
||||
|
||||
bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow();
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( treeleaf_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( DYNAMIC_LIGHT, lightState.HasDynamicLight() );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT, lightState.m_bStaticLight ? 1 : 0 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( NUM_LIGHTS, bUseStaticControlFlow ? 0 : lightState.m_nNumLights );
|
||||
SET_DYNAMIC_VERTEX_SHADER( treeleaf_vs20 );
|
||||
}
|
||||
Draw( );
|
||||
}
|
||||
END_SHADER
|
||||
19
materialsystem/stdshaders/TreeLeaf_ps2x.fxc
Normal file
19
materialsystem/stdshaders/TreeLeaf_ps2x.fxc
Normal file
@@ -0,0 +1,19 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
#define HDRTYPE HDR_TYPE_NONE
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 texCoord0 : TEXCOORD0;
|
||||
float3 color : COLOR;
|
||||
};
|
||||
|
||||
sampler BaseTextureSampler : register( s0 );
|
||||
|
||||
HALF4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4 baseTex = tex2D( BaseTextureSampler, i.texCoord0 );
|
||||
return FinalOutput( baseTex * float4( i.color, 1 ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
|
||||
74
materialsystem/stdshaders/TreeLeaf_vs20.fxc
Normal file
74
materialsystem/stdshaders/TreeLeaf_vs20.fxc
Normal file
@@ -0,0 +1,74 @@
|
||||
// STATIC: "HALFLAMBERT" "0..1"
|
||||
// STATIC: "FLATTEN_STATIC_CONTROL_FLOW" "0..1" [vs20] [PC]
|
||||
// STATIC: "FLATTEN_STATIC_CONTROL_FLOW" "0..0" [CONSOLE]
|
||||
|
||||
// DYNAMIC: "DYNAMIC_LIGHT" "0..1"
|
||||
// DYNAMIC: "STATIC_LIGHT" "0..1"
|
||||
// DYNAMIC: "NUM_LIGHTS" "0..2" [vs20] [PC]
|
||||
// DYNAMIC: "NUM_LIGHTS" "0..0" [vs20] [CONSOLE]
|
||||
|
||||
// If using static control flow on Direct3D, we should use the NUM_LIGHTS=0 combo
|
||||
// SKIP: ( $FLATTEN_STATIC_CONTROL_FLOW == 0 ) && ( $NUM_LIGHTS > 0 ) [vs20] [PC]
|
||||
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
static const bool g_bHalfLambert = HALFLAMBERT ? true : false;
|
||||
|
||||
const float3 cLeafCenter : register(SHADER_SPECIFIC_CONST_0);
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
// This is all of the stuff that we ever use.
|
||||
float4 vPos : POSITION;
|
||||
float4 vNormal : NORMAL;
|
||||
float2 vTexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
float3 color : COLOR;
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
bool bDynamicLight = DYNAMIC_LIGHT ? true : false;
|
||||
bool bStaticLight = STATIC_LIGHT ? true : false;
|
||||
|
||||
float3 worldPos;
|
||||
worldPos = mul( v.vPos, cModel[0] );
|
||||
|
||||
float3 normal = v.vPos.xyz - cLeafCenter.xyz;
|
||||
normal = normalize( normal );
|
||||
|
||||
float3 worldNormal = mul( float4( normal, 0.0f ), cModel[0] );
|
||||
|
||||
#if ( ( FLATTEN_STATIC_CONTROL_FLOW == 0 ) || defined ( SHADER_MODEL_VS_3_0 ) )
|
||||
float3 lighting = DoLighting( worldPos, worldNormal, float3(0,0,0), bStaticLight, bDynamicLight, g_bHalfLambert );
|
||||
#else
|
||||
float3 lighting = DoLightingUnrolled( worldPos, worldNormal, float3(0,0,0), bStaticLight, bDynamicLight, g_bHalfLambert, NUM_LIGHTS );
|
||||
#endif
|
||||
|
||||
float3 xAxis = float3( cViewModel[0].x, cViewModel[1].x, cViewModel[2].x );
|
||||
float3 yAxis = float3( cViewModel[0].y, cViewModel[1].y, cViewModel[2].y );
|
||||
|
||||
worldPos += xAxis * v.vTexCoord.x;
|
||||
worldPos += yAxis * (1.0f-v.vTexCoord.y);
|
||||
|
||||
float4 projPos = mul( float4(worldPos, 1.0f), cViewProj );
|
||||
|
||||
float3 light_vec = float3( 1.0f, 0.0, 1.0 );
|
||||
light_vec = normalize( light_vec );
|
||||
|
||||
o.projPos = projPos;
|
||||
// FIXME: if this shader gets put back into use, be sure this usage of normals jives with compressed verts
|
||||
o.texCoord = v.vNormal.xy;
|
||||
o.color = lighting;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
3
materialsystem/stdshaders/UPDB_X360/dummy.txt
Normal file
3
materialsystem/stdshaders/UPDB_X360/dummy.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
This directory needs to pre-exist for dynamic shader compile updb generation on Xbox 360.
|
||||
|
||||
I was unsuccessful at creating the directory at runtime in code across the network. So I'm letting perforce create it with this file.
|
||||
13
materialsystem/stdshaders/UnlitGeneric.psh
Normal file
13
materialsystem/stdshaders/UnlitGeneric.psh
Normal file
@@ -0,0 +1,13 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0 ; base color
|
||||
|
||||
mul r0, t0, v0
|
||||
297
materialsystem/stdshaders/WaterCheap_ps2x.fxc
Normal file
297
materialsystem/stdshaders/WaterCheap_ps2x.fxc
Normal file
@@ -0,0 +1,297 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// STATIC: "MULTITEXTURE" "0..1"
|
||||
// STATIC: "FRESNEL" "0..1"
|
||||
// STATIC: "BLEND" "0..1"
|
||||
// STATIC: "REFRACTALPHA" "0..1"
|
||||
// STATIC: "HDRTYPE" "0..2"
|
||||
// STATIC: "FLOWMAP" "0..1"
|
||||
// STATIC: "FLOW_DEBUG" "0..1"
|
||||
|
||||
// DYNAMIC: "HDRENABLED" "0..1"
|
||||
|
||||
#include "common_fog_ps_fxc.h"
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
#include "shader_constant_register_map.h"
|
||||
|
||||
// Constants
|
||||
const float3 g_WaterFogColor : register( c0 );
|
||||
|
||||
const float4 g_CheapWaterParams : register( c1 );
|
||||
#define g_CheapWaterStart g_CheapWaterParams.x
|
||||
#define g_CheapWaterEnd g_CheapWaterParams.y
|
||||
#define g_CheapWaterDeltaRecip g_CheapWaterParams.z
|
||||
#define g_CheapWaterStartDivDelta g_CheapWaterParams.w
|
||||
|
||||
const float4 g_ReflectTint : register( c2 );
|
||||
const float g_flTime : register( c10 );
|
||||
|
||||
const float4 g_EyePos : register( PSREG_EYEPOS_SPEC_EXPONENT ); // c11
|
||||
const float4 g_PixelFogParams : register( PSREG_FOG_PARAMS ); // c12
|
||||
|
||||
const float4 g_vFlowParams1 : register( c13 );
|
||||
#define g_flWorldUvScale ( g_vFlowParams1.x ) // 1.0f / 10.0f
|
||||
#define g_flNormalUvScale ( g_vFlowParams1.y ) // 1.0f / 1.15f
|
||||
#define g_flBumpStrength ( g_vFlowParams1.z ) // 3.0f
|
||||
#define g_flTimeScale ( g_vFlowParams1.w ) // 1.0f
|
||||
|
||||
const float3 g_vFlowParams2 : register( c14 );
|
||||
#define g_flFlowTimeIntervalInSeconds ( g_vFlowParams2.x ) // 0.4f // Number of seconds to lerp from texture 1 to texture 2
|
||||
#define g_flFlowUvScrollDistance ( g_vFlowParams2.y ) // 0.25f // Distance in uv space to fetch
|
||||
#define g_flNoiseScale ( g_vFlowParams2.z )
|
||||
|
||||
// Textures
|
||||
samplerCUBE EnvmapSampler : register( s0 );
|
||||
sampler NormalMapSampler : register( s1 );
|
||||
|
||||
#if REFRACTALPHA
|
||||
sampler RefractSampler : register( s2 );
|
||||
#endif
|
||||
|
||||
sampler FlowSampler : register( s3 );
|
||||
|
||||
sampler FlowNoiseSampler : register( s4 );
|
||||
|
||||
samplerCUBE NormalizeSampler : register( s6 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 worldSpaceEyeVect_normalMapX : TEXCOORD1;
|
||||
float3x3 tangentSpaceTranspose : TEXCOORD2;
|
||||
float4 vRefract_W_ProjZ : TEXCOORD5;
|
||||
|
||||
#if MULTITEXTURE
|
||||
float4 vExtraBumpTexCoord : TEXCOORD6;
|
||||
#endif
|
||||
|
||||
float4 worldPos_normalMapY : TEXCOORD7;
|
||||
};
|
||||
|
||||
float2 UnpackNormal2D( float2 vNormal )
|
||||
{
|
||||
return ( ( vNormal.xy * 2.0 ) - 1.0 );
|
||||
}
|
||||
|
||||
float3 UnpackNormal3D( float3 vNormal )
|
||||
{
|
||||
return ( ( vNormal.xyz * 2.0 ) - 1.0 );
|
||||
}
|
||||
|
||||
float3 ComputeNormalFromXY( float2 vXY )
|
||||
{
|
||||
float3 vNormalTs;
|
||||
|
||||
vNormalTs.xy = vXY.xy;
|
||||
vNormalTs.z = sqrt( saturate( 1.0 - dot( vNormalTs.xy, vNormalTs.xy ) ) );
|
||||
|
||||
return vNormalTs.xyz;
|
||||
}
|
||||
|
||||
float3 ComputeNormalFromRGTexture( float2 vRGPixel )
|
||||
{
|
||||
float3 vNormalTs;
|
||||
|
||||
vNormalTs.xy = UnpackNormal2D( vRGPixel.rg );
|
||||
vNormalTs.z = sqrt( saturate( 1.0 - dot( vNormalTs.xy, vNormalTs.xy ) ) );
|
||||
|
||||
return vNormalTs.xyz;
|
||||
}
|
||||
|
||||
float4_color_return_type main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float2 normalMapTexCoord = float2( i.worldSpaceEyeVect_normalMapX.w, i.worldPos_normalMapY.w );
|
||||
|
||||
float3 vNormal;
|
||||
#if ( FLOWMAP )
|
||||
{
|
||||
//*
|
||||
float flWorldUvScale = g_flWorldUvScale;
|
||||
float flNormalUvScale = g_flNormalUvScale;
|
||||
float flFlowTimeIntervalInSeconds = g_flFlowTimeIntervalInSeconds;
|
||||
float flFlowUvScrollDistance = g_flFlowUvScrollDistance;
|
||||
float flBumpStrength = g_flBumpStrength;
|
||||
float flTimeScale = g_flTimeScale;
|
||||
float flNoiseScale = g_flNoiseScale;
|
||||
//*/
|
||||
|
||||
/* River
|
||||
float flWorldUvScale = 1.0f / 6.0f;
|
||||
float flNormalUvScale = 1.0f / 0.5f;
|
||||
float flFlowTimeIntervalInSeconds = 0.4f; // Number of seconds to lerp from texture 1 to texture 2
|
||||
float flFlowUvScrollDistance = 0.2f; // Distance in uv space to fetch
|
||||
float flBumpStrength = 1.0f;
|
||||
float flTimeScale = 0.75f;
|
||||
//*/
|
||||
|
||||
/* Swamp - Heavy churn
|
||||
float flWorldUvScale = 1.0f / 10.0f;
|
||||
float flNormalUvScale = 1.0f / 1.15f;
|
||||
float flFlowTimeIntervalInSeconds = 0.4f; // Number of seconds to lerp from texture 1 to texture 2
|
||||
float flFlowUvScrollDistance = 0.25f; // Distance in uv space to fetch
|
||||
float flBumpStrength = 3.0f;
|
||||
float flTimeScale = 1.0f;
|
||||
//*/
|
||||
|
||||
/* Swamp - Calmer
|
||||
float flWorldUvScale = 1.0f / 10.0f;
|
||||
float flNormalUvScale = 1.0f / 1.15f;
|
||||
float flFlowTimeIntervalInSeconds = 0.25f; // Number of seconds to lerp from texture 1 to texture 2
|
||||
float flFlowUvScrollDistance = 0.15f; // Distance in uv space to fetch
|
||||
float flBumpStrength = 1.05f;
|
||||
float flTimeScale = 0.35f;
|
||||
//*/
|
||||
|
||||
// Input uv
|
||||
float2 vWorldUv = normalMapTexCoord.xy * flWorldUvScale;
|
||||
float2 vUv1 = float2( i.worldPos_normalMapY.x, -i.worldPos_normalMapY.y ) * flNormalUvScale;
|
||||
float2 vUv2 = vUv1.xy;
|
||||
|
||||
// Noise texture is used to offset the time interval different spatially so we don't see pulsing
|
||||
float flNoise = tex2D( FlowNoiseSampler, float2( i.worldPos_normalMapY.x, -i.worldPos_normalMapY.y ) * flNoiseScale ).g;
|
||||
|
||||
// Flow texel has a 2D flow vector in the rg channels of the texture
|
||||
float4 vFlowTexel = tex2D( FlowSampler, vWorldUv.xy );
|
||||
#if FLOW_DEBUG
|
||||
{
|
||||
return float4( vFlowTexel.rgb, 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
// Unpack world flow vector from texture
|
||||
float2 vFlowVectorTs = ( vFlowTexel.rg * 2.0f ) - 1.0f;
|
||||
|
||||
float flTimeInIntervals = ( ( g_flTime * flTimeScale ) + flNoise ) / ( flFlowTimeIntervalInSeconds * 2.0f );
|
||||
float flScrollTime1 = frac( flTimeInIntervals );
|
||||
float flScrollTime2 = frac( flTimeInIntervals + 0.5f ); // Half an interval off from texture 1
|
||||
|
||||
// Every interval has a unique offset so we don't see the same bump texels repeating continuously
|
||||
float flOffset1 = floor( flTimeInIntervals ) * 0.311f;
|
||||
float flOffset2 = floor( flTimeInIntervals + 0.5f ) * 0.311f + 0.5f; // The +0.5 is to match the phase offset
|
||||
|
||||
// Final flow uv is originalUv + interval offset + ( flowvector * scroll
|
||||
float2 vFlowUv1 = vUv1.xy + flOffset1 + ( flScrollTime1 * ( flFlowUvScrollDistance * vFlowVectorTs.xy ) );
|
||||
float2 vFlowUv2 = vUv2.xy + flOffset2 + ( flScrollTime2 * ( flFlowUvScrollDistance * vFlowVectorTs.xy ) );
|
||||
|
||||
// Lerp values to blend between the two layers of bump
|
||||
float flWeight1 = abs( ( 2.0f * frac( flTimeInIntervals + 0.5f ) ) - 1.0f );
|
||||
float flWeight2 = abs( ( 2.0f * frac( flTimeInIntervals ) ) - 1.0f );
|
||||
|
||||
float4 vNormalTexel1 = tex2D( NormalMapSampler, vFlowUv1.xy );
|
||||
float4 vNormalTexel2 = tex2D( NormalMapSampler, vFlowUv2.xy );
|
||||
|
||||
float3 vNormal1 = ( vNormalTexel1.rgb );
|
||||
float3 vNormal2 = ( vNormalTexel2.rgb );
|
||||
|
||||
// Combine both layers
|
||||
vNormal.xy = UnpackNormal2D( lerp( vNormal1.xy, vNormal2.xy, flWeight2 ) );
|
||||
|
||||
// Change bump strength based on the length of the flow vector
|
||||
//vNormal.xy *= ( length( vFlowVectorTs.xy ) + 0.05f ) * flBumpStrength;
|
||||
vNormal.xy *= ( ( vFlowVectorTs.x * vFlowVectorTs.x + vFlowVectorTs.y * vFlowVectorTs.y ) + 0.05f ) * flBumpStrength;
|
||||
|
||||
// Generate normal from 2D scaled normal
|
||||
vNormal.xyz = ComputeNormalFromXY( vNormal.xy );
|
||||
}
|
||||
#elif ( MULTITEXTURE )
|
||||
{
|
||||
vNormal.xyz = tex2D( NormalMapSampler, normalMapTexCoord ).xyz;
|
||||
float3 vNormal1 = tex2D( NormalMapSampler, i.vExtraBumpTexCoord.xy ).xyz;
|
||||
float3 vNormal2 = tex2D( NormalMapSampler, i.vExtraBumpTexCoord.zw ).xyz;
|
||||
vNormal = 0.33 * ( vNormal + vNormal1 + vNormal2 );
|
||||
|
||||
vNormal = 2.0 * vNormal - 1.0;
|
||||
}
|
||||
#else
|
||||
{
|
||||
vNormal.xyz = DecompressNormal( NormalMapSampler, normalMapTexCoord, NORM_DECODE_NONE ).xyz;
|
||||
}
|
||||
#endif
|
||||
|
||||
float3 worldSpaceNormal = mul( vNormal, i.tangentSpaceTranspose );
|
||||
float3 worldSpaceEye;
|
||||
|
||||
float flWorldSpaceDist = 1.0f;
|
||||
|
||||
#ifdef NV3X
|
||||
// for some reason, fxc doesn't convert length( half3 v ) into all _pp opcodes.
|
||||
#if ( BLEND )
|
||||
{
|
||||
worldSpaceEye = i.worldSpaceEyeVect_normalMapX.xyz;
|
||||
float worldSpaceDistSqr = dot( worldSpaceEye, worldSpaceEye );
|
||||
float rcpWorldSpaceDist = rsqrt( worldSpaceDistSqr );
|
||||
worldSpaceEye *= rcpWorldSpaceDist;
|
||||
flWorldSpaceDist = worldSpaceDistSqr * rcpWorldSpaceDist;
|
||||
}
|
||||
#else
|
||||
{
|
||||
worldSpaceEye = NormalizeWithCubemap( NormalizeSampler, i.worldSpaceEyeVect_normalMapX.xyz );
|
||||
}
|
||||
#endif
|
||||
#else // !NV3X
|
||||
#if ( BLEND )
|
||||
{
|
||||
worldSpaceEye = i.worldSpaceEyeVect_normalMapX.xyz;
|
||||
flWorldSpaceDist = length( worldSpaceEye );
|
||||
worldSpaceEye /= flWorldSpaceDist;
|
||||
}
|
||||
#else
|
||||
{
|
||||
worldSpaceEye = NormalizeWithCubemap( NormalizeSampler, i.worldSpaceEyeVect_normalMapX.xyz );
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float3 reflectVect = CalcReflectionVectorUnnormalized( worldSpaceNormal, worldSpaceEye );
|
||||
float3 specularLighting = ENV_MAP_SCALE * texCUBE( EnvmapSampler, reflectVect ).rgb;
|
||||
specularLighting *= g_ReflectTint.rgb;
|
||||
|
||||
#if FRESNEL
|
||||
// FIXME: It's unclear that we want to do this for cheap water
|
||||
// but the code did this previously and I didn't want to change it
|
||||
float flDotResult = dot( worldSpaceEye, worldSpaceNormal );
|
||||
flDotResult = 1.0f - max( 0.0f, flDotResult );
|
||||
|
||||
float flFresnelFactor = flDotResult * flDotResult;
|
||||
flFresnelFactor *= flFresnelFactor;
|
||||
flFresnelFactor *= flDotResult;
|
||||
#else
|
||||
float flFresnelFactor = g_ReflectTint.a;
|
||||
#endif
|
||||
|
||||
float flAlpha;
|
||||
#if ( BLEND )
|
||||
{
|
||||
float flReflectAmount = saturate( flWorldSpaceDist * g_CheapWaterDeltaRecip - g_CheapWaterStartDivDelta );
|
||||
flAlpha = saturate( flFresnelFactor + flReflectAmount );
|
||||
|
||||
#if REFRACTALPHA
|
||||
// Perform division by W only once
|
||||
float ooW = 1.0f / i.vRefract_W_ProjZ.z;
|
||||
float2 unwarpedRefractTexCoord = i.vRefract_W_ProjZ.xy * ooW;
|
||||
float fogDepthValue = tex2D( RefractSampler, unwarpedRefractTexCoord ).a;
|
||||
// Fade on the border between the water and land.
|
||||
flAlpha *= saturate( ( fogDepthValue - .05f ) * 20.0f );
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
{
|
||||
flAlpha = 1.0f;
|
||||
#if HDRTYPE == 0 || HDRENABLED == 0
|
||||
specularLighting = lerp( g_WaterFogColor, specularLighting, flFresnelFactor );
|
||||
#else
|
||||
specularLighting = lerp( GammaToLinear( g_WaterFogColor ), specularLighting, flFresnelFactor );
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// multiply the color by alpha.since we are using alpha blending to blend against dest alpha for borders.
|
||||
|
||||
#if (PIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE)
|
||||
float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_PixelFogParams, g_EyePos.xyz, i.worldPos_normalMapY.xyz, i.vRefract_W_ProjZ.w );
|
||||
#else
|
||||
float fogFactor = 0;
|
||||
#endif
|
||||
|
||||
return FinalOutput( float4( specularLighting, flAlpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR );
|
||||
}
|
||||
91
materialsystem/stdshaders/WaterCheap_vs20.fxc
Normal file
91
materialsystem/stdshaders/WaterCheap_vs20.fxc
Normal file
@@ -0,0 +1,91 @@
|
||||
// STATIC: "BLEND" "0..1"
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION;
|
||||
float4 vNormal : NORMAL;
|
||||
float2 vNormalMapCoord : TEXCOORD0;
|
||||
float3 vTangentS : TANGENT;
|
||||
float3 vTangentT : BINORMAL;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
|
||||
float fog : FOG;
|
||||
#endif
|
||||
float4 worldVertToEyeVector_normalMapX : TEXCOORD1;
|
||||
float3x3 tangentSpaceTranspose : TEXCOORD2;
|
||||
float4 vRefract_W_ProjZ : TEXCOORD5;
|
||||
float4 vExtraBumpTexCoord : TEXCOORD6;
|
||||
float4 worldPos_normalMapY : TEXCOORD7;
|
||||
};
|
||||
|
||||
const float4 cNormalMapTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
|
||||
const float4 TexOffsets : register( SHADER_SPECIFIC_CONST_3 );
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
float3 vObjNormal;
|
||||
DecompressVertex_Normal( v.vNormal, vObjNormal );
|
||||
|
||||
float4 projPos;
|
||||
float3 worldPos;
|
||||
|
||||
worldPos = mul4x3( v.vPos, cModel[0] );
|
||||
projPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
o.projPos = projPos;
|
||||
|
||||
#ifdef _PS3
|
||||
// Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
|
||||
o.projPos.y = -o.projPos.y;
|
||||
o.projPos.z = 2.0f * o.projPos.z - o.projPos.w;
|
||||
#endif // _PS3
|
||||
|
||||
#if BLEND
|
||||
// Map projected position to the reflection texture
|
||||
o.vRefract_W_ProjZ.x = projPos.x;
|
||||
o.vRefract_W_ProjZ.y = -projPos.y; // invert Y
|
||||
o.vRefract_W_ProjZ.xy = ( o.vRefract_W_ProjZ.xy + projPos.ww ) * float2( 0.5f, 0.5f );
|
||||
o.vRefract_W_ProjZ.z = projPos.w;
|
||||
#endif
|
||||
|
||||
o.vRefract_W_ProjZ.w = projPos.z;
|
||||
|
||||
float3 worldTangentS = mul3x3( v.vTangentS, ( const float3x3 )cModel[0] );
|
||||
float3 worldTangentT = mul3x3( v.vTangentT, ( const float3x3 )cModel[0] );
|
||||
float3 worldNormal = mul3x3( vObjNormal, ( float3x3 )cModel[0] );
|
||||
o.tangentSpaceTranspose[0] = worldTangentS;
|
||||
o.tangentSpaceTranspose[1] = worldTangentT;
|
||||
o.tangentSpaceTranspose[2] = worldNormal;
|
||||
|
||||
float3 worldVertToEyeVector = VSHADER_VECT_SCALE * (cEyePos - worldPos);
|
||||
o.worldVertToEyeVector_normalMapX.xyz = worldVertToEyeVector;
|
||||
|
||||
// FIXME: need to add a normalMapTransform to all of the water shaders.
|
||||
//o.worldVertToEyeVector_normalMapX.w = dot( v.vNormalMapCoord, cNormalMapTransform[0] ) + cNormalMapTransform[0].w;
|
||||
//o.worldPos_normalMapY.w = dot( v.vNormalMapCoord, cNormalMapTransform[1] ) + cNormalMapTransform[1].w;
|
||||
o.worldVertToEyeVector_normalMapX.w = v.vNormalMapCoord.x;
|
||||
o.worldPos_normalMapY.w = v.vNormalMapCoord.y;
|
||||
|
||||
float f45x=v.vNormalMapCoord.x+v.vNormalMapCoord.y;
|
||||
float f45y=v.vNormalMapCoord.y-v.vNormalMapCoord.x;
|
||||
o.vExtraBumpTexCoord.x=f45x*0.1+TexOffsets.x;
|
||||
o.vExtraBumpTexCoord.y=f45y*0.1+TexOffsets.y;
|
||||
o.vExtraBumpTexCoord.z=v.vNormalMapCoord.y*0.45+TexOffsets.z;
|
||||
o.vExtraBumpTexCoord.w=v.vNormalMapCoord.x*0.45+TexOffsets.w;
|
||||
|
||||
o.worldPos_normalMapY.xyz = worldPos;
|
||||
|
||||
#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
|
||||
o.fog = CalcFixedFunctionFog( worldPos, FOGTYPE_RANGE );
|
||||
#endif
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
168
materialsystem/stdshaders/Water_vs20.fxc
Normal file
168
materialsystem/stdshaders/Water_vs20.fxc
Normal file
@@ -0,0 +1,168 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
|
||||
// STATIC: "BASETEXTURE" "0..1"
|
||||
// STATIC: "MULTITEXTURE" "0..1"
|
||||
// STATIC: "FLASHLIGHT" "0..1"
|
||||
// STATIC: "LIGHTMAPWATERFOG" "0..1"
|
||||
// STATIC: "FLOWMAP" "0..1"
|
||||
|
||||
// Multitexture and basetexture are mutually exclusive.
|
||||
// SKIP: $MULTITEXTURE && $BASETEXTURE
|
||||
|
||||
// flowmap doesn't play with multitexture or basetexture
|
||||
// SKIP: $FLOWMAP && $MULTITEXTURE
|
||||
|
||||
// Have to have the flashlight on to get flashlightshadows.
|
||||
// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 )
|
||||
|
||||
// basetexture doesn't work with flashlight or lightmapwaterfog. multitexture doesn't either. We don't use basetexture or multitexture in newer code and instead use flowmap and flashlight.
|
||||
// SKIP: ( $FLASHLIGHT || $LIGHTMAPWATERFOG ) && ( ( $BASETEXTURE && !$FLOWMAP ) || $MULTITEXTURE )
|
||||
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
const float4 cBumpTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_1 );
|
||||
const float4 TexOffsets : register( SHADER_SPECIFIC_CONST_3 );
|
||||
|
||||
#if FLASHLIGHT
|
||||
const float4x4 g_FlashlightWorldToTexture : register( SHADER_SPECIFIC_CONST_4 );
|
||||
#endif
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION;
|
||||
float4 vNormal : NORMAL;
|
||||
float4 vBaseTexCoord : TEXCOORD0;
|
||||
float2 vLightmapTexCoord : TEXCOORD1;
|
||||
float2 vLightmapTexCoordOffset : TEXCOORD2;
|
||||
float3 vTangentS : TANGENT;
|
||||
float3 vTangentT : BINORMAL0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos_POSITION : POSITION;
|
||||
#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
|
||||
float fog : FOG;
|
||||
#endif
|
||||
float2 vBumpTexCoord : TEXCOORD0;
|
||||
float3 vPositionToCameraRayWs : TEXCOORD1;
|
||||
float4 vReflectXY_vRefractYX : TEXCOORD2;
|
||||
float4 vProjPos : TEXCOORD3;
|
||||
float3 worldPos : TEXCOORD4;
|
||||
#if FLASHLIGHT
|
||||
float4 flashlightSpacePos : TEXCOORD5;
|
||||
#endif
|
||||
#if MULTITEXTURE
|
||||
float4 vExtraBumpTexCoord : TEXCOORD5;
|
||||
#endif
|
||||
#if ( BASETEXTURE && !FLOWMAP )
|
||||
float4 lightmapTexCoord1And2 : TEXCOORD5;
|
||||
float2 lightmapTexCoord3 : TEXCOORD6;
|
||||
#endif
|
||||
|
||||
#if LIGHTMAPWATERFOG
|
||||
float2 lightmapTexCoord : TEXCOORD7;
|
||||
#endif
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o;
|
||||
|
||||
float3 vObjNormal;
|
||||
DecompressVertex_Normal( v.vNormal, vObjNormal );
|
||||
|
||||
// Projected position
|
||||
float3 vWorldPos = mul4x3( v.vPos, cModel[0] );
|
||||
float4 vProjPos = mul( float4( vWorldPos, 1 ), cViewProj );
|
||||
|
||||
o.vProjPos = o.vProjPos_POSITION = vProjPos;
|
||||
|
||||
|
||||
// Project tangent basis
|
||||
float2 vProjTangentS = mul( v.vTangentS, cViewProj ).xy;
|
||||
float2 vProjTangentT = mul( v.vTangentT, cViewProj ).xy;
|
||||
|
||||
// Map projected position to the reflection texture
|
||||
float2 vReflectPos;
|
||||
vReflectPos = (vProjPos.xy + vProjPos.w) * 0.5f;
|
||||
|
||||
// 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;
|
||||
|
||||
// Reflection transform
|
||||
o.vReflectXY_vRefractYX = float4( vReflectPos.x, vReflectPos.y, vRefractPos.y, vRefractPos.x );
|
||||
|
||||
#ifdef _PS3
|
||||
// Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
|
||||
o.vProjPos_POSITION.y = -o.vProjPos_POSITION.y;
|
||||
o.vProjPos_POSITION.z = 2.0f * o.vProjPos_POSITION.z - o.vProjPos_POSITION.w;
|
||||
#endif // _PS3
|
||||
|
||||
// Compute fog based on the position
|
||||
o.worldPos = vWorldPos;
|
||||
|
||||
#if ( !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) )
|
||||
{
|
||||
o.fog = CalcFixedFunctionFog( vWorldPos, FOGTYPE_RANGE );
|
||||
}
|
||||
#endif
|
||||
|
||||
// Eye vector
|
||||
float3 vPositionToCameraRayWs = cEyePos.xyz - vWorldPos.xyz;
|
||||
|
||||
// Transform to the tangent space
|
||||
//o.vTangentEyeVect.x = dot( vPositionToCameraRayWs, v.vTangentS );
|
||||
//o.vTangentEyeVect.y = dot( vPositionToCameraRayWs, v.vTangentT );
|
||||
//o.vTangentEyeVect.z = dot( vPositionToCameraRayWs, vObjNormal );
|
||||
|
||||
o.vPositionToCameraRayWs.xyz = vPositionToCameraRayWs.xyz;
|
||||
|
||||
// Tranform bump coordinates
|
||||
o.vBumpTexCoord.x = dot( v.vBaseTexCoord, cBumpTexCoordTransform[0] );
|
||||
o.vBumpTexCoord.y = dot( v.vBaseTexCoord, cBumpTexCoordTransform[1] );
|
||||
float f45x=v.vBaseTexCoord.x+v.vBaseTexCoord.y;
|
||||
float f45y=v.vBaseTexCoord.y-v.vBaseTexCoord.x;
|
||||
#if ( MULTITEXTURE )
|
||||
{
|
||||
o.vExtraBumpTexCoord.x=f45x*0.1+TexOffsets.x;
|
||||
o.vExtraBumpTexCoord.y=f45y*0.1+TexOffsets.y;
|
||||
o.vExtraBumpTexCoord.z=v.vBaseTexCoord.y*0.45+TexOffsets.z;
|
||||
o.vExtraBumpTexCoord.w=v.vBaseTexCoord.x*0.45+TexOffsets.w;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ( BASETEXTURE && !FLOWMAP )
|
||||
{
|
||||
o.lightmapTexCoord1And2.xy = v.vLightmapTexCoord + v.vLightmapTexCoordOffset;
|
||||
|
||||
float2 lightmapTexCoord2 = o.lightmapTexCoord1And2.xy + v.vLightmapTexCoordOffset;
|
||||
float2 lightmapTexCoord3 = lightmapTexCoord2 + v.vLightmapTexCoordOffset;
|
||||
|
||||
// reversed component order
|
||||
o.lightmapTexCoord1And2.w = lightmapTexCoord2.x;
|
||||
o.lightmapTexCoord1And2.z = lightmapTexCoord2.y;
|
||||
|
||||
o.lightmapTexCoord3.xy = lightmapTexCoord3;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LIGHTMAPWATERFOG
|
||||
{
|
||||
o.lightmapTexCoord.xy = v.vLightmapTexCoord.xy;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if FLASHLIGHT
|
||||
{
|
||||
o.flashlightSpacePos = TransformFlashlightWorldToTexture( vWorldPos, g_FlashlightWorldToTexture );
|
||||
}
|
||||
#endif
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
10
materialsystem/stdshaders/WorldVertexAlpha.psh
Normal file
10
materialsystem/stdshaders/WorldVertexAlpha.psh
Normal file
@@ -0,0 +1,10 @@
|
||||
ps.1.1
|
||||
|
||||
tex t0 ; basetexture
|
||||
tex t1 ; lightmap
|
||||
|
||||
mov r0.a, 1-t1.a
|
||||
;mov r0.rgb, t0 ; * 2 * (overbrightFactor/2)
|
||||
;mov_x2 r0.rgb, t0 ; * 2 * (overbrightFactor/2)
|
||||
mul r0.rgb, t0, t1;
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
37
materialsystem/stdshaders/WorldVertexAlpha.vsh
Normal file
37
materialsystem/stdshaders/WorldVertexAlpha.vsh
Normal file
@@ -0,0 +1,37 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
local( $worldPos, $worldNormal, $projPos, $reflectionVector );
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
mov oPos, $projPos
|
||||
|
||||
&AllocateRegister( \$worldPos );
|
||||
|
||||
; garymcthack
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
|
||||
&FreeRegister( \$worldPos );
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
; base texcoords
|
||||
mov oT0, $vTexCoord0
|
||||
|
||||
; lightmap texcoords
|
||||
mov oT1, $vTexCoord1
|
||||
|
||||
&FreeRegister( \$worldPos ); # garymcthack
|
||||
|
||||
40
materialsystem/stdshaders/WorldVertexAlpha_ps2x.fxc
Normal file
40
materialsystem/stdshaders/WorldVertexAlpha_ps2x.fxc
Normal file
@@ -0,0 +1,40 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// STATIC: "PASS" "0..1"
|
||||
|
||||
#define HDRTYPE HDR_TYPE_NONE
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler BaseSampler : register( s0 );
|
||||
sampler LightmapSampler: register( s1 );
|
||||
sampler LightmapAlphaSampler: register( s2 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 baseCoord : TEXCOORD0;
|
||||
float2 lightmapCoord : TEXCOORD1_centroid;
|
||||
};
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
bool bAlphaPass = PASS ? true : false;
|
||||
|
||||
float4 base = tex2D( BaseSampler, i.baseCoord );
|
||||
float4 lightmap = tex2D( LightmapSampler, i.lightmapCoord );
|
||||
float4 alpha = tex2D( LightmapAlphaSampler, i.lightmapCoord );
|
||||
|
||||
float4 color;
|
||||
|
||||
base.a = dot( base, float3( 0.33333f, 0.33333f, 0.33333f ) );
|
||||
color = 2.0f * base * lightmap; // The 2x is for an assumed overbright 2 (it's always 2 on dx9)
|
||||
|
||||
if( bAlphaPass )
|
||||
{
|
||||
// Don't care about color, just return pre-multiplied alpha
|
||||
return FinalOutput( float4( 0.0f, 0.0f, 1.0f, (1.0f - alpha.a) * color.a ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
else
|
||||
{
|
||||
return FinalOutput( float4( color.rgb, (1.0f - alpha.a) ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
}
|
||||
48
materialsystem/stdshaders/WorldVertexTransition.vsh
Normal file
48
materialsystem/stdshaders/WorldVertexTransition.vsh
Normal file
@@ -0,0 +1,48 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
local( $worldPos, $worldNormal, $projPos, $reflectionVector );
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
mov oPos, $projPos
|
||||
|
||||
&AllocateRegister( \$worldPos );
|
||||
|
||||
; garymcthack
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
|
||||
&FreeRegister( \$worldPos );
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
; base texcoords
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
|
||||
dp4 oT1.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
|
||||
dp4 oT1.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_3
|
||||
|
||||
; lightmap texcoords
|
||||
mov oT2, $vTexCoord1
|
||||
|
||||
; detail
|
||||
dp4 oT3.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_4
|
||||
dp4 oT3.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_5
|
||||
|
||||
; Now the basetexture/basetexture2 blend uses vertex color, so send it into the psh.
|
||||
mov oD0, $vColor
|
||||
|
||||
&FreeRegister( \$worldPos ); # garymcthack
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
mul r0.rgb, t1, t0 ; fold in lightmap (color)
|
||||
+mov r0.a, v0.a ; fold in lightmap (alpha)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
10
materialsystem/stdshaders/WorldVertexTransition_Editor.psh
Normal file
10
materialsystem/stdshaders/WorldVertexTransition_Editor.psh
Normal file
@@ -0,0 +1,10 @@
|
||||
ps.1.1
|
||||
|
||||
tex t0 ; basetexture
|
||||
tex t1 ; basetexture2
|
||||
tex t2 ; lightmap
|
||||
|
||||
; The editor uses vertex alpha as the blend factor
|
||||
lrp r0, 1-v0.a, t1, t0
|
||||
mul r0, r0, t2
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
45
materialsystem/stdshaders/WorldVertexTransition_ps2x.fxc
Normal file
45
materialsystem/stdshaders/WorldVertexTransition_ps2x.fxc
Normal file
@@ -0,0 +1,45 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// STATIC: "MACROS" "0..1"
|
||||
|
||||
#define HDRTYPE HDR_TYPE_NONE
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler BaseSampler : register( s0 );
|
||||
// NOTE: LightmapSampler is at the same place as the lightmap sampler in lightmappedgeneric so that we have
|
||||
// generally the same texture state here.
|
||||
sampler LightmapSampler: register( s1 );
|
||||
sampler BaseSampler2: register( s2 );
|
||||
sampler LightmapAlphaSampler: register( s3 );
|
||||
sampler MacrosSampler: register( s4 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 baseCoord : TEXCOORD0;
|
||||
float2 baseCoord2 : TEXCOORD1;
|
||||
float2 lightmapCoord : TEXCOORD2_centroid;
|
||||
float2 macrosCoord : TEXCOORD3;
|
||||
};
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
bool bMacros = MACROS ? true : false;
|
||||
|
||||
float4 base = tex2D( BaseSampler, i.baseCoord );
|
||||
float4 base2 = tex2D( BaseSampler2, i.baseCoord2 );
|
||||
|
||||
float4 lightmap = tex2D( LightmapSampler, i.lightmapCoord );
|
||||
float blendFactor = lightmap.a;
|
||||
|
||||
float4 color = 2.0f * lightmap * lerp( base2, base, blendFactor );
|
||||
if( bMacros )
|
||||
{
|
||||
float4 macros = tex2D( MacrosSampler, i.macrosCoord );
|
||||
|
||||
// Not sure what to do with macro alpha
|
||||
color.rgb *= 2.0f * lerp( macros.a, macros.b, blendFactor );
|
||||
}
|
||||
|
||||
return FinalOutput( color, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
|
||||
62
materialsystem/stdshaders/WorldVertexTransition_vs20.fxc
Normal file
62
materialsystem/stdshaders/WorldVertexTransition_vs20.fxc
Normal file
@@ -0,0 +1,62 @@
|
||||
#include "common_fog_vs_fxc.h"
|
||||
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
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 cMacrosTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_4 );
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
// This is all of the stuff that we ever use.
|
||||
float4 vPos : POSITION;
|
||||
float4 vColor : COLOR0;
|
||||
float4 vTexCoord0 : TEXCOORD0;
|
||||
float4 vTexCoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
#if !defined( _X360 )
|
||||
float fog : FOG;
|
||||
#endif
|
||||
float2 baseCoord : TEXCOORD0;
|
||||
float2 baseCoord2 : TEXCOORD1;
|
||||
float2 lightmapCoord : TEXCOORD2;
|
||||
float2 macrosCoord : TEXCOORD3;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
float3 worldNormal, worldPos;
|
||||
float2 texCoord;
|
||||
worldPos = mul( v.vPos, cModel[0] );
|
||||
float4 projPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
o.projPos = projPos;
|
||||
o.fogFactorsYZW = CalcFog( worldPos, projPos, g_FogType );
|
||||
#if !defined( _X360 )
|
||||
o.fog = o.fogFactorsYZW;
|
||||
#endif
|
||||
o.color = v.vColor;
|
||||
|
||||
o.baseCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] );
|
||||
o.baseCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] );
|
||||
|
||||
o.baseCoord2.x = dot( v.vTexCoord0, cBaseTexCoordTransform2[0] );
|
||||
o.baseCoord2.y = dot( v.vTexCoord0, cBaseTexCoordTransform2[1] );
|
||||
|
||||
o.lightmapCoord = v.vTexCoord1;
|
||||
|
||||
o.macrosCoord.x = dot( v.vTexCoord0, cMacrosTexCoordTransform[0] );
|
||||
o.macrosCoord.y = dot( v.vTexCoord0, cMacrosTexCoordTransform[1] );
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
// ----------------------------------------- //
|
||||
// File generated by VPC //
|
||||
// ----------------------------------------- //
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\BaseVSShader.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\BaseVSShader.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\BaseVSShader.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\common\debug_dll_check.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\common\debug_dll_check.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\common\debug_dll_check.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugdepth.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugdepth.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugdepth.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\DebugDrawEnvmapMask.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\DebugDrawEnvmapMask.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\DebugDrawEnvmapMask.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugluxel.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugluxel.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugluxel.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugnormalmap.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugnormalmap.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugnormalmap.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugtangentspace.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugtangentspace.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugtangentspace.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\fillrate.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\fillrate.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\fillrate.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\public\tier0\memoverride.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\public\tier0\memoverride.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\public\tier0\memoverride.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\shader_dll_verify.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\shader_dll_verify.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\shader_dll_verify.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
@@ -0,0 +1,850 @@
|
||||
// ----------------------------------------- //
|
||||
// File generated by VPC //
|
||||
// ----------------------------------------- //
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\common\debug_dll_check.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\common\debug_dll_check.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\common\debug_dll_check.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\public\tier0\memoverride.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\public\tier0\memoverride.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\public\tier0\memoverride.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\AccumBuff4Sample.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\AccumBuff4Sample.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\AccumBuff4Sample.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\accumbuff5sample.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\accumbuff5sample.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\accumbuff5sample.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\aftershock.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\aftershock.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\aftershock.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\aftershock_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\aftershock_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\aftershock_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\BaseVSShader.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\BaseVSShader.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\BaseVSShader.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\bik_dx90.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\bik_dx90.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\bik_dx90.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\black.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\black.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\black.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\Blob_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\Blob_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\Blob_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\Blob_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\Blob_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\Blob_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\Bloom.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\Bloom.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\Bloom.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\BlurFilterX.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\BlurFilterX.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\BlurFilterX.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\BlurFilterY.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\BlurFilterY.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\BlurFilterY.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\BufferClearObeyStencil_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\BufferClearObeyStencil_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\BufferClearObeyStencil_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\cable_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\cable_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\cable_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\character.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\character.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\character.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\character_ssao.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\character_ssao.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\character_ssao.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\cloak.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\cloak.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\cloak.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\cloak_blended_pass_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\cloak_blended_pass_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\cloak_blended_pass_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\cloak_dx9_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\cloak_dx9_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\cloak_dx9_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\colorcorrection.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\colorcorrection.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\colorcorrection.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\colorout.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\colorout.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\colorout.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\cs_grass.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\cs_grass.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\cs_grass.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\customcharacter.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\customcharacter.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\customcharacter.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\customclothing.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\customclothing.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\customclothing.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\customweapon_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\customweapon_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\customweapon_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\customweapon_dx9_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\customweapon_dx9_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\customweapon_dx9_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugmorphaccumulator_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugmorphaccumulator_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugmorphaccumulator_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugmrttexture.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugmrttexture.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\debugmrttexture.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\DebugTextureView.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\DebugTextureView.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\DebugTextureView.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\DecalModulate_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\DecalModulate_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\DecalModulate_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\DepthOfField_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\DepthOfField_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\DepthOfField_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\depthwrite.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\depthwrite.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\depthwrite.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\Downsample.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\Downsample.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\Downsample.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\downsample_nohdr.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\downsample_nohdr.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\downsample_nohdr.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\embroider.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\embroider.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\embroider.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\emissive_scroll_blended_pass_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\emissive_scroll_blended_pass_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\emissive_scroll_blended_pass_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\Engine_Post_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\Engine_Post_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\Engine_Post_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\eye_refract.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\eye_refract.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\eye_refract.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\eye_refract_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\eye_refract_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\eye_refract_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\eyeglint_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\eyeglint_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\eyeglint_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\eyes_dx8_dx9_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\eyes_dx8_dx9_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\eyes_dx8_dx9_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\eyes_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\eyes_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\eyes_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\filmdust.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\filmdust.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\filmdust.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\filmgrain.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\filmgrain.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\filmgrain.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\flesh_interior_blended_pass_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\flesh_interior_blended_pass_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\flesh_interior_blended_pass_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\floatcombine.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\floatcombine.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\floatcombine.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\floatcombine_autoexpose.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\floatcombine_autoexpose.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\floatcombine_autoexpose.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\floattoscreen.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\floattoscreen.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\floattoscreen.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\floattoscreen_vanilla.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\floattoscreen_vanilla.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\floattoscreen_vanilla.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\gamecontrols.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\gamecontrols.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\gamecontrols.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\HDRCombineTo16Bit.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\HDRCombineTo16Bit.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\HDRCombineTo16Bit.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\HDRSelectRange.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\HDRSelectRange.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\HDRSelectRange.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\hsl_filmgrain_pass1.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\hsl_filmgrain_pass1.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\hsl_filmgrain_pass1.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\hsl_filmgrain_pass2.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\hsl_filmgrain_pass2.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\hsl_filmgrain_pass2.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\hsv.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\hsv.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\hsv.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\IceSurface_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\IceSurface_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\IceSurface_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\IceSurface_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\IceSurface_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\IceSurface_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\introscreenspaceeffect.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\introscreenspaceeffect.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\introscreenspaceeffect.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmapped_4wayblend.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmapped_4wayblend.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmapped_4wayblend.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmapped_4wayblend_dx9_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmapped_4wayblend_dx9_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmapped_4wayblend_dx9_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmappedgeneric_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmappedgeneric_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmappedgeneric_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmappedgeneric_dx9_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmappedgeneric_dx9_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmappedgeneric_dx9_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmappedpaint_dx9_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmappedpaint_dx9_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmappedpaint_dx9_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmappedreflective.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmappedreflective.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightmappedreflective.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightshafts.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightshafts.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightshafts.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightshafts_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightshafts_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\lightshafts_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\modulate_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\modulate_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\modulate_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\MonitorScreen_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\MonitorScreen_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\MonitorScreen_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\morphaccumulate_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\morphaccumulate_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\morphaccumulate_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\morphweight_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\morphweight_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\morphweight_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\motion_blur_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\motion_blur_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\motion_blur_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\multiblend.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\multiblend.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\multiblend.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\multiblend_dx9_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\multiblend_dx9_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\multiblend_dx9_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\object_motion_blur_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\object_motion_blur_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\object_motion_blur_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\occlusion_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\occlusion_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\occlusion_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\paintblob_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\paintblob_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\paintblob_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\paintblob_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\paintblob_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\paintblob_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\parallaxtest.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\parallaxtest.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\parallaxtest.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\particlelitgeneric_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\particlelitgeneric_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\particlelitgeneric_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\particlelitgeneric_dx9_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\particlelitgeneric_dx9_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\particlelitgeneric_dx9_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\particlesphere_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\particlesphere_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\particlesphere_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\phong_dx9_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\phong_dx9_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\phong_dx9_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\portal.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\portal.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\portal.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\portal_refract.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\portal_refract.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\portal_refract.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\portal_refract_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\portal_refract_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\portal_refract_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\portalstaticoverlay.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\portalstaticoverlay.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\portalstaticoverlay.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\projected.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\projected.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\projected.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\projected_dx9_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\projected_dx9_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\projected_dx9_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\proto_ice.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\proto_ice.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\proto_ice.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\proto_ice_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\proto_ice_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\proto_ice_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\prototype.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\prototype.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\prototype.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\prototype_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\prototype_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\prototype_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\refract.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\refract.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\refract.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\refract_dx9_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\refract_dx9_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\refract_dx9_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sample4x4.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sample4x4.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sample4x4.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sample4x4_blend.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sample4x4_blend.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sample4x4_blend.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\screenspace_general.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\screenspace_general.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\screenspace_general.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_ambientocclusion.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_ambientocclusion.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_ambientocclusion.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_ao_blur.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_ao_blur.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_ao_blur.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_blurfilterx.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_blurfilterx.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_blurfilterx.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_blurfiltery.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_blurfiltery.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_blurfiltery.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_downsample.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_downsample.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_downsample.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_integercombine.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_integercombine.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_integercombine.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_shape.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_shape.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sfm_shape.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\shadow.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\shadow.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\shadow.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\shadowbuild_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\shadowbuild_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\shadowbuild_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\shadowmodel_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\shadowmodel_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\shadowmodel_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\shatteredglass.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\shatteredglass.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\shatteredglass.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\showz.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\showz.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\showz.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sky_hdr_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sky_hdr_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sky_hdr_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\solidenergy_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\solidenergy_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\solidenergy_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\solidenergy_dx9_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\solidenergy_dx9_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\solidenergy_dx9_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\splinerope.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\splinerope.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\splinerope.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sprite_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sprite_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\sprite_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\spritecard.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\spritecard.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\spritecard.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\teeth.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\teeth.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\teeth.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\TreeLeaf.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\TreeLeaf.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\TreeLeaf.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\unlitgeneric_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\unlitgeneric_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\unlitgeneric_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\unlittwotexture_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\unlittwotexture_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\unlittwotexture_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\unlitworld_screensample.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\unlitworld_screensample.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\unlitworld_screensample.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\vertexlitgeneric_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\vertexlitgeneric_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\vertexlitgeneric_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\vertexlitgeneric_dx9_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\vertexlitgeneric_dx9_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\vertexlitgeneric_dx9_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\volume_clouds.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\volume_clouds.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\volume_clouds.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\volume_clouds_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\volume_clouds_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\volume_clouds_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\vortwarp_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\vortwarp_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\vortwarp_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\water.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\water.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\water.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\weapondecal_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\weapondecal_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\weapondecal_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\weapondecal_dx9_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\weapondecal_dx9_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\weapondecal_dx9_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\windowimposter_dx90.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\windowimposter_dx90.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\windowimposter_dx90.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\wireframe_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\wireframe_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\wireframe_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\worldimposter.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\worldimposter.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\worldimposter.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\worldtwotextureblend.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\worldtwotextureblend.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\worldtwotextureblend.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\worldvertextransition.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\worldvertextransition.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\worldvertextransition.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\worldvertextransition_dx8_helper.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\worldvertextransition_dx8_helper.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\worldvertextransition_dx8_helper.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\writestencil_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\writestencil_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\writestencil_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\writez_dx9.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\writez_dx9.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\stdshaders\writez_dx9.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\tier1\checksum_crc.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\tier1\checksum_crc.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\tier1\checksum_crc.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\tier1\checksum_md5.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\tier1\checksum_md5.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\tier1\checksum_md5.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\materialsystem\shader_dll_verify.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\materialsystem\shader_dll_verify.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\materialsystem\shader_dll_verify.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
107
materialsystem/stdshaders/accumbuff5sample.cpp
Normal file
107
materialsystem/stdshaders/accumbuff5sample.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
//========= Copyright (c) 1996-2005, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "common_hlsl_cpp_consts.h"
|
||||
#include "screenspaceeffect_vs20.inc"
|
||||
#include "accumbuff5sample_ps20.inc"
|
||||
#include "accumbuff5sample_ps20b.inc"
|
||||
#include "convar.h"
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( accumbuff5sample, "Help for AccumBuff5Sample", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
|
||||
// Four textures to sample
|
||||
SHADER_PARAM( TEXTURE0, SHADER_PARAM_TYPE_TEXTURE, "", "" )
|
||||
SHADER_PARAM( TEXTURE1, SHADER_PARAM_TYPE_TEXTURE, "", "" )
|
||||
SHADER_PARAM( TEXTURE2, SHADER_PARAM_TYPE_TEXTURE, "", "" )
|
||||
SHADER_PARAM( TEXTURE3, SHADER_PARAM_TYPE_TEXTURE, "", "" )
|
||||
SHADER_PARAM( TEXTURE4, SHADER_PARAM_TYPE_TEXTURE, "", "" )
|
||||
|
||||
// Corresponding weights for the four input textures
|
||||
SHADER_PARAM( WEIGHTS, SHADER_PARAM_TYPE_VEC4, "", "Weight for Samples" )
|
||||
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
LoadTexture( TEXTURE0 );
|
||||
LoadTexture( TEXTURE1 );
|
||||
LoadTexture( TEXTURE2 );
|
||||
LoadTexture( TEXTURE3 );
|
||||
LoadTexture( TEXTURE4 );
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableDepthTest( false );
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
pShaderShadow->EnableBlending( false );
|
||||
pShaderShadow->EnableCulling( false );
|
||||
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER4, true );
|
||||
int fmt = VERTEX_POSITION;
|
||||
pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( accumbuff5sample_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER( accumbuff5sample_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( accumbuff5sample_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER( accumbuff5sample_ps20 );
|
||||
}
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, TEXTURE0, -1 );
|
||||
BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, TEXTURE1, -1 );
|
||||
BindTexture( SHADER_SAMPLER2, TEXTURE_BINDFLAGS_NONE, TEXTURE2, -1 );
|
||||
BindTexture( SHADER_SAMPLER3, TEXTURE_BINDFLAGS_NONE, TEXTURE3, -1 );
|
||||
BindTexture( SHADER_SAMPLER4, TEXTURE_BINDFLAGS_NONE, TEXTURE4, -1 );
|
||||
|
||||
SetPixelShaderConstant( 0, WEIGHTS );
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( accumbuff5sample_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( accumbuff5sample_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( accumbuff5sample_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( accumbuff5sample_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
33
materialsystem/stdshaders/accumbuff5sample_ps2x.fxc
Normal file
33
materialsystem/stdshaders/accumbuff5sample_ps2x.fxc
Normal file
@@ -0,0 +1,33 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler TexSampler0 : register( s0 );
|
||||
sampler TexSampler1 : register( s1 );
|
||||
sampler TexSampler2 : register( s2 );
|
||||
sampler TexSampler3 : register( s3 );
|
||||
sampler TexSampler4 : register( s4 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
const float4 weights : register( c0 );
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
// Just sample the four input textures
|
||||
float4 sample0 = tex2D( TexSampler0, i.texCoord );
|
||||
float4 sample1 = tex2D( TexSampler1, i.texCoord );
|
||||
float4 sample2 = tex2D( TexSampler2, i.texCoord );
|
||||
float4 sample3 = tex2D( TexSampler3, i.texCoord );
|
||||
float4 sample4 = tex2D( TexSampler4, i.texCoord );
|
||||
|
||||
// Compute weighted average and return
|
||||
return FinalOutput( weights.x * sample0 +
|
||||
weights.x * sample1 +
|
||||
weights.x * sample2 +
|
||||
weights.x * sample3 +
|
||||
weights.y * sample4, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
71
materialsystem/stdshaders/aftershock.cpp
Normal file
71
materialsystem/stdshaders/aftershock.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
//========= Copyright (c) 1996-2006, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "aftershock_helper.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DEFINE_FALLBACK_SHADER( Aftershock, Aftershock_dx9 )
|
||||
BEGIN_VS_SHADER( Aftershock_dx9, "Aftershock" )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( COLORTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "Color tint" )
|
||||
SHADER_PARAM( REFRACTAMOUNT, SHADER_PARAM_TYPE_FLOAT, "2", "" )
|
||||
|
||||
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( SILHOUETTETHICKNESS, SHADER_PARAM_TYPE_FLOAT, "1", "" )
|
||||
SHADER_PARAM( SILHOUETTECOLOR, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "Silhouette color tint" )
|
||||
SHADER_PARAM( GROUNDMIN, SHADER_PARAM_TYPE_FLOAT, "1", "" )
|
||||
SHADER_PARAM( GROUNDMAX, SHADER_PARAM_TYPE_FLOAT, "1", "" )
|
||||
SHADER_PARAM( BLURAMOUNT, SHADER_PARAM_TYPE_FLOAT, "1", "" )
|
||||
|
||||
SHADER_PARAM( TIME, SHADER_PARAM_TYPE_FLOAT, "0.0", "Needs CurrentTime Proxy" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
void SetupVarsAftershock( AftershockVars_t &info )
|
||||
{
|
||||
info.m_nColorTint = COLORTINT;
|
||||
info.m_nRefractAmount = REFRACTAMOUNT;
|
||||
|
||||
info.m_nBumpmap = NORMALMAP;
|
||||
info.m_nBumpFrame = BUMPFRAME;
|
||||
info.m_nBumpTransform = BUMPTRANSFORM;
|
||||
|
||||
info.m_nSilhouetteThickness = SILHOUETTETHICKNESS;
|
||||
info.m_nSilhouetteColor = SILHOUETTECOLOR;
|
||||
info.m_nGroundMin = GROUNDMIN;
|
||||
info.m_nGroundMax = GROUNDMAX;
|
||||
info.m_nBlurAmount = BLURAMOUNT;
|
||||
|
||||
info.m_nTime = TIME;
|
||||
}
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
AftershockVars_t info;
|
||||
SetupVarsAftershock( info );
|
||||
InitParamsAftershock( this, params, pMaterialName, info );
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
AftershockVars_t info;
|
||||
SetupVarsAftershock( info );
|
||||
InitAftershock( this, params, info );
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
AftershockVars_t info;
|
||||
SetupVarsAftershock( info );
|
||||
DrawAftershock( this, params, pShaderAPI, pShaderShadow, info, vertexCompression );
|
||||
}
|
||||
END_SHADER
|
||||
199
materialsystem/stdshaders/aftershock_helper.cpp
Normal file
199
materialsystem/stdshaders/aftershock_helper.cpp
Normal file
@@ -0,0 +1,199 @@
|
||||
//========= Copyright (c) 1996-2006, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "mathlib/vmatrix.h"
|
||||
#include "aftershock_helper.h"
|
||||
#include "convar.h"
|
||||
|
||||
// Auto generated inc files
|
||||
#include "aftershock_vs20.inc"
|
||||
#include "aftershock_ps20.inc"
|
||||
#include "aftershock_ps20b.inc"
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
void InitParamsAftershock( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, AftershockVars_t &info )
|
||||
{
|
||||
// Set material flags
|
||||
SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING );
|
||||
SET_FLAGS2( MATERIAL_VAR2_NEEDS_TANGENT_SPACES );
|
||||
|
||||
SET_FLAGS( MATERIAL_VAR_TRANSLUCENT );
|
||||
SET_FLAGS2( MATERIAL_VAR2_NEEDS_POWER_OF_TWO_FRAME_BUFFER_TEXTURE );
|
||||
|
||||
// Set material parameter default values
|
||||
if ( ( info.m_nRefractAmount != -1 ) && ( !params[info.m_nRefractAmount]->IsDefined() ) )
|
||||
{
|
||||
params[info.m_nRefractAmount]->SetFloatValue( kDefaultRefractAmount );
|
||||
}
|
||||
|
||||
if ( ( info.m_nColorTint != -1 ) && ( !params[info.m_nColorTint]->IsDefined() ) )
|
||||
{
|
||||
params[info.m_nColorTint]->SetVecValue( kDefaultColorTint[0], kDefaultColorTint[1], kDefaultColorTint[2], kDefaultColorTint[3] );
|
||||
}
|
||||
|
||||
if( (info.m_nBumpFrame != -1 ) && !params[info.m_nBumpFrame]->IsDefined() )
|
||||
{
|
||||
params[info.m_nBumpFrame]->SetIntValue( 0 );
|
||||
}
|
||||
|
||||
if ( ( info.m_nSilhouetteThickness != -1 ) && ( !params[info.m_nSilhouetteThickness]->IsDefined() ) )
|
||||
{
|
||||
params[info.m_nSilhouetteThickness]->SetFloatValue( kDefaultSilhouetteThickness );
|
||||
}
|
||||
|
||||
if ( ( info.m_nSilhouetteColor != -1 ) && ( !params[info.m_nSilhouetteColor]->IsDefined() ) )
|
||||
{
|
||||
params[info.m_nSilhouetteColor]->SetVecValue( kDefaultSilhouetteColor[0], kDefaultSilhouetteColor[1], kDefaultSilhouetteColor[2], kDefaultSilhouetteColor[3] );
|
||||
}
|
||||
|
||||
if ( ( info.m_nGroundMin != -1 ) && ( !params[info.m_nGroundMin]->IsDefined() ) )
|
||||
{
|
||||
params[info.m_nGroundMin]->SetFloatValue( kDefaultGroundMin );
|
||||
}
|
||||
|
||||
if ( ( info.m_nGroundMax != -1 ) && ( !params[info.m_nGroundMax]->IsDefined() ) )
|
||||
{
|
||||
params[info.m_nGroundMax]->SetFloatValue( kDefaultGroundMax );
|
||||
}
|
||||
|
||||
if ( ( info.m_nBlurAmount != -1 ) && ( !params[info.m_nBlurAmount]->IsDefined() ) )
|
||||
{
|
||||
params[info.m_nBlurAmount]->SetFloatValue( kDefaultBlurAmount );
|
||||
}
|
||||
|
||||
SET_PARAM_FLOAT_IF_NOT_DEFINED( info.m_nTime, 0.0f );
|
||||
}
|
||||
|
||||
void InitAftershock( CBaseVSShader *pShader, IMaterialVar** params, AftershockVars_t &info )
|
||||
{
|
||||
// Load textures
|
||||
if ( (info.m_nBumpmap != -1) && params[info.m_nBumpmap]->IsDefined() )
|
||||
{
|
||||
pShader->LoadTexture( info.m_nBumpmap );
|
||||
}
|
||||
}
|
||||
|
||||
void DrawAftershock( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI,
|
||||
IShaderShadow* pShaderShadow, AftershockVars_t &info, VertexCompressionType_t vertexCompression )
|
||||
{
|
||||
bool bBumpMapping = ( info.m_nBumpmap == -1 ) || !params[info.m_nBumpmap]->IsTexture() ? 0 : 1;
|
||||
|
||||
SHADOW_STATE
|
||||
{
|
||||
// Set stream format (note that this shader supports compression)
|
||||
unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL | VERTEX_FORMAT_COMPRESSED;
|
||||
int nTexCoordCount = 1;
|
||||
int userDataSize = 0;
|
||||
pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize );
|
||||
|
||||
// Vertex Shader
|
||||
DECLARE_STATIC_VERTEX_SHADER( aftershock_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( aftershock_vs20 );
|
||||
|
||||
// Pixel Shader
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( aftershock_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER( aftershock_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( aftershock_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER( aftershock_ps20 );
|
||||
}
|
||||
|
||||
// Textures
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); // Refraction texture
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true ); // Bump
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, false ); // Not sRGB
|
||||
pShaderShadow->EnableSRGBWrite( true );
|
||||
|
||||
// Blending
|
||||
pShader->EnableAlphaBlending( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
|
||||
pShaderShadow->EnableAlphaWrites( false );
|
||||
|
||||
// !!! We need to turn this back on because EnableAlphaBlending() above disables it!
|
||||
//pShaderShadow->EnableDepthWrites( true );
|
||||
}
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
// Set Vertex Shader Combos
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( aftershock_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
|
||||
SET_DYNAMIC_VERTEX_SHADER( aftershock_vs20 );
|
||||
|
||||
// Set Vertex Shader Constants
|
||||
if ( info.m_nBumpTransform != -1 )
|
||||
{
|
||||
pShader->SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, info.m_nBumpTransform );
|
||||
}
|
||||
|
||||
// Time % 1000
|
||||
float vPackedVsConst1[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
float flTime = IS_PARAM_DEFINED( info.m_nTime ) && params[info.m_nTime]->GetFloatValue() > 0.0f ? params[info.m_nTime]->GetFloatValue() : pShaderAPI->CurrentTime();
|
||||
vPackedVsConst1[0] = flTime;
|
||||
vPackedVsConst1[0] -= (float)( (int)( vPackedVsConst1[0] / 1000.0f ) ) * 1000.0f;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, vPackedVsConst1, 1 );
|
||||
|
||||
// Set Pixel Shader Combos
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( aftershock_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( aftershock_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( aftershock_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( aftershock_ps20 );
|
||||
}
|
||||
|
||||
// Bind textures
|
||||
pShaderAPI->BindStandardTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_SRGBREAD, TEXTURE_FRAME_BUFFER_FULL_TEXTURE_0 ); // Refraction Map
|
||||
if ( bBumpMapping )
|
||||
{
|
||||
pShader->BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, info.m_nBumpmap, info.m_nBumpFrame );
|
||||
}
|
||||
|
||||
// Set Pixel Shader Constants
|
||||
float vEyePos[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
pShaderAPI->GetWorldSpaceCameraPosition( vEyePos );
|
||||
pShaderAPI->SetPixelShaderConstant( 5, vEyePos, 1 );
|
||||
|
||||
float vPackedConst1[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
vPackedConst1[0] = IS_PARAM_DEFINED( info.m_nBlurAmount ) ? params[info.m_nBlurAmount]->GetFloatValue() : kDefaultBlurAmount;
|
||||
vPackedConst1[1] = IS_PARAM_DEFINED( info.m_nRefractAmount ) ? params[info.m_nRefractAmount]->GetFloatValue() : kDefaultRefractAmount;
|
||||
vPackedConst1[3] = vPackedVsConst1[0]; // Time
|
||||
pShaderAPI->SetPixelShaderConstant( 6, vPackedConst1, 1 );
|
||||
|
||||
// Refract color tint
|
||||
pShaderAPI->SetPixelShaderConstant( 7, IS_PARAM_DEFINED( info.m_nColorTint ) ? params[info.m_nColorTint]->GetVecValue() : kDefaultColorTint, 1 );
|
||||
|
||||
// Silhouette values
|
||||
float vPackedConst8[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
vPackedConst8[0] = IS_PARAM_DEFINED( info.m_nSilhouetteColor ) ? params[info.m_nSilhouetteColor]->GetVecValue()[0] : kDefaultSilhouetteColor[0];
|
||||
vPackedConst8[1] = IS_PARAM_DEFINED( info.m_nSilhouetteColor ) ? params[info.m_nSilhouetteColor]->GetVecValue()[1] : kDefaultSilhouetteColor[1];
|
||||
vPackedConst8[2] = IS_PARAM_DEFINED( info.m_nSilhouetteColor ) ? params[info.m_nSilhouetteColor]->GetVecValue()[2] : kDefaultSilhouetteColor[2];
|
||||
vPackedConst8[3] = IS_PARAM_DEFINED( info.m_nSilhouetteThickness ) ? params[info.m_nSilhouetteThickness]->GetFloatValue() : kDefaultSilhouetteThickness;
|
||||
pShaderAPI->SetPixelShaderConstant( 8, vPackedConst8, 1 );
|
||||
|
||||
// Ground min/max
|
||||
float vPackedConst9[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
vPackedConst9[0] = IS_PARAM_DEFINED( info.m_nGroundMin ) ? params[info.m_nGroundMin]->GetFloatValue() : kDefaultGroundMin;
|
||||
vPackedConst9[1] = IS_PARAM_DEFINED( info.m_nGroundMax ) ? params[info.m_nGroundMax]->GetFloatValue() : kDefaultGroundMax;
|
||||
pShaderAPI->SetPixelShaderConstant( 9, vPackedConst9, 1 );
|
||||
|
||||
// Set c0 and c1 to contain first two rows of ViewProj matrix
|
||||
VMatrix mView, mProj;
|
||||
pShaderAPI->GetMatrix( MATERIAL_VIEW, mView.m[0] );
|
||||
pShaderAPI->GetMatrix( MATERIAL_PROJECTION, mProj.m[0] );
|
||||
VMatrix mViewProj = mView * mProj;
|
||||
mViewProj = mViewProj.Transpose3x3();
|
||||
pShaderAPI->SetPixelShaderConstant( 0, mViewProj.m[0], 2 );
|
||||
}
|
||||
pShader->Draw();
|
||||
}
|
||||
56
materialsystem/stdshaders/aftershock_helper.h
Normal file
56
materialsystem/stdshaders/aftershock_helper.h
Normal file
@@ -0,0 +1,56 @@
|
||||
//========= Copyright (c) 1996-2006, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#ifndef AFTERSHOCK_HELPER_H
|
||||
#define AFTERSHOCK_HELPER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBaseVSShader;
|
||||
class IMaterialVar;
|
||||
class IShaderDynamicAPI;
|
||||
class IShaderShadow;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Init params/ init/ draw methods
|
||||
//-----------------------------------------------------------------------------
|
||||
struct AftershockVars_t
|
||||
{
|
||||
AftershockVars_t() { memset( this, 0xFF, sizeof(AftershockVars_t) ); }
|
||||
|
||||
int m_nColorTint;
|
||||
int m_nRefractAmount;
|
||||
|
||||
int m_nBumpmap;
|
||||
int m_nBumpFrame;
|
||||
int m_nBumpTransform;
|
||||
|
||||
int m_nSilhouetteThickness;
|
||||
int m_nSilhouetteColor;
|
||||
int m_nGroundMin;
|
||||
int m_nGroundMax;
|
||||
int m_nBlurAmount;
|
||||
|
||||
int m_nTime;
|
||||
};
|
||||
|
||||
// Default values (Arrays should only be vec[4])
|
||||
static const float kDefaultColorTint[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
static const float kDefaultRefractAmount = 0.1f;
|
||||
static const float kDefaultSilhouetteThickness = 0.2f;
|
||||
static const float kDefaultSilhouetteColor[4] = { 0.3f, 0.3f, 0.5f, 1.0f };
|
||||
static const float kDefaultGroundMin = -0.3f;
|
||||
static const float kDefaultGroundMax = -0.1f;
|
||||
static const float kDefaultBlurAmount = 0.01f;
|
||||
|
||||
void InitParamsAftershock( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, AftershockVars_t &info );
|
||||
void InitAftershock( CBaseVSShader *pShader, IMaterialVar** params, AftershockVars_t &info );
|
||||
void DrawAftershock( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI,
|
||||
IShaderShadow* pShaderShadow, AftershockVars_t &info, VertexCompressionType_t vertexCompression );
|
||||
|
||||
#endif // AFTERSHOCK_HELPER_H
|
||||
159
materialsystem/stdshaders/aftershock_ps2x.fxc
Normal file
159
materialsystem/stdshaders/aftershock_ps2x.fxc
Normal file
@@ -0,0 +1,159 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// Includes =======================================================================================
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
|
||||
// Texture Samplers ===============================================================================
|
||||
sampler g_tRefractionSampler : register( s0 );
|
||||
sampler g_tBumpSampler : register( s1 );
|
||||
|
||||
// Shaders Constants and Globals ==================================================================
|
||||
const float4 g_mViewProj0 : register( c0 ); // 1st row of matrix
|
||||
const float4 g_mViewProj1 : register( c1 ); // 2nd row of matrix
|
||||
|
||||
const float4 g_vCameraPosition : register( c5 );
|
||||
const float4 g_vPackedConst6 : register( c6 );
|
||||
#define g_flBlurAmount g_vPackedConst6.x // 0.01f;
|
||||
#define g_flRefractAmount g_vPackedConst6.y // Default = 1.0f
|
||||
#define g_flTime g_vPackedConst6.w
|
||||
|
||||
const float4 g_cColorTint : register( c7 );
|
||||
|
||||
const float4 g_vPackedConst8 : register( c8 );
|
||||
#define g_cSilhouetteColor g_vPackedConst8 //= { 0.3, 0.3, 0.5 };
|
||||
#define g_flSilhouetteThickness g_vPackedConst8.w //= 0.2f;
|
||||
|
||||
const float2 g_vGroundMinMax : register( c9 ); //= { -0.3, -0.1 };
|
||||
|
||||
// 8 2D Poisson offsets (designed to use .xy and .wz swizzles (not .zw)
|
||||
static const float4 g_vPoissonOffset[4] = { float4 (-0.0876f, 0.9703f, 0.5651f, 0.4802f ),
|
||||
float4 ( 0.1851f, 0.1580f, -0.0617f, -0.2616f ),
|
||||
float4 (-0.5477f, -0.6603f, 0.0711f, -0.5325f ),
|
||||
float4 (-0.0751f, -0.8954f, 0.4054f, 0.6384f ) };
|
||||
|
||||
// Interpolated values ============================================================================
|
||||
struct PS_INPUT
|
||||
{
|
||||
float3 vWorldNormal : TEXCOORD0; // World-space normal
|
||||
float3 vWorldTangent : TEXCOORD1;
|
||||
float3 vWorldBinormal : TEXCOORD2;
|
||||
float3 vProjPosForRefract : TEXCOORD3;
|
||||
float3 vWorldViewVector : TEXCOORD4;
|
||||
float4 vUv0 : TEXCOORD5; // uv.xy, uvScroll.xy
|
||||
float4 vUv1 : TEXCOORD6; // uv.xy, uvScroll.xy
|
||||
float2 vUvGroundNoise : TEXCOORD7;
|
||||
};
|
||||
|
||||
// Main ===========================================================================================
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
/*
|
||||
// Bump layer 0
|
||||
float2 vUv0 = i.vUv0Uv1.xy;
|
||||
float2 vUv0Scroll = i.vUv0Uv1.xy * 3.0f;
|
||||
vUv0Scroll.y -= g_flTime * 0.1f;
|
||||
|
||||
float4 vBumpTexel0 = tex2D( g_tBumpSampler, vUv0Scroll.xy );
|
||||
vBumpTexel0 = tex2D( g_tBumpSampler, vUv0.xy + (vBumpTexel0.xy*0.03) );
|
||||
|
||||
// Bump layer 1
|
||||
float2 vUv1 = i.vUv0Uv1.xy * 10.0f;
|
||||
float2 vUv1Scroll = i.vUv0Uv1.xy * 32.0f;
|
||||
vUv1Scroll.y -= g_flTime * 0.1f;
|
||||
|
||||
float4 vBumpTexel1 = tex2D( g_tBumpSampler, vUv1Scroll.xy );
|
||||
vBumpTexel1 = tex2D( g_tBumpSampler, vUv1.xy + (vBumpTexel1.xy*0.03) );
|
||||
//*/
|
||||
|
||||
// Bump layer 0
|
||||
float4 vBumpTexel0 = tex2D( g_tBumpSampler, i.vUv0.wz );
|
||||
vBumpTexel0 = tex2D( g_tBumpSampler, i.vUv0.xy + ( vBumpTexel0.xy*0.03 ) );
|
||||
|
||||
// Bump layer 1
|
||||
float4 vBumpTexel1 = tex2D( g_tBumpSampler, i.vUv1.wz );
|
||||
vBumpTexel1 = tex2D( g_tBumpSampler, i.vUv1.xy + ( vBumpTexel1.xy*0.03 ) );
|
||||
|
||||
// Combine bump layers into tangetn normal
|
||||
float3 vTangentNormal = ( vBumpTexel0 * 2.0f ) - 1.0f;
|
||||
vTangentNormal.xyz += ( vBumpTexel1 * 2.0f - 1.0f ) * 0.5f; // * 0.5f;
|
||||
|
||||
// Transform into world space
|
||||
float3 vWorldNormal = Vec3TangentToWorld( vTangentNormal.xyz, i.vWorldNormal, i.vWorldTangent, i.vWorldBinormal );
|
||||
|
||||
// Effect mask
|
||||
//float flEffectMask = saturate( dot( -i.vWorldViewVector.xyz, i.vWorldNormal.xyz ) * lerp( 2.0f, 1.0f, g_flSilhouetteThickness ) );
|
||||
float flEffectMask = saturate( dot( -i.vWorldViewVector.xyz, i.vWorldNormal.xyz ) * ( (2.0f - g_flSilhouetteThickness) ) );
|
||||
|
||||
// Simulate ground intersection
|
||||
flEffectMask *= smoothstep( g_vGroundMinMax.x, g_vGroundMinMax.y, i.vWorldNormal.z );
|
||||
|
||||
// Soften mask by squaring term
|
||||
flEffectMask *= flEffectMask;
|
||||
|
||||
// Silhouette mask
|
||||
float flSilhouetteHighlightMask = saturate( flEffectMask * ( 1.0f - flEffectMask ) * 4.0f );
|
||||
flSilhouetteHighlightMask *= flSilhouetteHighlightMask * flSilhouetteHighlightMask;
|
||||
|
||||
// Transform world space normal into clip space and project
|
||||
float3 vProjNormal;
|
||||
vProjNormal.x = dot( vWorldNormal.xyz, g_mViewProj0.xyz ); // 1st row
|
||||
vProjNormal.y = dot( vWorldNormal.xyz, g_mViewProj1.xyz ); // 2nd row
|
||||
|
||||
// Compute coordinates for sampling refraction
|
||||
float2 vRefractTexCoordNoWarp = i.vProjPosForRefract.xy / i.vProjPosForRefract.z;
|
||||
float2 vRefractTexCoord = vProjNormal.xy;
|
||||
float scale = lerp( 0.0f, g_flRefractAmount, flEffectMask );// * flEffectMask * flEffectMask ); // Using flEffectMask^3
|
||||
vRefractTexCoord.xy *= scale;
|
||||
vRefractTexCoord.xy += vRefractTexCoordNoWarp.xy;
|
||||
|
||||
// Blur by scalable Poisson filter
|
||||
float flBlurAmount = g_flBlurAmount * flEffectMask;
|
||||
float3 cRefract = tex2D( g_tRefractionSampler, vRefractTexCoord.xy );
|
||||
cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[0].xy * flBlurAmount ) );
|
||||
cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[0].wz * flBlurAmount ) );
|
||||
cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[1].xy * flBlurAmount ) );
|
||||
cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[1].wz * flBlurAmount ) );
|
||||
cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[2].xy * flBlurAmount ) );
|
||||
cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[2].wz * flBlurAmount ) );
|
||||
cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[3].xy * flBlurAmount ) );
|
||||
cRefract += tex2D( g_tRefractionSampler, vRefractTexCoord.xy + ( g_vPoissonOffset[3].wz * flBlurAmount ) );
|
||||
cRefract /= 9.0f;
|
||||
|
||||
// Undo tone mapping
|
||||
cRefract /= LINEAR_LIGHT_SCALE;
|
||||
|
||||
// Refract color tint
|
||||
float fColorTintStrength = 1.0f - flEffectMask;
|
||||
float3 cRefractColorTint = lerp( g_cColorTint, 1.0f, fColorTintStrength );
|
||||
|
||||
// Ground noise
|
||||
//float flGroundNoise = tex2D( g_tBumpSampler, i.vUvGroundNoise.xy ).g;
|
||||
//flGroundNoise *= smoothstep( g_vGroundMinMax.y, g_vGroundMinMax.y+0.4, -i.vWorldNormal.z );
|
||||
//flGroundNoise = smoothstep( 0.2, 0.9, flGroundNoise );
|
||||
|
||||
//===============//
|
||||
// Combine terms //
|
||||
//===============//
|
||||
float4 result;
|
||||
result.rgb = cRefract.rgb * cRefractColorTint.rgb;
|
||||
result.rgb += result.rgb * ( flSilhouetteHighlightMask * g_cSilhouetteColor.rgb );
|
||||
//result.rgb += flGroundNoise;
|
||||
|
||||
//result.rgb = float3( 0.0, 0.0, 0.0 );
|
||||
//result.rg = vRefractTexCoord.xy;
|
||||
//result.rg = i.vUv0Uv1.xy;
|
||||
//result.rgb = vBumpTexel0.rgb;
|
||||
//result.rgb = vTangentNormal;
|
||||
//result.rgb = vWorldNormal;
|
||||
//result = flEffectMask;
|
||||
//result = flSilhouetteHighlightMask;
|
||||
|
||||
//result = tex2D( g_tBumpSampler, i.vUvGroundNoise.xy ).y;
|
||||
//result.rgb = flGroundNoise;
|
||||
|
||||
// Set alpha to...
|
||||
result.a = flEffectMask;
|
||||
|
||||
|
||||
return FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR ); //go back to final output when it'll fit.
|
||||
}
|
||||
110
materialsystem/stdshaders/aftershock_vs20.fxc
Normal file
110
materialsystem/stdshaders/aftershock_vs20.fxc
Normal file
@@ -0,0 +1,110 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
// Globals
|
||||
static const bool g_bSkinning = SKINNING ? true : false;
|
||||
const float g_flTime : register( SHADER_SPECIFIC_CONST_0 );
|
||||
const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_1 );
|
||||
|
||||
// Structs
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION; // Position
|
||||
float4 vNormal : NORMAL; // Normal
|
||||
float4 vBoneWeights : BLENDWEIGHT; // Skin weights
|
||||
float4 vBoneIndices : BLENDINDICES; // Skin indices
|
||||
float4 vTexCoord0 : TEXCOORD0; // Base texture coordinates
|
||||
float4 vTangent : TANGENT;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPosition : POSITION; // Projection-space position
|
||||
float3 vWorldNormal : TEXCOORD0; // World-space normal
|
||||
float3 vWorldTangent : TEXCOORD1;
|
||||
float3 vWorldBinormal : TEXCOORD2;
|
||||
float3 vProjPosForRefract : TEXCOORD3;
|
||||
float3 vWorldViewVector : TEXCOORD4;
|
||||
float4 vUv0 : TEXCOORD5;
|
||||
float4 vUv1 : TEXCOORD6;
|
||||
float2 vUvGroundNoise : TEXCOORD7;
|
||||
};
|
||||
|
||||
// Main
|
||||
VS_OUTPUT main( const VS_INPUT i )
|
||||
{
|
||||
VS_OUTPUT o;
|
||||
|
||||
float4 vObjPosition = i.vPos;
|
||||
float4 vObjTangent = i.vTangent;
|
||||
float3 vObjNormal;
|
||||
DecompressVertex_Normal( i.vNormal, vObjNormal );
|
||||
|
||||
// Transform the position
|
||||
float3 vWorldPosition = { 0.0f, 0.0f, 0.0f };
|
||||
float3 vWorldNormal = { 0.0f, 0.0f, 0.0f };
|
||||
float3 vWorldTangent = { 0.0f, 0.0f, 0.0f };
|
||||
float3 vWorldBinormal = { 0.0f, 0.0f, 0.0f };
|
||||
SkinPositionNormalAndTangentSpace( g_bSkinning, vObjPosition, vObjNormal.xyz, vObjTangent.xyzw, i.vBoneWeights, i.vBoneIndices, vWorldPosition, vWorldNormal, vWorldTangent, vWorldBinormal );
|
||||
vWorldNormal.xyz = normalize( vWorldNormal.xyz );
|
||||
vWorldTangent.xyz = normalize( vWorldTangent.xyz );
|
||||
vWorldBinormal.xyz = normalize( vWorldBinormal.xyz );
|
||||
|
||||
o.vWorldNormal.xyz = vWorldNormal.xyz;
|
||||
o.vWorldTangent.xyz = vWorldTangent.xyz;
|
||||
o.vWorldBinormal.xyz = vWorldBinormal.xyz;
|
||||
|
||||
// Transform into projection space
|
||||
float4 vProjPosition = mul( float4( vWorldPosition, 1.0f ), cViewProj );
|
||||
o.vProjPosition = vProjPosition;
|
||||
|
||||
// Map projected position to the refraction texture
|
||||
float2 vRefractPos;
|
||||
vRefractPos.x = vProjPosition.x;
|
||||
vRefractPos.y = -vProjPosition.y; // Invert Y
|
||||
vRefractPos = (vRefractPos + vProjPosition.w) * 0.5f;
|
||||
o.vProjPosForRefract.xyz = float3(vRefractPos.x, vRefractPos.y, vProjPosition.w);
|
||||
|
||||
// View vector
|
||||
float3 vWorldViewVector = normalize (vWorldPosition.xyz - cEyePos.xyz);
|
||||
o.vWorldViewVector.xyz = vWorldViewVector.xyz;
|
||||
|
||||
// Tangent space transform
|
||||
//o.mTangentSpaceTranspose[0] = float3( vWorldTangent.x, vWorldBinormal.x, vWorldNormal.x );
|
||||
//o.mTangentSpaceTranspose[1] = float3( vWorldTangent.y, vWorldBinormal.y, vWorldNormal.y );
|
||||
//o.mTangentSpaceTranspose[2] = float3( vWorldTangent.z, vWorldBinormal.z, vWorldNormal.z );
|
||||
|
||||
// Texture coordinates
|
||||
float2 vBaseUv;
|
||||
vBaseUv.x = dot( i.vTexCoord0.xy, cBaseTexCoordTransform[0] );
|
||||
vBaseUv.y = dot( i.vTexCoord0.xy, cBaseTexCoordTransform[1] );
|
||||
|
||||
// Bump layer 0
|
||||
float2 vUv0 = vBaseUv.xy;
|
||||
float2 vUv0Scroll = vBaseUv.xy * 3.0f;
|
||||
vUv0Scroll.y -= g_flTime * 0.1f;
|
||||
|
||||
o.vUv0.xy = vUv0.xy;
|
||||
o.vUv0.wz = vUv0Scroll.xy;
|
||||
|
||||
// Bump layer 1
|
||||
float2 vUv1 = vBaseUv.xy * 8.0f;
|
||||
float2 vUv1Scroll = vBaseUv.xy * 16.0f;
|
||||
vUv1Scroll.y -= g_flTime * 0.1f;
|
||||
|
||||
o.vUv1.xy = vUv1.xy;
|
||||
o.vUv1.wz = vUv1Scroll.xy;
|
||||
|
||||
// Ground noise
|
||||
o.vUvGroundNoise.xy = vBaseUv.xy;
|
||||
o.vUvGroundNoise.x *= 3.5f;
|
||||
o.vUvGroundNoise.y *= 0.2105f;
|
||||
o.vUvGroundNoise.y -= g_flTime * 0.04f;
|
||||
|
||||
return o;
|
||||
}
|
||||
26
materialsystem/stdshaders/appchooser360movie_ps2x.fxc
Normal file
26
materialsystem/stdshaders/appchooser360movie_ps2x.fxc
Normal file
@@ -0,0 +1,26 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler TexSampler : register( s0 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 baseTexCoord : TEXCOORD0; // Base texture coordinate
|
||||
float4 vColor : TEXCOORD1;
|
||||
};
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
// Read PC sRGB color without using the HW sRGB read
|
||||
float4 vTextureColor = tex2D( TexSampler, i.baseTexCoord );
|
||||
|
||||
// Do a PC sRGB gamma->linear conversion
|
||||
vTextureColor.rgb = SrgbGammaToLinear( vTextureColor.rgb );
|
||||
|
||||
float4 result;
|
||||
result.rgb = vTextureColor.rgb * i.vColor.rgb;
|
||||
result.a = i.vColor.a;
|
||||
|
||||
return result;
|
||||
}
|
||||
133
materialsystem/stdshaders/bik_dx90.cpp
Normal file
133
materialsystem/stdshaders/bik_dx90.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
//========= Copyright (c) 1996-2006, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Header: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "cpp_shader_constant_register_map.h"
|
||||
|
||||
#include "bik_ps20.inc"
|
||||
#include "bik_ps20b.inc"
|
||||
#include "bik_vs20.inc"
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
BEGIN_VS_SHADER( Bik, "Help for Bik" )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( YTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "Y Bink Texture" )
|
||||
// re-enable this if we want alpha blending
|
||||
// SHADER_PARAM( ATEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "A Bink Texture" )
|
||||
SHADER_PARAM( CRTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "Cr Bink Texture" )
|
||||
SHADER_PARAM( CBTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "Cb Bink Texture" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if ( params[YTEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( YTEXTURE );
|
||||
}
|
||||
// if ( params[ATEXTURE]->IsDefined() )
|
||||
// {
|
||||
// LoadTexture( ATEXTURE );
|
||||
// }
|
||||
if ( params[CRTEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( CRTEXTURE );
|
||||
}
|
||||
if ( params[CBTEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( CBTEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
|
||||
// pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
|
||||
|
||||
unsigned int flags = VERTEX_POSITION | VERTEX_COLOR;
|
||||
bool bHasVertexAlpha = IS_FLAG_SET( MATERIAL_VAR_VERTEXALPHA );
|
||||
int numTexCoords = 1;
|
||||
pShaderShadow->VertexShaderVertexFormat( flags, numTexCoords, 0, 0 );
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( bik_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( bik_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( bik_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( VERTEXALPHA, bHasVertexAlpha );
|
||||
SET_STATIC_PIXEL_SHADER( bik_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( bik_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( VERTEXALPHA, bHasVertexAlpha );
|
||||
SET_STATIC_PIXEL_SHADER( bik_ps20 );
|
||||
}
|
||||
|
||||
// The 360 needs an sRGB write, but NOT an sRGB read!
|
||||
// Commenting this out because we're not using PWL textures on X360 for Portal2. Also see the disabled shader sRGB read in bik_ps2x.fxc.
|
||||
//if ( IsX360() )
|
||||
// pShaderShadow->EnableSRGBWrite( true );
|
||||
//else
|
||||
pShaderShadow->EnableSRGBWrite( false );
|
||||
|
||||
if ( bHasVertexAlpha )
|
||||
{
|
||||
EnableAlphaBlending( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
|
||||
}
|
||||
}
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, YTEXTURE, FRAME );
|
||||
BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, CRTEXTURE, FRAME );
|
||||
BindTexture( SHADER_SAMPLER2, TEXTURE_BINDFLAGS_NONE, CBTEXTURE, FRAME );
|
||||
// BindTexture( SHADER_SAMPLER3, ATEXTURE, FRAME );
|
||||
|
||||
// We need the view matrix
|
||||
LoadViewMatrixIntoVertexShaderConstant( VERTEX_SHADER_VIEWMODEL );
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( bik_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( bik_vs20 );
|
||||
|
||||
pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS );
|
||||
|
||||
float vEyePos_SpecExponent[4];
|
||||
pShaderAPI->GetWorldSpaceCameraPosition( vEyePos_SpecExponent );
|
||||
vEyePos_SpecExponent[3] = 0.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( bik_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( bik_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( bik_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( bik_ps20 );
|
||||
}
|
||||
}
|
||||
Draw( );
|
||||
}
|
||||
END_SHADER
|
||||
111
materialsystem/stdshaders/bik_ps2x.fxc
Normal file
111
materialsystem/stdshaders/bik_ps2x.fxc
Normal file
@@ -0,0 +1,111 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// STATIC: "VERTEXALPHA" "0..1"
|
||||
|
||||
#include "common_fog_ps_fxc.h"
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
#include "shader_constant_register_map.h"
|
||||
|
||||
const float4 g_FogParams : register( PSREG_FOG_PARAMS );
|
||||
const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT );
|
||||
|
||||
sampler YTextureSampler : register( s0 );
|
||||
sampler cRTextureSampler : register( s1 );
|
||||
sampler cBTextureSampler : register( s2 );
|
||||
//sampler ATextureSampler : register( s3 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 baseTexCoord : TEXCOORD0;
|
||||
float4 worldPos_projPosZ : TEXCOORD1;
|
||||
float flAlpha : TEXCOORD2;
|
||||
};
|
||||
|
||||
#if 0
|
||||
static float yuvtorgb[] =
|
||||
{
|
||||
1.164123535f, 1.595794678f, 0.0f, -0.87065506f,
|
||||
1.164123535f, -0.813476563f, -0.391448975f, 0.529705048f,
|
||||
1.164123535f, 0.0f, 2.017822266f, -1.081668854f,
|
||||
1.0f, 0.0f, 0.0f, 0.0f
|
||||
};
|
||||
" sampler tex0 : register( s0 ); "
|
||||
" sampler tex1 : register( s1 ); "
|
||||
" sampler tex2 : register( s2 ); "
|
||||
" sampler tex3 : register( s3 ); "
|
||||
" float4 tor : register( c0 ); "
|
||||
" float4 tog : register( c1 ); "
|
||||
" float4 tob : register( c2 ); "
|
||||
" float4 consts : register( c3 ); "
|
||||
" "
|
||||
" struct VS_OUT "
|
||||
" { "
|
||||
" float2 T0: TEXCOORD0; "
|
||||
" }; "
|
||||
" "
|
||||
" float4 main( VS_OUT In ) : COLOR "
|
||||
" { "
|
||||
" float4 c; "
|
||||
" float4 p; "
|
||||
" c.x = tex2D( tex0, In.T0 ).x; "
|
||||
" c.y = tex2D( tex1, In.T0 ).x; "
|
||||
" c.z = tex2D( tex2, In.T0 ).x; "
|
||||
" c.w = consts.x; "
|
||||
" p.w = tex2D( tex3, In.T0 ).x; "
|
||||
" p.x = dot( tor, c ); "
|
||||
" p.y = dot( tog, c ); "
|
||||
" p.z = dot( tob, c ); "
|
||||
" p.w *= consts.w; "
|
||||
" return p; "
|
||||
" } ";
|
||||
#endif
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
half y, cR, cB;
|
||||
y = tex2D( YTextureSampler, i.baseTexCoord.xy ).x;
|
||||
cR = tex2D( cRTextureSampler, i.baseTexCoord.xy ).x;
|
||||
cB = tex2D( cBTextureSampler, i.baseTexCoord.xy ).x;
|
||||
// half a = tex2D( ATextureSampler, i.baseTexCoord.xy );
|
||||
|
||||
#if defined( _X360 )
|
||||
{
|
||||
// Reduce the black level of videos on X360 - this is a workaround for our highly tweaked gamma ramp, which was optimized for 3D content and non-PWL textures.
|
||||
y = saturate( y - 6.0f / 255.0f );
|
||||
}
|
||||
#endif
|
||||
|
||||
float4 c;
|
||||
c = float4( y, cR, cB, 1.0f );
|
||||
|
||||
float4 tor = float4( 1.164123535f, 1.595794678f, 0.0f, -0.87065506f );
|
||||
float4 tog = float4( 1.164123535f, -0.813476563f, -0.391448975f, 0.529705048f );
|
||||
float4 tob = float4( 1.164123535f, 0.0f, 2.017822266f, -1.081668854f );
|
||||
|
||||
float4 rgba;
|
||||
|
||||
rgba.r = dot( c, tor );
|
||||
rgba.g = dot( c, tog );
|
||||
rgba.b = dot( c, tob );
|
||||
#if ( VERTEXALPHA )
|
||||
{
|
||||
rgba.a = i.flAlpha;
|
||||
}
|
||||
#else
|
||||
{
|
||||
rgba.a = 1.0f;
|
||||
}
|
||||
#endif
|
||||
|
||||
float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos_SpecExponent.xyz, i.worldPos_projPosZ.xyz, i.worldPos_projPosZ.w );
|
||||
float4 result = FinalOutput( rgba, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_NONE );
|
||||
|
||||
// The 360 will do an sRGB write to put the linear values into 360 gamma space, but the PC just outputs gamma values directly
|
||||
// Commenting this out because we're not using PWL textures on X360 for Portal2. Also see the disabled sRGB write in bik_dx9.cpp.
|
||||
// #if defined( _X360 )
|
||||
// result.rgb = SrgbGammaToLinear( result.rgb );
|
||||
// #endif
|
||||
|
||||
return result.rgba;
|
||||
}
|
||||
54
materialsystem/stdshaders/bik_vs20.fxc
Normal file
54
materialsystem/stdshaders/bik_vs20.fxc
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "common_fog_vs_fxc.h"
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
static const int g_FogType = DOWATERFOG;
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION;
|
||||
float4 vTexCoord0 : TEXCOORD0;
|
||||
float4 colorAlpha : COLOR; // Used only for vertex alpha currently.
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION; // Projection-space position
|
||||
#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
|
||||
float fog : FOG;
|
||||
#endif
|
||||
float2 baseTexCoord : TEXCOORD0; // Base texture coordinate
|
||||
float4 worldPos_projPosZ : TEXCOORD1; // Necessary for water fog dest alpha
|
||||
float flAlpha : TEXCOORD2;
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
float4 projPos;
|
||||
float3 worldPos;
|
||||
|
||||
// Need to use SkinPosition() to guarantee consistency with other shaders on X360.
|
||||
// The function uses [isolate] properly and simply does a mul4x3 if skinning is set to 'false'.
|
||||
SkinPosition( false, float4( v.vPos.xyz, 1 ), 0, 0, worldPos );
|
||||
projPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
|
||||
#ifdef _PS3
|
||||
// Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
|
||||
projPos.y = -projPos.y;
|
||||
projPos.z = 2.0f * projPos.z - projPos.w;
|
||||
#endif // _PS3
|
||||
|
||||
o.projPos = projPos;
|
||||
|
||||
#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
|
||||
o.fog = CalcFixedFunctionFog( worldPos, g_FogType );
|
||||
#endif
|
||||
|
||||
o.worldPos_projPosZ = float4( worldPos, projPos.z );
|
||||
o.baseTexCoord.xy = v.vTexCoord0.xy;
|
||||
o.flAlpha = v.colorAlpha.a;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
94
materialsystem/stdshaders/black.cpp
Normal file
94
materialsystem/stdshaders/black.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
//========= Copyright © 1996-2009, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "black_vs20.inc"
|
||||
#include "black_ps20.inc"
|
||||
#include "black_ps20b.inc"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
BEGIN_VS_SHADER( Black, "Help for Black" )
|
||||
BEGIN_SHADER_PARAMS
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING );
|
||||
SET_FLAGS( MATERIAL_VAR_VERTEXFOG );
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
// Set stream format (note that this shader supports compression)
|
||||
int flags = VERTEX_POSITION | VERTEX_FORMAT_COMPRESSED;
|
||||
// NOTE: Have to say that we want 1 texcoord here even though we don't use it or you'll get this Warning in another part of the code:
|
||||
// "ERROR: shader asking for a too-narrow vertex format - you will see errors if running with debug D3D DLLs!\n\tPadding the vertex format with extra texcoords"
|
||||
int nTexCoordCount = 1;
|
||||
int userDataSize = 0;
|
||||
pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize );
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( black_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( black_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( black_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER( black_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( black_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER( black_ps20 );
|
||||
}
|
||||
|
||||
pShaderShadow->EnableSRGBWrite( true );
|
||||
|
||||
FogToFogColor();
|
||||
}
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( black_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, s_pShaderAPI->GetCurrentNumBones() > 0 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( black_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( black_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( black_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( black_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( black_ps20 );
|
||||
}
|
||||
unsigned char gammaFogColor[3];
|
||||
pShaderAPI->GetSceneFogColor( gammaFogColor );
|
||||
|
||||
Vector4D fogColorPostTonemapLinearSpace;
|
||||
float flToneMappingScaleLinear = pShaderAPI->GetToneMappingScaleLinear().x;
|
||||
fogColorPostTonemapLinearSpace.x = flToneMappingScaleLinear * SrgbGammaToLinear( ( 1.0f / 255.0f ) * gammaFogColor[0] );
|
||||
fogColorPostTonemapLinearSpace.y = flToneMappingScaleLinear * SrgbGammaToLinear( ( 1.0f / 255.0f ) * gammaFogColor[1] );
|
||||
fogColorPostTonemapLinearSpace.z = flToneMappingScaleLinear * SrgbGammaToLinear( ( 1.0f / 255.0f ) * gammaFogColor[2] );
|
||||
fogColorPostTonemapLinearSpace.w = 1.0f;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, fogColorPostTonemapLinearSpace.Base() );
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
|
||||
END_SHADER
|
||||
|
||||
|
||||
38
materialsystem/stdshaders/black_ps2x.fxc
Normal file
38
materialsystem/stdshaders/black_ps2x.fxc
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_fog_ps_forcevertexfog_fxc.h"
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 projPos : POSITION; // Projection-space position
|
||||
|
||||
#if ( !HARDWAREFOGBLEND )
|
||||
// This is simply a blend between black and the fog color. Go ahead and send alpha through so that we can keep the pixel shader down to one instruction.
|
||||
float4 color : TEXCOORD0;
|
||||
#endif
|
||||
|
||||
#if defined( _X360 )
|
||||
float2 vScreenPos : VPOS;
|
||||
#endif
|
||||
};
|
||||
|
||||
float4_color_return_type main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
#if ( HARDWAREFOGBLEND )
|
||||
{
|
||||
return float4_color_return_type( 0.0f, 0.0f, 0.0f, 1.0f );
|
||||
}
|
||||
#else
|
||||
{
|
||||
float4_color_return_type vColor = i.color;
|
||||
|
||||
#if ( defined( _X360 ) )
|
||||
{
|
||||
vColor.xyz += ScreenSpaceOrderedDither( i.vScreenPos );
|
||||
}
|
||||
#endif
|
||||
|
||||
return vColor;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
58
materialsystem/stdshaders/black_vs20.fxc
Normal file
58
materialsystem/stdshaders/black_vs20.fxc
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "common_fog_vs_forcevertexfog_fxc.h"
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
const float3 g_FogColorPostTonemapLinearSpace : register( SHADER_SPECIFIC_CONST_0 );
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION;
|
||||
float4 vBoneWeights : BLENDWEIGHT;
|
||||
float4 vBoneIndices : BLENDINDICES;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION; // Projection-space position
|
||||
|
||||
#if ( HARDWAREFOGBLEND )
|
||||
float fog : FOG;
|
||||
#else
|
||||
float4 color : TEXCOORD0;
|
||||
#endif
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o;
|
||||
|
||||
float3 worldPos;
|
||||
SkinPosition( SKINNING, v.vPos, v.vBoneWeights, v.vBoneIndices, worldPos );
|
||||
|
||||
// Transform into projection space
|
||||
o.projPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
|
||||
#ifdef _PS3
|
||||
// Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
|
||||
o.projPos.y = -o.projPos.y;
|
||||
o.projPos.z = 2.0f * o.projPos.z - o.projPos.w;
|
||||
#endif // _PS3
|
||||
|
||||
#if ( HARDWAREFOGBLEND )
|
||||
{
|
||||
o.fog = CalcFixedFunctionFog( worldPos, DOWATERFOG );
|
||||
}
|
||||
#else
|
||||
{
|
||||
float flFogFactor = CalcNonFixedFunctionFog( worldPos, false );
|
||||
|
||||
// squaring the factor will get the middle range mixing closer to hardware fog
|
||||
o.color.xyz = g_FogColorPostTonemapLinearSpace * flFogFactor * flFogFactor;
|
||||
o.color.a = 1.0f;
|
||||
}
|
||||
#endif
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
95
materialsystem/stdshaders/blob_arm_ps20b.fxc
Normal file
95
materialsystem/stdshaders/blob_arm_ps20b.fxc
Normal file
@@ -0,0 +1,95 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// STATIC: "SELF_ILLUM_FRESNEL" "0..1"
|
||||
// STATIC: "PRE_PASS" "0..1"
|
||||
// STATIC: "NORMALMAP" "0..1"
|
||||
// STATIC: "MOVING_PULSES" "0..1"
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "shader_constant_register_map.h"
|
||||
|
||||
// SAMPLERS
|
||||
sampler g_tBase : register( s0 );
|
||||
sampler g_tNormal : register( s1 );
|
||||
|
||||
// SHADER CONSTANTS
|
||||
const float4 g_cArmColor : register( c19 );
|
||||
const float3 g_vLightCube[6] : register( PSREG_AMBIENT_CUBE );
|
||||
|
||||
const float4 g_vSelfIllumFresnelParams : register( c26 );
|
||||
#define g_flSelfIllumScale g_vSelfIllumFresnelParams.x
|
||||
#define g_flSelfIllumBias g_vSelfIllumFresnelParams.y
|
||||
#define g_flSelfIllumExp g_vSelfIllumFresnelParams.z
|
||||
#define g_flSelfIllumBrightness g_vSelfIllumFresnelParams.w
|
||||
|
||||
const float4 g_cSelfIllumTint : register( c27 );
|
||||
const float3 g_vEyePos : register( PSREG_EYEPOS_SPEC_EXPONENT );
|
||||
|
||||
// INPUT STRUCT
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 vWorldNormal : TEXCOORD0; // w is proj. z coord (for depth stuff)
|
||||
float3 vWorldTangent : TEXCOORD1;
|
||||
float3 vWorldBinormal : TEXCOORD2;
|
||||
float3 vWorldPos : TEXCOORD3;
|
||||
float2 vUV : TEXCOORD4;
|
||||
float4 vColor : TEXCOORD5;
|
||||
};
|
||||
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4 cBase = tex2D( g_tBase, i.vUV );
|
||||
float4 cOut;
|
||||
|
||||
#if PRE_PASS == 1
|
||||
return cBase; // First pass: output texture to alpha so that we can fill depth using alpha-to-coverage or alpha test
|
||||
#endif
|
||||
|
||||
// The 2nd pass does full shading and can output depth using the destalpha channel.
|
||||
|
||||
#if NORMALMAP == 1
|
||||
float3 vNormalTS = tex2D( g_tNormal, i.vUV );
|
||||
//return vNormalTS.rgbb;
|
||||
#else
|
||||
// make up some tubey looking normal
|
||||
float3 vNormalTS = float3( 0, (2*i.vUV.y-1) * 3.0, 1.0 );
|
||||
#endif
|
||||
|
||||
float3x3 mTan;
|
||||
mTan[0] = i.vWorldTangent;
|
||||
mTan[1] = i.vWorldBinormal;
|
||||
mTan[2] = i.vWorldNormal;
|
||||
float3 vNormal = normalize( mul( vNormalTS, mTan ) );
|
||||
float3 vView = normalize( g_vEyePos.xyz - i.vWorldPos.xyz );
|
||||
|
||||
// diffuse lighting using baked light cube
|
||||
float3 cDiffuse = PixelShaderAmbientLight( vNormal, g_vLightCube );
|
||||
|
||||
// selfillum
|
||||
#if SELF_ILLUM_FRESNEL == 1
|
||||
float flSelfIllumFresnel = ( pow( saturate( dot( vView.xyz, vNormal.xyz ) ), g_flSelfIllumExp ) * g_flSelfIllumScale ) + g_flSelfIllumBias;
|
||||
float3 cSelfIllumComponent = g_cSelfIllumTint * g_flSelfIllumBrightness;
|
||||
cDiffuse.rgb = lerp( cDiffuse.rgb, cSelfIllumComponent.rgb, saturate( flSelfIllumFresnel ) );
|
||||
#endif
|
||||
|
||||
// the u coord -- which is 0 at the root and 1 at the tip -- works well as an occlusion factor
|
||||
cOut = float4( i.vUV.x * cDiffuse * g_cArmColor.rgb * cBase.rgb, 1 );
|
||||
|
||||
// pulse
|
||||
float flPulseWidth = 0.4;
|
||||
#if MOVING_PULSES == 1
|
||||
float flPulse = smoothstep( i.vColor.a, i.vColor.a - flPulseWidth, i.vUV.x );// * ( 1 - smoothstep( i.vColor.a + flPulseWidth, i.vColor.a, i.vUV.x ) );
|
||||
flPulse *= 1 - smoothstep( i.vColor.a, i.vColor.a - flPulseWidth, i.vUV.x );// * ( 1 - smoothstep( i.vColor.a + flPulseWidth, i.vColor.a, i.vUV.x ) );
|
||||
#else
|
||||
float flPulse = max( 0.0, i.vColor.a );
|
||||
#endif
|
||||
cOut.rgb = lerp( 1.0 * cOut.rgb, 3 * i.vColor.rgb, flPulse );
|
||||
|
||||
//cOut.rgb *= float3( 1.0, 0.1, 0.1 );
|
||||
//cOut = float4( fmod( i.vUV, 1.0 ), 0, 0 );
|
||||
//float4 cOut = 0.5 * i.vWorldTangent.xyzz + 0.5;//float4( i.vUV, 0, 0 );
|
||||
|
||||
return FinalOutput( cOut, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR, true, i.vWorldNormal.w );
|
||||
}
|
||||
107
materialsystem/stdshaders/blob_arm_vs20.fxc
Normal file
107
materialsystem/stdshaders/blob_arm_vs20.fxc
Normal file
@@ -0,0 +1,107 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// STATIC: "WIDEN_TIPS" "0..1"
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
// Globals
|
||||
const float4 g_flWidthParams : register( SHADER_SPECIFIC_CONST_0 );
|
||||
#define g_flWidthExp g_flWidthParams.x
|
||||
#define g_flWidthScale g_flWidthParams.y
|
||||
#define g_flWidthBias g_flWidthParams.z
|
||||
#define g_flUVScale g_flWidthParams.w
|
||||
|
||||
const float3 g_vEyePos : register( SHADER_SPECIFIC_CONST_1 );
|
||||
|
||||
//#define g_flUVScale 0.05
|
||||
/*
|
||||
#define g_flWidthExp 4
|
||||
#define g_flWidthScale 5
|
||||
#define g_flWidthBias 0.2
|
||||
*/
|
||||
|
||||
/*
|
||||
#define g_flWidthExp 0.5
|
||||
#define g_flWidthScale 1.0
|
||||
#define g_flWidthBias 0.0
|
||||
*/
|
||||
|
||||
// Structs
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vTexCoord0 : TEXCOORD0; // distance to arm root, V texcoord, rel. position along arm, and t
|
||||
float4 vBezierCage0 : TEXCOORD1; // Bezier positions. 4th position in w coords of the first 3
|
||||
float4 vBezierCage1 : TEXCOORD2;
|
||||
float4 vBezierCage2 : TEXCOORD3;
|
||||
float4 vColor : TEXCOORD4;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPosition : POSITION; // Projection-space position
|
||||
float4 vWorldNormal : TEXCOORD0; // w is proj. z coord (for depth stuff)
|
||||
float3 vWorldTangent : TEXCOORD1;
|
||||
float3 vWorldBinormal : TEXCOORD2;
|
||||
float3 vWorldPos : TEXCOORD3;
|
||||
float3 vUV : TEXCOORD4; // z is normalized dist from root
|
||||
float4 vColor : TEXCOORD5;
|
||||
};
|
||||
|
||||
// Main
|
||||
VS_OUTPUT main( const VS_INPUT i )
|
||||
{
|
||||
VS_OUTPUT o;
|
||||
|
||||
float3 vBezierCage3 = float3( i.vBezierCage0.w, i.vBezierCage1.w, i.vBezierCage2.w );
|
||||
|
||||
// bezier evaluation
|
||||
float3 v0 = lerp( i.vBezierCage0.xyz, i.vBezierCage1.xyz, i.vTexCoord0.w );
|
||||
float3 v1 = lerp( i.vBezierCage1.xyz, i.vBezierCage2.xyz, i.vTexCoord0.w );
|
||||
float3 v2 = lerp( i.vBezierCage2.xyz, vBezierCage3.xyz, i.vTexCoord0.w );
|
||||
v0 = lerp( v0, v1, i.vTexCoord0.w );
|
||||
v1 = lerp( v1, v2, i.vTexCoord0.w );
|
||||
float3 vWorldPos = lerp( v0, v1, i.vTexCoord0.w ); // world position
|
||||
|
||||
// eval bezier derivative to get a tangent
|
||||
v0 = lerp( i.vBezierCage1.xyz - i.vBezierCage0.xyz, i.vBezierCage2.xyz - i.vBezierCage1.xyz, i.vTexCoord0.w );
|
||||
v1 = lerp( i.vBezierCage2.xyz - i.vBezierCage1.xyz, vBezierCage3.xyz - i.vBezierCage2.xyz, i.vTexCoord0.w );
|
||||
v0 = lerp( v0, v1, i.vTexCoord0.w );
|
||||
float3 vWorldTan = normalize( v0 );
|
||||
|
||||
float flDistAlongArm = i.vTexCoord0.z;
|
||||
//float flTotalArmLength = i.vTexCoord0.x / ( i.vTexCoord0.z - 1.0 );
|
||||
|
||||
float flWidthScale = g_flWidthScale + i.vColor.a * 0.5;
|
||||
|
||||
#if WIDEN_TIPS == 1
|
||||
float flWidth = g_flWidthBias + flWidthScale * pow( 1.0 - flDistAlongArm, g_flWidthExp );
|
||||
#else
|
||||
// regular tapering
|
||||
float flWidth = g_flWidthBias + flWidthScale * pow( flDistAlongArm, g_flWidthExp );
|
||||
#endif
|
||||
//flWidth = flDistAlongArm;
|
||||
|
||||
// quad expansion
|
||||
float3 vView = normalize( g_vEyePos - vWorldPos );
|
||||
float3 vSpan = cross( vView, vWorldTan );
|
||||
vWorldPos += vSpan * flWidth * 2.0 * ( i.vTexCoord0.y - 0.5 );
|
||||
|
||||
// Transform into projection space
|
||||
float4 vProjPosition = mul( float4( vWorldPos, 1.0f ), cViewProj );
|
||||
|
||||
o.vProjPosition = vProjPosition;
|
||||
o.vColor = i.vColor;
|
||||
|
||||
o.vWorldPos.xyz = vWorldPos.xyz;
|
||||
o.vWorldNormal.xyz = normalize( vView - dot( vView, vWorldTan ) * vWorldTan );
|
||||
o.vWorldTangent.xyz = vWorldTan;
|
||||
o.vWorldBinormal.xyz = vSpan;
|
||||
o.vWorldNormal.w = vProjPosition.z;
|
||||
|
||||
o.vUV.xy = i.vTexCoord0.xy * float2( g_flUVScale, 1.0 );
|
||||
o.vUV.x = 1.0 - flDistAlongArm;
|
||||
o.vUV.z = flDistAlongArm;
|
||||
return o;
|
||||
}
|
||||
599
materialsystem/stdshaders/blob_ps30.fxc
Normal file
599
materialsystem/stdshaders/blob_ps30.fxc
Normal file
@@ -0,0 +1,599 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// STATIC: "BACK_SURFACE" "0..1"
|
||||
// STATIC: "LIGHT_WARP" "0..1"
|
||||
// STATIC: "FRESNEL_WARP" "0..1"
|
||||
// STATIC: "HIGH_PRECISION_DEPTH" "0..1"
|
||||
// STATIC: "INTERIOR_LAYER" "0..1"
|
||||
// STATIC: "SELF_ILLUM_FRESNEL" "0..1"
|
||||
// STATIC: "OPACITY_TEXTURE" "0..1"
|
||||
// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..3" [ps20b] [PC]
|
||||
// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2" [ps30] [PC]
|
||||
// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX]
|
||||
// STATIC: "CONTACT_SHADOW" "0..1"
|
||||
// STATIC: "SELF_ILLUM_PULSE" "0..1"
|
||||
// STATIC: "VOLUME_TEXTURE" "0..1"
|
||||
// DYNAMIC: "NUM_LIGHTS" "0..4" [ps20b]
|
||||
// DYNAMIC: "NUM_LIGHTS" "0..4" [ps30]
|
||||
// DYNAMIC: "FLASHLIGHT" "0..1"
|
||||
// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1"
|
||||
|
||||
// SKIP: ( $CONTACT_SHADOW == 1 ) && ( $SELF_ILLUM_PULSE == 1 )
|
||||
|
||||
// For now, 'BACK_SURFACE' is a dead-simple path (just writes depth into dest alpha), so skip all non-HW-config combos:
|
||||
// SKIP: ( $BACK_SURFACE == 1 ) && ( $LIGHT_WARP > 0 )
|
||||
// SKIP: ( $BACK_SURFACE == 1 ) && ( $FRESNEL_WARP > 0 )
|
||||
// SKIP: ( $BACK_SURFACE == 1 ) && ( $INTERIOR_LAYER > 0 )
|
||||
// SKIP: ( $BACK_SURFACE == 1 ) && ( $SELF_ILLUM_FRESNEL > 0 )
|
||||
// SKIP: ( $BACK_SURFACE == 1 ) && ( $OPACITY_TEXTURE > 0 )
|
||||
// SKIP: ( $BACK_SURFACE == 1 ) && ( $CONTACT_SHADOW > 0 )
|
||||
// SKIP: ( $BACK_SURFACE == 1 ) && ( $SELF_ILLUM_PULSE > 0 )
|
||||
// SKIP: ( $BACK_SURFACE == 1 ) && ( $VOLUME_TEXTURE > 0 )
|
||||
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "shader_constant_register_map.h"
|
||||
|
||||
// SAMPLERS
|
||||
sampler g_tBase : register( s0 );
|
||||
sampler g_tBump : register( s1 );
|
||||
sampler g_tScreen : register( s2 );
|
||||
sampler g_tSpecMask : register( s3 );
|
||||
sampler g_tLightWarp : register( s4 );
|
||||
sampler g_tFresnelWarp : register( s5 );
|
||||
sampler g_tOpacity : register( s6 );
|
||||
sampler g_tShadowDepth : register( s7 ); // Flashlight shadow depth map sampler
|
||||
sampler g_tNormalizeRandRot : register( s8 ); // Normalization / RandomRotation samplers
|
||||
sampler g_tFlashlightCookie : register( s9 ); // Flashlight cookie
|
||||
|
||||
// SHADER CONSTANTS
|
||||
const float4 g_vMisc : register( c0 );
|
||||
#define g_flBumpStrength g_vMisc.x
|
||||
#define g_flDepthScale g_vMisc.y
|
||||
#define g_flInnerFogStrength g_vMisc.z
|
||||
#define g_flRefractStrength g_vMisc.w
|
||||
|
||||
const float4 g_vTranslucentFresnelParams_InteriorBoost : register( c1 );
|
||||
#define g_vTranslucentFresnelParams g_vTranslucentFresnelParams_InteriorBoost.xyz
|
||||
#define g_flInteriorBoost g_vTranslucentFresnelParams_InteriorBoost.w
|
||||
|
||||
const float4 g_vMisc2 : register( c3 );
|
||||
#define g_flRimLightExp g_vMisc2.x
|
||||
#define g_flRimLightScale g_vMisc2.y
|
||||
#define g_flSpecScale g_vMisc2.z
|
||||
#define g_flSpecExp2 g_vMisc2.w
|
||||
|
||||
const float4 g_vMisc3 : register( c10 );
|
||||
#define g_flSpecScale2 g_vMisc3.x
|
||||
#define g_flFresnelBumpStrength g_vMisc3.y
|
||||
#define g_flDiffuseScale g_vMisc3.z
|
||||
#define g_flInteriorLightScale g_vMisc3.w
|
||||
|
||||
const float4 g_vEyePos_SpecExp : register( PSREG_EYEPOS_SPEC_EXPONENT );
|
||||
#define g_vEyePos g_vEyePos_SpecExp.xyz
|
||||
#define g_flSpecExp g_vEyePos_SpecExp.w
|
||||
|
||||
const float4 g_ShaderControls : register( c12 );
|
||||
#define g_fWriteDepthToAlpha g_ShaderControls.x
|
||||
|
||||
const float4 g_vBaseTint_InteriorBackLightScale : register( c19 );
|
||||
#define g_cBaseTint g_vBaseTint_InteriorBackLightScale.rgb
|
||||
#define g_flInteriorBackLightScale g_vBaseTint_InteriorBackLightScale.w
|
||||
|
||||
const float4 g_vSelfIllumFresnelParams : register( c26 );
|
||||
#define g_flSelfIllumScale g_vSelfIllumFresnelParams.x
|
||||
#define g_flSelfIllumBias g_vSelfIllumFresnelParams.y
|
||||
#define g_flSelfIllumExp g_vSelfIllumFresnelParams.z
|
||||
#define g_flSelfIllumBrightness g_vSelfIllumFresnelParams.w
|
||||
|
||||
// TODO: pass in FOV so that we can account for it properly
|
||||
#define g_flHalfWindowWidth 1 /* tan(fov/2) */
|
||||
|
||||
const float4 g_cSelfIllumTint : register( c27 );
|
||||
//#define UNUSED g_cSelfIllumTint.w
|
||||
|
||||
const float4 g_vInteriorColor_RefractBlur : register( c32 );
|
||||
#define g_cInteriorColor g_vInteriorColor_RefractBlur.rgb
|
||||
#define g_flRefractBlur g_vInteriorColor_RefractBlur.w
|
||||
|
||||
const float3 cAmbientCube[6] : register( PSREG_AMBIENT_CUBE );
|
||||
|
||||
const PixelShaderLightInfo g_sLightInfo[3] : register( PSREG_LIGHT_INFO_ARRAY ); // 2 registers each - 6 registers total
|
||||
|
||||
const float4 g_vFlashlightAttenuationFactors_FarZ : register( PSREG_FLASHLIGHT_ATTENUATION );
|
||||
#define g_vFlashlightAttenuationFactors g_vFlashlightAttenuationFactors_FarZ.xyz
|
||||
#define g_flFlashlightFarZ g_vFlashlightAttenuationFactors_FarZ.w
|
||||
const float4 g_vFlashlightPos_RimBoost : register( PSREG_FLASHLIGHT_POSITION_RIM_BOOST );
|
||||
#define g_vFlashlightPos g_vFlashlightPos_RimBoost.xyz
|
||||
const float4x4 g_mFlashlightWorldToTexture : register( PSREG_FLASHLIGHT_TO_WORLD_TEXTURE );
|
||||
const float4 g_vShadowTweaks : register( PSREG_ENVMAP_TINT__SHADOW_TWEAKS );
|
||||
|
||||
const float3x3 g_mView : register( c33 );
|
||||
|
||||
const float4 g_vMisc4 : register( c36 );
|
||||
#define g_flLimitFogAtten g_vMisc4.x
|
||||
#define g_flFogNormalBoost g_vMisc4.y
|
||||
#define g_flGlowScale g_vMisc4.z
|
||||
//#define UNUSED g_vMisc4.w
|
||||
|
||||
// COMBO-DERIVED CONSTANTS
|
||||
static const bool bLightWarp = LIGHT_WARP ? true : false;
|
||||
static const bool bFlashLight = FLASHLIGHT ? true : false;
|
||||
|
||||
// How we use vertex colour (TEXCOORD2) varies based on static combos:
|
||||
#if ( CONTACT_SHADOW == 1 )
|
||||
#define i_ClosestSurfaceDir i.vClosestSurfaceDir
|
||||
#define i_PulseColor 0
|
||||
#define i_VertexAlpha 1
|
||||
#elif ( SELF_ILLUM_PULSE == 1 )
|
||||
#define i_ClosestSurfaceDir 0
|
||||
#define i_PulseColor i.vPulseColor.rgb
|
||||
#define i_VertexAlpha i.vPulseColor.a
|
||||
#else
|
||||
#define i_ClosestSurfaceDir 0
|
||||
#define i_PulseColor 0
|
||||
#define i_VertexAlpha 1
|
||||
#endif
|
||||
|
||||
|
||||
// INPUT STRUCT
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 vWorldNormal : TEXCOORD0; // w is proj. z coord (for depth stuff)
|
||||
#if CONTACT_SHADOW == 0
|
||||
float4 vPulseColor : TEXCOORD1;
|
||||
#else
|
||||
float4 vClosestSurfaceDir : TEXCOORD1;
|
||||
#endif
|
||||
float4 vWorldPos : TEXCOORD2; // w is proj. w coord
|
||||
float4 vUV0 : TEXCOORD3;
|
||||
float4 vUV1 : TEXCOORD4;
|
||||
float4 vLightAtten : TEXCOORD5;
|
||||
float3 vLightCube : TEXCOORD6;
|
||||
};
|
||||
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float Luminance( const float3 colour )
|
||||
{
|
||||
return dot( colour, float3( 0.3, 0.59, 0.11 ) );
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float3 ComputeTextureBlendWeights( float3 vWorldNormal )
|
||||
{
|
||||
float3 vBlendWeights = max( ( abs( vWorldNormal.xyz ) - 0.2 ) * 7.0, 0.0 );
|
||||
vBlendWeights /= dot( vBlendWeights, float3(1, 1, 1) ); // normalize
|
||||
return vBlendWeights;
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float4 BlendedTexFetchMAX( sampler s, float2 vUV0, float2 vUV1, float2 vUV2, float3 vBlendWeights )
|
||||
{
|
||||
// This 'max' blend is supposed to reduce the 'multiple layers sliding over one another'
|
||||
// appearance of the blob skin. NOTE: it doesn't preserve texture luminance.
|
||||
float4 vFetch0 = tex2D( s, vUV0 );
|
||||
float4 vFetch1 = tex2D( s, vUV1 );
|
||||
float4 vFetch2 = tex2D( s, vUV2 );
|
||||
//return vBlendWeights.x * vFetch0 + vBlendWeights.y * vFetch1 + vBlendWeights.z * vFetch2;
|
||||
return max( vBlendWeights.x * vFetch0, max( vBlendWeights.y * vFetch1, vBlendWeights.z * vFetch2 ) );
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float3 BumpedToWorldNormal( float3 vBumpedNormal,
|
||||
float3 vVertexNormal, // should be normalized
|
||||
float3 vTangentDir )
|
||||
{
|
||||
float3x3 mTanToWorld;
|
||||
mTanToWorld[2] = vVertexNormal;
|
||||
mTanToWorld[0] = vTangentDir - dot( vTangentDir, vVertexNormal ) * vVertexNormal;
|
||||
mTanToWorld[0] = normalize( mTanToWorld[0] );
|
||||
mTanToWorld[1] = cross( mTanToWorld[0], mTanToWorld[2] );
|
||||
return normalize( mul( vBumpedNormal, mTanToWorld ) );
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
void BlendedTexFetchNormal( sampler s, float2 vUV0, float2 vUV1, float2 vUV2, float3 vBlendWeights, float3 vWorldNormal,
|
||||
// Function outputs:
|
||||
out float2 vBumpedTSNormal, out float3 vBumpedWorldNormal, out float3 vFresnelWorldNormal )
|
||||
{
|
||||
float3 vNormalTS1 = 2.0 * tex2D( g_tBump, vUV0 ) - 1.0;
|
||||
float3 vNormalTS2 = 2.0 * tex2D( g_tBump, vUV1 ) - 1.0;
|
||||
float3 vNormalTS3 = 2.0 * tex2D( g_tBump, vUV2 ) - 1.0;
|
||||
vBumpedTSNormal = vBlendWeights.x * vNormalTS1.xy + vBlendWeights.y * vNormalTS2.xy + vBlendWeights.z * vNormalTS3.xy;
|
||||
|
||||
float3 vBumpedNormal1 = BumpedToWorldNormal( vNormalTS1, vWorldNormal, float3( 0, 1, 0 ) );
|
||||
float3 vBumpedNormal2 = BumpedToWorldNormal( vNormalTS2, vWorldNormal, float3( 1, 0, 0 ) );
|
||||
float3 vBumpedNormal3 = BumpedToWorldNormal( vNormalTS3, vWorldNormal, float3( 1, 0, 0 ) );
|
||||
vBumpedWorldNormal = vBlendWeights.x * vBumpedNormal1 + vBlendWeights.y * vBumpedNormal2 + vBlendWeights.z * vBumpedNormal3;
|
||||
|
||||
// Apply bump strength in world space (this is cheaper because we have to do it twice, for normal and fresnel bumpstrength)
|
||||
float3 vBumpStrengthDir = vBumpedWorldNormal - dot( vBumpedWorldNormal, vWorldNormal ) * vWorldNormal;
|
||||
vFresnelWorldNormal = normalize( vBumpedWorldNormal + ( g_flFresnelBumpStrength - 1.0 ) * vBumpStrengthDir );
|
||||
vBumpedWorldNormal = normalize( vBumpedWorldNormal + ( g_flBumpStrength - 1.0 ) * vBumpStrengthDir );
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
void ComputeOpacityAndFresnel( float2 vUV0, float2 vUV1, float2 vUV2, float3 vBlendWeights,
|
||||
float3 vEyeDir, float3 vWorldNormal, float flVertexAlpha,
|
||||
// Function outputs:
|
||||
out float flSkinOpacity, out float flBlobOpacity, out float flFresnel )
|
||||
{
|
||||
flSkinOpacity = 1;
|
||||
#if OPACITY_TEXTURE == 1
|
||||
flSkinOpacity = BlendedTexFetchMAX( g_tOpacity, vUV0, vUV1, vUV2, vBlendWeights );
|
||||
#endif
|
||||
|
||||
flFresnel = saturate( 1.0 - dot( vEyeDir.xyz, vWorldNormal.xyz ) );
|
||||
#if FRESNEL_WARP == 1
|
||||
float fTranslucentFresnel = tex1D( g_tFresnelWarp, flFresnel );
|
||||
#else
|
||||
float fTranslucentFresnel = lerp( g_vTranslucentFresnelParams.x, g_vTranslucentFresnelParams.y, pow( flFresnel, g_vTranslucentFresnelParams.z ) );
|
||||
#endif
|
||||
|
||||
// TODO: should decouple fresnel from the opacity map, this kills base texture alpha
|
||||
flSkinOpacity = max( flSkinOpacity, fTranslucentFresnel );
|
||||
|
||||
flBlobOpacity = flVertexAlpha;
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float3 BlobAmbientLight( float3 vVertexAmbient, float3 vEyeDir, float3 vWorldNormal, float flFresnel )
|
||||
{
|
||||
// Ambient lighting now comes from VS
|
||||
float3 cAmbient = vVertexAmbient;
|
||||
|
||||
// TODO: Replace lambert diffuse with pixelshader-ambient term of full lighting env.
|
||||
//float3 cAmbient = PixelShaderAmbientLight( vBumpedWorldNormal, cAmbientCube );
|
||||
|
||||
//float3 cAmbientSheen = PixelShaderAmbientLight( reflect( -vEyeDir, vBumpedWorldNormal ), cAmbientCube );
|
||||
//cAmbient = lerp( cAmbient, cAmbientSheen, flFresnel );
|
||||
|
||||
return cAmbient;
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
void BlobDynamicLight( float3 vWorldPos, float3 vEyeDir, float3 vBumpedWorldNormal, float4 vLightAtten, float flFresnel,
|
||||
// Function outputs:
|
||||
out float3 cDiffuse, out float3 cSpec, out float3 cSpec2, out float3 cRim )
|
||||
{
|
||||
cDiffuse = cSpec = cSpec2 = cRim = 0;
|
||||
|
||||
for ( int l = 0; l < NUM_LIGHTS; l++ )
|
||||
{
|
||||
cDiffuse.rgb += vLightAtten[l] * PixelShaderGetLightColor( g_sLightInfo, l ) *
|
||||
DiffuseTerm( true, vBumpedWorldNormal, PixelShaderGetLightVector( vWorldPos, g_sLightInfo, l ),
|
||||
bLightWarp, g_tLightWarp );
|
||||
|
||||
// spec 1
|
||||
float3 cCurrSpec, cCurrRim;
|
||||
bool bYesRimLight = true;
|
||||
SpecularAndRimTerms( vBumpedWorldNormal, PixelShaderGetLightVector( vWorldPos, g_sLightInfo, l ), g_flSpecExp, vEyeDir,
|
||||
false, g_tBump, 1.0, // dummy spec warp sampler & fresnel
|
||||
PixelShaderGetLightColor( g_sLightInfo, l ),
|
||||
bYesRimLight, g_flRimLightExp,
|
||||
cCurrSpec, cCurrRim );
|
||||
cSpec += vLightAtten[l] * cCurrSpec;
|
||||
cRim += vLightAtten[l] * cCurrRim;
|
||||
|
||||
// spec 2
|
||||
float3 cCurrSpec2, cDummy;
|
||||
bool bNoRimLight = false;
|
||||
SpecularAndRimTerms( vBumpedWorldNormal, PixelShaderGetLightVector( vWorldPos, g_sLightInfo, l ), g_flSpecExp2, vEyeDir,
|
||||
false, g_tBump, 1.0, // dummy spec warp sampler & fresnel
|
||||
PixelShaderGetLightColor( g_sLightInfo, l ),
|
||||
bNoRimLight, 0,
|
||||
cCurrSpec2, cDummy );
|
||||
cSpec2 += vLightAtten[l] * cCurrSpec2;
|
||||
// FIXME: no rim2 term?
|
||||
}
|
||||
|
||||
cRim *= flFresnel * flFresnel * flFresnel * flFresnel;
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
void BlobFlashlight( float3 vWorldPos, float3 vEyeDir, float3 vWorldNormal, float2 vScreenPos, float flSpecularExponent,
|
||||
// Function outputs:
|
||||
out float3 cOutFlashlightDiffuse, out float3 cOutFlashlightSpec, out float3 cOutFlashlightColor )
|
||||
{
|
||||
float3 delta = g_vFlashlightPos - vWorldPos;
|
||||
float3 vLightVec = normalize( delta );
|
||||
float distSquared = dot( delta, delta );
|
||||
float dist = sqrt( distSquared );
|
||||
|
||||
// Attenuation for light and to fade out shadow over distance
|
||||
float fAtten = saturate( dot( g_vFlashlightAttenuationFactors, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) );
|
||||
float endFalloffFactor = RemapValClamped( dist, g_flFlashlightFarZ, 0.6f * g_flFlashlightFarZ, 0.0f, 1.0f );
|
||||
|
||||
// Project into flashlight texture
|
||||
float4 flashlightSpacePosition = mul( float4( vWorldPos, 1.0f ), g_mFlashlightWorldToTexture ); // TODO: this can be moved to VS
|
||||
float3 vProjCoords = flashlightSpacePosition.xyz / flashlightSpacePosition.w;
|
||||
|
||||
// Flashlight colour
|
||||
cOutFlashlightColor = tex2D( g_tFlashlightCookie, vProjCoords );
|
||||
#if defined(SHADER_MODEL_PS_2_0) || defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0)
|
||||
cOutFlashlightColor *= cFlashlightColor.xyz;
|
||||
#endif
|
||||
cOutFlashlightColor *= endFalloffFactor * fAtten;
|
||||
|
||||
// Flashlight shadow
|
||||
#if (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0))
|
||||
if ( FLASHLIGHTSHADOWS )
|
||||
{
|
||||
float flShadow = DoFlashlightShadow( g_tShadowDepth, g_tNormalizeRandRot, vProjCoords, vScreenPos,
|
||||
FLASHLIGHTDEPTHFILTERMODE, g_vShadowTweaks );
|
||||
float flAttenuated = lerp( flShadow, 1.0f, g_vShadowTweaks.y ); // Blend between fully attenuated and not attenuated
|
||||
flShadow = saturate( lerp( flAttenuated, flShadow, fAtten ) ); // Blend between shadow and above, according to light attenuation
|
||||
cOutFlashlightColor *= flShadow; // Shadow term
|
||||
}
|
||||
#endif
|
||||
|
||||
// Flashlight diffuse term
|
||||
cOutFlashlightDiffuse = cOutFlashlightColor * DiffuseTerm( true, vWorldNormal, vLightVec, bLightWarp, g_tLightWarp );
|
||||
|
||||
// Flashlight specular term
|
||||
float3 cDummy;
|
||||
SpecularAndRimTerms( vWorldNormal, vLightVec, flSpecularExponent, -vEyeDir,
|
||||
false, g_tBump, 1.0, // dummy spec warp sampler & fresnel
|
||||
cOutFlashlightColor,
|
||||
false, g_flRimLightExp,
|
||||
cOutFlashlightSpec, cDummy );
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float4 SampleBackgroundBlurred( float2 vBumpedTSNormal, float3 vWorldNormal, float2 vScreenPos, float flCamDist, float flBlobOpacity )
|
||||
{
|
||||
static const float2 vPoissonOffset[8] = { float2( 0.3475f, 0.0042f ), float2( 0.8806f, 0.3430f ),
|
||||
float2( -0.0041f, -0.6197f ), float2( 0.0472f, 0.4964f ),
|
||||
float2( -0.3730f, 0.0874f ), float2( -0.9217f, -0.3177f ),
|
||||
float2( -0.6289f, 0.7388f ), float2( 0.5744f, -0.7741f ) };
|
||||
// TODO: get framebuffer res from constants
|
||||
float2 vScreenRes = float2( 1600, 1200 );
|
||||
float2 g_vInvScreenRes = 1.0 / vScreenRes;
|
||||
|
||||
// Project world-space blur radius into screen space.
|
||||
float flBlurRadius = flBlobOpacity * g_flRefractBlur * ( vScreenRes.x / ( flCamDist * g_flHalfWindowWidth ) );
|
||||
|
||||
// Bumped refract
|
||||
float flRefractStrength = flBlobOpacity * 80.0 * g_flRefractStrength / ( flCamDist * g_flHalfWindowWidth );
|
||||
float2 vBackgroundUV = flRefractStrength * vBumpedTSNormal + vScreenPos;
|
||||
/* // This gives the blob a more crystal-bally refractive look, which looks cool up-close, but looks weird when
|
||||
// it pulls foreground pixels in. It could work well if the innards were rendered into their own texture.
|
||||
float3 vOffset = mul( g_mView, normalize( -vWorldNormal ) );
|
||||
float2 vBackgroundUV = 0.07 * vOffset.xy + 0.03 * vBumpedTSNormal + vScreenPos; */
|
||||
|
||||
float4 cOut = 0;
|
||||
for( int i = 0; i < 8; i++ )
|
||||
{
|
||||
cOut += 1.0/8.0 * tex2D( g_tScreen, vBackgroundUV + flBlurRadius * g_vInvScreenRes.xy * vPoissonOffset[i] );
|
||||
}
|
||||
return cOut;
|
||||
}
|
||||
|
||||
float3 CubeAverage( void )
|
||||
{
|
||||
// TODO: Pass this average light color in as a const
|
||||
float3 cAvgLight = 0.0;
|
||||
for( int j = 0; j < 6; j++ )
|
||||
{
|
||||
cAvgLight += cAmbientCube[j] / 6.0;
|
||||
}
|
||||
return cAvgLight;
|
||||
}
|
||||
|
||||
float3 BlobInterior( float3 vWorldNormal, float2 vBumpedTSNormal, float3 vEyeDir,
|
||||
float2 vScreenPos, float flPixelDepth, float flCamDist, float flBlobOpacity, float3 cFlashlightColor )
|
||||
{
|
||||
float3 cInterior = 0;
|
||||
|
||||
// Sample the background (and inner blob brain/tentacles)
|
||||
float4 cBackground = SampleBackgroundBlurred( vBumpedTSNormal, vWorldNormal, vScreenPos, flCamDist, flBlobOpacity );
|
||||
// Boost bright background pixels
|
||||
float flLuminance = Luminance( cBackground.rgb );
|
||||
cBackground.rgb *= 1.0 + g_flInteriorBoost * flLuminance * flLuminance;
|
||||
|
||||
// Fake refract-like vector without any total internal reflection crappiness
|
||||
float3 vRefract = normalize( -( vEyeDir + vWorldNormal ) );
|
||||
|
||||
// Interior lighting through ambient cube
|
||||
float3 cBackLight = PixelShaderAmbientLight( vRefract, cAmbientCube );
|
||||
float3 cAvgLight = CubeAverage() + ( 0.6 * cFlashlightColor );
|
||||
cBackLight = max( g_flInteriorLightScale * cAvgLight, g_flInteriorBackLightScale * cBackLight );
|
||||
cBackLight *= g_cInteriorColor;
|
||||
|
||||
// Get eye ray travel distance through blob
|
||||
float flBackgroundDepth = cBackground.a * g_flDepthScale;
|
||||
float flDistThroughBlob = flBackgroundDepth - flPixelDepth;
|
||||
flDistThroughBlob = max( 0.0, flDistThroughBlob );
|
||||
// Compute the opacity ('fog') of the blob interior volume, based on its thickness
|
||||
float flFogAtten = pow( 2.0, -flDistThroughBlob * g_flInnerFogStrength ); // exponential falloff
|
||||
//float flFogAtten = saturate( 0.5 - 0.011 * flDistThroughBlob ); // linear falloff
|
||||
#if HIGH_PRECISION_DEPTH == 0
|
||||
// fade to constant interior fogginess as we run against the low-precision destalpha depth limit
|
||||
flFogAtten = lerp( flFogAtten, g_flLimitFogAtten, saturate( cBackground.a*cBackground.a*cBackground.a ) );
|
||||
#endif
|
||||
flFogAtten = lerp( 1.0, flFogAtten, flBlobOpacity );
|
||||
|
||||
// Composite the fog interior lighting/fog over the background
|
||||
cInterior = lerp( cBackLight, cBackground.rgb, flFogAtten );
|
||||
|
||||
//float flInScattering = flDistThroughBlob * 0.002;
|
||||
//cInterior.rgb += flInScattering * i.vLightCube.rgb;
|
||||
|
||||
return cInterior;
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
void BlobSelfIllumFresnel( float3 vFresnelWorldNormal, float3 vEyeDir,
|
||||
// Function-modified inputs:
|
||||
inout float3 cDiffuse )
|
||||
{
|
||||
float flSelfIllumFresnel = pow( saturate( dot( vEyeDir.xyz, vFresnelWorldNormal.xyz ) ), g_flSelfIllumExp );
|
||||
flSelfIllumFresnel = ( flSelfIllumFresnel * g_flSelfIllumScale ) + g_flSelfIllumBias;
|
||||
float3 cSelfIllumComponent = g_cSelfIllumTint * g_flSelfIllumBrightness;
|
||||
cDiffuse.rgb = lerp( cDiffuse.rgb, cSelfIllumComponent.rgb, saturate( flSelfIllumFresnel ) );
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float BlobContactShadow( float3 vWorldNormal, float4 vClosestSurfaceDir )
|
||||
{
|
||||
// contact darkening for blob regions that touch a surface
|
||||
float3 vSurfaceDir = normalize( vClosestSurfaceDir.xyz ) * vClosestSurfaceDir.w;
|
||||
float flContactShadow = saturate( 0.8 * ( 1.0 - dot( vSurfaceDir, vWorldNormal ) ) + 0.2 );
|
||||
flContactShadow = lerp ( 0.3, 1.0, flContactShadow * flContactShadow * flContactShadow );
|
||||
return flContactShadow;
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float3 BlobSelfIllumPulse( float3 cPulseColor, float3 cBase, float flSkinOpacity )
|
||||
{
|
||||
float flBaseLuminance = length( cBase.rgb );
|
||||
float flPulseLuminance = length( cPulseColor );
|
||||
float3 cSelfIllumPulse = sqrt( flSkinOpacity ) * g_flGlowScale * flBaseLuminance * flPulseLuminance * cPulseColor;
|
||||
return cSelfIllumPulse;
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float3 noise( float3 coord )
|
||||
{
|
||||
coord.z *= 50.0;
|
||||
float zfrac = frac( coord.z );
|
||||
float2 zhash = float2( coord.z, 1 + coord.z );
|
||||
zhash -= frac( zhash );
|
||||
zhash = ( zhash * zhash );
|
||||
zhash -= 31.0 * floor( zhash / 31.0 );
|
||||
zhash = ( zhash * zhash );
|
||||
zhash -= 31.0 * floor( zhash / 31.0 );
|
||||
zhash *= 1.0/31.0;
|
||||
float3 c0 = tex2D( g_tBase, float4( coord.xy + float2( 0, zhash.x ), 0, 0 ) ).rgb;
|
||||
float3 c1 = tex2D( g_tBase, float4( coord.xy + float2( 0, zhash.y ), 0, 0 ) ).rgb;
|
||||
|
||||
float3 rslt = lerp( c0, c1, zfrac );
|
||||
return rslt;
|
||||
}
|
||||
|
||||
void PerformVolumeTexturing( float3 vUVW, float3 vWorldNormal,
|
||||
// Function outputs:
|
||||
out float3 cOut )
|
||||
{
|
||||
// volumetric texturing test code
|
||||
float fNoiseScale = 0.002;
|
||||
float fStrengthScale = 1.0;
|
||||
cOut.rgb = 0;
|
||||
for ( int k = 0; k < 6; k++ )
|
||||
{
|
||||
cOut.rgb += fStrengthScale * noise( fNoiseScale * vUVW ).rgb;
|
||||
fNoiseScale *= 2.0; fStrengthScale /= 1.8;
|
||||
}
|
||||
cOut.rgb /= 2.0;
|
||||
cOut.rgb *= PixelShaderAmbientLight( vWorldNormal, cAmbientCube );
|
||||
}
|
||||
|
||||
//==============================================================================================================================================================
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4 cOut = { 0, 0, 0, 1 };
|
||||
|
||||
// Set up misc camera variables
|
||||
float flPixelDepth = i.vWorldNormal.w;
|
||||
float2 vScreenPos = i.vUV1.wz / i.vWorldPos.w;
|
||||
float3 vEyeDir = g_vEyePos.xyz - i.vWorldPos.xyz;
|
||||
float flCamDist = length( vEyeDir );
|
||||
vEyeDir /= flCamDist;
|
||||
// Set up contact shadowing or self-illum values (or neither), based on static combo
|
||||
float4 vClosestSurfaceDir = i_ClosestSurfaceDir;
|
||||
float3 cPulseColor = i_PulseColor;
|
||||
float flVertexAlpha = i_VertexAlpha;
|
||||
|
||||
|
||||
// For now, 'BACK_SURFACE' is a dead-simple path (just writes depth into dest alpha)
|
||||
#if ( BACK_SURFACE == 1 )
|
||||
cOut = tex2D( g_tScreen, vScreenPos );
|
||||
return FinalOutput( cOut, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR, g_fWriteDepthToAlpha, flPixelDepth );
|
||||
#endif
|
||||
|
||||
|
||||
// Blend weights for 3 blended planar projections
|
||||
float3 vWorldNormal = normalize( i.vWorldNormal.xyz );
|
||||
float3 vBlendWeights = ComputeTextureBlendWeights( vWorldNormal );
|
||||
|
||||
// Base+spec maps
|
||||
float4 cBase = BlendedTexFetchMAX( g_tBase, i.vUV0.xy, i.vUV0.wz, i.vUV1.xy, vBlendWeights );
|
||||
float flSpecMask = BlendedTexFetchMAX( g_tSpecMask, i.vUV0.xy, i.vUV0.wz, i.vUV1.xy, vBlendWeights );
|
||||
// Use base tex alpha channel as a tint mask
|
||||
cBase.rgb = lerp( cBase.rgb, Luminance( cBase.rgb ) * g_cBaseTint.rgb, cBase.a );
|
||||
|
||||
// Normal mapping
|
||||
float3 vBumpedWorldNormal, vFresnelWorldNormal;
|
||||
float2 vBumpedTSNormal;
|
||||
BlendedTexFetchNormal( g_tBump, i.vUV0.xy, i.vUV0.zw, i.vUV1.xy, vBlendWeights, vWorldNormal,
|
||||
vBumpedTSNormal, vBumpedWorldNormal, vFresnelWorldNormal );
|
||||
|
||||
// Opacity and fresnel
|
||||
float flSkinOpacity, flBlobOpacity, flFresnel;
|
||||
ComputeOpacityAndFresnel( i.vUV0.xy, i.vUV0.wz, i.vUV1.xy, vBlendWeights, vEyeDir, vFresnelWorldNormal, flVertexAlpha,
|
||||
flSkinOpacity, flBlobOpacity, flFresnel );
|
||||
|
||||
// Ambient light
|
||||
float3 cAmbient = BlobAmbientLight( i.vLightCube, vEyeDir, vBumpedWorldNormal, flFresnel );
|
||||
|
||||
// Dynamic lights
|
||||
float3 cDiffuse, cSpec, cSpec2, cRim;
|
||||
BlobDynamicLight( i.vWorldPos.xyz, vEyeDir, vBumpedWorldNormal, i.vLightAtten, flFresnel,
|
||||
cDiffuse, cSpec, cSpec2, cRim );
|
||||
|
||||
// Flashlight
|
||||
float3 cFlashlightColor = 0;
|
||||
#if FLASHLIGHT == 1
|
||||
float3 cFlashlightDiffuse, cFlashlightSpec;
|
||||
BlobFlashlight( i.vWorldPos.xyz, vEyeDir, vBumpedWorldNormal, vScreenPos, g_flSpecExp2,
|
||||
cFlashlightDiffuse, cFlashlightSpec, cFlashlightColor );
|
||||
cDiffuse.rgb += cFlashlightDiffuse;
|
||||
cSpec2 += cFlashlightSpec;
|
||||
#endif
|
||||
|
||||
// Scale light terms
|
||||
cDiffuse *= g_flDiffuseScale;
|
||||
cSpec *= g_flSpecScale;
|
||||
cSpec2 *= g_flSpecScale2;
|
||||
cRim *= g_flRimLightScale;
|
||||
|
||||
// Compute blob interior/background colour
|
||||
float3 cInterior = 0;
|
||||
#if INTERIOR_LAYER == 1
|
||||
cInterior = BlobInterior( vWorldNormal, vBumpedTSNormal, vEyeDir,
|
||||
vScreenPos, flPixelDepth, flCamDist, flBlobOpacity, cFlashlightColor );
|
||||
#endif
|
||||
|
||||
// Self-illum
|
||||
#if SELF_ILLUM_FRESNEL == 1
|
||||
BlobSelfIllumFresnel( vFresnelWorldNormal, vEyeDir,
|
||||
cDiffuse );
|
||||
#endif
|
||||
|
||||
#if ( INTERIOR_LAYER == 0 )
|
||||
// Outer layer only
|
||||
cOut.rgb = cBase.rgb * ( cAmbient.rgb + cDiffuse.rgb ) + flSpecMask * ( cSpec + cSpec2 ) + cRim;
|
||||
#else
|
||||
// Outer layer blended over inner/background colour
|
||||
cInterior.rgb += flBlobOpacity * flSpecMask * cSpec;
|
||||
cOut.rgb = cBase.rgb * ( cAmbient.rgb + cDiffuse.rgb ) + flSpecMask * cSpec2 + cRim;
|
||||
cOut.rgb = lerp( cInterior.rgb, cOut.rgb, flBlobOpacity * flSkinOpacity );
|
||||
#endif
|
||||
|
||||
#if CONTACT_SHADOW == 1
|
||||
cOut.rgb *= BlobContactShadow( vWorldNormal, vClosestSurfaceDir );
|
||||
#elif SELF_ILLUM_PULSE == 1
|
||||
cOut.rgb += BlobSelfIllumPulse( cPulseColor, cBase, flSkinOpacity );
|
||||
#endif
|
||||
|
||||
#if VOLUME_TEXTURE == 1
|
||||
PerformVolumeTexturing( i.vUV0.xyz, vWorldNormal, cOut.rgb );
|
||||
#endif
|
||||
|
||||
// TODO: Support fog
|
||||
cOut.a = 1;
|
||||
return FinalOutput( cOut, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR, g_fWriteDepthToAlpha, flPixelDepth );
|
||||
}
|
||||
128
materialsystem/stdshaders/blob_vs30.fxc
Normal file
128
materialsystem/stdshaders/blob_vs30.fxc
Normal file
@@ -0,0 +1,128 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// STATIC: "CONTACT_SHADOW" "0..1"
|
||||
// STATIC: "VOLUME_TEXTURE" "0..1"
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
// Globals
|
||||
const float g_flUVScale : register( SHADER_SPECIFIC_CONST_0 );
|
||||
const float3 g_vUVProjOffset : register( SHADER_SPECIFIC_CONST_1 );
|
||||
const float3 g_vBBMin : register( SHADER_SPECIFIC_CONST_2 );
|
||||
const float3 g_vBBMax : register( SHADER_SPECIFIC_CONST_3 );
|
||||
|
||||
// Structs
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION; // Position
|
||||
float4 vNormal : NORMAL; // Normal
|
||||
float4 vBoneWeights : BLENDWEIGHT; // Skin weights
|
||||
float4 vBoneIndices : BLENDINDICES; // Skin indices
|
||||
#if CONTACT_SHADOW == 1
|
||||
float4 vClosestSurfaceDir : TEXCOORD0;
|
||||
#else
|
||||
float4 vColor : TEXCOORD0;
|
||||
#endif
|
||||
float4 vTangent : TANGENT;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPosition : POSITION; // Projection-space position
|
||||
float4 vWorldNormal : TEXCOORD0; // w is proj. z coord (for depth stuff)
|
||||
#if CONTACT_SHADOW == 1
|
||||
float4 vClosestSurfaceDir : TEXCOORD1;
|
||||
#else
|
||||
float4 vColor : TEXCOORD1;
|
||||
#endif
|
||||
float4 vWorldPos : TEXCOORD2; // w is proj. w coord
|
||||
float4 vUV0 : TEXCOORD3;
|
||||
float4 vUV1 : TEXCOORD4;
|
||||
float4 vLightAtten : TEXCOORD5;
|
||||
float3 vAmbient : TEXCOORD6;
|
||||
};
|
||||
|
||||
float3 CubeUV( float3 vWorldPosition, float3 vWorldNormal, float3 vUVSpacePos )
|
||||
{
|
||||
// Generate texcoords for a cubemap wrapped around the blob's bounding box
|
||||
float3 vDir = normalize( lerp( normalize( vUVSpacePos.xyz ), vWorldNormal.xyz, 0.5 ) );
|
||||
float3 tMins = ( g_vBBMin - vWorldPosition ) / vDir;
|
||||
float3 tMaxs = ( g_vBBMax - vWorldPosition ) / vDir;
|
||||
tMaxs = max( tMaxs, tMins ); // weed out negative t's per axis
|
||||
float t = min( tMaxs.x, min( tMaxs.y, tMaxs.z ) );
|
||||
float3 vIntersectionPos = vWorldPosition + t * vDir;
|
||||
// transform into unit cube
|
||||
float3 vCubeUV = vIntersectionPos;
|
||||
vCubeUV -= 0.5*( g_vBBMax + g_vBBMin );
|
||||
vCubeUV /= 0.5*( g_vBBMax - g_vBBMin );
|
||||
vCubeUV = normalize( vCubeUV );
|
||||
return vCubeUV;
|
||||
}
|
||||
|
||||
|
||||
// Main
|
||||
VS_OUTPUT main( const VS_INPUT i )
|
||||
{
|
||||
VS_OUTPUT o;
|
||||
|
||||
float4 vObjPosition = i.vPos;
|
||||
float4 vObjTangent = i.vTangent;
|
||||
float3 vObjNormal;
|
||||
DecompressVertex_Normal( i.vNormal, vObjNormal );
|
||||
|
||||
// Transform the position and normal
|
||||
float3 vWorldPosition = { 0.0f, 0.0f, 0.0f };
|
||||
float3 vWorldNormal = { 0.0f, 0.0f, 0.0f };
|
||||
float3 vWorldTangent = { 0.0f, 0.0f, 0.0f };
|
||||
float3 vWorldBinormal = { 0.0f, 0.0f, 0.0f };
|
||||
SkinPositionNormalAndTangentSpace( SKINNING ? true : false,
|
||||
vObjPosition, vObjNormal.xyz, vObjTangent.xyzw,
|
||||
i.vBoneWeights, i.vBoneIndices,
|
||||
vWorldPosition, vWorldNormal, vWorldTangent, vWorldBinormal );
|
||||
vWorldNormal.xyz = normalize( vWorldNormal.xyz );
|
||||
|
||||
o.vWorldNormal.xyz = vWorldNormal.xyz;
|
||||
o.vWorldPos.xyz = vWorldPosition.xyz;
|
||||
|
||||
// Transform into projection space
|
||||
float4 vProjPosition = mul( float4( vWorldPosition, 1.0f ), cViewProj );
|
||||
o.vProjPosition = vProjPosition;
|
||||
o.vWorldNormal.w = vProjPosition.z;
|
||||
o.vWorldPos.w = vProjPosition.w;
|
||||
|
||||
// Seamless texturing UV projections
|
||||
float3 vUVSpacePos = vWorldPosition.xyz - g_vUVProjOffset.xyz;
|
||||
o.vUV0.xy = g_flUVScale * vUVSpacePos.yz;
|
||||
o.vUV0.wz = g_flUVScale * vUVSpacePos.xz;
|
||||
o.vUV1.xy = g_flUVScale * vUVSpacePos.xy;
|
||||
|
||||
// Cubemap UV gen
|
||||
//o.vCubeUVW.xyz = CubeUV( vWorldPosition, vWorldNormal, vUVSpacePos );
|
||||
|
||||
// Screen-space texcoord
|
||||
float2 vScreenPos = float2( 0.5, -0.5 ) * vProjPosition.xy + 0.5 * vProjPosition.w;
|
||||
o.vUV1.wz = vScreenPos;
|
||||
|
||||
// Dynamic light attenuation factors
|
||||
o.vLightAtten.x = GetVertexAttenForLight( vWorldPosition, 0 );
|
||||
o.vLightAtten.y = GetVertexAttenForLight( vWorldPosition, 1 );
|
||||
o.vLightAtten.z = GetVertexAttenForLight( vWorldPosition, 2 );
|
||||
o.vLightAtten.w = GetVertexAttenForLight( vWorldPosition, 3 );
|
||||
|
||||
// Ambient light
|
||||
o.vAmbient = AmbientLight( vWorldNormal );
|
||||
|
||||
#if CONTACT_SHADOW == 1
|
||||
// Closest surface's direction and distance, for contact shadowing
|
||||
o.vClosestSurfaceDir.xyz = i.vClosestSurfaceDir.xyz;
|
||||
o.vClosestSurfaceDir.w = length( i.vClosestSurfaceDir.xyz );
|
||||
#else
|
||||
// Vertex colour for self-illumination glow
|
||||
o.vColor.rgba = i.vColor.rgba;
|
||||
#endif
|
||||
|
||||
return o;
|
||||
}
|
||||
19
materialsystem/stdshaders/bloomadd_ps2x.fxc
Normal file
19
materialsystem/stdshaders/bloomadd_ps2x.fxc
Normal file
@@ -0,0 +1,19 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler TexSampler : register( s0 );
|
||||
|
||||
float g_flBloomAmount : register( c0 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 baseTexCoord : TEXCOORD0; // Base texture coordinate
|
||||
};
|
||||
|
||||
float4_color_return_type main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4_color_return_type result = g_flBloomAmount * tex2D( TexSampler, i.baseTexCoord );
|
||||
result.a = 1.0f;
|
||||
return result; //FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
34
materialsystem/stdshaders/blurentity_ps2x.fxc
Normal file
34
materialsystem/stdshaders/blurentity_ps2x.fxc
Normal file
@@ -0,0 +1,34 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
// blurs colors by averages
|
||||
// bleeds alpha by max of current vs averages
|
||||
|
||||
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 = tex2D( g_texSampler, float2( i.uv.x + g_vPsTapOffsets[0].x, i.uv.y + g_vPsTapOffsets[0].y ) );
|
||||
cOut += tex2D( g_texSampler, float2( i.uv.x , i.uv.y + g_vPsTapOffsets[0].y ) );
|
||||
cOut += tex2D( g_texSampler, float2( i.uv.x - g_vPsTapOffsets[0].x, i.uv.y + g_vPsTapOffsets[0].y ) );
|
||||
|
||||
cOut += tex2D( g_texSampler, float2( i.uv.x + g_vPsTapOffsets[0].x, i.uv.y ) );
|
||||
cOut += tex2D( g_texSampler, float2( i.uv.x , i.uv.y ) );
|
||||
cOut += tex2D( g_texSampler, float2( i.uv.x - g_vPsTapOffsets[0].x, i.uv.y ) );
|
||||
|
||||
cOut += tex2D( g_texSampler, float2( i.uv.x + g_vPsTapOffsets[0].x, i.uv.y - g_vPsTapOffsets[0].y ) );
|
||||
cOut += tex2D( g_texSampler, float2( i.uv.x , i.uv.y - g_vPsTapOffsets[0].y ) );
|
||||
cOut += tex2D( g_texSampler, float2( i.uv.x - g_vPsTapOffsets[0].x, i.uv.y - g_vPsTapOffsets[0].y ) );
|
||||
|
||||
cOut *= (1.0f/9.0f);
|
||||
|
||||
cOut.a = max( cOut.a * 1.0f, tex2D( g_texSampler, i.uv ).a ); //never reduce alpha, only increase it
|
||||
return saturate( cOut );
|
||||
}
|
||||
22
materialsystem/stdshaders/blurgaussian_3x3_ps2x.fxc
Normal file
22
materialsystem/stdshaders/blurgaussian_3x3_ps2x.fxc
Normal file
@@ -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;
|
||||
}
|
||||
28
materialsystem/stdshaders/bufferclearobeystencil_ps2x.fxc
Normal file
28
materialsystem/stdshaders/bufferclearobeystencil_ps2x.fxc
Normal file
@@ -0,0 +1,28 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// STATIC: "RELOADZCULL" "0..0" [XBOX]
|
||||
// STATIC: "RELOADZCULL" "0..0" [PC]
|
||||
// STATIC: "RELOADZCULL" "0..1" [SONYPS3]
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 vColor : COLOR0;
|
||||
};
|
||||
|
||||
HALF4 main(
|
||||
PS_INPUT i
|
||||
#if RELOADZCULL
|
||||
, out float flDepth : DEPTH
|
||||
#endif // RELOADZCULL
|
||||
) : COLOR
|
||||
{
|
||||
#if RELOADZCULL
|
||||
// When reloading Zcull memory on the PS3, we need to draw a quad with depth = 0 (so it doesn't get early-culled) but then emit a depth of 1.0
|
||||
// because we need to guarantee that every pixel is rejected by the hardware and simply forces the ROP unit to update Zcull memory
|
||||
flDepth = 1.0f;
|
||||
#endif // RELOADZCULL
|
||||
|
||||
return i.vColor;
|
||||
}
|
||||
41
materialsystem/stdshaders/bufferclearobeystencil_vs20.fxc
Normal file
41
materialsystem/stdshaders/bufferclearobeystencil_vs20.fxc
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "common_vs_fxc.h"
|
||||
// STATIC: "USESCOLOR" "0..1"
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION;
|
||||
# if (USESCOLOR == 1)
|
||||
float4 vColor : COLOR0;
|
||||
# endif
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
# if (USESCOLOR == 1)
|
||||
float4 vColor : COLOR0;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
o.vProjPos.xyz = v.vPos.xyz;
|
||||
o.vProjPos.w = 1.0f;
|
||||
|
||||
#ifdef _PS3
|
||||
// Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
|
||||
o.vProjPos.y = -o.vProjPos.y;
|
||||
o.vProjPos.z = 2.0f * o.vProjPos.z - o.vProjPos.w;
|
||||
#endif // _PS3
|
||||
|
||||
# if (USESCOLOR == 1)
|
||||
{
|
||||
o.vColor = v.vColor;
|
||||
}
|
||||
# endif
|
||||
|
||||
return o;
|
||||
}
|
||||
115
materialsystem/stdshaders/buildallshaders.bat
Normal file
115
materialsystem/stdshaders/buildallshaders.bat
Normal file
@@ -0,0 +1,115 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set TTEXE=..\..\devtools\bin\timeprecise.exe
|
||||
if not exist %TTEXE% goto no_ttexe
|
||||
goto no_ttexe_end
|
||||
|
||||
:no_ttexe
|
||||
set TTEXE=time /t
|
||||
:no_ttexe_end
|
||||
|
||||
|
||||
rem echo.
|
||||
rem echo ~~~~~~ buildallshaders %* ~~~~~~
|
||||
%TTEXE% -cur-Q
|
||||
set tt_all_start=%ERRORLEVEL%
|
||||
set tt_all_chkpt=%tt_start%
|
||||
|
||||
|
||||
|
||||
set sourcedir="shaders"
|
||||
set targetdir="..\..\..\game\platform\shaders"
|
||||
|
||||
set BUILD_SHADER=call buildshaders.bat
|
||||
|
||||
set ARG_X360=-x360
|
||||
set ARG_PS3=-ps3
|
||||
set ARG_EXTRA=
|
||||
|
||||
|
||||
|
||||
REM ****************
|
||||
REM usage: buildallshaders [-pc | -x360 | -ps3]
|
||||
REM ****************
|
||||
set ALLSHADERS_CONFIG=pc
|
||||
if /i "%1" == "-pc" goto shcfg_pc
|
||||
if /i "%1" == "-ps3" goto shcfg_ps3
|
||||
if /i "%1" == "-360" goto shcfg_x360
|
||||
if /i "%1" == "-x360" goto shcfg_x360
|
||||
if /i "%1" == "-xbox" goto shcfg_x360
|
||||
|
||||
REM // The default is to build shaders for all platforms when not specifying -pc, -x360, or -ps3
|
||||
call buildallshaders.bat -pc %*
|
||||
call buildallshaders.bat -x360 %*
|
||||
call buildallshaders.bat -ps3 %*
|
||||
goto end_of_file
|
||||
|
||||
:shcfg_pc
|
||||
echo.
|
||||
echo // PC (-pc command line option) ===============================================
|
||||
if /i "%2" == "-nompi" set ARG_EXTRA=-nompi
|
||||
set ALLSHADERS_CONFIG=pc
|
||||
goto shcfg_end
|
||||
:shcfg_ps3
|
||||
echo.
|
||||
echo // PS3 (-ps3 command line option) =============================================
|
||||
if /i "%2" == "-nompi" set ARG_EXTRA=-nompi
|
||||
if /i "%2" == "-ps3debug" set ARG_EXTRA=-ps3debug
|
||||
if /i "%2" == "-ps3scheduleoptimization" set ARG_EXTRA=-ps3scheduleoptimization
|
||||
set ALLSHADERS_CONFIG=ps3
|
||||
goto shcfg_end
|
||||
:shcfg_x360
|
||||
echo.
|
||||
echo // 360 (-360 command line option) =============================================
|
||||
if /i "%2" == "-nompi" set ARG_EXTRA=-nompi
|
||||
set ALLSHADERS_CONFIG=x360
|
||||
goto shcfg_end
|
||||
:shcfg_end
|
||||
|
||||
|
||||
REM ****************
|
||||
REM PC SHADERS
|
||||
REM ****************
|
||||
if /i "%ALLSHADERS_CONFIG%" == "pc" (
|
||||
%BUILD_SHADER% stdshader_dx9_20b %ARG_EXTRA%
|
||||
%BUILD_SHADER% stdshader_dx9_20b_new -dx9_30 %ARG_EXTRA%
|
||||
%BUILD_SHADER% stdshader_dx9_30 -dx9_30 -force30 %ARG_EXTRA%
|
||||
rem %BUILD_SHADER% stdshader_dx10 -dx10 %ARG_EXTRA%
|
||||
)
|
||||
|
||||
REM ****************
|
||||
REM X360 SHADERS
|
||||
REM ****************
|
||||
if /i "%ALLSHADERS_CONFIG%" == "x360" (
|
||||
%BUILD_SHADER% stdshader_dx9_20b %ARG_X360% %ARG_EXTRA%
|
||||
%BUILD_SHADER% stdshader_dx9_20b_new %ARG_X360% %ARG_EXTRA%
|
||||
rem %BUILD_SHADER% stdshader_dx9_30 %ARG_X360% %ARG_EXTRA%
|
||||
rem %BUILD_SHADER% stdshader_dx10 %ARG_X360% %ARG_EXTRA%
|
||||
)
|
||||
|
||||
REM ****************
|
||||
REM PS3 SHADERS
|
||||
REM ****************
|
||||
if /i "%ALLSHADERS_CONFIG%" == "ps3" (
|
||||
%BUILD_SHADER% stdshader_ps3 %ARG_PS3% %ARG_EXTRA%
|
||||
)
|
||||
|
||||
REM ****************
|
||||
REM END
|
||||
REM ****************
|
||||
:end
|
||||
|
||||
|
||||
|
||||
rem echo.
|
||||
if not "%dynamic_shaders%" == "1" (
|
||||
rem echo Finished full buildallshaders %*
|
||||
) else (
|
||||
rem echo Finished dynamic buildallshaders %*
|
||||
)
|
||||
|
||||
rem %TTEXE% -diff %tt_all_start% -cur
|
||||
rem echo.
|
||||
|
||||
:end_of_file
|
||||
55
materialsystem/stdshaders/buildincs.bat
Normal file
55
materialsystem/stdshaders/buildincs.bat
Normal file
@@ -0,0 +1,55 @@
|
||||
@echo off
|
||||
|
||||
set x360_args=
|
||||
set ps3_args=
|
||||
|
||||
if not exist %2.txt goto error1
|
||||
if /i "%1" == "-x360" goto set_x360_args
|
||||
if /i "%1" == "-ps3" goto set_ps3_args
|
||||
|
||||
echo.
|
||||
echo No valid platform specified for first argument; specify either -ps3 or -x360
|
||||
echo.
|
||||
|
||||
goto usage
|
||||
|
||||
:set_x360_args
|
||||
set x360_args=-x360
|
||||
set SHADERINCPATH=vshtmp9_360/... fxctmp9_360/...
|
||||
goto build_incs
|
||||
|
||||
:set_ps3_args
|
||||
set ps3_args=-ps3
|
||||
set SHADERINCPATH=vshtmp9_ps3/... fxctmp9_ps3/...
|
||||
goto build_incs
|
||||
|
||||
:build_incs
|
||||
|
||||
updateshaders.pl %1 -source ..\.. %2
|
||||
|
||||
nmake makefile.%2
|
||||
|
||||
copyshaderincfiles.pl inclist.txt %1
|
||||
|
||||
set SHADERINCPATH=vshtmp9/... fxctmp9/...
|
||||
p4autocheckout.pl inclist.txt "Shader Auto Checkout INC" . %SHADERINCPATH%
|
||||
|
||||
goto end
|
||||
|
||||
:error1
|
||||
|
||||
echo.
|
||||
echo File %2.txt does not exist
|
||||
echo.
|
||||
|
||||
goto usage
|
||||
|
||||
:usage
|
||||
|
||||
echo.
|
||||
echo "Usage: buildincs.bat [-x360|-ps3] [shader list]"
|
||||
echo .
|
||||
goto end
|
||||
|
||||
:end
|
||||
|
||||
321
materialsystem/stdshaders/buildshaders.bat
Normal file
321
materialsystem/stdshaders/buildshaders.bat
Normal file
@@ -0,0 +1,321 @@
|
||||
@echo off
|
||||
|
||||
set TTEXE=..\..\devtools\bin\timeprecise.exe
|
||||
if not exist %TTEXE% goto no_ttexe
|
||||
goto no_ttexe_end
|
||||
|
||||
:no_ttexe
|
||||
set TTEXE=time /t
|
||||
:no_ttexe_end
|
||||
|
||||
echo.
|
||||
rem echo ==================== buildshaders %* ==================
|
||||
%TTEXE% -cur-Q
|
||||
set tt_start=%ERRORLEVEL%
|
||||
set tt_chkpt=%tt_start%
|
||||
|
||||
|
||||
REM ****************
|
||||
REM usage: buildshaders <shaderProjectName> [-x360|-ps3]
|
||||
REM ****************
|
||||
|
||||
setlocal
|
||||
set arg_filename=%1
|
||||
rem set shadercompilecommand=echo shadercompile.exe -mpi_graphics -mpi_TrackEvents
|
||||
set shadercompilecommand=shadercompile.exe
|
||||
set shadercompileworkers=140
|
||||
set x360_args=
|
||||
set ps3_args=
|
||||
set ps3_additional_args=
|
||||
set targetdir=..\..\..\game\platform\shaders
|
||||
set SrcDirBase=..\..
|
||||
set ChangeToDir=../../../game/bin
|
||||
set shaderDir=shaders
|
||||
set SDKArgs=
|
||||
set SHADERINCPATH=vshtmp9/... fxctmp9/...
|
||||
|
||||
|
||||
set DIRECTX_SDK_VER=pc09.00
|
||||
set DIRECTX_SDK_BIN_DIR=dx9sdk\utilities
|
||||
|
||||
if /i "%2" == "-x360" goto dx_sdk_x360
|
||||
if /i "%2" == "-ps3" goto dx_sdk_ps3
|
||||
if /i "%2" == "-dx9_30" goto dx_sdk_dx9_30
|
||||
if /i "%2" == "-dx10" goto dx_sdk_dx10
|
||||
goto dx_sdk_end
|
||||
:dx_sdk_x360
|
||||
set DIRECTX_SDK_VER=x360.00
|
||||
set DIRECTX_SDK_BIN_DIR=x360xdk\bin\win32
|
||||
goto dx_sdk_end
|
||||
:dx_sdk_dx9_30
|
||||
set DIRECTX_SDK_VER=pc09.30
|
||||
set DIRECTX_SDK_BIN_DIR=dx10sdk\utilities\dx9_30
|
||||
goto dx_sdk_end
|
||||
:dx_sdk_dx10
|
||||
set DIRECTX_SDK_VER=pc10.00
|
||||
set DIRECTX_SDK_BIN_DIR=dx10sdk\utilities\dx10_40
|
||||
goto dx_sdk_end
|
||||
:dx_sdk_ps3
|
||||
set DIRECTX_SDK_VER=ps3
|
||||
set DIRECTX_SDK_BIN_DIR=ps3sdk\utilities
|
||||
goto dx_sdk_end
|
||||
:dx_sdk_end
|
||||
|
||||
if "%1" == "" goto usage
|
||||
set inputbase=%1
|
||||
|
||||
if /i "%3" == "-force30" goto set_force30_arg
|
||||
goto set_force_end
|
||||
:set_force30_arg
|
||||
set DIRECTX_FORCE_MODEL=30
|
||||
goto set_force_end
|
||||
:set_force_end
|
||||
|
||||
if /i "%2" == "-x360" goto set_x360_args
|
||||
if /i "%2" == "-ps3" goto set_ps3_args
|
||||
if /i "%2" == "-game" goto set_mod_args
|
||||
if /i "%2" == "-nompi" set SDKArgs=-nompi
|
||||
goto build_shaders
|
||||
|
||||
REM ****************
|
||||
REM USAGE
|
||||
REM ****************
|
||||
:usage
|
||||
echo.
|
||||
echo "usage: buildshaders <shaderProjectName> [-ps3 or -x360 or -dx10 or -game] [gameDir if -game was specified] [-nompi if -ps3 or -x360 was specified] [-source sourceDir]"
|
||||
echo " gameDir is where gameinfo.txt is (where it will store the compiled shaders)."
|
||||
echo " sourceDir is where the source code is (where it will find scripts and compilers)."
|
||||
echo "ex : buildshaders myshaders"
|
||||
echo "ex : buildshaders myshaders -game c:\steam\steamapps\sourcemods\mymod -source c:\mymod\src"
|
||||
echo "ex : buildshaders myshaders -x360 -nompi"
|
||||
echo.
|
||||
echo "PS3 specific parameters (mutually exclusive, and must directly follow the -ps3 parameter):"
|
||||
echo "-ps3debug - Generate PS3 debug information (only do this if you have an SSD - see the wiki)"
|
||||
echo "-ps3scheduleoptimization - Find optimal fragment shader compiler scheduler settings (this takes a LONG time!)"
|
||||
goto :end
|
||||
|
||||
REM ****************
|
||||
REM X360 ARGS
|
||||
REM ****************
|
||||
:set_x360_args
|
||||
set x360_args=-x360
|
||||
set SDKArgs=
|
||||
if /i "%3" == "-nompi" set SDKArgs=-nompi
|
||||
set SHADERINCPATH=vshtmp9_360/... fxctmp9_360/...
|
||||
goto build_shaders
|
||||
|
||||
REM ****************
|
||||
REM PS3 ARGS
|
||||
REM ****************
|
||||
:set_ps3_args
|
||||
set ps3_args=-ps3
|
||||
REM PS3 does not support MPI yet
|
||||
set SDKArgs=
|
||||
if /i "%3" == "-nompi" set SDKArgs=-nompi
|
||||
if /i "%3" == "-ps3scheduleoptimization" set ps3_additional_args=-ps3optimizeschedules
|
||||
if /i "%3" == "-ps3debug" set ps3_additional_args=-ps3debug
|
||||
set SHADERINCPATH=vshtmp9_ps3/... fxctmp9_ps3/...
|
||||
goto build_shaders
|
||||
|
||||
REM ****************
|
||||
REM MOD ARGS - look for -game or the vproject environment variable
|
||||
REM ****************
|
||||
:set_mod_args
|
||||
|
||||
if not exist %sourcesdk%\bin\shadercompile.exe goto NoShaderCompile
|
||||
set ChangeToDir=%sourcesdk%\bin
|
||||
|
||||
if /i "%4" NEQ "-source" goto NoSourceDirSpecified
|
||||
set SrcDirBase=%~5
|
||||
|
||||
REM ** use the -game parameter to tell us where to put the files
|
||||
set targetdir=%~3\shaders
|
||||
set SDKArgs=-nompi -game "%~3"
|
||||
|
||||
if not exist "%~3\gameinfo.txt" goto InvalidGameDirectory
|
||||
goto build_shaders
|
||||
|
||||
REM ****************
|
||||
REM ERRORS
|
||||
REM ****************
|
||||
:InvalidGameDirectory
|
||||
echo -
|
||||
echo Error: "%~3" is not a valid game directory.
|
||||
echo (The -game directory must have a gameinfo.txt file)
|
||||
echo -
|
||||
goto end
|
||||
|
||||
:NoSourceDirSpecified
|
||||
echo ERROR: If you specify -game on the command line, you must specify -source.
|
||||
goto usage
|
||||
goto end
|
||||
|
||||
:NoShaderCompile
|
||||
echo -
|
||||
echo - ERROR: shadercompile.exe doesn't exist in %sourcesdk%\bin
|
||||
echo -
|
||||
goto end
|
||||
|
||||
REM ****************
|
||||
REM BUILD SHADERS
|
||||
REM ****************
|
||||
:build_shaders
|
||||
|
||||
rem echo --------------------------------
|
||||
rem echo %inputbase%
|
||||
rem echo --------------------------------
|
||||
REM make sure that target dirs exist
|
||||
REM files will be built in these targets and copied to their final destination
|
||||
if not exist %shaderDir% mkdir %shaderDir%
|
||||
if not exist %shaderDir%\fxc mkdir %shaderDir%\fxc
|
||||
if not exist %shaderDir%\vsh mkdir %shaderDir%\vsh
|
||||
if not exist %shaderDir%\psh mkdir %shaderDir%\psh
|
||||
REM Nuke some files that we will add to later.
|
||||
if exist filelist.txt del /f /q filelist.txt
|
||||
if exist filestocopy.txt del /f /q filestocopy.txt
|
||||
if exist filelistgen.txt del /f /q filelistgen.txt
|
||||
if exist inclist.txt del /f /q inclist.txt
|
||||
if exist vcslist.txt del /f /q vcslist.txt
|
||||
if exist makefile.%inputbase%.copy del /f /q makefile.%inputbase%.copy
|
||||
|
||||
REM ****************
|
||||
REM Revert any targets (vcs or inc) that are opened for integrate.
|
||||
REM ****************
|
||||
perl "%SrcDirBase%\devtools\bin\p4revertshadertargets.pl" %x360_args% %ps3_args% -source "%SrcDirBase%" %inputbase%
|
||||
|
||||
REM ****************
|
||||
REM Generate a makefile for the shader project
|
||||
REM ****************
|
||||
perl "%SrcDirBase%\devtools\bin\updateshaders.pl" %x360_args% %ps3_args% -source "%SrcDirBase%" %inputbase%
|
||||
|
||||
|
||||
REM ****************
|
||||
REM Run the makefile, generating minimal work/build list for fxc files, go ahead and compile vsh and psh files.
|
||||
REM ****************
|
||||
rem nmake /S /C -f makefile.%inputbase% clean > clean.txt 2>&1
|
||||
echo Building inc files, asm vcs files, and VMPI worklist for %inputbase%...
|
||||
nmake /S /C -f makefile.%inputbase%
|
||||
|
||||
REM ****************
|
||||
REM Copy the inc files to their target
|
||||
REM ****************
|
||||
if exist "inclist.txt" (
|
||||
echo Publishing shader inc files to target...
|
||||
perl %SrcDirBase%\devtools\bin\copyshaderincfiles.pl inclist.txt %x360_args% %ps3_args%
|
||||
)
|
||||
|
||||
REM ****************
|
||||
REM Deal with perforce operations for inc files
|
||||
REM ****************
|
||||
if exist inclist.txt if not "%VALVE_NO_AUTO_P4_SHADERS%" == "1" (
|
||||
echo Executing perforce operations on .inc files.
|
||||
perl ..\..\devtools\bin\p4autocheckout.pl inclist.txt "Shader Auto Checkout INC" . %SHADERINCPATH%
|
||||
)
|
||||
|
||||
REM ****************
|
||||
REM Add the executables to the worklist.
|
||||
REM ****************
|
||||
if /i "%DIRECTX_SDK_VER%" == "pc09.00" (
|
||||
rem echo "Copy extra files for dx 9 std
|
||||
echo %SrcDirBase%\..\game\bin\d3dx9_33.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\d3dx9_43.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\d3dx10_33.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\d3dx10_43.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\d3dcompiler_41.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\d3dcompiler_43.dll >> filestocopy.txt
|
||||
)
|
||||
if /i "%DIRECTX_SDK_VER%" == "pc09.30" (
|
||||
echo %SrcDirBase%\..\game\bin\d3dx9_33.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\d3dx9_43.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\d3dx10_33.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\d3dx10_43.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\d3dcompiler_41.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\d3dcompiler_43.dll >> filestocopy.txt
|
||||
)
|
||||
if /i "%DIRECTX_SDK_VER%" == "pc10.00" (
|
||||
echo %SrcDirBase%\..\game\bin\d3dx9_33.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\d3dx9_43.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\d3dx10_33.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\d3dx10_43.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\d3dcompiler_41.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\d3dcompiler_43.dll >> filestocopy.txt
|
||||
)
|
||||
if /i "%DIRECTX_SDK_VER%" == "x360.00" (
|
||||
rem echo "Copy extra files for xbox360
|
||||
)
|
||||
if /i "%DIRECTX_SDK_VER%" == "ps3" (
|
||||
echo %SrcDirBase%\ps3sdk\utilities\libcgc.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\ps3sdk\utilities\sceshaderperf.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\ps3sdk\utilities\nvshaderperf.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\ps3sdk\utilities\nvshaderperf_rsx.dll >> filestocopy.txt
|
||||
if exist "%SrcDirBase%\materialsystem\stdshaders\ps3optimalschedules.bin" echo %SrcDirBase%\materialsystem\stdshaders\ps3optimalschedules.bin >> filestocopy.txt
|
||||
if exist "%ChangeToDir%\ps3compilelog.txt" move /Y "%ChangeToDir%\ps3compilelog.txt" "%ChangeToDir%\ps3compilelog_prev.txt"
|
||||
echo ***** Start of Log >> %ChangeToDir%\ps3compilelog.txt
|
||||
)
|
||||
|
||||
echo %SrcDirBase%\%DIRECTX_SDK_BIN_DIR%\dx_proxy.dll >> filestocopy.txt
|
||||
|
||||
echo %SrcDirBase%\..\game\bin\shadercompile.exe >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\shadercompile_dll.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\vstdlib.dll >> filestocopy.txt
|
||||
echo %SrcDirBase%\..\game\bin\tier0.dll >> filestocopy.txt
|
||||
|
||||
REM ****************
|
||||
REM Cull duplicate entries in work/build list
|
||||
REM ****************
|
||||
if exist filestocopy.txt type filestocopy.txt | perl "%SrcDirBase%\devtools\bin\uniqifylist.pl" > uniquefilestocopy.txt
|
||||
if exist filelistgen.txt if not "%dynamic_shaders%" == "1" (
|
||||
echo Generating action list...
|
||||
copy filelistgen.txt filelist.txt >nul
|
||||
rem %SrcDirBase%\devtools\bin\fxccombogen.exe <filelistgen.txt 1>nul 2>filelist.txt
|
||||
)
|
||||
|
||||
REM ****************
|
||||
REM Execute distributed process on work/build list
|
||||
REM ****************
|
||||
|
||||
set shader_path_cd=%cd%
|
||||
if exist "filelist.txt" if exist "uniquefilestocopy.txt" if not "%dynamic_shaders%" == "1" (
|
||||
echo Running distributed shader compilation...
|
||||
cd %ChangeToDir%
|
||||
echo %shadercompilecommand% -mpi_workercount %shadercompileworkers% -allowdebug -shaderpath "%shader_path_cd:/=\%" %x360_args% %ps3_args% %SDKArgs% %ps3_additional_args%
|
||||
%shadercompilecommand% -mpi_workercount %shadercompileworkers% -allowdebug -shaderpath "%shader_path_cd:/=\%" %x360_args% %ps3_args% %SDKArgs% %ps3_additional_args%
|
||||
|
||||
if /i "%DIRECTX_SDK_VER%" == "ps3" (
|
||||
echo.
|
||||
echo // PS3 fragment shader statistics: =============================================
|
||||
echo // Log file location: "%ChangeToDir%\ps3compilelog.txt"
|
||||
ps3shaderoptimizer ps3compilelog.txt
|
||||
)
|
||||
|
||||
cd %shader_path_cd%
|
||||
)
|
||||
|
||||
|
||||
REM ****************
|
||||
REM PC, 360, PS3 Shader copy
|
||||
REM Publish the generated files to the output dir using ROBOCOPY (smart copy) or XCOPY
|
||||
REM This batch file may have been invoked standalone or slaved (master does final smart mirror copy)
|
||||
REM ****************
|
||||
if not "%dynamic_shaders%" == "1" (
|
||||
if exist makefile.%inputbase%.copy echo Publishing shaders to target...
|
||||
if exist makefile.%inputbase%.copy perl %SrcDirBase%\devtools\bin\copyshaders.pl makefile.%inputbase%.copy %x360_args% %ps3_args%
|
||||
)
|
||||
|
||||
REM ****************
|
||||
REM Deal with perforce operations for vcs files
|
||||
REM ****************
|
||||
if not "%dynamic_shaders%" == "1" if exist vcslist.txt if not "%VALVE_NO_AUTO_P4_SHADERS%" == "1" (
|
||||
echo Executing perforce operations on .vcs files.
|
||||
perl ..\..\devtools\bin\p4autocheckout.pl vcslist.txt "Shader Auto Checkout VCS" ../../../game/platform/shaders ../../../game/platform/shaders/...
|
||||
)
|
||||
|
||||
REM ****************
|
||||
REM END
|
||||
REM ****************
|
||||
:end
|
||||
|
||||
|
||||
%TTEXE% -diff %tt_start%
|
||||
echo.
|
||||
|
||||
129
materialsystem/stdshaders/cable_dx9.cpp
Normal file
129
materialsystem/stdshaders/cable_dx9.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose: A wet version of base * lightmap
|
||||
//
|
||||
// $Header: $
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
|
||||
#include "cable_vs20.inc"
|
||||
#include "cable_ps20.inc"
|
||||
#include "cable_ps20b.inc"
|
||||
#include "cpp_shader_constant_register_map.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DEFINE_FALLBACK_SHADER( Cable, Cable_DX9 )
|
||||
|
||||
BEGIN_VS_SHADER( Cable_DX9,
|
||||
"Help for Cable shader" )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( BUMPMAP, SHADER_PARAM_TYPE_TEXTURE, "cable/cablenormalmap", "bumpmap texture" )
|
||||
SHADER_PARAM( MINLIGHT, SHADER_PARAM_TYPE_FLOAT, "0.1", "Minimum amount of light (0-1 value)" )
|
||||
SHADER_PARAM( MAXLIGHT, SHADER_PARAM_TYPE_FLOAT, "0.3", "Maximum amount of light" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
LoadBumpMap( BUMPMAP );
|
||||
LoadTexture( BASETEXTURE, TEXTUREFLAGS_SRGB );
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
BlendType_t nBlendType = EvaluateBlendRequirements( BASETEXTURE, true );
|
||||
bool bFullyOpaque = (nBlendType != BT_BLENDADD) && (nBlendType != BT_BLEND) && !IS_FLAG_SET(MATERIAL_VAR_ALPHATEST); //dest alpha is free for special use
|
||||
|
||||
SHADOW_STATE
|
||||
{
|
||||
// Enable blending?
|
||||
if ( IS_FLAG_SET( MATERIAL_VAR_TRANSLUCENT ) )
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableBlending( true );
|
||||
pShaderShadow->BlendFunc( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
|
||||
}
|
||||
|
||||
pShaderShadow->EnableAlphaTest( IS_FLAG_SET(MATERIAL_VAR_ALPHATEST) );
|
||||
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, true );
|
||||
|
||||
int tCoordDimensions[] = {2,2};
|
||||
pShaderShadow->VertexShaderVertexFormat(
|
||||
VERTEX_POSITION | VERTEX_COLOR | VERTEX_TANGENT_S | VERTEX_TANGENT_T,
|
||||
2, tCoordDimensions, 0 );
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( cable_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( cable_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( cable_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER( cable_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( cable_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER( cable_ps20 );
|
||||
}
|
||||
|
||||
// we are writing linear values from this shader.
|
||||
// This is kinda wrong. We are writing linear or gamma depending on "IsHDREnabled" below.
|
||||
// The COLOR really decides if we are gamma or linear.
|
||||
pShaderShadow->EnableSRGBWrite( true );
|
||||
|
||||
FogToFogColor();
|
||||
|
||||
pShaderShadow->EnableAlphaWrites( bFullyOpaque );
|
||||
}
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
bool bLightingOnly = g_pConfig->nFullbright == 2 && !IS_FLAG_SET( MATERIAL_VAR_NO_DEBUG_OVERRIDE );
|
||||
|
||||
BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, BUMPMAP );
|
||||
if ( bLightingOnly )
|
||||
{
|
||||
pShaderAPI->BindStandardTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_SRGBREAD, TEXTURE_GREY );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_SRGBREAD, BASETEXTURE );
|
||||
}
|
||||
|
||||
pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS );
|
||||
|
||||
float vEyePos_SpecExponent[4];
|
||||
pShaderAPI->GetWorldSpaceCameraPosition( vEyePos_SpecExponent );
|
||||
vEyePos_SpecExponent[3] = 0.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 );
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( cable_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( cable_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( cable_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bFullyOpaque && pShaderAPI->ShouldWriteDepthToDestAlpha() );
|
||||
SET_DYNAMIC_PIXEL_SHADER( cable_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( cable_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( cable_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
52
materialsystem/stdshaders/cable_ps2x.fxc
Normal file
52
materialsystem/stdshaders/cable_ps2x.fxc
Normal file
@@ -0,0 +1,52 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
#include "common_fog_ps_fxc.h"
|
||||
// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC]
|
||||
// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX]
|
||||
|
||||
#if defined( SHADER_MODEL_PS_2_0 )
|
||||
# define WRITE_DEPTH_TO_DESTALPHA 0
|
||||
#endif
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
#include "shader_constant_register_map.h"
|
||||
|
||||
sampler NormalSampler : register( s0 );
|
||||
sampler BaseTextureSampler : register( s1 );
|
||||
|
||||
const float4 g_FogParams : register( PSREG_FOG_PARAMS );
|
||||
const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord0 : TEXCOORD0;
|
||||
float2 vTexCoord1 : TEXCOORD1;
|
||||
|
||||
float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
|
||||
|
||||
float4 directionalLightColor : COLOR0;
|
||||
};
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float3 vNormalMapDir = tex2D( NormalSampler, i.vTexCoord0 ); // Get the 3-vector from the normal map
|
||||
float4 textureColor = tex2D( BaseTextureSampler, i.vTexCoord1 ); // Interpret tcoord t1 as color data.
|
||||
|
||||
//Expand compacted vectors
|
||||
//TODO: find if there's a better way to expand a color normal to a full vector ( _bx2 was used in the assembly code )
|
||||
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.directionalLightColor.rgb );
|
||||
resultColor.a = textureColor.a * i.directionalLightColor.a;
|
||||
|
||||
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_LINEAR, (WRITE_DEPTH_TO_DESTALPHA != 0), i.worldPos_projPosZ.w );
|
||||
}
|
||||
74
materialsystem/stdshaders/cable_vs20.fxc
Normal file
74
materialsystem/stdshaders/cable_vs20.fxc
Normal file
@@ -0,0 +1,74 @@
|
||||
#include "common_fog_vs_fxc.h"
|
||||
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
static const int g_FogType = DOWATERFOG;
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION;
|
||||
float2 vTexCoord0 : TEXCOORD0;
|
||||
float2 vTexCoord1 : TEXCOORD1;
|
||||
|
||||
float4 directionalLightColor : COLOR0;
|
||||
|
||||
float3 vTangentS : TANGENT;
|
||||
float3 vTangentT : BINORMAL;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord0 : TEXCOORD0;
|
||||
float2 vTexCoord1 : TEXCOORD1;
|
||||
|
||||
float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
|
||||
|
||||
float4 directionalLightColor : COLOR0;
|
||||
|
||||
#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
|
||||
float fog : FOG;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
float3 worldPos;
|
||||
worldPos = mul( v.vPos, cModel[0] );
|
||||
o.vProjPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
o.worldPos_projPosZ = float4( worldPos.xyz, o.vProjPos.z );
|
||||
|
||||
#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 )
|
||||
o.fog = CalcFixedFunctionFog( worldPos, g_FogType );
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Setup the tangent space
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Get S crossed with T (call it R)
|
||||
float3 r = cross( v.vTangentS, v.vTangentT );
|
||||
|
||||
// Normalize S (into s)
|
||||
float3 s = normalize( v.vTangentS );
|
||||
|
||||
// Normalize R (into r)
|
||||
r = normalize( r );
|
||||
|
||||
// Regenerate T (into t)
|
||||
float3 t = cross( r, v.vTangentS );
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Copy texcoords for the normal map and base texture
|
||||
//------------------------------------------------------------------------------
|
||||
o.vTexCoord0 = v.vTexCoord0;
|
||||
o.vTexCoord1 = v.vTexCoord1;
|
||||
|
||||
// Pass the dirlight color through
|
||||
o.directionalLightColor = v.directionalLightColor;
|
||||
|
||||
return o;
|
||||
}
|
||||
1243
materialsystem/stdshaders/character.cpp
Normal file
1243
materialsystem/stdshaders/character.cpp
Normal file
File diff suppressed because it is too large
Load Diff
740
materialsystem/stdshaders/character_ps20b.fxc
Normal file
740
materialsystem/stdshaders/character_ps20b.fxc
Normal file
@@ -0,0 +1,740 @@
|
||||
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
||||
|
||||
// STATIC: "MASKS1" "0..1"
|
||||
// STATIC: "MASKS2" "0..1"
|
||||
// STATIC: "FRESNELRANGESTEXTURE" "0..1"
|
||||
// STATIC: "PHONGWARPTEXTURE" "0..1" [ps30]
|
||||
// STATIC: "ENVMAP" "0..1"
|
||||
// STATIC: "AMBIENTREFLECTION" "0..1"
|
||||
// STATIC: "USEBOUNCECOLOR" "0..1" [ps30]
|
||||
// STATIC: "ANISOTROPY" "0..1" [ps30]
|
||||
// STATIC: "BASEALPHAPHONGMASK" "0..1" [ps30]
|
||||
// STATIC: "BASEALPHAENVMASK" "0..1"
|
||||
// STATIC: "BUMPALPHAENVMASK" "0..1"
|
||||
// STATIC: "SHADOWSATURATION" "0..1" [ps30]
|
||||
// STATIC: "BASEALPHASELFILLUMMASK" "0..1"
|
||||
// STATIC: "FAKERIM" "0..1"
|
||||
// STATIC: "CASCADED_SHADOW_MAPPING" "0..1" [ps30]
|
||||
// STATIC: "CSM_MODE" "0..3" [ps30]
|
||||
// STATIC: "DOPREVIEW" "0..1"
|
||||
// STATIC: "USEPATTERN" "0..4"
|
||||
// STATIC: "FLASHLIGHT" "0..1"
|
||||
// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..3"
|
||||
|
||||
// DYNAMIC: "NUM_LIGHTS" "0..4" [ps30]
|
||||
// DYNAMIC: "DYN_CSM_ENABLED" "0..1"
|
||||
// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0"
|
||||
// DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1"
|
||||
|
||||
#include "common_fog_ps_fxc.h"
|
||||
|
||||
// SKIP: ( $AMBIENTREFLECTION == 0 ) && ( $USEBOUNCECOLOR == 1 )
|
||||
// SKIP: ( $BASEALPHAENVMASK == 1 ) && ( $ENVMAP == 0 )
|
||||
// SKIP: ( $BUMPALPHAENVMASK == 1 ) && ( $ENVMAP == 0 )
|
||||
// SKIP: ( $BASEALPHAENVMASK == 1 ) && ( $BUMPALPHAENVMASK == 1 )
|
||||
// SKIP: ( $BASEALPHASELFILLUMMASK == 1) && ( $BASEALPHAENVMASK == 1 )
|
||||
// SKIP: ( $BASEALPHASELFILLUMMASK == 1) && ( $BASEALPHAPHONGMASK == 1 )
|
||||
// SKIP: ( $BASEALPHAENVMASK == 1 ) && ( $BASEALPHASELFILLUMMASK )
|
||||
// SKIP: ( $CASCADED_SHADOW_MAPPING == 0 ) && ( $DYN_CSM_ENABLED == 1 )
|
||||
// SKIP: ( $CASCADED_SHADOW_MAPPING == 0 ) && ( $CSM_MODE != 0 )
|
||||
// SKIP: ( $DOPREVIEW == 0 ) && ( $USEPATTERN != 0 )
|
||||
// SKIP: ( $DOPREVIEW == 1 ) && ( $USEBOUNCECOLOR == 1 )
|
||||
// SKIP: ( $DOPREVIEW == 1 ) && ( $BASEALPHASELFILLUMMASK == 1)
|
||||
// SKIP: ( $DOPREVIEW == 1 ) && ( $FAKERIM == 1 )
|
||||
// SKIP: ( $DOPREVIEW == 1 ) && ( $CSM_MODE > 0 )
|
||||
// SKIP: ( $DOPREVIEW == 1 ) && ( $DYN_CSM_ENALBED == 1 )
|
||||
// SKIP: ( $DOPREVIEW == 1 ) && ( $NUM_LIGHTS > 1 )
|
||||
// SKIP: ( $DOPREVIEW == 1 ) && ( $FLASHLIGHT == 1 )
|
||||
// SKIP: ( $CASCADED_SHADOW_MAPPING > 0) && ( $FLASHLIGHT == 1 )
|
||||
// SKIP: ( $DYN_CSM_ENALBED == 1 ) && ( $FLASHLIGHT == 1 )
|
||||
// SKIP: ( $CSM_MODE > 0 ) && ( $FLASHLIGHT == 1 )
|
||||
// SKIP: ( $FLASHLIGHTDEPTHFILTERMODE > 0 ) && ( $FLASHLIGHT == 0 )
|
||||
// SKIP: ( $FLASHLIGHT == 1 ) && ( $FAKERIM == 1 )
|
||||
|
||||
#define PHONG 1
|
||||
#define RIMLIGHT 1
|
||||
#define BUMPMAP 1
|
||||
#define HALFLAMBERT 0
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
#include "shader_constant_register_map.h"
|
||||
|
||||
#if ( DOPREVIEW == 1 )
|
||||
#define GENERATEBASETEXTURE 1
|
||||
#if ( BUMPMAP == 1 )
|
||||
#define GENERATENORMAL 1
|
||||
#endif
|
||||
#if( MASKS1 == 1 )
|
||||
#define GENERATEMASKS1 1
|
||||
#endif
|
||||
#define CHEAPFILTERING 1
|
||||
#include "custom_character_fxc.h"
|
||||
#endif
|
||||
|
||||
sampler BaseTextureSampler : register( s0 );
|
||||
sampler NormalMapSampler : register( s1 );
|
||||
#if ( DOPREVIEW == 1 )
|
||||
sampler Masks1Sampler : register( s2 );
|
||||
#else
|
||||
sampler Masks1Sampler : register( s10 );
|
||||
#endif
|
||||
sampler Masks2Sampler : register( s3 );
|
||||
sampler FresnelRangesSampler : register( s4 );
|
||||
sampler NormalizeSampler : register( s5 );
|
||||
sampler EnvmapSampler : register( s6 );
|
||||
sampler PhongWarpSampler : register( s7 );
|
||||
|
||||
|
||||
#if ( FLASHLIGHT == 1 )
|
||||
#include "common_flashlight_fxc.h"
|
||||
sampler FlashlightSampler : register( s8 );
|
||||
sampler ShadowDepthSampler : register( s11 );
|
||||
#else
|
||||
sampler CSMDepthAtlasSampler : register( s8 );
|
||||
#endif
|
||||
|
||||
//#undef CASCADED_SHADOW_MAPPING
|
||||
//#define CASCADED_SHADOW_MAPPING 1
|
||||
|
||||
#if ( CASCADED_SHADOW_MAPPING == 1 )
|
||||
#define CASCADE_SIZE 3
|
||||
#define CSM_ENABLED 1
|
||||
#include "csm_common_fxc.h"
|
||||
#endif
|
||||
|
||||
const float4 g_vBounceTerms : register( c0 );
|
||||
#define g_cBounce g_vBounceTerms.rgb
|
||||
#define g_fAmbientBounceBoost g_vBounceTerms.w
|
||||
|
||||
const float4 g_vDiffuseModulation : register( c1 );
|
||||
|
||||
const float4 g_vDiffuseTerms : register( c101 );
|
||||
#define g_fEnvmapLightScale g_vDiffuseTerms.x
|
||||
#define g_fShadowSaturation g_vDiffuseTerms.y
|
||||
#define g_fMetalness g_vDiffuseTerms.z
|
||||
#define g_fRimLightAlbedo g_vDiffuseTerms.w
|
||||
|
||||
const float4 g_vShadowSaturationBounds : register( c2 );
|
||||
const float3 g_vEyePos : register( c3 );
|
||||
|
||||
const float3 g_cAmbientCube[6] : register( PSREG_AMBIENT_CUBE ); // (c4-c9)
|
||||
|
||||
const float4 g_vPhongTerms : register( c10 );
|
||||
#define g_fPhongBoost g_vPhongTerms.x
|
||||
#define g_fPhongAlbedoBoost g_vPhongTerms.y
|
||||
#define g_fPhongExponent g_vPhongTerms.z
|
||||
#define g_fAnisotropyAmount g_vPhongTerms.w
|
||||
|
||||
const float4 g_vPhongTint_ShadowRimBoost : register( c11 );
|
||||
#define g_cPhongTint g_vPhongTint_ShadowRimBoost.rgb
|
||||
#define g_fShadowRimBoost g_vPhongTint_ShadowRimBoost.w
|
||||
|
||||
const float3 g_vFresnelRanges : register( c12 );
|
||||
const float4 g_cShadowTint : register( c102 );
|
||||
|
||||
const float4 g_vEnvmapTerm : register( c103 );
|
||||
#define g_vEnvmapLightScaleMin g_vEnvmapTerm.xxx
|
||||
#define g_vEnvmapLightScaleMax g_vEnvmapTerm.yyy
|
||||
#define g_fEnvmapContrast g_vEnvmapTerm.z
|
||||
#define g_fEnvmapSaturation g_vEnvmapTerm.w
|
||||
|
||||
const float3 g_cEnvmapTint : register( c104 );
|
||||
|
||||
const float4 g_vRimTerms_SelfIllumTerms : register( c105 );
|
||||
#define g_fRimLightExponent g_vRimTerms_SelfIllumTerms.x
|
||||
#define g_fRimLightBoost g_vRimTerms_SelfIllumTerms.y
|
||||
#define g_fSelfIllumBoost g_vRimTerms_SelfIllumTerms.z
|
||||
#define g_fWarpIndex g_vRimTerms_SelfIllumTerms.w
|
||||
|
||||
const float4 g_cRimLightTint_fRimHaloBoost : register( c106 );
|
||||
#define g_cRimLightTint g_cRimLightTint_fRimHaloBoost.xyz
|
||||
#define g_fRimHaloBoost g_cRimLightTint_fRimHaloBoost.w
|
||||
|
||||
|
||||
const float4 g_vFakeRimTint_ShadowScale : register( c107 );
|
||||
#define g_cFakeRimTint g_vFakeRimTint_ShadowScale.rgb
|
||||
#define g_fShadowScale g_vFakeRimTint_ShadowScale.w
|
||||
|
||||
const float4 g_FogParams : register( c19 );
|
||||
|
||||
PixelShaderLightInfo g_cLightInfo[3] : register( PSREG_LIGHT_INFO_ARRAY ); // (c20-c25)
|
||||
|
||||
const float4 g_vRimHaloBounds : register( c33 );
|
||||
|
||||
//const float4 cFlashlightColor : register( PSREG_FLASHLIGHT_COLOR ); // c28 - 31
|
||||
const float4 g_FlashlightAttenuationFactors : register( PSREG_FLASHLIGHT_ATTENUATION );
|
||||
const float4 g_FlashlightPos_RimBoost : register( PSREG_FLASHLIGHT_POSITION_RIM_BOOST );
|
||||
#define g_FlashlightPos g_FlashlightPos_RimBoost.xyz
|
||||
const float4x4 g_FlashlightWorldToTexture : register( PSREG_FLASHLIGHT_TO_WORLD_TEXTURE );
|
||||
const float4 g_vShadowTweaks : register( c109 );
|
||||
|
||||
#define g_fRetroReflectivityBoost 5.0f
|
||||
#define g_fRetroReflectivityPower 4.0f
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 vTexCoord0 : TEXCOORD0;
|
||||
float4 lightAtten : TEXCOORD1;
|
||||
float4 tangentSpaceTranspose0_FakeRimx : TEXCOORD2; // when flashlight is on, the .w components
|
||||
float4 tangentSpaceTranspose1_FakeRimy : TEXCOORD3; // hold the projection position
|
||||
float4 tangentSpaceTranspose2_FakeRimz : TEXCOORD4; // instead of rim params
|
||||
float4 vWorldPos_projZ : TEXCOORD5;
|
||||
float4 cAmbient_fRimBoost : TEXCOORD6;
|
||||
#if defined( SHADER_MODEL_PS_3_0 )
|
||||
float4 vWorldTangentS_vBounceCenterx : TEXCOORD7;
|
||||
float4 vWorldTangentT_vBounceCentery : TEXCOORD8;
|
||||
float4 vBounceCenterDir_vBounceCenterz : TEXCOORD9;
|
||||
#endif
|
||||
};
|
||||
|
||||
float3 saturateColor( float3 c1, float fsat )
|
||||
{
|
||||
float3 finalColor = c1;
|
||||
|
||||
if ( fsat != 0 )
|
||||
{
|
||||
|
||||
// perceptual luminance
|
||||
float3 lum = float3( 0.299, 0.587, 0.114 );
|
||||
|
||||
float3 c2 = pow( c1, 4 );
|
||||
float luminance1 = dot( c1, lum );
|
||||
|
||||
if ( fsat < 0 )
|
||||
{
|
||||
finalColor = lerp( c1, luminance1, -fsat );
|
||||
}
|
||||
else
|
||||
{
|
||||
float luminance2 = dot( c2, lum );
|
||||
luminance2 = max( luminance2, 0.000001f );
|
||||
c2 = c2 * luminance1 / luminance2;
|
||||
finalColor = lerp( c1, c2, fsat );
|
||||
}
|
||||
}
|
||||
return finalColor;
|
||||
}
|
||||
|
||||
float3 tintColor( float3 c1, float3 tint, float amt )
|
||||
{
|
||||
// perceptual luminance
|
||||
float3 lum = float3( 0.299, 0.587, 0.114 );
|
||||
|
||||
float3 c2 = tint;
|
||||
float luminance1 = dot( c1, lum );
|
||||
float luminance2 = dot( c2, lum );
|
||||
luminance2 = max( luminance2, 0.000001f );
|
||||
c2 = c2 * luminance1 / luminance2 ;
|
||||
return lerp( c1, c2, amt );
|
||||
}
|
||||
|
||||
void CharacterSpecularAndRimTerms( const float3 vWorldNormal, const float3 vLightDir, const float fSpecularExponent, const float3 vEyeDir,
|
||||
const bool bDoSpecularWarp, in sampler specularWarpSampler,
|
||||
const float3 color, const bool bDoRimLighting, const float fRimExponent, const float fWarpIndex,
|
||||
const bool bDoAnisotropy, const float fAnisoAmount, const float VdotT, const float sVdotT, const float vTangent,
|
||||
const bool bDoRetroReflectivity, const float fRetroReflectivityAmount, const float fRetroReflectivityFresnel,
|
||||
|
||||
// Outputs
|
||||
out float3 specularLighting, out float3 rimLighting, out float rimHalo )
|
||||
{
|
||||
float3 vHalfAngle = normalize( vEyeDir.xyz + vLightDir.xyz );
|
||||
float flNDotH = saturate( dot( vWorldNormal.xyz, vHalfAngle.xyz ) );
|
||||
float flNDotL = saturate( dot( vWorldNormal, vLightDir ) );
|
||||
specularLighting = float3( 0.0f, 0.0f, 0.0f );
|
||||
|
||||
if ( bDoAnisotropy )
|
||||
{
|
||||
float LdotT = dot( vLightDir, vTangent );
|
||||
float sLdotT = sqrt( 1 - LdotT * LdotT );
|
||||
|
||||
float anisotropicSpecular = saturate( VdotT * LdotT + sVdotT * sLdotT );
|
||||
/*if ( bDoSpecularWarp )
|
||||
{
|
||||
anisotropicSpecular = pow( anisotropicSpecular, 16.0f ); // need to raise it to a power to keep anisotropic feel, otherwise the falloff is too abrupt
|
||||
}*/
|
||||
flNDotH = lerp( flNDotH, anisotropicSpecular, fAnisoAmount );
|
||||
}
|
||||
|
||||
// Optionally warp as function of scalar specular
|
||||
if ( bDoSpecularWarp )
|
||||
{
|
||||
specularLighting = tex2D( specularWarpSampler, float2( flNDotH, fWarpIndex ) ).rgb;
|
||||
}
|
||||
else
|
||||
{
|
||||
specularLighting = pow( flNDotH, fSpecularExponent );
|
||||
}
|
||||
|
||||
if ( bDoRetroReflectivity )
|
||||
{
|
||||
float flVDotL = saturate( dot( vEyeDir.xyz, vLightDir.xyz ) );
|
||||
specularLighting = lerp( specularLighting, fRetroReflectivityFresnel * flVDotL * g_fRetroReflectivityBoost, fRetroReflectivityAmount );
|
||||
}
|
||||
|
||||
specularLighting *= pow( flNDotL, 0.5 );
|
||||
specularLighting *= color; // Modulate with light color
|
||||
|
||||
// Optionally do rim lighting
|
||||
rimLighting = float3( 0.0, 0.0, 0.0 );
|
||||
rimHalo = 0;
|
||||
if ( bDoRimLighting )
|
||||
{
|
||||
float flNDotV = 1.0f - saturate( dot( vWorldNormal.xyz, vEyeDir.xyz ) );
|
||||
|
||||
rimHalo = flNDotH * flNDotL;
|
||||
rimHalo *= pow( flNDotV, fRimExponent );
|
||||
rimHalo *= pow( flNDotL, 0.5 );
|
||||
|
||||
rimLighting = rimHalo * color;
|
||||
}
|
||||
}
|
||||
|
||||
void CharacterDoSpecularLighting( const float3 worldPos, const float3 vWorldNormal, const float fSpecularExponent, const float3 vEyeDir,
|
||||
const float4 lightAtten, const int nNumLights, PixelShaderLightInfo cLightInfo[3],
|
||||
const bool bDoSpecularWarp, in sampler specularWarpSampler,
|
||||
const bool bDoRimLighting, const float fRimExponent, const float flDirectShadow, const float fWarpIndex,
|
||||
const bool bDoAnisotropy, const float fAnisoAmount, const float fAnisotropyAngle,
|
||||
const float3 vTangent,
|
||||
const bool bDoRetroReflectivity, const float fRetroReflectivityAmount, const float3 ambient,
|
||||
|
||||
// Outputs
|
||||
out float3 specularLighting, out float3 rimLighting, out float rimHalo )
|
||||
{
|
||||
specularLighting = rimLighting = float3( 0.0f, 0.0f, 0.0f );
|
||||
rimHalo = 0.0f;
|
||||
float3 localSpecularTerm, localRimTerm = float3( 0.0f, 0.0f, 0.0f );
|
||||
float localRimHalo = 0.0f;
|
||||
float flVDotN = 0.0f;
|
||||
if ( bDoRetroReflectivity )
|
||||
{
|
||||
flVDotN = saturate( dot( vWorldNormal.xyz, vEyeDir.xyz ) );
|
||||
flVDotN = pow( flVDotN, g_fRetroReflectivityPower );
|
||||
specularLighting += fRetroReflectivityAmount * flVDotN * ambient * g_fRetroReflectivityBoost;
|
||||
}
|
||||
|
||||
float VdotT = 1;
|
||||
float sVdotT = 1;
|
||||
if ( bDoAnisotropy )
|
||||
{
|
||||
|
||||
VdotT = dot( vEyeDir, vTangent );
|
||||
sVdotT = sqrt( 1 - VdotT * VdotT );
|
||||
}
|
||||
|
||||
if( nNumLights > 0 )
|
||||
{
|
||||
// First local light will always be forced to a directional light in CS:GO (see CanonicalizeMaterialLightingState() in shaderapidx8.cpp) - it may be completely black.
|
||||
CharacterSpecularAndRimTerms( vWorldNormal, PixelShaderGetLightVector( worldPos, cLightInfo, 0 ), fSpecularExponent, vEyeDir,
|
||||
bDoSpecularWarp, specularWarpSampler, PixelShaderGetLightColor( cLightInfo, 0 ) * lightAtten[0],
|
||||
bDoRimLighting, fRimExponent, fWarpIndex,
|
||||
bDoAnisotropy, fAnisoAmount, VdotT, sVdotT, vTangent,
|
||||
bDoRetroReflectivity, fRetroReflectivityAmount, flVDotN,
|
||||
localSpecularTerm, localRimTerm, localRimHalo );
|
||||
|
||||
|
||||
specularLighting += localSpecularTerm * flDirectShadow; // Accumulate specular and rim terms
|
||||
rimLighting += localRimTerm * flDirectShadow;
|
||||
rimHalo += localRimHalo;
|
||||
}
|
||||
|
||||
if( nNumLights > 1 )
|
||||
{
|
||||
CharacterSpecularAndRimTerms( vWorldNormal, PixelShaderGetLightVector( worldPos, cLightInfo, 1 ), fSpecularExponent, vEyeDir,
|
||||
bDoSpecularWarp, specularWarpSampler, PixelShaderGetLightColor( cLightInfo, 1 ) * lightAtten[1],
|
||||
bDoRimLighting, fRimExponent, fWarpIndex,
|
||||
bDoAnisotropy, fAnisoAmount, VdotT, sVdotT, vTangent,
|
||||
bDoRetroReflectivity, fRetroReflectivityAmount, flVDotN,
|
||||
localSpecularTerm, localRimTerm, localRimHalo );
|
||||
|
||||
specularLighting += localSpecularTerm; // Accumulate specular and rim terms
|
||||
rimLighting += localRimTerm;
|
||||
rimHalo += localRimHalo;
|
||||
}
|
||||
|
||||
|
||||
if( nNumLights > 2 )
|
||||
{
|
||||
CharacterSpecularAndRimTerms( vWorldNormal, PixelShaderGetLightVector( worldPos, cLightInfo, 2 ), fSpecularExponent, vEyeDir,
|
||||
bDoSpecularWarp, specularWarpSampler, PixelShaderGetLightColor( cLightInfo, 2 ) * lightAtten[2],
|
||||
bDoRimLighting, fRimExponent, fWarpIndex,
|
||||
bDoAnisotropy, fAnisoAmount, VdotT, sVdotT, vTangent,
|
||||
bDoRetroReflectivity, fRetroReflectivityAmount, flVDotN,
|
||||
localSpecularTerm, localRimTerm, localRimHalo );
|
||||
|
||||
specularLighting += localSpecularTerm; // Accumulate specular and rim terms
|
||||
rimLighting += localRimTerm;
|
||||
rimHalo += localRimHalo;
|
||||
}
|
||||
|
||||
if( nNumLights > 3 )
|
||||
{
|
||||
CharacterSpecularAndRimTerms( vWorldNormal, PixelShaderGetLightVector( worldPos, cLightInfo, 3 ), fSpecularExponent, vEyeDir,
|
||||
bDoSpecularWarp, specularWarpSampler, PixelShaderGetLightColor( cLightInfo, 3 ) * lightAtten[3],
|
||||
bDoRimLighting, fRimExponent, fWarpIndex,
|
||||
bDoAnisotropy, fAnisoAmount, VdotT, sVdotT, vTangent,
|
||||
bDoRetroReflectivity, fRetroReflectivityAmount, flVDotN,
|
||||
localSpecularTerm, localRimTerm, localRimHalo );
|
||||
|
||||
specularLighting += localSpecularTerm; // Accumulate specular and rim terms
|
||||
rimLighting += localRimTerm;
|
||||
rimHalo += localRimHalo;
|
||||
}
|
||||
}
|
||||
|
||||
float3 desaturateColor( float3 c1 )
|
||||
{
|
||||
// perceptual luminance
|
||||
float3 lum = float3( 0.299, 0.587, 0.114 );
|
||||
|
||||
|
||||
return dot( c1, lum );
|
||||
}
|
||||
|
||||
|
||||
// ======================= MAIN ======================= //
|
||||
float4_color_return_type main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4 vBaseTextureSample = tex2D( BaseTextureSampler, i.vTexCoord0.xy );
|
||||
#if ( MASKS1 )
|
||||
float4 vMasks1Params = tex2D( Masks1Sampler, i.vTexCoord0.xy );
|
||||
#else
|
||||
float4 vMasks1Params = float4( 1.0f, 0.0f, 1.0f, 0.0f );
|
||||
#endif
|
||||
#if ( BUMPMAP )
|
||||
float4 vNormalSample = tex2D( NormalMapSampler, i.vTexCoord0.xy );
|
||||
#else
|
||||
float4 vNormalSample = float4( 0.0f, 0.0f, 1.0f, 1.0f );
|
||||
#endif
|
||||
#if ( DOPREVIEW )
|
||||
customizeCharacter( i.vTexCoord0.xy, vBaseTextureSample, vNormalSample, vMasks1Params );
|
||||
#endif
|
||||
float fAlpha = vBaseTextureSample.a;
|
||||
float3 cBase = vBaseTextureSample.rgb;
|
||||
float fSpecMask = 1.0f;
|
||||
float fEnvMask = 1.0f;
|
||||
float fSelfIllumMask = 0.0f;
|
||||
#if ( BASEALPHAPHONGMASK == 1 )
|
||||
fSpecMask = vBaseTextureSample.a;
|
||||
fAlpha = 1.0f;
|
||||
#endif
|
||||
#if ( BASEALPHAENVMASK == 1 )
|
||||
fEnvMask = vBaseTextureSample.a;
|
||||
fAlpha = 1.0f;
|
||||
#endif
|
||||
#if ( BASEALPHASELFILLUMMASK == 1 )
|
||||
fSelfIllumMask = vBaseTextureSample.a;
|
||||
#endif
|
||||
|
||||
float fRimMask = 1.0f;
|
||||
float fMetalnessMask = 1.0f;
|
||||
float fPhongAlbedoMask = 0.0f;
|
||||
float fWarpIndex = g_fWarpIndex;
|
||||
#if ( MASKS1 )
|
||||
{
|
||||
fRimMask = vMasks1Params.r;
|
||||
fPhongAlbedoMask = vMasks1Params.g;
|
||||
fMetalnessMask = vMasks1Params.b;
|
||||
fWarpIndex = vMasks1Params.a;
|
||||
}
|
||||
#else
|
||||
fMetalnessMask = g_fMetalness;
|
||||
#endif
|
||||
|
||||
float3 vTangentNormal = float3( 0.0f, 0.0f, 1.0f );
|
||||
#if ( BUMPMAP )
|
||||
{
|
||||
vTangentNormal = vNormalSample.xyz * 2.0f - 1.0f;
|
||||
#if ( BASEALPHAPHONGMASK == 0 )
|
||||
fSpecMask = vNormalSample.a;
|
||||
#endif
|
||||
#if ( BUMPALPHAENVMASK )
|
||||
fEnvMask = vNormalSample.a;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
float3x3 mTangentSpaceTranspose = float3x3( i.tangentSpaceTranspose0_FakeRimx.xyz, i.tangentSpaceTranspose1_FakeRimy.xyz, i.tangentSpaceTranspose2_FakeRimz.xyz );
|
||||
float3 vWorldNormal = normalize( mul( mTangentSpaceTranspose, vTangentNormal ) );
|
||||
float3 vEyeDir = normalize( g_vEyePos - i.vWorldPos_projZ.xyz );
|
||||
|
||||
#if ( FRESNELRANGESTEXTURE )
|
||||
float fFresnel = saturate( dot( vEyeDir, vWorldNormal ) );
|
||||
|
||||
float3 vFresnelParams = tex2D( FresnelRangesSampler, float2( fFresnel, fWarpIndex ) );
|
||||
fFresnel = vFresnelParams.y;
|
||||
float fAmbientReflectionMask = vFresnelParams.z * fRimMask;
|
||||
#else
|
||||
float fFresnel = Fresnel( vWorldNormal, vEyeDir, g_vFresnelRanges );
|
||||
float fAmbientReflectionMask = fFresnel * fRimMask;
|
||||
#endif
|
||||
|
||||
float fCSMShadow = 1.0f;
|
||||
#if ( CASCADED_SHADOW_MAPPING && DYN_CSM_ENABLED ) && defined( SHADER_MODEL_PS_3_0 )
|
||||
fCSMShadow = CSMComputeShadowing( i.vWorldPos_projZ.xyz );
|
||||
#endif
|
||||
|
||||
float3 linearLightColor = PixelShaderDoLighting( i.vWorldPos_projZ.xyz, vWorldNormal,
|
||||
float3( 0.0f, 0.0f, 0.0f), false,
|
||||
true, i.lightAtten, g_cAmbientCube,
|
||||
NormalizeSampler, NUM_LIGHTS, g_cLightInfo, ( HALFLAMBERT == 1 ),
|
||||
false, NULL, fCSMShadow );
|
||||
|
||||
float fShadowSaturationMask = 1.0f;
|
||||
float fAnisotropyAmount = g_fAnisotropyAmount;
|
||||
float fAnisotropyAngle = 1.57;
|
||||
|
||||
float fRetroReflectivityMask = 0.0f;
|
||||
float fEnvmapLightScale = g_fEnvmapLightScale;
|
||||
#if ( MASKS2 )
|
||||
float4 vMasks2Params = tex2D( Masks2Sampler, i.vTexCoord0.xy );
|
||||
fShadowSaturationMask *= vMasks2Params.x;
|
||||
fAnisotropyAmount *= ( vMasks2Params.g > 0 );
|
||||
fAnisotropyAngle = vMasks2Params.g * 3.14159;
|
||||
fEnvmapLightScale *= vMasks2Params.b;
|
||||
fRetroReflectivityMask = 1.0f - vMasks2Params.a;
|
||||
#endif
|
||||
|
||||
float3 cSpecularLight = float3( 0.0f, 0.0f, 0.0f );
|
||||
float3 cRimLight = float3( 0.0f, 0.0f, 0.0f );
|
||||
float3 cAdditiveRimlight = float3( 0.0f, 0.0f, 0.0f );
|
||||
float3 vTangent = float3( 0.0f, 0.0f, 0.0f );
|
||||
float3 vReflectionEyeVec = vEyeDir;
|
||||
float fRimHalo = 0;
|
||||
|
||||
#if ( FLASHLIGHT )
|
||||
float4 flashlightSpacePosition = TransformFlashlightWorldToTexture( i.vWorldPos_projZ.xyz, g_FlashlightWorldToTexture );
|
||||
float3 vProjPos = float3( i.tangentSpaceTranspose0_FakeRimx.w, i.tangentSpaceTranspose1_FakeRimy.w, i.tangentSpaceTranspose2_FakeRimz.w );
|
||||
float3 vProjCoords = flashlightSpacePosition.xyz / flashlightSpacePosition.w;
|
||||
float2 vScreenPos = vProjPos.xy / vProjPos.z;
|
||||
bool bShadows = true;
|
||||
|
||||
linearLightColor += DoFlashlight( g_FlashlightPos, i.vWorldPos_projZ.xyz, flashlightSpacePosition, vWorldNormal,
|
||||
g_FlashlightAttenuationFactors.xyz, g_FlashlightAttenuationFactors.w, FlashlightSampler, ShadowDepthSampler,
|
||||
NormalizeSampler, FLASHLIGHTDEPTHFILTERMODE, bShadows,
|
||||
vProjCoords.xy, false, g_vShadowTweaks, true );
|
||||
|
||||
#if ( PHONG )
|
||||
float3 cSpecularFlashlight = float3( 0.0f, 0.0f, 0.0f );
|
||||
float3 flashlightColor = tex2D( FlashlightSampler, vProjCoords.xy ).rgb;
|
||||
flashlightColor *= flashlightSpacePosition.www > float3(0,0,0);
|
||||
float3 vFlashlightDir = g_FlashlightPos - i.vWorldPos_projZ.xyz;
|
||||
float distSquared = dot( vFlashlightDir, vFlashlightDir );
|
||||
float dist = sqrt( distSquared );
|
||||
float fAtten = saturate( dot( g_FlashlightAttenuationFactors.xyz, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) );
|
||||
vFlashlightDir = normalize( vFlashlightDir );
|
||||
float endFalloffFactor = RemapNormalizedValClamped( dist, g_FlashlightAttenuationFactors.w, 0.6f * g_FlashlightAttenuationFactors.w );
|
||||
flashlightColor *= fAtten * endFalloffFactor * cFlashlightColor;
|
||||
float VdotT = 0;
|
||||
float sVdotT = 0;
|
||||
float NdotL = dot( vFlashlightDir, vWorldNormal );
|
||||
|
||||
if ( bShadows )
|
||||
{
|
||||
float flShadow = DoFlashlightShadow( ShadowDepthSampler, NormalizeSampler, vProjCoords.xyz, vScreenPos, FLASHLIGHTDEPTHFILTERMODE, g_vShadowTweaks, NdotL );
|
||||
float flAttenuated = lerp( flShadow, 1.0f, g_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 ( ANISOTROPY == 1 )
|
||||
{
|
||||
VdotT = dot( vEyeDir, vTangent );
|
||||
sVdotT = sqrt( 1 - VdotT * VdotT );
|
||||
}
|
||||
|
||||
CharacterSpecularAndRimTerms( vWorldNormal, vFlashlightDir, g_fPhongExponent, vEyeDir,
|
||||
( PHONGWARPTEXTURE == 1 ), PhongWarpSampler,
|
||||
flashlightColor, false, g_fRimLightExponent, fWarpIndex,
|
||||
( ANISOTROPY == 1 ), fAnisotropyAmount, VdotT, sVdotT, vTangent,
|
||||
false, 0, 0, // TODO: enable retroreflectivity with flashlight
|
||||
|
||||
// Outputs
|
||||
cSpecularFlashlight, cAdditiveRimlight, fRimHalo );
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if ( FAKERIM )
|
||||
{
|
||||
float3 localRimTerm, localSpecularTerm = float3( 0.0f, 0.0f, 0.0f );
|
||||
float localRimHalo = 0;
|
||||
float3 vFakeRimDir = float3( i.tangentSpaceTranspose0_FakeRimx.w, i.tangentSpaceTranspose1_FakeRimy.w, i.tangentSpaceTranspose2_FakeRimz.w );
|
||||
float3 cFakeRimColor = i.cAmbient_fRimBoost.rgb * i.cAmbient_fRimBoost.a * g_cFakeRimTint;
|
||||
|
||||
CharacterSpecularAndRimTerms( vWorldNormal, vFakeRimDir, 1.0f, vEyeDir,
|
||||
false, NULL, cFakeRimColor,
|
||||
true, g_fRimLightExponent, 0.0f,
|
||||
false, 0.0f, 0.0f, 0.0f, float3( 0.0f, 0.0f, 0.0f ),
|
||||
false, 0.0f, 0.0f,
|
||||
localSpecularTerm, localRimTerm, localRimHalo );
|
||||
cAdditiveRimlight += localRimTerm * fRimMask;
|
||||
// TODO: add rim saturation here?
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ( ANISOTROPY )
|
||||
float3 vnWorldTangentS = normalize( cross( vWorldNormal, i.vWorldTangentT_vBounceCentery.xyz ) );
|
||||
float3 vnWorldTangentT = normalize( cross( vWorldNormal, vnWorldTangentS ) );
|
||||
|
||||
float cr, sr;
|
||||
sincos( fAnisotropyAngle, cr, sr );
|
||||
vTangent = normalize( cr * vnWorldTangentT + sr * vnWorldTangentS );
|
||||
|
||||
float3 rvec = cross( vTangent, vWorldNormal.xyz );
|
||||
float3 uvec = cross( vEyeDir, rvec );
|
||||
float3 evec = normalize( cross( rvec, vTangent ) );
|
||||
vReflectionEyeVec = lerp( vEyeDir, evec, fAnisotropyAmount );
|
||||
#endif
|
||||
|
||||
#if ( PHONG )
|
||||
CharacterDoSpecularLighting( i.vWorldPos_projZ.xyz, vWorldNormal, g_fPhongExponent, vEyeDir,
|
||||
i.lightAtten, NUM_LIGHTS, g_cLightInfo,
|
||||
( PHONGWARPTEXTURE == 1 ), PhongWarpSampler,
|
||||
( RIMLIGHT == 1 ), g_fRimLightExponent, fCSMShadow, fWarpIndex,
|
||||
( ANISOTROPY == 1 ), fAnisotropyAmount, fAnisotropyAngle,
|
||||
vTangent,
|
||||
( ( MASKS2 == 1 ) && ( fRetroReflectivityMask > 0 ) ), fRetroReflectivityMask, i.cAmbient_fRimBoost.xyz,
|
||||
|
||||
// Outputs
|
||||
cSpecularLight, cRimLight, fRimHalo );
|
||||
#if ( FLASHLIGHT )
|
||||
cSpecularLight += cSpecularFlashlight;
|
||||
#endif
|
||||
#if ( RIMLIGHT )
|
||||
float fRimModulation = g_fRimLightBoost * fRimMask;
|
||||
float fRimBoost = i.cAmbient_fRimBoost.w * g_fShadowRimBoost;
|
||||
fRimBoost += 1.0f;
|
||||
fRimModulation *= fRimBoost;
|
||||
cRimLight *= fRimModulation;
|
||||
#endif
|
||||
float fPhongBoost = g_fPhongBoost;
|
||||
cSpecularLight *= fSpecMask;
|
||||
|
||||
#if ( MASKS1 )
|
||||
fPhongBoost = lerp( g_fPhongBoost, g_fPhongAlbedoBoost, fPhongAlbedoMask );
|
||||
#endif
|
||||
|
||||
cSpecularLight *= fPhongBoost;
|
||||
#endif
|
||||
|
||||
#if ( AMBIENTREFLECTION || ENVMAP )
|
||||
float3 vReflection = CalcReflectionVectorUnnormalized( vWorldNormal, vReflectionEyeVec );
|
||||
#endif
|
||||
|
||||
#if ( ENVMAP )
|
||||
float3 cEnvmap = ENV_MAP_SCALE * texCUBE( EnvmapSampler, vReflection ).rgb;
|
||||
|
||||
cEnvmap = saturateColor( cEnvmap, g_fEnvmapSaturation );
|
||||
|
||||
float3 cEnvmapLight = saturate( ( ( linearLightColor + i.cAmbient_fRimBoost.xyz ) - g_vEnvmapLightScaleMin ) * g_vEnvmapLightScaleMax );
|
||||
cEnvmap = lerp( cEnvmap, cEnvmap * cEnvmapLight, fEnvmapLightScale );
|
||||
|
||||
cEnvmap = lerp( cEnvmap, cEnvmap * cEnvmap, g_fEnvmapContrast );
|
||||
|
||||
cEnvmap *= fEnvMask * g_cEnvmapTint;
|
||||
|
||||
cSpecularLight += cEnvmap;
|
||||
#endif
|
||||
|
||||
#if ( PHONG || ENVMAP )
|
||||
#if ( MASKS2 )
|
||||
fFresnel = lerp( fFresnel, 1.0f, fRetroReflectivityMask );
|
||||
#endif
|
||||
cSpecularLight *= fFresnel;
|
||||
#endif
|
||||
|
||||
#if ( AMBIENTREFLECTION )
|
||||
float3 cAmbientReflection = AmbientLight( vReflection, g_cAmbientCube );
|
||||
|
||||
float3 cAmbientLightColor = PixelShaderDoLighting( i.vWorldPos_projZ.xyz, float3( 0.0f, 0.0f, 1.0f ),
|
||||
float3( 0.0f, 0.0f, 0.0f), false,
|
||||
false, i.lightAtten, g_cAmbientCube,
|
||||
NormalizeSampler, min( NUM_LIGHTS, 1 ), g_cLightInfo, false,
|
||||
false, NULL, 1.0f );
|
||||
|
||||
cAmbientReflection *= cAmbientLightColor;
|
||||
|
||||
#if ( USEBOUNCECOLOR )
|
||||
float3 vBounceCenter = float3( i.vWorldTangentS_vBounceCenterx.w, i.vWorldTangentT_vBounceCentery.w, i.vBounceCenterDir_vBounceCenterz.w );
|
||||
|
||||
float3 linearLightBounceModulate = PixelShaderDoLighting( vBounceCenter, -i.vBounceCenterDir_vBounceCenterz.xyz,
|
||||
float3( 0.0f, 0.0f, 0.0f), false,
|
||||
false, i.lightAtten, g_cAmbientCube,
|
||||
NormalizeSampler, min( NUM_LIGHTS, 1 ), g_cLightInfo, false,
|
||||
false, NULL, 1.0f );
|
||||
|
||||
float fBounceTerm = saturate( dot( vWorldNormal, i.vBounceCenterDir_vBounceCenterz.xyz ) );
|
||||
float3 cBounce = g_cBounce * i.cAmbient_fRimBoost.xyz * linearLightBounceModulate;
|
||||
|
||||
cAmbientReflection = lerp( cAmbientReflection, cBounce, fBounceTerm );
|
||||
#endif
|
||||
|
||||
cAmbientReflection *= g_fAmbientBounceBoost * fAmbientReflectionMask;
|
||||
|
||||
cSpecularLight += cAmbientReflection;
|
||||
#endif
|
||||
|
||||
float fRimLightAlbedo = g_fRimLightAlbedo;
|
||||
#if ( MASKS1 )
|
||||
cSpecularLight *= lerp( float3( 1.0f, 1.0f, 1.0f ), cBase, fPhongAlbedoMask );
|
||||
fRimLightAlbedo = g_fRimLightAlbedo * fPhongAlbedoMask;
|
||||
#endif
|
||||
cRimLight *= lerp( g_cRimLightTint, cBase * fRimLightAlbedo, saturate( fRimLightAlbedo ) );
|
||||
|
||||
float fShadowScale = saturate( g_fShadowScale + i.cAmbient_fRimBoost.w ); // If we darken shadows to increase contrast, don't do it in very dark areas
|
||||
|
||||
float lightIntensity = desaturateColor( linearLightColor + cRimLight );
|
||||
float fShadeLevels = smoothstep( 0.3, 0.0, lightIntensity );
|
||||
|
||||
#if ( SHADOWSATURATION )
|
||||
lightIntensity = desaturateColor( linearLightColor ).g;
|
||||
// dark-to-mid blend
|
||||
float fShadeLevelsDark = smoothstep( g_vShadowSaturationBounds.x, g_vShadowSaturationBounds.y, lightIntensity );
|
||||
// mid-to-light blend
|
||||
float fShadeLevelsLight = smoothstep( g_vShadowSaturationBounds.w, g_vShadowSaturationBounds.z, lightIntensity );
|
||||
#if ( RIMLIGHT )
|
||||
// don't just use linear lighting, make a nice saturated halo on the rimlight too
|
||||
float rimHalo = smoothstep( g_vRimHaloBounds.x, g_vRimHaloBounds.y, fRimHalo );
|
||||
rimHalo *= smoothstep( g_vRimHaloBounds.w, g_vRimHaloBounds.z, fRimHalo );
|
||||
rimHalo *= desaturateColor( cRimLight ).g;
|
||||
rimHalo *= g_fRimHaloBoost;
|
||||
lightIntensity += rimHalo;
|
||||
fShadeLevelsLight = fShadeLevelsLight + rimHalo;
|
||||
#endif
|
||||
|
||||
cBase = lerp( cBase, saturateColor( cBase, g_fShadowSaturation ), fShadeLevelsDark * fShadeLevelsLight * fShadowSaturationMask );
|
||||
cBase = lerp( cBase, tintColor( cBase, g_cShadowTint.rgb, g_cShadowTint.a ) * fShadowScale, fShadeLevels );
|
||||
#else
|
||||
cBase = lerp( cBase, tintColor( cBase, g_cShadowTint.rgb, g_cShadowTint.a ) * fShadowScale, fShadeLevels );
|
||||
#endif
|
||||
|
||||
linearLightColor += i.cAmbient_fRimBoost.xyz;
|
||||
|
||||
cBase *= fMetalnessMask;
|
||||
|
||||
float3 finalColor = ( cBase * linearLightColor ) + cSpecularLight + cRimLight + cAdditiveRimlight;
|
||||
|
||||
#if ( BASEALPHASELFILLUMMASK )
|
||||
finalColor = lerp( finalColor, vBaseTextureSample.rgb * ( 1.0f + g_fSelfIllumBoost ), fSelfIllumMask );
|
||||
#endif
|
||||
|
||||
float flVertexFogFactor = 0.0f;
|
||||
#if ( !HARDWAREFOGBLEND && !DOPIXELFOG )
|
||||
flVertexFogFactor = i.worldPos_vertexFogFactor.w;
|
||||
#endif
|
||||
|
||||
fAlpha *= g_vDiffuseModulation.a;
|
||||
finalColor *= g_vDiffuseModulation.rgb;
|
||||
|
||||
float fogFactor = CalcPixelFogFactorSupportsVertexFog( PIXELFOGTYPE, g_FogParams, g_vEyePos.xyz, i.vWorldPos_projZ.xyz, i.vWorldPos_projZ.w, flVertexFogFactor );
|
||||
|
||||
#if ( WRITEWATERFOGTODESTALPHA && ( PIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT ) )
|
||||
fAlpha = fogFactor;
|
||||
#endif
|
||||
|
||||
return FinalOutput( float4( finalColor, fAlpha ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, false, i.vWorldPos_projZ.w );
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user