1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-09-19 12:06:07 +08:00

Added most recent version of unmodified HL2 SDK for Episode 1 engine

This commit is contained in:
Scott Ehlert
2008-09-15 01:00:17 -05:00
commit cb8fd25d1f
3052 changed files with 1217106 additions and 0 deletions

View File

@ -0,0 +1,129 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $Header: $
// $NoKeywords: $
// An interface that should not ever be accessed directly from shaders
// but instead is visible only to shaderlib.
//=============================================================================//
#ifndef ISHADERSYSTEM_H
#define ISHADERSYSTEM_H
#ifdef _WIN32
#pragma once
#endif
#include "interface.h"
#include <materialsystem/IShader.h>
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
enum TextureStage_t;
class ITexture;
class IShader;
//-----------------------------------------------------------------------------
// The Shader system interface version
//-----------------------------------------------------------------------------
#define SHADERSYSTEM_INTERFACE_VERSION "ShaderSystem002"
//-----------------------------------------------------------------------------
// Modulation flags
//-----------------------------------------------------------------------------
enum
{
SHADER_USING_COLOR_MODULATION = 0x1,
SHADER_USING_ALPHA_MODULATION = 0x2,
SHADER_USING_FLASHLIGHT = 0x4,
SHADER_USING_FIXED_FUNCTION_BAKED_LIGHTING = 0x8,
SHADER_USING_EDITOR = 0x10,
};
//-----------------------------------------------------------------------------
// The shader system (a singleton)
//-----------------------------------------------------------------------------
abstract_class IShaderSystem
{
public:
// Binds a texture
virtual void BindTexture( TextureStage_t stage, ITexture *pTexture, int nFrameVar = 0 ) = 0;
// Takes a snapshot
virtual void TakeSnapshot( ) = 0;
// Draws a snapshot
virtual void DrawSnapshot() = 0;
// Are we using graphics?
virtual bool IsUsingGraphics() const = 0;
// Are we using graphics?
virtual bool CanUseEditorMaterials() const = 0;
};
//-----------------------------------------------------------------------------
// The Shader plug-in DLL interface version
//-----------------------------------------------------------------------------
#define SHADER_DLL_INTERFACE_VERSION "ShaderDLL003"
//-----------------------------------------------------------------------------
// 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 ) = 0;
virtual void Disconnect() = 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;
};
//-----------------------------------------------------------------------------
// This is the version of IShaderDLLInternal at the time of ship
//-----------------------------------------------------------------------------
#define SHADER_DLL_INTERFACE_VERSION_2 "ShaderDLL002"
namespace ShaderV2
{
class IShader;
}
//-----------------------------------------------------------------------------
// The Shader interface versions
//-----------------------------------------------------------------------------
abstract_class IShaderDLLInternalV2
{
public:
// Here's where the app systems get to learn about each other
virtual bool Connect( CreateInterfaceFn factory ) = 0;
virtual void Disconnect() = 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 ShaderV2::IShader *GetShader( int nShader ) = 0;
};
//-----------------------------------------------------------------------------
// Singleton interface
//-----------------------------------------------------------------------------
IShaderDLLInternal *GetShaderDLLInternal();
#endif // ISHADERSYSTEM_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,150 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $Header: $
// $NoKeywords: $
//=============================================================================//
#include "shaderlib/ShaderDLL.h"
#include "materialsystem/IShader.h"
#include "utlvector.h"
#include "tier0/dbg.h"
#include "materialsystem/imaterialsystemhardwareconfig.h"
#include "materialsystem/materialsystem_config.h"
#include "IShaderSystem.h"
#include "materialsystem/ishaderapi.h"
#include "shaderlib_cvar.h"
#include "mathlib.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
//-----------------------------------------------------------------------------
// The standard implementation of CShaderDLL
//-----------------------------------------------------------------------------
class CShaderDLL : public IShaderDLLInternal, public IShaderDLL
{
public:
CShaderDLL();
// methods of IShaderDLL
virtual bool Connect( CreateInterfaceFn factory );
virtual void Disconnect();
virtual int ShaderCount() const;
virtual IShader *GetShader( int nShader );
// methods of IShaderDLLInternal
virtual void InsertShader( IShader *pShader );
private:
CUtlVector< IShader * > m_ShaderList;
};
//-----------------------------------------------------------------------------
// Global interfaces/structures
//-----------------------------------------------------------------------------
IMaterialSystemHardwareConfig* g_pHardwareConfig;
const MaterialSystem_Config_t *g_pConfig;
//-----------------------------------------------------------------------------
// Interfaces/structures local to shaderlib
//-----------------------------------------------------------------------------
IShaderSystem* g_pSLShaderSystem;
// Pattern necessary because shaders register themselves in global constructors
static CShaderDLL *s_pShaderDLL;
//-----------------------------------------------------------------------------
// Global accessor
//-----------------------------------------------------------------------------
IShaderDLL *GetShaderDLL()
{
// Pattern necessary because shaders register themselves in global constructors
if ( !s_pShaderDLL )
{
s_pShaderDLL = new CShaderDLL;
}
return s_pShaderDLL;
}
IShaderDLLInternal *GetShaderDLLInternal()
{
// Pattern necessary because shaders register themselves in global constructors
if ( !s_pShaderDLL )
{
s_pShaderDLL = new CShaderDLL;
}
return static_cast<IShaderDLLInternal*>( s_pShaderDLL );
}
//-----------------------------------------------------------------------------
// Singleton interface
//-----------------------------------------------------------------------------
#ifndef _XBOX
EXPOSE_INTERFACE_FN( (InstantiateInterfaceFn)GetShaderDLLInternal, IShaderDLLInternal, SHADER_DLL_INTERFACE_VERSION );
#endif
//-----------------------------------------------------------------------------
// Connect, disconnect...
//-----------------------------------------------------------------------------
CShaderDLL::CShaderDLL()
{
MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f );
}
//-----------------------------------------------------------------------------
// Connect, disconnect...
//-----------------------------------------------------------------------------
bool CShaderDLL::Connect( CreateInterfaceFn factory )
{
g_pHardwareConfig = (IMaterialSystemHardwareConfig*)factory( MATERIALSYSTEM_HARDWARECONFIG_INTERFACE_VERSION, NULL );
g_pConfig = (const MaterialSystem_Config_t*)factory( MATERIALSYSTEM_CONFIG_VERSION, NULL );
g_pSLShaderSystem = (IShaderSystem*)factory( SHADERSYSTEM_INTERFACE_VERSION, NULL );
InitShaderLibCVars( factory );
return ( g_pConfig != NULL ) && (g_pHardwareConfig != NULL) && ( g_pSLShaderSystem != NULL );
}
void CShaderDLL::Disconnect()
{
g_pHardwareConfig = NULL;
g_pConfig = NULL;
g_pSLShaderSystem = NULL;
}
//-----------------------------------------------------------------------------
// Iterates over all shaders
//-----------------------------------------------------------------------------
int CShaderDLL::ShaderCount() const
{
return m_ShaderList.Count();
}
IShader *CShaderDLL::GetShader( int nShader )
{
if ( ( nShader < 0 ) || ( nShader >= m_ShaderList.Count() ) )
return NULL;
return m_ShaderList[nShader];
}
//-----------------------------------------------------------------------------
// Adds to the shader lists
//-----------------------------------------------------------------------------
void CShaderDLL::InsertShader( IShader *pShader )
{
Assert( pShader );
m_ShaderList.AddToTail( pShader );
}

View File

@ -0,0 +1,33 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $Header: $
// $NoKeywords: $
//=============================================================================//
#ifndef SHADERDLL_GLOBAL_H
#define SHADERDLL_GLOBAL_H
#ifdef _WIN32
#pragma once
#endif
//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
class IShaderSystem;
//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
inline IShaderSystem *GetShaderSystem()
{
extern IShaderSystem* g_pSLShaderSystem;
return g_pSLShaderSystem;
}
#endif // SHADERDLL_GLOBAL_H

View File

@ -0,0 +1,269 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="shaderlib"
ProjectGUID="{524F280F-2300-4B72-A6EB-6EF08C0DE615}"
SccProjectName=""
SccAuxPath=""
SccLocalPath=""
SccProvider="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="TRUE"
ImproveFloatingPointConsistency="FALSE"
FavorSizeOrSpeed="1"
OptimizeForProcessor="3"
AdditionalIncludeDirectories="./,../,../../public,../../public/tier1"
PreprocessorDefinitions="NDEBUG;_WINDOWS;fopen=dont_use_fopen;_WIN32"
StringPooling="TRUE"
ExceptionHandling="FALSE"
RuntimeLibrary="0"
BufferSecurityCheck="FALSE"
EnableFunctionLevelLinking="TRUE"
PrecompiledHeaderFile=".\Release/shaderlib.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="4"
SuppressStartupBanner="TRUE"
DebugInformationFormat="0"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\lib-vc7\public\shaderlib.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"
CommandLine="if exist ..\..\lib-vc7\public\shaderlib.lib attrib -r ..\..\lib-vc7\public\shaderlib.lib"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
ImproveFloatingPointConsistency="TRUE"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="./,../,../../public,../../public/tier1"
PreprocessorDefinitions="_DEBUG;_WINDOWS;fopen=dont_use_fopen;_WIN32"
ExceptionHandling="FALSE"
BasicRuntimeChecks="0"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug/shaderlib.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
BrowseInformation="1"
WarningLevel="4"
SuppressStartupBanner="TRUE"
DebugInformationFormat="1"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\lib-vc7\public\shaderlib.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"
CommandLine="if exist ..\..\lib-vc7\public\shaderlib.lib attrib -r ..\..\lib-vc7\public\shaderlib.lib"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="BaseShader.cpp">
</File>
<File
RelativePath="ShaderDLL.cpp">
</File>
<File
RelativePath="shaderDLL_Global.h">
</File>
<File
RelativePath="shaderlib_cvar.cpp">
</File>
<File
RelativePath="shaderlib_cvar.h">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="..\..\public\shaderlib\BaseShader.h">
</File>
<File
RelativePath="..\..\Public\tier0\basetypes.h">
</File>
<File
RelativePath="..\..\Public\commonmacros.h">
</File>
<File
RelativePath="..\..\public\shaderlib\cshader.h">
</File>
<File
RelativePath="..\..\public\tier0\dbg.h">
</File>
<File
RelativePath="..\..\public\tier0\fasttimer.h">
</File>
<File
RelativePath="..\..\public\appframework\IAppSystem.h">
</File>
<File
RelativePath="..\..\public\vstdlib\ICommandLine.h">
</File>
<File
RelativePath="..\..\Public\icvar.h">
</File>
<File
RelativePath="..\..\Public\ImageLoader.h">
</File>
<File
RelativePath="..\..\public\materialsystem\imaterial.h">
</File>
<File
RelativePath="..\..\public\materialsystem\imaterialsystem.h">
</File>
<File
RelativePath="..\..\public\materialsystem\imaterialsystemhardwareconfig.h">
</File>
<File
RelativePath="..\..\public\materialsystem\imaterialvar.h">
</File>
<File
RelativePath="..\..\public\materialsystem\imesh.h">
</File>
<File
RelativePath="..\..\public\materialsystem\IShader.h">
</File>
<File
RelativePath="..\..\public\materialsystem\ishaderapi.h">
</File>
<File
RelativePath="..\IShaderSystem.h">
</File>
<File
RelativePath="..\..\public\materialsystem\itexture.h">
</File>
<File
RelativePath="..\..\public\materialsystem\materialsystem_config.h">
</File>
<File
RelativePath="..\..\Public\MATHLIB.H">
</File>
<File
RelativePath="..\..\public\tier0\memdbgoff.h">
</File>
<File
RelativePath="..\..\public\tier0\memdbgon.h">
</File>
<File
RelativePath="..\..\public\tier0\platform.h">
</File>
<File
RelativePath="..\..\public\protected_things.h">
</File>
<File
RelativePath="..\..\public\shaderlib\ShaderDLL.h">
</File>
<File
RelativePath="..\..\public\string_t.h">
</File>
<File
RelativePath="..\..\public\vstdlib\strtools.h">
</File>
<File
RelativePath="..\..\public\tier1\utlmemory.h">
</File>
<File
RelativePath="..\..\public\tier1\utlvector.h">
</File>
<File
RelativePath="..\..\Public\vector.h">
</File>
<File
RelativePath="..\..\Public\vector2d.h">
</File>
<File
RelativePath="..\..\Public\vector4d.h">
</File>
<File
RelativePath="..\..\Public\vmatrix.h">
</File>
<File
RelativePath="..\..\Public\vplane.h">
</File>
<File
RelativePath="..\..\public\vstdlib\vstdlib.h">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,353 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="shaderlib-2005"
ProjectGUID="{524F280F-2300-4B72-A6EB-6EF08C0DE615}"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="./,../,../../public,../../public/tier1"
PreprocessorDefinitions="NDEBUG;_WINDOWS;fopen=dont_use_fopen;_WIN32"
StringPooling="true"
ExceptionHandling="0"
RuntimeLibrary="0"
BufferSecurityCheck="false"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Release/shaderlib.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="4"
SuppressStartupBanner="true"
DebugInformationFormat="0"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
CommandLine="if exist ..\..\lib\public\shaderlib.lib attrib -r ..\..\lib\public\shaderlib.lib"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\lib\public\shaderlib.lib"
SuppressStartupBanner="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="./,../,../../public,../../public/tier1"
PreprocessorDefinitions="_DEBUG;_WINDOWS;fopen=dont_use_fopen;_WIN32"
ExceptionHandling="0"
BasicRuntimeChecks="0"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug/shaderlib.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
BrowseInformation="1"
WarningLevel="4"
SuppressStartupBanner="true"
DebugInformationFormat="1"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
CommandLine="if exist ..\..\lib\public\shaderlib.lib attrib -r ..\..\lib\public\shaderlib.lib"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\lib\public\shaderlib.lib"
SuppressStartupBanner="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="BaseShader.cpp"
>
</File>
<File
RelativePath="ShaderDLL.cpp"
>
</File>
<File
RelativePath="shaderDLL_Global.h"
>
</File>
<File
RelativePath="shaderlib_cvar.cpp"
>
</File>
<File
RelativePath="shaderlib_cvar.h"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
<File
RelativePath="..\..\public\shaderlib\BaseShader.h"
>
</File>
<File
RelativePath="..\..\Public\tier0\basetypes.h"
>
</File>
<File
RelativePath="..\..\Public\commonmacros.h"
>
</File>
<File
RelativePath="..\..\public\shaderlib\cshader.h"
>
</File>
<File
RelativePath="..\..\public\tier0\dbg.h"
>
</File>
<File
RelativePath="..\..\public\tier0\fasttimer.h"
>
</File>
<File
RelativePath="..\..\public\appframework\IAppSystem.h"
>
</File>
<File
RelativePath="..\..\public\vstdlib\ICommandLine.h"
>
</File>
<File
RelativePath="..\..\Public\icvar.h"
>
</File>
<File
RelativePath="..\..\Public\ImageLoader.h"
>
</File>
<File
RelativePath="..\..\public\materialsystem\imaterial.h"
>
</File>
<File
RelativePath="..\..\public\materialsystem\imaterialsystem.h"
>
</File>
<File
RelativePath="..\..\public\materialsystem\imaterialsystemhardwareconfig.h"
>
</File>
<File
RelativePath="..\..\public\materialsystem\imaterialvar.h"
>
</File>
<File
RelativePath="..\..\public\materialsystem\imesh.h"
>
</File>
<File
RelativePath="..\..\public\materialsystem\IShader.h"
>
</File>
<File
RelativePath="..\..\public\materialsystem\ishaderapi.h"
>
</File>
<File
RelativePath="..\IShaderSystem.h"
>
</File>
<File
RelativePath="..\..\public\materialsystem\itexture.h"
>
</File>
<File
RelativePath="..\..\public\materialsystem\materialsystem_config.h"
>
</File>
<File
RelativePath="..\..\Public\MATHLIB.H"
>
</File>
<File
RelativePath="..\..\public\tier0\memdbgoff.h"
>
</File>
<File
RelativePath="..\..\public\tier0\memdbgon.h"
>
</File>
<File
RelativePath="..\..\public\tier0\platform.h"
>
</File>
<File
RelativePath="..\..\public\protected_things.h"
>
</File>
<File
RelativePath="..\..\public\shaderlib\ShaderDLL.h"
>
</File>
<File
RelativePath="..\..\public\string_t.h"
>
</File>
<File
RelativePath="..\..\public\vstdlib\strtools.h"
>
</File>
<File
RelativePath="..\..\public\tier1\utlmemory.h"
>
</File>
<File
RelativePath="..\..\public\tier1\utlvector.h"
>
</File>
<File
RelativePath="..\..\Public\vector.h"
>
</File>
<File
RelativePath="..\..\Public\vector2d.h"
>
</File>
<File
RelativePath="..\..\Public\vector4d.h"
>
</File>
<File
RelativePath="..\..\Public\vmatrix.h"
>
</File>
<File
RelativePath="..\..\Public\vplane.h"
>
</File>
<File
RelativePath="..\..\public\vstdlib\vstdlib.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,56 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "icvar.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
// ------------------------------------------------------------------------------------------- //
// ConVar stuff.
// ------------------------------------------------------------------------------------------- //
static ICvar *s_pCVar;
class CShaderLibConVarAccessor : public IConCommandBaseAccessor
{
public:
virtual bool RegisterConCommandBase( ConCommandBase *pCommand )
{
// Mark for easy removal
pCommand->AddFlags( FCVAR_MATERIAL_SYSTEM );
// Unlink from shaderlib only list
pCommand->SetNext( 0 );
// Link to engine's list instead
s_pCVar->RegisterConCommandBase( pCommand );
char const *pValue = s_pCVar->GetCommandLineValue( pCommand->GetName() );
if( pValue && !pCommand->IsCommand() )
{
( ( ConVar * )pCommand )->SetValue( pValue );
}
return true;
}
};
CShaderLibConVarAccessor g_ConVarAccessor;
void InitShaderLibCVars( CreateInterfaceFn cvarFactory )
{
s_pCVar = (ICvar*)cvarFactory( VENGINE_CVAR_INTERFACE_VERSION, NULL );
if ( s_pCVar )
{
ConCommandBaseMgr::OneTimeInit( &g_ConVarAccessor );
}
}
ICvar *GetCVar()
{
return s_pCVar;
}

