DeferredDirectionalLightPass.bsl 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #include "$ENGINE$\DeferredLightPass.bslinc"
  2. Technique =
  3. {
  4. Language = "HLSL11";
  5. Pass =
  6. {
  7. DepthRead = false;
  8. Common =
  9. {
  10. struct VStoFS
  11. {
  12. float4 position : SV_POSITION;
  13. float2 uv0 : TEXCOORD0;
  14. float3 screenDir : TEXCOORD1;
  15. };
  16. };
  17. Vertex =
  18. {
  19. struct VertexInput
  20. {
  21. float2 screenPos : POSITION;
  22. float2 uv0 : TEXCOORD0;
  23. };
  24. VStoFS main(VertexInput input)
  25. {
  26. VStoFS output;
  27. output.position = float4(input.screenPos, 0, 1);
  28. output.uv0 = input.uv0;
  29. output.screenDir = mul(gMatInvProj, float4(input.screenPos, 1, 0)).xyz - gViewOrigin.xyz;
  30. return output;
  31. }
  32. };
  33. Fragment =
  34. {
  35. float4 main(VStoFS input) : SV_Target0
  36. {
  37. GBufferData gBufferData = getGBufferData(input.uv0);
  38. if(gBufferData.worldNormal.w > 0.0f)
  39. {
  40. float3 cameraDir = normalize(input.screenDir);
  41. float3 worldPosition = input.screenDir * gBufferData.depth + gViewOrigin;
  42. LightData lightData = getLightData();
  43. return getLighting(worldPosition, input.uv0, gBufferData, lightData);
  44. }
  45. else
  46. return float4(0.0f, 0.0f, 0.0f, 0.0f);
  47. }
  48. };
  49. };
  50. };
  51. Technique =
  52. {
  53. Language = "GLSL";
  54. Pass =
  55. {
  56. DepthRead = false;
  57. Common =
  58. {
  59. varying vec4 position;
  60. varying vec2 uv0;
  61. varying vec3 screenDir;
  62. };
  63. Vertex =
  64. {
  65. in vec2 bs_position;
  66. in vec2 bs_texcoord0;
  67. out gl_PerVertex
  68. {
  69. vec4 gl_Position;
  70. };
  71. void main()
  72. {
  73. position = vec4(bs_position.x, bs_position.y, 0, 1);
  74. uv0 = bs_texcoord0;
  75. screenDir = (gMatInvProj * position).xyz - gViewOrigin.xyz;
  76. gl_Position = position;
  77. }
  78. };
  79. Fragment =
  80. {
  81. out vec4 fragColor;
  82. void main()
  83. {
  84. GBufferData gBufferData = getGBufferData(uv0);
  85. if(gBufferData.worldNormal.w > 0.0f)
  86. {
  87. vec3 cameraDir = normalize(screenDir);
  88. vec3 worldPosition = screenDir * gBufferData.depth + gViewOrigin;
  89. LightData lightData = getLightData();
  90. fragColor = getLighting(worldPosition, uv0, gBufferData, lightData);
  91. }
  92. else
  93. fragColor = vec4(0.0f, 0.0f, 0.0f, 0.0f);
  94. }
  95. };
  96. };
  97. };