UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

4 lines (2 loc) 931 B
var envAtlasPS = "\n// the envAtlas is fixed at 512 pixels. every equirect is generated with 1 pixel boundary.\nconst atlasSize : f32 = 512.0;\nconst seamSize : f32 = 1.0 / atlasSize;\n\n// map a normalized equirect UV to the given rectangle (taking 1 pixel seam into account).\nfn mapUv(uv : vec2f, rect : vec4f) -> vec2f {\n return vec2f(mix(rect.x + seamSize, rect.x + rect.z - seamSize, uv.x),\n mix(rect.y + seamSize, rect.y + rect.w - seamSize, uv.y));\n}\n\n// map a normalized equirect UV and roughness level to the correct atlas rect.\nfn mapRoughnessUv(uv : vec2f, level : f32) -> vec2f {\n let t : f32 = 1.0 / exp2(level);\n return mapUv(uv, vec4f(0.0, 1.0 - t, t, t * 0.5));\n}\n\n// map shiny level UV\nfn mapShinyUv(uv : vec2f, level : f32) -> vec2f {\n let t : f32 = 1.0 / exp2(level);\n return mapUv(uv, vec4f(1.0 - t, 1.0 - t, t, t * 0.5));\n}\n"; export { envAtlasPS as default };