Skybox.hlsl 948 B

12345678910111213141516171819202122232425262728293031
  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. #ifdef IGNORENODETRANSFORM
  12. float4x3 modelMatrix = { float3(1.0, 0.0, 0.0), float3(0.0, 1.0, 0.0), float3(0.0, 0.0, 1.0), cViewInv[3] };
  13. #else
  14. float4x3 modelMatrix = iModelMatrix;
  15. #endif
  16. float3 worldPos = GetWorldPos(modelMatrix);
  17. oPos = GetClipPos(worldPos);
  18. oPos.z = oPos.w;
  19. oTexCoord = iPos.xyz;
  20. }
  21. void PS(float3 iTexCoord : TEXCOORD0,
  22. out float4 oColor : OUTCOLOR0)
  23. {
  24. float4 sky = cMatDiffColor * SampleCube(DiffCubeMap, iTexCoord);
  25. #ifdef HDRSCALE
  26. 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);
  27. #endif
  28. oColor = sky;
  29. }