TriangleDepthVertexShader.hlsl 967 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "VertexConstants.h"
  2. struct VS_INPUT
  3. {
  4. // Per vertex data
  5. float3 vPos : POSITION;
  6. float3 vNorm : NORMAL;
  7. float2 vTex : TEXCOORD0;
  8. float4 vCol : COLOR;
  9. // Per instance data
  10. matrix iModel : INSTANCE_TRANSFORM; // model matrix
  11. matrix iModelInvTrans : INSTANCE_INV_TRANSFORM; // (model matrix^-1)^T
  12. float4 iCol : INSTANCE_COLOR; // color of the model
  13. };
  14. struct VS_OUTPUT
  15. {
  16. float4 Position : SV_POSITION;
  17. };
  18. VS_OUTPUT main(VS_INPUT input)
  19. {
  20. VS_OUTPUT output;
  21. // Check if the alpha = 0
  22. if (input.vCol.a * input.iCol.a == 0.0)
  23. {
  24. // Don't draw the triangle by moving it to an invalid location
  25. output.Position = float4(0, 0, 0, 0);
  26. }
  27. else
  28. {
  29. // Transform the position from world space to homogeneous projection space for the light
  30. float4 pos = float4(input.vPos, 1.0f);
  31. pos = mul(input.iModel, pos);
  32. pos = mul(LightView, pos);
  33. pos = mul(LightProjection, pos);
  34. output.Position = pos;
  35. }
  36. return output;
  37. }