add gs
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
[
|
||||
{ "name": "AdornVS", "source": "adorn.hlsl", "target": "vs_2_0", "entrypoint": "AdornVS" },
|
||||
{ "name": "AdornSelfLitVS", "source": "adorn.hlsl", "target": "vs_2_0", "entrypoint": "AdornSelfLitVS" },
|
||||
{ "name": "AdornSelfLitHighlightVS", "source": "adorn.hlsl", "target": "vs_2_0", "entrypoint": "AdornSelfLitHighlightVS" },
|
||||
{ "name": "AdornLightingVS", "source": "adorn.hlsl", "target": "vs_2_0", "entrypoint": "AdornVS", "defines": "PIN_LIGHTING" },
|
||||
{ "name": "AdornFS", "source": "adorn.hlsl", "target": "ps_2_0", "entrypoint": "AdornPS" },
|
||||
{ "name": "DefaultStaticVS", "source": "default.hlsl", "target": "vs_2_0", "entrypoint": "DefaultVS" },
|
||||
{ "name": "DefaultStaticHQVS", "source": "default.hlsl", "target": "vs_2_0", "entrypoint": "DefaultVS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultSkinnedVS", "source": "default.hlsl", "target": "vs_2_0", "entrypoint": "DefaultVS", "defines": "PIN_SKINNED" },
|
||||
{ "name": "DefaultSkinnedHQVS", "source": "default.hlsl", "target": "vs_2_0", "entrypoint": "DefaultVS", "defines": "PIN_SKINNED PIN_HQ" },
|
||||
{ "name": "DefaultStaticDebugVS", "source": "default.hlsl", "target": "vs_2_0", "entrypoint": "DefaultVS", "defines": "PIN_DEBUG" },
|
||||
{ "name": "DefaultSkinnedDebugVS", "source": "default.hlsl", "target": "vs_2_0", "entrypoint": "DefaultVS", "defines": "PIN_SKINNED PIN_DEBUG" },
|
||||
{ "name": "DefaultFS", "source": "default.hlsl", "target": "ps_2_0", "entrypoint": "DefaultPS" },
|
||||
{ "name": "DefaultHQFS", "source": "default.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultHQGBufferFS", "source": "default.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultStaticReflectionVS", "source": "default.hlsl", "target": "vs_2_0", "entrypoint": "DefaultVS", "defines": "PIN_REFLECTION" },
|
||||
{ "name": "DefaultSkinnedReflectionVS", "source": "default.hlsl", "target": "vs_2_0", "entrypoint": "DefaultVS", "defines": "PIN_SKINNED PIN_REFLECTION" },
|
||||
{ "name": "DefaultStaticSurfaceHQVS", "source": "default.hlsl", "target": "vs_2_0", "entrypoint": "DefaultVS", "defines": "PIN_SURFACE PIN_HQ" },
|
||||
{ "name": "DefaultSkinnedSurfaceHQVS", "source": "default.hlsl", "target": "vs_2_0", "entrypoint": "DefaultVS", "defines": "PIN_SKINNED PIN_SURFACE PIN_HQ" },
|
||||
{ "name": "DefaultPlasticFS", "source": "plastic.hlsl", "target": "ps_2_0", "entrypoint": "DefaultPS" },
|
||||
{ "name": "DefaultPlasticHQFS", "source": "plastic.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultPlasticHQGBufferFS", "source": "plastic.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultPlasticReflectionFS", "source": "plastic.hlsl", "target": "ps_2_0", "entrypoint": "DefaultPS", "defines": "PIN_REFLECTION" },
|
||||
{ "name": "DefaultPlasticReflectionHQFS", "source": "plastic.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_REFLECTION PIN_HQ" },
|
||||
{ "name": "DefaultPlasticReflectionHQGBufferFS", "source": "plastic.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_REFLECTION PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultSmoothPlasticFS", "source": "smoothplastic.hlsl", "target": "ps_2_0", "entrypoint": "DefaultPS" },
|
||||
{ "name": "DefaultSmoothPlasticHQFS", "source": "smoothplastic.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultSmoothPlasticHQGBufferFS", "source": "smoothplastic.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultSmoothPlasticReflectionFS", "source": "smoothplastic.hlsl", "target": "ps_2_0", "entrypoint": "DefaultPS", "defines": "PIN_REFLECTION" },
|
||||
{ "name": "DefaultSmoothPlasticReflectionHQFS", "source": "smoothplastic.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_REFLECTION PIN_HQ" },
|
||||
{ "name": "DefaultSmoothPlasticReflectionHQGBufferFS", "source": "smoothplastic.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_REFLECTION PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultWoodHQFS", "source": "wood.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultWoodHQGBufferFS", "source": "wood.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultMarbleHQFS", "source": "marble.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultMarbleHQGBufferFS", "source": "marble.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultSlateHQFS", "source": "slate.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultSlateHQGBufferFS", "source": "slate.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultGraniteHQFS", "source": "granite.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultGraniteHQGBufferFS", "source": "granite.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultConcreteHQFS", "source": "concrete.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultConcreteHQGBufferFS", "source": "concrete.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultPebbleHQFS", "source": "pebble.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultPebbleHQGBufferFS", "source": "pebble.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultBrickHQFS", "source": "brick.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultBrickHQGBufferFS", "source": "brick.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultRustHQFS", "source": "rust.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultRustHQGBufferFS", "source": "rust.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultDiamondplateHQFS", "source": "diamondplate.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultDiamondplateHQGBufferFS", "source": "diamondplate.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultAluminumHQFS", "source": "aluminum.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultAluminumHQGBufferFS", "source": "aluminum.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultGrassHQFS", "source": "grass.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultGrassHQGBufferFS", "source": "grass.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultSandHQFS", "source": "sand.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultSandHQGBufferFS", "source": "sand.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultFabricHQFS", "source": "fabric.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultFabricHQGBufferFS", "source": "fabric.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "DefaultIceHQFS", "source": "ice.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ" },
|
||||
{ "name": "DefaultIceHQGBufferFS", "source": "ice.hlsl", "target": "ps_2_a", "entrypoint": "DefaultPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "MegaClusterVS", "source": "megacluster.hlsl", "target": "vs_2_0", "entrypoint": "MegaClusterVS" },
|
||||
{ "name": "MegaClusterHQVS", "source": "megacluster.hlsl", "target": "vs_2_0", "entrypoint": "MegaClusterVS", "defines": "PIN_HQ" },
|
||||
{ "name": "MegaClusterFS", "source": "megacluster.hlsl", "target": "ps_2_0", "entrypoint": "MegaClusterPS" },
|
||||
{ "name": "MegaClusterHQFS", "source": "megacluster.hlsl", "target": "ps_2_a", "entrypoint": "MegaClusterPS", "defines": "PIN_HQ" },
|
||||
{ "name": "MegaClusterHQGBufferFS", "source": "megacluster.hlsl", "target": "ps_2_a", "entrypoint": "MegaClusterPS", "defines": "PIN_HQ PIN_GBUFFER", "exclude": "glsles" },
|
||||
{ "name": "ParticleVS", "source": "particle.hlsl", "target": "vs_1_1", "entrypoint": "vs" },
|
||||
{ "name": "ParticleAddFS", "source": "particle.hlsl", "target": "ps_2_0", "entrypoint": "psAdd" },
|
||||
{ "name": "ParticleMulFS", "source": "particle.hlsl", "target": "ps_2_0", "entrypoint": "psMul" },
|
||||
{ "name": "ShadowExtrudeVS", "source": "shadowextrude.hlsl", "target": "vs_2_0", "entrypoint": "DefaultVS" },
|
||||
{ "name": "ShadowExtrudeFS", "source": "shadowextrude.hlsl", "target": "ps_2_0", "entrypoint": "DefaultPS" },
|
||||
{ "name": "ShadowQuadVS", "source": "shadowquad.hlsl", "target": "vs_1_1", "entrypoint": "QuadVS" },
|
||||
{ "name": "ShadowQuadFS", "source": "shadowquad.hlsl", "target": "ps_2_0", "entrypoint": "QuadPS" },
|
||||
{ "name": "SkyVS", "source": "sky.hlsl", "target": "vs_1_1", "entrypoint": "SkyVS" },
|
||||
{ "name": "SkyFS", "source": "sky.hlsl", "target": "ps_2_0", "entrypoint": "SkyPS" },
|
||||
{ "name": "TexCompVS", "source": "texcomp.hlsl", "target": "vs_1_1", "entrypoint": "TexCompVS" },
|
||||
{ "name": "TexCompFS", "source": "texcomp.hlsl", "target": "ps_2_0", "entrypoint": "TexCompPS" },
|
||||
{ "name": "TexCompPMAFS", "source": "texcomp.hlsl", "target": "ps_2_0", "entrypoint": "TexCompPMAPS" },
|
||||
{ "name": "UIVS", "source": "ui.hlsl", "target": "vs_1_1", "entrypoint": "UIVS" },
|
||||
{ "name": "UIFogVS", "source": "ui.hlsl", "target": "vs_1_1", "entrypoint": "UIVS", "defines": "PIN_FOG" },
|
||||
{ "name": "UIFS", "source": "ui.hlsl", "target": "ps_2_0", "entrypoint": "UIPS" },
|
||||
{ "name": "UIFogFS", "source": "ui.hlsl", "target": "ps_2_0", "entrypoint": "UIPS", "defines": "PIN_FOG" },
|
||||
{ "name": "WaterVS", "source": "water.hlsl", "target": "vs_2_0", "entrypoint": "water_vs" },
|
||||
{ "name": "WaterHQVS", "source": "water.hlsl", "target": "vs_2_0", "entrypoint": "water_vs", "defines": "PIN_HQ" },
|
||||
{ "name": "WaterFS", "source": "water.hlsl", "target": "ps_2_0", "entrypoint": "water_ps" },
|
||||
{ "name": "WaterHQFS", "source": "water.hlsl", "target": "ps_2_a", "entrypoint": "water_ps", "defines": "PIN_HQ" },
|
||||
|
||||
{ "name": "OLD_WaterVS", "source": "water_r3.hlsl", "target": "vs_2_0", "entrypoint": "water_vs" },
|
||||
{ "name": "OLD_WaterHQVS", "source": "water_r3.hlsl", "target": "vs_2_0", "entrypoint": "water_vs", "defines": "PIN_HQ" },
|
||||
{ "name": "OLD_WaterFS", "source": "water_r3.hlsl", "target": "ps_2_0", "entrypoint": "water_ps" },
|
||||
{ "name": "OLD_WaterHQFS", "source": "water_r3.hlsl", "target": "ps_2_a", "entrypoint": "water_ps", "defines": "PIN_HQ" },
|
||||
|
||||
|
||||
{ "name": "SSAOVS", "source": "ssao.hlsl", "target": "vs_1_1", "entrypoint": "ssao_vs", "exclude": "glsles" },
|
||||
{ "name": "SSAOFS", "source": "ssao.hlsl", "target": "ps_2_a", "entrypoint": "ssao_ps", "exclude": "glsles" },
|
||||
{ "name": "SSAODepthDownVS", "source": "ssao.hlsl", "target": "vs_1_1", "entrypoint": "ssaoDepthDown_vs", "exclude": "glsles" },
|
||||
{ "name": "SSAODepthDownFS", "source": "ssao.hlsl", "target": "ps_2_a", "entrypoint": "ssaoDepthDown_ps", "exclude": "glsles" },
|
||||
{ "name": "SSAOBlurXVS", "source": "ssao.hlsl", "target": "vs_1_1", "entrypoint": "ssaoBlurX_vs", "exclude": "glsles" },
|
||||
{ "name": "SSAOBlurXFS", "source": "ssao.hlsl", "target": "ps_2_a", "entrypoint": "ssaoBlurX_ps", "exclude": "glsles" },
|
||||
{ "name": "SSAOBlurYVS", "source": "ssao.hlsl", "target": "vs_1_1", "entrypoint": "ssaoBlurY_vs", "exclude": "glsles" },
|
||||
{ "name": "SSAOBlurYFS", "source": "ssao.hlsl", "target": "ps_2_a", "entrypoint": "ssaoBlurY_ps", "exclude": "glsles" },
|
||||
{ "name": "SSAOCompositVS", "source": "ssao.hlsl", "target": "vs_1_1", "entrypoint": "ssaoComposit_vs", "exclude": "glsles" },
|
||||
{ "name": "SSAOCompositBlankFS", "source": "ssao.hlsl", "target": "ps_2_a", "entrypoint": "ssaoCompositBlank_ps", "exclude": "glsles" },
|
||||
{ "name": "SSAOCompositFS", "source": "ssao.hlsl", "target": "ps_2_a", "entrypoint": "ssaoComposit_ps", "exclude": "glsles" },
|
||||
{ "name": "MSAACompositVS", "source": "msaa.hlsl", "target": "vs_1_1", "entrypoint": "msaaComposit_vs" },
|
||||
{ "name": "MSAACompositFS", "source": "msaa.hlsl", "target": "ps_2_0", "entrypoint": "msaaComposit_ps" }
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,88 @@
|
||||
#include "globals.h"
|
||||
|
||||
struct Appdata
|
||||
{
|
||||
float4 Position : POSITION;
|
||||
float2 Uv : TEXCOORD0;
|
||||
float3 Normal : NORMAL0;
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 HPosition : POSITION;
|
||||
|
||||
float2 Uv : TEXCOORD0;
|
||||
float4 Color : COLOR0;
|
||||
|
||||
float FogFactor : TEXCOORD1;
|
||||
};
|
||||
|
||||
uniform float4x4 WorldMatrix;
|
||||
|
||||
uniform float4 Color;
|
||||
|
||||
VertexOutput AdornSelfLitVSGeneric(Appdata IN, float ambient)
|
||||
{
|
||||
VertexOutput OUT = (VertexOutput)0;
|
||||
|
||||
float4 position = mul(WorldMatrix, IN.Position);
|
||||
float3 normal = normalize(mul((float3x3)WorldMatrix, IN.Normal));
|
||||
|
||||
float3 light = normalize(G.CameraPosition - position.xyz);
|
||||
float ndotl = saturate(dot(normal, light));
|
||||
|
||||
float lighting = ambient + (1 - ambient) * ndotl;
|
||||
float specular = pow(ndotl, 64.0);
|
||||
|
||||
OUT.HPosition = mul(G.ViewProjection, mul(WorldMatrix, IN.Position));
|
||||
OUT.Uv = IN.Uv;
|
||||
OUT.Color = float4(Color.rgb * lighting + specular, Color.a);
|
||||
|
||||
OUT.FogFactor = (G.FogParams.z - OUT.HPosition.w) * G.FogParams.w;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
VertexOutput AdornSelfLitVS(Appdata IN)
|
||||
{
|
||||
return AdornSelfLitVSGeneric(IN, 0.5f);
|
||||
}
|
||||
|
||||
VertexOutput AdornSelfLitHighlightVS(Appdata IN)
|
||||
{
|
||||
return AdornSelfLitVSGeneric(IN, 0.75f);
|
||||
}
|
||||
|
||||
VertexOutput AdornVS(Appdata IN)
|
||||
{
|
||||
VertexOutput OUT = (VertexOutput)0;
|
||||
|
||||
float4 position = mul(WorldMatrix, IN.Position);
|
||||
|
||||
#ifdef PIN_LIGHTING
|
||||
float3 normal = normalize(mul((float3x3)WorldMatrix, IN.Normal));
|
||||
float ndotl = dot(normal, -G.Lamp0Dir);
|
||||
float3 lighting = G.AmbientColor + saturate(ndotl) * G.Lamp0Color + saturate(-ndotl) * G.Lamp1Color;
|
||||
#else
|
||||
float3 lighting = 1;
|
||||
#endif
|
||||
|
||||
OUT.HPosition = mul(G.ViewProjection, position);
|
||||
OUT.Uv = IN.Uv;
|
||||
OUT.Color = float4(Color.rgb * lighting, Color.a);
|
||||
|
||||
OUT.FogFactor = (G.FogParams.z - OUT.HPosition.w) * G.FogParams.w;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
sampler2D DiffuseMap: register(s0);
|
||||
|
||||
float4 AdornPS(VertexOutput IN): COLOR0
|
||||
{
|
||||
float4 result = tex2D(DiffuseMap, IN.Uv) * IN.Color;
|
||||
|
||||
result.rgb = lerp(G.FogColor, result.rgb, saturate(IN.FogFactor));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#define CFG_TEXTURE_TILING 1
|
||||
|
||||
#define CFG_DIFFUSE_SCALE 1
|
||||
#define CFG_SPECULAR_SCALE 1
|
||||
#define CFG_GLOSS_SCALE 256
|
||||
#define CFG_REFLECTION_SCALE 0.6
|
||||
|
||||
#define CFG_NORMAL_SHADOW_SCALE 0
|
||||
|
||||
#define CFG_SPECULAR_LOD 0.94
|
||||
#define CFG_GLOSS_LOD 240
|
||||
|
||||
#define CFG_NORMAL_DETAIL_TILING 0
|
||||
#define CFG_NORMAL_DETAIL_SCALE 0
|
||||
|
||||
#define CFG_FAR_TILING 0.25
|
||||
#define CFG_FAR_DIFFUSE_CUTOFF 0
|
||||
#define CFG_FAR_NORMAL_CUTOFF 0.75
|
||||
#define CFG_FAR_SPECULAR_CUTOFF 0
|
||||
|
||||
#define CFG_OPT_DIFFUSE_CONST
|
||||
|
||||
#include "material.hlsl"
|
||||
@@ -0,0 +1,21 @@
|
||||
#define CFG_TEXTURE_TILING 1
|
||||
|
||||
#define CFG_DIFFUSE_SCALE 1
|
||||
#define CFG_SPECULAR_SCALE 1.3
|
||||
#define CFG_GLOSS_SCALE 64
|
||||
#define CFG_REFLECTION_SCALE 0
|
||||
|
||||
#define CFG_NORMAL_SHADOW_SCALE 0.1
|
||||
|
||||
#define CFG_SPECULAR_LOD 0.26
|
||||
#define CFG_GLOSS_LOD 26
|
||||
|
||||
#define CFG_NORMAL_DETAIL_TILING 0
|
||||
#define CFG_NORMAL_DETAIL_SCALE 0
|
||||
|
||||
#define CFG_FAR_TILING 0
|
||||
#define CFG_FAR_DIFFUSE_CUTOFF 0
|
||||
#define CFG_FAR_NORMAL_CUTOFF 0
|
||||
#define CFG_FAR_SPECULAR_CUTOFF 0
|
||||
|
||||
#include "material.hlsl"
|
||||
@@ -0,0 +1,140 @@
|
||||
#include "globals.h"
|
||||
|
||||
// GLSLES has limited number of vertex shader registers so we have to use less bones
|
||||
#ifdef GLSLES
|
||||
#define MAX_BONE_COUNT 32
|
||||
#else
|
||||
#define MAX_BONE_COUNT 72
|
||||
#endif
|
||||
|
||||
// PowerVR saturate() is compiled to min/max pair
|
||||
// These are cross-platform specialized saturates that are free on PC and only cost 1 cycle on PowerVR
|
||||
#ifdef GLSLES
|
||||
float saturate0(float v) { return max(v, 0); }
|
||||
float saturate1(float v) { return min(v, 1); }
|
||||
#else
|
||||
float saturate0(float v) { return saturate(v); }
|
||||
float saturate1(float v) { return saturate(v); }
|
||||
#endif
|
||||
|
||||
#define GBUFFER_MAX_DEPTH 500.0f
|
||||
|
||||
float4 gbufferPack(float depth, float3 diffuse, float3 specular, float fog)
|
||||
{
|
||||
depth = saturate(depth / GBUFFER_MAX_DEPTH);
|
||||
|
||||
const float3 bitSh = float3(255*255, 255, 1);
|
||||
const float3 lumVec = float3(0.299, 0.587, 0.114);
|
||||
|
||||
float2 comp;
|
||||
comp = depth*float2(255,255*256);
|
||||
comp = frac(comp);
|
||||
comp = float2(depth,comp.x*256/255) - float2(comp.x, comp.y)/255;
|
||||
|
||||
float4 result;
|
||||
|
||||
result.r = lerp(1, dot(specular, lumVec), saturate(3 * fog));
|
||||
result.g = lerp(0, dot(diffuse, lumVec), saturate(3 * fog));
|
||||
result.ba = comp.yx;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
float3 getPosInLightSpace(float3 posIn)
|
||||
{
|
||||
float3 lightToWorld = posIn - G.BlobShadowData0.xyz;
|
||||
return float3(dot(G.Lamp0Right, lightToWorld), dot(G.Lamp0Up, lightToWorld), dot(G.Lamp0Dir, lightToWorld));
|
||||
}
|
||||
|
||||
float getSingleBlobShadowOrigin(float3 lightSpacePos, float4 blobData)
|
||||
{
|
||||
float distSq = dot(lightSpacePos.xy, lightSpacePos.xy);
|
||||
|
||||
// OH MY GOD! a BRANCH? Why? Because this produces a better assembly over other solution
|
||||
float projDistScaled = lightSpacePos.z * 0.04;
|
||||
if (lightSpacePos.z < 0)
|
||||
projDistScaled = lightSpacePos.z * -0.3;
|
||||
|
||||
return min(1, distSq * G.OutlineBrightness_ShadowInfo.z + projDistScaled + blobData.a);
|
||||
}
|
||||
|
||||
float getSingleBlobShadow(float3 lightSpacePos, float4 blobData)
|
||||
{
|
||||
return getSingleBlobShadowOrigin(lightSpacePos - blobData.xyz, blobData);
|
||||
}
|
||||
|
||||
float getBlobShadow(float3 lightSpacePos)
|
||||
{
|
||||
#ifdef PIN_HQ
|
||||
float shadow = min(getSingleBlobShadowOrigin(lightSpacePos, G.BlobShadowData0), getSingleBlobShadow(lightSpacePos, G.BlobShadowData1));
|
||||
shadow = min(getSingleBlobShadow(lightSpacePos, G.BlobShadowData2), shadow);
|
||||
shadow = min(getSingleBlobShadow(lightSpacePos, G.BlobShadowData3), shadow);
|
||||
return shadow;
|
||||
#else
|
||||
return getSingleBlobShadowOrigin(lightSpacePos, G.BlobShadowData0);
|
||||
#endif
|
||||
}
|
||||
|
||||
float3 lgridOffset(float3 v, float3 n)
|
||||
{
|
||||
// cells are 4 studs in size
|
||||
// offset in normal direction to prevent self-occlusion
|
||||
// the offset has to be 1.5 cells in order to fully eliminate the influence of the source cell with trilinear filtering
|
||||
// (i.e. 1 cell is enough for point filtering, but is not enough for trilinear filtering)
|
||||
return v + n * (1.5f * 4.f);
|
||||
}
|
||||
|
||||
float3 lgridPrepareSample(float3 c)
|
||||
{
|
||||
// yxz swizzle is necessary for GLSLES sampling to work efficiently
|
||||
// (having .y as the first component allows to do the LUT lookup as a non-dependent texture fetch)
|
||||
return c.yxz * G.LightConfig0.xyz + G.LightConfig1.xyz;
|
||||
}
|
||||
|
||||
#ifdef GLSLES
|
||||
#define LGRID_SAMPLER sampler2D
|
||||
|
||||
float4 lgridSample(LGRID_SAMPLER t, sampler2D lut, float3 data)
|
||||
{
|
||||
float4 offsets = tex2D(lut, data.xy);
|
||||
|
||||
// texture is 64 pixels high
|
||||
// let's compute slice lerp coeff
|
||||
float slicef = frac(data.x * 64);
|
||||
|
||||
// texture has 64 slices with 8x8 atlas setup
|
||||
float2 base = saturate(data.yz) * 0.125;
|
||||
|
||||
float4 s0 = tex2D(t, base + offsets.xy);
|
||||
float4 s1 = tex2D(t, base + offsets.zw);
|
||||
|
||||
return lerp(s0, s1, slicef);
|
||||
}
|
||||
#else
|
||||
#define LGRID_SAMPLER sampler3D
|
||||
|
||||
float4 lgridSample(LGRID_SAMPLER t, sampler2D lut, float3 data)
|
||||
{
|
||||
float3 edge = step(G.LightConfig3.xyz, abs(data - G.LightConfig2.xyz));
|
||||
float edgef = saturate1(dot(edge, 1));
|
||||
|
||||
// replace data with 0 on edges to minimize texture cache misses
|
||||
float4 light = tex3D(t, data.yzx - data.yzx * edgef);
|
||||
|
||||
return lerp(light, G.LightBorder, edgef);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GLSLES
|
||||
float3 nmapUnpack(float4 value)
|
||||
{
|
||||
return value.rgb * 2 - 1;
|
||||
}
|
||||
#else
|
||||
float3 nmapUnpack(float4 value)
|
||||
{
|
||||
float2 xy = value.ag * 2 - 1;
|
||||
|
||||
return float3(xy, sqrt(saturate(1 + dot(-xy, xy))));
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
#define CFG_TEXTURE_TILING 1
|
||||
|
||||
#define CFG_DIFFUSE_SCALE 1
|
||||
#define CFG_SPECULAR_SCALE 1.3
|
||||
#define CFG_GLOSS_SCALE 128
|
||||
#define CFG_REFLECTION_SCALE 0
|
||||
|
||||
#define CFG_NORMAL_SHADOW_SCALE 0
|
||||
|
||||
#define CFG_SPECULAR_LOD 0.07
|
||||
#define CFG_GLOSS_LOD 22
|
||||
|
||||
#define CFG_NORMAL_DETAIL_TILING 10
|
||||
#define CFG_NORMAL_DETAIL_SCALE 1
|
||||
|
||||
#define CFG_FAR_TILING 0.25
|
||||
#define CFG_FAR_DIFFUSE_CUTOFF 0.75
|
||||
#define CFG_FAR_NORMAL_CUTOFF 0
|
||||
#define CFG_FAR_SPECULAR_CUTOFF 0
|
||||
|
||||
#define CFG_OPT_NORMAL_CONST
|
||||
|
||||
#include "material.hlsl"
|
||||
@@ -0,0 +1,267 @@
|
||||
#include "common.h"
|
||||
|
||||
struct Appdata
|
||||
{
|
||||
float4 Position : POSITION;
|
||||
float3 Normal : NORMAL;
|
||||
float2 Uv : TEXCOORD0;
|
||||
float2 UvStuds : TEXCOORD1;
|
||||
|
||||
float4 Color : COLOR0;
|
||||
|
||||
// int4 produces better D3D asm, float4 produces better GLSL code
|
||||
#ifdef GLSL
|
||||
float4 Extra : COLOR1;
|
||||
#else
|
||||
int4 Extra : COLOR1;
|
||||
#endif
|
||||
|
||||
#ifdef PIN_SURFACE
|
||||
float3 Tangent : TEXCOORD2;
|
||||
#endif
|
||||
float4 EdgeDistances : TEXCOORD3;
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 HPosition : POSITION;
|
||||
float4 Uv_EdgeDistance1 : TEXCOORD0;
|
||||
float4 UvStuds_EdgeDistance2 : TEXCOORD1;
|
||||
|
||||
float4 Color : COLOR0;
|
||||
float4 LightPosition_Fog : TEXCOORD2;
|
||||
|
||||
#if defined(PIN_HQ) || defined(PIN_REFLECTION)
|
||||
float4 View_DepthMulFadeout : TEXCOORD3;
|
||||
float4 Normal_SpecPower : TEXCOORD4;
|
||||
#endif
|
||||
|
||||
#ifdef PIN_SURFACE
|
||||
float3 Tangent : TEXCOORD5;
|
||||
#else
|
||||
float4 Diffuse_Specular : COLOR1;
|
||||
#endif
|
||||
|
||||
float4 PosLightSpace_Reflectance: TEXCOORD6;
|
||||
};
|
||||
|
||||
#ifdef PIN_SKINNED
|
||||
uniform float4 WorldMatrixArray[MAX_BONE_COUNT * 3];
|
||||
#endif
|
||||
|
||||
#ifdef PIN_DEBUG
|
||||
uniform float4 DebugColor;
|
||||
#endif
|
||||
|
||||
VertexOutput DefaultVS(Appdata IN)
|
||||
{
|
||||
VertexOutput OUT = (VertexOutput)0;
|
||||
|
||||
// Transform position and normal to world space
|
||||
#ifdef PIN_SKINNED
|
||||
int boneIndex = IN.Extra.r;
|
||||
|
||||
float4 worldRow0 = WorldMatrixArray[boneIndex * 3 + 0];
|
||||
float4 worldRow1 = WorldMatrixArray[boneIndex * 3 + 1];
|
||||
float4 worldRow2 = WorldMatrixArray[boneIndex * 3 + 2];
|
||||
|
||||
float3 posWorld = float3(dot(worldRow0, IN.Position), dot(worldRow1, IN.Position), dot(worldRow2, IN.Position));
|
||||
float3 normalWorld = float3(dot(worldRow0.xyz, IN.Normal), dot(worldRow1.xyz, IN.Normal), dot(worldRow2.xyz, IN.Normal));
|
||||
#else
|
||||
float3 posWorld = IN.Position.xyz;
|
||||
float3 normalWorld = IN.Normal;
|
||||
#endif
|
||||
|
||||
// Decode diffuse/specular parameters; encoding depends on the skinned flag due to vertex declaration differences
|
||||
#if defined(PIN_DEBUG)
|
||||
float4 color = DebugColor;
|
||||
#else
|
||||
float4 color = IN.Color;
|
||||
#endif
|
||||
|
||||
float specularIntensity = IN.Extra.g / 255.f;
|
||||
float specularPower = IN.Extra.b;
|
||||
|
||||
float ndotl = dot(normalWorld, -G.Lamp0Dir);
|
||||
|
||||
#ifdef PIN_HQ
|
||||
// We'll calculate specular in pixel shader
|
||||
float2 lt = float2(saturate(ndotl), (ndotl > 0));
|
||||
#else
|
||||
// Using lit here improves performance on software vertex shader implementations
|
||||
float2 lt = lit(ndotl, dot(normalize(-G.Lamp0Dir + normalize(G.CameraPosition - posWorld.xyz)), normalWorld), specularPower).yz;
|
||||
#endif
|
||||
|
||||
OUT.HPosition = mul(G.ViewProjection, float4(posWorld, 1));
|
||||
|
||||
OUT.Uv_EdgeDistance1.xy = IN.Uv;
|
||||
OUT.UvStuds_EdgeDistance2.xy = IN.UvStuds;
|
||||
|
||||
OUT.Color = color;
|
||||
OUT.LightPosition_Fog = float4(lgridPrepareSample(lgridOffset(posWorld, normalWorld)), (G.FogParams.z - OUT.HPosition.w) * G.FogParams.w);
|
||||
|
||||
#if defined(PIN_HQ) || defined(PIN_REFLECTION)
|
||||
OUT.View_DepthMulFadeout = float4(G.CameraPosition - posWorld, OUT.HPosition.w * G.FadeDistance.y);
|
||||
float4 edgeDistances = IN.EdgeDistances*G.FadeDistance.z + 0.5 * OUT.View_DepthMulFadeout.w;
|
||||
OUT.Uv_EdgeDistance1.zw = edgeDistances.xy;
|
||||
OUT.UvStuds_EdgeDistance2.zw = edgeDistances.zw;
|
||||
OUT.Normal_SpecPower = float4(normalWorld, specularPower);
|
||||
OUT.PosLightSpace_Reflectance.w = IN.Extra.a / 255.f;
|
||||
#endif
|
||||
|
||||
#ifdef PIN_SURFACE
|
||||
#ifdef PIN_SKINNED
|
||||
float3 tangent = float3(dot(worldRow0.xyz, IN.Tangent), dot(worldRow1.xyz, IN.Tangent), dot(worldRow2.xyz, IN.Tangent));
|
||||
#else
|
||||
float3 tangent = IN.Tangent;
|
||||
#endif
|
||||
|
||||
OUT.Tangent = tangent;
|
||||
#else
|
||||
float3 diffuse = lt.x * G.Lamp0Color + max(-ndotl, 0) * G.Lamp1Color;
|
||||
|
||||
OUT.Diffuse_Specular = float4(diffuse, lt.y * specularIntensity);
|
||||
#endif
|
||||
|
||||
OUT.PosLightSpace_Reflectance.xyz = getPosInLightSpace(posWorld);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
#ifdef PIN_SURFACE
|
||||
struct SurfaceInput
|
||||
{
|
||||
float4 Color;
|
||||
float2 Uv;
|
||||
float2 UvStuds;
|
||||
|
||||
#ifdef PIN_REFLECTION
|
||||
float Reflectance;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct Surface
|
||||
{
|
||||
float3 albedo;
|
||||
float3 normal;
|
||||
float specular;
|
||||
float gloss;
|
||||
float reflectance;
|
||||
};
|
||||
|
||||
Surface surfaceShader(SurfaceInput IN, float fade);
|
||||
|
||||
Surface surfaceShaderExec(VertexOutput IN)
|
||||
{
|
||||
SurfaceInput SIN;
|
||||
SIN.Color = IN.Color;
|
||||
SIN.Uv = IN.Uv_EdgeDistance1.xy;
|
||||
SIN.UvStuds = IN.UvStuds_EdgeDistance2.xy;
|
||||
|
||||
#ifdef PIN_REFLECTION
|
||||
SIN.Reflectance = IN.PosLightSpace_Reflectance.w;
|
||||
#endif
|
||||
|
||||
float fade = saturate0(1 - IN.View_DepthMulFadeout.w);
|
||||
|
||||
return surfaceShader(SIN, fade);
|
||||
}
|
||||
#endif
|
||||
|
||||
sampler2D StudsMap: register(s0);
|
||||
LGRID_SAMPLER LightMap: register(s1);
|
||||
sampler2D LightMapLookup: register(s2);
|
||||
|
||||
sampler2D DiffuseMap: register(s3);
|
||||
sampler2D NormalMap: register(s4);
|
||||
samplerCUBE EnvironmentMap: register(s5);
|
||||
|
||||
sampler2D SpecularMap: register(s6);
|
||||
sampler2D NormalDetailMap: register(s7);
|
||||
|
||||
void DefaultPS(VertexOutput IN,
|
||||
#ifdef PIN_GBUFFER
|
||||
out float4 oColor1: COLOR1,
|
||||
#endif
|
||||
out float4 oColor0: COLOR0)
|
||||
{
|
||||
// Compute albedo term
|
||||
#ifdef PIN_SURFACE
|
||||
Surface surface = surfaceShaderExec(IN);
|
||||
|
||||
float4 albedo = float4(surface.albedo, IN.Color.a);
|
||||
|
||||
float3 bitangent = cross(IN.Normal_SpecPower.xyz, IN.Tangent.xyz);
|
||||
float3 normal = normalize(surface.normal.x * IN.Tangent.xyz + surface.normal.y * bitangent + surface.normal.z * IN.Normal_SpecPower.xyz);
|
||||
|
||||
float ndotl = dot(normal, -G.Lamp0Dir);
|
||||
|
||||
float3 diffuseIntensity = saturate0(ndotl) * G.Lamp0Color + max(-ndotl, 0) * G.Lamp1Color;
|
||||
float specularIntensity = step(0, ndotl) * surface.specular;
|
||||
float specularPower = surface.gloss;
|
||||
|
||||
float reflectance = surface.reflectance;
|
||||
#else
|
||||
#ifdef PIN_PLASTIC
|
||||
float4 studs = tex2D(StudsMap, IN.UvStuds_EdgeDistance2.xy);
|
||||
float4 albedo = float4(IN.Color.rgb * 2 * studs.rgb, IN.Color.a);
|
||||
#else
|
||||
float4 albedo = tex2D(DiffuseMap, IN.Uv_EdgeDistance1.xy) * IN.Color;
|
||||
#endif
|
||||
|
||||
#ifdef PIN_HQ
|
||||
float3 normal = normalize(IN.Normal_SpecPower.xyz);
|
||||
float specularPower = IN.Normal_SpecPower.w;
|
||||
#elif defined(PIN_REFLECTION)
|
||||
float3 normal = IN.Normal_SpecPower.xyz;
|
||||
#endif
|
||||
|
||||
float3 diffuseIntensity = IN.Diffuse_Specular.xyz;
|
||||
float specularIntensity = IN.Diffuse_Specular.w;
|
||||
|
||||
#ifdef PIN_REFLECTION
|
||||
float reflectance = IN.PosLightSpace_Reflectance.w;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
float4 light = lgridSample(LightMap, LightMapLookup, IN.LightPosition_Fog.xyz);
|
||||
|
||||
// Compute reflection term
|
||||
#if defined(PIN_SURFACE) || defined(PIN_REFLECTION)
|
||||
float3 reflection = texCUBE(EnvironmentMap, reflect(-IN.View_DepthMulFadeout.xyz, normal)).rgb;
|
||||
|
||||
albedo.rgb = lerp(albedo.rgb, reflection.rgb, reflectance);
|
||||
#endif
|
||||
|
||||
float shadow = getBlobShadow(IN.PosLightSpace_Reflectance.xyz) * light.a;
|
||||
|
||||
// Compute diffuse term
|
||||
float3 diffuse = (G.AmbientColor + diffuseIntensity * shadow + light.rgb) * albedo.rgb;
|
||||
|
||||
// Compute specular term
|
||||
#ifdef PIN_HQ
|
||||
float3 specular = G.Lamp0Color * (specularIntensity * shadow * (float)(half)pow(saturate(dot(normal, normalize(-G.Lamp0Dir + normalize(IN.View_DepthMulFadeout.xyz)))), specularPower));
|
||||
#else
|
||||
float3 specular = G.Lamp0Color * (specularIntensity * shadow);
|
||||
#endif
|
||||
|
||||
// Combine
|
||||
oColor0.rgb = diffuse.rgb + specular.rgb;
|
||||
oColor0.a = albedo.a;
|
||||
|
||||
#ifdef PIN_HQ
|
||||
float outlineFade = saturate1(IN.View_DepthMulFadeout.w * G.OutlineBrightness_ShadowInfo.x + G.OutlineBrightness_ShadowInfo.y);
|
||||
float2 minIntermediate = min(IN.Uv_EdgeDistance1.wz, IN.UvStuds_EdgeDistance2.wz);
|
||||
float minEdgesPlus = min(minIntermediate.x, minIntermediate.y) / IN.View_DepthMulFadeout.w;
|
||||
oColor0.rgb *= saturate1(outlineFade *(1.5 - minEdgesPlus) + minEdgesPlus);
|
||||
#endif
|
||||
|
||||
float fogAlpha = saturate(IN.LightPosition_Fog.w);
|
||||
|
||||
oColor0.rgb = lerp(G.FogColor, oColor0.rgb, fogAlpha);
|
||||
|
||||
#ifdef PIN_GBUFFER
|
||||
oColor1 = gbufferPack(IN.View_DepthMulFadeout.w*G.FadeDistance.x, diffuse.rgb, specular.rgb, fogAlpha);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#define CFG_TEXTURE_TILING 1
|
||||
|
||||
#define CFG_DIFFUSE_SCALE 1
|
||||
#define CFG_SPECULAR_SCALE 2.7
|
||||
#define CFG_GLOSS_SCALE 256
|
||||
#define CFG_REFLECTION_SCALE 0
|
||||
|
||||
#define CFG_NORMAL_SHADOW_SCALE 0.5
|
||||
|
||||
#define CFG_SPECULAR_LOD 0.9
|
||||
#define CFG_GLOSS_LOD 160
|
||||
|
||||
#define CFG_NORMAL_DETAIL_TILING 0
|
||||
#define CFG_NORMAL_DETAIL_SCALE 0
|
||||
|
||||
#define CFG_FAR_TILING 0
|
||||
#define CFG_FAR_DIFFUSE_CUTOFF 0
|
||||
#define CFG_FAR_NORMAL_CUTOFF 0
|
||||
#define CFG_FAR_SPECULAR_CUTOFF 0
|
||||
|
||||
#include "material.hlsl"
|
||||
@@ -0,0 +1,21 @@
|
||||
#define CFG_TEXTURE_TILING 1
|
||||
|
||||
#define CFG_DIFFUSE_SCALE 1
|
||||
#define CFG_SPECULAR_SCALE 0.2
|
||||
#define CFG_GLOSS_SCALE 128
|
||||
#define CFG_REFLECTION_SCALE 0
|
||||
|
||||
#define CFG_NORMAL_SHADOW_SCALE 0.2
|
||||
|
||||
#define CFG_SPECULAR_LOD 0.03
|
||||
#define CFG_GLOSS_LOD 16
|
||||
|
||||
#define CFG_NORMAL_DETAIL_TILING 0
|
||||
#define CFG_NORMAL_DETAIL_SCALE 0
|
||||
|
||||
#define CFG_FAR_TILING 0
|
||||
#define CFG_FAR_DIFFUSE_CUTOFF 0
|
||||
#define CFG_FAR_NORMAL_CUTOFF 0
|
||||
#define CFG_FAR_SPECULAR_CUTOFF 0
|
||||
|
||||
#include "material.hlsl"
|
||||
@@ -0,0 +1,34 @@
|
||||
struct Globals
|
||||
{
|
||||
float4x4 ViewProjection;
|
||||
|
||||
float4 ViewRight;
|
||||
float4 ViewUp;
|
||||
float3 CameraPosition;
|
||||
|
||||
float3 AmbientColor;
|
||||
float3 Lamp0Color;
|
||||
float3 Lamp0Dir;
|
||||
float3 Lamp0Right;
|
||||
float3 Lamp0Up;
|
||||
float3 Lamp1Color;
|
||||
|
||||
float3 FogColor;
|
||||
float4 FogParams;
|
||||
|
||||
float4 LightBorder;
|
||||
float4 LightConfig0;
|
||||
float4 LightConfig1;
|
||||
float4 LightConfig2;
|
||||
float4 LightConfig3;
|
||||
|
||||
float3 FadeDistance;
|
||||
float4 OutlineBrightness_ShadowInfo;
|
||||
|
||||
float4 BlobShadowData0;
|
||||
float4 BlobShadowData1;
|
||||
float4 BlobShadowData2;
|
||||
float4 BlobShadowData3;
|
||||
};
|
||||
|
||||
uniform Globals G: register(c0);
|
||||
@@ -0,0 +1,23 @@
|
||||
#define CFG_TEXTURE_TILING 1
|
||||
|
||||
#define CFG_DIFFUSE_SCALE 1
|
||||
#define CFG_SPECULAR_SCALE 0.5
|
||||
#define CFG_GLOSS_SCALE 128
|
||||
#define CFG_REFLECTION_SCALE 0.2
|
||||
|
||||
#define CFG_NORMAL_SHADOW_SCALE 0.1
|
||||
|
||||
#define CFG_SPECULAR_LOD 0.19
|
||||
#define CFG_GLOSS_LOD 24
|
||||
|
||||
#define CFG_NORMAL_DETAIL_TILING 0
|
||||
#define CFG_NORMAL_DETAIL_SCALE 0
|
||||
|
||||
#define CFG_FAR_TILING 0.25
|
||||
#define CFG_FAR_DIFFUSE_CUTOFF 0.75
|
||||
#define CFG_FAR_NORMAL_CUTOFF 0
|
||||
#define CFG_FAR_SPECULAR_CUTOFF 0
|
||||
|
||||
#define CFG_OPT_NORMAL_CONST
|
||||
|
||||
#include "material.hlsl"
|
||||
@@ -0,0 +1,21 @@
|
||||
#define CFG_TEXTURE_TILING 1
|
||||
|
||||
#define CFG_DIFFUSE_SCALE 1
|
||||
#define CFG_SPECULAR_SCALE 1
|
||||
#define CFG_GLOSS_SCALE 256
|
||||
#define CFG_REFLECTION_SCALE 0
|
||||
|
||||
#define CFG_NORMAL_SHADOW_SCALE 0.5
|
||||
|
||||
#define CFG_SPECULAR_LOD 0.17
|
||||
#define CFG_GLOSS_LOD 18
|
||||
|
||||
#define CFG_NORMAL_DETAIL_TILING 0
|
||||
#define CFG_NORMAL_DETAIL_SCALE 0
|
||||
|
||||
#define CFG_FAR_TILING 0
|
||||
#define CFG_FAR_DIFFUSE_CUTOFF 0
|
||||
#define CFG_FAR_NORMAL_CUTOFF 0
|
||||
#define CFG_FAR_SPECULAR_CUTOFF 0
|
||||
|
||||
#include "material.hlsl"
|
||||
@@ -0,0 +1,23 @@
|
||||
#define CFG_TEXTURE_TILING 1
|
||||
|
||||
#define CFG_DIFFUSE_SCALE 1.0
|
||||
#define CFG_SPECULAR_SCALE 1.2
|
||||
#define CFG_GLOSS_SCALE 256
|
||||
#define CFG_REFLECTION_SCALE 0.3
|
||||
|
||||
#define CFG_NORMAL_SHADOW_SCALE 0
|
||||
|
||||
#define CFG_SPECULAR_LOD 1
|
||||
#define CFG_GLOSS_LOD 190
|
||||
|
||||
#define CFG_NORMAL_DETAIL_TILING 0
|
||||
#define CFG_NORMAL_DETAIL_SCALE 0
|
||||
|
||||
#define CFG_FAR_TILING 0.25
|
||||
#define CFG_FAR_DIFFUSE_CUTOFF 0
|
||||
#define CFG_FAR_NORMAL_CUTOFF 0
|
||||
#define CFG_FAR_SPECULAR_CUTOFF 0.75
|
||||
|
||||
#define CFG_OPT_DIFFUSE_CONST
|
||||
|
||||
#include "material.hlsl"
|
||||
@@ -0,0 +1,23 @@
|
||||
#define CFG_TEXTURE_TILING 1
|
||||
|
||||
#define CFG_DIFFUSE_SCALE 1
|
||||
#define CFG_SPECULAR_SCALE 1.0
|
||||
#define CFG_GLOSS_SCALE 128
|
||||
#define CFG_REFLECTION_SCALE 0.2
|
||||
|
||||
#define CFG_NORMAL_SHADOW_SCALE 0.1
|
||||
|
||||
#define CFG_SPECULAR_LOD 0.7
|
||||
#define CFG_GLOSS_LOD 54
|
||||
|
||||
#define CFG_NORMAL_DETAIL_TILING 0
|
||||
#define CFG_NORMAL_DETAIL_SCALE 0
|
||||
|
||||
#define CFG_FAR_TILING 0
|
||||
#define CFG_FAR_DIFFUSE_CUTOFF 0
|
||||
#define CFG_FAR_NORMAL_CUTOFF 0
|
||||
#define CFG_FAR_SPECULAR_CUTOFF 0
|
||||
|
||||
#define CFG_OPT_NORMAL_CONST
|
||||
|
||||
#include "material.hlsl"
|
||||
@@ -0,0 +1,74 @@
|
||||
#define PIN_SURFACE
|
||||
#include "default.hlsl"
|
||||
|
||||
float4 sampleFar(sampler2D s, float2 uv, float fade, float cutoff)
|
||||
{
|
||||
#ifdef GLSLES
|
||||
return tex2D(s, uv);
|
||||
#else
|
||||
if (cutoff == 0)
|
||||
return tex2D(s, uv);
|
||||
else
|
||||
{
|
||||
float cscale = 1 / (1 - cutoff);
|
||||
|
||||
return lerp(tex2D(s, uv * (CFG_FAR_TILING)), tex2D(s, uv), saturate0(fade * cscale - cutoff * cscale));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Surface surfaceShader(SurfaceInput IN, float fade)
|
||||
{
|
||||
float2 uv = IN.Uv * (CFG_TEXTURE_TILING);
|
||||
|
||||
#ifdef CFG_OPT_DIFFUSE_CONST
|
||||
float4 diffuse = 1;
|
||||
#else
|
||||
float4 diffuse = sampleFar(DiffuseMap, uv, fade, CFG_FAR_DIFFUSE_CUTOFF);
|
||||
|
||||
diffuse.rgb = lerp(float3(1, 1, 1), diffuse.rgb * (CFG_DIFFUSE_SCALE), fade);
|
||||
#endif
|
||||
|
||||
#ifdef CFG_OPT_NORMAL_CONST
|
||||
float3 normal = float3(0, 0, 1);
|
||||
#else
|
||||
float3 normal = nmapUnpack(sampleFar(NormalMap, uv, fade, CFG_FAR_NORMAL_CUTOFF));
|
||||
#endif
|
||||
|
||||
#ifndef GLSLES
|
||||
float3 normalDetail = nmapUnpack(tex2D(NormalDetailMap, uv * (CFG_NORMAL_DETAIL_TILING)));
|
||||
|
||||
normal.xy += normalDetail.xy * (CFG_NORMAL_DETAIL_SCALE);
|
||||
#endif
|
||||
|
||||
normal.xy *= fade;
|
||||
|
||||
float shadowFactor = 1 + normal.x * (CFG_NORMAL_SHADOW_SCALE);
|
||||
|
||||
#ifdef CFG_OPT_BLEND_COLOR
|
||||
float3 albedo = lerp(float3(1, 1, 1), IN.Color.rgb, lerp(1, diffuse.a, fade)) * diffuse.rgb * shadowFactor;
|
||||
#else
|
||||
float3 albedo = IN.Color.rgb * diffuse.rgb * shadowFactor;
|
||||
#endif
|
||||
|
||||
#ifndef GLSLES
|
||||
float4 studs = tex2D(StudsMap, IN.UvStuds);
|
||||
|
||||
albedo *= studs.rgb * 2;
|
||||
#endif
|
||||
|
||||
float2 specular = sampleFar(SpecularMap, uv, fade, CFG_FAR_SPECULAR_CUTOFF).rg;
|
||||
|
||||
// make sure glossiness is never 0 to avoid fp specials
|
||||
float2 specbase = specular * float2(CFG_SPECULAR_SCALE, CFG_GLOSS_SCALE) + float2(0, 0.01);
|
||||
float2 specfade = lerp(float2(CFG_SPECULAR_LOD, CFG_GLOSS_LOD), specbase, fade);
|
||||
|
||||
Surface surface = (Surface)0;
|
||||
surface.albedo = albedo;
|
||||
surface.normal = normal;
|
||||
surface.specular = specfade.r;
|
||||
surface.gloss = specfade.g;
|
||||
surface.reflectance = specular.g * fade * (CFG_REFLECTION_SCALE);
|
||||
|
||||
return surface;
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
#include "common.h"
|
||||
|
||||
struct Appdata
|
||||
{
|
||||
float4 Position : POSITION;
|
||||
float3 Normal : NORMAL;
|
||||
float4 Uv : TEXCOORD0;
|
||||
#ifdef PIN_HQ
|
||||
float4 EdgeDistances: TEXCOORD1;
|
||||
float3 Tangent : TEXCOORD2;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 HPosition : POSITION;
|
||||
|
||||
float4 UvHigh_EdgeDistance1 : TEXCOORD0;
|
||||
float4 UvLow_EdgeDistance2 : TEXCOORD1;
|
||||
|
||||
float4 LightPosition_Fog : TEXCOORD2;
|
||||
|
||||
#ifdef PIN_HQ
|
||||
float4 View_Depth : TEXCOORD3;
|
||||
float4 Normal_Blend : TEXCOORD4;
|
||||
float3 Tangent : TEXCOORD5;
|
||||
#else
|
||||
float4 Diffuse_Blend : COLOR0;
|
||||
#endif
|
||||
|
||||
float3 PosLightSpace : TEXCOORD7;
|
||||
};
|
||||
|
||||
uniform float4x4 WorldMatrix;
|
||||
|
||||
VertexOutput MegaClusterVS(Appdata IN)
|
||||
{
|
||||
VertexOutput OUT = (VertexOutput)0;
|
||||
|
||||
// Decode vertex data
|
||||
IN.Normal = (IN.Normal - 127) / 127;
|
||||
IN.Uv /= 2048;
|
||||
|
||||
// Transform position and normal to world space
|
||||
// Note: world matrix does not contain rotation/scale for static geometry so we can avoid transforming normal
|
||||
float3 posWorld = mul(WorldMatrix, IN.Position).xyz;
|
||||
float3 normalWorld = IN.Normal;
|
||||
|
||||
OUT.HPosition = mul(G.ViewProjection, float4(posWorld, 1));
|
||||
|
||||
float blend = OUT.HPosition.w / 200;
|
||||
|
||||
OUT.LightPosition_Fog = float4(lgridPrepareSample(lgridOffset(posWorld, normalWorld)), (G.FogParams.z - OUT.HPosition.w) * G.FogParams.w);
|
||||
|
||||
OUT.UvHigh_EdgeDistance1.xy = IN.Uv.xy;
|
||||
OUT.UvLow_EdgeDistance2.xy = IN.Uv.zw;
|
||||
|
||||
#ifdef PIN_HQ
|
||||
OUT.View_Depth = float4(posWorld, OUT.HPosition.w * G.FadeDistance.y);
|
||||
float4 edgeDistances = IN.EdgeDistances*G.FadeDistance.z + 0.5 * OUT.View_Depth.w;
|
||||
|
||||
OUT.UvHigh_EdgeDistance1.zw = edgeDistances.xy;
|
||||
OUT.UvLow_EdgeDistance2.zw = edgeDistances.zw;
|
||||
|
||||
OUT.View_Depth.xyz = G.CameraPosition - posWorld;
|
||||
OUT.Normal_Blend = float4(IN.Normal, blend);
|
||||
// decode tangent
|
||||
OUT.Tangent = (IN.Tangent - 127) / 127;
|
||||
#else
|
||||
// IF LQ shading is performed in VS
|
||||
float ndotl = dot(normalWorld, -G.Lamp0Dir);
|
||||
float3 diffuse = saturate(ndotl) * G.Lamp0Color + max(-ndotl, 0) * G.Lamp1Color;
|
||||
|
||||
OUT.Diffuse_Blend = float4(diffuse, blend);
|
||||
#endif
|
||||
|
||||
OUT.PosLightSpace = getPosInLightSpace(posWorld);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
sampler2D DiffuseHighMap: register(s0);
|
||||
sampler2D DiffuseLowMap: register(s1);
|
||||
sampler2D NormalMap: register(s2);
|
||||
sampler2D SpecularMap: register(s3);
|
||||
LGRID_SAMPLER LightMap: register(s4);
|
||||
sampler2D LightMapLookup: register(s5);
|
||||
|
||||
void MegaClusterPS(VertexOutput IN,
|
||||
#ifdef PIN_GBUFFER
|
||||
out float4 oColor1: COLOR1,
|
||||
#endif
|
||||
out float4 oColor0: COLOR0)
|
||||
{
|
||||
float4 high = tex2D(DiffuseHighMap, IN.UvHigh_EdgeDistance1.xy);
|
||||
float4 low = tex2D(DiffuseLowMap, IN.UvLow_EdgeDistance2.xy);
|
||||
|
||||
float4 light = lgridSample(LightMap, LightMapLookup, IN.LightPosition_Fog.xyz);
|
||||
float shadow = getBlobShadow(IN.PosLightSpace) * light.a;
|
||||
|
||||
#ifdef PIN_HQ
|
||||
float3 albedo = lerp(high.rgb, low.rgb, saturate1(IN.Normal_Blend.a));
|
||||
|
||||
// sample normal map and specular map
|
||||
float4 normalMapSample = tex2D(NormalMap, IN.UvHigh_EdgeDistance1.xy);
|
||||
float4 specularMapSample = tex2D(SpecularMap, IN.UvHigh_EdgeDistance1.xy);
|
||||
|
||||
// compute bitangent and world space normal
|
||||
float3 bitangent = cross(IN.Normal_Blend.xyz, IN.Tangent.xyz);
|
||||
float3 nmap = nmapUnpack(normalMapSample);
|
||||
float3 normal = normalize(nmap.x * IN.Tangent.xyz + nmap.y * bitangent + nmap.z * IN.Normal_Blend.xyz);
|
||||
|
||||
float ndotl = dot(normal, -G.Lamp0Dir);
|
||||
float3 diffuseIntensity = saturate0(ndotl) * G.Lamp0Color + max(-ndotl, 0) * G.Lamp1Color;
|
||||
float specularIntensity = step(0, ndotl) * specularMapSample.r;
|
||||
float specularPower = specularMapSample.g * 255 + 0.01;
|
||||
|
||||
// Compute diffuse and specular and combine them
|
||||
float3 diffuse = (G.AmbientColor + diffuseIntensity * shadow + light.rgb) * albedo.rgb;
|
||||
float3 specular = G.Lamp0Color * (specularIntensity * shadow * (float)(half)pow(saturate(dot(normal, normalize(-G.Lamp0Dir + normalize(IN.View_Depth.xyz)))), specularPower));
|
||||
oColor0.rgb = diffuse + specular;
|
||||
|
||||
// apply outlines
|
||||
float outlineFade = saturate1(IN.View_Depth.w * G.OutlineBrightness_ShadowInfo.x + G.OutlineBrightness_ShadowInfo.y);
|
||||
float2 minIntermediate = min(IN.UvHigh_EdgeDistance1.wz, IN.UvLow_EdgeDistance2.wz);
|
||||
float minEdgesPlus = min(minIntermediate.x, minIntermediate.y) / IN.View_Depth.w;
|
||||
oColor0.rgb *= saturate1(outlineFade * (1.5 - minEdgesPlus) + minEdgesPlus);
|
||||
|
||||
oColor0.a = 1;
|
||||
|
||||
#else
|
||||
float3 albedo = lerp(high.rgb, low.rgb, saturate1(IN.Diffuse_Blend.a));
|
||||
|
||||
// Compute diffuse term
|
||||
float3 diffuse = (G.AmbientColor + IN.Diffuse_Blend.rgb * shadow + light.rgb) * albedo.rgb;
|
||||
|
||||
// Combine
|
||||
oColor0.rgb = diffuse;
|
||||
oColor0.a = 1;
|
||||
|
||||
#endif
|
||||
|
||||
float fogAlpha = saturate(IN.LightPosition_Fog.w);
|
||||
|
||||
oColor0.rgb = lerp(G.FogColor, oColor0.rgb, fogAlpha);
|
||||
|
||||
#ifdef PIN_GBUFFER
|
||||
oColor1 = gbufferPack(IN.View_Depth.w*G.FadeDistance.x, diffuse.rgb, 0, fogAlpha);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "common.h"
|
||||
|
||||
struct Appdata
|
||||
{
|
||||
float4 p : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 p : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
||||
float4 convertPosition(float4 p, float scale)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
float2 convertUv(float4 p)
|
||||
{
|
||||
return p.xy * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
VertexOutput msaaComposit_vs(Appdata IN)
|
||||
{
|
||||
float2 uv = convertUv(IN.p);
|
||||
|
||||
VertexOutput OUT;
|
||||
OUT.p = convertPosition(IN.p, 1);
|
||||
OUT.uv = uv;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
float4 msaaComposit_ps(float2 uv : TEXCOORD0, uniform sampler2D colorMap: register(s0)): COLOR0
|
||||
{
|
||||
return tex2D(colorMap, uv);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
#include "globals.h"
|
||||
|
||||
sampler2D tex : register(s0);
|
||||
|
||||
//#define
|
||||
|
||||
uniform float4 colorBias;
|
||||
uniform float4 throttleFactor; // .x = alpha cutoff, .y = alpha boost (clamp)
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float4 scaleRotLife : TEXCOORD0; // transform matrix
|
||||
float2 disp : TEXCOORD1; // .xy = corner, either (0,0), (1,0), (0,1), or (1,1)
|
||||
float4 color0: COLOR0;
|
||||
float4 color1: COLOR1;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float3 uvFog : TEXCOORD0;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
float4 rotScale( float4 scaleRotLife )
|
||||
{
|
||||
float cr = cos( scaleRotLife.z );
|
||||
float sr = sin( scaleRotLife.z );
|
||||
|
||||
float4 r;
|
||||
r.x = cr * scaleRotLife.x;
|
||||
r.y = -sr * scaleRotLife.x;
|
||||
r.z = sr * scaleRotLife.y;
|
||||
r.w = cr * scaleRotLife.y;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
VS_OUTPUT vs( VS_INPUT input )
|
||||
{
|
||||
VS_OUTPUT o;
|
||||
|
||||
float4 pos = float4( input.pos.xyz, 1 );
|
||||
float2 disp = input.disp.xy * 2 - 1; // -1..1
|
||||
|
||||
input.scaleRotLife *= float4( 1/256.0f, 1/256.0f, 2 * 3.1415926f / 32767, 1 / 32767.0f );
|
||||
|
||||
float4 rs = rotScale( input.scaleRotLife );
|
||||
|
||||
pos += G.ViewRight * dot( disp, rs.xy );
|
||||
pos += G.ViewUp * dot( disp, rs.zw );
|
||||
o.pos = mul( G.ViewProjection, pos );
|
||||
|
||||
o.uvFog.xy = input.disp.xy;
|
||||
o.uvFog.y = 1 - o.uvFog.y;
|
||||
o.uvFog.z = (G.FogParams.z - o.pos.w) * G.FogParams.w;
|
||||
float t = max( 0, min(1, input.scaleRotLife.w ) );
|
||||
o.color = lerp( input.color1, input.color0, t );
|
||||
|
||||
// alpha channel magic for particle throttling
|
||||
float2 cmp = o.color.aa < throttleFactor.xy;
|
||||
o.pos.xyz += cmp.xxx * (1e10f).xxx; // move the particle off-screen
|
||||
o.color.a = lerp( o.color.a, throttleFactor.y, cmp.y ); // if below threshold, alpha = threshold
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 psAdd( VS_OUTPUT input ) : COLOR0 // #0
|
||||
{
|
||||
float4 color = tex2D( tex, input.uvFog.xy );
|
||||
float4 result = float4( input.color.rgb + color.rgb + colorBias.rgb, color.a * input.color.a );
|
||||
result.rgb = lerp( G.FogColor.rgb, result.rgb, saturate( input.uvFog.zzz ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
float4 psMul( VS_OUTPUT input ) : COLOR0 // #1
|
||||
{
|
||||
float4 color = tex2D( tex, input.uvFog.xy );
|
||||
float4 result = input.color * color;
|
||||
result.rgb = lerp( G.FogColor.rgb, result.rgb, saturate( input.uvFog.zzz ) );
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#define CFG_TEXTURE_TILING 1
|
||||
|
||||
#define CFG_DIFFUSE_SCALE 1
|
||||
#define CFG_SPECULAR_SCALE 2.5
|
||||
#define CFG_GLOSS_SCALE 128
|
||||
#define CFG_REFLECTION_SCALE 0
|
||||
|
||||
#define CFG_NORMAL_SHADOW_SCALE 0
|
||||
|
||||
#define CFG_SPECULAR_LOD 0.15
|
||||
#define CFG_GLOSS_LOD 22
|
||||
|
||||
#define CFG_NORMAL_DETAIL_TILING 6
|
||||
#define CFG_NORMAL_DETAIL_SCALE 1.5
|
||||
|
||||
#define CFG_FAR_TILING 0
|
||||
#define CFG_FAR_DIFFUSE_CUTOFF 0
|
||||
#define CFG_FAR_NORMAL_CUTOFF 0
|
||||
#define CFG_FAR_SPECULAR_CUTOFF 0
|
||||
|
||||
#include "material.hlsl"
|
||||
@@ -0,0 +1,46 @@
|
||||
#if defined(PIN_HQ)
|
||||
#define PIN_SURFACE
|
||||
#include "default.hlsl"
|
||||
|
||||
#define CFG_TEXTURE_TILING 1
|
||||
|
||||
#define CFG_BUMP_INTENSITY 0.5
|
||||
|
||||
#define CFG_SPECULAR 0.4
|
||||
#define CFG_GLOSS 9
|
||||
|
||||
#define CFG_NORMAL_SHADOW_SCALE 0.1
|
||||
|
||||
Surface surfaceShader(SurfaceInput IN, float fade)
|
||||
{
|
||||
float4 studs = tex2D(DiffuseMap, IN.UvStuds);
|
||||
float3 normal = nmapUnpack(tex2D(NormalMap, IN.UvStuds));
|
||||
|
||||
float3 noise = nmapUnpack(tex2D(NormalDetailMap, IN.Uv * (CFG_TEXTURE_TILING)));
|
||||
|
||||
float noiseScale = saturate0(IN.Color.a * 2 * (CFG_BUMP_INTENSITY) - 1 * (CFG_BUMP_INTENSITY));
|
||||
|
||||
#ifdef PIN_REFLECTION
|
||||
noiseScale *= saturate(1 - 2 * IN.Reflectance);
|
||||
#endif
|
||||
|
||||
normal.xy += noise.xy * noiseScale;
|
||||
|
||||
normal.xy *= fade;
|
||||
|
||||
Surface surface = (Surface)0;
|
||||
surface.albedo = IN.Color.rgb * studs.rgb * 2;
|
||||
surface.normal = normal;
|
||||
surface.specular = (CFG_SPECULAR);
|
||||
surface.gloss = (CFG_GLOSS);
|
||||
|
||||
#ifdef PIN_REFLECTION
|
||||
surface.reflectance = IN.Reflectance;
|
||||
#endif
|
||||
|
||||
return surface;
|
||||
}
|
||||
#else
|
||||
#define PIN_PLASTIC
|
||||
#include "default.hlsl"
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
#define CFG_TEXTURE_TILING 1
|
||||
|
||||
#define CFG_DIFFUSE_SCALE 1
|
||||
#define CFG_SPECULAR_SCALE 1
|
||||
#define CFG_GLOSS_SCALE 256
|
||||
#define CFG_REFLECTION_SCALE 0
|
||||
|
||||
#define CFG_NORMAL_SHADOW_SCALE 0.5
|
||||
|
||||
#define CFG_SPECULAR_LOD 0.35
|
||||
#define CFG_GLOSS_LOD 103
|
||||
|
||||
#define CFG_NORMAL_DETAIL_TILING 0
|
||||
#define CFG_NORMAL_DETAIL_SCALE 0
|
||||
|
||||
#define CFG_FAR_TILING 0.5
|
||||
#define CFG_FAR_DIFFUSE_CUTOFF 0.75
|
||||
#define CFG_FAR_NORMAL_CUTOFF 0
|
||||
#define CFG_FAR_SPECULAR_CUTOFF 0
|
||||
|
||||
#define CFG_OPT_BLEND_COLOR
|
||||
|
||||
#include "material.hlsl"
|
||||
@@ -0,0 +1,21 @@
|
||||
#define CFG_TEXTURE_TILING 1
|
||||
|
||||
#define CFG_DIFFUSE_SCALE 1
|
||||
#define CFG_SPECULAR_SCALE 0.4
|
||||
#define CFG_GLOSS_SCALE 32
|
||||
#define CFG_REFLECTION_SCALE 0
|
||||
|
||||
#define CFG_NORMAL_SHADOW_SCALE 0
|
||||
|
||||
#define CFG_SPECULAR_LOD 0.07
|
||||
#define CFG_GLOSS_LOD 6
|
||||
|
||||
#define CFG_NORMAL_DETAIL_TILING 0
|
||||
#define CFG_NORMAL_DETAIL_SCALE 0
|
||||
|
||||
#define CFG_FAR_TILING 0
|
||||
#define CFG_FAR_DIFFUSE_CUTOFF 0
|
||||
#define CFG_FAR_NORMAL_CUTOFF 0
|
||||
#define CFG_FAR_SPECULAR_CUTOFF 0
|
||||
|
||||
#include "material.hlsl"
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "common.h"
|
||||
|
||||
struct Appdata
|
||||
{
|
||||
float4 Position : POSITION;
|
||||
|
||||
int4 BoneIndices : COLOR0;
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 HPosition : POSITION;
|
||||
};
|
||||
|
||||
uniform float ShadowExtrusionDistance;
|
||||
|
||||
uniform float4 WorldMatrixArray[MAX_BONE_COUNT * 3];
|
||||
|
||||
VertexOutput DefaultVS(Appdata IN)
|
||||
{
|
||||
VertexOutput OUT = (VertexOutput)0;
|
||||
|
||||
int boneIndex = IN.BoneIndices.r;
|
||||
|
||||
float4 worldRow0 = WorldMatrixArray[boneIndex * 3 + 0];
|
||||
float4 worldRow1 = WorldMatrixArray[boneIndex * 3 + 1];
|
||||
float4 worldRow2 = WorldMatrixArray[boneIndex * 3 + 2];
|
||||
|
||||
float3 posWorld = float3(dot(worldRow0, IN.Position), dot(worldRow1, IN.Position), dot(worldRow2, IN.Position));
|
||||
|
||||
float3 extrusion = G.Lamp0Dir * (ShadowExtrusionDistance * IN.BoneIndices.g);
|
||||
|
||||
OUT.HPosition = mul(G.ViewProjection, float4(posWorld + extrusion, 1));
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
float4 DefaultPS(): COLOR0
|
||||
{
|
||||
return float4(0, 0, 0, 1);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "globals.h"
|
||||
|
||||
struct Appdata
|
||||
{
|
||||
float4 Position : POSITION;
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 HPosition : POSITION;
|
||||
};
|
||||
|
||||
uniform float4 Color;
|
||||
|
||||
VertexOutput QuadVS(Appdata IN)
|
||||
{
|
||||
VertexOutput OUT = (VertexOutput)0;
|
||||
|
||||
OUT.HPosition = IN.Position;
|
||||
OUT.HPosition.z = 0.5; // force set depth to avoid depth clipping
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
float4 QuadPS(): COLOR0
|
||||
{
|
||||
return Color;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "globals.h"
|
||||
|
||||
struct Appdata
|
||||
{
|
||||
float4 Position : POSITION;
|
||||
float2 Uv : TEXCOORD0;
|
||||
float4 Color : COLOR0;
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 HPosition : POSITION;
|
||||
float PSize : PSIZE;
|
||||
|
||||
float2 Uv : TEXCOORD0;
|
||||
float4 Color : COLOR0;
|
||||
};
|
||||
|
||||
uniform float4x4 WorldMatrix;
|
||||
|
||||
uniform float4 Color;
|
||||
uniform float4 Color2;
|
||||
|
||||
VertexOutput SkyVS(Appdata IN)
|
||||
{
|
||||
VertexOutput OUT = (VertexOutput)0;
|
||||
|
||||
float4 wpos = mul(WorldMatrix, IN.Position);
|
||||
|
||||
OUT.HPosition = mul(G.ViewProjection, wpos);
|
||||
|
||||
// snap to far plane to prevent scene-sky intersections
|
||||
// small offset is needed to prevent 0/0 division in case w=0, which causes rasterization issues
|
||||
OUT.HPosition.z = OUT.HPosition.w - 1.f / 16;
|
||||
|
||||
OUT.PSize = 2.0; // star size
|
||||
|
||||
OUT.Uv = IN.Uv;
|
||||
OUT.Color = IN.Color * lerp(Color2,Color,wpos.y/1700);
|
||||
//OUT.Color = IN.Color * Color;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
sampler2D DiffuseMap: register(s0);
|
||||
|
||||
float4 SkyPS(VertexOutput IN): COLOR0
|
||||
{
|
||||
return tex2D(DiffuseMap, IN.Uv) * IN.Color;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#define CFG_TEXTURE_TILING 1
|
||||
|
||||
#define CFG_DIFFUSE_SCALE 1
|
||||
#define CFG_SPECULAR_SCALE 0.9
|
||||
#define CFG_GLOSS_SCALE 128
|
||||
#define CFG_REFLECTION_SCALE 0
|
||||
|
||||
#define CFG_NORMAL_SHADOW_SCALE 0.5
|
||||
|
||||
#define CFG_SPECULAR_LOD 0.14
|
||||
#define CFG_GLOSS_LOD 20
|
||||
|
||||
#define CFG_NORMAL_DETAIL_TILING 5
|
||||
#define CFG_NORMAL_DETAIL_SCALE 1
|
||||
|
||||
#define CFG_FAR_TILING 0.25
|
||||
#define CFG_FAR_DIFFUSE_CUTOFF 0.75
|
||||
#define CFG_FAR_NORMAL_CUTOFF 0
|
||||
#define CFG_FAR_SPECULAR_CUTOFF 0
|
||||
|
||||
#include "material.hlsl"
|
||||
@@ -0,0 +1,2 @@
|
||||
#define PIN_PLASTIC
|
||||
#include "default.hlsl"
|
||||
@@ -0,0 +1,447 @@
|
||||
#include "common.h"
|
||||
|
||||
// tweakables
|
||||
#define SSAO_NUM_PAIRS 8
|
||||
#define SSAO_SPHERE_RAD 2.0f // world-space
|
||||
#define SSAO_MIN_PIXEL_RANGE 10.0f
|
||||
#define SSAO_MAX_PIXEL_RANGE 100.0f
|
||||
#define BLUR_DEPTH_DELTA 0.4f
|
||||
|
||||
#define COMPOSITE_DEPTH_DELTA 0.02f
|
||||
#define COMPOSITE_DEPTH_DELTA2 0.4f
|
||||
|
||||
struct Appdata
|
||||
{
|
||||
float4 p : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 p : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
||||
// .xy = gbuffer width/height, .zw = inverse gbuffer width/height
|
||||
uniform float4 TextureSize;
|
||||
|
||||
#ifdef GLSL
|
||||
float4 convertPosition(float4 p, float scale)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
float2 convertUv(float4 p)
|
||||
{
|
||||
return p.xy * 0.5 + 0.5;
|
||||
}
|
||||
#else
|
||||
float4 convertPosition(float4 p, float scale)
|
||||
{
|
||||
// half-pixel offset
|
||||
return p + float4(-TextureSize.z, TextureSize.w, 0, 0) * scale;
|
||||
}
|
||||
|
||||
float2 convertUv(float4 p)
|
||||
{
|
||||
return p.xy * float2(0.5, -0.5) + 0.5;
|
||||
}
|
||||
#endif
|
||||
|
||||
VertexOutput ssao_vs(Appdata IN)
|
||||
{
|
||||
float2 uv = convertUv(IN.p);
|
||||
|
||||
VertexOutput OUT;
|
||||
OUT.p = convertPosition(IN.p, 1);
|
||||
OUT.uv = uv;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
// used for depth downsampling pass
|
||||
struct VertexOutput_4uv
|
||||
{
|
||||
float4 p : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 uv12 : TEXCOORD1;
|
||||
float4 uv34 : TEXCOORD2;
|
||||
};
|
||||
|
||||
VertexOutput_4uv ssaoDepthDown_vs(Appdata IN)
|
||||
{
|
||||
float2 uv = convertUv(IN.p);
|
||||
|
||||
VertexOutput_4uv OUT;
|
||||
OUT.p = convertPosition(IN.p, 2);
|
||||
OUT.uv = uv;
|
||||
|
||||
float2 uvOffset = TextureSize.zw * 0.5f;
|
||||
|
||||
OUT.uv12.xy = uv + uvOffset * float2(-1, -1);
|
||||
OUT.uv12.zw = uv + uvOffset * float2(+1, -1);
|
||||
OUT.uv34.xy = uv + uvOffset * float2(-1, +1);
|
||||
OUT.uv34.zw = uv + uvOffset * float2(+1, +1);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
struct VertexOutput_8uv
|
||||
{
|
||||
float4 p : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 uv12 : TEXCOORD1;
|
||||
float4 uv34 : TEXCOORD2;
|
||||
float4 uv56 : TEXCOORD3;
|
||||
float4 uv78 : TEXCOORD4;
|
||||
};
|
||||
|
||||
// used for ssao blurring passes
|
||||
VertexOutput_8uv ssaoBlur_vs(Appdata IN, float2 uvOffset)
|
||||
{
|
||||
float2 uv = convertUv(IN.p);
|
||||
|
||||
VertexOutput_8uv OUT;
|
||||
OUT.p = convertPosition(IN.p, 2);
|
||||
OUT.uv = uv;
|
||||
|
||||
OUT.uv12.xy = uv + 1 * uvOffset;
|
||||
OUT.uv12.zw = uv + 2 * uvOffset;
|
||||
OUT.uv34.xy = uv + 3 * uvOffset;
|
||||
OUT.uv34.zw = uv + 4 * uvOffset;
|
||||
|
||||
OUT.uv56.xy = uv - 1 * uvOffset;
|
||||
OUT.uv56.zw = uv - 2 * uvOffset;
|
||||
OUT.uv78.xy = uv - 3 * uvOffset;
|
||||
OUT.uv78.zw = uv - 4 * uvOffset;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
VertexOutput_8uv ssaoBlurX_vs(Appdata IN)
|
||||
{
|
||||
return ssaoBlur_vs(IN, float2(TextureSize.z * 2, 0));
|
||||
}
|
||||
|
||||
VertexOutput_8uv ssaoBlurY_vs(Appdata IN)
|
||||
{
|
||||
return ssaoBlur_vs(IN, float2(0, TextureSize.w * 2));
|
||||
}
|
||||
|
||||
float unpackDepth( sampler2D s, float2 uv )
|
||||
{
|
||||
float4 geomTex = tex2D(s, uv);
|
||||
float d = geomTex.z * (1.0f/256.0f) + geomTex.w;
|
||||
return d;
|
||||
}
|
||||
|
||||
float getDepth( sampler2D s, float2 uv )
|
||||
{
|
||||
return (float)tex2D(s,uv).r;
|
||||
}
|
||||
|
||||
#define NUM_PAIRS SSAO_NUM_PAIRS
|
||||
#define RANGE 60.0/1024.0
|
||||
|
||||
#define pi 3.14159265359
|
||||
#define RAD(X) ( (X) * (pi/180) )
|
||||
|
||||
float2 GetRotatedSample(float i)
|
||||
{
|
||||
return (i+1) / (NUM_PAIRS+2) * float2(cos( RAD(45) + i / NUM_PAIRS * 2 * pi ), sin( RAD(45) + i / NUM_PAIRS * 2 * pi ) );
|
||||
}
|
||||
|
||||
#define NUM_SAMPLES NUM_PAIRS*2+1
|
||||
|
||||
float4 ssao_ps(
|
||||
float2 uv: TEXCOORD0,
|
||||
uniform sampler2D depthBuffer: register(s0),
|
||||
uniform sampler2D randMap: register(s1)): COLOR0
|
||||
{
|
||||
float2 mapSize = TextureSize.xy / 2;
|
||||
|
||||
float baseDepth = getDepth( depthBuffer, uv );
|
||||
|
||||
float4 noiseTex = tex2D(randMap, uv*mapSize/4) * 2 - 1;
|
||||
|
||||
float2x2 rotation =
|
||||
{
|
||||
{ noiseTex.y, noiseTex.x },
|
||||
{ -noiseTex.x, noiseTex.y }
|
||||
};
|
||||
|
||||
float2 OFFSETS1[NUM_PAIRS] =
|
||||
{
|
||||
GetRotatedSample(0),
|
||||
GetRotatedSample(1),
|
||||
GetRotatedSample(2),
|
||||
GetRotatedSample(3),
|
||||
GetRotatedSample(4),
|
||||
GetRotatedSample(5),
|
||||
#if NUM_PAIRS > 6
|
||||
GetRotatedSample(6),
|
||||
GetRotatedSample(7),
|
||||
#if NUM_PAIRS > 8
|
||||
GetRotatedSample(8),
|
||||
GetRotatedSample(9),
|
||||
GetRotatedSample(10),
|
||||
GetRotatedSample(11),
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
float occ = 1;
|
||||
|
||||
float sphereRadiusZB = (float) ( 2.0f / GBUFFER_MAX_DEPTH );
|
||||
|
||||
#define MINPIXEL SSAO_MIN_PIXEL_RANGE
|
||||
#define MAXPIXEL SSAO_MAX_PIXEL_RANGE
|
||||
|
||||
float radiusTex = (float)clamp( 0.5*sphereRadiusZB / baseDepth, MINPIXEL / mapSize.x, MAXPIXEL / mapSize.y);
|
||||
|
||||
float numSamples = 2;
|
||||
|
||||
for(int i = 0; i < NUM_PAIRS; i++)
|
||||
{
|
||||
float2 offset1 = mul(rotation, OFFSETS1[i]);
|
||||
|
||||
float2 offseted1 = uv + offset1 * radiusTex;
|
||||
float2 offseted2 = uv - offset1 * radiusTex;
|
||||
|
||||
float2 offsetDepth;
|
||||
offsetDepth.x = getDepth( depthBuffer, offseted1 );
|
||||
offsetDepth.y = getDepth( depthBuffer, offseted2 );
|
||||
|
||||
float2 diff = offsetDepth - baseDepth.xx;
|
||||
|
||||
float normalizedOffsetLen = (float)(i+1)/(NUM_PAIRS+2);
|
||||
|
||||
float segmentDiff = (float) ( 1.5f*sphereRadiusZB*sqrt(1-normalizedOffsetLen*normalizedOffsetLen) );
|
||||
|
||||
float2 normalizedDiff = (diff / segmentDiff) + 0.5;
|
||||
|
||||
float minDiff = min(normalizedDiff.x, normalizedDiff.y);
|
||||
|
||||
// At 0, full sample
|
||||
// At -1, zero sample, zero weight
|
||||
|
||||
float sampleadd = (float) saturate(1+minDiff);
|
||||
|
||||
float a = (float)(saturate(normalizedDiff.x) + saturate(normalizedDiff.y))*sampleadd;
|
||||
occ += a;
|
||||
numSamples += 2 * sampleadd;
|
||||
}
|
||||
|
||||
occ = occ / numSamples;
|
||||
|
||||
float finalocc = (float)saturate(occ*2);
|
||||
|
||||
if(baseDepth - (1.0f-1/256.0f) > 0)
|
||||
finalocc += 1;
|
||||
|
||||
return float4(finalocc, finalocc, finalocc, 1);
|
||||
}
|
||||
|
||||
// this function estimates depth discrepancy tolerance for the blur filter
|
||||
float depthTolerance( float baseDepth, float sphereRadiusZB )
|
||||
{
|
||||
float ramp = 80; // tweak
|
||||
return ( clamp( sphereRadiusZB * (baseDepth * ramp) , 0.1f * sphereRadiusZB, 40*sphereRadiusZB ) );
|
||||
}
|
||||
|
||||
float ssaoBlur(
|
||||
float2 uv,
|
||||
|
||||
float4 uv12,
|
||||
float4 uv34,
|
||||
float4 uv56,
|
||||
float4 uv78,
|
||||
|
||||
sampler2D map,
|
||||
sampler2D depthBuffer
|
||||
)
|
||||
{
|
||||
float sphereRadiusZB = BLUR_DEPTH_DELTA / GBUFFER_MAX_DEPTH;
|
||||
float4 i = { 1, 2, 3, 4 };
|
||||
float4 iw = 4-i;
|
||||
float4 denom = 1;
|
||||
|
||||
|
||||
float4 sum = tex2D(map, uv).rrrr * denom;
|
||||
|
||||
float baseDepth = getDepth( depthBuffer, uv );
|
||||
|
||||
float4 newDepth, delta, ssample, coef;
|
||||
|
||||
newDepth.x = getDepth( depthBuffer, uv12.xy );
|
||||
newDepth.y = getDepth( depthBuffer, uv12.zw );
|
||||
newDepth.z = getDepth( depthBuffer, uv34.xy );
|
||||
newDepth.w = getDepth( depthBuffer, uv34.zw );
|
||||
|
||||
delta = (newDepth - baseDepth.xxxx);
|
||||
coef = iw * ( abs(delta) < depthTolerance( baseDepth, sphereRadiusZB ).xxxx );
|
||||
|
||||
|
||||
ssample.x = tex2D( map, uv12.xy ).r;
|
||||
ssample.y = tex2D( map, uv12.zw ).r;
|
||||
ssample.z = tex2D( map, uv34.xy ).r;
|
||||
ssample.w = tex2D( map, uv34.zw ).r;
|
||||
|
||||
sum += ssample * coef;
|
||||
denom += coef;
|
||||
|
||||
////////////////////////////////////////
|
||||
|
||||
newDepth.x = getDepth( depthBuffer, uv56.xy );
|
||||
newDepth.y = getDepth( depthBuffer, uv56.zw );
|
||||
newDepth.z = getDepth( depthBuffer, uv78.xy );
|
||||
newDepth.w = getDepth( depthBuffer, uv78.zw );
|
||||
|
||||
delta = newDepth - baseDepth.xxxx;
|
||||
coef = iw * ( abs(delta) < depthTolerance( baseDepth, sphereRadiusZB ).xxxx );
|
||||
|
||||
ssample.x = tex2D( map, uv56.xy ).r;
|
||||
ssample.y = tex2D( map, uv56.zw ).r;
|
||||
ssample.z = tex2D( map, uv78.xy ).r;
|
||||
ssample.w = tex2D( map, uv78.zw ).r;
|
||||
|
||||
sum += ssample * coef;
|
||||
denom += coef;
|
||||
|
||||
return dot( sum, float4(1,1,1,1) ) / dot( denom, float4(1,1,1,1) );
|
||||
}
|
||||
|
||||
|
||||
float4 ssaoBlurX_ps(
|
||||
float2 uv : TEXCOORD0,
|
||||
float4 uv12 : TEXCOORD1,
|
||||
float4 uv34 : TEXCOORD2,
|
||||
float4 uv56 : TEXCOORD3,
|
||||
float4 uv78 : TEXCOORD4,
|
||||
|
||||
uniform sampler2D map : register(s0), uniform sampler2D depthBuffer : register(s1) ): COLOR0
|
||||
{
|
||||
//return tex2D( map, uv );
|
||||
float ssaoTerm = ssaoBlur( uv, uv12, uv34, uv56, uv78, map, depthBuffer);
|
||||
|
||||
return float4(ssaoTerm.xxx, 1);
|
||||
}
|
||||
|
||||
#define SPECULAR_WEIGHT 3
|
||||
|
||||
|
||||
float4 ssaoBlurY_ps(
|
||||
float2 uv : TEXCOORD0,
|
||||
float4 uv12 : TEXCOORD1,
|
||||
float4 uv34 : TEXCOORD2,
|
||||
float4 uv56 : TEXCOORD3,
|
||||
float4 uv78 : TEXCOORD4,
|
||||
|
||||
uniform sampler2D map : register(s0), uniform sampler2D depthBuffer : register(s1), uniform sampler2D geomMap : register(s2) ): COLOR0
|
||||
{
|
||||
float ssaoTerm = ssaoBlur(uv, uv12, uv34, uv56, uv78, map, depthBuffer);
|
||||
|
||||
float4 geom = tex2D(geomMap, uv);
|
||||
|
||||
float specular = geom.x;
|
||||
float diffuse = geom.y;
|
||||
|
||||
// Making specular kill SSAO faster, so it doesn't get capped by 1
|
||||
return (SPECULAR_WEIGHT*specular + diffuse * ssaoTerm) / (SPECULAR_WEIGHT*specular + diffuse + 0.001);
|
||||
}
|
||||
|
||||
|
||||
|
||||
float4 ssaoDepthDown_ps(
|
||||
float2 uv : TEXCOORD0,
|
||||
float4 uv12 : TEXCOORD1,
|
||||
float4 uv34 : TEXCOORD2,
|
||||
|
||||
uniform sampler2D depthBuffer : register(s0)
|
||||
) : COLOR0
|
||||
{
|
||||
|
||||
float4 d;
|
||||
d.x = unpackDepth( depthBuffer, uv12.xy );
|
||||
d.y = unpackDepth( depthBuffer, uv12.zw );
|
||||
d.z = unpackDepth( depthBuffer, uv34.xy );
|
||||
d.w = unpackDepth( depthBuffer, uv34.zw );
|
||||
|
||||
float2 tmp = min( d.xy, d.zw );
|
||||
return min( tmp.x, tmp.y ).x;
|
||||
}
|
||||
|
||||
VertexOutput_4uv ssaoComposit_vs(Appdata IN)
|
||||
{
|
||||
float2 uv = convertUv(IN.p);
|
||||
|
||||
VertexOutput_4uv OUT;
|
||||
OUT.p = convertPosition(IN.p, 1);
|
||||
OUT.uv = uv;
|
||||
|
||||
float2 uvOffset = TextureSize.zw * 2;
|
||||
|
||||
OUT.uv12.xy = uv + float2(uvOffset.x, 0);
|
||||
OUT.uv12.zw = uv - float2(uvOffset.x, 0);
|
||||
OUT.uv34.xy = uv + float2(0, uvOffset.y);
|
||||
OUT.uv34.zw = uv - float2(0, uvOffset.y);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
float4 ssaoCompositBlank_ps(float2 uv : TEXCOORD0, uniform sampler2D colorMap: register(s0)): COLOR0
|
||||
{
|
||||
return tex2D(colorMap, uv);
|
||||
}
|
||||
|
||||
#define CMP_LESS(X,Y) ( (X) < (Y) )
|
||||
|
||||
float4 ssaoComposit_ps(
|
||||
float2 uv : TEXCOORD0,
|
||||
float4 uv12 : TEXCOORD1,
|
||||
float4 uv34 : TEXCOORD2,
|
||||
|
||||
uniform sampler2D colorMap : register(s0),
|
||||
uniform sampler2D map : register(s1),
|
||||
uniform sampler2D gbuffer : register(s2),
|
||||
uniform sampler2D depthBuffer: register(s3)
|
||||
): COLOR0
|
||||
{
|
||||
//return float4(1,0,0,1);
|
||||
float depth_range = COMPOSITE_DEPTH_DELTA / GBUFFER_MAX_DEPTH;
|
||||
float depth_range2 = COMPOSITE_DEPTH_DELTA2 / GBUFFER_MAX_DEPTH;
|
||||
|
||||
// we're here
|
||||
float baseDepth = unpackDepth( gbuffer, uv );
|
||||
float ssaoTerm = 1.0f;
|
||||
|
||||
float depth = getDepth( depthBuffer, uv );
|
||||
float diff = abs( depth - baseDepth );
|
||||
ssaoTerm = tex2D( map, uv ).x;
|
||||
|
||||
float chk1 = CMP_LESS( depth_range, diff ); // can we trust the base depth? 0 - yes, 1 - no
|
||||
float4 ssaoTermNew = 0, chk2, depth2, diff2;
|
||||
|
||||
depth2.x = getDepth( depthBuffer, uv12.xy );
|
||||
depth2.y = getDepth( depthBuffer, uv12.zw );
|
||||
depth2.z = getDepth( depthBuffer, uv34.xy );
|
||||
depth2.w = getDepth( depthBuffer, uv34.zw );
|
||||
|
||||
ssaoTermNew.x = tex2D( map, uv12.xy ).x;
|
||||
ssaoTermNew.y = tex2D( map, uv12.zw ).x;
|
||||
ssaoTermNew.z = tex2D( map, uv34.xy ).x;
|
||||
ssaoTermNew.w = tex2D( map, uv34.zw ).x;
|
||||
|
||||
diff2 = abs( depth2 - baseDepth.xxxx );
|
||||
chk2 = CMP_LESS( diff2, depth_range2.xxxx );
|
||||
|
||||
ssaoTermNew *= chk2;
|
||||
float den = dot( chk2, 1 ); // + 1e-5f; - TODO: add this if we encounter glitches; //
|
||||
ssaoTermNew.x = dot( ssaoTermNew, 1 ) / den;
|
||||
|
||||
// the final decision: pick the base sample or its estimate, if base depth in unauthorative
|
||||
ssaoTerm = saturate(den*chk1) ? ssaoTermNew.x : ssaoTerm;
|
||||
|
||||
return tex2D(colorMap, uv) * ssaoTerm;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "globals.h"
|
||||
|
||||
struct Appdata
|
||||
{
|
||||
float4 Position : POSITION;
|
||||
float2 Uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 HPosition : POSITION;
|
||||
float2 Uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexOutput TexCompVS(Appdata IN)
|
||||
{
|
||||
VertexOutput OUT = (VertexOutput)0;
|
||||
|
||||
OUT.HPosition = mul(G.ViewProjection, IN.Position);
|
||||
OUT.Uv = IN.Uv;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
sampler2D DiffuseMap: register(s0);
|
||||
|
||||
uniform float4 Color;
|
||||
|
||||
float4 TexCompPS(VertexOutput IN): COLOR0
|
||||
{
|
||||
return tex2Dbias(DiffuseMap, float4(IN.Uv, 0, -10)) * Color;
|
||||
}
|
||||
|
||||
float4 TexCompPMAPS(VertexOutput IN): COLOR0
|
||||
{
|
||||
float4 tex = tex2Dbias(DiffuseMap, float4(IN.Uv, 0, -10));
|
||||
|
||||
return float4(tex.rgb * tex.a * Color.rgb, tex.a * Color.a);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "globals.h"
|
||||
|
||||
struct Appdata
|
||||
{
|
||||
float4 Position : POSITION;
|
||||
float2 Uv : TEXCOORD0;
|
||||
float4 Color : COLOR0;
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 HPosition : POSITION;
|
||||
|
||||
float2 Uv : TEXCOORD0;
|
||||
float4 Color : COLOR0;
|
||||
|
||||
#if defined(PIN_FOG)
|
||||
float FogFactor : TEXCOORD1;
|
||||
#endif
|
||||
};
|
||||
|
||||
VertexOutput UIVS(Appdata IN)
|
||||
{
|
||||
VertexOutput OUT = (VertexOutput)0;
|
||||
|
||||
OUT.HPosition = mul(G.ViewProjection, IN.Position);
|
||||
|
||||
OUT.Uv = IN.Uv;
|
||||
OUT.Color = IN.Color;
|
||||
|
||||
#if defined(PIN_FOG)
|
||||
OUT.FogFactor = (G.FogParams.z - OUT.HPosition.w) * G.FogParams.w;
|
||||
#endif
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
sampler2D DiffuseMap: register(s0);
|
||||
|
||||
float4 UIPS(VertexOutput IN): COLOR0
|
||||
{
|
||||
float4 base = tex2D(DiffuseMap, IN.Uv);
|
||||
float4 result = IN.Color * base;
|
||||
|
||||
#if defined(PIN_FOG)
|
||||
result.rgb = lerp(G.FogColor, result.rgb, saturate(IN.FogFactor));
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
|
||||
//
|
||||
// Water shader.
|
||||
// Big, fat and ugly.
|
||||
//
|
||||
// All (most) things considered, I have converged to this particular way of rendering water:
|
||||
//
|
||||
// Vertex waves
|
||||
// No transparency. Solid color for deep water.
|
||||
// Fresnel law, reflects environment.
|
||||
// Phong speculars.
|
||||
// Ripples via animated normal map. Adjustable intensity, speed and scale. Affect reflection and speculars.
|
||||
|
||||
#include "common.h"
|
||||
|
||||
uniform float4x4 WorldMatrix;
|
||||
|
||||
uniform float4 nmAnimLerp; // ratio between normal map frames
|
||||
uniform float4 waveParams; // .x = frequency .y = phase .z = height
|
||||
uniform float4 WaterColor; // deep water color
|
||||
|
||||
#ifdef PIN_HQ
|
||||
# define WATER_LOD 1
|
||||
#else
|
||||
# define WATER_LOD 2
|
||||
#endif
|
||||
|
||||
#define LODBIAS (-1)
|
||||
|
||||
float fadeFactor( float3 wspos )
|
||||
{
|
||||
return saturate( -0.4f + 1.4f*length( G.CameraPosition.xyz - wspos.xyz ) * G.FadeDistance.y );
|
||||
}
|
||||
|
||||
float wave( float4 wspos )
|
||||
{
|
||||
float x = sin( ( wspos.z - wspos.x - waveParams.y ) * waveParams.x );
|
||||
float z = sin( ( wspos.z + wspos.x + waveParams.y ) * waveParams.x );
|
||||
float p = (x + z) * waveParams.z;
|
||||
return p - p * fadeFactor( wspos.xyz );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// perturbs the water mesh and vertex normals
|
||||
void makeWaves( inout float4 wspos, inout float3 wsnrm )
|
||||
{
|
||||
#if WATER_LOD == 0
|
||||
float gridSize = 4.0f;
|
||||
|
||||
float4 wspos1 = wspos;
|
||||
float4 wspos2 = wspos;
|
||||
|
||||
wspos1.x += gridSize;
|
||||
wspos2.z += gridSize;
|
||||
|
||||
wspos.y += wave(wspos) ;
|
||||
wspos1.y += wave(wspos1);
|
||||
wspos2.y += wave(wspos2);
|
||||
|
||||
wsnrm = normalize( cross( wspos2.xyz - wspos.xyz, wspos1.xyz - wspos.xyz ) );
|
||||
#elif WATER_LOD == 1
|
||||
wspos.y += wave( wspos );
|
||||
#else /* do n0thing */
|
||||
#endif
|
||||
}
|
||||
|
||||
struct V2P
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float4 tc0Fog : TEXCOORD0;
|
||||
float4 wspos : TEXCOORD1;
|
||||
float3 wsnrm : TEXCOORD2;
|
||||
float3 light : TEXCOORD3;
|
||||
float3 fade : TEXCOORD4;
|
||||
};
|
||||
|
||||
V2P water_vs(
|
||||
float4 pos : POSITION,
|
||||
float3 nrm : NORMAL
|
||||
)
|
||||
{
|
||||
V2P o;
|
||||
|
||||
// Decode vertex data
|
||||
nrm = (nrm - 127) / 127;
|
||||
|
||||
nrm = normalize(nrm);
|
||||
|
||||
float4 wspos = mul( WorldMatrix, pos );
|
||||
float3 wsnrm = nrm;
|
||||
|
||||
wspos.y -= 2*waveParams.z;
|
||||
|
||||
makeWaves( /*INOUT*/ wspos, /*INOUT*/ wsnrm );
|
||||
|
||||
o.wspos = wspos;
|
||||
o.wsnrm = wsnrm;
|
||||
|
||||
if( nrm.y < 0.01f ) o.wsnrm = nrm;
|
||||
|
||||
// box mapping
|
||||
//float3x2 m = { wspos.xz, wspos.xy, wspos.yz };
|
||||
//float2 tcselect = mul( abs( nrm.yzx ), m );
|
||||
|
||||
float2 tcselect;
|
||||
float3 wspostc = float3( wspos.x, -wspos.y, wspos.z );
|
||||
|
||||
tcselect.x = dot( abs( nrm.yxz ), wspostc.xzx );
|
||||
tcselect.y = dot( abs( nrm.yxz ), wspostc.zyy );
|
||||
|
||||
o.pos = mul( G.ViewProjection, wspos );
|
||||
o.tc0Fog.xy = tcselect * .05f;
|
||||
o.tc0Fog.z = saturate( (G.FogParams.z - o.pos.w) * G.FogParams.w );
|
||||
o.tc0Fog.w = LODBIAS;
|
||||
|
||||
o.light = lgridPrepareSample(lgridOffset(wspos.xyz, wsnrm.xyz));
|
||||
|
||||
o.fade.x = fadeFactor( wspos.xyz );
|
||||
o.fade.y = (1-o.fade.x) * saturate( dot( wsnrm, -G.Lamp0Dir ) ) * 100;
|
||||
o.fade.z = 1 - 0.9*saturate1( exp( -0.005 * length( G.CameraPosition.xyz - wspos.xyz ) ) );
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sampler2D NormalMap1 : register(s0);
|
||||
sampler2D NormalMap2 : register(s1);
|
||||
samplerCUBE EnvMap : register(s2);
|
||||
LGRID_SAMPLER LightMap : register(s3);
|
||||
sampler2D LightMapLookup: register(s4);
|
||||
|
||||
|
||||
|
||||
float3 pixelNormal( float4 tc0 )
|
||||
{
|
||||
float4 nm1 = tex2Dbias( NormalMap1, tc0 );
|
||||
#if WATER_LOD <= 1
|
||||
float4 nm2 = tex2Dbias( NormalMap2, tc0 );
|
||||
float3 normal = lerp( nm1, nm2, nmAnimLerp.xxxx ).agb;
|
||||
#else
|
||||
float3 normal = nm1.agb;
|
||||
#endif
|
||||
//normal = nm2;
|
||||
normal.xy = 2*normal.xy - 1;
|
||||
normal.z = sqrt( 1.001 - saturate1( dot( normal.xy, normal.xy ) ) );
|
||||
return normal;
|
||||
}
|
||||
|
||||
// Fresnel approximation. N1 and N2 are refractive indices.
|
||||
// for above water, use n1 = 1, n2 = 1.3, for underwater use n1 = 1.3, n2 = 1
|
||||
float fresnel( float3 N, float3 V, float n1, float n2, float p, float fade )
|
||||
{
|
||||
#if WATER_LOD == 0
|
||||
float r0 = (n1-n2)/(n1+n2);
|
||||
r0 *= r0;
|
||||
return r0 + (1-r0) * pow( 1 - abs( dot( normalize(N), V ) ), p );
|
||||
#else
|
||||
return 0.1 + saturate( - 1.9 * abs( dot( N, V ) ) + 0.8); // HAXX!
|
||||
//return 1 - 2 * abs( dot( N, V ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
float4 envColor( float3 N, float3 V, float fade )
|
||||
{
|
||||
float3 dir = reflect( V, N );
|
||||
return texCUBE(EnvMap, dir) * 0.91f;
|
||||
}
|
||||
|
||||
float4 deepWaterColor(float4 light)
|
||||
{
|
||||
//float4 tint = 5*float4( 0.1f, 0.1f, 0.13f, 1);
|
||||
float4 tint = 0.8f*float4( 118, 143, 153, 255 ) / 255;
|
||||
return (light + texCUBEbias( EnvMap, float4( 0,1,0, 10.0f) )) * tint;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
float4 water_ps( V2P v ) : COLOR0
|
||||
{
|
||||
|
||||
float4 WaterColorTest = 0.5 * float4( 26, 169, 185, 0 ) / 255;
|
||||
float4 FogColorTest = 0.8 * float4( 35, 107, 130, 0 ) / 255;
|
||||
|
||||
float3 N2 = v.wsnrm;
|
||||
float3 N1 = pixelNormal( v.tc0Fog ).xzy;
|
||||
float3 N3 = 0.5*(N2 + N1);
|
||||
|
||||
N3 = lerp( N3, N2, v.fade.z );
|
||||
|
||||
float3 L = /*normalize*/(-G.Lamp0Dir.xyz);
|
||||
float3 E = normalize( G.CameraPosition.xyz - v.wspos.xyz );
|
||||
|
||||
float4 light = lgridSample(LightMap, LightMapLookup, v.light.xyz);
|
||||
|
||||
float fre = fresnel( N3, E, 1.0f, 1.3f, 5, v.fade.x );
|
||||
float3 diffuse = deepWaterColor(light).rgb;
|
||||
float3 env = envColor( N3, -E, v.fade.x ).rgb;
|
||||
|
||||
float3 R = reflect( -L, N1 );
|
||||
|
||||
#if WATER_LOD <= 1
|
||||
float specular = pow( saturate0( dot( R, E ) ), 1600 ) * L.y * 100; // baseline
|
||||
# ifndef GLSLES
|
||||
specular = 0.65 * saturate1( specular * saturate0( light.a - 0.4f ) );
|
||||
# endif
|
||||
#else
|
||||
float specular = 0;
|
||||
#endif
|
||||
|
||||
float3 result = lerp( diffuse, env, fre ) + specular.xxx;
|
||||
result = lerp( G.FogColor.rgb, result, v.tc0Fog.z );
|
||||
|
||||
return float4( result, 1 );
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
|
||||
//
|
||||
// Old new water saved here for possible damage control.
|
||||
// To be removed in a couple of weeks.
|
||||
//
|
||||
// - Max
|
||||
//
|
||||
|
||||
#include "common.h"
|
||||
|
||||
uniform float4x4 WorldMatrix;
|
||||
|
||||
uniform float4 nmAnimLerp; // ratio between normal map frames
|
||||
uniform float4 waveParams; // .x = frequency .y = phase .z = height
|
||||
uniform float4 WaterColor; // deep water color
|
||||
|
||||
#ifdef PIN_HQ
|
||||
# define WATER_LOD 1
|
||||
#else
|
||||
# define WATER_LOD 2
|
||||
#endif
|
||||
|
||||
//#undef WATER_LOD
|
||||
//#define WATER_LOD 0
|
||||
|
||||
float fadeFactor( float3 wspos )
|
||||
{
|
||||
return saturate( -0.4f + 1.4f*length( G.CameraPosition.xyz - wspos.xyz ) * G.FadeDistance.y );
|
||||
}
|
||||
|
||||
float wave( float4 wspos )
|
||||
{
|
||||
float x = sin( ( wspos.z - wspos.x - waveParams.y ) * waveParams.x );
|
||||
float z = sin( ( wspos.z + wspos.x + waveParams.y ) * waveParams.x );
|
||||
float p = (x + z) * waveParams.z;
|
||||
return p - p * fadeFactor( wspos.xyz );
|
||||
}
|
||||
|
||||
// Fresnel approximation. N1 and N2 are refractive indices.
|
||||
// for above water, use n1 = 1, n2 = 1.3, for underwater use n1 = 1.3, n2 = 1
|
||||
// TODO: use mul/bias hack on ipad
|
||||
float fresnel( float3 N, float3 V, float n1, float n2, float p, float fade )
|
||||
{
|
||||
#if WATER_LOD == 0
|
||||
float r0 = (n1-n2)/(n1+n2);
|
||||
r0 *= r0;
|
||||
return r0 + (1-r0) * pow( 1 - abs( dot( N, V ) ), p );
|
||||
#else
|
||||
return saturate( - 2.5 * abs( dot( N, V ) ) + 0.78 ); // HAXX!
|
||||
//return 1 - 2 * abs( dot( N, V ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
// perturbs the water mesh and vertex normals
|
||||
// TODO: remove costly normal computations on ipad
|
||||
void makeWaves( inout float4 wspos, inout float3 wsnrm )
|
||||
{
|
||||
#if WATER_LOD == 0
|
||||
float gridSize = 4.0f;
|
||||
|
||||
float4 wspos1 = wspos;
|
||||
float4 wspos2 = wspos;
|
||||
|
||||
wspos1.x += gridSize;
|
||||
wspos2.z += gridSize;
|
||||
|
||||
wspos.y += wave(wspos) ;
|
||||
wspos1.y += wave(wspos1);
|
||||
wspos2.y += wave(wspos2);
|
||||
|
||||
wsnrm = normalize( cross( wspos2.xyz - wspos.xyz, wspos1.xyz - wspos.xyz ) );
|
||||
#elif WATER_LOD == 1
|
||||
wspos.y += wave( wspos );
|
||||
#else /* do n0thing */
|
||||
#endif
|
||||
}
|
||||
|
||||
struct V2P
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float3 tc0Fog : TEXCOORD0;
|
||||
float4 wspos : TEXCOORD1;
|
||||
float3 wsnrm : TEXCOORD2;
|
||||
float3 light : TEXCOORD3;
|
||||
float2 fade : TEXCOORD4;
|
||||
};
|
||||
|
||||
V2P water_vs(
|
||||
float4 pos : POSITION,
|
||||
float3 nrm : NORMAL
|
||||
)
|
||||
{
|
||||
V2P o;
|
||||
|
||||
// Decode vertex data
|
||||
nrm = (nrm - 127) / 127;
|
||||
|
||||
nrm = normalize(nrm);
|
||||
|
||||
float4 wspos = mul( WorldMatrix, pos );
|
||||
float3 wsnrm = nrm;
|
||||
|
||||
wspos.y -= 2*waveParams.z;
|
||||
|
||||
makeWaves( /*INOUT*/ wspos, /*INOUT*/ wsnrm );
|
||||
|
||||
o.wspos = wspos;
|
||||
o.wsnrm = wsnrm;
|
||||
|
||||
if( nrm.y < 0.01f ) o.wsnrm = nrm;
|
||||
|
||||
// box mapping
|
||||
//float3x2 m = { wspos.xz, wspos.xy, wspos.yz };
|
||||
//float2 tcselect = mul( abs( nrm.yzx ), m );
|
||||
|
||||
float2 tcselect;
|
||||
float3 wspostc = float3( wspos.x, -wspos.y, wspos.z );
|
||||
|
||||
tcselect.x = dot( abs( nrm.yxz ), wspostc.xzx );
|
||||
tcselect.y = dot( abs( nrm.yxz ), wspostc.zyy );
|
||||
|
||||
o.pos = mul( G.ViewProjection, wspos );
|
||||
o.tc0Fog.xy = tcselect * .05f;
|
||||
o.tc0Fog.z = saturate( (G.FogParams.z - o.pos.w) * G.FogParams.w );
|
||||
|
||||
o.light = lgridPrepareSample(lgridOffset(wspos.xyz, wsnrm.xyz));
|
||||
|
||||
o.fade.x = fadeFactor( wspos.xyz );
|
||||
o.fade.y = (1-o.fade.x) * saturate( dot( wsnrm, -G.Lamp0Dir ) ) * 100;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sampler2D NormalMap1 : register(s0);
|
||||
sampler2D NormalMap2 : register(s1);
|
||||
samplerCUBE EnvMap : register(s2);
|
||||
LGRID_SAMPLER LightMap : register(s3);
|
||||
sampler2D LightMapLookup: register(s4);
|
||||
|
||||
float3 pixelNormal( float2 tc0 )
|
||||
{
|
||||
float4 nm1 = tex2D( NormalMap1, tc0 );
|
||||
#if WATER_LOD <= 1
|
||||
float4 nm2 = tex2D( NormalMap2, tc0 );
|
||||
float3 normal = lerp( nm1, nm2, nmAnimLerp.xxxx ).agb;
|
||||
#else
|
||||
float3 normal = nm1.agb;
|
||||
#endif
|
||||
//normal = nm2;
|
||||
normal.xy = 2*normal.xy - 1;
|
||||
normal.z = sqrt( 1.001 - saturate1( dot( normal.xy, normal.xy ) ) );
|
||||
return normal;
|
||||
}
|
||||
|
||||
|
||||
float4 envColor( float3 N, float3 V, float fade )
|
||||
{
|
||||
float4 solidColor = float4( 0.65f, 0.85f, 0.93f, 1 )*.95f;
|
||||
#if WATER_LOD > 1
|
||||
return solidColor;
|
||||
#endif
|
||||
|
||||
float3 dir = reflect( V, N );
|
||||
return lerp( texCUBE( EnvMap, V ), solidColor, fade );
|
||||
|
||||
//return float3( 0.8f, 0.8f, 0.93f )*.91f;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
float4 water_ps( V2P v ) : COLOR0
|
||||
{
|
||||
float4 WaterColorTest = 0.5 * float4( 26, 169, 185, 0 ) / 255;
|
||||
float4 FogColorTest = 0.8 * float4( 35, 107, 130, 0 ) / 255;
|
||||
|
||||
float3 N2 = v.wsnrm;
|
||||
float3 N1 = pixelNormal( v.tc0Fog.xy ).xzy;
|
||||
float3 N3 = 0.5f * (N2 + N1);
|
||||
|
||||
float3 L = /*normalize*/(-G.Lamp0Dir.xyz);
|
||||
float3 E = normalize( G.CameraPosition.xyz - v.wspos.xyz );
|
||||
|
||||
float4 light = lgridSample(LightMap, LightMapLookup, v.light.xyz);
|
||||
|
||||
float3 ambient = ( light.rgb + G.AmbientColor.rgb );
|
||||
float fre = fresnel( N3, E, 1.0f, 1.3f, 8, v.fade.x );
|
||||
float3 diffuse = WaterColor.rgb + N1.y*0.02f;
|
||||
|
||||
float3 env = envColor( N3, E, v.fade.x ).rgb;
|
||||
|
||||
float3 R = reflect( -L, N1 );
|
||||
|
||||
#if WATER_LOD <= 1
|
||||
float3 specular = pow( saturate( dot( R, E ) ), 900 ) * saturate( light.a - 0.4f ) * v.fade.y; // * (L.y * 100);
|
||||
#else
|
||||
float3 specular = 0;
|
||||
#endif
|
||||
|
||||
float3 result = lerp( diffuse, env, fre ) * ( G.Lamp0Color.rgb * light.a + ambient ) + specular;
|
||||
result = lerp( G.FogColor.rgb, result, v.tc0Fog.z );
|
||||
|
||||
return float4( result, 1 );
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#define CFG_TEXTURE_TILING 1
|
||||
|
||||
#define CFG_DIFFUSE_SCALE 1
|
||||
#define CFG_SPECULAR_SCALE 2
|
||||
#define CFG_GLOSS_SCALE 256
|
||||
#define CFG_REFLECTION_SCALE 0
|
||||
|
||||
#define CFG_NORMAL_SHADOW_SCALE 0.3
|
||||
|
||||
#define CFG_SPECULAR_LOD 0.25
|
||||
#define CFG_GLOSS_LOD 32
|
||||
|
||||
#define CFG_NORMAL_DETAIL_TILING 7
|
||||
#define CFG_NORMAL_DETAIL_SCALE 0.6
|
||||
|
||||
#define CFG_FAR_TILING 0
|
||||
#define CFG_FAR_DIFFUSE_CUTOFF 0
|
||||
#define CFG_FAR_NORMAL_CUTOFF 0
|
||||
#define CFG_FAR_SPECULAR_CUTOFF 0
|
||||
|
||||
#include "material.hlsl"
|
||||
Reference in New Issue
Block a user