diff options
| author | Miles Macklin <[email protected]> | 2017-03-10 14:51:31 +1300 |
|---|---|---|
| committer | Miles Macklin <[email protected]> | 2017-03-10 14:51:31 +1300 |
| commit | ad3d90fafe5ee79964bdfe1f1e0704c3ffcdfd5f (patch) | |
| tree | 4cc6f3288363889d7342f7f8407c0251e6904819 /demo/d3d11/shaders/diffusePS.hlsl | |
| download | flex-ad3d90fafe5ee79964bdfe1f1e0704c3ffcdfd5f.tar.xz flex-ad3d90fafe5ee79964bdfe1f1e0704c3ffcdfd5f.zip | |
Initial 1.1.0 binary release
Diffstat (limited to 'demo/d3d11/shaders/diffusePS.hlsl')
| -rw-r--r-- | demo/d3d11/shaders/diffusePS.hlsl | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/demo/d3d11/shaders/diffusePS.hlsl b/demo/d3d11/shaders/diffusePS.hlsl new file mode 100644 index 0000000..c6e474e --- /dev/null +++ b/demo/d3d11/shaders/diffusePS.hlsl @@ -0,0 +1,37 @@ +#include "shaderCommon.h" + +cbuffer constBuf : register(b0) +{ + DiffuseShaderConst gParams; +}; + +float sqr(float x) { return x * x; } + + +float4 diffusePS(DiffuseGeometryOut input + //, out float gl_FragDepth : SV_DEPTH +) : SV_TARGET +{ + //return float4(1.0f, 0.0f, 0.0f, 1.0f); + + float attenuation = 1.0f; + float lifeTime = input.worldPos.w; + float lifeFade = min(1.0, lifeTime*0.125); + float velocityFade = input.viewVel.w; + + // calculate normal from texture coordinates + float3 normal; + normal.xy = input.uv.xy*float2(2.0, 2.0) + float2(-1.0, -1.0); + float mag = dot(normal.xy, normal.xy); + + // kill pixels outside circle + if (mag > 1.0) + discard; + + normal.z = 1.0-mag; + + float alpha = lifeFade*velocityFade*sqr(normal.z); + + return float4(alpha, alpha, alpha, alpha); + +} |