View File

@ -0,0 +1,20 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#ifndef SHADERLIB_CVAR_H
#define SHADERLIB_CVAR_H
#ifdef _WIN32
#pragma once
#endif
#include "interface.h"
void InitShaderLibCVars( CreateInterfaceFn cvarFactory );
#endif // SHADERLIB_CVAR_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,310 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
// This is what all vs/ps (dx8+) shaders inherit from.
//=============================================================================//
#ifndef BASEVSSHADER_H
#define BASEVSSHADER_H
#ifdef _WIN32
#pragma once
#endif
#include "shaderlib/cshader.h"
#include "shaderlib/baseshader.h"
#include <renderparm.h>
//-----------------------------------------------------------------------------
// Standard vertex shader constants used by shaders in the std shader DLLs
//-----------------------------------------------------------------------------
enum
{
VERTEX_SHADER_MODULATION_COLOR = 37,
};
//-----------------------------------------------------------------------------
// Helper macro for vertex shaders
//-----------------------------------------------------------------------------
#define BEGIN_VS_SHADER_FLAGS(_name, _help, _flags) __BEGIN_SHADER_INTERNAL( CBaseVSShader, _name, _help, _flags )
#define BEGIN_VS_SHADER(_name,_help) __BEGIN_SHADER_INTERNAL( CBaseVSShader, _name, _help, 0 )
// GR - indication of alpha usage
enum BlendType_t
{
// no alpha blending
BT_NONE = 0,
// src * srcAlpha + dst * (1-srcAlpha)
// two passes for HDR:
// pass 1:
// color: src * srcAlpha + dst * (1-srcAlpha)
// alpha: srcAlpha * zero + dstAlpha * (1-srcAlpha)
// pass 2:
// color: none
// alpha: srcAlpha * one + dstAlpha * one
//
BT_BLEND,
// src * one + dst * one
// one pass for HDR
BT_ADD,
// Why do we ever use this instead of using premultiplied alpha?
// src * srcAlpha + dst * one
// two passes for HDR
// pass 1:
// color: src * srcAlpha + dst * one
// alpha: srcAlpha * one + dstAlpha * one
// pass 2:
// color: none
// alpha: srcAlpha * one + dstAlpha * one
BT_BLENDADD
};
//-----------------------------------------------------------------------------
// Base class for shaders, contains helper methods.
//-----------------------------------------------------------------------------
class CBaseVSShader : public CBaseShader
{
public:
// Loads bump lightmap coordinates into the pixel shader
void LoadBumpLightmapCoordinateAxes_PixelShader( int pixelReg );
// Loads bump lightmap coordinates into the vertex shader
void LoadBumpLightmapCoordinateAxes_VertexShader( int vertexReg );
// Pixel and vertex shader constants....
void SetPixelShaderConstant( int pixelReg, int constantVar );
// Pixel and vertex shader constants....
void SetPixelShaderConstantGammaToLinear( int pixelReg, int constantVar );
// This version will put constantVar into x,y,z, and constantVar2 into the w
void SetPixelShaderConstant( int pixelReg, int constantVar, int constantVar2 );
void SetPixelShaderConstantGammaToLinear( int pixelReg, int constantVar, int constantVar2 );
// Helpers for setting constants that need to be converted to linear space (from gamma space).
void SetVertexShaderConstantGammaToLinear( int var, float const* pVec, int numConst = 1, bool bForce = false );
void SetPixelShaderConstantGammaToLinear( int var, float const* pVec, int numConst = 1, bool bForce = false );
void SetVertexShaderConstant( int vertexReg, int constantVar );
// GR - fix for const/lerp issues
void SetPixelShaderConstantFudge( int pixelReg, int constantVar );
// Sets light direction for pixel shaders.
void SetPixelShaderLightColors( int pixelReg );
// Sets vertex shader texture transforms
void SetVertexShaderTextureTranslation( int vertexReg, int translationVar );
void SetVertexShaderTextureScale( int vertexReg, int scaleVar );
void SetVertexShaderTextureTransform( int vertexReg, int transformVar );
void SetVertexShaderTextureScaledTransform( int vertexReg,
int transformVar, int scaleVar );
// Set pixel shader texture transforms
void SetPixelShaderTextureTranslation( int pixelReg, int translationVar );
void SetPixelShaderTextureScale( int pixelReg, int scaleVar );
void SetPixelShaderTextureTransform( int pixelReg, int transformVar );
void SetPixelShaderTextureScaledTransform( int pixelReg,
int transformVar, int scaleVar );
// Moves a matrix into vertex shader constants
void SetVertexShaderMatrix3x4( int vertexReg, int matrixVar );
void SetVertexShaderMatrix4x4( int vertexReg, int matrixVar );
// Loads the view matrix into pixel shader constants
void LoadViewMatrixIntoVertexShaderConstant( int vertexReg );
// Sets up ambient light cube...
void SetAmbientCubeDynamicStateVertexShader( );
float GetAmbientLightCubeLuminance( );
// Helpers for dealing with envmaptint
void SetEnvMapTintPixelShaderDynamicState( int pixelReg, int tintVar, int alphaVar, bool bConvertFromGammaToLinear = false );
// Helper methods for pixel shader overbrighting
void EnablePixelShaderOverbright( int reg, bool bEnable, bool bDivideByTwo );
// Helper for dealing with modulation
void SetModulationVertexShaderDynamicState();
void SetModulationPixelShaderDynamicState( int modulationVar );
void SetModulationPixelShaderDynamicState_LinearColorSpace( int modulationVar );
void SetModulationPixelShaderDynamicState_LinearColorSpace_LinearScale( int modulationVar, float flScale );
// Sets a color + alpha into shader constants
void SetColorVertexShaderConstant( int nVertexReg, int colorVar, int alphaVar );
void SetColorPixelShaderConstant( int nPixelReg, int colorVar, int alphaVar );
//
// Standard shader passes!
//
void InitParamsUnlitGeneric_DX8(
int baseTextureVar,
int detailScaleVar,
int envmapOptionalVar,
int envmapVar,
int envmapTintVar,
int envmapMaskScaleVar );
void InitUnlitGeneric_DX8(
int baseTextureVar,
int detailVar,
int envmapVar,
int envmapMaskVar );
// Dx8 Unlit Generic pass
void VertexShaderUnlitGenericPass( bool doSkin, int baseTextureVar, int frameVar,
int baseTextureTransformVar, int detailVar, int detailTransform, bool bDetailTransformIsScale,
int envmapVar, int envMapFrameVar, int envmapMaskVar, int envmapMaskFrameVar,
int envmapMaskScaleVar, int envmapTintVar, int alphaTestReferenceVar ) ;
// Helpers for drawing world bump mapped stuff.
void DrawModelBumpedSpecularLighting( int bumpMapVar, int bumpMapFrameVar,
int envMapVar, int envMapVarFrame,
int envMapTintVar, int alphaVar,
int envMapContrastVar, int envMapSaturationVar,
int bumpTransformVar,
bool bBlendSpecular, bool bNoWriteZ = false );
void DrawWorldBumpedSpecularLighting( int bumpmapVar, int envmapVar,
int bumpFrameVar, int envmapFrameVar,
int envmapTintVar, int alphaVar,
int envmapContrastVar, int envmapSaturationVar,
int bumpTransformVar, int fresnelReflectionVar,
bool bBlend, bool bNoWriteZ = false );
const char *UnlitGeneric_ComputeVertexShaderName( bool bMask,
bool bEnvmap,
bool bBaseTexture,
bool bBaseAlphaEnvmapMask,
bool bDetail,
bool bVertexColor,
bool bEnvmapCameraSpace,
bool bEnvmapSphere );
const char *UnlitGeneric_ComputePixelShaderName( bool bMask,
bool bEnvmap,
bool bBaseTexture,
bool bBaseAlphaEnvmapMask,
bool bDetail );
void DrawWorldBaseTexture( int baseTextureVar, int baseTextureTransformVar, int frameVar, int colorVar, int alphaVar );
void DrawWorldBumpedDiffuseLighting( int bumpmapVar, int bumpFrameVar,
int bumpTransformVar, bool bMultiply );
void DrawWorldBumpedSpecularLighting( int envmapMaskVar, int envmapMaskFrame,
int bumpmapVar, int envmapVar,
int bumpFrameVar, int envmapFrameVar,
int envmapTintVar, int alphaVar,
int envmapContrastVar, int envmapSaturationVar,
int bumpTransformVar, int fresnelReflectionVar,
bool bBlend );
void DrawBaseTextureBlend( int baseTextureVar, int baseTextureTransformVar,
int baseTextureFrameVar,
int baseTexture2Var, int baseTextureTransform2Var,
int baseTextureFrame2Var, int colorVar, int alphaVar );
void DrawWorldBumpedDiffuseLighting_Base_ps14( int bumpmapVar, int bumpFrameVar,
int bumpTransformVar, int baseTextureVar, int baseTextureTransformVar, int frameVar );
void DrawWorldBumpedDiffuseLighting_Blend_ps14( int bumpmapVar, int bumpFrameVar, int bumpTransformVar,
int baseTextureVar, int baseTextureTransformVar, int baseTextureFrameVar,
int baseTexture2Var, int baseTextureTransform2Var, int baseTextureFrame2Var);
void DrawWorldBumpedUsingVertexShader( int baseTextureVar, int baseTextureTransformVar,
int bumpmapVar, int bumpFrameVar,
int bumpTransformVar,
int envmapMaskVar, int envmapMaskFrame,
int envmapVar,
int envmapFrameVar,
int envmapTintVar, int colorVar, int alphaVar,
int envmapContrastVar, int envmapSaturationVar, int frameVar, int fresnelReflectionVar,
bool doBaseTexture2 = false,
int baseTexture2Var = -1, int baseTextureTransform2Var = -1,
int baseTextureFrame2Var = -1
);
// Computes the shader index for vertex lit materials
int ComputeVertexLitShaderIndex( bool bVertexLitGeneric, bool hasBump, bool hasEnvmap, bool hasVertexColor, bool bHasNormal ) const;
BlendType_t EvaluateBlendRequirements( int textureVar, bool isBaseTexture );
// Helper for setting up flashlight constants
void SetFlashlightVertexShaderConstants( bool bBump, int bumpTransformVar, bool bSetTextureTransforms );
void DrawFlashlight_dx80( IMaterialVar** params, IShaderDynamicAPI *pShaderAPI, IShaderShadow* pShaderShadow,
bool bBump, int bumpmapVar, int bumpmapFrame, int bumpTransform, int flashlightTextureVar,
int flashlightTextureFrameVar, bool bLightmappedGeneric, bool bWorldVertexTransition,
int nWorldVertexTransitionPassID, int baseTexture2Var, int baseTexture2FrameVar,
bool bTeeth=false, int nTeethForwardVar=0, int nTeethIllumFactorVar=0 );
struct DrawFlashlight_dx90_Vars_t
{
DrawFlashlight_dx90_Vars_t()
{
// set all ints to -1
memset( this, 0xFF, sizeof(DrawFlashlight_dx90_Vars_t) );
// set all bools to a default value.
m_bBump = false;
m_bLightmappedGeneric = false;
m_bWorldVertexTransition = false;
m_bTeeth = false;
}
bool m_bBump;
bool m_bLightmappedGeneric;
bool m_bWorldVertexTransition;
bool m_bTeeth;
int m_nBumpmapVar;
int m_nBumpmapFrame;
int m_nBumpTransform;
int m_nFlashlightTextureVar;
int m_nFlashlightTextureFrameVar;
int m_nBaseTexture2Var;
int m_nBaseTexture2FrameVar;
int m_nBumpmap2Var;
int m_nBumpmap2Frame;
int m_nTeethForwardVar;
int m_nTeethIllumFactorVar;
};
void DrawFlashlight_dx90( IMaterialVar** params,
IShaderDynamicAPI *pShaderAPI, IShaderShadow* pShaderShadow, DrawFlashlight_dx90_Vars_t &vars );
void SetWaterFogColorPixelShaderConstantLinear( int reg );
void SetWaterFogColorPixelShaderConstantGamma( int reg );
private:
// Helper methods for VertexLitGenericPass
void UnlitGenericShadowState( int baseTextureVar, int detailVar, int envmapVar, int envmapMaskVar, bool doSkin );
void UnlitGenericDynamicState( int baseTextureVar, int frameVar, int baseTextureTransformVar,
int detailVar, int detailTransform, bool bDetailTransformIsScale, int envmapVar,
int envMapFrameVar, int envmapMaskVar, int envmapMaskFrameVar,
int envmapMaskScaleVar, int envmapTintVar );
// Converts a color + alpha into a vector4
void ColorVarsToVector( int colorVar, int alphaVar, Vector4D &color );
};
FORCEINLINE void SetFlashLightColorFromState( FlashlightState_t const &state, IShaderDynamicAPI *pShaderAPI, int nPSRegister=28 )
{
float tmscale= ( pShaderAPI->GetToneMappingScaleLinear() ).x;
tmscale=1.0/tmscale;
float const *color=state.m_Color.Base();
float psconsts[4]={ tmscale*color[0], tmscale*color[1], tmscale*color[2], color[3] };
pShaderAPI->SetPixelShaderConstant( nPSRegister, (float *) psconsts );
}
class ConVar;
#ifdef _DEBUG
extern ConVar mat_envmaptintoverride;
extern ConVar mat_envmaptintscale;
#endif
#endif // BASEVSSHADER_H

