mirror of
https://github.com/Gigaslav/HL2Overcharged.git
synced 2026-01-04 02:10:18 +03:00
Init comit
This commit is contained in:
191
materialsystem/shaderapidx9/locald3dtypes.h
Normal file
191
materialsystem/shaderapidx9/locald3dtypes.h
Normal file
@@ -0,0 +1,191 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef LOCALD3DTYPES_H
|
||||
#define LOCALD3DTYPES_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined( DX10 ) && !defined( DX_TO_GL_ABSTRACTION )
|
||||
|
||||
#include <d3d10.h>
|
||||
#include <d3dx10.h>
|
||||
|
||||
struct IDirect3D10BaseTexture
|
||||
{
|
||||
ID3D10Resource *m_pBaseTexture;
|
||||
ID3D10ShaderResourceView *m_pSRView;
|
||||
ID3D10RenderTargetView *m_pRTView;
|
||||
};
|
||||
|
||||
class CDx10Types
|
||||
{
|
||||
public:
|
||||
typedef struct IDirect3D10BaseTexture IDirect3DTexture;
|
||||
// FIXME: What is this called now ?
|
||||
// typedef ID3D10TextureCube IDirect3DCubeTexture;
|
||||
typedef ID3D10Texture3D IDirect3DVolumeTexture;
|
||||
typedef ID3D10Device IDirect3DDevice;
|
||||
typedef D3D10_VIEWPORT D3DVIEWPORT;
|
||||
typedef ID3D10Buffer IDirect3DIndexBuffer;
|
||||
typedef ID3D10Buffer IDirect3DVertexBuffer;
|
||||
typedef ID3D10VertexShader IDirect3DVertexShader;
|
||||
typedef ID3D10PixelShader IDirect3DPixelShader;
|
||||
typedef ID3D10ShaderResourceView IDirect3DSurface;
|
||||
typedef ID3DX10Font ID3DXFont;
|
||||
typedef ID3D10Query ID3DQuery;
|
||||
|
||||
typedef ID3D10Device *LPDIRECT3DDEVICE;
|
||||
typedef ID3D10Buffer *LPDIRECT3DINDEXBUFFER;
|
||||
typedef ID3D10Buffer *LPDIRECT3DVERTEXBUFFER;
|
||||
};
|
||||
|
||||
#endif // defined( DX10 ) && !defined( DX_TO_GL_ABSTRACTION )
|
||||
|
||||
|
||||
#if !defined( _X360 ) && !defined( DX_TO_GL_ABSTRACTION )
|
||||
#ifdef _DEBUG
|
||||
#define D3D_DEBUG_INFO 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct IDirect3DTexture9;
|
||||
struct IDirect3DBaseTexture9;
|
||||
struct IDirect3DCubeTexture9;
|
||||
struct IDirect3D9;
|
||||
struct IDirect3DDevice9;
|
||||
struct IDirect3DSurface9;
|
||||
struct IDirect3DIndexBuffer9;
|
||||
struct IDirect3DVertexBuffer9;
|
||||
struct IDirect3DVertexShader9;
|
||||
struct IDirect3DPixelShader9;
|
||||
struct IDirect3DVolumeTexture9;
|
||||
|
||||
typedef struct _D3DLIGHT9 D3DLIGHT9;
|
||||
typedef struct _D3DADAPTER_IDENTIFIER9 D3DADAPTER_IDENTIFIER9;
|
||||
typedef struct _D3DCAPS9 D3DCAPS9;
|
||||
typedef struct _D3DVIEWPORT9 D3DVIEWPORT9;
|
||||
typedef struct _D3DMATERIAL9 D3DMATERIAL9;
|
||||
typedef IDirect3DTexture9 IDirect3DTexture;
|
||||
typedef IDirect3DBaseTexture9 IDirect3DBaseTexture;
|
||||
typedef IDirect3DCubeTexture9 IDirect3DCubeTexture;
|
||||
typedef IDirect3DVolumeTexture9 IDirect3DVolumeTexture;
|
||||
typedef IDirect3DDevice9 IDirect3DDevice;
|
||||
typedef D3DMATERIAL9 D3DMATERIAL;
|
||||
typedef D3DLIGHT9 D3DLIGHT;
|
||||
typedef IDirect3DSurface9 IDirect3DSurface;
|
||||
typedef D3DCAPS9 D3DCAPS;
|
||||
typedef IDirect3DIndexBuffer9 IDirect3DIndexBuffer;
|
||||
typedef IDirect3DVertexBuffer9 IDirect3DVertexBuffer;
|
||||
typedef IDirect3DPixelShader9 IDirect3DPixelShader;
|
||||
typedef IDirect3DDevice *LPDIRECT3DDEVICE;
|
||||
typedef IDirect3DIndexBuffer *LPDIRECT3DINDEXBUFFER;
|
||||
typedef IDirect3DVertexBuffer *LPDIRECT3DVERTEXBUFFER;
|
||||
|
||||
class CDx9Types
|
||||
{
|
||||
public:
|
||||
typedef IDirect3DTexture9 IDirect3DTexture;
|
||||
typedef IDirect3DBaseTexture9 IDirect3DBaseTexture;
|
||||
typedef IDirect3DCubeTexture9 IDirect3DCubeTexture;
|
||||
typedef IDirect3DVolumeTexture9 IDirect3DVolumeTexture;
|
||||
typedef IDirect3DDevice9 IDirect3DDevice;
|
||||
typedef D3DMATERIAL9 D3DMATERIAL;
|
||||
typedef D3DLIGHT9 D3DLIGHT;
|
||||
typedef IDirect3DSurface9 IDirect3DSurface;
|
||||
typedef D3DCAPS9 D3DCAPS;
|
||||
typedef IDirect3DIndexBuffer9 IDirect3DIndexBuffer;
|
||||
typedef IDirect3DVertexBuffer9 IDirect3DVertexBuffer;
|
||||
typedef IDirect3DPixelShader9 IDirect3DPixelShader;
|
||||
typedef IDirect3DDevice *LPDIRECT3DDEVICE;
|
||||
typedef IDirect3DIndexBuffer *LPDIRECT3DINDEXBUFFER;
|
||||
typedef IDirect3DVertexBuffer *LPDIRECT3DVERTEXBUFFER;
|
||||
};
|
||||
|
||||
typedef void *HardwareShader_t;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The vertex and pixel shader type
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef int VertexShader_t;
|
||||
typedef int PixelShader_t;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Bitpattern for an invalid shader
|
||||
//-----------------------------------------------------------------------------
|
||||
#define INVALID_SHADER ( 0xFFFFFFFF )
|
||||
#define INVALID_HARDWARE_SHADER ( NULL )
|
||||
|
||||
#define D3DSAMP_NOTSUPPORTED D3DSAMP_FORCE_DWORD
|
||||
#define D3DRS_NOTSUPPORTED D3DRS_FORCE_DWORD
|
||||
|
||||
#include "togl/rendermechanism.h"
|
||||
|
||||
#if defined( _X360 )
|
||||
|
||||
// not supported, keeping for port ease
|
||||
#define D3DSAMP_SRGBTEXTURE D3DSAMP_NOTSUPPORTED
|
||||
#define D3DRS_LIGHTING D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_DIFFUSEMATERIALSOURCE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_SPECULARENABLE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_SHADEMODE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_LASTPIXEL D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_DITHERENABLE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_FOGENABLE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_FOGCOLOR D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_FOGTABLEMODE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_FOGSTART D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_FOGEND D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_FOGDENSITY D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_RANGEFOGENABLE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_TEXTUREFACTOR D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_CLIPPING D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_AMBIENT D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_FOGVERTEXMODE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_COLORVERTEX D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_LOCALVIEWER D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_NORMALIZENORMALS D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_SPECULARMATERIALSOURCE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_AMBIENTMATERIALSOURCE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_EMISSIVEMATERIALSOURCE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_VERTEXBLEND D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_POINTSCALEENABLE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_POINTSCALE_A D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_POINTSCALE_B D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_POINTSCALE_C D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_PATCHEDGESTYLE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_DEBUGMONITORTOKEN D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_INDEXEDVERTEXBLENDENABLE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_TWEENFACTOR D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_POSITIONDEGREE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_NORMALDEGREE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_ANTIALIASEDLINEENABLE D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_ADAPTIVETESS_X D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_ADAPTIVETESS_Y D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_ADAPTIVETESS_Z D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_ADAPTIVETESS_W D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_ENABLEADAPTIVETESSELLATION D3DRS_NOTSUPPORTED
|
||||
#define D3DRS_SRGBWRITEENABLE D3DRS_NOTSUPPORTED
|
||||
#define D3DLOCK_DISCARD 0
|
||||
#define D3DUSAGE_DYNAMIC 0
|
||||
#define D3DUSAGE_AUTOGENMIPMAP 0
|
||||
#define D3DDEVTYPE_REF D3DDEVTYPE_HAL
|
||||
#define D3DENUM_WHQL_LEVEL 0
|
||||
#define D3DCREATE_SOFTWARE_VERTEXPROCESSING D3DCREATE_HARDWARE_VERTEXPROCESSING
|
||||
#define D3DDMT_ENABLE 0
|
||||
|
||||
typedef enum D3DSHADEMODE
|
||||
{
|
||||
D3DSHADE_FLAT = 0,
|
||||
D3DSHADE_GOURAUD = 0,
|
||||
};
|
||||
|
||||
#endif // _X360
|
||||
|
||||
#endif // LOCALD3DTYPES_H
|
||||
2303
materialsystem/stdshaders/BaseVSShader.cpp
Normal file
2303
materialsystem/stdshaders/BaseVSShader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
454
materialsystem/stdshaders/BaseVSShader.h
Normal file
454
materialsystem/stdshaders/BaseVSShader.h
Normal file
@@ -0,0 +1,454 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
// This is what all vs/ps (dx8+) shaders inherit from.
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef BASEVSSHADER_H
|
||||
#define BASEVSSHADER_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "shaderlib/cshader.h"
|
||||
#include "shaderlib/BaseShader.h"
|
||||
#include "convar.h"
|
||||
#include <renderparm.h>
|
||||
|
||||
#ifdef _X360
|
||||
#define SUPPORT_DX8 0
|
||||
#define SUPPORT_DX7 0
|
||||
#else
|
||||
#define SUPPORT_DX8 1
|
||||
#define SUPPORT_DX7 1
|
||||
#endif
|
||||
|
||||
#ifdef MAPBASE
|
||||
extern ConVar mat_specular_disable_on_missing;
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helper macro for vertex shaders
|
||||
//-----------------------------------------------------------------------------
|
||||
#define BEGIN_VS_SHADER_FLAGS(_name, _help, _flags) __BEGIN_SHADER_INTERNAL( CBaseVSShader, _name, _help, _flags )
|
||||
#define BEGIN_VS_SHADER(_name,_help) __BEGIN_SHADER_INTERNAL( CBaseVSShader, _name, _help, 0 )
|
||||
|
||||
|
||||
// useful parameter initialization macro
|
||||
#define INIT_FLOAT_PARM( parm, value ) \
|
||||
if ( !params[(parm)]->IsDefined() ) \
|
||||
{ \
|
||||
params[(parm)]->SetFloatValue( (value) ); \
|
||||
}
|
||||
|
||||
// useful pixel shader declaration macro for ps20/20b c++ code
|
||||
#define SET_STATIC_PS2X_PIXEL_SHADER_NO_COMBOS( basename ) \
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) \
|
||||
{ \
|
||||
DECLARE_STATIC_PIXEL_SHADER( basename##_ps20b ); \
|
||||
SET_STATIC_PIXEL_SHADER( basename##_ps20b ); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
DECLARE_STATIC_PIXEL_SHADER( basename##_ps20 ); \
|
||||
SET_STATIC_PIXEL_SHADER( basename##_ps20 ); \
|
||||
}
|
||||
|
||||
#define SET_DYNAMIC_PS2X_PIXEL_SHADER_NO_COMBOS( basename ) \
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() ) \
|
||||
{ \
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( basename##_ps20b ); \
|
||||
SET_DYNAMIC_PIXEL_SHADER( basename##_ps20b ); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( basename##_ps20 ); \
|
||||
SET_DYNAMIC_PIXEL_SHADER( basename##_ps20 ); \
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Base class for shaders, contains helper methods.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBaseVSShader : public CBaseShader
|
||||
{
|
||||
public:
|
||||
|
||||
// Loads bump lightmap coordinates into the pixel shader
|
||||
void LoadBumpLightmapCoordinateAxes_PixelShader( int pixelReg );
|
||||
|
||||
// Loads bump lightmap coordinates into the vertex shader
|
||||
void LoadBumpLightmapCoordinateAxes_VertexShader( int vertexReg );
|
||||
|
||||
// Pixel and vertex shader constants....
|
||||
void SetPixelShaderConstant( int pixelReg, int constantVar );
|
||||
|
||||
// Pixel and vertex shader constants....
|
||||
void SetPixelShaderConstantGammaToLinear( int pixelReg, int constantVar );
|
||||
|
||||
// This version will put constantVar into x,y,z, and constantVar2 into the w
|
||||
void SetPixelShaderConstant( int pixelReg, int constantVar, int constantVar2 );
|
||||
void SetPixelShaderConstantGammaToLinear( int pixelReg, int constantVar, int constantVar2 );
|
||||
|
||||
// Helpers for setting constants that need to be converted to linear space (from gamma space).
|
||||
void SetVertexShaderConstantGammaToLinear( int var, float const* pVec, int numConst = 1, bool bForce = false );
|
||||
void SetPixelShaderConstantGammaToLinear( int var, float const* pVec, int numConst = 1, bool bForce = false );
|
||||
|
||||
void SetVertexShaderConstant( int vertexReg, int constantVar );
|
||||
|
||||
// set rgb components of constant from a color parm and give an explicit w value
|
||||
void SetPixelShaderConstant_W( int pixelReg, int constantVar, float fWValue );
|
||||
|
||||
// GR - fix for const/lerp issues
|
||||
void SetPixelShaderConstantFudge( int pixelReg, int constantVar );
|
||||
|
||||
// Sets light direction for pixel shaders.
|
||||
void SetPixelShaderLightColors( int pixelReg );
|
||||
|
||||
// Sets vertex shader texture transforms
|
||||
void SetVertexShaderTextureTranslation( int vertexReg, int translationVar );
|
||||
void SetVertexShaderTextureScale( int vertexReg, int scaleVar );
|
||||
void SetVertexShaderTextureTransform( int vertexReg, int transformVar );
|
||||
void SetVertexShaderTextureScaledTransform( int vertexReg,
|
||||
int transformVar, int scaleVar );
|
||||
|
||||
// Set pixel shader texture transforms
|
||||
void SetPixelShaderTextureTranslation( int pixelReg, int translationVar );
|
||||
void SetPixelShaderTextureScale( int pixelReg, int scaleVar );
|
||||
void SetPixelShaderTextureTransform( int pixelReg, int transformVar );
|
||||
void SetPixelShaderTextureScaledTransform( int pixelReg,
|
||||
int transformVar, int scaleVar );
|
||||
|
||||
// Moves a matrix into vertex shader constants
|
||||
void SetVertexShaderMatrix3x4( int vertexReg, int matrixVar );
|
||||
void SetVertexShaderMatrix4x4( int vertexReg, int matrixVar );
|
||||
|
||||
// Loads the view matrix into vertex shader constants
|
||||
void LoadViewMatrixIntoVertexShaderConstant( int vertexReg );
|
||||
|
||||
// Loads the projection matrix into vertex shader constants
|
||||
void LoadProjectionMatrixIntoVertexShaderConstant( int vertexReg );
|
||||
|
||||
// Loads the model->view matrix into vertex shader constants
|
||||
void LoadModelViewMatrixIntoVertexShaderConstant( int vertexReg );
|
||||
|
||||
// Loads a scale/offset version of the viewport transform into the specified constant.
|
||||
void LoadViewportTransformScaledIntoVertexShaderConstant( int vertexReg );
|
||||
|
||||
// Sets up ambient light cube...
|
||||
void SetAmbientCubeDynamicStateVertexShader( );
|
||||
float GetAmbientLightCubeLuminance( );
|
||||
|
||||
// Helpers for dealing with envmaptint
|
||||
void SetEnvMapTintPixelShaderDynamicState( int pixelReg, int tintVar, int alphaVar, bool bConvertFromGammaToLinear = false );
|
||||
|
||||
// Helper methods for pixel shader overbrighting
|
||||
void EnablePixelShaderOverbright( int reg, bool bEnable, bool bDivideByTwo );
|
||||
|
||||
// Helper for dealing with modulation
|
||||
void SetModulationVertexShaderDynamicState();
|
||||
void SetModulationPixelShaderDynamicState( int modulationVar );
|
||||
void SetModulationPixelShaderDynamicState_LinearColorSpace( int modulationVar );
|
||||
void SetModulationPixelShaderDynamicState_LinearColorSpace_LinearScale( int modulationVar, float flScale );
|
||||
|
||||
// Sets a color + alpha into shader constants
|
||||
void SetColorVertexShaderConstant( int nVertexReg, int colorVar, int alphaVar );
|
||||
void SetColorPixelShaderConstant( int nPixelReg, int colorVar, int alphaVar );
|
||||
|
||||
|
||||
#ifndef GAME_SHADER_DLL
|
||||
//
|
||||
// Standard shader passes!
|
||||
//
|
||||
|
||||
void InitParamsUnlitGeneric_DX8(
|
||||
int baseTextureVar,
|
||||
int detailScaleVar,
|
||||
int envmapOptionalVar,
|
||||
int envmapVar,
|
||||
int envmapTintVar,
|
||||
int envmapMaskScaleVar,
|
||||
int nDetailBlendMode );
|
||||
|
||||
void InitUnlitGeneric_DX8(
|
||||
int baseTextureVar,
|
||||
int detailVar,
|
||||
int envmapVar,
|
||||
int envmapMaskVar );
|
||||
|
||||
// Dx8 Unlit Generic pass
|
||||
void VertexShaderUnlitGenericPass( int baseTextureVar, int frameVar,
|
||||
int baseTextureTransformVar,
|
||||
int detailVar, int detailTransform, bool bDetailTransformIsScale,
|
||||
int envmapVar, int envMapFrameVar, int envmapMaskVar,
|
||||
int envmapMaskFrameVar, int envmapMaskScaleVar, int envmapTintVar,
|
||||
int alphaTestReferenceVar,
|
||||
int nDetailBlendModeVar,
|
||||
int nOutlineVar,
|
||||
int nOutlineColorVar,
|
||||
int nOutlineStartVar,
|
||||
int nOutlineEndVar,
|
||||
int nSeparateDetailUVsVar
|
||||
);
|
||||
|
||||
// Helpers for drawing world bump mapped stuff.
|
||||
void DrawModelBumpedSpecularLighting( int bumpMapVar, int bumpMapFrameVar,
|
||||
int envMapVar, int envMapVarFrame,
|
||||
int envMapTintVar, int alphaVar,
|
||||
int envMapContrastVar, int envMapSaturationVar,
|
||||
int bumpTransformVar,
|
||||
bool bBlendSpecular, bool bNoWriteZ = false );
|
||||
void DrawWorldBumpedSpecularLighting( int bumpmapVar, int envmapVar,
|
||||
int bumpFrameVar, int envmapFrameVar,
|
||||
int envmapTintVar, int alphaVar,
|
||||
int envmapContrastVar, int envmapSaturationVar,
|
||||
int bumpTransformVar, int fresnelReflectionVar,
|
||||
bool bBlend, bool bNoWriteZ = false );
|
||||
|
||||
const char *UnlitGeneric_ComputeVertexShaderName( bool bMask,
|
||||
bool bEnvmap,
|
||||
bool bBaseTexture,
|
||||
bool bBaseAlphaEnvmapMask,
|
||||
bool bDetail,
|
||||
bool bVertexColor,
|
||||
bool bEnvmapCameraSpace,
|
||||
bool bEnvmapSphere );
|
||||
|
||||
const char *UnlitGeneric_ComputePixelShaderName( bool bMask,
|
||||
bool bEnvmap,
|
||||
bool bBaseTexture,
|
||||
bool bBaseAlphaEnvmapMask,
|
||||
bool bDetail,
|
||||
bool bMultiplyDetail,
|
||||
bool bMaskBaseByDetailAlpha );
|
||||
|
||||
void DrawWorldBaseTexture( int baseTextureVar, int baseTextureTransformVar, int frameVar, int colorVar, int alphaVar );
|
||||
void DrawWorldBumpedDiffuseLighting( int bumpmapVar, int bumpFrameVar,
|
||||
int bumpTransformVar, bool bMultiply, bool bSSBump );
|
||||
void DrawWorldBumpedSpecularLighting( int envmapMaskVar, int envmapMaskFrame,
|
||||
int bumpmapVar, int envmapVar,
|
||||
int bumpFrameVar, int envmapFrameVar,
|
||||
int envmapTintVar, int alphaVar,
|
||||
int envmapContrastVar, int envmapSaturationVar,
|
||||
int bumpTransformVar, int fresnelReflectionVar,
|
||||
bool bBlend );
|
||||
void DrawBaseTextureBlend( int baseTextureVar, int baseTextureTransformVar,
|
||||
int baseTextureFrameVar,
|
||||
int baseTexture2Var, int baseTextureTransform2Var,
|
||||
int baseTextureFrame2Var, int colorVar, int alphaVar );
|
||||
void DrawWorldBumpedDiffuseLighting_Base_ps14( int bumpmapVar, int bumpFrameVar,
|
||||
int bumpTransformVar, int baseTextureVar, int baseTextureTransformVar, int frameVar );
|
||||
void DrawWorldBumpedDiffuseLighting_Blend_ps14( int bumpmapVar, int bumpFrameVar, int bumpTransformVar,
|
||||
int baseTextureVar, int baseTextureTransformVar, int baseTextureFrameVar,
|
||||
int baseTexture2Var, int baseTextureTransform2Var, int baseTextureFrame2Var);
|
||||
void DrawWorldBumpedUsingVertexShader( int baseTextureVar, int baseTextureTransformVar,
|
||||
int bumpmapVar, int bumpFrameVar,
|
||||
int bumpTransformVar,
|
||||
int envmapMaskVar, int envmapMaskFrame,
|
||||
int envmapVar,
|
||||
int envmapFrameVar,
|
||||
int envmapTintVar, int colorVar, int alphaVar,
|
||||
int envmapContrastVar, int envmapSaturationVar, int frameVar, int fresnelReflectionVar,
|
||||
bool doBaseTexture2,
|
||||
int baseTexture2Var,
|
||||
int baseTextureTransform2Var,
|
||||
int baseTextureFrame2Var,
|
||||
bool bSSBump
|
||||
);
|
||||
|
||||
// Sets up hw morphing state for the vertex shader
|
||||
void SetHWMorphVertexShaderState( int nDimConst, int nSubrectConst, VertexTextureSampler_t morphSampler );
|
||||
|
||||
// Computes the shader index for vertex lit materials
|
||||
int ComputeVertexLitShaderIndex( bool bVertexLitGeneric, bool hasBump, bool hasEnvmap, bool hasVertexColor, bool bHasNormal ) const;
|
||||
|
||||
// Helper for setting up flashlight constants
|
||||
void SetFlashlightVertexShaderConstants( bool bBump, int bumpTransformVar, bool bDetail, int detailScaleVar, bool bSetTextureTransforms );
|
||||
|
||||
#if SUPPORT_DX8
|
||||
void DrawFlashlight_dx80( IMaterialVar** params, IShaderDynamicAPI *pShaderAPI, IShaderShadow* pShaderShadow,
|
||||
bool bBump, int bumpmapVar, int bumpmapFrame, int bumpTransform, int flashlightTextureVar,
|
||||
int flashlightTextureFrameVar, bool bLightmappedGeneric, bool bWorldVertexTransition,
|
||||
int nWorldVertexTransitionPassID, int baseTexture2Var, int baseTexture2FrameVar,
|
||||
bool bTeeth=false, int nTeethForwardVar=0, int nTeethIllumFactorVar=0 );
|
||||
#endif
|
||||
|
||||
struct DrawFlashlight_dx90_Vars_t
|
||||
{
|
||||
DrawFlashlight_dx90_Vars_t()
|
||||
{
|
||||
// set all ints to -1
|
||||
memset( this, 0xFF, sizeof(DrawFlashlight_dx90_Vars_t) );
|
||||
// set all bools to a default value.
|
||||
m_bBump = false;
|
||||
m_bLightmappedGeneric = false;
|
||||
m_bWorldVertexTransition = false;
|
||||
m_bTeeth = false;
|
||||
m_bSSBump = false;
|
||||
m_fSeamlessScale = 0.0;
|
||||
}
|
||||
bool m_bBump;
|
||||
bool m_bLightmappedGeneric;
|
||||
bool m_bWorldVertexTransition;
|
||||
bool m_bTeeth;
|
||||
int m_nBumpmapVar;
|
||||
int m_nBumpmapFrame;
|
||||
int m_nBumpTransform;
|
||||
int m_nFlashlightTextureVar;
|
||||
int m_nFlashlightTextureFrameVar;
|
||||
int m_nBaseTexture2Var;
|
||||
int m_nBaseTexture2FrameVar;
|
||||
#ifdef MAPBASE
|
||||
int m_nBaseTexture2TransformVar;
|
||||
#endif
|
||||
int m_nBumpmap2Var;
|
||||
int m_nBumpmap2Frame;
|
||||
int m_nBump2Transform;
|
||||
int m_nDetailVar;
|
||||
int m_nDetailScale;
|
||||
int m_nDetailTextureCombineMode;
|
||||
int m_nDetailTextureBlendFactor;
|
||||
int m_nDetailTint;
|
||||
int m_nTeethForwardVar;
|
||||
int m_nTeethIllumFactorVar;
|
||||
int m_nAlphaTestReference;
|
||||
bool m_bSSBump;
|
||||
float m_fSeamlessScale; // 0.0 = not seamless
|
||||
};
|
||||
void DrawFlashlight_dx90( IMaterialVar** params,
|
||||
IShaderDynamicAPI *pShaderAPI, IShaderShadow* pShaderShadow, DrawFlashlight_dx90_Vars_t &vars );
|
||||
#endif // GAME_SHADER_DLL
|
||||
|
||||
BlendType_t EvaluateBlendRequirements( int textureVar, bool isBaseTexture, int detailTextureVar = -1 );
|
||||
|
||||
void HashShadow2DJitter( const float fJitterSeed, float *fU, float* fV );
|
||||
|
||||
//Alpha tested materials can end up leaving garbage in the dest alpha buffer if they write depth.
|
||||
//This pass fills in the areas that passed the alpha test with depth in dest alpha
|
||||
//by writing only equal depth pixels and only if we should be writing depth to dest alpha
|
||||
void DrawEqualDepthToDestAlpha( void );
|
||||
|
||||
private:
|
||||
// Helper methods for VertexLitGenericPass
|
||||
// void UnlitGenericShadowState( int baseTextureVar, int detailVar, int envmapVar, int envmapMaskVar, bool doSkin );
|
||||
void UnlitGenericDynamicState( int baseTextureVar, int frameVar, int baseTextureTransformVar,
|
||||
int detailVar, int detailTransform, bool bDetailTransformIsScale, int envmapVar,
|
||||
int envMapFrameVar, int envmapMaskVar, int envmapMaskFrameVar,
|
||||
int envmapMaskScaleVar, int envmapTintVar );
|
||||
|
||||
// Converts a color + alpha into a vector4
|
||||
void ColorVarsToVector( int colorVar, int alphaVar, Vector4D &color );
|
||||
|
||||
};
|
||||
|
||||
extern ConVar r_flashlightbrightness;
|
||||
|
||||
FORCEINLINE void SetFlashLightColorFromState( FlashlightState_t const &state, IShaderDynamicAPI *pShaderAPI, int nPSRegister=28, bool bFlashlightNoLambert=false )
|
||||
{
|
||||
// Old code
|
||||
//float flToneMapScale = ( pShaderAPI->GetToneMappingScaleLinear() ).x;
|
||||
//float flFlashlightScale = 1.0f / flToneMapScale;
|
||||
|
||||
// Fix to old code to keep flashlight from ever getting brighter than 1.0
|
||||
//float flToneMapScale = ( pShaderAPI->GetToneMappingScaleLinear() ).x;
|
||||
//if ( flToneMapScale < 1.0f )
|
||||
// flToneMapScale = 1.0f;
|
||||
//float flFlashlightScale = 1.0f / flToneMapScale;
|
||||
|
||||
float flFlashlightScale = r_flashlightbrightness.GetFloat();
|
||||
|
||||
if ( !g_pHardwareConfig->GetHDREnabled() )
|
||||
{
|
||||
// Non-HDR path requires 2.0 flashlight
|
||||
flFlashlightScale = 2.0f;
|
||||
}
|
||||
|
||||
// DX10 requires some hackery due to sRGB/blend ordering change from DX9
|
||||
if ( g_pHardwareConfig->UsesSRGBCorrectBlending() )
|
||||
{
|
||||
flFlashlightScale *= 2.5f; // Magic number that works well on the NVIDIA 8800
|
||||
}
|
||||
|
||||
// INSOLENCE: This causes very odd projected texture flickering bugs, so it's commented out for now
|
||||
/*flFlashlightScale *= state.m_fBrightnessScale;*/
|
||||
|
||||
// Generate pixel shader constant
|
||||
float const *pFlashlightColor = state.m_Color;
|
||||
float vPsConst[4] = { flFlashlightScale * pFlashlightColor[0], flFlashlightScale * pFlashlightColor[1], flFlashlightScale * pFlashlightColor[2], pFlashlightColor[3] };
|
||||
vPsConst[3] = bFlashlightNoLambert ? 2.0f : 0.0f; // This will be added to N.L before saturate to force a 1.0 N.L term
|
||||
|
||||
// Red flashlight for testing
|
||||
//vPsConst[0] = 0.5f; vPsConst[1] = 0.0f; vPsConst[2] = 0.0f;
|
||||
|
||||
pShaderAPI->SetPixelShaderConstant( nPSRegister, ( float * )vPsConst );
|
||||
}
|
||||
|
||||
FORCEINLINE float ShadowAttenFromState( FlashlightState_t const &state )
|
||||
{
|
||||
// DX10 requires some hackery due to sRGB/blend ordering change from DX9, which makes the shadows too light
|
||||
if ( g_pHardwareConfig->UsesSRGBCorrectBlending() )
|
||||
return state.m_flShadowAtten * 0.1f; // magic number
|
||||
|
||||
return state.m_flShadowAtten;
|
||||
}
|
||||
|
||||
FORCEINLINE float ShadowFilterFromState( FlashlightState_t const &state )
|
||||
{
|
||||
//// We developed shadow maps at 1024, so we expect the penumbra size to have been tuned relative to that
|
||||
//return state.m_flShadowFilterSize / 1024.0f;
|
||||
|
||||
// INSOLENCE: Get the shadow map resolution from the same place we get the shadow filter size
|
||||
return state.m_flShadowFilterSize / state.m_flShadowMapResolution;
|
||||
}
|
||||
|
||||
|
||||
// convenient material variable access functions for helpers to use.
|
||||
FORCEINLINE bool IsTextureSet( int nVar, IMaterialVar **params )
|
||||
{
|
||||
return ( nVar != -1 ) && ( params[nVar]->IsTexture() );
|
||||
}
|
||||
|
||||
FORCEINLINE bool IsBoolSet( int nVar, IMaterialVar **params )
|
||||
{
|
||||
return ( nVar != -1 ) && ( params[nVar]->GetIntValue() );
|
||||
}
|
||||
|
||||
FORCEINLINE int GetIntParam( int nVar, IMaterialVar **params, int nDefaultValue = 0 )
|
||||
{
|
||||
return ( nVar != -1 ) ? ( params[nVar]->GetIntValue() ) : nDefaultValue;
|
||||
}
|
||||
|
||||
FORCEINLINE float GetFloatParam( int nVar, IMaterialVar **params, float flDefaultValue = 0.0 )
|
||||
{
|
||||
return ( nVar != -1 ) ? ( params[nVar]->GetFloatValue() ) : flDefaultValue;
|
||||
}
|
||||
|
||||
FORCEINLINE void InitFloatParam( int nIndex, IMaterialVar **params, float flValue )
|
||||
{
|
||||
if ( (nIndex != -1) && !params[nIndex]->IsDefined() )
|
||||
{
|
||||
params[nIndex]->SetFloatValue( flValue );
|
||||
}
|
||||
}
|
||||
|
||||
FORCEINLINE void InitIntParam( int nIndex, IMaterialVar **params, int nValue )
|
||||
{
|
||||
if ( (nIndex != -1) && !params[nIndex]->IsDefined() )
|
||||
{
|
||||
params[nIndex]->SetIntValue( nValue );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ConVar;
|
||||
|
||||
#ifdef _DEBUG
|
||||
extern ConVar mat_envmaptintoverride;
|
||||
extern ConVar mat_envmaptintscale;
|
||||
#endif
|
||||
|
||||
|
||||
#endif // BASEVSSHADER_H
|
||||
90
materialsystem/stdshaders/Bloom.cpp
Normal file
90
materialsystem/stdshaders/Bloom.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
|
||||
#include "SDK_screenspaceeffect_vs20.inc"
|
||||
#include "SDK_Bloom_ps20.inc"
|
||||
#include "SDK_Bloom_ps20b.inc"
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( SDK_Bloom, "Help for Bloom", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( FBTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_FullFrameFB", "" )
|
||||
SHADER_PARAM( BLURTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_SmallHDR0", "" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if( params[FBTEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( FBTEXTURE );
|
||||
}
|
||||
if( params[BLURTEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( BLURTEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
// Requires DX9 + above
|
||||
if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
|
||||
{
|
||||
Assert( 0 );
|
||||
return "Wireframe";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
int fmt = VERTEX_POSITION;
|
||||
pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
|
||||
|
||||
// Pre-cache shaders
|
||||
DECLARE_STATIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( sdk_bloom_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER( sdk_bloom_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( sdk_bloom_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER( sdk_bloom_ps20 );
|
||||
}
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, FBTEXTURE, -1 );
|
||||
BindTexture( SHADER_SAMPLER1, BLURTEXTURE, -1 );
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( sdk_bloom_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( sdk_bloom_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( sdk_bloom_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( sdk_bloom_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
122
materialsystem/stdshaders/BlurFilterX.cpp
Normal file
122
materialsystem/stdshaders/BlurFilterX.cpp
Normal file
@@ -0,0 +1,122 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "BlurFilter_vs20.inc"
|
||||
#include "BlurFilter_ps20.inc"
|
||||
#include "BlurFilter_ps20b.inc"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( BlurFilterX, "Help for BlurFilterX", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if( params[BASETEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
|
||||
{
|
||||
return "BlurFilterX_DX80";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
|
||||
|
||||
// Render targets are pegged as sRGB on POSIX, so just force these reads and writes
|
||||
bool bForceSRGBReadAndWrite = IsOSX() && g_pHardwareConfig->CanDoSRGBReadFromRTs();
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, bForceSRGBReadAndWrite );
|
||||
pShaderShadow->EnableSRGBWrite( bForceSRGBReadAndWrite );
|
||||
|
||||
// Pre-cache shaders
|
||||
blurfilter_vs20_Static_Index vshIndex;
|
||||
pShaderShadow->SetVertexShader( "BlurFilter_vs20", vshIndex.GetIndex() );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
#ifndef _X360
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( APPROX_SRGB_ADAPTER, bForceSRGBReadAndWrite );
|
||||
#endif
|
||||
SET_STATIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
}
|
||||
|
||||
if ( IS_FLAG_SET( MATERIAL_VAR_ADDITIVE ) )
|
||||
EnableAlphaBlending( SHADER_BLEND_ONE, SHADER_BLEND_ONE );
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, BASETEXTURE, -1 );
|
||||
|
||||
float v[4];
|
||||
|
||||
// The temp buffer is 1/4 back buffer size
|
||||
ITexture *src_texture = params[BASETEXTURE]->GetTextureValue();
|
||||
int width = src_texture->GetActualWidth();
|
||||
float dX = 1.0f / width;
|
||||
|
||||
// Tap offsets
|
||||
v[0] = 1.3366f * dX;
|
||||
v[1] = 0.0f;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, v, 1 );
|
||||
v[0] = 3.4295f * dX;
|
||||
v[1] = 0.0f;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, v, 1 );
|
||||
v[0] = 5.4264f * dX;
|
||||
v[1] = 0.0f;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, v, 1 );
|
||||
|
||||
v[0] = 7.4359f * dX;
|
||||
v[1] = 0.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( 0, v, 1 );
|
||||
v[0] = 9.4436f * dX;
|
||||
v[1] = 0.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( 1, v, 1 );
|
||||
v[0] = 11.4401f * dX;
|
||||
v[1] = 0.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( 2, v, 1 );
|
||||
v[0] = v[1] = v[2] = v[3] = 1.0;
|
||||
pShaderAPI->SetPixelShaderConstant( 3, v, 1 );
|
||||
|
||||
pShaderAPI->SetVertexShaderIndex( 0 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
86
materialsystem/stdshaders/BlurFilterX_dx80.cpp
Normal file
86
materialsystem/stdshaders/BlurFilterX_dx80.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DEFINE_FALLBACK_SHADER( BlurFilterX, BlurFilterX_DX80 )
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( BlurFilterX_DX80, "Help for BlurFilterX_DX80", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if( params[BASETEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
if ( g_pHardwareConfig->GetDXSupportLevel() < 80 )
|
||||
{
|
||||
return "Wireframe";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
|
||||
pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
|
||||
|
||||
// Pre-cache shaders
|
||||
pShaderShadow->SetVertexShader( "BlurFilter_vs11", 0 );
|
||||
pShaderShadow->SetPixelShader( "BlurFilter_ps11", 0 );
|
||||
|
||||
if ( IS_FLAG_SET( MATERIAL_VAR_ADDITIVE ) )
|
||||
EnableAlphaBlending( SHADER_BLEND_ONE, SHADER_BLEND_ONE );
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, BASETEXTURE, -1 );
|
||||
BindTexture( SHADER_SAMPLER1, BASETEXTURE, -1 );
|
||||
BindTexture( SHADER_SAMPLER2, BASETEXTURE, -1 );
|
||||
BindTexture( SHADER_SAMPLER3, BASETEXTURE, -1 );
|
||||
|
||||
// The temp buffer is 1/4 back buffer size
|
||||
ITexture *src_texture=params[BASETEXTURE]->GetTextureValue();
|
||||
int width = src_texture->GetActualWidth();
|
||||
float dX = 2.0f / width;
|
||||
|
||||
// 4 Tap offsets, expected from pixel center
|
||||
float v[4][4];
|
||||
v[0][0] = -1.5f * dX;
|
||||
v[0][1] = 0;
|
||||
v[1][0] = -0.5f * dX;
|
||||
v[1][1] = 0;
|
||||
v[2][0] = 0.5f * dX;
|
||||
v[2][1] = 0;
|
||||
v[3][0] = 1.5f * dX;
|
||||
v[3][1] = 0;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, &v[0][0], 4 );
|
||||
|
||||
v[0][0] = v[0][1] = v[0][2] = v[0][3] = 1.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( 1, v[0], 1 );
|
||||
|
||||
pShaderAPI->SetVertexShaderIndex( 0 );
|
||||
pShaderAPI->SetPixelShaderIndex( 0 );
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
136
materialsystem/stdshaders/BlurFilterY.cpp
Normal file
136
materialsystem/stdshaders/BlurFilterY.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "BlurFilter_vs20.inc"
|
||||
#include "BlurFilter_ps20.inc"
|
||||
#include "BlurFilter_ps20b.inc"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( BlurFilterY, "Help for BlurFilterY", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( BLOOMAMOUNT, SHADER_PARAM_TYPE_FLOAT, "1.0", "" )
|
||||
SHADER_PARAM( FRAMETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_SmallHDR0", "" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
if ( !( params[BLOOMAMOUNT]->IsDefined() ) )
|
||||
{
|
||||
params[BLOOMAMOUNT]->SetFloatValue( 1.0 );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if ( params[BASETEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
|
||||
{
|
||||
return "BlurFilterY_DX80";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
|
||||
|
||||
// Render targets are pegged as sRGB on POSIX, so just force these reads and writes
|
||||
bool bForceSRGBReadAndWrite = IsOSX() && g_pHardwareConfig->CanDoSRGBReadFromRTs();
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, bForceSRGBReadAndWrite );
|
||||
pShaderShadow->EnableSRGBWrite( bForceSRGBReadAndWrite );
|
||||
|
||||
// Pre-cache shaders
|
||||
DECLARE_STATIC_VERTEX_SHADER( blurfilter_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( blurfilter_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
#ifndef _X360
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( APPROX_SRGB_ADAPTER, bForceSRGBReadAndWrite );
|
||||
#endif
|
||||
SET_STATIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
}
|
||||
|
||||
if ( IS_FLAG_SET( MATERIAL_VAR_ADDITIVE ) )
|
||||
EnableAlphaBlending( SHADER_BLEND_ONE, SHADER_BLEND_ONE );
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, BASETEXTURE, -1 );
|
||||
|
||||
// The temp buffer is 1/4 back buffer size
|
||||
ITexture *src_texture = params[BASETEXTURE]->GetTextureValue();
|
||||
int height = src_texture->GetActualWidth();
|
||||
float dY = 1.0f / height;
|
||||
// dY *= 0.4;
|
||||
float v[4];
|
||||
|
||||
// Tap offsets
|
||||
v[0] = 0.0f;
|
||||
v[1] = 1.3366f * dY;
|
||||
v[2] = 0;
|
||||
v[3] = 0;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, v, 1 );
|
||||
v[0] = 0.0f;
|
||||
v[1] = 3.4295f * dY;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, v, 1 );
|
||||
v[0] = 0.0f;
|
||||
v[1] = 5.4264f * dY;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, v, 1 );
|
||||
|
||||
v[0] = 0.0f;
|
||||
v[1] = 7.4359f * dY;
|
||||
pShaderAPI->SetPixelShaderConstant( 0, v, 1 );
|
||||
v[0] = 0.0f;
|
||||
v[1] = 9.4436f * dY;
|
||||
pShaderAPI->SetPixelShaderConstant( 1, v, 1 );
|
||||
v[0] = 0.0f;
|
||||
v[1] = 11.4401f * dY;
|
||||
pShaderAPI->SetPixelShaderConstant( 2, v, 1 );
|
||||
|
||||
v[0]=v[1]=v[2]=params[BLOOMAMOUNT]->GetFloatValue();
|
||||
|
||||
pShaderAPI->SetPixelShaderConstant( 3, v, 1 );
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( blurfilter_ps20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER( blurfilter_ps20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER( blurfilter_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER( blurfilter_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
91
materialsystem/stdshaders/BlurFilterY_dx80.cpp
Normal file
91
materialsystem/stdshaders/BlurFilterY_dx80.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DEFINE_FALLBACK_SHADER( BlurFilterY, BlurFilterY_DX80 )
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( BlurFilterY_DX80, "Help for BlurFilterY_DX80", SHADER_NOT_EDITABLE )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( BLOOMAMOUNT, SHADER_PARAM_TYPE_FLOAT, "1.0", "" )
|
||||
SHADER_PARAM( FRAMETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_SmallHDR0", "" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if ( params[BASETEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
if ( !( params[BLOOMAMOUNT]->IsDefined() ) )
|
||||
params[BLOOMAMOUNT]->SetFloatValue(1.0);
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
if ( g_pHardwareConfig->GetDXSupportLevel() < 80 )
|
||||
{
|
||||
return "Wireframe";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableAlphaWrites( true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
|
||||
pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
|
||||
|
||||
// Pre-cache shaders
|
||||
pShaderShadow->SetVertexShader( "BlurFilter_vs11", 0 );
|
||||
pShaderShadow->SetPixelShader( "BlurFilter_ps11", 0 );
|
||||
|
||||
if ( IS_FLAG_SET( MATERIAL_VAR_ADDITIVE ) )
|
||||
EnableAlphaBlending( SHADER_BLEND_ONE, SHADER_BLEND_ONE );
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, BASETEXTURE, -1 );
|
||||
BindTexture( SHADER_SAMPLER1, BASETEXTURE, -1 );
|
||||
BindTexture( SHADER_SAMPLER2, BASETEXTURE, -1 );
|
||||
BindTexture( SHADER_SAMPLER3, BASETEXTURE, -1 );
|
||||
|
||||
int width, height;
|
||||
pShaderAPI->GetBackBufferDimensions( width, height );
|
||||
|
||||
// The temp buffer is 1/4 back buffer size
|
||||
float dY = 2.0f / height;
|
||||
|
||||
// 4 Tap offsets, expected from pixel center
|
||||
float v[4][4];
|
||||
v[0][0] = 0;
|
||||
v[0][1] = -1.5f * dY;
|
||||
v[1][0] = 0;
|
||||
v[1][1] = -0.5f * dY;
|
||||
v[2][0] = 0;
|
||||
v[2][1] = 0.5f * dY;
|
||||
v[3][0] = 0;
|
||||
v[3][1] = 1.5f * dY;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, &v[0][0], 4 );
|
||||
|
||||
v[0][0] = v[0][1] = v[0][2] = params[BLOOMAMOUNT]->GetFloatValue();
|
||||
pShaderAPI->SetPixelShaderConstant( 1, v[0], 1 );
|
||||
|
||||
pShaderAPI->SetVertexShaderIndex( 0 );
|
||||
pShaderAPI->SetPixelShaderIndex( 0 );
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
18
materialsystem/stdshaders/BlurFilter_ps11.psh
Normal file
18
materialsystem/stdshaders/BlurFilter_ps11.psh
Normal file
@@ -0,0 +1,18 @@
|
||||
ps.1.1
|
||||
|
||||
// 1221 filter constants
|
||||
def c0, 0.1667f, 0.1667f, 0.1667f, 0.3333f
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
mul r0.rgb, t0, c0
|
||||
mad r0.rgb, t1, c0.a, r0
|
||||
mad r0.rgb, t2, c0.a, r0
|
||||
mad r0.rgb, t3, c0, r0
|
||||
|
||||
mul r0.rgb, r0, c1 +
|
||||
mov r0.a, t0.a
|
||||
|
||||
91
materialsystem/stdshaders/BlurFilter_ps2x.fxc
Normal file
91
materialsystem/stdshaders/BlurFilter_ps2x.fxc
Normal file
@@ -0,0 +1,91 @@
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
|
||||
// STATIC: "APPROX_SRGB_ADAPTER" "0..1" [ps20b] [PC]
|
||||
|
||||
#define HDRTYPE HDR_TYPE_NONE
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler TexSampler : register( s0 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 coordTap0 : TEXCOORD0;
|
||||
float2 coordTap1 : TEXCOORD1;
|
||||
float2 coordTap2 : TEXCOORD2;
|
||||
float2 coordTap3 : TEXCOORD3;
|
||||
float2 coordTap1Neg : TEXCOORD4;
|
||||
float2 coordTap2Neg : TEXCOORD5;
|
||||
float2 coordTap3Neg : TEXCOORD6;
|
||||
};
|
||||
|
||||
float2 psTapOffs[3] : register( c0 );
|
||||
float3 scale_factor : register( c3 );
|
||||
|
||||
float4 SampleTexture( sampler texSampler, float2 uv )
|
||||
{
|
||||
float4 cSample = tex2D( texSampler, uv );
|
||||
|
||||
#if ( APPROX_SRGB_ADAPTER )
|
||||
{
|
||||
cSample.rgb = max( cSample.rgb, float3( 0.00001f, 0.00001f, 0.00001f ) ); // rsqrt doesn't like inputs of zero
|
||||
|
||||
float3 ooSQRT; //
|
||||
ooSQRT.r = rsqrt( cSample.r ); //
|
||||
ooSQRT.g = rsqrt( cSample.g ); // Approximate linear-to-sRGB conversion
|
||||
ooSQRT.b = rsqrt( cSample.b ); //
|
||||
cSample.rgb *= ooSQRT.rgb; //
|
||||
}
|
||||
#endif
|
||||
|
||||
return cSample;
|
||||
}
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4 s0, s1, s2, s3, s4, s5, s6, color;
|
||||
|
||||
// Sample taps with coordinates from VS
|
||||
s0 = SampleTexture( TexSampler, i.coordTap0 );
|
||||
s1 = SampleTexture( TexSampler, i.coordTap1 );
|
||||
s2 = SampleTexture( TexSampler, i.coordTap2 );
|
||||
s3 = SampleTexture( TexSampler, i.coordTap3 );
|
||||
s4 = SampleTexture( TexSampler, i.coordTap1Neg );
|
||||
s5 = SampleTexture( TexSampler, i.coordTap2Neg );
|
||||
s6 = SampleTexture( TexSampler, i.coordTap3Neg );
|
||||
|
||||
color = s0 * 0.2013f;
|
||||
color += ( s1 + s4 ) * 0.2185f;
|
||||
color += ( s2 + s5 ) * 0.0821f;
|
||||
color += ( s3 + s6 ) * 0.0461f;
|
||||
|
||||
// Compute tex coords for other taps
|
||||
float2 coordTap4 = i.coordTap0 + psTapOffs[0];
|
||||
float2 coordTap5 = i.coordTap0 + psTapOffs[1];
|
||||
float2 coordTap6 = i.coordTap0 + psTapOffs[2];
|
||||
float2 coordTap4Neg = i.coordTap0 - psTapOffs[0];
|
||||
float2 coordTap5Neg = i.coordTap0 - psTapOffs[1];
|
||||
float2 coordTap6Neg = i.coordTap0 - psTapOffs[2];
|
||||
|
||||
// Sample the taps
|
||||
s1 = SampleTexture( TexSampler, coordTap4 );
|
||||
s2 = SampleTexture( TexSampler, coordTap5 );
|
||||
s3 = SampleTexture( TexSampler, coordTap6 );
|
||||
s4 = SampleTexture( TexSampler, coordTap4Neg );
|
||||
s5 = SampleTexture( TexSampler, coordTap5Neg );
|
||||
s6 = SampleTexture( TexSampler, coordTap6Neg );
|
||||
|
||||
color += ( s1 + s4 ) * 0.0262f;
|
||||
color += ( s2 + s5 ) * 0.0162f;
|
||||
color += ( s3 + s6 ) * 0.0102f;
|
||||
color.xyz*=scale_factor.xyz;
|
||||
|
||||
#if ( APPROX_SRGB_ADAPTER )
|
||||
{
|
||||
color.xyz *= color.xyz; // Approximate sRGB-to-linear conversion
|
||||
}
|
||||
#endif
|
||||
|
||||
return color;
|
||||
//return FinalOutput( color, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
|
||||
34
materialsystem/stdshaders/BlurFilter_vs11.fxc
Normal file
34
materialsystem/stdshaders/BlurFilter_vs11.fxc
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vBaseTexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float2 coordTap0 : TEXCOORD0;
|
||||
float2 coordTap1 : TEXCOORD1;
|
||||
float2 coordTap2 : TEXCOORD2;
|
||||
float2 coordTap3 : TEXCOORD3;
|
||||
};
|
||||
|
||||
float2 vsTapOffs[4] : register ( SHADER_SPECIFIC_CONST_0 );
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
o.projPos = float4( v.vPos, 1.0f );
|
||||
|
||||
o.coordTap0 = v.vBaseTexCoord + vsTapOffs[0];
|
||||
o.coordTap1 = v.vBaseTexCoord + vsTapOffs[1];
|
||||
o.coordTap2 = v.vBaseTexCoord + vsTapOffs[2];
|
||||
o.coordTap3 = v.vBaseTexCoord + vsTapOffs[3];
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
39
materialsystem/stdshaders/BlurFilter_vs20.fxc
Normal file
39
materialsystem/stdshaders/BlurFilter_vs20.fxc
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 vPos : POSITION;
|
||||
float2 vBaseTexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float2 coordTap0 : TEXCOORD0;
|
||||
float2 coordTap1 : TEXCOORD1;
|
||||
float2 coordTap2 : TEXCOORD2;
|
||||
float2 coordTap3 : TEXCOORD3;
|
||||
float2 coordTap1Neg : TEXCOORD4;
|
||||
float2 coordTap2Neg : TEXCOORD5;
|
||||
float2 coordTap3Neg : TEXCOORD6;
|
||||
};
|
||||
|
||||
float2 vsTapOffs[3] : register ( SHADER_SPECIFIC_CONST_0 );
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
o.projPos = float4( v.vPos, 1.0f );
|
||||
o.coordTap0 = v.vBaseTexCoord;
|
||||
o.coordTap1 = v.vBaseTexCoord + vsTapOffs[0];
|
||||
o.coordTap2 = v.vBaseTexCoord + vsTapOffs[1];
|
||||
o.coordTap3 = v.vBaseTexCoord + vsTapOffs[2];
|
||||
o.coordTap1Neg = v.vBaseTexCoord - vsTapOffs[0];
|
||||
o.coordTap2Neg = v.vBaseTexCoord - vsTapOffs[1];
|
||||
o.coordTap3Neg = v.vBaseTexCoord - vsTapOffs[2];
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
27
materialsystem/stdshaders/Cable.psh
Normal file
27
materialsystem/stdshaders/Cable.psh
Normal file
@@ -0,0 +1,27 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; See the vertex shader for info
|
||||
;
|
||||
; This shader takes:
|
||||
; t0 = normal map
|
||||
; t1 = base texture
|
||||
; v0 = directional light color
|
||||
; t2 = directional light direction (biased into 0-1)
|
||||
; c0 = percent of dirlight to add as ambient
|
||||
;
|
||||
; Output:
|
||||
; (t0 dot t1) * v0
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0 ; Get the 3-vector from the normal map
|
||||
tex t1 ; Interpret tcoord t1 as color data.
|
||||
texcoord t2
|
||||
|
||||
dp3 r1, t0_bx2, t2_bx2 ; r1 = normalMap dot dirLightDir
|
||||
add r0, r1, c0 ; + 0.5
|
||||
|
||||
mul r1, v0, r0 ; scale the dot product by the dirlight's actual color
|
||||
mul r0.rgb, r1, t1 + ; scale by the texture color
|
||||
|
||||
mul r0.a, t1.a, v0.a
|
||||
117
materialsystem/stdshaders/Cable.vsh
Normal file
117
materialsystem/stdshaders/Cable.vsh
Normal file
@@ -0,0 +1,117 @@
|
||||
vs.1.1
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; The cable equation is:
|
||||
; [L dot N] * C * T
|
||||
;
|
||||
; where:
|
||||
; C = directional light color
|
||||
; T = baseTexture
|
||||
; N = particle normal (stored in the normal map)
|
||||
; L = directional light direction
|
||||
;
|
||||
; $SHADER_SPECIFIC_CONST_0 = Directional light direction
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Transform position from object to projection space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Setup the tangent space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$tmp1 );
|
||||
&AllocateRegister( \$tmp2 );
|
||||
&AllocateRegister( \$tmp3 );
|
||||
&AllocateRegister( \$r );
|
||||
|
||||
; Get S crossed with T (call it R)
|
||||
mov $tmp1, $vTangentS
|
||||
mov $tmp2, $vTangentT
|
||||
|
||||
mul $tmp3, $vTangentS.yzxw, $tmp2.zxyw
|
||||
mad $r, -$vTangentS.zxyw, $tmp2.yzxw, $tmp3
|
||||
|
||||
&FreeRegister( \$tmp2 );
|
||||
&FreeRegister( \$tmp3 );
|
||||
|
||||
&AllocateRegister( \$s );
|
||||
|
||||
; Normalize S (into $s)
|
||||
dp3 $s.w, $vTangentS, $vTangentS
|
||||
rsq $s.w, $s.w
|
||||
mul $s.xyz, $vTangentS, $s.w
|
||||
|
||||
; Normalize R (into $r)
|
||||
dp3 $r.w, $r, $r
|
||||
rsq $r.w, $r.w
|
||||
mul $r.xyz, $r, $r.w
|
||||
|
||||
&AllocateRegister( \$t );
|
||||
|
||||
; Regenerate T (into $t)
|
||||
mul $t, $r.yzxw, $tmp1.zxyw
|
||||
mad $t, -$r.zxyw, $tmp1.yzxw, $t
|
||||
|
||||
&FreeRegister( \$tmp1 );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Transform the light direction (into oD1)
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$lightDirection );
|
||||
|
||||
dp3 $lightDirection.x, $s, $SHADER_SPECIFIC_CONST_0
|
||||
dp3 $lightDirection.y, $t, $SHADER_SPECIFIC_CONST_0
|
||||
dp3 $lightDirection.z, $r, $SHADER_SPECIFIC_CONST_0
|
||||
|
||||
&FreeRegister( \$r );
|
||||
&FreeRegister( \$s );
|
||||
&FreeRegister( \$t );
|
||||
|
||||
; Scale into 0-1 range (we're assuming light direction was normalized prior to here)
|
||||
add oT2, $lightDirection, $cHalf ; + 0.5
|
||||
&FreeRegister( \$lightDirection );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Copy texcoords for the normal map and base texture
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
mov oT0, $vTexCoord0
|
||||
mov oT1, $vTexCoord1
|
||||
|
||||
; Pass the dirlight color through
|
||||
mov oD0.xyzw, $vColor
|
||||
|
||||
|
||||
23
materialsystem/stdshaders/DebugDrawDepth_ps2x.fxc
Normal file
23
materialsystem/stdshaders/DebugDrawDepth_ps2x.fxc
Normal file
@@ -0,0 +1,23 @@
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
|
||||
|
||||
#define HDRTYPE HDR_TYPE_NONE
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float3 zValue : TEXCOORD0;
|
||||
};
|
||||
|
||||
const float3 g_ZFilter : register( c1 );
|
||||
const float3 g_ModulationColor : register( c2 );
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float z = dot( i.zValue, g_ZFilter );
|
||||
z = saturate( z );
|
||||
float4 color = float4( z, z, z, 1.0f );
|
||||
color.rgb *= g_ModulationColor;
|
||||
return FinalOutput( color, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
38
materialsystem/stdshaders/DebugDrawDepth_vs20.fxc
Normal file
38
materialsystem/stdshaders/DebugDrawDepth_vs20.fxc
Normal file
@@ -0,0 +1,38 @@
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
static const bool g_bSkinning = SKINNING ? true : false;
|
||||
|
||||
const float2 cDepthFactor : register( SHADER_SPECIFIC_CONST_0 );
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION;
|
||||
float4 vBoneWeights : BLENDWEIGHT;
|
||||
float4 vBoneIndices : BLENDINDICES;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float2 zValue : TEXCOORD0;
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
float3 worldPos;
|
||||
SkinPosition( g_bSkinning, v.vPos, v.vBoneWeights, v.vBoneIndices, worldPos );
|
||||
float4 projPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
o.projPos = projPos;
|
||||
o.zValue.x = (o.projPos.z - cDepthFactor.y) / cDepthFactor.x;
|
||||
o.zValue.y = (o.projPos.w - cDepthFactor.y) / cDepthFactor.x;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
94
materialsystem/stdshaders/DebugDrawEnvmapMask.cpp
Normal file
94
materialsystem/stdshaders/DebugDrawEnvmapMask.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "debugdrawenvmapmask_vs20.inc"
|
||||
#include "debugdrawenvmapmask_ps20.inc"
|
||||
#include "debugdrawenvmapmask_ps20b.inc"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
BEGIN_VS_SHADER_FLAGS( DebugDrawEnvmapMask, "Help for DebugDrawEnvmapMask", SHADER_NOT_EDITABLE )
|
||||
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( SHOWALPHA, SHADER_PARAM_TYPE_INTEGER, "0", "" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING );
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
if( g_pHardwareConfig->GetDXSupportLevel() < 90 )
|
||||
{
|
||||
// Assert( 0 );
|
||||
return "Wireframe";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
|
||||
// Set stream format (note that this shader supports compression)
|
||||
unsigned int flags = VERTEX_POSITION | VERTEX_FORMAT_COMPRESSED;
|
||||
int nTexCoordCount = 1;
|
||||
int userDataSize = 0;
|
||||
pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize );
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( debugdrawenvmapmask_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( debugdrawenvmapmask_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( debugdrawenvmapmask_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER( debugdrawenvmapmask_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( debugdrawenvmapmask_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER( debugdrawenvmapmask_ps20 );
|
||||
}
|
||||
}
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
int numBones = s_pShaderAPI->GetCurrentNumBones();
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( debugdrawenvmapmask_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, numBones > 0 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
|
||||
SET_DYNAMIC_VERTEX_SHADER( debugdrawenvmapmask_vs20 );
|
||||
|
||||
bool bShowAlpha = params[SHOWALPHA]->GetIntValue() ? true : false;
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( debugdrawenvmapmask_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( SHOWALPHA, bShowAlpha );
|
||||
SET_DYNAMIC_PIXEL_SHADER( debugdrawenvmapmask_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( debugdrawenvmapmask_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( SHOWALPHA, bShowAlpha );
|
||||
SET_DYNAMIC_PIXEL_SHADER( debugdrawenvmapmask_ps20 );
|
||||
}
|
||||
|
||||
BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME );
|
||||
SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, BASETEXTURETRANSFORM );
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
26
materialsystem/stdshaders/DebugDrawEnvmapMask_ps2x.fxc
Normal file
26
materialsystem/stdshaders/DebugDrawEnvmapMask_ps2x.fxc
Normal file
@@ -0,0 +1,26 @@
|
||||
// DYNAMIC: "SHOWALPHA" "0..1"
|
||||
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
|
||||
|
||||
#define HDRTYPE HDR_TYPE_NONE
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler BaseTextureSampler : register( s0 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float2 baseTexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4 baseColor = tex2D( BaseTextureSampler, i.baseTexCoord );
|
||||
#if SHOWALPHA
|
||||
float4 result = float4( baseColor.a, baseColor.a, baseColor.a, 1.0f );
|
||||
#else
|
||||
float4 result = float4( baseColor.rgb, 1.0f );
|
||||
#endif
|
||||
return FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
39
materialsystem/stdshaders/DebugDrawEnvmapMask_vs20.fxc
Normal file
39
materialsystem/stdshaders/DebugDrawEnvmapMask_vs20.fxc
Normal file
@@ -0,0 +1,39 @@
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
static const bool g_bSkinning = SKINNING ? true : false;
|
||||
|
||||
const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION;
|
||||
float4 vBoneWeights : BLENDWEIGHT;
|
||||
float4 vBoneIndices : BLENDINDICES;
|
||||
float4 vTexCoord0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION;
|
||||
float2 baseTexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
float3 worldPos;
|
||||
SkinPosition( g_bSkinning, v.vPos, v.vBoneWeights, v.vBoneIndices, worldPos );
|
||||
float4 projPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
o.projPos = projPos;
|
||||
o.baseTexCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] );
|
||||
o.baseTexCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] );
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
104
materialsystem/stdshaders/DebugTextureView.cpp
Normal file
104
materialsystem/stdshaders/DebugTextureView.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "shaderlib/cshader.h"
|
||||
|
||||
#include "debugtextureview_vs20.inc"
|
||||
#include "debugtextureview_ps20.inc"
|
||||
#include "debugtextureview_ps20b.inc"
|
||||
|
||||
DEFINE_FALLBACK_SHADER( DebugTextureView, DebugTextureView_dx9 )
|
||||
BEGIN_VS_SHADER( DebugTextureView_dx9, "Help for DebugTextureView" )
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( SHOWALPHA, SHADER_PARAM_TYPE_BOOL, "0", "" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if ( params[BASETEXTURE]->IsDefined() )
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
|
||||
{
|
||||
return "UnlitGeneric";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableDepthWrites( false );
|
||||
pShaderShadow->EnableAlphaTest( true );
|
||||
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
|
||||
// Set stream format (note that this shader supports compression)
|
||||
unsigned int flags = VERTEX_POSITION | VERTEX_FORMAT_COMPRESSED;
|
||||
int nTexCoordCount = 1;
|
||||
int userDataSize = 0;
|
||||
pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize );
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( debugtextureview_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( debugtextureview_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( debugtextureview_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( SHOWALPHA, params[SHOWALPHA]->GetIntValue() != 0 );
|
||||
SET_STATIC_PIXEL_SHADER( debugtextureview_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( debugtextureview_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( SHOWALPHA, params[SHOWALPHA]->GetIntValue() != 0 );
|
||||
SET_STATIC_PIXEL_SHADER( debugtextureview_ps20 );
|
||||
}
|
||||
}
|
||||
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME );
|
||||
//pShaderAPI->BindStandardTexture( SHADER_SAMPLER1, TEXTURE_LIGHTMAP );
|
||||
|
||||
ITexture *pTexture = params[BASETEXTURE]->GetTextureValue();
|
||||
|
||||
float cPsConst0[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
if ( ( pTexture->GetImageFormat() == IMAGE_FORMAT_RGBA16161616F ) ||
|
||||
( pTexture->GetImageFormat() == IMAGE_FORMAT_RGBA16161616 ) ||
|
||||
( pTexture->GetImageFormat() == IMAGE_FORMAT_RGB323232F ) ||
|
||||
( pTexture->GetImageFormat() == IMAGE_FORMAT_RGBA32323232F ) )
|
||||
{
|
||||
if ( pTexture->IsCubeMap() )
|
||||
cPsConst0[0] = 1.0f;
|
||||
else
|
||||
cPsConst0[1] = 1.0f;
|
||||
}
|
||||
pShaderAPI->SetPixelShaderConstant( 0, cPsConst0 );
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( debugtextureview_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
|
||||
SET_DYNAMIC_VERTEX_SHADER( debugtextureview_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( debugtextureview_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( ISCUBEMAP, pTexture->IsCubeMap() );
|
||||
SET_DYNAMIC_PIXEL_SHADER( debugtextureview_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( debugtextureview_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( ISCUBEMAP, pTexture->IsCubeMap() );
|
||||
SET_DYNAMIC_PIXEL_SHADER( debugtextureview_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
81
materialsystem/stdshaders/DebugTextureView_ps2x.fxc
Normal file
81
materialsystem/stdshaders/DebugTextureView_ps2x.fxc
Normal file
@@ -0,0 +1,81 @@
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
|
||||
// STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
|
||||
// STATIC: "SHOWALPHA" "0..1"
|
||||
// DYNAMIC: "ISCUBEMAP" "0..1"
|
||||
|
||||
#define HDRTYPE HDR_TYPE_NONE
|
||||
#include "common_ps_fxc.h"
|
||||
|
||||
sampler g_tSampler : register( s0 );
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
const float3 g_vConst0 : register( c0 );
|
||||
#define g_flIsHdrCube g_vConst0.x
|
||||
#define g_flIsHdr2D g_vConst0.y
|
||||
|
||||
float4 main( PS_INPUT i ) : COLOR
|
||||
{
|
||||
float4 sample = tex2D( g_tSampler, i.texCoord );
|
||||
float4 result = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
result.rgb = sample.rgb;
|
||||
#if SHOWALPHA
|
||||
result.rgb = sample.a;
|
||||
#endif
|
||||
|
||||
if ( g_flIsHdr2D )
|
||||
result.rgb *= MAX_HDR_OVERBRIGHT;
|
||||
|
||||
#if ISCUBEMAP
|
||||
bool bNoDataForThisPixel = false;
|
||||
float3 vec = float3( 0, 0, 0 );
|
||||
float x = i.texCoord.x;
|
||||
float y = i.texCoord.y;
|
||||
float x2 = frac( ( i.texCoord.x ) * 3.0f ) * 2.0f - 1.0f;
|
||||
float y2 = frac( ( i.texCoord.y ) * 4.0f ) * 2.0f - 1.0f;
|
||||
if ( ( x >= 0.3333f ) && ( x <= 0.6666f ) ) //Center row
|
||||
{
|
||||
if ( y >= 0.75f )
|
||||
vec = float3( x2, 1.0, y2 );
|
||||
else if ( y >= 0.5f )
|
||||
vec = float3( x2, y2, -1.0 );
|
||||
else if ( y >= 0.25f )
|
||||
vec = float3( x2, -1.0, -y2 );
|
||||
else if ( y >= 0.0f )
|
||||
vec = float3( x2, -y2, 1.0 );
|
||||
}
|
||||
else if ( ( y >= 0.25f ) && ( y <= 0.5f ) )
|
||||
{
|
||||
if ( x <= 0.3333f )
|
||||
vec = float3( -1.0f, -x2, -y2 );
|
||||
else if (x >= 0.6666f)
|
||||
vec = float3( 1.0f, x2, -y2 );
|
||||
else
|
||||
bNoDataForThisPixel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bNoDataForThisPixel = true;
|
||||
}
|
||||
|
||||
float4 cBase = texCUBE( g_tSampler, vec );
|
||||
#if SHOWALPHA
|
||||
cBase.rgb = cBase.a;
|
||||
#endif
|
||||
|
||||
if ( g_flIsHdrCube )
|
||||
cBase.rgb *= ENV_MAP_SCALE;
|
||||
|
||||
if ( bNoDataForThisPixel == true )
|
||||
cBase.rgb = float3( 0.9f, 0.4f, 0.15f );
|
||||
|
||||
result.rgb = cBase.rgb;
|
||||
result.a = 1.0f; // - bNoDataForThisPixel;
|
||||
#endif
|
||||
|
||||
return FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
|
||||
}
|
||||
23
materialsystem/stdshaders/DebugTextureView_vs20.fxc
Normal file
23
materialsystem/stdshaders/DebugTextureView_vs20.fxc
Normal file
@@ -0,0 +1,23 @@
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION;
|
||||
float4 vTexCoord0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos : POSITION;
|
||||
float2 vUv0 : TEXCOORD0;
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT i )
|
||||
{
|
||||
VS_OUTPUT o;
|
||||
o.vProjPos.xyzw = mul( i.vPos.xyzw, cModelViewProj );
|
||||
o.vUv0.xy = i.vTexCoord0.xy;
|
||||
return o;
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v120_xp:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit
|
||||
Debug|Win32|D:\SourceCodes\project_overcharged_build_10_rtt\src_RTT\|
|
||||
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.
Binary file not shown.
Binary file not shown.
16
materialsystem/stdshaders/Eyes.psh
Normal file
16
materialsystem/stdshaders/Eyes.psh
Normal file
@@ -0,0 +1,16 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw the eyes
|
||||
; t0 - texture
|
||||
; t1 - iris
|
||||
; t2 - glint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
|
||||
lrp r0, t1.a, t1, t0 ; Blend in the iris with the background
|
||||
mad r0.rgb, r0, v0, t2 + ; Modulate by the illumination, add in the glint
|
||||
mov r0.a, t0.a
|
||||
18
materialsystem/stdshaders/Eyes_Overbright2.psh
Normal file
18
materialsystem/stdshaders/Eyes_Overbright2.psh
Normal file
@@ -0,0 +1,18 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw the eyes
|
||||
; t0 - texture
|
||||
; t1 - iris
|
||||
; t2 - glint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
|
||||
lrp r0, t1.a, t1, t0 ; Blend in the iris with the background
|
||||
mul_x2 r0, v0, r0 ; Modulate by the illumination with overbright
|
||||
|
||||
add r0.rgb, r0, t2 + ; Add in the glint
|
||||
mov r0.a, t0.a
|
||||
145
materialsystem/stdshaders/Eyes_vs20.fxc
Normal file
145
materialsystem/stdshaders/Eyes_vs20.fxc
Normal file
@@ -0,0 +1,145 @@
|
||||
//======= Copyright <20> 1996-2006, Valve Corporation, All rights reserved. ======
|
||||
// $SHADER_SPECIFIC_CONST_0 = eyeball origin
|
||||
// $SHADER_SPECIFIC_CONST_1 = eyeball up * 0.5
|
||||
// $SHADER_SPECIFIC_CONST_2 = iris projection U
|
||||
// $SHADER_SPECIFIC_CONST_3 = iris projection V
|
||||
// $SHADER_SPECIFIC_CONST_4 = glint projection U
|
||||
// $SHADER_SPECIFIC_CONST_5 = glint projection V
|
||||
//=============================================================================
|
||||
|
||||
// STATIC: "INTRO" "0..1"
|
||||
// STATIC: "HALFLAMBERT" "0..1"
|
||||
// STATIC: "USE_STATIC_CONTROL_FLOW" "0..1" [vs20]
|
||||
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
// DYNAMIC: "DOWATERFOG" "0..1"
|
||||
// DYNAMIC: "DYNAMIC_LIGHT" "0..1"
|
||||
// DYNAMIC: "STATIC_LIGHT" "0..1"
|
||||
// DYNAMIC: "MORPHING" "0..1" [vs30]
|
||||
// DYNAMIC: "NUM_LIGHTS" "0..2" [vs20]
|
||||
|
||||
// If using static control flow on Direct3D, we should use the NUM_LIGHTS=0 combo
|
||||
// SKIP: $USE_STATIC_CONTROL_FLOW && ( $NUM_LIGHTS > 0 ) [vs20]
|
||||
|
||||
#include "vortwarp_vs20_helper.h"
|
||||
|
||||
static const int g_bSkinning = SKINNING ? true : false;
|
||||
static const int g_FogType = DOWATERFOG;
|
||||
static const bool g_bHalfLambert = HALFLAMBERT ? true : false;
|
||||
|
||||
const float3 cEyeOrigin : register( SHADER_SPECIFIC_CONST_0 );
|
||||
const float3 cHalfEyeballUp : register( SHADER_SPECIFIC_CONST_1 );
|
||||
const float4 cIrisProjectionU : register( SHADER_SPECIFIC_CONST_2 );
|
||||
const float4 cIrisProjectionV : register( SHADER_SPECIFIC_CONST_3 );
|
||||
const float4 cGlintProjectionU : register( SHADER_SPECIFIC_CONST_4 );
|
||||
const float4 cGlintProjectionV : register( SHADER_SPECIFIC_CONST_5 );
|
||||
#if INTRO
|
||||
const float4 const4 : register( SHADER_SPECIFIC_CONST_6 );
|
||||
#define g_Time const4.w
|
||||
#define modelOrigin const4.xyz
|
||||
#endif
|
||||
|
||||
#ifdef SHADER_MODEL_VS_3_0
|
||||
// NOTE: cMorphTargetTextureDim.xy = target dimensions,
|
||||
// cMorphTargetTextureDim.z = 4tuples/morph
|
||||
const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_7 );
|
||||
const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_8 );
|
||||
|
||||
sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 );
|
||||
#endif
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION; // Position
|
||||
float4 vBoneWeights : BLENDWEIGHT; // Skin weights
|
||||
float4 vBoneIndices : BLENDINDICES; // Skin indices
|
||||
float4 vTexCoord0 : TEXCOORD0; // Base (sclera) texture coordinates
|
||||
|
||||
float3 vPosFlex : POSITION1; // Delta positions for flexing
|
||||
#ifdef SHADER_MODEL_VS_3_0
|
||||
float vVertexID : POSITION2;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 projPos : POSITION; // Projection-space position
|
||||
#if !defined( _X360 )
|
||||
float fog : FOG; // Fixed-function fog factor
|
||||
#endif
|
||||
float2 baseTC : TEXCOORD0; // Base texture coordinate
|
||||
float2 irisTC : TEXCOORD1; // Iris texture coordinates
|
||||
float2 glintTC : TEXCOORD2; // Glint texture coordinates
|
||||
float3 vColor : TEXCOORD3; // Vertex-lit color
|
||||
|
||||
float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
|
||||
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o;
|
||||
|
||||
bool bDynamicLight = DYNAMIC_LIGHT ? true : false;
|
||||
bool bStaticLight = STATIC_LIGHT ? true : false;
|
||||
|
||||
float4 vPosition = v.vPos;
|
||||
float3 dummy = v.vPos.xyz; // dummy values that can't be optimized out
|
||||
|
||||
#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING
|
||||
ApplyMorph( v.vPosFlex, vPosition.xyz );
|
||||
#else
|
||||
ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, v.vVertexID, dummy, vPosition.xyz );
|
||||
#endif
|
||||
|
||||
// Transform the position and dummy normal (not doing the dummy normal causes invariance issues with the flashlight!)
|
||||
float3 worldNormal, worldPos;
|
||||
SkinPositionAndNormal(
|
||||
g_bSkinning,
|
||||
vPosition, dummy,
|
||||
v.vBoneWeights, v.vBoneIndices,
|
||||
worldPos, worldNormal );
|
||||
|
||||
#if INTRO
|
||||
WorldSpaceVertexProcess( g_Time, modelOrigin, worldPos, dummy, dummy, dummy );
|
||||
#endif
|
||||
|
||||
// Transform into projection space
|
||||
float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
o.projPos = vProjPos;
|
||||
vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ );
|
||||
o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z );
|
||||
|
||||
#if !defined( _X360 )
|
||||
// Set fixed-function fog factor
|
||||
o.fog = CalcFog( worldPos, vProjPos, g_FogType );
|
||||
#endif
|
||||
|
||||
// Normal = (Pos - Eye origin) - just step on dummy normal created above
|
||||
worldNormal = worldPos - cEyeOrigin;
|
||||
|
||||
// Normal -= 0.5f * (Normal dot Eye Up) * Eye Up
|
||||
float normalDotUp = -dot( worldNormal, cHalfEyeballUp) * 0.5f;
|
||||
worldNormal = normalize(normalDotUp * cHalfEyeballUp + worldNormal);
|
||||
|
||||
// Vertex lighting
|
||||
#if ( USE_STATIC_CONTROL_FLOW || defined ( SHADER_MODEL_VS_3_0 ) )
|
||||
o.vColor = DoLighting( worldPos, worldNormal, float3(0.0f, 0.0f, 0.0f), bStaticLight, bDynamicLight, g_bHalfLambert );
|
||||
#else
|
||||
o.vColor = DoLightingUnrolled( worldPos, worldNormal, float3(0.0f, 0.0f, 0.0f), bStaticLight, bDynamicLight, g_bHalfLambert, NUM_LIGHTS );
|
||||
#endif
|
||||
|
||||
// Texture 0 is the base texture
|
||||
// Texture 1 is a planar projection used for the iris
|
||||
// Texture 2 is a planar projection used for the glint
|
||||
o.baseTC = v.vTexCoord0;
|
||||
o.irisTC.x = dot( cIrisProjectionU, float4(worldPos, 1) );
|
||||
o.irisTC.y = dot( cIrisProjectionV, float4(worldPos, 1) );
|
||||
o.glintTC.x = dot( cGlintProjectionU, float4(worldPos, 1) );
|
||||
o.glintTC.y = dot( cGlintProjectionV, float4(worldPos, 1) );
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
15
materialsystem/stdshaders/LightmappedGeneric.psh
Normal file
15
materialsystem/stdshaders/LightmappedGeneric.psh
Normal file
@@ -0,0 +1,15 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
mul r0, t0, v0 ; base times vertex color (with alpha)
|
||||
mul r0.rgb, t1, r0 ; fold in lightmap (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
@@ -0,0 +1,17 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t2 ; cube map
|
||||
tex t3 ; envmap mask
|
||||
|
||||
mul r0.rgb, t2, 1-t3.a
|
||||
mul r0.rgb, c2, r0 ; apply the envmaptint
|
||||
+ mul r0.a, c2.a, v0.a
|
||||
@@ -0,0 +1,17 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t2 ; cube map
|
||||
tex t3 ; envmap mask
|
||||
|
||||
mul r0.rgb, t2, t3
|
||||
mul r0.rgb, c2, r0
|
||||
+ mul r0.a, c2.a, v0.a
|
||||
@@ -0,0 +1,15 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c2 - envmaptint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t2 ; cube map
|
||||
|
||||
mul r0.rgb, t2, c2
|
||||
+ mul r0.a, v0.a, c2.a
|
||||
@@ -0,0 +1,22 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c1 - self-illum tint
|
||||
; c2 - envmap tint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
mul r0, t0, v0 ; base times vertex color (with alpha)
|
||||
mul r0.rgb, t1, r0 ; fold in lighting (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
mul r1, t2, 1-t3.a ; envmap * envmapmask (alpha)
|
||||
mad r0.rgb, r1, c2, r0 ; + envmap * envmapmask * envmaptint (color only)
|
||||
14
materialsystem/stdshaders/LightmappedGeneric_BaseTexture.psh
Normal file
14
materialsystem/stdshaders/LightmappedGeneric_BaseTexture.psh
Normal file
@@ -0,0 +1,14 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Get the color from the texture
|
||||
tex t0
|
||||
mul r0, t0, c0
|
||||
|
||||
38
materialsystem/stdshaders/LightmappedGeneric_BaseTexture.vsh
Normal file
38
materialsystem/stdshaders/LightmappedGeneric_BaseTexture.vsh
Normal file
@@ -0,0 +1,38 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
mov oPos, $projPos
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
mov oPos, $projPos
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
|
||||
dp4 oT1.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
|
||||
dp4 oT1.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_3
|
||||
|
||||
mov oT2, $vTexCoord1
|
||||
|
||||
; Now the basetexture/basetexture2 blend uses vertex color, so send it into the psh.
|
||||
mov oD0, $vColor
|
||||
@@ -0,0 +1,66 @@
|
||||
; STATIC: "NORMALMAPALPHAENVMAPMASK" "0..1"
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Environment mapping on a bumped surface
|
||||
; t0 - Normalmap
|
||||
; t3 - Cube environment map (*must* be a cube map!)
|
||||
;
|
||||
; c0 - color to multiply the results by
|
||||
; c1 - envmap contrast
|
||||
; c2 - envmap saturation
|
||||
; c3 - grey weights
|
||||
; c4 - fresnel amount
|
||||
; Input texture coords required here are a little wonky.
|
||||
; tc0.uv <- U,V into the normal map
|
||||
; tc1.uvw, tc2.uvw, tc3.uvw <- 3x3 matrix transform
|
||||
; from tangent space->env map space
|
||||
; tc1.q, tc2.q, tc3.q <- eye vector in env map space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Get the 3-vector from the normal map
|
||||
tex t0
|
||||
|
||||
; Perform matrix multiply to get a local normal bump. Then
|
||||
; reflect the eye vector through the normal and sample from
|
||||
; a cubic environment map.
|
||||
texm3x3pad t1, t0_bx2
|
||||
texm3x3pad t2, t0_bx2
|
||||
texm3x3vspec t3, t0_bx2
|
||||
|
||||
; FIXME FIXME - Need to do specialized versions of this with and without:
|
||||
; - constant color
|
||||
; - fresnel amount of exactly 0 or 1 or in between
|
||||
; - envmap contrast of 0, 1, or in between
|
||||
; - envmap saturation of 0, 1, or in between
|
||||
|
||||
; r0 = constant color * result of bump into envmap
|
||||
mul r0.rgb, t3, c0
|
||||
|
||||
; dot eye-vector with per-pixel normal from t0
|
||||
dp3_sat r1, v0_bx2, t0_bx2
|
||||
|
||||
; run Fresnel approx. on it: R0 + (1-R0) (1-cos(q))^5 in alpha channel
|
||||
mul r1.rgb, r0, r0 ; color squared
|
||||
+mul r0.a, 1-r1.a, 1-r1.a ; squared
|
||||
|
||||
lrp r0.rgb, c1, r1, r0 ; blend between color and color * color
|
||||
+mul r0.a, r0.a, r0.a ; quartic
|
||||
|
||||
dp3 r1.rgb, r0, c3 ; color greyscaled
|
||||
+mul r0.a, r0.a, 1-r1.a ; quintic
|
||||
|
||||
; FIXME - these should be able to pair (I think), but don't on nvidia for some reason.
|
||||
; (I think) cannot pair due to use of >2 constants in single stage
|
||||
lrp r0.rgb, c2, r0, r1 ; blend between color and greyscale
|
||||
mad r0.a, r0.a, c6.a, c4.a ; Take Fresnel R(0) into consideration
|
||||
|
||||
mul r0.rgb, r0, r0.a ; multiply output color by result of fresnel calc
|
||||
|
||||
#if NORMALMAPALPHAENVMAPMASK
|
||||
+mul r0.a, c0.a, t0.a ; Fade amount * alpha from the texture
|
||||
#else
|
||||
+mov r0.a, c0.a ; Just use the fade amount
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Shader specific constant:
|
||||
; $SHADER_SPECIFIC_CONST_5 = [sOffset, tOffset, 0, 0]
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$worldPos );
|
||||
|
||||
; Transform position from object to world
|
||||
dp4 $worldPos.x, $vPos, $cModel0
|
||||
dp4 $worldPos.y, $vPos, $cModel1
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
; Transform position from object to projection space
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Lighting
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Transform tangent space basis vectors to env map space (world space)
|
||||
; This will produce a set of vectors mapping from tangent space to env space
|
||||
; We'll use this to transform normals from the normal map from tangent space
|
||||
; to environment map space.
|
||||
; NOTE: use dp3 here since the basis vectors are vectors, not points
|
||||
|
||||
dp3 oT1.x, $vTangentS, $cModel0
|
||||
dp3 oT2.x, $vTangentS, $cModel1
|
||||
dp3 oT3.x, $vTangentS, $cModel2
|
||||
|
||||
dp3 oT1.y, $vTangentT, $cModel0
|
||||
dp3 oT2.y, $vTangentT, $cModel1
|
||||
dp3 oT3.y, $vTangentT, $cModel2
|
||||
|
||||
dp3 oT1.z, $vNormal, $cModel0
|
||||
dp3 oT2.z, $vNormal, $cModel1
|
||||
dp3 oT3.z, $vNormal, $cModel2
|
||||
|
||||
; Compute the vector from vertex to camera
|
||||
&AllocateRegister( \$worldEyeVect );
|
||||
sub $worldEyeVect.xyz, $cEyePos, $worldPos
|
||||
&FreeRegister( \$worldPos );
|
||||
|
||||
; Move it into the w component of the texture coords, as the wacky
|
||||
; pixel shader wants it there.
|
||||
mov oT1.w, $worldEyeVect.x
|
||||
mov oT2.w, $worldEyeVect.y
|
||||
mov oT3.w, $worldEyeVect.z
|
||||
|
||||
alloc $tangentEyeVect
|
||||
|
||||
; transform the eye vector to tangent space
|
||||
dp3 $tangentEyeVect.x, $worldEyeVect, $vTangentS
|
||||
dp3 $tangentEyeVect.y, $worldEyeVect, $vTangentT
|
||||
dp3 $tangentEyeVect.z, $worldEyeVect, $vNormal
|
||||
|
||||
&FreeRegister( \$worldEyeVect );
|
||||
|
||||
&Normalize( $tangentEyeVect );
|
||||
|
||||
; stick the tangent space eye vector into oD0
|
||||
mad oD0.xyz, $tangentEyeVect, $cHalf, $cHalf
|
||||
|
||||
&FreeRegister( \$tangentEyeVect );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
; STATIC: "NORMALMAPALPHAENVMAPMASK" "0..1"
|
||||
ps.1.4
|
||||
;------------------------------------------------------------------------------
|
||||
; Phase 1
|
||||
;------------------------------------------------------------------------------
|
||||
; Get the 3-vector from the normal map
|
||||
texld r0, t0
|
||||
; Get environment matrix
|
||||
texcrd r1.rgb, t1
|
||||
texcrd r2.rgb, t2
|
||||
texcrd r3.rgb, t3
|
||||
; Normalize eye-ray vector through normalizer cube map
|
||||
texld r4, t4 ; <---- CUBE MAP here!!!
|
||||
;mov r0.rgba, r4
|
||||
|
||||
; Transform normal
|
||||
dp3 r5.r, r1, r0_bx2
|
||||
dp3 r5.g, r2, r0_bx2
|
||||
dp3 r5.b, r3, r0_bx2
|
||||
; Reflection calculatiom
|
||||
dp3_x2 r3.rgb, r5, r4_bx2 ; 2(N.Eye)
|
||||
mul r3.rgb, r5, r3 ; 2N(N.Eye)
|
||||
dp3 r2.rgb, r5, r5 ; N.N
|
||||
mad r2.rgb, -r4_bx2, r2, r3 ; 2N(N.Eye) - Eye(N.N)
|
||||
|
||||
#if NORMALMAPALPHAENVMAPMASK
|
||||
; Alpha gets lost after phase marker, so store it here
|
||||
mov r5, r0.a
|
||||
#endif
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Phase 2
|
||||
;------------------------------------------------------------------------------
|
||||
; What's left over from the last phase:
|
||||
; r0 - normal
|
||||
; r1 - free
|
||||
; r2 - vector to sample in envmap
|
||||
; r3 - free
|
||||
; r4 - normal
|
||||
; r5 - normal map alpha (rgba)
|
||||
|
||||
phase
|
||||
|
||||
; Sample environment map
|
||||
texld r3, r2
|
||||
|
||||
; dot eye-vector with per-pixel normal from r0
|
||||
dp3_sat r1, v0_bx2, r0_bx2
|
||||
|
||||
; Result goes in output color (multiply by constant color c0)
|
||||
mul r0.rgb, r3, c0
|
||||
|
||||
; run Fresnel approx. on it: R0 + (1-R0) (1-cos(q))^5 in alpha channel
|
||||
mul r1.rgb, r0, r0
|
||||
+mul r0.a, 1-r1.a, 1-r1.a ; squared
|
||||
|
||||
lrp r0.rgb, c1, r1, r0 ; blend between color and color * color
|
||||
+mul r0.a, r0.a, r0.a ; quartic
|
||||
|
||||
dp3 r1.rgb, r0, c3
|
||||
+mul r0.a, r0.a, 1-r1.a ; quintic
|
||||
|
||||
lrp r0.rgb, c2, r0, r1 ; blend between color and greyscale
|
||||
mad r0.a, r0.a, c6.a, c4.a ; Take Fresnel R(0) into consideration
|
||||
|
||||
mul r0.rgb, r0, r0.a ; multiply output color by result of fresnel calc
|
||||
|
||||
#if NORMALMAPALPHAENVMAPMASK
|
||||
+mul r0.a, c0.a, r5.r ; Fade amount * alpha from the texture
|
||||
#else
|
||||
+mov r0.a, c0.a ; Just use the fade amount
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Shader specific constant:
|
||||
; $SHADER_SPECIFIC_CONST_5 = [sOffset, tOffset, 0, 0]
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$worldPos );
|
||||
|
||||
; Transform position from object to world
|
||||
dp4 $worldPos.x, $vPos, $cModel0
|
||||
dp4 $worldPos.y, $vPos, $cModel1
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
; Transform position from object to projection space
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Lighting
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Transform tangent space basis vectors to env map space (world space)
|
||||
; This will produce a set of vectors mapping from tangent space to env space
|
||||
; We'll use this to transform normals from the normal map from tangent space
|
||||
; to environment map space.
|
||||
; NOTE: use dp3 here since the basis vectors are vectors, not points
|
||||
|
||||
dp3 oT1.x, $vTangentS, $cModel0
|
||||
dp3 oT2.x, $vTangentS, $cModel1
|
||||
dp3 oT3.x, $vTangentS, $cModel2
|
||||
|
||||
dp3 oT1.y, $vTangentT, $cModel0
|
||||
dp3 oT2.y, $vTangentT, $cModel1
|
||||
dp3 oT3.y, $vTangentT, $cModel2
|
||||
|
||||
dp3 oT1.z, $vNormal, $cModel0
|
||||
dp3 oT2.z, $vNormal, $cModel1
|
||||
dp3 oT3.z, $vNormal, $cModel2
|
||||
|
||||
; Compute the vector from vertex to camera
|
||||
&AllocateRegister( \$worldEyeVect );
|
||||
sub $worldEyeVect.xyz, $cEyePos, $worldPos
|
||||
&FreeRegister( \$worldPos );
|
||||
|
||||
; eye vector
|
||||
mov oT4.xyz, $worldEyeVect
|
||||
|
||||
alloc $tangentEyeVect
|
||||
|
||||
; transform the eye vector to tangent space
|
||||
dp3 $tangentEyeVect.x, $worldEyeVect, $vTangentS
|
||||
dp3 $tangentEyeVect.y, $worldEyeVect, $vTangentT
|
||||
dp3 $tangentEyeVect.z, $worldEyeVect, $vNormal
|
||||
|
||||
&FreeRegister( \$worldEyeVect );
|
||||
|
||||
&Normalize( $tangentEyeVect );
|
||||
|
||||
; stick the tangent space eye vector into oD0
|
||||
mad oD0.xyz, $tangentEyeVect, $cHalf, $cHalf
|
||||
|
||||
&FreeRegister( \$tangentEyeVect );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Computes the diffuse component of lighting using lightmap + bumpmap
|
||||
; t0 - Normalmap
|
||||
; t1 - Lightmap1
|
||||
; t2 - Lightmap2
|
||||
; t3 - Lightmap3
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - Normalmap and lightmap texture coordinates
|
||||
; c0, c1, c2 - Axes of the lightmap coordinate system in tangent space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Get the 3-vector from the normal map
|
||||
tex t0
|
||||
|
||||
; Sample the lightmaps
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
; output = lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
|
||||
; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
|
||||
; lightmapColor[2] * ( ( N dot basis[2] )^2 ) +
|
||||
|
||||
; r0 = ( N dot basis[0] )
|
||||
; don't "_sat" here so that everything adds up to one even if the normal is outside of the basis!!!!!
|
||||
dp3 r0, t0_bx2, c0
|
||||
|
||||
; r1 = ( N dot basis[1] )
|
||||
dp3 r1, t0_bx2, c1
|
||||
|
||||
;----
|
||||
; r0 = ( N dot basis[0] )
|
||||
; r1 = ( N dot basis[1] )
|
||||
;----
|
||||
|
||||
; r0.rgb = ( N dot basis[0] )^2
|
||||
mul r0.rgb, r0, r0
|
||||
|
||||
; r1.a = ( N dot basis[1] )^2
|
||||
+mul r1.a, r1, r1
|
||||
|
||||
;----
|
||||
; r0.rgb = ( N dot basis[0] )^2
|
||||
; r1.a = ( N dot basis[1] )^2
|
||||
;----
|
||||
|
||||
mul t1, r0, t1
|
||||
|
||||
;----
|
||||
; r1.a = ( N dot basis[1] )^2
|
||||
; t1 = lightmapColor[0] * ( N dot basis[0] )^2
|
||||
;----
|
||||
|
||||
dp3 r0, t0_bx2, c2
|
||||
|
||||
;----
|
||||
; r1.a = ( N dot basis[1] )^2
|
||||
; t1 = lightmapColor[0] * ( N dot basis[0] )^2
|
||||
; r0 = ( N dot basis[2] )
|
||||
;----
|
||||
|
||||
mad t1.rgb, r1.a, t2, t1
|
||||
+mul r0.a, r0, r0
|
||||
|
||||
;----
|
||||
; t1.rgb = lightmapColor[0] * ( N dot basis[0] )^2 + lightmapColor[1] * ( N dot basis[1] )^2
|
||||
; r0.a = ( N dot basis[2] )^2
|
||||
;----
|
||||
|
||||
mad r0.rgba, r0.a, t3, t1
|
||||
|
||||
;----
|
||||
; r0.rgb = lightmapColor[0] * ( N dot basis[0] )^2 +
|
||||
; lightmapColor[1] * ( N dot basis[1] )^2 +
|
||||
; lightmapColor[2] * ( N dot basis[2] )^2
|
||||
;----
|
||||
@@ -0,0 +1,54 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
; Transform position from object to projection space
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Compute the texture coordinates given the offset between
|
||||
; each bumped lightmap
|
||||
&AllocateRegister( \$offset );
|
||||
mov $offset.xy, $vTexCoord2
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
add oT1.xy, $offset, $vTexCoord1
|
||||
mad oT2.xy, $offset, $cTwo, $vTexCoord1
|
||||
; make a 3
|
||||
alloc $three
|
||||
add $three, $cOne, $cTwo
|
||||
mad oT3.xy, $offset, $three, $vTexCoord1
|
||||
free $three
|
||||
|
||||
&FreeRegister( \$offset );
|
||||
@@ -0,0 +1,39 @@
|
||||
;------------------------------------------------------------------------------
|
||||
; Computes the diffuse component of lighting using lightmap + bumpmap
|
||||
; t0 - Normalmap
|
||||
; t1 - Lightmap1
|
||||
; t2 - Lightmap2
|
||||
; t3 - Lightmap3
|
||||
; t4 - Base
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - Normalmap and lightmap texture coordinates
|
||||
; c0, c1, c2 - Axes of the lightmap coordinate system in tangent space
|
||||
;------------------------------------------------------------------------------
|
||||
ps.1.4
|
||||
|
||||
; Get the 3-vector from the normal map
|
||||
texld r0, t0
|
||||
|
||||
; Sample the lightmaps
|
||||
texld r1, t1
|
||||
texld r2, t2
|
||||
texld r3, t3
|
||||
|
||||
; Sample the base texture
|
||||
texld r4, t4
|
||||
|
||||
; output = (lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
|
||||
; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
|
||||
; lightmapColor[2] * ( ( N dot basis[2] )^2 ) ) * base
|
||||
|
||||
dp3 r5.r, r0_bx2, c0
|
||||
dp3 r5.g, r0_bx2, c1
|
||||
dp3 r5.b, r0_bx2, c2
|
||||
mul r5.rgb, r5, r5
|
||||
mul r1, r1, r5.r
|
||||
mad r1, r2, r5.g, r1
|
||||
mad r1, r3, r5.g, r1
|
||||
|
||||
; assume overbright_2 !!!
|
||||
mul_x2 r0, r1, r4
|
||||
@@ -0,0 +1,55 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
; Transform position from object to projection space
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Compute the texture coordinates given the offset between
|
||||
; each bumped lightmap
|
||||
&AllocateRegister( \$offset );
|
||||
mov $offset.xy, $vTexCoord2
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
add oT1.xy, $offset, $vTexCoord1
|
||||
mad oT2.xy, $offset, $cTwo, $vTexCoord1
|
||||
alloc $three
|
||||
add $three, $cOne, $cTwo
|
||||
mad oT3.xy, $offset, $three, $vTexCoord1
|
||||
free $three
|
||||
dp4 oT4.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
|
||||
dp4 oT4.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_3
|
||||
|
||||
&FreeRegister( \$offset );
|
||||
@@ -0,0 +1,47 @@
|
||||
;------------------------------------------------------------------------------
|
||||
; Computes the diffuse component of lighting using lightmap + bumpmap
|
||||
; t0 - Normalmap
|
||||
; t1 - Lightmap1
|
||||
; t2 - Lightmap2
|
||||
; t3 - Lightmap3
|
||||
; t4 - Base1
|
||||
; t5 - Base2
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - Normalmap and lightmap texture coordinates
|
||||
; c0, c1, c2 - Axes of the lightmap coordinate system in tangent space
|
||||
;------------------------------------------------------------------------------
|
||||
ps.1.4
|
||||
|
||||
; output = (lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
|
||||
; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
|
||||
; lightmapColor[2] * ( ( N dot basis[2] )^2 ) ) * lerp(base1, base2, lightmapColor[0].a)
|
||||
|
||||
; Get the 3-vector from the normal map
|
||||
texld r0, t0
|
||||
|
||||
dp3 r5.r, r0_bx2, c0
|
||||
dp3 r5.g, r0_bx2, c1
|
||||
dp3 r5.b, r0_bx2, c2
|
||||
mul r5.rgb, r5, r5
|
||||
|
||||
phase
|
||||
|
||||
; Sample the lightmaps
|
||||
texld r1, t1
|
||||
texld r2, t2
|
||||
texld r3, t3
|
||||
|
||||
; Sample the base textures
|
||||
texld r4, t4
|
||||
texld r5, t5
|
||||
|
||||
mul r1, r1, r5.r
|
||||
mad r1, r2, r5.g, r1
|
||||
mad r1, r3, r5.g, r1
|
||||
|
||||
; blend base textures
|
||||
lrp r4, r4, r5, r1.a
|
||||
|
||||
; assume overbright_2 !!!
|
||||
mul_x2 r0, r1, r4
|
||||
@@ -0,0 +1,57 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
; Transform position from object to projection space
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Compute the texture coordinates given the offset between
|
||||
; each bumped lightmap
|
||||
&AllocateRegister( \$offset );
|
||||
mov $offset.xy, $vTexCoord2
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
add oT1.xy, $offset, $vTexCoord1
|
||||
mad oT2.xy, $offset, $cTwo, $vTexCoord1
|
||||
alloc $three
|
||||
add $three, $cOne, $cTwo
|
||||
mad oT3.xy, $offset, $three, $vTexCoord1
|
||||
free $three
|
||||
dp4 oT4.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
|
||||
dp4 oT4.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_3
|
||||
dp4 oT5.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_4
|
||||
dp4 oT5.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_5
|
||||
|
||||
&FreeRegister( \$offset );
|
||||
47
materialsystem/stdshaders/LightmappedGeneric_Decal.psh
Normal file
47
materialsystem/stdshaders/LightmappedGeneric_Decal.psh
Normal file
@@ -0,0 +1,47 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Computes the diffuse component of lighting using lightmap + bumpmap
|
||||
; t0 - decal texture
|
||||
; t1 - Lightmap1
|
||||
; t2 - Lightmap2
|
||||
; t3 - Lightmap3
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - Normalmap and lightmap texture coordinates
|
||||
; c0, c1, c2 - ( ( N dot basis[0] )^2 ), ( ( N dot basis[1] )^2 ), ( ( N dot basis[2] )^2 )
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Get the decal color
|
||||
tex t0
|
||||
|
||||
; Sample the lightmaps
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
; output = lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
|
||||
; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
|
||||
; lightmapColor[2] * ( ( N dot basis[2] )^2 ) +
|
||||
|
||||
; r0 = lightmapColor[0] * ( ( N dot basis[0] )^2 )
|
||||
mul r0, t1, c0
|
||||
|
||||
; r0 = lightmapColor[0] * ( ( N dot basis[0] )^2 ) + lightmapColor[1] * ( ( N dot basis[1] )^2 )
|
||||
mad r0, t2, c1, r0
|
||||
|
||||
; r0 = lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
|
||||
; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
|
||||
; lightmapColor[2] * ( ( N dot basis[2] )^2 )
|
||||
mad r0, t3, c2, r0
|
||||
|
||||
; Modulate by decal texture
|
||||
mul r0.rgb, r0, t0
|
||||
+ mov r0.a, t0.a
|
||||
|
||||
; Modulate by constant color
|
||||
mul r0, r0, c3
|
||||
|
||||
; Modulate by per-vertex factor
|
||||
mul r0, r0, v0
|
||||
|
||||
56
materialsystem/stdshaders/LightmappedGeneric_Decal.vsh
Normal file
56
materialsystem/stdshaders/LightmappedGeneric_Decal.vsh
Normal file
@@ -0,0 +1,56 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vertex blending
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
; Transform position from object to projection space
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Compute the texture coordinates given the offset between
|
||||
; each bumped lightmap
|
||||
&AllocateRegister( \$offset );
|
||||
mov $offset.x, $vTexCoord2.x
|
||||
mov $offset.y, $cZero
|
||||
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
|
||||
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
add oT1.xy, $offset, $vTexCoord1
|
||||
mad oT2.xy, $offset, $cTwo, $vTexCoord1
|
||||
; make a 3
|
||||
alloc $three
|
||||
add $three, $cOne, $cTwo
|
||||
mad oT3.xy, $offset, $three, $vTexCoord1
|
||||
free $three
|
||||
mov oD0, $vColor
|
||||
|
||||
&FreeRegister( \$offset );
|
||||
18
materialsystem/stdshaders/LightmappedGeneric_Detail.psh
Normal file
18
materialsystem/stdshaders/LightmappedGeneric_Detail.psh
Normal file
@@ -0,0 +1,18 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
mul r0, t0, v0 ; base times vertex color (with alpha)
|
||||
mul r0.rgb, t1, r0 ; fold in lightmap (color only)
|
||||
mul_x2 r1.rgb, r0, t2 ; detail texture
|
||||
lrp r0.rgb, c2, r1, r0
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
@@ -0,0 +1,16 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t1
|
||||
tex t2
|
||||
mul r0.rgb, t1, v0 + ; base times vertex color (with alpha)
|
||||
mov r0.a, v0.a
|
||||
mul_x2 r0.rgb, r0, t2 ; detail texture
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
@@ -0,0 +1,23 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
mul r0.rgb, t0, v0 + ; base times vertex color (no alpha)
|
||||
mov r0.a, v0.a ; Grab alpha from vertex color
|
||||
|
||||
mul r0.rgb, t1, r0 ; fold in lighting (color only)
|
||||
mul_x2 r1.rgb, r0, t2 ; detail texture
|
||||
lrp r0.rgb, c2, r1, r0
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
mul r1, c1, t0 ; Self illum * tint
|
||||
lrp r0.rgb, t0.a, r1, r0 ; Blend between self-illum + base * lightmap
|
||||
@@ -0,0 +1,21 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c1 - self-illum tint
|
||||
; c2 - envmap tint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t1
|
||||
tex t2
|
||||
|
||||
mov r0.rgb, v0 + ; vertex color
|
||||
mul r0.a, v0.a, t2.a ; vertex alpha * envmap alpha
|
||||
|
||||
mad r0.rgb, t2, c2, r0 ; + envmap * envmaptint (color only)
|
||||
mul r0.rgb, t1, r0 ; fold in lightmap (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
20
materialsystem/stdshaders/LightmappedGeneric_EnvMapV2.psh
Normal file
20
materialsystem/stdshaders/LightmappedGeneric_EnvMapV2.psh
Normal file
@@ -0,0 +1,20 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c1 - self-illum tint
|
||||
; c2 - envmap tint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
|
||||
mul r0, t0, v0 ; base times vertex color (with alpha)
|
||||
mul r0.rgb, t1, r0 ; fold in lightmap (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
mad r0.rgb, t2, c2, r0 ; + envmap * envmaptint (color only)
|
||||
@@ -0,0 +1,45 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; $SHADER_SPECIFIC_CONST_0-$SHADER_SPECIFIC_CONST_1 = Base texture transform
|
||||
; $SHADER_SPECIFIC_CONST_2-$SHADER_SPECIFIC_CONST_3 = Mask texture transform
|
||||
; $SHADER_SPECIFIC_CONST_4 = Modulation color
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
&AllocateRegister( \$projPos );
|
||||
|
||||
; Transform position from object to projection space
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Fog
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
if( $DOWATERFOG == 1 )
|
||||
{
|
||||
; Get the worldpos z component only since that's all we need for height fog
|
||||
dp4 $worldPos.z, $vPos, $cModel2
|
||||
}
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
free $worldPos
|
||||
|
||||
&FreeRegister( \$projPos );
|
||||
|
||||
; YUCK! This is to make texcoords continuous for mat_softwaretl
|
||||
mov oT0, $cZero
|
||||
; Texture coordinates
|
||||
mov oT1, $vTexCoord1
|
||||
|
||||
mov oD0, $cOne
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
ps.1.1
|
||||
|
||||
tex t1
|
||||
|
||||
mov r0.rgba, t1
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c1 - self-illum tint
|
||||
; c2 - envmap tint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
mov r0.rgb, v0 ; vertex color
|
||||
mul r1, t2, t3 ; envmap * envmapmask
|
||||
|
||||
mad r0.rgb, r1, c2, r0 + ; + envmap * envmapmask * envmaptint (color only)
|
||||
mul r0.a, v0.a, r1.a ; alpha = vertex alpha * envmap alpha * envmapmask alpha
|
||||
|
||||
mul r0.rgb, t1, r0 ; fold in lightmap (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
@@ -0,0 +1,22 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c1 - self-illum tint
|
||||
; c2 - envmap tint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
mul r0, t0, v0 ; base times vertex color (with alpha)
|
||||
mul r0.rgb, t1, r0 ; fold in lighting (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
mul r1, t2, t3 ; envmap * envmapmask
|
||||
mad r0.rgb, r1, c2, r0 ; + envmap * envmapmask * envmaptint (color only)
|
||||
@@ -0,0 +1,20 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
def c2, 1.0f, 1.0f, 1.0f, 1.0f
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
|
||||
; Blend between grey and lightmap color based on total alpha
|
||||
|
||||
mul_x2 r1.rgb, c0, t1 ; Apply overbright to lightmap
|
||||
+ mul_sat r1.a, t0, v0 ; base times vertex alpha
|
||||
lrp r0, r1.a, r1, c2 ; interpolate between white + color
|
||||
@@ -0,0 +1,20 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
def c2, 1.0f, 1.0f, 1.0f, 1.0f
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
|
||||
; Blend between grey and lightmap color based on total alpha
|
||||
|
||||
mul_x2 r1.rgb, c0, t1 ; Apply overbright to lightmap
|
||||
+ mov_sat r1.a, v0 ; vertex alpha
|
||||
lrp r0, r1.a, r1, c2 ; interpolate between white + color
|
||||
@@ -0,0 +1,23 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
def c2, 1.0f, 1.0f, 1.0f, 1.0f
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
|
||||
; Blend between white and lightmap color based on total alpha
|
||||
mul_x2 r1.rgb, c0, t1 ; Apply overbright to lightmap
|
||||
+ mov_sat r1.a, v0 ; opacity == vertex opacity (no alpha in texture)
|
||||
|
||||
lrp r0.rgb, t0.a, c1, r1 ; Blend between self-illum + lightmap
|
||||
+ mov r0.a, c2.a
|
||||
|
||||
lrp r0.rgb, r1.a, r0, c2 ; interpolate between white + color
|
||||
14
materialsystem/stdshaders/LightmappedGeneric_NoTexture.psh
Normal file
14
materialsystem/stdshaders/LightmappedGeneric_NoTexture.psh
Normal file
@@ -0,0 +1,14 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t1
|
||||
mul r0.rgb, t1, v0 + ; base times vertex color (with alpha)
|
||||
mov r0.a, v0.a
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
@@ -0,0 +1,34 @@
|
||||
ps.1.1
|
||||
def c0, 1,0,0,0
|
||||
def c1, 0,1,0,0
|
||||
def c2, 0,0,1,0
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Computes the diffuse component of lighting using lightmap + bumpmap
|
||||
; t0 - Normalmap
|
||||
; t1 - Lightmap1
|
||||
; t2 - Lightmap2
|
||||
; t3 - Lightmap3
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - Normalmap and lightmap texture coordinates
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Get the 3-vector from the normal map
|
||||
tex t0
|
||||
|
||||
; Sample the lightmaps
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
; output = lightmapColor[0] * n.r + lightmapColor[1] * n.g + lightmapColor[2] * n.b
|
||||
|
||||
|
||||
mov r0, t0
|
||||
dp3 r1, t0, c0
|
||||
mul r0.rgb, r1, t1
|
||||
dp3 r1, t0, c1
|
||||
mad r0.rgb, r1, t2, r0
|
||||
dp3 r1, t0, c2
|
||||
mad r0.rgb, r1, t3, r0
|
||||
@@ -0,0 +1,21 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
|
||||
mul r0.rgb, t0, v0 + ; base times vertex color (no alpha)
|
||||
mov r0.a, v0.a ; Grab alpha from vertex color
|
||||
|
||||
mul r0.rgb, t1, r0 ; fold in lighting (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
mul r1, c1, t0 ; Self illum * tint
|
||||
lrp r0.rgb, t0.a, r1, r0 ; Blend between self-illum + base * lightmap
|
||||
@@ -0,0 +1,27 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c1 - self-illum tint
|
||||
; c2 - envmap tint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
|
||||
mul r0.rgb, t0, v0 + ; base times vertex color (no alpha)
|
||||
mov r0.a, v0.a ; Grab alpha from vertex color
|
||||
|
||||
mul r1, t0.a, t0 ; Self illum
|
||||
mad r1, c1, r1, t1 ; Self illum * tint + lightmap
|
||||
|
||||
mul r0.rgb, r1, r0 ; fold in lighting (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
mad r0.rgb, t2, c2, r0 ; + envmap * envmaptint (color only)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
ps.1.1
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Draw a texture . . woo hoo!
|
||||
; t0 - texture
|
||||
;
|
||||
; The texture coordinates need to be defined as follows:
|
||||
; tc0 - texcoords
|
||||
; c1 - self-illum tint
|
||||
; c2 - envmap tint
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
tex t0
|
||||
tex t1
|
||||
tex t2
|
||||
tex t3
|
||||
|
||||
mul r0.rgb, t0, v0 + ; base times vertex color (with alpha)
|
||||
mov r0.a, v0.a ; Grab alpha from vertex color
|
||||
|
||||
mul r1, c1, t0.a ; Self illum alpha * tint
|
||||
mad r1, t0, r1, t1 ; Self illum * tint + lightmap
|
||||
mul r0.rgb, r1, r0 ; fold in lighting (color only)
|
||||
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
|
||||
|
||||
mul r1, t2, t3 ; envmap * envmapmask
|
||||
mad r0.rgb, r1, c2, r0 ; + envmap * envmapmask * envmaptint (color only)
|
||||
|
||||
15
materialsystem/stdshaders/LightmappedGeneric_VertexColor.vsh
Normal file
15
materialsystem/stdshaders/LightmappedGeneric_VertexColor.vsh
Normal file
@@ -0,0 +1,15 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
#include "LightmappedGeneric_inc.vsh"
|
||||
|
||||
$detail = 0;
|
||||
$envmap = 0;
|
||||
$envmapcameraspace = 0;
|
||||
$envmapsphere = 0;
|
||||
$vertexcolor = 1;
|
||||
|
||||
&LightmappedGeneric( $detail, $envmap, $envmapcameraspace, $envmapsphere,
|
||||
$vertexcolor );
|
||||
|
||||
182
materialsystem/stdshaders/MonitorScreen_dx9.cpp
Normal file
182
materialsystem/stdshaders/MonitorScreen_dx9.cpp
Normal file
@@ -0,0 +1,182 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "BaseVSShader.h"
|
||||
#include "SDK_unlittwotexture_vs20.inc"
|
||||
#include "SDK_monitorscreen_ps20.inc"
|
||||
#include "SDK_monitorscreen_ps20b.inc"
|
||||
#include "cpp_shader_constant_register_map.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
DEFINE_FALLBACK_SHADER( SDK_MonitorScreen, SDK_MonitorScreen_DX9 )
|
||||
|
||||
BEGIN_VS_SHADER( SDK_MonitorScreen_DX9,
|
||||
"This is a shader that does a contrast/saturation version of base times lightmap." )
|
||||
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( CONTRAST, SHADER_PARAM_TYPE_FLOAT, "0.0", "contrast 0 == normal 1 == color*color" )
|
||||
SHADER_PARAM( SATURATION, SHADER_PARAM_TYPE_FLOAT, "1.0", "saturation 0 == greyscale 1 == normal" )
|
||||
SHADER_PARAM( TINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "monitor tint" )
|
||||
SHADER_PARAM( TEXTURE2, SHADER_PARAM_TYPE_TEXTURE, "shadertest/lightmappedtexture", "second texture" )
|
||||
SHADER_PARAM( FRAME2, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $texture2" )
|
||||
SHADER_PARAM( TEXTURE2TRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "$texture2 texcoord transform" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
// Set up anything that is necessary to make decisions in SHADER_FALLBACK.
|
||||
SHADER_INIT_PARAMS()
|
||||
{
|
||||
SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING );
|
||||
if( !params[CONTRAST]->IsDefined() )
|
||||
{
|
||||
params[CONTRAST]->SetFloatValue( 0.0f );
|
||||
}
|
||||
if( !params[SATURATION]->IsDefined() )
|
||||
{
|
||||
params[SATURATION]->SetFloatValue( 1.0f );
|
||||
}
|
||||
if( !params[TINT]->IsDefined() )
|
||||
{
|
||||
params[TINT]->SetVecValue( 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
if (!IS_FLAG_DEFINED( MATERIAL_VAR_MODEL ))
|
||||
{
|
||||
CLEAR_FLAGS( MATERIAL_VAR_MODEL );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_FALLBACK
|
||||
{
|
||||
if( params && !params[BASETEXTURE]->IsDefined() )
|
||||
return "SDK_LightmappedGeneric";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHADER_INIT
|
||||
{
|
||||
if (params[BASETEXTURE]->IsDefined())
|
||||
{
|
||||
LoadTexture( BASETEXTURE );
|
||||
}
|
||||
if (params[TEXTURE2]->IsDefined())
|
||||
{
|
||||
LoadTexture( TEXTURE2 );
|
||||
}
|
||||
}
|
||||
|
||||
SHADER_DRAW
|
||||
{
|
||||
bool bHasTexture2 = params[TEXTURE2]->IsTexture();
|
||||
BlendType_t nBlendType = EvaluateBlendRequirements( BASETEXTURE, true );
|
||||
bool bFullyOpaque = (nBlendType != BT_BLENDADD) && (nBlendType != BT_BLEND) && !IS_FLAG_SET(MATERIAL_VAR_ALPHATEST); //dest alpha is free for special use
|
||||
|
||||
SHADOW_STATE
|
||||
{
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true );
|
||||
if ( bHasTexture2 )
|
||||
{
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
|
||||
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, true );
|
||||
}
|
||||
|
||||
pShaderShadow->EnableSRGBWrite( true );
|
||||
|
||||
// Either we've got a constant modulation
|
||||
bool isTranslucent = IsAlphaModulating();
|
||||
|
||||
// Or we've got a texture alpha on either texture
|
||||
isTranslucent = isTranslucent || TextureIsTranslucent( BASETEXTURE, true ) ||
|
||||
TextureIsTranslucent( TEXTURE2, true );
|
||||
|
||||
if ( isTranslucent )
|
||||
{
|
||||
if ( IS_FLAG_SET(MATERIAL_VAR_ADDITIVE) )
|
||||
EnableAlphaBlending( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE );
|
||||
else
|
||||
EnableAlphaBlending( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( IS_FLAG_SET(MATERIAL_VAR_ADDITIVE) )
|
||||
EnableAlphaBlending( SHADER_BLEND_ONE, SHADER_BLEND_ONE );
|
||||
else
|
||||
DisableAlphaBlending( );
|
||||
}
|
||||
|
||||
// Set stream format (note that this shader supports compression)
|
||||
unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL | VERTEX_FORMAT_COMPRESSED;
|
||||
int nTexCoordCount = 1;
|
||||
int userDataSize = 0;
|
||||
pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize );
|
||||
|
||||
DECLARE_STATIC_VERTEX_SHADER( sdk_unlittwotexture_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER( sdk_unlittwotexture_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( sdk_monitorscreen_ps20b );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( TEXTURE2, (bHasTexture2)?(1):(0) );
|
||||
SET_STATIC_PIXEL_SHADER( sdk_monitorscreen_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_STATIC_PIXEL_SHADER( sdk_monitorscreen_ps20 );
|
||||
SET_STATIC_PIXEL_SHADER_COMBO( TEXTURE2, (bHasTexture2)?(1):(0) );
|
||||
SET_STATIC_PIXEL_SHADER( sdk_monitorscreen_ps20 );
|
||||
}
|
||||
|
||||
DefaultFog();
|
||||
|
||||
pShaderShadow->EnableAlphaWrites( bFullyOpaque );
|
||||
}
|
||||
DYNAMIC_STATE
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME );
|
||||
if( bHasTexture2 )
|
||||
{
|
||||
BindTexture( SHADER_SAMPLER1, TEXTURE2, FRAME2 );
|
||||
SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, TEXTURE2TRANSFORM );
|
||||
}
|
||||
SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, BASETEXTURETRANSFORM );
|
||||
SetPixelShaderConstant( 1, CONTRAST );
|
||||
SetPixelShaderConstant( 2, SATURATION );
|
||||
SetPixelShaderConstant( 3, TINT );
|
||||
SetModulationVertexShaderDynamicState();
|
||||
|
||||
pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS );
|
||||
|
||||
float vEyePos_SpecExponent[4];
|
||||
pShaderAPI->GetWorldSpaceCameraPosition( vEyePos_SpecExponent );
|
||||
vEyePos_SpecExponent[3] = 0.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 );
|
||||
|
||||
|
||||
DECLARE_DYNAMIC_VERTEX_SHADER( sdk_unlittwotexture_vs20 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z );
|
||||
SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
|
||||
SET_DYNAMIC_VERTEX_SHADER( sdk_unlittwotexture_vs20 );
|
||||
|
||||
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( sdk_monitorscreen_ps20b );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bFullyOpaque && pShaderAPI->ShouldWriteDepthToDestAlpha() );
|
||||
SET_DYNAMIC_PIXEL_SHADER( sdk_monitorscreen_ps20b );
|
||||
}
|
||||
else
|
||||
{
|
||||
DECLARE_DYNAMIC_PIXEL_SHADER( sdk_monitorscreen_ps20 );
|
||||
SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() );
|
||||
SET_DYNAMIC_PIXEL_SHADER( sdk_monitorscreen_ps20 );
|
||||
}
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
END_SHADER
|
||||
105
materialsystem/stdshaders/Refract_model_vs11.vsh
Normal file
105
materialsystem/stdshaders/Refract_model_vs11.vsh
Normal file
@@ -0,0 +1,105 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
# DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Constants specified by the app
|
||||
; c0 = (0, 1, 2, 0.5)
|
||||
; c1 = (1/2.2, 0, 0, 0)
|
||||
; c2 = camera position *in world space*
|
||||
; c4-c7 = modelViewProj matrix (transpose)
|
||||
; c8-c11 = ViewProj matrix (transpose)
|
||||
; c12-c15 = model->view matrix (transpose)
|
||||
; c16 = [fogStart, fogEnd, fogRange, undefined]
|
||||
;
|
||||
; Vertex components (as specified in the vertex DECL)
|
||||
; $vPos = Position
|
||||
; $vTexCoord0.xy = TexCoord0
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
; Vertex components
|
||||
; $vPos = Position
|
||||
; $vNormal = normal
|
||||
; $vTexCoord0.xy = TexCoord0
|
||||
; $vTangentS = S axis of Texture space
|
||||
; $vTangentT = T axis of Texture space
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Transform the position from world to view space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
alloc $worldNormal
|
||||
alloc $worldTangentS
|
||||
alloc $worldTangentT
|
||||
|
||||
&SkinPositionNormalAndTangentSpace( $worldPos, $worldNormal,
|
||||
$worldTangentS, $worldTangentT );
|
||||
|
||||
alloc $projPos
|
||||
|
||||
; Transform position from world to projection space
|
||||
dp4 $projPos.x, $worldPos, $cViewProj0
|
||||
dp4 $projPos.y, $worldPos, $cViewProj1
|
||||
dp4 $projPos.z, $worldPos, $cViewProj2
|
||||
dp4 $projPos.w, $worldPos, $cViewProj3
|
||||
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
|
||||
alloc $worldEyeVect
|
||||
|
||||
; Get the eye vector in world space
|
||||
add $worldEyeVect.xyz, -$worldPos, $cEyePos
|
||||
|
||||
alloc $tangentEyeVect
|
||||
; transform the eye vector to tangent space
|
||||
dp3 oT3.x, $worldEyeVect, $worldTangentS
|
||||
dp3 oT3.y, $worldEyeVect, $worldTangentT
|
||||
dp3 oT3.z, $worldEyeVect, $worldNormal
|
||||
|
||||
alloc $bumpTexCoord
|
||||
|
||||
dp4 $bumpTexCoord.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
dp4 $bumpTexCoord.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
|
||||
|
||||
; dudv map
|
||||
mov oT0.xy, $bumpTexCoord
|
||||
|
||||
; refract tint + alpha channel
|
||||
mov oT2.xy, $bumpTexCoord
|
||||
mov oT3.xy, $bumpTexCoord
|
||||
|
||||
free $bumpTexCoord
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
; special case perspective correct texture projection so that the texture fits exactly on the screen
|
||||
|
||||
; flip Y by multiplying by -1
|
||||
mul $projPos.y, $projPos.y, $SHADER_SPECIFIC_CONST_4.w
|
||||
|
||||
; transform from [-w,w] to [0,2*w]
|
||||
; The reason this is w is because we are in perspective space/homogenous clip space.
|
||||
add $projPos.xy, $projPos.xy, $projPos.w
|
||||
|
||||
; transform from [0,2*w] to [0,w]
|
||||
; We'll end up dividing by w in the pixel shader to get to [0,1]
|
||||
mul $projPos.xy, $projPos.xy, $cHalf
|
||||
|
||||
mov oT1.xy, $projPos.xy
|
||||
|
||||
; emit w to both z and w in case the driver screws up and divides by z
|
||||
mov oT1.z, $projPos.w
|
||||
mov oT1.w, $projPos.w
|
||||
|
||||
free $projPos
|
||||
free $worldPos
|
||||
free $worldEyeVect
|
||||
free $tangentEyeVect
|
||||
free $w
|
||||
free $worldNormal
|
||||
free $worldTangentS
|
||||
free $worldTangentT
|
||||
36
materialsystem/stdshaders/Refract_ps11.psh
Normal file
36
materialsystem/stdshaders/Refract_ps11.psh
Normal file
@@ -0,0 +1,36 @@
|
||||
; STATIC: "REFRACTTINTTEXTURE" "0..1"
|
||||
; STATIC: "NORMALMAPALPHA" "0..1"
|
||||
|
||||
ps.1.1
|
||||
|
||||
; t0:
|
||||
; texture: dudv map
|
||||
; texcoords: dudvmap texcoords
|
||||
; t1:
|
||||
; texture: refraction render target
|
||||
; texcoords:
|
||||
|
||||
tex t0 ; sample dudv map
|
||||
texbem t1, t0 ; refraction
|
||||
|
||||
#if REFRACTTINTTEXTURE
|
||||
tex t2
|
||||
#endif
|
||||
|
||||
#if NORMALMAPALPHA
|
||||
tex t3
|
||||
#endif
|
||||
|
||||
; refracttint
|
||||
#if REFRACTTINTTEXTURE
|
||||
mul_x2 r0, t1, t2
|
||||
#else
|
||||
mov r0, t1
|
||||
#endif
|
||||
|
||||
#if NORMALMAPALPHA
|
||||
mul r0.rgb, r0, c0 +
|
||||
mov r0.a, t3.a
|
||||
#else
|
||||
mul r0.rgb, r0, c0
|
||||
#endif
|
||||
140
materialsystem/stdshaders/Refract_vs20.fxc
Normal file
140
materialsystem/stdshaders/Refract_vs20.fxc
Normal file
@@ -0,0 +1,140 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
// STATIC: "MODEL" "0..1"
|
||||
// STATIC: "COLORMODULATE" "0..1"
|
||||
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
static const bool g_bSkinning = SKINNING ? true : false;
|
||||
static const bool g_bModel = MODEL ? true : false;
|
||||
|
||||
const float4 cBumpTexCoordTransform[4] : register( SHADER_SPECIFIC_CONST_1 );
|
||||
|
||||
const float g_flTime : register( SHADER_SPECIFIC_CONST_5 );
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPos : POSITION;
|
||||
float4 vBoneWeights : BLENDWEIGHT;
|
||||
float4 vBoneIndices : BLENDINDICES;
|
||||
float4 vNormal : NORMAL;
|
||||
float4 vBaseTexCoord : TEXCOORD0;
|
||||
#if !MODEL
|
||||
float3 vTangentS : TANGENT;
|
||||
float3 vTangentT : BINORMAL0;
|
||||
#else
|
||||
float4 vUserData : TANGENT;
|
||||
#endif
|
||||
#if COLORMODULATE
|
||||
float4 vColor : COLOR0;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 vProjPos_POSITION : POSITION;
|
||||
#if !defined( _X360 )
|
||||
float vFog : FOG;
|
||||
#endif
|
||||
float4 vBumpTexCoord : TEXCOORD0;
|
||||
float3 vTangentEyeVect : TEXCOORD1;
|
||||
float3 vWorldNormal : TEXCOORD2;
|
||||
float3 vWorldTangent : TEXCOORD3;
|
||||
float3 vWorldBinormal : TEXCOORD4;
|
||||
float3 vRefractXYW : TEXCOORD5;
|
||||
float3 vWorldViewVector : TEXCOORD6;
|
||||
#if COLORMODULATE
|
||||
float4 vColor : COLOR0;
|
||||
#endif
|
||||
float4 fogFactorW : COLOR1;
|
||||
|
||||
float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
|
||||
};
|
||||
|
||||
VS_OUTPUT main( const VS_INPUT v )
|
||||
{
|
||||
VS_OUTPUT o = ( VS_OUTPUT )0;
|
||||
|
||||
#if COLORMODULATE
|
||||
o.vColor = v.vColor;
|
||||
#endif
|
||||
|
||||
float3 worldNormal, worldPos, worldTangentS, worldTangentT;
|
||||
|
||||
float3 vObjNormal;
|
||||
#if MODEL
|
||||
float4 vObjTangent;
|
||||
DecompressVertex_NormalTangent( v.vNormal, v.vUserData, vObjNormal, vObjTangent );
|
||||
|
||||
SkinPositionNormalAndTangentSpace(
|
||||
g_bSkinning,
|
||||
v.vPos, vObjNormal, vObjTangent,
|
||||
v.vBoneWeights, v.vBoneIndices,
|
||||
worldPos, worldNormal, worldTangentS, worldTangentT );
|
||||
#else
|
||||
DecompressVertex_Normal( v.vNormal, vObjNormal );
|
||||
|
||||
worldPos = mul( v.vPos, cModel[0] );
|
||||
worldTangentS = mul( v.vTangentS, ( const float3x3 )cModel[0] );
|
||||
worldTangentT = mul( v.vTangentT, ( const float3x3 )cModel[0] );
|
||||
worldNormal = mul( vObjNormal, ( float3x3 )cModel[0] );
|
||||
#endif
|
||||
|
||||
// World normal
|
||||
o.vWorldNormal.xyz = normalize( worldNormal.xyz );
|
||||
|
||||
// Projected position
|
||||
float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
|
||||
o.vProjPos_POSITION = vProjPos;
|
||||
vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ );
|
||||
o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z );
|
||||
//o.projNormal.xyz = mul( worldNormal, cViewProj );
|
||||
|
||||
// Map projected position to the refraction texture
|
||||
float2 vRefractPos;
|
||||
vRefractPos.x = vProjPos.x;
|
||||
vRefractPos.y = -vProjPos.y; // invert Y
|
||||
vRefractPos = (vRefractPos + vProjPos.w) * 0.5f;
|
||||
|
||||
// Refraction transform
|
||||
o.vRefractXYW = float3(vRefractPos.x, vRefractPos.y, vProjPos.w);
|
||||
|
||||
// Compute fog based on the position
|
||||
float3 vWorldPos = mul( v.vPos, cModel[0] );
|
||||
o.fogFactorW = CalcFog( vWorldPos, vProjPos, FOGTYPE_RANGE );
|
||||
#if !defined( _X360 )
|
||||
o.vFog = o.fogFactorW;
|
||||
#endif
|
||||
|
||||
// Eye vector
|
||||
float3 vWorldEyeVect = normalize( cEyePos - vWorldPos );
|
||||
o.vWorldViewVector.xyz = -vWorldEyeVect.xyz;
|
||||
|
||||
// Transform to the tangent space
|
||||
o.vTangentEyeVect.x = dot( vWorldEyeVect, worldTangentS );
|
||||
o.vTangentEyeVect.y = dot( vWorldEyeVect, worldTangentT );
|
||||
o.vTangentEyeVect.z = dot( vWorldEyeVect, worldNormal );
|
||||
|
||||
// Tranform bump coordinates
|
||||
o.vBumpTexCoord.x = dot( v.vBaseTexCoord, cBumpTexCoordTransform[0] );
|
||||
o.vBumpTexCoord.y = dot( v.vBaseTexCoord, cBumpTexCoordTransform[1] );
|
||||
|
||||
// Tranform bump coordinates (note wz, not zw)
|
||||
o.vBumpTexCoord.w = dot( v.vBaseTexCoord, cBumpTexCoordTransform[2] );
|
||||
o.vBumpTexCoord.z = dot( v.vBaseTexCoord, cBumpTexCoordTransform[3] );
|
||||
|
||||
|
||||
// Tangent space transform
|
||||
o.vWorldNormal.xyz = normalize( worldNormal.xyz );
|
||||
o.vWorldTangent.xyz = worldTangentS.xyz;
|
||||
o.vWorldBinormal.xyz = worldTangentT.xyz;
|
||||
|
||||
return o;
|
||||
}
|
||||
168
materialsystem/stdshaders/Refract_world_vs11.vsh
Normal file
168
materialsystem/stdshaders/Refract_world_vs11.vsh
Normal file
@@ -0,0 +1,168 @@
|
||||
vs.1.1
|
||||
|
||||
# DYNAMIC: "DOWATERFOG" "0..1"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Constants specified by the app
|
||||
; c0 = (0, 1, 2, 0.5)
|
||||
; c1 = (1/2.2, 0, 0, 0)
|
||||
; c2 = camera position *in world space*
|
||||
; c4-c7 = modelViewProj matrix (transpose)
|
||||
; c8-c11 = ViewProj matrix (transpose)
|
||||
; c12-c15 = model->view matrix (transpose)
|
||||
; c16 = [fogStart, fogEnd, fogRange, undefined]
|
||||
;
|
||||
; Vertex components (as specified in the vertex DECL)
|
||||
; $vPos = Position
|
||||
; $vTexCoord0.xy = TexCoord0
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
#include "macros.vsh"
|
||||
|
||||
; Vertex components
|
||||
; $vPos = Position
|
||||
; $vNormal = normal
|
||||
; $vTexCoord0.xy = TexCoord0
|
||||
; $vTangentS = S axis of Texture space
|
||||
; $vTangentT = T axis of Texture space
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Transform the position from world to view space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $worldPos
|
||||
alloc $worldNormal
|
||||
alloc $worldTangentS
|
||||
alloc $worldTangentT
|
||||
alloc $projPos
|
||||
|
||||
dp4 $projPos.x, $vPos, $cModelViewProj0
|
||||
dp4 $projPos.y, $vPos, $cModelViewProj1
|
||||
dp4 $projPos.z, $vPos, $cModelViewProj2
|
||||
dp4 $projPos.w, $vPos, $cModelViewProj3
|
||||
mov oPos, $projPos
|
||||
|
||||
dp3 $worldPos.x, $vPos, $cModel0
|
||||
dp3 $worldPos.y, $vPos, $cModel1
|
||||
dp3 $worldPos.z, $vPos, $cModel2
|
||||
|
||||
dp3 $worldNormal.x, $vNormal, $cModel0
|
||||
dp3 $worldNormal.y, $vNormal, $cModel1
|
||||
dp3 $worldNormal.z, $vNormal, $cModel2
|
||||
|
||||
dp3 $worldTangentS.x, $vTangentS, $cModel0
|
||||
dp3 $worldTangentS.y, $vTangentS, $cModel1
|
||||
dp3 $worldTangentS.z, $vTangentS, $cModel2
|
||||
|
||||
dp3 $worldTangentT.x, $vTangentT, $cModel0
|
||||
dp3 $worldTangentT.y, $vTangentT, $cModel1
|
||||
dp3 $worldTangentT.z, $vTangentT, $cModel2
|
||||
|
||||
&CalcFog( $worldPos, $projPos );
|
||||
|
||||
alloc $worldEyeVect
|
||||
|
||||
; Get the eye vector in world space
|
||||
add $worldEyeVect.xyz, -$worldPos, $cEyePos
|
||||
|
||||
alloc $tangentEyeVect
|
||||
alloc $bumpTexCoord
|
||||
|
||||
; transform the eye vector to tangent space
|
||||
dp3 $tangentEyeVect.x, $worldEyeVect, $worldTangentS
|
||||
dp3 $tangentEyeVect.y, $worldEyeVect, $worldTangentT
|
||||
dp3 $tangentEyeVect.z, $worldEyeVect, $worldNormal
|
||||
|
||||
&Normalize( $tangentEyeVect );
|
||||
|
||||
; stick the tangent space eye vector into oD0
|
||||
mad oD0.xyz, $tangentEyeVect, $cHalf, $cHalf
|
||||
|
||||
dp4 $bumpTexCoord.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
|
||||
dp4 $bumpTexCoord.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
|
||||
|
||||
; dudv map
|
||||
mov oT0.xy, $bumpTexCoord
|
||||
|
||||
; refract tint
|
||||
mov oT3.xy, $bumpTexCoord
|
||||
|
||||
free $bumpTexCoord
|
||||
|
||||
alloc $newProjPos
|
||||
alloc $w
|
||||
|
||||
mov oPos, $projPos
|
||||
|
||||
; special case perspective correct texture projection so that the texture fits exactly on the screen
|
||||
mul $projPos.y, $projPos.y, $SHADER_SPECIFIC_CONST_4.w
|
||||
add $projPos.xy, $projPos.xy, $projPos.w
|
||||
mul $projPos.xy, $projPos.xy, $cHalf
|
||||
|
||||
; Do the perspective divide here. .yuck . . we aren't going to be perspective correct
|
||||
rcp $w.w, $projPos.w
|
||||
mul $projPos, $projPos, $w.w
|
||||
|
||||
#max $projPos.x, $projPos.x, -$cOne
|
||||
#min $projPos.x, $projPos.x, $cOne
|
||||
#max $projPos.z, $projPos.z, $cZero
|
||||
#min $projPos.z, $projPos.z, $cOne
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Transform the tangentS from world to view space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $projTangentS
|
||||
|
||||
; we only care about x and y
|
||||
dp3 $projTangentS.x, $worldTangentS, $cViewProj0
|
||||
dp3 $projTangentS.y, $worldTangentS, $cViewProj1
|
||||
|
||||
; project tangentS
|
||||
mul $projTangentS.xy, $projTangentS.xy, $w.w
|
||||
|
||||
;max $projTangentS.xy, $projTangentS.xy, $cOne
|
||||
;min $projTangentS.xy, $projTangentS.xy, -$cOne
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Transform the tangentT from world to view space
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
alloc $projTangentT
|
||||
alloc $texCoord
|
||||
|
||||
; we only care about x and y
|
||||
dp3 $projTangentT.x, $worldTangentT, $cViewProj0
|
||||
dp3 $projTangentT.y, $worldTangentT, $cViewProj1
|
||||
|
||||
; project tangentT
|
||||
mul $projTangentT.xy, $projTangentT.xy, $w.w
|
||||
|
||||
;max $projTangentT.xy, $projTangentT.xy, $cOne
|
||||
;min $projTangentT.xy, $projTangentT.xy, -$cOne
|
||||
|
||||
;max $projPos.xy, $projPos.xy, $cOne
|
||||
;min $projPos.xy, $projPos.xy, -$cOne
|
||||
|
||||
mul oT1.x, $projTangentS.x, $SHADER_SPECIFIC_CONST_3.x
|
||||
mul oT1.y, $projTangentT.x, $SHADER_SPECIFIC_CONST_3.x
|
||||
mov oT1.z, $projPos.x ; huh?
|
||||
|
||||
mul $texCoord.x, $projTangentS.y, -$SHADER_SPECIFIC_CONST_3.x
|
||||
mul $texCoord.y, $projTangentT.y, -$SHADER_SPECIFIC_CONST_3.x
|
||||
mov $texCoord.z, $projPos.y
|
||||
mov oT2.xyz, $texCoord
|
||||
mov oT3.xyz, $texCoord
|
||||
|
||||
free $texCoord
|
||||
free $projPos
|
||||
free $worldPos
|
||||
free $worldEyeVect
|
||||
free $tangentEyeVect
|
||||
free $w
|
||||
free $projTangentS
|
||||
free $projTangentT
|
||||
free $newProjPos
|
||||
free $worldNormal
|
||||
free $worldTangentS
|
||||
free $worldTangentT
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v120_xp:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit
|
||||
Release|Win32|D:\PROJECTS\aMOD_scode\project_overcharged_build_rtt_11.5\src_RTT\|
|
||||
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v120_xp:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit
|
||||
Release|Win32|D:\SourceCodes\project_overcharged_build_10_rtt\src_RTT\|
|
||||
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.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user