playcanvas
Version:
PlayCanvas WebGL game engine
52 lines (50 loc) • 1.42 kB
JavaScript
var skyboxPS = `
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) {
gl_FragColor = float2vec4(vLinearDepth);
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)));
if (any(greaterThanEqual(linear, vec3(64.0)))) {
linear *= skyboxHighlightMultiplier;
}
gl_FragColor = vec4(gammaCorrectOutput(toneMap(processEnvironment(linear))), 1.0);
}
`;
export { skyboxPS as default };