View File

@ -0,0 +1,73 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#include "BaseVSShader.h"
#include "SDK_screenspaceeffect_vs20.inc"
#include "SDK_bloom_ps20.inc"
BEGIN_VS_SHADER_FLAGS( SDK_Bloom, "Help for SDK_Bloom", SHADER_NOT_EDITABLE )
BEGIN_SHADER_PARAMS
SHADER_PARAM( FBTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_FullFrameFB", "" )
SHADER_PARAM( BLURTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_SmallHDR0", "" )
END_SHADER_PARAMS
SHADER_INIT
{
if( params[FBTEXTURE]->IsDefined() )
{
LoadTexture( FBTEXTURE );
}
if( params[BLURTEXTURE]->IsDefined() )
{
LoadTexture( BLURTEXTURE );
}
}
SHADER_FALLBACK
{
// Requires DX9 + above
if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
{
Assert( 0 );
return "Wireframe";
}
return 0;
}
SHADER_DRAW
{
SHADOW_STATE
{
pShaderShadow->EnableDepthWrites( false );
pShaderShadow->EnableTexture( SHADER_TEXTURE_STAGE0, true );
pShaderShadow->EnableTexture( SHADER_TEXTURE_STAGE1, true );
int fmt = VERTEX_POSITION;
pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0, 0 );
// Pre-cache shaders
DECLARE_STATIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
SET_STATIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
DECLARE_STATIC_PIXEL_SHADER( sdk_bloom_ps20 );
SET_STATIC_PIXEL_SHADER( sdk_bloom_ps20 );
}
DYNAMIC_STATE
{
BindTexture( SHADER_TEXTURE_STAGE0, FBTEXTURE, -1 );
BindTexture( SHADER_TEXTURE_STAGE1, BLURTEXTURE, -1 );
DECLARE_DYNAMIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
SET_DYNAMIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
DECLARE_DYNAMIC_PIXEL_SHADER( sdk_bloom_ps20 );
SET_DYNAMIC_PIXEL_SHADER( sdk_bloom_ps20 );
}
Draw();
}
END_SHADER

View File

@ -0,0 +1,18 @@
#define HDRTYPE HDR_TYPE_NONE
#include "common_ps_fxc.h"
sampler FBSampler : register( s0 );
sampler BlurSampler : register( s1 );
struct PS_INPUT
{
float2 texCoord : TEXCOORD0;
};
float4 main( PS_INPUT i ) : COLOR
{
float4 fbSample = tex2D( FBSampler, i.texCoord );
float4 blurSample = tex2D( BlurSampler, i.texCoord );
return float4( fbSample + blurSample.rgb * blurSample.a * MAX_HDR_OVERBRIGHT, 1.0f );
}

View File

@ -0,0 +1,15 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t0
tex t1
mul r0, t0, v0 ; base times vertex color (with alpha)
mul r0.rgb, t1, r0 ; fold in lightmap (color only)
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)

View File

@ -0,0 +1,17 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c2 - envmaptint
;------------------------------------------------------------------------------
tex t2 ; cube map
tex t3 ; envmap mask
mul r0.rgb, t2, 1-t3.a
mul r0.rgb, c2, r0 ; apply the envmaptint
+ mul r0.a, c2.a, v0.a

View File

@ -0,0 +1,17 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c2 - envmaptint
;------------------------------------------------------------------------------
tex t2 ; cube map
tex t3 ; envmap mask
mul r0.rgb, t2, t3
mul r0.rgb, c2, r0
+ mul r0.a, c2.a, v0.a

View File

@ -0,0 +1,15 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c2 - envmaptint
;------------------------------------------------------------------------------
tex t2 ; cube map
mul r0.rgb, t2, c2
+ mul r0.a, v0.a, c2.a

View File

@ -0,0 +1,22 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c1 - self-illum tint
; c2 - envmap tint
;------------------------------------------------------------------------------
tex t0
tex t1
tex t2
tex t3
mul r0, t0, v0 ; base times vertex color (with alpha)
mul r0.rgb, t1, r0 ; fold in lighting (color only)
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul r1, t2, 1-t3.a ; envmap * envmapmask (alpha)
mad r0.rgb, r1, c2, r0 ; + envmap * envmapmask * envmaptint (color only)

View File

@ -0,0 +1,14 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
; Get the color from the texture
tex t0
mul r0, t0, c0

View File

@ -0,0 +1,38 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
#include "SDK_macros.vsh"
;------------------------------------------------------------------------------
; Vertex blending
;------------------------------------------------------------------------------
&AllocateRegister( \$projPos );
dp4 $projPos.x, $vPos, $cModelViewProj0
dp4 $projPos.y, $vPos, $cModelViewProj1
dp4 $projPos.z, $vPos, $cModelViewProj2
dp4 $projPos.w, $vPos, $cModelViewProj3
mov oPos, $projPos
alloc $worldPos
if( $DOWATERFOG == 1 )
{
; Get the worldpos z component only since that's all we need for height fog
dp4 $worldPos.z, $vPos, $cModel2
}
&CalcFog( $worldPos, $projPos );
free $worldPos
&FreeRegister( \$projPos );
;------------------------------------------------------------------------------
; Texture coordinates
;------------------------------------------------------------------------------
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1

View File

@ -0,0 +1,43 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
#include "SDK_macros.vsh"
;------------------------------------------------------------------------------
; Vertex blending
;------------------------------------------------------------------------------
&AllocateRegister( \$projPos );
dp4 $projPos.x, $vPos, $cModelViewProj0
dp4 $projPos.y, $vPos, $cModelViewProj1
dp4 $projPos.z, $vPos, $cModelViewProj2
dp4 $projPos.w, $vPos, $cModelViewProj3
mov oPos, $projPos
alloc $worldPos
if( $DOWATERFOG == 1 )
{
; Get the worldpos z component only since that's all we need for height fog
dp4 $worldPos.z, $vPos, $cModel2
}
&CalcFog( $worldPos, $projPos );
free $worldPos
&FreeRegister( \$projPos );
;------------------------------------------------------------------------------
; Texture coordinates
;------------------------------------------------------------------------------
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
dp4 oT1.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
dp4 oT1.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_3
mov oT2, $vTexCoord1
; Now the basetexture/basetexture2 blend uses vertex color, so send it into the psh.
mov oD0, $vColor

View File

@ -0,0 +1,78 @@
; STATIC: "NORMALMAPALPHAENVMAPMASK" "0..1"
#ifndef _XBOX
ps.1.1
#else
xps.1.1
#endif
;------------------------------------------------------------------------------
; Environment mapping on a bumped surface
; t0 - Normalmap
; t3 - Cube environment map (*must* be a cube map!)
;
; c0 - color to multiply the results by
; c1 - envmap contrast
; c2 - envmap saturation
; c3 - grey weights
; c4 - fresnel amount
; Input texture coords required here are a little wonky.
; tc0.uv <- U,V into the normal map
; tc1.uvw, tc2.uvw, tc3.uvw <- 3x3 matrix transform
; from tangent space->env map space
; tc1.q, tc2.q, tc3.q <- eye vector in env map space
;------------------------------------------------------------------------------
; Get the 3-vector from the normal map
tex t0
; Perform matrix multiply to get a local normal bump. Then
; reflect the eye vector through the normal and sample from
; a cubic environment map.
texm3x3pad t1, t0_bx2
texm3x3pad t2, t0_bx2
texm3x3vspec t3, t0_bx2
; FIXME FIXME - Need to do specialized versions of this with and without:
; - constant color
; - fresnel amount of exactly 0 or 1 or in between
; - envmap contrast of 0, 1, or in between
; - envmap saturation of 0, 1, or in between
#ifndef _XBOX
; r0 = constant color * result of bump into envmap
mul r0.rgb, t3, c0
#endif
#ifndef _XBOX
; dot eye-vector with per-pixel normal from t0
dp3_sat r1, v0_bx2, t0_bx2
#endif
#ifdef _XBOX
xdm r1,r0, v0_bx2, t0_bx2, t3, c0
mov r1, r1_sat
#endif
; run Fresnel approx. on it: R0 + (1-R0) (1-cos(q))^5 in alpha channel
mul r1.rgb, r0, r0 ; color squared
+mul r0.a, 1-r1.a, 1-r1.a ; squared
lrp r0.rgb, c1, r1, r0 ; blend between color and color * color
+mul r0.a, r0.a, r0.a ; quartic
dp3 r1.rgb, r0, c3 ; color greyscaled
+mul r0.a, r0.a, 1-r1.a ; quintic
; FIXME - these should be able to pair (I think), but don't on nvidia for some reason.
; (I think) cannot pair due to use of >2 constants in single stage
lrp r0.rgb, c2, r0, r1 ; blend between color and greyscale
mad r0.a, r0.a, c6.a, c4.a ; Take Fresnel R(0) into consideration
mul r0.rgb, r0, r0.a ; multiply output color by result of fresnel calc
#ifdef NORMALMAPALPHAENVMAPMASK_1
+mul r0.a, c0.a, t0.a ; Fade amount * alpha from the texture
#else
+mov r0.a, c0.a ; Just use the fade amount
#endif

View File

@ -0,0 +1,96 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
;------------------------------------------------------------------------------
; Shader specific constant:
; $SHADER_SPECIFIC_CONST_5 = [sOffset, tOffset, 0, 0]
;------------------------------------------------------------------------------
#include "SDK_macros.vsh"
;------------------------------------------------------------------------------
; Vertex blending
;------------------------------------------------------------------------------
&AllocateRegister( \$worldPos );
; Transform position from object to world
dp4 $worldPos.x, $vPos, $cModel0
dp4 $worldPos.y, $vPos, $cModel1
dp4 $worldPos.z, $vPos, $cModel2
&AllocateRegister( \$projPos );
; Transform position from object to projection space
dp4 $projPos.x, $vPos, $cModelViewProj0
dp4 $projPos.y, $vPos, $cModelViewProj1
dp4 $projPos.z, $vPos, $cModelViewProj2
dp4 $projPos.w, $vPos, $cModelViewProj3
mov oPos, $projPos
;------------------------------------------------------------------------------
; Fog
;------------------------------------------------------------------------------
&CalcFog( $worldPos, $projPos );
&FreeRegister( \$projPos );
;------------------------------------------------------------------------------
; Lighting
;------------------------------------------------------------------------------
; Transform tangent space basis vectors to env map space (world space)
; This will produce a set of vectors mapping from tangent space to env space
; We'll use this to transform normals from the normal map from tangent space
; to environment map space.
; NOTE: use dp3 here since the basis vectors are vectors, not points
dp3 oT1.x, $vTangentS, $cModel0
dp3 oT2.x, $vTangentS, $cModel1
dp3 oT3.x, $vTangentS, $cModel2
dp3 oT1.y, $vTangentT, $cModel0
dp3 oT2.y, $vTangentT, $cModel1
dp3 oT3.y, $vTangentT, $cModel2
dp3 oT1.z, $vNormal, $cModel0
dp3 oT2.z, $vNormal, $cModel1
dp3 oT3.z, $vNormal, $cModel2
; Compute the vector from vertex to camera
&AllocateRegister( \$worldEyeVect );
sub $worldEyeVect.xyz, $cEyePos, $worldPos
&FreeRegister( \$worldPos );
; Move it into the w component of the texture coords, as the wacky
; pixel shader wants it there.
mov oT1.w, $worldEyeVect.x
mov oT2.w, $worldEyeVect.y
mov oT3.w, $worldEyeVect.z
alloc $tangentEyeVect
; transform the eye vector to tangent space
dp3 $tangentEyeVect.x, $worldEyeVect, $vTangentS
dp3 $tangentEyeVect.y, $worldEyeVect, $vTangentT
dp3 $tangentEyeVect.z, $worldEyeVect, $vNormal
&FreeRegister( \$worldEyeVect );
&Normalize( $tangentEyeVect );
; stick the tangent space eye vector into oD0
mad oD0.xyz, $tangentEyeVect, $cHalf, $cHalf
&FreeRegister( \$tangentEyeVect );
;------------------------------------------------------------------------------
; Texture coordinates
;------------------------------------------------------------------------------
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1

View File

@ -0,0 +1,72 @@
; STATIC: "NORMALMAPALPHAENVMAPMASK" "0..1"
ps.1.4
;------------------------------------------------------------------------------
; Phase 1
;------------------------------------------------------------------------------
; Get the 3-vector from the normal map
texld r0, t0
; Get environment matrix
texcrd r1.rgb, t1
texcrd r2.rgb, t2
texcrd r3.rgb, t3
; Normalize eye-ray vector through normalizer cube map
texld r4, t4 ; <---- CUBE MAP here!!!
;mov r0.rgba, r4
; Transform normal
dp3 r5.r, r1, r0_bx2
dp3 r5.g, r2, r0_bx2
dp3 r5.b, r3, r0_bx2
; Reflection calculatiom
dp3_x2 r3.rgb, r5, r4_bx2 ; 2(N.Eye)
mul r3.rgb, r5, r3 ; 2N(N.Eye)
dp3 r2.rgb, r5, r5 ; N.N
mad r2.rgb, -r4_bx2, r2, r3 ; 2N(N.Eye) - Eye(N.N)
#if NORMALMAPALPHAENVMAPMASK
; Alpha gets lost after phase marker, so store it here
mov r5, r0.a
#endif
;------------------------------------------------------------------------------
; Phase 2
;------------------------------------------------------------------------------
; What's left over from the last phase:
; r0 - normal
; r1 - free
; r2 - vector to sample in envmap
; r3 - free
; r4 - normal
; r5 - normal map alpha (rgba)
phase
; Sample environment map
texld r3, r2
; dot eye-vector with per-pixel normal from r0
dp3_sat r1, v0_bx2, r0_bx2
; Result goes in output color (multiply by constant color c0)
mul r0.rgb, r3, c0
; run Fresnel approx. on it: R0 + (1-R0) (1-cos(q))^5 in alpha channel
mul r1.rgb, r0, r0
+mul r0.a, 1-r1.a, 1-r1.a ; squared
lrp r0.rgb, c1, r1, r0 ; blend between color and color * color
+mul r0.a, r0.a, r0.a ; quartic
dp3 r1.rgb, r0, c3
+mul r0.a, r0.a, 1-r1.a ; quintic
lrp r0.rgb, c2, r0, r1 ; blend between color and greyscale
mad r0.a, r0.a, c6.a, c4.a ; Take Fresnel R(0) into consideration
mul r0.rgb, r0, r0.a ; multiply output color by result of fresnel calc
#if NORMALMAPALPHAENVMAPMASK
+mul r0.a, c0.a, r5.r ; Fade amount * alpha from the texture
#else
+mov r0.a, c0.a ; Just use the fade amount
#endif

