You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
521 lines
23 KiB
521 lines
23 KiB
5 years ago
|
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||
|
//
|
||
|
// Purpose:
|
||
|
//
|
||
|
// $Header: $
|
||
|
// $NoKeywords: $
|
||
|
//=====================================================================================//
|
||
|
|
||
|
#include "BaseVSShader.h"
|
||
|
#include "vertexlitgeneric_dx9_helper.h"
|
||
|
#include "emissive_scroll_blended_pass_helper.h"
|
||
|
#include "cloak_blended_pass_helper.h"
|
||
|
#include "flesh_interior_blended_pass_helper.h"
|
||
|
#include "weapon_sheen_pass_helper.h"
|
||
|
|
||
|
|
||
|
BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" )
|
||
|
BEGIN_SHADER_PARAMS
|
||
|
SHADER_PARAM( ALBEDO, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "albedo (Base texture with no baked lighting)" )
|
||
|
SHADER_PARAM( COMPRESS, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "compression wrinklemap" )
|
||
|
SHADER_PARAM( STRETCH, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "expansion wrinklemap" )
|
||
|
SHADER_PARAM( SELFILLUMTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "Self-illumination tint" )
|
||
|
SHADER_PARAM( DETAIL, SHADER_PARAM_TYPE_TEXTURE, "shadertest/detail", "detail texture" )
|
||
|
SHADER_PARAM( DETAILFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $detail" )
|
||
|
SHADER_PARAM( DETAILSCALE, SHADER_PARAM_TYPE_FLOAT, "4", "scale of the detail texture" )
|
||
|
SHADER_PARAM( ENVMAP, SHADER_PARAM_TYPE_TEXTURE, "shadertest/shadertest_env", "envmap" )
|
||
|
SHADER_PARAM( ENVMAPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "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( ENVMAPMASKTRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$envmapmask texcoord transform" )
|
||
|
SHADER_PARAM( ENVMAPTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "envmap tint" )
|
||
|
SHADER_PARAM( BUMPMAP, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader1_normal", "bump map" )
|
||
|
SHADER_PARAM( BUMPCOMPRESS, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader3_normal", "compression bump map" )
|
||
|
SHADER_PARAM( BUMPSTRETCH, SHADER_PARAM_TYPE_TEXTURE, "models/shadertest/shader1_normal", "expansion bump map" )
|
||
|
SHADER_PARAM( BUMPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $bumpmap" )
|
||
|
SHADER_PARAM( BUMPTRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$bumpmap texcoord transform" )
|
||
|
SHADER_PARAM( ENVMAPCONTRAST, SHADER_PARAM_TYPE_FLOAT, "0.0", "contrast 0 == normal 1 == color*color" )
|
||
|
SHADER_PARAM( ENVMAPSATURATION, SHADER_PARAM_TYPE_FLOAT, "1.0", "saturation 0 == greyscale 1 == normal" )
|
||
|
SHADER_PARAM( SELFILLUM_ENVMAPMASK_ALPHA, SHADER_PARAM_TYPE_FLOAT,"0.0","defines that self illum value comes from env map mask alpha" )
|
||
|
SHADER_PARAM( SELFILLUMFRESNEL, SHADER_PARAM_TYPE_BOOL, "0", "Self illum fresnel" )
|
||
|
SHADER_PARAM( SELFILLUMFRESNELMINMAXEXP, SHADER_PARAM_TYPE_VEC4, "0", "Self illum fresnel min, max, exp" )
|
||
|
SHADER_PARAM( ALPHATESTREFERENCE, SHADER_PARAM_TYPE_FLOAT, "0.0", "" )
|
||
|
SHADER_PARAM( FLASHLIGHTNOLAMBERT, SHADER_PARAM_TYPE_BOOL, "0", "Flashlight pass sets N.L=1.0" )
|
||
|
|
||
|
// Debugging term for visualizing ambient data on its own
|
||
|
SHADER_PARAM( AMBIENTONLY, SHADER_PARAM_TYPE_INTEGER, "0", "Control drawing of non-ambient light ()" )
|
||
|
|
||
|
SHADER_PARAM( PHONGEXPONENT, SHADER_PARAM_TYPE_FLOAT, "5.0", "Phong exponent for local specular lights" )
|
||
|
SHADER_PARAM( PHONGTINT, SHADER_PARAM_TYPE_VEC3, "5.0", "Phong tint for local specular lights" )
|
||
|
SHADER_PARAM( PHONGALBEDOTINT, SHADER_PARAM_TYPE_BOOL, "1.0", "Apply tint by albedo (controlled by spec exponent texture" )
|
||
|
SHADER_PARAM( LIGHTWARPTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "1D ramp texture for tinting scalar diffuse term" )
|
||
|
SHADER_PARAM( PHONGWARPTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "warp the specular term" )
|
||
|
SHADER_PARAM( PHONGFRESNELRANGES, SHADER_PARAM_TYPE_VEC3, "[0 0.5 1]", "Parameters for remapping fresnel output" )
|
||
|
SHADER_PARAM( PHONGBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "Phong overbrightening factor (specular mask channel should be authored to account for this)" )
|
||
|
SHADER_PARAM( PHONGEXPONENTTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "Phong Exponent map" )
|
||
|
SHADER_PARAM( PHONG, SHADER_PARAM_TYPE_BOOL, "0", "enables phong lighting" )
|
||
|
SHADER_PARAM( BASEMAPALPHAPHONGMASK, SHADER_PARAM_TYPE_INTEGER, "0", "indicates that there is no normal map and that the phong mask is in base alpha" )
|
||
|
SHADER_PARAM( INVERTPHONGMASK, SHADER_PARAM_TYPE_INTEGER, "0", "invert the phong mask (0=full phong, 1=no phong)" )
|
||
|
SHADER_PARAM( ENVMAPFRESNEL, SHADER_PARAM_TYPE_FLOAT, "0", "Degree to which Fresnel should be applied to env map" )
|
||
|
SHADER_PARAM( SELFILLUMMASK, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "If we bind a texture here, it overrides base alpha (if any) for self illum" )
|
||
|
|
||
|
// detail (multi-) texturing
|
||
|
SHADER_PARAM( DETAILBLENDMODE, SHADER_PARAM_TYPE_INTEGER, "0", "mode for combining detail texture with base. 0=normal, 1= additive, 2=alpha blend detail over base, 3=crossfade" )
|
||
|
SHADER_PARAM( DETAILBLENDFACTOR, SHADER_PARAM_TYPE_FLOAT, "1", "blend amount for detail texture." )
|
||
|
SHADER_PARAM( DETAILTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "detail texture tint" )
|
||
|
SHADER_PARAM( DETAILTEXTURETRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$detail texcoord transform" )
|
||
|
|
||
|
// Rim lighting terms
|
||
|
SHADER_PARAM( RIMLIGHT, SHADER_PARAM_TYPE_BOOL, "0", "enables rim lighting" )
|
||
|
SHADER_PARAM( RIMLIGHTEXPONENT, SHADER_PARAM_TYPE_FLOAT, "4.0", "Exponent for rim lights" )
|
||
|
SHADER_PARAM( RIMLIGHTBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "Boost for rim lights" )
|
||
|
SHADER_PARAM( RIMMASK, SHADER_PARAM_TYPE_BOOL, "0", "Indicates whether or not to use alpha channel of exponent texture to mask the rim term" )
|
||
|
|
||
|
// Seamless mapping scale
|
||
|
SHADER_PARAM( SEAMLESS_BASE, SHADER_PARAM_TYPE_BOOL, "0", "whether to apply seamless mapping to the base texture. requires a smooth model." )
|
||
|
SHADER_PARAM( SEAMLESS_DETAIL, SHADER_PARAM_TYPE_BOOL, "0", "where to apply seamless mapping to the detail texture." )
|
||
|
SHADER_PARAM( SEAMLESS_SCALE, SHADER_PARAM_TYPE_FLOAT, "1.0", "the scale for the seamless mapping. # of repetions of texture per inch." )
|
||
|
|
||
|
// Emissive Scroll Pass
|
||
|
SHADER_PARAM( EMISSIVEBLENDENABLED, SHADER_PARAM_TYPE_BOOL, "0", "Enable emissive blend pass" )
|
||
|
SHADER_PARAM( EMISSIVEBLENDBASETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "self-illumination map" )
|
||
|
SHADER_PARAM( EMISSIVEBLENDSCROLLVECTOR, SHADER_PARAM_TYPE_VEC2, "[0.11 0.124]", "Emissive scroll vec" )
|
||
|
SHADER_PARAM( EMISSIVEBLENDSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "1.0", "Emissive blend strength" )
|
||
|
SHADER_PARAM( EMISSIVEBLENDTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "self-illumination map" )
|
||
|
SHADER_PARAM( EMISSIVEBLENDTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "Self-illumination tint" )
|
||
|
SHADER_PARAM( EMISSIVEBLENDFLOWTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "flow map" )
|
||
|
SHADER_PARAM( TIME, SHADER_PARAM_TYPE_FLOAT, "0.0", "Needs CurrentTime Proxy" )
|
||
|
|
||
|
// Cloak Pass
|
||
|
SHADER_PARAM( CLOAKPASSENABLED, SHADER_PARAM_TYPE_BOOL, "0", "Enables cloak render in a second pass" )
|
||
|
SHADER_PARAM( CLOAKFACTOR, SHADER_PARAM_TYPE_FLOAT, "0.0", "" )
|
||
|
SHADER_PARAM( CLOAKCOLORTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "Cloak color tint" )
|
||
|
SHADER_PARAM( REFRACTAMOUNT, SHADER_PARAM_TYPE_FLOAT, "2", "" )
|
||
|
|
||
|
// Weapon Sheen Pass
|
||
|
SHADER_PARAM( SHEENPASSENABLED, SHADER_PARAM_TYPE_BOOL, "0", "Enables weapon sheen render in a second pass" )
|
||
|
SHADER_PARAM( SHEENMAP, SHADER_PARAM_TYPE_TEXTURE, "shadertest/shadertest_env", "sheenmap" )
|
||
|
SHADER_PARAM( SHEENMAPMASK, SHADER_PARAM_TYPE_TEXTURE, "shadertest/shadertest_envmask", "sheenmap mask" )
|
||
|
SHADER_PARAM( SHEENMAPMASKFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "" )
|
||
|
SHADER_PARAM( SHEENMAPTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "sheenmap tint" )
|
||
|
SHADER_PARAM( SHEENMAPMASKSCALEX, SHADER_PARAM_TYPE_FLOAT, "1", "X Scale the size of the map mask to the size of the target" )
|
||
|
SHADER_PARAM( SHEENMAPMASKSCALEY, SHADER_PARAM_TYPE_FLOAT, "1", "Y Scale the size of the map mask to the size of the target" )
|
||
|
SHADER_PARAM( SHEENMAPMASKOFFSETX, SHADER_PARAM_TYPE_FLOAT, "0", "X Offset of the mask relative to model space coords of target" )
|
||
|
SHADER_PARAM( SHEENMAPMASKOFFSETY, SHADER_PARAM_TYPE_FLOAT, "0", "Y Offset of the mask relative to model space coords of target" )
|
||
|
SHADER_PARAM( SHEENMAPMASKDIRECTION, SHADER_PARAM_TYPE_INTEGER, "0", "The direction the sheen should move (length direction of weapon) XYZ, 0,1,2" )
|
||
|
SHADER_PARAM( SHEENINDEX, SHADER_PARAM_TYPE_INTEGER, "0", "Index of the Effect Type (Color Additive, Override etc...)" )
|
||
|
|
||
|
// Flesh Interior Pass
|
||
|
SHADER_PARAM( FLESHINTERIORENABLED, SHADER_PARAM_TYPE_BOOL, "0", "Enable Flesh interior blend pass" )
|
||
|
SHADER_PARAM( FLESHINTERIORTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Flesh color texture" )
|
||
|
SHADER_PARAM( FLESHINTERIORNOISETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Flesh noise texture" )
|
||
|
SHADER_PARAM( FLESHBORDERTEXTURE1D, SHADER_PARAM_TYPE_TEXTURE, "", "Flesh border 1D texture" )
|
||
|
SHADER_PARAM( FLESHNORMALTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Flesh normal texture" )
|
||
|
SHADER_PARAM( FLESHSUBSURFACETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Flesh subsurface texture" )
|
||
|
SHADER_PARAM( FLESHCUBETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Flesh cubemap texture" )
|
||
|
SHADER_PARAM( FLESHBORDERNOISESCALE, SHADER_PARAM_TYPE_FLOAT, "1.5", "Flesh Noise UV scalar for border" )
|
||
|
SHADER_PARAM( FLESHDEBUGFORCEFLESHON, SHADER_PARAM_TYPE_BOOL, "0", "Flesh Debug full flesh" )
|
||
|
SHADER_PARAM( FLESHEFFECTCENTERRADIUS1, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0.001]", "Flesh effect center and radius" )
|
||
|
SHADER_PARAM( FLESHEFFECTCENTERRADIUS2, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0.001]", "Flesh effect center and radius" )
|
||
|
SHADER_PARAM( FLESHEFFECTCENTERRADIUS3, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0.001]", "Flesh effect center and radius" )
|
||
|
SHADER_PARAM( FLESHEFFECTCENTERRADIUS4, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0.001]", "Flesh effect center and radius" )
|
||
|
SHADER_PARAM( FLESHSUBSURFACETINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "Subsurface Color" )
|
||
|
SHADER_PARAM( FLESHBORDERWIDTH, SHADER_PARAM_TYPE_FLOAT, "0.3", "Flesh border" )
|
||
|
SHADER_PARAM( FLESHBORDERSOFTNESS, SHADER_PARAM_TYPE_FLOAT, "0.42", "Flesh border softness (> 0.0 && <= 0.5)" )
|
||
|
SHADER_PARAM( FLESHBORDERTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "Flesh border Color" )
|
||
|
SHADER_PARAM( FLESHGLOBALOPACITY, SHADER_PARAM_TYPE_FLOAT, "1.0", "Flesh global opacity" )
|
||
|
SHADER_PARAM( FLESHGLOSSBRIGHTNESS, SHADER_PARAM_TYPE_FLOAT, "0.66", "Flesh gloss brightness" )
|
||
|
SHADER_PARAM( FLESHSCROLLSPEED, SHADER_PARAM_TYPE_FLOAT, "1.0", "Flesh scroll speed" )
|
||
|
|
||
|
SHADER_PARAM( SEPARATEDETAILUVS, SHADER_PARAM_TYPE_BOOL, "0", "Use texcoord1 for detail texture" )
|
||
|
SHADER_PARAM( LINEARWRITE, SHADER_PARAM_TYPE_INTEGER, "0", "Disables SRGB conversion of shader results." )
|
||
|
SHADER_PARAM( DEPTHBLEND, SHADER_PARAM_TYPE_INTEGER, "0", "fade at intersection boundaries. Only supported without bumpmaps" )
|
||
|
SHADER_PARAM( DEPTHBLENDSCALE, SHADER_PARAM_TYPE_FLOAT, "50.0", "Amplify or reduce DEPTHBLEND fading. Lower values make harder edges." )
|
||
|
|
||
|
SHADER_PARAM( BLENDTINTBYBASEALPHA, SHADER_PARAM_TYPE_BOOL, "0", "Use the base alpha to blend in the $color modulation")
|
||
|
SHADER_PARAM( BLENDTINTCOLOROVERBASE, SHADER_PARAM_TYPE_FLOAT, "0", "blend between tint acting as a multiplication versus a replace" )
|
||
|
END_SHADER_PARAMS
|
||
|
|
||
|
void SetupVars( VertexLitGeneric_DX9_Vars_t& info )
|
||
|
{
|
||
|
info.m_nBaseTexture = BASETEXTURE;
|
||
|
info.m_nWrinkle = COMPRESS;
|
||
|
info.m_nStretch = STRETCH;
|
||
|
info.m_nBaseTextureFrame = FRAME;
|
||
|
info.m_nBaseTextureTransform = BASETEXTURETRANSFORM;
|
||
|
info.m_nAlbedo = ALBEDO;
|
||
|
info.m_nSelfIllumTint = SELFILLUMTINT;
|
||
|
info.m_nDetail = DETAIL;
|
||
|
info.m_nDetailFrame = DETAILFRAME;
|
||
|
info.m_nDetailScale = DETAILSCALE;
|
||
|
info.m_nEnvmap = ENVMAP;
|
||
|
info.m_nEnvmapFrame = ENVMAPFRAME;
|
||
|
info.m_nEnvmapMask = ENVMAPMASK;
|
||
|
info.m_nEnvmapMaskFrame = ENVMAPMASKFRAME;
|
||
|
info.m_nEnvmapMaskTransform = ENVMAPMASKTRANSFORM;
|
||
|
info.m_nEnvmapTint = ENVMAPTINT;
|
||
|
info.m_nBumpmap = BUMPMAP;
|
||
|
info.m_nNormalWrinkle = BUMPCOMPRESS;
|
||
|
info.m_nNormalStretch = BUMPSTRETCH;
|
||
|
info.m_nBumpFrame = BUMPFRAME;
|
||
|
info.m_nBumpTransform = BUMPTRANSFORM;
|
||
|
info.m_nEnvmapContrast = ENVMAPCONTRAST;
|
||
|
info.m_nEnvmapSaturation = ENVMAPSATURATION;
|
||
|
info.m_nAlphaTestReference = ALPHATESTREFERENCE;
|
||
|
info.m_nFlashlightNoLambert = FLASHLIGHTNOLAMBERT;
|
||
|
|
||
|
info.m_nFlashlightTexture = FLASHLIGHTTEXTURE;
|
||
|
info.m_nFlashlightTextureFrame = FLASHLIGHTTEXTUREFRAME;
|
||
|
info.m_nSelfIllumEnvMapMask_Alpha = SELFILLUM_ENVMAPMASK_ALPHA;
|
||
|
info.m_nSelfIllumFresnel = SELFILLUMFRESNEL;
|
||
|
info.m_nSelfIllumFresnelMinMaxExp = SELFILLUMFRESNELMINMAXEXP;
|
||
|
|
||
|
info.m_nAmbientOnly = AMBIENTONLY;
|
||
|
info.m_nPhongExponent = PHONGEXPONENT;
|
||
|
info.m_nPhongExponentTexture = PHONGEXPONENTTEXTURE;
|
||
|
info.m_nPhongTint = PHONGTINT;
|
||
|
info.m_nPhongAlbedoTint = PHONGALBEDOTINT;
|
||
|
info.m_nDiffuseWarpTexture = LIGHTWARPTEXTURE;
|
||
|
info.m_nPhongWarpTexture = PHONGWARPTEXTURE;
|
||
|
info.m_nPhongBoost = PHONGBOOST;
|
||
|
info.m_nPhongFresnelRanges = PHONGFRESNELRANGES;
|
||
|
info.m_nPhong = PHONG;
|
||
|
info.m_nBaseMapAlphaPhongMask = BASEMAPALPHAPHONGMASK;
|
||
|
info.m_nEnvmapFresnel = ENVMAPFRESNEL;
|
||
|
info.m_nDetailTextureCombineMode = DETAILBLENDMODE;
|
||
|
info.m_nDetailTextureBlendFactor = DETAILBLENDFACTOR;
|
||
|
info.m_nDetailTextureTransform = DETAILTEXTURETRANSFORM;
|
||
|
|
||
|
// Rim lighting parameters
|
||
|
info.m_nRimLight = RIMLIGHT;
|
||
|
info.m_nRimLightPower = RIMLIGHTEXPONENT;
|
||
|
info.m_nRimLightBoost = RIMLIGHTBOOST;
|
||
|
info.m_nRimMask = RIMMASK;
|
||
|
|
||
|
// seamless
|
||
|
info.m_nSeamlessScale = SEAMLESS_SCALE;
|
||
|
info.m_nSeamlessDetail = SEAMLESS_DETAIL;
|
||
|
info.m_nSeamlessBase = SEAMLESS_BASE;
|
||
|
|
||
|
info.m_nSeparateDetailUVs = SEPARATEDETAILUVS;
|
||
|
|
||
|
info.m_nLinearWrite = LINEARWRITE;
|
||
|
info.m_nDetailTint = DETAILTINT;
|
||
|
info.m_nInvertPhongMask = INVERTPHONGMASK;
|
||
|
|
||
|
info.m_nDepthBlend = DEPTHBLEND;
|
||
|
info.m_nDepthBlendScale = DEPTHBLENDSCALE;
|
||
|
|
||
|
info.m_nSelfIllumMask = SELFILLUMMASK;
|
||
|
info.m_nBlendTintByBaseAlpha = BLENDTINTBYBASEALPHA;
|
||
|
info.m_nTintReplacesBaseColor = BLENDTINTCOLOROVERBASE;
|
||
|
}
|
||
|
|
||
|
// Cloak Pass
|
||
|
void SetupVarsCloakBlendedPass( CloakBlendedPassVars_t &info )
|
||
|
{
|
||
|
info.m_nCloakFactor = CLOAKFACTOR;
|
||
|
info.m_nCloakColorTint = CLOAKCOLORTINT;
|
||
|
info.m_nRefractAmount = REFRACTAMOUNT;
|
||
|
|
||
|
// Delete these lines if not bump mapping!
|
||
|
info.m_nBumpmap = BUMPMAP;
|
||
|
info.m_nBumpFrame = BUMPFRAME;
|
||
|
info.m_nBumpTransform = BUMPTRANSFORM;
|
||
|
}
|
||
|
|
||
|
// Weapon Sheen Pass
|
||
|
void SetupVarsWeaponSheenPass( WeaponSheenPassVars_t &info )
|
||
|
{
|
||
|
info.m_nSheenMap = SHEENMAP;
|
||
|
info.m_nSheenMapMask = SHEENMAPMASK;
|
||
|
info.m_nSheenMapMaskFrame = SHEENMAPMASKFRAME;
|
||
|
info.m_nSheenMapTint = SHEENMAPTINT;
|
||
|
info.m_nSheenMapMaskScaleX = SHEENMAPMASKSCALEX;
|
||
|
info.m_nSheenMapMaskScaleY = SHEENMAPMASKSCALEY;
|
||
|
info.m_nSheenMapMaskOffsetX = SHEENMAPMASKOFFSETX;
|
||
|
info.m_nSheenMapMaskOffsetY = SHEENMAPMASKOFFSETY;
|
||
|
info.m_nSheenMapMaskDirection = SHEENMAPMASKDIRECTION;
|
||
|
info.m_nSheenIndex = SHEENINDEX;
|
||
|
|
||
|
info.m_nBumpmap = BUMPMAP;
|
||
|
info.m_nBumpFrame = BUMPFRAME;
|
||
|
info.m_nBumpTransform = BUMPTRANSFORM;
|
||
|
}
|
||
|
|
||
|
bool NeedsPowerOfTwoFrameBufferTexture( IMaterialVar **params, bool bCheckSpecificToThisFrame ) const
|
||
|
{
|
||
|
if ( params[CLOAKPASSENABLED]->GetIntValue() ) // If material supports cloaking
|
||
|
{
|
||
|
if ( bCheckSpecificToThisFrame == false ) // For setting model flag at load time
|
||
|
return true;
|
||
|
else if ( ( params[CLOAKFACTOR]->GetFloatValue() > 0.0f ) && ( params[CLOAKFACTOR]->GetFloatValue() < 1.0f ) ) // Per-frame check
|
||
|
return true;
|
||
|
// else, not cloaking this frame, so check flag2 in case the base material still needs it
|
||
|
}
|
||
|
if ( params[SHEENPASSENABLED]->GetIntValue() ) // If material supports weapon sheen
|
||
|
return true;
|
||
|
|
||
|
// Check flag2 if not drawing cloak pass
|
||
|
return IS_FLAG2_SET( MATERIAL_VAR2_NEEDS_POWER_OF_TWO_FRAME_BUFFER_TEXTURE );
|
||
|
}
|
||
|
|
||
|
bool IsTranslucent( IMaterialVar **params ) const
|
||
|
{
|
||
|
if ( params[CLOAKPASSENABLED]->GetIntValue() ) // If material supports cloaking
|
||
|
{
|
||
|
if ( ( params[CLOAKFACTOR]->GetFloatValue() > 0.0f ) && ( params[CLOAKFACTOR]->GetFloatValue() < 1.0f ) ) // Per-frame check
|
||
|
return true;
|
||
|
// else, not cloaking this frame, so check flag in case the base material still needs it
|
||
|
}
|
||
|
|
||
|
// Check flag if not drawing cloak pass
|
||
|
return IS_FLAG_SET( MATERIAL_VAR_TRANSLUCENT );
|
||
|
}
|
||
|
|
||
|
// Emissive Scroll Pass
|
||
|
void SetupVarsEmissiveScrollBlendedPass( EmissiveScrollBlendedPassVars_t &info )
|
||
|
{
|
||
|
info.m_nBlendStrength = EMISSIVEBLENDSTRENGTH;
|
||
|
info.m_nBaseTexture = EMISSIVEBLENDBASETEXTURE;
|
||
|
info.m_nFlowTexture = EMISSIVEBLENDFLOWTEXTURE;
|
||
|
info.m_nEmissiveTexture = EMISSIVEBLENDTEXTURE;
|
||
|
info.m_nEmissiveTint = EMISSIVEBLENDTINT;
|
||
|
info.m_nEmissiveScrollVector = EMISSIVEBLENDSCROLLVECTOR;
|
||
|
info.m_nTime = TIME;
|
||
|
}
|
||
|
|
||
|
// Flesh Interior Pass
|
||
|
void SetupVarsFleshInteriorBlendedPass( FleshInteriorBlendedPassVars_t &info )
|
||
|
{
|
||
|
info.m_nFleshTexture = FLESHINTERIORTEXTURE;
|
||
|
info.m_nFleshNoiseTexture = FLESHINTERIORNOISETEXTURE;
|
||
|
info.m_nFleshBorderTexture1D = FLESHBORDERTEXTURE1D;
|
||
|
info.m_nFleshNormalTexture = FLESHNORMALTEXTURE;
|
||
|
info.m_nFleshSubsurfaceTexture = FLESHSUBSURFACETEXTURE;
|
||
|
info.m_nFleshCubeTexture = FLESHCUBETEXTURE;
|
||
|
|
||
|
info.m_nflBorderNoiseScale = FLESHBORDERNOISESCALE;
|
||
|
info.m_nflDebugForceFleshOn = FLESHDEBUGFORCEFLESHON;
|
||
|
info.m_nvEffectCenterRadius1 = FLESHEFFECTCENTERRADIUS1;
|
||
|
info.m_nvEffectCenterRadius2 = FLESHEFFECTCENTERRADIUS2;
|
||
|
info.m_nvEffectCenterRadius3 = FLESHEFFECTCENTERRADIUS3;
|
||
|
info.m_nvEffectCenterRadius4 = FLESHEFFECTCENTERRADIUS4;
|
||
|
|
||
|
info.m_ncSubsurfaceTint = FLESHSUBSURFACETINT;
|
||
|
info.m_nflBorderWidth = FLESHBORDERWIDTH;
|
||
|
info.m_nflBorderSoftness = FLESHBORDERSOFTNESS;
|
||
|
info.m_ncBorderTint = FLESHBORDERTINT;
|
||
|
info.m_nflGlobalOpacity = FLESHGLOBALOPACITY;
|
||
|
info.m_nflGlossBrightness = FLESHGLOSSBRIGHTNESS;
|
||
|
info.m_nflScrollSpeed = FLESHSCROLLSPEED;
|
||
|
|
||
|
info.m_nTime = TIME;
|
||
|
}
|
||
|
|
||
|
SHADER_INIT_PARAMS()
|
||
|
{
|
||
|
VertexLitGeneric_DX9_Vars_t vars;
|
||
|
SetupVars( vars );
|
||
|
InitParamsVertexLitGeneric_DX9( this, params, pMaterialName, true, vars );
|
||
|
|
||
|
// Cloak Pass
|
||
|
if ( !params[CLOAKPASSENABLED]->IsDefined() )
|
||
|
{
|
||
|
params[CLOAKPASSENABLED]->SetIntValue( 0 );
|
||
|
}
|
||
|
else if ( params[CLOAKPASSENABLED]->GetIntValue() )
|
||
|
{
|
||
|
CloakBlendedPassVars_t info;
|
||
|
SetupVarsCloakBlendedPass( info );
|
||
|
InitParamsCloakBlendedPass( this, params, pMaterialName, info );
|
||
|
}
|
||
|
|
||
|
// Sheen Pass
|
||
|
if ( !params[SHEENPASSENABLED]->IsDefined() )
|
||
|
{
|
||
|
params[SHEENPASSENABLED]->SetIntValue( 0 );
|
||
|
}
|
||
|
else if ( params[SHEENPASSENABLED]->GetIntValue() )
|
||
|
{
|
||
|
WeaponSheenPassVars_t info;
|
||
|
SetupVarsWeaponSheenPass( info );
|
||
|
InitParamsWeaponSheenPass( this, params, pMaterialName, info );
|
||
|
}
|
||
|
|
||
|
// Emissive Scroll Pass
|
||
|
if ( !params[EMISSIVEBLENDENABLED]->IsDefined() )
|
||
|
{
|
||
|
params[EMISSIVEBLENDENABLED]->SetIntValue( 0 );
|
||
|
}
|
||
|
else if ( params[EMISSIVEBLENDENABLED]->GetIntValue() )
|
||
|
{
|
||
|
EmissiveScrollBlendedPassVars_t info;
|
||
|
SetupVarsEmissiveScrollBlendedPass( info );
|
||
|
InitParamsEmissiveScrollBlendedPass( this, params, pMaterialName, info );
|
||
|
}
|
||
|
|
||
|
// Flesh Interior Pass
|
||
|
if ( !params[FLESHINTERIORENABLED]->IsDefined() )
|
||
|
{
|
||
|
params[FLESHINTERIORENABLED]->SetIntValue( 0 );
|
||
|
}
|
||
|
else if ( params[FLESHINTERIORENABLED]->GetIntValue() )
|
||
|
{
|
||
|
FleshInteriorBlendedPassVars_t info;
|
||
|
SetupVarsFleshInteriorBlendedPass( info );
|
||
|
InitParamsFleshInteriorBlendedPass( this, params, pMaterialName, info );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
SHADER_FALLBACK
|
||
|
{
|
||
|
if (g_pHardwareConfig->GetDXSupportLevel() < 70)
|
||
|
return "VertexLitGeneric_DX6";
|
||
|
|
||
|
if (g_pHardwareConfig->GetDXSupportLevel() < 80)
|
||
|
return "VertexLitGeneric_DX7";
|
||
|
|
||
|
if (g_pHardwareConfig->GetDXSupportLevel() < 90)
|
||
|
return "VertexLitGeneric_DX8";
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
SHADER_INIT
|
||
|
{
|
||
|
VertexLitGeneric_DX9_Vars_t vars;
|
||
|
SetupVars( vars );
|
||
|
InitVertexLitGeneric_DX9( this, params, true, vars );
|
||
|
|
||
|
// Cloak Pass
|
||
|
if ( params[CLOAKPASSENABLED]->GetIntValue() )
|
||
|
{
|
||
|
CloakBlendedPassVars_t info;
|
||
|
SetupVarsCloakBlendedPass( info );
|
||
|
InitCloakBlendedPass( this, params, info );
|
||
|
}
|
||
|
|
||
|
// TODO : Only do this if we're in range of the camera
|
||
|
// Weapon Sheen
|
||
|
if ( params[SHEENPASSENABLED]->GetIntValue() )
|
||
|
{
|
||
|
WeaponSheenPassVars_t info;
|
||
|
SetupVarsWeaponSheenPass( info );
|
||
|
InitWeaponSheenPass( this, params, info );
|
||
|
}
|
||
|
|
||
|
// Emissive Scroll Pass
|
||
|
if ( params[EMISSIVEBLENDENABLED]->GetIntValue() )
|
||
|
{
|
||
|
EmissiveScrollBlendedPassVars_t info;
|
||
|
SetupVarsEmissiveScrollBlendedPass( info );
|
||
|
InitEmissiveScrollBlendedPass( this, params, info );
|
||
|
}
|
||
|
|
||
|
// Flesh Interior Pass
|
||
|
if ( params[FLESHINTERIORENABLED]->GetIntValue() )
|
||
|
{
|
||
|
FleshInteriorBlendedPassVars_t info;
|
||
|
SetupVarsFleshInteriorBlendedPass( info );
|
||
|
InitFleshInteriorBlendedPass( this, params, info );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
SHADER_DRAW
|
||
|
{
|
||
|
// Skip the standard rendering if cloak pass is fully opaque
|
||
|
bool bDrawStandardPass = true;
|
||
|
if ( params[CLOAKPASSENABLED]->GetIntValue() && ( pShaderShadow == NULL ) ) // && not snapshotting
|
||
|
{
|
||
|
CloakBlendedPassVars_t info;
|
||
|
SetupVarsCloakBlendedPass( info );
|
||
|
if ( CloakBlendedPassIsFullyOpaque( params, info ) )
|
||
|
{
|
||
|
bDrawStandardPass = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Standard rendering pass
|
||
|
if ( bDrawStandardPass )
|
||
|
{
|
||
|
VertexLitGeneric_DX9_Vars_t vars;
|
||
|
SetupVars( vars );
|
||
|
DrawVertexLitGeneric_DX9( this, params, pShaderAPI, pShaderShadow, true, vars, vertexCompression, pContextDataPtr );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// Skip this pass!
|
||
|
Draw( false );
|
||
|
}
|
||
|
|
||
|
// Weapon sheen pass
|
||
|
// only if doing standard as well (don't do it if cloaked)
|
||
|
if ( params[SHEENPASSENABLED]->GetIntValue() )
|
||
|
{
|
||
|
WeaponSheenPassVars_t info;
|
||
|
SetupVarsWeaponSheenPass( info );
|
||
|
if ( ( pShaderShadow != NULL ) || ( bDrawStandardPass && ShouldDrawMaterialSheen( params, info ) ) )
|
||
|
{
|
||
|
DrawWeaponSheenPass( this, params, pShaderAPI, pShaderShadow, info, vertexCompression );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// Skip this pass!
|
||
|
Draw( false );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Cloak Pass
|
||
|
if ( params[CLOAKPASSENABLED]->GetIntValue() )
|
||
|
{
|
||
|
// If ( snapshotting ) or ( we need to draw this frame )
|
||
|
if ( ( pShaderShadow != NULL ) || ( ( params[CLOAKFACTOR]->GetFloatValue() > 0.0f ) && ( params[CLOAKFACTOR]->GetFloatValue() < 1.0f ) ) )
|
||
|
{
|
||
|
CloakBlendedPassVars_t info;
|
||
|
SetupVarsCloakBlendedPass( info );
|
||
|
DrawCloakBlendedPass( this, params, pShaderAPI, pShaderShadow, info, vertexCompression );
|
||
|
}
|
||
|
else // We're not snapshotting and we don't need to draw this frame
|
||
|
{
|
||
|
// Skip this pass!
|
||
|
Draw( false );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Emissive Scroll Pass
|
||
|
if ( params[EMISSIVEBLENDENABLED]->GetIntValue() )
|
||
|
{
|
||
|
// If ( snapshotting ) or ( we need to draw this frame )
|
||
|
if ( ( pShaderShadow != NULL ) || ( params[EMISSIVEBLENDSTRENGTH]->GetFloatValue() > 0.0f ) )
|
||
|
{
|
||
|
EmissiveScrollBlendedPassVars_t info;
|
||
|
SetupVarsEmissiveScrollBlendedPass( info );
|
||
|
DrawEmissiveScrollBlendedPass( this, params, pShaderAPI, pShaderShadow, info, vertexCompression );
|
||
|
}
|
||
|
else // We're not snapshotting and we don't need to draw this frame
|
||
|
{
|
||
|
// Skip this pass!
|
||
|
Draw( false );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Flesh Interior Pass
|
||
|
if ( params[FLESHINTERIORENABLED]->GetIntValue() )
|
||
|
{
|
||
|
// If ( snapshotting ) or ( we need to draw this frame )
|
||
|
if ( ( pShaderShadow != NULL ) || ( true ) )
|
||
|
{
|
||
|
FleshInteriorBlendedPassVars_t info;
|
||
|
SetupVarsFleshInteriorBlendedPass( info );
|
||
|
DrawFleshInteriorBlendedPass( this, params, pShaderAPI, pShaderShadow, info, vertexCompression );
|
||
|
}
|
||
|
else // We're not snapshotting and we don't need to draw this frame
|
||
|
{
|
||
|
// Skip this pass!
|
||
|
Draw( false );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
END_SHADER
|