Skybox.hlsl 793 B

12345678910111213141516171819202122232425262728
  1. #include "Uniforms.hlsl"
  2. #include "Samplers.hlsl"
  3. #include "Transform.hlsl"
  4. void VS(float4 iPos : POSITION,
  5. #ifdef INSTANCED
  6. float4x3 iModelInstance : TEXCOORD4,
  7. #endif
  8. out float3 oTexCoord : TEXCOORD0,
  9. out float4 oPos : OUTPOSITION)
  10. {
  11. float4x3 modelMatrix = iModelMatrix;
  12. float3 worldPos = GetWorldPos(modelMatrix);
  13. oPos = GetClipPos(worldPos);
  14. oPos.z = oPos.w;
  15. oTexCoord = iPos.xyz;
  16. }
  17. void PS(float3 iTexCoord : TEXCOORD0,
  18. out float4 oColor : OUTCOLOR0)
  19. {
  20. float4 sky = cMatDiffColor * SampleCube(DiffCubeMap, iTexCoord);
  21. #ifdef HDRSCALE
  22. sky = pow(sky + clamp((cAmbientColor.a - 1.0) * 0.1, 0.0, 0.25), max(cAmbientColor.a, 1.0)) * clamp(cAmbientColor.a, 0.0, 1.0);
  23. #endif
  24. oColor = sky;
  25. }