View File

@ -0,0 +1,92 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
;------------------------------------------------------------------------------
; Shader specific constant:
; $SHADER_SPECIFIC_CONST_5 = [sOffset, tOffset, 0, 0]
;------------------------------------------------------------------------------
#include "SDK_macros.vsh"
;------------------------------------------------------------------------------
; Vertex blending
;------------------------------------------------------------------------------
&AllocateRegister( \$worldPos );
; Transform position from object to world
dp4 $worldPos.x, $vPos, $cModel0
dp4 $worldPos.y, $vPos, $cModel1
dp4 $worldPos.z, $vPos, $cModel2
&AllocateRegister( \$projPos );
; Transform position from object to projection space
dp4 $projPos.x, $vPos, $cModelViewProj0
dp4 $projPos.y, $vPos, $cModelViewProj1
dp4 $projPos.z, $vPos, $cModelViewProj2
dp4 $projPos.w, $vPos, $cModelViewProj3
mov oPos, $projPos
;------------------------------------------------------------------------------
; Fog
;------------------------------------------------------------------------------
&CalcFog( $worldPos, $projPos );
&FreeRegister( \$projPos );
;------------------------------------------------------------------------------
; Lighting
;------------------------------------------------------------------------------
; Transform tangent space basis vectors to env map space (world space)
; This will produce a set of vectors mapping from tangent space to env space
; We'll use this to transform normals from the normal map from tangent space
; to environment map space.
; NOTE: use dp3 here since the basis vectors are vectors, not points
dp3 oT1.x, $vTangentS, $cModel0
dp3 oT2.x, $vTangentS, $cModel1
dp3 oT3.x, $vTangentS, $cModel2
dp3 oT1.y, $vTangentT, $cModel0
dp3 oT2.y, $vTangentT, $cModel1
dp3 oT3.y, $vTangentT, $cModel2
dp3 oT1.z, $vNormal, $cModel0
dp3 oT2.z, $vNormal, $cModel1
dp3 oT3.z, $vNormal, $cModel2
; Compute the vector from vertex to camera
&AllocateRegister( \$worldEyeVect );
sub $worldEyeVect.xyz, $cEyePos, $worldPos
&FreeRegister( \$worldPos );
; eye vector
mov oT4.xyz, $worldEyeVect
alloc $tangentEyeVect
; transform the eye vector to tangent space
dp3 $tangentEyeVect.x, $worldEyeVect, $vTangentS
dp3 $tangentEyeVect.y, $worldEyeVect, $vTangentT
dp3 $tangentEyeVect.z, $worldEyeVect, $vNormal
&FreeRegister( \$worldEyeVect );
&Normalize( $tangentEyeVect );
; stick the tangent space eye vector into oD0
mad oD0.xyz, $tangentEyeVect, $cHalf, $cHalf
&FreeRegister( \$tangentEyeVect );
;------------------------------------------------------------------------------
; Texture coordinates
;------------------------------------------------------------------------------
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1

View File

@ -0,0 +1,79 @@
ps.1.1
;------------------------------------------------------------------------------
; Computes the diffuse component of lighting using lightmap + bumpmap
; t0 - Normalmap
; t1 - Lightmap1
; t2 - Lightmap2
; t3 - Lightmap3
;
; The texture coordinates need to be defined as follows:
; tc0 - Normalmap and lightmap texture coordinates
; c0, c1, c2 - Axes of the lightmap coordinate system in tangent space
;------------------------------------------------------------------------------
; Get the 3-vector from the normal map
tex t0
; Sample the lightmaps
tex t1
tex t2
tex t3
; output = lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
; lightmapColor[2] * ( ( N dot basis[2] )^2 ) +
; r0 = ( N dot basis[0] )
; don't "_sat" here so that everything adds up to one even if the normal is outside of the basis!!!!!
dp3 r0, t0_bx2, c0
; r1 = ( N dot basis[1] )
dp3 r1, t0_bx2, c1
;----
; r0 = ( N dot basis[0] )
; r1 = ( N dot basis[1] )
;----
; r0.rgb = ( N dot basis[0] )^2
mul r0.rgb, r0, r0
; r1.a = ( N dot basis[1] )^2
+mul r1.a, r1, r1
;----
; r0.rgb = ( N dot basis[0] )^2
; r1.a = ( N dot basis[1] )^2
;----
mul t1, r0, t1
;----
; r1.a = ( N dot basis[1] )^2
; t1 = lightmapColor[0] * ( N dot basis[0] )^2
;----
dp3 r0, t0_bx2, c2
;----
; r1.a = ( N dot basis[1] )^2
; t1 = lightmapColor[0] * ( N dot basis[0] )^2
; r0 = ( N dot basis[2] )
;----
mad t1.rgb, r1.a, t2, t1
+mul r0.a, r0, r0
;----
; t1.rgb = lightmapColor[0] * ( N dot basis[0] )^2 + lightmapColor[1] * ( N dot basis[1] )^2
; r0.a = ( N dot basis[2] )^2
;----
mad r0.rgba, r0.a, t3, t1
;----
; r0.rgb = lightmapColor[0] * ( N dot basis[0] )^2 +
; lightmapColor[1] * ( N dot basis[1] )^2 +
; lightmapColor[2] * ( N dot basis[2] )^2
;----

View File

@ -0,0 +1,54 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
#include "SDK_macros.vsh"
;------------------------------------------------------------------------------
; Vertex blending
;------------------------------------------------------------------------------
&AllocateRegister( \$projPos );
; Transform position from object to projection space
dp4 $projPos.x, $vPos, $cModelViewProj0
dp4 $projPos.y, $vPos, $cModelViewProj1
dp4 $projPos.z, $vPos, $cModelViewProj2
dp4 $projPos.w, $vPos, $cModelViewProj3
mov oPos, $projPos
;------------------------------------------------------------------------------
; Fog
;------------------------------------------------------------------------------
alloc $worldPos
if( $DOWATERFOG == 1 )
{
; Get the worldpos z component only since that's all we need for height fog
dp4 $worldPos.z, $vPos, $cModel2
}
&CalcFog( $worldPos, $projPos );
free $worldPos
&FreeRegister( \$projPos );
;------------------------------------------------------------------------------
; Texture coordinates
;------------------------------------------------------------------------------
; Compute the texture coordinates given the offset between
; each bumped lightmap
&AllocateRegister( \$offset );
mov $offset.xy, $vTexCoord2
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
add oT1.xy, $offset, $vTexCoord1
mad oT2.xy, $offset, $cTwo, $vTexCoord1
; make a 3
alloc $three
add $three, $cOne, $cTwo
mad oT3.xy, $offset, $three, $vTexCoord1
free $three
&FreeRegister( \$offset );

View File

@ -0,0 +1,39 @@
;------------------------------------------------------------------------------
; Computes the diffuse component of lighting using lightmap + bumpmap
; t0 - Normalmap
; t1 - Lightmap1
; t2 - Lightmap2
; t3 - Lightmap3
; t4 - Base
;
; The texture coordinates need to be defined as follows:
; tc0 - Normalmap and lightmap texture coordinates
; c0, c1, c2 - Axes of the lightmap coordinate system in tangent space
;------------------------------------------------------------------------------
ps.1.4
; Get the 3-vector from the normal map
texld r0, t0
; Sample the lightmaps
texld r1, t1
texld r2, t2
texld r3, t3
; Sample the base texture
texld r4, t4
; output = (lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
; lightmapColor[2] * ( ( N dot basis[2] )^2 ) ) * base
dp3 r5.r, r0_bx2, c0
dp3 r5.g, r0_bx2, c1
dp3 r5.b, r0_bx2, c2
mul r5.rgb, r5, r5
mul r1, r1, r5.r
mad r1, r2, r5.g, r1
mad r1, r3, r5.g, r1
; assume overbright_2 !!!
mul_x2 r0, r1, r4

View File

@ -0,0 +1,55 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
#include "SDK_macros.vsh"
;------------------------------------------------------------------------------
; Vertex blending
;------------------------------------------------------------------------------
&AllocateRegister( \$projPos );
; Transform position from object to projection space
dp4 $projPos.x, $vPos, $cModelViewProj0
dp4 $projPos.y, $vPos, $cModelViewProj1
dp4 $projPos.z, $vPos, $cModelViewProj2
dp4 $projPos.w, $vPos, $cModelViewProj3
mov oPos, $projPos
;------------------------------------------------------------------------------
; Fog
;------------------------------------------------------------------------------
alloc $worldPos
if( $DOWATERFOG == 1 )
{
; Get the worldpos z component only since that's all we need for height fog
dp4 $worldPos.z, $vPos, $cModel2
}
&CalcFog( $worldPos, $projPos );
free $worldPos
&FreeRegister( \$projPos );
;------------------------------------------------------------------------------
; Texture coordinates
;------------------------------------------------------------------------------
; Compute the texture coordinates given the offset between
; each bumped lightmap
&AllocateRegister( \$offset );
mov $offset.xy, $vTexCoord2
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
add oT1.xy, $offset, $vTexCoord1
mad oT2.xy, $offset, $cTwo, $vTexCoord1
alloc $three
add $three, $cOne, $cTwo
mad oT3.xy, $offset, $three, $vTexCoord1
free $three
dp4 oT4.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
dp4 oT4.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_3
&FreeRegister( \$offset );

View File

@ -0,0 +1,47 @@
;------------------------------------------------------------------------------
; Computes the diffuse component of lighting using lightmap + bumpmap
; t0 - Normalmap
; t1 - Lightmap1
; t2 - Lightmap2
; t3 - Lightmap3
; t4 - Base1
; t5 - Base2
;
; The texture coordinates need to be defined as follows:
; tc0 - Normalmap and lightmap texture coordinates
; c0, c1, c2 - Axes of the lightmap coordinate system in tangent space
;------------------------------------------------------------------------------
ps.1.4
; output = (lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
; lightmapColor[2] * ( ( N dot basis[2] )^2 ) ) * lerp(base1, base2, lightmapColor[0].a)
; Get the 3-vector from the normal map
texld r0, t0
dp3 r5.r, r0_bx2, c0
dp3 r5.g, r0_bx2, c1
dp3 r5.b, r0_bx2, c2
mul r5.rgb, r5, r5
phase
; Sample the lightmaps
texld r1, t1
texld r2, t2
texld r3, t3
; Sample the base textures
texld r4, t4
texld r5, t5
mul r1, r1, r5.r
mad r1, r2, r5.g, r1
mad r1, r3, r5.g, r1
; blend base textures
lrp r4, r4, r5, r1.a
; assume overbright_2 !!!
mul_x2 r0, r1, r4

View File

@ -0,0 +1,57 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
#include "SDK_macros.vsh"
;------------------------------------------------------------------------------
; Vertex blending
;------------------------------------------------------------------------------
&AllocateRegister( \$projPos );
; Transform position from object to projection space
dp4 $projPos.x, $vPos, $cModelViewProj0
dp4 $projPos.y, $vPos, $cModelViewProj1
dp4 $projPos.z, $vPos, $cModelViewProj2
dp4 $projPos.w, $vPos, $cModelViewProj3
mov oPos, $projPos
;------------------------------------------------------------------------------
; Fog
;------------------------------------------------------------------------------
alloc $worldPos
if( $DOWATERFOG == 1 )
{
; Get the worldpos z component only since that's all we need for height fog
dp4 $worldPos.z, $vPos, $cModel2
}
&CalcFog( $worldPos, $projPos );
free $worldPos
&FreeRegister( \$projPos );
;------------------------------------------------------------------------------
; Texture coordinates
;------------------------------------------------------------------------------
; Compute the texture coordinates given the offset between
; each bumped lightmap
&AllocateRegister( \$offset );
mov $offset.xy, $vTexCoord2
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
add oT1.xy, $offset, $vTexCoord1
mad oT2.xy, $offset, $cTwo, $vTexCoord1
alloc $three
add $three, $cOne, $cTwo
mad oT3.xy, $offset, $three, $vTexCoord1
free $three
dp4 oT4.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
dp4 oT4.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_3
dp4 oT5.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_4
dp4 oT5.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_5
&FreeRegister( \$offset );

View File

@ -0,0 +1,47 @@
ps.1.1
;------------------------------------------------------------------------------
; Computes the diffuse component of lighting using lightmap + bumpmap
; t0 - decal texture
; t1 - Lightmap1
; t2 - Lightmap2
; t3 - Lightmap3
;
; The texture coordinates need to be defined as follows:
; tc0 - Normalmap and lightmap texture coordinates
; c0, c1, c2 - ( ( N dot basis[0] )^2 ), ( ( N dot basis[1] )^2 ), ( ( N dot basis[2] )^2 )
;------------------------------------------------------------------------------
; Get the decal color
tex t0
; Sample the lightmaps
tex t1
tex t2
tex t3
; output = lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
; lightmapColor[2] * ( ( N dot basis[2] )^2 ) +
; r0 = lightmapColor[0] * ( ( N dot basis[0] )^2 )
mul r0, t1, c0
; r0 = lightmapColor[0] * ( ( N dot basis[0] )^2 ) + lightmapColor[1] * ( ( N dot basis[1] )^2 )
mad r0, t2, c1, r0
; r0 = lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
; lightmapColor[2] * ( ( N dot basis[2] )^2 )
mad r0, t3, c2, r0
; Modulate by decal texture
mul r0.rgb, r0, t0
+ mov r0.a, t0.a
; Modulate by constant color
mul r0, r0, c3
; Modulate by per-vertex factor
mul r0, r0, v0

View File

