playcanvas
Version:
PlayCanvas WebGL game engine
4 lines (2 loc) • 1.05 kB
JavaScript
var reflectionEnvHQPS = "\n#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nuniform samplerCube texture_cubeMap;\nuniform float material_reflectivity;\n\nvec3 calcReflection(vec3 reflDir, float gloss) {\n vec3 dir = cubeMapProject(reflDir) * vec3(-1.0, 1.0, 1.0);\n vec2 uv = toSphericalUv(dir);\n\n // calculate roughness level\n float level = saturate(1.0 - gloss) * 5.0;\n float ilevel = floor(level);\n float flevel = level - ilevel;\n\n vec3 sharp = {reflectionCubemapDecode}(textureCube(texture_cubeMap, dir));\n vec3 roughA = {reflectionDecode}(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel)));\n vec3 roughB = {reflectionDecode}(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel + 1.0)));\n\n return processEnvironment(mix(sharp, mix(roughA, roughB, flevel), min(level, 1.0)));\n}\n\nvoid addReflection(vec3 reflDir, float gloss) { \n dReflection += vec4(calcReflection(reflDir, gloss), material_reflectivity);\n}\n";
export { reflectionEnvHQPS as default };