mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2024-12-27 07:15:31 +03:00
Added many shader source files
This should include the latest version of every shader that was in the 2007 SDK. It also includes a smattering of debug shaders, both VR distortion shaders, and other assorted shaders that will hopefully be useful. None of these new files are included in the game shader DLL project. If you need to modify one of these shaders for use in your mod you will need to rename it so that you don't collide with the version of that shader that lives in stdshader_dx9.dll.
This commit is contained in:
parent
9c37fcc3a8
commit
7309a5f13f
122
mp/src/materialsystem/stdshaders/BlurFilterX.cpp
Normal file
122
mp/src/materialsystem/stdshaders/BlurFilterX.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
//========= Copyright 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
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if( params[BASETEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
|
||||
{
|
||||
return "BlurFilterX_DX80";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
|
||||
|
||||
// Render targets are pegged as sRGB on POSIX, so just force these reads and writes
|
||||
bool bForceSRGBReadAndWrite = IsOSX() && g_pHardwareConfig->CanDoSRGBReadFromRTs();
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, bForceSRGBReadAndWrite );
|
||||
pShaderShadow->EnableSRGBWrite( bForceSRGBReadAndWrite );
|
||||
|
||||
// Pre-cache shaders
|
||||
blurfilter_vs20_Static_Index vshIndex;
|
||||
pShaderShadow->SetVertexShader( "BlurFilter_vs20", vshIndex.GetIndex() );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
#ifndef _X360
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( APPROX_SRGB_ADAPTER, bForceSRGBReadAndWrite );
|
||||
#endif
|
||||
SET_STATIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
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, 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;
|
||||
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 );
|
||||
|
||||
pShaderAPI->SetVertexShaderIndex( 0 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() )
|
||||
{
|
||||
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
|
86
mp/src/materialsystem/stdshaders/BlurFilterX_dx80.cpp
Normal file
86
mp/src/materialsystem/stdshaders/BlurFilterX_dx80.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DEFINE_FALLBACK_SHADER( BlurFilterX, BlurFilterX_DX80 )
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( BlurFilterX_DX80, "Help for BlurFilterX_DX80", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if( params[BASETEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
if ( g_pHardwareConfig->GetDXSupportLevel() < 80 )
|
||||
{
|
||||
return "Wireframe";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
|
||||
pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
|
||||
|
||||
// Pre-cache shaders
|
||||
pShaderShadow->SetVertexShader( "BlurFilter_vs11", 0 );
|
||||
pShaderShadow->SetPixelShader( "BlurFilter_ps11", 0 );
|
||||
|
||||
if ( IS_FLAG_SET( MATERIAL_VAR_ADDITIVE ) )
|
||||
EnableAlphaBlending( SHADER_BLEND_ONE, SHADER_BLEND_ONE );
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, BASETEXTURE, -1 );
|
||||
BindTexture( SHADER_SAMPLER1, BASETEXTURE, -1 );
|
||||
BindTexture( SHADER_SAMPLER2, BASETEXTURE, -1 );
|
||||
BindTexture( SHADER_SAMPLER3, BASETEXTURE, -1 );
|
||||
|
||||
// The temp buffer is 1/4 back buffer size
|
||||
ITexture *src_texture=params[BASETEXTURE]->GetTextureValue();
|
||||
int width = src_texture->GetActualWidth();
|
||||
float dX = 2.0f / width;
|
||||
|
||||
// 4 Tap offsets, expected from pixel center
|
||||
float v[4][4];
|
||||
v[0][0] = -1.5f * dX;
|
||||
v[0][1] = 0;
|
||||
v[1][0] = -0.5f * dX;
|
||||
v[1][1] = 0;
|
||||
v[2][0] = 0.5f * dX;
|
||||
v[2][1] = 0;
|
||||
v[3][0] = 1.5f * dX;
|
||||
v[3][1] = 0;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, &v[0][0], 4 );
|
||||
|
||||
v[0][0] = v[0][1] = v[0][2] = v[0][3] = 1.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( 1, v[0], 1 );
|
||||
|
||||
pShaderAPI->SetVertexShaderIndex( 0 );
|
||||
pShaderAPI->SetPixelShaderIndex( 0 );
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
136
mp/src/materialsystem/stdshaders/BlurFilterY.cpp
Normal file
136
mp/src/materialsystem/stdshaders/BlurFilterY.cpp
Normal file
@ -0,0 +1,136 @@
|
||||
//========= Copyright 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", "" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
if ( !( params[BLOOMAMOUNT]->IsDefined() ) )
|
||||
{
|
||||
params[BLOOMAMOUNT]->SetFloatValue( 1.0 );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if ( params[BASETEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
|
||||
{
|
||||
return "BlurFilterY_DX80";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
|
||||
|
||||
// Render targets are pegged as sRGB on POSIX, so just force these reads and writes
|
||||
bool bForceSRGBReadAndWrite = IsOSX() && g_pHardwareConfig->CanDoSRGBReadFromRTs();
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, bForceSRGBReadAndWrite );
|
||||
pShaderShadow->EnableSRGBWrite( bForceSRGBReadAndWrite );
|
||||
|
||||
// Pre-cache shaders
|
||||
DECLARE_STATIC_VERTEX_SHADER( blurfilter_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( blurfilter_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
#ifndef _X360
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( APPROX_SRGB_ADAPTER, bForceSRGBReadAndWrite );
|
||||
#endif
|
||||
SET_STATIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
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, BASETEXTURE, -1 );
|
||||
|
||||
// The temp buffer is 1/4 back buffer size
|
||||
ITexture *src_texture = params[BASETEXTURE]->GetTextureValue();
|
||||
int height = src_texture->GetActualWidth();
|
||||
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 );
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( blurfilter_ps20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( blurfilter_ps20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() )
|
||||
{
|
||||
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
|
91
mp/src/materialsystem/stdshaders/BlurFilterY_dx80.cpp
Normal file
91
mp/src/materialsystem/stdshaders/BlurFilterY_dx80.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DEFINE_FALLBACK_SHADER( BlurFilterY, BlurFilterY_DX80 )
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( BlurFilterY_DX80, "Help for BlurFilterY_DX80", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( BLOOMAMOUNT, SHADER_PARAM_TYPE_FLOAT, "1.0", "" )
|
||||
SHADER_PARAM( FRAMETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_SmallHDR0", "" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if ( params[BASETEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
if ( !( params[BLOOMAMOUNT]->IsDefined() ) )
|
||||
params[BLOOMAMOUNT]->SetFloatValue(1.0);
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
if ( g_pHardwareConfig->GetDXSupportLevel() < 80 )
|
||||
{
|
||||
return "Wireframe";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
|
||||
pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
|
||||
|
||||
// Pre-cache shaders
|
||||
pShaderShadow->SetVertexShader( "BlurFilter_vs11", 0 );
|
||||
pShaderShadow->SetPixelShader( "BlurFilter_ps11", 0 );
|
||||
|
||||
if ( IS_FLAG_SET( MATERIAL_VAR_ADDITIVE ) )
|
||||
EnableAlphaBlending( SHADER_BLEND_ONE, SHADER_BLEND_ONE );
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, BASETEXTURE, -1 );
|
||||
BindTexture( SHADER_SAMPLER1, BASETEXTURE, -1 );
|
||||
BindTexture( SHADER_SAMPLER2, BASETEXTURE, -1 );
|
||||
BindTexture( SHADER_SAMPLER3, BASETEXTURE, -1 );
|
||||
|
||||
int width, height;
|
||||
pShaderAPI->GetBackBufferDimensions( width, height );
|
||||
|
||||
// The temp buffer is 1/4 back buffer size
|
||||
float dY = 2.0f / height;
|
||||
|
||||
// 4 Tap offsets, expected from pixel center
|
||||
float v[4][4];
|
||||
v[0][0] = 0;
|
||||
v[0][1] = -1.5f * dY;
|
||||
v[1][0] = 0;
|
||||
v[1][1] = -0.5f * dY;
|
||||
v[2][0] = 0;
|
||||
v[2][1] = 0.5f * dY;
|
||||
v[3][0] = 0;
|
||||
v[3][1] = 1.5f * dY;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, &v[0][0], 4 );
|
||||
|
||||
v[0][0] = v[0][1] = v[0][2] = params[BLOOMAMOUNT]->GetFloatValue();
|
||||
pShaderAPI->SetPixelShaderConstant( 1, v[0], 1 );
|
||||
|
||||
pShaderAPI->SetVertexShaderIndex( 0 );
|
||||
pShaderAPI->SetPixelShaderIndex( 0 );
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
18
mp/src/materialsystem/stdshaders/BlurFilter_ps11.psh
Normal file
18
mp/src/materialsystem/stdshaders/BlurFilter_ps11.psh
Normal file
@ -0,0 +1,18 @@
|
||||
ps.1.1
|
||||
|
||||
// 1221 filter constants
|
||||
def c0, 0.1667f, 0.1667f, 0.1667f, 0.3333f
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
mul r0.rgb, t0, c0
|
||||
mad r0.rgb, t1, c0.a, r0
|
||||
mad r0.rgb, t2, c0.a, r0
|
||||
mad r0.rgb, t3, c0, r0
|
||||
|
||||
mul r0.rgb, r0, c1 +
|
||||
mov r0.a, t0.a
|
||||
|
91
mp/src/materialsystem/stdshaders/BlurFilter_ps2x.fxc
Normal file
91
mp/src/materialsystem/stdshaders/BlurFilter_ps2x.fxc
Normal file
@ -0,0 +1,91 @@
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
|
||||
// STATIC: "APPROX_SRGB_ADAPTER" "0..1" [ps20b] [PC]
|
||||
|
||||
#define HDRTYPE HDR_TYPE_NONE
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler TexSampler : register( s0 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 coordTap0 : TEXCOORD0;
|
||||
float2 coordTap1 : TEXCOORD1;
|
||||
float2 coordTap2 : TEXCOORD2;
|
||||
float2 coordTap3 : TEXCOORD3;
|
||||
float2 coordTap1Neg : TEXCOORD4;
|
||||
float2 coordTap2Neg : TEXCOORD5;
|
||||
float2 coordTap3Neg : TEXCOORD6;
|
||||
};
|
||||
|
||||
float2 psTapOffs[3] : register( c0 );
|
||||
float3 scale_factor : register( c3 );
|
||||
|
||||
float4 SampleTexture( sampler texSampler, float2 uv )
|
||||
{
|
||||
float4 cSample = tex2D( texSampler, uv );
|
||||
|
||||
#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
|
||||
|
||||
return cSample;
|
||||
}
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4 s0, s1, s2, s3, s4, s5, s6, color;
|
||||
|
||||
// Sample taps with coordinates from VS
|
||||
s0 = SampleTexture( TexSampler, i.coordTap0 );
|
||||
s1 = SampleTexture( TexSampler, i.coordTap1 );
|
||||
s2 = SampleTexture( TexSampler, i.coordTap2 );
|
||||
s3 = SampleTexture( TexSampler, i.coordTap3 );
|
||||
s4 = SampleTexture( TexSampler, i.coordTap1Neg );
|
||||
s5 = SampleTexture( TexSampler, i.coordTap2Neg );
|
||||
s6 = SampleTexture( 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 + psTapOffs[0];
|
||||
float2 coordTap5 = i.coordTap0 + psTapOffs[1];
|
||||
float2 coordTap6 = i.coordTap0 + psTapOffs[2];
|
||||
float2 coordTap4Neg = i.coordTap0 - psTapOffs[0];
|
||||
float2 coordTap5Neg = i.coordTap0 - psTapOffs[1];
|
||||
float2 coordTap6Neg = i.coordTap0 - psTapOffs[2];
|
||||
|
||||
// Sample the taps
|
||||
s1 = SampleTexture( TexSampler, coordTap4 );
|
||||
s2 = SampleTexture( TexSampler, coordTap5 );
|
||||
s3 = SampleTexture( TexSampler, coordTap6 );
|
||||
s4 = SampleTexture( TexSampler, coordTap4Neg );
|
||||
s5 = SampleTexture( TexSampler, coordTap5Neg );
|
||||
s6 = SampleTexture( TexSampler, coordTap6Neg );
|
||||
|
||||
color += ( s1 + s4 ) * 0.0262f;
|
||||
color += ( s2 + s5 ) * 0.0162f;
|
||||
color += ( s3 + s6 ) * 0.0102f;
|
||||
color.xyz*=scale_factor.xyz;
|
||||
|
||||
#if ( APPROX_SRGB_ADAPTER )
|
||||
{
|
||||
color.xyz *= color.xyz; // Approximate sRGB-to-linear conversion
|
||||
}
|
||||
#endif
|
||||
|
||||
return color;
|
||||
//return FinalOutput( color, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
|
34
mp/src/materialsystem/stdshaders/BlurFilter_vs11.fxc
Normal file
34
mp/src/materialsystem/stdshaders/BlurFilter_vs11.fxc
Normal file
@ -0,0 +1,34 @@
|
||||
#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 );
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
39
mp/src/materialsystem/stdshaders/BlurFilter_vs20.fxc
Normal file
39
mp/src/materialsystem/stdshaders/BlurFilter_vs20.fxc
Normal file
@ -0,0 +1,39 @@
|
||||
#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 coordTap1Neg : TEXCOORD4;
|
||||
float2 coordTap2Neg : TEXCOORD5;
|
||||
float2 coordTap3Neg : TEXCOORD6;
|
||||
};
|
||||
|
||||
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 );
|
||||
o.coordTap0 = v.vBaseTexCoord;
|
||||
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];
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
27
mp/src/materialsystem/stdshaders/Cable.psh
Normal file
27
mp/src/materialsystem/stdshaders/Cable.psh
Normal file
@ -0,0 +1,27 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; See the vertex shader for info
|
||||
;
|
||||
; This shader takes:
|
||||
; t0 = normal map
|
||||
; t1 = base texture
|
||||
; v0 = directional light color
|
||||
; t2 = directional light direction (biased into 0-1)
|
||||
; c0 = percent of dirlight to add as ambient
|
||||
;
|
||||
; Output:
|
||||
; (t0 dot t1) * v0
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0 ; Get the 3-vector from the normal map
|
||||
tex t1 ; Interpret tcoord t1 as color data.
|
||||
texcoord t2
|
||||
|
||||
dp3 r1, t0_bx2, t2_bx2 ; r1 = normalMap dot dirLightDir
|
||||
add r0, r1, c0 ; + 0.5
|
||||
|
||||
mul r1, v0, r0 ; scale the dot product by the dirlight's actual color
|
||||
mul r0.rgb, r1, t1 + ; scale by the texture color
|
||||
|
||||
mul r0.a, t1.a, v0.a
|
117
mp/src/materialsystem/stdshaders/Cable.vsh
Normal file
117
mp/src/materialsystem/stdshaders/Cable.vsh
Normal file
@ -0,0 +1,117 @@
|
||||
vs.1.1
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; The cable equation is:
|
||||
; [L dot N] * C * T
|
||||
;
|
||||
; where:
|
||||
; C = directional light color
|
||||
; T = baseTexture
|
||||
; N = particle normal (stored in the normal map)
|
||||
; L = directional light direction
|
||||
;
|
||||
; $SHADER_SPECIFIC_CONST_0 = Directional light direction
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Transform position from object to projection space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&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
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Setup the tangent space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$tmp1 );
|
||||
&AllocateRegister( \$tmp2 );
|
||||
&AllocateRegister( \$tmp3 );
|
||||
&AllocateRegister( \$r );
|
||||
|
||||
; Get S crossed with T (call it R)
|
||||
mov $tmp1, $vTangentS
|
||||
mov $tmp2, $vTangentT
|
||||
|
||||
mul $tmp3, $vTangentS.yzxw, $tmp2.zxyw
|
||||
mad $r, -$vTangentS.zxyw, $tmp2.yzxw, $tmp3
|
||||
|
||||
&FreeRegister( \$tmp2 );
|
||||
&FreeRegister( \$tmp3 );
|
||||
|
||||
&AllocateRegister( \$s );
|
||||
|
||||
; Normalize S (into $s)
|
||||
dp3 $s.w, $vTangentS, $vTangentS
|
||||
rsq $s.w, $s.w
|
||||
mul $s.xyz, $vTangentS, $s.w
|
||||
|
||||
; Normalize R (into $r)
|
||||
dp3 $r.w, $r, $r
|
||||
rsq $r.w, $r.w
|
||||
mul $r.xyz, $r, $r.w
|
||||
|
||||
&AllocateRegister( \$t );
|
||||
|
||||
; Regenerate T (into $t)
|
||||
mul $t, $r.yzxw, $tmp1.zxyw
|
||||
mad $t, -$r.zxyw, $tmp1.yzxw, $t
|
||||
|
||||
&FreeRegister( \$tmp1 );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Transform the light direction (into oD1)
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$lightDirection );
|
||||
|
||||
dp3 $lightDirection.x, $s, $SHADER_SPECIFIC_CONST_0
|
||||
dp3 $lightDirection.y, $t, $SHADER_SPECIFIC_CONST_0
|
||||
dp3 $lightDirection.z, $r, $SHADER_SPECIFIC_CONST_0
|
||||
|
||||
&FreeRegister( \$r );
|
||||
&FreeRegister( \$s );
|
||||
&FreeRegister( \$t );
|
||||
|
||||
; Scale into 0-1 range (we're assuming light direction was normalized prior to here)
|
||||
add oT2, $lightDirection, $cHalf ; + 0.5
|
||||
&FreeRegister( \$lightDirection );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Copy texcoords for the normal map and base texture
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
mov oT0, $vTexCoord0
|
||||
mov oT1, $vTexCoord1
|
||||
|
||||
; Pass the dirlight color through
|
||||
mov oD0.xyzw, $vColor
|
||||
|
||||
|
23
mp/src/materialsystem/stdshaders/DebugDrawDepth_ps2x.fxc
Normal file
23
mp/src/materialsystem/stdshaders/DebugDrawDepth_ps2x.fxc
Normal file
@ -0,0 +1,23 @@
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
|
||||
|
||||
#define HDRTYPE HDR_TYPE_NONE
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float3 zValue : TEXCOORD0;
|
||||
};
|
||||
|
||||
const float3 g_ZFilter : register( c1 );
|
||||
const float3 g_ModulationColor : register( c2 );
|
||||
|
||||
float4 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 );
|
||||
}
|
38
mp/src/materialsystem/stdshaders/DebugDrawDepth_vs20.fxc
Normal file
38
mp/src/materialsystem/stdshaders/DebugDrawDepth_vs20.fxc
Normal file
@ -0,0 +1,38 @@
|
||||
// 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;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
94
mp/src/materialsystem/stdshaders/DebugDrawEnvmapMask.cpp
Normal file
94
mp/src/materialsystem/stdshaders/DebugDrawEnvmapMask.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
//========= Copyright 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
|
||||
{
|
||||
if( g_pHardwareConfig->GetDXSupportLevel() < 90 )
|
||||
{
|
||||
// Assert( 0 );
|
||||
return "Wireframe";
|
||||
}
|
||||
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, BASETEXTURE, FRAME );
|
||||
SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, BASETEXTURETRANSFORM );
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
@ -0,0 +1,26 @@
|
||||
// DYNAMIC: "SHOWALPHA" "0..1"
|
||||
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
|
||||
|
||||
#define HDRTYPE HDR_TYPE_NONE
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler BaseTextureSampler : register( s0 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float2 baseTexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 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 );
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
// 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] );
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
104
mp/src/materialsystem/stdshaders/DebugTextureView.cpp
Normal file
104
mp/src/materialsystem/stdshaders/DebugTextureView.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "shaderlib/cshader.h"
|
||||
|
||||
#include "debugtextureview_vs20.inc"
|
||||
#include "debugtextureview_ps20.inc"
|
||||
#include "debugtextureview_ps20b.inc"
|
||||
|
||||
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
|
||||
{
|
||||
if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
|
||||
{
|
||||
return "UnlitGeneric";
|
||||
}
|
||||
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, 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;
|
||||
}
|
||||
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( debugtextureview_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( debugtextureview_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( ISCUBEMAP, pTexture->IsCubeMap() );
|
||||
SET_DYNAMIC_PIXEL_SHADER( debugtextureview_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
81
mp/src/materialsystem/stdshaders/DebugTextureView_ps2x.fxc
Normal file
81
mp/src/materialsystem/stdshaders/DebugTextureView_ps2x.fxc
Normal file
@ -0,0 +1,81 @@
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
|
||||
// STATIC: "SHOWALPHA" "0..1"
|
||||
// DYNAMIC: "ISCUBEMAP" "0..1"
|
||||
|
||||
#define HDRTYPE HDR_TYPE_NONE
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler g_tSampler : register( s0 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
const float3 g_vConst0 : register( c0 );
|
||||
#define g_flIsHdrCube g_vConst0.x
|
||||
#define g_flIsHdr2D g_vConst0.y
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4 sample = tex2D( g_tSampler, i.texCoord );
|
||||
float4 result = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
result.rgb = sample.rgb;
|
||||
#if SHOWALPHA
|
||||
result.rgb = sample.a;
|
||||
#endif
|
||||
|
||||
if ( g_flIsHdr2D )
|
||||
result.rgb *= MAX_HDR_OVERBRIGHT;
|
||||
|
||||
#if 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
|
||||
|
||||
return FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
23
mp/src/materialsystem/stdshaders/DebugTextureView_vs20.fxc
Normal file
23
mp/src/materialsystem/stdshaders/DebugTextureView_vs20.fxc
Normal file
@ -0,0 +1,23 @@
|
||||
// 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;
|
||||
return o;
|
||||
}
|
16
mp/src/materialsystem/stdshaders/Eyes.psh
Normal file
16
mp/src/materialsystem/stdshaders/Eyes.psh
Normal file
@ -0,0 +1,16 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw the eyes
|
||||
; t0 - texture
|
||||
; t1 - iris
|
||||
; t2 - glint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
|
||||
lrp r0, t1.a, t1, t0 ; Blend in the iris with the background
|
||||
mad r0.rgb, r0, v0, t2 + ; Modulate by the illumination, add in the glint
|
||||
mov r0.a, t0.a
|
18
mp/src/materialsystem/stdshaders/Eyes_Overbright2.psh
Normal file
18
mp/src/materialsystem/stdshaders/Eyes_Overbright2.psh
Normal file
@ -0,0 +1,18 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw the eyes
|
||||
; t0 - texture
|
||||
; t1 - iris
|
||||
; t2 - glint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
|
||||
lrp r0, t1.a, t1, t0 ; Blend in the iris with the background
|
||||
mul_x2 r0, v0, r0 ; Modulate by the illumination with overbright
|
||||
|
||||
add r0.rgb, r0, t2 + ; Add in the glint
|
||||
mov r0.a, t0.a
|
145
mp/src/materialsystem/stdshaders/Eyes_vs20.fxc
Normal file
145
mp/src/materialsystem/stdshaders/Eyes_vs20.fxc
Normal file
@ -0,0 +1,145 @@
|
||||
//======= Copyright © 1996-2006, 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: "INTRO" "0..1"
|
||||
// STATIC: "HALFLAMBERT" "0..1"
|
||||
// STATIC: "USE_STATIC_CONTROL_FLOW" "0..1" [vs20]
|
||||
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
// DYNAMIC: "DOWATERFOG" "0..1"
|
||||
// DYNAMIC: "DYNAMIC_LIGHT" "0..1"
|
||||
// DYNAMIC: "STATIC_LIGHT" "0..1"
|
||||
// DYNAMIC: "MORPHING" "0..1" [vs30]
|
||||
// DYNAMIC: "NUM_LIGHTS" "0..2" [vs20]
|
||||
|
||||
// If using static control flow on Direct3D, we should use the NUM_LIGHTS=0 combo
|
||||
// SKIP: $USE_STATIC_CONTROL_FLOW && ( $NUM_LIGHTS > 0 ) [vs20]
|
||||
|
||||
#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 );
|
||||
#if INTRO
|
||||
const float4 const4 : register( SHADER_SPECIFIC_CONST_6 );
|
||||
#define g_Time const4.w
|
||||
#define modelOrigin const4.xyz
|
||||
#endif
|
||||
|
||||
#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( D3DVERTEXTEXTURESAMPLER0, 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 )
|
||||
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;
|
||||
|
||||
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 );
|
||||
|
||||
#if INTRO
|
||||
WorldSpaceVertexProcess( g_Time, modelOrigin, worldPos, dummy, dummy, dummy );
|
||||
#endif
|
||||
|
||||
// Transform into projection space
|
||||
float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
o.projPos = vProjPos;
|
||||
vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ );
|
||||
o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z );
|
||||
|
||||
#if !defined( _X360 )
|
||||
// Set fixed-function fog factor
|
||||
o.fog = CalcFog( worldPos, vProjPos, 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 ( USE_STATIC_CONTROL_FLOW || 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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
15
mp/src/materialsystem/stdshaders/LightmappedGeneric.psh
Normal file
15
mp/src/materialsystem/stdshaders/LightmappedGeneric.psh
Normal file
@ -0,0 +1,15 @@
|
||||
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, t0, v0 ; base times vertex color (with alpha)
|
||||
mul r0.rgb, t1, r0 ; fold in lightmap (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
@ -0,0 +1,17 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t2 ; cube map
|
||||
tex t3 ; envmap mask
|
||||
|
||||
mul r0.rgb, t2, 1-t3.a
|
||||
mul r0.rgb, c2, r0 ; apply the envmaptint
|
||||
+ mul r0.a, c2.a, v0.a
|
@ -0,0 +1,17 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t2 ; cube map
|
||||
tex t3 ; envmap mask
|
||||
|
||||
mul r0.rgb, t2, t3
|
||||
mul r0.rgb, c2, r0
|
||||
+ mul r0.a, c2.a, v0.a
|
@ -0,0 +1,15 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t2 ; cube map
|
||||
|
||||
mul r0.rgb, t2, c2
|
||||
+ mul r0.a, v0.a, c2.a
|
@ -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
|
||||
; c1 - self-illum tint
|
||||
; c2 - envmap tint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
mul r0, t0, v0 ; base times vertex color (with alpha)
|
||||
mul r0.rgb, t1, r0 ; fold in lighting (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
mul r1, t2, 1-t3.a ; envmap * envmapmask (alpha)
|
||||
mad r0.rgb, r1, c2, r0 ; + envmap * envmapmask * envmaptint (color only)
|
@ -0,0 +1,14 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Get the color from the texture
|
||||
tex t0
|
||||
mul r0, t0, c0
|
||||
|
@ -0,0 +1,38 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&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
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
|
||||
|
||||
|
@ -0,0 +1,43 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&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
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
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
|
||||
|
||||
mov oT2, $vTexCoord1
|
||||
|
||||
; Now the basetexture/basetexture2 blend uses vertex color, so send it into the psh.
|
||||
mov oD0, $vColor
|
@ -0,0 +1,66 @@
|
||||
; STATIC: "NORMALMAPALPHAENVMAPMASK" "0..1"
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Environment mapping on a bumped surface
|
||||
; t0 - Normalmap
|
||||
; t3 - Cube environment map (*must* be a cube map!)
|
||||
;
|
||||
; c0 - color to multiply the results by
|
||||
; c1 - envmap contrast
|
||||
; c2 - envmap saturation
|
||||
; c3 - grey weights
|
||||
; c4 - fresnel amount
|
||||
; Input texture coords required here are a little wonky.
|
||||
; tc0.uv <- U,V into the normal map
|
||||
; tc1.uvw, tc2.uvw, tc3.uvw <- 3x3 matrix transform
|
||||
; from tangent space->env map space
|
||||
; tc1.q, tc2.q, tc3.q <- eye vector in env map space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Get the 3-vector from the normal map
|
||||
tex t0
|
||||
|
||||
; Perform matrix multiply to get a local normal bump. Then
|
||||
; reflect the eye vector through the normal and sample from
|
||||
; a cubic environment map.
|
||||
texm3x3pad t1, t0_bx2
|
||||
texm3x3pad t2, t0_bx2
|
||||
texm3x3vspec t3, t0_bx2
|
||||
|
||||
; FIXME FIXME - Need to do specialized versions of this with and without:
|
||||
; - constant color
|
||||
; - fresnel amount of exactly 0 or 1 or in between
|
||||
; - envmap contrast of 0, 1, or in between
|
||||
; - envmap saturation of 0, 1, or in between
|
||||
|
||||
; r0 = constant color * result of bump into envmap
|
||||
mul r0.rgb, t3, c0
|
||||
|
||||
; dot eye-vector with per-pixel normal from t0
|
||||
dp3_sat r1, v0_bx2, t0_bx2
|
||||
|
||||
; run Fresnel approx. on it: R0 + (1-R0) (1-cos(q))^5 in alpha channel
|
||||
mul r1.rgb, r0, r0 ; color squared
|
||||
+mul r0.a, 1-r1.a, 1-r1.a ; squared
|
||||
|
||||
lrp r0.rgb, c1, r1, r0 ; blend between color and color * color
|
||||
+mul r0.a, r0.a, r0.a ; quartic
|
||||
|
||||
dp3 r1.rgb, r0, c3 ; color greyscaled
|
||||
+mul r0.a, r0.a, 1-r1.a ; quintic
|
||||
|
||||
; FIXME - these should be able to pair (I think), but don't on nvidia for some reason.
|
||||
; (I think) cannot pair due to use of >2 constants in single stage
|
||||
lrp r0.rgb, c2, r0, r1 ; blend between color and greyscale
|
||||
mad r0.a, r0.a, c6.a, c4.a ; Take Fresnel R(0) into consideration
|
||||
|
||||
mul r0.rgb, r0, r0.a ; multiply output color by result of fresnel calc
|
||||
|
||||
#if NORMALMAPALPHAENVMAPMASK
|
||||
+mul r0.a, c0.a, t0.a ; Fade amount * alpha from the texture
|
||||
#else
|
||||
+mov r0.a, c0.a ; Just use the fade amount
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,96 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Shader specific constant:
|
||||
; $SHADER_SPECIFIC_CONST_5 = [sOffset, tOffset, 0, 0]
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$worldPos );
|
||||
|
||||
; Transform position from object to world
|
||||
dp4 $worldPos.x, $vPos, $cModel0
|
||||
dp4 $worldPos.y, $vPos, $cModel1
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
; Transform position from object to projection space
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Lighting
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Transform tangent space basis vectors to env map space (world space)
|
||||
; This will produce a set of vectors mapping from tangent space to env space
|
||||
; We'll use this to transform normals from the normal map from tangent space
|
||||
; to environment map space.
|
||||
; NOTE: use dp3 here since the basis vectors are vectors, not points
|
||||
|
||||
dp3 oT1.x, $vTangentS, $cModel0
|
||||
dp3 oT2.x, $vTangentS, $cModel1
|
||||
dp3 oT3.x, $vTangentS, $cModel2
|
||||
|
||||
dp3 oT1.y, $vTangentT, $cModel0
|
||||
dp3 oT2.y, $vTangentT, $cModel1
|
||||
dp3 oT3.y, $vTangentT, $cModel2
|
||||
|
||||
dp3 oT1.z, $vNormal, $cModel0
|
||||
dp3 oT2.z, $vNormal, $cModel1
|
||||
dp3 oT3.z, $vNormal, $cModel2
|
||||
|
||||
; Compute the vector from vertex to camera
|
||||
&AllocateRegister( \$worldEyeVect );
|
||||
sub $worldEyeVect.xyz, $cEyePos, $worldPos
|
||||
&FreeRegister( \$worldPos );
|
||||
|
||||
; Move it into the w component of the texture coords, as the wacky
|
||||
; pixel shader wants it there.
|
||||
mov oT1.w, $worldEyeVect.x
|
||||
mov oT2.w, $worldEyeVect.y
|
||||
mov oT3.w, $worldEyeVect.z
|
||||
|
||||
alloc $tangentEyeVect
|
||||
|
||||
; transform the eye vector to tangent space
|
||||
dp3 $tangentEyeVect.x, $worldEyeVect, $vTangentS
|
||||
dp3 $tangentEyeVect.y, $worldEyeVect, $vTangentT
|
||||
dp3 $tangentEyeVect.z, $worldEyeVect, $vNormal
|
||||
|
||||
&FreeRegister( \$worldEyeVect );
|
||||
|
||||
&Normalize( $tangentEyeVect );
|
||||
|
||||
; stick the tangent space eye vector into oD0
|
||||
mad oD0.xyz, $tangentEyeVect, $cHalf, $cHalf
|
||||
|
||||
&FreeRegister( \$tangentEyeVect );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
|
||||
|
||||
|
@ -0,0 +1,72 @@
|
||||
; STATIC: "NORMALMAPALPHAENVMAPMASK" "0..1"
|
||||
ps.1.4
|
||||
;------------------------------------------------------------------------------
|
||||
; Phase 1
|
||||
;------------------------------------------------------------------------------
|
||||
; Get the 3-vector from the normal map
|
||||
texld r0, t0
|
||||
; Get environment matrix
|
||||
texcrd r1.rgb, t1
|
||||
texcrd r2.rgb, t2
|
||||
texcrd r3.rgb, t3
|
||||
; Normalize eye-ray vector through normalizer cube map
|
||||
texld r4, t4 ; <---- CUBE MAP here!!!
|
||||
;mov r0.rgba, r4
|
||||
|
||||
; Transform normal
|
||||
dp3 r5.r, r1, r0_bx2
|
||||
dp3 r5.g, r2, r0_bx2
|
||||
dp3 r5.b, r3, r0_bx2
|
||||
; Reflection calculatiom
|
||||
dp3_x2 r3.rgb, r5, r4_bx2 ; 2(N.Eye)
|
||||
mul r3.rgb, r5, r3 ; 2N(N.Eye)
|
||||
dp3 r2.rgb, r5, r5 ; N.N
|
||||
mad r2.rgb, -r4_bx2, r2, r3 ; 2N(N.Eye) - Eye(N.N)
|
||||
|
||||
#if NORMALMAPALPHAENVMAPMASK
|
||||
; Alpha gets lost after phase marker, so store it here
|
||||
mov r5, r0.a
|
||||
#endif
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Phase 2
|
||||
;------------------------------------------------------------------------------
|
||||
; What's left over from the last phase:
|
||||
; r0 - normal
|
||||
; r1 - free
|
||||
; r2 - vector to sample in envmap
|
||||
; r3 - free
|
||||
; r4 - normal
|
||||
; r5 - normal map alpha (rgba)
|
||||
|
||||
phase
|
||||
|
||||
; Sample environment map
|
||||
texld r3, r2
|
||||
|
||||
; dot eye-vector with per-pixel normal from r0
|
||||
dp3_sat r1, v0_bx2, r0_bx2
|
||||
|
||||
; Result goes in output color (multiply by constant color c0)
|
||||
mul r0.rgb, r3, c0
|
||||
|
||||
; run Fresnel approx. on it: R0 + (1-R0) (1-cos(q))^5 in alpha channel
|
||||
mul r1.rgb, r0, r0
|
||||
+mul r0.a, 1-r1.a, 1-r1.a ; squared
|
||||
|
||||
lrp r0.rgb, c1, r1, r0 ; blend between color and color * color
|
||||
+mul r0.a, r0.a, r0.a ; quartic
|
||||
|
||||
dp3 r1.rgb, r0, c3
|
||||
+mul r0.a, r0.a, 1-r1.a ; quintic
|
||||
|
||||
lrp r0.rgb, c2, r0, r1 ; blend between color and greyscale
|
||||
mad r0.a, r0.a, c6.a, c4.a ; Take Fresnel R(0) into consideration
|
||||
|
||||
mul r0.rgb, r0, r0.a ; multiply output color by result of fresnel calc
|
||||
|
||||
#if NORMALMAPALPHAENVMAPMASK
|
||||
+mul r0.a, c0.a, r5.r ; Fade amount * alpha from the texture
|
||||
#else
|
||||
+mov r0.a, c0.a ; Just use the fade amount
|
||||
#endif
|
@ -0,0 +1,92 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Shader specific constant:
|
||||
; $SHADER_SPECIFIC_CONST_5 = [sOffset, tOffset, 0, 0]
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$worldPos );
|
||||
|
||||
; Transform position from object to world
|
||||
dp4 $worldPos.x, $vPos, $cModel0
|
||||
dp4 $worldPos.y, $vPos, $cModel1
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
; Transform position from object to projection space
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Lighting
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Transform tangent space basis vectors to env map space (world space)
|
||||
; This will produce a set of vectors mapping from tangent space to env space
|
||||
; We'll use this to transform normals from the normal map from tangent space
|
||||
; to environment map space.
|
||||
; NOTE: use dp3 here since the basis vectors are vectors, not points
|
||||
|
||||
dp3 oT1.x, $vTangentS, $cModel0
|
||||
dp3 oT2.x, $vTangentS, $cModel1
|
||||
dp3 oT3.x, $vTangentS, $cModel2
|
||||
|
||||
dp3 oT1.y, $vTangentT, $cModel0
|
||||
dp3 oT2.y, $vTangentT, $cModel1
|
||||
dp3 oT3.y, $vTangentT, $cModel2
|
||||
|
||||
dp3 oT1.z, $vNormal, $cModel0
|
||||
dp3 oT2.z, $vNormal, $cModel1
|
||||
dp3 oT3.z, $vNormal, $cModel2
|
||||
|
||||
; Compute the vector from vertex to camera
|
||||
&AllocateRegister( \$worldEyeVect );
|
||||
sub $worldEyeVect.xyz, $cEyePos, $worldPos
|
||||
&FreeRegister( \$worldPos );
|
||||
|
||||
; eye vector
|
||||
mov oT4.xyz, $worldEyeVect
|
||||
|
||||
alloc $tangentEyeVect
|
||||
|
||||
; transform the eye vector to tangent space
|
||||
dp3 $tangentEyeVect.x, $worldEyeVect, $vTangentS
|
||||
dp3 $tangentEyeVect.y, $worldEyeVect, $vTangentT
|
||||
dp3 $tangentEyeVect.z, $worldEyeVect, $vNormal
|
||||
|
||||
&FreeRegister( \$worldEyeVect );
|
||||
|
||||
&Normalize( $tangentEyeVect );
|
||||
|
||||
; stick the tangent space eye vector into oD0
|
||||
mad oD0.xyz, $tangentEyeVect, $cHalf, $cHalf
|
||||
|
||||
&FreeRegister( \$tangentEyeVect );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
|
@ -0,0 +1,79 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Computes the diffuse component of lighting using lightmap + bumpmap
|
||||
; t0 - Normalmap
|
||||
; t1 - Lightmap1
|
||||
; t2 - Lightmap2
|
||||
; t3 - Lightmap3
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - Normalmap and lightmap texture coordinates
|
||||
; c0, c1, c2 - Axes of the lightmap coordinate system in tangent space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Get the 3-vector from the normal map
|
||||
tex t0
|
||||
|
||||
; Sample the lightmaps
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
; output = lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
|
||||
; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
|
||||
; lightmapColor[2] * ( ( N dot basis[2] )^2 ) +
|
||||
|
||||
; r0 = ( N dot basis[0] )
|
||||
; don't "_sat" here so that everything adds up to one even if the normal is outside of the basis!!!!!
|
||||
dp3 r0, t0_bx2, c0
|
||||
|
||||
; r1 = ( N dot basis[1] )
|
||||
dp3 r1, t0_bx2, c1
|
||||
|
||||
;----
|
||||
; r0 = ( N dot basis[0] )
|
||||
; r1 = ( N dot basis[1] )
|
||||
;----
|
||||
|
||||
; r0.rgb = ( N dot basis[0] )^2
|
||||
mul r0.rgb, r0, r0
|
||||
|
||||
; r1.a = ( N dot basis[1] )^2
|
||||
+mul r1.a, r1, r1
|
||||
|
||||
;----
|
||||
; r0.rgb = ( N dot basis[0] )^2
|
||||
; r1.a = ( N dot basis[1] )^2
|
||||
;----
|
||||
|
||||
mul t1, r0, t1
|
||||
|
||||
;----
|
||||
; r1.a = ( N dot basis[1] )^2
|
||||
; t1 = lightmapColor[0] * ( N dot basis[0] )^2
|
||||
;----
|
||||
|
||||
dp3 r0, t0_bx2, c2
|
||||
|
||||
;----
|
||||
; r1.a = ( N dot basis[1] )^2
|
||||
; t1 = lightmapColor[0] * ( N dot basis[0] )^2
|
||||
; r0 = ( N dot basis[2] )
|
||||
;----
|
||||
|
||||
mad t1.rgb, r1.a, t2, t1
|
||||
+mul r0.a, r0, r0
|
||||
|
||||
;----
|
||||
; t1.rgb = lightmapColor[0] * ( N dot basis[0] )^2 + lightmapColor[1] * ( N dot basis[1] )^2
|
||||
; r0.a = ( N dot basis[2] )^2
|
||||
;----
|
||||
|
||||
mad r0.rgba, r0.a, t3, t1
|
||||
|
||||
;----
|
||||
; r0.rgb = lightmapColor[0] * ( N dot basis[0] )^2 +
|
||||
; lightmapColor[1] * ( N dot basis[1] )^2 +
|
||||
; lightmapColor[2] * ( N dot basis[2] )^2
|
||||
;----
|
@ -0,0 +1,54 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
; Transform position from object to projection space
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Compute the texture coordinates given the offset between
|
||||
; each bumped lightmap
|
||||
&AllocateRegister( \$offset );
|
||||
mov $offset.xy, $vTexCoord2
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
add oT1.xy, $offset, $vTexCoord1
|
||||
mad oT2.xy, $offset, $cTwo, $vTexCoord1
|
||||
; make a 3
|
||||
alloc $three
|
||||
add $three, $cOne, $cTwo
|
||||
mad oT3.xy, $offset, $three, $vTexCoord1
|
||||
free $three
|
||||
|
||||
&FreeRegister( \$offset );
|
@ -0,0 +1,39 @@
|
||||
;------------------------------------------------------------------------------
|
||||
; Computes the diffuse component of lighting using lightmap + bumpmap
|
||||
; t0 - Normalmap
|
||||
; t1 - Lightmap1
|
||||
; t2 - Lightmap2
|
||||
; t3 - Lightmap3
|
||||
; t4 - Base
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - Normalmap and lightmap texture coordinates
|
||||
; c0, c1, c2 - Axes of the lightmap coordinate system in tangent space
|
||||
;------------------------------------------------------------------------------
|
||||
ps.1.4
|
||||
|
||||
; Get the 3-vector from the normal map
|
||||
texld r0, t0
|
||||
|
||||
; Sample the lightmaps
|
||||
texld r1, t1
|
||||
texld r2, t2
|
||||
texld r3, t3
|
||||
|
||||
; Sample the base texture
|
||||
texld r4, t4
|
||||
|
||||
; output = (lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
|
||||
; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
|
||||
; lightmapColor[2] * ( ( N dot basis[2] )^2 ) ) * base
|
||||
|
||||
dp3 r5.r, r0_bx2, c0
|
||||
dp3 r5.g, r0_bx2, c1
|
||||
dp3 r5.b, r0_bx2, c2
|
||||
mul r5.rgb, r5, r5
|
||||
mul r1, r1, r5.r
|
||||
mad r1, r2, r5.g, r1
|
||||
mad r1, r3, r5.g, r1
|
||||
|
||||
; assume overbright_2 !!!
|
||||
mul_x2 r0, r1, r4
|
@ -0,0 +1,55 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
; Transform position from object to projection space
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Compute the texture coordinates given the offset between
|
||||
; each bumped lightmap
|
||||
&AllocateRegister( \$offset );
|
||||
mov $offset.xy, $vTexCoord2
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
add oT1.xy, $offset, $vTexCoord1
|
||||
mad oT2.xy, $offset, $cTwo, $vTexCoord1
|
||||
alloc $three
|
||||
add $three, $cOne, $cTwo
|
||||
mad oT3.xy, $offset, $three, $vTexCoord1
|
||||
free $three
|
||||
dp4 oT4.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
|
||||
dp4 oT4.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_3
|
||||
|
||||
&FreeRegister( \$offset );
|
@ -0,0 +1,47 @@
|
||||
;------------------------------------------------------------------------------
|
||||
; Computes the diffuse component of lighting using lightmap + bumpmap
|
||||
; t0 - Normalmap
|
||||
; t1 - Lightmap1
|
||||
; t2 - Lightmap2
|
||||
; t3 - Lightmap3
|
||||
; t4 - Base1
|
||||
; t5 - Base2
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - Normalmap and lightmap texture coordinates
|
||||
; c0, c1, c2 - Axes of the lightmap coordinate system in tangent space
|
||||
;------------------------------------------------------------------------------
|
||||
ps.1.4
|
||||
|
||||
; output = (lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
|
||||
; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
|
||||
; lightmapColor[2] * ( ( N dot basis[2] )^2 ) ) * lerp(base1, base2, lightmapColor[0].a)
|
||||
|
||||
; Get the 3-vector from the normal map
|
||||
texld r0, t0
|
||||
|
||||
dp3 r5.r, r0_bx2, c0
|
||||
dp3 r5.g, r0_bx2, c1
|
||||
dp3 r5.b, r0_bx2, c2
|
||||
mul r5.rgb, r5, r5
|
||||
|
||||
phase
|
||||
|
||||
; Sample the lightmaps
|
||||
texld r1, t1
|
||||
texld r2, t2
|
||||
texld r3, t3
|
||||
|
||||
; Sample the base textures
|
||||
texld r4, t4
|
||||
texld r5, t5
|
||||
|
||||
mul r1, r1, r5.r
|
||||
mad r1, r2, r5.g, r1
|
||||
mad r1, r3, r5.g, r1
|
||||
|
||||
; blend base textures
|
||||
lrp r4, r4, r5, r1.a
|
||||
|
||||
; assume overbright_2 !!!
|
||||
mul_x2 r0, r1, r4
|
@ -0,0 +1,57 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
; Transform position from object to projection space
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Compute the texture coordinates given the offset between
|
||||
; each bumped lightmap
|
||||
&AllocateRegister( \$offset );
|
||||
mov $offset.xy, $vTexCoord2
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
add oT1.xy, $offset, $vTexCoord1
|
||||
mad oT2.xy, $offset, $cTwo, $vTexCoord1
|
||||
alloc $three
|
||||
add $three, $cOne, $cTwo
|
||||
mad oT3.xy, $offset, $three, $vTexCoord1
|
||||
free $three
|
||||
dp4 oT4.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
|
||||
dp4 oT4.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_3
|
||||
dp4 oT5.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_4
|
||||
dp4 oT5.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_5
|
||||
|
||||
&FreeRegister( \$offset );
|
@ -0,0 +1,47 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Computes the diffuse component of lighting using lightmap + bumpmap
|
||||
; t0 - decal texture
|
||||
; t1 - Lightmap1
|
||||
; t2 - Lightmap2
|
||||
; t3 - Lightmap3
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - Normalmap and lightmap texture coordinates
|
||||
; c0, c1, c2 - ( ( N dot basis[0] )^2 ), ( ( N dot basis[1] )^2 ), ( ( N dot basis[2] )^2 )
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Get the decal color
|
||||
tex t0
|
||||
|
||||
; Sample the lightmaps
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
; output = lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
|
||||
; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
|
||||
; lightmapColor[2] * ( ( N dot basis[2] )^2 ) +
|
||||
|
||||
; r0 = lightmapColor[0] * ( ( N dot basis[0] )^2 )
|
||||
mul r0, t1, c0
|
||||
|
||||
; r0 = lightmapColor[0] * ( ( N dot basis[0] )^2 ) + lightmapColor[1] * ( ( N dot basis[1] )^2 )
|
||||
mad r0, t2, c1, r0
|
||||
|
||||
; r0 = lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
|
||||
; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
|
||||
; lightmapColor[2] * ( ( N dot basis[2] )^2 )
|
||||
mad r0, t3, c2, r0
|
||||
|
||||
; Modulate by decal texture
|
||||
mul r0.rgb, r0, t0
|
||||
+ mov r0.a, t0.a
|
||||
|
||||
; Modulate by constant color
|
||||
mul r0, r0, c3
|
||||
|
||||
; Modulate by per-vertex factor
|
||||
mul r0, r0, v0
|
||||
|
@ -0,0 +1,56 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
; Transform position from object to projection space
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Compute the texture coordinates given the offset between
|
||||
; each bumped lightmap
|
||||
&AllocateRegister( \$offset );
|
||||
mov $offset.x, $vTexCoord2.x
|
||||
mov $offset.y, $cZero
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
add oT1.xy, $offset, $vTexCoord1
|
||||
mad oT2.xy, $offset, $cTwo, $vTexCoord1
|
||||
; make a 3
|
||||
alloc $three
|
||||
add $three, $cOne, $cTwo
|
||||
mad oT3.xy, $offset, $three, $vTexCoord1
|
||||
free $three
|
||||
mov oD0, $vColor
|
||||
|
||||
&FreeRegister( \$offset );
|
@ -0,0 +1,18 @@
|
||||
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
|
||||
tex t2
|
||||
mul r0, t0, v0 ; base times vertex color (with alpha)
|
||||
mul r0.rgb, t1, r0 ; fold in lightmap (color only)
|
||||
mul_x2 r1.rgb, r0, t2 ; detail texture
|
||||
lrp r0.rgb, c2, r1, r0
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
@ -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 t1
|
||||
tex t2
|
||||
mul r0.rgb, t1, v0 + ; base times vertex color (with alpha)
|
||||
mov r0.a, v0.a
|
||||
mul_x2 r0.rgb, r0, t2 ; detail texture
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
@ -0,0 +1,23 @@
|
||||
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
|
||||
tex t2
|
||||
mul r0.rgb, t0, v0 + ; base times vertex color (no alpha)
|
||||
mov r0.a, v0.a ; Grab alpha from vertex color
|
||||
|
||||
mul r0.rgb, t1, r0 ; fold in lighting (color only)
|
||||
mul_x2 r1.rgb, r0, t2 ; detail texture
|
||||
lrp r0.rgb, c2, r1, r0
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
mul r1, c1, t0 ; Self illum * tint
|
||||
lrp r0.rgb, t0.a, r1, r0 ; Blend between self-illum + base * lightmap
|
@ -0,0 +1,21 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c1 - self-illum tint
|
||||
; c2 - envmap tint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t1
|
||||
tex t2
|
||||
|
||||
mov r0.rgb, v0 + ; vertex color
|
||||
mul r0.a, v0.a, t2.a ; vertex alpha * envmap alpha
|
||||
|
||||
mad r0.rgb, t2, c2, r0 ; + envmap * envmaptint (color only)
|
||||
mul r0.rgb, t1, r0 ; fold in lightmap (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
@ -0,0 +1,20 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c1 - self-illum tint
|
||||
; c2 - envmap tint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
|
||||
mul r0, t0, v0 ; base times vertex color (with alpha)
|
||||
mul r0.rgb, t1, r0 ; fold in lightmap (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
mad r0.rgb, t2, c2, r0 ; + envmap * envmaptint (color only)
|
@ -0,0 +1,45 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; $SHADER_SPECIFIC_CONST_0-$SHADER_SPECIFIC_CONST_1 = Base texture transform
|
||||
; $SHADER_SPECIFIC_CONST_2-$SHADER_SPECIFIC_CONST_3 = Mask texture transform
|
||||
; $SHADER_SPECIFIC_CONST_4 = Modulation color
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
; Transform position from object to projection space
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
; YUCK! This is to make texcoords continuous for mat_softwaretl
|
||||
mov oT0, $cZero
|
||||
; Texture coordinates
|
||||
mov oT1, $vTexCoord1
|
||||
|
||||
mov oD0, $cOne
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
ps.1.1
|
||||
|
||||
tex t1
|
||||
|
||||
mov r0.rgba, t1
|
||||
|
@ -0,0 +1,24 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c1 - self-illum tint
|
||||
; c2 - envmap tint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
mov r0.rgb, v0 ; vertex color
|
||||
mul r1, t2, t3 ; envmap * envmapmask
|
||||
|
||||
mad r0.rgb, r1, c2, r0 + ; + envmap * envmapmask * envmaptint (color only)
|
||||
mul r0.a, v0.a, r1.a ; alpha = vertex alpha * envmap alpha * envmapmask alpha
|
||||
|
||||
mul r0.rgb, t1, r0 ; fold in lightmap (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
@ -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
|
||||
; c1 - self-illum tint
|
||||
; c2 - envmap tint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
mul r0, t0, v0 ; base times vertex color (with alpha)
|
||||
mul r0.rgb, t1, r0 ; fold in lighting (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
mul r1, t2, t3 ; envmap * envmapmask
|
||||
mad r0.rgb, r1, c2, r0 ; + envmap * envmapmask * envmaptint (color only)
|
@ -0,0 +1,20 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
def c2, 1.0f, 1.0f, 1.0f, 1.0f
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
|
||||
; Blend between grey and lightmap color based on total alpha
|
||||
|
||||
mul_x2 r1.rgb, c0, t1 ; Apply overbright to lightmap
|
||||
+ mul_sat r1.a, t0, v0 ; base times vertex alpha
|
||||
lrp r0, r1.a, r1, c2 ; interpolate between white + color
|
@ -0,0 +1,20 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
def c2, 1.0f, 1.0f, 1.0f, 1.0f
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
|
||||
; Blend between grey and lightmap color based on total alpha
|
||||
|
||||
mul_x2 r1.rgb, c0, t1 ; Apply overbright to lightmap
|
||||
+ mov_sat r1.a, v0 ; vertex alpha
|
||||
lrp r0, r1.a, r1, c2 ; interpolate between white + color
|
@ -0,0 +1,23 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
def c2, 1.0f, 1.0f, 1.0f, 1.0f
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
|
||||
; Blend between white and lightmap color based on total alpha
|
||||
mul_x2 r1.rgb, c0, t1 ; Apply overbright to lightmap
|
||||
+ mov_sat r1.a, v0 ; opacity == vertex opacity (no alpha in texture)
|
||||
|
||||
lrp r0.rgb, t0.a, c1, r1 ; Blend between self-illum + lightmap
|
||||
+ mov r0.a, c2.a
|
||||
|
||||
lrp r0.rgb, r1.a, r0, c2 ; interpolate between white + color
|
@ -0,0 +1,14 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t1
|
||||
mul r0.rgb, t1, v0 + ; base times vertex color (with alpha)
|
||||
mov r0.a, v0.a
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
@ -0,0 +1,34 @@
|
||||
ps.1.1
|
||||
def c0, 1,0,0,0
|
||||
def c1, 0,1,0,0
|
||||
def c2, 0,0,1,0
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Computes the diffuse component of lighting using lightmap + bumpmap
|
||||
; t0 - Normalmap
|
||||
; t1 - Lightmap1
|
||||
; t2 - Lightmap2
|
||||
; t3 - Lightmap3
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - Normalmap and lightmap texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Get the 3-vector from the normal map
|
||||
tex t0
|
||||
|
||||
; Sample the lightmaps
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
; output = lightmapColor[0] * n.r + lightmapColor[1] * n.g + lightmapColor[2] * n.b
|
||||
|
||||
|
||||
mov r0, t0
|
||||
dp3 r1, t0, c0
|
||||
mul r0.rgb, r1, t1
|
||||
dp3 r1, t0, c1
|
||||
mad r0.rgb, r1, t2, r0
|
||||
dp3 r1, t0, c2
|
||||
mad r0.rgb, r1, t3, r0
|
@ -0,0 +1,21 @@
|
||||
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, t0, v0 + ; base times vertex color (no alpha)
|
||||
mov r0.a, v0.a ; Grab alpha from vertex color
|
||||
|
||||
mul r0.rgb, t1, r0 ; fold in lighting (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
mul r1, c1, t0 ; Self illum * tint
|
||||
lrp r0.rgb, t0.a, r1, r0 ; Blend between self-illum + base * lightmap
|
@ -0,0 +1,27 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c1 - self-illum tint
|
||||
; c2 - envmap tint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
|
||||
mul r0.rgb, t0, v0 + ; base times vertex color (no alpha)
|
||||
mov r0.a, v0.a ; Grab alpha from vertex color
|
||||
|
||||
mul r1, t0.a, t0 ; Self illum
|
||||
mad r1, c1, r1, t1 ; Self illum * tint + lightmap
|
||||
|
||||
mul r0.rgb, r1, r0 ; fold in lighting (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
mad r0.rgb, t2, c2, r0 ; + envmap * envmaptint (color only)
|
||||
|
@ -0,0 +1,28 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c1 - self-illum tint
|
||||
; c2 - envmap tint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
mul r0.rgb, t0, v0 + ; base times vertex color (with alpha)
|
||||
mov r0.a, v0.a ; Grab alpha from vertex color
|
||||
|
||||
mul r1, c1, t0.a ; Self illum alpha * tint
|
||||
mad r1, t0, r1, t1 ; Self illum * tint + lightmap
|
||||
mul r0.rgb, r1, r0 ; fold in lighting (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
mul r1, t2, t3 ; envmap * envmapmask
|
||||
mad r0.rgb, r1, c2, r0 ; + envmap * envmapmask * envmaptint (color only)
|
||||
|
@ -0,0 +1,15 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "LightmappedGeneric_inc.vsh"
|
||||
|
||||
$detail = 0;
|
||||
$envmap = 0;
|
||||
$envmapcameraspace = 0;
|
||||
$envmapsphere = 0;
|
||||
$vertexcolor = 1;
|
||||
|
||||
&LightmappedGeneric( $detail, $envmap, $envmapcameraspace, $envmapsphere,
|
||||
$vertexcolor );
|
||||
|
105
mp/src/materialsystem/stdshaders/Refract_model_vs11.vsh
Normal file
105
mp/src/materialsystem/stdshaders/Refract_model_vs11.vsh
Normal file
@ -0,0 +1,105 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
# DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Constants specified by the app
|
||||
; c0 = (0, 1, 2, 0.5)
|
||||
; c1 = (1/2.2, 0, 0, 0)
|
||||
; 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, undefined]
|
||||
;
|
||||
; Vertex components (as specified in the vertex DECL)
|
||||
; $vPos = Position
|
||||
; $vTexCoord0.xy = TexCoord0
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
; Vertex components
|
||||
; $vPos = Position
|
||||
; $vNormal = normal
|
||||
; $vTexCoord0.xy = TexCoord0
|
||||
; $vTangentS = S axis of Texture space
|
||||
; $vTangentT = T axis of Texture space
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Transform the position from world to view space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
alloc $worldNormal
|
||||
alloc $worldTangentS
|
||||
alloc $worldTangentT
|
||||
|
||||
&SkinPositionNormalAndTangentSpace( $worldPos, $worldNormal,
|
||||
$worldTangentS, $worldTangentT );
|
||||
|
||||
alloc $projPos
|
||||
|
||||
; Transform position from world to projection space
|
||||
dp4 $projPos.x, $worldPos, $cViewProj0
|
||||
dp4 $projPos.y, $worldPos, $cViewProj1
|
||||
dp4 $projPos.z, $worldPos, $cViewProj2
|
||||
dp4 $projPos.w, $worldPos, $cViewProj3
|
||||
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
|
||||
alloc $worldEyeVect
|
||||
|
||||
; Get the eye vector in world space
|
||||
add $worldEyeVect.xyz, -$worldPos, $cEyePos
|
||||
|
||||
alloc $tangentEyeVect
|
||||
; transform the eye vector to tangent space
|
||||
dp3 oT3.x, $worldEyeVect, $worldTangentS
|
||||
dp3 oT3.y, $worldEyeVect, $worldTangentT
|
||||
dp3 oT3.z, $worldEyeVect, $worldNormal
|
||||
|
||||
alloc $bumpTexCoord
|
||||
|
||||
dp4 $bumpTexCoord.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
dp4 $bumpTexCoord.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
|
||||
|
||||
; dudv map
|
||||
mov oT0.xy, $bumpTexCoord
|
||||
|
||||
; refract tint + alpha channel
|
||||
mov oT2.xy, $bumpTexCoord
|
||||
mov oT3.xy, $bumpTexCoord
|
||||
|
||||
free $bumpTexCoord
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
; special case perspective correct texture projection so that the texture fits exactly on the screen
|
||||
|
||||
; flip Y by multiplying by -1
|
||||
mul $projPos.y, $projPos.y, $SHADER_SPECIFIC_CONST_4.w
|
||||
|
||||
; transform from [-w,w] to [0,2*w]
|
||||
; The reason this is w is because we are in perspective space/homogenous clip space.
|
||||
add $projPos.xy, $projPos.xy, $projPos.w
|
||||
|
||||
; transform from [0,2*w] to [0,w]
|
||||
; We'll end up dividing by w in the pixel shader to get to [0,1]
|
||||
mul $projPos.xy, $projPos.xy, $cHalf
|
||||
|
||||
mov oT1.xy, $projPos.xy
|
||||
|
||||
; emit w to both z and w in case the driver screws up and divides by z
|
||||
mov oT1.z, $projPos.w
|
||||
mov oT1.w, $projPos.w
|
||||
|
||||
free $projPos
|
||||
free $worldPos
|
||||
free $worldEyeVect
|
||||
free $tangentEyeVect
|
||||
free $w
|
||||
free $worldNormal
|
||||
free $worldTangentS
|
||||
free $worldTangentT
|
36
mp/src/materialsystem/stdshaders/Refract_ps11.psh
Normal file
36
mp/src/materialsystem/stdshaders/Refract_ps11.psh
Normal file
@ -0,0 +1,36 @@
|
||||
; STATIC: "REFRACTTINTTEXTURE" "0..1"
|
||||
; STATIC: "NORMALMAPALPHA" "0..1"
|
||||
|
||||
ps.1.1
|
||||
|
||||
; t0:
|
||||
; texture: dudv map
|
||||
; texcoords: dudvmap texcoords
|
||||
; t1:
|
||||
; texture: refraction render target
|
||||
; texcoords:
|
||||
|
||||
tex t0 ; sample dudv map
|
||||
texbem t1, t0 ; refraction
|
||||
|
||||
#if REFRACTTINTTEXTURE
|
||||
tex t2
|
||||
#endif
|
||||
|
||||
#if NORMALMAPALPHA
|
||||
tex t3
|
||||
#endif
|
||||
|
||||
; refracttint
|
||||
#if REFRACTTINTTEXTURE
|
||||
mul_x2 r0, t1, t2
|
||||
#else
|
||||
mov r0, t1
|
||||
#endif
|
||||
|
||||
#if NORMALMAPALPHA
|
||||
mul r0.rgb, r0, c0 +
|
||||
mov r0.a, t3.a
|
||||
#else
|
||||
mul r0.rgb, r0, c0
|
||||
#endif
|
140
mp/src/materialsystem/stdshaders/Refract_vs20.fxc
Normal file
140
mp/src/materialsystem/stdshaders/Refract_vs20.fxc
Normal file
@ -0,0 +1,140 @@
|
||||
//====== Copyright © 1996-2005, 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 );
|
||||
|
||||
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 )
|
||||
float vFog : 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 fogFactorW : COLOR1;
|
||||
|
||||
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 = mul( v.vPos, cModel[0] );
|
||||
worldTangentS = mul( v.vTangentS, ( const float3x3 )cModel[0] );
|
||||
worldTangentT = mul( v.vTangentT, ( const float3x3 )cModel[0] );
|
||||
worldNormal = mul( vObjNormal, ( float3x3 )cModel[0] );
|
||||
#endif
|
||||
|
||||
// World normal
|
||||
o.vWorldNormal.xyz = normalize( worldNormal.xyz );
|
||||
|
||||
// Projected position
|
||||
float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
o.vProjPos_POSITION = vProjPos;
|
||||
vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ );
|
||||
o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z );
|
||||
//o.projNormal.xyz = mul( worldNormal, cViewProj );
|
||||
|
||||
// Map projected position to the refraction texture
|
||||
float2 vRefractPos;
|
||||
vRefractPos.x = vProjPos.x;
|
||||
vRefractPos.y = -vProjPos.y; // invert Y
|
||||
vRefractPos = (vRefractPos + vProjPos.w) * 0.5f;
|
||||
|
||||
// Refraction transform
|
||||
o.vRefractXYW = float3(vRefractPos.x, vRefractPos.y, vProjPos.w);
|
||||
|
||||
// Compute fog based on the position
|
||||
float3 vWorldPos = mul( v.vPos, cModel[0] );
|
||||
o.fogFactorW = CalcFog( vWorldPos, vProjPos, FOGTYPE_RANGE );
|
||||
#if !defined( _X360 )
|
||||
o.vFog = o.fogFactorW;
|
||||
#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 = normalize( worldNormal.xyz );
|
||||
o.vWorldTangent.xyz = worldTangentS.xyz;
|
||||
o.vWorldBinormal.xyz = worldTangentT.xyz;
|
||||
|
||||
return o;
|
||||
}
|
168
mp/src/materialsystem/stdshaders/Refract_world_vs11.vsh
Normal file
168
mp/src/materialsystem/stdshaders/Refract_world_vs11.vsh
Normal file
@ -0,0 +1,168 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Constants specified by the app
|
||||
; c0 = (0, 1, 2, 0.5)
|
||||
; c1 = (1/2.2, 0, 0, 0)
|
||||
; 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, undefined]
|
||||
;
|
||||
; Vertex components (as specified in the vertex DECL)
|
||||
; $vPos = Position
|
||||
; $vTexCoord0.xy = TexCoord0
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
; Vertex components
|
||||
; $vPos = Position
|
||||
; $vNormal = normal
|
||||
; $vTexCoord0.xy = TexCoord0
|
||||
; $vTangentS = S axis of Texture space
|
||||
; $vTangentT = T axis of Texture space
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Transform the position from world to view space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
alloc $worldNormal
|
||||
alloc $worldTangentS
|
||||
alloc $worldTangentT
|
||||
alloc $projPos
|
||||
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
mov oPos, $projPos
|
||||
|
||||
dp3 $worldPos.x, $vPos, $cModel0
|
||||
dp3 $worldPos.y, $vPos, $cModel1
|
||||
dp3 $worldPos.z, $vPos, $cModel2
|
||||
|
||||
dp3 $worldNormal.x, $vNormal, $cModel0
|
||||
dp3 $worldNormal.y, $vNormal, $cModel1
|
||||
dp3 $worldNormal.z, $vNormal, $cModel2
|
||||
|
||||
dp3 $worldTangentS.x, $vTangentS, $cModel0
|
||||
dp3 $worldTangentS.y, $vTangentS, $cModel1
|
||||
dp3 $worldTangentS.z, $vTangentS, $cModel2
|
||||
|
||||
dp3 $worldTangentT.x, $vTangentT, $cModel0
|
||||
dp3 $worldTangentT.y, $vTangentT, $cModel1
|
||||
dp3 $worldTangentT.z, $vTangentT, $cModel2
|
||||
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
|
||||
alloc $worldEyeVect
|
||||
|
||||
; Get the eye vector in world space
|
||||
add $worldEyeVect.xyz, -$worldPos, $cEyePos
|
||||
|
||||
alloc $tangentEyeVect
|
||||
alloc $bumpTexCoord
|
||||
|
||||
; transform the eye vector to tangent space
|
||||
dp3 $tangentEyeVect.x, $worldEyeVect, $worldTangentS
|
||||
dp3 $tangentEyeVect.y, $worldEyeVect, $worldTangentT
|
||||
dp3 $tangentEyeVect.z, $worldEyeVect, $worldNormal
|
||||
|
||||
&Normalize( $tangentEyeVect );
|
||||
|
||||
; stick the tangent space eye vector into oD0
|
||||
mad oD0.xyz, $tangentEyeVect, $cHalf, $cHalf
|
||||
|
||||
dp4 $bumpTexCoord.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
dp4 $bumpTexCoord.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
|
||||
|
||||
; dudv map
|
||||
mov oT0.xy, $bumpTexCoord
|
||||
|
||||
; refract tint
|
||||
mov oT3.xy, $bumpTexCoord
|
||||
|
||||
free $bumpTexCoord
|
||||
|
||||
alloc $newProjPos
|
||||
alloc $w
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
; special case perspective correct texture projection so that the texture fits exactly on the screen
|
||||
mul $projPos.y, $projPos.y, $SHADER_SPECIFIC_CONST_4.w
|
||||
add $projPos.xy, $projPos.xy, $projPos.w
|
||||
mul $projPos.xy, $projPos.xy, $cHalf
|
||||
|
||||
; Do the perspective divide here. .yuck . . we aren't going to be perspective correct
|
||||
rcp $w.w, $projPos.w
|
||||
mul $projPos, $projPos, $w.w
|
||||
|
||||
#max $projPos.x, $projPos.x, -$cOne
|
||||
#min $projPos.x, $projPos.x, $cOne
|
||||
#max $projPos.z, $projPos.z, $cZero
|
||||
#min $projPos.z, $projPos.z, $cOne
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Transform the tangentS from world to view space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $projTangentS
|
||||
|
||||
; we only care about x and y
|
||||
dp3 $projTangentS.x, $worldTangentS, $cViewProj0
|
||||
dp3 $projTangentS.y, $worldTangentS, $cViewProj1
|
||||
|
||||
; project tangentS
|
||||
mul $projTangentS.xy, $projTangentS.xy, $w.w
|
||||
|
||||
;max $projTangentS.xy, $projTangentS.xy, $cOne
|
||||
;min $projTangentS.xy, $projTangentS.xy, -$cOne
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Transform the tangentT from world to view space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $projTangentT
|
||||
alloc $texCoord
|
||||
|
||||
; we only care about x and y
|
||||
dp3 $projTangentT.x, $worldTangentT, $cViewProj0
|
||||
dp3 $projTangentT.y, $worldTangentT, $cViewProj1
|
||||
|
||||
; project tangentT
|
||||
mul $projTangentT.xy, $projTangentT.xy, $w.w
|
||||
|
||||
;max $projTangentT.xy, $projTangentT.xy, $cOne
|
||||
;min $projTangentT.xy, $projTangentT.xy, -$cOne
|
||||
|
||||
;max $projPos.xy, $projPos.xy, $cOne
|
||||
;min $projPos.xy, $projPos.xy, -$cOne
|
||||
|
||||
mul oT1.x, $projTangentS.x, $SHADER_SPECIFIC_CONST_3.x
|
||||
mul oT1.y, $projTangentT.x, $SHADER_SPECIFIC_CONST_3.x
|
||||
mov oT1.z, $projPos.x ; huh?
|
||||
|
||||
mul $texCoord.x, $projTangentS.y, -$SHADER_SPECIFIC_CONST_3.x
|
||||
mul $texCoord.y, $projTangentT.y, -$SHADER_SPECIFIC_CONST_3.x
|
||||
mov $texCoord.z, $projPos.y
|
||||
mov oT2.xyz, $texCoord
|
||||
mov oT3.xyz, $texCoord
|
||||
|
||||
free $texCoord
|
||||
free $projPos
|
||||
free $worldPos
|
||||
free $worldEyeVect
|
||||
free $tangentEyeVect
|
||||
free $w
|
||||
free $projTangentS
|
||||
free $projTangentT
|
||||
free $newProjPos
|
||||
free $worldNormal
|
||||
free $worldTangentS
|
||||
free $worldTangentT
|
22
mp/src/materialsystem/stdshaders/ShadowModel.psh
Normal file
22
mp/src/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
mp/src/materialsystem/stdshaders/ShadowModel.vsh
Normal file
85
mp/src/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 );
|
||||
|
97
mp/src/materialsystem/stdshaders/Teeth.vsh
Normal file
97
mp/src/materialsystem/stdshaders/Teeth.vsh
Normal file
@ -0,0 +1,97 @@
|
||||
vs.1.1
|
||||
|
||||
# STATIC: "INTRO" "0..1"
|
||||
# STATIC: "HALF_LAMBERT" "0..1"
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
# DYNAMIC: "LIGHT_COMBO" "0..21"
|
||||
# DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; $SHADER_SPECIFIC_CONST_0 = xyz = mouth forward direction vector, w = illum factor
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
$WARPPARAM = $SHADER_SPECIFIC_CONST_2;
|
||||
$ENTITY_ORIGIN = $SHADER_SPECIFIC_CONST_3;
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
alloc $worldPos
|
||||
alloc $worldNormal
|
||||
&SkinPositionAndNormal( $worldPos, $worldNormal );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Optional intro warping
|
||||
;------------------------------------------------------------------------------
|
||||
if ( $INTRO == 1 )
|
||||
{
|
||||
alloc $tmp
|
||||
sub $tmp.xyz, $worldPos, $ENTITY_ORIGIN
|
||||
mul $tmp.xy, $tmp, $WARPPARAM
|
||||
add $worldPos.xyz, $tmp, $ENTITY_ORIGIN
|
||||
free $tmp
|
||||
}
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Transform the position from world to view space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $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 );
|
||||
|
||||
free $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Lighting
|
||||
;------------------------------------------------------------------------------
|
||||
alloc $linearColor
|
||||
&DoDynamicLightingToLinear( $worldPos, $worldNormal, $linearColor );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Factor in teeth darkening factors
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $tmp
|
||||
|
||||
mul $linearColor.xyz, $SHADER_SPECIFIC_CONST_0.w, $linearColor ; FIXME Color darkened by illumination factor
|
||||
dp3 $tmp, $worldNormal, $SHADER_SPECIFIC_CONST_0 ; Figure out mouth forward dot normal
|
||||
max $tmp, $cZero, $tmp ; clamp from 0 to 1
|
||||
mul $linearColor.xyz, $tmp, $linearColor ; Darken by forward dot normal too
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Output color (gamma correction)
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $gammaColor
|
||||
&LinearToGamma( $linearColor, $gammaColor );
|
||||
free $linearColor
|
||||
mul oD0.xyz, $gammaColor.xyz, $cOverbrightFactor
|
||||
mov oD0.w, $cOne ; make sure all components are defined
|
||||
|
||||
|
||||
free $gammaColor
|
||||
free $worldPos
|
||||
free $worldNormal
|
||||
free $tmp
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
mov oT0, $vTexCoord0
|
||||
|
||||
|
||||
|
13
mp/src/materialsystem/stdshaders/UnlitGeneric.psh
Normal file
13
mp/src/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
|
@ -0,0 +1,19 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0 ; base color
|
||||
tex t1 ; cube map
|
||||
tex t2 ; envmap mask
|
||||
|
||||
mul r0.rgb, t1, 1-t2.a ; can't use mad cause can't use 3 texture registers
|
||||
mul r0.rgb, c2, r0 ; apply the envmaptint
|
||||
mad r0.rgb, t0, v0, r0
|
||||
+ mul r0.a, t0, v0
|
15
mp/src/materialsystem/stdshaders/UnlitGeneric_Detail.psh
Normal file
15
mp/src/materialsystem/stdshaders/UnlitGeneric_Detail.psh
Normal file
@ -0,0 +1,15 @@
|
||||
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
|
||||
tex t3 ; detail texture
|
||||
|
||||
mul r0, t0, v0
|
||||
mul_x2 r0.rgb, r0, t3
|
@ -0,0 +1,29 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0 ; base color
|
||||
tex t1 ; cube map
|
||||
tex t2 ; envmap mask
|
||||
tex t3 ; detail texture
|
||||
|
||||
; version 1: applies the mod2x *after* environment map
|
||||
;mul r0.rgb, t1, 1-t2.a ; can't use mad cause can't use 3 texture registers
|
||||
;mul r0.rgb, c2, r0 ; apply the envmaptint
|
||||
;mad r0.rgb, t0, v0, r0
|
||||
;+ mul r0.a, t0, v0
|
||||
;mul_x2 r0.rgb, r0, t3 ; mod2x detail texture
|
||||
|
||||
; version 2: applies the mod2x *before* environment map
|
||||
mul r0, t0, v0 ; Base times modulation color
|
||||
mul_x2 r0.rgb, r0, t3 ; mod2x detail texture
|
||||
mul r1, t1, 1-t2.a ; Have to invert the alpha for basealpha (feh!)
|
||||
mul r1, c2, r1 ; apply the envmaptint
|
||||
add r0.rgb, r0, r1 ; add in the envmap
|
@ -0,0 +1,25 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0 ; base color
|
||||
tex t1 ; cube map
|
||||
tex t3 ; detail texture
|
||||
|
||||
; version 1: applies the mod2x *after* environment map
|
||||
;mul r1, c2, t1
|
||||
;mad r0.rgb, t0, v0, r1
|
||||
;+ mul r0.a, t0, v0
|
||||
;mul_x2 r0.rgb, r0, t3 ; mod2x detail texture
|
||||
|
||||
; version 2: applies the mod2x *before* environment map
|
||||
mul r0, t0, v0 ; Base times modulation color
|
||||
mul_x2 r0.rgb, r0, t3 ; mod2x detail texture
|
||||
mad r0.rgb, c2, t1, r0 ; add in tinted envmap
|
@ -0,0 +1,29 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0 ; base color
|
||||
tex t1 ; cube map
|
||||
tex t2 ; envmap mask
|
||||
tex t3 ; detail texture
|
||||
|
||||
; version 1: applies the mod2x *after* environment map
|
||||
;mul r0.rgb, t1, t2 ; can't use mad cause can't use 3 texture registers
|
||||
;mul r0.rgb, c2, r0 ; apply the envmaptint
|
||||
;mad r0.rgb, t0, v0, r0
|
||||
;+ mul r0.a, t0, v0
|
||||
;mul_x2 r0.rgb, r0, t3 ; mod2x detail texture
|
||||
|
||||
; version 2: applies the mod2x *before* environment map
|
||||
mul r0, t0, v0 ; Base times modulation color
|
||||
mul_x2 r0.rgb, r0, t3 ; mod2x detail texture
|
||||
mul r1, t1, t2 ; Envmap * envmapmask
|
||||
mul r1, c2, r1 ; apply the envmaptint
|
||||
add r0.rgb, r0, r1 ; add in the envmap
|
@ -0,0 +1,21 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t1 ; cube map
|
||||
tex t2 ; envmap mask
|
||||
tex t3 ; detail texture
|
||||
|
||||
; version 1: applies the mod2x *after* environment map
|
||||
; version 2 doesn't make sense here!
|
||||
mul r0, t1, t2
|
||||
mul r0.rgb, c2, r0
|
||||
mul r0, r0, v0
|
||||
mul_x2 r0.rgb, r0, t3 ; mod2x detail texture
|
@ -0,0 +1,19 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t1 ; cube map
|
||||
tex t3 ; detail texture
|
||||
|
||||
; version 1: applies the mod2x *after* environment map
|
||||
; version 2 doesn't make sense here!
|
||||
mul r0, v0, t1
|
||||
mul r0.rgb, r0, c2
|
||||
mul_x2 r0.rgb, r0, t3 ; mod2x detail texture
|
@ -0,0 +1,10 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Just use the vertex color
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t3
|
||||
|
||||
mul_x2 r0.rgb, v0, t3
|
||||
+ mov r0.a, v0.a
|
17
mp/src/materialsystem/stdshaders/UnlitGeneric_EnvMap.psh
Normal file
17
mp/src/materialsystem/stdshaders/UnlitGeneric_EnvMap.psh
Normal file
@ -0,0 +1,17 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0 ; base color
|
||||
tex t1 ; cube map
|
||||
|
||||
mul r1, c2, t1
|
||||
mad r0.rgb, t0, v0, r1
|
||||
+ mul r0.a, t0, v0
|
19
mp/src/materialsystem/stdshaders/UnlitGeneric_EnvMapMask.psh
Normal file
19
mp/src/materialsystem/stdshaders/UnlitGeneric_EnvMapMask.psh
Normal file
@ -0,0 +1,19 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0 ; base color
|
||||
tex t1 ; cube map
|
||||
tex t2 ; envmap mask
|
||||
|
||||
mul r0.rgb, t1, t2 ; can't use mad cause can't use 3 texture registers
|
||||
mul r0.rgb, c2, r0 ; apply the envmaptint
|
||||
mad r0.rgb, t0, v0, r0
|
||||
+ mul r0.a, t0, v0
|
@ -0,0 +1,17 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t1 ; cube map
|
||||
tex t2 ; envmap mask
|
||||
|
||||
mul r0, t1, t2
|
||||
mul r0.rgb, c2, r0
|
||||
mul r0, r0, v0
|
@ -0,0 +1,15 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t1 ; cube map
|
||||
|
||||
mul r0, v0, t1
|
||||
mul r0.rgb, r0, c2
|
@ -0,0 +1,21 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
# DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
&AllocateRegister( \$worldPos );
|
||||
&SkinPosition( $worldPos );
|
||||
|
||||
; Transform the position from world to view space
|
||||
dp4 oPos.x, $worldPos, $cViewProj0
|
||||
dp4 oPos.y, $worldPos, $cViewProj1
|
||||
dp4 oPos.z, $worldPos, $cViewProj2
|
||||
dp4 oPos.w, $worldPos, $cViewProj3
|
||||
|
||||
&FreeRegister( \$worldPos );
|
||||
|
||||
mov oD0, $cOne
|
||||
|
||||
|
@ -0,0 +1,20 @@
|
||||
#define HDRTYPE HDR_TYPE_NONE
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 texCoord0 : TEXCOORD0;
|
||||
float2 texCoord1 : TEXCOORD3;
|
||||
};
|
||||
|
||||
sampler BaseTextureSampler : register( s0 );
|
||||
sampler DetailTextureSampler : register( s3 );
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
// Sample frames from texture 0
|
||||
float4 base= tex2D( BaseTextureSampler, i.texCoord0 );
|
||||
float4 detail=tex2D( DetailTextureSampler, i.texCoord1 );
|
||||
|
||||
return float4(base.rgb, base.a * detail.a);
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Just use the vertex color
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
mov r0, v0
|
13
mp/src/materialsystem/stdshaders/VertexLitGeneric.psh
Normal file
13
mp/src/materialsystem/stdshaders/VertexLitGeneric.psh
Normal file
@ -0,0 +1,13 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
; Get the color from the texture
|
||||
tex t0
|
||||
|
||||
mul r0, t0, c3
|
||||
mul r0.rgb, v0, r0 ; Apply lighting
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
+mov r0.a, c4 ; make alpha 255
|
||||
#endif
|
@ -0,0 +1,17 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
tex t0 ; base color
|
||||
tex t1 ; cube map
|
||||
tex t2 ; envmap mask
|
||||
|
||||
mul r0, t0, c3 ; Base times modulation
|
||||
mul r1, t1, 1-t2.a ; Envmap * mask (in alpha channel)
|
||||
mul r0.rgb, v0, r0 ; apply vertex lighting
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
mad r0.rgb, r1, c2, r0 ; + envmap * mask * tint
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
+mov r0.a, c4 ; make alpha 255
|
||||
#endif
|
||||
|
@ -0,0 +1,17 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
; Get the color from the texture
|
||||
tex t0
|
||||
|
||||
mul r0, c3, t0
|
||||
lrp r0.rgb, c1, c3, r0
|
||||
lrp r0.rgb, t0.a, r0, t0
|
||||
mul r0.rgb, v0, r0 ; Apply lighting
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
+mov r0.a, c4 ; make alpha 255
|
||||
#else
|
||||
+mov r0.a, c3
|
||||
#endif
|
16
mp/src/materialsystem/stdshaders/VertexLitGeneric_Detail.psh
Normal file
16
mp/src/materialsystem/stdshaders/VertexLitGeneric_Detail.psh
Normal file
@ -0,0 +1,16 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
; Get the color from the texture
|
||||
tex t0
|
||||
tex t3
|
||||
|
||||
mul r0, t0, c3
|
||||
mul r0.rgb, v0, r0 ; Apply lighting
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
mul_x2 r1.rgb, r0, t3 ; detail texture
|
||||
lrp r0.rgb, c1, r1, r0
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
+mov r0.a, c4 ; make alpha 255
|
||||
#endif
|
@ -0,0 +1,18 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
tex t0 ; base color
|
||||
tex t1 ; cube map
|
||||
tex t2 ; envmap mask
|
||||
tex t3 ; detail texture
|
||||
|
||||
mul r0, t0, c3 ; Base times modulation
|
||||
mul r1, t1, 1-t2.a ; Envmap * mask (in alpha channel)
|
||||
mul r0.rgb, v0, r0 ; apply vertex lighting
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
mul_x2 r0.rgb, r0, t3 ; detail texture
|
||||
mad r0.rgb, r1, c2, r0 ; + envmap * mask * tint
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
+mov r0.a, c4 ; make alpha 255
|
||||
#endif
|
@ -0,0 +1,16 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
tex t0 ; base color
|
||||
tex t1 ; cube map
|
||||
tex t3 ; detail texture
|
||||
|
||||
mul r0, t0, c3 ; base times modulation
|
||||
mul r0.rgb, v0, r0 ; apply vertex lighting
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
mul_x2 r0.rgb, r0, t3 ; detail texture
|
||||
mad r0.rgb, t1, c2, r0 ; + envmap * envmaptint (color only)
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
+mov r0.a, c4 ; make alpha 255
|
||||
#endif
|
@ -0,0 +1,18 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
tex t0 ; base color
|
||||
tex t1 ; cube map
|
||||
tex t2 ; envmap mask
|
||||
tex t3 ; detail texture
|
||||
|
||||
mul r0, t0, c3 ; Base times modulation
|
||||
mul r1, t1, t2 ; Envmap * mask
|
||||
mul r0.rgb, v0, r0 ; apply vertex lighting
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
mul_x2 r0.rgb, r0, t3 ; detail texture
|
||||
mad r0.rgb, r1, c2, r0 ; + envmap * mask * tint
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
+mov r0.a, c4 ; make alpha 255
|
||||
#endif
|
@ -0,0 +1,12 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
tex t3
|
||||
|
||||
mul r0, v0, c3
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
mul_x2 r0.rgb, r0, t3 ; detail texture
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
+mov r0.a, c4 ; make alpha 255
|
||||
#endif
|
@ -0,0 +1,22 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
; Get the color from the texture
|
||||
tex t0
|
||||
tex t3
|
||||
|
||||
; interpolate between illuminated + non-selfilluminated
|
||||
mul r0.rgb, t0, c3 + ; base times modulation
|
||||
mov r0.a, c3.a
|
||||
|
||||
mul r0.rgb, v0, r0 ; Apply lighting
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
mul_x2 r0.rgb, r0, t3 ; detail texture
|
||||
|
||||
mul r1, t0, c1 ; Self illum * tint
|
||||
lrp r0.rgb, t0.a, r1, r0 ; Blend between self-illum + base * lighting
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
mov r0.a, c4 ; make alpha 255
|
||||
#endif
|
@ -0,0 +1,24 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
; Get the color from the texture
|
||||
tex t0
|
||||
tex t1
|
||||
tex t3
|
||||
|
||||
mul r0.rgb, t0, c3 + ; base times modulation
|
||||
mov r0.a, c3.a ; use modulation alpha (don't use texture alpha)
|
||||
|
||||
mul r0.rgb, v0, r0 ; Apply lighting
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
mul_x2 r0.rgb, r0, t3 ; detail texture
|
||||
|
||||
mul r1, t0, c1 ; Self illum * tint
|
||||
lrp r0.rgb, t0.a, r1, r0 ; Blend between self-illum + base * lighting
|
||||
|
||||
mad r0.rgb, t1, c2, r0 ; + envmap * envmaptint (color only)
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
+mov r0.a, c4 ; make alpha 255
|
||||
#endif
|
@ -0,0 +1,26 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
; Get the color from the texture
|
||||
tex t0 ; base
|
||||
tex t1 ; env map
|
||||
tex t2 ; mask
|
||||
tex t3 ; detail
|
||||
|
||||
mul r0.rgb, t0, c3 + ; base times modulation
|
||||
mul r0.a, c3.a, t2.a ; alpha = mod alpha * mask alpha
|
||||
|
||||
mul r0.rgb, v0, r0 ; Apply lighting
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
mul_x2 r0.rgb, r0, t3 ; detail texture
|
||||
|
||||
mul r1, t0, c1 ; Self illum * tint
|
||||
lrp r0.rgb, t0.a, r1, r0 ; Blend between self-illum + base * lighting
|
||||
|
||||
mul r1, t2, t1 ; envmapmask * envmap
|
||||
mad r0.rgb, r1, c2, r0 ; + envmapmask * envmap * envmaptint (color only)
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
+mov r0.a, c4 ; make alpha 255
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
; Get the color from the texture
|
||||
tex t0
|
||||
tex t3
|
||||
|
||||
lrp r0, c1, t3, t0 ; Lerp between textures
|
||||
mul r0, r0, c3
|
||||
mul r0.rgb, v0, r0 ; Apply lighting
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
+mov r0.a, c4 ; make alpha 255
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
; Get the color from the texture
|
||||
tex t0
|
||||
tex t3
|
||||
|
||||
mul r1, c1, t3
|
||||
mad r0, t0, c3, r1
|
||||
mul r0.rgb, v0, r0 ; Apply lighting
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
+mov r0.a, c4 ; make alpha 255
|
||||
#endif
|
@ -0,0 +1,15 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
; Get the color from the texture
|
||||
tex t0
|
||||
tex t3
|
||||
|
||||
mul r0, c3, t0
|
||||
mul r0.rgb, v0, r0 ; Apply lighting
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
mad r0.rgb, c1, t3, r0
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
+mov r0.a, c4 ; make alpha 255
|
||||
#endif
|
@ -0,0 +1,14 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
tex t1 ; cube map
|
||||
|
||||
mul r0.rgb, t1, c2 + ; envmap * envmaptint (color only) +
|
||||
mov r0.a, c3.a ; Use alpha from modulation... (?)
|
||||
|
||||
mul r0.rgb, v0, r0 ; apply vertex lighting
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
+mov r0.a, c4 ; make alpha 255
|
||||
#endif
|
@ -0,0 +1,14 @@
|
||||
; DYNAMIC: "WRITEONETODESTALPHA" "0..1"
|
||||
ps.1.1
|
||||
|
||||
tex t0 ; base color
|
||||
tex t1 ; cube map
|
||||
|
||||
mul r0, t0, c3 ; base times modulation
|
||||
mul r0.rgb, v0, r0 ; apply vertex lighting
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
mad r0.rgb, t1, c2, r0 ; + envmap * envmaptint (color only)
|
||||
|
||||
#if WRITEONETODESTALPHA
|
||||
+mov r0.a, c4 ; make alpha 255
|
||||
#endif
|
@ -0,0 +1,36 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Environment mapping on a bumped surface
|
||||
; t0 - Normalmap
|
||||
; t3 - Cube environment map (*must* be a cube map!)
|
||||
;
|
||||
; c0 - color to multiply the results by
|
||||
; Input texture coords required here are a little wonky.
|
||||
; tc0.uv <- U,V into the normal map
|
||||
; tc1.uvw, tc2.uvw, tc3.uvw <- 3x3 matrix transform
|
||||
; from tangent space->env map space
|
||||
; tc1.q, tc2.q, tc3.q <- eye vector in env map space
|
||||
;------------------------------------------------------------------------------
|
||||
; This version doesn't multiply by lighting.
|
||||
|
||||
; Get the 3-vector from the normal map
|
||||
tex t0
|
||||
|
||||
; Perform matrix multiply to get a local normal bump. Then
|
||||
; reflect the eye vector through the normal and sample from
|
||||
; a cubic environment map.
|
||||
texm3x3pad t1, t0_bx2
|
||||
texm3x3pad t2, t0_bx2
|
||||
texm3x3vspec t3, t0_bx2
|
||||
|
||||
; result goes in output color
|
||||
mul r0.rgb, t3, c0 ; constant color
|
||||
+mov r0.a, c0.a
|
||||
|
||||
mul r1.rgb, r0, r0
|
||||
lrp r0.rgb, c1, r1, r0 ; blend between color and color * color
|
||||
dp3 r1.rgb, r0, c3
|
||||
lrp r0.rgb, c2, r0, r1 ; blend between color and greyscale
|
||||
|
||||
|
@ -0,0 +1,42 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Environment mapping on a bumped surface
|
||||
; t0 - Normalmap
|
||||
; t3 - Cube environment map (*must* be a cube map!)
|
||||
;
|
||||
; c0 - color to multiply the results by
|
||||
; Input texture coords required here are a little wonky.
|
||||
; tc0.uv <- U,V into the normal map
|
||||
; tc1.uvw, tc2.uvw, tc3.uvw <- 3x3 matrix transform
|
||||
; from tangent space->env map space
|
||||
; tc1.q, tc2.q, tc3.q <- eye vector in env map space
|
||||
;------------------------------------------------------------------------------
|
||||
; This version doesn't multiply by lighting.
|
||||
|
||||
; Get the 3-vector from the normal map
|
||||
tex t0
|
||||
|
||||
; Perform matrix multiply to get a local normal bump. Then
|
||||
; reflect the eye vector through the normal and sample from
|
||||
; a cubic environment map.
|
||||
texm3x3pad t1, t0_bx2
|
||||
texm3x3pad t2, t0_bx2
|
||||
texm3x3vspec t3, t0_bx2
|
||||
|
||||
; result goes in output color
|
||||
mul r0.rgb, t3, c0 ; constant color
|
||||
+mov r0.a, c0.a
|
||||
|
||||
mul r1.rgb, r0, r0
|
||||
lrp r0.rgb, c1, r1, r0 ; blend between color and color * color
|
||||
dp3 r1.rgb, r0, c3
|
||||
lrp r0.rgb, c2, r0, r1 ; blend between color and greyscale
|
||||
|
||||
; Multiply the output color by the alpha channel of the normal map.
|
||||
mul r0.rgb, t0.a, r0
|
||||
|
||||
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user