| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- #include "$ENGINE$\GBufferOutput.bslinc"
- #include "$ENGINE$\PerCameraData.bslinc"
- #include "$ENGINE$\PerObjectData.bslinc"
- #include "$ENGINE$\SkinnedVertexInput.bslinc"
- #include "$ENGINE$\NormalVertexInput.bslinc"
- #define USE_BLEND_SHAPES
- #include "$ENGINE$\SkinnedVertexInput.bslinc"
- #include "$ENGINE$\NormalVertexInput.bslinc"
- #undef USE_BLEND_SHAPES
- mixin ShadowDepthBase
- {
- code
- {
- struct ShadowVStoFS
- {
- float4 position : SV_Position;
-
- #ifdef USES_GS
- float4 worldPos : TEXCOORD0;
- #endif
- };
-
- cbuffer ShadowParams
- {
- float gDepthBias;
- float gDepthRange;
- };
- void linearizeDepth(inout float4 clipPos)
- {
- // Clamp to near plane if behind it
- if (clipPos.z < 0)
- {
- clipPos.z = 0.000001f;
- clipPos.w = 1.0f;
- }
- // Output linear depth in range [0, 1]
- // TODO - Handle case for backends using [-1, 1] depth range
- float linearDepth = clipPos.z * gDepthRange + gDepthBias;
- clipPos.z = linearDepth * clipPos.w;
- }
-
- ShadowVStoFS vsmain(VertexInput_PO input)
- {
- ShadowVStoFS output;
-
- float4 worldPosition = getVertexWorldPosition(input);
-
- #ifdef USES_GS
- output.worldPos = worldPosition;
- output.position = worldPosition;
- #else
- float4 clipPos = mul(gMatViewProj, worldPosition);
- linearizeDepth(clipPos);
-
- output.position = clipPos;
- #endif
-
- return output;
- }
- };
- };
- technique ShadowDepth
- {
- mixin GBufferOutput;
- mixin PerCameraData;
- mixin PerObjectData;
- mixin NormalVertexInput;
- mixin ShadowDepthBase;
- mixin ShadowDepth;
- };
- technique ShadowDepthSkinned
- {
- mixin GBufferOutput;
- mixin PerCameraData;
- mixin PerObjectData;
- mixin SkinnedVertexInput;
- mixin ShadowDepthBase;
- mixin ShadowDepth;
- tags = { "Skinned" };
- };
- technique ShadowDepthMorph
- {
- mixin GBufferOutput;
- mixin PerCameraData;
- mixin PerObjectData;
- mixin MorphVertexInput;
- mixin ShadowDepthBase;
- mixin ShadowDepth;
- tags = { "Morph" };
- };
- technique ShadowDepthSkinnedMorph
- {
- mixin GBufferOutput;
- mixin PerCameraData;
- mixin PerObjectData;
- mixin SkinnedMorphVertexInput;
- mixin ShadowDepthBase;
- mixin ShadowDepth;
- tags = { "SkinnedMorph" };
- };
|