playcanvas
Version:
PlayCanvas WebGL game engine
83 lines (53 loc) • 2.05 kB
JavaScript
var skyboxPS = /* glsl */ `
varying float vLinearDepth;
varying vec3 vViewDir;
uniform float skyboxHighlightMultiplier;
uniform samplerCube texture_cubeMap;
varying vec3 vWorldPos;
uniform mat3 cubeMapRotationMatrix;
uniform vec3 projectedSkydomeCenter;
uniform sampler2D texture_envAtlas;
uniform float mipLevel;
void main(void) {
// output linear depth during prepass
gl_FragColor = float2vec4(vLinearDepth);
// get vector from world space pos to tripod origin
vec3 envDir = normalize(vWorldPos - projectedSkydomeCenter);
vec3 dir = envDir * cubeMapRotationMatrix;
vec3 dir = vViewDir;
dir.x *= -1.0;
vec3 linear = {SKYBOX_DECODE_FNC}(textureCube(texture_cubeMap, dir));
vec3 dir = vViewDir * vec3(-1.0, 1.0, 1.0);
vec2 uv = toSphericalUv(normalize(dir));
vec3 linear = {SKYBOX_DECODE_FNC}(texture2D(texture_envAtlas, mapRoughnessUv(uv, mipLevel)));
// our HDR encodes values up to 64, so allow extra brightness for the clipped values
if (any(greaterThanEqual(linear, vec3(64.0)))) {
linear *= skyboxHighlightMultiplier;
}
gl_FragColor = vec4(gammaCorrectOutput(toneMap(processEnvironment(linear))), 1.0);
}
`;
export { skyboxPS as default };