@ -0,0 +1,56 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
#include "SDK_macros.vsh"
;------------------------------------------------------------------------------
; Vertex blending
;------------------------------------------------------------------------------
&AllocateRegister( \$projPos );
; Transform position from object to projection space
dp4 $projPos.x, $vPos, $cModelViewProj0
dp4 $projPos.y, $vPos, $cModelViewProj1
dp4 $projPos.z, $vPos, $cModelViewProj2
dp4 $projPos.w, $vPos, $cModelViewProj3
mov oPos, $projPos
;------------------------------------------------------------------------------
; Fog
;------------------------------------------------------------------------------
alloc $worldPos
if( $DOWATERFOG == 1 )
{
; Get the worldpos z component only since that's all we need for height fog
dp4 $worldPos.z, $vPos, $cModel2
}
&CalcFog( $worldPos, $projPos );
free $worldPos
&FreeRegister( \$projPos );
;------------------------------------------------------------------------------
; Texture coordinates
;------------------------------------------------------------------------------
; Compute the texture coordinates given the offset between
; each bumped lightmap
&AllocateRegister( \$offset );
mov $offset.x, $vTexCoord2.x
mov $offset.y, $cZero
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
add oT1.xy, $offset, $vTexCoord1
mad oT2.xy, $offset, $cTwo, $vTexCoord1
; make a 3
alloc $three
add $three, $cOne, $cTwo
mad oT3.xy, $offset, $three, $vTexCoord1
free $three
mov oD0, $vColor
&FreeRegister( \$offset );

View File

@ -0,0 +1,17 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t0
tex t1
tex t2
mul r0, t0, v0 ; base times vertex color (with alpha)
mul r0.rgb, t1, r0 ; fold in lightmap (color only)
mul_x2 r0.rgb, r0, t2 ; detail texture
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)

View File

@ -0,0 +1,16 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t1
tex t2
mul r0.rgb, t1, v0 + ; base times vertex color (with alpha)
mov r0.a, v0.a
mul_x2 r0.rgb, r0, t2 ; detail texture
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)

View File

@ -0,0 +1,22 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t0
tex t1
tex t2
mul r0.rgb, t0, v0 + ; base times vertex color (no alpha)
mov r0.a, v0.a ; Grab alpha from vertex color
mul r0.rgb, t1, r0 ; fold in lighting (color only)
mul_x2 r0.rgb, r0, t2 ; detail texture
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul r1, c1, t0 ; Self illum * tint
lrp r0.rgb, t0.a, r1, r0 ; Blend between self-illum + base * lightmap

View File

@ -0,0 +1,21 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c1 - self-illum tint
; c2 - envmap tint
;------------------------------------------------------------------------------
tex t1
tex t2
mov r0.rgb, v0 + ; vertex color
mul r0.a, v0.a, t2.a ; vertex alpha * envmap alpha
mad r0.rgb, t2, c2, r0 ; + envmap * envmaptint (color only)
mul r0.rgb, t1, r0 ; fold in lightmap (color only)
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)

View File

@ -0,0 +1,20 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c1 - self-illum tint
; c2 - envmap tint
;------------------------------------------------------------------------------
tex t0
tex t1
tex t2
mul r0, t0, v0 ; base times vertex color (with alpha)
mul r0.rgb, t1, r0 ; fold in lightmap (color only)
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mad r0.rgb, t2, c2, r0 ; + envmap * envmaptint (color only)

View File

@ -0,0 +1,45 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
#include "SDK_macros.vsh"
;------------------------------------------------------------------------------
; $SHADER_SPECIFIC_CONST_0-$SHADER_SPECIFIC_CONST_1 = Base texture transform
; $SHADER_SPECIFIC_CONST_2-$SHADER_SPECIFIC_CONST_3 = Mask texture transform
; $SHADER_SPECIFIC_CONST_4 = Modulation color
;------------------------------------------------------------------------------
&AllocateRegister( \$projPos );
; Transform position from object to projection space
dp4 $projPos.x, $vPos, $cModelViewProj0
dp4 $projPos.y, $vPos, $cModelViewProj1
dp4 $projPos.z, $vPos, $cModelViewProj2
dp4 $projPos.w, $vPos, $cModelViewProj3
mov oPos, $projPos
;------------------------------------------------------------------------------
; Fog
;------------------------------------------------------------------------------
alloc $worldPos
if( $DOWATERFOG == 1 )
{
; Get the worldpos z component only since that's all we need for height fog
dp4 $worldPos.z, $vPos, $cModel2
}
&CalcFog( $worldPos, $projPos );
free $worldPos
&FreeRegister( \$projPos );
; YUCK! This is to make texcoords continuous for mat_softwaretl
mov oT0, $cZero
; Texture coordinates
mov oT1, $vTexCoord1
mov oD0, $cOne

View File

@ -0,0 +1,6 @@
ps.1.1
tex t1
mov r0.rgba, t1

View File

@ -0,0 +1,24 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c1 - self-illum tint
; c2 - envmap tint
;------------------------------------------------------------------------------
tex t1
tex t2
tex t3
mov r0.rgb, v0 ; vertex color
mul r1, t2, t3 ; envmap * envmapmask
mad r0.rgb, r1, c2, r0 + ; + envmap * envmapmask * envmaptint (color only)
mul r0.a, v0.a, r1.a ; alpha = vertex alpha * envmap alpha * envmapmask alpha
mul r0.rgb, t1, r0 ; fold in lightmap (color only)
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)

View File

@ -0,0 +1,22 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c1 - self-illum tint
; c2 - envmap tint
;------------------------------------------------------------------------------
tex t0
tex t1
tex t2
tex t3
mul r0, t0, v0 ; base times vertex color (with alpha)
mul r0.rgb, t1, r0 ; fold in lighting (color only)
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul r1, t2, t3 ; envmap * envmapmask
mad r0.rgb, r1, c2, r0 ; + envmap * envmapmask * envmaptint (color only)

View File

@ -0,0 +1,25 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
def c2, 1.0f, 1.0f, 1.0f, 1.0f
tex t0
tex t1
; Blend between grey and lightmap color based on total alpha
mul_x2 r1.rgb, c0, t1 ; Apply overbright to lightmap
#ifndef _XBOX
+ mul_sat r1.a, t0, v0 ; base times vertex alpha
lrp r0, r1.a, r1, c2 ; interpolate between white + color
#else
+ mul r1.a, t0, v0 ; base times vertex alpha
lrp r0, r1_sat.a, r1, c2 ; interpolate between white + color
#endif

View File

@ -0,0 +1,25 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
def c2, 1.0f, 1.0f, 1.0f, 1.0f
tex t0
tex t1
; Blend between grey and lightmap color based on total alpha
mul_x2 r1.rgb, c0, t1 ; Apply overbright to lightmap
#ifndef _XBOX
+ mov_sat r1.a, v0 ; vertex alpha
lrp r0, r1.a, r1, c2 ; interpolate between white + color
#else
+ mov r1.a, v0 ; vertex alpha
lrp r0, r1_sat.a, r1, c2 ; interpolate between white + color
#endif

View File

@ -0,0 +1,32 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
def c2, 1.0f, 1.0f, 1.0f, 1.0f
tex t0
tex t1
; Blend between white and lightmap color based on total alpha
#ifndef _XBOX
mul_x2 r1.rgb, c0, t1 ; Apply overbright to lightmap
+ mov_sat r1.a, v0 ; opacity == vertex opacity (no alpha in texture)
#else
mul_x2 r1.rgb, c0, t1
+ mov r1.a, v0
#endif
lrp r0.rgb, t0.a, c1, r1 ; Blend between self-illum + lightmap
+ mov r0.a, c2.a
#ifndef _XBOX
lrp r0.rgb, r1.a, r0, c2 ; interpolate between white + color
#else
lrp r0.rgb, r1_sat.a, r0, c2
#endif

View File

@ -0,0 +1,14 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t1
mul r0.rgb, t1, v0 + ; base times vertex color (with alpha)
mov r0.a, v0.a
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)

View File

@ -0,0 +1,21 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t0
tex t1
mul r0.rgb, t0, v0 + ; base times vertex color (no alpha)
mov r0.a, v0.a ; Grab alpha from vertex color
mul r0.rgb, t1, r0 ; fold in lighting (color only)
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul r1, c1, t0 ; Self illum * tint
lrp r0.rgb, t0.a, r1, r0 ; Blend between self-illum + base * lightmap

View File

@ -0,0 +1,27 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c1 - self-illum tint
; c2 - envmap tint
;------------------------------------------------------------------------------
tex t0
tex t1
tex t2
mul r0.rgb, t0, v0 + ; base times vertex color (no alpha)
mov r0.a, v0.a ; Grab alpha from vertex color
mul r1, t0.a, t0 ; Self illum
mad r1, c1, r1, t1 ; Self illum * tint + lightmap
mul r0.rgb, r1, r0 ; fold in lighting (color only)
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mad r0.rgb, t2, c2, r0 ; + envmap * envmaptint (color only)

View File

@ -0,0 +1,28 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c1 - self-illum tint
; c2 - envmap tint
;------------------------------------------------------------------------------
tex t0
tex t1
tex t2
tex t3
mul r0.rgb, t0, v0 + ; base times vertex color (with alpha)
mov r0.a, v0.a ; Grab alpha from vertex color
mul r1, c1, t0.a ; Self illum alpha * tint
mad r1, t0, r1, t1 ; Self illum * tint + lightmap
mul r0.rgb, r1, r0 ; fold in lighting (color only)
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul r1, t2, t3 ; envmap * envmapmask
mad r0.rgb, r1, c2, r0 ; + envmap * envmapmask * envmaptint (color only)

View File

@ -0,0 +1,15 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
#include "SDK_LightmappedGeneric_inc.vsh"
$detail = 0;
$envmap = 0;
$envmapcameraspace = 0;
$envmapsphere = 0;
$vertexcolor = 1;
&LightmappedGeneric( $detail, $envmap, $envmapcameraspace, $envmapsphere,
$vertexcolor );

View File

@ -0,0 +1,114 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
# DYNAMIC: "SKINNING" "0..1" [XBOX]
# DYNAMIC: "NUM_BONES" "0..3" [PC]
;------------------------------------------------------------------------------
; Constants specified by the app
; c0 = (0, 1, 2, 0.5)
; c1 = (1/2.2, 0, 0, 0)
; c2 = camera position *in world space*
; c4-c7 = modelViewProj matrix (transpose)
; c8-c11 = ViewProj matrix (transpose)
; c12-c15 = model->view matrix (transpose)
; c16 = [fogStart, fogEnd, fogRange, undefined]
;
; Vertex components (as specified in the vertex DECL)
; $vPos = Position
; $vTexCoord0.xy = TexCoord0
;------------------------------------------------------------------------------
#include "SDK_macros.vsh"
; Vertex components
; $vPos = Position
; $vNormal = normal
; $vTexCoord0.xy = TexCoord0
; $vTangentS = S axis of Texture space
; $vTangentT = T axis of Texture space
;------------------------------------------------------------------------------
; Transform the position from world to view space
;------------------------------------------------------------------------------
alloc $worldPos
alloc $worldNormal
alloc $worldTangentS
alloc $worldTangentT
&SkinPositionNormalAndTangentSpace( $worldPos, $worldNormal,
$worldTangentS, $worldTangentT );
alloc $projPos
; Transform position from world to projection space
dp4 $projPos.x, $worldPos, $cViewProj0
dp4 $projPos.y, $worldPos, $cViewProj1
dp4 $projPos.z, $worldPos, $cViewProj2
dp4 $projPos.w, $worldPos, $cViewProj3
&CalcFog( $worldPos, $projPos );
alloc $worldEyeVect
; Get the eye vector in world space
add $worldEyeVect.xyz, -$worldPos, $cEyePos
alloc $tangentEyeVect
; transform the eye vector to tangent space
dp3 oT3.x, $worldEyeVect, $worldTangentS
dp3 oT3.y, $worldEyeVect, $worldTangentT
dp3 oT3.z, $worldEyeVect, $worldNormal
alloc $bumpTexCoord
dp4 $bumpTexCoord.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
dp4 $bumpTexCoord.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
; dudv map
mov oT0.xy, $bumpTexCoord
; refract tint + alpha channel
mov oT2.xy, $bumpTexCoord
mov oT3.xy, $bumpTexCoord
free $bumpTexCoord
mov oPos, $projPos
; special case perspective correct texture projection so that the texture fits exactly on the screen
; flip Y by multiplying by -1
mul $projPos.y, $projPos.y, $SHADER_SPECIFIC_CONST_4.w
; transform from [-w,w] to [0,2*w]
; The reason this is w is because we are in perspective space/homogenous clip space.
add $projPos.xy, $projPos.xy, $projPos.w
; transform from [0,2*w] to [0,w]
; We'll end up dividing by w in the pixel shader to get to [0,1]
mul $projPos.xy, $projPos.xy, $cHalf
#ifdef _XBOX
; divide out w
rcp $projPos.w, $projPos.w
mul $projPos.xy, $projPos.xy, $projPos.w
#endif
mov oT1.xy, $projPos.xy
#ifndef _XBOX
; emit w to both z and w in case the driver screws up and divides by z
mov oT1.z, $projPos.w
mov oT1.w, $projPos.w
#endif
free $projPos
free $worldPos
free $worldEyeVect
free $tangentEyeVect
free $w
free $worldNormal
free $worldTangentS
free $worldTangentT

View File

@ -0,0 +1,36 @@
; STATIC: "REFRACTTINTTEXTURE" "0..1"
; STATIC: "NORMALMAPALPHA" "0..1"
ps.1.1
; t0:
; texture: dudv map
; texcoords: dudvmap texcoords
; t1:
; texture: refraction render target
; texcoords:
tex t0 ; sample dudv map
texbem t1, t0 ; refraction
#ifdef REFRACTTINTTEXTURE_1
tex t2
#endif
#ifdef NORMALMAPALPHA_1
tex t3
#endif
; refracttint
#ifdef REFRACTTINTTEXTURE_1
mul_x2 r0, t1, t2
#else
mov r0, t1
#endif
#ifdef NORMALMAPALPHA_1
mul r0.rgb, r0, c0 +
mov r0.a, t3.a
#else
mul r0.rgb, r0, c0
#endif

View File

