Skybox.bsl 887 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "$ENGINE$\PerCameraData.bslinc"
  2. technique Skybox
  3. {
  4. mixin PerCameraData;
  5. variations
  6. {
  7. SOLID_COLOR = { true, false };
  8. };
  9. raster
  10. {
  11. cull = cw;
  12. };
  13. depth
  14. {
  15. compare = lte;
  16. write = false;
  17. };
  18. code
  19. {
  20. void vsmain(
  21. in float3 inPos : POSITION,
  22. out float4 oPosition : SV_Position,
  23. out float3 oDir : TEXCOORD0)
  24. {
  25. float4 pos = mul(gMatViewProj, float4(inPos.xyz + gViewOrigin, 1));
  26. // Set Z = W so that final depth is 1.0f and it renders behind everything else
  27. oPosition = pos.xyww;
  28. oDir = inPos;
  29. }
  30. TextureCube gSkyTex;
  31. SamplerState gSkySamp;
  32. [internal]
  33. cbuffer Params
  34. {
  35. float4 gClearColor;
  36. }
  37. float4 fsmain(
  38. in float4 inPos : SV_Position,
  39. in float3 dir : TEXCOORD0) : SV_Target
  40. {
  41. #if SOLID_COLOR
  42. return gClearColor;
  43. #else
  44. return gSkyTex.SampleLevel(gSkySamp, dir, 0);
  45. #endif
  46. }
  47. };
  48. };