aboutsummaryrefslogtreecommitdiff
path: root/demo/d3d/shaders/meshVS.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/meshVS.hlsl
parentUpdate README.md (diff)
downloadflex-688b5f42e9bfe498d7af7075d4d8f4429867f3a3.tar.xz
flex-688b5f42e9bfe498d7af7075d4d8f4429867f3a3.zip
1.2.0.beta.11.2.0.beta.1
Diffstat (limited to 'demo/d3d/shaders/meshVS.hlsl')
-rw-r--r--demo/d3d/shaders/meshVS.hlsl35
1 files changed, 35 insertions, 0 deletions
diff --git a/demo/d3d/shaders/meshVS.hlsl b/demo/d3d/shaders/meshVS.hlsl
new file mode 100644
index 0000000..d2fa9e5
--- /dev/null
+++ b/demo/d3d/shaders/meshVS.hlsl
@@ -0,0 +1,35 @@
+#include "shaderCommon.h"
+
+cbuffer constBuf : register(b0)
+{
+ MeshShaderConst gParams;
+};
+
+MeshVertexOut meshVS(MeshVertexIn input)
+{
+ const float4x4 modelViewProjectionMatrix = gParams.modelViewProjection;
+ const float4x4 modelViewMatrix = gParams.modelView;
+ const float4x4 objectTransform = gParams.objectTransform;
+ const float4x4 lightTransform = gParams.lightTransform;
+
+ float3 n = normalize(mul(objectTransform, float4(input.normal, 0.0)).xyz);
+ float3 p = mul(objectTransform, float4(input.position.xyz, 1.0)).xyz;
+
+ // calculate window-space point size
+ MeshVertexOut output;
+ output.position = mul(modelViewProjectionMatrix, float4(p + gParams.expand * n, 1.0));
+
+ output.worldNormal = n;
+ output.lightOffsetPosition = mul(lightTransform, float4(p + n * gParams.bias, 1.0));
+ output.viewLightDir = mul(modelViewMatrix, float4(gParams.lightDir, 0.0));
+ output.worldPosition = p;
+ if (gParams.colorArray)
+ output.color = input.color;
+ else
+ output.color = gParams.color;
+ output.texCoord = float2(input.texCoord.x, 1.0f - input.texCoord.y); // flip the y component of uv (glsl to hlsl conversion)
+ output.secondaryColor = gParams.secondaryColor;
+ output.viewPosition = mul(modelViewMatrix, float4(input.position.xyz, 1.0));
+
+ return output;
+}