|
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "BaseVSShader.h"
#include "predator.inc"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
DEFINE_FALLBACK_SHADER( Predator, Predator_DX80 )
BEGIN_VS_SHADER( Predator_DX80, "Help for Predator" )
BEGIN_SHADER_PARAMS SHADER_PARAM( REFRACTIONAMOUNT, SHADER_PARAM_TYPE_VEC2, "[0.2 0.2]", "refaction amount" ) SHADER_PARAM( ENVMAP, SHADER_PARAM_TYPE_TEXTURE, "shadertest/shadertest_env", "envmap" ) SHADER_PARAM( ENVMAPFRAME, SHADER_PARAM_TYPE_INTEGER, "", "envmap frame number" ) SHADER_PARAM( ENVMAPMASK, SHADER_PARAM_TYPE_TEXTURE, "shadertest/shadertest_envmask", "envmap mask" ) SHADER_PARAM( ENVMAPMASKFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "" ) SHADER_PARAM( ENVMAPMASKSCALE, SHADER_PARAM_TYPE_FLOAT, "1", "envmap mask scale" ) SHADER_PARAM( ENVMAPTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "envmap tint" ) SHADER_PARAM( REFRACTTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "refraction tint" ) SHADER_PARAM( BUMPMAP, SHADER_PARAM_TYPE_TEXTURE, "models/shadertes/shader1_normal", "bump map" ) SHADER_PARAM( BUMPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $bumpmap" ) SHADER_PARAM( BUMPOFFSET, SHADER_PARAM_TYPE_VEC2, "[0 0]", "2D bump offset for texture scrolling" ) END_SHADER_PARAMS SHADER_INIT_PARAMS() { SET_FLAGS2( MATERIAL_VAR2_NEEDS_TANGENT_SPACES ); SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING ); SET_FLAGS( MATERIAL_VAR_TRANSLUCENT ); SET_FLAGS2( MATERIAL_VAR2_NEEDS_POWER_OF_TWO_FRAME_BUFFER_TEXTURE ); }
SHADER_FALLBACK { if (!g_pHardwareConfig->SupportsVertexAndPixelShaders()) return "Predator_DX60"; return 0; }
SHADER_INIT { if( params[ENVMAP]->IsDefined() ) { LoadCubeMap( ENVMAP ); } if( params[ENVMAPMASK]->IsDefined() ) { LoadTexture( ENVMAPMASK ); } if( !params[ENVMAPTINT]->IsDefined() ) { params[ENVMAPTINT]->SetVecValue( 1.0f, 1.0f, 1.0f ); } if( !params[REFRACTTINT]->IsDefined() ) { params[REFRACTTINT]->SetVecValue( 1.0f, 1.0f, 1.0f ); } }
SHADER_DRAW { // Refractive pass
SHADOW_STATE { pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); int fmt = VERTEX_POSITION | VERTEX_NORMAL; pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
predator_Static_Index vshIndex; pShaderShadow->SetVertexShader( "predator", vshIndex.GetIndex() );
pShaderShadow->SetPixelShader( "predator" ); } DYNAMIC_STATE { pShaderAPI->SetDefaultState(); pShaderAPI->BindStandardTexture( SHADER_SAMPLER0, TEXTURE_FRAME_BUFFER_FULL_TEXTURE_0 ); SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_4, REFRACTIONAMOUNT ); float c95[4] = { 1.0f, 1.0f, 0.0f, 0.0f }; pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_5, c95, 1 ); SetPixelShaderConstant( 2, REFRACTTINT );
predator_Dynamic_Index vshIndex; vshIndex.SetDOWATERFOG( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); vshIndex.SetSKINNING( pShaderAPI->GetCurrentNumBones() > 0 ); pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() ); } Draw(); } END_SHADER
|