Fix Vegetation shadow shader for D3D11. Ensure LitSolid changes are ported to Vegetation shader. Put wind related parameters to a custom constant buffer on D3D11. Closes #1052.

This commit is contained in:
Lasse Öörni 2015-11-23 13:49:00 +02:00
parent 371a49afb0
commit d13addbbd7
5 changed files with 81 additions and 7 deletions

View File

@ -70,7 +70,7 @@ void VS()
#ifdef SPOTLIGHT
// Spotlight projection: transform from world space to projector texture coordinates
vSpotPos = projWorldPos * cLightMatrices[0];
vSpotPos = projWorldPos * cLightMatrices[0];
#endif
#ifdef POINTLIGHT

View File

@ -16,6 +16,9 @@ uniform vec2 cWindWorldSpacing;
#endif
varying vec3 vNormal;
varying vec4 vWorldPos;
#ifdef VERTEXCOLOR
varying vec4 vColor;
#endif
#ifdef PERPIXEL
#ifdef SHADOW
varying vec4 vShadowPos[NUMCASCADES];
@ -52,6 +55,10 @@ void VS()
vNormal = GetWorldNormal(modelMatrix);
vWorldPos = vec4(worldPos, GetDepth(gl_Position));
#ifdef VERTEXCOLOR
vColor = iColor;
#endif
#ifdef NORMALMAP
vec3 tangent = GetWorldTangent(modelMatrix);
vec3 bitangent = cross(tangent, vNormal) * iTangent.w;

View File

@ -5,14 +5,37 @@
#include "Lighting.hlsl"
#include "Fog.hlsl"
#ifndef D3D11
// D3D9 uniforms
uniform float cWindHeightFactor;
uniform float cWindHeightPivot;
uniform float cWindPeriod;
uniform float2 cWindWorldSpacing;
#else
// D3D11 constant buffer
cbuffer CustomVS : register(b6)
{
float cWindHeightFactor;
float cWindHeightPivot;
float cWindPeriod;
float2 cWindWorldSpacing;
}
#endif
void VS(float4 iPos : POSITION,
float3 iNormal : NORMAL,
float2 iTexCoord : TEXCOORD0,
#ifndef BILLBOARD
float3 iNormal : NORMAL,
#endif
#ifndef NOUV
float2 iTexCoord : TEXCOORD0,
#endif
#ifdef VERTEXCOLOR
float4 iColor : COLOR0,
#endif
#if defined(LIGHTMAP) || defined(AO)
float2 iTexCoord2 : TEXCOORD1,
#endif
@ -57,11 +80,19 @@ void VS(float4 iPos : POSITION,
out float2 oTexCoord2 : TEXCOORD7,
#endif
#endif
#ifdef VERTEXCOLOR
out float4 oColor : COLOR0,
#endif
#if defined(D3D11) && defined(CLIPPLANE)
out float oClip : SV_CLIPDISTANCE0,
#endif
out float4 oPos : OUTPOSITION)
{
// Define a 0,0 UV coord if not expected from the vertex data
#ifdef NOUV
float2 iTexCoord = float2(0.0, 0.0);
#endif
float4x3 modelMatrix = iModelMatrix;
float3 worldPos = GetWorldPos(modelMatrix);
float height = worldPos.y - cModel._m31;
@ -78,7 +109,11 @@ void VS(float4 iPos : POSITION,
#if defined(D3D11) && defined(CLIPPLANE)
oClip = dot(oPos, cClipPlane);
#endif
#ifdef VERTEXCOLOR
oColor = iColor;
#endif
#ifdef NORMALMAP
float3 tangent = GetWorldTangent(modelMatrix);
float3 bitangent = cross(tangent, oNormal) * iTangent.w;
@ -103,7 +138,7 @@ void VS(float4 iPos : POSITION,
#endif
#ifdef POINTLIGHT
oCubeMaskVec = mul(cLightPos.xyz - worldPos, (float3x3)cLightMatrices[0]);
oCubeMaskVec = mul(worldPos - cLightPos.xyz, (float3x3)cLightMatrices[0]);
#endif
#else
// Ambient & per-vertex lighting

View File

@ -2,11 +2,27 @@
#include "Samplers.hlsl"
#include "Transform.hlsl"
#ifndef D3D11
// D3D9 uniforms
uniform float cWindHeightFactor;
uniform float cWindHeightPivot;
uniform float cWindPeriod;
uniform float2 cWindWorldSpacing;
#else
// D3D11 constant buffer
cbuffer CustomVS : register(b6)
{
float cWindHeightFactor;
float cWindHeightPivot;
float cWindPeriod;
float2 cWindWorldSpacing;
}
#endif
void VS(float4 iPos : POSITION,
#ifdef SKINNED
float4 iBlendWeights : BLENDWEIGHT,
@ -17,7 +33,7 @@ void VS(float4 iPos : POSITION,
#endif
float2 iTexCoord : TEXCOORD0,
out float3 oTexCoord : TEXCOORD0,
out float4 oPos : POSITION)
out float4 oPos : OUTPOSITION)
{
float4x3 modelMatrix = iModelMatrix;
float3 worldPos = GetWorldPos(modelMatrix);

View File

@ -2,11 +2,27 @@
#include "Samplers.hlsl"
#include "Transform.hlsl"
#ifndef D3D11
// D3D9 uniforms
uniform float cWindHeightFactor;
uniform float cWindHeightPivot;
uniform float cWindPeriod;
uniform float2 cWindWorldSpacing;
#else
// D3D11 constant buffer
cbuffer CustomVS : register(b6)
{
float cWindHeightFactor;
float cWindHeightPivot;
float cWindPeriod;
float2 cWindWorldSpacing;
}
#endif
void VS(float4 iPos : POSITION,
#ifdef SKINNED
float4 iBlendWeights : BLENDWEIGHT,
@ -17,7 +33,7 @@ void VS(float4 iPos : POSITION,
#endif
float2 iTexCoord : TEXCOORD0,
out float2 oTexCoord : TEXCOORD0,
out float4 oPos : POSITION)
out float4 oPos : OUTPOSITION)
{
float4x3 modelMatrix = iModelMatrix;
float3 worldPos = GetWorldPos(modelMatrix);