UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 1.68 kB
import{SEMANTIC_POSITION as e}from"../../../platform/graphics/constants.js";import{shaderChunks as t}from"../chunks/chunks.js";import{ChunkUtils as n}from"../chunk-utils.js";import{ShaderUtils as s}from"../../../platform/graphics/shader-utils.js";import{ShaderGenerator as a}from"./shader-generator.js";import{SKYTYPE_INFINITE as o}from"../../constants.js";const i=[128,64,16,8,4,2];const m=new class extends a{generateKey(e){return`skybox-${e.type}-${e.encoding}-${e.gamma}-${e.toneMapping}-${e.skymesh}`+("cubemap"===e.type?`-${e.mip}`:"")}createShaderDefinition(m,p){const r=new Map;r.set("SKYBOX_DECODE_FNC",n.decodeFunc(p.encoding)),p.skymesh!==o&&r.set("SKYMESH",""),"cubemap"===p.type&&(r.set("SKY_CUBEMAP",""),r.set("SKYBOX_MIP",(1-1/i[p.mip]).toString()));const c=new Map;return c.set("decodePS",t.decodePS),c.set("gamma",a.gammaCode(p.gamma)),c.set("tonemapping",a.tonemapCode(p.toneMapping)),c.set("envMultiplyPS",t.envMultiplyPS),"cubemap"===p.type?(c.set("cubemapSeams",p.mip?t.fixCubemapSeamsStretchPS:t.fixCubemapSeamsNonePS),c.set("skyboxHDRPS",t.skyboxHDRPS)):(c.set("sphericalPS",t.sphericalPS),c.set("envAtlasPS",t.envAtlasPS),c.set("skyboxEnvPS",t.skyboxEnvPS)),s.createDefinition(m,{name:"SkyboxShader",attributes:{aPosition:e},vertexCode:t.skyboxVS,vertexDefines:r,fragmentCode:'\n\t\t#include "decodePS"\n\t\t#include "gamma"\n\t\t#include "tonemapping"\n\t\t#include "envMultiplyPS"\n\n\t\t#ifdef SKY_CUBEMAP\n\t\t\t\t#include "cubemapSeams"\n\t\t\t\t#include "skyboxHDRPS"\n\t\t#else\n\t\t\t\t#include "sphericalPS"\n\t\t\t\t#include "envAtlasPS"\n\t\t\t\t#include "skyboxEnvPS"\n\t\t#endif\n',fragmentDefines:r,fragmentIncludes:c})}};export{m as skybox};