UNPKG

playcanvas

Version:

Open-source WebGL/WebGPU 3D engine for the web

3 lines (2 loc) 3.25 kB
declare const _default: "\n #define LIT_SKYBOX_INTENSITY\n\n #include \"envProcPS\"\n #include \"gammaPS\"\n #include \"tonemappingPS\"\n\n #ifdef PREPASS_PASS\n varying float vLinearDepth;\n #include \"floatAsUintPS\"\n #endif\n\n varying vec3 vViewDir;\n uniform float skyboxHighlightMultiplier;\n\n #if defined(SKY_FISHEYE) && !defined(SKYMESH)\n uniform float fisheye_k;\n uniform float fisheye_invK;\n uniform float fisheye_projMat00;\n uniform float fisheye_projMat11;\n uniform mat4 matrix_view;\n uniform mat3 cubeMapRotationMatrix;\n varying vec3 vClipXYW;\n #endif\n\n #ifdef SKY_CUBEMAP\n\n uniform samplerCube texture_cubeMap;\n\n #ifdef SKYMESH\n varying vec3 vWorldPos;\n uniform mat3 cubeMapRotationMatrix;\n uniform vec3 projectedSkydomeCenter;\n #endif\n\n #else // env-atlas\n\n #include \"sphericalPS\"\n #include \"envAtlasPS\"\n\n uniform sampler2D texture_envAtlas;\n uniform float mipLevel;\n\n #endif\n\n void main(void) {\n\n #ifdef PREPASS_PASS\n\n // output linear depth during prepass\n gl_FragColor = float2vec4(vLinearDepth);\n\n #else\n\n // --- compute view direction ---\n\n #if defined(SKY_FISHEYE) && !defined(SKYMESH)\n\n vec2 ndc = vClipXYW.xy / vClipXYW.z;\n float px = ndc.x / fisheye_projMat00;\n float py = ndc.y / fisheye_projMat11;\n float r = sqrt(px * px + py * py);\n float theta = fisheye_k * atan(r * fisheye_invK);\n float sinT = sin(theta);\n float cosT = cos(theta);\n vec3 camDir = (r > 1e-6)\n ? vec3(px / r * sinT, py / r * sinT, -cosT)\n : vec3(0.0, 0.0, -1.0);\n vec3 dir = transpose(mat3(matrix_view)) * camDir;\n dir = dir * cubeMapRotationMatrix;\n\n #elif defined(SKY_CUBEMAP) && defined(SKYMESH)\n\n // get vector from world space pos to tripod origin\n vec3 envDir = normalize(vWorldPos - projectedSkydomeCenter);\n vec3 dir = envDir * cubeMapRotationMatrix;\n\n #else\n\n vec3 dir = vViewDir;\n\n #endif\n\n // --- sample environment ---\n\n #ifdef SKY_CUBEMAP\n\n dir.x *= -1.0;\n vec3 linear = {SKYBOX_DECODE_FNC}(textureCube(texture_cubeMap, dir));\n\n #else // env-atlas\n\n dir *= vec3(-1.0, 1.0, 1.0);\n vec2 uv = toSphericalUv(normalize(dir));\n vec3 linear = {SKYBOX_DECODE_FNC}(texture2D(texture_envAtlas, mapRoughnessUv(uv, mipLevel)));\n\n #endif\n\n // our HDR encodes values up to 64, so allow extra brightness for the clipped values\n if (any(greaterThanEqual(linear, vec3(64.0)))) {\n linear *= skyboxHighlightMultiplier;\n }\n\n gl_FragColor = vec4(gammaCorrectOutput(toneMap(processEnvironment(linear))), 1.0);\n\n #endif\n }\n"; export default _default;