aboutsummaryrefslogtreecommitdiff
path: root/demo/d3d/shaders/diffusePS.hlsl
diff options
context:
space:
mode:
authorMiles Macklin <[email protected]>2017-06-09 13:41:15 +1200
committerMiles Macklin <[email protected]>2017-06-09 13:41:15 +1200
commit688b5f42e9bfe498d7af7075d4d8f4429867f3a3 (patch)
tree7e0d0e7c95298f0418723abd92f61ac6e16b055e /demo/d3d/shaders/diffusePS.hlsl
parentUpdate README.md (diff)
downloadflex-1.2.0.beta.1.tar.xz
flex-1.2.0.beta.1.zip
1.2.0.beta.11.2.0.beta.1
Diffstat (limited to 'demo/d3d/shaders/diffusePS.hlsl')
-rw-r--r--demo/d3d/shaders/diffusePS.hlsl29
1 files changed, 29 insertions, 0 deletions
diff --git a/demo/d3d/shaders/diffusePS.hlsl b/demo/d3d/shaders/diffusePS.hlsl
new file mode 100644
index 0000000..b548b49
--- /dev/null
+++ b/demo/d3d/shaders/diffusePS.hlsl
@@ -0,0 +1,29 @@
+#include "shaderCommon.h"
+
+cbuffer constBuf : register(b0)
+{
+ DiffuseShaderConst gParams;
+};
+
+float sqr(float x) { return x * x; }
+
+float4 diffusePS(DiffuseGeometryOut input) : SV_TARGET
+{
+ 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 = float3(input.uv * 2.0 + float2(-1.0, -1.0), 0.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);
+}