mirror of
https://github.com/celisej567/BCWSsrc.git
synced 2025-12-31 01:48:13 +03:00
gigacommit
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -256,6 +256,16 @@ $Project
|
||||
|
||||
//$File "c_env_cascade_light.cpp"
|
||||
//$File "C_Env_Cascade_Light.h"
|
||||
|
||||
$Folder "GString"
|
||||
{
|
||||
$File "gstring/c_lights.cpp"
|
||||
$File "gstring/c_lights.h"
|
||||
|
||||
$File "gstring/c_gstring_util.cpp"
|
||||
$File "gstring/c_gstring_util.h"
|
||||
}
|
||||
|
||||
$File "hl2\C_Func_Monitor.cpp"
|
||||
$File "geiger.cpp"
|
||||
$File "history_resource.cpp"
|
||||
|
||||
@@ -1054,6 +1054,11 @@ private:
|
||||
|
||||
friend class CVisibleShadowList;
|
||||
friend class CVisibleShadowFrustumList;
|
||||
|
||||
// GSTRINGMIGRATION
|
||||
CTextureReference m_CascadedDepthTexture;
|
||||
CTextureReference m_CascadedColorTexture;
|
||||
// END GSTRINGMIGRATION
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1498,9 +1503,11 @@ void CClientShadowMgr::InitDepthTextureShadows()
|
||||
|
||||
#if defined(MAPBASE) //&& !defined(ASW_PROJECTED_TEXTURES)
|
||||
// SAUL: ensure the depth texture size wasn't changed
|
||||
Assert(depthTex->GetActualWidth() == m_nDepthTextureResolution);
|
||||
//Assert(depthTex->GetActualWidth() == m_nDepthTextureResolution);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
if ( i == 0 )
|
||||
{
|
||||
// Shadow may be resized during allocation (due to resolution constraints etc)
|
||||
@@ -1512,6 +1519,13 @@ void CClientShadowMgr::InitDepthTextureShadows()
|
||||
m_DepthTextureCacheLocks.AddToTail( bFalse );
|
||||
}
|
||||
|
||||
const int iCadcadedShadowWidth = 2048;
|
||||
const int iCadcadedShadowHeight = 1024;
|
||||
m_CascadedColorTexture.InitRenderTarget(iCadcadedShadowWidth, iCadcadedShadowHeight, RT_SIZE_NO_CHANGE,
|
||||
nullFormat, MATERIAL_RT_DEPTH_NONE, false, "_rt_CascadedShadowColor");
|
||||
m_CascadedDepthTexture.InitRenderTarget(iCadcadedShadowWidth, iCadcadedShadowHeight, RT_SIZE_NO_CHANGE,
|
||||
dstFormat, MATERIAL_RT_DEPTH_NONE, false, "_rt_CascadedShadowDepth");
|
||||
|
||||
materials->EndRenderTargetAllocation();
|
||||
}
|
||||
}
|
||||
@@ -1531,6 +1545,9 @@ void CClientShadowMgr::ShutdownDepthTextureShadows()
|
||||
m_DepthTextureCache.Remove( m_DepthTextureCache.Count()-1 );
|
||||
}
|
||||
|
||||
m_CascadedDepthTexture.Shutdown();
|
||||
m_CascadedColorTexture.Shutdown();
|
||||
|
||||
m_bDepthTextureActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
139
sp/src/game/client/gstring/c_gstring_util.cpp
Normal file
139
sp/src/game/client/gstring/c_gstring_util.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
|
||||
#include "cbase.h"
|
||||
#include "c_gstring_util.h"
|
||||
#include "bone_setup.h"
|
||||
|
||||
#include "engine/ivmodelinfo.h"
|
||||
#include "vcollide_parse.h"
|
||||
#include "solidsetdefaults.h"
|
||||
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "tier3/tier3.h"
|
||||
|
||||
int ConvertPhysBoneToStudioBone( C_BaseAnimating *pEntity, int iPhysBone )
|
||||
{
|
||||
int iStudioBone = -1;
|
||||
vcollide_t *pCollide = modelinfo->GetVCollide( pEntity->GetModelIndex() );
|
||||
|
||||
if ( pCollide != NULL
|
||||
&& iPhysBone >= 0 )
|
||||
{
|
||||
IVPhysicsKeyParser *pParse = physcollision->VPhysicsKeyParserCreate( pCollide->pKeyValues );
|
||||
|
||||
while ( !pParse->Finished() )
|
||||
{
|
||||
const char *pBlock = pParse->GetCurrentBlockName();
|
||||
|
||||
// need to parse the phys solids and compare to their indices
|
||||
if ( !strcmpi( pBlock, "solid" ) )
|
||||
{
|
||||
solid_t solid;
|
||||
pParse->ParseSolid( &solid, &g_SolidSetup );
|
||||
|
||||
if ( solid.index == iPhysBone )
|
||||
{
|
||||
iStudioBone = pEntity->LookupBone( solid.name );
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pParse->SkipBlock();
|
||||
}
|
||||
}
|
||||
|
||||
physcollision->VPhysicsKeyParserDestroy( pParse );
|
||||
}
|
||||
|
||||
return iStudioBone;
|
||||
}
|
||||
|
||||
int BoneParentDepth( CStudioHdr *pHdr, int iBone, int iPotentialParent )
|
||||
{
|
||||
if ( iBone < 0
|
||||
|| iPotentialParent < 0 )
|
||||
return -1;
|
||||
|
||||
if ( iBone == iPotentialParent )
|
||||
return 0;
|
||||
|
||||
int iParent = pHdr->pBone( iBone )->parent;
|
||||
|
||||
if ( iParent == iPotentialParent )
|
||||
return 1;
|
||||
|
||||
if ( iParent < 0 )
|
||||
return -1;
|
||||
|
||||
int iRet = BoneParentDepth( pHdr, iParent, iPotentialParent );
|
||||
|
||||
return ( iRet < 0 ) ? -1 : 1 + iRet;
|
||||
}
|
||||
|
||||
int BoneParentDepth( CStudioHdr *pHdr, const char *pszBone, const char *pszPotentialParent )
|
||||
{
|
||||
Assert( pHdr );
|
||||
|
||||
int iBone = Studio_BoneIndexByName( pHdr, pszBone );
|
||||
int iParent = Studio_BoneIndexByName( pHdr, pszPotentialParent );
|
||||
|
||||
return BoneParentDepth( pHdr, iBone, iParent );
|
||||
}
|
||||
|
||||
bool BoneHasParent( CStudioHdr *pHdr, int iBone, int iPotentialParent )
|
||||
{
|
||||
return BoneParentDepth( pHdr, iBone, iPotentialParent ) > 0;
|
||||
}
|
||||
|
||||
bool BoneHasParent( CStudioHdr *pHdr, const char *pszBone, const char *pszPotentialParent )
|
||||
{
|
||||
return BoneParentDepth( pHdr, pszBone, pszPotentialParent ) > 0;
|
||||
}
|
||||
|
||||
bool SupportsCascadedShadows()
|
||||
{
|
||||
static bool bInit = true;
|
||||
static bool bValue = false;
|
||||
|
||||
if ( bInit )
|
||||
{
|
||||
bInit = false;
|
||||
bValue = g_pMaterialSystemHardwareConfig->SupportsShaderModel_3_0() &&
|
||||
g_pMaterialSystemHardwareConfig->NumVertexShaderConstants() >= 243;
|
||||
}
|
||||
|
||||
return bValue;
|
||||
}
|
||||
|
||||
const wchar_t *SafeLocalize( const char *tokenName )
|
||||
{
|
||||
const wchar_t *pResult = g_pVGuiLocalize->Find( tokenName );
|
||||
if ( pResult != NULL )
|
||||
{
|
||||
return pResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
static wchar_t s_wszTranslated[ 256 ];
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( tokenName, s_wszTranslated, sizeof( s_wszTranslated ) );
|
||||
return s_wszTranslated;
|
||||
}
|
||||
}
|
||||
|
||||
SafeLocalizeInline::SafeLocalizeInline( const char *tokenName )
|
||||
{
|
||||
const wchar_t *pResult = g_pVGuiLocalize->Find( tokenName );
|
||||
if ( pResult != NULL )
|
||||
{
|
||||
Q_wcsncpy( m_wszLocalized, pResult, sizeof( m_wszLocalized ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( tokenName, m_wszLocalized, sizeof( m_wszLocalized ) );
|
||||
}
|
||||
}
|
||||
|
||||
SafeLocalizeInline::~SafeLocalizeInline()
|
||||
{
|
||||
|
||||
}
|
||||
37
sp/src/game/client/gstring/c_gstring_util.h
Normal file
37
sp/src/game/client/gstring/c_gstring_util.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef C_GSTRING_UTIL_H
|
||||
#define C_GSTRING_UTIL_H
|
||||
|
||||
|
||||
extern int ConvertPhysBoneToStudioBone( C_BaseAnimating *pEntity, int iPhysBone );
|
||||
|
||||
extern int BoneParentDepth( CStudioHdr *pHdr, int iBone, int iPotentialParent );
|
||||
extern int BoneParentDepth( CStudioHdr *pHdr, const char *pszBone, const char *pszPotentialParent );
|
||||
|
||||
extern bool BoneHasParent( CStudioHdr *pHdr, int iBone, int iPotentialParent );
|
||||
extern bool BoneHasParent( CStudioHdr *pHdr, const char *pszBone, const char *pszPotentialParent );
|
||||
|
||||
extern bool SupportsCascadedShadows();
|
||||
|
||||
extern const wchar_t *SafeLocalize( const char *tokenName );
|
||||
|
||||
class SafeLocalizeInline
|
||||
{
|
||||
public:
|
||||
SafeLocalizeInline( const char *tokenName );
|
||||
~SafeLocalizeInline();
|
||||
|
||||
operator const wchar_t *() const
|
||||
{
|
||||
return m_wszLocalized;
|
||||
}
|
||||
|
||||
const wchar_t *Get()
|
||||
{
|
||||
return m_wszLocalized;
|
||||
}
|
||||
|
||||
private:
|
||||
wchar_t m_wszLocalized[ 256 ];
|
||||
};
|
||||
|
||||
#endif
|
||||
49
sp/src/game/client/gstring/c_lights.cpp
Normal file
49
sp/src/game/client/gstring/c_lights.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "cbase.h"
|
||||
#include "c_lights.h"
|
||||
|
||||
C_EnvLight *g_pCSMEnvLight;
|
||||
|
||||
static ConVar gstring_csm_enabled( "gstring_csm_enabled", "1", 0, "0 = off, 1 = on, 2 = force" );
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT_NOBASE( C_EnvLight, DT_CEnvLight, CEnvLight )
|
||||
RecvPropQAngles( RECVINFO( m_angSunAngles ) ),
|
||||
RecvPropVector( RECVINFO( m_vecLight ) ),
|
||||
RecvPropVector( RECVINFO( m_vecAmbient ) ),
|
||||
RecvPropBool( RECVINFO( m_bCascadedShadowMappingEnabled ) ),
|
||||
END_RECV_TABLE()
|
||||
|
||||
C_EnvLight::C_EnvLight()
|
||||
: m_angSunAngles( vec3_angle )
|
||||
, m_vecLight( vec3_origin )
|
||||
, m_vecAmbient( vec3_origin )
|
||||
, m_bCascadedShadowMappingEnabled( true )
|
||||
{
|
||||
g_pCSMEnvLight = this;
|
||||
}
|
||||
|
||||
C_EnvLight::~C_EnvLight()
|
||||
{
|
||||
if ( g_pCSMEnvLight == this )
|
||||
{
|
||||
g_pCSMEnvLight = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void C_EnvLight::OnDataChanged( DataUpdateType_t type )
|
||||
{
|
||||
BaseClass::OnDataChanged( type );
|
||||
|
||||
if ( g_pCSMEnvLight == NULL ||
|
||||
m_bCascadedShadowMappingEnabled && !g_pCSMEnvLight->m_bCascadedShadowMappingEnabled ||
|
||||
m_vecLight.Length() > g_pCSMEnvLight->m_vecLight.Length() ) // If there are multiple lights, use the brightest one if CSM is forced
|
||||
{
|
||||
g_pCSMEnvLight = this;
|
||||
}
|
||||
}
|
||||
|
||||
bool C_EnvLight::IsCascadedShadowMappingEnabled() const
|
||||
{
|
||||
const int iCSMCvarEnabled = gstring_csm_enabled.GetInt();
|
||||
return m_bCascadedShadowMappingEnabled && iCSMCvarEnabled == 1 ||
|
||||
iCSMCvarEnabled == 2;
|
||||
}
|
||||
35
sp/src/game/client/gstring/c_lights.h
Normal file
35
sp/src/game/client/gstring/c_lights.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef C_LIGHTS_H
|
||||
#define C_LIGHTS_H
|
||||
|
||||
#include "c_baseentity.h"
|
||||
|
||||
class C_EnvLight : public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_EnvLight, C_BaseEntity );
|
||||
DECLARE_NETWORKCLASS();
|
||||
|
||||
C_EnvLight();
|
||||
~C_EnvLight();
|
||||
|
||||
virtual void OnDataChanged( DataUpdateType_t type );
|
||||
|
||||
bool IsCascadedShadowMappingEnabled() const;
|
||||
|
||||
void GetShadowMappingConstants( QAngle &angSunAngles, Vector &vecLight, Vector &vecAmbient ) const
|
||||
{
|
||||
angSunAngles = m_angSunAngles;
|
||||
vecLight = m_vecLight;
|
||||
vecAmbient = m_vecAmbient;
|
||||
}
|
||||
|
||||
private:
|
||||
QAngle m_angSunAngles;
|
||||
Vector m_vecLight;
|
||||
Vector m_vecAmbient;
|
||||
bool m_bCascadedShadowMappingEnabled;
|
||||
};
|
||||
|
||||
extern C_EnvLight *g_pCSMEnvLight;
|
||||
|
||||
#endif
|
||||
@@ -81,12 +81,18 @@
|
||||
// Projective textures
|
||||
#include "C_Env_Projected_Texture.h"
|
||||
|
||||
#include "gstring\c_gstring_util.h"
|
||||
#include "gstring\c_lights.h"
|
||||
|
||||
//Shader Editor
|
||||
//#include "ShaderEditor/ShaderEditorSystem.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
static ConVar gstring_csm_color_light("gstring_csm_color_light", "0");
|
||||
static ConVar gstring_csm_color_ambient("gstring_csm_color_ambient", "0");
|
||||
|
||||
|
||||
static void testfreezeframe_f( void )
|
||||
{
|
||||
@@ -200,7 +206,6 @@ static bool g_bRenderingView = false; // For debugging...
|
||||
static int g_CurrentViewID = VIEW_NONE;
|
||||
bool g_bRenderingScreenshot = false;
|
||||
|
||||
|
||||
#define FREEZECAM_SNAPSHOT_FADE_SPEED 340
|
||||
float g_flFreezeFlash = 0.0f;
|
||||
|
||||
@@ -237,6 +242,18 @@ CON_COMMAND( r_cheapwaterend, "" )
|
||||
}
|
||||
|
||||
|
||||
static Vector ConvertLightmapGammaToLinear(int* iColor4)
|
||||
{
|
||||
Vector vecColor;
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
vecColor[i] = powf(iColor4[i] / 255.0f, 2.2f);
|
||||
}
|
||||
vecColor *= iColor4[3] / 255.0f;
|
||||
return vecColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Describes a pruned set of leaves to be rendered this view. Reference counted
|
||||
@@ -1347,7 +1364,7 @@ bool CViewRender::UpdateShadowDepthTexture( ITexture *pRenderTarget, ITexture *p
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Renders world and all entities, etc.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CViewRender::ViewDrawScene( bool bDrew3dSkybox, SkyboxVisibility_t nSkyboxVisible, const CViewSetup &view,
|
||||
void CViewRender::ViewDrawScene(CascadedConfigMode cascadedMode, bool bDrew3dSkybox, SkyboxVisibility_t nSkyboxVisible, const CViewSetup &view,
|
||||
int nClearFlags, view_id_t viewID, bool bDrawViewModel, int baseDrawFlags, ViewCustomVisibility_t *pCustomVisibility )
|
||||
{
|
||||
VPROF( "CViewRender::ViewDrawScene" );
|
||||
@@ -1360,12 +1377,26 @@ void CViewRender::ViewDrawScene( bool bDrew3dSkybox, SkyboxVisibility_t nSkyboxV
|
||||
g_pClientShadowMgr->PreRender();
|
||||
|
||||
// Shadowed flashlights supported on ps_2_b and up...
|
||||
if ( r_flashlightdepthtexture.GetBool() && (viewID == VIEW_MAIN) )
|
||||
if ( r_flashlightdepthtexture.GetBool() && (viewID == VIEW_MAIN) && view.m_eStereoEye == GetFirstEye())
|
||||
{
|
||||
g_pClientShadowMgr->ComputeShadowDepthTextures( view );
|
||||
#ifdef ASW_PROJECTED_TEXTURES
|
||||
CMatRenderContextPtr pRenderContext( materials );
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// GSTRINGMIGRATION
|
||||
if (g_pCSMEnvLight != NULL && g_pCSMEnvLight->IsCascadedShadowMappingEnabled())
|
||||
{
|
||||
UpdateCascadedShadow(view, cascadedMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
pRenderContext->SetIntRenderingParameter(INT_CASCADED_DEPTHTEXTURE, 0);
|
||||
}
|
||||
// END GSTRINGMIGRATION
|
||||
|
||||
}
|
||||
|
||||
m_BaseDrawFlags = baseDrawFlags;
|
||||
@@ -1900,6 +1931,202 @@ void CViewRender::CleanupMain3DView( const CViewSetup &view )
|
||||
render->PopView( GetFrustum() );
|
||||
}
|
||||
|
||||
void CViewRender::UpdateCascadedShadow(const CViewSetup& view, CascadedConfigMode mode)
|
||||
{
|
||||
static CTextureReference s_CascadedShadowDepthTexture;
|
||||
static CTextureReference s_CascadedShadowColorTexture;
|
||||
if (!s_CascadedShadowDepthTexture.IsValid())
|
||||
{
|
||||
s_CascadedShadowDepthTexture.Init(materials->FindTexture("_rt_ShadowDepthTexture_%d", TEXTURE_GROUP_OTHER));
|
||||
|
||||
}
|
||||
|
||||
if (!s_CascadedShadowColorTexture.IsValid())
|
||||
{
|
||||
s_CascadedShadowColorTexture.Init(materials->FindTexture("_rt_CascadedShadowColor", TEXTURE_GROUP_OTHER));
|
||||
}
|
||||
|
||||
ITexture* pDepthTexture = s_CascadedShadowDepthTexture;
|
||||
|
||||
Msg("88888888888888888888\n");
|
||||
|
||||
CMatRenderContextPtr pRenderContext(materials);
|
||||
pRenderContext->SetIntRenderingParameter(INT_CASCADED_DEPTHTEXTURE, int(pDepthTexture));
|
||||
|
||||
QAngle angCascadedAngles;
|
||||
Vector vecLight, vecAmbient;
|
||||
g_pCSMEnvLight->GetShadowMappingConstants(angCascadedAngles, vecLight, vecAmbient);
|
||||
|
||||
if (gstring_csm_color_light.GetBool())
|
||||
{
|
||||
int iParsed[4];
|
||||
UTIL_StringToIntArray(iParsed, 4, gstring_csm_color_light.GetString());
|
||||
vecLight = ConvertLightmapGammaToLinear(iParsed);
|
||||
}
|
||||
|
||||
if (gstring_csm_color_ambient.GetBool())
|
||||
{
|
||||
int iParsed[4];
|
||||
UTIL_StringToIntArray(iParsed, 4, gstring_csm_color_ambient.GetString());
|
||||
vecAmbient = ConvertLightmapGammaToLinear(iParsed);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
vecAmbient[i] = MIN(vecAmbient[i], vecLight[i]);
|
||||
}
|
||||
|
||||
Vector vecAmbientDelta = vecLight - vecAmbient;
|
||||
vecAmbientDelta.NormalizeInPlace();
|
||||
pRenderContext->SetVectorRenderingParameter(VECTOR_RENDERPARM_GSTRING_CASCADED_AMBIENT_MIN, vecAmbient);
|
||||
pRenderContext->SetVectorRenderingParameter(VECTOR_RENDERPARM_GSTRING_CASCADED_AMBIENT_DELTA, vecAmbientDelta);
|
||||
|
||||
Vector vecFwd, vecRight, vecUp;
|
||||
AngleVectors(angCascadedAngles, &vecFwd, &vecRight, &vecUp);
|
||||
|
||||
pRenderContext->SetVectorRenderingParameter(VECTOR_RENDERPARM_GSTRING_CASCADED_FORWARD, vecFwd);
|
||||
|
||||
Vector vecMainViewFwd;
|
||||
AngleVectors(view.angles, &vecMainViewFwd);
|
||||
|
||||
CViewSetup cascadedShadowView;
|
||||
cascadedShadowView.angles = angCascadedAngles;
|
||||
cascadedShadowView.m_bOrtho = true;
|
||||
|
||||
cascadedShadowView.width = s_CascadedShadowDepthTexture->GetMappingWidth() / 2;
|
||||
cascadedShadowView.height = s_CascadedShadowDepthTexture->GetMappingHeight();
|
||||
|
||||
cascadedShadowView.m_flAspectRatio = 1.0f;
|
||||
cascadedShadowView.m_bDoBloomAndToneMapping = false;
|
||||
cascadedShadowView.zFar = cascadedShadowView.zFarViewmodel = 2000.0f;
|
||||
cascadedShadowView.zNear = cascadedShadowView.zNearViewmodel = 7.0f;
|
||||
cascadedShadowView.fov = cascadedShadowView.fovViewmodel = 90.0f;
|
||||
|
||||
struct ShadowConfig_t
|
||||
{
|
||||
float flOrthoSize;
|
||||
float flForwardOffset;
|
||||
float flUVOffsetX;
|
||||
float flViewDepthBiasHack;
|
||||
} shadowConfigs[] = {
|
||||
{ 64.0f, 0.0f, 0.25f, 0.0f },
|
||||
{ 384.0f, 256.0f, 0.75f, 0.0f }
|
||||
};
|
||||
const int iCascadedShadowCount = ARRAYSIZE(shadowConfigs);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case CASCADEDCONFIG_NORMAL:
|
||||
{
|
||||
ShadowConfig_t& closeShadow = shadowConfigs[0];
|
||||
ShadowConfig_t& farShadow = shadowConfigs[1];
|
||||
closeShadow.flOrthoSize = 164.0f;
|
||||
closeShadow.flForwardOffset = 102.0f;
|
||||
farShadow.flOrthoSize = 786.0f;
|
||||
farShadow.flForwardOffset = 384.0f;
|
||||
|
||||
vecMainViewFwd.z = 0.0f;
|
||||
vecMainViewFwd.NormalizeInPlace();
|
||||
}
|
||||
break;
|
||||
|
||||
case CASCADEDCONFIG_SPACE:
|
||||
{
|
||||
ShadowConfig_t& closeShadow = shadowConfigs[0];
|
||||
ShadowConfig_t& farShadow = shadowConfigs[1];
|
||||
//closeShadow.flOrthoSize = 4.0f;
|
||||
closeShadow.flOrthoSize = 7.5f;
|
||||
closeShadow.flForwardOffset = 2.0f;
|
||||
closeShadow.flUVOffsetX = 0.25f;
|
||||
closeShadow.flViewDepthBiasHack = 0.001f;
|
||||
farShadow.flViewDepthBiasHack = 1.5f;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
vecMainViewFwd -= vecFwd * DotProduct(vecMainViewFwd, vecFwd);
|
||||
|
||||
static VMatrix s_CSMSwapMatrix[2];
|
||||
static int s_iCSMSwapIndex = 0;
|
||||
|
||||
C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
|
||||
Vector vecCascadeOrigin((mode == CASCADEDCONFIG_SPACE) ? view.origin :
|
||||
pPlayer ? pPlayer->GetRenderOrigin() : vec3_origin);
|
||||
vecCascadeOrigin -= vecFwd * 1024.0f;
|
||||
|
||||
// This can only be set once per frame, not per shadow view. Fuckers.
|
||||
if (mode == CASCADEDCONFIG_SPACE)
|
||||
{
|
||||
pRenderContext->SetShadowDepthBiasFactors(1.0f, 0.000005f);
|
||||
}
|
||||
else
|
||||
{
|
||||
pRenderContext->SetShadowDepthBiasFactors(8.0f, 0.0005f);
|
||||
}
|
||||
|
||||
for (int i = 0; i < iCascadedShadowCount; i++)
|
||||
{
|
||||
const ShadowConfig_t& shadowConfig = shadowConfigs[i];
|
||||
|
||||
cascadedShadowView.m_OrthoTop = -shadowConfig.flOrthoSize;
|
||||
cascadedShadowView.m_OrthoRight = shadowConfig.flOrthoSize;
|
||||
cascadedShadowView.m_OrthoBottom = shadowConfig.flOrthoSize;
|
||||
cascadedShadowView.m_OrthoLeft = -shadowConfig.flOrthoSize;
|
||||
|
||||
cascadedShadowView.x = i * cascadedShadowView.width;
|
||||
cascadedShadowView.y = 0;
|
||||
|
||||
Vector vecOrigin = vecCascadeOrigin + vecMainViewFwd * shadowConfig.flForwardOffset;
|
||||
const float flViewFrustumWidthScale = shadowConfig.flOrthoSize * 2.0f / cascadedShadowView.width;
|
||||
const float flViewFrustumHeightScale = shadowConfig.flOrthoSize * 2.0f / cascadedShadowView.height;
|
||||
const float flFractionX = fmod(DotProduct(vecOrigin, vecRight), flViewFrustumWidthScale);
|
||||
const float flFractionY = fmod(DotProduct(vecOrigin, vecUp), flViewFrustumHeightScale);
|
||||
vecOrigin -= flFractionX * vecRight;
|
||||
vecOrigin -= flFractionY * vecUp;
|
||||
|
||||
Msg("HI!\n");
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
const ShadowConfig_t& prevShadowConfig = shadowConfigs[i - 1];
|
||||
const float flCascadedScale = prevShadowConfig.flOrthoSize / shadowConfig.flOrthoSize;
|
||||
Vector vecOffsetShadowMapSpace = vecOrigin - cascadedShadowView.origin;
|
||||
Vector2D vecCascadedOffset(DotProduct(-vecRight, vecOffsetShadowMapSpace) * 0.5f,
|
||||
DotProduct(vecUp, vecOffsetShadowMapSpace));
|
||||
vecCascadedOffset *= 0.5f / shadowConfig.flOrthoSize;
|
||||
|
||||
vecCascadedOffset.x = vecCascadedOffset.x + 0.5f + 0.25f * (1.0f - flCascadedScale);
|
||||
vecCascadedOffset.y = vecCascadedOffset.y + 0.5f - flCascadedScale * 0.5f;
|
||||
|
||||
vecOffsetShadowMapSpace.Init(flCascadedScale, vecCascadedOffset.x, vecCascadedOffset.y);
|
||||
pRenderContext->SetVectorRenderingParameter(VECTOR_RENDERPARM_GSTRING_CASCADED_STEP, vecOffsetShadowMapSpace);
|
||||
}
|
||||
|
||||
cascadedShadowView.origin = vecOrigin;
|
||||
|
||||
VMatrix worldToView, viewToProjection, worldToProjection, worldToTexture;
|
||||
render->GetMatricesForView(cascadedShadowView, &worldToView, &viewToProjection, &worldToProjection, &worldToTexture);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
VMatrix tmp;
|
||||
MatrixBuildScale(tmp, 0.25f, -0.5f, 1.0f);
|
||||
tmp[0][3] = shadowConfig.flUVOffsetX;
|
||||
tmp[1][3] = 0.5f;
|
||||
|
||||
VMatrix& currentSwapMatrix = s_CSMSwapMatrix[s_iCSMSwapIndex];
|
||||
MatrixMultiply(tmp, worldToProjection, currentSwapMatrix);
|
||||
pRenderContext->SetIntRenderingParameter(INT_CASCADED_MATRIX_ADDRESS_0, (int)¤tSwapMatrix);
|
||||
}
|
||||
|
||||
cascadedShadowView.origin -= vecFwd * shadowConfig.flViewDepthBiasHack;
|
||||
UpdateShadowDepthTexture(s_CascadedShadowColorTexture, s_CascadedShadowDepthTexture, cascadedShadowView);
|
||||
}
|
||||
|
||||
s_iCSMSwapIndex = (s_iCSMSwapIndex + 1) % 2;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Queues up an overlay rendering
|
||||
@@ -1981,6 +2208,8 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT
|
||||
}
|
||||
}
|
||||
|
||||
CascadedConfigMode cascadedMode = CASCADEDCONFIG_NORMAL;
|
||||
|
||||
CMatRenderContextPtr pRenderContext( materials );
|
||||
ITexture *saveRenderTarget = pRenderContext->GetRenderTarget();
|
||||
pRenderContext.SafeRelease(); // don't want to hold for long periods in case in a locking active share thread mode
|
||||
@@ -2079,15 +2308,18 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT
|
||||
// We can't put it in ViewDrawScene() directly because other functions use it as well.
|
||||
|
||||
// if the 3d skybox world is drawn, then don't draw the normal skybox
|
||||
CSkyboxView *pSkyView = new CSkyboxView( this );
|
||||
if ( ( bDrew3dSkybox = pSkyView->Setup( view, &nClearFlags, &nSkyboxVisible ) ) != false )
|
||||
{
|
||||
AddViewToScene( pSkyView );
|
||||
}
|
||||
SafeRelease( pSkyView );
|
||||
|
||||
|
||||
//CSkyboxView *pSkyView = new CSkyboxView( this );
|
||||
//if ( ( bDrew3dSkybox = pSkyView->Setup( view, &nClearFlags, &nSkyboxVisible ) ) != false )
|
||||
//{
|
||||
//AddViewToScene( pSkyView );
|
||||
//}
|
||||
//SafeRelease( pSkyView );
|
||||
#endif
|
||||
|
||||
ViewDrawScene( bDrew3dSkybox, nSkyboxVisible, view, nClearFlags, VIEW_MAIN, whatToDraw & RENDERVIEW_DRAWVIEWMODEL );
|
||||
ViewDrawScene(cascadedMode, bDrew3dSkybox, nSkyboxVisible, view, nClearFlags, VIEW_MAIN, (whatToDraw & RENDERVIEW_DRAWVIEWMODEL) != 0);
|
||||
//Msg("bebra\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3392,7 +3624,7 @@ bool CViewRender::DrawOneMonitor( ITexture *pRenderTarget, int cameraNum, C_Poin
|
||||
}
|
||||
SafeRelease( pSkyView );
|
||||
|
||||
ViewDrawScene( bDrew3dSkybox, nSkyMode, monitorView, nClearFlags, VIEW_MONITOR );
|
||||
ViewDrawScene(CASCADEDCONFIG_NORMAL, bDrew3dSkybox, nSkyMode, monitorView, nClearFlags, VIEW_MONITOR );
|
||||
render->PopView( frustum );
|
||||
}
|
||||
else if (nSkyMode == SKYBOX_NOT_VISIBLE)
|
||||
@@ -3409,7 +3641,7 @@ bool CViewRender::DrawOneMonitor( ITexture *pRenderTarget, int cameraNum, C_Poin
|
||||
pRenderContext->OverrideAlphaWriteEnable( true, true );
|
||||
}
|
||||
|
||||
ViewDrawScene( false, nSkyMode, monitorView, 0, VIEW_MONITOR );
|
||||
ViewDrawScene(CASCADEDCONFIG_NORMAL, false, nSkyMode, monitorView, 0, VIEW_MONITOR );
|
||||
|
||||
pRenderContext->PopRenderTargetAndViewport();
|
||||
render->PopView( frustum );
|
||||
@@ -3419,7 +3651,7 @@ bool CViewRender::DrawOneMonitor( ITexture *pRenderTarget, int cameraNum, C_Poin
|
||||
// @MULTICORE (toml 8/11/2006): this should be a renderer....
|
||||
Frustum frustum;
|
||||
render->Push3DView( monitorView, VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR, pRenderTarget, (VPlane *)frustum );
|
||||
ViewDrawScene( false, nSkyMode, monitorView, 0, VIEW_MONITOR );
|
||||
ViewDrawScene(CASCADEDCONFIG_NORMAL, false, nSkyMode, monitorView, 0, VIEW_MONITOR );
|
||||
render->PopView( frustum );
|
||||
}
|
||||
#else
|
||||
@@ -3617,7 +3849,7 @@ bool CViewRender::DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldP
|
||||
CMatRenderContextPtr pRenderContext( materials );
|
||||
pRenderContext->PushCustomClipPlane( plane.Base() );
|
||||
|
||||
ViewDrawScene( bDrew3dSkybox, nSkyMode, monitorView, nClearFlags, VIEW_MONITOR );
|
||||
ViewDrawScene(CASCADEDCONFIG_NORMAL, bDrew3dSkybox, nSkyMode, monitorView, nClearFlags, VIEW_MONITOR );
|
||||
|
||||
pRenderContext->PopCustomClipPlane();
|
||||
render->PopView( frustum );
|
||||
|
||||
@@ -41,6 +41,15 @@ class CReplayScreenshotTaker;
|
||||
class C_FuncFakeWorldPortal;
|
||||
#endif
|
||||
|
||||
|
||||
enum CascadedConfigMode
|
||||
{
|
||||
CASCADEDCONFIG_NONE = 0,
|
||||
CASCADEDCONFIG_NORMAL,
|
||||
CASCADEDCONFIG_SPACE
|
||||
//CASCADEDCONFIG_FAR
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Data specific to intro mode to control rendering.
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -444,7 +453,7 @@ private:
|
||||
|
||||
// General draw methods
|
||||
// baseDrawFlags is a combination of DF_ defines. DF_MONITOR is passed into here while drawing a monitor.
|
||||
void ViewDrawScene( bool bDrew3dSkybox, SkyboxVisibility_t nSkyboxVisible, const CViewSetup &view, int nClearFlags, view_id_t viewID, bool bDrawViewModel = false, int baseDrawFlags = 0, ViewCustomVisibility_t *pCustomVisibility = NULL );
|
||||
void ViewDrawScene(CascadedConfigMode cascadedMode, bool bDrew3dSkybox, SkyboxVisibility_t nSkyboxVisible, const CViewSetup &view, int nClearFlags, view_id_t viewID, bool bDrawViewModel = false, int baseDrawFlags = 0, ViewCustomVisibility_t *pCustomVisibility = NULL );
|
||||
|
||||
void DrawMonitors( const CViewSetup &cameraView );
|
||||
|
||||
@@ -495,6 +504,8 @@ private:
|
||||
void SetupMain3DView( const CViewSetup &view, int &nClearFlags );
|
||||
void CleanupMain3DView( const CViewSetup &view );
|
||||
|
||||
void UpdateCascadedShadow(const CViewSetup& view, CascadedConfigMode mode);
|
||||
|
||||
|
||||
// This stores the current view
|
||||
CViewSetup m_CurrentView;
|
||||
|
||||
@@ -12,6 +12,18 @@
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
static Vector ConvertLightmapGammaToLinear(int* iColor4)
|
||||
{
|
||||
Vector vecColor;
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
vecColor[i] = powf(iColor4[i] / 255.0f, 2.2f);
|
||||
}
|
||||
vecColor *= iColor4[3] / 255.0f;
|
||||
return vecColor;
|
||||
}
|
||||
|
||||
|
||||
LINK_ENTITY_TO_CLASS( light, CLight );
|
||||
|
||||
BEGIN_DATADESC( CLight )
|
||||
@@ -232,8 +244,102 @@ void CLight::FadeThink(void)
|
||||
LINK_ENTITY_TO_CLASS( light_spot, CLight );
|
||||
LINK_ENTITY_TO_CLASS( light_glspot, CLight );
|
||||
|
||||
LINK_ENTITY_TO_CLASS(light_environment, CEnvLight);
|
||||
|
||||
BEGIN_DATADESC(CEnvLight)
|
||||
DEFINE_FIELD(m_angSunAngles, FIELD_VECTOR),
|
||||
DEFINE_FIELD(m_vecLight, FIELD_VECTOR),
|
||||
DEFINE_FIELD(m_vecAmbient, FIELD_VECTOR),
|
||||
DEFINE_FIELD(m_bCascadedShadowMappingEnabled, FIELD_BOOLEAN),
|
||||
END_DATADESC()
|
||||
|
||||
IMPLEMENT_SERVERCLASS_ST_NOBASE(CEnvLight, DT_CEnvLight)
|
||||
SendPropQAngles(SENDINFO(m_angSunAngles)),
|
||||
SendPropVector(SENDINFO(m_vecLight)),
|
||||
SendPropVector(SENDINFO(m_vecAmbient)),
|
||||
SendPropBool(SENDINFO(m_bCascadedShadowMappingEnabled)),
|
||||
END_SEND_TABLE()
|
||||
|
||||
CEnvLight::CEnvLight()
|
||||
: m_bHasHDRLightSet(false)
|
||||
, m_bHasHDRAmbientSet(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool CEnvLight::KeyValue(const char* szKeyName, const char* szValue)
|
||||
{
|
||||
if (FStrEq(szKeyName, "pitch"))
|
||||
{
|
||||
m_angSunAngles.SetX(-atof(szValue));
|
||||
}
|
||||
else if (FStrEq(szKeyName, "angles"))
|
||||
{
|
||||
Vector vecParsed;
|
||||
UTIL_StringToVector(vecParsed.Base(), szValue);
|
||||
m_angSunAngles.SetY(vecParsed.y);
|
||||
}
|
||||
else if (FStrEq(szKeyName, "_light") || FStrEq(szKeyName, "_lightHDR"))
|
||||
{
|
||||
int iParsed[4];
|
||||
UTIL_StringToIntArray(iParsed, 4, szValue);
|
||||
|
||||
if (iParsed[0] <= 0 || iParsed[1] <= 0 || iParsed[2] <= 0)
|
||||
return true;
|
||||
|
||||
if (FStrEq(szKeyName, "_lightHDR"))
|
||||
{
|
||||
// HDR overrides LDR
|
||||
m_bHasHDRLightSet = true;
|
||||
}
|
||||
else if (m_bHasHDRLightSet)
|
||||
{
|
||||
// If this is LDR and we got HDR already, bail out.
|
||||
return true;
|
||||
}
|
||||
|
||||
m_vecLight = ConvertLightmapGammaToLinear(iParsed);
|
||||
Msg("Parsed light_environment light: %i %i %i %i\n",
|
||||
iParsed[0], iParsed[1], iParsed[2], iParsed[3]);
|
||||
}
|
||||
else if (FStrEq(szKeyName, "_ambient") || FStrEq(szKeyName, "_ambientHDR"))
|
||||
{
|
||||
int iParsed[4];
|
||||
UTIL_StringToIntArray(iParsed, 4, szValue);
|
||||
|
||||
if (iParsed[0] <= 0 || iParsed[1] <= 0 || iParsed[2] <= 0)
|
||||
return true;
|
||||
|
||||
if (FStrEq(szKeyName, "_ambientHDR"))
|
||||
{
|
||||
// HDR overrides LDR
|
||||
m_bHasHDRLightSet = true;
|
||||
}
|
||||
else if (m_bHasHDRLightSet)
|
||||
{
|
||||
// If this is LDR and we got HDR already, bail out.
|
||||
return true;
|
||||
}
|
||||
|
||||
m_vecAmbient = ConvertLightmapGammaToLinear(iParsed);
|
||||
Msg("Parsed light_environment ambient: %i %i %i %i\n",
|
||||
iParsed[0], iParsed[1], iParsed[2], iParsed[3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BaseClass::KeyValue(szKeyName, szValue);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEnvLight::Spawn()
|
||||
{
|
||||
BaseClass::Spawn();
|
||||
|
||||
m_bCascadedShadowMappingEnabled = HasSpawnFlags(0x01);
|
||||
}
|
||||
|
||||
/*
|
||||
LINK_ENTITY_TO_CLASS( light_environment, CEnvLight );
|
||||
|
||||
bool CEnvLight::KeyValue( const char *szKeyName, const char *szValue )
|
||||
@@ -255,3 +361,4 @@ void CEnvLight::Spawn( void )
|
||||
{
|
||||
BaseClass::Spawn( );
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -45,13 +45,35 @@ private:
|
||||
char m_iTargetFade;
|
||||
};
|
||||
|
||||
class CEnvLight : public CLight
|
||||
class CEnvLight : public CBaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS(CEnvLight, CLight);
|
||||
DECLARE_CLASS(CEnvLight, CBaseEntity);
|
||||
DECLARE_NETWORKCLASS();
|
||||
DECLARE_DATADESC();
|
||||
|
||||
bool KeyValue(const char* szKeyName, const char* szValue);
|
||||
void Spawn(void);
|
||||
CEnvLight();
|
||||
|
||||
virtual bool KeyValue(const char* szKeyName, const char* szValue);
|
||||
virtual void Spawn();
|
||||
|
||||
virtual int ObjectCaps()
|
||||
{
|
||||
return BaseClass::ObjectCaps() & ~FCAP_ACROSS_TRANSITION;
|
||||
}
|
||||
|
||||
virtual int UpdateTransmitState()
|
||||
{
|
||||
return SetTransmitState(FL_EDICT_ALWAYS);
|
||||
}
|
||||
|
||||
private:
|
||||
CNetworkQAngle(m_angSunAngles);
|
||||
CNetworkVector(m_vecLight);
|
||||
CNetworkVector(m_vecAmbient);
|
||||
CNetworkVar(bool, m_bCascadedShadowMappingEnabled);
|
||||
bool m_bHasHDRLightSet;
|
||||
bool m_bHasHDRAmbientSet;
|
||||
};
|
||||
|
||||
#endif // LIGHTS_H
|
||||
|
||||
@@ -1946,8 +1946,6 @@ void CGameMovement::WalkMove( void )
|
||||
fmove = mv->m_flForwardMove;
|
||||
smove = mv->m_flSideMove;
|
||||
|
||||
|
||||
|
||||
if (cl_viewbob_enabled.GetBool() && !engine->IsPaused())
|
||||
{
|
||||
CHL2_Player* HLplayer = dynamic_cast<CHL2_Player*>(player);
|
||||
|
||||
55
sp/src/game/shared/gstring/gstring_cvars.cpp
Normal file
55
sp/src/game/shared/gstring/gstring_cvars.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#ifdef GAME_DLL
|
||||
ConVar cvar_gstring_enable_entities( "gstring_enable_entities", "1" );
|
||||
#else
|
||||
ConVar cvar_gstring_enable_postprocessing( "gstring_enable_postprocessing", "1" );
|
||||
ConVar cvar_gstring_enable_hud( "gstring_enable_hud", "1" );
|
||||
|
||||
ConVar cvar_gstring_drawdetailpropsfirst( "gstring_Drawdetailpropsfirst", "1", FCVAR_ARCHIVE );
|
||||
//ConVar cvar_gstring_drawbars( "gstring_DrawBars", "1", FCVAR_ARCHIVE );
|
||||
//ConVar cvar_gstring_drawfilmgrain( "gstring_DrawFilmGrain", "1", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_drawvignette( "gstring_DrawVignette", "1", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_drawgodrays( "gstring_DrawGodrays", "1", FCVAR_ARCHIVE );
|
||||
//ConVar cvar_gstring_drawexplosionblur( "gstring_DrawExplosionFX", "1", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_drawmotionblur( "gstring_DrawMotionblur", "1", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_drawscreenblur( "gstring_DrawScreenBlur", "0", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_drawdreamblur( "gstring_DrawDreamBlur", "1", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_drawlensflare( "gstring_DrawLensFlare", "1", FCVAR_ARCHIVE );
|
||||
//ConVar cvar_gstring_drawbloomflare( "gstring_DrawBloomFlare", "2", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_drawwatereffects( "gstring_DrawWaterEffects", "1", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_drawcinemaoverlay( "gstring_DrawCinemaOverlay", "1", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_drawdof( "gstring_DrawDoF", "0", FCVAR_ARCHIVE );
|
||||
|
||||
|
||||
ConVar cvar_gstring_bars_scale( "gstring_Bars_scale", "0", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_explosionfx_strength( "gstring_ExplosionFx_strength", "0.3", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_motionblur_scale( "gstring_MotionBlur_scale", "0.3", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_barsandgrain_zoom( "gstring_BarsAndGrain_zoom", "0.06", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_bloomflare_strength( "gstring_BloomFlare_strength", "3.5", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_desaturation_strength( "gstring_Desaturation_strength", "0.0", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_filmgrain_strength( "gstring_FilmGrain_strength", "0.02", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_bend_strength( "gstring_bend_strength", "0.2", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_chromatic_aberration( "gstring_chromatic_aberration", "0.002", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_vignette_strength( "gstring_Vignette_strength", "3.0", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_vignette_range_min( "gstring_Vignette_range_min", "0.1", FCVAR_ARCHIVE );
|
||||
ConVar cvar_gstring_vignette_range_max( "gstring_Vignette_range_max", "1", FCVAR_ARCHIVE );
|
||||
|
||||
ConVar cvar_gstring_debug_vguiparticles( "gstring_debug_VguiParticles", "0" );
|
||||
ConVar cvar_gstring_nightvision_minlighting( "gstring_nightvision_minlighting", "0.5" );
|
||||
|
||||
ConVar cvar_gstring_drawhurtfx( "gstring_DrawHurtFX", "1", FCVAR_ARCHIVE );
|
||||
ConVar gstring_hud_color( "gstring_hud_color", "255 229 153 255", FCVAR_ARCHIVE );
|
||||
|
||||
|
||||
ConVar gstring_dof_autofocus( "gstring_dof_autofocus", "1" );
|
||||
ConVar gstring_dof_focaldistance( "gstring_dof_focaldistance", "0.15" );
|
||||
ConVar gstring_dof_focallength( "gstring_dof_focallength", "3.5" );
|
||||
ConVar gstring_dof_aperture( "gstring_dof_aperture", "1", FCVAR_ARCHIVE );
|
||||
ConVar gstring_dof_smooth_speed( "gstring_dof_smooth_speed", "5", FCVAR_ARCHIVE );
|
||||
ConVar gstring_dof_max_distance( "gstring_dof_max_distance", "3000", FCVAR_ARCHIVE );
|
||||
ConVar gstring_dof_radius( "gstring_dof_radius", "0.02" );
|
||||
ConVar gstring_dof_override( "gstring_dof_override", "0" );
|
||||
|
||||
#endif
|
||||
58
sp/src/game/shared/gstring/gstring_cvars.h
Normal file
58
sp/src/game/shared/gstring/gstring_cvars.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef GSTRING_CVARS_H
|
||||
#define GSTRING_CVARS_H
|
||||
|
||||
#ifdef GAME_DLL
|
||||
extern ConVar cvar_gstring_enable_entities;
|
||||
#else
|
||||
extern ConVar cvar_gstring_enable_postprocessing;
|
||||
extern ConVar cvar_gstring_enable_hud;
|
||||
|
||||
extern ConVar cvar_gstring_drawdetailpropsfirst;
|
||||
//extern ConVar cvar_gstring_drawbars;
|
||||
//extern ConVar cvar_gstring_drawfilmgrain;
|
||||
extern ConVar cvar_gstring_drawvignette;
|
||||
extern ConVar cvar_gstring_drawgodrays;
|
||||
//extern ConVar cvar_gstring_drawexplosionblur;
|
||||
extern ConVar cvar_gstring_drawmotionblur;
|
||||
extern ConVar cvar_gstring_drawscreenblur;
|
||||
extern ConVar cvar_gstring_drawdreamblur;
|
||||
//extern ConVar cvar_gstring_drawbloomflare;
|
||||
extern ConVar cvar_gstring_drawlensflare;
|
||||
extern ConVar cvar_gstring_drawwatereffects;
|
||||
extern ConVar cvar_gstring_drawcinemaoverlay;
|
||||
extern ConVar cvar_gstring_drawdof;
|
||||
|
||||
extern ConVar cvar_gstring_bars_scale;
|
||||
extern ConVar cvar_gstring_explosionfx_strength;
|
||||
extern ConVar cvar_gstring_motionblur_scale;
|
||||
extern ConVar cvar_gstring_bloomflare_strength;
|
||||
extern ConVar cvar_gstring_desaturation_strength;
|
||||
extern ConVar cvar_gstring_filmgrain_strength;
|
||||
extern ConVar cvar_gstring_bend_strength;
|
||||
extern ConVar cvar_gstring_vignette_strength;
|
||||
extern ConVar cvar_gstring_vignette_range_min;
|
||||
extern ConVar cvar_gstring_vignette_range_max;
|
||||
|
||||
extern ConVar cvar_gstring_debug_vguiparticles;
|
||||
extern ConVar cvar_gstring_nightvision_minlighting;
|
||||
|
||||
extern ConVar cvar_gstring_drawhurtfx;
|
||||
extern ConVar cvar_gstring_chromatic_aberration;
|
||||
|
||||
extern ConVar gstring_spacecraft_firstperson;
|
||||
extern ConVar gstring_hud_color;
|
||||
|
||||
extern ConVar gstring_dof_autofocus;
|
||||
extern ConVar gstring_dof_focaldistance;
|
||||
extern ConVar gstring_dof_focallength;
|
||||
extern ConVar gstring_dof_aperture;
|
||||
extern ConVar gstring_dof_smooth_speed;
|
||||
extern ConVar gstring_dof_max_distance;
|
||||
extern ConVar gstring_dof_radius;
|
||||
extern ConVar gstring_dof_override;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,104 +0,0 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Header: $
|
||||
// $NoKeywords: $
|
||||
// An interface that should not ever be accessed directly from shaders
|
||||
// but instead is visible only to shaderlib.
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef ISHADERSYSTEM_H
|
||||
#define ISHADERSYSTEM_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "interface.h"
|
||||
#include <materialsystem/IShader.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
enum Sampler_t;
|
||||
class ITexture;
|
||||
class IShader;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The Shader system interface version
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADERSYSTEM_INTERFACE_VERSION "ShaderSystem002"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Modulation flags
|
||||
//-----------------------------------------------------------------------------
|
||||
enum
|
||||
{
|
||||
SHADER_USING_COLOR_MODULATION = 0x1,
|
||||
SHADER_USING_ALPHA_MODULATION = 0x2,
|
||||
SHADER_USING_FLASHLIGHT = 0x4,
|
||||
SHADER_USING_FIXED_FUNCTION_BAKED_LIGHTING = 0x8,
|
||||
SHADER_USING_EDITOR = 0x10,
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The shader system (a singleton)
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IShaderSystem
|
||||
{
|
||||
public:
|
||||
virtual ShaderAPITextureHandle_t GetShaderAPITextureBindHandle( ITexture *pTexture, int nFrameVar, int nTextureChannel = 0 ) =0;
|
||||
|
||||
// Binds a texture
|
||||
virtual void BindTexture( Sampler_t sampler1, ITexture *pTexture, int nFrameVar = 0 ) = 0;
|
||||
virtual void BindTexture( Sampler_t sampler1, Sampler_t sampler2, ITexture *pTexture, int nFrameVar = 0 ) = 0;
|
||||
|
||||
// Takes a snapshot
|
||||
virtual void TakeSnapshot( ) = 0;
|
||||
|
||||
// Draws a snapshot
|
||||
virtual void DrawSnapshot( bool bMakeActualDrawCall = true ) = 0;
|
||||
|
||||
// Are we using graphics?
|
||||
virtual bool IsUsingGraphics() const = 0;
|
||||
|
||||
// Are we using graphics?
|
||||
virtual bool CanUseEditorMaterials() const = 0;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The Shader plug-in DLL interface version
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADER_DLL_INTERFACE_VERSION "ShaderDLL004"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The Shader interface versions
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IShaderDLLInternal
|
||||
{
|
||||
public:
|
||||
// Here's where the app systems get to learn about each other
|
||||
virtual bool Connect( CreateInterfaceFn factory, bool bIsMaterialSystem ) = 0;
|
||||
virtual void Disconnect( bool bIsMaterialSystem ) = 0;
|
||||
|
||||
// Returns the number of shaders defined in this DLL
|
||||
virtual int ShaderCount() const = 0;
|
||||
|
||||
// Returns information about each shader defined in this DLL
|
||||
virtual IShader *GetShader( int nShader ) = 0;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Singleton interface
|
||||
//-----------------------------------------------------------------------------
|
||||
IShaderDLLInternal *GetShaderDLLInternal();
|
||||
|
||||
|
||||
#endif // ISHADERSYSTEM_H
|
||||
@@ -1,577 +0,0 @@
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
#include "cbase.h"
|
||||
#include "filesystem.h"
|
||||
#else
|
||||
#include "stdshaders/shaderincludes.h"
|
||||
#include "ProcShaderInterface.h"
|
||||
#endif
|
||||
|
||||
#include "IVProcShader.h"
|
||||
|
||||
#ifndef AllocCheck_Alloc
|
||||
#define AllocCheck_Alloc() ((void)NULL)
|
||||
#endif
|
||||
#ifndef AllocCheck_Free
|
||||
#define AllocCheck_Free() ((void)NULL)
|
||||
#endif
|
||||
#ifndef AllocCheck_AllocS
|
||||
#define AllocCheck_AllocS(x) ((void)NULL)
|
||||
#endif
|
||||
#ifndef AllocCheck_FreeS
|
||||
#define AllocCheck_FreeS(x) ((void)NULL)
|
||||
#endif
|
||||
|
||||
|
||||
void AddDataToMaterial( KeyValues *pMat, KeyValues *pData, int recursionDepth = 0 )
|
||||
{
|
||||
UnpackMaterial( pData, recursionDepth );
|
||||
|
||||
for ( KeyValues *pValue = pData->GetFirstValue(); pValue != NULL; pValue = pValue->GetNextValue() )
|
||||
{
|
||||
const char *pszParam = pValue->GetName();
|
||||
const char *pszValue = pValue->GetString();
|
||||
|
||||
pMat->SetString( pszParam, pszValue );
|
||||
}
|
||||
}
|
||||
|
||||
void UnpackMaterial( KeyValues *pKV, int recursionDepth )
|
||||
{
|
||||
Assert( pKV );
|
||||
|
||||
if ( recursionDepth > 99 )
|
||||
{
|
||||
Warning( "ABORTING MATERIAL UNPACKING OF %s - INFINITELY RECURSIVE!\n", pKV->GetName() );
|
||||
return;
|
||||
}
|
||||
|
||||
const bool bIsPatch = !Q_stricmp( pKV->GetName(), "patch" );
|
||||
|
||||
for ( KeyValues *pSub = pKV->GetFirstSubKey(); pSub != NULL; pSub = pSub->GetNextKey() )
|
||||
{
|
||||
const char *pszName = pSub->GetName();
|
||||
|
||||
if ( !Q_stricmp( pszName, "include" ) ) // a string
|
||||
{
|
||||
const char *pFile = pSub->GetString();
|
||||
if ( !pFile || !*pFile )
|
||||
continue;
|
||||
|
||||
KeyValues *pInlcude = new KeyValues( "include" );
|
||||
if ( pInlcude->LoadFromFile( g_pFullFileSystem, pFile ) )
|
||||
{
|
||||
AddDataToMaterial( pKV, pInlcude, recursionDepth );
|
||||
if ( bIsPatch ) // recursive patches!
|
||||
pKV->SetName( pInlcude->GetName() );
|
||||
}
|
||||
|
||||
pInlcude->deleteThis();
|
||||
}
|
||||
else if ( !Q_stricmp( pszName, "replace" ) || !Q_stricmp( pszName, "insert" ) ) // a subkey
|
||||
{
|
||||
for ( KeyValues *pValue = pSub->GetFirstValue(); pValue != NULL; pValue = pValue->GetNextValue() )
|
||||
{
|
||||
pKV->SetString( pValue->GetName(), pValue->GetString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_clCallback::_clCallback()
|
||||
{
|
||||
name = NULL;
|
||||
func = NULL;
|
||||
numComps = 1;
|
||||
}
|
||||
_clCallback::~_clCallback()
|
||||
{
|
||||
delete [] name;
|
||||
}
|
||||
_clCallback::_clCallback( const _clCallback &o )
|
||||
{
|
||||
name = NULL;
|
||||
if ( o.name != NULL && Q_strlen( o.name ) )
|
||||
{
|
||||
name = new char [ Q_strlen( o.name ) + 1 ];
|
||||
Q_strcpy( name, o.name );
|
||||
}
|
||||
func = o.func;
|
||||
numComps = o.numComps;
|
||||
}
|
||||
|
||||
int RemapEnvironmentConstant( bool bPixelShader, int iNormalized )
|
||||
{
|
||||
if ( iNormalized < 0 )
|
||||
return -1;
|
||||
|
||||
int offset = 0;
|
||||
Assert( iNormalized >= 0 );
|
||||
if ( !bPixelShader )
|
||||
{
|
||||
offset = 48;
|
||||
Assert( iNormalized <= 9 );
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 0
|
||||
if ( iNormalized <= 3 )
|
||||
offset = 0;
|
||||
else if ( iNormalized <= 8 )
|
||||
offset = 6;
|
||||
else if ( iNormalized <= 9 )
|
||||
offset = 6 + 4;
|
||||
else if ( iNormalized <= 10 )
|
||||
offset = 6 + 4 + 6;
|
||||
Assert( iNormalized <= 8 );
|
||||
#else
|
||||
offset = 16;
|
||||
Assert( iNormalized <= 13 );
|
||||
#endif
|
||||
}
|
||||
return offset + iNormalized;
|
||||
}
|
||||
|
||||
void ShaderNameToSwarmUnique( char *pBuf, int maxLen )
|
||||
{
|
||||
if ( !pBuf || !*pBuf || maxLen < 1 )
|
||||
return;
|
||||
|
||||
char tmp[MAX_PATH*4];
|
||||
Q_snprintf( tmp, sizeof( tmp ), "%s", pBuf );
|
||||
|
||||
const char *pLastUnderscore = pBuf + Q_strlen(pBuf) - 1;
|
||||
while ( pLastUnderscore > pBuf && *pLastUnderscore != '_' )
|
||||
pLastUnderscore--;
|
||||
|
||||
if ( pLastUnderscore < pBuf || *pLastUnderscore != '_' )
|
||||
return;
|
||||
|
||||
pLastUnderscore++;
|
||||
int offset = pLastUnderscore - pBuf;
|
||||
|
||||
if ( offset >= sizeof( tmp ) || offset < 0 )
|
||||
return;
|
||||
|
||||
tmp[offset] = '\0';
|
||||
Q_strcat( tmp, "mod_", sizeof( tmp ) );
|
||||
|
||||
if ( *pLastUnderscore )
|
||||
Q_strcat( tmp, pLastUnderscore, sizeof( tmp ) );
|
||||
|
||||
Q_snprintf( pBuf, maxLen, "%s", tmp );
|
||||
}
|
||||
|
||||
BasicShaderCfg_t::BasicShaderCfg_t()
|
||||
{
|
||||
iShaderModel = SM_30;
|
||||
iCullmode = CULLMODE_CW;
|
||||
iAlphablendmode = ABLEND_NONE;
|
||||
flAlphaTestRef = 0.5f;
|
||||
iDepthtestmode = DEPTHTEST_NORMAL;
|
||||
iDepthwritemode = DEPTHWRITE_NORMAL;
|
||||
bsRGBWrite = false;
|
||||
bPreviewMode = false;
|
||||
|
||||
iVFMT_flags = VERTEX_POSITION;
|
||||
iVFMT_numTexcoords = 1;
|
||||
iVFMT_numUserData = 0;
|
||||
iVFMT_texDim[0] = 2;
|
||||
iVFMT_texDim[1] = 2;
|
||||
iVFMT_texDim[2] = 2;
|
||||
|
||||
ProcVSName = NULL;
|
||||
ProcPSName = NULL;
|
||||
CanvasName = NULL;
|
||||
Filename = NULL;
|
||||
dumpversion[0] = '\0';
|
||||
//pVS_Identifiers = pPS_Identifiers = NULL;
|
||||
pVS_Identifiers = new IdentifierLists_t();
|
||||
pPS_Identifiers = new IdentifierLists_t();
|
||||
|
||||
bVertexLighting = false;
|
||||
bRefractionSupport = false;
|
||||
|
||||
AllocCheck_Alloc();
|
||||
}
|
||||
|
||||
BasicShaderCfg_t::BasicShaderCfg_t( const BasicShaderCfg_t &o )
|
||||
{
|
||||
ProcVSName = NULL;
|
||||
ProcPSName = NULL;
|
||||
CanvasName = NULL;
|
||||
Filename = NULL;
|
||||
|
||||
if ( o.ProcVSName )
|
||||
{
|
||||
int len = Q_strlen( o.ProcVSName ) + 1;
|
||||
ProcVSName = new char[ len ];
|
||||
Q_snprintf( ProcVSName, len, "%s", o.ProcVSName );
|
||||
}
|
||||
if ( o.ProcPSName )
|
||||
{
|
||||
int len = Q_strlen( o.ProcPSName ) + 1;
|
||||
ProcPSName = new char[ len ];
|
||||
Q_snprintf( ProcPSName, len, "%s", o.ProcPSName );
|
||||
}
|
||||
if ( o.CanvasName )
|
||||
{
|
||||
int len = Q_strlen( o.CanvasName ) + 1;
|
||||
CanvasName = new char[ len ];
|
||||
Q_snprintf( CanvasName, len, "%s", o.CanvasName );
|
||||
}
|
||||
if ( o.Filename )
|
||||
{
|
||||
int len = Q_strlen( o.Filename ) + 1;
|
||||
Filename = new char[ len ];
|
||||
Q_snprintf( Filename, len, "%s", o.Filename );
|
||||
}
|
||||
|
||||
Q_strcpy( dumpversion, o.dumpversion );
|
||||
|
||||
iShaderModel = o.iShaderModel;
|
||||
iCullmode = o.iCullmode;
|
||||
iAlphablendmode = o.iAlphablendmode;
|
||||
flAlphaTestRef = o.flAlphaTestRef;
|
||||
iDepthtestmode = o.iDepthtestmode;
|
||||
iDepthwritemode = o.iDepthwritemode;
|
||||
bsRGBWrite = o.bsRGBWrite;
|
||||
bPreviewMode = o.bPreviewMode;
|
||||
|
||||
iVFMT_flags = o.iVFMT_flags;
|
||||
iVFMT_numTexcoords = o.iVFMT_numTexcoords;
|
||||
iVFMT_numUserData = o.iVFMT_numUserData;
|
||||
Q_memcpy( iVFMT_texDim, o.iVFMT_texDim, sizeof(int) * 3 );
|
||||
|
||||
pVS_Identifiers = NULL;
|
||||
pPS_Identifiers = NULL;
|
||||
|
||||
bVertexLighting = o.bVertexLighting;
|
||||
bRefractionSupport = o.bRefractionSupport;
|
||||
|
||||
if ( o.pVS_Identifiers )
|
||||
pVS_Identifiers = new IdentifierLists_t(*o.pVS_Identifiers);
|
||||
if ( o.pPS_Identifiers )
|
||||
pPS_Identifiers = new IdentifierLists_t(*o.pPS_Identifiers);
|
||||
|
||||
AllocCheck_Alloc();
|
||||
}
|
||||
|
||||
BasicShaderCfg_t::~BasicShaderCfg_t()
|
||||
{
|
||||
delete [] ProcVSName;
|
||||
delete [] ProcPSName;
|
||||
delete [] CanvasName;
|
||||
delete [] Filename;
|
||||
|
||||
delete pVS_Identifiers;
|
||||
delete pPS_Identifiers;
|
||||
|
||||
AllocCheck_Free();
|
||||
}
|
||||
|
||||
SimpleCombo::SimpleCombo()
|
||||
{
|
||||
bStatic = false;
|
||||
bInPreviewMode = false;
|
||||
min = 0;
|
||||
max = 1;
|
||||
name = NULL;
|
||||
iComboType = 0;
|
||||
|
||||
AllocCheck_Alloc();
|
||||
}
|
||||
SimpleCombo::~SimpleCombo()
|
||||
{
|
||||
delete [] name;
|
||||
|
||||
AllocCheck_Free();
|
||||
}
|
||||
SimpleCombo::SimpleCombo(const SimpleCombo &o)
|
||||
{
|
||||
name = NULL;
|
||||
if ( o.name )
|
||||
{
|
||||
int len = Q_strlen( o.name ) + 1;
|
||||
name = new char[ len ];
|
||||
Q_snprintf( name, len, "%s", o.name );
|
||||
}
|
||||
min = o.min;
|
||||
max = o.max;
|
||||
bStatic = o.bStatic;
|
||||
iComboType = o.iComboType;
|
||||
bInPreviewMode = o.bInPreviewMode;
|
||||
|
||||
AllocCheck_Alloc();
|
||||
}
|
||||
SimpleTexture::SimpleTexture()
|
||||
{
|
||||
szTextureName = NULL;
|
||||
szParamName = NULL;
|
||||
szFallbackName = NULL;
|
||||
iSamplerIndex = 0;
|
||||
iTextureMode = 0;
|
||||
bCubeTexture = false;
|
||||
bSRGB = false;
|
||||
|
||||
AllocCheck_Alloc();
|
||||
}
|
||||
SimpleTexture::~SimpleTexture()
|
||||
{
|
||||
if ( szTextureName != NULL )
|
||||
AllocCheck_FreeS( "szTextureName" );
|
||||
|
||||
delete [] szTextureName;
|
||||
delete [] szParamName;
|
||||
delete [] szFallbackName;
|
||||
|
||||
m_hTargetNodes.PurgeAndDeleteElements();
|
||||
|
||||
AllocCheck_Free();
|
||||
}
|
||||
SimpleTexture::SimpleTexture( const SimpleTexture &o )
|
||||
{
|
||||
iSamplerIndex = o.iSamplerIndex;
|
||||
iTextureMode = o.iTextureMode;
|
||||
bCubeTexture = o.bCubeTexture;
|
||||
bSRGB = o.bSRGB;
|
||||
|
||||
if ( o.szTextureName )
|
||||
{
|
||||
int len = Q_strlen( o.szTextureName ) + 1;
|
||||
szTextureName = new char[ len ];
|
||||
Q_snprintf( szTextureName, len, "%s", o.szTextureName );
|
||||
|
||||
AllocCheck_AllocS( "szTextureName" );
|
||||
}
|
||||
else
|
||||
szTextureName = NULL;
|
||||
if ( o.szParamName )
|
||||
{
|
||||
int len = Q_strlen( o.szParamName ) + 1;
|
||||
szParamName = new char[ len ];
|
||||
Q_snprintf( szParamName, len, "%s", o.szParamName );
|
||||
}
|
||||
else
|
||||
szParamName = NULL;
|
||||
if ( o.szFallbackName )
|
||||
{
|
||||
int len = Q_strlen( o.szFallbackName ) + 1;
|
||||
szFallbackName = new char[ len ];
|
||||
Q_snprintf( szFallbackName, len, "%s", o.szFallbackName );
|
||||
}
|
||||
else
|
||||
szFallbackName = NULL;
|
||||
|
||||
for ( int i = 0; i < o.m_hTargetNodes.Count(); i++ )
|
||||
m_hTargetNodes.AddToTail( new HNODE( *o.m_hTargetNodes[i] ) );
|
||||
|
||||
AllocCheck_Alloc();
|
||||
}
|
||||
|
||||
SimpleEnvConstant::SimpleEnvConstant()
|
||||
{
|
||||
iEnvC_ID = HLSLENV_TIME;
|
||||
iHLSLRegister = 0;
|
||||
iConstSize = 1;
|
||||
szSmartHelper = NULL;
|
||||
iFastLookup = -1;
|
||||
iSmartNumComps = 3;
|
||||
Q_memset( flSmartDefaultValues, 0, sizeof( flSmartDefaultValues ) );
|
||||
|
||||
AllocCheck_Alloc();
|
||||
}
|
||||
SimpleEnvConstant::~SimpleEnvConstant()
|
||||
{
|
||||
delete [] szSmartHelper;
|
||||
|
||||
AllocCheck_Free();
|
||||
}
|
||||
SimpleEnvConstant::SimpleEnvConstant( const SimpleEnvConstant &o )
|
||||
{
|
||||
szSmartHelper = NULL;
|
||||
if ( o.szSmartHelper && Q_strlen( o.szSmartHelper ) )
|
||||
{
|
||||
szSmartHelper = new char[ Q_strlen( o.szSmartHelper ) + 1 ];
|
||||
Q_strcpy( szSmartHelper, o.szSmartHelper );
|
||||
}
|
||||
|
||||
iEnvC_ID = o.iEnvC_ID;
|
||||
iHLSLRegister = o.iHLSLRegister;
|
||||
iConstSize = o.iConstSize;
|
||||
iFastLookup = o.iFastLookup;
|
||||
iSmartNumComps = o.iSmartNumComps;
|
||||
Q_memcpy( flSmartDefaultValues, o.flSmartDefaultValues, sizeof( flSmartDefaultValues ) );
|
||||
|
||||
AllocCheck_Alloc();
|
||||
}
|
||||
SimpleArray::SimpleArray()
|
||||
{
|
||||
vecData = NULL;
|
||||
iSize_X = 0;
|
||||
iSize_Y = 0;
|
||||
iNumComps = 0;
|
||||
iIndex = 0;
|
||||
|
||||
AllocCheck_Alloc();
|
||||
}
|
||||
SimpleArray::SimpleArray( const SimpleArray &o )
|
||||
{
|
||||
iSize_X = o.iSize_X;
|
||||
iSize_Y = o.iSize_Y;
|
||||
iNumComps = o.iNumComps;
|
||||
iIndex = o.iIndex;
|
||||
vecData = NULL;
|
||||
|
||||
const int numComps = iSize_X * iSize_Y;
|
||||
if ( numComps > 0 )
|
||||
{
|
||||
vecData = new Vector4D[ numComps ];
|
||||
Q_memcpy( vecData, o.vecData, sizeof(Vector4D) * numComps );
|
||||
}
|
||||
|
||||
AllocCheck_Alloc();
|
||||
}
|
||||
SimpleArray::~SimpleArray()
|
||||
{
|
||||
delete [] vecData;
|
||||
|
||||
AllocCheck_Free();
|
||||
}
|
||||
|
||||
SimpleFunction::SimpleFunction()
|
||||
{
|
||||
szFuncName = NULL;
|
||||
szFilePath = NULL;
|
||||
szCode_Global = NULL;
|
||||
szCode_Body = NULL;
|
||||
}
|
||||
SimpleFunction::~SimpleFunction()
|
||||
{
|
||||
delete [] szFuncName;
|
||||
delete [] szFilePath;
|
||||
delete [] szCode_Global;
|
||||
delete [] szCode_Body;
|
||||
hParams.PurgeAndDeleteElements();
|
||||
}
|
||||
SimpleFunction::SimpleFunction( const SimpleFunction &o )
|
||||
{
|
||||
if ( o.szFuncName && *o.szFuncName )
|
||||
{
|
||||
int len = Q_strlen( o.szFuncName ) + 1;
|
||||
szFuncName = new char[ len ];
|
||||
Q_strcpy( szFuncName, o.szFuncName );
|
||||
}
|
||||
else
|
||||
szFuncName = NULL;
|
||||
|
||||
if ( o.szFilePath && *o.szFilePath )
|
||||
{
|
||||
int len = Q_strlen( o.szFilePath ) + 1;
|
||||
szFilePath = new char[ len ];
|
||||
Q_strcpy( szFilePath, o.szFilePath );
|
||||
}
|
||||
else
|
||||
szFilePath = NULL;
|
||||
|
||||
if ( o.szCode_Global && *o.szCode_Global )
|
||||
{
|
||||
int len = Q_strlen( o.szCode_Global ) + 1;
|
||||
szCode_Global = new char[ len ];
|
||||
Q_strcpy( szCode_Global, o.szCode_Global );
|
||||
}
|
||||
else
|
||||
szCode_Global = NULL;
|
||||
|
||||
if ( o.szCode_Body && *o.szCode_Body )
|
||||
{
|
||||
int len = Q_strlen( o.szCode_Body ) + 1;
|
||||
szCode_Body = new char[ len ];
|
||||
Q_strcpy( szCode_Body, o.szCode_Body );
|
||||
}
|
||||
else
|
||||
szCode_Body = NULL;
|
||||
|
||||
for ( int i = 0; i < o.hParams.Count(); i++ )
|
||||
hParams.AddToTail( new __funcParamSetup( *o.hParams[i] ) );
|
||||
}
|
||||
bool SimpleFunction::IsInline()
|
||||
{
|
||||
return !szFilePath || !Q_strlen(szFilePath);
|
||||
}
|
||||
|
||||
__funcParamSetup::__funcParamSetup()
|
||||
{
|
||||
iFlag = 1; //::HLSLVAR_FLOAT1;
|
||||
pszName = NULL;
|
||||
bOutput = false;
|
||||
}
|
||||
__funcParamSetup::~__funcParamSetup()
|
||||
{
|
||||
if ( pszName != NULL )
|
||||
delete [] pszName;
|
||||
}
|
||||
__funcParamSetup::__funcParamSetup( const __funcParamSetup &o )
|
||||
{
|
||||
iFlag = o.iFlag;
|
||||
pszName = NULL;
|
||||
bOutput = o.bOutput;
|
||||
|
||||
if ( o.pszName != NULL )
|
||||
{
|
||||
pszName = new char[ Q_strlen( o.pszName ) + 1 ];
|
||||
Q_strcpy( pszName, o.pszName );
|
||||
}
|
||||
}
|
||||
const char *__funcParamSetup::GetSafeName( int num )
|
||||
{
|
||||
if ( !pszName )
|
||||
{
|
||||
char _name[32];
|
||||
Q_snprintf( _name, sizeof(_name), "var_%02i", num );
|
||||
int len = Q_strlen( _name ) + 1;
|
||||
pszName = new char[ len ];
|
||||
Q_strcpy( pszName, _name );
|
||||
}
|
||||
return pszName;
|
||||
}
|
||||
|
||||
IdentifierLists_t::IdentifierLists_t()
|
||||
{
|
||||
inum_DynamicCombos = 1;
|
||||
|
||||
AllocCheck_Alloc();
|
||||
}
|
||||
IdentifierLists_t::~IdentifierLists_t()
|
||||
{
|
||||
hList_Combos.PurgeAndDeleteElements();
|
||||
hList_Textures.PurgeAndDeleteElements();
|
||||
hList_EConstants.PurgeAndDeleteElements();
|
||||
hList_Arrays.PurgeAndDeleteElements();
|
||||
hList_Functions.PurgeAndDeleteElements();
|
||||
|
||||
AllocCheck_Free();
|
||||
}
|
||||
IdentifierLists_t::IdentifierLists_t( const IdentifierLists_t &o )
|
||||
{
|
||||
for ( int i = 0; i < o.hList_Combos.Count(); i++ )
|
||||
hList_Combos.AddToTail( new SimpleCombo( *o.hList_Combos[ i ] ) );
|
||||
|
||||
for ( int i = 0; i < o.hList_Textures.Count(); i++ )
|
||||
hList_Textures.AddToTail( new SimpleTexture( *o.hList_Textures[ i ] ) );
|
||||
|
||||
for ( int i = 0; i < o.hList_EConstants.Count(); i++ )
|
||||
hList_EConstants.AddToTail( new SimpleEnvConstant( *o.hList_EConstants[ i ] ) );
|
||||
|
||||
for ( int i = 0; i < o.hList_Arrays.Count(); i++ )
|
||||
hList_Arrays.AddToTail( new SimpleArray( *o.hList_Arrays[ i ] ) );
|
||||
|
||||
for ( int i = 0; i < o.hList_Functions.Count(); i++ )
|
||||
hList_Functions.AddToTail( new SimpleFunction( *o.hList_Functions[ i ] ) );
|
||||
|
||||
inum_DynamicCombos = o.inum_DynamicCombos;
|
||||
|
||||
AllocCheck_Alloc();
|
||||
}
|
||||
|
||||
//CUtlVector< SimpleCombo* > hList_Combos;
|
||||
@@ -1,565 +0,0 @@
|
||||
#ifndef IPROCSHADER_H
|
||||
#define IPROCSHADER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "../../shadereditor/ivshadereditor.h"
|
||||
|
||||
#define AMT_PS_SAMPLERS 16
|
||||
#define AMT_PS_CREG 13 //14
|
||||
|
||||
#define AMT_VS_SAMPLERS 4
|
||||
#define AMT_VS_CREG 10
|
||||
|
||||
#define AMT_VMT_STATIC 16
|
||||
#define AMT_VMT_MUTABLE 10
|
||||
|
||||
struct _clCallback
|
||||
{
|
||||
_clCallback();
|
||||
~_clCallback();
|
||||
_clCallback( const _clCallback &o );
|
||||
|
||||
char *name;
|
||||
pFnClCallback( func );
|
||||
int numComps;
|
||||
};
|
||||
|
||||
void ShaderNameToSwarmUnique( char *pBuf, int maxLen );
|
||||
|
||||
#if defined(DEBUG) && !defined(PROCSHADER_DLL)
|
||||
#include "../../shadereditor/editorcommon.h"
|
||||
class HNODE
|
||||
{
|
||||
public:
|
||||
HNODE()
|
||||
{
|
||||
value = 0;
|
||||
AllocCheck_Alloc();
|
||||
};
|
||||
HNODE( unsigned int i )
|
||||
{
|
||||
value = i;
|
||||
AllocCheck_Alloc();
|
||||
};
|
||||
~HNODE()
|
||||
{
|
||||
AllocCheck_Free();
|
||||
};
|
||||
HNODE(const HNODE &o)
|
||||
{
|
||||
AllocCheck_Alloc();
|
||||
value = o.value;
|
||||
};
|
||||
|
||||
operator unsigned int() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
inline bool operator==( const HNODE &o ){ return value == o.value; };
|
||||
inline bool operator==( unsigned int i ){ return value == i; };
|
||||
inline HNODE& operator=( const HNODE &o ){ value = o.value; return *this; };
|
||||
inline HNODE& operator=( unsigned int i ){ value = i; return *this; };
|
||||
inline HNODE& operator++(){ value++; return *this; };
|
||||
inline HNODE operator++(int){ HNODE t = *this; ++*this; return t; };
|
||||
inline HNODE& operator--(){ value--; return *this; };
|
||||
inline HNODE operator--(int){ HNODE t = *this; --*this; return t; };
|
||||
|
||||
private:
|
||||
unsigned int value;
|
||||
};
|
||||
#else
|
||||
typedef unsigned int HNODE;
|
||||
#endif
|
||||
|
||||
class KeyValues;
|
||||
void UnpackMaterial( KeyValues *pKV, int recursionDepth = 0 );
|
||||
|
||||
enum
|
||||
{
|
||||
NPSOP_WRITE_TEXCOORD_0 = 0,
|
||||
NPSOP_WRITE_TEXCOORD_1,
|
||||
NPSOP_WRITE_TEXCOORD_2,
|
||||
NPSOP_WRITE_TEXCOORD_3,
|
||||
NPSOP_WRITE_TEXCOORD_4,
|
||||
NPSOP_WRITE_TEXCOORD_5,
|
||||
NPSOP_WRITE_TEXCOORD_6,
|
||||
NPSOP_WRITE_TEXCOORD_7,
|
||||
NPSOP_WRITE_COLOR_0,
|
||||
NPSOP_WRITE_COLOR_1,
|
||||
|
||||
NPSOP_WRITE_MAX,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
NPSOP_CALC_ADD = 0,
|
||||
NPSOP_CALC_SUBTRACT,
|
||||
NPSOP_CALC_SWIZZLE,
|
||||
NPSOP_CALC_MULTIPLY,
|
||||
NPSOP_CALC_DIVIDE,
|
||||
|
||||
NPSOP_TEXTURE_LOOKUP_2D,
|
||||
NPSOP_TEXTURE_LOOKUP_3D,
|
||||
|
||||
NPSOP_SET_CONSTANT,
|
||||
NPSOP_UTILITY_DECLARE,
|
||||
NPSOP_UTILITY_ASSIGN,
|
||||
|
||||
NPSOP_CALC_DOT,
|
||||
NPSOP_CALC_NORMALIZE,
|
||||
NPSOP_CALC_LERP,
|
||||
NPSOP_CALC_SMOOTHSTEP,
|
||||
NPSOP_CALC_CLAMP,
|
||||
NPSOP_CALC_LENGTH,
|
||||
NPSOP_CALC_POW,
|
||||
NPSOP_CALC_STEP,
|
||||
NPSOP_CALC_ROUND,
|
||||
NPSOP_CALC_FRAC,
|
||||
NPSOP_CALC_FLOOR,
|
||||
NPSOP_CALC_CEIL,
|
||||
NPSOP_CALC_ABS,
|
||||
|
||||
NPSOP_CALC_SIN,
|
||||
NPSOP_CALC_ASIN,
|
||||
NPSOP_CALC_SINH,
|
||||
NPSOP_CALC_COS,
|
||||
NPSOP_CALC_ACOS,
|
||||
NPSOP_CALC_COSH,
|
||||
NPSOP_CALC_TAN,
|
||||
NPSOP_CALC_ATAN,
|
||||
NPSOP_CALC_TANH,
|
||||
NPSOP_CALC_ATAN2,
|
||||
|
||||
NPSOP_CALC_MIN,
|
||||
NPSOP_CALC_MAX,
|
||||
NPSOP_CALC_FMOD,
|
||||
NPSOP_CALC_DEGREES,
|
||||
NPSOP_CALC_RADIANS,
|
||||
|
||||
NPSOP_CALC_REFLECT,
|
||||
NPSOP_CALC_REFRACT,
|
||||
NPSOP_CALC_SATURATE,
|
||||
NPSOP_CALC_INVERT,
|
||||
|
||||
NPSOP_CALC_TEXTRANSFORM,
|
||||
NPSOP_CALC_SIGN,
|
||||
NPSOP_CALC_APPEND,
|
||||
NPSOP_CALC_SQRT,
|
||||
NPSOP_CALC_CROSS,
|
||||
|
||||
NPSOP_CALC_PSLIGHTING,
|
||||
NPSOP_CALC_MCOMP,
|
||||
|
||||
NPSOP_CALC_LOG,
|
||||
NPSOP_CALC_LOG2,
|
||||
NPSOP_CALC_LOG10,
|
||||
|
||||
NPSOP_CALC_EXP,
|
||||
NPSOP_CALC_EXP2,
|
||||
|
||||
NPSOP_CALC_DDX,
|
||||
NPSOP_CALC_DDY,
|
||||
|
||||
NPSOP_TEXTURE_LOOKUP_FIXED,
|
||||
|
||||
NPSOP_CALC_DIST,
|
||||
|
||||
NPSOP_CALC_LAST,
|
||||
};
|
||||
|
||||
enum HLSLComboTypes
|
||||
{
|
||||
HLSLCOMBO_INVALID = 0,
|
||||
|
||||
HLSLCOMBO_CUSTOM,
|
||||
|
||||
HLSLCOMBO_SKINNING,
|
||||
HLSLCOMBO_MORPHING,
|
||||
|
||||
HLSLCOMBO_LIGHT_STATIC,
|
||||
HLSLCOMBO_LIGHT_DYNAMIC,
|
||||
HLSLCOMBO_NUM_LIGHTS,
|
||||
|
||||
HLSLCOMBO_PIXELFOG,
|
||||
HLSLCOMBO_WATERFOG_TOALPHA,
|
||||
|
||||
HLSLCOMBO_FLASHLIGHT_ENABLED,
|
||||
HLSLCOMBO_FLASHLIGHT_FILTER_MODE,
|
||||
HLSLCOMBO_FLASHLIGHT_DO_SHADOWS,
|
||||
|
||||
HLSLCOMBO_VERTEXCOMPRESSION,
|
||||
HLSLCOMBO_MAX,
|
||||
};
|
||||
|
||||
enum HLSLTextureSamplerModes
|
||||
{
|
||||
HLSLTEX_CUSTOMPARAM = 0,
|
||||
|
||||
HLSLTEX_BASETEXTURE,
|
||||
HLSLTEX_BUMPMAP,
|
||||
HLSLTEX_LIGHTMAP,
|
||||
HLSLTEX_LIGHTMAP_BUMPMAPPED,
|
||||
|
||||
HLSLTEX_FRAMEBUFFER,
|
||||
HLSLTEX_ENVMAP,
|
||||
|
||||
HLSLTEX_BLACK,
|
||||
HLSLTEX_WHITE,
|
||||
HLSLTEX_GREY,
|
||||
|
||||
HLSLTEX_FLASHLIGHT_COOKIE,
|
||||
HLSLTEX_FLASHLIGHT_DEPTH,
|
||||
HLSLTEX_FLASHLIGHT_RANDOM,
|
||||
|
||||
HLSLTEX_MORPH,
|
||||
HLSLTEX_,
|
||||
};
|
||||
|
||||
#define HLSLTEXSAM_LAST_USABLE HLSLTEX_GREY
|
||||
//#define ISTEXTURESAMPLERLOCKED(x) ( x == HLSLTEX_FLASHLIGHT_COOKIE || x == HLSLTEX_FLASHLIGHT_RANDOM || x == HLSLTEX_FLASHLIGHT_DEPTH )
|
||||
#define IS_TEXTURE_SAMPLER_USING_CUSTOM_TEXTURE( x ) ( x == HLSLTEX_CUSTOMPARAM ||\
|
||||
x == HLSLTEX_BASETEXTURE ||\
|
||||
x == HLSLTEX_BUMPMAP )
|
||||
|
||||
enum
|
||||
{
|
||||
CMATRIX_VIEW = 0,
|
||||
CMATRIX_PROJ,
|
||||
CMATRIX_VIEWPROJ,
|
||||
|
||||
CMATRIX_VIEW_INV,
|
||||
CMATRIX_PROJ_INV,
|
||||
CMATRIX_VIEWPROJ_INV,
|
||||
|
||||
CMATRIX_LAST,
|
||||
};
|
||||
|
||||
enum HLSLEnvironmentConstants
|
||||
{
|
||||
HLSLENV_TIME = 0,
|
||||
|
||||
HLSLENV_VIEW_ORIGIN,
|
||||
HLSLENV_VIEW_FWD,
|
||||
HLSLENV_VIEW_RIGHT,
|
||||
HLSLENV_VIEW_UP,
|
||||
HLSLENV_VIEW_WORLDDEPTH,
|
||||
HLSLENV_PIXEL_SIZE,
|
||||
HLSLENV_FOG_PARAMS,
|
||||
|
||||
// helper constants
|
||||
HLSLENV_STUDIO_LIGHTING_VS,
|
||||
HLSLENV_STUDIO_LIGHTING_PS,
|
||||
HLSLENV_STUDIO_MORPHING,
|
||||
|
||||
HLSLENV_FLASHLIGHT_VPMATRIX,
|
||||
HLSLENV_FLASHLIGHT_DATA,
|
||||
HLSLENV_CUSTOM_MATRIX,
|
||||
|
||||
HLSLENV_SMART_CALLBACK,
|
||||
HLSLENV_SMART_VMT_STATIC,
|
||||
HLSLENV_SMART_VMT_MUTABLE,
|
||||
HLSLENV_SMART_RANDOM_FLOAT,
|
||||
|
||||
HLSLENV_LIGHTMAP_RGB,
|
||||
|
||||
HLSLENV_MAX,
|
||||
};
|
||||
|
||||
// true when using custom hlsl code printing
|
||||
#define HLSLENV_IS_MANUAL_CONST( x ) ( x >= HLSLENV_STUDIO_LIGHTING_VS )
|
||||
// true when using smarthelper string on uniquify
|
||||
#define HLSLENV_IS_SMART_CONST( x ) ( x >= HLSLENV_SMART_CALLBACK && x <= HLSLENV_SMART_RANDOM_FLOAT )
|
||||
// true if const uses custom register
|
||||
#define HLSLENV_SHOULD_COUNT_CONST( x, IsPS ) ( x <= HLSLENV_FOG_PARAMS ||\
|
||||
( x == HLSLENV_FLASHLIGHT_VPMATRIX && !IsPS ) ||\
|
||||
x == HLSLENV_SMART_CALLBACK ||\
|
||||
x == HLSLENV_SMART_VMT_STATIC ||\
|
||||
x == HLSLENV_SMART_VMT_MUTABLE ||\
|
||||
x == HLSLENV_SMART_RANDOM_FLOAT ||\
|
||||
x == HLSLENV_CUSTOM_MATRIX ||\
|
||||
x == HLSLENV_LIGHTMAP_RGB)
|
||||
|
||||
// autocopy data from viewsetup
|
||||
#define HLSLENV_AUTOCOPYCONST_FIRST HLSLENV_VIEW_ORIGIN
|
||||
#define HLSLENV_AUTOCOPYCONST_LAST HLSLENV_VIEW_WORLDDEPTH
|
||||
|
||||
// map it to an actual hlsl register
|
||||
int RemapEnvironmentConstant( bool bPixelShader, int iNormalized );
|
||||
|
||||
#ifndef PROCSHADER_DLL
|
||||
#include "interface.h"
|
||||
#else
|
||||
#include "../public/tier1/interface.h"
|
||||
#endif
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
SM_20B = 0,
|
||||
SM_30,
|
||||
};
|
||||
enum
|
||||
{
|
||||
CULLMODE_CW = 0,
|
||||
CULLMODE_CCW,
|
||||
//CULLMODE_DOUBLE,
|
||||
CULLMODE_NONE,
|
||||
};
|
||||
enum
|
||||
{
|
||||
ABLEND_NONE = 0,
|
||||
ABLEND_SIMPLE,
|
||||
ABLEND_SIMPLE_INVERTED,
|
||||
ABLEND_ALPHATEST,
|
||||
ABLEND_ADDITIVE,
|
||||
ABLEND_ALPHA2COVERAGE,
|
||||
};
|
||||
#define ABLEND_IS_TRANSLUCENT( x ) ( x >= ABLEND_SIMPLE && x <= ABLEND_SIMPLE_INVERTED ||\
|
||||
x == ABLEND_ADDITIVE )
|
||||
enum
|
||||
{
|
||||
DEPTHTEST_OFF = 0,
|
||||
DEPTHTEST_NORMAL,
|
||||
};
|
||||
enum
|
||||
{
|
||||
DEPTHWRITE_OFF = 0,
|
||||
DEPTHWRITE_NORMAL,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROCS_TEX_TYPE_DEFAULT = 0,
|
||||
PROCS_TEX_TYPE_CUBEMAP,
|
||||
PROCS_TEX_TYPE_NORMALMAP,
|
||||
};
|
||||
|
||||
struct __funcParamSetup
|
||||
{
|
||||
public:
|
||||
__funcParamSetup();
|
||||
~__funcParamSetup();
|
||||
__funcParamSetup( const __funcParamSetup &o );
|
||||
|
||||
const bool operator==( const __funcParamSetup &o ) const
|
||||
{
|
||||
return //bOutput == o.bOutput &&
|
||||
iFlag == o.iFlag;
|
||||
};
|
||||
const bool operator!=( const __funcParamSetup &o ) const
|
||||
{ return !( (*this) == o ); };
|
||||
|
||||
int iFlag;
|
||||
char *pszName;
|
||||
bool bOutput;
|
||||
|
||||
const char *GetSafeName( int num );
|
||||
};
|
||||
|
||||
struct SimpleTexture
|
||||
{
|
||||
public:
|
||||
SimpleTexture();
|
||||
~SimpleTexture();
|
||||
SimpleTexture( const SimpleTexture &o );
|
||||
|
||||
// custom texture to load
|
||||
char *szTextureName;
|
||||
|
||||
// custom parameter - uniquify this
|
||||
char *szParamName;
|
||||
// use this texture when param undefined in vmt
|
||||
char *szFallbackName;
|
||||
// sampler index - defined on uniquify
|
||||
int iSamplerIndex;
|
||||
// texture mode, bind standard or from param?
|
||||
int iTextureMode;
|
||||
// do we need a cubemap lookup?
|
||||
bool bCubeTexture;
|
||||
bool bSRGB;
|
||||
|
||||
CUtlVector< HNODE* >m_hTargetNodes;
|
||||
};
|
||||
|
||||
struct SimpleCombo
|
||||
{
|
||||
public:
|
||||
SimpleCombo();
|
||||
~SimpleCombo();
|
||||
SimpleCombo( const SimpleCombo &o );
|
||||
|
||||
char *name;
|
||||
int iComboType;
|
||||
bool bStatic;
|
||||
int min;
|
||||
int max;
|
||||
|
||||
bool bInPreviewMode;
|
||||
|
||||
int GetAmt()
|
||||
{
|
||||
Assert( max >= min );
|
||||
return (max - min) + 1;
|
||||
};
|
||||
};
|
||||
|
||||
struct SimpleEnvConstant
|
||||
{
|
||||
public:
|
||||
SimpleEnvConstant();
|
||||
~SimpleEnvConstant();
|
||||
SimpleEnvConstant( const SimpleEnvConstant &o );
|
||||
|
||||
int iEnvC_ID;
|
||||
int iHLSLRegister;
|
||||
int iConstSize;
|
||||
|
||||
char *szSmartHelper;
|
||||
int iSmartNumComps;
|
||||
float flSmartDefaultValues[4];
|
||||
|
||||
// only valid in shader lib *AFTER* shader init
|
||||
int iFastLookup;
|
||||
};
|
||||
|
||||
// only valid for compilation, never saved to dumps!
|
||||
struct SimpleArray
|
||||
{
|
||||
public:
|
||||
SimpleArray();
|
||||
~SimpleArray();
|
||||
SimpleArray( const SimpleArray &o );
|
||||
|
||||
Vector4D *vecData;
|
||||
int iSize_X;
|
||||
int iSize_Y;
|
||||
|
||||
int iNumComps;
|
||||
|
||||
HNODE iIndex;
|
||||
};
|
||||
|
||||
// only valid for compilation, never saved to dumps!
|
||||
struct SimpleFunction
|
||||
{
|
||||
public:
|
||||
SimpleFunction();
|
||||
~SimpleFunction();
|
||||
SimpleFunction( const SimpleFunction &o );
|
||||
|
||||
bool IsInline();
|
||||
|
||||
char *szFuncName;
|
||||
char *szFilePath;
|
||||
|
||||
char *szCode_Global;
|
||||
char *szCode_Body;
|
||||
|
||||
CUtlVector< __funcParamSetup* >hParams;
|
||||
};
|
||||
|
||||
struct IdentifierLists_t
|
||||
{
|
||||
public:
|
||||
IdentifierLists_t();
|
||||
~IdentifierLists_t();
|
||||
IdentifierLists_t( const IdentifierLists_t &o );
|
||||
|
||||
CUtlVector< SimpleTexture* > hList_Textures;
|
||||
CUtlVector< SimpleCombo* > hList_Combos;
|
||||
CUtlVector< SimpleEnvConstant* > hList_EConstants;
|
||||
CUtlVector< SimpleArray* > hList_Arrays;
|
||||
CUtlVector< SimpleFunction* > hList_Functions;
|
||||
|
||||
int inum_DynamicCombos;
|
||||
};
|
||||
|
||||
struct BasicShaderCfg_t
|
||||
{
|
||||
BasicShaderCfg_t();
|
||||
BasicShaderCfg_t( const BasicShaderCfg_t &o );
|
||||
~BasicShaderCfg_t();
|
||||
|
||||
char *CanvasName; // only for preloaded shaders!
|
||||
char *Filename;
|
||||
|
||||
char *ProcVSName;
|
||||
char *ProcPSName;
|
||||
|
||||
char dumpversion[16];
|
||||
|
||||
int iShaderModel;
|
||||
int iCullmode;
|
||||
int iAlphablendmode;
|
||||
float flAlphaTestRef;
|
||||
int iDepthtestmode;
|
||||
int iDepthwritemode;
|
||||
bool bsRGBWrite;
|
||||
|
||||
int iVFMT_flags;
|
||||
int iVFMT_numTexcoords;
|
||||
int iVFMT_numUserData;
|
||||
int iVFMT_texDim[3];
|
||||
|
||||
bool bVertexLighting;
|
||||
bool bRefractionSupport;
|
||||
bool bPreviewMode;
|
||||
|
||||
//CUtlVector< SimpleCombo* > hList_Combos_VS;
|
||||
//CUtlVector< SimpleCombo* > hList_Combos_PS;
|
||||
|
||||
IdentifierLists_t *pVS_Identifiers;
|
||||
IdentifierLists_t *pPS_Identifiers;
|
||||
};
|
||||
|
||||
class IVPPEHelper;
|
||||
|
||||
class IVProcShader : public IBaseInterface
|
||||
{
|
||||
public:
|
||||
virtual bool Init( CreateInterfaceFn appSystemFactory, IVPPEHelper *pPPEHelper = NULL ) = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
virtual void *SwapShaderSystem( void *_data, const int &index ) = 0;
|
||||
virtual void UpdateEnvironmentData( int iEnvC, float *_fl4 ) = 0;
|
||||
|
||||
virtual void SetNormalizedPuzzleDelta( float d ) = 0;
|
||||
|
||||
virtual void AddPreloadShader( void *data ) = 0;
|
||||
virtual int GetNumPreloadShaders() = 0;
|
||||
virtual int FindPreloadShader( const char *name ) = 0;
|
||||
virtual void *GetPreloadShader( const int idx ) = 0;
|
||||
virtual void *GetAndRemovePreloadShader( const int idx ) = 0;
|
||||
virtual void *SwapPreloadShader( const int idx, void *_data ) = 0;
|
||||
|
||||
virtual void LinkCallbacks( CUtlVector< _clCallback* > *hList ) = 0;
|
||||
};
|
||||
|
||||
#define PPEINLINE_PARAM_KEY __PPE_INLINE
|
||||
|
||||
class IVPPEHelper : public IBaseInterface
|
||||
{
|
||||
public:
|
||||
|
||||
virtual KeyValues *GetInlineMaterial( const char *szmatName ) = 0;
|
||||
virtual void DestroyKeyValues( KeyValues *pKV ) = 0;
|
||||
};
|
||||
|
||||
#ifndef PROCSHADER_DLL
|
||||
extern IVProcShader *gProcShaderCTRL;
|
||||
|
||||
class CPPEHelper;
|
||||
extern CPPEHelper *gPPEHelper;
|
||||
#else
|
||||
class ProcShaderInterface;
|
||||
extern ProcShaderInterface *gProcShaderCTRL;
|
||||
|
||||
extern IVPPEHelper *gPPEHelper;
|
||||
#endif
|
||||
|
||||
#define PROCSHADER_INTERFACE_VERSION "ProceduralShaderImplementation_001"
|
||||
|
||||
#endif
|
||||
@@ -1,206 +0,0 @@
|
||||
|
||||
#include "stdshaders/shaderincludes.h"
|
||||
|
||||
#include "ProcShaderInterface.h"
|
||||
|
||||
#include "tier1.h"
|
||||
|
||||
#define VENGINE_CLIENT_RANDOM_INTERFACE_VERSION "VEngineRandom001"
|
||||
|
||||
static ProcShaderInterface __g_ProcShaderCTRL;
|
||||
ProcShaderInterface *gProcShaderCTRL = &__g_ProcShaderCTRL;
|
||||
|
||||
BasicShaderCfg_t *pShaderCFG[2] = { NULL, NULL };
|
||||
|
||||
#ifndef SHADER_EDITOR_DLL_SWARM
|
||||
IFileSystem *g_pFullFileSystem = NULL;
|
||||
#else
|
||||
extern IFileSystem *g_pFullFileSystem;
|
||||
#endif
|
||||
IUniformRandomStream *random = NULL;
|
||||
|
||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( ProcShaderInterface, IVProcShader, PROCSHADER_INTERFACE_VERSION, __g_ProcShaderCTRL );
|
||||
|
||||
ProcShaderInterface::ProcShaderInterface()
|
||||
{
|
||||
_pixeldelta = 0;
|
||||
hCallbackList = NULL;
|
||||
}
|
||||
ProcShaderInterface::~ProcShaderInterface()
|
||||
{
|
||||
Assert( !hPreloadList.Count() ); // must be destructed in editordll heap
|
||||
}
|
||||
|
||||
//extern CreateInterfaceFn baseFactory;
|
||||
|
||||
IVPPEHelper *gPPEHelper = NULL;
|
||||
|
||||
bool ProcShaderInterface::Init( CreateInterfaceFn appSystemFactory, IVPPEHelper *pPPEHelper )
|
||||
{
|
||||
gPPEHelper = pPPEHelper;
|
||||
|
||||
if ( (g_pFullFileSystem = (IFileSystem *)appSystemFactory(FILESYSTEM_INTERFACE_VERSION, NULL)) == NULL )
|
||||
return false;
|
||||
|
||||
if ( (random = (IUniformRandomStream *)appSystemFactory(VENGINE_CLIENT_RANDOM_INTERFACE_VERSION, NULL)) == NULL )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
void ProcShaderInterface::Shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
void ProcShaderInterface::LoadInterfacesOnDemand()
|
||||
{
|
||||
}
|
||||
|
||||
void *ProcShaderInterface::SwapShaderSystem( void *_data, const int &index )
|
||||
{
|
||||
Assert( index >= 0 && index < 2 );
|
||||
m_Lock.Lock();
|
||||
BasicShaderCfg_t *tmp = pShaderCFG[index];
|
||||
pShaderCFG[index] = (BasicShaderCfg_t*)_data;
|
||||
m_Lock.Unlock();
|
||||
return tmp;
|
||||
}
|
||||
|
||||
BasicShaderCfg_t *ProcShaderInterface::AccessVolatileData( const int index )
|
||||
{
|
||||
Assert( index >= 0 && index < 2 );
|
||||
m_Lock.Lock();
|
||||
m_Lock.Unlock();
|
||||
return pShaderCFG[index];
|
||||
}
|
||||
|
||||
void ProcShaderInterface::SetNormalizedPuzzleDelta( float d )
|
||||
{
|
||||
_pixeldelta = d;
|
||||
}
|
||||
|
||||
static float _envdataCollection[HLSLENV_MAX][4];
|
||||
void ProcShaderInterface::UpdateEnvironmentData( int iEnvC, float *_fl4 )
|
||||
{
|
||||
Q_memcpy( _envdataCollection[iEnvC], _fl4, sizeof(float) * 4 );
|
||||
}
|
||||
|
||||
float *ProcShaderInterface::AccessEnvConstant( int i )
|
||||
{
|
||||
return _envdataCollection[i];
|
||||
}
|
||||
|
||||
|
||||
void ProcShaderInterface::AddPreloadShader( void *data )
|
||||
{
|
||||
m_Lock.Lock();
|
||||
|
||||
BasicShaderCfg_t *pShader = (BasicShaderCfg_t*)data;
|
||||
hPreloadList.AddToTail( pShader );
|
||||
|
||||
m_Lock.Unlock();
|
||||
}
|
||||
int ProcShaderInterface::GetNumPreloadShaders()
|
||||
{
|
||||
m_Lock.Lock();
|
||||
|
||||
int num = hPreloadList.Count();
|
||||
|
||||
m_Lock.Unlock();
|
||||
return num;
|
||||
}
|
||||
int ProcShaderInterface::FindPreloadShader( const char *name )
|
||||
{
|
||||
m_Lock.Lock();
|
||||
int index = -1;
|
||||
for ( int i = 0; i < hPreloadList.Count(); i++ )
|
||||
{
|
||||
Assert( hPreloadList[i]->CanvasName );
|
||||
if ( !Q_stricmp( hPreloadList[i]->CanvasName, name ) )
|
||||
{
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
m_Lock.Unlock();
|
||||
return index;
|
||||
}
|
||||
void *ProcShaderInterface::GetPreloadShader( const int idx )
|
||||
{
|
||||
m_Lock.Lock();
|
||||
|
||||
Assert( hPreloadList.IsValidIndex( idx ) );
|
||||
BasicShaderCfg_t *pOut = hPreloadList[idx];
|
||||
|
||||
m_Lock.Unlock();
|
||||
return pOut;
|
||||
}
|
||||
void *ProcShaderInterface::SwapPreloadShader( const int idx, void *_data )
|
||||
{
|
||||
m_Lock.Lock();
|
||||
|
||||
Assert( hPreloadList.IsValidIndex( idx ) );
|
||||
BasicShaderCfg_t *pOut = hPreloadList[idx];
|
||||
hPreloadList[idx] = (BasicShaderCfg_t*)_data;
|
||||
|
||||
m_Lock.Unlock();
|
||||
return pOut;
|
||||
}
|
||||
void *ProcShaderInterface::GetAndRemovePreloadShader( const int idx )
|
||||
{
|
||||
m_Lock.Lock();
|
||||
|
||||
Assert( hPreloadList.IsValidIndex( idx ) );
|
||||
BasicShaderCfg_t *pOut = hPreloadList[idx];
|
||||
hPreloadList.Remove(idx);
|
||||
|
||||
m_Lock.Unlock();
|
||||
return pOut;
|
||||
}
|
||||
|
||||
BasicShaderCfg_t *ProcShaderInterface::GetPreloadShader_Internal( const int &idx )
|
||||
{
|
||||
Assert( hPreloadList.IsValidIndex( idx ) );
|
||||
return hPreloadList[ idx ];
|
||||
}
|
||||
BasicShaderCfg_t *ProcShaderInterface::GetPreloadShader_Internal( const char *name, int *index )
|
||||
{
|
||||
for ( int i = 0; i < hPreloadList.Count(); i++ )
|
||||
{
|
||||
Assert( hPreloadList[i]->CanvasName );
|
||||
if ( !Q_stricmp( hPreloadList[i]->CanvasName, name ) )
|
||||
{
|
||||
if ( index )
|
||||
*index = i;
|
||||
return hPreloadList[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ProcShaderInterface::LinkCallbacks( CUtlVector< _clCallback* > *hList )
|
||||
{
|
||||
hCallbackList = hList;
|
||||
}
|
||||
int ProcShaderInterface::GetNumCallbacks()
|
||||
{
|
||||
if ( !hCallbackList )
|
||||
return 0;
|
||||
return hCallbackList->Count();
|
||||
}
|
||||
_clCallback *ProcShaderInterface::GetCallback( int i )
|
||||
{
|
||||
Assert( hCallbackList );
|
||||
Assert( hCallbackList->IsValidIndex( i ) );
|
||||
return hCallbackList->Element( i );
|
||||
}
|
||||
int ProcShaderInterface::FindCallback( const char *name )
|
||||
{
|
||||
if ( !name || !Q_strlen( name ) )
|
||||
return -1;
|
||||
Assert( hCallbackList );
|
||||
for ( int i = 0; i < hCallbackList->Count(); i++ )
|
||||
{
|
||||
if ( !Q_stricmp( hCallbackList->Element( i )->name, name ) )
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
#ifndef PROCSHADER_INTERFACE_H
|
||||
#define PROCSHADER_INTERFACE_H
|
||||
|
||||
#include "IVProcShader.h"
|
||||
#include "filesystem.h"
|
||||
#include "vstdlib/random.h"
|
||||
#include "tier1/KeyValues.h"
|
||||
|
||||
#define STANDARDTEX_USER_FIRST_INDEX TEXTURE_BLACK //( TEXTURE_IDENTITY_LIGHTWARP + 1 )
|
||||
|
||||
class ProcShaderInterface : public IVProcShader
|
||||
{
|
||||
public:
|
||||
ProcShaderInterface();
|
||||
~ProcShaderInterface();
|
||||
|
||||
virtual bool Init( CreateInterfaceFn appSystemFactory, IVPPEHelper *pPPEHelper );
|
||||
virtual void Shutdown();
|
||||
|
||||
virtual void *SwapShaderSystem( void *_data, const int &index );
|
||||
virtual void SetNormalizedPuzzleDelta( float d );
|
||||
virtual void UpdateEnvironmentData( int iEnvC, float *_fl4 );
|
||||
|
||||
BasicShaderCfg_t *AccessVolatileData( const int index = 0 );
|
||||
float *AccessEnvConstant( int i );
|
||||
float &GetNormalizedPuzzleDelta(){return _pixeldelta;};
|
||||
|
||||
virtual void AddPreloadShader( void *data );
|
||||
virtual int GetNumPreloadShaders();
|
||||
|
||||
virtual int FindPreloadShader( const char *name );
|
||||
virtual void *GetPreloadShader( const int idx );
|
||||
virtual void *GetAndRemovePreloadShader( const int idx );
|
||||
virtual void *SwapPreloadShader( const int idx, void *_data );
|
||||
|
||||
virtual BasicShaderCfg_t *GetPreloadShader_Internal( const int &idx );
|
||||
virtual BasicShaderCfg_t *GetPreloadShader_Internal( const char *name, int *index = NULL );
|
||||
|
||||
virtual void LinkCallbacks( CUtlVector< _clCallback* > *hList );
|
||||
int GetNumCallbacks();
|
||||
_clCallback *GetCallback( int i );
|
||||
int FindCallback( const char *name );
|
||||
|
||||
void LoadInterfacesOnDemand();
|
||||
|
||||
private:
|
||||
CThreadMutex m_Lock;
|
||||
|
||||
float _pixeldelta;
|
||||
|
||||
CUtlVector< BasicShaderCfg_t* >hPreloadList;
|
||||
CUtlVector< _clCallback* >*hCallbackList;
|
||||
};
|
||||
|
||||
class CProceduralContext;
|
||||
|
||||
bool IsTextypeUsingCustomTexture( int textype );
|
||||
void BindTextureByAutoType( bool bPreview, IShaderDynamicAPI *pShaderAPI, CBaseVSShader *pShader,
|
||||
int type, int sampleridx, int TextureVar, int FrameVar = -1, bool bPS = true );
|
||||
void UpdateConstantByIdentifier( CBaseVSShader *pShader, IShaderDynamicAPI* pShaderAPI, IMaterialVar **params, SimpleEnvConstant *pConst, CProceduralContext *pContext,
|
||||
bool bPS, int iFirstMutable = -1, int iFirstStatic = -1 );
|
||||
|
||||
extern IUniformRandomStream *random;
|
||||
extern IFileSystem *g_pFullFileSystem;
|
||||
|
||||
#endif
|
||||
@@ -1,96 +0,0 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include <windows.h>
|
||||
#include "shader_dll_verify.h"
|
||||
|
||||
|
||||
static unsigned char *g_pLastInputData = 0;
|
||||
static HANDLE g_hDLLInst = 0;
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void __declspec( dllexport ) _ftol3( char *pData );
|
||||
BOOL WINAPI DllMain (HANDLE hInst, ULONG ulInit, LPVOID lpReserved);
|
||||
};
|
||||
|
||||
|
||||
BOOL WINAPI DllMain (HANDLE hInst, ULONG ulInit, LPVOID lpReserved)
|
||||
{
|
||||
lpReserved = lpReserved;
|
||||
ulInit = ulInit;
|
||||
|
||||
g_hDLLInst = hInst;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
class CShaderDLLVerification : public IShaderDLLVerification
|
||||
{
|
||||
public:
|
||||
|
||||
virtual CRC32_t Function1( unsigned char *pData );
|
||||
virtual void Function2( int a, int b, int c );
|
||||
virtual void Function3( int a, int b, int c );
|
||||
virtual void Function4( int a, int b, int c );
|
||||
virtual CRC32_t Function5();
|
||||
};
|
||||
|
||||
static CShaderDLLVerification g_Blah;
|
||||
|
||||
|
||||
|
||||
// The main exported function.. return a pointer to g_Blah.
|
||||
void __declspec( dllexport ) _ftol3( char *pData )
|
||||
{
|
||||
pData += SHADER_DLL_VERIFY_DATA_PTR_OFFSET;
|
||||
char *pToFillIn = (char*)&g_Blah;
|
||||
memcpy( pData, &pToFillIn, 4 );
|
||||
}
|
||||
|
||||
|
||||
CRC32_t CShaderDLLVerification::Function1( unsigned char *pData )
|
||||
{
|
||||
pData += SHADER_DLL_VERIFY_DATA_PTR_OFFSET;
|
||||
g_pLastInputData = (unsigned char*)pData;
|
||||
|
||||
void *pVerifyPtr1 = &g_Blah;
|
||||
|
||||
CRC32_t testCRC;
|
||||
CRC32_Init( &testCRC );
|
||||
CRC32_ProcessBuffer( &testCRC, pData, SHADER_DLL_VERIFY_DATA_LEN1 );
|
||||
CRC32_ProcessBuffer( &testCRC, &g_hDLLInst, 4 );
|
||||
CRC32_ProcessBuffer( &testCRC, &pVerifyPtr1, 4 );
|
||||
CRC32_Final( &testCRC );
|
||||
|
||||
return testCRC;
|
||||
}
|
||||
|
||||
void CShaderDLLVerification::Function2( int a, int b, int c )
|
||||
{
|
||||
a=b=c;
|
||||
MD5Context_t md5Context;
|
||||
MD5Init( &md5Context );
|
||||
MD5Update( &md5Context, g_pLastInputData + SHADER_DLL_VERIFY_DATA_PTR_OFFSET, SHADER_DLL_VERIFY_DATA_LEN1 - SHADER_DLL_VERIFY_DATA_PTR_OFFSET );
|
||||
MD5Final( g_pLastInputData, &md5Context );
|
||||
}
|
||||
|
||||
void CShaderDLLVerification::Function3( int a, int b, int c )
|
||||
{
|
||||
a=b=c;
|
||||
}
|
||||
|
||||
void CShaderDLLVerification::Function4( int a, int b, int c )
|
||||
{
|
||||
a=b=c;
|
||||
}
|
||||
|
||||
|
||||
CRC32_t CShaderDLLVerification::Function5()
|
||||
{
|
||||
return 32423;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose: This is temporary obfuscation code to verify that a base shader
|
||||
// DLL comes from us (because it includes some interfaces that we don't
|
||||
// give out with the SDK).
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef SHADER_DLL_VERIFY_H
|
||||
#define SHADER_DLL_VERIFY_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/checksum_crc.h"
|
||||
#include "tier1/checksum_md5.h"
|
||||
|
||||
|
||||
#define SHADER_DLL_VERIFY_DATA_LEN1 4101
|
||||
#define SHADER_DLL_VERIFY_DATA_PTR_OFFSET 43
|
||||
|
||||
#define SHADER_DLL_FNNAME_1 "_ftol3"
|
||||
typedef void (*ShaderDLLVerifyFn)( char *pData );
|
||||
|
||||
abstract_class IShaderDLLVerification
|
||||
{
|
||||
public:
|
||||
|
||||
virtual CRC32_t Function1( unsigned char *pData ) = 0;
|
||||
virtual void Function2( int a, int b, int c ) = 0;
|
||||
virtual void Function3( int a, int b, int c ) = 0;
|
||||
virtual void Function4( int a, int b, int c ) = 0;
|
||||
virtual CRC32_t Function5() = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // SHADER_DLL_VERIFY_H
|
||||
@@ -55,6 +55,9 @@ static ConVar mat_fullbright( "mat_fullbright","0", FCVAR_CHEAT );
|
||||
ConVar r_flashlightbrightness( "r_flashlightbrightness", "0.25", FCVAR_CHEAT );
|
||||
|
||||
#ifdef MAPBASE
|
||||
// This constant should change with each Mapbase update
|
||||
ConVar mapbase_version_shaders( "mapbase_version_shaders", "uhh, no", FCVAR_NONE, "The version of Mapbase currently being used in this mod's game_shader_dx9.dll");
|
||||
|
||||
ConVar mat_specular_disable_on_missing( "mat_specular_disable_on_missing", "1", FCVAR_ARCHIVE, "Disables specular reflections on a material when the envmap cannot be found." );
|
||||
#endif
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
222
sp/src/materialsystem/stdshaders/SDK_core_ps2x.fxc
Normal file
222
sp/src/materialsystem/stdshaders/SDK_core_ps2x.fxc
Normal file
@@ -0,0 +1,222 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
|
||||
// STATIC: "CUBEMAP" "0..1"
|
||||
// STATIC: "FLOWMAP" "0..1"
|
||||
// STATIC: "CORECOLORTEXTURE" "0..1"
|
||||
// STATIC: "REFRACT" "0..1"
|
||||
// DYNAMIC: "PIXELFOGTYPE" "0..1"
|
||||
|
||||
// SKIP: ( $REFRACT || $CORECOLORTEXTURE ) && $CUBEMAP
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler RefractSampler : register( s2 );
|
||||
sampler NormalSampler : register( s3 );
|
||||
#if CUBEMAP
|
||||
sampler EnvmapSampler : register( s4 );
|
||||
#endif
|
||||
#if FLOWMAP
|
||||
sampler FlowmapSampler : register( s6 );
|
||||
#endif
|
||||
|
||||
#if CORECOLORTEXTURE
|
||||
sampler CoreColorSampler : register( s7 );
|
||||
#endif
|
||||
|
||||
const HALF3 g_EnvmapTint : register( c0 );
|
||||
const HALF3 g_RefractTint : register( c1 );
|
||||
const HALF3 g_EnvmapContrast : register( c2 );
|
||||
const HALF3 g_EnvmapSaturation : register( c3 );
|
||||
const HALF2 g_RefractScale : register( c5 );
|
||||
#if FLOWMAP
|
||||
const float g_Time : register( c6 );
|
||||
const float2 g_FlowScrollRate : register( c7 );
|
||||
const float g_CoreColorTexCoordOffset : register( c9 );
|
||||
#endif
|
||||
|
||||
const float3 g_EyePos : register( c8 );
|
||||
const float4 g_FogParams : register( c11 );
|
||||
|
||||
|
||||
const float3 g_SphereCenter : register( c12 );
|
||||
const float3 g_SphereRadius : register( c15 );
|
||||
|
||||
float LengthThroughSphere( float3 vecRayOrigin, float3 vecRayDelta,
|
||||
float3 vecSphereCenter, float flRadius, out float alpha )
|
||||
{
|
||||
// Solve using the ray equation + the sphere equation
|
||||
// P = o + dt
|
||||
// (x - xc)^2 + (y - yc)^2 + (z - zc)^2 = r^2
|
||||
// (ox + dx * t - xc)^2 + (oy + dy * t - yc)^2 + (oz + dz * t - zc)^2 = r^2
|
||||
// (ox - xc)^2 + 2 * (ox-xc) * dx * t + dx^2 * t^2 +
|
||||
// (oy - yc)^2 + 2 * (oy-yc) * dy * t + dy^2 * t^2 +
|
||||
// (oz - zc)^2 + 2 * (oz-zc) * dz * t + dz^2 * t^2 = r^2
|
||||
// (dx^2 + dy^2 + dz^2) * t^2 + 2 * ((ox-xc)dx + (oy-yc)dy + (oz-zc)dz) t +
|
||||
// (ox-xc)^2 + (oy-yc)^2 + (oz-zc)^2 - r^2 = 0
|
||||
// or, t = (-b +/- sqrt( b^2 - 4ac)) / 2a
|
||||
// a = DotProduct( vecRayDelta, vecRayDelta );
|
||||
// b = 2 * DotProduct( vecRayOrigin - vecCenter, vecRayDelta )
|
||||
// c = DotProduct(vecRayOrigin - vecCenter, vecRayOrigin - vecCenter) - flRadius * flRadius;
|
||||
|
||||
float3 vecSphereToRay;
|
||||
vecSphereToRay = vecRayOrigin - vecSphereCenter;
|
||||
|
||||
float a = dot( vecRayDelta, vecRayDelta );
|
||||
|
||||
// This would occur in the case of a zero-length ray
|
||||
// if ( a == 0.0f )
|
||||
// {
|
||||
// *pT1 = *pT2 = 0.0f;
|
||||
// return vecSphereToRay.LengthSqr() <= flRadius * flRadius;
|
||||
// }
|
||||
|
||||
float b = 2 * dot( vecSphereToRay, vecRayDelta );
|
||||
float c = dot( vecSphereToRay, vecSphereToRay ) - flRadius * flRadius;
|
||||
float flDiscrim = b * b - 4 * a * c;
|
||||
// if ( flDiscrim < 0.0f )
|
||||
// return 0.0f;
|
||||
|
||||
float hack = flDiscrim;
|
||||
flDiscrim = sqrt( flDiscrim );
|
||||
float oo2a = 0.5f / a;
|
||||
|
||||
|
||||
//if( hack < 0.0f )
|
||||
//{
|
||||
// alpha = 0.0f;
|
||||
// return 0.0f;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// alpha = 1.0f;
|
||||
// return abs( flDiscrim ) * 2 * oo2a;
|
||||
//}
|
||||
|
||||
//replacing the if's above because if's in hlsl are bad.....
|
||||
float fHackGreaterThanZero = step( 0.0f, hack );
|
||||
alpha = fHackGreaterThanZero;
|
||||
return (fHackGreaterThanZero * (abs( flDiscrim ) * 2 * oo2a));
|
||||
|
||||
|
||||
// *pT1 = ( - b - flDiscrim ) * oo2a;
|
||||
// *pT2 = ( - b + flDiscrim ) * oo2a;
|
||||
// return true;
|
||||
}
|
||||
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vBumpTexCoord : TEXCOORD0; // dudvMapAndNormalMapTexCoord
|
||||
HALF3 vWorldVertToEyeVector : TEXCOORD1;
|
||||
HALF3x3 tangentSpaceTranspose : TEXCOORD2;
|
||||
float3 vRefractXYW : TEXCOORD5;
|
||||
float3 projNormal : TEXCOORD6;
|
||||
float4 worldPos_projPosZ : TEXCOORD7;
|
||||
};
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
HALF3 result = 0.0f;
|
||||
|
||||
HALF blend = 1.0f;
|
||||
|
||||
#if FLOWMAP
|
||||
// Mapbase tries to un-hack some of this code
|
||||
//float3 g_SphereCenter = { 2688.0f, 12139.0f, 5170.0f };
|
||||
//float g_SphereDiameter = 430.0f;
|
||||
//float g_SphereRadius = g_SphereDiameter * 0.5f;
|
||||
|
||||
float g_SphereDiameter = g_SphereRadius * 2.0f;
|
||||
|
||||
float3 tmp = i.worldPos_projPosZ.xyz - g_SphereCenter;
|
||||
float hackRadius = 1.05f * sqrt( dot( tmp, tmp ) );
|
||||
|
||||
float sphereAlpha;
|
||||
float lengthThroughSphere = LengthThroughSphere( g_EyePos, normalize( i.worldPos_projPosZ.xyz - g_EyePos ),
|
||||
g_SphereCenter, /*g_SphereRadius*/ hackRadius, sphereAlpha );
|
||||
|
||||
float normalizedLengthThroughSphere = lengthThroughSphere / g_SphereDiameter;
|
||||
|
||||
|
||||
float3 hackWorldSpaceNormal = normalize( i.worldPos_projPosZ.xyz - g_SphereCenter );
|
||||
float3 realFuckingNormal = abs( hackWorldSpaceNormal );
|
||||
hackWorldSpaceNormal = 0.5f * ( hackWorldSpaceNormal + 1.0f );
|
||||
|
||||
// hackWorldSpaceNormal = abs( hackWorldSpaceNormal );
|
||||
|
||||
// return float4( hackWorldSpaceNormal.x, 0.0f, 0.0f, 1.0f );
|
||||
|
||||
i.vBumpTexCoord.xy = 0.0f;
|
||||
i.vBumpTexCoord.xy = realFuckingNormal.z * tex2D( FlowmapSampler, hackWorldSpaceNormal.xy );
|
||||
i.vBumpTexCoord.xy += realFuckingNormal.y * tex2D( FlowmapSampler, hackWorldSpaceNormal.xz );
|
||||
i.vBumpTexCoord.xy += realFuckingNormal.x * tex2D( FlowmapSampler, hackWorldSpaceNormal.yz );
|
||||
i.vBumpTexCoord.xy += g_Time * g_FlowScrollRate;
|
||||
// return float4( i.vBumpTexCoord.xy, 0.0f, 0.0f );
|
||||
#endif
|
||||
|
||||
// Load normal and expand range
|
||||
HALF4 vNormalSample = tex2D( NormalSampler, i.vBumpTexCoord );
|
||||
// return vNormalSample;
|
||||
HALF3 tangentSpaceNormal = vNormalSample * 2.0 - 1.0;
|
||||
|
||||
HALF3 refractTintColor = g_RefractTint;
|
||||
|
||||
// Perform division by W only once
|
||||
float ooW = 1.0f / i.vRefractXYW.z;
|
||||
|
||||
// Compute coordinates for sampling refraction
|
||||
float2 vRefractTexCoordNoWarp = i.vRefractXYW.xy * ooW;
|
||||
float2 vRefractTexCoord = tangentSpaceNormal.xy;
|
||||
HALF scale = vNormalSample.a * g_RefractScale.x;
|
||||
#if FLOWMAP
|
||||
scale *= normalizedLengthThroughSphere;
|
||||
#endif
|
||||
vRefractTexCoord *= scale;
|
||||
#if FLOWMAP
|
||||
float2 hackOffset = vRefractTexCoord;
|
||||
#endif
|
||||
vRefractTexCoord += vRefractTexCoordNoWarp;
|
||||
|
||||
float3 colorWarp = tex2D( RefractSampler, vRefractTexCoord.xy );
|
||||
float3 colorNoWarp = tex2D( RefractSampler, vRefractTexCoordNoWarp.xy );
|
||||
|
||||
colorWarp *= refractTintColor;
|
||||
#if REFRACT
|
||||
result = lerp( colorNoWarp, colorWarp, blend );
|
||||
// return float4( 1.0f, 0.0f, 0.0f, 1.0f );
|
||||
#endif
|
||||
|
||||
#if CUBEMAP
|
||||
HALF specularFactor = vNormalSample.a;
|
||||
|
||||
HALF3 worldSpaceNormal = mul( i.tangentSpaceTranspose, tangentSpaceNormal );
|
||||
|
||||
HALF3 reflectVect = CalcReflectionVectorUnnormalized( worldSpaceNormal, i.vWorldVertToEyeVector );
|
||||
HALF3 specularLighting = texCUBE( EnvmapSampler, reflectVect );
|
||||
specularLighting *= specularFactor;
|
||||
specularLighting *= g_EnvmapTint;
|
||||
HALF3 specularLightingSquared = specularLighting * specularLighting;
|
||||
specularLighting = lerp( specularLighting, specularLightingSquared, g_EnvmapContrast );
|
||||
HALF3 greyScale = dot( specularLighting, HALF3( 0.299f, 0.587f, 0.114f ) );
|
||||
specularLighting = lerp( greyScale, specularLighting, g_EnvmapSaturation );
|
||||
result += specularLighting;
|
||||
#endif
|
||||
|
||||
#if CORECOLORTEXTURE && FLOWMAP
|
||||
float4 coreColorTexel = tex2D( CoreColorSampler, hackOffset + float2( normalizedLengthThroughSphere, g_CoreColorTexCoordOffset ) );
|
||||
HALF4 rgba = HALF4( lerp( result, coreColorTexel, coreColorTexel.a /*normalizedLengthThroughSphere*/ ), sphereAlpha );
|
||||
#else
|
||||
HALF4 rgba = HALF4( result, vNormalSample.a );
|
||||
#endif
|
||||
|
||||
|
||||
float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams, g_EyePos.z, i.worldPos_projPosZ.z, i.worldPos_projPosZ.w );
|
||||
return FinalOutput( rgba, fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
|
||||
103
sp/src/materialsystem/stdshaders/SDK_core_vs20.fxc
Normal file
103
sp/src/materialsystem/stdshaders/SDK_core_vs20.fxc
Normal file
@@ -0,0 +1,103 @@
|
||||
// STATIC: "MODEL" "0..1"
|
||||
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
static const bool g_bSkinning = SKINNING ? true : false;
|
||||
static const bool g_bModel = MODEL ? true : false;
|
||||
|
||||
const float4 cBumpTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_1 );
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION;
|
||||
float4 vBoneWeights : BLENDWEIGHT;
|
||||
float4 vBoneIndices : BLENDINDICES;
|
||||
float4 vNormal : NORMAL;
|
||||
float4 vBaseTexCoord : TEXCOORD0;
|
||||
#if !MODEL
|
||||
float3 vTangentS : TANGENT;
|
||||
float3 vTangentT : BINORMAL0;
|
||||
#else
|
||||
float4 vUserData : TANGENT;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos_POSITION : POSITION;
|
||||
float vFog : FOG;
|
||||
float2 vBumpTexCoord : TEXCOORD0;
|
||||
float3 vTangentEyeVect : TEXCOORD1;
|
||||
float3x3 tangentSpaceTranspose : TEXCOORD2;
|
||||
float3 vRefractXYW : TEXCOORD5;
|
||||
float4 projNormal_screenCoordW : TEXCOORD6;
|
||||
float4 worldPos_projPosZ : TEXCOORD7;
|
||||
float4 fogFactorW : COLOR1;
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
float3 worldNormal, worldPos, worldTangentS, worldTangentT;
|
||||
|
||||
float3 vObjNormal;
|
||||
#if MODEL
|
||||
float4 vObjTangent;
|
||||
DecompressVertex_NormalTangent( v.vNormal, v.vUserData, vObjNormal, vObjTangent );
|
||||
|
||||
SkinPositionNormalAndTangentSpace(
|
||||
g_bSkinning,
|
||||
v.vPos, vObjNormal, vObjTangent,
|
||||
v.vBoneWeights, v.vBoneIndices,
|
||||
worldPos, worldNormal, worldTangentS, worldTangentT );
|
||||
#else
|
||||
DecompressVertex_Normal( v.vNormal, vObjNormal );
|
||||
|
||||
worldPos = mul( v.vPos, cModel[0] );
|
||||
worldTangentS = mul( v.vTangentS, ( const float3x3 )cModel[0] );
|
||||
worldTangentT = mul( v.vTangentT, ( const float3x3 )cModel[0] );
|
||||
worldNormal = mul( vObjNormal, ( float3x3 )cModel[0] );
|
||||
#endif
|
||||
|
||||
|
||||
// Projected position
|
||||
float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
o.vProjPos_POSITION = vProjPos;
|
||||
o.projNormal_screenCoordW.xyz = mul( worldNormal, cViewProj );
|
||||
|
||||
o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z );
|
||||
|
||||
// Map projected position to the refraction texture
|
||||
float2 vRefractPos;
|
||||
vRefractPos.x = vProjPos.x;
|
||||
vRefractPos.y = -vProjPos.y; // invert Y
|
||||
vRefractPos = (vRefractPos + vProjPos.w) * 0.5f;
|
||||
|
||||
// Refraction transform
|
||||
o.vRefractXYW = float3(vRefractPos.x, vRefractPos.y, vProjPos.w);
|
||||
|
||||
// Compute fog based on the position
|
||||
float3 vWorldPos = mul( v.vPos, cModel[0] );
|
||||
o.fogFactorW = o.vFog = CalcFog( vWorldPos, vProjPos, FOGTYPE_RANGE );
|
||||
|
||||
// Eye vector
|
||||
float3 vWorldEyeVect = cEyePos - vWorldPos;
|
||||
// Transform to the tangent space
|
||||
o.vTangentEyeVect.x = dot( vWorldEyeVect, worldTangentS );
|
||||
o.vTangentEyeVect.y = dot( vWorldEyeVect, worldTangentT );
|
||||
o.vTangentEyeVect.z = dot( vWorldEyeVect, worldNormal );
|
||||
|
||||
// Tranform bump coordinates
|
||||
o.vBumpTexCoord.x = dot( v.vBaseTexCoord, cBumpTexCoordTransform[0] );
|
||||
o.vBumpTexCoord.y = dot( v.vBaseTexCoord, cBumpTexCoordTransform[1] );
|
||||
|
||||
o.tangentSpaceTranspose[0] = worldTangentS;
|
||||
o.tangentSpaceTranspose[1] = worldTangentT;
|
||||
o.tangentSpaceTranspose[2] = worldNormal;
|
||||
|
||||
return o;
|
||||
}
|
||||
@@ -37,6 +37,9 @@
|
||||
|
||||
// SKIP: $SEAMLESS && $RELIEF_MAPPING [ps20b]
|
||||
|
||||
// DYNAMIC: "CASCADED_SHADOW" "0..1" [ps30]
|
||||
// SKIP: $CASCADED_SHADOW && $FLASHLIGHT
|
||||
|
||||
// SKIP: (! $DETAILTEXTURE) && ( $DETAIL_BLEND_MODE != 0 )
|
||||
|
||||
// SKIP: ($DETAIL_BLEND_MODE == 2 ) || ($DETAIL_BLEND_MODE == 3 ) || ($DETAIL_BLEND_MODE == 4 )
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
// STATIC: "SEAMLESS" "0..1"
|
||||
// STATIC: "BUMPMASK" "0..1"
|
||||
// STATIC: "FLASHLIGHT" "0..1" [XBOX]
|
||||
|
||||
|
||||
// DYNAMIC: "CASCADED_SHADOW" "0..1" [vs30]
|
||||
// SKIP: $CASCADED_SHADOW && $FLASHLIGHT
|
||||
|
||||
|
||||
// STATIC: "BASETEXTURETRANSFORM2" "0..1"
|
||||
|
||||
// DYNAMIC: "FASTPATH" "0..1"
|
||||
@@ -23,6 +29,9 @@
|
||||
// SKIP: $BUMPMASK && $RELIEF_MAPPING
|
||||
// SKIP: $BUMPMASK && $SEAMLESS
|
||||
|
||||
// SKIP: $CASCADED_SHADOW && $LIGHTING_PREVIEW
|
||||
// SKIP: !$TANGENTSPACE
|
||||
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
static const int g_FogType = DOWATERFOG;
|
||||
@@ -89,16 +98,25 @@ struct VS_OUTPUT
|
||||
float4 lightmapTexCoord3 : TEXCOORD3; // and basetexcoord*mask_scale
|
||||
float4 worldPos_projPosZ : TEXCOORD4;
|
||||
|
||||
#if TANGENTSPACE || (LIGHTING_PREVIEW) || defined( _X360 )
|
||||
float3x3 tangentSpaceTranspose : TEXCOORD5; // and 6 and 7
|
||||
#if CASCADED_SHADOW
|
||||
float4 tangentSpaceTranspose_Row0 : TEXCOORD5;
|
||||
float4 tangentSpaceTranspose_Row1 : TEXCOORD6;
|
||||
float4 tangentSpaceTranspose_Row2 : TEXCOORD7;
|
||||
#endif
|
||||
|
||||
#if TANGENTSPACE || (LIGHTING_PREVIEW) || defined( _X360 )
|
||||
|
||||
|
||||
float4 vertexColor : COLOR; // in seamless, r g b = blend weights
|
||||
float4 vertexBlendX_fogFactorW : COLOR1;
|
||||
|
||||
// Extra iterators on 360, used in flashlight combo
|
||||
#if defined( _X360 ) && FLASHLIGHT
|
||||
#if FLASHLIGHT || CASCADED_SHADOW
|
||||
float4 flashlightSpacePos : TEXCOORD8;
|
||||
#endif
|
||||
|
||||
#if defined( _X360 ) && FLASHLIGHT || CASCADED_SHADOW
|
||||
//float4 flashlightSpacePos : TEXCOORD8;
|
||||
float4 vProjPos : TEXCOORD9;
|
||||
#endif
|
||||
|
||||
@@ -128,14 +146,30 @@ VS_OUTPUT main( const VS_INPUT v )
|
||||
#if SEAMLESS && BUMPMAP && defined( _X360 )
|
||||
float3 n = normalize( worldNormal );
|
||||
float3 n2 = n * n; // sums to 1.
|
||||
|
||||
o.tangentSpaceTranspose[0] = normalize( float3( n2.y + n2.z, 0.0f, n2.x ) );
|
||||
o.tangentSpaceTranspose[1] = normalize( float3( 0.0f, n2.x + n2.z, n2.y ) );
|
||||
o.tangentSpaceTranspose[2] = worldNormal;
|
||||
#if CASCADED_SHADOW
|
||||
o.tangentSpaceTranspose_Row0.xyz = normalize( float3( n2.y + n2.z, 0.0f, n2.x ) );
|
||||
o.tangentSpaceTranspose_Row1.xyz = normalize( float3( 0.0f, n2.x + n2.z, n2.y ) );
|
||||
o.tangentSpaceTranspose_Row2.xyz = worldNormal;
|
||||
#else
|
||||
o.tangentSpaceTranspose[0] = normalize( float3( n2.y + n2.z, 0.0f, n2.x ) );
|
||||
o.tangentSpaceTranspose[1] = normalize( float3( 0.0f, n2.x + n2.z, n2.y ) );
|
||||
o.tangentSpaceTranspose[2] = worldNormal;
|
||||
#endif
|
||||
#else
|
||||
o.tangentSpaceTranspose[0] = worldTangentS;
|
||||
o.tangentSpaceTranspose[1] = worldTangentT;
|
||||
o.tangentSpaceTranspose[2] = worldNormal;
|
||||
#if CASCADED_SHADOW
|
||||
o.tangentSpaceTranspose_Row0.xyz = worldTangentS;
|
||||
o.tangentSpaceTranspose_Row1.xyz = worldTangentT;
|
||||
o.tangentSpaceTranspose_Row2.xyz = worldNormal;
|
||||
#else
|
||||
o.tangentSpaceTranspose[0] = worldTangentS;
|
||||
o.tangentSpaceTranspose[1] = worldTangentT;
|
||||
o.tangentSpaceTranspose[2] = worldNormal;
|
||||
#endif
|
||||
#endif
|
||||
#if CASCADED_SHADOW
|
||||
o.tangentSpaceTranspose_Row0.w = o.projPos.x;
|
||||
o.tangentSpaceTranspose_Row1.w = o.projPos.y;
|
||||
o.tangentSpaceTranspose_Row2.w = o.projPos.w;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -254,6 +288,11 @@ VS_OUTPUT main( const VS_INPUT v )
|
||||
#endif
|
||||
|
||||
// On 360, we have extra iterators and can fold the flashlight into this shader
|
||||
|
||||
#if FLASHLIGHT || CASCADED_SHADOW
|
||||
o.flashlightSpacePos = mul( float4( worldPos, 1.0f ), g_FlashlightWorldToTexture );
|
||||
#endif
|
||||
|
||||
#if defined( _X360 ) && FLASHLIGHT
|
||||
o.flashlightSpacePos = mul( float4( worldPos, 1.0f ), g_FlashlightWorldToTexture );
|
||||
o.vProjPos = vProjPos;
|
||||
|
||||
@@ -55,7 +55,7 @@ struct VS_INPUT
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
#if !defined( _X360 )
|
||||
#if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) && !INTRO
|
||||
float fog : FOG;
|
||||
#endif
|
||||
float2 baseTexCoord : TEXCOORD0;
|
||||
@@ -105,10 +105,9 @@ VS_OUTPUT main( const VS_INPUT v )
|
||||
o.projPos = vProjPos;
|
||||
vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ );
|
||||
|
||||
o.worldPos_projPosZ = float4( worldPos, vProjPos.z );
|
||||
#if !defined( _X360 )
|
||||
// Set fixed-function fog factor
|
||||
o.fog = CalcFog( worldPos, vProjPos, g_FogType );
|
||||
o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z );
|
||||
#if !defined( _X360 )&& !defined( SHADER_MODEL_VS_3_0 ) && !INTRO
|
||||
o.fog = CalcFixedFunctionFog( worldPos, g_FogType );
|
||||
#endif
|
||||
// Needed for specular
|
||||
o.worldVertToEyeVector_Darkening.xyz = cEyePos - worldPos;
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX]
|
||||
// STATIC: "DEPTHBLEND" "0..1" [ps20b] [ps30]
|
||||
// STATIC: "BLENDTINTBYBASEALPHA" "0..1"
|
||||
// STATIC: "ENVMAPFRESNEL" "0..1" [ps30]
|
||||
// STATIC: "SRGB_INPUT_ADAPTER" "0..1" [ps20b]
|
||||
// STATIC: "CUBEMAP_SPHERE_LEGACY" "0..1"
|
||||
|
||||
// DYNAMIC: "PIXELFOGTYPE" "0..1" [ps20]
|
||||
// DYNAMIC: "LIGHTING_PREVIEW" "0..2" [PC]
|
||||
@@ -51,6 +51,10 @@
|
||||
// SKIP: ($DISTANCEALPHA == 0) && ($DISTANCEALPHAFROMDETAIL || $SOFT_MASK || $OUTLINE || $OUTER_GLOW)
|
||||
// SKIP: ($DETAILTEXTURE == 0) && ($DISTANCEALPHAFROMDETAIL)
|
||||
|
||||
// envmap stuff is meaningless if we're not using a cubemap
|
||||
// SKIP: ( $CUBEMAP == 0 ) && ( ( $ENVMAPFRESNEL == 1 ) || ( $BASEALPHAENVMAPMASK == 1 ) )
|
||||
// SKIP: ( $CUBEMAP == 0 ) && ( $ENVMAPMASK == 1 ) && ( $SELFILLUM_ENVMAPMASK_ALPHA == 0 )
|
||||
|
||||
// We don't care about flashlight depth unless the flashlight is on
|
||||
// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps20b]
|
||||
// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps30]
|
||||
@@ -60,7 +64,7 @@
|
||||
// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps30]
|
||||
|
||||
// DISTANCEALPHA-related skips
|
||||
// SKIP: ($DISTANCEALPHA) && ($ENVMAPMASK || $BASEALPHAENVMAPMASK || $SELFILLUM || $SELFILLUM_ENVMAPMASK_ALPHA )
|
||||
// SKIP: ($DISTANCEALPHA) && ($ENVMAPMASK || $BASEALPHAENVMAPMASK || $SELFILLUM || $SELFILLUM_ENVMAPMASK_ALPHA || $ENVMAPFRESNEL)
|
||||
// SKIP: ($DISTANCEALPHA) && ($SEAMLESS_BASE || $SEAMLESS_DETAIL || $CUBEMAP || $LIGHTING_PREVIEW )
|
||||
// SKIP: ($DISTANCEALPHA) && ($WRITEWATERFOGTODESTALPHA || $PIXELFOGTYPE || $FLASHLIGHT || $FLASHLIGHTSHADOWS || $SRGB_INPUT_ADAPTER )
|
||||
|
||||
@@ -87,6 +91,12 @@ const float4 g_SelfIllumTint_and_BlendFactor : register( c4 );
|
||||
const float4 g_ShaderControls : register( c12 );
|
||||
const float4 g_DepthFeatheringConstants : register( c13 );
|
||||
|
||||
const float4 g_FresnelConstants : register( c14 );
|
||||
#define g_flFresnelBias g_FresnelConstants.x
|
||||
#define g_flFresnelScale g_FresnelConstants.y
|
||||
#define g_flFresnelExp g_FresnelConstants.z
|
||||
#define g_flBaseAlphaEnvMapMaskExp g_FresnelConstants.w
|
||||
|
||||
const float4 g_EyePos_MinLight : register( c20 );
|
||||
#define g_EyePos g_EyePos_MinLight.xyz
|
||||
#define g_fMinLighting g_EyePos_MinLight.w
|
||||
@@ -159,6 +169,8 @@ const float4 g_GlowColor : register( c6 );
|
||||
const float4 g_DistanceAlphaParams : register( c7 );
|
||||
#define SOFT_MASK_MAX g_DistanceAlphaParams.x
|
||||
#define SOFT_MASK_MIN g_DistanceAlphaParams.y
|
||||
#define g_flBaseAlphaEnvMapMaskBias g_DistanceAlphaParams.z
|
||||
#define g_flBaseAlphaEnvMapMaskScale g_DistanceAlphaParams.w
|
||||
|
||||
const float4 g_OutlineColor : register( c8 );
|
||||
#define OUTLINE_COLOR g_OutlineColor
|
||||
@@ -337,11 +349,19 @@ float4 main( PS_INPUT i ) : COLOR
|
||||
specularFactor *= envmapMaskTexel.xyz;
|
||||
}
|
||||
|
||||
if( bBaseAlphaEnvmapMask )
|
||||
if ( bBaseAlphaEnvmapMask )
|
||||
{
|
||||
specularFactor *= 1.0 - baseColor.a; // this blows!
|
||||
specularFactor *= saturate( g_flBaseAlphaEnvMapMaskScale * pow( baseColor.a, g_flBaseAlphaEnvMapMaskExp ) + g_flBaseAlphaEnvMapMaskBias );
|
||||
}
|
||||
|
||||
#if ( ENVMAPFRESNEL )
|
||||
{
|
||||
float flFresnel = 1-saturate( dot( normalize( i.worldSpaceNormal.xyz ), normalize( i.worldVertToEyeVector.xyz ) ) );
|
||||
flFresnel = g_flFresnelScale * pow( flFresnel, g_flFresnelExp ) + g_flFresnelBias;
|
||||
specularFactor *= flFresnel;
|
||||
}
|
||||
#endif
|
||||
|
||||
float3 diffuseLighting = float3( 1.0f, 1.0f, 1.0f );
|
||||
if( bDiffuseLighting || bVertexColor && !( bVertexColor && bDiffuseLighting ) )
|
||||
{
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
// STATIC: "FLASHLIGHTDEPTHFILTERMODE" "0..0" [ps20b] [XBOX]
|
||||
// STATIC: "DEPTHBLEND" "0..1" [ps20b] [ps30]
|
||||
// STATIC: "BLENDTINTBYBASEALPHA" "0..1"
|
||||
// STATIC: "ENVMAPFRESNEL" "0..1" [ps30]
|
||||
// STATIC: "SRGB_INPUT_ADAPTER" "0..1" [ps20b]
|
||||
// STATIC: "CUBEMAP_SPHERE_LEGACY" "0..1"
|
||||
|
||||
// DYNAMIC: "PIXELFOGTYPE" "0..1" [ps20]
|
||||
// DYNAMIC: "LIGHTING_PREVIEW" "0..2" [PC]
|
||||
@@ -47,6 +47,10 @@
|
||||
// SKIP: ($DISTANCEALPHA == 0) && ($DISTANCEALPHAFROMDETAIL || $SOFT_MASK || $OUTLINE || $OUTER_GLOW)
|
||||
// SKIP: ($DETAILTEXTURE == 0) && ($DISTANCEALPHAFROMDETAIL)
|
||||
|
||||
// envmap stuff is meaningless if we're not using a cubemap
|
||||
// SKIP: ( $CUBEMAP == 0 ) && ( ( $ENVMAPFRESNEL == 1 ) || ( $BASEALPHAENVMAPMASK == 1 ) )
|
||||
// SKIP: ( $CUBEMAP == 0 ) && ( $ENVMAPMASK == 1 ) && ( $SELFILLUM_ENVMAPMASK_ALPHA == 0 )
|
||||
|
||||
// We don't care about flashlight depth unless the flashlight is on
|
||||
// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps20b]
|
||||
// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTSHADOWS == 1 ) [ps30]
|
||||
@@ -56,7 +60,7 @@
|
||||
// SKIP: ( $FLASHLIGHT == 0 ) && ( $FLASHLIGHTDEPTHFILTERMODE != 0 ) [ps30]
|
||||
|
||||
// DISTANCEALPHA-related skips
|
||||
// SKIP: ($DISTANCEALPHA) && ($ENVMAPMASK || $BASEALPHAENVMAPMASK || $SELFILLUM || $SELFILLUM_ENVMAPMASK_ALPHA )
|
||||
// SKIP: ($DISTANCEALPHA) && ($ENVMAPMASK || $BASEALPHAENVMAPMASK || $SELFILLUM || $SELFILLUM_ENVMAPMASK_ALPHA || $ENVMAPFRESNEL)
|
||||
// SKIP: ($DISTANCEALPHA) && ($SEAMLESS_BASE || $SEAMLESS_DETAIL || $CUBEMAP || $LIGHTING_PREVIEW )
|
||||
// SKIP: ($DISTANCEALPHA) && ($WRITEWATERFOGTODESTALPHA || $PIXELFOGTYPE || $FLASHLIGHT || $FLASHLIGHTSHADOWS || $SRGB_INPUT_ADAPTER )
|
||||
|
||||
@@ -83,6 +87,12 @@ const float4 g_SelfIllumTint_and_BlendFactor : register( c4 );
|
||||
const float4 g_ShaderControls : register( c12 );
|
||||
const float4 g_DepthFeatheringConstants : register( c13 );
|
||||
|
||||
const float4 g_FresnelConstants : register( c14 );
|
||||
#define g_flFresnelBias g_FresnelConstants.x
|
||||
#define g_flFresnelScale g_FresnelConstants.y
|
||||
#define g_flFresnelExp g_FresnelConstants.z
|
||||
#define g_flBaseAlphaEnvMapMaskExp g_FresnelConstants.w
|
||||
|
||||
const float4 g_EyePos : register( c20 );
|
||||
const float4 g_FogParams : register( c21 );
|
||||
|
||||
@@ -152,6 +162,8 @@ const float4 g_GlowColor : register( c6 );
|
||||
const float4 g_DistanceAlphaParams : register( c7 );
|
||||
#define SOFT_MASK_MAX g_DistanceAlphaParams.x
|
||||
#define SOFT_MASK_MIN g_DistanceAlphaParams.y
|
||||
#define g_flBaseAlphaEnvMapMaskBias g_DistanceAlphaParams.z
|
||||
#define g_flBaseAlphaEnvMapMaskScale g_DistanceAlphaParams.w
|
||||
|
||||
const float4 g_OutlineColor : register( c8 );
|
||||
#define OUTLINE_COLOR g_OutlineColor
|
||||
@@ -323,17 +335,26 @@ float4 main( PS_INPUT i ) : COLOR
|
||||
|
||||
float3 specularFactor = 1.0f;
|
||||
float4 envmapMaskTexel;
|
||||
if( bEnvmapMask )
|
||||
#if ( ENVMAPMASK )
|
||||
{
|
||||
envmapMaskTexel = tex2D( EnvmapMaskSampler, i.baseTexCoord.xy );
|
||||
specularFactor *= envmapMaskTexel.xyz;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( bBaseAlphaEnvmapMask )
|
||||
if ( bBaseAlphaEnvmapMask )
|
||||
{
|
||||
specularFactor *= 1.0 - baseColor.a; // this blows!
|
||||
specularFactor *= saturate( g_flBaseAlphaEnvMapMaskScale * pow( baseColor.a, g_flBaseAlphaEnvMapMaskExp ) + g_flBaseAlphaEnvMapMaskBias );
|
||||
}
|
||||
|
||||
#if ( ENVMAPFRESNEL )
|
||||
{
|
||||
float flFresnel = 1-saturate( dot( normalize( i.worldSpaceNormal.xyz ), normalize( i.worldVertToEyeVector.xyz ) ) );
|
||||
flFresnel = g_flFresnelScale * pow( flFresnel, g_flFresnelExp ) + g_flFresnelBias;
|
||||
specularFactor *= flFresnel;
|
||||
}
|
||||
#endif
|
||||
|
||||
float3 diffuseLighting = float3( 1.0f, 1.0f, 1.0f );
|
||||
if( bDiffuseLighting || bVertexColor && !( bVertexColor && bDiffuseLighting ) )
|
||||
{
|
||||
|
||||
@@ -24,11 +24,11 @@ struct PS_INPUT
|
||||
float3 eyeToVertVector : TEXCOORD0;
|
||||
float4 vertexColor : COLOR;
|
||||
|
||||
#if PARALLAXCORRECT
|
||||
float3 worldSpaceNormal : TEXCOORD1;
|
||||
#endif
|
||||
float4 worldPos_projPosZ : TEXCOORD1; // Necessary for pixel fog
|
||||
|
||||
float4 worldPos_projPosZ : TEXCOORD2; // Necessary for pixel fog
|
||||
#if PARALLAXCORRECT
|
||||
float3 worldSpaceNormal : TEXCOORD2;
|
||||
#endif
|
||||
};
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
|
||||
@@ -28,11 +28,11 @@ struct VS_OUTPUT
|
||||
float3 eyeToVertVector : TEXCOORD0;
|
||||
float4 vertexColor : COLOR;
|
||||
|
||||
#if PARALLAXCORRECT
|
||||
float3 worldNormal : TEXCOORD1;
|
||||
#endif
|
||||
float4 worldPos_projPosZ : TEXCOORD1; // Necessary for pixel fog
|
||||
|
||||
float4 worldPos_projPosZ : TEXCOORD2; // Necessary for pixel fog
|
||||
#if PARALLAXCORRECT
|
||||
float3 worldNormal : TEXCOORD2;
|
||||
#endif
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,44 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
sampler _Sampler_01 : register( s1 );
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float4 _texLookup_3 = tex2D( _Sampler_00, In.vTexCoord_0 );
|
||||
float3 _var0 = _texLookup_3.rgb;
|
||||
float _var1 = _texLookup_3.a;
|
||||
float4 _texLookup_5 = tex2D( _Sampler_01, In.vTexCoord_0 );
|
||||
float3 _var2 = _texLookup_5.rgb;
|
||||
float _var3 = _texLookup_5.a;
|
||||
_var0 = lerp( _var0, _var2, float( 0.800000 ) );
|
||||
_var1 = lerp( _var1, _var3, float( 0.400000 ) );
|
||||
float4 _var4 = float4( _var0, _var1 );
|
||||
Out.vColor_0 = _var4;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = float4( In.vPos.x, In.vPos.y, In.vPos.z, 1.000000 );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
sampler _Sampler_01 : register( s1 );
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float4 _var0 = tex2D( _Sampler_00, In.vTexCoord_0 ).rgba;
|
||||
float4 _var1 = tex2D( _Sampler_01, In.vTexCoord_0 ).rgba;
|
||||
float _var2 = distance( In.vTexCoord_0, float2( 0.500000, 0.500000 ) );
|
||||
_var2 = smoothstep( float( 0.000000 ), float( 0.600000 ), _var2 );
|
||||
_var0 = lerp( _var0, _var1, _var2 );
|
||||
Out.vColor_0 = _var0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = float4( In.vPos.x, In.vPos.y, In.vPos.z, 1.000000 );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,821 +0,0 @@
|
||||
//====== Copyright <20> 1996-2007, Valve Corporation, All rights reserved. =======//
|
||||
//
|
||||
// Purpose: Common pixel shader code specific to flashlights
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#ifndef COMMON_FLASHLIGHT_FXC_H_
|
||||
#define COMMON_FLASHLIGHT_FXC_H_
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
|
||||
// JasonM - TODO: remove this simpleton version
|
||||
float DoShadow( sampler DepthSampler, float4 texCoord )
|
||||
{
|
||||
const float g_flShadowBias = 0.0005f;
|
||||
float2 uoffset = float2( 0.5f/512.f, 0.0f );
|
||||
float2 voffset = float2( 0.0f, 0.5f/512.f );
|
||||
float3 projTexCoord = texCoord.xyz / texCoord.w;
|
||||
float4 flashlightDepth = float4( tex2D( DepthSampler, projTexCoord + uoffset + voffset ).x,
|
||||
tex2D( DepthSampler, projTexCoord + uoffset - voffset ).x,
|
||||
tex2D( DepthSampler, projTexCoord - uoffset + voffset ).x,
|
||||
tex2D( DepthSampler, projTexCoord - uoffset - voffset ).x );
|
||||
|
||||
# if ( defined( REVERSE_DEPTH_ON_X360 ) )
|
||||
{
|
||||
flashlightDepth = 1.0f - flashlightDepth;
|
||||
}
|
||||
# endif
|
||||
|
||||
float shadowed = 0.0f;
|
||||
float z = texCoord.z/texCoord.w;
|
||||
float4 dz = float4(z,z,z,z) - (flashlightDepth + float4( g_flShadowBias, g_flShadowBias, g_flShadowBias, g_flShadowBias));
|
||||
float4 shadow = float4(0.25f,0.25f,0.25f,0.25f);
|
||||
|
||||
if( dz.x <= 0.0f )
|
||||
shadowed += shadow.x;
|
||||
if( dz.y <= 0.0f )
|
||||
shadowed += shadow.y;
|
||||
if( dz.z <= 0.0f )
|
||||
shadowed += shadow.z;
|
||||
if( dz.w <= 0.0f )
|
||||
shadowed += shadow.w;
|
||||
|
||||
return shadowed;
|
||||
}
|
||||
|
||||
|
||||
float DoShadowNvidiaRAWZOneTap( sampler DepthSampler, const float4 shadowMapPos )
|
||||
{
|
||||
float ooW = 1.0f / shadowMapPos.w; // 1 / w
|
||||
float3 shadowMapCenter_objDepth = shadowMapPos.xyz * ooW; // Do both projections at once
|
||||
|
||||
float2 shadowMapCenter = shadowMapCenter_objDepth.xy; // Center of shadow filter
|
||||
float objDepth = shadowMapCenter_objDepth.z; // Object depth in shadow space
|
||||
|
||||
float fDepth = dot(tex2D(DepthSampler, shadowMapCenter).arg, float3(0.996093809371817670572857294849, 0.0038909914428586627756752238080039, 1.5199185323666651467481343000015e-5));
|
||||
|
||||
return fDepth > objDepth;
|
||||
}
|
||||
|
||||
|
||||
float DoShadowNvidiaRAWZ( sampler DepthSampler, const float4 shadowMapPos )
|
||||
{
|
||||
float fE = 1.0f / 512.0f; // Epsilon
|
||||
|
||||
float ooW = 1.0f / shadowMapPos.w; // 1 / w
|
||||
float3 shadowMapCenter_objDepth = shadowMapPos.xyz * ooW; // Do both projections at once
|
||||
|
||||
float2 shadowMapCenter = shadowMapCenter_objDepth.xy; // Center of shadow filter
|
||||
float objDepth = shadowMapCenter_objDepth.z; // Object depth in shadow space
|
||||
|
||||
float4 vDepths;
|
||||
vDepths.x = dot(tex2D(DepthSampler, shadowMapCenter + float2( fE, fE )).arg, float3(0.996093809371817670572857294849, 0.0038909914428586627756752238080039, 1.5199185323666651467481343000015e-5));
|
||||
vDepths.y = dot(tex2D(DepthSampler, shadowMapCenter + float2( -fE, fE )).arg, float3(0.996093809371817670572857294849, 0.0038909914428586627756752238080039, 1.5199185323666651467481343000015e-5));
|
||||
vDepths.z = dot(tex2D(DepthSampler, shadowMapCenter + float2( fE, -fE )).arg, float3(0.996093809371817670572857294849, 0.0038909914428586627756752238080039, 1.5199185323666651467481343000015e-5));
|
||||
vDepths.w = dot(tex2D(DepthSampler, shadowMapCenter + float2( -fE, -fE )).arg, float3(0.996093809371817670572857294849, 0.0038909914428586627756752238080039, 1.5199185323666651467481343000015e-5));
|
||||
|
||||
return dot(vDepths > objDepth.xxxx, float4(0.25, 0.25, 0.25, 0.25));
|
||||
}
|
||||
|
||||
|
||||
float DoShadowNvidiaCheap( sampler DepthSampler, const float4 shadowMapPos )
|
||||
{
|
||||
float fTexelEpsilon = 1.0f / 1024.0f;
|
||||
|
||||
float ooW = 1.0f / shadowMapPos.w; // 1 / w
|
||||
float3 shadowMapCenter_objDepth = shadowMapPos.xyz * ooW; // Do both projections at once
|
||||
|
||||
float2 shadowMapCenter = shadowMapCenter_objDepth.xy; // Center of shadow filter
|
||||
float objDepth = shadowMapCenter_objDepth.z; // Object depth in shadow space
|
||||
|
||||
float4 vTaps;
|
||||
vTaps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTexelEpsilon, fTexelEpsilon), objDepth, 1 ) ).x;
|
||||
vTaps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTexelEpsilon, fTexelEpsilon), objDepth, 1 ) ).x;
|
||||
vTaps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTexelEpsilon, -fTexelEpsilon), objDepth, 1 ) ).x;
|
||||
vTaps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTexelEpsilon, -fTexelEpsilon), objDepth, 1 ) ).x;
|
||||
|
||||
return dot(vTaps, float4(0.25, 0.25, 0.25, 0.25));
|
||||
}
|
||||
|
||||
float DoShadowNvidiaPCF3x3Box( sampler DepthSampler, const float4 shadowMapPos )
|
||||
{
|
||||
float fTexelEpsilon = 1.0f / 1024.0f;
|
||||
|
||||
float ooW = 1.0f / shadowMapPos.w; // 1 / w
|
||||
float3 shadowMapCenter_objDepth = shadowMapPos.xyz * ooW; // Do both projections at once
|
||||
|
||||
float2 shadowMapCenter = shadowMapCenter_objDepth.xy; // Center of shadow filter
|
||||
float objDepth = shadowMapCenter_objDepth.z; // Object depth in shadow space
|
||||
|
||||
float4 vOneTaps;
|
||||
vOneTaps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTexelEpsilon, fTexelEpsilon ), objDepth, 1 ) ).x;
|
||||
vOneTaps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTexelEpsilon, fTexelEpsilon ), objDepth, 1 ) ).x;
|
||||
vOneTaps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTexelEpsilon, -fTexelEpsilon ), objDepth, 1 ) ).x;
|
||||
vOneTaps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTexelEpsilon, -fTexelEpsilon ), objDepth, 1 ) ).x;
|
||||
float flOneTaps = dot( vOneTaps, float4(1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f));
|
||||
|
||||
float4 vTwoTaps;
|
||||
vTwoTaps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTexelEpsilon, 0 ), objDepth, 1 ) ).x;
|
||||
vTwoTaps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTexelEpsilon, 0 ), objDepth, 1 ) ).x;
|
||||
vTwoTaps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fTexelEpsilon ), objDepth, 1 ) ).x;
|
||||
vTwoTaps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fTexelEpsilon ), objDepth, 1 ) ).x;
|
||||
float flTwoTaps = dot( vTwoTaps, float4(1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f));
|
||||
|
||||
float flCenterTap = tex2Dproj( DepthSampler, float4( shadowMapCenter, objDepth, 1 ) ).x * (1.0f / 9.0f);
|
||||
|
||||
// Sum all 9 Taps
|
||||
return flOneTaps + flTwoTaps + flCenterTap;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 1 4 7 4 1
|
||||
// 4 20 33 20 4
|
||||
// 7 33 55 33 7
|
||||
// 4 20 33 20 4
|
||||
// 1 4 7 4 1
|
||||
//
|
||||
float DoShadowNvidiaPCF5x5Gaussian( sampler DepthSampler, const float4 shadowMapPos )
|
||||
{
|
||||
float fEpsilon = 1.0f / 512.0f;
|
||||
float fTwoEpsilon = 2.0f * fEpsilon;
|
||||
|
||||
float ooW = 1.0f / shadowMapPos.w; // 1 / w
|
||||
float3 shadowMapCenter_objDepth = shadowMapPos.xyz * ooW; // Do both projections at once
|
||||
|
||||
float2 shadowMapCenter = shadowMapCenter_objDepth.xy; // Center of shadow filter
|
||||
float objDepth = shadowMapCenter_objDepth.z; // Object depth in shadow space
|
||||
|
||||
float4 vOneTaps;
|
||||
vOneTaps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilon, fTwoEpsilon ), objDepth, 1 ) ).x;
|
||||
vOneTaps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilon, fTwoEpsilon ), objDepth, 1 ) ).x;
|
||||
vOneTaps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilon, -fTwoEpsilon ), objDepth, 1 ) ).x;
|
||||
vOneTaps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilon, -fTwoEpsilon ), objDepth, 1 ) ).x;
|
||||
float flOneTaps = dot( vOneTaps, float4(1.0f / 331.0f, 1.0f / 331.0f, 1.0f / 331.0f, 1.0f / 331.0f));
|
||||
|
||||
float4 vSevenTaps;
|
||||
vSevenTaps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilon, 0 ), objDepth, 1 ) ).x;
|
||||
vSevenTaps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilon, 0 ), objDepth, 1 ) ).x;
|
||||
vSevenTaps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fTwoEpsilon ), objDepth, 1 ) ).x;
|
||||
vSevenTaps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fTwoEpsilon ), objDepth, 1 ) ).x;
|
||||
float flSevenTaps = dot( vSevenTaps, float4( 7.0f / 331.0f, 7.0f / 331.0f, 7.0f / 331.0f, 7.0f / 331.0f ) );
|
||||
|
||||
float4 vFourTapsA, vFourTapsB;
|
||||
vFourTapsA.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilon, fEpsilon ), objDepth, 1 ) ).x;
|
||||
vFourTapsA.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilon, fTwoEpsilon ), objDepth, 1 ) ).x;
|
||||
vFourTapsA.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilon, fTwoEpsilon ), objDepth, 1 ) ).x;
|
||||
vFourTapsA.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilon, fEpsilon ), objDepth, 1 ) ).x;
|
||||
vFourTapsB.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fTwoEpsilon, -fEpsilon ), objDepth, 1 ) ).x;
|
||||
vFourTapsB.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilon, -fTwoEpsilon ), objDepth, 1 ) ).x;
|
||||
vFourTapsB.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilon, -fTwoEpsilon ), objDepth, 1 ) ).x;
|
||||
vFourTapsB.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fTwoEpsilon, -fEpsilon ), objDepth, 1 ) ).x;
|
||||
float flFourTapsA = dot( vFourTapsA, float4( 4.0f / 331.0f, 4.0f / 331.0f, 4.0f / 331.0f, 4.0f / 331.0f ) );
|
||||
float flFourTapsB = dot( vFourTapsB, float4( 4.0f / 331.0f, 4.0f / 331.0f, 4.0f / 331.0f, 4.0f / 331.0f ) );
|
||||
|
||||
float4 v20Taps;
|
||||
v20Taps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilon, fEpsilon ), objDepth, 1 ) ).x;
|
||||
v20Taps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilon, fEpsilon ), objDepth, 1 ) ).x;
|
||||
v20Taps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilon, -fEpsilon ), objDepth, 1 ) ).x;
|
||||
v20Taps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilon, -fEpsilon ), objDepth, 1 ) ).x;
|
||||
float fl20Taps = dot( v20Taps, float4(20.0f / 331.0f, 20.0f / 331.0f, 20.0f / 331.0f, 20.0f / 331.0f));
|
||||
|
||||
float4 v33Taps;
|
||||
v33Taps.x = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( fEpsilon, 0 ), objDepth, 1 ) ).x;
|
||||
v33Taps.y = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( -fEpsilon, 0 ), objDepth, 1 ) ).x;
|
||||
v33Taps.z = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fEpsilon ), objDepth, 1 ) ).x;
|
||||
v33Taps.w = tex2Dproj( DepthSampler, float4( shadowMapCenter + float2( 0, -fEpsilon ), objDepth, 1 ) ).x;
|
||||
float fl33Taps = dot( v33Taps, float4(33.0f / 331.0f, 33.0f / 331.0f, 33.0f / 331.0f, 33.0f / 331.0f));
|
||||
|
||||
float flCenterTap = tex2Dproj( DepthSampler, float4( shadowMapCenter, objDepth, 1 ) ).x * (55.0f / 331.0f);
|
||||
|
||||
// Sum all 25 Taps
|
||||
return flOneTaps + flSevenTaps + +flFourTapsA + flFourTapsB + fl20Taps + fl33Taps + flCenterTap;
|
||||
}
|
||||
|
||||
|
||||
float DoShadowATICheap( sampler DepthSampler, const float4 shadowMapPos )
|
||||
{
|
||||
float2 shadowMapCenter = shadowMapPos.xy/shadowMapPos.w;
|
||||
float objDepth = shadowMapPos.z / shadowMapPos.w;
|
||||
float fSampleDepth = tex2D( DepthSampler, shadowMapCenter ).x;
|
||||
|
||||
objDepth = min( objDepth, 0.99999 ); //HACKHACK: On 360, surfaces at or past the far flashlight plane have an abrupt cutoff. This is temp until a smooth falloff is implemented
|
||||
|
||||
return fSampleDepth > objDepth;
|
||||
}
|
||||
|
||||
|
||||
// Poisson disc, randomly rotated at different UVs
|
||||
float DoShadowPoisson16Sample( sampler DepthSampler, sampler RandomRotationSampler, const float3 vProjCoords, const float2 vScreenPos, const float4 vShadowTweaks, bool bNvidiaHardwarePCF, bool bFetch4 )
|
||||
{
|
||||
float2 vPoissonOffset[8] = { float2( 0.3475f, 0.0042f ),
|
||||
float2( 0.8806f, 0.3430f ),
|
||||
float2( -0.0041f, -0.6197f ),
|
||||
float2( 0.0472f, 0.4964f ),
|
||||
float2( -0.3730f, 0.0874f ),
|
||||
float2( -0.9217f, -0.3177f ),
|
||||
float2( -0.6289f, 0.7388f ),
|
||||
float2( 0.5744f, -0.7741f ) };
|
||||
|
||||
float flScaleOverMapSize = vShadowTweaks.x * 2; // Tweak parameters to shader
|
||||
float2 vNoiseOffset = vShadowTweaks.zw;
|
||||
float4 vLightDepths = 0, accum = 0.0f;
|
||||
float2 rotOffset = 0;
|
||||
|
||||
float2 shadowMapCenter = vProjCoords.xy; // Center of shadow filter
|
||||
float objDepth = min( vProjCoords.z, 0.99999 ); // Object depth in shadow space
|
||||
|
||||
// 2D Rotation Matrix setup
|
||||
float3 RMatTop = 0, RMatBottom = 0;
|
||||
#if defined(SHADER_MODEL_PS_2_0) || defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0)
|
||||
RMatTop.xy = tex2D( RandomRotationSampler, cFlashlightScreenScale.xy * (vScreenPos * 0.5 + 0.5) + vNoiseOffset) * 2.0 - 1.0;
|
||||
RMatBottom.xy = float2(-1.0, 1.0) * RMatTop.yx; // 2x2 rotation matrix in 4-tuple
|
||||
#endif
|
||||
|
||||
RMatTop *= flScaleOverMapSize; // Scale up kernel while accounting for texture resolution
|
||||
RMatBottom *= flScaleOverMapSize;
|
||||
|
||||
RMatTop.z = shadowMapCenter.x; // To be added in d2adds generated below
|
||||
RMatBottom.z = shadowMapCenter.y;
|
||||
|
||||
float fResult = 0.0f;
|
||||
|
||||
if ( bNvidiaHardwarePCF )
|
||||
{
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[0].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[0].xy) + RMatBottom.z;
|
||||
vLightDepths.x += tex2Dproj( DepthSampler, float4(rotOffset, objDepth, 1) ).x;
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[1].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[1].xy) + RMatBottom.z;
|
||||
vLightDepths.y += tex2Dproj( DepthSampler, float4(rotOffset, objDepth, 1) ).x;
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[2].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[2].xy) + RMatBottom.z;
|
||||
vLightDepths.z += tex2Dproj( DepthSampler, float4(rotOffset, objDepth, 1) ).x;
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[3].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[3].xy) + RMatBottom.z;
|
||||
vLightDepths.w += tex2Dproj( DepthSampler, float4(rotOffset, objDepth, 1) ).x;
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[4].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[4].xy) + RMatBottom.z;
|
||||
vLightDepths.x += tex2Dproj( DepthSampler, float4(rotOffset, objDepth, 1) ).x;
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[5].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[5].xy) + RMatBottom.z;
|
||||
vLightDepths.y += tex2Dproj( DepthSampler, float4(rotOffset, objDepth, 1) ).x;
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[6].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[6].xy) + RMatBottom.z;
|
||||
vLightDepths.z += tex2Dproj( DepthSampler, float4(rotOffset, objDepth, 1) ).x;
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[7].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[7].xy) + RMatBottom.z;
|
||||
vLightDepths.w += tex2Dproj( DepthSampler, float4(rotOffset, objDepth, 1) ).x;
|
||||
|
||||
fResult = dot( vLightDepths, float4( 0.25, 0.25, 0.25, 0.25) );
|
||||
}
|
||||
else if ( bFetch4 )
|
||||
{
|
||||
/*
|
||||
|
||||
TODO: Fix this contact hardening stuff
|
||||
|
||||
float flNumCloserSamples = 1;
|
||||
float flAccumulatedCloserSamples = objDepth;
|
||||
float4 vBlockerDepths;
|
||||
|
||||
// First, search for blockers
|
||||
for( int j=0; j<8; j++ )
|
||||
{
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[j].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[j].xy) + RMatBottom.z;
|
||||
vBlockerDepths = tex2D( DepthSampler, rotOffset.xy );
|
||||
|
||||
// Which samples are closer than the pixel we're rendering?
|
||||
float4 vCloserSamples = (vBlockerDepths < objDepth.xxxx ); // Binary comparison results
|
||||
flNumCloserSamples += dot( vCloserSamples, float4(1, 1, 1, 1) ); // How many samples are closer than receiver?
|
||||
flAccumulatedCloserSamples += dot (vCloserSamples, vBlockerDepths ); // Total depths from samples closer than receiver
|
||||
}
|
||||
|
||||
float flBlockerDepth = flAccumulatedCloserSamples / flNumCloserSamples;
|
||||
float flContactHardeningScale = (objDepth - flBlockerDepth) / flBlockerDepth;
|
||||
|
||||
// Scale the kernel
|
||||
RMatTop.xy *= flContactHardeningScale;
|
||||
RMatBottom.xy *= flContactHardeningScale;
|
||||
*/
|
||||
|
||||
for( int i=0; i<8; i++ )
|
||||
{
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[i].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[i].xy) + RMatBottom.z;
|
||||
vLightDepths = tex2D( DepthSampler, rotOffset.xy );
|
||||
accum += (vLightDepths > objDepth.xxxx);
|
||||
}
|
||||
|
||||
fResult = dot( accum, float4( 1.0f/32.0f, 1.0f/32.0f, 1.0f/32.0f, 1.0f/32.0f) );
|
||||
}
|
||||
else // ATI vanilla hardware shadow mapping
|
||||
{
|
||||
for( int i=0; i<2; i++ )
|
||||
{
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[4*i+0].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[4*i+0].xy) + RMatBottom.z;
|
||||
vLightDepths.x = tex2D( DepthSampler, rotOffset.xy ).x;
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[4*i+1].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[4*i+1].xy) + RMatBottom.z;
|
||||
vLightDepths.y = tex2D( DepthSampler, rotOffset.xy ).x;
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[4*i+2].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[4*i+2].xy) + RMatBottom.z;
|
||||
vLightDepths.z = tex2D( DepthSampler, rotOffset.xy ).x;
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[4*i+3].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[4*i+3].xy) + RMatBottom.z;
|
||||
vLightDepths.w = tex2D( DepthSampler, rotOffset.xy ).x;
|
||||
|
||||
accum += (vLightDepths > objDepth.xxxx);
|
||||
}
|
||||
|
||||
fResult = dot( accum, float4( 0.125, 0.125, 0.125, 0.125) );
|
||||
}
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
#if defined( _X360 )
|
||||
|
||||
// Poisson disc, randomly rotated at different UVs
|
||||
float DoShadow360Simple( sampler DepthSampler, const float3 vProjCoords )
|
||||
{
|
||||
float fLOD;
|
||||
float2 shadowMapCenter = vProjCoords.xy; // Center of shadow filter
|
||||
float objDepth = min( vProjCoords.z, 0.99999 ); // Object depth in shadow space
|
||||
|
||||
#if defined( REVERSE_DEPTH_ON_X360 )
|
||||
objDepth = 1.0f - objDepth;
|
||||
#endif
|
||||
|
||||
float4 vSampledDepths, vWeights;
|
||||
|
||||
asm {
|
||||
getCompTexLOD2D fLOD.x, shadowMapCenter.xy, DepthSampler, AnisoFilter=max16to1
|
||||
setTexLOD fLOD.x
|
||||
|
||||
tfetch2D vSampledDepths.x___, shadowMapCenter, DepthSampler, OffsetX = -0.5, OffsetY = -0.5, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
tfetch2D vSampledDepths._x__, shadowMapCenter, DepthSampler, OffsetX = 0.5, OffsetY = -0.5, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
tfetch2D vSampledDepths.__x_, shadowMapCenter, DepthSampler, OffsetX = -0.5, OffsetY = 0.5, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
tfetch2D vSampledDepths.___x, shadowMapCenter, DepthSampler, OffsetX = 0.5, OffsetY = 0.5, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
|
||||
getWeights2D vWeights, shadowMapCenter.xy, DepthSampler, MagFilter=linear, MinFilter=linear, UseComputedLOD=false, UseRegisterLOD=true
|
||||
};
|
||||
|
||||
vWeights = float4( (1-vWeights.x)*(1-vWeights.y), vWeights.x*(1-vWeights.y), (1-vWeights.x)*vWeights.y, vWeights.x*vWeights.y );
|
||||
|
||||
#if defined( REVERSE_DEPTH_ON_X360 )
|
||||
float4 vCompare = (vSampledDepths < objDepth.xxxx);
|
||||
#else
|
||||
float4 vCompare = (vSampledDepths > objDepth.xxxx);
|
||||
#endif
|
||||
|
||||
return dot( vCompare, vWeights );
|
||||
}
|
||||
|
||||
|
||||
float Do360PCFFetch( sampler DepthSampler, float2 tc, float objDepth )
|
||||
{
|
||||
float fLOD;
|
||||
float4 vSampledDepths, vWeights;
|
||||
|
||||
asm {
|
||||
getCompTexLOD2D fLOD.x, tc.xy, DepthSampler, AnisoFilter=max16to1
|
||||
setTexLOD fLOD.x
|
||||
|
||||
tfetch2D vSampledDepths.x___, tc, DepthSampler, OffsetX = -0.5, OffsetY = -0.5, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
tfetch2D vSampledDepths._x__, tc, DepthSampler, OffsetX = 0.5, OffsetY = -0.5, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
tfetch2D vSampledDepths.__x_, tc, DepthSampler, OffsetX = -0.5, OffsetY = 0.5, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
tfetch2D vSampledDepths.___x, tc, DepthSampler, OffsetX = 0.5, OffsetY = 0.5, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
|
||||
getWeights2D vWeights, tc.xy, DepthSampler, MagFilter=linear, MinFilter=linear, UseComputedLOD=false, UseRegisterLOD=true
|
||||
};
|
||||
|
||||
vWeights = float4( (1-vWeights.x)*(1-vWeights.y), vWeights.x*(1-vWeights.y), (1-vWeights.x)*vWeights.y, vWeights.x*vWeights.y );
|
||||
|
||||
#if defined( REVERSE_DEPTH_ON_X360 )
|
||||
float4 vCompare = (vSampledDepths < objDepth.xxxx);
|
||||
#else
|
||||
float4 vCompare = (vSampledDepths > objDepth.xxxx);
|
||||
#endif
|
||||
|
||||
return dot( vCompare, vWeights );
|
||||
}
|
||||
|
||||
|
||||
|
||||
float Do360NearestFetch( sampler DepthSampler, float2 tc, float objDepth )
|
||||
{
|
||||
float fLOD;
|
||||
float4 vSampledDepth;
|
||||
|
||||
asm {
|
||||
getCompTexLOD2D fLOD.x, tc.xy, DepthSampler, AnisoFilter=max16to1
|
||||
setTexLOD fLOD.x
|
||||
|
||||
tfetch2D vSampledDepth.x___, tc, DepthSampler, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
};
|
||||
|
||||
#if defined( REVERSE_DEPTH_ON_X360 )
|
||||
return (vSampledDepth.x < objDepth.x);
|
||||
#else
|
||||
return (vSampledDepth.x > objDepth.x);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
float AmountShadowed_8Tap_360( sampler DepthSampler, float2 tc, float objDepth )
|
||||
{
|
||||
float fLOD;
|
||||
float4 vSampledDepthsA, vSampledDepthsB;
|
||||
|
||||
// Optimal 8 rooks pattern to get an idea about whether we're at a penumbra or not
|
||||
// From [Kallio07] "Scanline Edge-Flag Algorithm for Antialiasing"
|
||||
//
|
||||
// +---+---+---+---+---+---+---+---+
|
||||
// | | | | | | o | | |
|
||||
// +---+---+---+---+---+---+---+---+
|
||||
// | o | | | | | | | |
|
||||
// +---+---+---+---+---+---+---+---+
|
||||
// | | | | o | | | | |
|
||||
// +---+---+---+---+---+---+---+---+
|
||||
// | | | | | | | o | |
|
||||
// +---+---+---+---+---+---+---+---+
|
||||
// | | o | | | | | | |
|
||||
// +---+---+---+---+---+---+---+---+
|
||||
// | | | | | o | | | |
|
||||
// +---+---+---+---+---+---+---+---+
|
||||
// | | | | | | | | o |
|
||||
// +---+---+---+---+---+---+---+---+
|
||||
// | | | o | | | | | |
|
||||
// +---+---+---+---+---+---+---+---+
|
||||
//
|
||||
asm {
|
||||
getCompTexLOD2D fLOD.x, tc.xy, DepthSampler, AnisoFilter=max16to1
|
||||
setTexLOD fLOD.x
|
||||
|
||||
tfetch2D vSampledDepthsA.x___, tc, DepthSampler, OffsetX = -2.0, OffsetY = -1.5, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
tfetch2D vSampledDepthsA._x__, tc, DepthSampler, OffsetX = -1.5, OffsetY = 0.5, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
tfetch2D vSampledDepthsA.__x_, tc, DepthSampler, OffsetX = -1.0, OffsetY = 2.0, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
tfetch2D vSampledDepthsA.___x, tc, DepthSampler, OffsetX = -0.5, OffsetY = -1.0, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
|
||||
tfetch2D vSampledDepthsB.x___, tc, DepthSampler, OffsetX = 0.5, OffsetY = 1.0, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
tfetch2D vSampledDepthsB._x__, tc, DepthSampler, OffsetX = 1.0, OffsetY = -2.0, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
tfetch2D vSampledDepthsB.__x_, tc, DepthSampler, OffsetX = 1.5, OffsetY = -0.5, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
tfetch2D vSampledDepthsB.___x, tc, DepthSampler, OffsetX = 2.0, OffsetY = 1.5, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
};
|
||||
|
||||
#if defined( REVERSE_DEPTH_ON_X360 )
|
||||
float4 vCompareA = (vSampledDepthsA < objDepth.xxxx);
|
||||
float4 vCompareB = (vSampledDepthsB < objDepth.xxxx);
|
||||
#else
|
||||
float4 vCompareA = (vSampledDepthsA > objDepth.xxxx);
|
||||
float4 vCompareB = (vSampledDepthsB > objDepth.xxxx);
|
||||
#endif
|
||||
|
||||
return dot( vCompareA, float4(0.125,0.125,0.125,0.125) ) + dot( vCompareB, float4(0.125,0.125,0.125,0.125) );
|
||||
}
|
||||
|
||||
|
||||
float AmountShadowed_4Tap_360( sampler DepthSampler, float2 tc, float objDepth )
|
||||
{
|
||||
float fLOD;
|
||||
float4 vSampledDepths;
|
||||
|
||||
// Rotated grid pattern to get an idea about whether we're at a penumbra or not
|
||||
asm {
|
||||
getCompTexLOD2D fLOD.x, tc.xy, DepthSampler, AnisoFilter=max16to1
|
||||
setTexLOD fLOD.x
|
||||
|
||||
tfetch2D vSampledDepths.x___, tc, DepthSampler, OffsetX = -1.0, OffsetY = 0.5, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
tfetch2D vSampledDepths._x__, tc, DepthSampler, OffsetX = -0.5, OffsetY = -1.0, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
tfetch2D vSampledDepths.__x_, tc, DepthSampler, OffsetX = 0.5, OffsetY = 1.0, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
tfetch2D vSampledDepths.___x, tc, DepthSampler, OffsetX = 1.0, OffsetY = -0.5, UseComputedLOD=false, UseRegisterLOD=true, MagFilter = point, MinFilter = point
|
||||
};
|
||||
|
||||
#if defined( REVERSE_DEPTH_ON_X360 )
|
||||
float4 vCompare = (vSampledDepths < objDepth.xxxx);
|
||||
#else
|
||||
float4 vCompare = (vSampledDepths > objDepth.xxxx);
|
||||
#endif
|
||||
|
||||
return dot( vCompare, float4(0.25,0.25,0.25,0.25) );
|
||||
}
|
||||
|
||||
// Poisson disc, randomly rotated at different UVs
|
||||
float DoShadowPoisson360( sampler DepthSampler, sampler RandomRotationSampler, const float3 vProjCoords, const float2 vScreenPos, const float4 vShadowTweaks )
|
||||
{
|
||||
float2 vPoissonOffset[8] = { float2( 0.3475f, 0.0042f ), float2( 0.8806f, 0.3430f ),
|
||||
float2( -0.0041f, -0.6197f ), float2( 0.0472f, 0.4964f ),
|
||||
float2( -0.3730f, 0.0874f ), float2( -0.9217f, -0.3177f ),
|
||||
float2( -0.6289f, 0.7388f ), float2( 0.5744f, -0.7741f ) };
|
||||
|
||||
float2 shadowMapCenter = vProjCoords.xy; // Center of shadow filter
|
||||
float objDepth = min( vProjCoords.z, 0.99999 ); // Object depth in shadow space
|
||||
|
||||
#if defined( REVERSE_DEPTH_ON_X360 )
|
||||
objDepth = 1.0f - objDepth;
|
||||
#endif
|
||||
|
||||
float fAmountShadowed = AmountShadowed_4Tap_360( DepthSampler, shadowMapCenter, objDepth );
|
||||
|
||||
if ( fAmountShadowed >= 1.0f ) // Fully in light
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
else // Do the expensive filtering since we're at least partially shadowed
|
||||
{
|
||||
float flScaleOverMapSize = 1.7f / 512.0f; // Tweak parameters to shader
|
||||
|
||||
// 2D Rotation Matrix setup
|
||||
float3 RMatTop = 0, RMatBottom = 0;
|
||||
#if defined(SHADER_MODEL_PS_2_0) || defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0)
|
||||
RMatTop.xy = tex2D( RandomRotationSampler, cFlashlightScreenScale.xy * (vScreenPos * 0.5 + 0.5)) * 2.0 - 1.0;
|
||||
RMatBottom.xy = float2(-1.0, 1.0) * RMatTop.yx; // 2x2 rotation matrix in 4-tuple
|
||||
#endif
|
||||
|
||||
RMatTop *= flScaleOverMapSize; // Scale up kernel while accounting for texture resolution
|
||||
RMatBottom *= flScaleOverMapSize;
|
||||
RMatTop.z = shadowMapCenter.x; // To be added in d2adds generated below
|
||||
RMatBottom.z = shadowMapCenter.y;
|
||||
float2 rotOffset = float2(0,0);
|
||||
float4 vAccum = 0;
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[0].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[0].xy) + RMatBottom.z;
|
||||
vAccum.x = Do360NearestFetch( DepthSampler, rotOffset, objDepth );
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[1].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[1].xy) + RMatBottom.z;
|
||||
vAccum.y = Do360NearestFetch( DepthSampler, rotOffset, objDepth );
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[2].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[2].xy) + RMatBottom.z;
|
||||
vAccum.z = Do360NearestFetch( DepthSampler, rotOffset, objDepth );
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[3].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[3].xy) + RMatBottom.z;
|
||||
vAccum.w = Do360NearestFetch( DepthSampler, rotOffset, objDepth );
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[4].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[4].xy) + RMatBottom.z;
|
||||
vAccum.x += Do360NearestFetch( DepthSampler, rotOffset, objDepth );
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[5].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[5].xy) + RMatBottom.z;
|
||||
vAccum.y += Do360NearestFetch( DepthSampler, rotOffset, objDepth );
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[6].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[6].xy) + RMatBottom.z;
|
||||
vAccum.z += Do360NearestFetch( DepthSampler, rotOffset, objDepth );
|
||||
|
||||
rotOffset.x = dot (RMatTop.xy, vPoissonOffset[7].xy) + RMatTop.z;
|
||||
rotOffset.y = dot (RMatBottom.xy, vPoissonOffset[7].xy) + RMatBottom.z;
|
||||
vAccum.w += Do360NearestFetch( DepthSampler, rotOffset, objDepth );
|
||||
|
||||
return dot( vAccum, float4( 0.25, 0.25, 0.25, 0.25) );
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _X360
|
||||
|
||||
|
||||
float DoFlashlightShadow( sampler DepthSampler, sampler RandomRotationSampler, float3 vProjCoords, float2 vScreenPos, int nShadowLevel, float4 vShadowTweaks, bool bAllowHighQuality )
|
||||
{
|
||||
float flShadow = 1.0f;
|
||||
|
||||
#if !defined( _X360 ) //PC
|
||||
if( nShadowLevel == NVIDIA_PCF_POISSON )
|
||||
flShadow = DoShadowPoisson16Sample( DepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, vShadowTweaks, true, false );
|
||||
else if( nShadowLevel == ATI_NOPCF )
|
||||
flShadow = DoShadowPoisson16Sample( DepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, vShadowTweaks, false, false );
|
||||
else if( nShadowLevel == ATI_NO_PCF_FETCH4 )
|
||||
flShadow = DoShadowPoisson16Sample( DepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, vShadowTweaks, false, true );
|
||||
|
||||
return flShadow;
|
||||
#else
|
||||
|
||||
// Compile-time switch for shaders which allow high quality modes on 360
|
||||
if ( bAllowHighQuality )
|
||||
{
|
||||
// Static control flow switch for shadow quality. Some non-interactive sequences use the high quality path
|
||||
if ( g_bHighQualityShadows )
|
||||
{
|
||||
flShadow = DoShadowPoisson360( DepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, vShadowTweaks );
|
||||
}
|
||||
else
|
||||
{
|
||||
flShadow = DoShadow360Simple( DepthSampler, vProjCoords );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flShadow = DoShadow360Simple( DepthSampler, vProjCoords );
|
||||
}
|
||||
|
||||
return flShadow;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
float3 SpecularLight( const float3 vWorldNormal, const float3 vLightDir, const float fSpecularExponent,
|
||||
const float3 vEyeDir, /*const bool bDoSpecularWarp, in sampler specularWarpSampler,*/ float fFresnel )
|
||||
{
|
||||
float3 result = float3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
float3 vReflect = reflect( -vEyeDir, vWorldNormal ); // Reflect view through normal
|
||||
float3 vSpecular = saturate(dot( vReflect, vLightDir )); // L.R (use half-angle instead?)
|
||||
vSpecular = pow( vSpecular.x, fSpecularExponent ); // Raise to specular power
|
||||
|
||||
// Optionally warp as function of scalar specular and fresnel
|
||||
//if ( bDoSpecularWarp )
|
||||
// vSpecular *= tex2D( specularWarpSampler, float2(vSpecular.x, fFresnel) ); // Sample at { (L.R)^k, fresnel }
|
||||
vSpecular *= fFresnel;
|
||||
|
||||
return vSpecular;
|
||||
}
|
||||
|
||||
void DoSpecularFlashlight( float3 flashlightPos, float3 worldPos, float4 flashlightSpacePosition, float3 worldNormal,
|
||||
float3 attenuationFactors, float farZ, sampler FlashlightSampler, sampler FlashlightDepthSampler, sampler RandomRotationSampler,
|
||||
int nShadowLevel, bool bDoShadows, bool bAllowHighQuality, const float2 vScreenPos, const float fSpecularExponent, const float3 vEyeDir,
|
||||
/*const bool bDoSpecularWarp, sampler specularWarpSampler,*/ float fFresnel, float4 vShadowTweaks,
|
||||
|
||||
// Outputs of this shader...separate shadowed diffuse and specular from the flashlight
|
||||
out float3 diffuseLighting, out float3 specularLighting )
|
||||
{
|
||||
float3 vProjCoords = flashlightSpacePosition.xyz / flashlightSpacePosition.w;
|
||||
float3 flashlightColor = float3(1,1,1);
|
||||
|
||||
#if ( defined( _X360 ) )
|
||||
|
||||
float3 ltz = vProjCoords.xyz < float3( 0.0f, 0.0f, 0.0f );
|
||||
float3 gto = vProjCoords.xyz > float3( 1.0f, 1.0f, 1.0f );
|
||||
|
||||
[branch]
|
||||
if ( dot(ltz + gto, float3(1,1,1)) > 0 )
|
||||
{
|
||||
clip(-1);
|
||||
diffuseLighting = specularLighting = float3(0,0,0);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
flashlightColor = tex2D( FlashlightSampler, vProjCoords );
|
||||
|
||||
[branch]
|
||||
if ( dot(flashlightColor.xyz, float3(1,1,1)) <= 0 )
|
||||
{
|
||||
clip(-1);
|
||||
diffuseLighting = specularLighting = float3(0,0,0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#else
|
||||
flashlightColor = tex2D( FlashlightSampler, vProjCoords );
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(SHADER_MODEL_PS_2_0) || defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0)
|
||||
flashlightColor *= cFlashlightColor.xyz; // Flashlight color
|
||||
#endif
|
||||
|
||||
float3 delta = flashlightPos - worldPos;
|
||||
float3 L = normalize( delta );
|
||||
float distSquared = dot( delta, delta );
|
||||
float dist = sqrt( distSquared );
|
||||
|
||||
float endFalloffFactor = RemapValClamped( dist, farZ, 0.6f * farZ, 0.0f, 1.0f );
|
||||
|
||||
// Attenuation for light and to fade out shadow over distance
|
||||
float fAtten = saturate( dot( attenuationFactors, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) );
|
||||
|
||||
// Shadowing and coloring terms
|
||||
#if (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0))
|
||||
if ( bDoShadows )
|
||||
{
|
||||
float flShadow = DoFlashlightShadow( FlashlightDepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, nShadowLevel, vShadowTweaks, bAllowHighQuality );
|
||||
float flAttenuated = lerp( flShadow, 1.0f, vShadowTweaks.y ); // Blend between fully attenuated and not attenuated
|
||||
flShadow = saturate( lerp( flAttenuated, flShadow, fAtten ) ); // Blend between shadow and above, according to light attenuation
|
||||
flashlightColor *= flShadow; // Shadow term
|
||||
}
|
||||
#endif
|
||||
|
||||
diffuseLighting = fAtten;
|
||||
#if defined(SHADER_MODEL_PS_2_0) || defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0)
|
||||
diffuseLighting *= saturate( dot( L.xyz, worldNormal.xyz ) + flFlashlightNoLambertValue ); // Lambertian term
|
||||
#else
|
||||
diffuseLighting *= saturate( dot( L.xyz, worldNormal.xyz ) ); // Lambertian (not Half-Lambert) term
|
||||
#endif
|
||||
diffuseLighting *= flashlightColor;
|
||||
diffuseLighting *= endFalloffFactor;
|
||||
|
||||
// Specular term (masked by diffuse)
|
||||
specularLighting = diffuseLighting * SpecularLight ( worldNormal, L, fSpecularExponent, vEyeDir, /*bDoSpecularWarp, specularWarpSampler,*/ fFresnel );
|
||||
}
|
||||
|
||||
// Diffuse only version
|
||||
float3 DoFlashlight( float3 flashlightPos, float3 worldPos, float4 flashlightSpacePosition, float3 worldNormal,
|
||||
float3 attenuationFactors, float farZ, sampler FlashlightSampler, sampler FlashlightDepthSampler,
|
||||
sampler RandomRotationSampler, int nShadowLevel, bool bDoShadows, bool bAllowHighQuality,
|
||||
const float2 vScreenPos, bool bClip, float4 vShadowTweaks = float4(3/1024.0f, 0.0005f, 0.0f, 0.0f), bool bHasNormal = true )
|
||||
{
|
||||
float3 vProjCoords = flashlightSpacePosition.xyz / flashlightSpacePosition.w;
|
||||
float3 flashlightColor = float3(1,1,1);
|
||||
|
||||
#if ( defined( _X360 ) )
|
||||
|
||||
float3 ltz = vProjCoords.xyz < float3( 0.0f, 0.0f, 0.0f );
|
||||
float3 gto = vProjCoords.xyz > float3( 1.0f, 1.0f, 1.0f );
|
||||
|
||||
[branch]
|
||||
if ( dot(ltz + gto, float3(1,1,1)) > 0 )
|
||||
{
|
||||
if ( bClip )
|
||||
{
|
||||
clip(-1);
|
||||
}
|
||||
return float3(0,0,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
flashlightColor = tex2D( FlashlightSampler, vProjCoords );
|
||||
|
||||
[branch]
|
||||
if ( dot(flashlightColor.xyz, float3(1,1,1)) <= 0 )
|
||||
{
|
||||
if ( bClip )
|
||||
{
|
||||
clip(-1);
|
||||
}
|
||||
return float3(0,0,0);
|
||||
}
|
||||
}
|
||||
#else
|
||||
flashlightColor = tex2D( FlashlightSampler, vProjCoords );
|
||||
#endif
|
||||
|
||||
#if defined(SHADER_MODEL_PS_2_0) || defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0)
|
||||
flashlightColor *= cFlashlightColor.xyz; // Flashlight color
|
||||
#endif
|
||||
|
||||
float3 delta = flashlightPos - worldPos;
|
||||
float3 L = normalize( delta );
|
||||
float distSquared = dot( delta, delta );
|
||||
float dist = sqrt( distSquared );
|
||||
|
||||
float endFalloffFactor = RemapValClamped( dist, farZ, 0.6f * farZ, 0.0f, 1.0f );
|
||||
|
||||
// Attenuation for light and to fade out shadow over distance
|
||||
float fAtten = saturate( dot( attenuationFactors, float3( 1.0f, 1.0f/dist, 1.0f/distSquared ) ) );
|
||||
|
||||
// Shadowing and coloring terms
|
||||
#if (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0))
|
||||
if ( bDoShadows )
|
||||
{
|
||||
float flShadow = DoFlashlightShadow( FlashlightDepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, nShadowLevel, vShadowTweaks, bAllowHighQuality );
|
||||
float flAttenuated = lerp( flShadow, 1.0f, vShadowTweaks.y ); // Blend between fully attenuated and not attenuated
|
||||
flShadow = saturate( lerp( flAttenuated, flShadow, fAtten ) ); // Blend between shadow and above, according to light attenuation
|
||||
flashlightColor *= flShadow; // Shadow term
|
||||
}
|
||||
#endif
|
||||
|
||||
float3 diffuseLighting = fAtten;
|
||||
|
||||
float flLDotWorldNormal;
|
||||
if ( bHasNormal )
|
||||
{
|
||||
flLDotWorldNormal = dot( L.xyz, worldNormal.xyz );
|
||||
}
|
||||
else
|
||||
{
|
||||
flLDotWorldNormal = 1.0f;
|
||||
}
|
||||
|
||||
#if defined(SHADER_MODEL_PS_2_0) || defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0)
|
||||
diffuseLighting *= saturate( flLDotWorldNormal + flFlashlightNoLambertValue ); // Lambertian term
|
||||
#else
|
||||
diffuseLighting *= saturate( flLDotWorldNormal ); // Lambertian (not Half-Lambert) term
|
||||
#endif
|
||||
|
||||
diffuseLighting *= flashlightColor;
|
||||
diffuseLighting *= endFalloffFactor;
|
||||
|
||||
return diffuseLighting;
|
||||
}
|
||||
|
||||
#endif //#ifndef COMMON_FLASHLIGHT_FXC_H_
|
||||
@@ -1,326 +0,0 @@
|
||||
//========= Copyright <20> 1996-2007, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#ifndef COMMON_FXC_H_
|
||||
#define COMMON_FXC_H_
|
||||
|
||||
#include "common_pragmas.h"
|
||||
#include "common_hlsl_cpp_consts.h"
|
||||
|
||||
#ifdef NV3X
|
||||
# define HALF half
|
||||
# define HALF2 half2
|
||||
# define HALF3 half3
|
||||
# define HALF4 half4
|
||||
# define HALF3x3 half3x3
|
||||
# define HALF3x4 half3x4
|
||||
# define HALF4x3 half4x3
|
||||
# define HALF_CONSTANT( _constant ) ((HALF)_constant)
|
||||
#else
|
||||
# define HALF float
|
||||
# define HALF2 float2
|
||||
# define HALF3 float3
|
||||
# define HALF4 float4
|
||||
# define HALF3x3 float3x3
|
||||
# define HALF3x4 float3x4
|
||||
# define HALF4x3 float4x3
|
||||
# define HALF_CONSTANT( _constant ) _constant
|
||||
#endif
|
||||
|
||||
// This is where all common code for both vertex and pixel shaders.
|
||||
#define OO_SQRT_3 0.57735025882720947f
|
||||
static const HALF3 bumpBasis[3] = {
|
||||
HALF3( 0.81649661064147949f, 0.0f, OO_SQRT_3 ),
|
||||
HALF3( -0.40824833512306213f, 0.70710676908493042f, OO_SQRT_3 ),
|
||||
HALF3( -0.40824821591377258f, -0.7071068286895752f, OO_SQRT_3 )
|
||||
};
|
||||
static const HALF3 bumpBasisTranspose[3] = {
|
||||
HALF3( 0.81649661064147949f, -0.40824833512306213f, -0.40824833512306213f ),
|
||||
HALF3( 0.0f, 0.70710676908493042f, -0.7071068286895752f ),
|
||||
HALF3( OO_SQRT_3, OO_SQRT_3, OO_SQRT_3 )
|
||||
};
|
||||
|
||||
#if defined( _X360 )
|
||||
#define REVERSE_DEPTH_ON_X360 //uncomment to use D3DFMT_D24FS8 with an inverted depth viewport for better performance. Keep this in sync with the same named #define in public/shaderapi/shareddefs.h
|
||||
//Note that the reversal happens in the viewport. So ONLY reading back from a depth texture should be affected. Projected math is unaffected.
|
||||
#endif
|
||||
|
||||
HALF3 CalcReflectionVectorNormalized( HALF3 normal, HALF3 eyeVector )
|
||||
{
|
||||
// FIXME: might be better of normalizing with a normalizing cube map and
|
||||
// get rid of the dot( normal, normal )
|
||||
// compute reflection vector r = 2 * ((n dot v)/(n dot n)) n - v
|
||||
return 2.0 * ( dot( normal, eyeVector ) / dot( normal, normal ) ) * normal - eyeVector;
|
||||
}
|
||||
|
||||
HALF3 CalcReflectionVectorUnnormalized( HALF3 normal, HALF3 eyeVector )
|
||||
{
|
||||
// FIXME: might be better of normalizing with a normalizing cube map and
|
||||
// get rid of the dot( normal, normal )
|
||||
// compute reflection vector r = 2 * ((n dot v)/(n dot n)) n - v
|
||||
// multiply all values through by N.N. uniformly scaling reflection vector won't affect result
|
||||
// since it is used in a cubemap lookup
|
||||
return (2.0*(dot( normal, eyeVector ))*normal) - (dot( normal, normal )*eyeVector);
|
||||
}
|
||||
|
||||
float3 HuePreservingColorClamp( float3 c )
|
||||
{
|
||||
// Get the max of all of the color components and a specified maximum amount
|
||||
float maximum = max( max( c.x, c.y ), max( c.z, 1.0f ) );
|
||||
|
||||
return (c / maximum);
|
||||
}
|
||||
|
||||
HALF3 HuePreservingColorClamp( HALF3 c, HALF maxVal )
|
||||
{
|
||||
// Get the max of all of the color components and a specified maximum amount
|
||||
float maximum = max( max( c.x, c.y ), max( c.z, maxVal ) );
|
||||
return (c * ( maxVal / maximum ) );
|
||||
}
|
||||
|
||||
#if (AA_CLAMP==1)
|
||||
HALF2 ComputeLightmapCoordinates( HALF4 Lightmap1and2Coord, HALF2 Lightmap3Coord )
|
||||
{
|
||||
HALF2 result = saturate(Lightmap1and2Coord.xy) * Lightmap1and2Coord.wz * 0.99;
|
||||
result += Lightmap3Coord;
|
||||
return result;
|
||||
}
|
||||
|
||||
void ComputeBumpedLightmapCoordinates( HALF4 Lightmap1and2Coord, HALF2 Lightmap3Coord,
|
||||
out HALF2 bumpCoord1,
|
||||
out HALF2 bumpCoord2,
|
||||
out HALF2 bumpCoord3 )
|
||||
{
|
||||
HALF2 result = saturate(Lightmap1and2Coord.xy) * Lightmap1and2Coord.wz * 0.99;
|
||||
result += Lightmap3Coord;
|
||||
bumpCoord1 = result + HALF2(Lightmap1and2Coord.z, 0);
|
||||
bumpCoord2 = result + 2*HALF2(Lightmap1and2Coord.z, 0);
|
||||
bumpCoord3 = result + 3*HALF2(Lightmap1and2Coord.z, 0);
|
||||
}
|
||||
#else
|
||||
HALF2 ComputeLightmapCoordinates( HALF4 Lightmap1and2Coord, HALF2 Lightmap3Coord )
|
||||
{
|
||||
return Lightmap1and2Coord.xy;
|
||||
}
|
||||
|
||||
void ComputeBumpedLightmapCoordinates( HALF4 Lightmap1and2Coord, HALF2 Lightmap3Coord,
|
||||
out HALF2 bumpCoord1,
|
||||
out HALF2 bumpCoord2,
|
||||
out HALF2 bumpCoord3 )
|
||||
{
|
||||
bumpCoord1 = Lightmap1and2Coord.xy;
|
||||
bumpCoord2 = Lightmap1and2Coord.wz; // reversed order!!!
|
||||
bumpCoord3 = Lightmap3Coord.xy;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Versions of matrix multiply functions which force HLSL compiler to explictly use DOTs,
|
||||
// not giving it the option of using MAD expansion. In a perfect world, the compiler would
|
||||
// always pick the best strategy, and these shouldn't be needed.. but.. well.. umm..
|
||||
//
|
||||
// lorenmcq
|
||||
|
||||
float3 mul3x3(float3 v, float3x3 m)
|
||||
{
|
||||
#if !defined( _X360 )
|
||||
return float3(dot(v, transpose(m)[0]), dot(v, transpose(m)[1]), dot(v, transpose(m)[2]));
|
||||
#else
|
||||
// xbox360 fxc.exe (new back end) borks with transposes, generates bad code
|
||||
return mul( v, m );
|
||||
#endif
|
||||
}
|
||||
|
||||
float3 mul4x3(float4 v, float4x3 m)
|
||||
{
|
||||
#if !defined( _X360 )
|
||||
return float3(dot(v, transpose(m)[0]), dot(v, transpose(m)[1]), dot(v, transpose(m)[2]));
|
||||
#else
|
||||
// xbox360 fxc.exe (new back end) borks with transposes, generates bad code
|
||||
return mul( v, m );
|
||||
#endif
|
||||
}
|
||||
|
||||
float3 DecompressHDR( float4 input )
|
||||
{
|
||||
return input.rgb * input.a * MAX_HDR_OVERBRIGHT;
|
||||
}
|
||||
|
||||
float4 CompressHDR( float3 input )
|
||||
{
|
||||
// FIXME: want to use min so that we clamp to white, but what happens if we
|
||||
// have an albedo component that's less than 1/MAX_HDR_OVERBRIGHT?
|
||||
// float fMax = max( max( color.r, color.g ), color.b );
|
||||
float4 output;
|
||||
float fMax = min( min( input.r, input.g ), input.b );
|
||||
if( fMax > 1.0f )
|
||||
{
|
||||
float oofMax = 1.0f / fMax;
|
||||
output.rgb = oofMax * input.rgb;
|
||||
output.a = min( fMax / MAX_HDR_OVERBRIGHT, 1.0f );
|
||||
}
|
||||
else
|
||||
{
|
||||
output.rgb = input.rgb;
|
||||
output.a = 0.0f;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
float3 LinearToGamma( const float3 f3linear )
|
||||
{
|
||||
return pow( f3linear, 1.0f / 2.2f );
|
||||
}
|
||||
|
||||
float4 LinearToGamma( const float4 f4linear )
|
||||
{
|
||||
return float4( pow( f4linear.xyz, 1.0f / 2.2f ), f4linear.w );
|
||||
}
|
||||
|
||||
float LinearToGamma( const float f1linear )
|
||||
{
|
||||
return pow( f1linear, 1.0f / 2.2f );
|
||||
}
|
||||
|
||||
float3 GammaToLinear( const float3 gamma )
|
||||
{
|
||||
return pow( gamma, 2.2f );
|
||||
}
|
||||
|
||||
float4 GammaToLinear( const float4 gamma )
|
||||
{
|
||||
return float4( pow( gamma.xyz, 2.2f ), gamma.w );
|
||||
}
|
||||
|
||||
float GammaToLinear( const float gamma )
|
||||
{
|
||||
return pow( gamma, 2.2f );
|
||||
}
|
||||
|
||||
// These two functions use the actual sRGB math
|
||||
float SrgbGammaToLinear( float flSrgbGammaValue )
|
||||
{
|
||||
float x = saturate( flSrgbGammaValue );
|
||||
return ( x <= 0.04045f ) ? ( x / 12.92f ) : ( pow( ( x + 0.055f ) / 1.055f, 2.4f ) );
|
||||
}
|
||||
|
||||
float SrgbLinearToGamma( float flLinearValue )
|
||||
{
|
||||
float x = saturate( flLinearValue );
|
||||
return ( x <= 0.0031308f ) ? ( x * 12.92f ) : ( 1.055f * pow( x, ( 1.0f / 2.4f ) ) ) - 0.055f;
|
||||
}
|
||||
|
||||
// These twofunctions use the XBox 360's exact piecewise linear algorithm
|
||||
float X360GammaToLinear( float fl360GammaValue )
|
||||
{
|
||||
float flLinearValue;
|
||||
|
||||
fl360GammaValue = saturate( fl360GammaValue );
|
||||
if ( fl360GammaValue < ( 96.0f / 255.0f ) )
|
||||
{
|
||||
if ( fl360GammaValue < ( 64.0f / 255.0f ) )
|
||||
{
|
||||
flLinearValue = fl360GammaValue * 255.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
flLinearValue = fl360GammaValue * ( 255.0f * 2.0f ) - 64.0f;
|
||||
flLinearValue += floor( flLinearValue * ( 1.0f / 512.0f ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( fl360GammaValue < ( 192.0f / 255.0f ) )
|
||||
{
|
||||
flLinearValue = fl360GammaValue * ( 255.0f * 4.0f ) - 256.0f;
|
||||
flLinearValue += floor( flLinearValue * ( 1.0f / 256.0f ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
flLinearValue = fl360GammaValue * ( 255.0f * 8.0f ) - 1024.0f;
|
||||
flLinearValue += floor( flLinearValue * ( 1.0f / 128.0f ) );
|
||||
}
|
||||
}
|
||||
|
||||
flLinearValue *= 1.0f / 1023.0f;
|
||||
|
||||
flLinearValue = saturate( flLinearValue );
|
||||
return flLinearValue;
|
||||
}
|
||||
|
||||
float X360LinearToGamma( float flLinearValue )
|
||||
{
|
||||
float fl360GammaValue;
|
||||
|
||||
flLinearValue = saturate( flLinearValue );
|
||||
if ( flLinearValue < ( 128.0f / 1023.0f ) )
|
||||
{
|
||||
if ( flLinearValue < ( 64.0f / 1023.0f ) )
|
||||
{
|
||||
fl360GammaValue = flLinearValue * ( 1023.0f * ( 1.0f / 255.0f ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
fl360GammaValue = flLinearValue * ( ( 1023.0f / 2.0f ) * ( 1.0f / 255.0f ) ) + ( 32.0f / 255.0f );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( flLinearValue < ( 512.0f / 1023.0f ) )
|
||||
{
|
||||
fl360GammaValue = flLinearValue * ( ( 1023.0f / 4.0f ) * ( 1.0f / 255.0f ) ) + ( 64.0f / 255.0f );
|
||||
}
|
||||
else
|
||||
{
|
||||
fl360GammaValue = flLinearValue * ( ( 1023.0f /8.0f ) * ( 1.0f / 255.0f ) ) + ( 128.0f /255.0f ); // 1.0 -> 1.0034313725490196078431372549016
|
||||
if ( fl360GammaValue > 1.0f )
|
||||
{
|
||||
fl360GammaValue = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fl360GammaValue = saturate( fl360GammaValue );
|
||||
return fl360GammaValue;
|
||||
}
|
||||
|
||||
float SrgbGammaTo360Gamma( float flSrgbGammaValue )
|
||||
{
|
||||
float flLinearValue = SrgbGammaToLinear( flSrgbGammaValue );
|
||||
float fl360GammaValue = X360LinearToGamma( flLinearValue );
|
||||
return fl360GammaValue;
|
||||
}
|
||||
|
||||
float3 Vec3WorldToTangent( float3 iWorldVector, float3 iWorldNormal, float3 iWorldTangent, float3 iWorldBinormal )
|
||||
{
|
||||
float3 vTangentVector;
|
||||
vTangentVector.x = dot( iWorldVector.xyz, iWorldTangent.xyz );
|
||||
vTangentVector.y = dot( iWorldVector.xyz, iWorldBinormal.xyz );
|
||||
vTangentVector.z = dot( iWorldVector.xyz, iWorldNormal.xyz );
|
||||
return vTangentVector.xyz; // Return without normalizing
|
||||
}
|
||||
|
||||
float3 Vec3WorldToTangentNormalized( float3 iWorldVector, float3 iWorldNormal, float3 iWorldTangent, float3 iWorldBinormal )
|
||||
{
|
||||
return normalize( Vec3WorldToTangent( iWorldVector, iWorldNormal, iWorldTangent, iWorldBinormal ) );
|
||||
}
|
||||
|
||||
float3 Vec3TangentToWorld( float3 iTangentVector, float3 iWorldNormal, float3 iWorldTangent, float3 iWorldBinormal )
|
||||
{
|
||||
float3 vWorldVector;
|
||||
vWorldVector.xyz = iTangentVector.x * iWorldTangent.xyz;
|
||||
vWorldVector.xyz += iTangentVector.y * iWorldBinormal.xyz;
|
||||
vWorldVector.xyz += iTangentVector.z * iWorldNormal.xyz;
|
||||
return vWorldVector.xyz; // Return without normalizing
|
||||
}
|
||||
|
||||
float3 Vec3TangentToWorldNormalized( float3 iTangentVector, float3 iWorldNormal, float3 iWorldTangent, float3 iWorldBinormal )
|
||||
{
|
||||
return normalize( Vec3TangentToWorld( iTangentVector, iWorldNormal, iWorldTangent, iWorldBinormal ) );
|
||||
}
|
||||
|
||||
#endif //#ifndef COMMON_FXC_H_
|
||||
@@ -1,27 +0,0 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#ifndef COMMON_HLSL_CONSTS_H_
|
||||
#define COMMON_HLSL_CONSTS_H_
|
||||
|
||||
#ifdef NV3X
|
||||
#define PSHADER_VECT_SCALE 20.0
|
||||
#define VSHADER_VECT_SCALE (1.0 / (PSHADER_VECT_SCALE) )
|
||||
#else
|
||||
#define PSHADER_VECT_SCALE 1.0
|
||||
#define VSHADER_VECT_SCALE 1.0
|
||||
#endif
|
||||
|
||||
// GR - HDR luminance maps to 0..n range
|
||||
// IMPORTANT: Keep the same value as in materialsystem_global.h
|
||||
// HDRFIXME: Make this a pixel shader constant?
|
||||
#define MAX_HDR_OVERBRIGHT 16.0f
|
||||
|
||||
#define LINEAR_FOG_COLOR 29
|
||||
#define TONE_MAPPING_SCALE_PSH_CONSTANT 30
|
||||
|
||||
#endif //#ifndef COMMON_HLSL_CONSTS_H_
|
||||
@@ -1,201 +0,0 @@
|
||||
|
||||
|
||||
#if defined( _X360 )
|
||||
|
||||
void GetBaseTextureAndNormal( sampler base, sampler base2, sampler bump, bool bBase2, bool bBump, float3 coords, float3 vWeights,
|
||||
out float4 vResultBase, out float4 vResultBase2, out float4 vResultBump )
|
||||
{
|
||||
vResultBase = 0;
|
||||
vResultBase2 = 0;
|
||||
vResultBump = 0;
|
||||
|
||||
if ( !bBump )
|
||||
{
|
||||
vResultBump = float4(0, 0, 1, 1);
|
||||
}
|
||||
|
||||
#if SEAMLESS
|
||||
|
||||
vWeights = max( vWeights - 0.3, 0 );
|
||||
|
||||
vWeights *= 1.0f / dot( vWeights, float3(1,1,1) );
|
||||
|
||||
[branch]
|
||||
if (vWeights.x > 0)
|
||||
{
|
||||
vResultBase += vWeights.x * tex2D( base, coords.zy );
|
||||
|
||||
if ( bBase2 )
|
||||
{
|
||||
vResultBase2 += vWeights.x * tex2D( base2, coords.zy );
|
||||
}
|
||||
|
||||
if ( bBump )
|
||||
{
|
||||
vResultBump += vWeights.x * tex2D( bump, coords.zy );
|
||||
}
|
||||
}
|
||||
|
||||
[branch]
|
||||
if (vWeights.y > 0)
|
||||
{
|
||||
vResultBase += vWeights.y * tex2D( base, coords.xz );
|
||||
|
||||
if ( bBase2 )
|
||||
{
|
||||
vResultBase2 += vWeights.y * tex2D( base2, coords.xz );
|
||||
}
|
||||
if ( bBump )
|
||||
{
|
||||
vResultBump += vWeights.y * tex2D( bump, coords.xz );
|
||||
}
|
||||
}
|
||||
|
||||
[branch]
|
||||
if (vWeights.z > 0)
|
||||
{
|
||||
vResultBase += vWeights.z * tex2D( base, coords.xy );
|
||||
if ( bBase2 )
|
||||
{
|
||||
vResultBase2 += vWeights.z * tex2D( base2, coords.xy );
|
||||
}
|
||||
|
||||
if ( bBump )
|
||||
{
|
||||
vResultBump += vWeights.z * tex2D( bump, coords.xy );
|
||||
}
|
||||
}
|
||||
|
||||
#else // not seamless
|
||||
|
||||
vResultBase = tex2D( base, coords.xy );
|
||||
|
||||
if ( bBase2 )
|
||||
{
|
||||
vResultBase2 = tex2D( base2, coords.xy );
|
||||
}
|
||||
|
||||
if ( bBump )
|
||||
{
|
||||
vResultBump = tex2D( bump, coords.xy );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
#else // PC
|
||||
|
||||
void GetBaseTextureAndNormal( sampler base, sampler base2, sampler bump, bool bBase2, bool bBump, float3 coords, float3 vWeights,
|
||||
out float4 vResultBase, out float4 vResultBase2, out float4 vResultBump )
|
||||
{
|
||||
vResultBase = 0;
|
||||
vResultBase2 = 0;
|
||||
vResultBump = 0;
|
||||
|
||||
if ( !bBump )
|
||||
{
|
||||
vResultBump = float4(0, 0, 1, 1);
|
||||
}
|
||||
|
||||
#if SEAMLESS
|
||||
|
||||
vResultBase += vWeights.x * tex2D( base, coords.zy );
|
||||
if ( bBase2 )
|
||||
{
|
||||
vResultBase2 += vWeights.x * tex2D( base2, coords.zy );
|
||||
}
|
||||
if ( bBump )
|
||||
{
|
||||
vResultBump += vWeights.x * tex2D( bump, coords.zy );
|
||||
}
|
||||
|
||||
vResultBase += vWeights.y * tex2D( base, coords.xz );
|
||||
if ( bBase2 )
|
||||
{
|
||||
vResultBase2 += vWeights.y * tex2D( base2, coords.xz );
|
||||
}
|
||||
if ( bBump )
|
||||
{
|
||||
vResultBump += vWeights.y * tex2D( bump, coords.xz );
|
||||
}
|
||||
|
||||
vResultBase += vWeights.z * tex2D( base, coords.xy );
|
||||
if ( bBase2 )
|
||||
{
|
||||
vResultBase2 += vWeights.z * tex2D( base2, coords.xy );
|
||||
}
|
||||
if ( bBump )
|
||||
{
|
||||
vResultBump += vWeights.z * tex2D( bump, coords.xy );
|
||||
}
|
||||
|
||||
#else // not seamless
|
||||
|
||||
vResultBase = tex2D( base, coords.xy );
|
||||
if ( bBase2 )
|
||||
{
|
||||
vResultBase2 = tex2D( base2, coords.xy );
|
||||
}
|
||||
if ( bBump )
|
||||
{
|
||||
vResultBump = tex2D( bump, coords.xy );
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
float3 LightMapSample( sampler LightmapSampler, float2 vTexCoord )
|
||||
{
|
||||
# if ( !defined( _X360 ) || !defined( USE_32BIT_LIGHTMAPS_ON_360 ) )
|
||||
{
|
||||
float3 sample = tex2D( LightmapSampler, vTexCoord );
|
||||
|
||||
return sample;
|
||||
}
|
||||
# else
|
||||
{
|
||||
# if 0 //1 for cheap sampling, 0 for accurate scaling from the individual samples
|
||||
{
|
||||
float4 sample = tex2D( LightmapSampler, vTexCoord );
|
||||
|
||||
return sample.rgb * sample.a;
|
||||
}
|
||||
# else
|
||||
{
|
||||
float4 Weights;
|
||||
float4 samples_0; //no arrays allowed in inline assembly
|
||||
float4 samples_1;
|
||||
float4 samples_2;
|
||||
float4 samples_3;
|
||||
|
||||
asm {
|
||||
tfetch2D samples_0, vTexCoord.xy, LightmapSampler, OffsetX = -0.5, OffsetY = -0.5, MinFilter=point, MagFilter=point, MipFilter=keep, UseComputedLOD=false
|
||||
tfetch2D samples_1, vTexCoord.xy, LightmapSampler, OffsetX = 0.5, OffsetY = -0.5, MinFilter=point, MagFilter=point, MipFilter=keep, UseComputedLOD=false
|
||||
tfetch2D samples_2, vTexCoord.xy, LightmapSampler, OffsetX = -0.5, OffsetY = 0.5, MinFilter=point, MagFilter=point, MipFilter=keep, UseComputedLOD=false
|
||||
tfetch2D samples_3, vTexCoord.xy, LightmapSampler, OffsetX = 0.5, OffsetY = 0.5, MinFilter=point, MagFilter=point, MipFilter=keep, UseComputedLOD=false
|
||||
|
||||
getWeights2D Weights, vTexCoord.xy, LightmapSampler
|
||||
};
|
||||
|
||||
Weights = float4( (1-Weights.x)*(1-Weights.y), Weights.x*(1-Weights.y), (1-Weights.x)*Weights.y, Weights.x*Weights.y );
|
||||
|
||||
float3 result;
|
||||
result.rgb = samples_0.rgb * (samples_0.a * Weights.x);
|
||||
result.rgb += samples_1.rgb * (samples_1.a * Weights.y);
|
||||
result.rgb += samples_2.rgb * (samples_2.a * Weights.z);
|
||||
result.rgb += samples_3.rgb * (samples_3.a * Weights.w);
|
||||
|
||||
return result;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
@@ -1,247 +0,0 @@
|
||||
#ifndef COMMON_PARALLAX_H
|
||||
#define COMMON_PARALLAX_H
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
void GetWorldSpaceOffset( const bool bDoCalc, float3 wpos, float2 uvdelta,
|
||||
float prlxamt, float scale, out float3 worldSpaceOffset )
|
||||
{
|
||||
if ( bDoCalc )
|
||||
{
|
||||
worldSpaceOffset.xy = uvdelta * scale;
|
||||
worldSpaceOffset.z = prlxamt; // * 0.7f;
|
||||
}
|
||||
else
|
||||
worldSpaceOffset = float3( 0, 0, 0 );
|
||||
}
|
||||
|
||||
float CalcDerivativeScale( const bool bDoCalc, float2 uvddx, float2 uvddy, float3 wpos )
|
||||
{
|
||||
float scale = 1;
|
||||
if ( bDoCalc )
|
||||
scale = max( length( ddx( wpos ) ) / length(uvddx), length( ddy( wpos ) ) / length(uvddy) );
|
||||
return scale;
|
||||
}
|
||||
|
||||
float2 CalcParallaxUV_Relief( float2 inTexCoord, float3 vViewTS, float flParallaxAmt, float3 vNormal,
|
||||
float3 vViewW, sampler HeightMapSampler,
|
||||
const int samples_min, const int samples_max, const int binary_max,
|
||||
float3 WPos, out float3 worldSpaceOffset,
|
||||
const bool bDoGradient, const bool bGetOffset )
|
||||
{
|
||||
float3 p = float3(inTexCoord,1);
|
||||
float3 v = normalize(vViewTS);
|
||||
v.z = abs(v.z);
|
||||
|
||||
float2 dx = ddx( inTexCoord );
|
||||
float2 dy = ddy( inTexCoord );
|
||||
float scale = CalcDerivativeScale( true, dx, dy, WPos );
|
||||
|
||||
flParallaxAmt /= scale;
|
||||
|
||||
float depthBias = 1.0 - v.z;
|
||||
depthBias = 1.0f - pow( depthBias, 10 );
|
||||
|
||||
v.xy *= depthBias * flParallaxAmt;
|
||||
|
||||
int linearSearchSteps = samples_max;
|
||||
if ( bDoGradient )
|
||||
{
|
||||
vViewW = normalize( vViewW );
|
||||
linearSearchSteps = (int) lerp( samples_max, samples_min, dot( vViewW, vNormal ) );
|
||||
}
|
||||
int binarySearchSteps = binary_max;
|
||||
|
||||
v /= v.z * linearSearchSteps;
|
||||
int i;
|
||||
float curh = 0;
|
||||
v.z *= -1.0f;
|
||||
|
||||
if ( !bDoGradient )
|
||||
{
|
||||
for ( i = 0; i < linearSearchSteps; i++ )
|
||||
{
|
||||
curh = tex2D( HeightMapSampler, p.xy ).r;
|
||||
if ( curh < p.z )
|
||||
p += v;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool bCondition = true;
|
||||
int nStepIndex = 0;
|
||||
while ( bCondition == true && nStepIndex < linearSearchSteps )
|
||||
{
|
||||
curh = tex2Dgrad( HeightMapSampler, p.xy, dx, dy ).r;
|
||||
if ( curh > p.z )
|
||||
bCondition = false;
|
||||
else
|
||||
{
|
||||
p += v;
|
||||
nStepIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( i = 0; i < binarySearchSteps; i++ )
|
||||
{
|
||||
v *= 0.5f;
|
||||
float tex = tex2D(HeightMapSampler, p.xy).r;
|
||||
if (p.z > tex)
|
||||
p += v;
|
||||
else
|
||||
p -= v;
|
||||
}
|
||||
|
||||
GetWorldSpaceOffset( bGetOffset, WPos, (inTexCoord-p.xy),
|
||||
(1.0f-p.z), scale, worldSpaceOffset );
|
||||
return p.xy;
|
||||
}
|
||||
|
||||
|
||||
//===================================================================================//
|
||||
// This is based on Natasha Tatarchuk's Parallax Occlusion Mapping (ATI)
|
||||
//===================================================================================//
|
||||
// INPUT:
|
||||
// inTexCoord:
|
||||
// the texcoord for the height/displacement map before parallaxing
|
||||
//
|
||||
// vParallax:
|
||||
// Compute initial parallax displacement direction:
|
||||
// float2 vParallaxDirection = normalize( vViewTS.xy );
|
||||
// float fLength = length( vViewTS );
|
||||
// float fParallaxLength = sqrt( fLength * fLength - vViewTS.z * vViewTS.z ) / vViewTS.z;
|
||||
// Out.vParallax = vParallaxDirection * fParallaxLength * fProjectedBumpHeight;
|
||||
//
|
||||
// vNormal:
|
||||
// tangent space normal
|
||||
//
|
||||
// vViewW:
|
||||
// float3 vViewW = /*normalize*/(mul( matViewInverse, float4( 0, 0, 0, 1)) - inPosition );
|
||||
//
|
||||
// OUTPUT:
|
||||
// the new texcoord after parallaxing
|
||||
|
||||
float2 CalcParallaxUV_POM( float2 inTexCoord, float3 vViewTS, float flParallaxAmt, float3 vNormal,
|
||||
float3 vViewW, sampler HeightMapSampler,
|
||||
const int samples_min, const int samples_max, const int binary_max,
|
||||
float3 WPos, out float3 worldSpaceOffset,
|
||||
const bool bDoGradient, const bool bGetOffset )
|
||||
{
|
||||
float2 dx = ddx( inTexCoord );
|
||||
float2 dy = ddy( inTexCoord );
|
||||
|
||||
float scale = CalcDerivativeScale( true, dx, dy, WPos );
|
||||
flParallaxAmt /= scale;
|
||||
|
||||
float2 vParallax = normalize( vViewTS.xy );
|
||||
float fLength = length( vViewTS );
|
||||
float fParallaxLength = sqrt( fLength * fLength - vViewTS.z * vViewTS.z ) / vViewTS.z;
|
||||
vParallax *= fParallaxLength * flParallaxAmt;
|
||||
|
||||
vViewW = normalize( vViewW );
|
||||
|
||||
//===============================================//
|
||||
// Parallax occlusion mapping offset computation //
|
||||
//===============================================//
|
||||
int nNumSteps = (int) lerp( samples_max, samples_min, dot( vViewW, vNormal ) );
|
||||
|
||||
float fCurrHeight = 0.0;
|
||||
float fStepSize = 1.0 / (float) nNumSteps;
|
||||
float fPrevHeight = 1.0;
|
||||
float fNextHeight = 0.0;
|
||||
|
||||
int nStepIndex = 0;
|
||||
|
||||
float2 vTexOffsetPerStep = fStepSize * vParallax;
|
||||
|
||||
float2 vTexCurrentOffset = inTexCoord;
|
||||
float fCurrentBound = 1.0;
|
||||
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float xh = 0;
|
||||
float yh = 0;
|
||||
|
||||
float2 texOffset2 = 0;
|
||||
|
||||
bool bCondition = true;
|
||||
while ( bCondition == true && nStepIndex < nNumSteps )
|
||||
{
|
||||
vTexCurrentOffset -= vTexOffsetPerStep;
|
||||
|
||||
fCurrHeight = tex2Dgrad( HeightMapSampler, vTexCurrentOffset, dx, dy ).r;
|
||||
|
||||
fCurrentBound -= fStepSize;
|
||||
|
||||
if ( fCurrHeight > fCurrentBound )
|
||||
{
|
||||
x = fCurrentBound;
|
||||
y = fCurrentBound + fStepSize;
|
||||
xh = fCurrHeight;
|
||||
yh = fPrevHeight;
|
||||
|
||||
texOffset2 = vTexCurrentOffset - vTexOffsetPerStep;
|
||||
|
||||
bCondition = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
nStepIndex++;
|
||||
fPrevHeight = fCurrHeight;
|
||||
}
|
||||
|
||||
} // End of while ( bCondition == true && nStepIndex > -1 )#else
|
||||
//fCurrentBound -= fStepSize;
|
||||
|
||||
float fParallaxAmount;
|
||||
float numerator = (x * (y - yh) - y * (x - xh));
|
||||
float denomenator = ((y - yh) - (x - xh));
|
||||
// avoid NaN generation
|
||||
if( ( numerator == 0.0f ) && ( denomenator == 0.0f ) )
|
||||
{
|
||||
fParallaxAmount = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
fParallaxAmount = numerator / denomenator;
|
||||
}
|
||||
|
||||
fParallaxAmount = 1.0f - fParallaxAmount;
|
||||
float2 vParallaxOffset = vParallax * fParallaxAmount;
|
||||
float2 texSampleBase = inTexCoord - vParallaxOffset;
|
||||
|
||||
vParallaxOffset = clamp( vParallaxOffset, -1, 1 );
|
||||
|
||||
GetWorldSpaceOffset( bGetOffset, WPos, vParallaxOffset,
|
||||
fParallaxAmount, scale, worldSpaceOffset );
|
||||
|
||||
return texSampleBase;
|
||||
}
|
||||
float CalcParallaxedShadows_OneLight( float2 UV, float2 UV_prlx, float3 vecLightTS, float3 WPos, float flParallaxAmt, float flSoftening, sampler Heightmap )
|
||||
{
|
||||
float scale = CalcDerivativeScale( true, ddx( UV ), ddy( UV ), WPos );
|
||||
flParallaxAmt /= scale;
|
||||
|
||||
float2 inXY = vecLightTS.xy * flParallaxAmt;
|
||||
|
||||
float sh0 = tex2D( Heightmap, UV_prlx).r;
|
||||
float shA = (tex2D( Heightmap, UV_prlx + inXY * 0.88 ).r - sh0 - 0.88 ) * 1 * flSoftening;
|
||||
float sh9 = (tex2D( Heightmap, UV_prlx + inXY * 0.77 ).r - sh0 - 0.77 ) * 2 * flSoftening;
|
||||
float sh8 = (tex2D( Heightmap, UV_prlx + inXY * 0.66 ).r - sh0 - 0.66 ) * 4 * flSoftening;
|
||||
float sh7 = (tex2D( Heightmap, UV_prlx + inXY * 0.55 ).r - sh0 - 0.55 ) * 6 * flSoftening;
|
||||
float sh6 = (tex2D( Heightmap, UV_prlx + inXY * 0.44 ).r - sh0 - 0.44 ) * 8 * flSoftening;
|
||||
float sh5 = (tex2D( Heightmap, UV_prlx + inXY * 0.33 ).r - sh0 - 0.33 ) * 10 * flSoftening;
|
||||
float sh4 = (tex2D( Heightmap, UV_prlx + inXY * 0.22 ).r - sh0 - 0.22 ) * 12 * flSoftening;
|
||||
|
||||
float fShadow = 1.0f - max( max( max( max( max( max( shA, sh9 ), sh8 ), sh7 ), sh6 ), sh5 ), sh4 );
|
||||
return saturate( fShadow );
|
||||
}
|
||||
float CalcParallaxedShadows( float2 UV, float3 WPos, float flParallaxAmt, float flSoftening, sampler Heightmap )
|
||||
{
|
||||
return 1;
|
||||
//float3 vecLightTS = float3( 0, 0.7f, 0 );
|
||||
//return CalcParallaxedShadows_OneLight( UV, vecLightTS, WPos, flParallaxAmt, flSoftening, Heightmap );
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,38 +0,0 @@
|
||||
//========= Copyright <20> 1996-2007, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Common shader compiler pragmas
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#ifndef COMMON_PRAGMAS_H_
|
||||
#define COMMON_PRAGMAS_H_
|
||||
|
||||
//
|
||||
// Validated shader models:
|
||||
//
|
||||
// SHADER_MODEL_VS_1_1
|
||||
// SHADER_MODEL_VS_2_0
|
||||
// SHADER_MODEL_VS_3_0
|
||||
//
|
||||
// SHADER_MODEL_PS_1_1
|
||||
// SHADER_MODEL_PS_1_4
|
||||
// SHADER_MODEL_PS_2_0
|
||||
// SHADER_MODEL_PS_2_B
|
||||
// SHADER_MODEL_PS_3_0
|
||||
//
|
||||
//
|
||||
//
|
||||
// Platforms:
|
||||
//
|
||||
// PC
|
||||
// _X360
|
||||
//
|
||||
|
||||
// Special pragmas silencing common warnings
|
||||
#pragma warning ( disable : 3557 ) // warning X3557: Loop only executes for N iteration(s), forcing loop to unroll
|
||||
#pragma warning ( disable : 3595 ) // warning X3595: Microcode Compiler possible performance issue: pixel shader input semantic ___ is unused
|
||||
#pragma warning ( disable : 3596 ) // warning X3596: Microcode Compiler possible performance issue: pixel shader input semantic ___ is unused
|
||||
#pragma warning ( disable : 4702 ) // warning X4702: complement opportunity missed because input result WAS clamped from 0 to 1
|
||||
|
||||
#endif //#ifndef COMMON_PRAGMAS_H_
|
||||
@@ -1,664 +0,0 @@
|
||||
//====== Copyright <20> 1996-2007, Valve Corporation, All rights reserved. =======//
|
||||
//
|
||||
// Purpose: Common pixel shader code
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#ifndef COMMON_PS_FXC_H_
|
||||
#define COMMON_PS_FXC_H_
|
||||
|
||||
#include "common_fxc.h"
|
||||
|
||||
// Put global skip commands here. . make sure and check that the appropriate vars are defined
|
||||
// so these aren't used on the wrong shaders!
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// HDR should never be enabled if we don't aren't running in float or integer HDR mode.
|
||||
// SKIP: defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED
|
||||
// --------------------------------------------------------------------------------
|
||||
// We don't ever write water fog to dest alpha if we aren't doing water fog.
|
||||
// SKIP: defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA
|
||||
// --------------------------------------------------------------------------------
|
||||
// We don't need fog in the pixel shader if we aren't in float fog mode2
|
||||
// NOSKIP: defined $HDRTYPE && defined $HDRENABLED && defined $PIXELFOGTYPE && $HDRTYPE != HDR_TYPE_FLOAT && $FOGTYPE != 0
|
||||
// --------------------------------------------------------------------------------
|
||||
// We don't do HDR and LIGHTING_PREVIEW at the same time since it's running LDR in hammer.
|
||||
// SKIP: defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0
|
||||
// --------------------------------------------------------------------------------
|
||||
// Ditch all fastpath attempts if we are doing LIGHTING_PREVIEW.
|
||||
// SKIP: defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT
|
||||
// SKIP: defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST
|
||||
// SKIP: defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH
|
||||
// --------------------------------------------------------------------------------
|
||||
// Ditch flashlight depth when flashlight is disabled
|
||||
// SKIP: ($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
// System defined pixel shader constants
|
||||
|
||||
#if defined( _X360 )
|
||||
const bool g_bHighQualityShadows : register( b0 );
|
||||
#endif
|
||||
|
||||
// NOTE: w == 1.0f / (Dest alpha compressed depth range).
|
||||
const float4 g_LinearFogColor : register( c29 );
|
||||
|
||||
#define OO_DESTALPHA_DEPTH_RANGE (g_LinearFogColor.w)
|
||||
|
||||
// Linear and gamma light scale values
|
||||
const float4 cLightScale : register( c30 );
|
||||
#define LINEAR_LIGHT_SCALE (cLightScale.x)
|
||||
#define LIGHT_MAP_SCALE (cLightScale.y)
|
||||
#define ENV_MAP_SCALE (cLightScale.z)
|
||||
#define GAMMA_LIGHT_SCALE (cLightScale.w)
|
||||
|
||||
// Flashlight constants
|
||||
#if defined(SHADER_MODEL_PS_2_0) || defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0)
|
||||
const float4 cFlashlightColor : register( c10 ); //register( c28 );
|
||||
const float4 cFlashlightScreenScale : register( c11 ); //register( c31 ); // .zw are currently unused
|
||||
#define flFlashlightNoLambertValue cFlashlightColor.w // This is either 0.0 or 2.0
|
||||
#endif
|
||||
|
||||
#define HDR_INPUT_MAP_SCALE 16.0f
|
||||
|
||||
#define TONEMAP_SCALE_NONE 0
|
||||
#define TONEMAP_SCALE_LINEAR 1
|
||||
#define TONEMAP_SCALE_GAMMA 2
|
||||
|
||||
#define PIXEL_FOG_TYPE_NONE -1 //MATERIAL_FOG_NONE is handled by PIXEL_FOG_TYPE_RANGE, this is for explicitly disabling fog in the shader
|
||||
#define PIXEL_FOG_TYPE_RANGE 0 //range+none packed together in ps2b. Simply none in ps20 (instruction limits)
|
||||
#define PIXEL_FOG_TYPE_HEIGHT 1
|
||||
|
||||
// If you change these, make the corresponding change in hardwareconfig.cpp
|
||||
#define NVIDIA_PCF_POISSON 0
|
||||
#define ATI_NOPCF 1
|
||||
#define ATI_NO_PCF_FETCH4 2
|
||||
|
||||
struct LPREVIEW_PS_OUT
|
||||
{
|
||||
float4 color : COLOR0;
|
||||
float4 normal : COLOR1;
|
||||
float4 position : COLOR2;
|
||||
float4 flags : COLOR3;
|
||||
};
|
||||
|
||||
/*
|
||||
// unused
|
||||
HALF Luminance( HALF3 color )
|
||||
{
|
||||
return dot( color, HALF3( HALF_CONSTANT(0.30f), HALF_CONSTANT(0.59f), HALF_CONSTANT(0.11f) ) );
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
// unused
|
||||
HALF LuminanceScaled( HALF3 color )
|
||||
{
|
||||
return dot( color, HALF3( HALF_CONSTANT(0.30f) / MAX_HDR_OVERBRIGHT, HALF_CONSTANT(0.59f) / MAX_HDR_OVERBRIGHT, HALF_CONSTANT(0.11f) / MAX_HDR_OVERBRIGHT ) );
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
// unused
|
||||
HALF AvgColor( HALF3 color )
|
||||
{
|
||||
return dot( color, HALF3( HALF_CONSTANT(0.33333f), HALF_CONSTANT(0.33333f), HALF_CONSTANT(0.33333f) ) );
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
// unused
|
||||
HALF4 DiffuseBump( sampler lightmapSampler,
|
||||
float2 lightmapTexCoord1,
|
||||
float2 lightmapTexCoord2,
|
||||
float2 lightmapTexCoord3,
|
||||
HALF3 normal )
|
||||
{
|
||||
HALF3 lightmapColor1 = tex2D( lightmapSampler, lightmapTexCoord1 );
|
||||
HALF3 lightmapColor2 = tex2D( lightmapSampler, lightmapTexCoord2 );
|
||||
HALF3 lightmapColor3 = tex2D( lightmapSampler, lightmapTexCoord3 );
|
||||
|
||||
HALF3 diffuseLighting;
|
||||
diffuseLighting = saturate( dot( normal, bumpBasis[0] ) ) * lightmapColor1 +
|
||||
saturate( dot( normal, bumpBasis[1] ) ) * lightmapColor2 +
|
||||
saturate( dot( normal, bumpBasis[2] ) ) * lightmapColor3;
|
||||
|
||||
return HALF4( diffuseLighting, LuminanceScaled( diffuseLighting ) );
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
// unused
|
||||
HALF Fresnel( HALF3 normal,
|
||||
HALF3 eye,
|
||||
HALF2 scaleBias )
|
||||
{
|
||||
HALF fresnel = HALF_CONSTANT(1.0f) - dot( normal, eye );
|
||||
fresnel = pow( fresnel, HALF_CONSTANT(5.0f) );
|
||||
|
||||
return fresnel * scaleBias.x + scaleBias.y;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
// unused
|
||||
HALF4 GetNormal( sampler normalSampler,
|
||||
float2 normalTexCoord )
|
||||
{
|
||||
HALF4 normal = tex2D( normalSampler, normalTexCoord );
|
||||
normal.rgb = HALF_CONSTANT(2.0f) * normal.rgb - HALF_CONSTANT(1.0f);
|
||||
|
||||
return normal;
|
||||
}
|
||||
*/
|
||||
|
||||
// Needs to match NormalDecodeMode_t enum in imaterialsystem.h
|
||||
#define NORM_DECODE_NONE 0
|
||||
#define NORM_DECODE_ATI2N 1
|
||||
#define NORM_DECODE_ATI2N_ALPHA 2
|
||||
|
||||
float4 DecompressNormal( sampler NormalSampler, float2 tc, int nDecompressionMode, sampler AlphaSampler )
|
||||
{
|
||||
float4 normalTexel = tex2D( NormalSampler, tc );
|
||||
float4 result;
|
||||
|
||||
if ( nDecompressionMode == NORM_DECODE_NONE )
|
||||
{
|
||||
result = float4(normalTexel.xyz * 2.0f - 1.0f, normalTexel.a );
|
||||
}
|
||||
else if ( nDecompressionMode == NORM_DECODE_ATI2N )
|
||||
{
|
||||
result.xy = normalTexel.xy * 2.0f - 1.0f;
|
||||
result.z = sqrt( 1.0f - dot(result.xy, result.xy) );
|
||||
result.a = 1.0f;
|
||||
}
|
||||
else // ATI2N plus ATI1N for alpha
|
||||
{
|
||||
result.xy = normalTexel.xy * 2.0f - 1.0f;
|
||||
result.z = sqrt( 1.0f - dot(result.xy, result.xy) );
|
||||
result.a = tex2D( AlphaSampler, tc ).x; // Note that this comes in on the X channel
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
float4 DecompressNormal( sampler NormalSampler, float2 tc, int nDecompressionMode )
|
||||
{
|
||||
return DecompressNormal( NormalSampler, tc, nDecompressionMode, NormalSampler );
|
||||
}
|
||||
|
||||
|
||||
HALF3 NormalizeWithCubemap( sampler normalizeSampler, HALF3 input )
|
||||
{
|
||||
// return texCUBE( normalizeSampler, input ) * 2.0f - 1.0f;
|
||||
return texCUBE( normalizeSampler, input );
|
||||
}
|
||||
|
||||
/*
|
||||
HALF4 EnvReflect( sampler envmapSampler,
|
||||
sampler normalizeSampler,
|
||||
HALF3 normal,
|
||||
float3 eye,
|
||||
HALF2 fresnelScaleBias )
|
||||
{
|
||||
HALF3 normEye = NormalizeWithCubemap( normalizeSampler, eye );
|
||||
HALF fresnel = Fresnel( normal, normEye, fresnelScaleBias );
|
||||
HALF3 reflect = CalcReflectionVectorUnnormalized( normal, eye );
|
||||
return texCUBE( envmapSampler, reflect );
|
||||
}
|
||||
*/
|
||||
|
||||
float CalcWaterFogAlpha( const float flWaterZ, const float flEyePosZ, const float flWorldPosZ, const float flProjPosZ, const float flFogOORange )
|
||||
{
|
||||
// float flDepthFromWater = flWaterZ - flWorldPosZ + 2.0f; // hackity hack . .this is for the DF_FUDGE_UP in view_scene.cpp
|
||||
float flDepthFromWater = flWaterZ - flWorldPosZ;
|
||||
|
||||
// if flDepthFromWater < 0, then set it to 0
|
||||
// This is the equivalent of moving the vert to the water surface if it's above the water surface
|
||||
// We'll do this with the saturate at the end instead.
|
||||
// flDepthFromWater = max( 0.0f, flDepthFromWater );
|
||||
|
||||
// Calculate the ratio of water fog to regular fog (ie. how much of the distance from the viewer
|
||||
// to the vert is actually underwater.
|
||||
float flDepthFromEye = flEyePosZ - flWorldPosZ;
|
||||
float f = (flDepthFromWater / flDepthFromEye) * flProjPosZ;
|
||||
|
||||
// $tmp.w is now the distance that we see through water.
|
||||
return saturate( f * flFogOORange );
|
||||
}
|
||||
|
||||
#if defined(SHADER_EDITOR_SWARM_COMPILE)
|
||||
float CalcRangeFog( const float3 flEyePos, const float3 flWorldPos, const float flFogEndOverRange, const float flFogMaxDensity, const float flFogOORange )
|
||||
#else
|
||||
float CalcRangeFog( const float flProjPosZ, const float flFogEndOverRange, const float flFogMaxDensity, const float flFogOORange )
|
||||
#endif // SHADER_EDITOR_SWARM_COMPILE
|
||||
{
|
||||
#if defined(SHADER_EDITOR_SWARM_COMPILE)
|
||||
return min( flFogMaxDensity, saturate( flFogEndOverRange + ( distance( flEyePos, flWorldPos ) * flFogOORange ) ) );
|
||||
#elif defined(SHADER_EDITOR_2013_COMPILE)
|
||||
return min( flFogMaxDensity, ( saturate( flProjPosZ * flFogOORange - flFogEndOverRange ) ) );
|
||||
#else
|
||||
#if !(defined(SHADER_MODEL_PS_1_1) || defined(SHADER_MODEL_PS_1_4) || defined(SHADER_MODEL_PS_2_0)) //Minimum requirement of ps2b
|
||||
return min( flFogMaxDensity, ( saturate( 1.0 - (flFogEndOverRange - (flProjPosZ * flFogOORange)) ) ) );
|
||||
#else
|
||||
return 0.0f; //ps20 shaders will never have range fog enabled because too many ran out of slots.
|
||||
#endif
|
||||
#endif // SHADER_EDITOR_SWARM_COMPILE
|
||||
}
|
||||
|
||||
#if defined(SHADER_EDITOR_SWARM_COMPILE)
|
||||
float CalcPixelFogFactor( int iPIXELFOGTYPE, const float4 fogParams, const float3 flEyePos, const float3 flWorldPos )
|
||||
#else
|
||||
float CalcPixelFogFactor( int iPIXELFOGTYPE, const float4 fogParams, const float flEyePosZ, const float flWorldPosZ, const float flProjPosZ )
|
||||
#endif // SHADER_EDITOR_SWARM_COMPILE
|
||||
{
|
||||
float retVal;
|
||||
if ( iPIXELFOGTYPE == PIXEL_FOG_TYPE_NONE )
|
||||
{
|
||||
retVal = 0.0f;
|
||||
}
|
||||
if ( iPIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE ) //range fog, or no fog depending on fog parameters
|
||||
{
|
||||
#if defined(SHADER_EDITOR_SWARM_COMPILE)
|
||||
retVal = CalcRangeFog( flEyePos, flWorldPos, fogParams.x, fogParams.z, fogParams.w );
|
||||
#else
|
||||
retVal = CalcRangeFog( flProjPosZ, fogParams.x, fogParams.z, fogParams.w );
|
||||
#endif // SHADER_EDITOR_SWARM_COMPILE
|
||||
}
|
||||
else if ( iPIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT ) //height fog
|
||||
{
|
||||
#if defined(SHADER_EDITOR_SWARM_COMPILE)
|
||||
retVal = 0.0f;
|
||||
#else
|
||||
retVal = CalcWaterFogAlpha( fogParams.y, flEyePosZ, flWorldPosZ, flProjPosZ, fogParams.w );
|
||||
#endif // SHADER_EDITOR_SWARM_COMPILE
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//g_FogParams not defined by default, but this is the same layout for every shader that does define it
|
||||
#define g_FogEndOverRange g_FogParams.x
|
||||
#define g_WaterZ g_FogParams.y
|
||||
#define g_FogMaxDensity g_FogParams.z
|
||||
#define g_FogOORange g_FogParams.w
|
||||
|
||||
float3 BlendPixelFog( const float3 vShaderColor, float pixelFogFactor, const float3 vFogColor, const int iPIXELFOGTYPE )
|
||||
{
|
||||
if( iPIXELFOGTYPE == PIXEL_FOG_TYPE_RANGE ) //either range fog or no fog depending on fog parameters and whether this is ps20 or ps2b
|
||||
{
|
||||
# if !(defined(SHADER_MODEL_PS_1_1) || defined(SHADER_MODEL_PS_1_4) || defined(SHADER_MODEL_PS_2_0)) //Minimum requirement of ps2b
|
||||
pixelFogFactor = saturate( pixelFogFactor );
|
||||
return lerp( vShaderColor.rgb, vFogColor.rgb, pixelFogFactor * pixelFogFactor ); //squaring the factor will get the middle range mixing closer to hardware fog
|
||||
# else
|
||||
return vShaderColor;
|
||||
# endif
|
||||
}
|
||||
else if( iPIXELFOGTYPE == PIXEL_FOG_TYPE_HEIGHT )
|
||||
{
|
||||
return lerp( vShaderColor.rgb, vFogColor.rgb, saturate( pixelFogFactor ) );
|
||||
}
|
||||
else if( iPIXELFOGTYPE == PIXEL_FOG_TYPE_NONE )
|
||||
{
|
||||
return vShaderColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if ((defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0)) && ( CONVERT_TO_SRGB != 0 ) )
|
||||
sampler1D GammaTableSampler : register( s15 );
|
||||
|
||||
float3 SRGBOutput( const float3 vShaderColor )
|
||||
{
|
||||
//On ps2b capable hardware we always have the linear->gamma conversion table texture in sampler s15.
|
||||
float3 result;
|
||||
result.r = tex1D( GammaTableSampler, vShaderColor.r ).r;
|
||||
result.g = tex1D( GammaTableSampler, vShaderColor.g ).r;
|
||||
result.b = tex1D( GammaTableSampler, vShaderColor.b ).r;
|
||||
return result;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
float3 SRGBOutput( const float3 vShaderColor )
|
||||
{
|
||||
return vShaderColor; //ps 1.1, 1.4, and 2.0 never do srgb conversion in the pixel shader
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
float SoftParticleDepth( float flDepth )
|
||||
{
|
||||
return flDepth * OO_DESTALPHA_DEPTH_RANGE;
|
||||
}
|
||||
|
||||
|
||||
float DepthToDestAlpha( const float flProjZ )
|
||||
{
|
||||
#if !(defined(SHADER_MODEL_PS_1_1) || defined(SHADER_MODEL_PS_1_4) || defined(SHADER_MODEL_PS_2_0)) //Minimum requirement of ps2b
|
||||
return SoftParticleDepth( flProjZ );
|
||||
#else
|
||||
return 1.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
float4 FinalOutput( const float4 vShaderColor, float pixelFogFactor, const int iPIXELFOGTYPE, const int iTONEMAP_SCALE_TYPE, const bool bWriteDepthToDestAlpha = false, const float flProjZ = 1.0f )
|
||||
{
|
||||
float4 result;
|
||||
if( iTONEMAP_SCALE_TYPE == TONEMAP_SCALE_LINEAR )
|
||||
{
|
||||
result.rgb = vShaderColor.rgb * LINEAR_LIGHT_SCALE;
|
||||
}
|
||||
else if( iTONEMAP_SCALE_TYPE == TONEMAP_SCALE_GAMMA )
|
||||
{
|
||||
result.rgb = vShaderColor.rgb * GAMMA_LIGHT_SCALE;
|
||||
}
|
||||
else if( iTONEMAP_SCALE_TYPE == TONEMAP_SCALE_NONE )
|
||||
{
|
||||
result.rgb = vShaderColor.rgb;
|
||||
}
|
||||
|
||||
if( bWriteDepthToDestAlpha )
|
||||
#if ( WRITEWATERFOGTODESTALPHA == 1 )
|
||||
result.a = pixelFogFactor;
|
||||
#else
|
||||
result.a = DepthToDestAlpha( flProjZ );
|
||||
#endif
|
||||
else
|
||||
result.a = vShaderColor.a;
|
||||
|
||||
result.rgb = BlendPixelFog( result.rgb, pixelFogFactor, g_LinearFogColor.rgb, iPIXELFOGTYPE );
|
||||
|
||||
#if !(defined(SHADER_EDITOR_SWARM_COMPILE))
|
||||
|
||||
#if !(defined(SHADER_MODEL_PS_1_1) || defined(SHADER_MODEL_PS_1_4) || defined(SHADER_MODEL_PS_2_0)) //Minimum requirement of ps2b
|
||||
result.rgb = SRGBOutput( result.rgb ); //SRGB in pixel shader conversion
|
||||
#endif
|
||||
|
||||
#endif // SHADER_EDITOR_SWARM_COMPILE
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LPREVIEW_PS_OUT FinalOutput( const LPREVIEW_PS_OUT vShaderColor, float pixelFogFactor, const int iPIXELFOGTYPE, const int iTONEMAP_SCALE_TYPE )
|
||||
{
|
||||
LPREVIEW_PS_OUT result;
|
||||
result.color = FinalOutput( vShaderColor.color, pixelFogFactor, iPIXELFOGTYPE, iTONEMAP_SCALE_TYPE );
|
||||
result.normal.rgb = SRGBOutput( vShaderColor.normal.rgb );
|
||||
result.normal.a = vShaderColor.normal.a;
|
||||
|
||||
result.position.rgb = SRGBOutput( vShaderColor.position.rgb );
|
||||
result.position.a = vShaderColor.position.a;
|
||||
|
||||
result.flags.rgb = SRGBOutput( vShaderColor.flags.rgb );
|
||||
result.flags.a = vShaderColor.flags.a;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float RemapValClamped( float val, float A, float B, float C, float D)
|
||||
{
|
||||
float cVal = (val - A) / (B - A);
|
||||
cVal = saturate( cVal );
|
||||
|
||||
return C + (D - C) * cVal;
|
||||
}
|
||||
|
||||
//======================================//
|
||||
// HSL Color space conversion routines //
|
||||
//======================================//
|
||||
|
||||
#define HUE 0
|
||||
#define SATURATION 1
|
||||
#define LIGHTNESS 2
|
||||
|
||||
// Convert from RGB to HSL color space
|
||||
float4 RGBtoHSL( float4 inColor )
|
||||
{
|
||||
float h, s;
|
||||
float flMax = max( inColor.r, max( inColor.g, inColor.b ) );
|
||||
float flMin = min( inColor.r, min( inColor.g, inColor.b ) );
|
||||
|
||||
float l = (flMax + flMin) / 2.0f;
|
||||
|
||||
if (flMax == flMin) // achromatic case
|
||||
{
|
||||
s = h = 0;
|
||||
}
|
||||
else // chromatic case
|
||||
{
|
||||
// Next, calculate the hue
|
||||
float delta = flMax - flMin;
|
||||
|
||||
// First, calculate the saturation
|
||||
if (l < 0.5f) // If we're in the lower hexcone
|
||||
{
|
||||
s = delta/(flMax + flMin);
|
||||
}
|
||||
else
|
||||
{
|
||||
s = delta/(2 - flMax - flMin);
|
||||
}
|
||||
|
||||
if ( inColor.r == flMax )
|
||||
{
|
||||
h = (inColor.g - inColor.b)/delta; // color between yellow and magenta
|
||||
}
|
||||
else if ( inColor.g == flMax )
|
||||
{
|
||||
h = 2 + (inColor.b - inColor.r)/delta; // color between cyan and yellow
|
||||
}
|
||||
else // blue must be max
|
||||
{
|
||||
h = 4 + (inColor.r - inColor.g)/delta; // color between magenta and cyan
|
||||
}
|
||||
|
||||
h *= 60.0f;
|
||||
|
||||
if (h < 0.0f)
|
||||
{
|
||||
h += 360.0f;
|
||||
}
|
||||
|
||||
h /= 360.0f;
|
||||
}
|
||||
|
||||
return float4 (h, s, l, 1.0f);
|
||||
}
|
||||
|
||||
float HueToRGB( float v1, float v2, float vH )
|
||||
{
|
||||
float fResult = v1;
|
||||
|
||||
vH = fmod (vH + 1.0f, 1.0f);
|
||||
|
||||
if ( ( 6.0f * vH ) < 1.0f )
|
||||
{
|
||||
fResult = ( v1 + ( v2 - v1 ) * 6.0f * vH );
|
||||
}
|
||||
else if ( ( 2.0f * vH ) < 1.0f )
|
||||
{
|
||||
fResult = ( v2 );
|
||||
}
|
||||
else if ( ( 3.0f * vH ) < 2.0f )
|
||||
{
|
||||
fResult = ( v1 + ( v2 - v1 ) * ( ( 2.0f / 3.0f ) - vH ) * 6.0f );
|
||||
}
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
// Convert from HSL to RGB color space
|
||||
float4 HSLtoRGB( float4 hsl )
|
||||
{
|
||||
float r, g, b;
|
||||
float h = hsl[HUE];
|
||||
float s = hsl[SATURATION];
|
||||
float l = hsl[LIGHTNESS];
|
||||
|
||||
if ( s == 0 )
|
||||
{
|
||||
r = g = b = l;
|
||||
}
|
||||
else
|
||||
{
|
||||
float v1, v2;
|
||||
|
||||
if ( l < 0.5f )
|
||||
v2 = l * ( 1.0f + s );
|
||||
else
|
||||
v2 = ( l + s ) - ( s * l );
|
||||
|
||||
v1 = 2 * l - v2;
|
||||
|
||||
r = HueToRGB( v1, v2, h + ( 1.0f / 3.0f ) );
|
||||
g = HueToRGB( v1, v2, h );
|
||||
b = HueToRGB( v1, v2, h - ( 1.0f / 3.0f ) );
|
||||
}
|
||||
|
||||
return float4( r, g, b, 1.0f );
|
||||
}
|
||||
|
||||
|
||||
// texture combining modes for combining base and detail/basetexture2
|
||||
#define TCOMBINE_RGB_EQUALS_BASE_x_DETAILx2 0 // original mode
|
||||
#define TCOMBINE_RGB_ADDITIVE 1 // base.rgb+detail.rgb*fblend
|
||||
#define TCOMBINE_DETAIL_OVER_BASE 2
|
||||
#define TCOMBINE_FADE 3 // straight fade between base and detail.
|
||||
#define TCOMBINE_BASE_OVER_DETAIL 4 // use base alpha for blend over detail
|
||||
#define TCOMBINE_RGB_ADDITIVE_SELFILLUM 5 // add detail color post lighting
|
||||
#define TCOMBINE_RGB_ADDITIVE_SELFILLUM_THRESHOLD_FADE 6
|
||||
#define TCOMBINE_MOD2X_SELECT_TWO_PATTERNS 7 // use alpha channel of base to select between mod2x channels in r+a of detail
|
||||
#define TCOMBINE_MULTIPLY 8
|
||||
#define TCOMBINE_MASK_BASE_BY_DETAIL_ALPHA 9 // use alpha channel of detail to mask base
|
||||
#define TCOMBINE_SSBUMP_BUMP 10 // use detail to modulate lighting as an ssbump
|
||||
#define TCOMBINE_SSBUMP_NOBUMP 11 // detail is an ssbump but use it as an albedo. shader does the magic here - no user needs to specify mode 11
|
||||
|
||||
float4 TextureCombine( float4 baseColor, float4 detailColor, int combine_mode,
|
||||
float fBlendFactor )
|
||||
{
|
||||
if ( combine_mode == TCOMBINE_MOD2X_SELECT_TWO_PATTERNS)
|
||||
{
|
||||
float3 dc=lerp(detailColor.r,detailColor.a, baseColor.a);
|
||||
baseColor.rgb*=lerp(float3(1,1,1),2.0*dc,fBlendFactor);
|
||||
}
|
||||
if ( combine_mode == TCOMBINE_RGB_EQUALS_BASE_x_DETAILx2)
|
||||
baseColor.rgb*=lerp(float3(1,1,1),2.0*detailColor.rgb,fBlendFactor);
|
||||
if ( combine_mode == TCOMBINE_RGB_ADDITIVE )
|
||||
baseColor.rgb += fBlendFactor * detailColor.rgb;
|
||||
if ( combine_mode == TCOMBINE_DETAIL_OVER_BASE )
|
||||
{
|
||||
float fblend=fBlendFactor * detailColor.a;
|
||||
baseColor.rgb = lerp( baseColor.rgb, detailColor.rgb, fblend);
|
||||
}
|
||||
if ( combine_mode == TCOMBINE_FADE )
|
||||
{
|
||||
baseColor = lerp( baseColor, detailColor, fBlendFactor);
|
||||
}
|
||||
if ( combine_mode == TCOMBINE_BASE_OVER_DETAIL )
|
||||
{
|
||||
float fblend=fBlendFactor * (1-baseColor.a);
|
||||
baseColor.rgb = lerp( baseColor.rgb, detailColor.rgb, fblend );
|
||||
baseColor.a = detailColor.a;
|
||||
}
|
||||
if ( combine_mode == TCOMBINE_MULTIPLY )
|
||||
{
|
||||
baseColor = lerp( baseColor, baseColor*detailColor, fBlendFactor);
|
||||
}
|
||||
|
||||
if (combine_mode == TCOMBINE_MASK_BASE_BY_DETAIL_ALPHA )
|
||||
{
|
||||
baseColor.a = lerp( baseColor.a, baseColor.a*detailColor.a, fBlendFactor );
|
||||
}
|
||||
if ( combine_mode == TCOMBINE_SSBUMP_NOBUMP )
|
||||
{
|
||||
baseColor.rgb = baseColor.rgb * dot( detailColor.rgb, 2.0/3.0 );
|
||||
}
|
||||
return baseColor;
|
||||
}
|
||||
|
||||
float3 lerp5(float3 f1, float3 f2, float i1, float i2, float x)
|
||||
{
|
||||
return f1+(f2-f1)*(x-i1)/(i2-i1);
|
||||
}
|
||||
|
||||
float3 TextureCombinePostLighting( float3 lit_baseColor, float4 detailColor, int combine_mode,
|
||||
float fBlendFactor )
|
||||
{
|
||||
if ( combine_mode == TCOMBINE_RGB_ADDITIVE_SELFILLUM )
|
||||
lit_baseColor += fBlendFactor * detailColor.rgb;
|
||||
if ( combine_mode == TCOMBINE_RGB_ADDITIVE_SELFILLUM_THRESHOLD_FADE )
|
||||
{
|
||||
// fade in an unusual way - instead of fading out color, remap an increasing band of it from
|
||||
// 0..1
|
||||
if ( fBlendFactor > 0.5)
|
||||
lit_baseColor += min(1, (1.0/fBlendFactor)*max(0, detailColor.rgb-(1-fBlendFactor) ) );
|
||||
else
|
||||
lit_baseColor += 2*fBlendFactor*2*max(0, detailColor.rgb-.5);
|
||||
}
|
||||
return lit_baseColor;
|
||||
}
|
||||
|
||||
//NOTE: On X360. fProjZ is expected to be pre-reversed for cheaper math here in the pixel shader
|
||||
float DepthFeathering( sampler DepthSampler, const float2 vScreenPos, float fProjZ, float fProjW, float4 vDepthBlendConstants )
|
||||
{
|
||||
# if ( !(defined(SHADER_MODEL_PS_1_1) || defined(SHADER_MODEL_PS_1_4) || defined(SHADER_MODEL_PS_2_0)) ) //minimum requirement of ps2b
|
||||
{
|
||||
float flFeatheredAlpha;
|
||||
float2 flDepths;
|
||||
#define flSceneDepth flDepths.x
|
||||
#define flSpriteDepth flDepths.y
|
||||
|
||||
# if ( defined( _X360 ) )
|
||||
{
|
||||
//Get depth from the depth texture. Need to sample with the offset of (0.5, 0.5) to fix rounding errors
|
||||
asm {
|
||||
tfetch2D flDepths.x___, vScreenPos, DepthSampler, OffsetX=0.5, OffsetY=0.5, MinFilter=point, MagFilter=point, MipFilter=point
|
||||
};
|
||||
|
||||
# if( !defined( REVERSE_DEPTH_ON_X360 ) )
|
||||
flSceneDepth = 1.0f - flSceneDepth;
|
||||
# endif
|
||||
|
||||
//get the sprite depth into the same range as the texture depth
|
||||
flSpriteDepth = fProjZ / fProjW;
|
||||
|
||||
//unproject to get at the pre-projection z. This value is much more linear than depth
|
||||
flDepths = vDepthBlendConstants.z / flDepths;
|
||||
flDepths = vDepthBlendConstants.y - flDepths;
|
||||
|
||||
flFeatheredAlpha = flSceneDepth - flSpriteDepth;
|
||||
flFeatheredAlpha *= vDepthBlendConstants.x;
|
||||
flFeatheredAlpha = saturate( flFeatheredAlpha );
|
||||
}
|
||||
# else
|
||||
{
|
||||
flSceneDepth = tex2D( DepthSampler, vScreenPos ).a; // PC uses dest alpha of the frame buffer
|
||||
flSpriteDepth = SoftParticleDepth( fProjZ );
|
||||
|
||||
flFeatheredAlpha = abs(flSceneDepth - flSpriteDepth) * vDepthBlendConstants.x;
|
||||
flFeatheredAlpha = max( smoothstep( 0.75f, 1.0f, flSceneDepth ), flFeatheredAlpha ); //as the sprite approaches the edge of our compressed depth space, the math stops working. So as the sprite approaches the far depth, smoothly remove feathering.
|
||||
flFeatheredAlpha = saturate( flFeatheredAlpha );
|
||||
}
|
||||
# endif
|
||||
|
||||
#undef flSceneDepth
|
||||
#undef flSpriteDepth
|
||||
|
||||
return flFeatheredAlpha;
|
||||
}
|
||||
# else
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif //#ifndef COMMON_PS_FXC_H_
|
||||
@@ -1,449 +0,0 @@
|
||||
#ifndef COMMON_VERTEXLITGENERIC_DX9_H_
|
||||
#define COMMON_VERTEXLITGENERIC_DX9_H_
|
||||
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
// We store four light colors and positions in an
|
||||
// array of three of these structures like so:
|
||||
//
|
||||
// x y z w
|
||||
// +------+------+------+------+
|
||||
// | L0.rgb | |
|
||||
// +------+------+------+ |
|
||||
// | L0.pos | L3 |
|
||||
// +------+------+------+ rgb |
|
||||
// | L1.rgb | |
|
||||
// +------+------+------+------+
|
||||
// | L1.pos | |
|
||||
// +------+------+------+ |
|
||||
// | L2.rgb | L3 |
|
||||
// +------+------+------+ pos |
|
||||
// | L2.pos | |
|
||||
// +------+------+------+------+
|
||||
//
|
||||
struct PixelShaderLightInfo
|
||||
{
|
||||
float4 color;
|
||||
float4 pos;
|
||||
};
|
||||
|
||||
#define cOverbright 2.0f
|
||||
#define cOOOverbright 0.5f
|
||||
|
||||
#define LIGHTTYPE_NONE 0
|
||||
#define LIGHTTYPE_SPOT 1
|
||||
#define LIGHTTYPE_POINT 2
|
||||
#define LIGHTTYPE_DIRECTIONAL 3
|
||||
|
||||
// Better suited to Pixel shader models, 11 instructions in pixel shader
|
||||
float3 PixelShaderAmbientLight( const float3 worldNormal, const float3 cAmbientCube[6] )
|
||||
{
|
||||
float3 linearColor, nSquared = worldNormal * worldNormal;
|
||||
float3 isNegative = ( worldNormal < 0.0 );
|
||||
float3 isPositive = 1-isNegative;
|
||||
|
||||
isNegative *= nSquared;
|
||||
isPositive *= nSquared;
|
||||
|
||||
linearColor = isPositive.x * cAmbientCube[0] + isNegative.x * cAmbientCube[1] +
|
||||
isPositive.y * cAmbientCube[2] + isNegative.y * cAmbientCube[3] +
|
||||
isPositive.z * cAmbientCube[4] + isNegative.z * cAmbientCube[5];
|
||||
|
||||
return linearColor;
|
||||
}
|
||||
|
||||
// Better suited to Vertex shader models
|
||||
// Six VS instructions due to use of constant indexing (slt, mova, mul, mul, mad, mad)
|
||||
float3 VertexShaderAmbientLight( const float3 worldNormal, const float3 cAmbientCube[6] )
|
||||
{
|
||||
float3 nSquared = worldNormal * worldNormal;
|
||||
int3 isNegative = ( worldNormal < 0.0 );
|
||||
float3 linearColor;
|
||||
linearColor = nSquared.x * cAmbientCube[isNegative.x] +
|
||||
nSquared.y * cAmbientCube[isNegative.y+2] +
|
||||
nSquared.z * cAmbientCube[isNegative.z+4];
|
||||
return linearColor;
|
||||
}
|
||||
|
||||
float3 AmbientLight( const float3 worldNormal, const float3 cAmbientCube[6] )
|
||||
{
|
||||
// Vertex shader cases
|
||||
#ifdef SHADER_MODEL_VS_1_0
|
||||
return VertexShaderAmbientLight( worldNormal, cAmbientCube );
|
||||
#elif SHADER_MODEL_VS_1_1
|
||||
return VertexShaderAmbientLight( worldNormal, cAmbientCube );
|
||||
#elif SHADER_MODEL_VS_2_0
|
||||
return VertexShaderAmbientLight( worldNormal, cAmbientCube );
|
||||
#elif SHADER_MODEL_VS_3_0
|
||||
return VertexShaderAmbientLight( worldNormal, cAmbientCube );
|
||||
#else
|
||||
// Pixel shader case
|
||||
return PixelShaderAmbientLight( worldNormal, cAmbientCube );
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Compute scalar diffuse term with various optional tweaks such as
|
||||
// Half Lambert and ambient occlusion
|
||||
//-----------------------------------------------------------------------------
|
||||
float3 DiffuseTerm(const bool bHalfLambert, const float3 worldNormal, const float3 lightDir,
|
||||
const bool bDoAmbientOcclusion, const float fAmbientOcclusion/*,
|
||||
const bool bDoLightingWarp, in sampler lightWarpSampler*/ )
|
||||
{
|
||||
float fResult;
|
||||
|
||||
float NDotL = dot( worldNormal, lightDir ); // Unsaturated dot (-1 to 1 range)
|
||||
|
||||
if ( bHalfLambert )
|
||||
{
|
||||
fResult = saturate(NDotL * 0.5 + 0.5); // Scale and bias to 0 to 1 range
|
||||
|
||||
//if ( !bDoLightingWarp )
|
||||
{
|
||||
fResult *= fResult; // Square
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fResult = saturate( NDotL ); // Saturate pure Lambertian term
|
||||
}
|
||||
|
||||
if ( bDoAmbientOcclusion )
|
||||
{
|
||||
// Raise to higher powers for darker AO values
|
||||
// float fAOPower = lerp( 4.0f, 1.0f, fAmbientOcclusion );
|
||||
// result *= pow( NDotL * 0.5 + 0.5, fAOPower );
|
||||
fResult *= fAmbientOcclusion;
|
||||
}
|
||||
|
||||
float3 fOut = float3( fResult, fResult, fResult );
|
||||
//if ( bDoLightingWarp )
|
||||
//{
|
||||
// fOut = 2.0f * tex1D( lightWarpSampler, fResult );
|
||||
//}
|
||||
|
||||
return fOut;
|
||||
}
|
||||
|
||||
float3 PixelShaderDoGeneralDiffuseLight( const float fAtten, const float3 worldPos, const float3 worldNormal,
|
||||
/* in sampler NormalizeSampler,*/
|
||||
const float3 vPosition, const float3 vColor, const bool bHalfLambert,
|
||||
const bool bDoAmbientOcclusion, const float fAmbientOcclusion/*,
|
||||
const bool bDoLightingWarp, in sampler lightWarpSampler*/ )
|
||||
{
|
||||
//#if (defined(SHADER_MODEL_PS_2_B) || defined(SHADER_MODEL_PS_3_0))
|
||||
float3 lightDir = normalize( vPosition - worldPos );
|
||||
//#else
|
||||
// float3 lightDir = NormalizeWithCubemap( NormalizeSampler, vPosition - worldPos );
|
||||
//#endif
|
||||
return vColor * fAtten * DiffuseTerm( bHalfLambert, worldNormal, lightDir, bDoAmbientOcclusion, fAmbientOcclusion/*, bDoLightingWarp, lightWarpSampler*/ );
|
||||
}
|
||||
|
||||
float3 PixelShaderGetLightVector( const float3 worldPos, PixelShaderLightInfo cLightInfo[3], int nLightIndex )
|
||||
{
|
||||
if ( nLightIndex == 3 )
|
||||
{
|
||||
// Unpack light 3 from w components...
|
||||
float3 vLight3Pos = float3( cLightInfo[1].pos.w, cLightInfo[2].color.w, cLightInfo[2].pos.w );
|
||||
return normalize( vLight3Pos - worldPos );
|
||||
}
|
||||
else
|
||||
{
|
||||
return normalize( cLightInfo[nLightIndex].pos - worldPos );
|
||||
}
|
||||
}
|
||||
|
||||
float3 PixelShaderGetLightColor( PixelShaderLightInfo cLightInfo[3], int nLightIndex )
|
||||
{
|
||||
if ( nLightIndex == 3 )
|
||||
{
|
||||
// Unpack light 3 from w components...
|
||||
return float3( cLightInfo[0].color.w, cLightInfo[0].pos.w, cLightInfo[1].color.w );
|
||||
}
|
||||
else
|
||||
{
|
||||
return cLightInfo[nLightIndex].color.rgb;
|
||||
}
|
||||
}
|
||||
|
||||
void GetLightData( PixelShaderLightInfo cLightInfo[3], int index, float3 worldpos,
|
||||
out float3 color, out float3 dir )
|
||||
{
|
||||
color = PixelShaderGetLightColor( cLightInfo, index );
|
||||
dir = PixelShaderGetLightVector( worldpos, cLightInfo, index );
|
||||
}
|
||||
|
||||
|
||||
void SpecularAndRimTerms( const float3 vWorldNormal, const float3 vLightDir, const float fSpecularExponent,
|
||||
const float3 vEyeDir, const bool bDoAmbientOcclusion, const float fAmbientOcclusion,
|
||||
/*const bool bDoSpecularWarp, in sampler specularWarpSampler,*/ const float fFresnel,
|
||||
const float3 color, /*const bool bDoRimLighting, const float fRimExponent,*/
|
||||
|
||||
// Outputs
|
||||
out float3 specularLighting/*, out float3 rimLighting*/ )
|
||||
{
|
||||
//rimLighting = float3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
float3 vReflect = reflect( -vEyeDir, vWorldNormal ); // Reflect view through normal
|
||||
float LdotR = saturate(dot( vReflect, vLightDir )); // L.R (use half-angle instead?)
|
||||
specularLighting = pow( LdotR, fSpecularExponent ); // Raise to specular exponent
|
||||
|
||||
// Optionally warp as function of scalar specular and fresnel
|
||||
//if ( bDoSpecularWarp )
|
||||
// specularLighting *= tex2D( specularWarpSampler, float2(specularLighting.x, fFresnel) ); // Sample at { (L.R)^k, fresnel }
|
||||
specularLighting *= fFresnel; // Sample at { (L.R)^k, fresnel }
|
||||
|
||||
specularLighting *= saturate(dot( vWorldNormal, vLightDir )); // Mask with N.L
|
||||
specularLighting *= color; // Modulate with light color
|
||||
|
||||
if ( bDoAmbientOcclusion ) // Optionally modulate with ambient occlusion
|
||||
specularLighting *= fAmbientOcclusion;
|
||||
|
||||
//if ( bDoRimLighting ) // Optionally do rim lighting
|
||||
//{
|
||||
// rimLighting = pow( LdotR, fRimExponent ); // Raise to rim exponent
|
||||
// rimLighting *= saturate(dot( vWorldNormal, vLightDir )); // Mask with N.L
|
||||
// rimLighting *= color; // Modulate with light color
|
||||
//}
|
||||
}
|
||||
|
||||
// Traditional fresnel term approximation
|
||||
float Fresnel( const float3 vNormal, const float3 vEyeDir )
|
||||
{
|
||||
float fresnel = 1-saturate( dot( vNormal, vEyeDir ) ); // 1-(N.V) for Fresnel term
|
||||
return fresnel * fresnel; // Square for a more subtle look
|
||||
}
|
||||
|
||||
// Traditional fresnel term approximation which uses 4th power (square twice)
|
||||
float Fresnel4( const float3 vNormal, const float3 vEyeDir )
|
||||
{
|
||||
float fresnel = 1-saturate( dot( vNormal, vEyeDir ) ); // 1-(N.V) for Fresnel term
|
||||
fresnel = fresnel * fresnel; // Square
|
||||
return fresnel * fresnel; // Square again for a more subtle look
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Custom Fresnel with low, mid and high parameters defining a piecewise continuous function
|
||||
// with traditional fresnel (0 to 1 range) as input. The 0 to 0.5 range blends between
|
||||
// low and mid while the 0.5 to 1 range blends between mid and high
|
||||
//
|
||||
// |
|
||||
// | . M . . . H
|
||||
// | .
|
||||
// L
|
||||
// |
|
||||
// +----------------
|
||||
// 0 1
|
||||
//
|
||||
float Fresnel( const float3 vNormal, const float3 vEyeDir, float3 vRanges )
|
||||
{
|
||||
float result, f = Fresnel( vNormal, vEyeDir ); // Traditional Fresnel
|
||||
|
||||
if ( f > 0.5f )
|
||||
result = lerp( vRanges.y, vRanges.z, (2*f)-1 ); // Blend between mid and high values
|
||||
else
|
||||
result = lerp( vRanges.x, vRanges.y, 2*f ); // Blend between low and mid values
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void PixelShaderDoSpecularLight( const float3 vWorldPos, const float3 vWorldNormal, const float fSpecularExponent, const float3 vEyeDir,
|
||||
const float fAtten, const float3 vLightColor, const float3 vLightDir,
|
||||
const bool bDoAmbientOcclusion, const float fAmbientOcclusion,
|
||||
/*const bool bDoSpecularWarp, in sampler specularWarpSampler,*/ float fFresnel,
|
||||
/*const bool bDoRimLighting, const float fRimExponent,*/
|
||||
|
||||
// Outputs
|
||||
out float3 specularLighting/*, out float3 rimLighting*/ )
|
||||
{
|
||||
// Compute Specular and rim terms
|
||||
SpecularAndRimTerms( vWorldNormal, vLightDir, fSpecularExponent,
|
||||
vEyeDir, bDoAmbientOcclusion, fAmbientOcclusion,
|
||||
/*bDoSpecularWarp, specularWarpSampler,*/ fFresnel, vLightColor * fAtten,
|
||||
/*bDoRimLighting, fRimExponent,*/ specularLighting/*, rimLighting*/ );
|
||||
}
|
||||
|
||||
float3 PixelShaderDoLightingLinear( const float3 worldPos, const float3 worldNormal,
|
||||
const float3 staticLightingColor, const bool bStaticLight,
|
||||
const bool bAmbientLight, const float4 lightAtten, const float3 cAmbientCube[6],
|
||||
/*in sampler NormalizeSampler,*/ const int nNumLights, PixelShaderLightInfo cLightInfo[3],
|
||||
const bool bHalfLambert, const bool bDoAmbientOcclusion, const float fAmbientOcclusion/*,
|
||||
const bool bDoLightingWarp, in sampler lightWarpSampler*/ )
|
||||
{
|
||||
float3 linearColor = 0.0f;
|
||||
|
||||
if ( bStaticLight )
|
||||
{
|
||||
// The static lighting comes in in gamma space and has also been premultiplied by $cOOOverbright
|
||||
// need to get it into
|
||||
// linear space so that we can do adds.
|
||||
linearColor += GammaToLinear( staticLightingColor * cOverbright );
|
||||
}
|
||||
|
||||
if ( bAmbientLight )
|
||||
{
|
||||
float3 ambient = AmbientLight( worldNormal, cAmbientCube );
|
||||
|
||||
if ( bDoAmbientOcclusion )
|
||||
ambient *= fAmbientOcclusion * fAmbientOcclusion; // Note squaring...
|
||||
|
||||
linearColor += ambient;
|
||||
}
|
||||
|
||||
if ( nNumLights > 0 )
|
||||
{
|
||||
linearColor += PixelShaderDoGeneralDiffuseLight( lightAtten.x, worldPos, worldNormal, /*NormalizeSampler,*/
|
||||
cLightInfo[0].pos, cLightInfo[0].color, bHalfLambert,
|
||||
bDoAmbientOcclusion, fAmbientOcclusion/*,
|
||||
bDoLightingWarp, lightWarpSampler*/ );
|
||||
if ( nNumLights > 1 )
|
||||
{
|
||||
linearColor += PixelShaderDoGeneralDiffuseLight( lightAtten.y, worldPos, worldNormal, /*NormalizeSampler,*/
|
||||
cLightInfo[1].pos, cLightInfo[1].color, bHalfLambert,
|
||||
bDoAmbientOcclusion, fAmbientOcclusion/*,
|
||||
bDoLightingWarp, lightWarpSampler*/ );
|
||||
if ( nNumLights > 2 )
|
||||
{
|
||||
linearColor += PixelShaderDoGeneralDiffuseLight( lightAtten.z, worldPos, worldNormal, /*NormalizeSampler,*/
|
||||
cLightInfo[2].pos, cLightInfo[2].color, bHalfLambert,
|
||||
bDoAmbientOcclusion, fAmbientOcclusion/*,
|
||||
bDoLightingWarp, lightWarpSampler*/ );
|
||||
if ( nNumLights > 3 )
|
||||
{
|
||||
// Unpack the 4th light's data from tight constant packing
|
||||
float3 vLight3Color = float3( cLightInfo[0].color.w, cLightInfo[0].pos.w, cLightInfo[1].color.w );
|
||||
float3 vLight3Pos = float3( cLightInfo[1].pos.w, cLightInfo[2].color.w, cLightInfo[2].pos.w );
|
||||
linearColor += PixelShaderDoGeneralDiffuseLight( lightAtten.w, worldPos, worldNormal, /*NormalizeSampler,*/
|
||||
vLight3Pos, vLight3Color, bHalfLambert,
|
||||
bDoAmbientOcclusion, fAmbientOcclusion/*,
|
||||
bDoLightingWarp, lightWarpSampler*/ );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return linearColor;
|
||||
}
|
||||
|
||||
void PixelShaderDoSpecularLighting( const float3 worldPos, const float3 worldNormal, const float fSpecularExponent, const float3 vEyeDir,
|
||||
const float4 lightAtten, const int nNumLights, PixelShaderLightInfo cLightInfo[3],
|
||||
const bool bDoAmbientOcclusion, const float fAmbientOcclusion,
|
||||
/*const bool bDoSpecularWarp, in sampler specularWarpSampler,*/ float fFresnel,
|
||||
/*const bool bDoRimLighting, const float fRimExponent,*/
|
||||
|
||||
// Outputs
|
||||
out float3 specularLighting/*, out float3 rimLighting*/ )
|
||||
{
|
||||
specularLighting /*= rimLighting*/ = float3( 0.0f, 0.0f, 0.0f );
|
||||
float3 localSpecularTerm/*, localRimTerm*/;
|
||||
|
||||
if( nNumLights > 0 )
|
||||
{
|
||||
PixelShaderDoSpecularLight( worldPos, worldNormal, fSpecularExponent, vEyeDir,
|
||||
lightAtten.x, PixelShaderGetLightColor( cLightInfo, 0 ),
|
||||
PixelShaderGetLightVector( worldPos, cLightInfo, 0 ),
|
||||
bDoAmbientOcclusion, fAmbientOcclusion,
|
||||
/*bDoSpecularWarp, specularWarpSampler,*/ fFresnel,
|
||||
/*bDoRimLighting, fRimExponent,*/
|
||||
localSpecularTerm/*, localRimTerm*/ );
|
||||
|
||||
specularLighting += localSpecularTerm; // Accumulate specular and rim terms
|
||||
/*rimLighting += localRimTerm;*/
|
||||
}
|
||||
|
||||
if( nNumLights > 1 )
|
||||
{
|
||||
PixelShaderDoSpecularLight( worldPos, worldNormal, fSpecularExponent, vEyeDir,
|
||||
lightAtten.y, PixelShaderGetLightColor( cLightInfo, 1 ),
|
||||
PixelShaderGetLightVector( worldPos, cLightInfo, 1 ),
|
||||
bDoAmbientOcclusion, fAmbientOcclusion,
|
||||
/*bDoSpecularWarp, specularWarpSampler,*/ fFresnel,
|
||||
/*bDoRimLighting, fRimExponent,*/
|
||||
localSpecularTerm/*, localRimTerm*/ );
|
||||
|
||||
specularLighting += localSpecularTerm; // Accumulate specular and rim terms
|
||||
/*rimLighting += localRimTerm;*/
|
||||
}
|
||||
|
||||
|
||||
if( nNumLights > 2 )
|
||||
{
|
||||
PixelShaderDoSpecularLight( worldPos, worldNormal, fSpecularExponent, vEyeDir,
|
||||
lightAtten.z, PixelShaderGetLightColor( cLightInfo, 2 ),
|
||||
PixelShaderGetLightVector( worldPos, cLightInfo, 2 ),
|
||||
bDoAmbientOcclusion, fAmbientOcclusion,
|
||||
/*bDoSpecularWarp, specularWarpSampler,*/ fFresnel,
|
||||
/*bDoRimLighting, fRimExponent,*/
|
||||
localSpecularTerm/*, localRimTerm*/ );
|
||||
|
||||
specularLighting += localSpecularTerm; // Accumulate specular and rim terms
|
||||
/*rimLighting += localRimTerm;*/
|
||||
}
|
||||
|
||||
if( nNumLights > 3 )
|
||||
{
|
||||
PixelShaderDoSpecularLight( worldPos, worldNormal, fSpecularExponent, vEyeDir,
|
||||
lightAtten.w, PixelShaderGetLightColor( cLightInfo, 3 ),
|
||||
PixelShaderGetLightVector( worldPos, cLightInfo, 3 ),
|
||||
bDoAmbientOcclusion, fAmbientOcclusion,
|
||||
/*bDoSpecularWarp, specularWarpSampler,*/ fFresnel,
|
||||
/*bDoRimLighting, fRimExponent,*/
|
||||
localSpecularTerm/*, localRimTerm*/ );
|
||||
|
||||
specularLighting += localSpecularTerm; // Accumulate specular and rim terms
|
||||
/*rimLighting += localRimTerm;*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
float3 PixelShaderDoRimLighting( const float3 worldNormal, const float3 vEyeDir, const float3 cAmbientCube[6], float fFresnel )
|
||||
{
|
||||
float3 vReflect = reflect( -vEyeDir, worldNormal ); // Reflect view through normal
|
||||
|
||||
return fFresnel * PixelShaderAmbientLight( vEyeDir, cAmbientCube );
|
||||
}
|
||||
|
||||
// Called directly by newer shaders or through the following wrapper for older shaders
|
||||
float3 PixelShaderDoLighting( const float3 worldPos, const float3 worldNormal,
|
||||
const float3 staticLightingColor, const bool bStaticLight,
|
||||
const bool bAmbientLight, const float4 lightAtten, const float3 cAmbientCube[6],
|
||||
/*in sampler NormalizeSampler,*/ const int nNumLights, PixelShaderLightInfo cLightInfo[3],
|
||||
const bool bHalfLambert,
|
||||
|
||||
// New optional/experimental parameters
|
||||
const bool bDoAmbientOcclusion, const float fAmbientOcclusion/*,
|
||||
const bool bDoLightingWarp, in sampler lightWarpSampler*/ )
|
||||
{
|
||||
float3 returnColor;
|
||||
|
||||
// special case for no lighting
|
||||
if( !bStaticLight && !bAmbientLight )
|
||||
{
|
||||
returnColor = float3( 0.0f, 0.0f, 0.0f );
|
||||
}
|
||||
else if( bStaticLight && !bAmbientLight )
|
||||
{
|
||||
// special case for static lighting only
|
||||
returnColor = GammaToLinear( staticLightingColor );
|
||||
}
|
||||
else
|
||||
{
|
||||
float3 linearColor;
|
||||
|
||||
linearColor = PixelShaderDoLightingLinear( worldPos, worldNormal, staticLightingColor,
|
||||
bStaticLight, bAmbientLight, lightAtten,
|
||||
cAmbientCube, /*NormalizeSampler,*/ nNumLights, cLightInfo, bHalfLambert,
|
||||
bDoAmbientOcclusion, fAmbientOcclusion/*,
|
||||
bDoLightingWarp, lightWarpSampler*/ );
|
||||
|
||||
// go ahead and clamp to the linear space equivalent of overbright 2 so that we match
|
||||
// everything else.
|
||||
// returnColor = HuePreservingColorClamp( linearColor, pow( 2.0f, 2.2 ) );
|
||||
returnColor = linearColor;
|
||||
}
|
||||
|
||||
return returnColor;
|
||||
}
|
||||
|
||||
#endif //#ifndef COMMON_VERTEXLITGENERIC_DX9_H_
|
||||
@@ -1,959 +0,0 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose: This is where all common code for vertex shaders go.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
|
||||
|
||||
#ifndef COMMON_VS_FXC_H_
|
||||
#define COMMON_VS_FXC_H_
|
||||
|
||||
#include "common_fxc.h"
|
||||
|
||||
// Put global skip commands here. . make sure and check that the appropriate vars are defined
|
||||
// so these aren't used on the wrong shaders!
|
||||
// --------------------------------------------------------------------------------
|
||||
// Ditch all fastpath attemps if we are doing LIGHTING_PREVIEW.
|
||||
// SKIP: defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef COMPRESSED_VERTS
|
||||
// Default to no vertex compression
|
||||
#define COMPRESSED_VERTS 0
|
||||
#endif
|
||||
|
||||
#if ( !defined( SHADER_MODEL_VS_2_0 ) && !defined( SHADER_MODEL_VS_3_0 ) )
|
||||
#if COMPRESSED_VERTS == 1
|
||||
#error "Vertex compression is only for DX9 and up!"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// We're testing 2 normal compression methods
|
||||
// One compressed normals+tangents into a SHORT2 each (8 bytes total)
|
||||
// The other compresses them together, into a single UBYTE4 (4 bytes total)
|
||||
// FIXME: pick one or the other, compare lighting quality in important cases
|
||||
#define COMPRESSED_NORMALS_SEPARATETANGENTS_SHORT2 0
|
||||
#define COMPRESSED_NORMALS_COMBINEDTANGENTS_UBYTE4 1
|
||||
//#define COMPRESSED_NORMALS_TYPE COMPRESSED_NORMALS_SEPARATETANGENTS_SHORT2
|
||||
#define COMPRESSED_NORMALS_TYPE COMPRESSED_NORMALS_COMBINEDTANGENTS_UBYTE4
|
||||
|
||||
|
||||
#define FOGTYPE_RANGE 0
|
||||
#define FOGTYPE_HEIGHT 1
|
||||
|
||||
#define COMPILE_ERROR ( 1/0; )
|
||||
|
||||
// -------------------------
|
||||
// CONSTANTS
|
||||
// -------------------------
|
||||
|
||||
#pragma def ( vs, c0, 0.0f, 1.0f, 2.0f, 0.5f )
|
||||
|
||||
const float4 cConstants1 : register(c1);
|
||||
#define cOOGamma cConstants1.x
|
||||
#define cOverbright 2.0f
|
||||
#define cOneThird cConstants1.z
|
||||
#define cOOOverbright ( 1.0f / 2.0f )
|
||||
|
||||
|
||||
// The g_bLightEnabled registers and g_nLightCountRegister hold the same information regarding
|
||||
// enabling lights, but callers internal to this file tend to use the loops, while external
|
||||
// callers will end up using the booleans
|
||||
const bool g_bLightEnabled[4] : register(b0);
|
||||
// through b3
|
||||
|
||||
const int g_nLightCountRegister : register(i0);
|
||||
|
||||
|
||||
#define g_nLightCount g_nLightCountRegister.x
|
||||
|
||||
const float4 cEyePosWaterZ : register(c2);
|
||||
#define cEyePos cEyePosWaterZ.xyz
|
||||
|
||||
// This is still used by asm stuff.
|
||||
const float4 cObsoleteLightIndex : register(c3);
|
||||
|
||||
const float4x4 cModelViewProj : register(c4);
|
||||
const float4x4 cViewProj : register(c8);
|
||||
|
||||
// Only cFlexScale.x is used
|
||||
// It is a binary value used to switch on/off the addition of the flex delta stream
|
||||
const float4 cFlexScale : register(c13);
|
||||
|
||||
const float4 cFogParams : register(c16);
|
||||
#define cFogEndOverFogRange cFogParams.x
|
||||
#define cFogOne cFogParams.y
|
||||
#define cFogMaxDensity cFogParams.z
|
||||
#define cOOFogRange cFogParams.w
|
||||
|
||||
const float4x4 cViewModel : register(c17);
|
||||
|
||||
const float3 cAmbientCubeX [ 2 ] : register ( c21 ) ;
|
||||
const float3 cAmbientCubeY [ 2 ] : register ( c23 ) ;
|
||||
const float3 cAmbientCubeZ [ 2 ] : register ( c25 ) ;
|
||||
|
||||
#ifdef SHADER_MODEL_VS_3_0
|
||||
const float4 cFlexWeights [ 512 ] : register ( c1024 ) ;
|
||||
#endif
|
||||
|
||||
struct LightInfo
|
||||
{
|
||||
float4 color; // {xyz} is color w is light type code (see comment below)
|
||||
float4 dir; // {xyz} is dir w is light type code
|
||||
float4 pos;
|
||||
float4 spotParams;
|
||||
float4 atten;
|
||||
};
|
||||
|
||||
// w components of color and dir indicate light type:
|
||||
// 1x - directional
|
||||
// 01 - spot
|
||||
// 00 - point
|
||||
|
||||
// Four lights x 5 constants each = 20 constants
|
||||
LightInfo cLightInfo[4] : register(c27);
|
||||
#define LIGHT_0_POSITION_REG c29
|
||||
|
||||
#ifdef SHADER_MODEL_VS_1_1
|
||||
|
||||
const float4 cModulationColor : register(c37);
|
||||
|
||||
#define SHADER_SPECIFIC_CONST_0 c38
|
||||
#define SHADER_SPECIFIC_CONST_1 c39
|
||||
#define SHADER_SPECIFIC_CONST_2 c40
|
||||
#define SHADER_SPECIFIC_CONST_3 c41
|
||||
#define SHADER_SPECIFIC_CONST_4 c42
|
||||
#define SHADER_SPECIFIC_CONST_5 c43
|
||||
#define SHADER_SPECIFIC_CONST_6 c44
|
||||
#define SHADER_SPECIFIC_CONST_7 c45
|
||||
#define SHADER_SPECIFIC_CONST_8 c46
|
||||
#define SHADER_SPECIFIC_CONST_9 c47
|
||||
#define SHADER_SPECIFIC_CONST_10 c14
|
||||
#define SHADER_SPECIFIC_CONST_11 c15
|
||||
|
||||
static const int cModel0Index = 48;
|
||||
const float4x3 cModel[16] : register(c48);
|
||||
// last cmodel is c105 for dx80, c214 for dx90
|
||||
|
||||
#else // DX9 shaders (vs20 and beyond)
|
||||
|
||||
const float4 cModulationColor : register( c47 );
|
||||
|
||||
#define SHADER_SPECIFIC_CONST_0 c48
|
||||
#define SHADER_SPECIFIC_CONST_1 c49
|
||||
#define SHADER_SPECIFIC_CONST_2 c50
|
||||
#define SHADER_SPECIFIC_CONST_3 c51
|
||||
#define SHADER_SPECIFIC_CONST_4 c52
|
||||
#define SHADER_SPECIFIC_CONST_5 c53
|
||||
#define SHADER_SPECIFIC_CONST_6 c54
|
||||
#define SHADER_SPECIFIC_CONST_7 c55
|
||||
#define SHADER_SPECIFIC_CONST_8 c56
|
||||
#define SHADER_SPECIFIC_CONST_9 c57
|
||||
#define SHADER_SPECIFIC_CONST_10 c14
|
||||
#define SHADER_SPECIFIC_CONST_11 c15
|
||||
|
||||
static const int cModel0Index = 58;
|
||||
const float4x3 cModel[53] : register( c58 );
|
||||
// last cmodel is c105 for dx80, c214 for dx90
|
||||
|
||||
#define SHADER_SPECIFIC_BOOL_CONST_0 b4
|
||||
#define SHADER_SPECIFIC_BOOL_CONST_1 b5
|
||||
#define SHADER_SPECIFIC_BOOL_CONST_2 b6
|
||||
#define SHADER_SPECIFIC_BOOL_CONST_3 b7
|
||||
#define SHADER_SPECIFIC_BOOL_CONST_4 b8
|
||||
#define SHADER_SPECIFIC_BOOL_CONST_5 b9
|
||||
#define SHADER_SPECIFIC_BOOL_CONST_6 b10
|
||||
#define SHADER_SPECIFIC_BOOL_CONST_7 b11
|
||||
#endif // vertex shader model constant packing changes
|
||||
|
||||
|
||||
//=======================================================================================
|
||||
// Methods to decompress vertex normals
|
||||
//=======================================================================================
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
// Decompress a normal from two-component compressed format
|
||||
// We expect this data to come from a signed SHORT2 stream in the range of -32768..32767
|
||||
//
|
||||
// -32678 and 0 are invalid encodings
|
||||
// w contains the sign to use in the cross product when generating a binormal
|
||||
void _DecompressShort2Tangent( float2 inputTangent, out float4 outputTangent )
|
||||
{
|
||||
float2 ztSigns = sign( inputTangent ); // sign bits for z and tangent (+1 or -1)
|
||||
float2 xyAbs = abs( inputTangent ); // 1..32767
|
||||
outputTangent.xy = (xyAbs - 16384.0f) / 16384.0f; // x and y
|
||||
outputTangent.z = ztSigns.x * sqrt( saturate( 1.0f - dot( outputTangent.xy, outputTangent.xy ) ) );
|
||||
outputTangent.w = ztSigns.y;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
// Same code as _DecompressShort2Tangent, just one returns a float4, one a float3
|
||||
void _DecompressShort2Normal( float2 inputNormal, out float3 outputNormal )
|
||||
{
|
||||
float4 result;
|
||||
_DecompressShort2Tangent( inputNormal, result );
|
||||
outputNormal = result.xyz;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
// Decompress normal+tangent together
|
||||
void _DecompressShort2NormalTangent( float2 inputNormal, float2 inputTangent, out float3 outputNormal, out float4 outputTangent )
|
||||
{
|
||||
// FIXME: if we end up sticking with the SHORT2 format, pack the normal and tangent into a single SHORT4 element
|
||||
// (that would make unpacking normal+tangent here together much cheaper than the sum of their parts)
|
||||
_DecompressShort2Normal( inputNormal, outputNormal );
|
||||
_DecompressShort2Tangent( inputTangent, outputTangent );
|
||||
}
|
||||
|
||||
//=======================================================================================
|
||||
// Decompress a normal and tangent from four-component compressed format
|
||||
// We expect this data to come from an unsigned UBYTE4 stream in the range of 0..255
|
||||
// The final vTangent.w contains the sign to use in the cross product when generating a binormal
|
||||
void _DecompressUByte4NormalTangent( float4 inputNormal,
|
||||
out float3 outputNormal, // {nX, nY, nZ}
|
||||
out float4 outputTangent ) // {tX, tY, tZ, sign of binormal}
|
||||
{
|
||||
float fOne = 1.0f;
|
||||
|
||||
float4 ztztSignBits = ( inputNormal - 128.0f ) < 0; // sign bits for zs and binormal (1 or 0) set-less-than (slt) asm instruction
|
||||
float4 xyxyAbs = abs( inputNormal - 128.0f ) - ztztSignBits; // 0..127
|
||||
float4 xyxySignBits = ( xyxyAbs - 64.0f ) < 0; // sign bits for xs and ys (1 or 0)
|
||||
float4 normTan = (abs( xyxyAbs - 64.0f ) - xyxySignBits) / 63.0f; // abs({nX, nY, tX, tY})
|
||||
outputNormal.xy = normTan.xy; // abs({nX, nY, __, __})
|
||||
outputTangent.xy = normTan.zw; // abs({tX, tY, __, __})
|
||||
|
||||
float4 xyxySigns = 1 - 2*xyxySignBits; // Convert sign bits to signs
|
||||
float4 ztztSigns = 1 - 2*ztztSignBits; // ( [1,0] -> [-1,+1] )
|
||||
|
||||
outputNormal.z = 1.0f - outputNormal.x - outputNormal.y; // Project onto x+y+z=1
|
||||
outputNormal.xyz = normalize( outputNormal.xyz ); // Normalize onto unit sphere
|
||||
outputNormal.xy *= xyxySigns.xy; // Restore x and y signs
|
||||
outputNormal.z *= ztztSigns.x; // Restore z sign
|
||||
|
||||
outputTangent.z = 1.0f - outputTangent.x - outputTangent.y; // Project onto x+y+z=1
|
||||
outputTangent.xyz = normalize( outputTangent.xyz ); // Normalize onto unit sphere
|
||||
outputTangent.xy *= xyxySigns.zw; // Restore x and y signs
|
||||
outputTangent.z *= ztztSigns.z; // Restore z sign
|
||||
outputTangent.w = ztztSigns.w; // Binormal sign
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
// Decompress just a normal from four-component compressed format (same as above)
|
||||
// We expect this data to come from an unsigned UBYTE4 stream in the range of 0..255
|
||||
// [ When compiled, this works out to approximately 17 asm instructions ]
|
||||
void _DecompressUByte4Normal( float4 inputNormal,
|
||||
out float3 outputNormal) // {nX, nY, nZ}
|
||||
{
|
||||
float fOne = 1.0f;
|
||||
|
||||
float2 ztSigns = ( inputNormal.xy - 128.0f ) < 0; // sign bits for zs and binormal (1 or 0) set-less-than (slt) asm instruction
|
||||
float2 xyAbs = abs( inputNormal.xy - 128.0f ) - ztSigns; // 0..127
|
||||
float2 xySigns = ( xyAbs - 64.0f ) < 0; // sign bits for xs and ys (1 or 0)
|
||||
outputNormal.xy = ( abs( xyAbs - 64.0f ) - xySigns ) / 63.0f; // abs({nX, nY})
|
||||
|
||||
outputNormal.z = 1.0f - outputNormal.x - outputNormal.y; // Project onto x+y+z=1
|
||||
outputNormal.xyz = normalize( outputNormal.xyz ); // Normalize onto unit sphere
|
||||
|
||||
outputNormal.xy *= lerp( fOne.xx, -fOne.xx, xySigns ); // Restore x and y signs
|
||||
outputNormal.z *= lerp( fOne.x, -fOne.x, ztSigns.x ); // Restore z sign
|
||||
}
|
||||
|
||||
|
||||
void DecompressVertex_Normal( float4 inputNormal, out float3 outputNormal )
|
||||
{
|
||||
if ( COMPRESSED_VERTS == 1 )
|
||||
{
|
||||
if ( COMPRESSED_NORMALS_TYPE == COMPRESSED_NORMALS_SEPARATETANGENTS_SHORT2 )
|
||||
{
|
||||
_DecompressShort2Normal( inputNormal.xy, outputNormal );
|
||||
}
|
||||
else // ( COMPRESSED_NORMALS_TYPE == COMPRESSED_NORMALS_COMBINEDTANGENTS_UBYTE4 )
|
||||
{
|
||||
_DecompressUByte4Normal( inputNormal, outputNormal );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outputNormal = inputNormal.xyz;
|
||||
}
|
||||
}
|
||||
|
||||
void DecompressVertex_NormalTangent( float4 inputNormal, float4 inputTangent, out float3 outputNormal, out float4 outputTangent )
|
||||
{
|
||||
if ( COMPRESSED_VERTS == 1 )
|
||||
{
|
||||
if ( COMPRESSED_NORMALS_TYPE == COMPRESSED_NORMALS_SEPARATETANGENTS_SHORT2 )
|
||||
{
|
||||
_DecompressShort2NormalTangent( inputNormal.xy, inputTangent.xy, outputNormal, outputTangent );
|
||||
}
|
||||
else // ( COMPRESSED_NORMALS_TYPE == COMPRESSED_NORMALS_COMBINEDTANGENTS_UBYTE4 )
|
||||
{
|
||||
_DecompressUByte4NormalTangent( inputNormal, outputNormal, outputTangent );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outputNormal = inputNormal.xyz;
|
||||
outputTangent = inputTangent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef SHADER_MODEL_VS_3_0
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Methods to sample morph data from a vertex texture
|
||||
// NOTE: vMorphTargetTextureDim.x = width, cVertexTextureDim.y = height, cVertexTextureDim.z = # of float4 fields per vertex
|
||||
// For position + normal morph for example, there will be 2 fields.
|
||||
//-----------------------------------------------------------------------------
|
||||
float4 SampleMorphDelta( sampler2D vt, const float3 vMorphTargetTextureDim, const float4 vMorphSubrect, const float flVertexID, const float flField )
|
||||
{
|
||||
float flColumn = floor( flVertexID / vMorphSubrect.w );
|
||||
|
||||
float4 t;
|
||||
t.x = vMorphSubrect.x + vMorphTargetTextureDim.z * flColumn + flField + 0.5f;
|
||||
t.y = vMorphSubrect.y + flVertexID - flColumn * vMorphSubrect.w + 0.5f;
|
||||
t.xy /= vMorphTargetTextureDim.xy;
|
||||
t.z = t.w = 0.f;
|
||||
|
||||
return tex2Dlod( vt, t );
|
||||
}
|
||||
|
||||
// Optimized version which reads 2 deltas
|
||||
void SampleMorphDelta2( sampler2D vt, const float3 vMorphTargetTextureDim, const float4 vMorphSubrect, const float flVertexID, out float4 delta1, out float4 delta2 )
|
||||
{
|
||||
float flColumn = floor( flVertexID / vMorphSubrect.w );
|
||||
|
||||
float4 t;
|
||||
t.x = vMorphSubrect.x + vMorphTargetTextureDim.z * flColumn + 0.5f;
|
||||
t.y = vMorphSubrect.y + flVertexID - flColumn * vMorphSubrect.w + 0.5f;
|
||||
t.xy /= vMorphTargetTextureDim.xy;
|
||||
t.z = t.w = 0.f;
|
||||
|
||||
delta1 = tex2Dlod( vt, t );
|
||||
t.x += 1.0f / vMorphTargetTextureDim.x;
|
||||
delta2 = tex2Dlod( vt, t );
|
||||
}
|
||||
|
||||
#endif // SHADER_MODEL_VS_3_0
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Method to apply morphs
|
||||
//-----------------------------------------------------------------------------
|
||||
bool ApplyMorph( float3 vPosFlex, in float3 vPosition, out float3 vPosition_O )
|
||||
{
|
||||
// Flexes coming in from a separate stream
|
||||
float3 vPosDelta = vPosFlex.xyz * cFlexScale.x;
|
||||
vPosition_O.xyz = vPosition + vPosDelta;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ApplyMorph( float3 vPosFlex, float3 vNormalFlex,
|
||||
in float3 vPosition, out float3 vPosition_O,
|
||||
in float3 vNormal, out float3 vNormal_O )
|
||||
{
|
||||
// Flexes coming in from a separate stream
|
||||
float3 vPosDelta = vPosFlex.xyz * cFlexScale.x;
|
||||
float3 vNormalDelta = vNormalFlex.xyz * cFlexScale.x;
|
||||
vPosition_O.xyz = vPosition + vPosDelta;
|
||||
vNormal_O.xyz = vNormal + vNormalDelta;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ApplyMorph( float3 vPosFlex, float3 vNormalFlex,
|
||||
in float3 vPosition, out float3 vPosition_O,
|
||||
in float3 vNormal, out float3 vNormal_O,
|
||||
in float3 vTangent, out float3 vTangent_O )
|
||||
{
|
||||
// Flexes coming in from a separate stream
|
||||
float3 vPosDelta = vPosFlex.xyz * cFlexScale.x;
|
||||
float3 vNormalDelta = vNormalFlex.xyz * cFlexScale.x;
|
||||
vPosition_O.xyz = vPosition + vPosDelta;
|
||||
vNormal_O.xyz = vNormal + vNormalDelta;
|
||||
vTangent_O.xyz = vTangent + vNormalDelta;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ApplyMorph( float4 vPosFlex, float3 vNormalFlex,
|
||||
inout float3 vPosition, inout float3 vNormal, inout float3 vTangent, out float flWrinkle )
|
||||
{
|
||||
// Flexes coming in from a separate stream
|
||||
float3 vPosDelta = vPosFlex.xyz * cFlexScale.x;
|
||||
float3 vNormalDelta = vNormalFlex.xyz * cFlexScale.x;
|
||||
flWrinkle = vPosFlex.w * cFlexScale.y;
|
||||
vPosition.xyz += vPosDelta;
|
||||
vNormal += vNormalDelta;
|
||||
vTangent.xyz += vNormalDelta;
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SHADER_MODEL_VS_3_0
|
||||
|
||||
bool ApplyMorph( sampler2D morphSampler, const float3 vMorphTargetTextureDim, const float4 vMorphSubrect,
|
||||
const float flVertexID, const float3 vMorphTexCoord,
|
||||
in float3 vPosition, out float3 vPosition_O )
|
||||
{
|
||||
#if MORPHING
|
||||
|
||||
#if 1
|
||||
// Flexes coming in from a separate stream
|
||||
float4 vPosDelta = SampleMorphDelta( morphSampler, vMorphTargetTextureDim, vMorphSubrect, flVertexID, 0 );
|
||||
vPosition_O = vPosition + vPosDelta.xyz;
|
||||
#else
|
||||
float4 t = float4( vMorphTexCoord.x, vMorphTexCoord.y, 0.0f, 0.0f );
|
||||
float3 vPosDelta = tex2Dlod( morphSampler, t );
|
||||
vPosition += vPosDelta.xyz * vMorphTexCoord.z;
|
||||
#endif // DECAL
|
||||
|
||||
return true;
|
||||
|
||||
#else // !MORPHING
|
||||
vPosition_O = vPosition;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ApplyMorph( sampler2D morphSampler, const float3 vMorphTargetTextureDim, const float4 vMorphSubrect,
|
||||
const float flVertexID, const float3 vMorphTexCoord,
|
||||
in float3 vPosition, out float3 vPosition_O,
|
||||
in float3 vNormal, out float3 vNormal_O )
|
||||
{
|
||||
#if MORPHING
|
||||
|
||||
#if 1
|
||||
float4 vPosDelta, vNormalDelta;
|
||||
SampleMorphDelta2( morphSampler, vMorphTargetTextureDim, vMorphSubrect, flVertexID, vPosDelta, vNormalDelta );
|
||||
vPosition_O = vPosition + vPosDelta.xyz;
|
||||
vNormal_O = vNormal + vNormalDelta.xyz;
|
||||
#else
|
||||
float4 t = float4( vMorphTexCoord.x, vMorphTexCoord.y, 0.0f, 0.0f );
|
||||
float3 vPosDelta = tex2Dlod( morphSampler, t );
|
||||
t.x += 1.0f / vMorphTargetTextureDim.x;
|
||||
float3 vNormalDelta = tex2Dlod( morphSampler, t );
|
||||
vPosition += vPosDelta.xyz * vMorphTexCoord.z;
|
||||
vNormal += vNormalDelta.xyz * vMorphTexCoord.z;
|
||||
#endif // DECAL
|
||||
|
||||
return true;
|
||||
|
||||
#else // !MORPHING
|
||||
vPosition_O = vPosition;
|
||||
vNormal_O = vNormal;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ApplyMorph( sampler2D morphSampler, const float3 vMorphTargetTextureDim, const float4 vMorphSubrect,
|
||||
const float flVertexID, const float3 vMorphTexCoord,
|
||||
in float3 vPosition, out float3 vPosition_O,
|
||||
in float3 vNormal, out float3 vNormal_O,
|
||||
in float3 vTangent, out float3 vTangent_O )
|
||||
{
|
||||
#if MORPHING
|
||||
|
||||
#if 1
|
||||
float4 vPosDelta, vNormalDelta;
|
||||
SampleMorphDelta2( morphSampler, vMorphTargetTextureDim, vMorphSubrect, flVertexID, vPosDelta, vNormalDelta );
|
||||
vPosition_O = vPosition + vPosDelta.xyz;
|
||||
vNormal_O = vNormal + vNormalDelta.xyz;
|
||||
vTangent_O = vTangent + vNormalDelta.xyz;
|
||||
#else
|
||||
float4 t = float4( vMorphTexCoord.x, vMorphTexCoord.y, 0.0f, 0.0f );
|
||||
float3 vPosDelta = tex2Dlod( morphSampler, t );
|
||||
t.x += 1.0f / vMorphTargetTextureDim.x;
|
||||
float3 vNormalDelta = tex2Dlod( morphSampler, t );
|
||||
vPosition += vPosDelta.xyz * vMorphTexCoord.z;
|
||||
vNormal += vNormalDelta.xyz * vMorphTexCoord.z;
|
||||
vTangent += vNormalDelta.xyz * vMorphTexCoord.z;
|
||||
#endif // DECAL
|
||||
|
||||
return true;
|
||||
|
||||
#else // MORPHING
|
||||
vPosition_O = vPosition;
|
||||
vNormal_O = vNormal;
|
||||
vTangent_O = vTangent;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ApplyMorph( sampler2D morphSampler, const float3 vMorphTargetTextureDim, const float4 vMorphSubrect,
|
||||
const float flVertexID, const float3 vMorphTexCoord,
|
||||
inout float3 vPosition, inout float3 vNormal, inout float3 vTangent, out float flWrinkle )
|
||||
{
|
||||
#if MORPHING
|
||||
|
||||
#if !DECAL
|
||||
float4 vPosDelta, vNormalDelta;
|
||||
SampleMorphDelta2( morphSampler, vMorphTargetTextureDim, vMorphSubrect, flVertexID, vPosDelta, vNormalDelta );
|
||||
vPosition += vPosDelta.xyz;
|
||||
vNormal += vNormalDelta.xyz;
|
||||
vTangent += vNormalDelta.xyz;
|
||||
flWrinkle = vPosDelta.w;
|
||||
#else
|
||||
float4 t = float4( vMorphTexCoord.x, vMorphTexCoord.y, 0.0f, 0.0f );
|
||||
float4 vPosDelta = tex2Dlod( morphSampler, t );
|
||||
t.x += 1.0f / vMorphTargetTextureDim.x;
|
||||
float3 vNormalDelta = tex2Dlod( morphSampler, t );
|
||||
|
||||
vPosition += vPosDelta.xyz * vMorphTexCoord.z;
|
||||
vNormal += vNormalDelta.xyz * vMorphTexCoord.z;
|
||||
vTangent += vNormalDelta.xyz * vMorphTexCoord.z;
|
||||
flWrinkle = vPosDelta.w * vMorphTexCoord.z;
|
||||
#endif // DECAL
|
||||
|
||||
return true;
|
||||
|
||||
#else // MORPHING
|
||||
|
||||
flWrinkle = 0.0f;
|
||||
return false;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // SHADER_MODEL_VS_3_0
|
||||
|
||||
|
||||
float RangeFog( const float3 projPos )
|
||||
{
|
||||
return max( cFogMaxDensity, ( -projPos.z * cOOFogRange + cFogEndOverFogRange ) );
|
||||
}
|
||||
|
||||
float WaterFog( const float3 worldPos, const float3 projPos )
|
||||
{
|
||||
float4 tmp;
|
||||
|
||||
tmp.xy = cEyePosWaterZ.wz - worldPos.z;
|
||||
|
||||
// tmp.x is the distance from the water surface to the vert
|
||||
// tmp.y is the distance from the eye position to the vert
|
||||
|
||||
// if $tmp.x < 0, then set it to 0
|
||||
// This is the equivalent of moving the vert to the water surface if it's above the water surface
|
||||
|
||||
tmp.x = max( 0.0f, tmp.x );
|
||||
|
||||
// $tmp.w = $tmp.x / $tmp.y
|
||||
tmp.w = tmp.x / tmp.y;
|
||||
|
||||
tmp.w *= projPos.z;
|
||||
|
||||
// $tmp.w is now the distance that we see through water.
|
||||
|
||||
return max( cFogMaxDensity, ( -tmp.w * cOOFogRange + cFogOne ) );
|
||||
}
|
||||
|
||||
float CalcFog( const float3 worldPos, const float3 projPos, const int fogType )
|
||||
{
|
||||
#if defined( _X360 )
|
||||
// 360 only does pixel fog
|
||||
return 1.0f;
|
||||
#endif
|
||||
|
||||
if( fogType == FOGTYPE_RANGE )
|
||||
{
|
||||
return RangeFog( projPos );
|
||||
}
|
||||
else
|
||||
{
|
||||
#if SHADERMODEL_VS_2_0 == 1
|
||||
// We do this work in the pixel shader in dx9, so don't do any fog here.
|
||||
return 1.0f;
|
||||
#else
|
||||
return WaterFog( worldPos, projPos );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
float CalcFog( const float3 worldPos, const float3 projPos, const bool bWaterFog )
|
||||
{
|
||||
#if defined( _X360 )
|
||||
// 360 only does pixel fog
|
||||
return 1.0f;
|
||||
#endif
|
||||
|
||||
float flFog;
|
||||
if( !bWaterFog )
|
||||
{
|
||||
flFog = RangeFog( projPos );
|
||||
}
|
||||
else
|
||||
{
|
||||
#if SHADERMODEL_VS_2_0 == 1
|
||||
// We do this work in the pixel shader in dx9, so don't do any fog here.
|
||||
flFog = 1.0f;
|
||||
#else
|
||||
flFog = WaterFog( worldPos, projPos );
|
||||
#endif
|
||||
}
|
||||
|
||||
return flFog;
|
||||
}
|
||||
|
||||
float4 DecompressBoneWeights( const float4 weights )
|
||||
{
|
||||
float4 result = weights;
|
||||
|
||||
if ( COMPRESSED_VERTS )
|
||||
{
|
||||
// Decompress from SHORT2 to float. In our case, [-1, +32767] -> [0, +1]
|
||||
// NOTE: we add 1 here so we can divide by 32768 - which is exact (divide by 32767 is not).
|
||||
// This avoids cracking between meshes with different numbers of bone weights.
|
||||
// We use SHORT2 instead of SHORT2N for a similar reason - the GPU's conversion
|
||||
// from [-32768,+32767] to [-1,+1] is imprecise in the same way.
|
||||
result += 1;
|
||||
result /= 32768;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void SkinPosition( bool bSkinning, const float4 modelPos,
|
||||
const float4 boneWeights, float4 fBoneIndices,
|
||||
out float3 worldPos )
|
||||
{
|
||||
#if !defined( _X360 )
|
||||
int3 boneIndices = D3DCOLORtoUBYTE4( fBoneIndices );
|
||||
#else
|
||||
int3 boneIndices = fBoneIndices;
|
||||
#endif
|
||||
|
||||
// Needed for invariance issues caused by multipass rendering
|
||||
#if defined( _X360 )
|
||||
[isolate]
|
||||
#endif
|
||||
{
|
||||
if ( !bSkinning )
|
||||
{
|
||||
worldPos = mul4x3( modelPos, cModel[0] );
|
||||
}
|
||||
else // skinning - always three bones
|
||||
{
|
||||
float4x3 mat1 = cModel[boneIndices[0]];
|
||||
float4x3 mat2 = cModel[boneIndices[1]];
|
||||
float4x3 mat3 = cModel[boneIndices[2]];
|
||||
|
||||
float3 weights = DecompressBoneWeights( boneWeights ).xyz;
|
||||
weights[2] = 1 - (weights[0] + weights[1]);
|
||||
|
||||
float4x3 blendMatrix = mat1 * weights[0] + mat2 * weights[1] + mat3 * weights[2];
|
||||
worldPos = mul4x3( modelPos, blendMatrix );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SkinPositionAndNormal( bool bSkinning, const float4 modelPos, const float3 modelNormal,
|
||||
const float4 boneWeights, float4 fBoneIndices,
|
||||
out float3 worldPos, out float3 worldNormal )
|
||||
{
|
||||
// Needed for invariance issues caused by multipass rendering
|
||||
#if defined( _X360 )
|
||||
[isolate]
|
||||
#endif
|
||||
{
|
||||
|
||||
#if !defined( _X360 )
|
||||
int3 boneIndices = D3DCOLORtoUBYTE4( fBoneIndices );
|
||||
#else
|
||||
int3 boneIndices = fBoneIndices;
|
||||
#endif
|
||||
|
||||
if ( !bSkinning )
|
||||
{
|
||||
worldPos = mul4x3( modelPos, cModel[0] );
|
||||
worldNormal = mul3x3( modelNormal, ( const float3x3 )cModel[0] );
|
||||
}
|
||||
else // skinning - always three bones
|
||||
{
|
||||
float4x3 mat1 = cModel[boneIndices[0]];
|
||||
float4x3 mat2 = cModel[boneIndices[1]];
|
||||
float4x3 mat3 = cModel[boneIndices[2]];
|
||||
|
||||
float3 weights = DecompressBoneWeights( boneWeights ).xyz;
|
||||
weights[2] = 1 - (weights[0] + weights[1]);
|
||||
|
||||
float4x3 blendMatrix = mat1 * weights[0] + mat2 * weights[1] + mat3 * weights[2];
|
||||
worldPos = mul4x3( modelPos, blendMatrix );
|
||||
worldNormal = mul3x3( modelNormal, ( float3x3 )blendMatrix );
|
||||
}
|
||||
|
||||
} // end [isolate]
|
||||
}
|
||||
|
||||
// Is it worth keeping SkinPosition and SkinPositionAndNormal around since the optimizer
|
||||
// gets rid of anything that isn't used?
|
||||
void SkinPositionNormalAndTangentSpace(
|
||||
bool bSkinning,
|
||||
const float4 modelPos, const float3 modelNormal,
|
||||
const float4 modelTangentS,
|
||||
const float4 boneWeights, float4 fBoneIndices,
|
||||
out float3 worldPos, out float3 worldNormal,
|
||||
out float3 worldTangentS, out float3 worldTangentT )
|
||||
{
|
||||
#if !defined( _X360 )
|
||||
int3 boneIndices = D3DCOLORtoUBYTE4( fBoneIndices );
|
||||
#else
|
||||
int3 boneIndices = fBoneIndices;
|
||||
#endif
|
||||
|
||||
// Needed for invariance issues caused by multipass rendering
|
||||
#if defined( _X360 )
|
||||
[isolate]
|
||||
#endif
|
||||
{
|
||||
if ( !bSkinning )
|
||||
{
|
||||
worldPos = mul4x3( modelPos, cModel[0] );
|
||||
worldNormal = mul3x3( modelNormal, ( const float3x3 )cModel[0] );
|
||||
worldTangentS = mul3x3( ( float3 )modelTangentS, ( const float3x3 )cModel[0] );
|
||||
}
|
||||
else // skinning - always three bones
|
||||
{
|
||||
float4x3 mat1 = cModel[boneIndices[0]];
|
||||
float4x3 mat2 = cModel[boneIndices[1]];
|
||||
float4x3 mat3 = cModel[boneIndices[2]];
|
||||
|
||||
float3 weights = DecompressBoneWeights( boneWeights ).xyz;
|
||||
weights[2] = 1 - (weights[0] + weights[1]);
|
||||
|
||||
float4x3 blendMatrix = mat1 * weights[0] + mat2 * weights[1] + mat3 * weights[2];
|
||||
worldPos = mul4x3( modelPos, blendMatrix );
|
||||
worldNormal = mul3x3( modelNormal, ( const float3x3 )blendMatrix );
|
||||
worldTangentS = mul3x3( ( float3 )modelTangentS, ( const float3x3 )blendMatrix );
|
||||
}
|
||||
worldTangentT = cross( worldNormal, worldTangentS ) * -modelTangentS.w;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Lighting helper functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
float3 AmbientLight( const float3 worldNormal )
|
||||
{
|
||||
float3 nSquared = worldNormal * worldNormal;
|
||||
int3 isNegative = ( worldNormal < 0.0 );
|
||||
float3 linearColor;
|
||||
linearColor = nSquared.x * cAmbientCubeX[isNegative.x] +
|
||||
nSquared.y * cAmbientCubeY[isNegative.y] +
|
||||
nSquared.z * cAmbientCubeZ[isNegative.z];
|
||||
return linearColor;
|
||||
}
|
||||
|
||||
// The following "internal" routines are called "privately" by other routines in this file which
|
||||
// handle the particular flavor of vs20 control flow appropriate to the original caller
|
||||
float VertexAttenInternal( const float3 worldPos, int lightNum )
|
||||
{
|
||||
float result = 0.0f;
|
||||
|
||||
// Get light direction
|
||||
float3 lightDir = cLightInfo[lightNum].pos - worldPos;
|
||||
|
||||
// Get light distance squared.
|
||||
float lightDistSquared = dot( lightDir, lightDir );
|
||||
|
||||
// Get 1/lightDistance
|
||||
float ooLightDist = rsqrt( lightDistSquared );
|
||||
|
||||
// Normalize light direction
|
||||
lightDir *= ooLightDist;
|
||||
|
||||
float3 vDist;
|
||||
# if defined( _X360 )
|
||||
{
|
||||
//X360 dynamic compile hits an internal compiler error using dst(), this is the breakdown of how dst() works from the 360 docs.
|
||||
vDist.x = 1;
|
||||
vDist.y = lightDistSquared * ooLightDist;
|
||||
vDist.z = lightDistSquared;
|
||||
//flDist.w = ooLightDist;
|
||||
}
|
||||
# else
|
||||
{
|
||||
vDist = dst( lightDistSquared, ooLightDist );
|
||||
}
|
||||
# endif
|
||||
|
||||
float flDistanceAtten = 1.0f / dot( cLightInfo[lightNum].atten.xyz, vDist );
|
||||
|
||||
// Spot attenuation
|
||||
float flCosTheta = dot( cLightInfo[lightNum].dir.xyz, -lightDir );
|
||||
float flSpotAtten = (flCosTheta - cLightInfo[lightNum].spotParams.z) * cLightInfo[lightNum].spotParams.w;
|
||||
flSpotAtten = max( 0.0001f, flSpotAtten );
|
||||
flSpotAtten = pow( flSpotAtten, cLightInfo[lightNum].spotParams.x );
|
||||
flSpotAtten = saturate( flSpotAtten );
|
||||
|
||||
// Select between point and spot
|
||||
float flAtten = lerp( flDistanceAtten, flDistanceAtten * flSpotAtten, cLightInfo[lightNum].dir.w );
|
||||
|
||||
// Select between above and directional (no attenuation)
|
||||
result = lerp( flAtten, 1.0f, cLightInfo[lightNum].color.w );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
float CosineTermInternal( const float3 worldPos, const float3 worldNormal, int lightNum, bool bHalfLambert )
|
||||
{
|
||||
// Calculate light direction assuming this is a point or spot
|
||||
float3 lightDir = normalize( cLightInfo[lightNum].pos - worldPos );
|
||||
|
||||
// Select the above direction or the one in the structure, based upon light type
|
||||
lightDir = lerp( lightDir, -cLightInfo[lightNum].dir, cLightInfo[lightNum].color.w );
|
||||
|
||||
// compute N dot L
|
||||
float NDotL = dot( worldNormal, lightDir );
|
||||
|
||||
if ( !bHalfLambert )
|
||||
{
|
||||
NDotL = max( 0.0f, NDotL );
|
||||
}
|
||||
else // Half-Lambert
|
||||
{
|
||||
NDotL = NDotL * 0.5 + 0.5;
|
||||
NDotL = NDotL * NDotL;
|
||||
}
|
||||
return NDotL;
|
||||
}
|
||||
|
||||
// This routine uses booleans to do early-outs and is meant to be called by routines OUTSIDE of this file
|
||||
float GetVertexAttenForLight( const float3 worldPos, int lightNum )
|
||||
{
|
||||
float result = 0.0f;
|
||||
if ( g_bLightEnabled[lightNum] )
|
||||
{
|
||||
result = VertexAttenInternal( worldPos, lightNum );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// This routine uses booleans to do early-outs and is meant to be called by routines OUTSIDE of this file
|
||||
float CosineTerm( const float3 worldPos, const float3 worldNormal, int lightNum, bool bHalfLambert )
|
||||
{
|
||||
float flResult = 0.0f;
|
||||
if ( g_bLightEnabled[lightNum] )
|
||||
{
|
||||
flResult = CosineTermInternal( worldPos, worldNormal, lightNum, bHalfLambert );
|
||||
}
|
||||
|
||||
return flResult;
|
||||
}
|
||||
|
||||
float3 DoLightInternal( const float3 worldPos, const float3 worldNormal, int lightNum, bool bHalfLambert )
|
||||
{
|
||||
return cLightInfo[lightNum].color *
|
||||
CosineTermInternal( worldPos, worldNormal, lightNum, bHalfLambert ) *
|
||||
VertexAttenInternal( worldPos, lightNum );
|
||||
}
|
||||
|
||||
// This routine
|
||||
float3 DoLighting( const float3 worldPos, const float3 worldNormal,
|
||||
const float3 staticLightingColor, const bool bStaticLight,
|
||||
const bool bDynamicLight, bool bHalfLambert )
|
||||
{
|
||||
float3 linearColor = float3( 0.0f, 0.0f, 0.0f );
|
||||
|
||||
if( bStaticLight ) // Static light
|
||||
{
|
||||
float3 col = staticLightingColor * cOverbright;
|
||||
#if defined ( _X360 )
|
||||
linearColor += col * col;
|
||||
#else
|
||||
linearColor += GammaToLinear( col );
|
||||
#endif
|
||||
}
|
||||
|
||||
if( bDynamicLight ) // Dynamic light
|
||||
{
|
||||
for (int i = 0; i < g_nLightCount; i++)
|
||||
{
|
||||
linearColor += DoLightInternal( worldPos, worldNormal, i, bHalfLambert );
|
||||
}
|
||||
}
|
||||
|
||||
if( bDynamicLight )
|
||||
{
|
||||
linearColor += AmbientLight( worldNormal ); //ambient light is already remapped
|
||||
}
|
||||
|
||||
return linearColor;
|
||||
}
|
||||
|
||||
float3 DoLightingUnrolled( const float3 worldPos, const float3 worldNormal,
|
||||
const float3 staticLightingColor, const bool bStaticLight,
|
||||
const bool bDynamicLight, bool bHalfLambert, const int nNumLights )
|
||||
{
|
||||
float3 linearColor = float3( 0.0f, 0.0f, 0.0f );
|
||||
|
||||
if( bStaticLight ) // Static light
|
||||
{
|
||||
linearColor += GammaToLinear( staticLightingColor * cOverbright );
|
||||
}
|
||||
|
||||
if( bDynamicLight ) // Ambient light
|
||||
{
|
||||
if ( nNumLights >= 1 )
|
||||
linearColor += DoLightInternal( worldPos, worldNormal, 0, bHalfLambert );
|
||||
if ( nNumLights >= 2 )
|
||||
linearColor += DoLightInternal( worldPos, worldNormal, 1, bHalfLambert );
|
||||
if ( nNumLights >= 3 )
|
||||
linearColor += DoLightInternal( worldPos, worldNormal, 2, bHalfLambert );
|
||||
if ( nNumLights >= 4 )
|
||||
linearColor += DoLightInternal( worldPos, worldNormal, 3, bHalfLambert );
|
||||
}
|
||||
|
||||
if( bDynamicLight )
|
||||
{
|
||||
linearColor += AmbientLight( worldNormal ); //ambient light is already remapped
|
||||
}
|
||||
|
||||
return linearColor;
|
||||
}
|
||||
|
||||
int4 FloatToInt( in float4 floats )
|
||||
{
|
||||
return D3DCOLORtoUBYTE4( floats.zyxw / 255.001953125 );
|
||||
}
|
||||
|
||||
float2 ComputeSphereMapTexCoords( in float3 reflectionVector )
|
||||
{
|
||||
// transform reflection vector into view space
|
||||
reflectionVector = mul( reflectionVector, ( float3x3 )cViewModel );
|
||||
|
||||
// generate <rx ry rz+1>
|
||||
float3 tmp = float3( reflectionVector.x, reflectionVector.y, reflectionVector.z + 1.0f );
|
||||
|
||||
// find 1 / len
|
||||
float ooLen = dot( tmp, tmp );
|
||||
ooLen = 1.0f / sqrt( ooLen );
|
||||
|
||||
// tmp = tmp/|tmp| + 1
|
||||
tmp.xy = ooLen * tmp.xy + 1.0f;
|
||||
|
||||
return tmp.xy * 0.5f;
|
||||
}
|
||||
|
||||
|
||||
#define DEFORMATION_CLAMP_TO_BOX_IN_WORLDSPACE 1
|
||||
// minxyz.minsoftness / maxxyz.maxsoftness
|
||||
float3 ApplyDeformation( float3 worldpos, int deftype, float4 defparms0, float4 defparms1,
|
||||
float4 defparms2, float4 defparms3 )
|
||||
{
|
||||
float3 ret = worldpos;
|
||||
if ( deftype == DEFORMATION_CLAMP_TO_BOX_IN_WORLDSPACE )
|
||||
{
|
||||
ret=max( ret, defparms2.xyz );
|
||||
ret=min( ret, defparms3.xyz );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#endif //#ifndef COMMON_VS_FXC_H_
|
||||
@@ -1,45 +0,0 @@
|
||||
//========= Copyright <20> 1996-2006, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose: Provide convenient mapping for shader constants
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#define C_CODE_HACK
|
||||
#include "shader_constant_register_map.h"
|
||||
#undef C_CODE_HACK
|
||||
|
||||
// For the C code, map the above file's defines back to integers...
|
||||
#define PSREG_CONSTANT_00 0
|
||||
#define PSREG_CONSTANT_01 1
|
||||
#define PSREG_CONSTANT_02 2
|
||||
#define PSREG_CONSTANT_03 3
|
||||
#define PSREG_CONSTANT_04 4
|
||||
#define PSREG_CONSTANT_05 5
|
||||
#define PSREG_CONSTANT_06 6
|
||||
#define PSREG_CONSTANT_07 7
|
||||
#define PSREG_CONSTANT_08 8
|
||||
#define PSREG_CONSTANT_09 9
|
||||
#define PSREG_CONSTANT_10 10
|
||||
#define PSREG_CONSTANT_11 11
|
||||
#define PSREG_CONSTANT_12 12
|
||||
#define PSREG_CONSTANT_13 13
|
||||
#define PSREG_CONSTANT_14 14
|
||||
#define PSREG_CONSTANT_15 15
|
||||
#define PSREG_CONSTANT_16 16
|
||||
#define PSREG_CONSTANT_17 17
|
||||
#define PSREG_CONSTANT_18 18
|
||||
#define PSREG_CONSTANT_19 19
|
||||
#define PSREG_CONSTANT_20 20
|
||||
#define PSREG_CONSTANT_21 21
|
||||
#define PSREG_CONSTANT_22 22
|
||||
#define PSREG_CONSTANT_23 23
|
||||
#define PSREG_CONSTANT_24 24
|
||||
#define PSREG_CONSTANT_25 25
|
||||
#define PSREG_CONSTANT_26 26
|
||||
#define PSREG_CONSTANT_27 27
|
||||
#define PSREG_CONSTANT_28 28
|
||||
#define PSREG_CONSTANT_29 29
|
||||
#define PSREG_CONSTANT_30 30
|
||||
#define PSREG_CONSTANT_31 31
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
// Combos
|
||||
// STATIC: "FLASHLIGHT" "0..1"
|
||||
// DYNAMIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2"
|
||||
// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1"
|
||||
// DYNAMIC: "PIXELFOGTYPE" "0..1"
|
||||
// DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1"
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
sampler _gSampler_Flashlight_Cookie : register( s1 );
|
||||
sampler _gSampler_Flashlight_Depth : register( s2 );
|
||||
sampler _gSampler_Flashlight_Random : register( s3 );
|
||||
|
||||
// Constants
|
||||
const float3 g_cData_grass_spec_color : register( c16 ); // Static
|
||||
const float3 _g_VecForward : register( c17 );
|
||||
const float4 _g_FogParams : register( c18 );
|
||||
const float3 _g_VecOrig : register( c19 );
|
||||
const float4 g_cFlashlightAttenuationFactors : register( c8 );
|
||||
const float4 g_cFlashlightPos : register( c9 );
|
||||
const float4 g_cShadowTweaks : register( c7 );
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
float3 vTexCoord_1 : TEXCOORD1;
|
||||
float4 vTexCoord_2 : TEXCOORD2;
|
||||
float4 vTexCoord_3 : TEXCOORD3;
|
||||
float3 vTexCoord_4 : TEXCOORD4;
|
||||
float vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float4 _texLookup_16 = tex2D( _Sampler_00, In.vTexCoord_0 );
|
||||
float3 _var0 = _texLookup_16.rgb;
|
||||
float _var1 = _texLookup_16.a;
|
||||
float3 _var2 = float3( 0.000000, 0.000000, 0.000000 );
|
||||
float3 _var3 = float3( 0.000000, 0.000000, 0.000000 );
|
||||
float3 _var4 = float( -1.000000 ) * _g_VecForward;
|
||||
float _var5 = _g_VecOrig.z;
|
||||
float _var6 = In.vTexCoord_4.z;
|
||||
float _var7 = In.vTexCoord_3.z;
|
||||
#if ( FLASHLIGHT == 0 )
|
||||
float _var8 = smoothstep( float( 0.290000 ), float( 0.300000 ), _var1 );
|
||||
_var3 = In.vTexCoord_1;
|
||||
_var8 = In.vColor_0 * _var8;
|
||||
float3 _var9 = _var8 * g_cData_grass_spec_color;
|
||||
_var2 = _var9;
|
||||
#endif
|
||||
#if ( FLASHLIGHT == 1 )
|
||||
float2 _var10 = In.vTexCoord_3.xy;
|
||||
float _var11 = In.vTexCoord_3.w;
|
||||
_var10 = _var10 / _var11;
|
||||
_var4 = DoFlashlight( g_cFlashlightPos.xyz, In.vTexCoord_4, In.vTexCoord_2, _var4,
|
||||
g_cFlashlightAttenuationFactors.xyz, g_cFlashlightAttenuationFactors.w,
|
||||
_gSampler_Flashlight_Cookie, _gSampler_Flashlight_Depth, _gSampler_Flashlight_Random,
|
||||
FLASHLIGHTDEPTHFILTERMODE, FLASHLIGHTSHADOWS, true,
|
||||
_var10, false, g_cShadowTweaks );
|
||||
_var3 = _var4;
|
||||
#endif
|
||||
_var0 = _var0 + _var2;
|
||||
_var3 = _var3;
|
||||
float _var12 = _var1 - float( 0.100000 );
|
||||
_var5 = CalcPixelFogFactor( PIXELFOGTYPE, _g_FogParams, _var5, _var6, _var7 );
|
||||
_var0 = _var0 * _var3;
|
||||
clip( _var12 );
|
||||
float4 _var13 = float4( _var0, _var12 );
|
||||
_var13 = FinalOutput( _var13, _var5, PIXELFOGTYPE, TONEMAP_SCALE_GAMMA, true, _var7 );
|
||||
Out.vColor_0 = _var13;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
// Combos
|
||||
// STATIC: "FLASHLIGHT" "0..1"
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Constants
|
||||
const float3 g_cData_Mutable_01 : register( c48 ); // Mutable
|
||||
const float g_cData_Mutable_02 : register( c49 ); // Mutable
|
||||
const float _g_Time : register( c50 );
|
||||
const float4x4 g_cFlashlightWorldToTexture : register( c51 );
|
||||
|
||||
// User code - globals
|
||||
float3 triangle( float3 a )
|
||||
{
|
||||
return abs( frac( a + 0.5f ) * 2.0f - 1.0f );
|
||||
}
|
||||
|
||||
// User code - function bodies
|
||||
void UserFunction_195( in float3 var_00, out float3 var_01 )
|
||||
{
|
||||
var_01 = triangle( var_00 );
|
||||
|
||||
var_01 = ( 3.0 - 2.000000000001 * var_01 ) * var_01 * var_01;
|
||||
}
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float3 vNormal : NORMAL;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
float3 vTexCoord_1 : TEXCOORD1;
|
||||
float3 vTexCoord_2 : TEXCOORD2;
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
float3 vTexCoord_1 : TEXCOORD1;
|
||||
float4 vTexCoord_2 : TEXCOORD2;
|
||||
float4 vTexCoord_3 : TEXCOORD3;
|
||||
float3 vTexCoord_4 : TEXCOORD4;
|
||||
float vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float _var0 = dot( In.vTexCoord_2, In.vNormal );
|
||||
float _var1 = In.vTexCoord_1.z;
|
||||
float3 _var2 = In.vNormal * float( -0.900000 );
|
||||
float _var3 = dot( In.vNormal, g_cData_Mutable_01 );
|
||||
float _var4 = In.vTexCoord_1.y;
|
||||
float _var5 = In.vTexCoord_1.x;
|
||||
float _var6 = cos( g_cData_Mutable_02 );
|
||||
float _var7 = In.vPos.x;
|
||||
float _var8 = sin( g_cData_Mutable_02 );
|
||||
float _var9 = In.vPos.y;
|
||||
float _var10 = In.vPos.z;
|
||||
float _var11 = _g_Time * float( 0.700000 );
|
||||
float3 _var12 = In.vColor_0.xyz;
|
||||
float4 _var13 = float4( 0.000000, 0.000000, 0.000000, 0.000000 );
|
||||
float3 _var14 = _var0 * In.vNormal;
|
||||
_var2 = _var1 * _var2;
|
||||
float3 _var15 = _var3 * In.vNormal;
|
||||
float _var16 = 1.0f - _var4;
|
||||
float _var17 = _var6 * _var7;
|
||||
float _var18 = _var8 * _var9;
|
||||
float _var19 = _var9 * _var6;
|
||||
float _var20 = _var8 * _var7;
|
||||
float _var21 = _var4 * float( 0.400000 );
|
||||
_var14 = In.vTexCoord_2 - _var14;
|
||||
_var15 = g_cData_Mutable_01 - _var15;
|
||||
float _var22 = _var16 * _var5;
|
||||
_var17 = _var17 - _var18;
|
||||
_var19 = _var19 + _var20;
|
||||
_var12 = _var21 + _var12;
|
||||
float _var23 = _var5 * _var16;
|
||||
_var14 = _var14 * _var1;
|
||||
_var15 = normalize( _var15 );
|
||||
float2 _var24 = float2( _var17, _var19 );
|
||||
_var14 = _var14 + _var2;
|
||||
_var15 = _var15 * float( 2.000000 );
|
||||
float3 _var25 = float3( _var24, _var10 );
|
||||
_var15 = _var15 * _var22;
|
||||
_var25 = _var25 * float( 0.005000 );
|
||||
_var25 = _var25 + _var11;
|
||||
float3 _var26 = (float3)0;
|
||||
UserFunction_195( _var25, _var26 );
|
||||
float3 _var27 = sin( _var25 );
|
||||
float3 _var28 = abs( _var26 );
|
||||
float3 _var29 = sign( _var26 );
|
||||
_var27 = abs( _var27 );
|
||||
_var28 = pow( _var28, float( 3.000000 ) );
|
||||
float _var30 = dot( _var27, float3( 0.333333, 0.333333, 0.333333 ) );
|
||||
_var29 = _var28 * _var29;
|
||||
float3 _var31 = _var12 * _var30;
|
||||
float _var32 = dot( _var28, float3( 0.333333, 0.333333, 0.333333 ) );
|
||||
float _var33 = pow( _var30, float( 2.000000 ) );
|
||||
_var15 = _var15 * _var29;
|
||||
_var31 = lerp( _var12, _var31, float( 0.400000 ) );
|
||||
_var32 = _var32 * _var33;
|
||||
_var15 = In.vPos + _var15;
|
||||
_var23 = _var23 * _var32;
|
||||
_var14 = _var14 + _var15;
|
||||
float4 _var34 = mul( float4(_var14.xyz,1), cModelViewProj );
|
||||
float4 _var35 = _var34;
|
||||
#if ( FLASHLIGHT == 1 )
|
||||
float4 _var36 = mul( float4(_var14.xyz,1), g_cFlashlightWorldToTexture );
|
||||
float2 _var37 = _var34.xy;
|
||||
float _var38 = _var34.z;
|
||||
float _var39 = _var34.w;
|
||||
_var13 = _var36;
|
||||
_var38 = _var38 - float( 0.100000 );
|
||||
float3 _var40 = float3( _var37, _var38 );
|
||||
float4 _var41 = float4( _var40, _var39 );
|
||||
_var35 = _var41;
|
||||
#endif
|
||||
Out.vProjPos = _var35;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
Out.vTexCoord_1 = _var31;
|
||||
Out.vTexCoord_2 = _var13;
|
||||
Out.vTexCoord_3 = _var35;
|
||||
Out.vTexCoord_4 = _var14;
|
||||
Out.vColor_0 = _var23;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
|
||||
// Constants
|
||||
const float2 _g_TexelSize : register( c16 );
|
||||
|
||||
// Arrays
|
||||
static const float2 g_cArray_202[4] =
|
||||
{
|
||||
float2( 0.000000f, 0.000000f ),
|
||||
float2( 2.000000f, 0.000000f ),
|
||||
float2( 0.000000f, 2.000000f ),
|
||||
float2( 2.000000f, 2.000000f ),
|
||||
};
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float4 _var0 = float4( 0.000000, 0.000000, 0.000000, 0.000000 );
|
||||
float2 _var1 = _g_TexelSize * float( 0.500000 );
|
||||
_var1 = In.vTexCoord_0 + _var1;
|
||||
for ( int _var2 = 0; _var2 < 4; _var2++ )
|
||||
{
|
||||
float2 _var3 = _var1;
|
||||
float2 _var4 = g_cArray_202[_var2] * _g_TexelSize;
|
||||
_var3 = _var3 + _var4;
|
||||
float4 _var5 = tex2D( _Sampler_00, _var3 ).rgba;
|
||||
_var0 = _var0 + _var5;
|
||||
}
|
||||
_var0 = _var0 * float( 0.250000 );
|
||||
Out.vColor_0 = _var0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = float4( In.vPos.x, In.vPos.y, In.vPos.z, 1.000000 );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
*** generated by shadereditor.dll ***
|
||||
#BEGIN 000000_lightmap_parallax_pos_preview_vs30
|
||||
000000_lightmap_parallax_pos_preview_vs30.fxc
|
||||
#DEFINES-D:
|
||||
#DEFINES-S:
|
||||
#SKIP:
|
||||
(defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED)||(defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA)||(defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0)||(defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT)||(defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST)||(defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH)||(($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW)||0
|
||||
#COMMAND:
|
||||
fxc.exe /DTOTALSHADERCOMBOS=1 /DCENTROIDMASK=0 /DNUMDYNAMICCOMBOS=1 /DFLAGS=0x0 /Dmain=main /Emain /Tvs_3_0 /DSHADER_MODEL_VS_3_0=1 /nologo /Foshader.o 000000_lightmap_parallax_pos_preview_vs30.fxc>output.txt 2>&1
|
||||
#END
|
||||
*************************************
|
||||
*** generated by shadereditor.dll ***
|
||||
#BEGIN 000000_lightmap_parallax_pos_preview_vs30
|
||||
000000_lightmap_parallax_pos_preview_vs30.fxc
|
||||
#DEFINES-D:
|
||||
#DEFINES-S:
|
||||
#SKIP:
|
||||
(defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED)||(defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA)||(defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0)||(defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT)||(defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST)||(defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH)||(($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW)||0
|
||||
#COMMAND:
|
||||
fxc.exe /DTOTALSHADERCOMBOS=1 /DCENTROIDMASK=0 /DNUMDYNAMICCOMBOS=1 /DFLAGS=0x0 /Dmain=main /Emain /Tvs_3_0 /DSHADER_MODEL_VS_3_0=1 /nologo /Foshader.o 000000_lightmap_parallax_pos_preview_vs30.fxc>output.txt 2>&1
|
||||
#END
|
||||
*************************************
|
||||
|
||||
*** generated by shadereditor.dll ***
|
||||
#BEGIN 000000_lightmap_parallax_preview_vs30
|
||||
000000_lightmap_parallax_preview_vs30.fxc
|
||||
#DEFINES-D:
|
||||
#DEFINES-S:
|
||||
#SKIP:
|
||||
(defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED)||(defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA)||(defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0)||(defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT)||(defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST)||(defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH)||(($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW)||0
|
||||
#COMMAND:
|
||||
fxc.exe /DTOTALSHADERCOMBOS=1 /DCENTROIDMASK=0 /DNUMDYNAMICCOMBOS=1 /DFLAGS=0x0 /Dmain=main /Emain /Tvs_3_0 /DSHADER_MODEL_VS_3_0=1 /nologo /Foshader.o 000000_lightmap_parallax_preview_vs30.fxc>output.txt 2>&1
|
||||
#END
|
||||
*************************************
|
||||
*** generated by shadereditor.dll ***
|
||||
#BEGIN 000000_lightmap_parallax_preview_vs30
|
||||
000000_lightmap_parallax_preview_vs30.fxc
|
||||
#DEFINES-D:
|
||||
#DEFINES-S:
|
||||
#SKIP:
|
||||
(defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED)||(defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA)||(defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0)||(defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT)||(defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST)||(defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH)||(($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW)||0
|
||||
#COMMAND:
|
||||
fxc.exe /DTOTALSHADERCOMBOS=1 /DCENTROIDMASK=0 /DNUMDYNAMICCOMBOS=1 /DFLAGS=0x0 /Dmain=main /Emain /Tvs_3_0 /DSHADER_MODEL_VS_3_0=1 /nologo /Foshader.o 000000_lightmap_parallax_preview_vs30.fxc>output.txt 2>&1
|
||||
#END
|
||||
*************************************
|
||||
|
||||
*** generated by shadereditor.dll ***
|
||||
#BEGIN 000000_lightmap_parallax_preview_ps30
|
||||
000000_lightmap_parallax_preview_ps30.fxc
|
||||
#DEFINES-D:
|
||||
#DEFINES-S:
|
||||
#SKIP:
|
||||
(defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED)||(defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA)||(defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0)||(defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT)||(defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST)||(defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH)||(($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW)||0
|
||||
#COMMAND:
|
||||
fxc.exe /DTOTALSHADERCOMBOS=48 /DCENTROIDMASK=0 /DNUMDYNAMICCOMBOS=1 /DFLAGS=0x0 /Dmain=main /Emain /Tps_3_0 /DSHADER_MODEL_PS_3_0=1 /nologo /Foshader.o 000000_lightmap_parallax_preview_ps30.fxc>output.txt 2>&1
|
||||
#END
|
||||
*************************************
|
||||
*** generated by shadereditor.dll ***
|
||||
#BEGIN 000000_lightmap_parallax_preview_ps30
|
||||
000000_lightmap_parallax_preview_ps30.fxc
|
||||
#DEFINES-D:
|
||||
#DEFINES-S:
|
||||
#SKIP:
|
||||
(defined $HDRTYPE && defined $HDRENABLED && !$HDRTYPE && $HDRENABLED)||(defined $PIXELFOGTYPE && defined $WRITEWATERFOGTODESTALPHA && ( $PIXELFOGTYPE != 1 ) && $WRITEWATERFOGTODESTALPHA)||(defined $LIGHTING_PREVIEW && defined $HDRTYPE && $LIGHTING_PREVIEW && $HDRTYPE != 0)||(defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPTINT && $LIGHTING_PREVIEW && $FASTPATHENVMAPTINT)||(defined $LIGHTING_PREVIEW && defined $FASTPATHENVMAPCONTRAST && $LIGHTING_PREVIEW && $FASTPATHENVMAPCONTRAST)||(defined $LIGHTING_PREVIEW && defined $FASTPATH && $LIGHTING_PREVIEW && $FASTPATH)||(($FLASHLIGHT || $FLASHLIGHTSHADOWS) && $LIGHTING_PREVIEW)||0
|
||||
#COMMAND:
|
||||
fxc.exe /DTOTALSHADERCOMBOS=48 /DCENTROIDMASK=0 /DNUMDYNAMICCOMBOS=1 /DFLAGS=0x0 /Dmain=main /Emain /Tps_3_0 /DSHADER_MODEL_PS_3_0=1 /nologo /Foshader.o 000000_lightmap_parallax_preview_ps30.fxc>output.txt 2>&1
|
||||
#END
|
||||
*************************************
|
||||
@@ -1,58 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
|
||||
// Constants
|
||||
const float2 _g_TexelSize : register( c16 );
|
||||
|
||||
// Arrays
|
||||
static const float g_cArray_231[5] =
|
||||
{
|
||||
float( 0.054489f ),
|
||||
float( 0.244201f ),
|
||||
float( 0.402620f ),
|
||||
float( 0.244201f ),
|
||||
float( 0.054489f ),
|
||||
};
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float4 _var0 = float4( 0.000000, 0.000000, 0.000000, 0.000000 );
|
||||
float2 _var1 = float2( 3.000000, 0.000000 ) * _g_TexelSize;
|
||||
float2 _var2 = float2( 1.000000, 0.000000 ) * _g_TexelSize;
|
||||
_var1 = In.vTexCoord_0 - _var1;
|
||||
for ( int _var3 = 0; _var3 < 5; _var3++ )
|
||||
{
|
||||
_var1 = _var1 + _var2;
|
||||
float4 _var4 = tex2D( _Sampler_00, _var1 ).rgba;
|
||||
_var4 = _var4 * g_cArray_231[_var3];
|
||||
_var0 = _var0 + _var4;
|
||||
}
|
||||
Out.vColor_0 = _var0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = float4( In.vPos.x, In.vPos.y, In.vPos.z, 1.000000 );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
|
||||
// Constants
|
||||
const float2 _g_TexelSize : register( c16 );
|
||||
|
||||
// Arrays
|
||||
static const float g_cArray_253[5] =
|
||||
{
|
||||
float( 0.054489f ),
|
||||
float( 0.244201f ),
|
||||
float( 0.402620f ),
|
||||
float( 0.244201f ),
|
||||
float( 0.054489f ),
|
||||
};
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float4 _var0 = float4( 0.000000, 0.000000, 0.000000, 0.000000 );
|
||||
float2 _var1 = float2( 0.000000, 3.000000 ) * _g_TexelSize;
|
||||
float2 _var2 = float2( 0.000000, 1.000000 ) * _g_TexelSize;
|
||||
_var1 = In.vTexCoord_0 - _var1;
|
||||
for ( int _var3 = 0; _var3 < 5; _var3++ )
|
||||
{
|
||||
_var1 = _var1 + _var2;
|
||||
float4 _var4 = tex2D( _Sampler_00, _var1 ).rgba;
|
||||
_var4 = _var4 * g_cArray_253[_var3];
|
||||
_var0 = _var0 + _var4;
|
||||
}
|
||||
Out.vColor_0 = _var0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = float4( In.vPos.x, In.vPos.y, In.vPos.z, 1.000000 );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
|
||||
// Constants
|
||||
const float2 _g_TexelSize : register( c16 );
|
||||
|
||||
// Arrays
|
||||
static const float g_cArray_274[7] =
|
||||
{
|
||||
float( 0.167839f ),
|
||||
float( 0.684901f ),
|
||||
float( 1.592437f ),
|
||||
float( 2.109639f ),
|
||||
float( 1.592437f ),
|
||||
float( 0.684901f ),
|
||||
float( 0.167839f ),
|
||||
};
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float4 _var0 = float4( 0.000000, 0.000000, 0.000000, 0.000000 );
|
||||
float2 _var1 = float2( 4.000000, 0.000000 ) * _g_TexelSize;
|
||||
float2 _var2 = float2( 1.000000, 0.000000 ) * _g_TexelSize;
|
||||
float _var3 = float( 0.000000 );
|
||||
_var1 = In.vTexCoord_0 - _var1;
|
||||
for ( int _var4 = 0; _var4 < 7; _var4++ )
|
||||
{
|
||||
_var1 = _var1 + _var2;
|
||||
float4 _texLookup_16 = tex2D( _Sampler_00, _var1 );
|
||||
float3 _var5 = _texLookup_16.rgb;
|
||||
float _var6 = _texLookup_16.a;
|
||||
_var6 = ceil( _var6 );
|
||||
float4 _var7 = float4( _var5, _var6 );
|
||||
_var3 = _var3 + _var6;
|
||||
_var7 = _var7 * g_cArray_274[_var4];
|
||||
_var0 = _var0 + _var7;
|
||||
}
|
||||
float3 _var8 = _var0.xyz;
|
||||
float _var9 = _var0.w;
|
||||
_var8 = _var8 / _var3;
|
||||
_var9 = _var9 / float( 7.000000 );
|
||||
float4 _var10 = float4( _var8, _var9 );
|
||||
Out.vColor_0 = _var10;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = float4( In.vPos.x, In.vPos.y, In.vPos.z, 1.000000 );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
|
||||
// Constants
|
||||
const float2 _g_TexelSize : register( c16 );
|
||||
|
||||
// Arrays
|
||||
static const float g_cArray_305[7] =
|
||||
{
|
||||
float( 0.167839f ),
|
||||
float( 0.684901f ),
|
||||
float( 1.592437f ),
|
||||
float( 2.109639f ),
|
||||
float( 1.592437f ),
|
||||
float( 0.684901f ),
|
||||
float( 0.167839f ),
|
||||
};
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float4 _var0 = float4( 0.000000, 0.000000, 0.000000, 0.000000 );
|
||||
float2 _var1 = float2( 0.000000, 4.000000 ) * _g_TexelSize;
|
||||
float2 _var2 = float2( 0.000000, 1.000000 ) * _g_TexelSize;
|
||||
float _var3 = float( 0.000000 );
|
||||
_var1 = In.vTexCoord_0 - _var1;
|
||||
for ( int _var4 = 0; _var4 < 7; _var4++ )
|
||||
{
|
||||
_var1 = _var1 + _var2;
|
||||
float4 _texLookup_16 = tex2D( _Sampler_00, _var1 );
|
||||
float4 _var5 = _texLookup_16.rgba;
|
||||
float _var6 = _texLookup_16.a;
|
||||
_var5 = _var5 * g_cArray_305[_var4];
|
||||
_var6 = ceil( _var6 );
|
||||
_var0 = _var0 + _var5;
|
||||
_var3 = _var3 + _var6;
|
||||
}
|
||||
float3 _var7 = _var0.xyz;
|
||||
float _var8 = _var0.w;
|
||||
_var7 = _var7 / _var3;
|
||||
_var8 = _var8 / float( 7.000000 );
|
||||
float4 _var9 = float4( _var7, _var8 );
|
||||
Out.vColor_0 = _var9;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = float4( In.vPos.x, In.vPos.y, In.vPos.z, 1.000000 );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
|
||||
// Constants
|
||||
const float2 _g_TexelSize : register( c16 );
|
||||
|
||||
// Arrays
|
||||
static const float g_cArray_332[3] =
|
||||
{
|
||||
float( 0.196842f ),
|
||||
float( 0.606316f ),
|
||||
float( 0.196842f ),
|
||||
};
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float4 _var0 = float4( 0.000000, 0.000000, 0.000000, 0.000000 );
|
||||
float2 _var1 = float2( 2.000000, 0.000000 ) * _g_TexelSize;
|
||||
float2 _var2 = float2( 1.000000, 0.000000 ) * _g_TexelSize;
|
||||
_var1 = In.vTexCoord_0 - _var1;
|
||||
for ( int _var3 = 0; _var3 < 3; _var3++ )
|
||||
{
|
||||
_var1 = _var1 + _var2;
|
||||
float4 _var4 = tex2D( _Sampler_00, _var1 ).rgba;
|
||||
_var4 = _var4 * g_cArray_332[_var3];
|
||||
_var0 = _var0 + _var4;
|
||||
}
|
||||
Out.vColor_0 = _var0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = float4( In.vPos.x, In.vPos.y, In.vPos.z, 1.000000 );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
|
||||
// Constants
|
||||
const float2 _g_TexelSize : register( c16 );
|
||||
|
||||
// Arrays
|
||||
static const float g_cArray_351[3] =
|
||||
{
|
||||
float( 0.196842f ),
|
||||
float( 0.606316f ),
|
||||
float( 0.196842f ),
|
||||
};
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float4 _var0 = float4( 0.000000, 0.000000, 0.000000, 0.000000 );
|
||||
float2 _var1 = float2( 0.000000, 2.000000 ) * _g_TexelSize;
|
||||
float2 _var2 = float2( 0.000000, 1.000000 ) * _g_TexelSize;
|
||||
_var1 = In.vTexCoord_0 - _var1;
|
||||
for ( int _var3 = 0; _var3 < 3; _var3++ )
|
||||
{
|
||||
_var1 = _var1 + _var2;
|
||||
float4 _var4 = tex2D( _Sampler_00, _var1 ).rgba;
|
||||
_var4 = _var4 * g_cArray_351[_var3];
|
||||
_var0 = _var0 + _var4;
|
||||
}
|
||||
Out.vColor_0 = _var0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = float4( In.vPos.x, In.vPos.y, In.vPos.z, 1.000000 );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,260 +0,0 @@
|
||||
// Absolute value (per component).
|
||||
auto abs( multi x );
|
||||
|
||||
// Returns the arccosine of each component of x.
|
||||
auto acos( multi x );
|
||||
|
||||
// Test if all components of x are nonzero.
|
||||
auto all( multi x );
|
||||
|
||||
// Test if any component of x is nonzero.
|
||||
auto any( multi x );
|
||||
|
||||
// Returns the arcsine of each component of x.
|
||||
auto asin( multi x );
|
||||
|
||||
// Returns the arctangent of x.
|
||||
auto atan( multi x );
|
||||
|
||||
// Returns the arctangent of of two values (x,y).
|
||||
auto atan2( multi x, auto y );
|
||||
|
||||
// Returns the smallest integer which is greater than or equal to x.
|
||||
auto ceil( multi x );
|
||||
|
||||
// Clamps x to the range [min, max].
|
||||
auto clamp( multi x, auto min, auto max );
|
||||
|
||||
// Discards the current pixel, if any component of x is less than zero.
|
||||
auto clip( multi x );
|
||||
|
||||
// Returns the cosine of x.
|
||||
auto cos( multi x );
|
||||
|
||||
// Returns the hyperbolic cosine of x.
|
||||
auto cosh( multi x );
|
||||
|
||||
// Returns the cross product of two 3D vectors.
|
||||
float3 cross( float3 x, float3 y );
|
||||
|
||||
// Swizzles and scales components of the 4D vector xto compensate for the lack of UBYTE4 support in some hardware.
|
||||
int4 D3DCOLORtoUBYTE4( float4 x );
|
||||
|
||||
// Returns the partial derivative of x with respect to the screen-space x-coordinate.
|
||||
auto ddx( multi x );
|
||||
|
||||
// Returns the partial derivative of x with respect to the screen-space y-coordinate.
|
||||
auto ddy( multi x );
|
||||
|
||||
// Converts x from radians to degrees.
|
||||
auto degrees( multi x );
|
||||
|
||||
// Returns the determinant of the square matrix m.
|
||||
float determinant( matrix m );
|
||||
|
||||
// Returns the distance between two points.
|
||||
float distance( vector x, vector y );
|
||||
|
||||
// Returns the dot product of two vectors.
|
||||
float dot( vector x, vector y );
|
||||
|
||||
// Returns the base-e exponent.
|
||||
auto exp( multi x );
|
||||
|
||||
// Base 2 exponent (per component).
|
||||
auto exp2( multi x );
|
||||
|
||||
// Returns -n * sign(dot(i, ng)).
|
||||
auto faceforward( vector n, auto i, auto ng );
|
||||
|
||||
// Returns the greatest integer which is less than or equal to x.
|
||||
auto floor( multi x );
|
||||
|
||||
// Returns the floating point remainder of x/y.
|
||||
auto fmod( multi x, auto y );
|
||||
|
||||
// Returns the fractional part of x.
|
||||
auto frac( multi x );
|
||||
|
||||
// Returns the mantissa and exponent of x.
|
||||
auto frexp( multi x, auto exp );
|
||||
|
||||
// Returns abs(ddx(x)) + abs(ddy(x))
|
||||
auto fwidth( multi x );
|
||||
|
||||
// Returns true if x is finite, false otherwise.
|
||||
bool isfinite( multi x );
|
||||
|
||||
// Returns true if x is +INF or -INF, false otherwise.
|
||||
bool isinf( multi x );
|
||||
|
||||
// Returns true if x is NAN or QNAN, false otherwise.
|
||||
bool isnan( multi x );
|
||||
|
||||
// Returns x * 2exp
|
||||
auto ldexp( multi x, auto exp );
|
||||
|
||||
// Returns the length of the vector v.
|
||||
float length( vector x );
|
||||
|
||||
// Returns x + s(y - x).
|
||||
auto lerp( multi x, auto y, auto s );
|
||||
|
||||
// Returns a lighting vector (ambient, diffuse, specular, 1)
|
||||
float4 lit( float n_dot_l, float n_dot_h, float m );
|
||||
|
||||
// Returns the base-e logarithm of x.
|
||||
auto log( multi x );
|
||||
|
||||
// Returns the base-10 logarithm of x.
|
||||
auto log10( multi x );
|
||||
|
||||
// Returns the base-2 logarithm of x.
|
||||
auto log2( multi x );
|
||||
|
||||
// Selects the greater of x and y.
|
||||
auto max( multi x, auto y );
|
||||
|
||||
// Selects the lesser of x and y.
|
||||
auto min( multi x, auto y );
|
||||
|
||||
// Splits the value x into fractional and integer parts.
|
||||
auto modf( multi x, out auto ip );
|
||||
|
||||
// Performs matrix multiplication using x and y.
|
||||
multi mul( multi x, multi y );
|
||||
|
||||
// Generates a random value using the Perlin-noise algorithm.
|
||||
float noise( vector x );
|
||||
|
||||
// Returns a normalized vector.
|
||||
auto normalize( vector x );
|
||||
|
||||
// Returns x^y
|
||||
auto pow( multi x, auto y );
|
||||
|
||||
// Converts x from degrees to radians.
|
||||
auto radians( multi x );
|
||||
|
||||
// Returns a reflection vector.
|
||||
auto reflect( vector i, auto n );
|
||||
|
||||
// Returns the refraction vector.
|
||||
auto refract( vector i, auto n, float index );
|
||||
|
||||
// Rounds x to the nearest integer.
|
||||
auto round( multi x );
|
||||
|
||||
// Returns 1 / sqrt(x)
|
||||
auto rsqrt( multi x );
|
||||
|
||||
// Clamps x to the range [0, 1]
|
||||
auto saturate( multi x );
|
||||
|
||||
// Computes the sign of x.
|
||||
auto sign( multi x );
|
||||
|
||||
// Returns the sine of x
|
||||
auto sin( multi x );
|
||||
|
||||
// Returns the sine and cosine of x.
|
||||
void sincos( multi x, out auto s, out auto c );
|
||||
|
||||
// Returns the hyperbolic sine of x
|
||||
auto sinh( multi x );
|
||||
|
||||
// Returns a smooth Hermite interpolation between 0 and 1.
|
||||
auto smoothstep( auto min, auto max, multi x );
|
||||
|
||||
// Square root (per component)
|
||||
auto sqrt( multi x );
|
||||
|
||||
// Returns (x >= y) ? 1 : 0
|
||||
auto step( multi y, auto x );
|
||||
|
||||
// Returns the tangent of x
|
||||
auto tan( multi x );
|
||||
|
||||
// Returns the hyperbolic tangent of x
|
||||
auto tanh( multi x );
|
||||
|
||||
// Returns the transpose of the matrix m.
|
||||
matrix transpose( matrix x );
|
||||
|
||||
// Truncates floating-point value(s) to integer value(s)
|
||||
auto trunc( multi x );
|
||||
|
||||
// 1D texture lookup.
|
||||
float4 tex1D( sampler s, float t );
|
||||
|
||||
// 1D texture lookup.
|
||||
float4 tex1D( sampler s, float t, float ddx, float ddy );
|
||||
|
||||
// 1D texture lookup with bias.
|
||||
float4 tex1Dbias( sampler s, float4 t );
|
||||
|
||||
// 1D texture lookup with a gradient.
|
||||
float4 tex1Dgrad( sampler s, float t, float ddx, float ddy );
|
||||
|
||||
// 1D texture lookup with LOD.
|
||||
float4 tex1Dlod( sampler s, float4 t );
|
||||
|
||||
// 1D texture lookup with projective divide.
|
||||
float4 tex1Dproj( sampler s, float4 t );
|
||||
|
||||
|
||||
// 2D texture lookup.
|
||||
float4 tex2D( sampler s, float2 t );
|
||||
|
||||
// 2D texture lookup.
|
||||
float4 tex2D( sampler s, float2 t, float2 ddx, float2 ddy );
|
||||
|
||||
// 2D texture lookup with bias.
|
||||
float4 tex2Dbias( sampler s, float4 t );
|
||||
|
||||
// 2D texture lookup with a gradient.
|
||||
float4 tex2Dgrad( sampler s, float2 t, float2 ddx, float2 ddy );
|
||||
|
||||
// 2D texture lookup with LOD.
|
||||
float4 tex2Dlod( sampler s, float4 t );
|
||||
|
||||
// 2D texture lookup with projective divide.
|
||||
float4 tex2Dproj( sampler s, float4 t );
|
||||
|
||||
|
||||
// 3D texture lookup.
|
||||
float4 tex3D( sampler s, float3 t );
|
||||
|
||||
// 3D texture lookup.
|
||||
float4 tex3D( sampler s, float3 t, float3 ddx, float3 ddy );
|
||||
|
||||
// 3D texture lookup with bias.
|
||||
float4 tex3Dbias( sampler s, float4 t );
|
||||
|
||||
// 3D texture lookup with a gradient.
|
||||
float4 tex3Dgrad( sampler s, float3 t, float3 ddx, float3 ddy );
|
||||
|
||||
// 3D texture lookup with LOD.
|
||||
float4 tex3Dlod( sampler s, float4 t );
|
||||
|
||||
// 3D texture lookup with projective divide.
|
||||
float4 tex3Dproj( sampler s, float4 t );
|
||||
|
||||
|
||||
// Cube texture lookup.
|
||||
float4 texCUBE( sampler s, float3 t );
|
||||
|
||||
// Cube texture lookup.
|
||||
float4 texCUBE( sampler s, float3 t, float3 ddx, float3 ddy );
|
||||
|
||||
// Cube texture lookup with bias.
|
||||
float4 texCUBEbias( sampler s, float4 t );
|
||||
|
||||
// Cube texture lookup with a gradient.
|
||||
float4 texCUBEgrad( sampler s, float3 t, float3 ddx, float3 ddy );
|
||||
|
||||
// Cube texture lookup with LOD.
|
||||
float4 texCUBElod( sampler s, float4 t );
|
||||
|
||||
// Cube texture lookup with projective divide.
|
||||
float4 texCUBEproj( sampler s, float4 t );
|
||||
@@ -1,188 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
// Combos
|
||||
// DYNAMIC: "PIXELFOGTYPE" "0..1"
|
||||
// DYNAMIC: "FLASHLIGHT" "0..1"
|
||||
// DYNAMIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2"
|
||||
// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1"
|
||||
// DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1"
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
sampler _Sampler_01 : register( s1 );
|
||||
sampler _Sampler_02 : register( s2 );
|
||||
sampler _Sampler_03 : register( s3 );
|
||||
sampler _Sampler_04 : register( s4 );
|
||||
sampler _Sampler_05 : register( s5 );
|
||||
sampler _Sampler_06 : register( s6 );
|
||||
sampler _Sampler_07 : register( s7 );
|
||||
sampler _Sampler_08 : register( s8 );
|
||||
sampler _Sampler_09 : register( s9 );
|
||||
sampler _Sampler_10 : register( s10 );
|
||||
sampler _gSampler_Flashlight_Cookie : register( s11 );
|
||||
sampler _gSampler_Flashlight_Depth : register( s12 );
|
||||
sampler _gSampler_Flashlight_Random : register( s13 );
|
||||
|
||||
// Constants
|
||||
const float4x4 g_cFlashlightWorldToTexture : register( c12 );
|
||||
const float2 g_cData_base_detail_0_smoothing : register( c16 ); // Static
|
||||
const float2 g_cData_base_detail_1_smoothing : register( c17 ); // Static
|
||||
const float3 _g_VecOrig : register( c18 );
|
||||
const float4 _g_FogParams : register( c19 );
|
||||
const float4 g_cFlashlightAttenuationFactors : register( c8 );
|
||||
const float4 g_cFlashlightPos : register( c9 );
|
||||
const float4 g_cShadowTweaks : register( c7 );
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 vTexCoord_0 : TEXCOORD0;
|
||||
float4 vTexCoord_1 : TEXCOORD1;
|
||||
float3 vTexCoord_2 : TEXCOORD2;
|
||||
float3 vTexCoord_3 : TEXCOORD3;
|
||||
float4 vTexCoord_4 : TEXCOORD4;
|
||||
float3 vTexCoord_5 : TEXCOORD5;
|
||||
float3 vTexCoord_6 : TEXCOORD6;
|
||||
float2 vTexCoord_7 : TEXCOORD7;
|
||||
float4 vColor_0 : COLOR0;
|
||||
float4 vColor_1 : COLOR1;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float3 _var0 = float3( 0.000000, 0.000000, 0.000000 );
|
||||
float2 _var1 = In.vTexCoord_0.xy;
|
||||
float2 _var2 = In.vTexCoord_4.zw;
|
||||
float _var3 = In.vColor_1.w;
|
||||
float2 _var4 = In.vTexCoord_0.zw;
|
||||
float2 _var5 = In.vTexCoord_4.xy;
|
||||
float _var6 = g_cData_base_detail_0_smoothing.x;
|
||||
float _var7 = g_cData_base_detail_0_smoothing.y;
|
||||
float2 _var8 = In.vTexCoord_7.xy;
|
||||
float _var9 = g_cData_base_detail_1_smoothing.x;
|
||||
float _var10 = g_cData_base_detail_1_smoothing.y;
|
||||
float3 _var11 = float3( 0.000000, 0.000000, 0.000000 );
|
||||
float _var12 = _g_VecOrig.z;
|
||||
float _var13 = In.vTexCoord_3.z;
|
||||
float _var14 = In.vColor_0.z;
|
||||
float4 _texLookup_48 = tex2D( _Sampler_00, _var1 );
|
||||
float3 _var15 = _texLookup_48.rgb;
|
||||
float _var16 = _texLookup_48.b;
|
||||
float3 _var17 = tex2D( _Sampler_01, _var2 ).rgb;
|
||||
float4 _texLookup_51 = tex2D( _Sampler_02, _var1 );
|
||||
float3 _var18 = _texLookup_51.rgb;
|
||||
float _var19 = _texLookup_51.b;
|
||||
float3 _var20 = tex2D( _Sampler_03, _var2 ).rgb;
|
||||
float4 _texLookup_54 = tex2D( _Sampler_04, _var4 );
|
||||
float _var21 = _texLookup_54.r;
|
||||
float _var22 = _texLookup_54.g;
|
||||
float3 _var23 = tex2D( _Sampler_05, _var1 ).rgb;
|
||||
float3 _var24 = tex2D( _Sampler_06, _var8 ).rgb;
|
||||
float4 _texLookup_58 = tex2D( _Sampler_07, _var1 );
|
||||
float3 _var25 = _texLookup_58.rgb;
|
||||
float _var26 = _texLookup_58.g;
|
||||
float3 _var27 = tex2D( _Sampler_08, _var8 ).rgb;
|
||||
_var12 = CalcPixelFogFactor( PIXELFOGTYPE, _g_FogParams, _var12, _var13, _var14 );
|
||||
float2 _var28 = _var15.xy;
|
||||
float2 _var29 = _var17.xy;
|
||||
float2 _var30 = _var18.xy;
|
||||
float2 _var31 = _var20.xy;
|
||||
_var21 = min( _var3, _var21 );
|
||||
_var22 = max( _var3, _var22 );
|
||||
_var24 = smoothstep( _var6, _var7, _var24 );
|
||||
_var27 = smoothstep( _var9, _var10, _var27 );
|
||||
_var29 = _var29 - float( 0.500000 );
|
||||
_var31 = _var31 - float( 0.500000 );
|
||||
_var21 = lerp( _var21, _var22, _var3 );
|
||||
_var23 = _var23 * _var24;
|
||||
_var25 = _var25 * _var27;
|
||||
_var28 = _var28 + _var29;
|
||||
_var30 = _var30 + _var31;
|
||||
_var21 = smoothstep( float( 0.400000 ), float( 0.600000 ), _var21 );
|
||||
_var28 = saturate( _var28 );
|
||||
_var30 = saturate( _var30 );
|
||||
_var23 = lerp( _var23, _var25, _var21 );
|
||||
_var26 = _var26 * _var21;
|
||||
float3 _var32 = float3( _var28, _var16 );
|
||||
float3 _var33 = float3( _var30, _var19 );
|
||||
_var32 = lerp( _var32, _var33, _var21 );
|
||||
_var32 = _var32 * float( 2.000000 );
|
||||
_var32 = _var32 - float( 1.000000 );
|
||||
#if ( FLASHLIGHT == 0 )
|
||||
float2 _var34 = In.vTexCoord_1.xy;
|
||||
float _var35 = dot( _var32, bumpBasis[0] );
|
||||
float _var36 = dot( _var32, bumpBasis[1] );
|
||||
float _var37 = dot( _var32, bumpBasis[2] );
|
||||
float2 _var38 = In.vTexCoord_1.zw;
|
||||
float3 _var39 = tex2D( _Sampler_09, _var5 ).rgb;
|
||||
float3 _var40 = In.vTexCoord_3 - _g_VecOrig;
|
||||
float3 _var41 = lerp( _var32, In.vTexCoord_2, float( 0.900000 ) );
|
||||
float3 _var42 = tex2D( _Sampler_09, _var34 ).rgb;
|
||||
float2 _var43 = float2( _var35, _var36 );
|
||||
float3 _var44 = tex2D( _Sampler_09, _var38 ).rgb;
|
||||
_var40 = reflect( _var40, _var41 );
|
||||
float3 _var45 = float3( _var43, _var37 );
|
||||
float3 _var46 = texCUBE( _Sampler_10, _var40 ).rgb;
|
||||
_var45 = saturate( _var45 );
|
||||
_var46 = _var46 * float( 0.040000 );
|
||||
_var45 = _var45 * _var45;
|
||||
_var46 = _var46 * ENV_MAP_SCALE;
|
||||
float _var47 = _var45.x;
|
||||
float _var48 = _var45.y;
|
||||
float _var49 = _var45.z;
|
||||
float _var50 = dot( float3( float( 1.000000 ), float( 1.000000 ), float( 1.000000 ) ), _var45 );
|
||||
_var11 = _var46;
|
||||
_var42 = _var42 * _var47;
|
||||
_var44 = _var44 * _var48;
|
||||
_var39 = _var39 * _var49;
|
||||
_var50 = LIGHT_MAP_SCALE / _var50;
|
||||
_var42 = _var42 + _var44;
|
||||
_var42 = _var42 + _var39;
|
||||
_var42 = _var42 * _var50;
|
||||
_var0 = _var42;
|
||||
#endif
|
||||
#if ( FLASHLIGHT == 1 )
|
||||
float3x3 _var51 = { In.vTexCoord_5,
|
||||
In.vTexCoord_6,
|
||||
In.vTexCoord_2 };
|
||||
float4 _var52 = mul( float4(In.vTexCoord_3.xyz,1), g_cFlashlightWorldToTexture );
|
||||
float2 _var53 = In.vColor_0.xy;
|
||||
float _var54 = In.vColor_0.w;
|
||||
float3 _var55 = mul( _var32, _var51 );
|
||||
_var53 = _var53 / _var54;
|
||||
_var55 = normalize( _var55 );
|
||||
_var53 = _var53 * float( 0.500000 );
|
||||
_var53 = _var53 + float( 0.500000 );
|
||||
_var55 = DoFlashlight( g_cFlashlightPos.xyz, In.vTexCoord_3, _var52, _var55,
|
||||
g_cFlashlightAttenuationFactors.xyz, g_cFlashlightAttenuationFactors.w,
|
||||
_gSampler_Flashlight_Cookie, _gSampler_Flashlight_Depth, _gSampler_Flashlight_Random,
|
||||
FLASHLIGHTDEPTHFILTERMODE, FLASHLIGHTSHADOWS, true,
|
||||
_var53, false, g_cShadowTweaks );
|
||||
_var0 = _var55;
|
||||
#endif
|
||||
_var0 = _var0;
|
||||
_var11 = _var11 * _var26;
|
||||
_var0 = _var0 * _var23;
|
||||
_var0 = _var0 + _var11;
|
||||
float4 _var56 = float4( _var0.x, _var0.y, _var0.z, 1.000000 );
|
||||
_var56 = FinalOutput( _var56, _var12, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, true, _var14 );
|
||||
Out.vColor_0 = _var56;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float3 vNormal : NORMAL;
|
||||
float3 vTangent_S : TANGENT;
|
||||
float3 vTangent_T : BINORMAL;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
float2 vTexCoord_1 : TEXCOORD1;
|
||||
float2 vTexCoord_2 : TEXCOORD2;
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float4 vTexCoord_0 : TEXCOORD0;
|
||||
float4 vTexCoord_1 : TEXCOORD1;
|
||||
float3 vTexCoord_2 : TEXCOORD2;
|
||||
float3 vTexCoord_3 : TEXCOORD3;
|
||||
float4 vTexCoord_4 : TEXCOORD4;
|
||||
float3 vTexCoord_5 : TEXCOORD5;
|
||||
float3 vTexCoord_6 : TEXCOORD6;
|
||||
float2 vTexCoord_7 : TEXCOORD7;
|
||||
float4 vColor_0 : COLOR0;
|
||||
float4 vColor_1 : COLOR1;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float3 _var0 = mul( float4(In.vPos.xyz,1), cModel[0] );
|
||||
float2 _var1 = In.vTexCoord_0 * float( 1.000000 );
|
||||
float2 _var2 = In.vTexCoord_0 * float( 0.120000 );
|
||||
float2 _var3 = In.vTexCoord_1 + In.vTexCoord_2;
|
||||
float3 _var4 = mul( float4(In.vNormal.xyz,1), cModel[0] );
|
||||
float2 _var5 = In.vTexCoord_0 * float2( 5.000000, 5.000000 );
|
||||
float3 _var6 = mul( float4(In.vTangent_S.xyz,1), cModel[0] );
|
||||
float3 _var7 = mul( float4(In.vTangent_T.xyz,1), cModel[0] );
|
||||
float2 _var8;
|
||||
{
|
||||
float2 center_def = float2( 0.5f, 0.5f );
|
||||
float2 trans_def = float2( 0.0f, 0.0f );
|
||||
float fs = sin( float( 45.000000 ) );
|
||||
float fc = cos( float( 45.000000 ) );
|
||||
float4 row_0 = float4( fc * float2( 4.000000, 4.000000 ).x, -fs * float2( 4.000000, 4.000000 ).x, 0, ( -center_def.x * fc + center_def.y * fs ) * float2( 4.000000, 4.000000 ).x + center_def.x + trans_def.x );
|
||||
float4 row_1 = float4( fs * float2( 4.000000, 4.000000 ).y, fc * float2( 4.000000, 4.000000 ).y, 0, ( -center_def.x * fs - center_def.y * fc ) * float2( 4.000000, 4.000000 ).y + center_def.y + trans_def.y );
|
||||
_var8.x = dot( float4( In.vTexCoord_0, 0, 1 ), row_0 );
|
||||
_var8.y = dot( float4( In.vTexCoord_0, 0, 1 ), row_1 );
|
||||
}
|
||||
float4 _var9 = mul( float4(_var0.xyz,1), cViewProj );
|
||||
float4 _var10 = float4( _var1, _var2 );
|
||||
float2 _var11 = _var3 + In.vTexCoord_2;
|
||||
_var4 = normalize( _var4 );
|
||||
_var6 = normalize( _var6 );
|
||||
_var7 = normalize( _var7 );
|
||||
float4 _var12 = float4( _var3, _var11 );
|
||||
float2 _var13 = _var11 + In.vTexCoord_2;
|
||||
float4 _var14 = float4( _var13, _var5 );
|
||||
Out.vProjPos = _var9;
|
||||
Out.vTexCoord_0 = _var10;
|
||||
Out.vTexCoord_1 = _var12;
|
||||
Out.vTexCoord_2 = _var4;
|
||||
Out.vTexCoord_3 = _var0;
|
||||
Out.vTexCoord_4 = _var14;
|
||||
Out.vTexCoord_5 = _var6;
|
||||
Out.vTexCoord_6 = _var7;
|
||||
Out.vTexCoord_7 = _var8;
|
||||
Out.vColor_0 = _var9;
|
||||
Out.vColor_1 = In.vColor_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
// Combos
|
||||
// DYNAMIC: "FLASHLIGHT" "0..1"
|
||||
// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1"
|
||||
// DYNAMIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2"
|
||||
// DYNAMIC: "PIXELFOGTYPE" "0..1"
|
||||
// DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1"
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
sampler _Sampler_01 : register( s1 );
|
||||
sampler _Sampler_02 : register( s2 );
|
||||
sampler _Sampler_03 : register( s3 );
|
||||
sampler _gSampler_Flashlight_Cookie : register( s4 );
|
||||
sampler _gSampler_Flashlight_Depth : register( s5 );
|
||||
sampler _gSampler_Flashlight_Random : register( s6 );
|
||||
|
||||
// Constants
|
||||
const float3 _g_VecOrig : register( c16 );
|
||||
const float g_cData_parallax_geo_height : register( c17 ); // Static
|
||||
const float4x4 g_cFlashlightWorldToTexture : register( c12 );
|
||||
const float4x4 g_cCMatrix_ViewProj : register( c18 );
|
||||
const float4 g_cFlashlightAttenuationFactors : register( c8 );
|
||||
const float4 g_cFlashlightPos : register( c9 );
|
||||
const float4 g_cShadowTweaks : register( c7 );
|
||||
const float4 _g_FogParams : register( c22 );
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
float4 vTexCoord_1 : TEXCOORD1;
|
||||
float3 vTexCoord_2 : TEXCOORD2;
|
||||
float3 vTexCoord_3 : TEXCOORD3;
|
||||
float2 vTexCoord_4 : TEXCOORD4;
|
||||
float3 vTexCoord_5 : TEXCOORD5;
|
||||
float3 vTexCoord_6 : TEXCOORD6;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
float vDepth : DEPTH;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float3 _var0 = float3( 0.000000, 0.000000, 0.000000 );
|
||||
float2 _var1 = float2( 0.000000, 0.000000 );
|
||||
float3x3 _var2 = { In.vTexCoord_5,
|
||||
In.vTexCoord_6,
|
||||
In.vTexCoord_2 };
|
||||
float3 _var3 = In.vTexCoord_3 - _g_VecOrig;
|
||||
float3 _var4 = _g_VecOrig - In.vTexCoord_3;
|
||||
float3 _var5 = float3( 0.000000, 0.000000, 0.000000 );
|
||||
float _var6 = _g_VecOrig.z;
|
||||
_var3 = mul( _var2, _var3 );
|
||||
#if ( FLASHLIGHT == 0 )
|
||||
float3 _var8 = (float3)0;
|
||||
float2 _var7 = CalcParallaxUV_Relief( In.vTexCoord_0, _var3, g_cData_parallax_geo_height, In.vTexCoord_2, _var4,
|
||||
_Sampler_00, 10, 30, 5, In.vTexCoord_3,
|
||||
_var8, true, true );
|
||||
_var5 = _var8;
|
||||
_var1 = _var7;
|
||||
#endif
|
||||
#if ( FLASHLIGHT == 1 )
|
||||
float3 _var10 = (float3)0;
|
||||
float2 _var9 = CalcParallaxUV_Relief( In.vTexCoord_0, _var3, g_cData_parallax_geo_height, In.vTexCoord_2, _var4,
|
||||
_Sampler_00, 8, 15, 5, In.vTexCoord_3,
|
||||
_var10, false, true );
|
||||
_var10 = _var10 * float( 0.900000 );
|
||||
_var1 = _var9;
|
||||
_var5 = _var10;
|
||||
#endif
|
||||
_var1 = _var1;
|
||||
_var5 = _var5;
|
||||
float3 _var11 = tex2D( _Sampler_01, _var1 ).rgb;
|
||||
float _var12 = _var5.x;
|
||||
float _var13 = _var5.y;
|
||||
float _var14 = _var5.z;
|
||||
float3 _var15 = tex2D( _Sampler_02, _var1 ).rgb;
|
||||
_var11 = _var11 * float( 2.000000 );
|
||||
float3 _var16 = _var12 * In.vTexCoord_5;
|
||||
float3 _var17 = _var13 * In.vTexCoord_6;
|
||||
float _var18 = _var14 * g_cData_parallax_geo_height;
|
||||
float _var19 = 1.0f - _var14;
|
||||
_var11 = _var11 - float( 1.000000 );
|
||||
_var16 = _var16 + _var17;
|
||||
float3 _var20 = _var18 * In.vTexCoord_2;
|
||||
_var19 = _var19 * _var19;
|
||||
#if ( FLASHLIGHT == 0 )
|
||||
float2 _var21 = In.vTexCoord_1.xy;
|
||||
float _var22 = dot( _var11, bumpBasis[0] );
|
||||
float _var23 = dot( _var11, bumpBasis[1] );
|
||||
float _var24 = dot( _var11, bumpBasis[2] );
|
||||
float2 _var25 = In.vTexCoord_1.zw;
|
||||
float3 _var26 = tex2D( _Sampler_03, In.vTexCoord_4 ).rgb;
|
||||
float3 _var27 = tex2D( _Sampler_03, _var21 ).rgb;
|
||||
_var22 = saturate( _var22 );
|
||||
_var23 = saturate( _var23 );
|
||||
_var24 = saturate( _var24 );
|
||||
float3 _var28 = tex2D( _Sampler_03, _var25 ).rgb;
|
||||
float2 _var29 = float2( _var22, _var23 );
|
||||
float3 _var30 = float3( _var29, _var24 );
|
||||
_var30 = _var30 * _var30;
|
||||
float _var31 = _var30.x;
|
||||
float _var32 = _var30.y;
|
||||
float _var33 = _var30.z;
|
||||
float _var34 = dot( float3( float( 1.000000 ), float( 1.000000 ), float( 1.000000 ) ), _var30 );
|
||||
_var27 = _var27 * _var31;
|
||||
_var28 = _var28 * _var32;
|
||||
_var26 = _var26 * _var33;
|
||||
_var34 = LIGHT_MAP_SCALE / _var34;
|
||||
_var27 = _var27 + _var28;
|
||||
_var27 = _var27 + _var26;
|
||||
_var27 = _var27 * _var34;
|
||||
_var0 = _var27;
|
||||
#endif
|
||||
_var16 = _var16 + _var20;
|
||||
_var15 = _var15 * _var19;
|
||||
_var16 = In.vTexCoord_3 - _var16;
|
||||
float4 _var35 = mul( float4(_var16.xyz,1), g_cCMatrix_ViewProj );
|
||||
float _var36 = _var16.z;
|
||||
#if ( FLASHLIGHT == 1 )
|
||||
float3 _var37 = mul( _var11, _var2 );
|
||||
float4 _var38 = mul( float4(_var16.xyz,1), g_cFlashlightWorldToTexture );
|
||||
float2 _var39 = _var35.xy;
|
||||
float _var40 = _var35.w;
|
||||
_var37 = normalize( _var37 );
|
||||
_var39 = _var39 / _var40;
|
||||
_var39 = _var39 * float( 0.500000 );
|
||||
_var39 = _var39 + float( 0.500000 );
|
||||
_var37 = DoFlashlight( g_cFlashlightPos.xyz, _var16, _var38, _var37,
|
||||
g_cFlashlightAttenuationFactors.xyz, g_cFlashlightAttenuationFactors.w,
|
||||
_gSampler_Flashlight_Cookie, _gSampler_Flashlight_Depth, _gSampler_Flashlight_Random,
|
||||
FLASHLIGHTDEPTHFILTERMODE, FLASHLIGHTSHADOWS, true,
|
||||
_var39, false, g_cShadowTweaks );
|
||||
float3 _var41 = _var37;
|
||||
#if ( FLASHLIGHTSHADOWS == 1 )
|
||||
float _var42 = dot( float3( float( 1.000000 ), float( 1.000000 ), float( 1.000000 ) ), _var37 );
|
||||
if ( _var42 > float( 0.010000 ) )
|
||||
{
|
||||
float3 _var43 = _var16 - float3( g_cFlashlightPos.xyz );
|
||||
_var43 = mul( _var2, _var43 );
|
||||
_var43 = normalize( _var43 );
|
||||
float _var44 = CalcParallaxedShadows_OneLight( In.vTexCoord_0, _var1, _var43,
|
||||
In.vTexCoord_3, g_cData_parallax_geo_height, float( 1.000000 ), _Sampler_00 );
|
||||
_var41 = _var41 * _var44;
|
||||
}
|
||||
#endif
|
||||
_var0 = _var41;
|
||||
#endif
|
||||
_var0 = _var0;
|
||||
float _var45 = _var35.z;
|
||||
float _var46 = _var35.z;
|
||||
float _var47 = _var35.w;
|
||||
_var0 = _var0 * _var15;
|
||||
_var6 = CalcPixelFogFactor( PIXELFOGTYPE, _g_FogParams, _var6, _var36, _var45 );
|
||||
_var46 = _var46 / _var47;
|
||||
float4 _var48 = float4( _var0.x, _var0.y, _var0.z, 1.000000 );
|
||||
_var46 = saturate( _var46 );
|
||||
_var48 = FinalOutput( _var48, _var6, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, true, _var45 );
|
||||
Out.vColor_0 = _var48;
|
||||
Out.vDepth = _var46;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Constants
|
||||
const float g_cData_parallax_geo_height : register( c48 ); // Static
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float3 vNormal : NORMAL;
|
||||
float3 vTangent_S : TANGENT;
|
||||
float3 vTangent_T : BINORMAL;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
float2 vTexCoord_1 : TEXCOORD1;
|
||||
float2 vTexCoord_2 : TEXCOORD2;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
float4 vTexCoord_1 : TEXCOORD1;
|
||||
float3 vTexCoord_2 : TEXCOORD2;
|
||||
float3 vTexCoord_3 : TEXCOORD3;
|
||||
float2 vTexCoord_4 : TEXCOORD4;
|
||||
float3 vTexCoord_5 : TEXCOORD5;
|
||||
float3 vTexCoord_6 : TEXCOORD6;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float3 _var0 = mul( float4(In.vPos.xyz,1), cModel[0] );
|
||||
float3 _var1 = mul( float4(In.vNormal.xyz,1), cModel[0] );
|
||||
float2 _var2 = In.vTexCoord_1 + In.vTexCoord_2;
|
||||
float3 _var3 = mul( float4(In.vTangent_S.xyz,1), cModel[0] );
|
||||
float3 _var4 = mul( float4(In.vTangent_T.xyz,1), cModel[0] );
|
||||
_var1 = normalize( _var1 );
|
||||
float2 _var5 = _var2 + In.vTexCoord_2;
|
||||
_var3 = normalize( _var3 );
|
||||
_var4 = normalize( _var4 );
|
||||
float3 _var6 = _var1 * g_cData_parallax_geo_height;
|
||||
float4 _var7 = float4( _var2, _var5 );
|
||||
float2 _var8 = _var5 + In.vTexCoord_2;
|
||||
_var0 = _var0 + _var6;
|
||||
float4 _var9 = mul( float4(_var0.xyz,1), cViewProj );
|
||||
Out.vProjPos = _var9;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
Out.vTexCoord_1 = _var7;
|
||||
Out.vTexCoord_2 = _var1;
|
||||
Out.vTexCoord_3 = _var0;
|
||||
Out.vTexCoord_4 = _var8;
|
||||
Out.vTexCoord_5 = _var3;
|
||||
Out.vTexCoord_6 = _var4;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
sampler _Sampler_01 : register( s1 );
|
||||
sampler _Sampler_02 : register( s2 );
|
||||
|
||||
// Constants
|
||||
const float4x4 g_cCMatrix_ViewProj : register( c16 );
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
float3 vTexCoord_1 : TEXCOORD1;
|
||||
float3 vTexCoord_2 : TEXCOORD2;
|
||||
float4 vTexCoord_3 : TEXCOORD3;
|
||||
float3 vTexCoord_4 : TEXCOORD4;
|
||||
float3 vTexCoord_5 : TEXCOORD5;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float2 _var0 = In.vTexCoord_3.xy;
|
||||
float _var1 = In.vTexCoord_3.w;
|
||||
float3 _var2 = tex2D( _Sampler_00, In.vTexCoord_0 ).rgb;
|
||||
float3x3 _var3 = { In.vTexCoord_4,
|
||||
In.vTexCoord_5,
|
||||
In.vTexCoord_1 };
|
||||
float3 _var4 = normalize( In.vTexCoord_2 );
|
||||
float _var5 = In.vTexCoord_3.z;
|
||||
_var0 = _var0 / _var1;
|
||||
_var2 = lerp( _var2, float3( 0.500000, 0.500000, 1.000000 ), float( 0.500000 ) );
|
||||
_var5 = smoothstep( float( 1.000000 ), float( 2.500000 ), _var5 );
|
||||
_var0 = _var0 * float2( 0.500000, -0.500000 );
|
||||
_var2 = _var2 * float( 2.000000 );
|
||||
_var5 = float( 0.800000 ) * _var5;
|
||||
_var0 = _var0 + float( 0.500000 );
|
||||
_var2 = _var2 - float( 1.000000 );
|
||||
_var2 = mul( _var2, _var3 );
|
||||
_var2 = normalize( _var2 );
|
||||
float3 _var6 = mul( float4(_var2.xyz,1), (float3x3)g_cCMatrix_ViewProj );
|
||||
float _var7 = dot( _var2, _var4 );
|
||||
float3 _var8 = reflect( _var4, _var2 );
|
||||
float2 _var9 = _var6.xy;
|
||||
float _var10 = smoothstep( float( -0.050000 ), float( -0.100000 ), _var7 );
|
||||
float _var11 = abs( _var7 );
|
||||
float _var12 = smoothstep( float( -1.000000 ), float( 0.000000 ), _var7 );
|
||||
float3 _var13 = texCUBE( _Sampler_01, _var8 ).rgb;
|
||||
float _var14 = smoothstep( float( -1.000000 ), float( -0.500000 ), _var7 );
|
||||
float _var15 = smoothstep( float( 0.100000 ), float( -0.500000 ), _var7 );
|
||||
_var9 = _var9 * _var10;
|
||||
_var11 = 1.0f - _var11;
|
||||
float _var16 = pow( _var12, float( 2.000000 ) );
|
||||
_var13 = _var13 * ENV_MAP_SCALE;
|
||||
_var14 = min( _var14, _var15 );
|
||||
float _var17 = pow( _var12, float( 20.000000 ) );
|
||||
_var9 = _var9 * float2( 1.000000, -1.000000 );
|
||||
_var11 = _var11 * float( 0.100000 );
|
||||
float3 _var18 = lerp( float( 1.000000 ), float3( 0.830000, 0.867400, 1.000000 ), _var16 );
|
||||
_var14 = _var14 * float( 0.500000 );
|
||||
_var17 = _var17 * float( 0.300000 );
|
||||
float _var19 = float( 0.005000 ) + _var11;
|
||||
float _var20 = float( 0.010000 ) + _var11;
|
||||
float _var21 = float( 0.015000 ) + _var11;
|
||||
float2 _var22 = _var9 * _var19;
|
||||
float2 _var23 = _var9 * _var20;
|
||||
float2 _var24 = _var9 * _var21;
|
||||
_var22 = _var0 - _var22;
|
||||
_var23 = _var0 - _var23;
|
||||
_var24 = _var0 - _var24;
|
||||
float _var25 = tex2D( _Sampler_02, _var22 ).r;
|
||||
float _var26 = tex2D( _Sampler_02, _var23 ).g;
|
||||
float _var27 = tex2D( _Sampler_02, _var24 ).b;
|
||||
float2 _var28 = float2( _var25, _var26 );
|
||||
float3 _var29 = float3( _var28, _var27 );
|
||||
_var29 = _var29 * _var18;
|
||||
_var29 = lerp( _var29, _var13, _var14 );
|
||||
_var29 = lerp( _var29, float( 1.000000 ), _var17 );
|
||||
float4 _var30 = float4( _var29, _var5 );
|
||||
Out.vColor_0 = _var30;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
// Combos
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Constants
|
||||
const float3 _g_VecOrig : register( c48 );
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float4 vBoneWeights : BLENDWEIGHT;
|
||||
float4 vBoneIndices : BLENDINDICES;
|
||||
float4 vNormal : NORMAL;
|
||||
float4 vTangent_S : TANGENT;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
float3 vTexCoord_1 : TEXCOORD1;
|
||||
float3 vTexCoord_2 : TEXCOORD2;
|
||||
float4 vTexCoord_3 : TEXCOORD3;
|
||||
float3 vTexCoord_4 : TEXCOORD4;
|
||||
float3 vTexCoord_5 : TEXCOORD5;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float3 _var0 = (float3)0;
|
||||
float4 _var1 = (float4)0;
|
||||
DecompressVertex_NormalTangent( In.vNormal, In.vTangent_S, _var0, _var1 );
|
||||
float3 _var2 = (float3)0;
|
||||
float3 _var3 = (float3)0;
|
||||
float3 _var4 = (float3)0;
|
||||
float3 _var5 = (float3)0;
|
||||
SkinPositionNormalAndTangentSpace( SKINNING, float4( In.vPos, 1 ), _var0, _var1,
|
||||
In.vBoneWeights, In.vBoneIndices,
|
||||
_var2, _var3, _var4, _var5 );
|
||||
float4 _var6 = mul( float4(_var2.xyz,1), cViewProj );
|
||||
_var3 = normalize( _var3 );
|
||||
float3 _var7 = _var2 - _g_VecOrig;
|
||||
_var4 = normalize( _var4 );
|
||||
_var5 = normalize( _var5 );
|
||||
Out.vProjPos = _var6;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
Out.vTexCoord_1 = _var3;
|
||||
Out.vTexCoord_2 = _var7;
|
||||
Out.vTexCoord_3 = _var6;
|
||||
Out.vTexCoord_4 = _var4;
|
||||
Out.vTexCoord_5 = _var5;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
// Combos
|
||||
// DYNAMIC: "PIXELFOGTYPE" "0..1"
|
||||
// DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1"
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float3 vTexCoord_0 : TEXCOORD0;
|
||||
float3 vTexCoord_1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float3 _var0 = reflect( In.vTexCoord_0, In.vTexCoord_1 );
|
||||
float4 _var1 = texCUBE( _Sampler_00, _var0 ).rgba;
|
||||
_var1 = FinalOutput( _var1, float( 0.000000 ), PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, true, float( 0.000000 ) );
|
||||
Out.vColor_0 = _var1;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
// Combos
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Constants
|
||||
const float3 _g_VecOrig : register( c48 );
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float4 vBoneWeights : BLENDWEIGHT;
|
||||
float4 vBoneIndices : BLENDINDICES;
|
||||
float4 vNormal : NORMAL;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float3 vTexCoord_0 : TEXCOORD0;
|
||||
float3 vTexCoord_1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float3 _var0 = (float3)0;
|
||||
DecompressVertex_Normal( In.vNormal, _var0 );
|
||||
float3 _var1 = (float3)0;
|
||||
float3 _var2 = (float3)0;
|
||||
SkinPositionAndNormal( SKINNING, float4( In.vPos, 1 ), _var0,
|
||||
In.vBoneWeights, In.vBoneIndices,
|
||||
_var1, _var2 );
|
||||
float4 _var3 = mul( float4(_var1.xyz,1), cViewProj );
|
||||
float3 _var4 = _var1 - _g_VecOrig;
|
||||
_var4 = normalize( _var4 );
|
||||
Out.vProjPos = _var3;
|
||||
Out.vTexCoord_0 = _var4;
|
||||
Out.vTexCoord_1 = _var2;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Combos
|
||||
// STATIC: "FLASHLIGHT" "0..1"
|
||||
// DYNAMIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2"
|
||||
// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1"
|
||||
// DYNAMIC: "NUM_LIGHTS" "0..4"
|
||||
// DYNAMIC: "PIXELFOGTYPE" "0..1"
|
||||
// DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1"
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
sampler _gSampler_Flashlight_Cookie : register( s1 );
|
||||
sampler _gSampler_Flashlight_Depth : register( s2 );
|
||||
sampler _gSampler_Flashlight_Random : register( s3 );
|
||||
sampler _Sampler_04 : register( s4 );
|
||||
|
||||
// Constants
|
||||
const float4x3 g_cCMatrix_View : register( c16 );
|
||||
const float4 _g_FogParams : register( c19 );
|
||||
const float3 _g_VecOrig : register( c20 );
|
||||
const float4 g_cFlashlightAttenuationFactors : register( c8 );
|
||||
const float4 g_cFlashlightPos : register( c9 );
|
||||
const float4 g_cShadowTweaks : register( c7 );
|
||||
const float3 g_cAmbientCube[6] : register( c0 );
|
||||
PixelShaderLightInfo g_cLightInfo[3] : register( c6 );
|
||||
|
||||
// Arrays
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
float3 vTexCoord_1 : TEXCOORD1;
|
||||
float3 vTexCoord_2 : TEXCOORD2;
|
||||
float4 vTexCoord_3 : TEXCOORD3;
|
||||
float4 vTexCoord_4 : TEXCOORD4;
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float4 _texLookup_12 = tex2D( _Sampler_00, In.vTexCoord_0 );
|
||||
float3 _var0 = _texLookup_12.rgb;
|
||||
float _var1 = _texLookup_12.a;
|
||||
float3 _var2 = float3( 0.000000, 0.000000, 0.000000 );
|
||||
float3 _var3 = mul( float4(In.vTexCoord_2.xyz,1), (float3x3)g_cCMatrix_View );
|
||||
float _var4 = _g_VecOrig.z;
|
||||
float _var5 = In.vTexCoord_1.z;
|
||||
float _var6 = In.vTexCoord_3.z;
|
||||
#if ( FLASHLIGHT == 1 )
|
||||
float2 _var7 = In.vTexCoord_3.xy;
|
||||
float _var8 = In.vTexCoord_3.w;
|
||||
_var7 = _var7 / _var8;
|
||||
float3 _var9 = DoFlashlight( g_cFlashlightPos.xyz, In.vTexCoord_1, In.vTexCoord_4, In.vTexCoord_2,
|
||||
g_cFlashlightAttenuationFactors.xyz, g_cFlashlightAttenuationFactors.w,
|
||||
_gSampler_Flashlight_Cookie, _gSampler_Flashlight_Depth, _gSampler_Flashlight_Random,
|
||||
FLASHLIGHTDEPTHFILTERMODE, FLASHLIGHTSHADOWS, true,
|
||||
_var7, false, g_cShadowTweaks );
|
||||
_var2 = _var9;
|
||||
#endif
|
||||
#if ( FLASHLIGHT == 0 )
|
||||
float3 _var10 = PixelShaderDoLighting( In.vTexCoord_1, In.vTexCoord_2, float3(0,0,0),
|
||||
false, true, In.vColor_0,
|
||||
g_cAmbientCube, NUM_LIGHTS, g_cLightInfo,
|
||||
false, false, 1.0f );
|
||||
_var2 = _var10;
|
||||
#endif
|
||||
_var2 = _var2;
|
||||
float2 _var11 = _var3.xy;
|
||||
_var4 = CalcPixelFogFactor( PIXELFOGTYPE, _g_FogParams, _var4, _var5, _var6 );
|
||||
_var11 = _var11 * float2( 1.000000, -1.000000 );
|
||||
_var11 = _var11 * float( 0.500000 );
|
||||
_var11 = _var11 + float( 0.500000 );
|
||||
float3 _var12 = tex2D( _Sampler_04, _var11 ).rgb;
|
||||
_var2 = _var2 + _var12;
|
||||
_var0 = _var0 * _var2;
|
||||
float4 _var13 = float4( _var0, _var1 );
|
||||
_var13 = FinalOutput( _var13, _var4, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, true, _var6 );
|
||||
Out.vColor_0 = _var13;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Combos
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
// STATIC: "FLASHLIGHT" "0..1"
|
||||
|
||||
// Samplers
|
||||
|
||||
// Constants
|
||||
const float4x4 g_cFlashlightWorldToTexture : register( c48 );
|
||||
|
||||
// Arrays
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float4 vBoneWeights : BLENDWEIGHT;
|
||||
float4 vBoneIndices : BLENDINDICES;
|
||||
float3 vNormal : NORMAL;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
float3 vTexCoord_1 : TEXCOORD1;
|
||||
float3 vTexCoord_2 : TEXCOORD2;
|
||||
float4 vTexCoord_3 : TEXCOORD3;
|
||||
float4 vTexCoord_4 : TEXCOORD4;
|
||||
float4 vTexCoord_5 : TEXCOORD5;
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float3 _var0 = (float3)0;
|
||||
float3 _var1 = (float3)0;
|
||||
SkinPositionAndNormal( SKINNING, float4( In.vPos, 1 ), In.vNormal,
|
||||
In.vBoneWeights, In.vBoneIndices,
|
||||
_var0, _var1 );
|
||||
float4 _var2 = float4( 0.000000, 0.000000, 0.000000, 0.000000 );
|
||||
float4 _var3 = mul( float4(_var0.xyz,1), cViewProj );
|
||||
#if ( FLASHLIGHT == 1 )
|
||||
float4 _var4 = mul( float4(_var0.xyz,1), g_cFlashlightWorldToTexture );
|
||||
_var2 = _var4;
|
||||
#endif
|
||||
float4 _var5 = mul( float4(_var1.xyz,1), cViewProj );
|
||||
float4 _var6 = float4( GetVertexAttenForLight( _var0, 0 ),
|
||||
GetVertexAttenForLight( _var0, 1 ),
|
||||
GetVertexAttenForLight( _var0, 2 ),
|
||||
GetVertexAttenForLight( _var0, 3 ) );
|
||||
Out.vProjPos = _var3;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
Out.vTexCoord_1 = _var0;
|
||||
Out.vTexCoord_2 = _var1;
|
||||
Out.vTexCoord_3 = _var3;
|
||||
Out.vTexCoord_4 = _var2;
|
||||
Out.vTexCoord_5 = _var5;
|
||||
Out.vColor_0 = _var6;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,209 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
// Combos
|
||||
// DYNAMIC: "PIXELFOGTYPE" "0..1"
|
||||
// STATIC: "FLASHLIGHT" "0..1"
|
||||
// DYNAMIC: "FLASHLIGHTDEPTHFILTERMODE" "0..2"
|
||||
// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1"
|
||||
// DYNAMIC: "NUM_LIGHTS" "0..4"
|
||||
// DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1"
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
sampler _Sampler_01 : register( s1 );
|
||||
sampler _Sampler_02 : register( s2 );
|
||||
sampler _Sampler_03 : register( s3 );
|
||||
sampler _Sampler_04 : register( s4 );
|
||||
sampler _Sampler_05 : register( s5 );
|
||||
sampler _gSampler_Flashlight_Cookie : register( s6 );
|
||||
sampler _gSampler_Flashlight_Depth : register( s7 );
|
||||
sampler _gSampler_Flashlight_Random : register( s8 );
|
||||
sampler _Sampler_09 : register( s9 );
|
||||
|
||||
// Constants
|
||||
const float4 _g_FogParams : register( c16 );
|
||||
const float3 _g_VecOrig : register( c17 );
|
||||
const float4 g_cFlashlightAttenuationFactors : register( c8 );
|
||||
const float4 g_cFlashlightPos : register( c9 );
|
||||
const float4 g_cShadowTweaks : register( c7 );
|
||||
const float3 g_cAmbientCube[6] : register( c0 );
|
||||
PixelShaderLightInfo g_cLightInfo[3] : register( c6 );
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 vTexCoord_0 : TEXCOORD0;
|
||||
float3 vTexCoord_1 : TEXCOORD1;
|
||||
float3 vTexCoord_2 : TEXCOORD2;
|
||||
float4 vTexCoord_3 : TEXCOORD3;
|
||||
float4 vTexCoord_4 : TEXCOORD4;
|
||||
float3 vTexCoord_5 : TEXCOORD5;
|
||||
float3 vTexCoord_6 : TEXCOORD6;
|
||||
float3 vTexCoord_7 : TEXCOORD7;
|
||||
float4 vColor_0 : COLOR0;
|
||||
float4 vColor_1 : COLOR1;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float3 _var0 = float3( 0.000000, 0.000000, 0.000000 );
|
||||
float2 _var1 = In.vTexCoord_0.xy;
|
||||
float2 _var2 = In.vTexCoord_0.zw;
|
||||
float _var3 = In.vColor_1.w;
|
||||
float _var4 = In.vColor_1.x;
|
||||
float _var5 = In.vColor_1.y;
|
||||
float _var6 = In.vColor_1.z;
|
||||
float _var7 = dot( In.vTexCoord_1, float3( 0.000000, 0.000000, 1.000000 ) );
|
||||
float3x3 _var8 = { In.vTexCoord_5,
|
||||
In.vTexCoord_6,
|
||||
In.vTexCoord_1 };
|
||||
float2 _var9 = In.vTexCoord_4.xy;
|
||||
float _var10 = In.vTexCoord_4.w;
|
||||
float3 _var11 = normalize( In.vTexCoord_7 );
|
||||
float3 _var12 = float3( 0.000000, 0.000000, 0.000000 );
|
||||
float _var13 = In.vTexCoord_4.z;
|
||||
float _var14 = _g_VecOrig.z;
|
||||
float _var15 = In.vTexCoord_2.z;
|
||||
float _var16 = In.vTexCoord_4.z;
|
||||
float4 _texLookup_56 = tex2D( _Sampler_00, _var1 );
|
||||
float3 _var17 = _texLookup_56.rgb;
|
||||
float _var18 = _texLookup_56.a;
|
||||
float3 _var19 = float3( _var2, _var3 );
|
||||
_var9 = _var9 / _var10;
|
||||
float3 _var20 = _var11 * float( -1.000000 );
|
||||
float _var21 = tex2D( _Sampler_01, _var1 ).r;
|
||||
float4 _texLookup_62 = tex2D( _Sampler_02, _var1 );
|
||||
float3 _var22 = _texLookup_62.rgb;
|
||||
float _var23 = _texLookup_62.a;
|
||||
_var13 = smoothstep( float( 50.000000 ), float( 0.000000 ), _var13 );
|
||||
_var14 = CalcPixelFogFactor( PIXELFOGTYPE, _g_FogParams, _var14, _var15, _var16 );
|
||||
float3 _var24 = _var19 * float( 0.015000 );
|
||||
float _var25 = 1.0f - _var21;
|
||||
float _var26 = _var21 * float( 150.000000 );
|
||||
_var13 = _var13 * float( 0.500000 );
|
||||
float2 _var27 = _var24.zy;
|
||||
float2 _var28 = _var24.xz;
|
||||
float2 _var29 = _var24.xy;
|
||||
_var25 = _var25 + _var26;
|
||||
_var13 = _var13 + float( 0.100000 );
|
||||
float3 _var30 = tex2D( _Sampler_03, _var27 ).rgb;
|
||||
float3 _var31 = tex2D( _Sampler_03, _var28 ).rgb;
|
||||
float3 _var32 = tex2D( _Sampler_03, _var29 ).rgb;
|
||||
float4 _var33 = tex2D( _Sampler_04, _var27 ).rgba;
|
||||
float4 _var34 = tex2D( _Sampler_04, _var28 ).rgba;
|
||||
float4 _var35 = tex2D( _Sampler_04, _var29 ).rgba;
|
||||
float3 _var36 = _var19 * _var13;
|
||||
_var30 = _var30 * _var4;
|
||||
_var31 = _var31 * _var5;
|
||||
_var32 = _var32 * _var6;
|
||||
_var33 = _var33 * _var4;
|
||||
_var34 = _var34 * _var5;
|
||||
_var35 = _var35 * _var6;
|
||||
float2 _var37 = _var36.zy;
|
||||
float2 _var38 = _var36.xz;
|
||||
float2 _var39 = _var36.xy;
|
||||
_var30 = _var30 + _var31;
|
||||
_var33 = _var33 + _var34;
|
||||
float3 _var40 = tex2D( _Sampler_05, _var37 ).rgb;
|
||||
float3 _var41 = tex2D( _Sampler_05, _var38 ).rgb;
|
||||
float3 _var42 = tex2D( _Sampler_05, _var39 ).rgb;
|
||||
_var30 = _var30 + _var32;
|
||||
_var33 = _var33 + _var35;
|
||||
_var40 = _var40 * _var4;
|
||||
_var41 = _var41 * _var5;
|
||||
_var42 = _var42 * _var6;
|
||||
float _var43 = _var33.w;
|
||||
float3 _var44 = _var33.xyz;
|
||||
_var40 = _var40 + _var41;
|
||||
float _var45 = pow( _var43, float( 10.000000 ) );
|
||||
float _var46 = _var43 * float( 0.500000 );
|
||||
_var44 = _var44 * float3( 0.540000, 0.570000, 0.600000 );
|
||||
_var40 = _var40 + _var42;
|
||||
float _var47 = min( _var7, _var45 );
|
||||
float _var48 = max( _var7, _var45 );
|
||||
_var46 = _var46 + float( 0.500000 );
|
||||
float _var49 = _var40.x;
|
||||
float3 _var50 = _var40 * float( 2.000000 );
|
||||
_var47 = lerp( _var47, _var48, _var7 );
|
||||
float3 _var51 = lerp( float3( 0.900000, 0.950000, 1.000000 ), float3( 0.500000, 0.700000, 1.000000 ), _var49 );
|
||||
_var50 = _var50 - float( 1.000000 );
|
||||
_var47 = smoothstep( float( 0.100000 ), float( 0.600000 ), _var47 );
|
||||
_var50 = normalize( _var50 );
|
||||
_var46 = min( _var47, _var46 );
|
||||
_var17 = lerp( _var17, _var30, _var46 );
|
||||
_var22 = lerp( _var22, _var44, _var46 );
|
||||
_var17 = _var17 * float( 2.000000 );
|
||||
_var17 = _var17 - float( 1.000000 );
|
||||
_var17 = mul( _var17, _var8 );
|
||||
_var17 = normalize( _var17 );
|
||||
float _var52 = dot( _var17, _var20 );
|
||||
float _var53 = dot( _var17, _var50 );
|
||||
_var52 = abs( _var52 );
|
||||
_var53 = smoothstep( float( 0.995000 ), float( 0.996000 ), _var53 );
|
||||
_var52 = 1.0f - _var52;
|
||||
_var51 = _var51 * _var53;
|
||||
_var52 = pow( _var52, float( 3.000000 ) );
|
||||
_var51 = _var51 * float( 0.400000 );
|
||||
float _var54 = max( _var52, _var18 );
|
||||
_var51 = _var51 * _var47;
|
||||
#if ( FLASHLIGHT == 1 )
|
||||
float3 _var55 = (float3)0;
|
||||
float3 _var56 = (float3)0;
|
||||
DoSpecularFlashlight( g_cFlashlightPos.xyz, In.vTexCoord_2, In.vColor_0, _var17,
|
||||
g_cFlashlightAttenuationFactors.xyz, g_cFlashlightAttenuationFactors.w,
|
||||
_gSampler_Flashlight_Cookie, _gSampler_Flashlight_Depth, _gSampler_Flashlight_Random,
|
||||
FLASHLIGHTDEPTHFILTERMODE, FLASHLIGHTSHADOWS, true,
|
||||
_var9, _var25, _var20, _var54, g_cShadowTweaks,
|
||||
_var55, _var56 );
|
||||
_var0 = _var55;
|
||||
_var12 = _var56;
|
||||
#endif
|
||||
#if ( FLASHLIGHT == 0 )
|
||||
float3 _var57 = (float3)0;
|
||||
PixelShaderDoSpecularLighting( In.vTexCoord_2, _var17, _var25, _var20,
|
||||
In.vTexCoord_3, NUM_LIGHTS, g_cLightInfo,
|
||||
false, 1.0f, _var54, _var57 );
|
||||
float3 _var58 = PixelShaderDoLighting( In.vTexCoord_2, _var17, float3(0,0,0),
|
||||
false, true, In.vTexCoord_3,
|
||||
g_cAmbientCube, NUM_LIGHTS, g_cLightInfo,
|
||||
false, false, 1.0f );
|
||||
_var12 = _var57;
|
||||
_var0 = _var58;
|
||||
#endif
|
||||
_var0 = _var0;
|
||||
_var12 = _var12;
|
||||
_var0 = _var0 * _var22;
|
||||
_var0 = _var0 + _var12;
|
||||
#if ( FLASHLIGHT == 0 )
|
||||
float3 _var59 = reflect( _var11, _var17 );
|
||||
float3 _var60 = texCUBE( _Sampler_09, _var59 ).rgb;
|
||||
_var60 = _var60 * ENV_MAP_SCALE;
|
||||
float3 _var61 = _var60 * _var18;
|
||||
_var61 = lerp( _var61, _var60, _var47 );
|
||||
_var61 = _var52 * _var61;
|
||||
_var61 = _var61 * float( 0.100000 );
|
||||
_var0 = _var0 + _var61;
|
||||
#endif
|
||||
_var0 = _var0 + _var51;
|
||||
float4 _var62 = float4( _var0, _var23 );
|
||||
_var62 = FinalOutput( _var62, _var14, PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, true, _var16 );
|
||||
Out.vColor_0 = _var62;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
// Combos
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "MORPHING" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
// STATIC: "FLASHLIGHT" "0..1"
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 );
|
||||
|
||||
// Constants
|
||||
const float3 _g_VecOrig : register( c48 );
|
||||
const float4x4 g_cFlashlightWorldToTexture : register( c49 );
|
||||
#ifdef SHADER_MODEL_VS_3_0
|
||||
const float3 g_cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_10 );
|
||||
const float4 g_cMorphSubrect : register( SHADER_SPECIFIC_CONST_11 );
|
||||
#endif
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float3 vFlexDelta : POSITION1;
|
||||
float3 vFlexDelta_Normal : NORMAL1;
|
||||
float4 vBoneWeights : BLENDWEIGHT;
|
||||
float4 vBoneIndices : BLENDINDICES;
|
||||
float4 vNormal : NORMAL;
|
||||
float4 vTangent_S : TANGENT;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
#ifdef SHADER_MODEL_VS_3_0
|
||||
float vVertexID : POSITION2;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float4 vTexCoord_0 : TEXCOORD0;
|
||||
float3 vTexCoord_1 : TEXCOORD1;
|
||||
float3 vTexCoord_2 : TEXCOORD2;
|
||||
float4 vTexCoord_3 : TEXCOORD3;
|
||||
float4 vTexCoord_4 : TEXCOORD4;
|
||||
float3 vTexCoord_5 : TEXCOORD5;
|
||||
float3 vTexCoord_6 : TEXCOORD6;
|
||||
float3 vTexCoord_7 : TEXCOORD7;
|
||||
float4 vColor_0 : COLOR0;
|
||||
float4 vColor_1 : COLOR1;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float3 _var0 = (float3)0;
|
||||
float4 _var1 = (float4)0;
|
||||
DecompressVertex_NormalTangent( In.vNormal, In.vTangent_S, _var0, _var1 );
|
||||
float2 _var2 = In.vPos.xy;
|
||||
float4 _var3 = float4( 0.000000, 0.000000, 0.000000, 0.000000 );
|
||||
float _var4 = In.vPos.z;
|
||||
float3 _var5 = _var1.xyz;
|
||||
float _var6 = _var1.w;
|
||||
float4 _var7 = float4( In.vTexCoord_0, _var2 );
|
||||
float3 _var8 = _var0 * _var0;
|
||||
float3 _var9 = (float3)0;
|
||||
#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING
|
||||
ApplyMorph( In.vFlexDelta, In.vFlexDelta_Normal,
|
||||
In.vPos, _var9,
|
||||
_var0, _var0,
|
||||
_var5, _var5 );
|
||||
#else
|
||||
ApplyMorph( morphSampler, g_cMorphTargetTextureDim, g_cMorphSubrect,
|
||||
In.vVertexID, float3( 0, 0, 0 ),
|
||||
In.vPos, _var9,
|
||||
_var0, _var0,
|
||||
_var5, _var5 );
|
||||
#endif
|
||||
float4 _var10 = float4( _var8, _var4 );
|
||||
float4 _var11 = float4( _var5, _var6 );
|
||||
float3 _var12 = (float3)0;
|
||||
float3 _var13 = (float3)0;
|
||||
float3 _var14 = (float3)0;
|
||||
float3 _var15 = (float3)0;
|
||||
SkinPositionNormalAndTangentSpace( SKINNING, float4( _var9, 1 ), _var0, _var11,
|
||||
In.vBoneWeights, In.vBoneIndices,
|
||||
_var12, _var13, _var14, _var15 );
|
||||
float4 _var16 = mul( float4(_var12.xyz,1), cViewProj );
|
||||
_var13 = normalize( _var13 );
|
||||
float4 _var17 = float4( GetVertexAttenForLight( _var12, 0 ),
|
||||
GetVertexAttenForLight( _var12, 1 ),
|
||||
GetVertexAttenForLight( _var12, 2 ),
|
||||
GetVertexAttenForLight( _var12, 3 ) );
|
||||
_var14 = normalize( _var14 );
|
||||
_var15 = normalize( _var15 );
|
||||
float3 _var18 = _var12 - _g_VecOrig;
|
||||
#if ( FLASHLIGHT == 1 )
|
||||
float4 _var19 = mul( float4(_var12.xyz,1), g_cFlashlightWorldToTexture );
|
||||
_var3 = _var19;
|
||||
#endif
|
||||
Out.vProjPos = _var16;
|
||||
Out.vTexCoord_0 = _var7;
|
||||
Out.vTexCoord_1 = _var13;
|
||||
Out.vTexCoord_2 = _var12;
|
||||
Out.vTexCoord_3 = _var17;
|
||||
Out.vTexCoord_4 = _var16;
|
||||
Out.vTexCoord_5 = _var14;
|
||||
Out.vTexCoord_6 = _var15;
|
||||
Out.vTexCoord_7 = _var18;
|
||||
Out.vColor_0 = _var3;
|
||||
Out.vColor_1 = _var10;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
|
||||
|
||||
// Combos
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
sampler _Sampler_01 : register( s1 );
|
||||
|
||||
// Constants
|
||||
const float4 g_cData_sun_data : register( c0 ); // Callback
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float4 _texLookup_9 = tex2D( _Sampler_00, In.vTexCoord_0 );
|
||||
float3 _var0 = _texLookup_9.rgb;
|
||||
float _var1 = _texLookup_9.a;
|
||||
float3 _var2 = float3( 0.000000, 0.000000, 0.000000 );
|
||||
float2 _var3 = In.vTexCoord_0;
|
||||
float2 _var4 = g_cData_sun_data.xy;
|
||||
float _var5 = float( 1.000000 );
|
||||
float _var6 = g_cData_sun_data.z;
|
||||
_var4 = In.vTexCoord_0 - _var4;
|
||||
_var6 = saturate( _var6 );
|
||||
float _var7 = length( _var4 );
|
||||
float2 _var8 = _var4 / _var7;
|
||||
float _var9 = smoothstep( float( 0.000000 ), float( 0.700000 ), _var7 );
|
||||
_var8 = _var8 * _var9;
|
||||
_var8 = _var8 * float( 0.010000 );
|
||||
for ( int _var10 = 0; _var10 < 35; _var10++ )
|
||||
{
|
||||
float2 _var11 = _var8;
|
||||
_var5 = _var5 * float( 0.960000 );
|
||||
_var3 = _var3 - _var11;
|
||||
float4 _texLookup_28 = tex2D( _Sampler_01, _var3 );
|
||||
float3 _var12 = _texLookup_28.rgb;
|
||||
float _var13 = _texLookup_28.a;
|
||||
_var12 = _var12 * _var13;
|
||||
_var12 = _var12 * _var5;
|
||||
_var2 = _var2 + _var12;
|
||||
}
|
||||
_var2 = _var2 * float( 0.050000 );
|
||||
_var2 = _var2 * _var6;
|
||||
_var0 = _var0 + _var2;
|
||||
float4 _var14 = float4( _var0, _var1 );
|
||||
Out.vColor_0 = _var14;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Combos
|
||||
|
||||
// Samplers
|
||||
|
||||
// Constants
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = float4( In.vPos.x, In.vPos.y, In.vPos.z, 1.000000 );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
// Combos
|
||||
// DYNAMIC: "PIXELFOGTYPE" "0..1"
|
||||
// DYNAMIC: "WRITEWATERFOGTODESTALPHA" "0..1"
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float4 _var0 = tex2D( _Sampler_00, In.vTexCoord_0 ).rgba;
|
||||
_var0 = _var0 * In.vColor_0;
|
||||
_var0 = FinalOutput( _var0, float( 0.000000 ), PIXELFOGTYPE, TONEMAP_SCALE_LINEAR, false, 1.0f );
|
||||
Out.vColor_0 = _var0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = mul( float4(In.vPos.xyz,1), cModelViewProj );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
Out.vColor_0 = In.vColor_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,228 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
|
||||
// Constants
|
||||
const float2 _g_TexelSize : register( c16 );
|
||||
|
||||
// User code - globals
|
||||
#define PI 3.14159265
|
||||
|
||||
//--------------------------------------------------------
|
||||
//a list of user parameters
|
||||
|
||||
#define METHOD 0
|
||||
|
||||
static float near = 7; //Z-near
|
||||
static float far = 192.0; //Z-far
|
||||
static float zScaleLinear = near / far;
|
||||
static float zScaleLinearRev = far / near;
|
||||
|
||||
#if ( METHOD == 0 )
|
||||
static int samples = 3; //samples on the first ring (3 - 5)
|
||||
static int rings = 3; //ring count (3 - 5)
|
||||
static float radius_close = 6.0; //ao radius
|
||||
static float radius_far = 0.5; //ao radius
|
||||
#else
|
||||
static int samples = 24; //samples on the first ring (3 - 5)
|
||||
static float radius_close = 7.0; //ao radius
|
||||
static float radius_far = 1.5; //ao radius
|
||||
#endif
|
||||
|
||||
static float dist_exp = 6.0f;
|
||||
|
||||
static float diffarea = 0.45; //self-shadowing reduction
|
||||
static float gdisplace = 0.4; //gauss bell center
|
||||
|
||||
static float lumInfluence = 0.4; //how much luminance affects occlusion
|
||||
static float aoBoost_far = 2.5f;
|
||||
static float aoBoost_close = 6.0f;
|
||||
|
||||
static bool noise = true; //use noise instead of pattern for sample dithering?
|
||||
static bool onlyAO = true; //use only ambient occlusion pass?
|
||||
static bool fadeout = true;
|
||||
|
||||
//--------------------------------------------------------
|
||||
|
||||
float2 rand(float2 coord, float2 size) //generating noise/pattern texture for dithering
|
||||
{
|
||||
float noiseX = ((frac(1.0-coord.x*(size.x/2.0))*0.25)+(frac(coord.y*(size.y/2.0))*0.75))*2.0-1.0;
|
||||
float noiseY = ((frac(1.0-coord.x*(size.x/2.0))*0.75)+(frac(coord.y*(size.y/2.0))*0.25))*2.0-1.0;
|
||||
|
||||
if (noise)
|
||||
{
|
||||
noiseX = frac(sin(dot(coord ,float2(12.9898,78.233))) * 43758.5453) * 2.0-1.0;
|
||||
noiseY = frac(sin(dot(coord ,float2(12.9898,78.233)*2.0)) * 43758.5453) * 2.0-1.0;
|
||||
}
|
||||
return float2(noiseX,noiseY)*0.001;
|
||||
}
|
||||
|
||||
float readDepth(in float2 coord, sampler tex)
|
||||
{
|
||||
return tex2D(tex, coord ).a * zScaleLinear;
|
||||
//return (2.0 * near) / (far + near - tex2D(tex, coord ).a * (far-near));
|
||||
}
|
||||
|
||||
float readDepth(float linDepth)
|
||||
{
|
||||
return linDepth * zScaleLinear;
|
||||
}
|
||||
|
||||
float compareDepths(in float depth1, in float depth2,inout int far)
|
||||
{
|
||||
float garea = 2.0; //gauss bell width
|
||||
float diff = (depth1 - depth2)*100.0; //depth difference (0-100)
|
||||
//reduce left bell width to avoid self-shadowing
|
||||
|
||||
|
||||
if ( diff < gdisplace )
|
||||
{
|
||||
garea = diffarea;
|
||||
}else{
|
||||
far = 1;
|
||||
}
|
||||
|
||||
float gauss = pow(2.7182,-2.0*(diff-gdisplace)*(diff-gdisplace)/(garea*garea));
|
||||
return gauss;
|
||||
}
|
||||
|
||||
float calAO(float2 uv,float localDepth, float depth, float dw, float dh, sampler tex)
|
||||
{
|
||||
float dd = (1.0-depth)*lerp( radius_far, radius_close, localDepth );
|
||||
|
||||
float temp = 0.0;
|
||||
float temp2 = 0.0;
|
||||
float coordw = uv.x + dw*dd;
|
||||
float coordh = uv.y + dh*dd;
|
||||
float coordw2 = uv.x - dw*dd;
|
||||
float coordh2 = uv.y - dh*dd;
|
||||
|
||||
float2 coord = float2(coordw , coordh);
|
||||
float2 coord2 = float2(coordw2, coordh2);
|
||||
|
||||
int far = 0;
|
||||
temp = compareDepths(depth, readDepth(coord,tex),far);
|
||||
//DEPTH EXTRAPOLATION:
|
||||
if (far > 0)
|
||||
{
|
||||
temp2 = compareDepths(readDepth(coord2,tex),depth,far);
|
||||
temp += (1.0-temp)*temp2;
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
// User code - function bodies
|
||||
void DoSSAO( in float2 uv, in float2 texelSize, in sampler color_depth, out float ao_out )
|
||||
{
|
||||
float2 size = 1.0f / texelSize;
|
||||
|
||||
float2 noise = rand(uv,size);
|
||||
float depthSample = tex2D(color_depth, uv ).a;
|
||||
float depth = readDepth(depthSample);
|
||||
depthSample = pow( (1.0f - depthSample), dist_exp );
|
||||
float d;
|
||||
|
||||
float w = texelSize.x/clamp(depth,0.25,1.0)+(noise.x*(1.0-noise.x));
|
||||
float h = texelSize.y/clamp(depth,0.25,1.0)+(noise.y*(1.0-noise.y));
|
||||
|
||||
float pw;
|
||||
float ph;
|
||||
|
||||
float ao;
|
||||
float s;
|
||||
|
||||
int ringsamples;
|
||||
|
||||
#if (METHOD == 0)
|
||||
for (int i = 1; i <= rings; i++)
|
||||
{
|
||||
ringsamples = i * samples;
|
||||
for (int j = 0 ; j < ringsamples ; j += 1)
|
||||
{
|
||||
float step = PI*2.0 / float(ringsamples);
|
||||
pw = (cos(float(j)*step)*float(i));
|
||||
ph = (sin(float(j)*step)*float(i));
|
||||
ao += calAO( uv, depthSample, depth, pw*w, ph*h, color_depth );
|
||||
s += 1.0;
|
||||
}
|
||||
}
|
||||
ao /= s;
|
||||
ao = 1.0-ao;
|
||||
#else
|
||||
float dl = PI*(3.0-sqrt(5.0));
|
||||
float dz = 1.0/float(samples);
|
||||
float l = 0.0;
|
||||
float z = 1.0 - dz/2.0;
|
||||
|
||||
for (int i = 0; i <= samples; i ++)
|
||||
{
|
||||
float r = sqrt(1.0-z);
|
||||
|
||||
pw = cos(l)*r;
|
||||
ph = sin(l)*r;
|
||||
ao += calAO(uv,depthSample,depth,pw*w,ph*h,color_depth);
|
||||
z = z - dz;
|
||||
l = l + dl;
|
||||
}
|
||||
|
||||
ao /= float(samples);
|
||||
ao = 1.0-ao;
|
||||
#endif
|
||||
|
||||
float3 color = tex2D(color_depth,uv).rgb;
|
||||
|
||||
float3 lumcoeff = float3(0.299,0.587,0.114);
|
||||
float lum = dot(color.rgb, lumcoeff);
|
||||
float3 luminance = float3(lum, lum, lum);
|
||||
|
||||
ao = pow( ao, lerp( aoBoost_far, aoBoost_close, depthSample ) );
|
||||
|
||||
//lum = lerp(ao,1.0,luminance*lumInfluence);
|
||||
ao_out = lerp(ao,1.0,luminance*lumInfluence);
|
||||
|
||||
if ( fadeout )
|
||||
{
|
||||
float fade = depth * zScaleLinearRev;
|
||||
ao_out = lerp( ao_out, 0.65, pow( fade, 3 ) );
|
||||
}
|
||||
|
||||
//if(onlyAO)
|
||||
// ao = lum; //ambient occlusion only
|
||||
//else
|
||||
// col = color * lum;
|
||||
}
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float _var0 = (float)0;
|
||||
DoSSAO( In.vTexCoord_0, _g_TexelSize, _Sampler_00, _var0 );
|
||||
float4 _var1 = float4( _var0.x, _var0.x, _var0.x, 1.000000 );
|
||||
Out.vColor_0 = _var1;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = float4( In.vPos.x, In.vPos.y, In.vPos.z, 1.000000 );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
sampler _Sampler_01 : register( s1 );
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float4 _texLookup_3 = tex2D( _Sampler_00, In.vTexCoord_0 );
|
||||
float3 _var0 = _texLookup_3.rgb;
|
||||
float _var1 = _texLookup_3.a;
|
||||
float _var2 = tex2D( _Sampler_01, In.vTexCoord_0 ).r;
|
||||
_var2 = _var2 * float( 2.000000 );
|
||||
_var0 = _var0 * _var2;
|
||||
_var0 = _var0 * float( 0.850000 );
|
||||
float4 _var3 = float4( _var0, _var1 );
|
||||
Out.vColor_0 = _var3;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = float4( In.vPos.x, In.vPos.y, In.vPos.z, 1.000000 );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
|
||||
// Constants
|
||||
const float2 _g_TexelSize : register( c16 );
|
||||
|
||||
// User code - globals
|
||||
#define FXAA_PC 1
|
||||
#define FXAA_HLSL_3 1
|
||||
#define FXAA_GREEN_AS_LUMA 1
|
||||
#define FXAA_DISCARD 1
|
||||
#define FXAA_QUALITY__PRESET 10
|
||||
|
||||
#include "fxaa3_11.h"
|
||||
|
||||
// User code - function bodies
|
||||
void DoFXAA( in sampler tex, in float2 uv, in float2 texelsize, out float4 col )
|
||||
{
|
||||
col = FxaaPixelShader( uv,
|
||||
(float4)0,
|
||||
tex,
|
||||
tex,
|
||||
tex,
|
||||
texelsize,
|
||||
(float4)0,
|
||||
(float4)0,
|
||||
(float4)0,
|
||||
// fxaaQualitySubpix
|
||||
// This used to be the FXAA_QUALITY__SUBPIX define.
|
||||
// It is here now to allow easier tuning.
|
||||
// Choose the amount of sub-pixel aliasing removal.
|
||||
// This can effect sharpness.
|
||||
// 1.00 - upper limit (softer)
|
||||
// 0.75 - default amount of filtering
|
||||
// 0.50 - lower limit (sharper, less sub-pixel aliasing removal)
|
||||
// 0.25 - almost off
|
||||
// 0.00 - completely off
|
||||
0.5,
|
||||
// This used to be the FXAA_QUALITY__EDGE_THRESHOLD define.
|
||||
// It is here now to allow easier tuning.
|
||||
// The minimum amount of local contrast required to apply algorithm.
|
||||
// 0.333 - too little (faster)
|
||||
// 0.250 - low quality
|
||||
// 0.166 - default
|
||||
// 0.125 - high quality
|
||||
// 0.063 - overkill (slower)
|
||||
// fxaaQualityEdgeThreshold
|
||||
0.2,
|
||||
// This used to be the FXAA_QUALITY__EDGE_THRESHOLD_MIN define.
|
||||
// It is here now to allow easier tuning.
|
||||
// Trims the algorithm from processing darks.
|
||||
// 0.0833 - upper limit (default, the start of visible unfiltered edges)
|
||||
// 0.0625 - high quality (faster)
|
||||
// 0.0312 - visible limit (slower)
|
||||
// Special notes when using FXAA_GREEN_AS_LUMA,
|
||||
// Likely want to set this to zero.
|
||||
// As colors that are mostly not-green
|
||||
// will appear very dark in the green channel!
|
||||
// Tune by looking at mostly non-green content,
|
||||
// then start at zero and increase until aliasing is a problem.
|
||||
0.0833,
|
||||
0, 0, 0, (float4)0 );
|
||||
}
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float4 _var0 = (float4)0;
|
||||
DoFXAA( _Sampler_00, In.vTexCoord_0, _g_TexelSize, _var0 );
|
||||
Out.vColor_0 = _var0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = float4( In.vPos.x, In.vPos.y, In.vPos.z, 1.000000 );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
|
||||
// Constants
|
||||
const float4 g_cData_sun_data : register( c16 ); // Callback
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float3 _var0 = float3( 0.000000, 0.000000, 0.000000 );
|
||||
float2 _var1 = In.vTexCoord_0;
|
||||
float2 _var2 = g_cData_sun_data.xy;
|
||||
float _var3 = float( 1.000000 );
|
||||
float _var4 = g_cData_sun_data.z;
|
||||
_var2 = In.vTexCoord_0 - _var2;
|
||||
_var4 = saturate( _var4 );
|
||||
float _var5 = length( _var2 );
|
||||
float2 _var6 = _var2 / _var5;
|
||||
float _var7 = smoothstep( float( 0.000000 ), float( 0.700000 ), _var5 );
|
||||
_var6 = _var6 * _var7;
|
||||
_var6 = _var6 * float( 0.011000 );
|
||||
for ( int _var8 = 0; _var8 < 35; _var8++ )
|
||||
{
|
||||
float2 _var9 = _var6;
|
||||
_var3 = _var3 * float( 0.950000 );
|
||||
_var1 = _var1 - _var9;
|
||||
float4 _texLookup_26 = tex2D( _Sampler_00, _var1 );
|
||||
float3 _var10 = _texLookup_26.rgb;
|
||||
float _var11 = _texLookup_26.a;
|
||||
_var10 = _var10 * _var11;
|
||||
_var10 = _var10 * _var3;
|
||||
_var0 = _var0 + _var10;
|
||||
}
|
||||
_var0 = _var0 * float( 0.060000 );
|
||||
_var0 = _var0 * _var4;
|
||||
float4 _var12 = float4( _var0.x, _var0.y, _var0.z, 1.000000 );
|
||||
Out.vColor_0 = _var12;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = float4( In.vPos.x, In.vPos.y, In.vPos.z, 1.000000 );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
// ********************************
|
||||
// ** auto generated pixelshader **
|
||||
// ********************************
|
||||
|
||||
// Includes
|
||||
#include "common_ps_fxc.h"
|
||||
#include "common_vertexlitgeneric_dx9.h"
|
||||
#include "common_lightmappedgeneric_fxc.h"
|
||||
#include "common_flashlight_fxc.h"
|
||||
#include "common_parallax.h"
|
||||
|
||||
|
||||
// Samplers
|
||||
sampler _Sampler_00 : register( s0 );
|
||||
sampler _Sampler_01 : register( s1 );
|
||||
|
||||
// Semantic structures
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_OUTPUT
|
||||
{
|
||||
float4 vColor_0 : COLOR0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
PS_OUTPUT main( const PS_INPUT In )
|
||||
{
|
||||
PS_OUTPUT Out;
|
||||
float3 _var0 = float3( 0.000000, 0.000000, 0.000000 );
|
||||
float4 _texLookup_12 = tex2D( _Sampler_00, In.vTexCoord_0 );
|
||||
float3 _var1 = _texLookup_12.rgb;
|
||||
float _var2 = _texLookup_12.a;
|
||||
for ( int _var3 = -40; _var3 <= 40; _var3++ )
|
||||
{
|
||||
float2 _var4 = float2( 0.005000, 0.000000 ) * _var3;
|
||||
float _var5 = abs( _var3 );
|
||||
_var4 = _var4 + In.vTexCoord_0;
|
||||
_var5 = _var5 / float( 25.000000 );
|
||||
float3 _var6 = tex2D( _Sampler_01, _var4 ).rgb;
|
||||
float _var7 = _var4.x;
|
||||
_var5 = 1.0f - _var5;
|
||||
_var6 = smoothstep( float( 0.250000 ), float( 0.350000 ), _var6 );
|
||||
_var7 = _var7 - float( 0.500000 );
|
||||
_var5 = pow( _var5, float( 2.000000 ) );
|
||||
_var7 = abs( _var7 );
|
||||
_var7 = smoothstep( float( 0.500000 ), float( 0.400000 ), _var7 );
|
||||
_var7 = _var7 * _var5;
|
||||
_var6 = _var6 * _var7;
|
||||
_var0 = _var0 + _var6;
|
||||
}
|
||||
_var0 = _var0 * float3( 0.030000, 0.040000, 0.050000 );
|
||||
_var0 = _var0 + _var1;
|
||||
float4 _var8 = float4( _var0, _var2 );
|
||||
Out.vColor_0 = _var8;
|
||||
return Out;
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
// *********************************
|
||||
// ** auto generated vertexshader **
|
||||
// *********************************
|
||||
|
||||
// Includes
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
|
||||
// Semantic structures
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vTexCoord_0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Entry point
|
||||
VS_OUTPUT main( const VS_INPUT In )
|
||||
{
|
||||
VS_OUTPUT Out;
|
||||
float4 _var0 = float4( In.vPos.x, In.vPos.y, In.vPos.z, 1.000000 );
|
||||
Out.vProjPos = _var0;
|
||||
Out.vTexCoord_0 = In.vTexCoord_0;
|
||||
return Out;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user