@ -0,0 +1,152 @@
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
// STATIC: "BLUR" "0..1"
// STATIC: "FADEOUTONSILHOUETTE" "0..1"
// STATIC: "CUBEMAP" "0..1"
// STATIC: "REFRACTTINTTEXTURE" "0..1"
// STATIC: "MASKED" "0..1"
// DYNAMIC: "FOGTYPE" "0..2"
// SKIP: $MASKED && $BLUR
#include "common_ps_fxc.h"
sampler RefractSampler : register( s2 );
sampler NormalSampler : register( s3 );
#if CUBEMAP
sampler EnvmapSampler : register( s4 );
#endif
#if REFRACTTINTTEXTURE
sampler RefractTintSampler : register( s5 );
#endif
const HALF3 g_EnvmapTint : register( c0 );
const HALF3 g_RefractTint : register( c1 );
const HALF3 g_EnvmapContrast : register( c2 );
const HALF3 g_EnvmapSaturation : register( c3 );
const HALF2 g_RefractScale : register( c5 );
static const int g_BlurCount = BLUR;
static const float g_BlurFraction = 1.0f / 512.0f;
static const float g_HalfBlurFraction = 0.5 * g_BlurFraction;
static const float4 g_BlurFractionVec = float4( g_BlurFraction, g_HalfBlurFraction,
-g_BlurFraction,-g_HalfBlurFraction );
struct PS_INPUT
{
float2 vBumpTexCoord : TEXCOORD0; // dudvMapAndNormalMapTexCoord
HALF3 vWorldVertToEyeVector : TEXCOORD1;
HALF3x3 tangentSpaceTranspose : TEXCOORD2;
float3 vRefractXYW : TEXCOORD5;
float3 projNormal : TEXCOORD6;
float4 vProjPos : TEXCOORD7;
};
HALF4 main( PS_INPUT i ) : COLOR
{
HALF3 result;
#if FADEOUTONSILHOUETTE
HALF blend = -i.projNormal.z;
blend = blend * blend * blend;
#else
HALF blend = 1.0f;
#endif
// Load normal and expand range
HALF4 vNormalSample = tex2D( NormalSampler, i.vBumpTexCoord );
HALF3 tangentSpaceNormal = vNormalSample * 2.0 - 1.0;
#if REFRACTTINTTEXTURE
HALF3 refractTintColor = 2.0 * g_RefractTint * tex2D( RefractTintSampler, i.vBumpTexCoord );
#else
HALF3 refractTintColor = g_RefractTint;
#endif
// Perform division by W only once
float ooW = 1.0f / i.vRefractXYW.z;
// Compute coordinates for sampling refraction
float2 vRefractTexCoordNoWarp = i.vRefractXYW.xy * ooW;
float2 vRefractTexCoord = tangentSpaceNormal.xy;
HALF scale = vNormalSample.a * g_RefractScale;
vRefractTexCoord *= scale;
vRefractTexCoord += vRefractTexCoordNoWarp;
#if (BLUR==1) // use polyphase magic to convert 9 lookups into 4
// basic principle behind this transformation:
// [ A B C ]
// [ D E F ]
// [ G H I ]
// use bilinear filtering hardware to weight upper 2x2 samples evenly (0.25* [A + B + D + E]).
// scale the upper 2x2 by 4/9 (total area of kernel occupied)
// use bilinear filtering hardware to weight right 1x2 samples evenly (0.5*[C + F])
// scale right 1x2 by 2/9
// use bilinear filtering hardware to weight lower 2x1 samples evenly (0.5*[G + H])
// scale bottom 2x1 by 2/9
// fetch last sample (I) and scale by 1/9.
float2 upper_2x2_loc = vRefractTexCoord.xy - float2(g_HalfBlurFraction, g_HalfBlurFraction);
float2 right_1x2_loc = vRefractTexCoord.xy + float2(g_BlurFraction, -g_HalfBlurFraction);
float2 lower_2x1_loc = vRefractTexCoord.xy + float2(-g_HalfBlurFraction, g_BlurFraction);
float2 singleton_loc = vRefractTexCoord.xy + float2(g_BlurFraction, g_BlurFraction);
result = tex2D(RefractSampler, upper_2x2_loc) * 0.4444444;
result += tex2D(RefractSampler, right_1x2_loc) * 0.2222222;
result += tex2D(RefractSampler, lower_2x1_loc) * 0.2222222;
result += tex2D(RefractSampler, singleton_loc) * 0.1111111;
HALF3 unblurredColor = tex2D(RefractSampler, vRefractTexCoordNoWarp.xy);
result = lerp(unblurredColor, result * refractTintColor, blend);
#elif (BLUR>0) // iteratively step through render target
int x, y;
result = float3( 0.0f, 0.0f, 0.0f );
for( x = -g_BlurCount; x <= g_BlurCount; x++ )
{
for( y = -g_BlurCount; y <= g_BlurCount; y++ )
{
result += tex2D( RefractSampler, vRefractTexCoord.xy + float2( g_BlurFraction * x, g_BlurFraction * y ) );
}
}
int width = g_BlurCount * 2 + 1;
result *= 1.0f / ( width * width );
// result is the blurred one now. . .now lerp.
float3 unblurredColor = tex2D( RefractSampler, vRefractTexCoordNoWarp.xy );
result = lerp( unblurredColor, result * refractTintColor, blend );
#else
# if MASKED
return tex2D( RefractSampler, vRefractTexCoord.xy );
# else
float3 colorWarp = tex2D( RefractSampler, vRefractTexCoord.xy );
float3 colorNoWarp = tex2D( RefractSampler, vRefractTexCoordNoWarp.xy );
colorWarp *= refractTintColor;
result = lerp( colorNoWarp, colorWarp, blend );
# endif
#endif
#if CUBEMAP
HALF specularFactor = vNormalSample.a;
HALF3 worldSpaceNormal = mul( i.tangentSpaceTranspose, tangentSpaceNormal );
HALF3 reflectVect = CalcReflectionVectorUnnormalized( worldSpaceNormal, i.vWorldVertToEyeVector );
HALF3 specularLighting = texCUBE( EnvmapSampler, reflectVect );
specularLighting *= specularFactor;
specularLighting *= g_EnvmapTint;
HALF3 specularLightingSquared = specularLighting * specularLighting;
specularLighting = lerp( specularLighting, specularLightingSquared, g_EnvmapContrast );
HALF3 greyScale = dot( specularLighting, HALF3( 0.299f, 0.587f, 0.114f ) );
specularLighting = lerp( greyScale, specularLighting, g_EnvmapSaturation );
result += specularLighting;
#endif
return HALF4( result, vNormalSample.a );
}

View File

@ -0,0 +1,99 @@
// DYNAMIC: "NUMBONES" "0..3"
// STATIC: "MODEL" "0..1"
#include "common_vs_fxc.h"
static const int g_NumBones = NUMBONES;
static const bool g_bModel = MODEL ? true : false;
const float4 cBumpTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_1 );
struct VS_INPUT
{
float4 vPos : POSITION;
float4 vBoneWeights : BLENDWEIGHT;
float4 vBoneIndices : BLENDINDICES;
float3 vNormal : NORMAL;
float4 vBaseTexCoord : TEXCOORD0;
#if !MODEL
float3 vTangentS : TANGENT;
float3 vTangentT : BINORMAL0;
#else
float4 vUserData : TANGENT;
#endif
};
struct VS_OUTPUT
{
float4 vProjPos_POSITION : POSITION;
float vFog : FOG;
float2 vBumpTexCoord : TEXCOORD0;
float3 vTangentEyeVect : TEXCOORD1;
float3x3 tangentSpaceTranspose : TEXCOORD2;
float3 vRefractXYW : TEXCOORD5;
float4 projNormal_screenCoordW : TEXCOORD6;
float3 worldPos : TEXCOORD7;
float4 fogFactorW : COLOR1;
};
VS_OUTPUT main( const VS_INPUT v )
{
VS_OUTPUT o = ( VS_OUTPUT )0;
float4 projPos;
float3 worldNormal, worldPos, worldTangentS, worldTangentT;
#if MODEL
SkinPositionNormalAndTangentSpace(
# ifdef USE_CONDITIONALS
g_bZeroBones, g_bOneBone, g_bTwoBones,
# else
g_NumBones,
# endif
v.vPos, v.vNormal, v.vUserData,
v.vBoneWeights, v.vBoneIndices,
worldPos, worldNormal, worldTangentS, worldTangentT );
#else
worldPos = mul( v.vPos, cModel[0] );
worldNormal = v.vNormal;
worldTangentS = mul( v.vTangentS, ( const float3x3 )cModel[0] );
worldTangentT = mul( v.vTangentT, ( const float3x3 )cModel[0] );
worldNormal = mul( v.vNormal, ( float3x3 )cModel[0] );
#endif
o.worldPos = worldPos;
// Projected position
float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
o.vProjPos_POSITION = vProjPos;
o.projNormal_screenCoordW.xyz = mul( worldNormal, cViewProj );
// Map projected position to the refraction texture
float2 vRefractPos;
vRefractPos.x = vProjPos.x;
vRefractPos.y = -vProjPos.y; // invert Y
vRefractPos = (vRefractPos + vProjPos.w) * cHalf;
// Refraction transform
o.vRefractXYW = float3(vRefractPos.x, vRefractPos.y, vProjPos.w);
// Compute fog based on the position
float3 vWorldPos = mul( v.vPos, cModel[0] );
o.fogFactorW = o.vFog = CalcFog( vWorldPos, vProjPos, FOGTYPE_RANGE );
// Eye vector
float3 vWorldEyeVect = cEyePos - vWorldPos;
// Transform to the tangent space
o.vTangentEyeVect.x = dot( vWorldEyeVect, worldTangentS );
o.vTangentEyeVect.y = dot( vWorldEyeVect, worldTangentT );
o.vTangentEyeVect.z = dot( vWorldEyeVect, worldNormal );
// Tranform bump coordinates
o.vBumpTexCoord.x = dot( v.vBaseTexCoord, cBumpTexCoordTransform[0] );
o.vBumpTexCoord.y = dot( v.vBaseTexCoord, cBumpTexCoordTransform[1] );
o.tangentSpaceTranspose[0] = worldTangentS;
o.tangentSpaceTranspose[1] = worldTangentT;
o.tangentSpaceTranspose[2] = worldNormal;
return o;
}

View File

@ -0,0 +1,168 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
;------------------------------------------------------------------------------
; Constants specified by the app
; c0 = (0, 1, 2, 0.5)
; c1 = (1/2.2, 0, 0, 0)
; c2 = camera position *in world space*
; c4-c7 = modelViewProj matrix (transpose)
; c8-c11 = ViewProj matrix (transpose)
; c12-c15 = model->view matrix (transpose)
; c16 = [fogStart, fogEnd, fogRange, undefined]
;
; Vertex components (as specified in the vertex DECL)
; $vPos = Position
; $vTexCoord0.xy = TexCoord0
;------------------------------------------------------------------------------
#include "SDK_macros.vsh"
; Vertex components
; $vPos = Position
; $vNormal = normal
; $vTexCoord0.xy = TexCoord0
; $vTangentS = S axis of Texture space
; $vTangentT = T axis of Texture space
;------------------------------------------------------------------------------
; Transform the position from world to view space
;------------------------------------------------------------------------------
alloc $worldPos
alloc $worldNormal
alloc $worldTangentS
alloc $worldTangentT
alloc $projPos
dp4 $projPos.x, $vPos, $cModelViewProj0
dp4 $projPos.y, $vPos, $cModelViewProj1
dp4 $projPos.z, $vPos, $cModelViewProj2
dp4 $projPos.w, $vPos, $cModelViewProj3
mov oPos, $projPos
dp3 $worldPos.x, $vPos, $cModel0
dp3 $worldPos.y, $vPos, $cModel1
dp3 $worldPos.z, $vPos, $cModel2
dp3 $worldNormal.x, $vNormal, $cModel0
dp3 $worldNormal.y, $vNormal, $cModel1
dp3 $worldNormal.z, $vNormal, $cModel2
dp3 $worldTangentS.x, $vTangentS, $cModel0
dp3 $worldTangentS.y, $vTangentS, $cModel1
dp3 $worldTangentS.z, $vTangentS, $cModel2
dp3 $worldTangentT.x, $vTangentT, $cModel0
dp3 $worldTangentT.y, $vTangentT, $cModel1
dp3 $worldTangentT.z, $vTangentT, $cModel2
&CalcFog( $worldPos, $projPos );
alloc $worldEyeVect
; Get the eye vector in world space
add $worldEyeVect.xyz, -$worldPos, $cEyePos
alloc $tangentEyeVect
alloc $bumpTexCoord
; transform the eye vector to tangent space
dp3 $tangentEyeVect.x, $worldEyeVect, $worldTangentS
dp3 $tangentEyeVect.y, $worldEyeVect, $worldTangentT
dp3 $tangentEyeVect.z, $worldEyeVect, $worldNormal
&Normalize( $tangentEyeVect );
; stick the tangent space eye vector into oD0
mad oD0.xyz, $tangentEyeVect, $cHalf, $cHalf
dp4 $bumpTexCoord.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
dp4 $bumpTexCoord.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
; dudv map
mov oT0.xy, $bumpTexCoord
; refract tint
mov oT3.xy, $bumpTexCoord
free $bumpTexCoord
alloc $newProjPos
alloc $w
mov oPos, $projPos
; special case perspective correct texture projection so that the texture fits exactly on the screen
mul $projPos.y, $projPos.y, $SHADER_SPECIFIC_CONST_4.w
add $projPos.xy, $projPos.xy, $projPos.w
mul $projPos.xy, $projPos.xy, $cHalf
; Do the perspective divide here. .yuck . . we aren't going to be perspective correct
rcp $w.w, $projPos.w
mul $projPos, $projPos, $w.w
#max $projPos.x, $projPos.x, -$cOne
#min $projPos.x, $projPos.x, $cOne
#max $projPos.z, $projPos.z, $cZero
#min $projPos.z, $projPos.z, $cOne
;------------------------------------------------------------------------------
; Transform the tangentS from world to view space
;------------------------------------------------------------------------------
alloc $projTangentS
; we only care about x and y
dp3 $projTangentS.x, $worldTangentS, $cViewProj0
dp3 $projTangentS.y, $worldTangentS, $cViewProj1
; project tangentS
mul $projTangentS.xy, $projTangentS.xy, $w.w
;max $projTangentS.xy, $projTangentS.xy, $cOne
;min $projTangentS.xy, $projTangentS.xy, -$cOne
;------------------------------------------------------------------------------
; Transform the tangentT from world to view space
;------------------------------------------------------------------------------
alloc $projTangentT
alloc $texCoord
; we only care about x and y
dp3 $projTangentT.x, $worldTangentT, $cViewProj0
dp3 $projTangentT.y, $worldTangentT, $cViewProj1
; project tangentT
mul $projTangentT.xy, $projTangentT.xy, $w.w
;max $projTangentT.xy, $projTangentT.xy, $cOne
;min $projTangentT.xy, $projTangentT.xy, -$cOne
;max $projPos.xy, $projPos.xy, $cOne
;min $projPos.xy, $projPos.xy, -$cOne
mul oT1.x, $projTangentS.x, $SHADER_SPECIFIC_CONST_3.x
mul oT1.y, $projTangentT.x, $SHADER_SPECIFIC_CONST_3.x
mov oT1.z, $projPos.x ; huh?
mul $texCoord.x, $projTangentS.y, -$SHADER_SPECIFIC_CONST_3.x
mul $texCoord.y, $projTangentT.y, -$SHADER_SPECIFIC_CONST_3.x
mov $texCoord.z, $projPos.y
mov oT2.xyz, $texCoord
mov oT3.xyz, $texCoord
free $texCoord
free $projPos
free $worldPos
free $worldEyeVect
free $tangentEyeVect
free $w
free $projTangentS
free $projTangentT
free $newProjPos
free $worldNormal
free $worldTangentS
free $worldTangentT

View File

