@luma.gl/shadertools 8.5.19 → 8.5.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/assemble-shaders.js.map +1 -1
- package/dist/es5/lib/constants.js.map +1 -1
- package/dist/es5/lib/filters/prop-types.js.map +1 -1
- package/dist/es5/lib/inject-shader.js.map +1 -1
- package/dist/es5/lib/platform-defines.js.map +1 -1
- package/dist/es5/lib/resolve-modules.js.map +1 -1
- package/dist/es5/lib/shader-module.js.map +1 -1
- package/dist/es5/lib/transpile-shader.js.map +1 -1
- package/dist/es5/modules/dirlight/dirlight.js.map +1 -1
- package/dist/es5/modules/fp32/fp32.js.map +1 -1
- package/dist/es5/modules/fp64/fp64-arithmetic.glsl.js.map +1 -1
- package/dist/es5/modules/fp64/fp64-functions.glsl.js.map +1 -1
- package/dist/es5/modules/fp64/fp64-utils.js.map +1 -1
- package/dist/es5/modules/fp64/fp64.js.map +1 -1
- package/dist/es5/modules/fxaa/fxaa.js.map +1 -1
- package/dist/es5/modules/geometry/geometry.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/brightnesscontrast.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/denoise.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/noise.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/sepia.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/vibrance.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/vignette.js.map +1 -1
- package/dist/es5/modules/image-blur-filters/tiltshift.js.map +1 -1
- package/dist/es5/modules/image-blur-filters/triangleblur.js.map +1 -1
- package/dist/es5/modules/image-blur-filters/zoomblur.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/colorhalftone.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/dotscreen.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/edgework.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/hexagonalpixelate.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/ink.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/magnify.js.map +1 -1
- package/dist/es5/modules/image-warp-filters/bulgepinch.js.map +1 -1
- package/dist/es5/modules/image-warp-filters/swirl.js.map +1 -1
- package/dist/es5/modules/image-warp-filters/warp.js.map +1 -1
- package/dist/es5/modules/index.js.map +1 -1
- package/dist/es5/modules/lights/lights.glsl.js.map +1 -1
- package/dist/es5/modules/lights/lights.js.map +1 -1
- package/dist/es5/modules/module-injectors.js.map +1 -1
- package/dist/es5/modules/pbr/pbr-fragment.glsl.js.map +1 -1
- package/dist/es5/modules/pbr/pbr-vertex.glsl.js.map +1 -1
- package/dist/es5/modules/pbr/pbr.js.map +1 -1
- package/dist/es5/modules/phong-lighting/phong-lighting.glsl.js.map +1 -1
- package/dist/es5/modules/phong-lighting/phong-lighting.js.map +1 -1
- package/dist/es5/modules/picking/picking.js.map +1 -1
- package/dist/es5/modules/project/project.js.map +1 -1
- package/dist/es5/modules/transform/transform.js.map +1 -1
- package/dist/es5/modules/utils/random.js.map +1 -1
- package/dist/es5/utils/assert.js.map +1 -1
- package/dist/es5/utils/index.js.map +1 -1
- package/dist/es5/utils/is-old-ie.js.map +1 -1
- package/dist/es5/utils/shader-utils.js.map +1 -1
- package/dist/es5/utils/webgl-info.js.map +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/assemble-shaders.js.map +1 -1
- package/dist/esm/lib/constants.js.map +1 -1
- package/dist/esm/lib/filters/prop-types.js.map +1 -1
- package/dist/esm/lib/inject-shader.js.map +1 -1
- package/dist/esm/lib/platform-defines.js.map +1 -1
- package/dist/esm/lib/resolve-modules.js.map +1 -1
- package/dist/esm/lib/shader-module.js.map +1 -1
- package/dist/esm/lib/transpile-shader.js.map +1 -1
- package/dist/esm/modules/dirlight/dirlight.js.map +1 -1
- package/dist/esm/modules/fp32/fp32.js.map +1 -1
- package/dist/esm/modules/fp64/fp64-arithmetic.glsl.js.map +1 -1
- package/dist/esm/modules/fp64/fp64-functions.glsl.js.map +1 -1
- package/dist/esm/modules/fp64/fp64-utils.js.map +1 -1
- package/dist/esm/modules/fp64/fp64.js.map +1 -1
- package/dist/esm/modules/fxaa/fxaa.js.map +1 -1
- package/dist/esm/modules/geometry/geometry.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/brightnesscontrast.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/denoise.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/noise.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/sepia.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/vibrance.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/vignette.js.map +1 -1
- package/dist/esm/modules/image-blur-filters/tiltshift.js.map +1 -1
- package/dist/esm/modules/image-blur-filters/triangleblur.js.map +1 -1
- package/dist/esm/modules/image-blur-filters/zoomblur.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/colorhalftone.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/dotscreen.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/edgework.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/hexagonalpixelate.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/ink.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/magnify.js.map +1 -1
- package/dist/esm/modules/image-warp-filters/bulgepinch.js.map +1 -1
- package/dist/esm/modules/image-warp-filters/swirl.js.map +1 -1
- package/dist/esm/modules/image-warp-filters/warp.js.map +1 -1
- package/dist/esm/modules/index.js.map +1 -1
- package/dist/esm/modules/lights/lights.glsl.js.map +1 -1
- package/dist/esm/modules/lights/lights.js.map +1 -1
- package/dist/esm/modules/module-injectors.js.map +1 -1
- package/dist/esm/modules/pbr/pbr-fragment.glsl.js.map +1 -1
- package/dist/esm/modules/pbr/pbr-vertex.glsl.js.map +1 -1
- package/dist/esm/modules/pbr/pbr.js.map +1 -1
- package/dist/esm/modules/phong-lighting/phong-lighting.glsl.js.map +1 -1
- package/dist/esm/modules/phong-lighting/phong-lighting.js.map +1 -1
- package/dist/esm/modules/picking/picking.js.map +1 -1
- package/dist/esm/modules/project/project.js.map +1 -1
- package/dist/esm/modules/transform/transform.js.map +1 -1
- package/dist/esm/modules/utils/random.js.map +1 -1
- package/dist/esm/utils/assert.js.map +1 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/is-old-ie.js.map +1 -1
- package/dist/esm/utils/shader-utils.js.map +1 -1
- package/dist/esm/utils/webgl-info.js.map +1 -1
- package/package.json +2 -2
- package/src/.DS_Store +0 -0
- package/src/lib/.DS_Store +0 -0
- package/src/modules/.DS_Store +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"swirl.js","names":["warp","fs","uniforms","center","radius","value","min","softMax","angle","softMin","swirl","name","dependencies","passes","sampler"],"sources":["../../../../src/modules/image-warp-filters/swirl.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\nimport {warp} from './warp';\n\nconst fs = `\\\nuniform float radius;\nuniform float angle;\nuniform vec2 center;\n\nvec2 swirl_warp(vec2 coord, vec2 texCenter) {\n coord -= texCenter;\n float distance = length(coord);\n if (distance < radius) {\n float percent = (radius - distance) / radius;\n float theta = percent * percent * angle;\n float s = sin(theta);\n float c = cos(theta);\n coord = vec2(\n coord.x * c - coord.y * s,\n coord.x * s + coord.y * c\n );\n }\n coord += texCenter;\n return coord;\n}\n\nvec4 swirl_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n vec2 coord = texCoord * texSize;\n coord = swirl_warp(coord, center * texSize);\n\n return warp_sampleColor(texture, texSize, coord);\n}\n`;\n\nconst uniforms = {\n center: [0.5, 0.5],\n radius: {value: 200, min: 1, softMax: 600},\n angle: {value: 3, softMin: -25, softMax: 25}\n};\n\n/** @type {ShaderPass} */\nexport const swirl = {\n name: 'swirl',\n fs,\n uniforms,\n dependencies: [warp],\n passes: [{sampler: true}]\n};\n"],"mappings":"AACA,SAAQA,IAAR,QAAmB,QAAnB;AAEA,MAAMC,EAAE,8sBAAR;AA8BA,MAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE,CAAC,GAAD,EAAM,GAAN,CADO;EAEfC,MAAM,EAAE;IAACC,KAAK,EAAE,GAAR;IAAaC,GAAG,EAAE,CAAlB;IAAqBC,OAAO,EAAE;EAA9B,CAFO;EAGfC,KAAK,EAAE;IAACH,KAAK,EAAE,CAAR;IAAWI,OAAO,EAAE,CAAC,EAArB;IAAyBF,OAAO,EAAE;EAAlC;AAHQ,CAAjB;AAOA,OAAO,MAAMG,KAAK,GAAG;EACnBC,IAAI,EAAE,OADa;EAEnBV,EAFmB;EAGnBC,QAHmB;EAInBU,YAAY,EAAE,CAACZ,IAAD,CAJK;EAKnBa,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD;AALW,CAAd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"warp.js","names":["fs","warp","name"],"sources":["../../../../src/modules/image-warp-filters/warp.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderModule} ShaderModule */\n\nconst fs = `\\\nvec4 warp_sampleColor(sampler2D texture, vec2 texSize, vec2 coord) {\n vec4 color = texture2D(texture, coord / texSize);\n vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);\n if (coord != clampedCoord) {\n /* fade to transparent if we are outside the image */\n color.a *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n\n return color;\n}\n`;\n\n/** @type {ShaderModule} */\nexport const warp = {\n name: 'warp',\n fs\n};\n"],"mappings":"AAEA,MAAMA,EAAE,kTAAR;AAcA,OAAO,MAAMC,IAAI,GAAG;EAClBC,IAAI,EAAE,MADY;EAElBF;AAFkB,CAAb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["random","fp32","fp64","fp64arithmetic","project","lights","dirlight","picking","gouraudLighting","phongLighting","pbr","tiltShift","triangleBlur","zoomBlur","brightnessContrast","denoise","hueSaturation","noise","sepia","vibrance","vignette","colorHalftone","dotScreen","edgeWork","hexagonalPixelate","ink","magnify","bulgePinch","swirl","warp","_warp","fxaa","transform","_transform"],"sources":["../../../src/modules/index.js"],"sourcesContent":["// utils\nexport {random} from './utils/random';\n\n// math libraries\nexport {fp32} from './fp32/fp32';\nexport {fp64, fp64arithmetic} from './fp64/fp64';\n\n// projection and lighting\nexport {project} from './project/project';\nexport {lights} from './lights/lights';\nexport {dirlight} from './dirlight/dirlight';\nexport {picking} from './picking/picking';\nexport {gouraudLighting, phongLighting} from './phong-lighting/phong-lighting';\nexport {pbr} from './pbr/pbr';\n\n// glfx BLUR shader modules\nexport {tiltShift} from './image-blur-filters/tiltshift';\nexport {triangleBlur} from './image-blur-filters/triangleblur';\nexport {zoomBlur} from './image-blur-filters/zoomblur';\n\n// glfx image adjustment shader modules\nexport {brightnessContrast} from './image-adjust-filters/brightnesscontrast';\nexport {denoise} from './image-adjust-filters/denoise';\nexport {hueSaturation} from './image-adjust-filters/huesaturation';\nexport {noise} from './image-adjust-filters/noise';\nexport {sepia} from './image-adjust-filters/sepia';\nexport {vibrance} from './image-adjust-filters/vibrance';\nexport {vignette} from './image-adjust-filters/vignette';\n\n// glfx FUN shader modules\nexport {colorHalftone} from './image-fun-filters/colorhalftone';\nexport {dotScreen} from './image-fun-filters/dotscreen';\nexport {edgeWork} from './image-fun-filters/edgework';\nexport {hexagonalPixelate} from './image-fun-filters/hexagonalpixelate';\nexport {ink} from './image-fun-filters/ink';\nexport {magnify} from './image-fun-filters/magnify';\n\n// glfx WARP shader modules\nexport {bulgePinch} from './image-warp-filters/bulgepinch';\nexport {swirl} from './image-warp-filters/swirl';\nexport {warp as _warp} from './image-warp-filters/warp';\n\n// Postprocessing\nexport {fxaa} from './fxaa/fxaa';\n\n// experimental\nexport {transform as _transform} from './transform/transform';\n"],"mappings":"AACA,SAAQA,MAAR,QAAqB,gBAArB;AAGA,SAAQC,IAAR,QAAmB,aAAnB;AACA,SAAQC,IAAR,EAAcC,cAAd,QAAmC,aAAnC;AAGA,SAAQC,OAAR,QAAsB,mBAAtB;AACA,SAAQC,MAAR,QAAqB,iBAArB;AACA,SAAQC,QAAR,QAAuB,qBAAvB;AACA,SAAQC,OAAR,QAAsB,mBAAtB;AACA,SAAQC,eAAR,EAAyBC,aAAzB,QAA6C,iCAA7C;AACA,SAAQC,GAAR,QAAkB,WAAlB;AAGA,SAAQC,SAAR,QAAwB,gCAAxB;AACA,SAAQC,YAAR,QAA2B,mCAA3B;AACA,SAAQC,QAAR,QAAuB,+BAAvB;AAGA,SAAQC,kBAAR,QAAiC,2CAAjC;AACA,SAAQC,OAAR,QAAsB,gCAAtB;AACA,SAAQC,aAAR,QAA4B,sCAA5B;AACA,SAAQC,KAAR,QAAoB,8BAApB;AACA,SAAQC,KAAR,QAAoB,8BAApB;AACA,SAAQC,QAAR,QAAuB,iCAAvB;AACA,SAAQC,QAAR,QAAuB,iCAAvB;AAGA,SAAQC,aAAR,QAA4B,mCAA5B;AACA,SAAQC,SAAR,QAAwB,+BAAxB;AACA,SAAQC,QAAR,QAAuB,8BAAvB;AACA,SAAQC,iBAAR,QAAgC,uCAAhC;AACA,SAAQC,GAAR,QAAkB,yBAAlB;AACA,SAAQC,OAAR,QAAsB,6BAAtB;AAGA,SAAQC,UAAR,QAAyB,iCAAzB;AACA,SAAQC,KAAR,QAAoB,4BAApB;AACA,SAAQC,IAAI,IAAIC,KAAhB,QAA4B,2BAA5B;AAGA,SAAQC,IAAR,QAAmB,aAAnB;AAGA,SAAQC,SAAS,IAAIC,UAArB,QAAsC,uBAAtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"lights.glsl.js","names":[],"sources":["../../../../src/modules/lights/lights.glsl.js"],"sourcesContent":["export default `\\\n#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\n\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n\n // Constant-Linear-Exponential\n vec3 attenuation;\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform AmbientLight lighting_uAmbientLight;\nuniform PointLight lighting_uPointLight[MAX_LIGHTS];\nuniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];\nuniform int lighting_uPointLightCount;\nuniform int lighting_uDirectionalLightCount;\n\nuniform bool lighting_uEnabled;\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n#endif\n`;\n"],"mappings":"AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"lights.js","names":["lightingShader","INITIAL_MODULE_OPTIONS","lightSources","convertColor","color","intensity","map","component","getLightSourceUniforms","ambientLight","pointLights","directionalLights","lightSourceUniforms","forEach","pointLight","index","position","attenuation","lighting_uPointLightCount","length","directionalLight","direction","lighting_uDirectionalLightCount","getUniforms","opts","hasLights","lighting_uEnabled","Object","assign","light","lights","type","push","name","vs","fs","defines","MAX_LIGHTS"],"sources":["../../../../src/modules/lights/lights.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderModule} ShaderModule */\n\nimport lightingShader from './lights.glsl';\n\nconst INITIAL_MODULE_OPTIONS = {\n lightSources: {}\n};\n\n// Take color 0-255 and intensity as input and output 0.0-1.0 range\nfunction convertColor({color = [0, 0, 0], intensity = 1.0} = {}) {\n return color.map(component => (component * intensity) / 255.0);\n}\n\nfunction getLightSourceUniforms({ambientLight, pointLights = [], directionalLights = []}) {\n const lightSourceUniforms = {};\n\n if (ambientLight) {\n lightSourceUniforms['lighting_uAmbientLight.color'] = convertColor(ambientLight);\n } else {\n lightSourceUniforms['lighting_uAmbientLight.color'] = [0, 0, 0];\n }\n\n pointLights.forEach((pointLight, index) => {\n lightSourceUniforms[`lighting_uPointLight[${index}].color`] = convertColor(pointLight);\n lightSourceUniforms[`lighting_uPointLight[${index}].position`] = pointLight.position;\n lightSourceUniforms[`lighting_uPointLight[${index}].attenuation`] = pointLight.attenuation || [\n 1,\n 0,\n 0\n ];\n });\n lightSourceUniforms.lighting_uPointLightCount = pointLights.length;\n\n directionalLights.forEach((directionalLight, index) => {\n lightSourceUniforms[`lighting_uDirectionalLight[${index}].color`] = convertColor(\n directionalLight\n );\n lightSourceUniforms[`lighting_uDirectionalLight[${index}].direction`] =\n directionalLight.direction;\n });\n lightSourceUniforms.lighting_uDirectionalLightCount = directionalLights.length;\n\n return lightSourceUniforms;\n}\n\n// eslint-disable-next-line complexity\nfunction getUniforms(opts = INITIAL_MODULE_OPTIONS) {\n // Specify lights separately\n if ('lightSources' in opts) {\n const {ambientLight, pointLights, directionalLights} = opts.lightSources || {};\n const hasLights =\n ambientLight ||\n (pointLights && pointLights.length > 0) ||\n (directionalLights && directionalLights.length > 0);\n\n if (!hasLights) {\n return {lighting_uEnabled: false};\n }\n\n return Object.assign(\n {},\n getLightSourceUniforms({ambientLight, pointLights, directionalLights}),\n {\n lighting_uEnabled: true\n }\n );\n }\n\n // Support for array of lights. Type of light is detected by type field\n if ('lights' in opts) {\n const lightSources = {pointLights: [], directionalLights: []};\n // @ts-ignore\n for (const light of opts.lights || []) {\n switch (light.type) {\n case 'ambient':\n // Note: Only uses last ambient light\n // TODO - add ambient light sources on CPU?\n lightSources.ambientLight = light;\n break;\n case 'directional':\n lightSources.directionalLights.push(light);\n break;\n case 'point':\n lightSources.pointLights.push(light);\n break;\n default:\n // eslint-disable-next-line\n // console.warn(light.type);\n }\n }\n\n // Call the `opts.lightSources`` version\n return getUniforms({lightSources});\n }\n\n return {};\n}\n\n/** @type {ShaderModule} */\nexport const lights = {\n name: 'lights',\n vs: lightingShader,\n fs: lightingShader,\n getUniforms,\n defines: {\n MAX_LIGHTS: 3\n }\n};\n"],"mappings":"AAEA,OAAOA,cAAP,MAA2B,eAA3B;AAEA,MAAMC,sBAAsB,GAAG;EAC7BC,YAAY,EAAE;AADe,CAA/B;;AAKA,SAASC,YAAT,GAAiE;EAAA,IAA3C;IAACC,KAAK,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAT;IAAoBC,SAAS,GAAG;EAAhC,CAA2C,uEAAJ,EAAI;EAC/D,OAAOD,KAAK,CAACE,GAAN,CAAUC,SAAS,IAAKA,SAAS,GAAGF,SAAb,GAA0B,KAAjD,CAAP;AACD;;AAED,SAASG,sBAAT,OAA0F;EAAA,IAA1D;IAACC,YAAD;IAAeC,WAAW,GAAG,EAA7B;IAAiCC,iBAAiB,GAAG;EAArD,CAA0D;EACxF,MAAMC,mBAAmB,GAAG,EAA5B;;EAEA,IAAIH,YAAJ,EAAkB;IAChBG,mBAAmB,CAAC,8BAAD,CAAnB,GAAsDT,YAAY,CAACM,YAAD,CAAlE;EACD,CAFD,MAEO;IACLG,mBAAmB,CAAC,8BAAD,CAAnB,GAAsD,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAtD;EACD;;EAEDF,WAAW,CAACG,OAAZ,CAAoB,CAACC,UAAD,EAAaC,KAAb,KAAuB;IACzCH,mBAAmB,gCAAyBG,KAAzB,aAAnB,GAA8DZ,YAAY,CAACW,UAAD,CAA1E;IACAF,mBAAmB,gCAAyBG,KAAzB,gBAAnB,GAAiED,UAAU,CAACE,QAA5E;IACAJ,mBAAmB,gCAAyBG,KAAzB,mBAAnB,GAAoED,UAAU,CAACG,WAAX,IAA0B,CAC5F,CAD4F,EAE5F,CAF4F,EAG5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AL;UAGE7B,YAAY,CAACO,YAAb,GAA4BoB,KAA5B;UACA;;QACF,KAAK,aAAL;UACE3B,YAAY,CAACS,iBAAb,CAA+BqB,IAA/B,CAAoCH,KAApC;UACA;;QACF,KAAK,OAAL;UACE3B,YAAY,CAACQ,WAAb,CAAyBsB,IAAzB,CAA8BH,KAA9B;UACA;;QACF;MAZF;IAgBD;;IAGD,OAAON,WAAW,CAAC;MAACrB;IAAD,CAAD,CAAlB;EACD;;EAED,OAAO,EAAP;AACD;;AAGD,OAAO,MAAM4B,MAAM,GAAG;EACpBG,IAAI,EAAE,QADc;EAEpBC,EAAE,EAAElC,cAFgB;EAGpBmC,EAAE,EAAEnC,cAHgB;EAIpBuB,WAJoB;EAKpBa,OAAO,EAAE;IACPC,UAAU,EAAE;EADL;AALW,CAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"module-injectors.js","names":["MODULE_INJECTORS_VS","MODULE_INJECTORS_FS"],"sources":["../../../src/modules/module-injectors.js"],"sourcesContent":["export const MODULE_INJECTORS_VS = `\\\n#ifdef MODULE_LOGDEPTH\n logdepth_adjustPosition(gl_Position);\n#endif\n`;\n\nexport const MODULE_INJECTORS_FS = `\\\n#ifdef MODULE_MATERIAL\n gl_FragColor = material_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LIGHTING\n gl_FragColor = lighting_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_FOG\n gl_FragColor = fog_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_PICKING\n gl_FragColor = picking_filterHighlightColor(gl_FragColor);\n gl_FragColor = picking_filterPickingColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LOGDEPTH\n logdepth_setFragDepth();\n#endif\n`;\n"],"mappings":"AAAA,OAAO,MAAMA,mBAAmB,8EAAzB;AAMP,OAAO,MAAMC,mBAAmB,0dAAzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/pbr/pbr-fragment.glsl.js"],"names":[],"mappings":"AAOA","sourcesContent":["// This fragment shader defines a reference implementation for Physically Based Shading of\n// a microfacet surface material defined by a glTF model.\n//\n// Attribution:\n// MIT license, Copyright (c) 2016-2017 Mohamad Moneimne and Contributors\n\n// TODO - better do the checks outside of shader\nexport default `\\\n#if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)\n# error PBR fragment shader: Texture LOD is not available\n#endif\n\n#if !defined(HAS_TANGENTS) && !defined(FEATURE_GLSL_DERIVATIVES)\n# error PBR fragment shader: Derivatives are not available\n#endif\n\n// WebGL 1.0 does not support non-constant in for loops\n// This provides an easy way to handle these cases\n// and still take advantage of WebGL 2.0\n#if (__VERSION__ < 300)\n #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL1COND; INCR)\n#else\n #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)\n#endif\n\nprecision highp float;\n\nuniform bool pbr_uUnlit;\n\n#ifdef USE_IBL\nuniform samplerCube u_DiffuseEnvSampler;\nuniform samplerCube u_SpecularEnvSampler;\nuniform sampler2D u_brdfLUT;\nuniform vec2 u_ScaleIBLAmbient;\n#endif\n\n#ifdef HAS_BASECOLORMAP\nuniform sampler2D u_BaseColorSampler;\n#endif\n#ifdef HAS_NORMALMAP\nuniform sampler2D u_NormalSampler;\nuniform float u_NormalScale;\n#endif\n#ifdef HAS_EMISSIVEMAP\nuniform sampler2D u_EmissiveSampler;\nuniform vec3 u_EmissiveFactor;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\nuniform sampler2D u_MetallicRoughnessSampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\nuniform sampler2D u_OcclusionSampler;\nuniform float u_OcclusionStrength;\n#endif\n\n#ifdef ALPHA_CUTOFF\nuniform float u_AlphaCutoff;\n#endif\n\nuniform vec2 u_MetallicRoughnessValues;\nuniform vec4 u_BaseColorFactor;\n\nuniform vec3 u_Camera;\n\n// debugging flags used for shader output of intermediate PBR variables\n#ifdef PBR_DEBUG\nuniform vec4 u_ScaleDiffBaseMR;\nuniform vec4 u_ScaleFGDSpec;\n#endif\n\nvarying vec3 pbr_vPosition;\n\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n#else\nvarying vec3 pbr_vNormal;\n#endif\n#endif\n\n// Encapsulate the various inputs used by the various functions in the shading equation\n// We store values in this struct to simplify the integration of alternative implementations\n// of the shading terms, outlined in the Readme.MD Appendix.\nstruct PBRInfo\n{\n float NdotL; // cos angle between normal and light direction\n float NdotV; // cos angle between normal and view direction\n float NdotH; // cos angle between normal and half vector\n float LdotH; // cos angle between light direction and half vector\n float VdotH; // cos angle between view direction and half vector\n float perceptualRoughness; // roughness value, as authored by the model creator (input to shader)\n float metalness; // metallic value at the surface\n vec3 reflectance0; // full reflectance color (normal incidence angle)\n vec3 reflectance90; // reflectance color at grazing angle\n float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2])\n vec3 diffuseColor; // color contribution from diffuse lighting\n vec3 specularColor; // color contribution from specular lighting\n vec3 n; // normal at surface point\n vec3 v; // vector from surface point to camera\n};\n\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\n\nvec4 SRGBtoLINEAR(vec4 srgbIn)\n{\n#ifdef MANUAL_SRGB\n#ifdef SRGB_FAST_APPROXIMATION\n vec3 linOut = pow(srgbIn.xyz,vec3(2.2));\n#else //SRGB_FAST_APPROXIMATION\n vec3 bLess = step(vec3(0.04045),srgbIn.xyz);\n vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );\n#endif //SRGB_FAST_APPROXIMATION\n return vec4(linOut,srgbIn.w);;\n#else //MANUAL_SRGB\n return srgbIn;\n#endif //MANUAL_SRGB\n}\n\n// Find the normal for this fragment, pulling either from a predefined normal map\n// or from the interpolated mesh normal and tangent attributes.\nvec3 getNormal()\n{\n // Retrieve the tangent space matrix\n#ifndef HAS_TANGENTS\n vec3 pos_dx = dFdx(pbr_vPosition);\n vec3 pos_dy = dFdy(pbr_vPosition);\n vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));\n vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0));\n vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);\n\n#ifdef HAS_NORMALS\n vec3 ng = normalize(pbr_vNormal);\n#else\n vec3 ng = cross(pos_dx, pos_dy);\n#endif\n\n t = normalize(t - ng * dot(ng, t));\n vec3 b = normalize(cross(ng, t));\n mat3 tbn = mat3(t, b, ng);\n#else // HAS_TANGENTS\n mat3 tbn = pbr_vTBN;\n#endif\n\n#ifdef HAS_NORMALMAP\n vec3 n = texture2D(u_NormalSampler, pbr_vUV).rgb;\n n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));\n#else\n // The tbn matrix is linearly interpolated, so we need to re-normalize\n vec3 n = normalize(tbn[2].xyz);\n#endif\n\n return n;\n}\n\n// Calculation of the lighting contribution from an optional Image Based Light source.\n// Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].\n// See our README.md on Environment Maps [3] for additional discussion.\n#ifdef USE_IBL\nvec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)\n{\n float mipCount = 9.0; // resolution of 512x512\n float lod = (pbrInputs.perceptualRoughness * mipCount);\n // retrieve a scale and bias to F0. See [1], Figure 3\n vec3 brdf = SRGBtoLINEAR(texture2D(u_brdfLUT,\n vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;\n vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;\n\n#ifdef USE_TEX_LOD\n vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;\n#else\n vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;\n#endif\n\n vec3 diffuse = diffuseLight * pbrInputs.diffuseColor;\n vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);\n\n // For presentation, this allows us to disable IBL terms\n diffuse *= u_ScaleIBLAmbient.x;\n specular *= u_ScaleIBLAmbient.y;\n\n return diffuse + specular;\n}\n#endif\n\n// Basic Lambertian diffuse\n// Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog\n// See also [1], Equation 1\nvec3 diffuse(PBRInfo pbrInputs)\n{\n return pbrInputs.diffuseColor / M_PI;\n}\n\n// The following equation models the Fresnel reflectance term of the spec equation (aka F())\n// Implementation of fresnel from [4], Equation 15\nvec3 specularReflection(PBRInfo pbrInputs)\n{\n return pbrInputs.reflectance0 +\n (pbrInputs.reflectance90 - pbrInputs.reflectance0) *\n pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0);\n}\n\n// This calculates the specular geometric attenuation (aka G()),\n// where rougher material will reflect less light back to the viewer.\n// This implementation is based on [1] Equation 4, and we adopt their modifications to\n// alphaRoughness as input as originally proposed in [2].\nfloat geometricOcclusion(PBRInfo pbrInputs)\n{\n float NdotL = pbrInputs.NdotL;\n float NdotV = pbrInputs.NdotV;\n float r = pbrInputs.alphaRoughness;\n\n float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\n float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\n return attenuationL * attenuationV;\n}\n\n// The following equation(s) model the distribution of microfacet normals across\n// the area being drawn (aka D())\n// Implementation from \"Average Irregularity Representation of a Roughened Surface\n// for Ray Reflection\" by T. S. Trowbridge, and K. P. Reitz\n// Follows the distribution function recommended in the SIGGRAPH 2013 course notes\n// from EPIC Games [1], Equation 3.\nfloat microfacetDistribution(PBRInfo pbrInputs)\n{\n float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;\n float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;\n return roughnessSq / (M_PI * f * f);\n}\n\nvoid PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) {\n pbrInputs.NdotL = 1.0;\n pbrInputs.NdotH = 0.0;\n pbrInputs.LdotH = 0.0;\n pbrInputs.VdotH = 1.0;\n}\n\nvoid PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) {\n vec3 n = pbrInputs.n;\n vec3 v = pbrInputs.v;\n vec3 l = normalize(lightDirection); // Vector from surface point to light\n vec3 h = normalize(l+v); // Half vector between both l and v\n\n pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0);\n pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0);\n pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0);\n pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);\n}\n\nvoid PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) {\n vec3 light_direction = normalize(pointLight.position - pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInputs, light_direction);\n}\n\nvec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) {\n // Calculate the shading terms for the microfacet specular shading model\n vec3 F = specularReflection(pbrInputs);\n float G = geometricOcclusion(pbrInputs);\n float D = microfacetDistribution(pbrInputs);\n\n // Calculation of analytical lighting contribution\n vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);\n vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);\n // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)\n return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);\n}\n\nvec4 pbr_filterColor(vec4 colorUnused)\n{\n // The albedo may be defined from a base texture or a flat color\n#ifdef HAS_BASECOLORMAP\n vec4 baseColor = SRGBtoLINEAR(texture2D(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;\n#else\n vec4 baseColor = u_BaseColorFactor;\n#endif\n\n#ifdef ALPHA_CUTOFF\n if (baseColor.a < u_AlphaCutoff) {\n discard;\n }\n#endif\n\n vec3 color = vec3(0, 0, 0);\n\n if(pbr_uUnlit){\n color.rgb = baseColor.rgb;\n }\n else{\n // Metallic and Roughness material properties are packed together\n // In glTF, these factors can be specified by fixed scalar values\n // or from a metallic-roughness map\n float perceptualRoughness = u_MetallicRoughnessValues.y;\n float metallic = u_MetallicRoughnessValues.x;\n#ifdef HAS_METALROUGHNESSMAP\n // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.\n // This layout intentionally reserves the 'r' channel for (optional) occlusion map data\n vec4 mrSample = texture2D(u_MetallicRoughnessSampler, pbr_vUV);\n perceptualRoughness = mrSample.g * perceptualRoughness;\n metallic = mrSample.b * metallic;\n#endif\n perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\n metallic = clamp(metallic, 0.0, 1.0);\n // Roughness is authored as perceptual roughness; as is convention,\n // convert to material roughness by squaring the perceptual roughness [2].\n float alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n vec3 f0 = vec3(0.04);\n vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);\n diffuseColor *= 1.0 - metallic;\n vec3 specularColor = mix(f0, baseColor.rgb, metallic);\n\n // Compute reflectance.\n float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n\n // For typical incident reflectance range (between 4% to 100%) set the grazing\n // reflectance to 100% for typical fresnel effect.\n // For very low reflectance range on highly diffuse objects (below 4%),\n // incrementally reduce grazing reflecance to 0%.\n float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n vec3 specularEnvironmentR0 = specularColor.rgb;\n vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\n\n vec3 n = getNormal(); // normal at surface point\n vec3 v = normalize(u_Camera - pbr_vPosition); // Vector from surface point to camera\n\n float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\n vec3 reflection = -normalize(reflect(v, n));\n\n PBRInfo pbrInputs = PBRInfo(\n 0.0, // NdotL\n NdotV,\n 0.0, // NdotH\n 0.0, // LdotH\n 0.0, // VdotH\n perceptualRoughness,\n metallic,\n specularEnvironmentR0,\n specularEnvironmentR90,\n alphaRoughness,\n diffuseColor,\n specularColor,\n n,\n v\n );\n\n#ifdef USE_LIGHTS\n // Apply ambient light\n PBRInfo_setAmbientLight(pbrInputs);\n color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);\n\n // Apply directional light\n SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uDirectionalLightCount, i++) {\n if (i < lighting_uDirectionalLightCount) {\n PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);\n color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);\n }\n }\n\n // Apply point light\n SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uPointLightCount, i++) {\n if (i < lighting_uPointLightCount) {\n PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);\n float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));\n color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);\n }\n }\n#endif\n\n // Calculate lighting contribution from image based lighting source (IBL)\n#ifdef USE_IBL\n color += getIBLContribution(pbrInputs, n, reflection);\n#endif\n\n // Apply optional PBR terms for additional (optional) shading\n#ifdef HAS_OCCLUSIONMAP\n float ao = texture2D(u_OcclusionSampler, pbr_vUV).r;\n color = mix(color, color * ao, u_OcclusionStrength);\n#endif\n\n#ifdef HAS_EMISSIVEMAP\n vec3 emissive = SRGBtoLINEAR(texture2D(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;\n color += emissive;\n#endif\n\n // This section uses mix to override final color for reference app visualization\n // of various parameters in the lighting equation.\n#ifdef PBR_DEBUG\n // TODO: Figure out how to debug multiple lights\n\n // color = mix(color, F, u_ScaleFGDSpec.x);\n // color = mix(color, vec3(G), u_ScaleFGDSpec.y);\n // color = mix(color, vec3(D), u_ScaleFGDSpec.z);\n // color = mix(color, specContrib, u_ScaleFGDSpec.w);\n\n // color = mix(color, diffuseContrib, u_ScaleDiffBaseMR.x);\n color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);\n color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);\n color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);\n#endif\n\n }\n\n return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);\n}\n`;\n"],"file":"pbr-fragment.glsl.js"}
|
|
1
|
+
{"version":3,"file":"pbr-fragment.glsl.js","names":[],"sources":["../../../../src/modules/pbr/pbr-fragment.glsl.js"],"sourcesContent":["// This fragment shader defines a reference implementation for Physically Based Shading of\n// a microfacet surface material defined by a glTF model.\n//\n// Attribution:\n// MIT license, Copyright (c) 2016-2017 Mohamad Moneimne and Contributors\n\n// TODO - better do the checks outside of shader\nexport default `\\\n#if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)\n# error PBR fragment shader: Texture LOD is not available\n#endif\n\n#if !defined(HAS_TANGENTS) && !defined(FEATURE_GLSL_DERIVATIVES)\n# error PBR fragment shader: Derivatives are not available\n#endif\n\n// WebGL 1.0 does not support non-constant in for loops\n// This provides an easy way to handle these cases\n// and still take advantage of WebGL 2.0\n#if (__VERSION__ < 300)\n #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL1COND; INCR)\n#else\n #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)\n#endif\n\nprecision highp float;\n\nuniform bool pbr_uUnlit;\n\n#ifdef USE_IBL\nuniform samplerCube u_DiffuseEnvSampler;\nuniform samplerCube u_SpecularEnvSampler;\nuniform sampler2D u_brdfLUT;\nuniform vec2 u_ScaleIBLAmbient;\n#endif\n\n#ifdef HAS_BASECOLORMAP\nuniform sampler2D u_BaseColorSampler;\n#endif\n#ifdef HAS_NORMALMAP\nuniform sampler2D u_NormalSampler;\nuniform float u_NormalScale;\n#endif\n#ifdef HAS_EMISSIVEMAP\nuniform sampler2D u_EmissiveSampler;\nuniform vec3 u_EmissiveFactor;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\nuniform sampler2D u_MetallicRoughnessSampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\nuniform sampler2D u_OcclusionSampler;\nuniform float u_OcclusionStrength;\n#endif\n\n#ifdef ALPHA_CUTOFF\nuniform float u_AlphaCutoff;\n#endif\n\nuniform vec2 u_MetallicRoughnessValues;\nuniform vec4 u_BaseColorFactor;\n\nuniform vec3 u_Camera;\n\n// debugging flags used for shader output of intermediate PBR variables\n#ifdef PBR_DEBUG\nuniform vec4 u_ScaleDiffBaseMR;\nuniform vec4 u_ScaleFGDSpec;\n#endif\n\nvarying vec3 pbr_vPosition;\n\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n#else\nvarying vec3 pbr_vNormal;\n#endif\n#endif\n\n// Encapsulate the various inputs used by the various functions in the shading equation\n// We store values in this struct to simplify the integration of alternative implementations\n// of the shading terms, outlined in the Readme.MD Appendix.\nstruct PBRInfo\n{\n float NdotL; // cos angle between normal and light direction\n float NdotV; // cos angle between normal and view direction\n float NdotH; // cos angle between normal and half vector\n float LdotH; // cos angle between light direction and half vector\n float VdotH; // cos angle between view direction and half vector\n float perceptualRoughness; // roughness value, as authored by the model creator (input to shader)\n float metalness; // metallic value at the surface\n vec3 reflectance0; // full reflectance color (normal incidence angle)\n vec3 reflectance90; // reflectance color at grazing angle\n float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2])\n vec3 diffuseColor; // color contribution from diffuse lighting\n vec3 specularColor; // color contribution from specular lighting\n vec3 n; // normal at surface point\n vec3 v; // vector from surface point to camera\n};\n\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\n\nvec4 SRGBtoLINEAR(vec4 srgbIn)\n{\n#ifdef MANUAL_SRGB\n#ifdef SRGB_FAST_APPROXIMATION\n vec3 linOut = pow(srgbIn.xyz,vec3(2.2));\n#else //SRGB_FAST_APPROXIMATION\n vec3 bLess = step(vec3(0.04045),srgbIn.xyz);\n vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );\n#endif //SRGB_FAST_APPROXIMATION\n return vec4(linOut,srgbIn.w);;\n#else //MANUAL_SRGB\n return srgbIn;\n#endif //MANUAL_SRGB\n}\n\n// Find the normal for this fragment, pulling either from a predefined normal map\n// or from the interpolated mesh normal and tangent attributes.\nvec3 getNormal()\n{\n // Retrieve the tangent space matrix\n#ifndef HAS_TANGENTS\n vec3 pos_dx = dFdx(pbr_vPosition);\n vec3 pos_dy = dFdy(pbr_vPosition);\n vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));\n vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0));\n vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);\n\n#ifdef HAS_NORMALS\n vec3 ng = normalize(pbr_vNormal);\n#else\n vec3 ng = cross(pos_dx, pos_dy);\n#endif\n\n t = normalize(t - ng * dot(ng, t));\n vec3 b = normalize(cross(ng, t));\n mat3 tbn = mat3(t, b, ng);\n#else // HAS_TANGENTS\n mat3 tbn = pbr_vTBN;\n#endif\n\n#ifdef HAS_NORMALMAP\n vec3 n = texture2D(u_NormalSampler, pbr_vUV).rgb;\n n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));\n#else\n // The tbn matrix is linearly interpolated, so we need to re-normalize\n vec3 n = normalize(tbn[2].xyz);\n#endif\n\n return n;\n}\n\n// Calculation of the lighting contribution from an optional Image Based Light source.\n// Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].\n// See our README.md on Environment Maps [3] for additional discussion.\n#ifdef USE_IBL\nvec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)\n{\n float mipCount = 9.0; // resolution of 512x512\n float lod = (pbrInputs.perceptualRoughness * mipCount);\n // retrieve a scale and bias to F0. See [1], Figure 3\n vec3 brdf = SRGBtoLINEAR(texture2D(u_brdfLUT,\n vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;\n vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;\n\n#ifdef USE_TEX_LOD\n vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;\n#else\n vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;\n#endif\n\n vec3 diffuse = diffuseLight * pbrInputs.diffuseColor;\n vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);\n\n // For presentation, this allows us to disable IBL terms\n diffuse *= u_ScaleIBLAmbient.x;\n specular *= u_ScaleIBLAmbient.y;\n\n return diffuse + specular;\n}\n#endif\n\n// Basic Lambertian diffuse\n// Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog\n// See also [1], Equation 1\nvec3 diffuse(PBRInfo pbrInputs)\n{\n return pbrInputs.diffuseColor / M_PI;\n}\n\n// The following equation models the Fresnel reflectance term of the spec equation (aka F())\n// Implementation of fresnel from [4], Equation 15\nvec3 specularReflection(PBRInfo pbrInputs)\n{\n return pbrInputs.reflectance0 +\n (pbrInputs.reflectance90 - pbrInputs.reflectance0) *\n pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0);\n}\n\n// This calculates the specular geometric attenuation (aka G()),\n// where rougher material will reflect less light back to the viewer.\n// This implementation is based on [1] Equation 4, and we adopt their modifications to\n// alphaRoughness as input as originally proposed in [2].\nfloat geometricOcclusion(PBRInfo pbrInputs)\n{\n float NdotL = pbrInputs.NdotL;\n float NdotV = pbrInputs.NdotV;\n float r = pbrInputs.alphaRoughness;\n\n float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\n float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\n return attenuationL * attenuationV;\n}\n\n// The following equation(s) model the distribution of microfacet normals across\n// the area being drawn (aka D())\n// Implementation from \"Average Irregularity Representation of a Roughened Surface\n// for Ray Reflection\" by T. S. Trowbridge, and K. P. Reitz\n// Follows the distribution function recommended in the SIGGRAPH 2013 course notes\n// from EPIC Games [1], Equation 3.\nfloat microfacetDistribution(PBRInfo pbrInputs)\n{\n float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;\n float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;\n return roughnessSq / (M_PI * f * f);\n}\n\nvoid PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) {\n pbrInputs.NdotL = 1.0;\n pbrInputs.NdotH = 0.0;\n pbrInputs.LdotH = 0.0;\n pbrInputs.VdotH = 1.0;\n}\n\nvoid PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) {\n vec3 n = pbrInputs.n;\n vec3 v = pbrInputs.v;\n vec3 l = normalize(lightDirection); // Vector from surface point to light\n vec3 h = normalize(l+v); // Half vector between both l and v\n\n pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0);\n pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0);\n pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0);\n pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);\n}\n\nvoid PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) {\n vec3 light_direction = normalize(pointLight.position - pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInputs, light_direction);\n}\n\nvec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) {\n // Calculate the shading terms for the microfacet specular shading model\n vec3 F = specularReflection(pbrInputs);\n float G = geometricOcclusion(pbrInputs);\n float D = microfacetDistribution(pbrInputs);\n\n // Calculation of analytical lighting contribution\n vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);\n vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);\n // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)\n return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);\n}\n\nvec4 pbr_filterColor(vec4 colorUnused)\n{\n // The albedo may be defined from a base texture or a flat color\n#ifdef HAS_BASECOLORMAP\n vec4 baseColor = SRGBtoLINEAR(texture2D(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;\n#else\n vec4 baseColor = u_BaseColorFactor;\n#endif\n\n#ifdef ALPHA_CUTOFF\n if (baseColor.a < u_AlphaCutoff) {\n discard;\n }\n#endif\n\n vec3 color = vec3(0, 0, 0);\n\n if(pbr_uUnlit){\n color.rgb = baseColor.rgb;\n }\n else{\n // Metallic and Roughness material properties are packed together\n // In glTF, these factors can be specified by fixed scalar values\n // or from a metallic-roughness map\n float perceptualRoughness = u_MetallicRoughnessValues.y;\n float metallic = u_MetallicRoughnessValues.x;\n#ifdef HAS_METALROUGHNESSMAP\n // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.\n // This layout intentionally reserves the 'r' channel for (optional) occlusion map data\n vec4 mrSample = texture2D(u_MetallicRoughnessSampler, pbr_vUV);\n perceptualRoughness = mrSample.g * perceptualRoughness;\n metallic = mrSample.b * metallic;\n#endif\n perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\n metallic = clamp(metallic, 0.0, 1.0);\n // Roughness is authored as perceptual roughness; as is convention,\n // convert to material roughness by squaring the perceptual roughness [2].\n float alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n vec3 f0 = vec3(0.04);\n vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);\n diffuseColor *= 1.0 - metallic;\n vec3 specularColor = mix(f0, baseColor.rgb, metallic);\n\n // Compute reflectance.\n float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n\n // For typical incident reflectance range (between 4% to 100%) set the grazing\n // reflectance to 100% for typical fresnel effect.\n // For very low reflectance range on highly diffuse objects (below 4%),\n // incrementally reduce grazing reflecance to 0%.\n float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n vec3 specularEnvironmentR0 = specularColor.rgb;\n vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\n\n vec3 n = getNormal(); // normal at surface point\n vec3 v = normalize(u_Camera - pbr_vPosition); // Vector from surface point to camera\n\n float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\n vec3 reflection = -normalize(reflect(v, n));\n\n PBRInfo pbrInputs = PBRInfo(\n 0.0, // NdotL\n NdotV,\n 0.0, // NdotH\n 0.0, // LdotH\n 0.0, // VdotH\n perceptualRoughness,\n metallic,\n specularEnvironmentR0,\n specularEnvironmentR90,\n alphaRoughness,\n diffuseColor,\n specularColor,\n n,\n v\n );\n\n#ifdef USE_LIGHTS\n // Apply ambient light\n PBRInfo_setAmbientLight(pbrInputs);\n color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);\n\n // Apply directional light\n SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uDirectionalLightCount, i++) {\n if (i < lighting_uDirectionalLightCount) {\n PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);\n color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);\n }\n }\n\n // Apply point light\n SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uPointLightCount, i++) {\n if (i < lighting_uPointLightCount) {\n PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);\n float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));\n color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);\n }\n }\n#endif\n\n // Calculate lighting contribution from image based lighting source (IBL)\n#ifdef USE_IBL\n color += getIBLContribution(pbrInputs, n, reflection);\n#endif\n\n // Apply optional PBR terms for additional (optional) shading\n#ifdef HAS_OCCLUSIONMAP\n float ao = texture2D(u_OcclusionSampler, pbr_vUV).r;\n color = mix(color, color * ao, u_OcclusionStrength);\n#endif\n\n#ifdef HAS_EMISSIVEMAP\n vec3 emissive = SRGBtoLINEAR(texture2D(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;\n color += emissive;\n#endif\n\n // This section uses mix to override final color for reference app visualization\n // of various parameters in the lighting equation.\n#ifdef PBR_DEBUG\n // TODO: Figure out how to debug multiple lights\n\n // color = mix(color, F, u_ScaleFGDSpec.x);\n // color = mix(color, vec3(G), u_ScaleFGDSpec.y);\n // color = mix(color, vec3(D), u_ScaleFGDSpec.z);\n // color = mix(color, specContrib, u_ScaleFGDSpec.w);\n\n // color = mix(color, diffuseContrib, u_ScaleDiffBaseMR.x);\n color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);\n color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);\n color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);\n#endif\n\n }\n\n return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);\n}\n`;\n"],"mappings":"AAOA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"pbr-vertex.glsl.js","names":[],"sources":["../../../../src/modules/pbr/pbr-vertex.glsl.js"],"sourcesContent":["export default `\\\nuniform mat4 u_MVPMatrix;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_NormalMatrix;\n\nvarying vec3 pbr_vPosition;\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n# else\nvarying vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\n vec4 pos = u_ModelMatrix * position;\n pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\n vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\n vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else // HAS_TANGENTS != 1\n pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n pbr_vUV = uv;\n#else\n pbr_vUV = vec2(0.,0.);\n#endif\n}\n`;\n"],"mappings":"AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"pbr.js","names":["lights","vs","fs","pbr","name","defines","LIGHTING_FRAGMENT","dependencies"],"sources":["../../../../src/modules/pbr/pbr.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderModule} ShaderModule */\n\nimport {lights} from '../lights/lights';\n\nimport vs from './pbr-vertex.glsl';\nimport fs from './pbr-fragment.glsl';\n\n/**\n * @type {ShaderModule}\n * PBR lighting shader module\n */\nexport const pbr = {\n name: 'pbr',\n vs,\n fs,\n defines: {\n LIGHTING_FRAGMENT: 1\n },\n dependencies: [lights]\n};\n"],"mappings":"AAEA,SAAQA,MAAR,QAAqB,kBAArB;AAEA,OAAOC,EAAP,MAAe,mBAAf;AACA,OAAOC,EAAP,MAAe,qBAAf;AAMA,OAAO,MAAMC,GAAG,GAAG;EACjBC,IAAI,EAAE,KADW;EAEjBH,EAFiB;EAGjBC,EAHiB;EAIjBG,OAAO,EAAE;IACPC,iBAAiB,EAAE;EADZ,CAJQ;EAOjBC,YAAY,EAAE,CAACP,MAAD;AAPG,CAAZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"phong-lighting.glsl.js","names":[],"sources":["../../../../src/modules/phong-lighting/phong-lighting.glsl.js"],"sourcesContent":["export default `\\\n\nuniform float lighting_uAmbient;\nuniform float lighting_uDiffuse;\nuniform float lighting_uShininess;\nuniform vec3 lighting_uSpecularColor;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, lighting_uShininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * lighting_uDiffuse * surfaceColor + specular * lighting_uSpecularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (lighting_uEnabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = lighting_uAmbient * surfaceColor * lighting_uAmbientLight.color;\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uPointLightCount) {\n break;\n }\n PointLight pointLight = lighting_uPointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uDirectionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting_uDirectionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n\nvec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = vec3(0, 0, 0);\n vec3 surfaceColor = vec3(0, 0, 0);\n\n if (lighting_uEnabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uPointLightCount) {\n break;\n }\n PointLight pointLight = lighting_uPointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uDirectionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting_uDirectionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n`;\n"],"mappings":"AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"phong-lighting.js","names":["lights","lightingShader","INITIAL_MODULE_OPTIONS","getMaterialUniforms","material","ambient","diffuse","shininess","specularColor","lighting_uAmbient","lighting_uDiffuse","lighting_uShininess","lighting_uSpecularColor","map","x","getUniforms","opts","lighting_uEnabled","gouraudLighting","name","dependencies","vs","defines","LIGHTING_VERTEX","phongLighting","fs","LIGHTING_FRAGMENT"],"sources":["../../../../src/modules/phong-lighting/phong-lighting.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderModule} ShaderModule */\n\nimport {lights} from '../lights/lights';\nimport lightingShader from './phong-lighting.glsl';\n\nconst INITIAL_MODULE_OPTIONS = {};\n\nfunction getMaterialUniforms(material) {\n const {ambient = 0.35, diffuse = 0.6, shininess = 32, specularColor = [30, 30, 30]} = material;\n\n return {\n lighting_uAmbient: ambient,\n lighting_uDiffuse: diffuse,\n lighting_uShininess: shininess,\n lighting_uSpecularColor: specularColor.map(x => x / 255)\n };\n}\n\nfunction getUniforms(opts = INITIAL_MODULE_OPTIONS) {\n if (!('material' in opts)) {\n return {};\n }\n\n const {material} = opts;\n\n if (!material) {\n return {lighting_uEnabled: false};\n }\n\n return getMaterialUniforms(material);\n}\n\n/** @type {ShaderModule} */\nexport const gouraudLighting = {\n name: 'gouraud-lighting',\n dependencies: [lights],\n vs: lightingShader,\n defines: {\n LIGHTING_VERTEX: 1\n },\n getUniforms\n};\n\n/** @type {ShaderModule} */\nexport const phongLighting = {\n name: 'phong-lighting',\n dependencies: [lights],\n fs: lightingShader,\n defines: {\n LIGHTING_FRAGMENT: 1\n },\n getUniforms\n};\n"],"mappings":"AAEA,SAAQA,MAAR,QAAqB,kBAArB;AACA,OAAOC,cAAP,MAA2B,uBAA3B;AAEA,MAAMC,sBAAsB,GAAG,EAA/B;;AAEA,SAASC,mBAAT,CAA6BC,QAA7B,EAAuC;EACrC,MAAM;IAACC,OAAO,GAAG,IAAX;IAAiBC,OAAO,GAAG,GAA3B;IAAgCC,SAAS,GAAG,EAA5C;IAAgDC,aAAa,GAAG,CAAC,EAAD,EAAK,EAAL,EAAS,EAAT;EAAhE,IAAgFJ,QAAtF;EAEA,OAAO;IACLK,iBAAiB,EAAEJ,OADd;IAELK,iBAAiB,EAAEJ,OAFd;IAGLK,mBAAmB,EAAEJ,SAHhB;IAILK,uBAAuB,EAAEJ,aAAa,CAACK,GAAd,CAAkBC,CAAC,IAAIA,CAAC,GAAG,GAA3B;EAJpB,CAAP;AAMD;;AAED,SAASC,WAAT,GAAoD;EAAA,IAA/BC,IAA+B,uEAAxBd,sBAAwB;;EAClD,IAAI,EAAE,cAAcc,IAAhB,CAAJ,EAA2B;IACzB,OAAO,EAAP;EACD;;EAED,MAAM;IAACZ;EAAD,IAAaY,IAAnB;;EAEA,IAAI,CAACZ,QAAL,EAAe;IACb,OAAO;MAACa,iBAAiB,EAAE;IAApB,CAAP;EACD;;EAED,OAAOd,mBAAmB,CAACC,QAAD,CAA1B;AACD;;AAGD,OAAO,MAAMc,eAAe,GAAG;EAC7BC,IAAI,EAAE,kBADuB;EAE7BC,YAAY,EAAE,CAACpB,MAAD,CAFe;EAG7BqB,EAAE,EAAEpB,cAHyB;EAI7BqB,OAAO,EAAE;IACPC,eAAe,EAAE;EADV,CAJoB;EAO7BR;AAP6B,CAAxB;AAWP,OAAO,MAAMS,aAAa,GAAG;EAC3BL,IAAI,EAAE,gBADqB;EAE3BC,YAAY,EAAE,CAACpB,MAAD,CAFa;EAG3ByB,EAAE,EAAExB,cAHuB;EAI3BqB,OAAO,EAAE;IACPI,iBAAiB,EAAE;EADZ,CAJkB;EAO3BX;AAP2B,CAAtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"picking.js","names":["DEFAULT_HIGHLIGHT_COLOR","Uint8Array","DEFAULT_MODULE_OPTIONS","pickingSelectedColor","pickingHighlightColor","pickingActive","pickingAttribute","getUniforms","opts","uniforms","undefined","picking_uSelectedColorValid","selectedColor","slice","picking_uSelectedColor","color","Array","from","x","Number","isFinite","picking_uHighlightColor","picking_uActive","Boolean","picking_uAttribute","vs","fs","picking","name"],"sources":["../../../../src/modules/picking/picking.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderModule} ShaderModule */\n\nconst DEFAULT_HIGHLIGHT_COLOR = new Uint8Array([0, 255, 255, 255]);\n\nconst DEFAULT_MODULE_OPTIONS = {\n pickingSelectedColor: null, // Set to a picking color to visually highlight that item\n pickingHighlightColor: DEFAULT_HIGHLIGHT_COLOR, // Color of visual highlight of \"selected\" item\n pickingActive: false, // Set to true when rendering to off-screen \"picking\" buffer\n pickingAttribute: false // Set to true when picking an attribute value instead of object index\n};\n\n/* eslint-disable camelcase */\nfunction getUniforms(opts = DEFAULT_MODULE_OPTIONS) {\n const uniforms = {};\n if (opts.pickingSelectedColor !== undefined) {\n if (!opts.pickingSelectedColor) {\n uniforms.picking_uSelectedColorValid = 0;\n } else {\n const selectedColor = opts.pickingSelectedColor.slice(0, 3);\n uniforms.picking_uSelectedColorValid = 1;\n uniforms.picking_uSelectedColor = selectedColor;\n }\n }\n if (opts.pickingHighlightColor) {\n const color = Array.from(opts.pickingHighlightColor, x => x / 255);\n if (!Number.isFinite(color[3])) {\n color[3] = 1;\n }\n uniforms.picking_uHighlightColor = color;\n }\n if (opts.pickingActive !== undefined) {\n uniforms.picking_uActive = Boolean(opts.pickingActive);\n uniforms.picking_uAttribute = Boolean(opts.pickingAttribute);\n }\n return uniforms;\n}\n\nconst vs = `\\\nuniform bool picking_uActive;\nuniform bool picking_uAttribute;\nuniform vec3 picking_uSelectedColor;\nuniform bool picking_uSelectedColorValid;\n\nout vec4 picking_vRGBcolor_Avalid;\n\nconst float COLOR_SCALE = 1. / 255.;\n\nbool picking_isColorValid(vec3 color) {\n return dot(color, vec3(1.0)) > 0.001;\n}\n\nbool isVertexPicked(vec3 vertexColor) {\n return\n picking_uSelectedColorValid &&\n !picking_isColorValid(abs(vertexColor - picking_uSelectedColor));\n}\n\nvoid picking_setPickingColor(vec3 pickingColor) {\n if (picking_uActive) {\n // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable\n picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\n\n if (!picking_uAttribute) {\n // Stores the picking color so that the fragment shader can render it during picking\n picking_vRGBcolor_Avalid.rgb = pickingColor * COLOR_SCALE;\n }\n } else {\n // Do the comparison with selected item color in vertex shader as it should mean fewer compares\n picking_vRGBcolor_Avalid.a = float(isVertexPicked(pickingColor));\n }\n}\n\nvoid picking_setPickingAttribute(float value) {\n if (picking_uAttribute) {\n picking_vRGBcolor_Avalid.r = value;\n }\n}\nvoid picking_setPickingAttribute(vec2 value) {\n if (picking_uAttribute) {\n picking_vRGBcolor_Avalid.rg = value;\n }\n}\nvoid picking_setPickingAttribute(vec3 value) {\n if (picking_uAttribute) {\n picking_vRGBcolor_Avalid.rgb = value;\n }\n}\n`;\n\nconst fs = `\\\nuniform bool picking_uActive;\nuniform vec3 picking_uSelectedColor;\nuniform vec4 picking_uHighlightColor;\n\nin vec4 picking_vRGBcolor_Avalid;\n\n/*\n * Returns highlight color if this item is selected.\n */\nvec4 picking_filterHighlightColor(vec4 color) {\n if (picking_uActive) {\n return color;\n }\n bool selected = bool(picking_vRGBcolor_Avalid.a);\n\n if (selected) {\n float highLightAlpha = picking_uHighlightColor.a;\n float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\n float highLightRatio = highLightAlpha / blendedAlpha;\n\n vec3 blendedRGB = mix(color.rgb, picking_uHighlightColor.rgb, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n } else {\n return color;\n }\n}\n\n/*\n * Returns picking color if picking enabled else unmodified argument.\n */\nvec4 picking_filterPickingColor(vec4 color) {\n if (picking_uActive) {\n if (picking_vRGBcolor_Avalid.a == 0.0) {\n discard;\n }\n return picking_vRGBcolor_Avalid;\n }\n return color;\n}\n\n/*\n * Returns picking color if picking is enabled if not\n * highlight color if this item is selected, otherwise unmodified argument.\n */\nvec4 picking_filterColor(vec4 color) {\n vec4 highightColor = picking_filterHighlightColor(color);\n return picking_filterPickingColor(highightColor);\n}\n\n`;\n\n/** @type {ShaderModule} */\nexport const picking = {\n name: 'picking',\n vs,\n fs,\n getUniforms\n};\n"],"mappings":"AAEA,MAAMA,uBAAuB,GAAG,IAAIC,UAAJ,CAAe,CAAC,CAAD,EAAI,GAAJ,EAAS,GAAT,EAAc,GAAd,CAAf,CAAhC;AAEA,MAAMC,sBAAsB,GAAG;EAC7BC,oBAAoB,EAAE,IADO;EAE7BC,qBAAqB,EAAEJ,uBAFM;EAG7BK,aAAa,EAAE,KAHc;EAI7BC,gBAAgB,EAAE;AAJW,CAA/B;;AAQA,SAASC,WAAT,GAAoD;EAAA,IAA/BC,IAA+B,uEAAxBN,sBAAwB;EAClD,MAAMO,QAAQ,GAAG,EAAj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projectionMatrix","cameraPositionWorld","getUniforms","opts","prevUniforms","uniforms","undefined","viewProjectionMatrix","multiplyRight","common","vs","fs","project","name"],"sources":["../../../../src/modules/project/project.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderModule} ShaderModule */\n\nimport {Matrix4} from '@math.gl/core';\n\nconst IDENTITY_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n\nconst DEFAULT_MODULE_OPTIONS = {\n modelMatrix: IDENTITY_MATRIX,\n viewMatrix: IDENTITY_MATRIX,\n projectionMatrix: IDENTITY_MATRIX,\n cameraPositionWorld: [0, 0, 0]\n};\n\nfunction getUniforms(opts = DEFAULT_MODULE_OPTIONS, prevUniforms = {}) {\n // const viewProjectionInverse = viewProjection.invert();\n // viewInverseMatrix: view.invert(),\n // viewProjectionInverseMatrix: viewProjectionInverse\n\n const uniforms = {};\n if (opts.modelMatrix !== undefined) {\n uniforms.modelMatrix = opts.modelMatrix;\n }\n if (opts.viewMatrix !== undefined) {\n uniforms.viewMatrix = opts.viewMatrix;\n }\n if (opts.projectionMatrix !== undefined) {\n uniforms.projectionMatrix = opts.projectionMatrix;\n }\n if (opts.cameraPositionWorld !== undefined) {\n uniforms.cameraPositionWorld = opts.cameraPositionWorld;\n }\n\n // COMPOSITE UNIFORMS\n if (opts.projectionMatrix !== undefined || opts.viewMatrix !== undefined) {\n uniforms.viewProjectionMatrix = new Matrix4(opts.projectionMatrix).multiplyRight(\n opts.viewMatrix\n );\n }\n\n return uniforms;\n}\n\nconst common = `\\\nvarying vec4 project_vPositionWorld;\nvarying vec3 project_vNormalWorld;\n\nvec4 project_getPosition_World() {\n return project_vPositionWorld;\n}\n\nvec3 project_getNormal_World() {\n return project_vNormalWorld;\n}\n`;\n\nconst vs = `\\\n${common}\n\n// Unprefixed uniforms\nuniform mat4 modelMatrix;\nuniform mat4 viewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewProjectionMatrix;\nuniform vec3 cameraPositionWorld;\n\nstruct World {\n vec3 position;\n vec3 normal;\n};\n\nWorld world;\n\nvoid project_setPosition(vec4 position) {\n project_vPositionWorld = position;\n}\n\nvoid project_setNormal(vec3 normal) {\n project_vNormalWorld = normal;\n}\n\nvoid project_setPositionAndNormal_World(vec3 position, vec3 normal) {\n world.position = position;\n world.normal = normal;\n}\n\nvoid project_setPositionAndNormal_Model(vec3 position, vec3 normal) {\n world.position = (modelMatrix * vec4(position, 1.)).xyz;\n world.normal = mat3(modelMatrix) * normal;\n}\n\nvec4 project_model_to_clipspace(vec4 position) {\n return viewProjectionMatrix * modelMatrix * position;\n}\n\nvec4 project_model_to_clipspace(vec3 position) {\n return viewProjectionMatrix * modelMatrix * vec4(position, 1.);\n}\n\nvec4 project_world_to_clipspace(vec3 position) {\n return viewProjectionMatrix * vec4(position, 1.);\n}\n\nvec4 project_view_to_clipspace(vec3 position) {\n return projectionMatrix * vec4(position, 1.);\n}\n\nvec4 project_to_clipspace(vec3 position) {\n return viewProjectionMatrix * vec4(position, 1.);\n}\n`;\n\nconst fs = `\n${common}\\\n`;\n\n/** @type {ShaderModule} */\nexport const project = {\n name: 'project',\n getUniforms,\n vs,\n fs\n};\n"],"mappings":"AAEA,SAAQA,OAAR,QAAsB,eAAtB;AAEA,MAAMC,eAAe,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,EAAa,CAAb,EAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,EAA4B,CAA5B,EAA+B,CAA/B,EAAkC,CAAlC,EAAqC,CAArC,EAAwC,CAAxC,EAA2C,CAA3C,EAA8C,CAA9C,CAAxB;AAEA,MAAMC,sBAAsB,GAAG;EAC7BC,WAAW,EAAEF,eADgB;EAE7BG,UAAU,EAAEH,eAFiB;EAG7BI,gBAAgB,EAAEJ,eAHW;EAI7BK,mBAAmB,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP;AAJQ,CAA/B;;AAOA,SAASC,WAAT,GAAuE;EAAA,IAAlDC,IAAkD,uEAA3CN,sBAA2C;EAAA,IAAnBO,YAAmB,uEAAJ,EAAI;EAKrE,MAAMC,QAAQ,GAAG,EAAjB;;EACA,IAAIF,IAAI,CAACL,WAAL,KAAqBQ,SAAzB,EAAoC;IAClCD,QAAQ,CAACP,WAAT,GAAuBK,IAAI,CAACL,WAA5B;EACD;;EACD,IAAIK,IAAI,CAACJ,UAAL,KAAoBO,SAAxB,EAAmC;IACjCD,QAAQ,CAACN,UAAT,GAAsBI,IAAI,CAACJ,UAA3B;EACD;;EACD,IAAII,IAAI,CAACH,gBAAL,KAA0BM,SAA9B,EAAyC;IACvCD,QAAQ,CAACL,gBAAT,GAA4BG,IAAI,CAACH,gBAAjC;EACD;;EACD,IAAIG,IAAI,CAACF,mBAAL,KAA6BK,SAAjC,EAA4C;IAC1CD,QAAQ,CAACJ,mBAAT,GAA+BE,IAAI,CAACF,mBAApC;EACD;;EAGD,IAAIE,IAAI,CAACH,gBAAL,KAA0BM,SAA1B,IAAuCH,IAAI,CAACJ,UAAL,KAAoBO,SAA/D,EAA0E;IACxED,QAAQ,CAACE,oBAAT,GAAgC,IAAIZ,OAAJ,CAAYQ,IAAI,CAACH,gBAAjB,EAAmCQ,aAAnC,CAC9BL,IAAI,CAACJ,UADyB,CAAhC;EAGD;;EAED,OAAOM,QAAP;AACD;;AAED,MAAMI,MAAM,iOAAZ;AAaA,MAAMC,EAAE,aACND,MADM,4uCAAR;AAwDA,MAAME,EAAE,eACNF,MADM,CAAR;AAKA,OAAO,MAAMG,OAAO,GAAG;EACrBC,IAAI,EAAE,SADe;EAErBX,WAFqB;EAGrBQ,EAHqB;EAIrBC;AAJqB,CAAhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"transform.js","names":["vs","transform","name","fs"],"sources":["../../../../src/modules/transform/transform.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderModule} ShaderModule */\n\nconst vs = `\\\nattribute float transform_elementID;\n\n// returns half of pixel size, used to move the pixel position to center of the pixel.\nvec2 transform_getPixelSizeHalf(vec2 size) {\n return vec2(1.) / (2. * size);\n}\n\n// returns current elements pixel indeces [x, y],\n// where x ranges in [0 to texSize-1] and y ranges in [0 to texSize-1]\nvec2 transform_getPixelIndices(vec2 texSize, vec2 pixelSizeHalf) {\n // Add safe offset (half of pixel height) before doing floor\n float yIndex = floor((transform_elementID / texSize[0]) + pixelSizeHalf[1]);\n float xIndex = transform_elementID - (yIndex * texSize[0]);\n return vec2(xIndex, yIndex);\n}\n\n// returns current elementID's texture co-ordianate\nvec2 transform_getTexCoord(vec2 size) {\n vec2 pixelSizeHalf = transform_getPixelSizeHalf(size);\n vec2 indices = transform_getPixelIndices(size, pixelSizeHalf);\n vec2 coord = indices / size + pixelSizeHalf;\n return coord;\n}\n\n// returns current elementID's position\nvec2 transform_getPos(vec2 size) {\n vec2 texCoord = transform_getTexCoord(size);\n // Change from [0 1] range to [-1 1]\n vec2 pos = (texCoord * (2.0, 2.0)) - (1., 1.);\n return pos;\n}\n\n// returns current elementID's pixel value\nvec4 transform_getInput(sampler2D texSampler, vec2 size) {\n vec2 texCoord = transform_getTexCoord(size);\n vec4 textureColor = texture2D(texSampler, texCoord);\n return textureColor;\n}\n`;\n\n/** @type {ShaderModule} */\nexport const transform = {\n name: 'transform',\n vs,\n fs: null\n};\n"],"mappings":"AAEA,MAAMA,EAAE,s7BAAR;AA0CA,OAAO,MAAMC,SAAS,GAAG;EACvBC,IAAI,EAAE,WADiB;EAEvBF,EAFuB;EAGvBG,EAAE,EAAE;AAHmB,CAAlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"random.js","names":["fs","random","name"],"sources":["../../../../src/modules/utils/random.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderModule} ShaderModule */\n\nconst fs = `\\\nfloat random(vec3 scale, float seed) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n`;\n\nexport const random = {\n name: 'random',\n fs\n};\n"],"mappings":"AAEA,MAAMA,EAAE,+HAAR;AAOA,OAAO,MAAMC,MAAM,GAAG;EACpBC,IAAI,EAAE,QADc;EAEpBF;AAFoB,CAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"assert.js","names":["assert","condition","message","Error"],"sources":["../../../src/utils/assert.js"],"sourcesContent":["// Recommendation is to ignore message but current test suite checks agains the\n// message so keep it for now.\nexport default function assert(condition, message) {\n if (!condition) {\n throw new Error(message || 'shadertools: assertion failed.');\n }\n}\n"],"mappings":"AAEA,eAAe,SAASA,MAAT,CAAgBC,SAAhB,EAA2BC,OAA3B,EAAoC;EACjD,IAAI,CAACD,SAAL,EAAgB;IACd,MAAM,IAAIE,KAAJ,CAAUD,OAAO,IAAI,gCAArB,CAAN;EACD;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","assert"],"sources":["../../../src/utils/index.js"],"sourcesContent":["export {default as assert} from './assert';\n"],"mappings":"AAAA,SAAQA,OAAO,IAAIC,MAAnB,QAAgC,UAAhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"is-old-ie.js","names":["isOldIE","opts","navigator","window","userAgent","isMSIE","indexOf","isTrident"],"sources":["../../../src/utils/is-old-ie.js"],"sourcesContent":["// opts allows user agent to be overridden for testing\nexport default function isOldIE(opts = {}) {\n const navigator = typeof window !== 'undefined' ? window.navigator || {} : {};\n // @ts-ignore\n const userAgent = opts.userAgent || navigator.userAgent || '';\n // We only care about older versions of IE (IE 11 and below). Newer versions of IE (Edge)\n // have much better web standards support.\n const isMSIE = userAgent.indexOf('MSIE ') !== -1;\n const isTrident = userAgent.indexOf('Trident/') !== -1;\n return isMSIE || isTrident;\n}\n"],"mappings":"AACA,eAAe,SAASA,OAAT,GAA4B;EAAA,IAAXC,IAAW,uEAAJ,EAAI;EACzC,MAAMC,SAAS,GAAG,OAAOC,MAAP,KAAkB,WAAlB,GAAgCA,MAAM,CAACD,SAAP,IAAoB,EAApD,GAAyD,EAA3E;EAEA,MAAME,SAAS,GAAGH,IAAI,CAACG,SAAL,IAAkBF,SAAS,CAACE,SAA5B,IAAyC,EAA3D;EAGA,MAAMC,MAAM,GAAGD,SAAS,CAACE,OAAV,CAAkB,OAAlB,MAA+B,CAAC,CAA/C;EACA,MAAMC,SAAS,GAAGH,SAAS,CAACE,OAAV,CAAkB,UAAlB,MAAkC,CAAC,CAArD;EACA,OAAOD,MAAM,IAAIE,SAAjB;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"shader-utils.js","names":["assert","FS100","FS_GLES","FS300","getQualifierDetails","line","qualifiers","Array","isArray","words","replace","split","qualifier","type","definition","includes","name","getPassthroughFS","options","version","input","inputType","output","outputValue","convertToVec4","typeToChannelSuffix","typeToChannelCount","variable"],"sources":["../../../src/utils/shader-utils.js"],"sourcesContent":["import {assert} from '../utils';\nconst FS100 = `void main() {gl_FragColor = vec4(0);}`;\nconst FS_GLES = `\\\nout vec4 transform_output;\nvoid main() {\n transform_output = vec4(0);\n}`;\nconst FS300 = `#version 300 es\\n${FS_GLES}`;\n\n// Prase given glsl line and return qualifier details or null\nexport function getQualifierDetails(line, qualifiers) {\n qualifiers = Array.isArray(qualifiers) ? qualifiers : [qualifiers];\n const words = line.replace(/^\\s+/, '').split(/\\s+/);\n // TODO add support for precession qualifiers (highp, mediump and lowp)\n const [qualifier, type, definition] = words;\n if (!qualifiers.includes(qualifier) || !type || !definition) {\n return null;\n }\n const name = definition.split(';')[0];\n return {qualifier, type, name};\n}\n\n// Given the shader version, input and output variable names,\n// builds and return a pass through fragment shader.\nexport function getPassthroughFS(options = {}) {\n const {version = 100, input, inputType, output} = options;\n if (!input) {\n if (version === 300) {\n // Fast-path for WebGL 2.0\n return FS300;\n } else if (version > 300) {\n // Use the supplied version for OpenGL/ES 3.2+\n return `#version ${version}\\n${FS_GLES}`;\n }\n // Fast-path for WebGL 1.0\n return FS100;\n }\n const outputValue = convertToVec4(input, inputType);\n if (version >= 300) {\n // If version is 300, assume WebGL 2.0\n return `\\\n#version ${version} ${version === 300 ? 'es' : ''}\nin ${inputType} ${input};\nout vec4 ${output};\nvoid main() {\n ${output} = ${outputValue};\n}`;\n }\n // WebGL 1.0\n return `\\\nvarying ${inputType} ${input};\nvoid main() {\n gl_FragColor = ${outputValue};\n}`;\n}\n\n// convert glsl type to suffix\nexport function typeToChannelSuffix(type) {\n switch (type) {\n case 'float':\n return 'x';\n case 'vec2':\n return 'xy';\n case 'vec3':\n return 'xyz';\n case 'vec4':\n return 'xyzw';\n default:\n assert(false);\n return null;\n }\n}\n\n// convert glsl type to channel count\nexport function typeToChannelCount(type) {\n switch (type) {\n case 'float':\n return 1;\n case 'vec2':\n return 2;\n case 'vec3':\n return 3;\n case 'vec4':\n return 4;\n default:\n assert(false);\n return null;\n }\n}\n\n// Returns glsl instruction for converting to vec4\nexport function convertToVec4(variable, type) {\n switch (type) {\n case 'float':\n return `vec4(${variable}, 0.0, 0.0, 1.0)`;\n case 'vec2':\n return `vec4(${variable}, 0.0, 1.0)`;\n case 'vec3':\n return `vec4(${variable}, 1.0)`;\n case 'vec4':\n return variable;\n default:\n assert(false);\n return null;\n }\n}\n"],"mappings":"AAAA,SAAQA,MAAR,QAAqB,UAArB;AACA,MAAMC,KAAK,0CAAX;AACA,MAAMC,OAAO,gFAAb;AAKA,MAAMC,KAAK,8BAAuBD,OAAvB,CAAX;AAGA,OAAO,SAASE,mBAAT,CAA6BC,IAA7B,EAAmCC,UAAnC,EAA+C;EACpDA,UAAU,GAAGC,KAAK,CAACC,OAAN,CAAcF,UAAd,IAA4BA,UAA5B,GAAyC,CAACA,UAAD,C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AP;;IACF,KAAK,MAAL;MACE,OAAO,IAAP;;IACF,KAAK,MAAL;MACE,OAAO,KAAP;;IACF,KAAK,MAAL;MACE,OAAO,MAAP;;IACF;MACEb,MAAM,CAAC,KAAD,CAAN;MACA,OAAO,IAAP;EAXJ;AAaD;AAGD,OAAO,SAAS0B,kBAAT,CAA4Bb,IAA5B,EAAkC;EACvC,QAAQA,IAAR;IACE,KAAK,OAAL;MACE,OAAO,CAAP;;IACF,KAAK,MAAL;MACE,OAAO,CAAP;;IACF,KAAK,MAAL;MACE,OAAO,CAAP;;IACF,KAAK,MAAL;MACE,OAAO,CAAP;;IACF;MACEb,MAAM,CAAC,KAAD,CAAN;MACA,OAAO,IAAP;EAXJ;AAaD;AAGD,OAAO,SAASwB,aAAT,CAAuBG,QAAvB,EAAiCd,IAAjC,EAAuC;EAC5C,QAAQA,IAAR;IACE,KAAK,OAAL;MACE,sBAAec,QAAf;;IACF,KAAK,MAAL;MACE,sBAAeA,QAAf;;IACF,KAAK,MAAL;MACE,sBAAeA,QAAf;;IACF,KAAK,MAAL;MACE,OAAOA,QAAP;;IACF;MACE3B,MAAM,CAAC,KAAD,CAAN;MACA,OAAO,IAAP;EAXJ;AAaD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"webgl-info.js","names":["isOldIE","assert","GL_VENDOR","GL_RENDERER","GL_VERSION","GL_SHADING_LANGUAGE_VERSION","WEBGL_FEATURES","GLSL_FRAG_DATA","GLSL_FRAG_DEPTH","GLSL_DERIVATIVES","GLSL_TEXTURE_LOD","FEATURES","Object","keys","forEach","key","isWebGL2","gl","WebGL2RenderingContext","Boolean","_version","getContextInfo","info","getExtension","vendor","getParameter","UNMASKED_VENDOR_WEBGL","renderer","UNMASKED_RENDERER_WEBGL","gpuVendor","identifyGPUVendor","gpuInfo","version","shadingLanguageVersion","match","compiledGlslExtensions","canCompileGLGSExtension","cap","opts","feature","extensionName","behavior","source","shader","createShader","shaderSource","compileShader","canCompile","getShaderParameter","deleteShader","getFeature","value","hasFeatures","features","Array","isArray","every"],"sources":["../../../src/utils/webgl-info.js"],"sourcesContent":["// Feature detection for WebGL\n//\n// Provides a function that enables simple checking of which WebGL features are\n// available in an WebGL1 or WebGL2 environment.\n\n/* eslint-disable no-inline-comments, max-len */\nimport isOldIE from './is-old-ie';\nimport assert from './assert';\n\nconst GL_VENDOR = 0x1f00;\nconst GL_RENDERER = 0x1f01;\nconst GL_VERSION = 0x1f02;\nconst GL_SHADING_LANGUAGE_VERSION = 0x8b8c;\n\n// Defines luma.gl \"feature\" names and semantics\nconst WEBGL_FEATURES = {\n // GLSL extensions\n GLSL_FRAG_DATA: ['WEBGL_draw_buffers', true], // TODO - name makes no sense in GLSL 3.00\n GLSL_FRAG_DEPTH: ['EXT_frag_depth', true],\n GLSL_DERIVATIVES: ['OES_standard_derivatives', true],\n GLSL_TEXTURE_LOD: ['EXT_shader_texture_lod', true]\n};\n\n// Create a key-mirrored FEATURES array\nconst FEATURES = {};\nObject.keys(WEBGL_FEATURES).forEach(key => {\n FEATURES[key] = key;\n});\n\nexport {FEATURES};\n\nfunction isWebGL2(gl) {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n return Boolean(gl && gl._version === 2);\n}\n\nexport function getContextInfo(gl) {\n const info = gl.getExtension('WEBGL_debug_renderer_info');\n const vendor = gl.getParameter((info && info.UNMASKED_VENDOR_WEBGL) || GL_VENDOR);\n const renderer = gl.getParameter((info && info.UNMASKED_RENDERER_WEBGL) || GL_RENDERER);\n const gpuVendor = identifyGPUVendor(vendor, renderer);\n const gpuInfo = {\n gpuVendor,\n vendor,\n renderer,\n version: gl.getParameter(GL_VERSION),\n shadingLanguageVersion: gl.getParameter(GL_SHADING_LANGUAGE_VERSION)\n };\n return gpuInfo;\n}\n\nfunction identifyGPUVendor(vendor, renderer) {\n if (vendor.match(/NVIDIA/i) || renderer.match(/NVIDIA/i)) {\n return 'NVIDIA';\n }\n if (vendor.match(/INTEL/i) || renderer.match(/INTEL/i)) {\n return 'INTEL';\n }\n if (\n vendor.match(/AMD/i) ||\n renderer.match(/AMD/i) ||\n vendor.match(/ATI/i) ||\n renderer.match(/ATI/i)\n ) {\n return 'AMD';\n }\n return 'UNKNOWN GPU';\n}\n\nconst compiledGlslExtensions = {};\n\n// Enables feature detection in IE11 due to a bug where gl.getExtension may return true\n// but fail to compile when the extension is enabled in the shader. Specifically,\n// the OES_standard_derivatives and WEBGL_draw_buffers extensions fails to compile in IE11 even though its included\n// in the list of supported extensions.\n// opts allows user agent to be overridden for testing\n/*\n* Inputs :\n* gl : WebGL context\n* cap : Key of WEBGL_FEATURES object identifying the extension\n* opts :\n* behavior : behavior of extension to be tested, by defualt `enable` is used\n* Returns : true, if shader is compiled successfully, false otherwise\n*/\nexport function canCompileGLGSExtension(gl, cap, opts = {}) {\n const feature = WEBGL_FEATURES[cap];\n assert(feature, cap);\n\n if (!isOldIE(opts)) {\n return true;\n }\n\n if (cap in compiledGlslExtensions) {\n return compiledGlslExtensions[cap];\n }\n\n const extensionName = feature[0];\n const behavior = opts.behavior || 'enable';\n const source = `#extension GL_${extensionName} : ${behavior}\\nvoid main(void) {}`;\n\n const shader = gl.createShader(gl.VERTEX_SHADER);\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n const canCompile = gl.getShaderParameter(shader, gl.COMPILE_STATUS);\n gl.deleteShader(shader);\n compiledGlslExtensions[cap] = canCompile;\n return canCompile;\n}\n\n// TODO - cache the value\nfunction getFeature(gl, cap) {\n const feature = WEBGL_FEATURES[cap];\n assert(feature, cap);\n\n // Get extension name from table\n const extensionName = isWebGL2(gl) ? feature[1] || feature[0] : feature[0];\n\n // Check if the value is dependent on checking an extension\n const value =\n typeof extensionName === 'string' ? Boolean(gl.getExtension(extensionName)) : extensionName;\n\n assert(value === false || value === true);\n\n return value;\n}\n\nexport function hasFeatures(gl, features) {\n features = Array.isArray(features) ? features : [features];\n return features.every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AAU,CAACjC,EAAD,EAAKsB,OAAL,CAApC,CAAP;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/shadertools",
|
|
3
|
-
"version": "8.5.
|
|
3
|
+
"version": "8.5.21",
|
|
4
4
|
"description": "Shader module system for luma.gl",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"@babel/runtime": "^7.0.0",
|
|
40
40
|
"@math.gl/core": "^3.5.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "a25cd26e6ad4df757b02004270c9c1872566c76f"
|
|
43
43
|
}
|
package/src/.DS_Store
CHANGED
|
Binary file
|
|
Binary file
|
package/src/modules/.DS_Store
CHANGED
|
Binary file
|