1
0
mirror of https://github.com/ncblakely/GiantsTools synced 2024-11-24 23:25:37 +01:00

Add shader project.

This commit is contained in:
Nick Blakely 2020-08-11 12:08:49 -07:00
parent dcf44ec7d0
commit d8a107b5ca
9 changed files with 1092 additions and 0 deletions

View File

@ -13,32 +13,88 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Giants.Launcher", "Giants.L
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Giants.WebApi.Clients", "Giants.WebApi.Clients\Giants.WebApi.Clients.csproj", "{D4C21170-82D4-4D1F-81EC-036835AC1238}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Shaders", "Shaders\Shaders.vcxproj", "{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Debug|x64.ActiveCfg = Debug|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Debug|x64.Build.0 = Debug|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Debug|x86.ActiveCfg = Debug|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Debug|x86.Build.0 = Debug|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Release|Any CPU.Build.0 = Release|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Release|x64.ActiveCfg = Release|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Release|x64.Build.0 = Release|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Release|x86.ActiveCfg = Release|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Release|x86.Build.0 = Release|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Debug|x64.ActiveCfg = Debug|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Debug|x64.Build.0 = Debug|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Debug|x86.ActiveCfg = Debug|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Debug|x86.Build.0 = Debug|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Release|Any CPU.Build.0 = Release|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Release|x64.ActiveCfg = Release|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Release|x64.Build.0 = Release|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Release|x86.ActiveCfg = Release|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Release|x86.Build.0 = Release|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Debug|x64.ActiveCfg = Debug|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Debug|x64.Build.0 = Debug|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Debug|x86.ActiveCfg = Debug|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Debug|x86.Build.0 = Debug|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Release|Any CPU.Build.0 = Release|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Release|x64.ActiveCfg = Release|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Release|x64.Build.0 = Release|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Release|x86.ActiveCfg = Release|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Release|x86.Build.0 = Release|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Debug|x64.ActiveCfg = Debug|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Debug|x64.Build.0 = Debug|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Debug|x86.ActiveCfg = Debug|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Debug|x86.Build.0 = Debug|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Release|Any CPU.Build.0 = Release|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Release|x64.ActiveCfg = Release|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Release|x64.Build.0 = Release|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Release|x86.ActiveCfg = Release|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Release|x86.Build.0 = Release|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Debug|x64.ActiveCfg = Debug|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Debug|x64.Build.0 = Debug|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Debug|x86.ActiveCfg = Debug|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Debug|x86.Build.0 = Debug|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Release|Any CPU.Build.0 = Release|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Release|x64.ActiveCfg = Release|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Release|x64.Build.0 = Release|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Release|x86.ActiveCfg = Release|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Release|x86.Build.0 = Release|Any CPU
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Debug|Any CPU.ActiveCfg = Debug|Win32
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Debug|x64.ActiveCfg = Debug|x64
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Debug|x64.Build.0 = Debug|x64
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Debug|x86.ActiveCfg = Debug|Win32
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Debug|x86.Build.0 = Debug|Win32
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Release|Any CPU.ActiveCfg = Release|Win32
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Release|x64.ActiveCfg = Release|x64
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Release|x64.Build.0 = Release|x64
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Release|x86.ActiveCfg = Release|Win32
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

28
Shaders/Shaders.sln Normal file
View File

@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.4
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Shaders", "Shaders.vcxproj", "{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Debug|x64.ActiveCfg = Debug|x64
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Debug|x64.Build.0 = Debug|x64
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Debug|x86.ActiveCfg = Debug|Win32
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Debug|x86.Build.0 = Debug|Win32
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Release|x64.ActiveCfg = Release|x64
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Release|x64.Build.0 = Release|x64
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Release|x86.ActiveCfg = Release|Win32
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

94
Shaders/Shaders.vcxproj Normal file
View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<FxCompile>
<ShaderType>Effect</ShaderType>
<ShaderModel>2.0</ShaderModel>
<EntryPointName />
</FxCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<FxCompile>
<ShaderType>Effect</ShaderType>
<ShaderModel>2.0</ShaderModel>
<EntryPointName />
</FxCompile>
</ItemDefinitionGroup>
<ItemGroup>
<FxCompile Include="fx\LandBump.fx" />
<FxCompile Include="fx\Ocean.fx">
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">/Gec %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">/Gec %(AdditionalOptions)</AdditionalOptions>
</FxCompile>
<FxCompile Include="fx\Sky.fx">
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</EntryPointName>
</FxCompile>
<FxCompile Include="fx\Water.fx" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

268
Shaders/fx.rules Normal file
View File

@ -0,0 +1,268 @@
<?xml version="1.0" encoding="utf-8"?>
<VisualStudioToolFile
Name="Direct3D Shader Compiler"
Version="8.00"
>
<Rules>
<CustomBuildRule
Name="CompileShader"
DisplayName="Effect File"
CommandLine="fxc [AllOptions] $(InputPath) /Fo fxo\$(InputName).fxo"
Outputs="$(InputDir)$(InputName).fxo"
FileExtensions="*.fx"
ExecutionDescription="Compiling $(InputFileName)..."
>
<Properties>
<BooleanProperty
Name="NoLogo"
DisplayName="Suppress copyright message"
Switch="/nologo"
DefaultValue="true"
/>
<BooleanProperty
Name="DisablePreshaders"
DisplayName="Disable preshaders"
Switch="/Op"
/>
<BooleanProperty
Name="DisableOpts"
DisplayName="Disable optimizations"
Switch="/Od"
/>
<EnumProperty
Name="Optimization"
DisplayName="Optimization"
>
<Values>
<EnumValue
Value="0"
DisplayName="Use default"
/>
<EnumValue
Value="1"
Switch="/O0"
DisplayName="Level 0"
/>
<EnumValue
Value="2"
Switch="/O1"
DisplayName="Level 1"
/>
<EnumValue
Value="3"
Switch="/O2"
DisplayName="Level 2"
/>
<EnumValue
Value="4"
Switch="/O3"
DisplayName="Level 3"
/>
</Values>
</EnumProperty>
<BooleanProperty
Name="DisableValidation"
DisplayName="Disable validation"
Switch="/Vd"
/>
<BooleanProperty
Name="EnableDebugging"
DisplayName="Enable Debugging"
Switch="/Zi"
/>
<EnumProperty
Name="PackMatrices"
DisplayName="Pack Matrix Order"
>
<Values>
<EnumValue
Value="0"
DisplayName="Use default"
/>
<EnumValue
Value="1"
Switch="/Zpr"
DisplayName="Pack matrices in row-major order"
/>
<EnumValue
Value="2"
Switch="/Zpc"
DisplayName="Pack matrices in column-major order"
/>
</Values>
</EnumProperty>
<BooleanProperty
Name="PartialPrecision"
DisplayName="Force partial precision"
Switch="/Gpp"
/>
<EnumProperty
Name="FlowControlConstructs"
DisplayName="Flow control constructs"
>
<Values>
<EnumValue
Value="0"
DisplayName="No preference (default)"
/>
<EnumValue
Value="1"
Switch="/Gfa"
DisplayName="Avoid flow control constructs"
/>
<EnumValue
Value="2"
Switch="/Gfp"
DisplayName="Prefer Flow control constructs"
/>
</Values>
</EnumProperty>
<BooleanProperty
Name="PerfMode"
DisplayName="Disable Effect Performance Mode"
Switch="/Gdp"
/>
<BooleanProperty
Name="StrictMode"
DisplayName="Strict mode"
Switch="/Ges"
/>
<BooleanProperty
Name="CompatibilityMode"
DisplayName="Backwards compatibility mode"
Switch="/Gec"
/>
<BooleanProperty
Name="IEEEMode"
DisplayName="Force IEE strictness"
Switch="/Gis"
/>
<EnumProperty
Name="Profile"
DisplayName="Profile"
Description="Target Profile"
DefaultValue="18"
>
<Values>
<EnumValue
Value="0"
Switch="/Tvs_1_1"
DisplayName="vs_1_1"
/>
<EnumValue
Value="1"
Switch="/Tvs_2_0"
DisplayName="vs_2_0"
/>
<EnumValue
Value="2"
Switch="/Tvs_2_a"
DisplayName="vs_2_a"
/>
<EnumValue
Value="3"
Switch="/Tvs_2_sw"
DisplayName="vs_2_sw"
/>
<EnumValue
Value="4"
Switch="/Tvs_3_0"
DisplayName="vs_3_0"
/>
<EnumValue
Value="5"
Switch="/Tvs_3_sw"
DisplayName="vs_3_sw"
/>
<EnumValue
Value="6"
Switch="/Tvs_4_0"
DisplayName="vs_4_0"
/>
<EnumValue
Value="7"
Switch="/Tvs_4_1"
DisplayName="vs_4_1"
/>
<EnumValue
Value="8"
Switch="/Tps_2_0"
DisplayName="ps_2_0"
/>
<EnumValue
Value="9"
Switch="/Tps_2_a"
DisplayName="ps_2_a"
/>
<EnumValue
Value="10"
Switch="/Tps_2_b"
DisplayName="ps_2_b"
/>
<EnumValue
Value="11"
Switch="/Tps_2_sw"
DisplayName="ps_2_sw"
/>
<EnumValue
Value="12"
Switch="/Tps_3_0"
DisplayName="ps_3_0"
/>
<EnumValue
Value="13"
Switch="/Tps_3_sw"
DisplayName="ps_3_sw"
/>
<EnumValue
Value="14"
Switch="/Tps_4_0"
DisplayName="ps_4_0"
/>
<EnumValue
Value="15"
Switch="/Tps_4_1"
DisplayName="ps_4_1"
/>
<EnumValue
Value="16"
Switch="/Tgs_4_0"
DisplayName="gs_4_0"
/>
<EnumValue
Value="17"
Switch="/Tgs_4_1"
DisplayName="gs_4_1"
/>
<EnumValue
Value="18"
Switch="/Tfx_2_0"
DisplayName="fx_2_0"
/>
<EnumValue
Value="19"
Switch="/Tfx_4_0"
DisplayName="fx_4_0"
/>
<EnumValue
Value="20"
Switch="/Tfx_4_1"
DisplayName="fx_4_1"
/>
</Values>
</EnumProperty>
<BooleanProperty
Name="LoadD3DX931DLL"
DisplayName="Load d3dx9_31.dll"
Switch="/LD"
/>
<BooleanProperty
Name="ChildEffect"
DisplayName="Compile as child effect"
Description="Compile as child effect for FX 4.x targets"
Switch="/Gch"
/>
</Properties>
</CustomBuildRule>
</Rules>
</VisualStudioToolFile>

376
Shaders/fx/LandBump.fx Normal file
View File

@ -0,0 +1,376 @@
//--------------------------------------------------------------------------------------
// LandBump.fx
// Land bumpmapping and lighting shader.
//--------------------------------------------------------------------------------------
#define MAX_LIGHTS 4
float4x4 g_mWorldViewProjection : WorldViewProjection;
float4x4 g_World : World;
float4x4 g_TexGenTransform0 : TexGenTransform0;
float4x4 g_TexGenTransform1 : TexGenTransform1;
float4x4 g_ShoreGen : TexGenTransform2;
float4 g_LightDiffuseColors[MAX_LIGHTS] : EffectLightColors;
float3 g_LightPositions[MAX_LIGHTS] : EffectLightPositions;
float g_LightRangeSquared[MAX_LIGHTS] : EffectLightRanges;
float4 g_TextureFactor : TextureFactor;
int g_NumLights = 0;
//////////////////////////////////////////////////////
//The sizes of the various terrain UV Coordinates
float detailScale = 1;
float diffuseScale = 5;
float globalScale;
float detailMapStrength = 1;
float3 sunlightVector = float3(.5,.5,.8);
//The Colour (and brightness) of the Sunlight
float3 lightColour = float3(2,2,2);
//The colour (and birghtness) of the ambient light
float3 ambientColour = float3(.1,.1,.1);
texture g_LandTexture;
texture g_LandBumpTexture;
texture g_ShoreTexture;
texture g_LandDetailTexture;
//--------------------------------------------------------------------------------------
// Texture samplers
//--------------------------------------------------------------------------------------
sampler g_LandTextureSampler =
sampler_state
{
Texture = <g_LandTexture>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
sampler g_LandBumpTextureSampler =
sampler_state
{
Texture = <g_LandBumpTexture>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
sampler g_LandDetailTextureSampler =
sampler_state
{
Texture = <g_LandDetailTexture>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
sampler g_ShoreTextureSampler =
sampler_state
{
Texture = <g_LandBumpTexture>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
//--------------------------------------------------------------------------------------
// Vertex shader output structure
//--------------------------------------------------------------------------------------
struct VS_OUTPUT_BUMP
{
float4 Position : POSITION;
float4 LandBumpDiffuse : COLOR1;
float4 LandDiffuse : COLOR0;
float2 LandBumpTextureUV : TEXCOORD0;
float2 LandTextureUV : TEXCOORD1;
float3 WorldPos : TEXCOORD2;
float3 Normal : TEXCOORD3;
float3 ShoreTextureUV : TEXCOORD4;
};
float4 bx2(float4 x)
{
return float4(2.0f * x.xyzw - 1.0f);
}
VS_OUTPUT_BUMP LandBumpVS( float4 vPos : POSITION,
float3 vNormal : NORMAL,
float4 vDiffuse : COLOR0,
float4 vDiffuse2 : COLOR1)
{
VS_OUTPUT_BUMP Output;
// Transform the position from object space to homogeneous projection space
Output.Position = mul(vPos, g_mWorldViewProjection);
Output.LandBumpDiffuse = vDiffuse2 * .5f;
Output.LandBumpDiffuse.a = 1.0f;
//Output.LandDiffuse
Output.LandDiffuse.rgb = vDiffuse;
Output.LandDiffuse.a = 1.0f;
Output.WorldPos = mul(vPos, g_World);
// Set dynamically generated tex coords
Output.LandBumpTextureUV = mul(vPos, g_TexGenTransform0);
Output.LandTextureUV = mul(vPos, g_TexGenTransform1);
Output.ShoreTextureUV = mul(vPos, g_ShoreGen);
// Transform the normal from object space to world space
Output.Normal = normalize(mul(vNormal, (float3x3)g_World)); // normal (world space)
return Output;
}
float4 LandBumpPS(VS_OUTPUT_BUMP input) : COLOR0
{
float4 normal = bx2(tex2D(g_LandBumpTextureSampler, input.LandBumpTextureUV));
float4 normalcol = bx2(input.LandDiffuse);
float3 normalMap;
normalMap = saturate((float4)dot((float3)normal, (float3)normalcol)).xyz;
#ifdef MIX_4X
float3 texel = tex2D(g_LandTextureSampler, input.LandTextureUV).rgb * tex2D(g_LandTextureSampler, input.LandTextureUV * -0.25).rgb * 4;
float3 finalColor = 2.0 * (normalMap * (texel) + input.LandBumpDiffuse);
#else
float3 finalColor = 2.0 * (normalMap * (tex2D(g_LandTextureSampler, input.LandTextureUV)) + input.LandBumpDiffuse);
//finalColor *= tex2D(g_ShoreTextureSampler, input.ShoreTextureUV);
#endif
//finalColor = (g_TextureFactor * (1 - input.LandDiffuse)) + finalColor;
for (int i = 0; i < MAX_LIGHTS; i++)
{
// Get light direction for this fragment
float3 lightDir = normalize(input.WorldPos - g_LightPositions[i]); // per pixel diffuse lighting
// Note: Non-uniform scaling not supported
float diffuseLighting = saturate(dot(input.Normal, -lightDir));
// Introduce fall-off of light intensity
diffuseLighting *= (g_LightRangeSquared[i] / dot(g_LightPositions[i] - input.WorldPos, g_LightPositions[i] - input.WorldPos));
float4 diffuseColor = diffuseLighting * g_LightDiffuseColors[i];
finalColor += diffuseColor;
}
return float4(finalColor, 1);
}
technique LandBump
{
pass P0
{
VertexShader = compile vs_2_0 LandBumpVS();
PixelShader = compile ps_2_0 LandBumpPS();
}
}
VS_OUTPUT_BUMP LandNormalVS( float4 vPos : POSITION,
float3 vNormal : NORMAL,
float4 vDiffuse : COLOR0,
float4 vDiffuse2 : COLOR1)
{
VS_OUTPUT_BUMP Output;
// Transform the position from object space to homogeneous projection space
Output.Position = mul(vPos, g_mWorldViewProjection);
Output.LandBumpDiffuse = vDiffuse2 * .5f;
Output.LandBumpDiffuse.a = 1.0f;
//Output.LandDiffuse
Output.LandDiffuse.rgb = vDiffuse;
Output.LandDiffuse.a = 1.0f;
Output.WorldPos = mul(vPos, g_World);
// Set dynamically generated tex coords
Output.LandBumpTextureUV = mul(vPos, g_TexGenTransform0);
Output.LandTextureUV = mul(vPos, g_TexGenTransform1);
Output.ShoreTextureUV = mul(vPos, g_ShoreGen);
// Transform the normal from object space to world space
Output.Normal = normalize(mul(vNormal, (float3x3)g_World)); // normal (world space)
return Output;
}
float4 LandNormalPS(VS_OUTPUT_BUMP input) : COLOR0
{
float4 Output;
//Get Global Normal from the full terrain normal map
float3 Normal = tex2D(g_LandBumpTextureSampler, input.LandTextureUV);
Normal[0] -= .5;
Normal[1] -= .5;
Normal[2] -= .5;
Normal = normalize(Normal);
//{
//
// //Get Detail Normal from the detail map
// float3 detailNormalMap = (tex2D(g_LandDetailTextureSampler, input.LandTextureUV*100/detailScale));
// detailNormalMap[0] -= .5;
// detailNormalMap[1] -= .5;
// detailNormalMap[2] -= .5;
// //Multiply Detail Normal by detailMapStrength
// detailNormalMap[0] = mul(detailNormalMap[0], detailMapStrength);
// detailNormalMap[1] = mul(detailNormalMap[1], detailMapStrength);
//
// //Normalize detail Normal
// detailNormalMap = normalize(detailNormalMap);
//
// if(false)
// {
// //Generate the Tangent Basis for the Detail Normal Map.
// float3x3 tangentBasis;
//
// tangentBasis[0] = cross(Normal, float3(1,0,0));
// tangentBasis[1] = cross(Normal, tangentBasis[0]);
// tangentBasis[2] = Normal;
//
// detailNormalMap = detailNormalMap, detailMapStrength;
//
// Normal = mul(detailNormalMap, tangentBasis);
// Normal = normalize(Normal);
// }
// else
// {
// Normal = normalize(Normal*2+detailNormalMap*detailMapStrength);
// }
//}
float3 sv = normalize(sunlightVector);
float3 lightLevel;
lightLevel[0] = max(dot(Normal, sv), 0)*lightColour[0]*2;//+ambientColour[0];
lightLevel[1] = max(dot(Normal, sv), 0)*lightColour[1]*2;//+ambientColour[1];
lightLevel[2] = max(dot(Normal, sv), 0)*lightColour[2]*2;//+ambientColour[2];
return float4(tex2D(g_LandTextureSampler, input.LandTextureUV) * lightLevel, 1) + input.LandBumpDiffuse;
float4 normal = bx2(tex2D(g_LandBumpTextureSampler, input.LandBumpTextureUV));
float4 normalcol = bx2(input.LandDiffuse);
float3 normalMap;
normalMap = saturate((float4)dot((float3)normal, (float3)normalcol)).xyz;
#ifdef MIX_4X
float3 texel = tex2D(g_LandTextureSampler, input.LandTextureUV).rgb * tex2D(g_LandTextureSampler, input.LandTextureUV * -0.25).rgb * 4;
float3 finalColor = 2.0 * (normalMap * (texel) + input.LandBumpDiffuse);
#else
float3 finalColor = 2.0 * (normalMap * (tex2D(g_LandTextureSampler, input.LandTextureUV)) + input.LandBumpDiffuse);
//finalColor *= tex2D(g_ShoreTextureSampler, input.ShoreTextureUV);
#endif
//finalColor = (g_TextureFactor * (1 - input.LandDiffuse)) + finalColor;
for (int i = 0; i < MAX_LIGHTS; i++)
{
// Get light direction for this fragment
float3 lightDir = normalize(input.WorldPos - g_LightPositions[i]); // per pixel diffuse lighting
// Note: Non-uniform scaling not supported
float diffuseLighting = saturate(dot(input.Normal, -lightDir));
// Introduce fall-off of light intensity
diffuseLighting *= (g_LightRangeSquared[i] / dot(g_LightPositions[i] - input.WorldPos, g_LightPositions[i] - input.WorldPos));
float4 diffuseColor = diffuseLighting * g_LightDiffuseColors[i];
finalColor += diffuseColor;
}
return float4(finalColor, 1);
}
technique LandNormal
{
pass P0
{
VertexShader = compile vs_2_0 LandNormalVS();
PixelShader = compile ps_2_0 LandNormalPS();
}
}
//--------------------------------------------------------------------------------------
// Vertex shader output structure
//--------------------------------------------------------------------------------------
struct VS_OUTPUT
{
float4 Position : POSITION;
float4 Diffuse : COLOR0;
float2 TextureUV : TEXCOORD0;
float3 Normal : TEXCOORD1;
float3 WorldPos : TEXCOORD2;
};
VS_OUTPUT LandscapeVS( float4 vPos : POSITION,
float3 vNormal : NORMAL,
float4 vDiffuse : COLOR0)
{
VS_OUTPUT Output;
// Transform the position from object space to homogeneous projection space
Output.Position = mul(vPos, g_mWorldViewProjection);
// Transform the normal from object space to world space
Output.Normal = normalize(mul(vNormal, (float3x3)g_World)); // normal (world space)
Output.Diffuse.rgb = vDiffuse;
Output.Diffuse.a = 1.0f;
Output.WorldPos = mul(vPos, g_World);
// Set dynamically generated tex coords
Output.TextureUV = mul(vPos, g_TexGenTransform0);
return Output;
}
float4 LandscapePS(VS_OUTPUT input) : COLOR0
{
float4 finalColor = 0;
for (int i = 0; i < MAX_LIGHTS; i++)
{
// Get light direction for this fragment
float3 lightDir = normalize(input.WorldPos - g_LightPositions[i]); // per pixel diffuse lighting
// Note: Non-uniform scaling not supported
float diffuseLighting = saturate(dot(input.Normal, -lightDir));
// Introduce fall-off of light intensity
diffuseLighting *= (g_LightRangeSquared[i] / dot(g_LightPositions[i] - input.WorldPos, g_LightPositions[i] - input.WorldPos));
float4 diffuseColor = diffuseLighting * g_LightDiffuseColors[i];
finalColor += diffuseColor;
}
#ifdef MIX_4X
float3 texel = tex2D(g_LandTextureSampler, input.TextureUV).rgb * tex2D(g_LandTextureSampler, input.TextureUV * -0.25).rgb * 4;
#else
float3 texel = tex2D(g_LandTextureSampler, input.TextureUV);
#endif
return float4(saturate((texel.xyz + input.Diffuse) + (finalColor)), 1.0f);
}
technique Landscape
{
pass P0
{
VertexShader = compile vs_2_0 LandscapeVS();
PixelShader = compile ps_2_0 LandscapePS();
}
}

147
Shaders/fx/Ocean.fx Normal file
View File

@ -0,0 +1,147 @@
//--------------------------------------------------------------------------------------
// Water.fx
// Ocean water reflection shader.
//--------------------------------------------------------------------------------------
/* Original asm code:
ps_1_1
tex t0
tex t1
lrp r0, -v0.w, t0, t1 // lrp = linear interpolate
*/
struct PS_INPUT
{
float4 color : COLOR0;
float4 texCoord0 : TEXCOORD0;
float4 texCoord1 : TEXCOORD1;
};
sampler s0, s1;
float4 MainPS(const PS_INPUT input) : COLOR0
{
// Interpolate linearly between Environment Texture, seabed, and inverted alpha of current pixel
return lerp(tex2D(s1, input.texCoord1), tex2D(s0, input.texCoord0), 1-input.color.a);
}
// C45: {0.00333, 0, 0, 0}
// C44:
// C27: {0, 1.0, 0.5, 0.25}
// C26: {minfog, maxfog, 1.0f / (maxfog - minfog), 1.0}
float4 const44 : register(c44);
matrix<float, 4, 4> matWorld : WorldViewProjectionTranspose : register(c2);
float4 fog : register (c26);
texture tex0;
texture tex1;
struct VS_OUTPUT
{
float4 pos : POSITION;
float4 texCoord1 : TEXCOORD1;
//float4 texCoord0 : TEXCOORD0;
//float4 color : COLOR0;
//float fog : FOG;
};
struct VS_INPUT
{
float4 pos : POSITION;
};
VS_OUTPUT MainVS(const VS_INPUT input)
{
float4 const27 = {0.0f, 1.0f, 0.5f, 0.75f};
VS_OUTPUT output;
output.pos = mul(input.pos, matWorld);
// add r0, v0, -c44
float4 r0 = input.pos + -const44;
// mov r0.z, -r0.z
r0.z = -r0.z;
// dp3 r0.w, r0, r0
r0.w = dot(r0.xyz, r0.xyz);
// rsq r0.w, r0.w
r0.w = rsqrt(r0.w);
// mul oT1.x, -r0, r0.w
// mul oT1.y, r0, r0.w
// mul oT1.z, r0, r0.w
// mov oT1.w, c27.y
output.texCoord1.x = -r0 * r0.w;
output.texCoord1.y = r0 * r0.w;
output.texCoord1.z = r0 * r0.w;
output.texCoord1.w = const27.y;
return output;
}
technique t0
{
pass p0
{
Texture[0] = <tex0>; // Seabed texture
Texture[1] = <tex1>; // Environment texture
// All of these constants are set by the game engine before drawing the shader
// Each constant register (c# in the asm code) has 4 floating point values
// World view matrix
VertexShaderConstant[2] = <matWorld[0]>;
VertexShaderConstant[3] = <matWorld[1]>;
VertexShaderConstant[4] = <matWorld[2]>;
VertexShaderConstant[5] = <matWorld[3]>;
VertexShaderConstant[26] = <fog>; // This constant is calculated from the current fog min/max values
VertexShaderConstant[27] = {0.0f, 1.0f, 0.5f, 0.75f}; // I don't know what this does but it doesn't change
VertexShaderConstant[44] = <const44>; // I don't know what this is
VertexShaderConstant[45] = {0.00033333333f, 0, 0, 0}; // I don't know what this does but it doesn't change
#if 1 // 1 to use asm shader
VertexShader =
asm
{
vs_1_1
dcl_position v0
dcl_texcoord v2
/* Places the dot product of the world view matrix and v0 in the output register oPos */
dp4 oPos.x, v0, c2
dp4 oPos.y, v0, c3
dp4 oPos.z, v0, c4
dp4 oPos.w, v0, c5
// this is some kind of vector normalization or transform
add r0, v0, -c44
mov r0.z, -r0.z
dp3 r0.w, r0, r0
rsq r0.w, r0.w
/* Output register for texture 1 (environment texture) is modified by register 0 */
mul oT1.x, -r0, r0.w
mul oT1.y, r0, r0.w
mul oT1.z, r0, r0.w
mov oT1.w, c27.y
rcp r0.w, r0.w
mul r0.w, r0.w, c45.x
max r0.x, r0.w, c27.x
min oD0.w, r0.w, c27.y
mov oT0, v2
dp4 r0.z, v0, c5
add r0.x, -r0.z, c26.y
mul oFog, r0.x, c26.z
};
#else
VertexShader = compile vs_1_1 MainVS();
#endif
PixelShader = compile ps_1_3 MainPS(); // effect will not work > ps 1.3
}
}

61
Shaders/fx/Sky.fx Normal file
View File

@ -0,0 +1,61 @@
//--------------------------------------------------------------------------------------
// Sky.fx
// Experimental sky shader. Does nothing currently.
//--------------------------------------------------------------------------------------
float4x4 g_mWorldViewProjection : WorldViewProjection;
float4x4 g_World : World;
float4x4 g_View : View;
float4x4 g_Projection : Projection;
float intensityThreshold = 1.f;
float colorMultiplier = 1.f;
texture g_SkyTexture;
sampler g_SkyTextureSampler =
sampler_state
{
Texture = <g_SkyTexture>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
void RenderSceneVS(
float3 iPosition : POSITION,
float2 iTexCoord0 : TEXCOORD0,
out float4 oPosition : POSITION,
out float4 oColor0 : COLOR0,
out float2 oTexCoord0 : TEXCOORD0 )
{
oPosition = mul(iPosition, g_mWorldViewProjection);
//oPosition = mul(iPosition, g_World);
//oPosition = mul(oPosition, g_View);
//oPosition = mul(oPosition, g_Projection);
oColor0 = float4(1, 1, 1, 1);
oTexCoord0 = iTexCoord0;
}
float4 RenderScenePS(
float4 iColor : COLOR,
float2 iTexCoord0 : TEXCOORD0) : COLOR0
{
//return float4(1, 1, 1, 1);
return tex2D(g_SkyTextureSampler, iTexCoord0);
//oColor0 = tex2D(TextureDiffuse0Sampler, iTexCoord0);
//float intensity = dot(oColor0.rgb, float3(0.3, 0.59, 0.11));
//float p = smoothstep(intensityThreshold, 1.f, intensity);
//oColor0 = oColor0 * p * colorMultiplier;
}
technique RenderWithPixelShader
{
pass Pass0
{
VertexShader = compile vs_1_1 RenderSceneVS();
PixelShader = compile ps_2_0 RenderScenePS();
ZEnable = FALSE;
ZWriteEnable = FALSE;
}
}

62
Shaders/fx/Water.fx Normal file
View File

@ -0,0 +1,62 @@
//--------------------------------------------------------------------------------------
// Water.fx
// Very basic shader that implements D3DTOP_ADDSMOOTH functionality in HLSL, replicating
// the original fixed-function water rendering behavior.
//--------------------------------------------------------------------------------------
float4x4 g_WorldViewProjection : WorldViewProjection;
float4 g_TextureFactor : TextureFactor;
//float4 g_Fog : Fog;
texture2D g_WaterTexture;
sampler2D g_WaterTextureSampler =
sampler_state
{
Texture = <g_WaterTexture>;
};
struct VS_OUTPUT
{
float4 Position : POSITION; // vertex position
float2 TextureUV : TEXCOORD0; // vertex texture coords
float4 Color : COLOR0;
//float Fog : FOG;
};
VS_OUTPUT RenderSceneVS(float4 inPos : POSITION,
float4 inDiffuse : COLOR0,
float4 inTextureUV : TEXCOORD0)
{
VS_OUTPUT Output;
Output.Position = mul(inPos, g_WorldViewProjection);
Output.TextureUV = inTextureUV;
Output.Color = inDiffuse;
// Don't think this is right, but we can use FFP fog unless this is compiled for SM 3.0
//float4 r0;
//r0.z = inPos.z * g_WorldViewProjection[3];
//r0.x = -r0.z + g_Fog.y;
//Output.Fog.x = r0.x * g_Fog.z;
return Output;
}
float4 RenderScenePS(VS_OUTPUT input) : COLOR0
{
float4 texel = tex2D(g_WaterTextureSampler, input.TextureUV);
float4 result = saturate(texel + (1 - texel) * g_TextureFactor); // equivalent to saturate((texel + g_TextureFactor) - (texel * g_TextureFactor));
result.a = input.Color.a * g_TextureFactor.a;
return result;
}
technique RenderScene
{
pass P0
{
VertexShader = compile vs_2_0 RenderSceneVS();
PixelShader = compile ps_2_0 RenderScenePS();
}
}

0
Shaders/fxo/.gitkeep Normal file
View File