initial
This commit is contained in:
77
public/materialsystem/IColorCorrection.h
Normal file
77
public/materialsystem/IColorCorrection.h
Normal file
@ -0,0 +1,77 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =====//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef ICOLORCORRECTION_H
|
||||
#define ICOLORCORRECTION_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier1/interface.h"
|
||||
#include "tier0/basetypes.h"
|
||||
#include "bitmap/imageformat.h"
|
||||
|
||||
typedef uintptr_t ColorCorrectionHandle_t;
|
||||
struct ShaderColorCorrectionInfo_t;
|
||||
|
||||
abstract_class IColorCorrectionSystem
|
||||
{
|
||||
public:
|
||||
virtual void Init() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
virtual ColorCorrectionHandle_t AddLookup( const char *pName ) = 0;
|
||||
virtual bool RemoveLookup( ColorCorrectionHandle_t handle ) = 0;
|
||||
|
||||
virtual void SetLookupWeight( ColorCorrectionHandle_t handle, float flWeight ) = 0;
|
||||
virtual float GetLookupWeight( ColorCorrectionHandle_t handle ) = 0;
|
||||
virtual float GetLookupWeight( int i ) = 0;
|
||||
|
||||
virtual void LockLookup() = 0;
|
||||
virtual void LockLookup( ColorCorrectionHandle_t handle ) = 0;
|
||||
|
||||
virtual void UnlockLookup() = 0;
|
||||
virtual void UnlockLookup( ColorCorrectionHandle_t handle, bool bDownload = true ) = 0;
|
||||
|
||||
virtual void SetLookup( RGBX5551_t inColor, color24 outColor ) = 0;
|
||||
virtual void SetLookup( ColorCorrectionHandle_t handle, RGBX5551_t inColor, color24 outColor ) = 0;
|
||||
|
||||
virtual color24 GetLookup( RGBX5551_t inColor ) = 0;
|
||||
virtual color24 GetLookup( ColorCorrectionHandle_t handle, RGBX5551_t inColor ) = 0;
|
||||
|
||||
virtual void LoadLookup( const char *pLookupName ) = 0;
|
||||
virtual void LoadLookup( ColorCorrectionHandle_t handle, const char *pLookupName ) = 0;
|
||||
|
||||
virtual void CopyLookup( const color24 *pSrcColorCorrection ) = 0;
|
||||
virtual void CopyLookup( ColorCorrectionHandle_t handle, const color24 *pSrcColorCorrection ) = 0;
|
||||
|
||||
virtual void ResetLookup( ColorCorrectionHandle_t handle ) = 0;
|
||||
virtual void ResetLookup( ) = 0;
|
||||
|
||||
virtual void ReleaseTextures( ) = 0;
|
||||
virtual void RestoreTextures( ) = 0;
|
||||
|
||||
virtual void ResetLookupWeights( ) = 0;
|
||||
|
||||
virtual int GetNumLookups( ) = 0;
|
||||
|
||||
virtual color24 ConvertToColor24( RGBX5551_t inColor ) = 0;
|
||||
|
||||
virtual void SetResetable( ColorCorrectionHandle_t handle, bool bResetable ) = 0;
|
||||
|
||||
virtual void EnableColorCorrection( bool bEnable ) = 0;
|
||||
|
||||
// FIXME: Move this to a private interface only the material system can see?
|
||||
virtual void GetCurrentColorCorrection( ShaderColorCorrectionInfo_t* pInfo ) = 0;
|
||||
|
||||
virtual void OnProceduralRegenComplete( ColorCorrectionHandle_t handle ) = 0;
|
||||
|
||||
virtual ColorCorrectionHandle_t FindLookup( const char *pName ) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
256
public/materialsystem/IShader.h
Normal file
256
public/materialsystem/IShader.h
Normal file
@ -0,0 +1,256 @@
|
||||
//========= Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef ISHADER_H
|
||||
#define ISHADER_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
//==================================================================================================
|
||||
// **this goes into both platforms which run the translator, either the real Mac client or
|
||||
// the Windows client running with r_emulategl mode **
|
||||
//
|
||||
// size of the VS register bank in ARB / GLSL we expose
|
||||
#define DXABSTRACT_VS_PARAM_SLOTS 256
|
||||
#define DXABSTRACT_VS_FIRST_BONE_SLOT VERTEX_SHADER_MODEL
|
||||
#define DXABSTRACT_VS_LAST_BONE_SLOT (VERTEX_SHADER_SHADER_SPECIFIC_CONST_13-1)
|
||||
|
||||
// user clip plane 0 goes in DXABSTRACT_VS_CLIP_PLANE_BASE... plane 1 goes in the slot after that
|
||||
// dxabstract uses these constants to check plane index limit and to deliver planes to shader for DP4 -> oCLP[n]
|
||||
#define DXABSTRACT_VS_CLIP_PLANE_BASE (DXABSTRACT_VS_PARAM_SLOTS-2)
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
#include "materialsystem/ishaderapi.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class IMaterialVar;
|
||||
class IShaderShadow;
|
||||
class IShaderDynamicAPI;
|
||||
class IShaderInit;
|
||||
class CBasePerMaterialContextData;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Shader flags
|
||||
//-----------------------------------------------------------------------------
|
||||
enum ShaderFlags_t
|
||||
{
|
||||
SHADER_NOT_EDITABLE = 0x1
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Shader parameter flags
|
||||
//-----------------------------------------------------------------------------
|
||||
enum ShaderParamFlags_t
|
||||
{
|
||||
SHADER_PARAM_NOT_EDITABLE = 0x1
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Information about each shader parameter
|
||||
//-----------------------------------------------------------------------------
|
||||
struct ShaderParamInfo_t
|
||||
{
|
||||
const char *m_pName;
|
||||
const char *m_pHelp;
|
||||
ShaderParamType_t m_Type;
|
||||
const char *m_pDefaultValue;
|
||||
int m_nFlags;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// shaders can keep per material data in classes descended from this
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBasePerMaterialContextData
|
||||
{
|
||||
public:
|
||||
uint32 m_nVarChangeID;
|
||||
bool m_bMaterialVarsChanged; // set by mat system when material vars change. shader should rehtink and then clear the var
|
||||
|
||||
FORCEINLINE CBasePerMaterialContextData( void )
|
||||
{
|
||||
m_bMaterialVarsChanged = true;
|
||||
m_nVarChangeID = 0xffffffff;
|
||||
}
|
||||
|
||||
// virtual destructor so that derived classes can have their own data to be cleaned up on
|
||||
// delete of material
|
||||
virtual ~CBasePerMaterialContextData( void )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// shaders can keep per instance data in classes descended from this
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBasePerInstanceContextData
|
||||
{
|
||||
public:
|
||||
|
||||
virtual unsigned char* GetInstanceCommandBuffer() = 0;
|
||||
|
||||
// virtual destructor so that derived classes can have their own data
|
||||
// to be cleaned up on delete of material
|
||||
virtual ~CBasePerInstanceContextData( void )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Standard vertex shader constants
|
||||
//-----------------------------------------------------------------------------
|
||||
enum
|
||||
{
|
||||
// Standard vertex shader constants
|
||||
VERTEX_SHADER_MATH_CONSTANTS0 = 0,
|
||||
VERTEX_SHADER_MATH_CONSTANTS1 = 1,
|
||||
VERTEX_SHADER_CAMERA_POS = 2,
|
||||
VERTEX_SHADER_LIGHT_INDEX = 3,
|
||||
VERTEX_SHADER_MODELVIEWPROJ = 4,
|
||||
VERTEX_SHADER_VIEWPROJ = 8,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_12 = 12,
|
||||
VERTEX_SHADER_FLEXSCALE = 13,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_10 = 14,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_11 = 15,
|
||||
VERTEX_SHADER_FOG_PARAMS = 16,
|
||||
VERTEX_SHADER_VIEWMODEL = 17,
|
||||
VERTEX_SHADER_AMBIENT_LIGHT = 21,
|
||||
VERTEX_SHADER_LIGHTS = 27,
|
||||
VERTEX_SHADER_LIGHT0_POSITION = 29,
|
||||
VERTEX_SHADER_MODULATION_COLOR = 47,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_0 = 48,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_1 = 49,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_2 = 50,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_3 = 51,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_4 = 52,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_5 = 53,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_6 = 54,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_7 = 55,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_8 = 56,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_9 = 57,
|
||||
VERTEX_SHADER_MODEL = 58,
|
||||
//
|
||||
// We reserve up through 217 for the 53 bones supported on DX9
|
||||
//
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_CSM = 37, // to match the define in common_vs_fxc.h
|
||||
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_13 = 217,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_14 = 219,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_15 = 221,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_16 = 223,
|
||||
|
||||
// 254 ClipPlane0 |------ OpenGL will jam clip planes into these two
|
||||
// 255 ClipPlane1 |
|
||||
|
||||
VERTEX_SHADER_FLEX_WEIGHTS = 1024,
|
||||
VERTEX_SHADER_MAX_FLEX_WEIGHT_COUNT = 512,
|
||||
};
|
||||
|
||||
#define VERTEX_SHADER_BONE_TRANSFORM( k ) ( VERTEX_SHADER_MODEL + 3 * (k) )
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Standard vertex shader constants
|
||||
//-----------------------------------------------------------------------------
|
||||
enum
|
||||
{
|
||||
// Standard vertex shader constants
|
||||
VERTEX_SHADER_LIGHT_ENABLE_BOOL_CONST = 0,
|
||||
VERTEX_SHADER_LIGHT_ENABLE_BOOL_CONST_COUNT = 4,
|
||||
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_0 = 4,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_1 = 5,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_2 = 6,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_3 = 7,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_4 = 8,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_5 = 9,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_6 = 10,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_7 = 11,
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The public methods exposed by each shader
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IShader
|
||||
{
|
||||
public:
|
||||
// Returns the shader name
|
||||
virtual char const* GetName( ) const = 0;
|
||||
|
||||
// returns the shader fallbacks
|
||||
virtual char const* GetFallbackShader( IMaterialVar** params ) const = 0;
|
||||
|
||||
// Shader parameters
|
||||
virtual int GetParamCount( ) const = 0;
|
||||
virtual const ShaderParamInfo_t& GetParamInfo( int paramIndex ) const = 0;
|
||||
|
||||
// These functions must be implemented by the shader
|
||||
virtual void InitShaderParams( IMaterialVar** ppParams, const char *pMaterialName ) = 0;
|
||||
virtual void InitShaderInstance( IMaterialVar** ppParams, IShaderInit *pShaderInit, const char *pMaterialName, const char *pTextureGroupName ) = 0;
|
||||
virtual void DrawElements( IMaterialVar **params, int nModulationFlags,
|
||||
IShaderShadow* pShaderShadow, IShaderDynamicAPI* pShaderAPI,
|
||||
VertexCompressionType_t vertexCompression, CBasePerMaterialContextData **pContextDataPtr, CBasePerInstanceContextData** pInstanceDataPtr ) = 0;
|
||||
|
||||
virtual void ExecuteFastPath( int * vsDynIndex, int *psDynIndex, IMaterialVar** params,
|
||||
IShaderDynamicAPI * pShaderAPI, VertexCompressionType_t vertexCompression, CBasePerMaterialContextData **pContextDataPtr,
|
||||
BOOL bCSMEnabled )
|
||||
{
|
||||
*vsDynIndex = -1;
|
||||
*psDynIndex = -1;
|
||||
}
|
||||
|
||||
// FIXME: Figure out a better way to do this?
|
||||
virtual int ComputeModulationFlags( IMaterialVar** params, IShaderDynamicAPI* pShaderAPI ) = 0;
|
||||
virtual bool NeedsPowerOfTwoFrameBufferTexture( IMaterialVar **params, bool bCheckSpecificToThisFrame = true ) const = 0;
|
||||
virtual bool NeedsFullFrameBufferTexture( IMaterialVar **params, bool bCheckSpecificToThisFrame ) const = 0;
|
||||
virtual bool IsTranslucent( IMaterialVar **params ) const = 0;
|
||||
|
||||
virtual int GetFlags() const = 0;
|
||||
|
||||
virtual void SetPPParams( IMaterialVar **params ) = 0;
|
||||
virtual void SetModulationFlags( int modulationFlags ) = 0;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Shader dictionaries defined in DLLs
|
||||
//-----------------------------------------------------------------------------
|
||||
enum PrecompiledShaderType_t
|
||||
{
|
||||
PRECOMPILED_VERTEX_SHADER = 0,
|
||||
PRECOMPILED_PIXEL_SHADER,
|
||||
|
||||
PRECOMPILED_SHADER_TYPE_COUNT,
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Flags field of PrecompiledShader_t
|
||||
//-----------------------------------------------------------------------------
|
||||
enum
|
||||
{
|
||||
// runtime flags
|
||||
SHADER_IS_ASM = 0x1,
|
||||
SHADER_FAILED_LOAD = 0x2,
|
||||
};
|
||||
|
||||
#endif // ISHADER_H
|
259
public/materialsystem/MaterialSystemUtil.cpp
Normal file
259
public/materialsystem/MaterialSystemUtil.cpp
Normal file
@ -0,0 +1,259 @@
|
||||
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Workfile: $
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#include "materialsystem/MaterialSystemUtil.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/itexture.h"
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
#include "tier1/keyvalues.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Little utility class to deal with material references
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// constructor, destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CMaterialReference::CMaterialReference( char const* pMaterialName, const char *pTextureGroupName, bool bComplain ) : m_pMaterial( 0 )
|
||||
{
|
||||
if ( pMaterialName )
|
||||
{
|
||||
Assert( pTextureGroupName );
|
||||
Init( pMaterialName, pTextureGroupName, bComplain );
|
||||
}
|
||||
}
|
||||
|
||||
const CMaterialReference& CMaterialReference::operator=( const CMaterialReference &ref )
|
||||
{
|
||||
Init( ref.m_pMaterial );
|
||||
return *this;
|
||||
}
|
||||
|
||||
CMaterialReference::~CMaterialReference()
|
||||
{
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Attach to a material
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMaterialReference::Init( char const* pMaterialName, const char *pTextureGroupName, bool bComplain )
|
||||
{
|
||||
IMaterial *pMaterial = materials->FindMaterial( pMaterialName, pTextureGroupName, bComplain);
|
||||
if( IsErrorMaterial( pMaterial ) )
|
||||
{
|
||||
if (IsOSX())
|
||||
{
|
||||
printf("\n ##### CMaterialReference::Init got error material for %s in tex group %s", pMaterialName, pTextureGroupName );
|
||||
}
|
||||
}
|
||||
|
||||
Assert( pMaterial );
|
||||
Init( pMaterial );
|
||||
}
|
||||
|
||||
void CMaterialReference::Init( const char *pMaterialName, KeyValues *pVMTKeyValues )
|
||||
{
|
||||
// CreateMaterial has a refcount of 1
|
||||
Shutdown();
|
||||
m_pMaterial = materials->CreateMaterial( pMaterialName, pVMTKeyValues );
|
||||
}
|
||||
|
||||
void CMaterialReference::Init( const char *pMaterialName, const char *pTextureGroupName, KeyValues *pVMTKeyValues )
|
||||
{
|
||||
IMaterial *pMaterial = materials->FindProceduralMaterial( pMaterialName, pTextureGroupName, pVMTKeyValues );
|
||||
Assert( pMaterial );
|
||||
Init( pMaterial );
|
||||
}
|
||||
|
||||
void CMaterialReference::Init( IMaterial* pMaterial )
|
||||
{
|
||||
if ( m_pMaterial != pMaterial )
|
||||
{
|
||||
Shutdown();
|
||||
m_pMaterial = pMaterial;
|
||||
if ( m_pMaterial )
|
||||
{
|
||||
m_pMaterial->IncrementReferenceCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CMaterialReference::Init( CMaterialReference& ref )
|
||||
{
|
||||
if ( m_pMaterial != ref.m_pMaterial )
|
||||
{
|
||||
Shutdown();
|
||||
m_pMaterial = ref.m_pMaterial;
|
||||
if (m_pMaterial)
|
||||
{
|
||||
m_pMaterial->IncrementReferenceCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Detach from a material
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMaterialReference::Shutdown( bool bDeleteIfUnreferenced /*=false*/ )
|
||||
{
|
||||
if ( m_pMaterial && materials )
|
||||
{
|
||||
m_pMaterial->DecrementReferenceCount();
|
||||
if ( bDeleteIfUnreferenced )
|
||||
{
|
||||
m_pMaterial->DeleteIfUnreferenced();
|
||||
}
|
||||
m_pMaterial = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Little utility class to deal with texture references
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// constructor, destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CTextureReference::CTextureReference( ) : m_pTexture(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CTextureReference::CTextureReference( const CTextureReference &ref ) : m_pTexture( NULL )
|
||||
{
|
||||
Init( ref.m_pTexture );
|
||||
}
|
||||
|
||||
const CTextureReference& CTextureReference::operator=( CTextureReference &ref )
|
||||
{
|
||||
Init( ref.m_pTexture );
|
||||
return *this;
|
||||
}
|
||||
|
||||
CTextureReference::~CTextureReference( )
|
||||
{
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Attach to a texture
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTextureReference::Init( char const* pTextureName, const char *pTextureGroupName, bool bComplain /* = false */, int nAdditionalCreationFlags /* = 0 */ )
|
||||
{
|
||||
Shutdown();
|
||||
m_pTexture = materials->FindTexture( pTextureName, pTextureGroupName, bComplain, nAdditionalCreationFlags );
|
||||
if ( m_pTexture )
|
||||
{
|
||||
m_pTexture->IncrementReferenceCount();
|
||||
}
|
||||
}
|
||||
|
||||
void CTextureReference::Init( ITexture* pTexture )
|
||||
{
|
||||
if ( m_pTexture != pTexture )
|
||||
{
|
||||
Shutdown();
|
||||
|
||||
m_pTexture = pTexture;
|
||||
if (m_pTexture)
|
||||
{
|
||||
m_pTexture->IncrementReferenceCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CTextureReference::InitProceduralTexture( const char *pTextureName, const char *pTextureGroupName, int w, int h, ImageFormat fmt, int nFlags )
|
||||
{
|
||||
Shutdown();
|
||||
|
||||
m_pTexture = materials->CreateProceduralTexture( pTextureName, pTextureGroupName, w, h, fmt, nFlags );
|
||||
|
||||
// NOTE: The texture reference is already incremented internally above!
|
||||
/*
|
||||
if ( m_pTexture )
|
||||
{
|
||||
m_pTexture->IncrementReferenceCount();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void CTextureReference::InitRenderTarget( int w, int h, RenderTargetSizeMode_t sizeMode, ImageFormat fmt, MaterialRenderTargetDepth_t depth, bool bHDR, char *pStrOptionalName /* = NULL */ )
|
||||
{
|
||||
Shutdown();
|
||||
|
||||
int textureFlags = TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT;
|
||||
if ( depth == MATERIAL_RT_DEPTH_ONLY )
|
||||
textureFlags |= TEXTUREFLAGS_POINTSAMPLE;
|
||||
|
||||
int renderTargetFlags = bHDR ? CREATERENDERTARGETFLAGS_HDR : 0;
|
||||
|
||||
// NOTE: Refcount returned by CreateRenderTargetTexture is 1
|
||||
m_pTexture = materials->CreateNamedRenderTargetTextureEx( pStrOptionalName, w, h, sizeMode, fmt,
|
||||
depth, textureFlags, renderTargetFlags );
|
||||
|
||||
Assert( m_pTexture );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Detach from a texture
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTextureReference::Shutdown( bool bDeleteIfUnReferenced )
|
||||
{
|
||||
if ( m_pTexture && materials )
|
||||
{
|
||||
m_pTexture->DecrementReferenceCount();
|
||||
if ( bDeleteIfUnReferenced )
|
||||
{
|
||||
m_pTexture->DeleteIfUnreferenced();
|
||||
}
|
||||
m_pTexture = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Builds ONLY the system ram render target. Used when caller is explicitly managing.
|
||||
// The paired EDRAM surface can be built in an alternate format.
|
||||
//-----------------------------------------------------------------------------
|
||||
#if defined( _X360 )
|
||||
void CTextureReference::InitRenderTargetTexture( int w, int h, RenderTargetSizeMode_t sizeMode, ImageFormat fmt, MaterialRenderTargetDepth_t depth, bool bHDR, char *pStrOptionalName, int nRenderTargetFlags )
|
||||
{
|
||||
// other variants not implemented yet
|
||||
Assert( depth == MATERIAL_RT_DEPTH_NONE || depth == MATERIAL_RT_DEPTH_SHARED );
|
||||
Assert( !bHDR );
|
||||
|
||||
m_pTexture = materials->CreateNamedRenderTargetTextureEx(
|
||||
pStrOptionalName,
|
||||
w,
|
||||
h,
|
||||
sizeMode,
|
||||
fmt,
|
||||
depth,
|
||||
TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT,
|
||||
CREATERENDERTARGETFLAGS_NOEDRAM | nRenderTargetFlags );
|
||||
Assert( m_pTexture );
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Builds ONLY the EDRAM render target surface. Used when caller is explicitly managing.
|
||||
// The paired system memory texture can be built in an alternate format.
|
||||
//-----------------------------------------------------------------------------
|
||||
#if defined( _X360 )
|
||||
void CTextureReference::InitRenderTargetSurface( int width, int height, ImageFormat fmt, bool bSameAsTexture, RTMultiSampleCount360_t multiSampleCount )
|
||||
{
|
||||
// texture has to be created first
|
||||
Assert( m_pTexture && m_pTexture->IsRenderTarget() );
|
||||
|
||||
m_pTexture->CreateRenderTargetSurface( width, height, fmt, bSameAsTexture, multiSampleCount );
|
||||
}
|
||||
#endif
|
||||
|
103
public/materialsystem/MaterialSystemUtil.h
Normal file
103
public/materialsystem/MaterialSystemUtil.h
Normal file
@ -0,0 +1,103 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
#ifndef MATERIALSYSTEMUTIL_H
|
||||
#define MATERIALSYSTEMUTIL_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "bitmap/imageformat.h" //ImageFormat enum definition
|
||||
#include "materialsystem/imaterialsystem.h" // RenderTargetSizeMode_t and MaterialRenderTargetDepth_t definition
|
||||
#include "materialsystem/itexture.h"
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class IMaterial;
|
||||
class KeyValues;
|
||||
|
||||
class KeyValues;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Little utility class to deal with material references
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMaterialReference
|
||||
{
|
||||
public:
|
||||
// constructor, destructor
|
||||
CMaterialReference( char const* pMaterialName = 0, const char *pTextureGroupName = 0, bool bComplain = true );
|
||||
~CMaterialReference();
|
||||
|
||||
// Attach to a material
|
||||
void Init( const char* pMaterialName, const char *pTextureGroupName, bool bComplain = true );
|
||||
void Init( const char *pMaterialName, KeyValues *pVMTKeyValues );
|
||||
void Init( IMaterial* pMaterial );
|
||||
void Init( CMaterialReference& ref );
|
||||
void Init( const char *pMaterialName, const char *pTextureGroupName, KeyValues *pVMTKeyValues );
|
||||
|
||||
// Detach from a material
|
||||
void Shutdown( bool bDeleteIfUnreferenced = false );
|
||||
bool IsValid() { return m_pMaterial != 0; }
|
||||
|
||||
// Automatic casts to IMaterial
|
||||
operator IMaterial*() { return m_pMaterial; }
|
||||
operator const IMaterial *() const { return m_pMaterial; }
|
||||
IMaterial* operator->() { return m_pMaterial; }
|
||||
|
||||
// Assignment operator
|
||||
const CMaterialReference& operator=( const CMaterialReference &ref );
|
||||
|
||||
|
||||
private:
|
||||
CMaterialReference( CMaterialReference &ref ) { }
|
||||
|
||||
IMaterial* m_pMaterial;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Little utility class to deal with texture references
|
||||
//-----------------------------------------------------------------------------
|
||||
class CTextureReference
|
||||
{
|
||||
public:
|
||||
// constructor, destructor
|
||||
CTextureReference( );
|
||||
CTextureReference( const CTextureReference &ref );
|
||||
~CTextureReference();
|
||||
|
||||
// Attach to a texture
|
||||
void Init( char const* pTexture, const char *pTextureGroupName, bool bComplain = true, int nAdditionalCreationFlags = 0 );
|
||||
void InitProceduralTexture( const char *pTextureName, const char *pTextureGroupName, int w, int h, ImageFormat fmt, int nFlags );
|
||||
void InitRenderTarget( int w, int h, RenderTargetSizeMode_t sizeMode, ImageFormat fmt, MaterialRenderTargetDepth_t depth, bool bHDR, char *pStrOptionalName = NULL );
|
||||
#if defined( _X360 )
|
||||
// used when RT coupling is disparate (texture is DDR based, surface is EDRAM based)
|
||||
void InitRenderTargetTexture( int width, int height, RenderTargetSizeMode_t sizeMode, ImageFormat fmt, MaterialRenderTargetDepth_t depth, bool bHDR, char *pStrOptionalName = NULL, int nRenderTargetFlags = 0 );
|
||||
void InitRenderTargetSurface( int width, int height, ImageFormat fmt, bool bSameAsTexture, RTMultiSampleCount360_t multiSampleCount = RT_MULTISAMPLE_NONE );
|
||||
#endif
|
||||
void Init( ITexture* pTexture );
|
||||
|
||||
// Detach from a texture
|
||||
void Shutdown( bool bDeleteIfUnReferenced = false );
|
||||
bool IsValid() { return m_pTexture != 0; }
|
||||
|
||||
// Automatic casts to ITexture
|
||||
operator ITexture*() { return m_pTexture; }
|
||||
operator ITexture const*() const { return m_pTexture; }
|
||||
ITexture* operator->() { return m_pTexture; }
|
||||
|
||||
// Assignment operator
|
||||
const CTextureReference& operator=( CTextureReference &ref );
|
||||
|
||||
private:
|
||||
ITexture* m_pTexture;
|
||||
};
|
||||
|
||||
|
||||
#endif // !MATERIALSYSTEMUTIL_H
|
104
public/materialsystem/base_visuals_data_processor.h
Normal file
104
public/materialsystem/base_visuals_data_processor.h
Normal file
@ -0,0 +1,104 @@
|
||||
//========= Copyright <20> 1996-2013, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Provide custom texture generation (compositing)
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASE_VISUALS_DATA_PROCESSOR_H
|
||||
#define BASE_VISUALS_DATA_PROCESSOR_H
|
||||
|
||||
#include "ivisualsdataprocessor.h"
|
||||
#include "utlbuffer.h"
|
||||
#include "utlbufferutil.h"
|
||||
|
||||
|
||||
// derive from and extend this class if you have additional items to compare in your Visuals Data Processor
|
||||
class CBaseVisualsDataCompare : public IVisualsDataCompare
|
||||
{
|
||||
public:
|
||||
CBaseVisualsDataCompare() = default;
|
||||
|
||||
CBaseVisualsDataCompare( CBaseVisualsDataCompare&& moveFrom ) // = default;
|
||||
: m_nIndex( Move( moveFrom.m_nIndex ) )
|
||||
, m_nSeed( Move( moveFrom.m_nSeed ) )
|
||||
, m_flWear( Move( moveFrom.m_flWear ) )
|
||||
, m_nLOD( Move( moveFrom.m_nLOD ) )
|
||||
, m_nModelID( Move( moveFrom.m_nModelID ) )
|
||||
, m_compareBlob( Move( moveFrom.m_compareBlob ) )
|
||||
{}
|
||||
|
||||
CBaseVisualsDataCompare& operator=( CBaseVisualsDataCompare&& moveFrom ) // = default;
|
||||
{
|
||||
m_nIndex = Move( moveFrom.m_nIndex );
|
||||
m_nSeed = Move( moveFrom.m_nSeed );
|
||||
m_flWear = Move( moveFrom.m_flWear );
|
||||
m_nLOD = Move( moveFrom.m_nLOD );
|
||||
m_nModelID = Move( moveFrom.m_nModelID );
|
||||
m_compareBlob = Move( moveFrom.m_compareBlob );
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual void FillCompareBlob()
|
||||
{
|
||||
SerializeToBuffer( m_compareBlob );
|
||||
}
|
||||
virtual const CUtlBuffer &GetCompareBlob() const
|
||||
{
|
||||
return m_compareBlob;
|
||||
}
|
||||
|
||||
virtual bool Compare( const CUtlBuffer &otherBuf )
|
||||
{
|
||||
return ( m_compareBlob.TellPut() == otherBuf.TellPut() && V_memcmp( otherBuf.Base(), m_compareBlob.Base(), m_compareBlob.TellPut() ) == 0 );
|
||||
}
|
||||
|
||||
int m_nIndex;
|
||||
int m_nSeed;
|
||||
float m_flWear;
|
||||
int m_nLOD;
|
||||
int m_nModelID; // for weapons this is CSWeaponID, for clothing this is ClothingDefinitionSlotId_t
|
||||
|
||||
protected:
|
||||
virtual void SerializeToBuffer( CUtlBuffer &buf )
|
||||
{
|
||||
buf.Clear();
|
||||
Serialize( buf, m_nIndex );
|
||||
Serialize( buf, m_nSeed );
|
||||
Serialize( buf, m_flWear );
|
||||
Serialize( buf, m_nLOD );
|
||||
Serialize( buf, m_nModelID );
|
||||
}
|
||||
|
||||
private:
|
||||
CUtlBuffer m_compareBlob;
|
||||
};
|
||||
|
||||
template< class T >
|
||||
class CBaseVisualsDataProcessor : public IVisualsDataProcessor
|
||||
{
|
||||
public:
|
||||
CBaseVisualsDataProcessor() {}
|
||||
|
||||
virtual bool Compare( const CUtlBuffer &otherBuf ) { return GetCompareObject()->Compare( otherBuf ); }
|
||||
virtual IVisualsDataCompare *GetCompareObject() { return &m_compareObject; }
|
||||
virtual const char *GetPatternVTFName() const { return NULL; }
|
||||
|
||||
protected:
|
||||
T m_compareObject;
|
||||
};
|
||||
|
||||
enum MaterialParamID_t
|
||||
{
|
||||
MATERIAL_PARAM_ID_BASE_DIFFUSE_TEXTURE = 0,
|
||||
MATERIAL_PARAM_ID_PHONG_EXPONENT_TEXTURE,
|
||||
MATERIAL_PARAM_ID_BUMP_MAP,
|
||||
MATERIAL_PARAM_ID_ANISOTROPY_MAP,
|
||||
MATERIAL_PARAM_ID_MASKS1_MAP,
|
||||
|
||||
MATERIAL_PARAM_ID_COUNT
|
||||
};
|
||||
|
||||
extern const char g_szMaterialParamNames[MATERIAL_PARAM_ID_COUNT][32];
|
||||
|
||||
#endif // BASE_VISUALS_DATA_PROCESSOR_H
|
89
public/materialsystem/custommaterialowner.h
Normal file
89
public/materialsystem/custommaterialowner.h
Normal file
@ -0,0 +1,89 @@
|
||||
//========= Copyright <20> Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Provide interface to custom materials for entities that use them
|
||||
//
|
||||
//=============================================================================//
|
||||
#pragma once
|
||||
|
||||
#include "refcount.h"
|
||||
#include "materialsystem/icustommaterial.h"
|
||||
|
||||
class IMaterial;
|
||||
class CCustomMaterialOwner;
|
||||
class CCompositeTexture;
|
||||
|
||||
// classes that want to have a custom material should derive from this
|
||||
class CCustomMaterialOwner
|
||||
{
|
||||
public:
|
||||
virtual ~CCustomMaterialOwner() { ClearCustomMaterials( true ); }
|
||||
ICustomMaterial *GetCustomMaterial( int nIndex = 0 ) const; // returns NULL if the index is out of range
|
||||
virtual void SetCustomMaterial( ICustomMaterial* pCustomMaterial, int nIndex = 0 ); // either replaces and existing material (releasing the old one), or adds one to the vector
|
||||
bool IsCustomMaterialValid( int nIndex = 0 ) const;
|
||||
int GetCustomMaterialCount() const { return m_ppCustomMaterials.Count(); }
|
||||
void ClearCustomMaterials( bool bPurge = false );
|
||||
virtual void OnCustomMaterialsUpdated() {}
|
||||
virtual void DuplicateCustomMaterialsToOther( CCustomMaterialOwner *pOther ) const;
|
||||
|
||||
private:
|
||||
// Pointers to custom materials owned by the mat system for this entity. Index
|
||||
// in this vector corresponds to the model material index to override with the custom material.
|
||||
CUtlVector< ICustomMaterial* > m_ppCustomMaterials;
|
||||
};
|
||||
|
||||
inline ICustomMaterial *CCustomMaterialOwner::GetCustomMaterial( int nIndex ) const
|
||||
{
|
||||
return ( m_ppCustomMaterials.Count() > nIndex ) ? m_ppCustomMaterials[ nIndex ] : NULL;
|
||||
}
|
||||
|
||||
inline void CCustomMaterialOwner::SetCustomMaterial( ICustomMaterial* pCustomMaterial, int nIndex )
|
||||
{
|
||||
while ( m_ppCustomMaterials.Count() <= nIndex )
|
||||
{
|
||||
m_ppCustomMaterials.AddToTail( NULL );
|
||||
}
|
||||
|
||||
pCustomMaterial->AddRef();
|
||||
if ( m_ppCustomMaterials[ nIndex ] )
|
||||
m_ppCustomMaterials[ nIndex ]->Release();
|
||||
|
||||
m_ppCustomMaterials[ nIndex ] = pCustomMaterial;
|
||||
}
|
||||
|
||||
inline bool CCustomMaterialOwner::IsCustomMaterialValid( int nIndex ) const
|
||||
{
|
||||
return ( m_ppCustomMaterials.Count() > nIndex && m_ppCustomMaterials[ nIndex ] != NULL ) ? m_ppCustomMaterials[ nIndex ]->IsValid() : false;
|
||||
}
|
||||
|
||||
inline void CCustomMaterialOwner::ClearCustomMaterials( bool bPurge )
|
||||
{
|
||||
for ( int i = 0; i < m_ppCustomMaterials.Count(); i++ )
|
||||
{
|
||||
if ( m_ppCustomMaterials[ i ] != NULL )
|
||||
{
|
||||
m_ppCustomMaterials[ i ]->Release();
|
||||
m_ppCustomMaterials[ i ] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ( bPurge )
|
||||
{
|
||||
m_ppCustomMaterials.Purge();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ppCustomMaterials.RemoveAll();
|
||||
}
|
||||
}
|
||||
|
||||
inline void CCustomMaterialOwner::DuplicateCustomMaterialsToOther( CCustomMaterialOwner *pOther ) const
|
||||
{
|
||||
pOther->ClearCustomMaterials();
|
||||
for ( int i = 0; i < CCustomMaterialOwner::m_ppCustomMaterials.Count(); i++ )
|
||||
{
|
||||
if ( m_ppCustomMaterials[ i ] == NULL )
|
||||
continue;
|
||||
|
||||
pOther->SetCustomMaterial( m_ppCustomMaterials[ i ], i );
|
||||
}
|
||||
}
|
58
public/materialsystem/deformations.h
Normal file
58
public/materialsystem/deformations.h
Normal file
@ -0,0 +1,58 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =====//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef DEFORMATIONS_H
|
||||
#define DEFORMATIONS_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier0/platform.h"
|
||||
|
||||
// nonlinear transformations which may be applied to model vertices when rendering. must be powers of two
|
||||
enum DeformationType_t
|
||||
{
|
||||
DEFORMATION_CLAMP_TO_BOX_IN_WORLDSPACE = 1, // minxyz.minsoftness / maxxyz.maxsoftness
|
||||
};
|
||||
|
||||
|
||||
struct DeformationBase_t // base class. don't use this
|
||||
{
|
||||
DeformationType_t m_eType;
|
||||
};
|
||||
|
||||
|
||||
struct BoxDeformation_t : DeformationBase_t
|
||||
{
|
||||
// don't change the layout without changing code in shaderapidx8!!!!
|
||||
Vector m_SourceMins; // cube to clamp within
|
||||
float m_flPad0;
|
||||
Vector m_SourceMaxes;
|
||||
float m_flPad1;
|
||||
|
||||
Vector m_ClampMins;
|
||||
float m_flPad2;
|
||||
Vector m_ClampMaxes;
|
||||
float m_flPad3;
|
||||
|
||||
FORCEINLINE BoxDeformation_t( void )
|
||||
{
|
||||
m_eType = DEFORMATION_CLAMP_TO_BOX_IN_WORLDSPACE;
|
||||
// invalid cube
|
||||
m_SourceMins.Init( 0,0,0 );
|
||||
m_SourceMaxes.Init( -1, -1, -1 );
|
||||
|
||||
// no clamp
|
||||
m_ClampMins.Init( -FLT_MAX, -FLT_MAX, -FLT_MAX );
|
||||
m_ClampMaxes.Init( FLT_MAX, FLT_MAX, FLT_MAX );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
86
public/materialsystem/hardwareverts.h
Normal file
86
public/materialsystem/hardwareverts.h
Normal file
@ -0,0 +1,86 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Hardware Verts
|
||||
//
|
||||
// Contains data purposely formatted for a dma copy into a D3D Vertex Buffer.
|
||||
// The file is divided into two partitions, the foremost contains the static
|
||||
// portion (header), the latter contains the streamable compliant portion.
|
||||
// The streamable component starts and ends on a sector (512) aligned boundary.
|
||||
// The header identifies the vertex format of the data and the atomic sizes of each component.
|
||||
// The hierarchial mesh is flattened for dma but the vertex counts are available
|
||||
// per mesh to transfer each mesh individually.
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef HARDWAREVERTS_H
|
||||
#define HARDWAREVERTS_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "datamap.h"
|
||||
|
||||
// valve hardware vertexes
|
||||
#define VHV_VERSION 2
|
||||
|
||||
namespace HardwareVerts
|
||||
{
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
struct MeshHeader_t
|
||||
{
|
||||
DECLARE_BYTESWAP_DATADESC();
|
||||
|
||||
// this mesh is part of this lod
|
||||
unsigned int m_nLod;
|
||||
|
||||
// this mesh has this many vertexes
|
||||
unsigned int m_nVertexes;
|
||||
|
||||
// starting at this offset
|
||||
unsigned int m_nOffset;
|
||||
|
||||
unsigned int m_nUnused[4];
|
||||
};
|
||||
|
||||
struct FileHeader_t
|
||||
{
|
||||
DECLARE_BYTESWAP_DATADESC();
|
||||
|
||||
// file version as defined by VHV_VERSION
|
||||
int m_nVersion;
|
||||
|
||||
// must match checkSum in the .mdl header
|
||||
unsigned int m_nChecksum;
|
||||
|
||||
// a vertex consists of these components
|
||||
uint32 m_nVertexFlags;
|
||||
|
||||
// the byte size of a single vertex
|
||||
// this won't be adequate, need some concept of byte format i.e. rgbexp32 vs rgba8888
|
||||
unsigned int m_nVertexSize;
|
||||
|
||||
// total number of vertexes
|
||||
unsigned int m_nVertexes;
|
||||
|
||||
int m_nMeshes;
|
||||
inline MeshHeader_t *pMesh( int nMesh ) const
|
||||
{
|
||||
return (MeshHeader_t *)(((byte *)this) + sizeof(FileHeader_t)) + nMesh;
|
||||
};
|
||||
|
||||
inline void *pVertexBase( int nMesh ) const
|
||||
{
|
||||
return (void *)((byte *)this + pMesh( nMesh )->m_nOffset);
|
||||
};
|
||||
|
||||
unsigned int m_nUnused[4];
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
|
||||
}; // end namespace
|
||||
|
||||
#endif // HARDWAREVERTS_H
|
||||
|
20
public/materialsystem/icompositetexture.h
Normal file
20
public/materialsystem/icompositetexture.h
Normal file
@ -0,0 +1,20 @@
|
||||
//========= Copyright <20> 1996-2013, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Interface to composite texture objects
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef I_COMPOSITETEXTURE_H
|
||||
#define I_COMPOSITETEXTURE_H
|
||||
|
||||
class ICompositeTexture
|
||||
{
|
||||
public:
|
||||
virtual bool IsReady() const = 0;
|
||||
virtual bool GenerationComplete() const = 0;
|
||||
virtual IVTFTexture *GetResultVTF() = 0;
|
||||
virtual const char *GetName() = 0;
|
||||
};
|
||||
|
||||
#endif // I_COMPOSITETEXTURE_H
|
48
public/materialsystem/icompositetexturegenerator.h
Normal file
48
public/materialsystem/icompositetexturegenerator.h
Normal file
@ -0,0 +1,48 @@
|
||||
//========= Copyright <20> 1996-2013, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Provide interface to the custom texture generator
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef I_COMPOSITE_TEXTURE_GENERATOR_H
|
||||
#define I_COMPOSITE_TEXTURE_GENERATOR_H
|
||||
|
||||
#include "materialsystem/icompositetexture.h"
|
||||
|
||||
class IVisualsDataProcessor;
|
||||
|
||||
|
||||
enum CompositeTextureFormat_t
|
||||
{
|
||||
COMPOSITE_TEXTURE_FORMAT_DXT1 = 1,
|
||||
COMPOSITE_TEXTURE_FORMAT_DXT5 = 5
|
||||
};
|
||||
|
||||
enum CompositeTextureSize_t
|
||||
{
|
||||
COMPOSITE_TEXTURE_SIZE_256 = 8,
|
||||
COMPOSITE_TEXTURE_SIZE_512,
|
||||
COMPOSITE_TEXTURE_SIZE_1024,
|
||||
COMPOSITE_TEXTURE_SIZE_2048
|
||||
};
|
||||
|
||||
struct SCompositeTextureInfo
|
||||
{
|
||||
IVisualsDataProcessor *m_pVisualsDataProcessor;
|
||||
CompositeTextureSize_t m_size;
|
||||
CompositeTextureFormat_t m_format;
|
||||
int m_nMaterialParamID;
|
||||
bool m_bSRGB;
|
||||
};
|
||||
|
||||
class ICompositeTextureGenerator
|
||||
{
|
||||
public:
|
||||
virtual bool Process( void ) = 0;
|
||||
virtual ICompositeTexture *GetCompositeTexture( IVisualsDataProcessor *pVisualsDataProcessor, int nMaterialParamNameId, CompositeTextureSize_t size, CompositeTextureFormat_t format, bool bSRGB, bool bIgnorePicMip = false , bool bAllowCreate = true ) = 0;
|
||||
virtual ICompositeTexture *GetCompositeTexture( const SCompositeTextureInfo &textureInfo, bool bIgnorePicMip = false , bool bAllowCreate = true ) = 0;
|
||||
virtual bool ForceRegenerate( ICompositeTexture *pTexture ) = 0;
|
||||
};
|
||||
|
||||
#endif // I_COMPOSITE_TEXTURE_GENERATOR_H
|
23
public/materialsystem/icustommaterial.h
Normal file
23
public/materialsystem/icustommaterial.h
Normal file
@ -0,0 +1,23 @@
|
||||
//========= Copyright <20> Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Provide interface to custom materials for entities that use them
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "refcount.h"
|
||||
|
||||
class IMaterial;
|
||||
class ICompositeTexture;
|
||||
|
||||
class ICustomMaterial : public CRefCounted<>
|
||||
{
|
||||
public:
|
||||
virtual IMaterial *GetMaterial() = 0;
|
||||
virtual void AddTexture( ICompositeTexture *pTexture ) = 0;
|
||||
virtual ICompositeTexture *GetTexture( int nIndex ) = 0;
|
||||
virtual bool IsValid() const = 0;
|
||||
virtual bool CheckRegenerate( int nSize ) = 0;
|
||||
virtual const char* GetBaseMaterialName( void ) = 0;
|
||||
};
|
29
public/materialsystem/icustommaterialmanager.h
Normal file
29
public/materialsystem/icustommaterialmanager.h
Normal file
@ -0,0 +1,29 @@
|
||||
//========= Copyright <20> 1996-2013, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Provide interface to custom material manager
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef I_CUSTOM_MATERIAL_MANAGER_H
|
||||
#define I_CUSTOM_MATERIAL_MANAGER_H
|
||||
|
||||
#include "materialsystem/icustommaterial.h"
|
||||
#include "materialsystem/icompositetexturegenerator.h"
|
||||
|
||||
class IVisualsDataCompare;
|
||||
class KeyValues;
|
||||
|
||||
class ICustomMaterialManager
|
||||
{
|
||||
public:
|
||||
virtual bool Process() = 0;
|
||||
|
||||
// get or create a custom material with the given attributes
|
||||
virtual ICustomMaterial *GetOrCreateCustomMaterial( KeyValues *pKeyValues, const CUtlVector< SCompositeTextureInfo > &vecTextureInfos, bool bIgnorePicMip = false ) = 0;
|
||||
|
||||
virtual int DebugGetNumActiveCustomMaterials() = 0;
|
||||
virtual bool GetVMTKeyValues( const char *pszVMTName, KeyValues **ppVMTKeyValues ) = 0;
|
||||
};
|
||||
|
||||
#endif // I_CUSTOM_MATERIAL_MANAGER_H
|
70
public/materialsystem/idebugtextureinfo.h
Normal file
70
public/materialsystem/idebugtextureinfo.h
Normal file
@ -0,0 +1,70 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef IDEBUGTEXTUREINFO_H
|
||||
#define IDEBUGTEXTUREINFO_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
class KeyValues;
|
||||
|
||||
|
||||
// This interface is actually exported by the shader API DLL.
|
||||
|
||||
|
||||
abstract_class IDebugTextureInfo
|
||||
{
|
||||
public:
|
||||
|
||||
// Use this to turn on the mode where it builds the debug texture list.
|
||||
// At the end of the next frame, GetDebugTextureList() will return a valid list of the textures.
|
||||
virtual void EnableDebugTextureList( bool bEnable ) = 0;
|
||||
|
||||
// If this is on, then it will return all textures that exist, not just the ones that were bound in the last frame.
|
||||
// It is required to enable debug texture list to get this.
|
||||
virtual void EnableGetAllTextures( bool bEnable ) = 0;
|
||||
|
||||
// Use this to get the results of the texture list.
|
||||
// Do NOT release the KeyValues after using them.
|
||||
// There will be a bunch of subkeys, each with these values:
|
||||
// Name - the texture's filename
|
||||
// Binds - how many times the texture was bound
|
||||
// Format - ImageFormat of the texture
|
||||
// Width - Width of the texture
|
||||
// Height - Height of the texture
|
||||
// It is required to enable debug texture list to get this.
|
||||
// You MUST release the texture list after having copied it or whatever so that it can be updated again on a separate thread.
|
||||
virtual KeyValues* LockDebugTextureList( void ) = 0;
|
||||
virtual void UnlockDebugTextureList( void ) = 0;
|
||||
|
||||
// Texture memory usage
|
||||
enum TextureMemoryType
|
||||
{
|
||||
MEMORY_RESERVED_MIN = 0,
|
||||
MEMORY_BOUND_LAST_FRAME, // sums up textures bound last frame
|
||||
MEMORY_TOTAL_LOADED, // total texture memory used
|
||||
MEMORY_ESTIMATE_PICMIP_1, // estimate of running with "picmip 1"
|
||||
MEMORY_ESTIMATE_PICMIP_2, // estimate of running with "picmip 2"
|
||||
MEMORY_RESERVED_MAX
|
||||
};
|
||||
|
||||
// This returns how much memory was used.
|
||||
virtual int GetTextureMemoryUsed( TextureMemoryType eTextureMemory ) = 0;
|
||||
|
||||
// Use this to determine if texture debug info was computed within last numFramesAllowed frames.
|
||||
virtual bool IsDebugTextureListFresh( int numFramesAllowed = 1 ) = 0;
|
||||
|
||||
// Enable debug texture rendering when texture binds should not count towards textures
|
||||
// used during a frame. Returns the old state of debug texture rendering flag to use
|
||||
// it for restoring the mode.
|
||||
virtual bool SetDebugTextureRendering( bool bEnable ) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // IDEBUGTEXTUREINFO_H
|
664
public/materialsystem/imaterial.h
Normal file
664
public/materialsystem/imaterial.h
Normal file
@ -0,0 +1,664 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef IMATERIAL_H
|
||||
#define IMATERIAL_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "bitmap/imageformat.h"
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class IMaterialVar;
|
||||
class ITexture;
|
||||
class IMaterialProxy;
|
||||
class Vector;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Flags for GetVertexFormat
|
||||
//-----------------------------------------------------------------------------
|
||||
#define VERTEX_POSITION 0x0001
|
||||
#define VERTEX_NORMAL 0x0002
|
||||
#define VERTEX_COLOR 0x0004
|
||||
#define VERTEX_SPECULAR 0x0008
|
||||
|
||||
#define VERTEX_TANGENT_S 0x0010
|
||||
#define VERTEX_TANGENT_T 0x0020
|
||||
#define VERTEX_TANGENT_SPACE ( VERTEX_TANGENT_S | VERTEX_TANGENT_T )
|
||||
|
||||
// Indicates we're using wrinkle
|
||||
#define VERTEX_WRINKLE 0x0040
|
||||
|
||||
// Indicates we're using bone indices
|
||||
#define VERTEX_BONE_INDEX 0x0080
|
||||
|
||||
// Indicates this expects a color stream on stream 1
|
||||
#define VERTEX_COLOR_STREAM_1 0x0100
|
||||
|
||||
// Indicates this format shouldn't be bloated to cache align it
|
||||
// (only used for VertexUsage)
|
||||
#define VERTEX_FORMAT_USE_EXACT_FORMAT 0x0200
|
||||
|
||||
// Indicates that compressed vertex elements are to be used (see also VertexCompressionType_t)
|
||||
#define VERTEX_FORMAT_COMPRESSED 0x400
|
||||
|
||||
// Position or normal (if present) should be 4D not 3D
|
||||
#define VERTEX_FORMAT_PAD_POS_NORM 0x800
|
||||
|
||||
// Update this if you add or remove bits...
|
||||
#define VERTEX_LAST_BIT 11
|
||||
|
||||
#define VERTEX_BONE_WEIGHT_BIT (VERTEX_LAST_BIT + 1)
|
||||
#define USER_DATA_SIZE_BIT (VERTEX_LAST_BIT + 4)
|
||||
#define TEX_COORD_SIZE_BIT (VERTEX_LAST_BIT + 7)
|
||||
|
||||
#define VERTEX_BONE_WEIGHT_MASK ( 0x7 << VERTEX_BONE_WEIGHT_BIT )
|
||||
#define USER_DATA_SIZE_MASK ( 0x7 << USER_DATA_SIZE_BIT )
|
||||
|
||||
#define VERTEX_FORMAT_FIELD_MASK 0x0FF
|
||||
|
||||
// If everything is off, it's an unknown vertex format
|
||||
#define VERTEX_FORMAT_UNKNOWN 0
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Macros for construction..
|
||||
//-----------------------------------------------------------------------------
|
||||
#define VERTEX_BONEWEIGHT( _n ) ((_n) << VERTEX_BONE_WEIGHT_BIT)
|
||||
#define VERTEX_USERDATA_SIZE( _n ) ((_n) << USER_DATA_SIZE_BIT)
|
||||
#define VERTEX_TEXCOORD_MASK( _coord ) (( 0x7ULL ) << ( TEX_COORD_SIZE_BIT + 3 * (_coord) ))
|
||||
|
||||
inline VertexFormat_t VERTEX_TEXCOORD_SIZE( int nIndex, int nNumCoords )
|
||||
{
|
||||
uint64 n64=nNumCoords;
|
||||
uint64 nShift=TEX_COORD_SIZE_BIT + (3*nIndex);
|
||||
return n64 << nShift;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets at various vertex format info...
|
||||
//-----------------------------------------------------------------------------
|
||||
inline int VertexFlags( VertexFormat_t vertexFormat )
|
||||
{
|
||||
return static_cast<int> ( vertexFormat & ( (1 << (VERTEX_LAST_BIT+1)) - 1 ) );
|
||||
}
|
||||
|
||||
inline int NumBoneWeights( VertexFormat_t vertexFormat )
|
||||
{
|
||||
return static_cast<int> ( (vertexFormat >> VERTEX_BONE_WEIGHT_BIT) & 0x7 );
|
||||
}
|
||||
|
||||
inline int UserDataSize( VertexFormat_t vertexFormat )
|
||||
{
|
||||
return static_cast<int> ( (vertexFormat >> USER_DATA_SIZE_BIT) & 0x7 );
|
||||
}
|
||||
|
||||
inline int TexCoordSize( int nTexCoordIndex, VertexFormat_t vertexFormat )
|
||||
{
|
||||
return static_cast<int> ( (vertexFormat >> (TEX_COORD_SIZE_BIT + 3*nTexCoordIndex) ) & 0x7 );
|
||||
}
|
||||
|
||||
inline VertexCompressionType_t CompressionType( VertexFormat_t vertexFormat )
|
||||
{
|
||||
// This is trivial now, but we may add multiple flavors of compressed vertex later on
|
||||
if ( vertexFormat & VERTEX_FORMAT_COMPRESSED )
|
||||
return VERTEX_COMPRESSION_ON;
|
||||
else
|
||||
return VERTEX_COMPRESSION_NONE;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// VertexElement_t (enumerates all usable vertex elements)
|
||||
//-----------------------------------------------------------------------------
|
||||
// FIXME: unify this with VertexFormat_t (i.e. construct the lower bits of VertexFormat_t with "1 << (VertexElement_t)element")
|
||||
enum VertexElement_t
|
||||
{
|
||||
VERTEX_ELEMENT_NONE = -1,
|
||||
|
||||
// Deliberately explicitly numbered so it's a pain in the ass to change, so you read this:
|
||||
// #!#!#NOTE#!#!# update GetVertexElementSize, VertexElementToDeclType and
|
||||
// CVBAllocTracker (elementTable) when you update this!
|
||||
VERTEX_ELEMENT_POSITION = 0,
|
||||
VERTEX_ELEMENT_POSITION4D = 1,
|
||||
VERTEX_ELEMENT_NORMAL = 2,
|
||||
VERTEX_ELEMENT_NORMAL4D = 3,
|
||||
VERTEX_ELEMENT_COLOR = 4,
|
||||
VERTEX_ELEMENT_SPECULAR = 5,
|
||||
VERTEX_ELEMENT_TANGENT_S = 6,
|
||||
VERTEX_ELEMENT_TANGENT_T = 7,
|
||||
VERTEX_ELEMENT_WRINKLE = 8,
|
||||
VERTEX_ELEMENT_BONEINDEX = 9,
|
||||
VERTEX_ELEMENT_BONEWEIGHTS1 = 10,
|
||||
VERTEX_ELEMENT_BONEWEIGHTS2 = 11,
|
||||
VERTEX_ELEMENT_BONEWEIGHTS3 = 12,
|
||||
VERTEX_ELEMENT_BONEWEIGHTS4 = 13,
|
||||
VERTEX_ELEMENT_USERDATA1 = 14,
|
||||
VERTEX_ELEMENT_USERDATA2 = 15,
|
||||
VERTEX_ELEMENT_USERDATA3 = 16,
|
||||
VERTEX_ELEMENT_USERDATA4 = 17,
|
||||
VERTEX_ELEMENT_TEXCOORD1D_0 = 18,
|
||||
VERTEX_ELEMENT_TEXCOORD1D_1 = 19,
|
||||
VERTEX_ELEMENT_TEXCOORD1D_2 = 20,
|
||||
VERTEX_ELEMENT_TEXCOORD1D_3 = 21,
|
||||
VERTEX_ELEMENT_TEXCOORD1D_4 = 22,
|
||||
VERTEX_ELEMENT_TEXCOORD1D_5 = 23,
|
||||
VERTEX_ELEMENT_TEXCOORD1D_6 = 24,
|
||||
VERTEX_ELEMENT_TEXCOORD1D_7 = 25,
|
||||
VERTEX_ELEMENT_TEXCOORD2D_0 = 26,
|
||||
VERTEX_ELEMENT_TEXCOORD2D_1 = 27,
|
||||
VERTEX_ELEMENT_TEXCOORD2D_2 = 28,
|
||||
VERTEX_ELEMENT_TEXCOORD2D_3 = 29,
|
||||
VERTEX_ELEMENT_TEXCOORD2D_4 = 30,
|
||||
VERTEX_ELEMENT_TEXCOORD2D_5 = 31,
|
||||
VERTEX_ELEMENT_TEXCOORD2D_6 = 32,
|
||||
VERTEX_ELEMENT_TEXCOORD2D_7 = 33,
|
||||
VERTEX_ELEMENT_TEXCOORD3D_0 = 34,
|
||||
VERTEX_ELEMENT_TEXCOORD3D_1 = 35,
|
||||
VERTEX_ELEMENT_TEXCOORD3D_2 = 36,
|
||||
VERTEX_ELEMENT_TEXCOORD3D_3 = 37,
|
||||
VERTEX_ELEMENT_TEXCOORD3D_4 = 38,
|
||||
VERTEX_ELEMENT_TEXCOORD3D_5 = 39,
|
||||
VERTEX_ELEMENT_TEXCOORD3D_6 = 40,
|
||||
VERTEX_ELEMENT_TEXCOORD3D_7 = 41,
|
||||
VERTEX_ELEMENT_TEXCOORD4D_0 = 42,
|
||||
VERTEX_ELEMENT_TEXCOORD4D_1 = 43,
|
||||
VERTEX_ELEMENT_TEXCOORD4D_2 = 44,
|
||||
VERTEX_ELEMENT_TEXCOORD4D_3 = 45,
|
||||
VERTEX_ELEMENT_TEXCOORD4D_4 = 46,
|
||||
VERTEX_ELEMENT_TEXCOORD4D_5 = 47,
|
||||
VERTEX_ELEMENT_TEXCOORD4D_6 = 48,
|
||||
VERTEX_ELEMENT_TEXCOORD4D_7 = 49,
|
||||
|
||||
VERTEX_ELEMENT_NUMELEMENTS = 50
|
||||
};
|
||||
|
||||
inline void Detect_VertexElement_t_Changes( VertexElement_t element ) // GREPs for VertexElement_t will hit this
|
||||
{
|
||||
// Make it harder for someone to change VertexElement_t without noticing that dependent code
|
||||
// (GetVertexElementSize, VertexElementToDeclType, CVBAllocTracker) needs updating
|
||||
Assert( VERTEX_ELEMENT_NUMELEMENTS == 50 );
|
||||
switch ( element )
|
||||
{
|
||||
case VERTEX_ELEMENT_POSITION: Assert( VERTEX_ELEMENT_POSITION == 0 ); break;
|
||||
case VERTEX_ELEMENT_POSITION4D: Assert( VERTEX_ELEMENT_POSITION4D == 1 ); break;
|
||||
case VERTEX_ELEMENT_NORMAL: Assert( VERTEX_ELEMENT_NORMAL == 2 ); break;
|
||||
case VERTEX_ELEMENT_NORMAL4D: Assert( VERTEX_ELEMENT_NORMAL4D == 3 ); break;
|
||||
case VERTEX_ELEMENT_COLOR: Assert( VERTEX_ELEMENT_COLOR == 4 ); break;
|
||||
case VERTEX_ELEMENT_SPECULAR: Assert( VERTEX_ELEMENT_SPECULAR == 5 ); break;
|
||||
case VERTEX_ELEMENT_TANGENT_S: Assert( VERTEX_ELEMENT_TANGENT_S == 6 ); break;
|
||||
case VERTEX_ELEMENT_TANGENT_T: Assert( VERTEX_ELEMENT_TANGENT_T == 7 ); break;
|
||||
case VERTEX_ELEMENT_WRINKLE: Assert( VERTEX_ELEMENT_WRINKLE == 8 ); break;
|
||||
case VERTEX_ELEMENT_BONEINDEX: Assert( VERTEX_ELEMENT_BONEINDEX == 9 ); break;
|
||||
case VERTEX_ELEMENT_BONEWEIGHTS1: Assert( VERTEX_ELEMENT_BONEWEIGHTS1 == 10 ); break;
|
||||
case VERTEX_ELEMENT_BONEWEIGHTS2: Assert( VERTEX_ELEMENT_BONEWEIGHTS2 == 11 ); break;
|
||||
case VERTEX_ELEMENT_BONEWEIGHTS3: Assert( VERTEX_ELEMENT_BONEWEIGHTS3 == 12 ); break;
|
||||
case VERTEX_ELEMENT_BONEWEIGHTS4: Assert( VERTEX_ELEMENT_BONEWEIGHTS4 == 13 ); break;
|
||||
case VERTEX_ELEMENT_USERDATA1: Assert( VERTEX_ELEMENT_USERDATA1 == 14 ); break;
|
||||
case VERTEX_ELEMENT_USERDATA2: Assert( VERTEX_ELEMENT_USERDATA2 == 15 ); break;
|
||||
case VERTEX_ELEMENT_USERDATA3: Assert( VERTEX_ELEMENT_USERDATA3 == 16 ); break;
|
||||
case VERTEX_ELEMENT_USERDATA4: Assert( VERTEX_ELEMENT_USERDATA4 == 17 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_0: Assert( VERTEX_ELEMENT_TEXCOORD1D_0 == 18 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_1: Assert( VERTEX_ELEMENT_TEXCOORD1D_1 == 19 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_2: Assert( VERTEX_ELEMENT_TEXCOORD1D_2 == 20 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_3: Assert( VERTEX_ELEMENT_TEXCOORD1D_3 == 21 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_4: Assert( VERTEX_ELEMENT_TEXCOORD1D_4 == 22 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_5: Assert( VERTEX_ELEMENT_TEXCOORD1D_5 == 23 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_6: Assert( VERTEX_ELEMENT_TEXCOORD1D_6 == 24 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_7: Assert( VERTEX_ELEMENT_TEXCOORD1D_7 == 25 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_0: Assert( VERTEX_ELEMENT_TEXCOORD2D_0 == 26 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_1: Assert( VERTEX_ELEMENT_TEXCOORD2D_1 == 27 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_2: Assert( VERTEX_ELEMENT_TEXCOORD2D_2 == 28 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_3: Assert( VERTEX_ELEMENT_TEXCOORD2D_3 == 29 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_4: Assert( VERTEX_ELEMENT_TEXCOORD2D_4 == 30 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_5: Assert( VERTEX_ELEMENT_TEXCOORD2D_5 == 31 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_6: Assert( VERTEX_ELEMENT_TEXCOORD2D_6 == 32 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_7: Assert( VERTEX_ELEMENT_TEXCOORD2D_7 == 33 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_0: Assert( VERTEX_ELEMENT_TEXCOORD3D_0 == 34 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_1: Assert( VERTEX_ELEMENT_TEXCOORD3D_1 == 35 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_2: Assert( VERTEX_ELEMENT_TEXCOORD3D_2 == 36 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_3: Assert( VERTEX_ELEMENT_TEXCOORD3D_3 == 37 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_4: Assert( VERTEX_ELEMENT_TEXCOORD3D_4 == 38 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_5: Assert( VERTEX_ELEMENT_TEXCOORD3D_5 == 39 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_6: Assert( VERTEX_ELEMENT_TEXCOORD3D_6 == 40 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_7: Assert( VERTEX_ELEMENT_TEXCOORD3D_7 == 41 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_0: Assert( VERTEX_ELEMENT_TEXCOORD4D_0 == 42 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_1: Assert( VERTEX_ELEMENT_TEXCOORD4D_1 == 43 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_2: Assert( VERTEX_ELEMENT_TEXCOORD4D_2 == 44 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_3: Assert( VERTEX_ELEMENT_TEXCOORD4D_3 == 45 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_4: Assert( VERTEX_ELEMENT_TEXCOORD4D_4 == 46 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_5: Assert( VERTEX_ELEMENT_TEXCOORD4D_5 == 47 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_6: Assert( VERTEX_ELEMENT_TEXCOORD4D_6 == 48 ); break;
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_7: Assert( VERTEX_ELEMENT_TEXCOORD4D_7 == 49 ); break;
|
||||
default:
|
||||
Assert( 0 ); // Invalid input or VertexElement_t has definitely changed
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// We're testing 2 normal compression methods
|
||||
// One compressed normals+tangents into a SHORT2 each (8 bytes total)
|
||||
// The other compresses them together, into a single UBYTE4 (4 bytes total)
|
||||
// FIXME: pick one or the other, compare lighting quality in important cases
|
||||
#define COMPRESSED_NORMALS_SEPARATETANGENTS_SHORT2 0
|
||||
#define COMPRESSED_NORMALS_COMBINEDTANGENTS_UBYTE4 1
|
||||
//#define COMPRESSED_NORMALS_TYPE COMPRESSED_NORMALS_SEPARATETANGENTS_SHORT2
|
||||
#define COMPRESSED_NORMALS_TYPE COMPRESSED_NORMALS_COMBINEDTANGENTS_UBYTE4
|
||||
|
||||
inline int GetVertexElementSize( VertexElement_t element, VertexCompressionType_t compressionType )
|
||||
{
|
||||
Detect_VertexElement_t_Changes( element );
|
||||
|
||||
if ( compressionType == VERTEX_COMPRESSION_ON )
|
||||
{
|
||||
// Compressed-vertex element sizes
|
||||
switch ( element )
|
||||
{
|
||||
#if ( COMPRESSED_NORMALS_TYPE == COMPRESSED_NORMALS_SEPARATETANGENTS_SHORT2 )
|
||||
case VERTEX_ELEMENT_NORMAL:
|
||||
return ( 2 * sizeof( short ) );
|
||||
case VERTEX_ELEMENT_USERDATA4:
|
||||
return ( 2 * sizeof( short ) );
|
||||
#else //( COMPRESSED_NORMALS_TYPE == COMPRESSED_NORMALS_COMBINEDTANGENTS_UBYTE4 )
|
||||
// Normals and tangents (userdata4) are combined into a single UBYTE4 vertex element
|
||||
case VERTEX_ELEMENT_NORMAL:
|
||||
return ( 4 * sizeof( unsigned char ) );
|
||||
case VERTEX_ELEMENT_USERDATA4:
|
||||
return ( 0 );
|
||||
#endif
|
||||
// Compressed bone weights use a SHORT2 vertex element:
|
||||
case VERTEX_ELEMENT_BONEWEIGHTS1:
|
||||
case VERTEX_ELEMENT_BONEWEIGHTS2:
|
||||
return ( 2 * sizeof( short ) );
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Uncompressed-vertex element sizes
|
||||
switch ( element )
|
||||
{
|
||||
case VERTEX_ELEMENT_POSITION: return ( 3 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_POSITION4D: return ( 4 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_NORMAL: return ( 3 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_NORMAL4D: return ( 4 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_COLOR: return ( 4 * sizeof( unsigned char ) );
|
||||
case VERTEX_ELEMENT_SPECULAR: return ( 4 * sizeof( unsigned char ) );
|
||||
case VERTEX_ELEMENT_TANGENT_S: return ( 3 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TANGENT_T: return ( 3 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_WRINKLE: return ( 1 * sizeof( float ) ); // Packed into Position.W
|
||||
case VERTEX_ELEMENT_BONEINDEX: return ( 4 * sizeof( unsigned char ) );
|
||||
case VERTEX_ELEMENT_BONEWEIGHTS1: return ( 1 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_BONEWEIGHTS2: return ( 2 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_BONEWEIGHTS3: return ( 3 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_BONEWEIGHTS4: return ( 4 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_USERDATA1: return ( 1 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_USERDATA2: return ( 2 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_USERDATA3: return ( 3 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_USERDATA4: return ( 4 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_0: return ( 1 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_1: return ( 1 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_2: return ( 1 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_3: return ( 1 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_4: return ( 1 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_5: return ( 1 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_6: return ( 1 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD1D_7: return ( 1 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_0: return ( 2 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_1: return ( 2 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_2: return ( 2 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_3: return ( 2 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_4: return ( 2 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_5: return ( 2 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_6: return ( 2 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD2D_7: return ( 2 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_0: return ( 3 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_1: return ( 3 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_2: return ( 3 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_3: return ( 3 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_4: return ( 3 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_5: return ( 3 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_6: return ( 3 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD3D_7: return ( 3 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_0: return ( 4 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_1: return ( 4 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_2: return ( 4 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_3: return ( 4 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_4: return ( 4 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_5: return ( 4 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_6: return ( 4 * sizeof( float ) );
|
||||
case VERTEX_ELEMENT_TEXCOORD4D_7: return ( 4 * sizeof( float ) );
|
||||
default:
|
||||
Assert(0);
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Shader state flags can be read from the FLAGS materialvar
|
||||
// Also can be read or written to with the Set/GetMaterialVarFlags() call
|
||||
// Also make sure you add/remove a string associated with each flag below to CShaderSystem::ShaderStateString in ShaderSystem.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
enum MaterialVarFlags_t
|
||||
{
|
||||
MATERIAL_VAR_DEBUG = (1 << 0),
|
||||
MATERIAL_VAR_NO_DEBUG_OVERRIDE = (1 << 1),
|
||||
MATERIAL_VAR_NO_DRAW = (1 << 2),
|
||||
MATERIAL_VAR_USE_IN_FILLRATE_MODE = (1 << 3),
|
||||
|
||||
MATERIAL_VAR_VERTEXCOLOR = (1 << 4),
|
||||
MATERIAL_VAR_VERTEXALPHA = (1 << 5),
|
||||
MATERIAL_VAR_SELFILLUM = (1 << 6),
|
||||
MATERIAL_VAR_ADDITIVE = (1 << 7),
|
||||
MATERIAL_VAR_ALPHATEST = (1 << 8),
|
||||
MATERIAL_VAR_PSEUDO_TRANSLUCENT = (1 << 9), // used to mark water materials for rendering after opaques but before translucents (with alpha blending but also with depth writes)
|
||||
MATERIAL_VAR_ZNEARER = (1 << 10),
|
||||
MATERIAL_VAR_MODEL = (1 << 11),
|
||||
MATERIAL_VAR_FLAT = (1 << 12),
|
||||
MATERIAL_VAR_NOCULL = (1 << 13),
|
||||
MATERIAL_VAR_NOFOG = (1 << 14),
|
||||
MATERIAL_VAR_IGNOREZ = (1 << 15),
|
||||
MATERIAL_VAR_DECAL = (1 << 16),
|
||||
MATERIAL_VAR_ENVMAPSPHERE = (1 << 17), // OBSOLETE
|
||||
MATERIAL_VAR_AOPREPASS = (1 << 18),
|
||||
MATERIAL_VAR_ENVMAPCAMERASPACE = (1 << 19), // OBSOLETE
|
||||
MATERIAL_VAR_BASEALPHAENVMAPMASK = (1 << 20),
|
||||
MATERIAL_VAR_TRANSLUCENT = (1 << 21),
|
||||
MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK = (1 << 22),
|
||||
MATERIAL_VAR_NEEDS_SOFTWARE_SKINNING = (1 << 23), // OBSOLETE
|
||||
MATERIAL_VAR_OPAQUETEXTURE = (1 << 24),
|
||||
MATERIAL_VAR_MULTIPLY = (1 << 25),
|
||||
MATERIAL_VAR_SUPPRESS_DECALS = (1 << 26),
|
||||
MATERIAL_VAR_HALFLAMBERT = (1 << 27),
|
||||
MATERIAL_VAR_WIREFRAME = (1 << 28),
|
||||
MATERIAL_VAR_ALLOWALPHATOCOVERAGE = (1 << 29),
|
||||
MATERIAL_VAR_ALPHA_MODIFIED_BY_PROXY = (1 << 30),
|
||||
MATERIAL_VAR_VERTEXFOG = (1 << 31),
|
||||
|
||||
// NOTE: Only add flags here that either should be read from
|
||||
// .vmts or can be set directly from client code. Other, internal
|
||||
// flags should to into the flag enum in IMaterialInternal.h
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Internal flags not accessible from outside the material system. Stored in Flags2
|
||||
//-----------------------------------------------------------------------------
|
||||
enum MaterialVarFlags2_t
|
||||
{
|
||||
// NOTE: These are for $flags2!!!!!
|
||||
// UNUSED = (1 << 0),
|
||||
|
||||
MATERIAL_VAR2_LIGHTING_UNLIT = 0,
|
||||
MATERIAL_VAR2_LIGHTING_VERTEX_LIT = (1 << 1),
|
||||
MATERIAL_VAR2_LIGHTING_LIGHTMAP = (1 << 2),
|
||||
MATERIAL_VAR2_LIGHTING_BUMPED_LIGHTMAP = (1 << 3),
|
||||
MATERIAL_VAR2_LIGHTING_MASK =
|
||||
( MATERIAL_VAR2_LIGHTING_VERTEX_LIT |
|
||||
MATERIAL_VAR2_LIGHTING_LIGHTMAP |
|
||||
MATERIAL_VAR2_LIGHTING_BUMPED_LIGHTMAP ),
|
||||
|
||||
// FIXME: Should this be a part of the above lighting enums?
|
||||
MATERIAL_VAR2_DIFFUSE_BUMPMAPPED_MODEL = (1 << 4),
|
||||
MATERIAL_VAR2_USES_ENV_CUBEMAP = (1 << 5),
|
||||
MATERIAL_VAR2_NEEDS_TANGENT_SPACES = (1 << 6),
|
||||
MATERIAL_VAR2_NEEDS_SOFTWARE_LIGHTING = (1 << 7),
|
||||
// GR - HDR path puts lightmap alpha in separate texture...
|
||||
MATERIAL_VAR2_BLEND_WITH_LIGHTMAP_ALPHA = (1 << 8),
|
||||
MATERIAL_VAR2_USE_FLASHLIGHT = (1 << 10),
|
||||
MATERIAL_VAR2_USE_PAINT = (1 << 11),
|
||||
MATERIAL_VAR2_NEEDS_FIXED_FUNCTION_FLASHLIGHT = (1 << 12),
|
||||
MATERIAL_VAR2_USE_EDITOR = (1 << 13),
|
||||
MATERIAL_VAR2_NEEDS_POWER_OF_TWO_FRAME_BUFFER_TEXTURE = (1 << 14),
|
||||
MATERIAL_VAR2_NEEDS_FULL_FRAME_BUFFER_TEXTURE = (1 << 15),
|
||||
MATERIAL_VAR2_IS_SPRITECARD = (1 << 16),
|
||||
MATERIAL_VAR2_USES_VERTEXID = (1 << 17),
|
||||
MATERIAL_VAR2_SUPPORTS_HW_SKINNING = (1 << 18),
|
||||
MATERIAL_VAR2_SUPPORTS_FLASHLIGHT = (1 << 19),
|
||||
MATERIAL_VAR2_USE_GBUFFER0 = (1 << 20),
|
||||
MATERIAL_VAR2_USE_GBUFFER1 = (1 << 21),
|
||||
MATERIAL_VAR2_SELFILLUMMASK = (1 << 22),
|
||||
MATERIAL_VAR2_SUPPORTS_TESSELLATION = (1 << 23)
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Preview image return values
|
||||
//-----------------------------------------------------------------------------
|
||||
enum PreviewImageRetVal_t
|
||||
{
|
||||
MATERIAL_PREVIEW_IMAGE_BAD = 0,
|
||||
MATERIAL_PREVIEW_IMAGE_OK,
|
||||
MATERIAL_NO_PREVIEW_IMAGE,
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// material interface
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IMaterial
|
||||
{
|
||||
public:
|
||||
// Get the name of the material. This is a full path to
|
||||
// the vmt file starting from "hl2/materials" (or equivalent) without
|
||||
// a file extension.
|
||||
virtual const char * GetName() const = 0;
|
||||
virtual const char * GetTextureGroupName() const = 0;
|
||||
|
||||
// Get the preferred size/bitDepth of a preview image of a material.
|
||||
// This is the sort of image that you would use for a thumbnail view
|
||||
// of a material, or in WorldCraft until it uses materials to render.
|
||||
// separate this for the tools maybe
|
||||
virtual PreviewImageRetVal_t GetPreviewImageProperties( int *width, int *height,
|
||||
ImageFormat *imageFormat, bool* isTranslucent ) const = 0;
|
||||
|
||||
// Get a preview image at the specified width/height and bitDepth.
|
||||
// Will do resampling if necessary.(not yet!!! :) )
|
||||
// Will do color format conversion. (works now.)
|
||||
virtual PreviewImageRetVal_t GetPreviewImage( unsigned char *data,
|
||||
int width, int height,
|
||||
ImageFormat imageFormat ) const = 0;
|
||||
//
|
||||
virtual int GetMappingWidth( ) = 0;
|
||||
virtual int GetMappingHeight( ) = 0;
|
||||
|
||||
virtual int GetNumAnimationFrames( ) = 0;
|
||||
|
||||
// For material subrects (material pages). Offset(u,v) and scale(u,v) are normalized to texture.
|
||||
virtual bool InMaterialPage( void ) = 0;
|
||||
virtual void GetMaterialOffset( float *pOffset ) = 0;
|
||||
virtual void GetMaterialScale( float *pScale ) = 0;
|
||||
virtual IMaterial *GetMaterialPage( void ) = 0;
|
||||
|
||||
// find a vmt variable.
|
||||
// This is how game code affects how a material is rendered.
|
||||
// The game code must know about the params that are used by
|
||||
// the shader for the material that it is trying to affect.
|
||||
virtual IMaterialVar * FindVar( const char *varName, bool *found, bool complain = true ) = 0;
|
||||
|
||||
// The user never allocates or deallocates materials. Reference counting is
|
||||
// used instead. Garbage collection is done upon a call to
|
||||
// IMaterialSystem::UncacheUnusedMaterials.
|
||||
virtual void IncrementReferenceCount( void ) = 0;
|
||||
virtual void DecrementReferenceCount( void ) = 0;
|
||||
|
||||
inline void AddRef() { IncrementReferenceCount(); }
|
||||
inline void Release() { DecrementReferenceCount(); }
|
||||
|
||||
// Each material is assigned a number that groups it with like materials
|
||||
// for sorting in the application.
|
||||
virtual int GetEnumerationID( void ) const = 0;
|
||||
|
||||
virtual void GetLowResColorSample( float s, float t, float *color ) const = 0;
|
||||
|
||||
// This computes the state snapshots for this material
|
||||
virtual void RecomputeStateSnapshots() = 0;
|
||||
|
||||
// Are we translucent?
|
||||
virtual bool IsTranslucent() = 0;
|
||||
|
||||
// Are we alphatested?
|
||||
virtual bool IsAlphaTested() = 0;
|
||||
|
||||
// Are we vertex lit?
|
||||
virtual bool IsVertexLit() = 0;
|
||||
|
||||
// Gets the vertex format
|
||||
virtual VertexFormat_t GetVertexFormat() const = 0;
|
||||
|
||||
// returns true if this material uses a material proxy
|
||||
virtual bool HasProxy( void ) const = 0;
|
||||
|
||||
virtual bool UsesEnvCubemap( void ) = 0;
|
||||
|
||||
virtual bool NeedsTangentSpace( void ) = 0;
|
||||
|
||||
virtual bool NeedsPowerOfTwoFrameBufferTexture( bool bCheckSpecificToThisFrame = true ) = 0;
|
||||
virtual bool NeedsFullFrameBufferTexture( bool bCheckSpecificToThisFrame = true ) = 0;
|
||||
|
||||
// returns true if the shader doesn't do skinning itself and requires
|
||||
// the data that is sent to it to be preskinned.
|
||||
virtual bool NeedsSoftwareSkinning( void ) = 0;
|
||||
|
||||
// Apply constant color or alpha modulation
|
||||
virtual void AlphaModulate( float alpha ) = 0;
|
||||
virtual void ColorModulate( float r, float g, float b ) = 0;
|
||||
|
||||
// Material Var flags...
|
||||
virtual void SetMaterialVarFlag( MaterialVarFlags_t flag, bool on ) = 0;
|
||||
virtual bool GetMaterialVarFlag( MaterialVarFlags_t flag ) const = 0;
|
||||
|
||||
// Gets material reflectivity
|
||||
virtual void GetReflectivity( Vector& reflect ) = 0;
|
||||
|
||||
// Gets material property flags
|
||||
virtual bool GetPropertyFlag( MaterialPropertyTypes_t type ) = 0;
|
||||
|
||||
// Is the material visible from both sides?
|
||||
virtual bool IsTwoSided() = 0;
|
||||
|
||||
// Sets the shader associated with the material
|
||||
virtual void SetShader( const char *pShaderName ) = 0;
|
||||
|
||||
// Can't be const because the material might have to precache itself.
|
||||
virtual int GetNumPasses( void ) = 0;
|
||||
|
||||
// Can't be const because the material might have to precache itself.
|
||||
virtual int GetTextureMemoryBytes( void ) = 0;
|
||||
|
||||
// Meant to be used with materials created using CreateMaterial
|
||||
// It updates the materials to reflect the current values stored in the material vars
|
||||
virtual void Refresh() = 0;
|
||||
|
||||
// GR - returns true is material uses lightmap alpha for blending
|
||||
virtual bool NeedsLightmapBlendAlpha( void ) = 0;
|
||||
|
||||
// returns true if the shader doesn't do lighting itself and requires
|
||||
// the data that is sent to it to be prelighted
|
||||
virtual bool NeedsSoftwareLighting( void ) = 0;
|
||||
|
||||
// Gets at the shader parameters
|
||||
virtual int ShaderParamCount() const = 0;
|
||||
virtual IMaterialVar **GetShaderParams( void ) = 0;
|
||||
|
||||
// Returns true if this is the error material you get back from IMaterialSystem::FindMaterial if
|
||||
// the material can't be found.
|
||||
virtual bool IsErrorMaterial() const = 0;
|
||||
|
||||
// Don't want to mess with the vtable layout
|
||||
virtual void Unused( ) {}
|
||||
|
||||
// Gets the current alpha modulation
|
||||
virtual float GetAlphaModulation() = 0;
|
||||
virtual void GetColorModulation( float *r, float *g, float *b ) = 0;
|
||||
|
||||
// Is this translucent given a particular alpha modulation?
|
||||
virtual bool IsTranslucentUnderModulation( float fAlphaModulation = 1.0f ) const = 0;
|
||||
|
||||
// fast find that stores the index of the found var in the string table in local cache
|
||||
virtual IMaterialVar * FindVarFast( char const *pVarName, unsigned int *pToken ) = 0;
|
||||
|
||||
// Sets new VMT shader parameters for the material
|
||||
virtual void SetShaderAndParams( KeyValues *pKeyValues ) = 0;
|
||||
virtual const char * GetShaderName() const = 0;
|
||||
|
||||
virtual void DeleteIfUnreferenced() = 0;
|
||||
|
||||
virtual bool IsSpriteCard() = 0;
|
||||
|
||||
virtual void CallBindProxy( void *proxyData, ICallQueue *pCallQueue ) = 0;
|
||||
|
||||
virtual void RefreshPreservingMaterialVars() = 0;
|
||||
|
||||
virtual bool WasReloadedFromWhitelist() = 0;
|
||||
|
||||
// when enabled, 0 will be a pure exclude, otherwise the desired maxmip
|
||||
virtual bool SetTempExcluded( bool bSet, int nExcludedDimensionLimit = 0 ) = 0;
|
||||
|
||||
virtual int GetReferenceCount() const = 0;
|
||||
};
|
||||
|
||||
|
||||
inline bool IsErrorMaterial( IMaterial *pMat )
|
||||
{
|
||||
return !pMat || pMat->IsErrorMaterial();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Vertex stream specifications
|
||||
//
|
||||
|
||||
struct VertexStreamSpec_t
|
||||
{
|
||||
enum StreamSpec_t
|
||||
{
|
||||
STREAM_DEFAULT, // stream 0: with position, normal, etc.
|
||||
STREAM_SPECULAR1, // stream 1: following specular vhv lighting
|
||||
STREAM_FLEXDELTA, // stream 2: flex deltas
|
||||
STREAM_MORPH, // stream 3: morph
|
||||
STREAM_UNIQUE_A, // unique stream 4
|
||||
STREAM_UNIQUE_B, // unique stream 5
|
||||
STREAM_UNIQUE_C, // unique stream 6
|
||||
STREAM_UNIQUE_D, // unique stream 7
|
||||
STREAM_SUBDQUADS, // stream 8: quad buffer for subd's
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_UNIQUE_STREAMS = 4
|
||||
};
|
||||
|
||||
VertexFormat_t iVertexDataElement;
|
||||
StreamSpec_t iStreamSpec;
|
||||
};
|
||||
|
||||
inline VertexStreamSpec_t * FindVertexStreamSpec( VertexFormat_t iElement, VertexStreamSpec_t *arrVertexStreamSpec )
|
||||
{
|
||||
for ( ; arrVertexStreamSpec &&
|
||||
arrVertexStreamSpec->iVertexDataElement != VERTEX_FORMAT_UNKNOWN ;
|
||||
++ arrVertexStreamSpec )
|
||||
{
|
||||
if ( arrVertexStreamSpec->iVertexDataElement == iElement )
|
||||
return arrVertexStreamSpec;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
#endif // IMATERIAL_H
|
109
public/materialsystem/imaterial_declarations.h
Normal file
109
public/materialsystem/imaterial_declarations.h
Normal file
@ -0,0 +1,109 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
#ifndef IMATERIAL_DECLARATIONS_HDR
|
||||
#define IMATERIAL_DECLARATIONS_HDR
|
||||
|
||||
#include "materialsystem/imaterialsystemhardwareconfig_declarations.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Shader state flags can be read from the FLAGS materialvar
|
||||
// Also can be read or written to with the Set/GetMaterialVarFlags() call
|
||||
// Also make sure you add/remove a string associated with each flag below to CShaderSystem::ShaderStateString in ShaderSystem.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
enum MaterialVarFlags_t
|
||||
{
|
||||
MATERIAL_VAR_DEBUG = (1 << 0),
|
||||
MATERIAL_VAR_NO_DEBUG_OVERRIDE = (1 << 1),
|
||||
MATERIAL_VAR_NO_DRAW = (1 << 2),
|
||||
MATERIAL_VAR_USE_IN_FILLRATE_MODE = (1 << 3),
|
||||
|
||||
MATERIAL_VAR_VERTEXCOLOR = (1 << 4),
|
||||
MATERIAL_VAR_VERTEXALPHA = (1 << 5),
|
||||
MATERIAL_VAR_SELFILLUM = (1 << 6),
|
||||
MATERIAL_VAR_ADDITIVE = (1 << 7),
|
||||
MATERIAL_VAR_ALPHATEST = (1 << 8),
|
||||
#if defined( _PS3 ) || defined SPU
|
||||
// This Material flag is specifically for the final bloom pass only (the bloom add pass).
|
||||
// We need to disable alpha writes for 2x MSAA otherwise this pass will cause a heavy
|
||||
// blurring artifact to appear. It's only ever used in bloomadd_ps3.vmt, a modified version
|
||||
// of bloomadd.vmt for PS3 only - Jawad.
|
||||
MATERIAL_VAR_NOALPHAWRITES = (1 << 30),
|
||||
#endif //_PS3
|
||||
MATERIAL_VAR_ZNEARER = (1 << 10),
|
||||
MATERIAL_VAR_MODEL = (1 << 11),
|
||||
MATERIAL_VAR_FLAT = (1 << 12),
|
||||
MATERIAL_VAR_NOCULL = (1 << 13),
|
||||
MATERIAL_VAR_NOFOG = (1 << 14),
|
||||
MATERIAL_VAR_IGNOREZ = (1 << 15),
|
||||
MATERIAL_VAR_DECAL = (1 << 16),
|
||||
MATERIAL_VAR_ENVMAPSPHERE = (1 << 17), // OBSOLETE
|
||||
// MATERIAL_VAR_UNUSED = (1 << 18),
|
||||
MATERIAL_VAR_ENVMAPCAMERASPACE = (1 << 19), // OBSOLETE
|
||||
MATERIAL_VAR_BASEALPHAENVMAPMASK = (1 << 20),
|
||||
MATERIAL_VAR_TRANSLUCENT = (1 << 21),
|
||||
MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK = (1 << 22),
|
||||
MATERIAL_VAR_NEEDS_SOFTWARE_SKINNING = (1 << 23), // OBSOLETE
|
||||
MATERIAL_VAR_OPAQUETEXTURE = (1 << 24),
|
||||
MATERIAL_VAR_MULTIPLY = (1 << 25),
|
||||
MATERIAL_VAR_SUPPRESS_DECALS = (1 << 26),
|
||||
MATERIAL_VAR_HALFLAMBERT = (1 << 27),
|
||||
MATERIAL_VAR_WIREFRAME = (1 << 28),
|
||||
MATERIAL_VAR_ALLOWALPHATOCOVERAGE = (1 << 29),
|
||||
MATERIAL_VAR_ALPHA_MODIFIED_BY_PROXY = (1 << 30),
|
||||
MATERIAL_VAR_VERTEXFOG = (1 << 31),
|
||||
|
||||
// NOTE: Only add flags here that either should be read from
|
||||
// .vmts or can be set directly from client code. Other, internal
|
||||
// flags should to into the flag enum in IMaterialInternal.h
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Internal flags not accessible from outside the material system. Stored in Flags2
|
||||
//-----------------------------------------------------------------------------
|
||||
enum MaterialVarFlags2_t
|
||||
{
|
||||
// NOTE: These are for $flags2!!!!!
|
||||
// UNUSED = (1 << 0),
|
||||
|
||||
MATERIAL_VAR2_LIGHTING_UNLIT = 0,
|
||||
MATERIAL_VAR2_LIGHTING_VERTEX_LIT = (1 << 1),
|
||||
MATERIAL_VAR2_LIGHTING_LIGHTMAP = (1 << 2),
|
||||
MATERIAL_VAR2_LIGHTING_BUMPED_LIGHTMAP = (1 << 3),
|
||||
MATERIAL_VAR2_LIGHTING_MASK =
|
||||
( MATERIAL_VAR2_LIGHTING_VERTEX_LIT |
|
||||
MATERIAL_VAR2_LIGHTING_LIGHTMAP |
|
||||
MATERIAL_VAR2_LIGHTING_BUMPED_LIGHTMAP ),
|
||||
|
||||
// FIXME: Should this be a part of the above lighting enums?
|
||||
MATERIAL_VAR2_DIFFUSE_BUMPMAPPED_MODEL = (1 << 4),
|
||||
MATERIAL_VAR2_USES_ENV_CUBEMAP = (1 << 5),
|
||||
MATERIAL_VAR2_NEEDS_TANGENT_SPACES = (1 << 6),
|
||||
MATERIAL_VAR2_NEEDS_SOFTWARE_LIGHTING = (1 << 7),
|
||||
// GR - HDR path puts lightmap alpha in separate texture...
|
||||
MATERIAL_VAR2_BLEND_WITH_LIGHTMAP_ALPHA = (1 << 8),
|
||||
MATERIAL_VAR2_NEEDS_BAKED_LIGHTING_SNAPSHOTS = (1 << 9),
|
||||
MATERIAL_VAR2_USE_FLASHLIGHT = (1 << 10),
|
||||
MATERIAL_VAR2_USE_FIXED_FUNCTION_BAKED_LIGHTING = (1 << 11),
|
||||
MATERIAL_VAR2_NEEDS_FIXED_FUNCTION_FLASHLIGHT = (1 << 12),
|
||||
MATERIAL_VAR2_USE_EDITOR = (1 << 13),
|
||||
MATERIAL_VAR2_NEEDS_POWER_OF_TWO_FRAME_BUFFER_TEXTURE = (1 << 14),
|
||||
MATERIAL_VAR2_NEEDS_FULL_FRAME_BUFFER_TEXTURE = (1 << 15),
|
||||
MATERIAL_VAR2_IS_SPRITECARD = (1 << 16),
|
||||
MATERIAL_VAR2_USES_VERTEXID = (1 << 17),
|
||||
MATERIAL_VAR2_SUPPORTS_HW_SKINNING = (1 << 18),
|
||||
MATERIAL_VAR2_SUPPORTS_FLASHLIGHT = (1 << 19),
|
||||
MATERIAL_VAR2_USE_GBUFFER0 = (1 << 20),
|
||||
MATERIAL_VAR2_USE_GBUFFER1 = (1 << 21),
|
||||
MATERIAL_VAR2_SELFILLUMMASK = (1 << 22),
|
||||
MATERIAL_VAR2_SUPPORTS_TESSELLATION = (1 << 23),
|
||||
|
||||
// Support for types of vertex compression:
|
||||
MATERIAL_VAR2_SUPPORTS_VERTEX_COMPRESSION_BIT = 26,
|
||||
MATERIAL_VAR2_SUPPORTS_VERTEX_COMPRESSION_FULL = ( VERTEX_COMPRESSION_FULL << MATERIAL_VAR2_SUPPORTS_VERTEX_COMPRESSION_BIT ),
|
||||
MATERIAL_VAR2_SUPPORTS_VERTEX_COMPRESSION_NOUV = ( VERTEX_COMPRESSION_NOUV << MATERIAL_VAR2_SUPPORTS_VERTEX_COMPRESSION_BIT ),
|
||||
MATERIAL_VAR2_SUPPORTS_VERTEX_COMPRESSION_MASK =
|
||||
( MATERIAL_VAR2_SUPPORTS_VERTEX_COMPRESSION_FULL |
|
||||
MATERIAL_VAR2_SUPPORTS_VERTEX_COMPRESSION_NOUV ),
|
||||
};
|
||||
|
||||
#endif
|
38
public/materialsystem/imaterialproxy.h
Normal file
38
public/materialsystem/imaterialproxy.h
Normal file
@ -0,0 +1,38 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef IMATERIALPROXY_H
|
||||
#define IMATERIALPROXY_H
|
||||
#pragma once
|
||||
|
||||
#include "interface.h"
|
||||
|
||||
#define IMATERIAL_PROXY_INTERFACE_VERSION "_IMaterialProxy003"
|
||||
|
||||
class IMaterial;
|
||||
class KeyValues;
|
||||
|
||||
abstract_class IMaterialProxy
|
||||
{
|
||||
public:
|
||||
virtual bool Init( IMaterial* pMaterial, KeyValues *pKeyValues ) = 0;
|
||||
virtual void OnBind( void * ) = 0;
|
||||
virtual void Release() = 0;
|
||||
virtual IMaterial * GetMaterial() = 0;
|
||||
|
||||
// Is this material proxy allowed to be called in the async thread? Most are no, a few are yes.
|
||||
// This could be converted from a true interface to having a single bool that gets set at construction
|
||||
// time for this. I'm considering it because this gets called on the hot path, but it's probably not
|
||||
// worth it now.
|
||||
virtual bool CanBeCalledAsync() const { return false; }
|
||||
|
||||
protected:
|
||||
// no one should call this directly
|
||||
virtual ~IMaterialProxy() {}
|
||||
};
|
||||
|
||||
#endif // IMATERIALPROXY_H
|
26
public/materialsystem/imaterialproxyfactory.h
Normal file
26
public/materialsystem/imaterialproxyfactory.h
Normal file
@ -0,0 +1,26 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef IMATERIALPROXYFACTORY_H
|
||||
#define IMATERIALPROXYFACTORY_H
|
||||
#pragma once
|
||||
|
||||
#include "interface.h"
|
||||
|
||||
#define IMATERIAL_PROXY_FACTOR_INTERFACE_VERSION "IMaterialProxyFactory001"
|
||||
|
||||
class IMaterialProxy;
|
||||
|
||||
abstract_class IMaterialProxyFactory
|
||||
{
|
||||
public:
|
||||
virtual IMaterialProxy *CreateProxy( const char *proxyName ) = 0;
|
||||
virtual void DeleteProxy( IMaterialProxy *pProxy ) = 0;
|
||||
virtual CreateInterfaceFn GetFactory() = 0;
|
||||
};
|
||||
|
||||
#endif // IMATERIALPROXYFACTORY_H
|
2128
public/materialsystem/imaterialsystem.h
Normal file
2128
public/materialsystem/imaterialsystem.h
Normal file
File diff suppressed because it is too large
Load Diff
216
public/materialsystem/imaterialsystem_declarations.h
Normal file
216
public/materialsystem/imaterialsystem_declarations.h
Normal file
@ -0,0 +1,216 @@
|
||||
//===== Copyright (c), Valve Corporation, All rights reserved. ======//
|
||||
#ifndef imaterialsystem_declarations_h
|
||||
#define imaterialsystem_declarations_h
|
||||
|
||||
#ifndef IMPLEMENT_OPERATOR_EQUAL
|
||||
// Define a reasonable operator=
|
||||
#define IMPLEMENT_OPERATOR_EQUAL( _classname ) \
|
||||
public: \
|
||||
_classname &operator=( const _classname &src ) \
|
||||
{ \
|
||||
memcpy( this, &src, sizeof(_classname) ); \
|
||||
return *this; \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Sergiy: moved to _declarations.h
|
||||
/** EAPS3 [ pWallace ]
|
||||
* Moved to DmaPacketPcStubs.h:
|
||||
*
|
||||
* - Standard vertex shader constants
|
||||
*/
|
||||
|
||||
enum MaterialMatrixMode_t
|
||||
{
|
||||
MATERIAL_VIEW = 0,
|
||||
MATERIAL_PROJECTION,
|
||||
|
||||
/*
|
||||
MATERIAL_MATRIX_UNUSED0,
|
||||
MATERIAL_MATRIX_UNUSED1,
|
||||
MATERIAL_MATRIX_UNUSED2,
|
||||
MATERIAL_MATRIX_UNUSED3,
|
||||
MATERIAL_MATRIX_UNUSED4,
|
||||
MATERIAL_MATRIX_UNUSED5,
|
||||
MATERIAL_MATRIX_UNUSED6,
|
||||
MATERIAL_MATRIX_UNUSED7,
|
||||
*/
|
||||
// Texture matrices; used to be UNUSED
|
||||
MATERIAL_TEXTURE0,
|
||||
MATERIAL_TEXTURE1,
|
||||
MATERIAL_TEXTURE2,
|
||||
MATERIAL_TEXTURE3,
|
||||
MATERIAL_TEXTURE4,
|
||||
MATERIAL_TEXTURE5,
|
||||
MATERIAL_TEXTURE6,
|
||||
MATERIAL_TEXTURE7,
|
||||
|
||||
MATERIAL_MODEL,
|
||||
|
||||
// Total number of matrices
|
||||
NUM_MATRIX_MODES = MATERIAL_MODEL+1,
|
||||
|
||||
// Number of texture transforms
|
||||
NUM_TEXTURE_TRANSFORMS = MATERIAL_TEXTURE7 - MATERIAL_TEXTURE0 + 1
|
||||
};
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* MaterialFogMode_t
|
||||
*******************************************************************************/
|
||||
|
||||
enum MaterialFogMode_t
|
||||
{
|
||||
MATERIAL_FOG_NONE,
|
||||
MATERIAL_FOG_LINEAR,
|
||||
MATERIAL_FOG_LINEAR_BELOW_FOG_Z,
|
||||
};
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Uberlight parameters
|
||||
//--------------------------------------------------------------------------------
|
||||
struct UberlightState_t
|
||||
{
|
||||
UberlightState_t()
|
||||
{
|
||||
m_fNearEdge = 2.0f;
|
||||
m_fFarEdge = 100.0f;
|
||||
m_fCutOn = 10.0f;
|
||||
m_fCutOff = 650.0f;
|
||||
m_fShearx = 0.0f;
|
||||
m_fSheary = 0.0f;
|
||||
m_fWidth = 0.3f;
|
||||
m_fWedge = 0.05f;
|
||||
m_fHeight = 0.3f;
|
||||
m_fHedge = 0.05f;
|
||||
m_fRoundness = 0.8f;
|
||||
}
|
||||
|
||||
float m_fNearEdge;
|
||||
float m_fFarEdge;
|
||||
float m_fCutOn;
|
||||
float m_fCutOff;
|
||||
float m_fShearx;
|
||||
float m_fSheary;
|
||||
float m_fWidth;
|
||||
float m_fWedge;
|
||||
float m_fHeight;
|
||||
float m_fHedge;
|
||||
float m_fRoundness;
|
||||
|
||||
IMPLEMENT_OPERATOR_EQUAL( UberlightState_t );
|
||||
};
|
||||
|
||||
|
||||
class ITexture;
|
||||
class IMaterial;
|
||||
|
||||
// fixme: should move this into something else.
|
||||
struct FlashlightState_t
|
||||
{
|
||||
FlashlightState_t()
|
||||
{
|
||||
m_bEnableShadows = false; // Provide reasonable defaults for shadow depth mapping parameters
|
||||
m_bDrawShadowFrustum = false;
|
||||
m_flShadowMapResolution = 1024.0f;
|
||||
m_flShadowFilterSize = 3.0f;
|
||||
m_flShadowSlopeScaleDepthBias = 16.0f;
|
||||
m_flShadowDepthBias = 0.0005f;
|
||||
m_flShadowJitterSeed = 0.0f;
|
||||
m_flFlashlightTime = 0.0f;
|
||||
m_flShadowAtten = 0.0f;
|
||||
m_flAmbientOcclusion = 0.0f;
|
||||
m_bScissor = false;
|
||||
m_nLeft = -1;
|
||||
m_nTop = -1;
|
||||
m_nRight = -1;
|
||||
m_nBottom = -1;
|
||||
m_nShadowQuality = 0;
|
||||
m_bShadowHighRes = false;
|
||||
m_bUberlight = false;
|
||||
m_bVolumetric = false;
|
||||
m_flNoiseStrength = 0.8f;
|
||||
m_nNumPlanes = 64;
|
||||
m_flPlaneOffset = 0.0f;
|
||||
m_flVolumetricIntensity = 1.0f;
|
||||
m_bOrtho = false;
|
||||
m_fOrthoLeft = -1.0f;
|
||||
m_fOrthoRight = 1.0f;
|
||||
m_fOrthoTop = -1.0f;
|
||||
m_fOrthoBottom = 1.0f;
|
||||
m_flProjectionSize = 500.0f;
|
||||
m_flProjectionRotation = 0.0f;
|
||||
}
|
||||
|
||||
Vector m_vecLightOrigin;
|
||||
Quaternion m_quatOrientation;
|
||||
float m_NearZ;
|
||||
float m_FarZ;
|
||||
float m_fHorizontalFOVDegrees;
|
||||
float m_fVerticalFOVDegrees;
|
||||
bool m_bOrtho;
|
||||
float m_fOrthoLeft;
|
||||
float m_fOrthoRight;
|
||||
float m_fOrthoTop;
|
||||
float m_fOrthoBottom;
|
||||
float m_fQuadraticAtten;
|
||||
float m_fLinearAtten;
|
||||
float m_fConstantAtten;
|
||||
float m_FarZAtten;
|
||||
float m_Color[4];
|
||||
ITexture *m_pSpotlightTexture;
|
||||
IMaterial *m_pProjectedMaterial;
|
||||
int m_nSpotlightTextureFrame;
|
||||
|
||||
// Shadow depth mapping parameters
|
||||
bool m_bEnableShadows;
|
||||
bool m_bDrawShadowFrustum;
|
||||
float m_flShadowMapResolution;
|
||||
float m_flShadowFilterSize;
|
||||
float m_flShadowSlopeScaleDepthBias;
|
||||
float m_flShadowDepthBias;
|
||||
float m_flShadowJitterSeed;
|
||||
float m_flShadowAtten;
|
||||
float m_flAmbientOcclusion;
|
||||
int m_nShadowQuality;
|
||||
bool m_bShadowHighRes;
|
||||
|
||||
// simple projection
|
||||
float m_flProjectionSize;
|
||||
float m_flProjectionRotation;
|
||||
|
||||
// Uberlight parameters
|
||||
bool m_bUberlight;
|
||||
UberlightState_t m_uberlightState;
|
||||
|
||||
bool m_bVolumetric;
|
||||
float m_flNoiseStrength;
|
||||
float m_flFlashlightTime;
|
||||
int m_nNumPlanes;
|
||||
float m_flPlaneOffset;
|
||||
float m_flVolumetricIntensity;
|
||||
|
||||
// Getters for scissor members
|
||||
bool DoScissor() const { return m_bScissor; }
|
||||
int GetLeft() const { return m_nLeft; }
|
||||
int GetTop() const { return m_nTop; }
|
||||
int GetRight() const { return m_nRight; }
|
||||
int GetBottom() const { return m_nBottom; }
|
||||
|
||||
private:
|
||||
|
||||
friend class CShadowMgr;
|
||||
|
||||
bool m_bScissor;
|
||||
int m_nLeft;
|
||||
int m_nTop;
|
||||
int m_nRight;
|
||||
int m_nBottom;
|
||||
IMPLEMENT_OPERATOR_EQUAL( FlashlightState_t ) ;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
258
public/materialsystem/imaterialsystemhardwareconfig.h
Normal file
258
public/materialsystem/imaterialsystemhardwareconfig.h
Normal file
@ -0,0 +1,258 @@
|
||||
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Header: $
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef IMATERIALSYSTEMHARDWARECONFIG_H
|
||||
#define IMATERIALSYSTEMHARDWARECONFIG_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined( DX_TO_GL_ABSTRACTION )
|
||||
#define IsPlatformOpenGL() true
|
||||
#else
|
||||
#define IsPlatformOpenGL() false
|
||||
#endif
|
||||
|
||||
#include "tier1/interface.h"
|
||||
//#include "tier2/tier2.h"
|
||||
#include "bitmap/imageformat.h"
|
||||
#include "imaterialsystem.h"
|
||||
//-----------------------------------------------------------------------------
|
||||
// Material system interface version
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
FORCEINLINE bool IsOpenGL( void )
|
||||
{
|
||||
return IsPlatformOpenGL();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Material system interface version
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// For now, vertex compression is simply "on or off" (for the sake of simplicity
|
||||
// and MeshBuilder perf.), but later we may support multiple flavours.
|
||||
enum VertexCompressionType_t
|
||||
{
|
||||
// This indicates an uninitialized VertexCompressionType_t value
|
||||
VERTEX_COMPRESSION_INVALID = 0xFFFFFFFF,
|
||||
|
||||
// 'VERTEX_COMPRESSION_NONE' means that no elements of a vertex are compressed
|
||||
VERTEX_COMPRESSION_NONE = 0,
|
||||
|
||||
// Currently (more stuff may be added as needed), 'VERTEX_COMPRESSION_ON' means:
|
||||
// - if a vertex contains VERTEX_ELEMENT_NORMAL, this is compressed
|
||||
// (see CVertexBuilder::CompressedNormal3f)
|
||||
// - if a vertex contains VERTEX_ELEMENT_USERDATA4 (and a normal - together defining a tangent
|
||||
// frame, with the binormal reconstructed in the vertex shader), this is compressed
|
||||
// (see CVertexBuilder::CompressedUserData)
|
||||
// - if a vertex contains VERTEX_ELEMENT_BONEWEIGHTSx, this is compressed
|
||||
// (see CVertexBuilder::CompressedBoneWeight3fv)
|
||||
VERTEX_COMPRESSION_ON = 1
|
||||
};
|
||||
|
||||
|
||||
// use DEFCONFIGMETHOD to define time-critical methods that we want to make just return constants
|
||||
// on the 360, so that the checks will happen at compile time. Not all methods are defined this way
|
||||
// - just the ones that I perceive as being called often in the frame interval.
|
||||
#ifdef _GAMECONSOLE
|
||||
#define DEFCONFIGMETHOD( ret_type, method, xbox_return_value ) \
|
||||
FORCEINLINE ret_type method const \
|
||||
{ \
|
||||
return xbox_return_value; \
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
#define DEFCONFIGMETHOD( ret_type, method, xbox_return_value ) \
|
||||
virtual ret_type method const = 0;
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Shadow filter types
|
||||
// Important notes: These enums directly correspond to combo indices.
|
||||
// If you change these, make the corresponding change in common_ps_fxc.h
|
||||
// Cheap ones are at the end on purpose, and are only run on ps2b
|
||||
// SHADOWFILTERMODE_DEFAULT must be 0.
|
||||
//-----------------------------------------------------------------------------
|
||||
enum ShadowFilterMode_t
|
||||
{
|
||||
SHADOWFILTERMODE_DEFAULT = 0,
|
||||
|
||||
NVIDIA_PCF = 0,
|
||||
ATI_NO_PCF_FETCH4 = 1,
|
||||
NVIDIA_PCF_CHEAP = 2,
|
||||
ATI_NOPCF = 3,
|
||||
|
||||
// Game consoles use a different set of combo indices to control shadow filtering.
|
||||
GAMECONSOLE_NINE_TAP_PCF = 0,
|
||||
GAMECONSOLE_SINGLE_TAP_PCF = 1,
|
||||
|
||||
// All modes >= SHADOWFILTERMODE_FIRST_CHEAP_MODE are considered the "cheap" modes.
|
||||
|
||||
#if defined( _GAMECONSOLE )
|
||||
SHADOWFILTERMODE_FIRST_CHEAP_MODE = GAMECONSOLE_SINGLE_TAP_PCF,
|
||||
#else
|
||||
SHADOWFILTERMODE_FIRST_CHEAP_MODE = NVIDIA_PCF_CHEAP,
|
||||
#endif
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
enum CSMQualityMode_t
|
||||
{
|
||||
CSMQUALITY_VERY_LOW,
|
||||
CSMQUALITY_LOW,
|
||||
CSMQUALITY_MEDIUM,
|
||||
CSMQUALITY_HIGH,
|
||||
|
||||
CSMQUALITY_TOTAL_MODES
|
||||
};
|
||||
|
||||
// CSMShaderMode_t must match the CSM_MODE static combo in the pixel shaders
|
||||
enum CSMShaderMode_t
|
||||
{
|
||||
CSMSHADERMODE_LOW_OR_VERY_LOW = 0,
|
||||
CSMSHADERMODE_MEDIUM = 1,
|
||||
CSMSHADERMODE_HIGH = 2,
|
||||
CSMSHADERMODE_ATIFETCH4 = 3,
|
||||
|
||||
CSMSHADERMODE_TOTAL_MODES
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Material system configuration
|
||||
//-----------------------------------------------------------------------------
|
||||
class IMaterialSystemHardwareConfig
|
||||
{
|
||||
public:
|
||||
virtual int GetFrameBufferColorDepth() const = 0;
|
||||
virtual int GetSamplerCount() const = 0;
|
||||
virtual bool HasSetDeviceGammaRamp() const = 0;
|
||||
DEFCONFIGMETHOD( bool, SupportsStaticControlFlow(), true );
|
||||
virtual VertexCompressionType_t SupportsCompressedVertices() const = 0;
|
||||
virtual int MaximumAnisotropicLevel() const = 0; // 0 means no anisotropic filtering
|
||||
virtual int MaxTextureWidth() const = 0;
|
||||
virtual int MaxTextureHeight() const = 0;
|
||||
virtual int TextureMemorySize() const = 0;
|
||||
virtual bool SupportsMipmappedCubemaps() const = 0;
|
||||
|
||||
virtual int NumVertexShaderConstants() const = 0;
|
||||
virtual int NumPixelShaderConstants() const = 0;
|
||||
virtual int MaxNumLights() const = 0;
|
||||
virtual int MaxTextureAspectRatio() const = 0;
|
||||
virtual int MaxVertexShaderBlendMatrices() const = 0;
|
||||
virtual int MaxUserClipPlanes() const = 0;
|
||||
virtual bool UseFastClipping() const = 0;
|
||||
|
||||
// This here should be the major item looked at when checking for compat
|
||||
// from anywhere other than the material system shaders
|
||||
DEFCONFIGMETHOD( int, GetDXSupportLevel(), 98 );
|
||||
virtual const char *GetShaderDLLName() const = 0;
|
||||
|
||||
virtual bool ReadPixelsFromFrontBuffer() const = 0;
|
||||
|
||||
// Are dx dynamic textures preferred?
|
||||
virtual bool PreferDynamicTextures() const = 0;
|
||||
|
||||
DEFCONFIGMETHOD( bool, SupportsHDR(), true );
|
||||
|
||||
virtual bool NeedsAAClamp() const = 0;
|
||||
virtual bool NeedsATICentroidHack() const = 0;
|
||||
|
||||
// This is the max dx support level supported by the card
|
||||
virtual int GetMaxDXSupportLevel() const = 0;
|
||||
|
||||
// Does the card specify fog color in linear space when sRGBWrites are enabled?
|
||||
virtual bool SpecifiesFogColorInLinearSpace() const = 0;
|
||||
|
||||
// Does the card support sRGB reads/writes?
|
||||
DEFCONFIGMETHOD( bool, SupportsSRGB(), true );
|
||||
DEFCONFIGMETHOD( bool, FakeSRGBWrite(), false );
|
||||
DEFCONFIGMETHOD( bool, CanDoSRGBReadFromRTs(), true );
|
||||
|
||||
virtual bool SupportsGLMixedSizeTargets() const = 0;
|
||||
|
||||
virtual bool IsAAEnabled() const = 0; // Is antialiasing being used?
|
||||
|
||||
// NOTE: Anything after this was added after shipping HL2.
|
||||
virtual int GetVertexSamplerCount() const = 0;
|
||||
virtual int GetMaxVertexTextureDimension() const = 0;
|
||||
|
||||
virtual int MaxTextureDepth() const = 0;
|
||||
|
||||
virtual HDRType_t GetHDRType() const = 0;
|
||||
virtual HDRType_t GetHardwareHDRType() const = 0;
|
||||
|
||||
virtual bool SupportsStreamOffset() const = 0;
|
||||
|
||||
virtual int StencilBufferBits() const = 0;
|
||||
virtual int MaxViewports() const = 0;
|
||||
|
||||
virtual void OverrideStreamOffsetSupport( bool bOverrideEnabled, bool bEnableSupport ) = 0;
|
||||
|
||||
virtual ShadowFilterMode_t GetShadowFilterMode( bool bForceLowQualityShadows, bool bPS30 ) const = 0;
|
||||
|
||||
virtual int NeedsShaderSRGBConversion() const = 0;
|
||||
|
||||
DEFCONFIGMETHOD( bool, UsesSRGBCorrectBlending(), IsX360() );
|
||||
|
||||
virtual bool HasFastVertexTextures() const = 0;
|
||||
virtual int MaxHWMorphBatchCount() const = 0;
|
||||
|
||||
virtual bool SupportsHDRMode( HDRType_t nHDRMode ) const = 0;
|
||||
|
||||
virtual bool GetHDREnabled( void ) const = 0;
|
||||
virtual void SetHDREnabled( bool bEnable ) = 0;
|
||||
|
||||
virtual bool SupportsBorderColor( void ) const = 0;
|
||||
virtual bool SupportsFetch4( void ) const = 0;
|
||||
|
||||
virtual float GetShadowDepthBias() const = 0;
|
||||
virtual float GetShadowSlopeScaleDepthBias() const = 0;
|
||||
|
||||
virtual bool PreferZPrepass() const = 0;
|
||||
|
||||
virtual bool SuppressPixelShaderCentroidHackFixup() const = 0;
|
||||
virtual bool PreferTexturesInHWMemory() const = 0;
|
||||
virtual bool PreferHardwareSync() const = 0;
|
||||
virtual bool ActualHasFastVertexTextures() const = 0;
|
||||
|
||||
virtual bool SupportsShadowDepthTextures( void ) const = 0;
|
||||
virtual ImageFormat GetShadowDepthTextureFormat( void ) const = 0;
|
||||
virtual ImageFormat GetHighPrecisionShadowDepthTextureFormat( void ) const = 0;
|
||||
virtual ImageFormat GetNullTextureFormat( void ) const = 0;
|
||||
virtual int GetMinDXSupportLevel() const = 0;
|
||||
virtual bool IsUnsupported() const = 0;
|
||||
|
||||
virtual float GetLightMapScaleFactor() const = 0;
|
||||
|
||||
virtual bool SupportsCascadedShadowMapping() const = 0;
|
||||
virtual CSMQualityMode_t GetCSMQuality() const = 0;
|
||||
virtual bool SupportsBilinearPCFSampling() const = 0;
|
||||
virtual CSMShaderMode_t GetCSMShaderMode( CSMQualityMode_t nQualityLevel ) const = 0;
|
||||
virtual bool GetCSMAccurateBlending( void ) const = 0;
|
||||
virtual void SetCSMAccurateBlending( bool bEnable ) = 0;
|
||||
|
||||
virtual bool SupportsResolveDepth() const = 0;
|
||||
virtual bool HasFullResolutionDepthTexture() const = 0;
|
||||
|
||||
// Backward compat for stdshaders
|
||||
#if defined ( STDSHADER_DBG_DLL_EXPORT ) || defined( STDSHADER_DX9_DLL_EXPORT )
|
||||
inline bool SupportsPixelShaders_2_b() const { return GetDXSupportLevel() >= 92; }
|
||||
inline bool SupportsPixelShaders_3_0() const { return GetDXSupportLevel() >= 95; }
|
||||
#endif
|
||||
|
||||
inline bool ShouldAlwaysUseShaderModel2bShaders() const { return IsOpenGL(); }
|
||||
inline bool PlatformRequiresNonNullPixelShaders() const { return IsOpenGL(); }
|
||||
};
|
||||
|
||||
#endif // IMATERIALSYSTEMHARDWARECONFIG_H
|
@ -0,0 +1,52 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef IMATERIALSYSTEMHARDWARECONFIG_DECLARATIONS_H
|
||||
#define IMATERIALSYSTEMHARDWARECONFIG_DECLARATIONS_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// HDRFIXME NOTE: must match common_ps_fxc.h
|
||||
enum HDRType_t
|
||||
{
|
||||
HDR_TYPE_NONE,
|
||||
HDR_TYPE_INTEGER,
|
||||
HDR_TYPE_FLOAT,
|
||||
};
|
||||
|
||||
|
||||
|
||||
enum VertexCompressionType_t
|
||||
{
|
||||
// This indicates an uninitialized VertexCompressionType_t value
|
||||
VERTEX_COMPRESSION_INVALID = 0xFFFFFFFF,
|
||||
|
||||
// 'VERTEX_COMPRESSION_NONE' means that no elements of a vertex are compressed
|
||||
VERTEX_COMPRESSION_NONE = 0,
|
||||
|
||||
// Currently (more stuff may be added as needed), 'VERTEX_COMPRESSION_FULL' means:
|
||||
// - if a vertex contains VERTEX_ELEMENT_NORMAL, this is compressed
|
||||
// (see CVertexBuilder::CompressedNormal3f)
|
||||
// - if a vertex contains VERTEX_ELEMENT_USERDATA4 (and a normal - together defining a tangent
|
||||
// frame, with the binormal reconstructed in the vertex shader), this is compressed
|
||||
// (see CVertexBuilder::CompressedUserData)
|
||||
// - if a vertex contains VERTEX_ELEMENT_BONEWEIGHTSx, this is compressed
|
||||
// (see CVertexBuilder::CompressedBoneWeight3fv)
|
||||
// - if a vertex contains VERTEX_ELEMENT_TEXCOORD2D_0, this is compressed
|
||||
// (see CVertexBuilder::CompressedTexCoord2fv)
|
||||
VERTEX_COMPRESSION_FULL = (1 << 0),
|
||||
VERTEX_COMPRESSION_ON = VERTEX_COMPRESSION_FULL,
|
||||
// VERTEX_COMPRESSION_NOUV is the same as VERTEX_COMPRESSION_FULL, but does not compress
|
||||
// texture coordinates. Some assets use very large texture coordinates, so these cannot be
|
||||
// compressed - but the rest of the vertex data can be.
|
||||
VERTEX_COMPRESSION_NOUV = (1 << 1),
|
||||
|
||||
VERTEX_COMPRESSION_MASK = ( VERTEX_COMPRESSION_FULL |
|
||||
VERTEX_COMPRESSION_NOUV ),
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // IMATERIALSYSTEMHARDWARECONFIG_H
|
31
public/materialsystem/imaterialsystemstub.h
Normal file
31
public/materialsystem/imaterialsystemstub.h
Normal file
@ -0,0 +1,31 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef IMATERIALSYSTEMSTUB_H
|
||||
#define IMATERIALSYSTEMSTUB_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
|
||||
|
||||
// If you get this interface out of the material system, it'll return an IMaterialSystem
|
||||
// with everything stubbed. This is used for running the client in text mode.
|
||||
#define MATERIAL_SYSTEM_STUB_INTERFACE_VERSION "VMaterialSystemStub001"
|
||||
|
||||
|
||||
class IMaterialSystemStub : public IMaterialSystem
|
||||
{
|
||||
public:
|
||||
// If this is called, then the stub will call through to the real material
|
||||
// system in some functions.
|
||||
virtual void SetRealMaterialSystem( IMaterialSystem *pSys ) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // IMATERIALSYSTEMSTUB_H
|
246
public/materialsystem/imaterialvar.h
Normal file
246
public/materialsystem/imaterialvar.h
Normal file
@ -0,0 +1,246 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef IMATERIALVAR_H
|
||||
#define IMATERIALVAR_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlsymbol.h"
|
||||
#include "mathlib/vector4d.h"
|
||||
class IMaterial;
|
||||
class VMatrix;
|
||||
class ITexture;
|
||||
|
||||
#define MAKE_MATERIALVAR_FOURCC(ch0, ch1, ch2, ch3) \
|
||||
((unsigned long)(ch0) | ((unsigned long)(ch1) << 8) | \
|
||||
((unsigned long)(ch2) << 16) | ((unsigned long)(ch3) << 24 ))
|
||||
|
||||
// This fourcc is reserved.
|
||||
#define FOURCC_UNKNOWN MAKE_MATERIALVAR_FOURCC('U','N','K','N')
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Various material var types
|
||||
//-----------------------------------------------------------------------------
|
||||
enum MaterialVarType_t
|
||||
{
|
||||
MATERIAL_VAR_TYPE_FLOAT = 0,
|
||||
MATERIAL_VAR_TYPE_STRING,
|
||||
MATERIAL_VAR_TYPE_VECTOR,
|
||||
MATERIAL_VAR_TYPE_TEXTURE,
|
||||
MATERIAL_VAR_TYPE_INT,
|
||||
MATERIAL_VAR_TYPE_FOURCC,
|
||||
MATERIAL_VAR_TYPE_UNDEFINED,
|
||||
MATERIAL_VAR_TYPE_MATRIX,
|
||||
MATERIAL_VAR_TYPE_MATERIAL,
|
||||
};
|
||||
|
||||
typedef unsigned short MaterialVarSym_t;
|
||||
|
||||
class IMaterialVar
|
||||
{
|
||||
public:
|
||||
typedef unsigned long FourCC;
|
||||
|
||||
protected:
|
||||
// base data and accessors
|
||||
char* m_pStringVal;
|
||||
int m_intVal;
|
||||
Vector4D m_VecVal;
|
||||
|
||||
// member data. total = 4 bytes
|
||||
uint8 m_Type : 4;
|
||||
uint8 m_nNumVectorComps : 3;
|
||||
uint8 m_bFakeMaterialVar : 1;
|
||||
uint8 m_nTempIndex;
|
||||
CUtlSymbol m_Name;
|
||||
|
||||
public:
|
||||
// class factory methods
|
||||
static IMaterialVar* Create( IMaterial* pMaterial, char const* pKey, VMatrix const& matrix );
|
||||
static IMaterialVar* Create( IMaterial* pMaterial, char const* pKey, char const* pVal );
|
||||
static IMaterialVar* Create( IMaterial* pMaterial, char const* pKey, float* pVal, int numcomps );
|
||||
static IMaterialVar* Create( IMaterial* pMaterial, char const* pKey, float val );
|
||||
static IMaterialVar* Create( IMaterial* pMaterial, char const* pKey, int val );
|
||||
static IMaterialVar* Create( IMaterial* pMaterial, char const* pKey );
|
||||
static void Destroy( IMaterialVar* pVar );
|
||||
static MaterialVarSym_t GetSymbol( char const* pName );
|
||||
static MaterialVarSym_t FindSymbol( char const* pName );
|
||||
static bool SymbolMatches( char const* pName, MaterialVarSym_t symbol );
|
||||
static void DeleteUnreferencedTextures( bool enable );
|
||||
|
||||
virtual ITexture *GetTextureValue( void ) = 0;
|
||||
virtual bool IsTextureValueInternalEnvCubemap( void ) const = 0;
|
||||
|
||||
virtual char const * GetName( void ) const = 0;
|
||||
virtual MaterialVarSym_t GetNameAsSymbol() const = 0;
|
||||
|
||||
virtual void SetFloatValue( float val ) = 0;
|
||||
|
||||
virtual void SetIntValue( int val ) = 0;
|
||||
|
||||
virtual void SetStringValue( char const *val ) = 0;
|
||||
virtual char const * GetStringValue( void ) const = 0;
|
||||
|
||||
// Use FourCC values to pass app-defined data structures between
|
||||
// the proxy and the shader. The shader should ignore the data if
|
||||
// its FourCC type not correct.
|
||||
virtual void SetFourCCValue( FourCC type, void *pData ) = 0;
|
||||
virtual void GetFourCCValue( FourCC *type, void **ppData ) = 0;
|
||||
|
||||
// Vec (dim 2-4)
|
||||
virtual void SetVecValue( float const* val, int numcomps ) = 0;
|
||||
virtual void SetVecValue( float x, float y ) = 0;
|
||||
virtual void SetVecValue( float x, float y, float z ) = 0;
|
||||
virtual void SetVecValue( float x, float y, float z, float w ) = 0;
|
||||
virtual void GetLinearVecValue( float *val, int numcomps ) const = 0;
|
||||
|
||||
// revisit: is this a good interface for textures?
|
||||
virtual void SetTextureValue( ITexture * ) = 0;
|
||||
|
||||
virtual IMaterial * GetMaterialValue( void ) = 0;
|
||||
virtual void SetMaterialValue( IMaterial * ) = 0;
|
||||
|
||||
virtual bool IsDefined() const = 0;
|
||||
virtual void SetUndefined() = 0;
|
||||
|
||||
// Matrix
|
||||
virtual void SetMatrixValue( VMatrix const& matrix ) = 0;
|
||||
virtual const VMatrix &GetMatrixValue( ) = 0;
|
||||
virtual bool MatrixIsIdentity() const = 0;
|
||||
|
||||
// Copy....
|
||||
virtual void CopyFrom( IMaterialVar *pMaterialVar ) = 0;
|
||||
|
||||
virtual void SetValueAutodetectType( char const *val ) = 0;
|
||||
|
||||
virtual IMaterial * GetOwningMaterial() = 0;
|
||||
|
||||
//set just 1 component
|
||||
virtual void SetVecComponentValue( float fVal, int nComponent ) = 0;
|
||||
|
||||
protected:
|
||||
virtual int GetIntValueInternal( void ) const = 0;
|
||||
virtual float GetFloatValueInternal( void ) const = 0;
|
||||
virtual float const* GetVecValueInternal( ) const = 0;
|
||||
virtual void GetVecValueInternal( float *val, int numcomps ) const = 0;
|
||||
virtual int VectorSizeInternal() const = 0;
|
||||
|
||||
public:
|
||||
FORCEINLINE MaterialVarType_t GetType( void ) const
|
||||
{
|
||||
return ( MaterialVarType_t )m_Type;
|
||||
}
|
||||
|
||||
FORCEINLINE bool IsTexture() const
|
||||
{
|
||||
return m_Type == MATERIAL_VAR_TYPE_TEXTURE;
|
||||
}
|
||||
|
||||
FORCEINLINE operator ITexture*()
|
||||
{
|
||||
return GetTextureValue();
|
||||
}
|
||||
|
||||
// NOTE: Fast methods should only be called in thread-safe situations
|
||||
FORCEINLINE int GetIntValueFast( void ) const
|
||||
{
|
||||
// Set methods for float and vector update this
|
||||
return m_intVal;
|
||||
}
|
||||
|
||||
FORCEINLINE float GetFloatValueFast( void ) const
|
||||
{
|
||||
return m_VecVal[0];
|
||||
}
|
||||
|
||||
FORCEINLINE float const* GetVecValueFast( ) const
|
||||
{
|
||||
return m_VecVal.Base();
|
||||
}
|
||||
|
||||
FORCEINLINE void GetVecValueFast( float *val, int numcomps ) const
|
||||
{
|
||||
Assert( ( numcomps >0 ) && ( numcomps <= 4 ) );
|
||||
for( int i=0 ; i < numcomps; i++ )
|
||||
{
|
||||
val[i] = m_VecVal[ i ];
|
||||
}
|
||||
}
|
||||
|
||||
FORCEINLINE int VectorSizeFast() const
|
||||
{
|
||||
return m_nNumVectorComps;
|
||||
}
|
||||
|
||||
#ifdef FAST_MATERIALVAR_ACCESS
|
||||
FORCEINLINE int GetIntValue( void ) const
|
||||
{
|
||||
return GetIntValueFast();
|
||||
}
|
||||
|
||||
FORCEINLINE float GetFloatValue( void ) const
|
||||
{
|
||||
return GetFloatValueFast();
|
||||
}
|
||||
|
||||
FORCEINLINE float const* GetVecValue( ) const
|
||||
{
|
||||
return GetVecValueFast();
|
||||
}
|
||||
|
||||
FORCEINLINE void GetVecValue( float *val, int numcomps ) const
|
||||
{
|
||||
GetVecValueFast( val, numcomps );
|
||||
}
|
||||
|
||||
FORCEINLINE int VectorSize() const
|
||||
{
|
||||
return VectorSizeFast();
|
||||
}
|
||||
#else // !FAST_MATERIALVAR_ACCESS
|
||||
FORCEINLINE int GetIntValue( void ) const
|
||||
{
|
||||
return GetIntValueInternal();
|
||||
}
|
||||
|
||||
FORCEINLINE float GetFloatValue( void ) const
|
||||
{
|
||||
return GetFloatValueInternal();
|
||||
}
|
||||
|
||||
FORCEINLINE float const* GetVecValue( ) const
|
||||
{
|
||||
return GetVecValueInternal();
|
||||
}
|
||||
|
||||
FORCEINLINE void GetVecValue( float *val, int numcomps ) const
|
||||
{
|
||||
return GetVecValueInternal( val, numcomps );
|
||||
}
|
||||
|
||||
FORCEINLINE int VectorSize() const
|
||||
{
|
||||
return VectorSizeInternal();
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
FORCEINLINE void SetTempIndex( int nIndex )
|
||||
{
|
||||
m_nTempIndex = nIndex;
|
||||
}
|
||||
|
||||
friend void EnableThreadedMaterialVarAccess( bool bEnable, IMaterialVar **ppParams, int nVarCount );
|
||||
};
|
||||
|
||||
#endif // IMATERIALVAR_H
|
22
public/materialsystem/imaterialvar_declarations.h
Normal file
22
public/materialsystem/imaterialvar_declarations.h
Normal file
@ -0,0 +1,22 @@
|
||||
//===== Copyright <20> , Valve Corporation, All rights reserved. ======//
|
||||
#ifndef IMATERIALVAR_DECLARATIONS_HDR
|
||||
#define IMATERIALVAR_DECLARATIONS_HDR
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Various material var types
|
||||
//-----------------------------------------------------------------------------
|
||||
enum MaterialVarType_t
|
||||
{
|
||||
MATERIAL_VAR_TYPE_FLOAT = 0,
|
||||
MATERIAL_VAR_TYPE_STRING,
|
||||
MATERIAL_VAR_TYPE_VECTOR,
|
||||
MATERIAL_VAR_TYPE_TEXTURE,
|
||||
MATERIAL_VAR_TYPE_INT,
|
||||
MATERIAL_VAR_TYPE_FOURCC,
|
||||
MATERIAL_VAR_TYPE_UNDEFINED,
|
||||
MATERIAL_VAR_TYPE_MATRIX,
|
||||
MATERIAL_VAR_TYPE_MATERIAL,
|
||||
};
|
||||
|
||||
|
||||
#endif
|
4402
public/materialsystem/imesh.h
Normal file
4402
public/materialsystem/imesh.h
Normal file
File diff suppressed because it is too large
Load Diff
26
public/materialsystem/imesh_declarations.h
Normal file
26
public/materialsystem/imesh_declarations.h
Normal file
@ -0,0 +1,26 @@
|
||||
//===== Copyright <20> Valve Corporation, All rights reserved. ======//
|
||||
#ifndef IMESH_DECLARATIONS_HDR
|
||||
#define IMESH_DECLARATIONS_HDR
|
||||
|
||||
enum SpuMeshRenderDataEnum{ MAX_SPU_MESHRENDERDATA = 2, MAX_SPU_PRIM_DATA = 128 };
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int primFirstIndex;
|
||||
int primNumIndices;
|
||||
} SPUPrimRenderData;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/*GfxPrimType*/int primType;
|
||||
MaterialPrimitiveType_t materialType;
|
||||
SPUPrimRenderData primData[ MAX_SPU_PRIM_DATA ];
|
||||
uint32 numPrims;
|
||||
uint32 firstIndex;
|
||||
|
||||
} SPUMeshRenderData;
|
||||
|
||||
|
||||
|
||||
#endif
|
251
public/materialsystem/imorph.h
Normal file
251
public/materialsystem/imorph.h
Normal file
@ -0,0 +1,251 @@
|
||||
//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
|
||||
//
|
||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||
// The contents may be used and/or copied only with the written permission of
|
||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
||||
// the agreement/contract under which the contents have been supplied.
|
||||
//
|
||||
// $Header: $
|
||||
// $NoKeywords: $
|
||||
//
|
||||
// Interface used to construct morph buffers
|
||||
//=============================================================================
|
||||
|
||||
#ifndef IMORPH_H
|
||||
#define IMORPH_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "mathlib/vector.h"
|
||||
#include <float.h>
|
||||
#include "tier0/dbg.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Single morph data
|
||||
//-----------------------------------------------------------------------------
|
||||
struct MorphVertexInfo_t
|
||||
{
|
||||
int m_nVertexId; // What vertex is this going to affect?
|
||||
int m_nMorphTargetId; // What morph did it come from?
|
||||
Vector m_PositionDelta; // Positional morph delta
|
||||
Vector m_NormalDelta; // Normal morph delta
|
||||
float m_flWrinkleDelta; // Wrinkle morph delta
|
||||
float m_flSpeed;
|
||||
float m_flSide;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Morph weight data
|
||||
//-----------------------------------------------------------------------------
|
||||
enum MorphWeightType_t
|
||||
{
|
||||
MORPH_WEIGHT = 0,
|
||||
MORPH_WEIGHT_LAGGED,
|
||||
MORPH_WEIGHT_STEREO,
|
||||
MORPH_WEIGHT_STEREO_LAGGED,
|
||||
|
||||
MORPH_WEIGHT_COUNT,
|
||||
};
|
||||
|
||||
struct MorphWeight_t
|
||||
{
|
||||
float m_pWeight[MORPH_WEIGHT_COUNT];
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Interface to the morph
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IMorph
|
||||
{
|
||||
public:
|
||||
// Locks the morph, destroys any existing contents
|
||||
virtual void Lock( float flFloatToFixedScale = 1.0f ) = 0;
|
||||
|
||||
// Adds a morph
|
||||
virtual void AddMorph( const MorphVertexInfo_t &info ) = 0;
|
||||
|
||||
// Unlocks the morph
|
||||
virtual void Unlock( ) = 0;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Morph builders
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMorphBuilder
|
||||
{
|
||||
public:
|
||||
CMorphBuilder();
|
||||
~CMorphBuilder();
|
||||
|
||||
// Start building the morph
|
||||
void Begin( IMorph *pMorph, float flFloatToFixedScale = 1.0f );
|
||||
|
||||
// End building the morph
|
||||
void End();
|
||||
|
||||
void PositionDelta3fv( const float *pDelta );
|
||||
void PositionDelta3f( float dx, float dy, float dz );
|
||||
void PositionDelta3( const Vector &vec );
|
||||
|
||||
void NormalDelta3fv( const float *pDelta );
|
||||
void NormalDelta3f( float dx, float dy, float dz );
|
||||
void NormalDelta3( const Vector &vec );
|
||||
|
||||
void WrinkleDelta1f( float flWrinkle );
|
||||
|
||||
// Both are 0-1 values indicating which morph target to use (for stereo morph targets)
|
||||
// and how much to blend between using lagged weights vs actual weights
|
||||
// Speed: 0 - use lagged, 1 - use actual
|
||||
void Speed1f( float flSpeed );
|
||||
void Side1f( float flSide );
|
||||
|
||||
void AdvanceMorph( int nSourceVertex, int nMorphTargetId );
|
||||
|
||||
private:
|
||||
MorphVertexInfo_t m_Info;
|
||||
IMorph *m_pMorph;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor, destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
inline CMorphBuilder::CMorphBuilder()
|
||||
{
|
||||
m_pMorph = NULL;
|
||||
}
|
||||
|
||||
inline CMorphBuilder::~CMorphBuilder()
|
||||
{
|
||||
// You forgot to call End()!
|
||||
Assert( !m_pMorph );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Start building the morph
|
||||
//-----------------------------------------------------------------------------
|
||||
inline void CMorphBuilder::Begin( IMorph *pMorph, float flFloatToFixedScale )
|
||||
{
|
||||
Assert( pMorph && !m_pMorph );
|
||||
m_pMorph = pMorph;
|
||||
m_pMorph->Lock( flFloatToFixedScale );
|
||||
|
||||
#ifdef _DEBUG
|
||||
m_Info.m_PositionDelta.Init( VEC_T_NAN, VEC_T_NAN, VEC_T_NAN );
|
||||
m_Info.m_NormalDelta.Init( VEC_T_NAN, VEC_T_NAN, VEC_T_NAN );
|
||||
m_Info.m_flWrinkleDelta = VEC_T_NAN;
|
||||
m_Info.m_flSpeed = VEC_T_NAN;
|
||||
m_Info.m_flSide = VEC_T_NAN;
|
||||
#endif
|
||||
}
|
||||
|
||||
// End building the morph
|
||||
inline void CMorphBuilder::End()
|
||||
{
|
||||
Assert( m_pMorph );
|
||||
m_pMorph->Unlock();
|
||||
m_pMorph = NULL;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Set position delta
|
||||
//-----------------------------------------------------------------------------
|
||||
inline void CMorphBuilder::PositionDelta3fv( const float *pDelta )
|
||||
{
|
||||
Assert( m_pMorph );
|
||||
m_Info.m_PositionDelta.Init( pDelta[0], pDelta[1], pDelta[2] );
|
||||
}
|
||||
|
||||
inline void CMorphBuilder::PositionDelta3f( float dx, float dy, float dz )
|
||||
{
|
||||
Assert( m_pMorph );
|
||||
m_Info.m_PositionDelta.Init( dx, dy, dz );
|
||||
}
|
||||
|
||||
inline void CMorphBuilder::PositionDelta3( const Vector &vec )
|
||||
{
|
||||
Assert( m_pMorph );
|
||||
m_Info.m_PositionDelta = vec;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Set normal delta
|
||||
//-----------------------------------------------------------------------------
|
||||
inline void CMorphBuilder::NormalDelta3fv( const float *pDelta )
|
||||
{
|
||||
Assert( m_pMorph );
|
||||
m_Info.m_NormalDelta.Init( pDelta[0], pDelta[1], pDelta[2] );
|
||||
}
|
||||
|
||||
inline void CMorphBuilder::NormalDelta3f( float dx, float dy, float dz )
|
||||
{
|
||||
Assert( m_pMorph );
|
||||
m_Info.m_NormalDelta.Init( dx, dy, dz );
|
||||
}
|
||||
|
||||
inline void CMorphBuilder::NormalDelta3( const Vector &vec )
|
||||
{
|
||||
Assert( m_pMorph );
|
||||
m_Info.m_NormalDelta = vec;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Set wrinkle delta
|
||||
//-----------------------------------------------------------------------------
|
||||
inline void CMorphBuilder::WrinkleDelta1f( float flWrinkle )
|
||||
{
|
||||
Assert( m_pMorph );
|
||||
m_Info.m_flWrinkleDelta = flWrinkle;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Set speed,side data
|
||||
//-----------------------------------------------------------------------------
|
||||
inline void CMorphBuilder::Speed1f( float flSpeed )
|
||||
{
|
||||
Assert( m_pMorph );
|
||||
m_Info.m_flSpeed = flSpeed;
|
||||
}
|
||||
|
||||
inline void CMorphBuilder::Side1f( float flSide )
|
||||
{
|
||||
Assert( m_pMorph );
|
||||
m_Info.m_flSide = flSide;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Advance morph
|
||||
//-----------------------------------------------------------------------------
|
||||
inline void CMorphBuilder::AdvanceMorph( int nSourceVertex, int nMorphTargetId )
|
||||
{
|
||||
Assert( m_pMorph );
|
||||
|
||||
m_Info.m_nVertexId = nSourceVertex;
|
||||
m_Info.m_nMorphTargetId = nMorphTargetId;
|
||||
|
||||
m_pMorph->AddMorph( m_Info );
|
||||
|
||||
#ifdef _DEBUG
|
||||
m_Info.m_PositionDelta.Init( VEC_T_NAN, VEC_T_NAN, VEC_T_NAN );
|
||||
m_Info.m_NormalDelta.Init( VEC_T_NAN, VEC_T_NAN, VEC_T_NAN );
|
||||
m_Info.m_flWrinkleDelta = VEC_T_NAN;
|
||||
m_Info.m_flSpeed = VEC_T_NAN;
|
||||
m_Info.m_flSide = VEC_T_NAN;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif // IMORPH_H
|
49
public/materialsystem/ipaintmapdatamanager.h
Normal file
49
public/materialsystem/ipaintmapdatamanager.h
Normal file
@ -0,0 +1,49 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef IPaintmapMANIPULATOR_H
|
||||
#define IPaintmapMANIPULATOR_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier0/platform.h"
|
||||
|
||||
struct Rect_t;
|
||||
|
||||
//owned by the client
|
||||
abstract_class IPaintmapDataManager
|
||||
{
|
||||
public:
|
||||
//called just before the material system initializes the paint textures
|
||||
virtual void BeginPaintmapsDataAllocation( int iPaintmapCount ) = 0;
|
||||
|
||||
virtual void AllocatePaintmapData( int iPaintmapID, int iCorrespondingLightMapWidth, int iCorrespondingLightMapHeight ) = 0;
|
||||
|
||||
virtual void DestroyPaintmapsData( void ) = 0; // clean up old Paintmaps data
|
||||
|
||||
virtual BYTE* GetPaintmapData( int paintmap ) = 0;
|
||||
|
||||
virtual void GetPaintmapSize( int paintmap, int& width, int& height ) = 0;
|
||||
|
||||
virtual void OnRestorePaintmaps() = 0;
|
||||
};
|
||||
|
||||
|
||||
//owned by materialsystem
|
||||
abstract_class IPaintmapTextureManager
|
||||
{
|
||||
public:
|
||||
virtual void BeginUpdatePaintmaps() = 0;
|
||||
virtual void UpdatePaintmap( int iPaintmapID, BYTE* pPaintData, int numRects, Rect_t* pRects ) = 0;
|
||||
virtual void EndUpdatePaintmaps() = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // IPaintmapMANIPULATOR_H
|
132
public/materialsystem/ishader_declarations.h
Normal file
132
public/materialsystem/ishader_declarations.h
Normal file
@ -0,0 +1,132 @@
|
||||
//===== Copyright <20> Valve Corporation, All rights reserved. ======//
|
||||
#ifndef ISHADER_DECLARATIONS_HDR
|
||||
#define ISHADER_DECLARATIONS_HDR
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Standard vertex shader constants
|
||||
//-----------------------------------------------------------------------------
|
||||
enum
|
||||
{
|
||||
// Standard vertex shader constants
|
||||
VERTEX_SHADER_MATH_CONSTANTS0 = 0,
|
||||
VERTEX_SHADER_MATH_CONSTANTS1 = 1,
|
||||
VERTEX_SHADER_CAMERA_POS = 2,
|
||||
VERTEX_SHADER_LIGHT_INDEX = 3,
|
||||
VERTEX_SHADER_MODELVIEWPROJ = 4,
|
||||
VERTEX_SHADER_VIEWPROJ = 8,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_12 = 12,
|
||||
VERTEX_SHADER_FLEXSCALE = 13,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_10 = 14,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_11 = 15,
|
||||
VERTEX_SHADER_FOG_PARAMS = 16,
|
||||
VERTEX_SHADER_VIEWMODEL = 17,
|
||||
VERTEX_SHADER_AMBIENT_LIGHT = 21,
|
||||
VERTEX_SHADER_LIGHTS = 27,
|
||||
VERTEX_SHADER_LIGHT0_POSITION = 29,
|
||||
VERTEX_SHADER_MODULATION_COLOR = 47,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_0 = 48,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_1 = 49,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_2 = 50,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_3 = 51,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_4 = 52,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_5 = 53,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_6 = 54,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_7 = 55,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_8 = 56,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_CONST_9 = 57,
|
||||
VERTEX_SHADER_MODEL = 58,
|
||||
//
|
||||
// We reserve up through 217 for the 53 bones supported on DX9
|
||||
//
|
||||
|
||||
VERTEX_SHADER_FLEX_WEIGHTS = 1024,
|
||||
VERTEX_SHADER_MAX_FLEX_WEIGHT_COUNT = 512,
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class IMaterialVar;
|
||||
class IShaderShadow;
|
||||
class IShaderDynamicAPI;
|
||||
class IShaderInit;
|
||||
class CBasePerMaterialContextData;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Shader flags
|
||||
//-----------------------------------------------------------------------------
|
||||
enum ShaderFlags_t
|
||||
{
|
||||
SHADER_NOT_EDITABLE = 0x1
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Shader parameter flags
|
||||
//-----------------------------------------------------------------------------
|
||||
enum ShaderParamFlags_t
|
||||
{
|
||||
SHADER_PARAM_NOT_EDITABLE = 0x1
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Information about each shader parameter
|
||||
//-----------------------------------------------------------------------------
|
||||
struct ShaderParamInfo_t
|
||||
{
|
||||
const char *m_pName;
|
||||
const char *m_pHelp;
|
||||
ShaderParamType_t m_Type;
|
||||
const char *m_pDefaultValue;
|
||||
int m_nFlags;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Standard vertex shader constants
|
||||
//-----------------------------------------------------------------------------
|
||||
enum
|
||||
{
|
||||
// Standard vertex shader constants
|
||||
VERTEX_SHADER_LIGHT_ENABLE_BOOL_CONST = 0,
|
||||
VERTEX_SHADER_LIGHT_ENABLE_BOOL_CONST_COUNT = 4,
|
||||
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_0 = 4,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_1 = 5,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_2 = 6,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_3 = 7,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_4 = 8,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_5 = 9,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_6 = 10,
|
||||
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_7 = 11,
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Shader dictionaries defined in DLLs
|
||||
//-----------------------------------------------------------------------------
|
||||
enum PrecompiledShaderType_t
|
||||
{
|
||||
PRECOMPILED_VERTEX_SHADER = 0,
|
||||
PRECOMPILED_PIXEL_SHADER,
|
||||
|
||||
PRECOMPILED_SHADER_TYPE_COUNT,
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Flags field of PrecompiledShader_t
|
||||
//-----------------------------------------------------------------------------
|
||||
enum
|
||||
{
|
||||
// runtime flags
|
||||
SHADER_IS_ASM = 0x1,
|
||||
SHADER_FAILED_LOAD = 0x2,
|
||||
};
|
||||
|
||||
|
||||
#endif
|
43
public/materialsystem/ishaderapi.h
Normal file
43
public/materialsystem/ishaderapi.h
Normal file
@ -0,0 +1,43 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose: NOTE: This file is for backward compat!
|
||||
// We'll get rid of it soon. Most of the contents of this file were moved
|
||||
// into shaderpi/ishadershadow.h, shaderapi/ishaderdynamic.h, or
|
||||
// shaderapi/shareddefs.h
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef ISHADERAPI_MS_H
|
||||
#define ISHADERAPI_MS_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <shaderapi/shareddefs.h>
|
||||
#include <shaderapi/ishadershadow.h>
|
||||
#include <shaderapi/ishaderdynamic.h>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class IMaterialVar;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Methods that can be called from the SHADER_INIT blocks of shaders
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IShaderInit
|
||||
{
|
||||
public:
|
||||
// Loads up a texture
|
||||
virtual void LoadTexture( IMaterialVar *pTextureVar, const char *pTextureGroupName, int nAdditionalCreationFlags = 0 ) = 0;
|
||||
virtual void LoadBumpMap( IMaterialVar *pTextureVar, const char *pTextureGroupName, int nAdditionalCreationFlags = 0 ) = 0;
|
||||
virtual void LoadCubeMap( IMaterialVar **ppParams, IMaterialVar *pTextureVar, int nAdditionalCreationFlags = 0 ) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // ISHADERAPI_MS_H
|
133
public/materialsystem/ishadersystem.h
Normal file
133
public/materialsystem/ishadersystem.h
Normal file
@ -0,0 +1,133 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Header: $
|
||||
// $NoKeywords: $
|
||||
// An interface that should not ever be accessed directly from shaders
|
||||
// but instead is visible only to shaderlib.
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef ISHADERSYSTEM_H
|
||||
#define ISHADERSYSTEM_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "interface.h"
|
||||
#include <materialsystem/IShader.h>
|
||||
#include <materialsystem/ishadersystem_declarations.h>
|
||||
#include "shaderlib/shadercombosemantics.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
enum Sampler_t;
|
||||
class ITexture;
|
||||
class IShader;
|
||||
struct ShaderComboSemantics_t;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The Shader system interface version
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADERSYSTEM_INTERFACE_VERSION "ShaderSystem002"
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The shader system (a singleton)
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IShaderSystem
|
||||
{
|
||||
public:
|
||||
virtual ShaderAPITextureHandle_t GetShaderAPITextureBindHandle( ITexture *pTexture, int nFrameVar, int nTextureChannel = 0 ) =0;
|
||||
|
||||
// Binds a texture
|
||||
virtual void BindTexture( Sampler_t sampler1, TextureBindFlags_t nBindFlags, ITexture *pTexture, int nFrameVar = 0 ) = 0;
|
||||
virtual void BindTexture( Sampler_t sampler1, Sampler_t sampler2, TextureBindFlags_t nBindFlags, ITexture *pTexture, int nFrameVar = 0 ) = 0;
|
||||
|
||||
// Takes a snapshot
|
||||
virtual void TakeSnapshot( ) = 0;
|
||||
|
||||
// Draws a snapshot
|
||||
virtual void DrawSnapshot( const unsigned char *pInstanceCommandBuffer, bool bMakeActualDrawCall = true ) = 0;
|
||||
|
||||
// Are we using graphics?
|
||||
virtual bool IsUsingGraphics() const = 0;
|
||||
|
||||
// Are editor materials enabled?
|
||||
virtual bool CanUseEditorMaterials() const = 0;
|
||||
|
||||
// Bind vertex texture
|
||||
virtual void BindVertexTexture( VertexTextureSampler_t vtSampler, ITexture *pTexture, int nFrameVar = 0 ) = 0;
|
||||
|
||||
virtual void AddShaderComboInformation( const ShaderComboSemantics_t *pSemantics ) = 0;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The Shader plug-in DLL interface version
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADER_DLL_INTERFACE_VERSION "ShaderDLL004"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The Shader interface versions
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IShaderDLLInternal
|
||||
{
|
||||
public:
|
||||
// Here's where the app systems get to learn about each other
|
||||
virtual bool Connect( CreateInterfaceFn factory, bool bIsMaterialSystem ) = 0;
|
||||
virtual void Disconnect( bool bIsMaterialSystem ) = 0;
|
||||
|
||||
// Returns the number of shaders defined in this DLL
|
||||
virtual int ShaderCount() const = 0;
|
||||
|
||||
// Returns information about each shader defined in this DLL
|
||||
virtual IShader *GetShader( int nShader ) = 0;
|
||||
|
||||
// Deals with all of the shader combo semantics from inc files.
|
||||
virtual int ShaderComboSemanticsCount() const = 0;
|
||||
virtual const ShaderComboSemantics_t *GetComboSemantics( int n ) = 0;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Singleton interface
|
||||
//-----------------------------------------------------------------------------
|
||||
IShaderDLLInternal *GetShaderDLLInternal();
|
||||
|
||||
|
||||
#ifdef _PS3
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PS3 non-virtual implementation proxy
|
||||
//
|
||||
// cat ishadersystem.h | nonvirtualscript.pl > shadersystem_ps3nonvirt.inl
|
||||
struct CPs3NonVirt_IShaderSystem
|
||||
{
|
||||
//NONVIRTUALSCRIPTBEGIN
|
||||
//NONVIRTUALSCRIPT/PROXY/CPs3NonVirt_IShaderSystem
|
||||
//NONVIRTUALSCRIPT/DELEGATE/s_ShaderSystem.CShaderSystem::
|
||||
|
||||
//
|
||||
// IShaderSystem
|
||||
//
|
||||
static ShaderAPITextureHandle_t GetShaderAPITextureBindHandle( ITexture *pTexture, int nFrameVar, int nTextureChannel = 0 );
|
||||
static void BindTexture( Sampler_t sampler1, TextureBindFlags_t nBindFlags, ITexture *pTexture, int nFrameVar = 0 );
|
||||
static void BindTexture( Sampler_t sampler1, Sampler_t sampler2, TextureBindFlags_t nBindFlags, ITexture *pTexture, int nFrameVar = 0 );
|
||||
static void TakeSnapshot();
|
||||
static void DrawSnapshot( const unsigned char *pInstanceCommandBuffer, bool bMakeActualDrawCall = true );
|
||||
static bool IsUsingGraphics();
|
||||
static bool CanUseEditorMaterials();
|
||||
static void BindVertexTexture( VertexTextureSampler_t vtSampler, ITexture *pTexture, int nFrameVar = 0 );
|
||||
|
||||
//NONVIRTUALSCRIPTEND
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif // ISHADERSYSTEM_H
|
28
public/materialsystem/ishadersystem_declarations.h
Normal file
28
public/materialsystem/ishadersystem_declarations.h
Normal file
@ -0,0 +1,28 @@
|
||||
//===== Copyright <20> Valve Corporation, All rights reserved. ======//
|
||||
|
||||
#ifndef ishadersystem_declarations_hdr
|
||||
#define ishadersystem_declarations_hdr
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
// Modulation flags
|
||||
//-----------------------------------------------------------------------------
|
||||
enum
|
||||
{
|
||||
SHADER_USING_ALPHA_MODULATION = 0x01,
|
||||
SHADER_USING_FLASHLIGHT = 0x02,
|
||||
SHADER_USING_PAINT = 0x04,
|
||||
SHADER_USING_EDITOR = 0x08,
|
||||
|
||||
// the BUFFER0 and GBUFFER1 bits provide 3 g-buffermodes plus the normal modes.
|
||||
// the modes are:
|
||||
// Normal rendering = ( gbuffer1 = 0, gbuffer0 = 0 )
|
||||
// Output pos, normal, albedo via mrts = (0,1)
|
||||
// output fixed lighted single image = (1,0)
|
||||
// output the normal = (1,1)
|
||||
SHADER_USING_GBUFFER0 = 0x10,
|
||||
SHADER_USING_GBUFFER1 = 0x20,
|
||||
};
|
||||
|
||||
#endif
|
176
public/materialsystem/itexture.h
Normal file
176
public/materialsystem/itexture.h
Normal file
@ -0,0 +1,176 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef ITEXTURE_H
|
||||
#define ITEXTURE_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "bitmap/imageformat.h" // ImageFormat defn.
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
|
||||
class IVTFTexture;
|
||||
class ITexture;
|
||||
struct Rect_t;
|
||||
|
||||
#ifdef _X360
|
||||
enum RTMultiSampleCount360_t
|
||||
{
|
||||
RT_MULTISAMPLE_NONE = 0,
|
||||
RT_MULTISAMPLE_2_SAMPLES = 2,
|
||||
RT_MULTISAMPLE_4_SAMPLES = 4,
|
||||
RT_MULTISAMPLE_MATCH_BACKBUFFER
|
||||
};
|
||||
#endif
|
||||
|
||||
struct AsyncTextureContext_t
|
||||
{
|
||||
ITexture *m_pTexture;
|
||||
|
||||
// snapshot at the point of async start
|
||||
// used to resolve disparity at moment of latent async arrival
|
||||
unsigned int m_nInternalFlags;
|
||||
int m_nDesiredTempDimensionLimit;
|
||||
int m_nActualDimensionLimit;
|
||||
|
||||
// Keeps track of the VTF texture in case the shader api texture gets
|
||||
// created the next frame. Generating the texture from the file can
|
||||
// then be split in multiple parts across frames.
|
||||
IVTFTexture *m_pVTFTexture;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This will get called on procedural textures to re-fill the textures
|
||||
// with the appropriate bit pattern. Calling Download() will also
|
||||
// cause this interface to be called. It will also be called upon
|
||||
// mode switch, or on other occasions where the bits are discarded.
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class ITextureRegenerator
|
||||
{
|
||||
public:
|
||||
// This will be called when the texture bits need to be regenerated.
|
||||
// Use the VTFTexture interface, which has been set up with the
|
||||
// appropriate texture size + format
|
||||
// The rect specifies which part of the texture needs to be updated
|
||||
// You can choose to update all of the bits if you prefer
|
||||
virtual void RegenerateTextureBits( ITexture *pTexture, IVTFTexture *pVTFTexture, Rect_t *pRect ) = 0;
|
||||
|
||||
// This will be called when the regenerator needs to be deleted
|
||||
// which will happen when the texture is destroyed
|
||||
virtual void Release() = 0;
|
||||
|
||||
virtual bool HasPreallocatedScratchTexture() const { return false; }
|
||||
virtual IVTFTexture *GetPreallocatedScratchTexture() { return NULL; }
|
||||
};
|
||||
|
||||
abstract_class ITexture
|
||||
{
|
||||
public:
|
||||
// Various texture polling methods
|
||||
virtual const char *GetName( void ) const = 0;
|
||||
virtual int GetMappingWidth() const = 0;
|
||||
virtual int GetMappingHeight() const = 0;
|
||||
virtual int GetActualWidth() const = 0;
|
||||
virtual int GetActualHeight() const = 0;
|
||||
virtual int GetNumAnimationFrames() const = 0;
|
||||
virtual bool IsTranslucent() const = 0;
|
||||
virtual bool IsMipmapped() const = 0;
|
||||
|
||||
virtual void GetLowResColorSample( float s, float t, float *color ) const = 0;
|
||||
|
||||
// Gets texture resource data of the specified type.
|
||||
// Params:
|
||||
// eDataType type of resource to retrieve.
|
||||
// pnumBytes on return is the number of bytes available in the read-only data buffer or is undefined
|
||||
// Returns:
|
||||
// pointer to the resource data, or NULL
|
||||
virtual void *GetResourceData( uint32 eDataType, size_t *pNumBytes ) const = 0;
|
||||
|
||||
// Methods associated with reference count
|
||||
virtual void IncrementReferenceCount( void ) = 0;
|
||||
virtual void DecrementReferenceCount( void ) = 0;
|
||||
|
||||
inline void AddRef() { IncrementReferenceCount(); }
|
||||
inline void Release() { DecrementReferenceCount(); }
|
||||
|
||||
// Used to modify the texture bits (procedural textures only)
|
||||
virtual void SetTextureRegenerator( ITextureRegenerator *pTextureRegen, bool releaseExisting = true ) = 0;
|
||||
|
||||
// Reconstruct the texture bits in HW memory
|
||||
|
||||
// If rect is not specified, reconstruct all bits, otherwise just
|
||||
// reconstruct a subrect.
|
||||
virtual void Download( Rect_t *pRect = 0, int nAdditionalCreationFlags = 0 ) = 0;
|
||||
|
||||
// Uses for stats. . .get the approximate size of the texture in it's current format.
|
||||
virtual int GetApproximateVidMemBytes( void ) const = 0;
|
||||
|
||||
// Returns true if the texture data couldn't be loaded.
|
||||
virtual bool IsError() const = 0;
|
||||
|
||||
// NOTE: Stuff after this is added after shipping HL2.
|
||||
|
||||
// For volume textures
|
||||
virtual bool IsVolumeTexture() const = 0;
|
||||
virtual int GetMappingDepth() const = 0;
|
||||
virtual int GetActualDepth() const = 0;
|
||||
|
||||
virtual ImageFormat GetImageFormat() const = 0;
|
||||
|
||||
// Various information about the texture
|
||||
virtual bool IsRenderTarget() const = 0;
|
||||
virtual bool IsCubeMap() const = 0;
|
||||
virtual bool IsNormalMap() const = 0;
|
||||
virtual bool IsProcedural() const = 0;
|
||||
virtual bool IsDefaultPool() const = 0;
|
||||
|
||||
virtual void DeleteIfUnreferenced() = 0;
|
||||
|
||||
#if defined( _X360 )
|
||||
virtual bool ClearTexture( int r, int g, int b, int a ) = 0;
|
||||
virtual bool CreateRenderTargetSurface( int width, int height, ImageFormat format, bool bSameAsTexture, RTMultiSampleCount360_t multiSampleCount = RT_MULTISAMPLE_NONE ) = 0;
|
||||
#endif
|
||||
|
||||
// swap everything except the name with another texture
|
||||
virtual void SwapContents( ITexture *pOther ) = 0;
|
||||
|
||||
// Retrieve the vtf flags mask
|
||||
virtual unsigned int GetFlags( void ) const = 0;
|
||||
|
||||
// Force LOD override (automatically downloads the texture)
|
||||
virtual void ForceLODOverride( int iNumLodsOverrideUpOrDown ) = 0;
|
||||
|
||||
// Force exclude override (automatically downloads the texture)
|
||||
virtual void ForceExcludeOverride( int iExcludeOverride ) = 0;
|
||||
|
||||
//swap out the active texture surface, only valid for MultiRenderTarget textures
|
||||
virtual void AddDownsizedSubTarget( const char *szName, int iDownsizePow2, MaterialRenderTargetDepth_t depth ) = 0;
|
||||
virtual void SetActiveSubTarget( const char *szName ) = 0; //NULL to return to base target
|
||||
|
||||
virtual int GetReferenceCount() const = 0;
|
||||
|
||||
virtual bool IsTempExcluded() const = 0;
|
||||
virtual bool CanBeTempExcluded() const = 0;
|
||||
|
||||
virtual bool FinishAsyncDownload( AsyncTextureContext_t *pContext, void *pData, int nNumReadBytes, bool bAbort, float flMaxTimeMs ) = 0;
|
||||
|
||||
virtual bool IsForceExcluded() const = 0;
|
||||
virtual bool ClearForceExclusion() = 0;
|
||||
};
|
||||
|
||||
|
||||
inline bool IsErrorTexture( ITexture *pTex )
|
||||
{
|
||||
return !pTex || pTex->IsError();
|
||||
}
|
||||
|
||||
|
||||
#endif // ITEXTURE_H
|
34
public/materialsystem/ivballoctracker.h
Normal file
34
public/materialsystem/ivballoctracker.h
Normal file
@ -0,0 +1,34 @@
|
||||
//===== Copyright <20> 1996-2007, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose: tracks VB allocations (and compressed/uncompressed vertex memory usage)
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef IVBALLOCTRACKER_H
|
||||
#define IVBALLOCTRACKER_H
|
||||
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
|
||||
// By default, only enable this alloc tracking for a debug shaderapidx*.dll
|
||||
// (it uses about 0.25MB to track ~7000 allocations)
|
||||
#if defined(_DEBUG)
|
||||
#define ENABLE_VB_ALLOC_TRACKER 1
|
||||
#else
|
||||
#define ENABLE_VB_ALLOC_TRACKER 0
|
||||
#endif
|
||||
|
||||
// This interface is actually exported by the shader API DLL.
|
||||
|
||||
// Interface to the VB mem alloc tracker
|
||||
abstract_class IVBAllocTracker
|
||||
{
|
||||
public:
|
||||
// This should be called wherever VertexBuffers are allocated
|
||||
virtual void CountVB( void * buffer, bool isDynamic, int bufferSize, int vertexSize, VertexFormat_t fmt ) = 0;
|
||||
// This should be called wherever VertexBuffers are freed
|
||||
virtual void UnCountVB( void * buffer ) = 0;
|
||||
// Track mesh allocations (set this before an allocation, clear it after)
|
||||
virtual bool TrackMeshAllocations( const char * allocatorName ) = 0;
|
||||
};
|
||||
|
||||
#endif // IVBALLOCTRACKER_H
|
50
public/materialsystem/ivisualsdataprocessor.h
Normal file
50
public/materialsystem/ivisualsdataprocessor.h
Normal file
@ -0,0 +1,50 @@
|
||||
//========= Copyright <20> 1996-2013, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef IVISUALSDATAPROCESSOR_H
|
||||
#define IVISUALSDATAPROCESSOR_H
|
||||
|
||||
#include "refcount.h"
|
||||
|
||||
class KeyValues;
|
||||
class CUtlBuffer;
|
||||
|
||||
//
|
||||
// Visuals Data Interface
|
||||
//
|
||||
// This abstracts the visuals data processing so that the main composite texture code
|
||||
// can be used for weapons, clothing, or whatever.
|
||||
// You need to implement one of these for use with CCompositeTexture.
|
||||
//
|
||||
|
||||
class IVisualsDataCompare
|
||||
{
|
||||
public:
|
||||
virtual void FillCompareBlob() = 0;
|
||||
virtual const CUtlBuffer &GetCompareBlob() const = 0;
|
||||
virtual bool Compare( const CUtlBuffer &pOther ) = 0;
|
||||
};
|
||||
|
||||
class IVisualsDataProcessor : public CRefCounted<>
|
||||
{
|
||||
public:
|
||||
IVisualsDataProcessor() {}
|
||||
|
||||
virtual KeyValues *GenerateCustomMaterialKeyValues() = 0;
|
||||
virtual KeyValues *GenerateCompositeMaterialKeyValues( int nMaterialParamId ) = 0;
|
||||
virtual IVisualsDataCompare *GetCompareObject() = 0;
|
||||
virtual bool HasCustomMaterial() const = 0;
|
||||
virtual const char* GetOriginalMaterialName() const = 0;
|
||||
virtual const char* GetOriginalMaterialBaseName() const = 0;
|
||||
virtual const char* GetPatternVTFName() const = 0;
|
||||
virtual void Refresh() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~IVisualsDataProcessor() {}
|
||||
};
|
||||
|
||||
#endif // IVISUALSDATAPROCESSOR_H
|
221
public/materialsystem/materialsystem_config.h
Normal file
221
public/materialsystem/materialsystem_config.h
Normal file
@ -0,0 +1,221 @@
|
||||
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef MATERIALSYSTEM_CONFIG_H
|
||||
#define MATERIALSYSTEM_CONFIG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if (!defined(_CERT)) && defined (_X360)
|
||||
#define X360_ALLOW_TIMESTAMPS 1 // Comment in to enable showfps 12 etc...
|
||||
#endif
|
||||
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
|
||||
#define MATERIALSYSTEM_CONFIG_VERSION "VMaterialSystemConfig004"
|
||||
|
||||
enum MaterialSystem_Config_Flags_t
|
||||
{
|
||||
MATSYS_VIDCFG_FLAGS_WINDOWED = ( 1 << 0 ),
|
||||
MATSYS_VIDCFG_FLAGS_RESIZING = ( 1 << 1 ),
|
||||
MATSYS_VIDCFG_FLAGS_NO_WAIT_FOR_VSYNC = ( 1 << 3 ),
|
||||
MATSYS_VIDCFG_FLAGS_STENCIL = ( 1 << 4 ),
|
||||
MATSYS_VIDCFG_FLAGS_DISABLE_SPECULAR = ( 1 << 7 ),
|
||||
MATSYS_VIDCFG_FLAGS_DISABLE_BUMPMAP = ( 1 << 8 ),
|
||||
MATSYS_VIDCFG_FLAGS_ENABLE_PARALLAX_MAPPING = ( 1 << 9 ),
|
||||
MATSYS_VIDCFG_FLAGS_USE_Z_PREFILL = ( 1 << 10 ),
|
||||
MATSYS_VIDCFG_FLAGS_ENABLE_HDR = ( 1 << 12 ),
|
||||
MATSYS_VIDCFG_FLAGS_LIMIT_WINDOWED_SIZE = ( 1 << 13 ),
|
||||
MATSYS_VIDCFG_FLAGS_SCALE_TO_OUTPUT_RESOLUTION = ( 1 << 14 ),
|
||||
MATSYS_VIDCFG_FLAGS_USING_MULTIPLE_WINDOWS = ( 1 << 15 ),
|
||||
MATSYS_VIDCFG_FLAGS_DISABLE_PHONG = ( 1 << 16 ),
|
||||
MATSYS_VIDCFG_FLAGS_NO_WINDOW_BORDER = ( 1 << 17 ),
|
||||
MATSYS_VIDCFG_FLAGS_DISABLE_DETAIL = ( 1 << 18 ),
|
||||
MATSYS_VIDCFG_FLAGS_UNSUPPORTED = ( 1 << 19 ),
|
||||
};
|
||||
|
||||
struct MaterialSystemHardwareIdentifier_t
|
||||
{
|
||||
char *m_pCardName;
|
||||
unsigned int m_nVendorID;
|
||||
unsigned int m_nDeviceID;
|
||||
};
|
||||
|
||||
struct MaterialSystem_Config_t
|
||||
{
|
||||
bool Windowed() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_WINDOWED ) != 0; }
|
||||
bool NoWindowBorder() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_NO_WINDOW_BORDER ) != 0; }
|
||||
bool Resizing() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_RESIZING ) != 0; }
|
||||
bool WaitForVSync() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_NO_WAIT_FOR_VSYNC ) == 0; }
|
||||
bool Stencil() const { return (m_Flags & MATSYS_VIDCFG_FLAGS_STENCIL ) != 0; }
|
||||
bool UseSpecular() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_DISABLE_SPECULAR ) == 0; }
|
||||
bool UseBumpmapping() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_DISABLE_BUMPMAP ) == 0; }
|
||||
bool UseDetailTexturing() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_DISABLE_DETAIL ) == 0; }
|
||||
bool UseParallaxMapping() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_ENABLE_PARALLAX_MAPPING ) != 0; }
|
||||
bool UseZPrefill() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_USE_Z_PREFILL ) != 0; }
|
||||
bool HDREnabled() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_ENABLE_HDR ) != 0; }
|
||||
bool LimitWindowedSize() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_LIMIT_WINDOWED_SIZE ) != 0; }
|
||||
bool ScaleToOutputResolution() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_SCALE_TO_OUTPUT_RESOLUTION ) != 0; }
|
||||
bool UsingMultipleWindows() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_USING_MULTIPLE_WINDOWS ) != 0; }
|
||||
bool ShadowDepthTexture() const { return m_bShadowDepthTexture; }
|
||||
bool MotionBlur() const { return m_bMotionBlur; }
|
||||
bool SupportFlashlight() const { return m_bSupportFlashlight; }
|
||||
bool UsePhong() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_DISABLE_PHONG ) == 0; }
|
||||
bool IsUnsupported() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_UNSUPPORTED ) != 0; }
|
||||
CSMQualityMode_t GetCSMQualityMode() const { return m_nCSMQuality; }
|
||||
|
||||
void SetFlag( unsigned int flag, bool val )
|
||||
{
|
||||
if( val )
|
||||
{
|
||||
m_Flags |= flag;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Flags &= ~flag;
|
||||
}
|
||||
}
|
||||
|
||||
// control panel stuff
|
||||
MaterialVideoMode_t m_VideoMode;
|
||||
float m_fMonitorGamma;
|
||||
float m_fGammaTVRangeMin;
|
||||
float m_fGammaTVRangeMax;
|
||||
float m_fGammaTVExponent;
|
||||
bool m_bGammaTVEnabled;
|
||||
|
||||
bool m_bWantTripleBuffered; // We only get triple buffering if fullscreen and vsync'd
|
||||
int m_nAASamples;
|
||||
int m_nForceAnisotropicLevel;
|
||||
int skipMipLevels;
|
||||
int dxSupportLevel;
|
||||
unsigned int m_Flags;
|
||||
bool bEditMode; // true if in Hammer.
|
||||
unsigned char proxiesTestMode; // 0 = normal, 1 = no proxies, 2 = alpha test all, 3 = color mod all
|
||||
bool bCompressedTextures;
|
||||
bool bFilterLightmaps;
|
||||
bool bFilterTextures;
|
||||
bool bReverseDepth;
|
||||
bool bBufferPrimitives;
|
||||
bool bDrawFlat;
|
||||
bool bMeasureFillRate;
|
||||
bool bVisualizeFillRate;
|
||||
bool bNoTransparency;
|
||||
bool bSoftwareLighting;
|
||||
bool bAllowCheats;
|
||||
char nShowMipLevels;
|
||||
bool bShowLowResImage;
|
||||
bool bShowNormalMap;
|
||||
bool bMipMapTextures;
|
||||
unsigned char nFullbright;
|
||||
bool m_bFastNoBump;
|
||||
bool m_bSuppressRendering;
|
||||
bool bDrawGray;
|
||||
|
||||
// debug modes
|
||||
bool bShowSpecular; // This is the fast version that doesn't require reloading materials
|
||||
bool bShowDiffuse; // This is the fast version that doesn't require reloading materials
|
||||
|
||||
uint m_WindowedSizeLimitWidth;
|
||||
uint m_WindowedSizeLimitHeight;
|
||||
int m_nAAQuality;
|
||||
bool m_bShadowDepthTexture;
|
||||
bool m_bMotionBlur;
|
||||
bool m_bSupportFlashlight;
|
||||
|
||||
// PAINT
|
||||
// True if the current mod supports paint at all (should be always true or always false in a game, and is practically only true in Portal2)
|
||||
bool m_bPaintInGame;
|
||||
// True if the current level supports paint (should be only true if m_bPaintInGame is true AND the currently loaded level supports paint)
|
||||
bool m_bPaintInMap;
|
||||
|
||||
CSMQualityMode_t m_nCSMQuality;
|
||||
bool m_bCSMAccurateBlending;
|
||||
|
||||
MaterialSystem_Config_t()
|
||||
{
|
||||
memset( this, 0, sizeof( *this ) );
|
||||
|
||||
// video config defaults
|
||||
SetFlag( MATSYS_VIDCFG_FLAGS_WINDOWED, false );
|
||||
SetFlag( MATSYS_VIDCFG_FLAGS_NO_WINDOW_BORDER, false );
|
||||
SetFlag( MATSYS_VIDCFG_FLAGS_RESIZING, false );
|
||||
SetFlag( MATSYS_VIDCFG_FLAGS_NO_WAIT_FOR_VSYNC, true );
|
||||
SetFlag( MATSYS_VIDCFG_FLAGS_STENCIL, false );
|
||||
SetFlag( MATSYS_VIDCFG_FLAGS_DISABLE_SPECULAR, false );
|
||||
SetFlag( MATSYS_VIDCFG_FLAGS_DISABLE_BUMPMAP, false );
|
||||
SetFlag( MATSYS_VIDCFG_FLAGS_DISABLE_DETAIL, false );
|
||||
SetFlag( MATSYS_VIDCFG_FLAGS_ENABLE_PARALLAX_MAPPING, true );
|
||||
SetFlag( MATSYS_VIDCFG_FLAGS_USE_Z_PREFILL, false );
|
||||
SetFlag( MATSYS_VIDCFG_FLAGS_LIMIT_WINDOWED_SIZE, false );
|
||||
SetFlag( MATSYS_VIDCFG_FLAGS_SCALE_TO_OUTPUT_RESOLUTION, false );
|
||||
SetFlag( MATSYS_VIDCFG_FLAGS_USING_MULTIPLE_WINDOWS, false );
|
||||
SetFlag( MATSYS_VIDCFG_FLAGS_UNSUPPORTED, false );
|
||||
|
||||
m_VideoMode.m_Width = 640;
|
||||
m_VideoMode.m_Height = 480;
|
||||
m_VideoMode.m_RefreshRate = 60;
|
||||
dxSupportLevel = 0;
|
||||
bCompressedTextures = true;
|
||||
bFilterTextures = true;
|
||||
bFilterLightmaps = true;
|
||||
bMipMapTextures = true;
|
||||
bBufferPrimitives = true;
|
||||
|
||||
m_fMonitorGamma = 2.2f;
|
||||
m_fGammaTVRangeMin = 16.0f;
|
||||
m_fGammaTVRangeMax = 255.0f;
|
||||
m_fGammaTVExponent = 2.5;
|
||||
m_bGammaTVEnabled = IsGameConsole();
|
||||
|
||||
m_bWantTripleBuffered = false;
|
||||
m_nAASamples = 1;
|
||||
m_bShadowDepthTexture = false;
|
||||
m_bMotionBlur = false;
|
||||
m_bSupportFlashlight = true;
|
||||
|
||||
// misc defaults
|
||||
bAllowCheats = false;
|
||||
bCompressedTextures = true;
|
||||
bEditMode = false;
|
||||
|
||||
// debug modes
|
||||
bShowSpecular = true;
|
||||
bShowDiffuse = true;
|
||||
nFullbright = 0;
|
||||
bShowNormalMap = false;
|
||||
bFilterLightmaps = true;
|
||||
bFilterTextures = true;
|
||||
bMipMapTextures = true;
|
||||
nShowMipLevels = 0;
|
||||
bShowLowResImage = false;
|
||||
bReverseDepth = false;
|
||||
bBufferPrimitives = true;
|
||||
bDrawFlat = false;
|
||||
bMeasureFillRate = false;
|
||||
bVisualizeFillRate = false;
|
||||
bSoftwareLighting = false;
|
||||
bNoTransparency = false;
|
||||
proxiesTestMode = 0;
|
||||
m_bFastNoBump = false;
|
||||
m_bSuppressRendering = false;
|
||||
m_WindowedSizeLimitWidth = 1280;
|
||||
m_WindowedSizeLimitHeight = 1024;
|
||||
bDrawGray = false;
|
||||
|
||||
// PAINT
|
||||
m_bPaintInGame = false;
|
||||
m_bPaintInMap = false;
|
||||
|
||||
m_nCSMQuality = CSMQUALITY_VERY_LOW;
|
||||
m_bCSMAccurateBlending = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // MATERIALSYSTEM_CONFIG_H
|
268
public/materialsystem/meshreader.h
Normal file
268
public/materialsystem/meshreader.h
Normal file
@ -0,0 +1,268 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#ifndef MESHREADER_H
|
||||
#define MESHREADER_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This is used to read vertex and index data out of already-created meshes.
|
||||
// xbox uses this a lot so it doesn't have to store sysmem backups of the
|
||||
// vertex data.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBaseMeshReader : protected MeshDesc_t
|
||||
{
|
||||
// Initialization.
|
||||
public:
|
||||
|
||||
CBaseMeshReader();
|
||||
~CBaseMeshReader();
|
||||
|
||||
// Use BeginRead/EndRead to initialize the mesh reader.
|
||||
void BeginRead(
|
||||
IMesh* pMesh,
|
||||
int firstVertex = 0,
|
||||
int numVertices = 0,
|
||||
int firstIndex = 0,
|
||||
int numIndices = 0 );
|
||||
|
||||
void EndRead();
|
||||
|
||||
// PC can use this if it stores its own copy of meshes around, in case
|
||||
// locking static buffers is too costly.
|
||||
void BeginRead_Direct( const MeshDesc_t &desc, int numVertices, int nIndices );
|
||||
|
||||
// Resets the mesh builder so it points to the start of everything again
|
||||
void Reset();
|
||||
|
||||
|
||||
protected:
|
||||
IMesh *m_pMesh;
|
||||
int m_MaxVertices;
|
||||
int m_MaxIndices;
|
||||
};
|
||||
|
||||
|
||||
// A bunch of accessors for the data that CBaseMeshReader sets up.
|
||||
class CMeshReader : public CBaseMeshReader
|
||||
{
|
||||
public:
|
||||
// Access to vertex data.
|
||||
public:
|
||||
int NumIndices() const;
|
||||
unsigned short Index( int index ) const;
|
||||
|
||||
const Vector& Position( int iVertex ) const;
|
||||
|
||||
unsigned int Color( int iVertex ) const;
|
||||
|
||||
const float *TexCoord( int iVertex, int stage ) const;
|
||||
void TexCoord2f( int iVertex, int stage, float &s, float &t ) const;
|
||||
const Vector2D& TexCoordVector2D( int iVertex, int stage ) const;
|
||||
|
||||
int NumBoneWeights() const;
|
||||
float Wrinkle( int iVertex ) const;
|
||||
|
||||
const Vector &Normal( int iVertex ) const;
|
||||
void Normal( int iVertex, Vector &vNormal ) const;
|
||||
|
||||
const Vector &TangentS( int iVertex ) const;
|
||||
const Vector &TangentT( int iVertex ) const;
|
||||
float BoneWeight( int iVertex ) const;
|
||||
|
||||
#ifdef NEW_SKINNING
|
||||
float* BoneMatrix( int iVertex ) const;
|
||||
#else
|
||||
unsigned char* BoneMatrix( int iVertex ) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CBaseMeshReader implementation.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
inline CBaseMeshReader::CBaseMeshReader()
|
||||
{
|
||||
m_pMesh = NULL;
|
||||
}
|
||||
|
||||
inline CBaseMeshReader::~CBaseMeshReader()
|
||||
{
|
||||
Assert( !m_pMesh );
|
||||
}
|
||||
|
||||
inline void CBaseMeshReader::BeginRead(
|
||||
IMesh* pMesh,
|
||||
int firstVertex,
|
||||
int numVertices,
|
||||
int firstIndex,
|
||||
int numIndices )
|
||||
{
|
||||
Assert( pMesh && (!m_pMesh) );
|
||||
|
||||
if ( numVertices < 0 )
|
||||
{
|
||||
numVertices = pMesh->VertexCount();
|
||||
}
|
||||
|
||||
if ( numIndices < 0 )
|
||||
{
|
||||
numIndices = pMesh->IndexCount();
|
||||
}
|
||||
|
||||
m_pMesh = pMesh;
|
||||
m_MaxVertices = numVertices;
|
||||
m_MaxIndices = numIndices;
|
||||
|
||||
// UNDONE: support reading from compressed VBs if needed
|
||||
VertexCompressionType_t compressionType = CompressionType( pMesh->GetVertexFormat() );
|
||||
Assert( compressionType == VERTEX_COMPRESSION_NONE );
|
||||
if ( compressionType != VERTEX_COMPRESSION_NONE )
|
||||
{
|
||||
Warning( "Cannot use CBaseMeshReader with compressed vertices! Will get junk data or a crash.\n" );
|
||||
}
|
||||
|
||||
// Locks mesh for modifying
|
||||
pMesh->ModifyBeginEx( true, firstVertex, numVertices, firstIndex, numIndices, *this );
|
||||
|
||||
// Point to the start of the buffers..
|
||||
Reset();
|
||||
}
|
||||
|
||||
inline void CBaseMeshReader::EndRead()
|
||||
{
|
||||
Assert( m_pMesh );
|
||||
m_pMesh->ModifyEnd( *this );
|
||||
m_pMesh = NULL;
|
||||
}
|
||||
|
||||
inline void CBaseMeshReader::BeginRead_Direct( const MeshDesc_t &desc, int nVertices, int nIndices )
|
||||
{
|
||||
MeshDesc_t *pThis = this;
|
||||
*pThis = desc;
|
||||
m_MaxVertices = nVertices;
|
||||
m_MaxIndices = nIndices;
|
||||
|
||||
// UNDONE: support reading from compressed verts if necessary
|
||||
Assert( desc.m_CompressionType == VERTEX_COMPRESSION_NONE );
|
||||
if ( desc.m_CompressionType != VERTEX_COMPRESSION_NONE )
|
||||
{
|
||||
Warning( "Cannot use CBaseMeshReader with compressed vertices!\n" );
|
||||
}
|
||||
}
|
||||
|
||||
inline void CBaseMeshReader::Reset()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------- //
|
||||
// CMeshReader implementation.
|
||||
// -------------------------------------------------------------------------------------- //
|
||||
|
||||
inline int CMeshReader::NumIndices() const
|
||||
{
|
||||
return m_MaxIndices;
|
||||
}
|
||||
|
||||
inline unsigned short CMeshReader::Index( int index ) const
|
||||
{
|
||||
Assert( (index >= 0) && (index < m_MaxIndices) );
|
||||
return m_pIndices[index * m_nIndexSize];
|
||||
}
|
||||
|
||||
inline const Vector& CMeshReader::Position( int iVertex ) const
|
||||
{
|
||||
Assert( iVertex >= 0 && iVertex < m_MaxVertices );
|
||||
return *(Vector*)((char*)m_pPosition + iVertex * m_VertexSize_Position);
|
||||
}
|
||||
|
||||
inline unsigned int CMeshReader::Color( int iVertex ) const
|
||||
{
|
||||
Assert( iVertex >= 0 && iVertex < m_MaxVertices );
|
||||
unsigned char *pColor = m_pColor + iVertex * m_VertexSize_Color;
|
||||
return (pColor[0] << 16) | (pColor[1] << 8) | (pColor[2]) | (pColor[3] << 24);
|
||||
}
|
||||
|
||||
inline const float *CMeshReader::TexCoord( int iVertex, int iStage ) const
|
||||
{
|
||||
Assert( iVertex >= 0 && iVertex < m_MaxVertices );
|
||||
return (float*)( (char*)m_pTexCoord[iStage] + iVertex * m_VertexSize_TexCoord[iStage] );
|
||||
}
|
||||
|
||||
inline void CMeshReader::TexCoord2f( int iVertex, int iStage, float &s, float &t ) const
|
||||
{
|
||||
Assert( iVertex >= 0 && iVertex < m_MaxVertices );
|
||||
float *p = (float*)( (char*)m_pTexCoord[iStage] + iVertex * m_VertexSize_TexCoord[iStage] );
|
||||
s = p[0];
|
||||
t = p[1];
|
||||
}
|
||||
|
||||
inline const Vector2D& CMeshReader::TexCoordVector2D( int iVertex, int iStage ) const
|
||||
{
|
||||
Assert( iVertex >= 0 && iVertex < m_MaxVertices );
|
||||
Vector2D *p = (Vector2D*)( (char*)m_pTexCoord[iStage] + iVertex * m_VertexSize_TexCoord[iStage] );
|
||||
return *p;
|
||||
}
|
||||
|
||||
inline float CMeshReader::Wrinkle( int iVertex ) const
|
||||
{
|
||||
Assert( iVertex >= 0 && iVertex < m_MaxVertices );
|
||||
return *(float*)( (char*)m_pWrinkle + iVertex * m_VertexSize_Wrinkle );
|
||||
}
|
||||
|
||||
inline int CMeshReader::NumBoneWeights() const
|
||||
{
|
||||
return m_NumBoneWeights;
|
||||
}
|
||||
|
||||
inline const Vector &CMeshReader::Normal( int iVertex ) const
|
||||
{
|
||||
Assert( iVertex >= 0 && iVertex < m_MaxVertices );
|
||||
return *(const Vector *)(const float*)( (char*)m_pNormal + iVertex * m_VertexSize_Normal );
|
||||
}
|
||||
|
||||
inline void CMeshReader::Normal( int iVertex, Vector &vNormal ) const
|
||||
{
|
||||
Assert( iVertex >= 0 && iVertex < m_MaxVertices );
|
||||
const float *p = (const float*)( (char*)m_pNormal + iVertex * m_VertexSize_Normal );
|
||||
vNormal.Init( p[0], p[1], p[2] );
|
||||
}
|
||||
|
||||
inline const Vector &CMeshReader::TangentS( int iVertex ) const
|
||||
{
|
||||
Assert( iVertex >= 0 && iVertex < m_MaxVertices );
|
||||
return *(const Vector*)( (char*)m_pTangentS + iVertex * m_VertexSize_TangentS );
|
||||
}
|
||||
|
||||
inline const Vector &CMeshReader::TangentT( int iVertex ) const
|
||||
{
|
||||
Assert( iVertex >= 0 && iVertex < m_MaxVertices );
|
||||
return *(const Vector*)( (char*)m_pTangentT + iVertex * m_VertexSize_TangentT );
|
||||
}
|
||||
|
||||
inline float CMeshReader::BoneWeight( int iVertex ) const
|
||||
{
|
||||
Assert( iVertex >= 0 && iVertex < m_MaxVertices );
|
||||
float *p = (float*)( (char*)m_pBoneWeight + iVertex * m_VertexSize_BoneWeight );
|
||||
return *p;
|
||||
}
|
||||
|
||||
#endif // MESHREADER_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
75
public/materialsystem/shader_vcs_version.h
Normal file
75
public/materialsystem/shader_vcs_version.h
Normal file
@ -0,0 +1,75 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SHADER_VCS_VERSION_H
|
||||
#define SHADER_VCS_VERSION_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// 1 = hl2 shipped
|
||||
// 2 = compressed with diffs version (lostcoast)
|
||||
// 3 = compressed with bzip
|
||||
// 4 = v2 + crc32
|
||||
// 5 = v3 + crc32
|
||||
// 6 = v5 + duplicate static combo records
|
||||
#define SHADER_VCS_VERSION_NUMBER 6
|
||||
|
||||
#define MAX_SHADER_UNPACKED_BLOCK_SIZE (1<<17)
|
||||
#define MAX_SHADER_PACKED_SIZE (1+MAX_SHADER_UNPACKED_BLOCK_SIZE)
|
||||
|
||||
#pragma pack(1)
|
||||
struct ShaderHeader_t
|
||||
{
|
||||
int32 m_nVersion;
|
||||
int32 m_nTotalCombos;
|
||||
int32 m_nDynamicCombos;
|
||||
uint32 m_nFlags;
|
||||
uint32 m_nCentroidMask;
|
||||
uint32 m_nNumStaticCombos; // includes sentinal key
|
||||
uint32 m_nSourceCRC32; // NOTE: If you move this, update copyshaders.pl, *_prep.pl, updateshaders.pl
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
#pragma pack(1)
|
||||
struct ShaderHeader_t_v4 // still used for assembly shaders
|
||||
{
|
||||
int32 m_nVersion;
|
||||
int32 m_nTotalCombos;
|
||||
int32 m_nDynamicCombos;
|
||||
uint32 m_nFlags;
|
||||
uint32 m_nCentroidMask;
|
||||
uint32 m_nDiffReferenceSize;
|
||||
uint32 m_nSourceCRC32; // NOTE: If you move this, update copyshaders.pl, *_prep.pl, updateshaders.pl
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
// for old format files
|
||||
struct ShaderDictionaryEntry_t
|
||||
{
|
||||
int m_Offset;
|
||||
int m_Size;
|
||||
};
|
||||
|
||||
// record for one static combo
|
||||
struct StaticComboRecord_t
|
||||
{
|
||||
uint32 m_nStaticComboID;
|
||||
uint32 m_nFileOffset;
|
||||
};
|
||||
|
||||
|
||||
struct StaticComboAliasRecord_t // for duplicate static combos
|
||||
{
|
||||
uint32 m_nStaticComboID; // this combo
|
||||
uint32 m_nSourceStaticCombo; // the combo it is the same as
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // SHADER_VCS_VERSION_H
|
||||
|
Reference in New Issue
Block a user