Skybox.bsl 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. float4 main(
  33. in float4 inPos : SV_Position,
  34. in float3 dir : TEXCOORD0) : SV_Target
  35. {
  36. return gSkyTex.Sample(gSkySamp, dir);
  37. }
  38. };
  39. };
  40. };
  41. Technique : inherits("PerCameraData") =
  42. {
  43. Language = "GLSL";
  44. Pass =
  45. {
  46. Cull = CW;
  47. CompareFunc = LTE;
  48. DepthWrite = false;
  49. Vertex =
  50. {
  51. layout(location = 0) in vec3 bs_position;
  52. layout(location = 0) out vec3 dir;
  53. out gl_PerVertex
  54. {
  55. vec4 gl_Position;
  56. };
  57. void main()
  58. {
  59. vec4 pos = gMatViewProj * vec4(bs_position.xyz + gViewOrigin, 1);
  60. // Set Z = W so that final depth is 1.0f and it renders behind everything else
  61. gl_Position = pos.xyww;
  62. dir = bs_position;
  63. }
  64. };
  65. Fragment =
  66. {
  67. layout(location = 0) in vec3 dir;
  68. layout(binding = 1) uniform samplerCube gSkyTex;
  69. layout(location = 0) out vec4 fragColor;
  70. void main()
  71. {
  72. fragColor = texture(gSkyTex, dir);
  73. }
  74. };
  75. };
  76. };