@onerjs/core 8.26.2 → 8.26.4
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/Shaders/ShadersInclude/openpbrBaseLayerData.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrBaseLayerData.js +127 -0
- package/Shaders/ShadersInclude/openpbrBaseLayerData.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrBlockAmbientOcclusion.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrBlockAmbientOcclusion.js +35 -0
- package/Shaders/ShadersInclude/openpbrBlockAmbientOcclusion.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrBlockNormalFinal.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrBlockNormalFinal.js +25 -0
- package/Shaders/ShadersInclude/openpbrBlockNormalFinal.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrCoatLayerData.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrCoatLayerData.js +59 -0
- package/Shaders/ShadersInclude/openpbrCoatLayerData.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrConductorReflectance.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrConductorReflectance.js +19 -0
- package/Shaders/ShadersInclude/openpbrConductorReflectance.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrDielectricReflectance.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrDielectricReflectance.js +30 -0
- package/Shaders/ShadersInclude/openpbrDielectricReflectance.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrDirectLighting.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrDirectLighting.js +69 -0
- package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrDirectLightingInit.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrDirectLightingInit.js +80 -0
- package/Shaders/ShadersInclude/openpbrDirectLightingInit.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrDirectLightingShadow.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrDirectLightingShadow.js +129 -0
- package/Shaders/ShadersInclude/openpbrDirectLightingShadow.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +106 -0
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrFragmentDeclaration.d.ts +6 -0
- package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js +115 -0
- package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.d.ts +6 -0
- package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.js +72 -0
- package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrGeometryInfo.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrGeometryInfo.js +46 -0
- package/Shaders/ShadersInclude/openpbrGeometryInfo.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrIblFunctions.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrIblFunctions.js +221 -0
- package/Shaders/ShadersInclude/openpbrIblFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragment.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragment.js +64 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragment.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragmentFunctions.d.ts +6 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragmentFunctions.js +45 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragmentFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragmentMainFunctions.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragmentMainFunctions.js +72 -0
- package/Shaders/ShadersInclude/openpbrNormalMapFragmentMainFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrNormalMapVertex.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrNormalMapVertex.js +16 -0
- package/Shaders/ShadersInclude/openpbrNormalMapVertex.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrNormalMapVertexDeclaration.d.ts +5 -0
- package/Shaders/ShadersInclude/openpbrNormalMapVertexDeclaration.js +16 -0
- package/Shaders/ShadersInclude/openpbrNormalMapVertexDeclaration.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrUboDeclaration.d.ts +7 -0
- package/Shaders/ShadersInclude/openpbrUboDeclaration.js +18 -0
- package/Shaders/ShadersInclude/openpbrUboDeclaration.js.map +1 -0
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.d.ts +6 -0
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.js +103 -0
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.js.map +1 -0
- package/Shaders/openpbr.fragment.d.ts +54 -0
- package/Shaders/openpbr.fragment.js +206 -0
- package/Shaders/openpbr.fragment.js.map +1 -0
- package/Shaders/openpbr.vertex.d.ts +39 -0
- package/Shaders/openpbr.vertex.js +238 -0
- package/Shaders/openpbr.vertex.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js +126 -0
- package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockAmbientOcclusion.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockAmbientOcclusion.js +36 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockAmbientOcclusion.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockNormalFinal.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockNormalFinal.js +25 -0
- package/ShadersWGSL/ShadersInclude/openpbrBlockNormalFinal.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrCoatLayerData.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrCoatLayerData.js +59 -0
- package/ShadersWGSL/ShadersInclude/openpbrCoatLayerData.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrConductorReflectance.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrConductorReflectance.js +19 -0
- package/ShadersWGSL/ShadersInclude/openpbrConductorReflectance.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrDielectricReflectance.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrDielectricReflectance.js +33 -0
- package/ShadersWGSL/ShadersInclude/openpbrDielectricReflectance.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +69 -0
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js +80 -0
- package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +112 -0
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.d.ts +6 -0
- package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.js +68 -0
- package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrGeometryInfo.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrGeometryInfo.js +54 -0
- package/ShadersWGSL/ShadersInclude/openpbrGeometryInfo.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js +218 -0
- package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragment.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragment.js +64 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragment.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentFunctions.d.ts +6 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentFunctions.js +45 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentMainFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentMainFunctions.js +51 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentMainFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapVertex.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapVertex.js +16 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapVertex.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapVertexDeclaration.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapVertexDeclaration.js +16 -0
- package/ShadersWGSL/ShadersInclude/openpbrNormalMapVertexDeclaration.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.d.ts +7 -0
- package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js +17 -0
- package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js.map +1 -0
- package/ShadersWGSL/openpbr.fragment.d.ts +52 -0
- package/ShadersWGSL/openpbr.fragment.js +193 -0
- package/ShadersWGSL/openpbr.fragment.js.map +1 -0
- package/ShadersWGSL/openpbr.vertex.d.ts +37 -0
- package/ShadersWGSL/openpbr.vertex.js +227 -0
- package/ShadersWGSL/openpbr.vertex.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
const name = "openpbrDielectricReflectance";
|
|
4
|
+
const shader = `struct ReflectanceParams
|
|
5
|
+
{F0: f32,
|
|
6
|
+
F90: f32,
|
|
7
|
+
coloredF0: vec3f,
|
|
8
|
+
coloredF90: vec3f,};
|
|
9
|
+
#define pbr_inline
|
|
10
|
+
fn dielectricReflectance(
|
|
11
|
+
insideIOR: f32,outsideIOR: f32,specularColor: vec3f,specularWeight: f32
|
|
12
|
+
)->ReflectanceParams
|
|
13
|
+
{var outParams: ReflectanceParams;let dielectricF0=pow((insideIOR-outsideIOR)/(insideIOR+outsideIOR),2.0);
|
|
14
|
+
#if DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_GLTF
|
|
15
|
+
let maxF0=max(specularColor.r,max(specularColor.g,specularColor.b));outParams.F0=dielectricF0*maxF0*specularWeight;
|
|
16
|
+
#else
|
|
17
|
+
outParams.F0=dielectricF0*specularWeight;
|
|
18
|
+
#endif
|
|
19
|
+
let f90Scale=clamp(2.0f*abs(insideIOR-outsideIOR),0.0f,1.0f);outParams.F90=f90Scale*specularWeight;outParams.coloredF0=vec3f(dielectricF0*specularWeight)*specularColor.rgb;
|
|
20
|
+
#if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR)
|
|
21
|
+
let dielectricColorF90: vec3f=specularColor.rgb*vec3f(f90Scale)*specularWeight;
|
|
22
|
+
#else
|
|
23
|
+
let dielectricColorF90: vec3f=vec3f(f90Scale)*specularWeight;
|
|
24
|
+
#endif
|
|
25
|
+
outParams.coloredF90=dielectricColorF90;return outParams;}
|
|
26
|
+
`;
|
|
27
|
+
// Sideeffect
|
|
28
|
+
if (!ShaderStore.IncludesShadersStoreWGSL[name]) {
|
|
29
|
+
ShaderStore.IncludesShadersStoreWGSL[name] = shader;
|
|
30
|
+
}
|
|
31
|
+
/** @internal */
|
|
32
|
+
export const openpbrDielectricReflectanceWGSL = { name, shader };
|
|
33
|
+
//# sourceMappingURL=openpbrDielectricReflectance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrDielectricReflectance.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/openpbrDielectricReflectance.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,8BAA8B,CAAC;AAC5C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;CAsBd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"openpbrDielectricReflectance\";\nconst shader = `struct ReflectanceParams\n{F0: f32,\nF90: f32,\ncoloredF0: vec3f,\ncoloredF90: vec3f,};\n#define pbr_inline\nfn dielectricReflectance(\ninsideIOR: f32,outsideIOR: f32,specularColor: vec3f,specularWeight: f32\n)->ReflectanceParams\n{var outParams: ReflectanceParams;let dielectricF0=pow((insideIOR-outsideIOR)/(insideIOR+outsideIOR),2.0);\n#if DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_GLTF\nlet maxF0=max(specularColor.r,max(specularColor.g,specularColor.b));outParams.F0=dielectricF0*maxF0*specularWeight;\n#else\noutParams.F0=dielectricF0*specularWeight;\n#endif\nlet f90Scale=clamp(2.0f*abs(insideIOR-outsideIOR),0.0f,1.0f);outParams.F90=f90Scale*specularWeight;outParams.coloredF0=vec3f(dielectricF0*specularWeight)*specularColor.rgb;\n#if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR)\nlet dielectricColorF90: vec3f=specularColor.rgb*vec3f(f90Scale)*specularWeight;\n#else\nlet dielectricColorF90: vec3f=vec3f(f90Scale)*specularWeight;\n#endif\noutParams.coloredF90=dielectricColorF90;return outParams;}\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrDielectricReflectanceWGSL = { name, shader };\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
const name = "openpbrDirectLighting";
|
|
4
|
+
const shader = `#ifdef LIGHT{X}
|
|
5
|
+
{var slab_diffuse: vec3f=vec3f(0.f,0.f,0.f);var slab_subsurface: vec3f=vec3f(0.f,0.f,0.f);var slab_translucent: vec3f=vec3f(0.f,0.f,0.f);var slab_glossy: vec3f=vec3f(0.f,0.f,0.f);var specularFresnel: f32=0.0f;var slab_metal: vec3f=vec3f(0.f,0.f,0.f);var slab_coat: vec3f=vec3f(0.f,0.f,0.f);var coatFresnel: f32=0.0f;var slab_fuzz: vec3f=vec3f(0.f,0.f,0.f);
|
|
6
|
+
#ifdef HEMILIGHT{X}
|
|
7
|
+
slab_diffuse=computeHemisphericDiffuseLighting(preInfo{X},lightColor{X}.rgb,light{X}.vLightGround);
|
|
8
|
+
#elif defined(AREALIGHT{X})
|
|
9
|
+
slab_diffuse=computeAreaDiffuseLighting(preInfo{X},lightColor{X}.rgb);
|
|
10
|
+
#else
|
|
11
|
+
slab_diffuse=computeDiffuseLighting(preInfo{X},lightColor{X}.rgb);
|
|
12
|
+
#endif
|
|
13
|
+
#ifdef PROJECTEDLIGHTTEXTURE{X}
|
|
14
|
+
slab_diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},vPositionW);
|
|
15
|
+
#endif
|
|
16
|
+
numLights+=1.0f;
|
|
17
|
+
#if AREALIGHT{X}
|
|
18
|
+
slab_glossy=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);
|
|
19
|
+
#else
|
|
20
|
+
{
|
|
21
|
+
#ifdef ANISOTROPIC_BASE
|
|
22
|
+
slab_glossy=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,
|
|
23
|
+
baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,
|
|
24
|
+
0.0f,lightColor{X}.rgb);
|
|
25
|
+
#else
|
|
26
|
+
slab_glossy=computeSpecularLighting(preInfo{X},normalW,baseDielectricReflectance.coloredF0,baseDielectricReflectance.coloredF90,specular_roughness,lightColor{X}.rgb);
|
|
27
|
+
#endif
|
|
28
|
+
let NdotH: f32=dot(normalW,preInfo{X}.H);specularFresnel=fresnelSchlickGGX(NdotH,baseDielectricReflectance.F0,baseDielectricReflectance.F90);}
|
|
29
|
+
#endif
|
|
30
|
+
#if AREALIGHT{X}
|
|
31
|
+
slab_metal=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);
|
|
32
|
+
#else
|
|
33
|
+
{
|
|
34
|
+
#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
|
|
35
|
+
let coloredFresnel: vec3f=specular_weight*getF82Specular(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90,specular_roughness);
|
|
36
|
+
#else
|
|
37
|
+
let coloredFresnel: vec3f=fresnelSchlickGGX(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90);
|
|
38
|
+
#endif
|
|
39
|
+
#ifdef ANISOTROPIC_BASE
|
|
40
|
+
slab_metal=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,0.0,lightColor{X}.rgb);
|
|
41
|
+
#else
|
|
42
|
+
slab_metal=computeSpecularLighting(preInfo{X},normalW,vec3f(baseConductorReflectance.coloredF0),coloredFresnel,specular_roughness,lightColor{X}.rgb);
|
|
43
|
+
#endif
|
|
44
|
+
}
|
|
45
|
+
#endif
|
|
46
|
+
#if AREALIGHT{X}
|
|
47
|
+
slab_coat=computeAreaSpecularLighting(preInfoCoat{X},light{X}.vLightSpecular.rgb,coatReflectance.F0,coatReflectance.F90);
|
|
48
|
+
#else
|
|
49
|
+
{
|
|
50
|
+
#ifdef ANISOTROPIC_COAT
|
|
51
|
+
slab_coat=computeAnisotropicSpecularLighting(preInfoCoat{X},viewDirectionW,coatNormalW,
|
|
52
|
+
coatGeoInfo.anisotropicTangent,coatGeoInfo.anisotropicBitangent,coatGeoInfo.anisotropy,0.0,
|
|
53
|
+
lightColor{X}.rgb);
|
|
54
|
+
#else
|
|
55
|
+
slab_coat=computeSpecularLighting(preInfoCoat{X},coatNormalW,vec3f(coatReflectance.F0),vec3f(1.0f),coat_roughness,lightColor{X}.rgb);
|
|
56
|
+
#endif
|
|
57
|
+
let NdotH: f32=dot(coatNormalW,preInfoCoat{X}.H);coatFresnel=fresnelSchlickGGX(NdotH,coatReflectance.F0,coatReflectance.F90);}
|
|
58
|
+
#endif
|
|
59
|
+
var coatAbsorption=vec3f(1.0f);if (coat_weight>0.0) {let cosTheta_view: f32=max(preInfoCoat{X}.NdotV,0.001f);let cosTheta_light: f32=max(preInfoCoat{X}.NdotL,0.001f);let fresnel_view: f32=coatReflectance.F0+(1.0f-coatReflectance.F0)*pow(1.0f-cosTheta_view,5.0);let fresnel_light: f32=coatReflectance.F0+(1.0f-coatReflectance.F0)*pow(1.0f-cosTheta_light,5.0);let averageReflectance: f32=(fresnel_view+fresnel_light)*0.5;var darkened_transmission: f32=(1.0f-averageReflectance)/(1.0f+averageReflectance);darkened_transmission=mix(1.0f,darkened_transmission,coat_darkening);var sin2: f32=1.0f-coatGeoInfo.NdotV*coatGeoInfo.NdotV;sin2=sin2/(coat_ior*coat_ior);let cos_t: f32=sqrt(1.0f-sin2);let coatPathLength=1.0f/cos_t;let colored_transmission: vec3f=pow(coat_color,vec3f(coatPathLength));coatAbsorption=mix(vec3f(1.0f),colored_transmission*vec3f(darkened_transmission),coat_weight);}
|
|
60
|
+
slab_diffuse*=base_color.rgb;let material_opaque_base: vec3f=mix(slab_diffuse,slab_subsurface,subsurface_weight);let material_dielectric_base: vec3f=mix(material_opaque_base,slab_translucent,transmission_weight);let material_dielectric_gloss: vec3f=layer(material_dielectric_base,slab_glossy,specularFresnel,vec3f(1.0),specular_color);let material_base_substrate: vec3f=mix(material_dielectric_gloss,slab_metal,base_metalness);let material_coated_base: vec3f=layer(material_base_substrate,slab_coat,coatFresnel,coatAbsorption,vec3f(1.0));material_surface_direct+=mix(material_coated_base,slab_fuzz,fuzz_weight);}
|
|
61
|
+
#endif
|
|
62
|
+
`;
|
|
63
|
+
// Sideeffect
|
|
64
|
+
if (!ShaderStore.IncludesShadersStoreWGSL[name]) {
|
|
65
|
+
ShaderStore.IncludesShadersStoreWGSL[name] = shader;
|
|
66
|
+
}
|
|
67
|
+
/** @internal */
|
|
68
|
+
export const openpbrDirectLightingWGSL = { name, shader };
|
|
69
|
+
//# sourceMappingURL=openpbrDirectLighting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrDirectLighting.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/openpbrDirectLighting.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Dd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"openpbrDirectLighting\";\nconst shader = `#ifdef LIGHT{X}\n{var slab_diffuse: vec3f=vec3f(0.f,0.f,0.f);var slab_subsurface: vec3f=vec3f(0.f,0.f,0.f);var slab_translucent: vec3f=vec3f(0.f,0.f,0.f);var slab_glossy: vec3f=vec3f(0.f,0.f,0.f);var specularFresnel: f32=0.0f;var slab_metal: vec3f=vec3f(0.f,0.f,0.f);var slab_coat: vec3f=vec3f(0.f,0.f,0.f);var coatFresnel: f32=0.0f;var slab_fuzz: vec3f=vec3f(0.f,0.f,0.f);\n#ifdef HEMILIGHT{X}\nslab_diffuse=computeHemisphericDiffuseLighting(preInfo{X},lightColor{X}.rgb,light{X}.vLightGround);\n#elif defined(AREALIGHT{X})\nslab_diffuse=computeAreaDiffuseLighting(preInfo{X},lightColor{X}.rgb);\n#else\nslab_diffuse=computeDiffuseLighting(preInfo{X},lightColor{X}.rgb);\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nslab_diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},vPositionW);\n#endif\nnumLights+=1.0f;\n#if AREALIGHT{X}\nslab_glossy=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);\n#else\n{\n#ifdef ANISOTROPIC_BASE\nslab_glossy=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,\nbaseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,\n0.0f,lightColor{X}.rgb);\n#else\nslab_glossy=computeSpecularLighting(preInfo{X},normalW,baseDielectricReflectance.coloredF0,baseDielectricReflectance.coloredF90,specular_roughness,lightColor{X}.rgb);\n#endif\nlet NdotH: f32=dot(normalW,preInfo{X}.H);specularFresnel=fresnelSchlickGGX(NdotH,baseDielectricReflectance.F0,baseDielectricReflectance.F90);}\n#endif\n#if AREALIGHT{X}\nslab_metal=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);\n#else\n{\n#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)\nlet coloredFresnel: vec3f=specular_weight*getF82Specular(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90,specular_roughness);\n#else\nlet coloredFresnel: vec3f=fresnelSchlickGGX(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90);\n#endif\n#ifdef ANISOTROPIC_BASE\nslab_metal=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,0.0,lightColor{X}.rgb);\n#else\nslab_metal=computeSpecularLighting(preInfo{X},normalW,vec3f(baseConductorReflectance.coloredF0),coloredFresnel,specular_roughness,lightColor{X}.rgb);\n#endif\n}\n#endif\n#if AREALIGHT{X}\nslab_coat=computeAreaSpecularLighting(preInfoCoat{X},light{X}.vLightSpecular.rgb,coatReflectance.F0,coatReflectance.F90);\n#else\n{\n#ifdef ANISOTROPIC_COAT\nslab_coat=computeAnisotropicSpecularLighting(preInfoCoat{X},viewDirectionW,coatNormalW,\ncoatGeoInfo.anisotropicTangent,coatGeoInfo.anisotropicBitangent,coatGeoInfo.anisotropy,0.0,\nlightColor{X}.rgb);\n#else\nslab_coat=computeSpecularLighting(preInfoCoat{X},coatNormalW,vec3f(coatReflectance.F0),vec3f(1.0f),coat_roughness,lightColor{X}.rgb);\n#endif\nlet NdotH: f32=dot(coatNormalW,preInfoCoat{X}.H);coatFresnel=fresnelSchlickGGX(NdotH,coatReflectance.F0,coatReflectance.F90);}\n#endif\nvar coatAbsorption=vec3f(1.0f);if (coat_weight>0.0) {let cosTheta_view: f32=max(preInfoCoat{X}.NdotV,0.001f);let cosTheta_light: f32=max(preInfoCoat{X}.NdotL,0.001f);let fresnel_view: f32=coatReflectance.F0+(1.0f-coatReflectance.F0)*pow(1.0f-cosTheta_view,5.0);let fresnel_light: f32=coatReflectance.F0+(1.0f-coatReflectance.F0)*pow(1.0f-cosTheta_light,5.0);let averageReflectance: f32=(fresnel_view+fresnel_light)*0.5;var darkened_transmission: f32=(1.0f-averageReflectance)/(1.0f+averageReflectance);darkened_transmission=mix(1.0f,darkened_transmission,coat_darkening);var sin2: f32=1.0f-coatGeoInfo.NdotV*coatGeoInfo.NdotV;sin2=sin2/(coat_ior*coat_ior);let cos_t: f32=sqrt(1.0f-sin2);let coatPathLength=1.0f/cos_t;let colored_transmission: vec3f=pow(coat_color,vec3f(coatPathLength));coatAbsorption=mix(vec3f(1.0f),colored_transmission*vec3f(darkened_transmission),coat_weight);}\nslab_diffuse*=base_color.rgb;let material_opaque_base: vec3f=mix(slab_diffuse,slab_subsurface,subsurface_weight);let material_dielectric_base: vec3f=mix(material_opaque_base,slab_translucent,transmission_weight);let material_dielectric_gloss: vec3f=layer(material_dielectric_base,slab_glossy,specularFresnel,vec3f(1.0),specular_color);let material_base_substrate: vec3f=mix(material_dielectric_gloss,slab_metal,base_metalness);let material_coated_base: vec3f=layer(material_base_substrate,slab_coat,coatFresnel,coatAbsorption,vec3f(1.0));material_surface_direct+=mix(material_coated_base,slab_fuzz,fuzz_weight);}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrDirectLightingWGSL = { name, shader };\n"]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
const name = "openpbrDirectLightingInit";
|
|
4
|
+
const shader = `#ifdef LIGHT{X}
|
|
5
|
+
var preInfo{X}: preLightingInfo;var preInfoCoat{X}: preLightingInfo;let lightColor{X}: vec4f=light{X}.vLightDiffuse;var shadow{X}: f32=1.0f;
|
|
6
|
+
#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
|
|
7
|
+
#else
|
|
8
|
+
#define CUSTOM_LIGHT{X}_COLOR
|
|
9
|
+
#ifdef SPOTLIGHT{X}
|
|
10
|
+
preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);
|
|
11
|
+
#elif defined(POINTLIGHT{X})
|
|
12
|
+
preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);
|
|
13
|
+
#elif defined(HEMILIGHT{X})
|
|
14
|
+
preInfo{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);
|
|
15
|
+
#elif defined(DIRLIGHT{X})
|
|
16
|
+
preInfo{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);
|
|
17
|
+
#elif defined(AREALIGHT{X}) && defined(AREALIGHTSUPPORTED)
|
|
18
|
+
preInfo{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,specular_roughness);preInfoCoat{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,coatNormalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,coat_roughness);
|
|
19
|
+
#endif
|
|
20
|
+
preInfo{X}.NdotV=baseGeoInfo.NdotV;preInfoCoat{X}.NdotV=coatGeoInfo.NdotV;
|
|
21
|
+
#ifdef SPOTLIGHT{X}
|
|
22
|
+
#ifdef LIGHT_FALLOFF_GLTF{X}
|
|
23
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);
|
|
24
|
+
#ifdef IESLIGHTTEXTURE{X}
|
|
25
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
|
|
26
|
+
#else
|
|
27
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
|
|
28
|
+
#endif
|
|
29
|
+
#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
|
|
30
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);
|
|
31
|
+
#ifdef IESLIGHTTEXTURE{X}
|
|
32
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
|
|
33
|
+
#else
|
|
34
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w);
|
|
35
|
+
#endif
|
|
36
|
+
#elif defined(LIGHT_FALLOFF_STANDARD{X})
|
|
37
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);
|
|
38
|
+
#ifdef IESLIGHTTEXTURE{X}
|
|
39
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
|
|
40
|
+
#else
|
|
41
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
|
|
42
|
+
#endif
|
|
43
|
+
#else
|
|
44
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
|
|
45
|
+
#ifdef IESLIGHTTEXTURE{X}
|
|
46
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
|
|
47
|
+
#else
|
|
48
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
|
|
49
|
+
#endif
|
|
50
|
+
#endif
|
|
51
|
+
#elif defined(POINTLIGHT{X})
|
|
52
|
+
#ifdef LIGHT_FALLOFF_GLTF{X}
|
|
53
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);
|
|
54
|
+
#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
|
|
55
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);
|
|
56
|
+
#elif defined(LIGHT_FALLOFF_STANDARD{X})
|
|
57
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);
|
|
58
|
+
#else
|
|
59
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
|
|
60
|
+
#endif
|
|
61
|
+
#else
|
|
62
|
+
preInfo{X}.attenuation=1.0f;
|
|
63
|
+
#endif
|
|
64
|
+
preInfoCoat{X}.attenuation=preInfo{X}.attenuation;
|
|
65
|
+
#if defined(HEMILIGHT{X}) || defined(AREALIGHT{X})
|
|
66
|
+
preInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness;
|
|
67
|
+
#else
|
|
68
|
+
preInfo{X}.roughness=adjustRoughnessFromLightProperties(specular_roughness,light{X}.vLightSpecular.a,preInfo{X}.lightDistance);preInfoCoat{X}.roughness=adjustRoughnessFromLightProperties(coat_roughness,light{X}.vLightSpecular.a,preInfoCoat{X}.lightDistance);
|
|
69
|
+
#endif
|
|
70
|
+
preInfo{X}.diffuseRoughness=base_diffuse_roughness;preInfo{X}.surfaceAlbedo=base_color.rgb;
|
|
71
|
+
#endif
|
|
72
|
+
#endif
|
|
73
|
+
`;
|
|
74
|
+
// Sideeffect
|
|
75
|
+
if (!ShaderStore.IncludesShadersStoreWGSL[name]) {
|
|
76
|
+
ShaderStore.IncludesShadersStoreWGSL[name] = shader;
|
|
77
|
+
}
|
|
78
|
+
/** @internal */
|
|
79
|
+
export const openpbrDirectLightingInitWGSL = { name, shader };
|
|
80
|
+
//# sourceMappingURL=openpbrDirectLightingInit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrDirectLightingInit.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,2BAA2B,CAAC;AACzC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqEd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"openpbrDirectLightingInit\";\nconst shader = `#ifdef LIGHT{X}\nvar preInfo{X}: preLightingInfo;var preInfoCoat{X}: preLightingInfo;let lightColor{X}: vec4f=light{X}.vLightDiffuse;var shadow{X}: f32=1.0f;\n#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n#else\n#define CUSTOM_LIGHT{X}_COLOR \n#ifdef SPOTLIGHT{X}\npreInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);\n#elif defined(POINTLIGHT{X})\npreInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);\n#elif defined(HEMILIGHT{X})\npreInfo{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);\n#elif defined(DIRLIGHT{X})\npreInfo{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);\n#elif defined(AREALIGHT{X}) && defined(AREALIGHTSUPPORTED)\npreInfo{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,specular_roughness);preInfoCoat{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,coatNormalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,coat_roughness);\n#endif\npreInfo{X}.NdotV=baseGeoInfo.NdotV;preInfoCoat{X}.NdotV=coatGeoInfo.NdotV;\n#ifdef SPOTLIGHT{X}\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);\n#ifdef IESLIGHTTEXTURE{X}\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});\n#else\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);\n#ifdef IESLIGHTTEXTURE{X}\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});\n#else\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w);\n#endif\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);\n#ifdef IESLIGHTTEXTURE{X}\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});\n#else\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#endif\n#else\npreInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#ifdef IESLIGHTTEXTURE{X}\npreInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});\n#else\npreInfo{X}.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#endif\n#elif defined(POINTLIGHT{X})\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);\n#else\npreInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\n#else\npreInfo{X}.attenuation=1.0f;\n#endif\npreInfoCoat{X}.attenuation=preInfo{X}.attenuation;\n#if defined(HEMILIGHT{X}) || defined(AREALIGHT{X})\npreInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness;\n#else\npreInfo{X}.roughness=adjustRoughnessFromLightProperties(specular_roughness,light{X}.vLightSpecular.a,preInfo{X}.lightDistance);preInfoCoat{X}.roughness=adjustRoughnessFromLightProperties(coat_roughness,light{X}.vLightSpecular.a,preInfoCoat{X}.lightDistance);\n#endif\npreInfo{X}.diffuseRoughness=base_diffuse_roughness;preInfo{X}.surfaceAlbedo=base_color.rgb;\n#endif\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrDirectLightingInitWGSL = { name, shader };\n"]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
const name = "openpbrEnvironmentLighting";
|
|
4
|
+
const shader = `#ifdef REFLECTION
|
|
5
|
+
var baseDiffuseEnvironmentLight: vec3f=sampleIrradiance(
|
|
6
|
+
normalW
|
|
7
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
8
|
+
,vEnvironmentIrradiance
|
|
9
|
+
#endif
|
|
10
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
11
|
+
,uniforms.reflectionMatrix
|
|
12
|
+
#endif
|
|
13
|
+
#ifdef USEIRRADIANCEMAP
|
|
14
|
+
,irradianceSampler
|
|
15
|
+
,irradianceSamplerSampler
|
|
16
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
17
|
+
,uniforms.vReflectionDominantDirection
|
|
18
|
+
#endif
|
|
19
|
+
#endif
|
|
20
|
+
#ifdef REALTIME_FILTERING
|
|
21
|
+
,uniforms.vReflectionFilteringInfo
|
|
22
|
+
#ifdef IBL_CDF_FILTERING
|
|
23
|
+
,icdfSampler
|
|
24
|
+
,icdfSamplerSampler
|
|
25
|
+
#endif
|
|
26
|
+
#endif
|
|
27
|
+
,uniforms.vReflectionInfos
|
|
28
|
+
,viewDirectionW
|
|
29
|
+
,base_diffuse_roughness
|
|
30
|
+
,base_color
|
|
31
|
+
);
|
|
32
|
+
#ifdef REFLECTIONMAP_3D
|
|
33
|
+
var reflectionCoords: vec3f=vec3f(0.f,0.f,0.f);
|
|
34
|
+
#else
|
|
35
|
+
var reflectionCoords: vec2f=vec2f(0.f,0.f);
|
|
36
|
+
#endif
|
|
37
|
+
let specularAlphaG: f32=specular_roughness*specular_roughness;
|
|
38
|
+
#ifdef ANISOTROPIC_BASE
|
|
39
|
+
var baseSpecularEnvironmentLight: vec3f=sampleRadianceAnisotropic(specularAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
|
|
40
|
+
,baseGeoInfo
|
|
41
|
+
,normalW
|
|
42
|
+
,viewDirectionW
|
|
43
|
+
,fragmentInputs.vPositionW
|
|
44
|
+
,noise
|
|
45
|
+
,reflectionSampler
|
|
46
|
+
,reflectionSamplerSampler
|
|
47
|
+
#ifdef REALTIME_FILTERING
|
|
48
|
+
,uniforms.vReflectionFilteringInfo
|
|
49
|
+
#endif
|
|
50
|
+
);
|
|
51
|
+
#else
|
|
52
|
+
reflectionCoords=createReflectionCoords(fragmentInputs.vPositionW,normalW);var baseSpecularEnvironmentLight: vec3f=sampleRadiance(specularAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
|
|
53
|
+
,baseGeoInfo
|
|
54
|
+
,reflectionSampler
|
|
55
|
+
,reflectionSamplerSampler
|
|
56
|
+
,reflectionCoords
|
|
57
|
+
#ifdef REALTIME_FILTERING
|
|
58
|
+
,uniforms.vReflectionFilteringInfo
|
|
59
|
+
#endif
|
|
60
|
+
);
|
|
61
|
+
#endif
|
|
62
|
+
#ifdef ANISOTROPIC_BASE
|
|
63
|
+
baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG*specularAlphaG *max(1.0f-baseGeoInfo.anisotropy,0.3f));
|
|
64
|
+
#else
|
|
65
|
+
baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG);
|
|
66
|
+
#endif
|
|
67
|
+
var coatEnvironmentLight: vec3f=vec3f(0.f,0.f,0.f);if (coat_weight>0.0) {
|
|
68
|
+
#ifdef REFLECTIONMAP_3D
|
|
69
|
+
var reflectionCoords: vec3f=vec3f(0.f,0.f,0.f);
|
|
70
|
+
#else
|
|
71
|
+
var reflectionCoords: vec2f=vec2f(0.f,0.f);
|
|
72
|
+
#endif
|
|
73
|
+
reflectionCoords=createReflectionCoords(fragmentInputs.vPositionW,coatNormalW);var coatAlphaG: f32=coat_roughness*coat_roughness;
|
|
74
|
+
#ifdef ANISOTROPIC_COAT
|
|
75
|
+
coatEnvironmentLight=sampleRadianceAnisotropic(coatAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
|
|
76
|
+
,coatGeoInfo
|
|
77
|
+
,coatNormalW
|
|
78
|
+
,viewDirectionW
|
|
79
|
+
,fragmentInputs.vPositionW
|
|
80
|
+
,noise
|
|
81
|
+
,reflectionSampler
|
|
82
|
+
,reflectionSamplerSampler
|
|
83
|
+
#ifdef REALTIME_FILTERING
|
|
84
|
+
,uniforms.vReflectionFilteringInfo
|
|
85
|
+
#endif
|
|
86
|
+
);
|
|
87
|
+
#else
|
|
88
|
+
coatEnvironmentLight=sampleRadiance(coatAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
|
|
89
|
+
,coatGeoInfo
|
|
90
|
+
,reflectionSampler
|
|
91
|
+
,reflectionSamplerSampler
|
|
92
|
+
,reflectionCoords
|
|
93
|
+
#ifdef REALTIME_FILTERING
|
|
94
|
+
,uniforms.vReflectionFilteringInfo
|
|
95
|
+
#endif
|
|
96
|
+
);
|
|
97
|
+
#endif
|
|
98
|
+
}
|
|
99
|
+
let dielectricIblFresnel: f32=getReflectanceFromBRDFWithEnvLookup(vec3f(baseDielectricReflectance.F0),vec3f(baseDielectricReflectance.F90),baseGeoInfo.environmentBrdf).r;let dielectricIblColoredFresnel: vec3f=getReflectanceFromBRDFWithEnvLookup(baseDielectricReflectance.coloredF0,baseDielectricReflectance.coloredF90,baseGeoInfo.environmentBrdf);let conductorIblFresnel: vec3f=conductorIblFresnel(baseConductorReflectance,baseGeoInfo.NdotV,specular_roughness,baseGeoInfo.environmentBrdf);var coatIblFresnel: f32=0.0;if (coat_weight>0.0) {coatIblFresnel=getReflectanceFromBRDFWithEnvLookup(vec3f(coatReflectance.F0),vec3f(coatReflectance.F90),coatGeoInfo.environmentBrdf).r;}
|
|
100
|
+
var slab_diffuse_ibl: vec3f=vec3f(0.,0.,0.);var slab_glossy_ibl: vec3f=vec3f(0.,0.,0.);var slab_metal_ibl: vec3f=vec3f(0.,0.,0.);var slab_coat_ibl: vec3f=vec3f(0.,0.,0.);slab_diffuse_ibl=baseDiffuseEnvironmentLight*uniforms.vLightingIntensity.z;slab_diffuse_ibl*=aoOut.ambientOcclusionColor;slab_glossy_ibl=baseSpecularEnvironmentLight*uniforms.vLightingIntensity.z;slab_metal_ibl=baseSpecularEnvironmentLight*conductorIblFresnel*uniforms.vLightingIntensity.z;var coatAbsorption=vec3f(1.0);if (coat_weight>0.0) {slab_coat_ibl=coatEnvironmentLight*uniforms.vLightingIntensity.z;let hemisphere_avg_fresnel: f32=coatReflectance.F0+0.5f*(1.0f-coatReflectance.F0);var averageReflectance: f32=(coatIblFresnel+hemisphere_avg_fresnel)*0.5f;let roughnessFactor=1.0f-coat_roughness*0.5f;averageReflectance*=roughnessFactor;var darkened_transmission: f32=(1.0f-averageReflectance)*(1.0f-averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);var sin2: f32=1.0f-coatGeoInfo.NdotV*coatGeoInfo.NdotV;sin2=sin2/(coat_ior*coat_ior);let cos_t: f32=sqrt(1.0f-sin2);let coatPathLength=1.0f/cos_t;let colored_transmission: vec3f=pow(coat_color,vec3f(coatPathLength));coatAbsorption=mix(vec3f(1.0f),colored_transmission*vec3f(darkened_transmission),coat_weight);}
|
|
101
|
+
var slab_subsurface_ibl: vec3f=vec3f(0.,0.,0.);var slab_translucent_base_ibl: vec3f=vec3f(0.,0.,0.);var slab_fuzz_ibl: vec3f=vec3f(0.,0.,0.);slab_diffuse_ibl*=base_color.rgb;
|
|
102
|
+
#define CUSTOM_FRAGMENT_BEFORE_IBLLAYERCOMPOSITION
|
|
103
|
+
let material_opaque_base_ibl: vec3f=mix(slab_diffuse_ibl,slab_subsurface_ibl,subsurface_weight);let material_dielectric_base_ibl: vec3f=mix(material_opaque_base_ibl,slab_translucent_base_ibl,transmission_weight);let material_dielectric_gloss_ibl: vec3f=layer(material_dielectric_base_ibl,slab_glossy_ibl,dielectricIblFresnel,vec3f(1.0f),specular_color);let material_base_substrate_ibl: vec3f=mix(material_dielectric_gloss_ibl,slab_metal_ibl,base_metalness);let material_coated_base_ibl: vec3f=layer(material_base_substrate_ibl,slab_coat_ibl,coatIblFresnel,coatAbsorption,vec3f(1.0f));material_surface_ibl=mix(material_coated_base_ibl,slab_fuzz_ibl,fuzz_weight);
|
|
104
|
+
#endif
|
|
105
|
+
`;
|
|
106
|
+
// Sideeffect
|
|
107
|
+
if (!ShaderStore.IncludesShadersStoreWGSL[name]) {
|
|
108
|
+
ShaderStore.IncludesShadersStoreWGSL[name] = shader;
|
|
109
|
+
}
|
|
110
|
+
/** @internal */
|
|
111
|
+
export const openpbrEnvironmentLightingWGSL = { name, shader };
|
|
112
|
+
//# sourceMappingURL=openpbrEnvironmentLighting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrEnvironmentLighting.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,4BAA4B,CAAC;AAC1C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqGd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,8BAA8B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"openpbrEnvironmentLighting\";\nconst shader = `#ifdef REFLECTION\nvar baseDiffuseEnvironmentLight: vec3f=sampleIrradiance(\nnormalW\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\n,vEnvironmentIrradiance \n#endif\n#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))\n,uniforms.reflectionMatrix\n#endif\n#ifdef USEIRRADIANCEMAP\n,irradianceSampler\n,irradianceSamplerSampler\n#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION\n,uniforms.vReflectionDominantDirection\n#endif\n#endif\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#ifdef IBL_CDF_FILTERING\n,icdfSampler\n,icdfSamplerSampler\n#endif\n#endif\n,uniforms.vReflectionInfos\n,viewDirectionW\n,base_diffuse_roughness\n,base_color\n);\n#ifdef REFLECTIONMAP_3D\nvar reflectionCoords: vec3f=vec3f(0.f,0.f,0.f);\n#else\nvar reflectionCoords: vec2f=vec2f(0.f,0.f);\n#endif\nlet specularAlphaG: f32=specular_roughness*specular_roughness;\n#ifdef ANISOTROPIC_BASE\nvar baseSpecularEnvironmentLight: vec3f=sampleRadianceAnisotropic(specularAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,baseGeoInfo\n,normalW\n,viewDirectionW\n,fragmentInputs.vPositionW\n,noise\n,reflectionSampler\n,reflectionSamplerSampler\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n);\n#else\nreflectionCoords=createReflectionCoords(fragmentInputs.vPositionW,normalW);var baseSpecularEnvironmentLight: vec3f=sampleRadiance(specularAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,baseGeoInfo\n,reflectionSampler\n,reflectionSamplerSampler\n,reflectionCoords\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n);\n#endif\n#ifdef ANISOTROPIC_BASE\nbaseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG*specularAlphaG *max(1.0f-baseGeoInfo.anisotropy,0.3f));\n#else\nbaseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG);\n#endif\nvar coatEnvironmentLight: vec3f=vec3f(0.f,0.f,0.f);if (coat_weight>0.0) {\n#ifdef REFLECTIONMAP_3D\nvar reflectionCoords: vec3f=vec3f(0.f,0.f,0.f);\n#else\nvar reflectionCoords: vec2f=vec2f(0.f,0.f);\n#endif\nreflectionCoords=createReflectionCoords(fragmentInputs.vPositionW,coatNormalW);var coatAlphaG: f32=coat_roughness*coat_roughness;\n#ifdef ANISOTROPIC_COAT\ncoatEnvironmentLight=sampleRadianceAnisotropic(coatAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,coatGeoInfo\n,coatNormalW\n,viewDirectionW\n,fragmentInputs.vPositionW\n,noise\n,reflectionSampler\n,reflectionSamplerSampler\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n);\n#else\ncoatEnvironmentLight=sampleRadiance(coatAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos\n,coatGeoInfo\n,reflectionSampler\n,reflectionSamplerSampler\n,reflectionCoords\n#ifdef REALTIME_FILTERING\n,uniforms.vReflectionFilteringInfo\n#endif\n);\n#endif\n}\nlet dielectricIblFresnel: f32=getReflectanceFromBRDFWithEnvLookup(vec3f(baseDielectricReflectance.F0),vec3f(baseDielectricReflectance.F90),baseGeoInfo.environmentBrdf).r;let dielectricIblColoredFresnel: vec3f=getReflectanceFromBRDFWithEnvLookup(baseDielectricReflectance.coloredF0,baseDielectricReflectance.coloredF90,baseGeoInfo.environmentBrdf);let conductorIblFresnel: vec3f=conductorIblFresnel(baseConductorReflectance,baseGeoInfo.NdotV,specular_roughness,baseGeoInfo.environmentBrdf);var coatIblFresnel: f32=0.0;if (coat_weight>0.0) {coatIblFresnel=getReflectanceFromBRDFWithEnvLookup(vec3f(coatReflectance.F0),vec3f(coatReflectance.F90),coatGeoInfo.environmentBrdf).r;}\nvar slab_diffuse_ibl: vec3f=vec3f(0.,0.,0.);var slab_glossy_ibl: vec3f=vec3f(0.,0.,0.);var slab_metal_ibl: vec3f=vec3f(0.,0.,0.);var slab_coat_ibl: vec3f=vec3f(0.,0.,0.);slab_diffuse_ibl=baseDiffuseEnvironmentLight*uniforms.vLightingIntensity.z;slab_diffuse_ibl*=aoOut.ambientOcclusionColor;slab_glossy_ibl=baseSpecularEnvironmentLight*uniforms.vLightingIntensity.z;slab_metal_ibl=baseSpecularEnvironmentLight*conductorIblFresnel*uniforms.vLightingIntensity.z;var coatAbsorption=vec3f(1.0);if (coat_weight>0.0) {slab_coat_ibl=coatEnvironmentLight*uniforms.vLightingIntensity.z;let hemisphere_avg_fresnel: f32=coatReflectance.F0+0.5f*(1.0f-coatReflectance.F0);var averageReflectance: f32=(coatIblFresnel+hemisphere_avg_fresnel)*0.5f;let roughnessFactor=1.0f-coat_roughness*0.5f;averageReflectance*=roughnessFactor;var darkened_transmission: f32=(1.0f-averageReflectance)*(1.0f-averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);var sin2: f32=1.0f-coatGeoInfo.NdotV*coatGeoInfo.NdotV;sin2=sin2/(coat_ior*coat_ior);let cos_t: f32=sqrt(1.0f-sin2);let coatPathLength=1.0f/cos_t;let colored_transmission: vec3f=pow(coat_color,vec3f(coatPathLength));coatAbsorption=mix(vec3f(1.0f),colored_transmission*vec3f(darkened_transmission),coat_weight);}\nvar slab_subsurface_ibl: vec3f=vec3f(0.,0.,0.);var slab_translucent_base_ibl: vec3f=vec3f(0.,0.,0.);var slab_fuzz_ibl: vec3f=vec3f(0.,0.,0.);slab_diffuse_ibl*=base_color.rgb;\n#define CUSTOM_FRAGMENT_BEFORE_IBLLAYERCOMPOSITION\nlet material_opaque_base_ibl: vec3f=mix(slab_diffuse_ibl,slab_subsurface_ibl,subsurface_weight);let material_dielectric_base_ibl: vec3f=mix(material_opaque_base_ibl,slab_translucent_base_ibl,transmission_weight);let material_dielectric_gloss_ibl: vec3f=layer(material_dielectric_base_ibl,slab_glossy_ibl,dielectricIblFresnel,vec3f(1.0f),specular_color);let material_base_substrate_ibl: vec3f=mix(material_dielectric_gloss_ibl,slab_metal_ibl,base_metalness);let material_coated_base_ibl: vec3f=layer(material_base_substrate_ibl,slab_coat_ibl,coatIblFresnel,coatAbsorption,vec3f(1.0f));material_surface_ibl=mix(material_coated_base_ibl,slab_fuzz_ibl,fuzz_weight);\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrEnvironmentLightingWGSL = { name, shader };\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
import "./samplerFragmentDeclaration.js";
|
|
4
|
+
const name = "openpbrFragmentSamplersDeclaration";
|
|
5
|
+
const shader = `#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor,_SAMPLERNAME_,baseColor)
|
|
6
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight)
|
|
7
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness)
|
|
8
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_METALNESS,_VARYINGNAME_,BaseMetalness,_SAMPLERNAME_,baseMetalness)
|
|
9
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_WEIGHT,_VARYINGNAME_,SpecularWeight,_SAMPLERNAME_,specularWeight)
|
|
10
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_COLOR,_VARYINGNAME_,SpecularColor,_SAMPLERNAME_,specularColor)
|
|
11
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS,_VARYINGNAME_,SpecularRoughness,_SAMPLERNAME_,specularRoughness)
|
|
12
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,SpecularRoughnessAnisotropy,_SAMPLERNAME_,specularRoughnessAnisotropy)
|
|
13
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_WEIGHT,_VARYINGNAME_,CoatWeight,_SAMPLERNAME_,coatWeight)
|
|
14
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_COLOR,_VARYINGNAME_,CoatColor,_SAMPLERNAME_,coatColor)
|
|
15
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS,_VARYINGNAME_,CoatRoughness,_SAMPLERNAME_,coatRoughness)
|
|
16
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,CoatRoughnessAnisotropy,_SAMPLERNAME_,coatRoughnessAnisotropy)
|
|
17
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_DARKENING,_VARYINGNAME_,CoatDarkening,_SAMPLERNAME_,coatDarkening)
|
|
18
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_OPACITY,_VARYINGNAME_,GeometryOpacity,_SAMPLERNAME_,geometryOpacity)
|
|
19
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_TANGENT,_VARYINGNAME_,GeometryTangent,_SAMPLERNAME_,geometryTangent)
|
|
20
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_COAT_TANGENT,_VARYINGNAME_,GeometryCoatTangent,_SAMPLERNAME_,geometryCoatTangent)
|
|
21
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSION_COLOR,_VARYINGNAME_,EmissionColor,_SAMPLERNAME_,emissionColor)
|
|
22
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_SAMPLERNAME_,ambientOcclusion)
|
|
23
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
|
|
24
|
+
#ifdef REFLECTION
|
|
25
|
+
#ifdef REFLECTIONMAP_3D
|
|
26
|
+
var reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube<f32>;
|
|
27
|
+
#ifdef LODBASEDMICROSFURACE
|
|
28
|
+
#else
|
|
29
|
+
var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_cube<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_cube<f32>;
|
|
30
|
+
#endif
|
|
31
|
+
#ifdef USEIRRADIANCEMAP
|
|
32
|
+
var irradianceSamplerSampler: sampler;var irradianceSampler: texture_cube<f32>;
|
|
33
|
+
#endif
|
|
34
|
+
#else
|
|
35
|
+
var reflectionSamplerSampler: sampler;var reflectionSampler: texture_2d<f32>;
|
|
36
|
+
#ifdef LODBASEDMICROSFURACE
|
|
37
|
+
#else
|
|
38
|
+
var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_2d<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_2d<f32>;
|
|
39
|
+
#endif
|
|
40
|
+
#ifdef USEIRRADIANCEMAP
|
|
41
|
+
var irradianceSamplerSampler: sampler;var irradianceSampler: texture_2d<f32>;
|
|
42
|
+
#endif
|
|
43
|
+
#endif
|
|
44
|
+
#ifdef REFLECTIONMAP_SKYBOX
|
|
45
|
+
varying vPositionUVW: vec3f;
|
|
46
|
+
#else
|
|
47
|
+
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
|
48
|
+
varying vDirectionW: vec3f;
|
|
49
|
+
#endif
|
|
50
|
+
#endif
|
|
51
|
+
#endif
|
|
52
|
+
#ifdef ENVIRONMENTBRDF
|
|
53
|
+
var environmentBrdfSamplerSampler: sampler;var environmentBrdfSampler: texture_2d<f32>;
|
|
54
|
+
#endif
|
|
55
|
+
#ifdef ANISOTROPIC
|
|
56
|
+
var blueNoiseSamplerSampler: sampler;var blueNoiseSampler: texture_2d<f32>;
|
|
57
|
+
#endif
|
|
58
|
+
#ifdef IBL_CDF_FILTERING
|
|
59
|
+
var icdfSamplerSampler: sampler;var icdfSampler: texture_2d<f32>;
|
|
60
|
+
#endif
|
|
61
|
+
`;
|
|
62
|
+
// Sideeffect
|
|
63
|
+
if (!ShaderStore.IncludesShadersStoreWGSL[name]) {
|
|
64
|
+
ShaderStore.IncludesShadersStoreWGSL[name] = shader;
|
|
65
|
+
}
|
|
66
|
+
/** @internal */
|
|
67
|
+
export const openpbrFragmentSamplersDeclarationWGSL = { name, shader };
|
|
68
|
+
//# sourceMappingURL=openpbrFragmentSamplersDeclaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrFragmentSamplersDeclaration.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,8BAA8B,CAAC;AAEtC,MAAM,IAAI,GAAG,oCAAoC,CAAC;AAClD,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,sCAAsC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\nimport \"./samplerFragmentDeclaration\";\n\nconst name = \"openpbrFragmentSamplersDeclaration\";\nconst shader = `#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor,_SAMPLERNAME_,baseColor)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_METALNESS,_VARYINGNAME_,BaseMetalness,_SAMPLERNAME_,baseMetalness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_WEIGHT,_VARYINGNAME_,SpecularWeight,_SAMPLERNAME_,specularWeight)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_COLOR,_VARYINGNAME_,SpecularColor,_SAMPLERNAME_,specularColor)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS,_VARYINGNAME_,SpecularRoughness,_SAMPLERNAME_,specularRoughness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,SpecularRoughnessAnisotropy,_SAMPLERNAME_,specularRoughnessAnisotropy)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_WEIGHT,_VARYINGNAME_,CoatWeight,_SAMPLERNAME_,coatWeight)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_COLOR,_VARYINGNAME_,CoatColor,_SAMPLERNAME_,coatColor)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS,_VARYINGNAME_,CoatRoughness,_SAMPLERNAME_,coatRoughness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,CoatRoughnessAnisotropy,_SAMPLERNAME_,coatRoughnessAnisotropy)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_DARKENING,_VARYINGNAME_,CoatDarkening,_SAMPLERNAME_,coatDarkening)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_OPACITY,_VARYINGNAME_,GeometryOpacity,_SAMPLERNAME_,geometryOpacity)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_TANGENT,_VARYINGNAME_,GeometryTangent,_SAMPLERNAME_,geometryTangent)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_COAT_TANGENT,_VARYINGNAME_,GeometryCoatTangent,_SAMPLERNAME_,geometryCoatTangent)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSION_COLOR,_VARYINGNAME_,EmissionColor,_SAMPLERNAME_,emissionColor)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_SAMPLERNAME_,ambientOcclusion)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nvar reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube<f32>;\n#ifdef LODBASEDMICROSFURACE\n#else\nvar reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_cube<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_cube<f32>;\n#endif\n#ifdef USEIRRADIANCEMAP\nvar irradianceSamplerSampler: sampler;var irradianceSampler: texture_cube<f32>;\n#endif\n#else\nvar reflectionSamplerSampler: sampler;var reflectionSampler: texture_2d<f32>;\n#ifdef LODBASEDMICROSFURACE\n#else\nvar reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_2d<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_2d<f32>;\n#endif\n#ifdef USEIRRADIANCEMAP\nvar irradianceSamplerSampler: sampler;var irradianceSampler: texture_2d<f32>;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vPositionUVW: vec3f;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vDirectionW: vec3f;\n#endif\n#endif\n#endif\n#ifdef ENVIRONMENTBRDF\nvar environmentBrdfSamplerSampler: sampler;var environmentBrdfSampler: texture_2d<f32>;\n#endif\n#ifdef ANISOTROPIC\nvar blueNoiseSamplerSampler: sampler;var blueNoiseSampler: texture_2d<f32>;\n#endif\n#ifdef IBL_CDF_FILTERING\nvar icdfSamplerSampler: sampler;var icdfSampler: texture_2d<f32>;\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrFragmentSamplersDeclarationWGSL = { name, shader };\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
const name = "openpbrGeometryInfo";
|
|
4
|
+
const shader = `struct geometryInfoOutParams
|
|
5
|
+
{NdotV: f32,
|
|
6
|
+
NdotVUnclamped: f32,
|
|
7
|
+
environmentBrdf: vec3f,
|
|
8
|
+
horizonOcclusion: f32};
|
|
9
|
+
#ifdef ANISOTROPIC
|
|
10
|
+
struct geometryInfoAnisoOutParams
|
|
11
|
+
{NdotV: f32,
|
|
12
|
+
NdotVUnclamped: f32,
|
|
13
|
+
environmentBrdf: vec3f,
|
|
14
|
+
horizonOcclusion: f32,
|
|
15
|
+
anisotropy: f32,
|
|
16
|
+
anisotropicTangent: vec3f,
|
|
17
|
+
anisotropicBitangent: vec3f,
|
|
18
|
+
TBN: mat3x3<f32>};
|
|
19
|
+
#endif
|
|
20
|
+
fn geometryInfo(
|
|
21
|
+
normalW: vec3f,viewDirectionW: vec3f,roughness: f32,geometricNormalW: vec3f
|
|
22
|
+
)->geometryInfoOutParams
|
|
23
|
+
{var outParams: geometryInfoOutParams;outParams.NdotVUnclamped=dot(normalW,viewDirectionW);outParams.NdotV=absEps(outParams.NdotVUnclamped);
|
|
24
|
+
#if defined(ENVIRONMENTBRDF)
|
|
25
|
+
outParams.environmentBrdf=getBRDFLookup(outParams.NdotV,roughness);
|
|
26
|
+
#else
|
|
27
|
+
outParams.environmentBrdf=vec3f(0.0);
|
|
28
|
+
#endif
|
|
29
|
+
outParams.horizonOcclusion=1.0f;
|
|
30
|
+
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
|
31
|
+
#ifdef HORIZONOCCLUSION
|
|
32
|
+
#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL)
|
|
33
|
+
#ifdef REFLECTIONMAP_3D
|
|
34
|
+
outParams.horizonOcclusion=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
|
|
35
|
+
#endif
|
|
36
|
+
#endif
|
|
37
|
+
#endif
|
|
38
|
+
#endif
|
|
39
|
+
return outParams;}
|
|
40
|
+
#ifdef ANISOTROPIC
|
|
41
|
+
fn geometryInfoAniso(
|
|
42
|
+
normalW: vec3f,viewDirectionW: vec3f,roughness: f32,geometricNormalW: vec3f
|
|
43
|
+
,vAnisotropy: vec3f,TBN: mat3x3<f32>
|
|
44
|
+
)->geometryInfoAnisoOutParams
|
|
45
|
+
{let geoInfo: geometryInfoOutParams=geometryInfo(normalW,viewDirectionW,roughness,geometricNormalW);var outParams: geometryInfoAnisoOutParams;outParams.NdotV=geoInfo.NdotV;outParams.NdotVUnclamped=geoInfo.NdotVUnclamped;outParams.environmentBrdf=geoInfo.environmentBrdf;outParams.horizonOcclusion=geoInfo.horizonOcclusion;outParams.anisotropy=vAnisotropy.b;let anisotropyDirection: vec3f=vec3f(vAnisotropy.xy,0.);let anisoTBN: mat3x3<f32>=mat3x3<f32>(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));outParams.anisotropicTangent=normalize(anisoTBN*anisotropyDirection);outParams.anisotropicBitangent=normalize(cross(anisoTBN[2],outParams.anisotropicTangent));outParams.TBN=TBN;return outParams;}
|
|
46
|
+
#endif
|
|
47
|
+
`;
|
|
48
|
+
// Sideeffect
|
|
49
|
+
if (!ShaderStore.IncludesShadersStoreWGSL[name]) {
|
|
50
|
+
ShaderStore.IncludesShadersStoreWGSL[name] = shader;
|
|
51
|
+
}
|
|
52
|
+
/** @internal */
|
|
53
|
+
export const openpbrGeometryInfoWGSL = { name, shader };
|
|
54
|
+
//# sourceMappingURL=openpbrGeometryInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openpbrGeometryInfo.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/openpbrGeometryInfo.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Cd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"openpbrGeometryInfo\";\nconst shader = `struct geometryInfoOutParams\n{NdotV: f32,\nNdotVUnclamped: f32,\nenvironmentBrdf: vec3f,\nhorizonOcclusion: f32};\n#ifdef ANISOTROPIC\nstruct geometryInfoAnisoOutParams\n{NdotV: f32,\nNdotVUnclamped: f32,\nenvironmentBrdf: vec3f,\nhorizonOcclusion: f32,\nanisotropy: f32,\nanisotropicTangent: vec3f,\nanisotropicBitangent: vec3f,\nTBN: mat3x3<f32>};\n#endif\nfn geometryInfo(\nnormalW: vec3f,viewDirectionW: vec3f,roughness: f32,geometricNormalW: vec3f\n)->geometryInfoOutParams\n{var outParams: geometryInfoOutParams;outParams.NdotVUnclamped=dot(normalW,viewDirectionW);outParams.NdotV=absEps(outParams.NdotVUnclamped);\n#if defined(ENVIRONMENTBRDF)\noutParams.environmentBrdf=getBRDFLookup(outParams.NdotV,roughness);\n#else\noutParams.environmentBrdf=vec3f(0.0);\n#endif\noutParams.horizonOcclusion=1.0f;\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n#ifdef HORIZONOCCLUSION\n#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL)\n#ifdef REFLECTIONMAP_3D\noutParams.horizonOcclusion=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);\n#endif\n#endif\n#endif\n#endif\nreturn outParams;}\n#ifdef ANISOTROPIC\nfn geometryInfoAniso(\nnormalW: vec3f,viewDirectionW: vec3f,roughness: f32,geometricNormalW: vec3f\n,vAnisotropy: vec3f,TBN: mat3x3<f32>\n)->geometryInfoAnisoOutParams\n{let geoInfo: geometryInfoOutParams=geometryInfo(normalW,viewDirectionW,roughness,geometricNormalW);var outParams: geometryInfoAnisoOutParams;outParams.NdotV=geoInfo.NdotV;outParams.NdotVUnclamped=geoInfo.NdotVUnclamped;outParams.environmentBrdf=geoInfo.environmentBrdf;outParams.horizonOcclusion=geoInfo.horizonOcclusion;outParams.anisotropy=vAnisotropy.b;let anisotropyDirection: vec3f=vec3f(vAnisotropy.xy,0.);let anisoTBN: mat3x3<f32>=mat3x3<f32>(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));outParams.anisotropicTangent=normalize(anisoTBN*anisotropyDirection);outParams.anisotropicBitangent=normalize(cross(anisoTBN[2],outParams.anisotropicTangent));outParams.TBN=TBN;return outParams;}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const openpbrGeometryInfoWGSL = { name, shader };\n"]}
|