Skybox.bsl 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #include "$ENGINE$\PerCameraData.bslinc"
  2. Parameters =
  3. {
  4. SamplerCUBE gSkySamp : alias("gSkyTex");
  5. TextureCUBE gSkyTex;
  6. };
  7. Technique : inherits("PerCameraData") =
  8. {
  9. Language = "HLSL11";
  10. Pass =
  11. {
  12. Cull = CW;
  13. CompareFunc = LTE;
  14. DepthWrite = false;
  15. Vertex =
  16. {
  17. void main(
  18. in float3 inPos : POSITION,
  19. out float4 oPosition : SV_Position,
  20. out float3 oDir : TEXCOORD0)
  21. {
  22. float4 pos = mul(gMatViewProj, float4(inPos.xyz + gViewOrigin, 1));
  23. // Set Z = W so that final depth is 1.0f and it renders behind everything else
  24. oPosition = pos.xyww;
  25. oDir = inPos;
  26. }
  27. };
  28. Fragment =
  29. {
  30. TextureCube gSkyTex : register(t0);
  31. SamplerState gSkySamp : register(s0);
  32. cbuffer Params : register(b0)
  33. {
  34. float4 gClearColor;
  35. }
  36. float4 main(
  37. in float4 inPos : SV_Position,
  38. in float3 dir : TEXCOORD0) : SV_Target
  39. {
  40. #ifdef SOLID_COLOR
  41. return gClearColor;
  42. #else
  43. return gSkyTex.SampleLevel(gSkySamp, dir, 0);
  44. #endif
  45. }
  46. };
  47. };
  48. };
  49. Technique : inherits("PerCameraData") =
  50. {
  51. Language = "GLSL";
  52. Pass =
  53. {
  54. Cull = CW;
  55. CompareFunc = LTE;
  56. DepthWrite = false;
  57. Vertex =
  58. {
  59. layout(location = 0) in vec3 bs_position;
  60. layout(location = 0) out vec3 dir;
  61. out gl_PerVertex
  62. {
  63. vec4 gl_Position;
  64. };
  65. void main()
  66. {
  67. vec4 pos = gMatViewProj * vec4(bs_position.xyz + gViewOrigin, 1);
  68. // Set Z = W so that final depth is 1.0f and it renders behind everything else
  69. gl_Position = pos.xyww;
  70. dir = bs_position;
  71. }
  72. };
  73. Fragment =
  74. {
  75. layout(location = 0) in vec3 dir;
  76. layout(binding = 1) uniform samplerCube gSkyTex;
  77. layout(binding = 2, std140) uniform Params
  78. {
  79. vec4 gClearColor;
  80. };
  81. layout(location = 0) out vec4 fragColor;
  82. void main()
  83. {
  84. #ifdef SOLID_COLOR
  85. fragColor = gClearColor;
  86. #else
  87. fragColor = textureLod(gSkyTex, dir, 0);
  88. #endif
  89. }
  90. };
  91. };
  92. };