@ -0,0 +1,29 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
;------------------------------------------------------------------------------
; Constants specified by the app
; c0 = (0, 1, 2, 0.5)
; c1 = (1/2.2, 3, 255, overbright factor)
; c2 = camera position *in world space*
; c4-c7 = modelViewProj matrix (transpose)
; c8-c11 = ViewProj matrix (transpose)
; c12-c15 = model->view matrix (transpose)
; c16 = [fogStart, fogEnd, fogRange, 1.0/fogRange]
; $SHADER_SPECIFIC_CONST_0-$SHADER_SPECIFIC_CONST_1 = Base texture transform
; $SHADER_SPECIFIC_CONST_2-$SHADER_SPECIFIC_CONST_3 = Mask texture transform
;------------------------------------------------------------------------------
#include "SDK_macros.vsh"
;------------------------------------------------------------------------------
; No vertex blending required. Input vertex data is in screen space
;------------------------------------------------------------------------------
mov oPos.xyz, $vPos.xyz
mov oPos.w, $cOne
;------------------------------------------------------------------------------
; Pass any and all texture coordinates through
;------------------------------------------------------------------------------
mov oT0, $vTexCoord0

View File

@ -0,0 +1,13 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t0 ; base color
mul r0, t0, v0

View File

@ -0,0 +1,19 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c2 - envmaptint
;------------------------------------------------------------------------------
tex t0 ; base color
tex t1 ; cube map
tex t2 ; envmap mask
mul r0.rgb, t1, 1-t2.a ; can't use mad cause can't use 3 texture registers
mul r0.rgb, c2, r0 ; apply the envmaptint
mad r0.rgb, t0, v0, r0
+ mul r0.a, t0, v0

View File

@ -0,0 +1,15 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t0 ; base color
tex t3 ; detail texture
mul r0, t0, v0
mul_x2 r0.rgb, r0, t3

View File

@ -0,0 +1,29 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c2 - envmaptint
;------------------------------------------------------------------------------
tex t0 ; base color
tex t1 ; cube map
tex t2 ; envmap mask
tex t3 ; detail texture
; version 1: applies the mod2x *after* environment map
;mul r0.rgb, t1, 1-t2.a ; can't use mad cause can't use 3 texture registers
;mul r0.rgb, c2, r0 ; apply the envmaptint
;mad r0.rgb, t0, v0, r0
;+ mul r0.a, t0, v0
;mul_x2 r0.rgb, r0, t3 ; mod2x detail texture
; version 2: applies the mod2x *before* environment map
mul r0, t0, v0 ; Base times modulation color
mul_x2 r0.rgb, r0, t3 ; mod2x detail texture
mul r1, t1, 1-t2.a ; Have to invert the alpha for basealpha (feh!)
mul r1, c2, r1 ; apply the envmaptint
add r0.rgb, r0, r1 ; add in the envmap

View File

@ -0,0 +1,25 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c2 - envmaptint
;------------------------------------------------------------------------------
tex t0 ; base color
tex t1 ; cube map
tex t3 ; detail texture
; version 1: applies the mod2x *after* environment map
;mul r1, c2, t1
;mad r0.rgb, t0, v0, r1
;+ mul r0.a, t0, v0
;mul_x2 r0.rgb, r0, t3 ; mod2x detail texture
; version 2: applies the mod2x *before* environment map
mul r0, t0, v0 ; Base times modulation color
mul_x2 r0.rgb, r0, t3 ; mod2x detail texture
mad r0.rgb, c2, t1, r0 ; add in tinted envmap

View File

@ -0,0 +1,29 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c2 - envmaptint
;------------------------------------------------------------------------------
tex t0 ; base color
tex t1 ; cube map
tex t2 ; envmap mask
tex t3 ; detail texture
; version 1: applies the mod2x *after* environment map
;mul r0.rgb, t1, t2 ; can't use mad cause can't use 3 texture registers
;mul r0.rgb, c2, r0 ; apply the envmaptint
;mad r0.rgb, t0, v0, r0
;+ mul r0.a, t0, v0
;mul_x2 r0.rgb, r0, t3 ; mod2x detail texture
; version 2: applies the mod2x *before* environment map
mul r0, t0, v0 ; Base times modulation color
mul_x2 r0.rgb, r0, t3 ; mod2x detail texture
mul r1, t1, t2 ; Envmap * envmapmask
mul r1, c2, r1 ; apply the envmaptint
add r0.rgb, r0, r1 ; add in the envmap

View File

@ -0,0 +1,21 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c2 - envmaptint
;------------------------------------------------------------------------------
tex t1 ; cube map
tex t2 ; envmap mask
tex t3 ; detail texture
; version 1: applies the mod2x *after* environment map
; version 2 doesn't make sense here!
mul r0, t1, t2
mul r0.rgb, c2, r0
mul r0, r0, v0
mul_x2 r0.rgb, r0, t3 ; mod2x detail texture

View File

@ -0,0 +1,19 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c2 - envmaptint
;------------------------------------------------------------------------------
tex t1 ; cube map
tex t3 ; detail texture
; version 1: applies the mod2x *after* environment map
; version 2 doesn't make sense here!
mul r0, v0, t1
mul r0.rgb, r0, c2
mul_x2 r0.rgb, r0, t3 ; mod2x detail texture

View File

@ -0,0 +1,10 @@
ps.1.1
;------------------------------------------------------------------------------
; Just use the vertex color
;------------------------------------------------------------------------------
tex t3
mul_x2 r0.rgb, v0, t3
+ mov r0.a, v0.a

View File

@ -0,0 +1,17 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c2 - envmaptint
;------------------------------------------------------------------------------
tex t0 ; base color
tex t1 ; cube map
mul r1, c2, t1
mad r0.rgb, t0, v0, r1
+ mul r0.a, t0, v0

View File

@ -0,0 +1,19 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c2 - envmaptint
;------------------------------------------------------------------------------
tex t0 ; base color
tex t1 ; cube map
tex t2 ; envmap mask
mul r0.rgb, t1, t2 ; can't use mad cause can't use 3 texture registers
mul r0.rgb, c2, r0 ; apply the envmaptint
mad r0.rgb, t0, v0, r0
+ mul r0.a, t0, v0

View File

@ -0,0 +1,17 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c2 - envmaptint
;------------------------------------------------------------------------------
tex t1 ; cube map
tex t2 ; envmap mask
mul r0, t1, t2
mul r0.rgb, c2, r0
mul r0, r0, v0

View File

@ -0,0 +1,15 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
; c2 - envmaptint
;------------------------------------------------------------------------------
tex t1 ; cube map
mul r0, v0, t1
mul r0.rgb, r0, c2

View File

@ -0,0 +1,22 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
# DYNAMIC: "SKINNING" "0..1" [XBOX]
# DYNAMIC: "NUM_BONES" "0..3" [PC]
#include "SDK_macros.vsh"
&AllocateRegister( \$worldPos );
&SkinPosition( $worldPos );
; Transform the position from world to view space
dp4 oPos.x, $worldPos, $cViewProj0
dp4 oPos.y, $worldPos, $cViewProj1
dp4 oPos.z, $worldPos, $cViewProj2
dp4 oPos.w, $worldPos, $cViewProj3
&FreeRegister( \$worldPos );
mov oD0, $cOne

View File

@ -0,0 +1,7 @@
ps.1.1
;------------------------------------------------------------------------------
; Just use the vertex color
;------------------------------------------------------------------------------
mov r0, v0

View File

@ -0,0 +1,15 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t0 ; base color
tex t1 ; texture 2
mul r0, t0, v0
mul r0, t1, r0

View File

@ -0,0 +1,11 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
# DYNAMIC: "SKINNING" "0..1" [XBOX]
# DYNAMIC: "NUM_BONES" "0..3" [PC]
#include "unlittwotexture_inc.vsh"
$vertexcolor = 0;
&UnlitTwoTexture( $vertexcolor );

View File

@ -0,0 +1,17 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
; Get the color from the texture
tex t0
mul r0, t0, c3
mul r0.rgb, v0, r0 ; Apply lighting
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)

View File

@ -0,0 +1,19 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t0 ; base color
tex t1 ; cube map
tex t2 ; envmap mask
mul r0, t0, c3 ; Base times modulation
mul r1, t1, 1-t2.a ; Envmap * mask (in alpha channel)
mul r0.rgb, v0, r0 ; apply vertex lighting
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mad r0.rgb, r1, c2, r0 ; + envmap * mask * tint

View File

@ -0,0 +1,19 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
; Get the color from the texture
tex t0
tex t3
mul r0, t0, c3
mul r0.rgb, v0, r0 ; Apply lighting
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul_x2 r0.rgb, r0, t3 ; detail texture

View File

@ -0,0 +1,21 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t0 ; base color
tex t1 ; cube map
tex t2 ; envmap mask
tex t3 ; detail texture
mul r0, t0, c3 ; Base times modulation
mul r1, t1, 1-t2.a ; Envmap * mask (in alpha channel)
mul r0.rgb, v0, r0 ; apply vertex lighting
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul_x2 r0.rgb, r0, t3 ; detail texture
mad r0.rgb, r1, c2, r0 ; + envmap * mask * tint

View File

@ -0,0 +1,19 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t0 ; base color
tex t1 ; cube map
tex t3 ; detail texture
mul r0, t0, c3 ; base times modulation
mul r0.rgb, v0, r0 ; apply vertex lighting
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul_x2 r0.rgb, r0, t3 ; detail texture
mad r0.rgb, t1, c2, r0 ; + envmap * envmaptint (color only)

View File

@ -0,0 +1,21 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t0 ; base color
tex t1 ; cube map
tex t2 ; envmap mask
tex t3 ; detail texture
mul r0, t0, c3 ; Base times modulation
mul r1, t1, t2 ; Envmap * mask
mul r0.rgb, v0, r0 ; apply vertex lighting
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul_x2 r0.rgb, r0, t3 ; detail texture
mad r0.rgb, r1, c2, r0 ; + envmap * mask * tint

View File

@ -0,0 +1,16 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t3
mul r0, v0, c3
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul_x2 r0.rgb, r0, t3 ; detail texture

View File

@ -0,0 +1,26 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
; Get the color from the texture
tex t0
tex t3
; interpolate between illuminated + non-selfilluminated
mul r0.rgb, t0, c3 + ; base times modulation
mov r0.a, c3.a
mul r0.rgb, v0, r0 ; Apply lighting
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul_x2 r0.rgb, r0, t3 ; detail texture
mul r1, t0, c1 ; Self illum * tint
lrp r0.rgb, t0.a, r1, r0 ; Blend between self-illum + base * lighting

View File

@ -0,0 +1,27 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
; Get the color from the texture
tex t0
tex t1
tex t3
mul r0.rgb, t0, c3 + ; base times modulation
mov r0.a, c3.a ; use modulation alpha (don't use texture alpha)
mul r0.rgb, v0, r0 ; Apply lighting
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul_x2 r0.rgb, r0, t3 ; detail texture
mul r1, t0, c1 ; Self illum * tint
lrp r0.rgb, t0.a, r1, r0 ; Blend between self-illum + base * lighting
mad r0.rgb, t1, c2, r0 ; + envmap * envmaptint (color only)

View File

@ -0,0 +1,29 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
; Get the color from the texture
tex t0 ; base
tex t1 ; env map
tex t2 ; mask
tex t3 ; detail
mul r0.rgb, t0, c3 + ; base times modulation
mul r0.a, c3.a, t2.a ; alpha = mod alpha * mask alpha
mul r0.rgb, v0, r0 ; Apply lighting
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul_x2 r0.rgb, r0, t3 ; detail texture
mul r1, t0, c1 ; Self illum * tint
lrp r0.rgb, t0.a, r1, r0 ; Blend between self-illum + base * lighting
mul r1, t2, t1 ; envmapmask * envmap
mad r0.rgb, r1, c2, r0 ; + envmapmask * envmap * envmaptint (color only)

View File

@ -0,0 +1,17 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t1 ; cube map
mul r0.rgb, t1, c2 + ; envmap * envmaptint (color only) +
mov r0.a, c3.a ; Use alpha from modulation... (?)
mul r0.rgb, v0, r0 ; apply vertex lighting
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)

View File

@ -0,0 +1,17 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t0 ; base color
tex t1 ; cube map
mul r0, t0, c3 ; base times modulation
mul r0.rgb, v0, r0 ; apply vertex lighting
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mad r0.rgb, t1, c2, r0 ; + envmap * envmaptint (color only)

View File

@ -0,0 +1,36 @@
ps.1.1
;------------------------------------------------------------------------------
; Environment mapping on a bumped surface
; t0 - Normalmap
; t3 - Cube environment map (*must* be a cube map!)
;
; c0 - color to multiply the results by
; Input texture coords required here are a little wonky.
; tc0.uv <- U,V into the normal map
; tc1.uvw, tc2.uvw, tc3.uvw <- 3x3 matrix transform
; from tangent space->env map space
; tc1.q, tc2.q, tc3.q <- eye vector in env map space
;------------------------------------------------------------------------------
; This version doesn't multiply by lighting.
; Get the 3-vector from the normal map
tex t0
; Perform matrix multiply to get a local normal bump. Then
; reflect the eye vector through the normal and sample from
; a cubic environment map.
texm3x3pad t1, t0_bx2
texm3x3pad t2, t0_bx2
texm3x3vspec t3, t0_bx2
; result goes in output color
mul r0.rgb, t3, c0 ; constant color
+mov r0.a, c0.a
mul r1.rgb, r0, r0
lrp r0.rgb, c1, r1, r0 ; blend between color and color * color
dp3 r1.rgb, r0, c3
lrp r0.rgb, c2, r0, r1 ; blend between color and greyscale

View File

@ -0,0 +1,42 @@
ps.1.1
;------------------------------------------------------------------------------
; Environment mapping on a bumped surface
; t0 - Normalmap
; t3 - Cube environment map (*must* be a cube map!)
;
; c0 - color to multiply the results by
; Input texture coords required here are a little wonky.
; tc0.uv <- U,V into the normal map
; tc1.uvw, tc2.uvw, tc3.uvw <- 3x3 matrix transform
; from tangent space->env map space
; tc1.q, tc2.q, tc3.q <- eye vector in env map space
;------------------------------------------------------------------------------
; This version doesn't multiply by lighting.
; Get the 3-vector from the normal map
tex t0
; Perform matrix multiply to get a local normal bump. Then
; reflect the eye vector through the normal and sample from
; a cubic environment map.
texm3x3pad t1, t0_bx2
texm3x3pad t2, t0_bx2
texm3x3vspec t3, t0_bx2
; result goes in output color
mul r0.rgb, t3, c0 ; constant color
+mov r0.a, c0.a
mul r1.rgb, r0, r0
lrp r0.rgb, c1, r1, r0 ; blend between color and color * color
dp3 r1.rgb, r0, c3
lrp r0.rgb, c2, r0, r1 ; blend between color and greyscale
; Multiply the output color by the alpha channel of the normal map.
mul r0.rgb, t0.a, r0

View File

