Urho3D/bin/CoreData/Shaders/HLSL/VegetationDepth.hlsl
gleblebedev c4a8e9b098
Vegetation shader and technique bugfixes (#2659)
* Vegetation shader and technique bugfixes

* GLSL bug fix for vegetation shader

* pivot fixed

* Shaders fixed

* Text formatting
2020-07-14 04:08:32 +03:00

60 lines
1.5 KiB
HLSL

#include "Uniforms.hlsl"
#include "Samplers.hlsl"
#include "Transform.hlsl"
#ifndef D3D11
// D3D9 uniforms
uniform float cWindHeightFactor;
uniform float cWindHeightPivot;
uniform float cWindPeriod;
uniform float2 cWindWorldSpacing;
#ifdef WINDSTEMAXIS
uniform float3 cWindStemAxis;
#endif
#else
// D3D11 constant buffer
cbuffer CustomVS : register(b6)
{
float cWindHeightFactor;
float cWindHeightPivot;
float cWindPeriod;
float2 cWindWorldSpacing;
#ifdef WINDSTEMAXIS
float3 cWindStemAxis;
#endif
}
#endif
void VS(float4 iPos : POSITION,
#ifdef SKINNED
float4 iBlendWeights : BLENDWEIGHT,
int4 iBlendIndices : BLENDINDICES,
#endif
#ifdef INSTANCED
float4x3 iModelInstance : TEXCOORD4,
#endif
float2 iTexCoord : TEXCOORD0,
out float3 oTexCoord : TEXCOORD0,
out float4 oPos : OUTPOSITION)
{
float4x3 modelMatrix = iModelMatrix;
float3 worldPos = GetWorldPos(modelMatrix);
#ifdef WINDSTEMAXIS
float stemDistance = dot(iPos, cWindStemAxis);
#else
float stemDistance = iPos.y;
#endif
float windStrength = max(stemDistance - cWindHeightPivot, 0.0) * cWindHeightFactor;
float windPeriod = cElapsedTime * cWindPeriod + dot(worldPos.xz, cWindWorldSpacing);
worldPos.x += windStrength * sin(windPeriod);
worldPos.z -= windStrength * cos(windPeriod);
oPos = GetClipPos(worldPos);
oTexCoord = float3(GetTexCoord(iTexCoord), GetDepth(oPos));
}