@ -0,0 +1,42 @@
ps.1.4
;------------------------------------------------------------------------------
; Phase 1
;------------------------------------------------------------------------------
; Get the 3-vector from the normal map
texld r0, t0
; Get environment matrix
texcrd r1.rgb, t1
texcrd r2.rgb, t2
texcrd r3.rgb, t3
; Normalize eye-ray vector through normalizer cube map
texld r4, t4 ; <---- CUBE MAP here!!!
;mov r0.rgba, r4
; Transform normal
dp3 r5.r, r1, r0_bx2
dp3 r5.g, r2, r0_bx2
dp3 r5.b, r3, r0_bx2
; Reflection calculatiom
dp3_x2 r3.rgb, r5, r4_bx2 ; 2(N.Eye)
mul r3.rgb, r5, r3 ; 2N(N.Eye)
dp3 r2.rgb, r5, r5 ; N.N
mad r2.rgb, -r4_bx2, r2, r3 ; 2N(N.Eye) - Eye(N.N)
; Alpha gets lost after phase marker, so store it here
mov r5, r0.a
;------------------------------------------------------------------------------
; Phase 2
;------------------------------------------------------------------------------
phase
; Sample environment map
texld r3, r2
; Result goes in output color (multiply by constant color c0)
mul r0.rgb, r3, c0
+mov r0.a, c0.a
mul r1.rgb, r0, r0
lrp r0.rgb, c1, r1, r0 ; blend between color and color * color
dp3 r1.rgb, r0, c3
lrp r0.rgb, c2, r0, r1 ; blend between color and greyscale
; mult by alpha
mul r0.rgb, r0, r5

View File

@ -0,0 +1,39 @@
ps.1.4
;------------------------------------------------------------------------------
; Phase 1
;------------------------------------------------------------------------------
; Get the 3-vector from the normal map
texld r0, t0
; Get environment matrix
texcrd r1.rgb, t1
texcrd r2.rgb, t2
texcrd r3.rgb, t3
; Normalize eye-ray vector through normalizer cube map
texld r4, t4 ; <---- CUBE MAP here!!!
; Transform normal
dp3 r5.r, r1, r0_bx2
dp3 r5.g, r2, r0_bx2
dp3 r5.b, r3, r0_bx2
; Reflection calculatiom
dp3_x2 r3.rgb, r5, r4_bx2 ; 2(N.Eye)
mul r3.rgb, r5, r3 ; 2N(N.Eye)
dp3 r2.rgb, r5, r5 ; N.N
mad r2.rgb, -r4_bx2, r2, r3 ; 2N(N.Eye) - Eye(N.N)
; Alpha gets lost after phase marker, so store it here
mov r5, r0.a
;------------------------------------------------------------------------------
; Phase 2
;------------------------------------------------------------------------------
phase
; Sample environment map
texld r3, r2
; Result goes in output color (multiply by constant color c0)
mul r0.rgb, r3, c0
+mov r0.a, c0.a
mul r1.rgb, r0, r0
lrp r0.rgb, c1, r1, r0 ; blend between color and color * color
dp3 r1.rgb, r0, c3
lrp r0.rgb, c2, r0, r1 ; blend between color and greyscale

View File

@ -0,0 +1,94 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
# DYNAMIC: "SKINNING" "0..1" [XBOX]
# DYNAMIC: "NUM_BONES" "0..3" [PC]
;------------------------------------------------------------------------------
; Shader specific constant:
; $SHADER_SPECIFIC_CONST_5 = [sOffset, tOffset, 0, 0]
;------------------------------------------------------------------------------
#include "SDK_macros.vsh"
;------------------------------------------------------------------------------
; Vertex blending
;------------------------------------------------------------------------------
&AllocateRegister( \$worldPos );
&AllocateRegister( \$worldNormal );
&AllocateRegister( \$worldTangentS );
&AllocateRegister( \$worldTangentT );
&SkinPositionNormalAndTangentSpace( $worldPos, $worldNormal,
$worldTangentS, $worldTangentT );
;------------------------------------------------------------------------------
; Transform the position from world to proj space
;------------------------------------------------------------------------------
&AllocateRegister( \$projPos );
dp4 $projPos.x, $worldPos, $cViewProj0
dp4 $projPos.y, $worldPos, $cViewProj1
dp4 $projPos.z, $worldPos, $cViewProj2
dp4 $projPos.w, $worldPos, $cViewProj3
mov oPos, $projPos
;------------------------------------------------------------------------------
; Fog
;------------------------------------------------------------------------------
&CalcFog( $worldPos, $projPos );
&FreeRegister( \$projPos );
;------------------------------------------------------------------------------
; Lighting
;------------------------------------------------------------------------------
; Transform tangent space basis vectors to env map space (world space)
; This will produce a set of vectors mapping from tangent space to env space
; We'll use this to transform normals from the normal map from tangent space
; to environment map space.
; NOTE: use dp3 here since the basis vectors are vectors, not points
; svect
mov oT1.x, $worldTangentS.x
mov oT2.x, $worldTangentS.y
mov oT3.x, $worldTangentS.z
&FreeRegister( \$worldTangentS );
; tvect
mov oT1.y, $worldTangentT.x
mov oT2.y, $worldTangentT.y
mov oT3.y, $worldTangentT.z
&FreeRegister( \$worldTangentT );
; normal
mov oT1.z, $worldNormal.x
mov oT2.z, $worldNormal.y
mov oT3.z, $worldNormal.z
&FreeRegister( \$worldNormal );
; Compute the vector from vertex to camera
&AllocateRegister( \$eyeVector );
sub $eyeVector.xyz, $cEyePos, $worldPos
&FreeRegister( \$worldPos );
; Move it into the w component of the texture coords, as the wacky
; pixel shader wants it there.
mov oT1.w, $eyeVector.x
mov oT2.w, $eyeVector.y
mov oT3.w, $eyeVector.z
&FreeRegister( \$eyeVector );
;------------------------------------------------------------------------------
; Texture coordinates
;------------------------------------------------------------------------------
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_4
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_5

View File

@ -0,0 +1,91 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
# DYNAMIC: "SKINNING" "0..1" [XBOX]
# DYNAMIC: "NUM_BONES" "0..3" [PC]
;------------------------------------------------------------------------------
; Shader specific constant:
; $SHADER_SPECIFIC_CONST_5 = [sOffset, tOffset, 0, 0]
;------------------------------------------------------------------------------
#include "SDK_macros.vsh"
;------------------------------------------------------------------------------
; Vertex blending
;------------------------------------------------------------------------------
&AllocateRegister( \$worldPos );
&AllocateRegister( \$worldNormal );
&AllocateRegister( \$worldTangentS );
&AllocateRegister( \$worldTangentT );
&SkinPositionNormalAndTangentSpace( $worldPos, $worldNormal,
$worldTangentS, $worldTangentT );
;------------------------------------------------------------------------------
; Transform the position from world to proj space
;------------------------------------------------------------------------------
&AllocateRegister( \$projPos );
dp4 $projPos.x, $worldPos, $cViewProj0
dp4 $projPos.y, $worldPos, $cViewProj1
dp4 $projPos.z, $worldPos, $cViewProj2
dp4 $projPos.w, $worldPos, $cViewProj3
mov oPos, $projPos
;------------------------------------------------------------------------------
; Fog
;------------------------------------------------------------------------------
&CalcFog( $worldPos, $projPos );
&FreeRegister( \$projPos );
;------------------------------------------------------------------------------
; Lighting
;------------------------------------------------------------------------------
; Transform tangent space basis vectors to env map space (world space)
; This will produce a set of vectors mapping from tangent space to env space
; We'll use this to transform normals from the normal map from tangent space
; to environment map space.
; NOTE: use dp3 here since the basis vectors are vectors, not points
; svect
mov oT1.x, $worldTangentS.x
mov oT2.x, $worldTangentS.y
mov oT3.x, $worldTangentS.z
&FreeRegister( \$worldTangentS );
; tvect
mov oT1.y, $worldTangentT.x
mov oT2.y, $worldTangentT.y
mov oT3.y, $worldTangentT.z
&FreeRegister( \$worldTangentT );
; normal
mov oT1.z, $worldNormal.x
mov oT2.z, $worldNormal.y
mov oT3.z, $worldNormal.z
&FreeRegister( \$worldNormal );
; Compute the vector from vertex to camera
&AllocateRegister( \$eyeVector );
sub $eyeVector.xyz, $cEyePos, $worldPos
&FreeRegister( \$worldPos );
; eye vector
mov oT4.xyz, $eyeVector
&FreeRegister( \$eyeVector );
;------------------------------------------------------------------------------
; Texture coordinates
;------------------------------------------------------------------------------
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_4
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_5

View File

@ -0,0 +1,18 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t1 ; cube map
tex t2 ; envmap mask
mul r1, t1, t2 ; Envmap * mask
mul r0.rgb, r1, c2 ; envmap * mask * tint
mul r0.rgb, v0, r0 ; apply vertex lighting
mul_x2 r0.rgb, c0, r0 + ; * 2 * (overbrightFactor/2)
mul r0.a, c3.a, t2.a ; alpha = modulation * mask alpha

View File

@ -0,0 +1,19 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
tex t0 ; base color
tex t1 ; cube map
tex t2 ; envmap mask
mul r0, t0, c3 ; Base times modulation
mul r1, t1, t2 ; Envmap * mask
mul r0.rgb, v0, r0 ; apply vertex lighting
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mad r0.rgb, r1, c2, r0 ; + envmap * mask * tint

View File

@ -0,0 +1,13 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
mul r0, v0, c3
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)

View File

@ -0,0 +1,5 @@
ps.1.1
tex t0
mul r0.rgba, c0, t0

View File

@ -0,0 +1,42 @@
vs.1.1
# DYNAMIC: "DOWATERFOG" "0..1"
# DYNAMIC: "SKINNING" "0..1" [XBOX]
# DYNAMIC: "NUM_BONES" "0..3" [PC]
#include "SDK_macros.vsh"
;------------------------------------------------------------------------------
; Vertex blending
;------------------------------------------------------------------------------
&AllocateRegister( \$worldPos );
&SkinPosition( $worldPos );
;------------------------------------------------------------------------------
; Transform the position from world to view space
;------------------------------------------------------------------------------
&AllocateRegister( \$projPos );
dp4 $projPos.x, $worldPos, $cViewProj0
dp4 $projPos.y, $worldPos, $cViewProj1
dp4 $projPos.z, $worldPos, $cViewProj2
dp4 $projPos.w, $worldPos, $cViewProj3
mov oPos, $projPos
;------------------------------------------------------------------------------
; Fog
;------------------------------------------------------------------------------
&CalcFog( $worldPos, $projPos );
&FreeRegister( \$projPos );
&FreeRegister( \$worldPos );
;------------------------------------------------------------------------------
; Texture coordinates
;------------------------------------------------------------------------------
dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1

View File

@ -0,0 +1,24 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
; Get the color from the texture
tex t0
; interpolate between illuminated + non-selfilluminated
mul r0.rgb, t0, c3 + ; base times modulation
mov r0.a, c3.a
mul r0.rgb, v0, r0 ; Apply lighting
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul r1, t0, c1 ; Self illum * tint
lrp r0.rgb, t0.a, r1, r0 ; Blend between self-illum + base * lighting

View File

@ -0,0 +1,24 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
; Get the color from the texture
tex t0
tex t1
mul r0.rgb, t0, c3 + ; base times modulation
mov r0.a, c3.a ; use modulation alpha (don't use texture alpha)
mul r0.rgb, v0, r0 ; Apply lighting
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul r1, t0, c1 ; Self illum * tint
lrp r0.rgb, t0.a, r1, r0 ; Blend between self-illum + base * lighting
mad r0.rgb, t1, c2, r0 ; + envmap * envmaptint (color only)

View File

@ -0,0 +1,27 @@
ps.1.1
;------------------------------------------------------------------------------
; Draw a texture . . woo hoo!
; t0 - texture
;
; The texture coordinates need to be defined as follows:
; tc0 - texcoords
;------------------------------------------------------------------------------
; Get the color from the texture
tex t0 ; base
tex t1 ; env map
tex t2 ; mask
mul r0.rgb, t0, c3 + ; base times modulation
mul r0.a, c3.a, t2.a ; alpha = mod alpha * mask alpha
mul r0.rgb, v0, r0 ; Apply lighting
mul_x2 r0.rgb, c0, r0 ; * 2 * (overbrightFactor/2)
mul r1, t0, c1 ; Self illum * tint
lrp r0.rgb, t0.a, r1, r0 ; Blend between self-illum + base * lighting
mul r1, t2, t1 ; envmapmask * envmap
mad r0.rgb, r1, c2, r0 ; + envmapmask * envmap * envmaptint (color only)

View File

@ -0,0 +1,40 @@
ps.1.4
; Get the 3-vector from the normal map
texld r0, t0
; Get environment matrix
texcrd r1.rgb, t1
texcrd r2.rgb, t2
texcrd r3.rgb, t3
; Normalize eye-ray vector through normalizer cube map
texld r4, t4 ; <---- CUBE MAP here!!!
; Transform normal
dp3 r5.r, r1, r0_bx2
dp3 r5.g, r2, r0_bx2
dp3 r5.b, r3, r0_bx2
; Reflection calculatiom
dp3_x2 r3.rgb, r5, r4_bx2 ; 2(N.Eye)
mul r3.rgb, r5, r3 ; 2N(N.Eye)
dp3 r2.rgb, r5, r5 ; N.N
mad r2.rgb, -r4_bx2, r2, r3 ; 2N(N.Eye) - Eye(N.N)
phase
; Sample environment map
texld r3, r2
texld r4, t5 ; Normalize the tangent-space eye vector
; dot eye-vector with per-pixel normal from r0
dp3_sat r1, r4_bx2, r0_bx2
; run Fresnel approx. on it: R0 + (1-R0) (1-cos(q))^5 in alpha channel
mul r0.a, 1-r1.a, 1-r1.a ; squared
mul r0.a, r0.a, r0.a ; quartic
mul_sat r1.a, r0.a, 1-r1.a ; quintic
; multiply color by reflecttint
mul r0, r3, c1
; blend between reflected color and fog color based on fresnel
lrp r0.rgb, r1.a, r0, c0

View File

@ -0,0 +1,39 @@
ps.1.4
; Get the 3-vector from the normal map
texld r0, t0
; Get environment matrix
texcrd r1.rgb, t1
texcrd r2.rgb, t2
texcrd r3.rgb, t3
; Normalize eye-ray vector through normalizer cube map
texld r4, t4 ; <---- CUBE MAP here!!!
; Transform normal
dp3 r5.r, r1, r0_bx2
dp3 r5.g, r2, r0_bx2
dp3 r5.b, r3, r0_bx2
; Reflection calculatiom
dp3_x2 r3.rgb, r5, r4_bx2 ; 2(N.Eye)
mul r3.rgb, r5, r3 ; 2N(N.Eye)
dp3 r2.rgb, r5, r5 ; N.N
mad r2.rgb, -r4_bx2, r2, r3 ; 2N(N.Eye) - Eye(N.N)
phase
; Sample environment map
texld r3, r2
texld r4, t5 ; Normalize the tangent-space eye vector
; dot eye-vector with per-pixel normal from r0
dp3_sat r1, r4_bx2, r0_bx2
; run Fresnel approx. on it: R0 + (1-R0) (1-cos(q))^5 in alpha channel
mul r0.a, 1-r1.a, 1-r1.a ; squared
mul r0.a, r0.a, r0.a ; quartic
mul_sat r1.a, r0.a, 1-r1.a ; quintic
; multiply color by reflecttint
mul r0.rgb, r3, c1
+mov_sat r0.a, v0.a
add_sat r0.a, r1.a, r0.a

Some files were not shown because too many files have changed in this diff Show More