@graphty/graphty-element 1.0.1
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/README.md +9 -0
- package/dist/basisTextureLoader-BqIvxvNl.js +312 -0
- package/dist/basisTextureLoader-BqIvxvNl.js.map +1 -0
- package/dist/custom-elements.json +1 -0
- package/dist/dds-BlAaKjyJ.js +357 -0
- package/dist/dds-BlAaKjyJ.js.map +1 -0
- package/dist/ddsTextureLoader-D7Jh83wc.js +44 -0
- package/dist/ddsTextureLoader-D7Jh83wc.js.map +1 -0
- package/dist/default.fragment-BNc4beoN.js +452 -0
- package/dist/default.fragment-BNc4beoN.js.map +1 -0
- package/dist/default.fragment-CSeCDRwv.js +512 -0
- package/dist/default.fragment-CSeCDRwv.js.map +1 -0
- package/dist/default.vertex-9pBFrn06.js +202 -0
- package/dist/default.vertex-9pBFrn06.js.map +1 -0
- package/dist/default.vertex-DDjK1DRv.js +185 -0
- package/dist/default.vertex-DDjK1DRv.js.map +1 -0
- package/dist/defaultUboDeclaration-CG47IDRY.js +9 -0
- package/dist/defaultUboDeclaration-CG47IDRY.js.map +1 -0
- package/dist/defaultUboDeclaration-Ct5CiQ-w.js +11 -0
- package/dist/defaultUboDeclaration-Ct5CiQ-w.js.map +1 -0
- package/dist/dumpTools-DA1xMSIZ.js +103 -0
- package/dist/dumpTools-DA1xMSIZ.js.map +1 -0
- package/dist/envTextureLoader-DdCLpySN.js +238 -0
- package/dist/envTextureLoader-DdCLpySN.js.map +1 -0
- package/dist/exrTextureLoader-CnJSRQ9w.js +741 -0
- package/dist/exrTextureLoader-CnJSRQ9w.js.map +1 -0
- package/dist/graphty.js +12 -0
- package/dist/graphty.js.map +1 -0
- package/dist/graphty.umd.cjs +12657 -0
- package/dist/graphty.umd.cjs.map +1 -0
- package/dist/greasedLine.fragment-BZnGGe-r.js +30 -0
- package/dist/greasedLine.fragment-BZnGGe-r.js.map +1 -0
- package/dist/greasedLine.fragment-DixuqXus.js +12 -0
- package/dist/greasedLine.fragment-DixuqXus.js.map +1 -0
- package/dist/greasedLine.vertex-BhhwFKPy.js +33 -0
- package/dist/greasedLine.vertex-BhhwFKPy.js.map +1 -0
- package/dist/greasedLine.vertex-DIhgGSOi.js +49 -0
- package/dist/greasedLine.vertex-DIhgGSOi.js.map +1 -0
- package/dist/harmonicsFunctions-B9jTNKTF.js +197 -0
- package/dist/harmonicsFunctions-B9jTNKTF.js.map +1 -0
- package/dist/harmonicsFunctions-D9ZL5yLA.js +194 -0
- package/dist/harmonicsFunctions-D9ZL5yLA.js.map +1 -0
- package/dist/hdrTextureLoader-DreWCvHD.js +112 -0
- package/dist/hdrTextureLoader-DreWCvHD.js.map +1 -0
- package/dist/helperFunctions-Dh1WD8YN.js +106 -0
- package/dist/helperFunctions-Dh1WD8YN.js.map +1 -0
- package/dist/helperFunctions-ZBnqb-in.js +79 -0
- package/dist/helperFunctions-ZBnqb-in.js.map +1 -0
- package/dist/iesTextureLoader-JdfAyRK-.js +94 -0
- package/dist/iesTextureLoader-JdfAyRK-.js.map +1 -0
- package/dist/index-ChGTkj2q.js +62191 -0
- package/dist/index-ChGTkj2q.js.map +1 -0
- package/dist/instancesVertex-BrWNnWxF.js +46 -0
- package/dist/instancesVertex-BrWNnWxF.js.map +1 -0
- package/dist/instancesVertex-evcSIvCA.js +55 -0
- package/dist/instancesVertex-evcSIvCA.js.map +1 -0
- package/dist/ktxTextureLoader-Dg1h0a-4.js +520 -0
- package/dist/ktxTextureLoader-Dg1h0a-4.js.map +1 -0
- package/dist/logDepthDeclaration-BHUUDd5l.js +12 -0
- package/dist/logDepthDeclaration-BHUUDd5l.js.map +1 -0
- package/dist/logDepthDeclaration-Bou5AJOP.js +28 -0
- package/dist/logDepthDeclaration-Bou5AJOP.js.map +1 -0
- package/dist/logDepthVertex-CCFGLExi.js +496 -0
- package/dist/logDepthVertex-CCFGLExi.js.map +1 -0
- package/dist/logDepthVertex-r_niddz9.js +496 -0
- package/dist/logDepthVertex-r_niddz9.js.map +1 -0
- package/dist/mesh.vertexData.functions-Bc9lJlrU.js +75 -0
- package/dist/mesh.vertexData.functions-Bc9lJlrU.js.map +1 -0
- package/dist/meshUboDeclaration-Dg__Mhmj.js +18 -0
- package/dist/meshUboDeclaration-Dg__Mhmj.js.map +1 -0
- package/dist/oitFragment-Bn29Ggvj.js +1191 -0
- package/dist/oitFragment-Bn29Ggvj.js.map +1 -0
- package/dist/oitFragment-D6JBEGk0.js +1328 -0
- package/dist/oitFragment-D6JBEGk0.js.map +1 -0
- package/dist/pass.fragment-C9O4ZLJL.js +11 -0
- package/dist/pass.fragment-C9O4ZLJL.js.map +1 -0
- package/dist/pass.fragment-Cf0ob1Y3.js +11 -0
- package/dist/pass.fragment-Cf0ob1Y3.js.map +1 -0
- package/dist/passCube.fragment-Mg8Qj5T9.js +30 -0
- package/dist/passCube.fragment-Mg8Qj5T9.js.map +1 -0
- package/dist/passCube.fragment-uM4B7TOI.js +30 -0
- package/dist/passCube.fragment-uM4B7TOI.js.map +1 -0
- package/dist/pbr.fragment-C8Lm3cwF.js +3176 -0
- package/dist/pbr.fragment-C8Lm3cwF.js.map +1 -0
- package/dist/pbr.fragment-siOdCYqI.js +3219 -0
- package/dist/pbr.fragment-siOdCYqI.js.map +1 -0
- package/dist/pbr.vertex-Bw_TrGQv.js +229 -0
- package/dist/pbr.vertex-Bw_TrGQv.js.map +1 -0
- package/dist/pbr.vertex-CmEPCcBW.js +365 -0
- package/dist/pbr.vertex-CmEPCcBW.js.map +1 -0
- package/dist/postprocess.vertex-B086G8mM.js +16 -0
- package/dist/postprocess.vertex-B086G8mM.js.map +1 -0
- package/dist/rgbdDecode.fragment-bNaGtQ-x.js +9 -0
- package/dist/rgbdDecode.fragment-bNaGtQ-x.js.map +1 -0
- package/dist/rgbdDecode.fragment-koAcppx0.js +9 -0
- package/dist/rgbdDecode.fragment-koAcppx0.js.map +1 -0
- package/dist/rgbdEncode.fragment-BDHL2P_i.js +9 -0
- package/dist/rgbdEncode.fragment-BDHL2P_i.js.map +1 -0
- package/dist/rgbdEncode.fragment-Dw0FS9aH.js +9 -0
- package/dist/rgbdEncode.fragment-Dw0FS9aH.js.map +1 -0
- package/dist/tgaTextureLoader-DIfkfgQh.js +199 -0
- package/dist/tgaTextureLoader-DIfkfgQh.js.map +1 -0
- package/package.json +124 -0
|
@@ -0,0 +1,3219 @@
|
|
|
1
|
+
import { S as e } from "./index-ChGTkj2q.js";
|
|
2
|
+
import "./oitFragment-D6JBEGk0.js";
|
|
3
|
+
import "./harmonicsFunctions-D9ZL5yLA.js";
|
|
4
|
+
import "./logDepthDeclaration-Bou5AJOP.js";
|
|
5
|
+
import "./helperFunctions-Dh1WD8YN.js";
|
|
6
|
+
const n = "pbrFragmentDeclaration", V = `uniform vec4 vEyePosition;uniform vec3 vReflectionColor;uniform vec4 vAlbedoColor;uniform float baseWeight;uniform float baseDiffuseRoughness;uniform vec4 vLightingIntensity;uniform vec4 vReflectivityColor;uniform vec4 vMetallicReflectanceFactors;uniform vec3 vEmissiveColor;uniform float visibility;uniform vec3 vAmbientColor;
|
|
7
|
+
#ifdef ALBEDO
|
|
8
|
+
uniform vec2 vAlbedoInfos;
|
|
9
|
+
#endif
|
|
10
|
+
#ifdef BASE_WEIGHT
|
|
11
|
+
uniform vec2 vBaseWeightInfos;
|
|
12
|
+
#endif
|
|
13
|
+
#ifdef BASE_DIFFUSE_ROUGHNESS
|
|
14
|
+
uniform vec2 vBaseDiffuseRoughnessInfos;
|
|
15
|
+
#endif
|
|
16
|
+
#ifdef AMBIENT
|
|
17
|
+
uniform vec4 vAmbientInfos;
|
|
18
|
+
#endif
|
|
19
|
+
#ifdef BUMP
|
|
20
|
+
uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;
|
|
21
|
+
#endif
|
|
22
|
+
#ifdef OPACITY
|
|
23
|
+
uniform vec2 vOpacityInfos;
|
|
24
|
+
#endif
|
|
25
|
+
#ifdef EMISSIVE
|
|
26
|
+
uniform vec2 vEmissiveInfos;
|
|
27
|
+
#endif
|
|
28
|
+
#ifdef LIGHTMAP
|
|
29
|
+
uniform vec2 vLightmapInfos;
|
|
30
|
+
#endif
|
|
31
|
+
#ifdef REFLECTIVITY
|
|
32
|
+
uniform vec3 vReflectivityInfos;
|
|
33
|
+
#endif
|
|
34
|
+
#ifdef MICROSURFACEMAP
|
|
35
|
+
uniform vec2 vMicroSurfaceSamplerInfos;
|
|
36
|
+
#endif
|
|
37
|
+
#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION) || defined(PREPASS)
|
|
38
|
+
uniform mat4 view;
|
|
39
|
+
#endif
|
|
40
|
+
#ifdef REFLECTION
|
|
41
|
+
uniform vec2 vReflectionInfos;
|
|
42
|
+
#ifdef REALTIME_FILTERING
|
|
43
|
+
uniform vec2 vReflectionFilteringInfo;
|
|
44
|
+
#endif
|
|
45
|
+
uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;
|
|
46
|
+
#if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION)
|
|
47
|
+
uniform vec3 vReflectionDominantDirection;
|
|
48
|
+
#endif
|
|
49
|
+
#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
|
|
50
|
+
uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize;
|
|
51
|
+
#endif
|
|
52
|
+
#endif
|
|
53
|
+
#if defined(SS_REFRACTION) && defined(SS_USE_LOCAL_REFRACTIONMAP_CUBIC)
|
|
54
|
+
uniform vec3 vRefractionPosition;uniform vec3 vRefractionSize;
|
|
55
|
+
#endif
|
|
56
|
+
#ifdef CLEARCOAT
|
|
57
|
+
uniform vec2 vClearCoatParams;uniform vec4 vClearCoatRefractionParams;
|
|
58
|
+
#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
|
|
59
|
+
uniform vec4 vClearCoatInfos;
|
|
60
|
+
#endif
|
|
61
|
+
#ifdef CLEARCOAT_TEXTURE
|
|
62
|
+
uniform mat4 clearCoatMatrix;
|
|
63
|
+
#endif
|
|
64
|
+
#ifdef CLEARCOAT_TEXTURE_ROUGHNESS
|
|
65
|
+
uniform mat4 clearCoatRoughnessMatrix;
|
|
66
|
+
#endif
|
|
67
|
+
#ifdef CLEARCOAT_BUMP
|
|
68
|
+
uniform vec2 vClearCoatBumpInfos;uniform vec2 vClearCoatTangentSpaceParams;uniform mat4 clearCoatBumpMatrix;
|
|
69
|
+
#endif
|
|
70
|
+
#ifdef CLEARCOAT_TINT
|
|
71
|
+
uniform vec4 vClearCoatTintParams;uniform float clearCoatColorAtDistance;
|
|
72
|
+
#ifdef CLEARCOAT_TINT_TEXTURE
|
|
73
|
+
uniform vec2 vClearCoatTintInfos;uniform mat4 clearCoatTintMatrix;
|
|
74
|
+
#endif
|
|
75
|
+
#endif
|
|
76
|
+
#endif
|
|
77
|
+
#ifdef IRIDESCENCE
|
|
78
|
+
uniform vec4 vIridescenceParams;
|
|
79
|
+
#if defined(IRIDESCENCE_TEXTURE) || defined(IRIDESCENCE_THICKNESS_TEXTURE)
|
|
80
|
+
uniform vec4 vIridescenceInfos;
|
|
81
|
+
#endif
|
|
82
|
+
#ifdef IRIDESCENCE_TEXTURE
|
|
83
|
+
uniform mat4 iridescenceMatrix;
|
|
84
|
+
#endif
|
|
85
|
+
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
|
|
86
|
+
uniform mat4 iridescenceThicknessMatrix;
|
|
87
|
+
#endif
|
|
88
|
+
#endif
|
|
89
|
+
#ifdef ANISOTROPIC
|
|
90
|
+
uniform vec3 vAnisotropy;
|
|
91
|
+
#ifdef ANISOTROPIC_TEXTURE
|
|
92
|
+
uniform vec2 vAnisotropyInfos;uniform mat4 anisotropyMatrix;
|
|
93
|
+
#endif
|
|
94
|
+
#endif
|
|
95
|
+
#ifdef SHEEN
|
|
96
|
+
uniform vec4 vSheenColor;
|
|
97
|
+
#ifdef SHEEN_ROUGHNESS
|
|
98
|
+
uniform float vSheenRoughness;
|
|
99
|
+
#endif
|
|
100
|
+
#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
|
|
101
|
+
uniform vec4 vSheenInfos;
|
|
102
|
+
#endif
|
|
103
|
+
#ifdef SHEEN_TEXTURE
|
|
104
|
+
uniform mat4 sheenMatrix;
|
|
105
|
+
#endif
|
|
106
|
+
#ifdef SHEEN_TEXTURE_ROUGHNESS
|
|
107
|
+
uniform mat4 sheenRoughnessMatrix;
|
|
108
|
+
#endif
|
|
109
|
+
#endif
|
|
110
|
+
#ifdef SUBSURFACE
|
|
111
|
+
#ifdef SS_REFRACTION
|
|
112
|
+
uniform vec4 vRefractionMicrosurfaceInfos;uniform vec4 vRefractionInfos;uniform mat4 refractionMatrix;
|
|
113
|
+
#ifdef REALTIME_FILTERING
|
|
114
|
+
uniform vec2 vRefractionFilteringInfo;
|
|
115
|
+
#endif
|
|
116
|
+
#ifdef SS_DISPERSION
|
|
117
|
+
uniform float dispersion;
|
|
118
|
+
#endif
|
|
119
|
+
#endif
|
|
120
|
+
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
|
121
|
+
uniform vec2 vThicknessInfos;uniform mat4 thicknessMatrix;
|
|
122
|
+
#endif
|
|
123
|
+
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
|
|
124
|
+
uniform vec2 vRefractionIntensityInfos;uniform mat4 refractionIntensityMatrix;
|
|
125
|
+
#endif
|
|
126
|
+
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
|
|
127
|
+
uniform vec2 vTranslucencyIntensityInfos;uniform mat4 translucencyIntensityMatrix;
|
|
128
|
+
#endif
|
|
129
|
+
uniform vec2 vThicknessParam;uniform vec3 vDiffusionDistance;uniform vec4 vTintColor;uniform vec3 vSubSurfaceIntensity;uniform vec4 vTranslucencyColor;
|
|
130
|
+
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
|
131
|
+
uniform vec2 vTranslucencyColorInfos;uniform mat4 translucencyColorMatrix;
|
|
132
|
+
#endif
|
|
133
|
+
#endif
|
|
134
|
+
#ifdef PREPASS
|
|
135
|
+
#ifdef SS_SCATTERING
|
|
136
|
+
uniform float scatteringDiffusionProfile;
|
|
137
|
+
#endif
|
|
138
|
+
#endif
|
|
139
|
+
#if DEBUGMODE>0
|
|
140
|
+
uniform vec2 vDebugMode;
|
|
141
|
+
#endif
|
|
142
|
+
#ifdef DETAIL
|
|
143
|
+
uniform vec4 vDetailInfos;
|
|
144
|
+
#endif
|
|
145
|
+
#include<decalFragmentDeclaration>
|
|
146
|
+
#ifdef USESPHERICALFROMREFLECTIONMAP
|
|
147
|
+
#ifdef SPHERICAL_HARMONICS
|
|
148
|
+
uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22;
|
|
149
|
+
#else
|
|
150
|
+
uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX;
|
|
151
|
+
#endif
|
|
152
|
+
#endif
|
|
153
|
+
#define ADDITIONAL_FRAGMENT_DECLARATION
|
|
154
|
+
`;
|
|
155
|
+
e.IncludesShadersStore[n] || (e.IncludesShadersStore[n] = V);
|
|
156
|
+
const a = "pbrFragmentExtraDeclaration", H = `varying vec3 vPositionW;
|
|
157
|
+
#if DEBUGMODE>0
|
|
158
|
+
varying vec4 vClipSpacePosition;
|
|
159
|
+
#endif
|
|
160
|
+
#include<mainUVVaryingDeclaration>[1..7]
|
|
161
|
+
#ifdef NORMAL
|
|
162
|
+
varying vec3 vNormalW;
|
|
163
|
+
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
|
|
164
|
+
varying vec3 vEnvironmentIrradiance;
|
|
165
|
+
#endif
|
|
166
|
+
#endif
|
|
167
|
+
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
|
168
|
+
varying vec4 vColor;
|
|
169
|
+
#endif
|
|
170
|
+
`;
|
|
171
|
+
e.IncludesShadersStore[a] || (e.IncludesShadersStore[a] = H);
|
|
172
|
+
const o = "samplerFragmentAlternateDeclaration", x = `#ifdef _DEFINENAME_
|
|
173
|
+
#if _DEFINENAME_DIRECTUV==1
|
|
174
|
+
#define v_VARYINGNAME_UV vMainUV1
|
|
175
|
+
#elif _DEFINENAME_DIRECTUV==2
|
|
176
|
+
#define v_VARYINGNAME_UV vMainUV2
|
|
177
|
+
#elif _DEFINENAME_DIRECTUV==3
|
|
178
|
+
#define v_VARYINGNAME_UV vMainUV3
|
|
179
|
+
#elif _DEFINENAME_DIRECTUV==4
|
|
180
|
+
#define v_VARYINGNAME_UV vMainUV4
|
|
181
|
+
#elif _DEFINENAME_DIRECTUV==5
|
|
182
|
+
#define v_VARYINGNAME_UV vMainUV5
|
|
183
|
+
#elif _DEFINENAME_DIRECTUV==6
|
|
184
|
+
#define v_VARYINGNAME_UV vMainUV6
|
|
185
|
+
#else
|
|
186
|
+
varying vec2 v_VARYINGNAME_UV;
|
|
187
|
+
#endif
|
|
188
|
+
#endif
|
|
189
|
+
`;
|
|
190
|
+
e.IncludesShadersStore[o] || (e.IncludesShadersStore[o] = x);
|
|
191
|
+
const r = "pbrFragmentSamplersDeclaration", W = `#include<samplerFragmentDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo)
|
|
192
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight)
|
|
193
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness)
|
|
194
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
|
|
195
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
|
|
196
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
|
|
197
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
|
|
198
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity)
|
|
199
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface)
|
|
200
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance)
|
|
201
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance)
|
|
202
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
|
|
203
|
+
#ifdef CLEARCOAT
|
|
204
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat)
|
|
205
|
+
#include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
|
|
206
|
+
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS)
|
|
207
|
+
uniform sampler2D clearCoatRoughnessSampler;
|
|
208
|
+
#endif
|
|
209
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump)
|
|
210
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint)
|
|
211
|
+
#endif
|
|
212
|
+
#ifdef IRIDESCENCE
|
|
213
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_SAMPLERNAME_,iridescence)
|
|
214
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_SAMPLERNAME_,iridescenceThickness)
|
|
215
|
+
#endif
|
|
216
|
+
#ifdef SHEEN
|
|
217
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen)
|
|
218
|
+
#include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
|
|
219
|
+
#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS)
|
|
220
|
+
uniform sampler2D sheenRoughnessSampler;
|
|
221
|
+
#endif
|
|
222
|
+
#endif
|
|
223
|
+
#ifdef ANISOTROPIC
|
|
224
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy)
|
|
225
|
+
#endif
|
|
226
|
+
#ifdef REFLECTION
|
|
227
|
+
#ifdef REFLECTIONMAP_3D
|
|
228
|
+
#define sampleReflection(s,c) textureCube(s,c)
|
|
229
|
+
uniform samplerCube reflectionSampler;
|
|
230
|
+
#ifdef LODBASEDMICROSFURACE
|
|
231
|
+
#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)
|
|
232
|
+
#else
|
|
233
|
+
uniform samplerCube reflectionSamplerLow;uniform samplerCube reflectionSamplerHigh;
|
|
234
|
+
#endif
|
|
235
|
+
#ifdef USEIRRADIANCEMAP
|
|
236
|
+
uniform samplerCube irradianceSampler;
|
|
237
|
+
#endif
|
|
238
|
+
#else
|
|
239
|
+
#define sampleReflection(s,c) texture2D(s,c)
|
|
240
|
+
uniform sampler2D reflectionSampler;
|
|
241
|
+
#ifdef LODBASEDMICROSFURACE
|
|
242
|
+
#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)
|
|
243
|
+
#else
|
|
244
|
+
uniform sampler2D reflectionSamplerLow;uniform sampler2D reflectionSamplerHigh;
|
|
245
|
+
#endif
|
|
246
|
+
#ifdef USEIRRADIANCEMAP
|
|
247
|
+
uniform sampler2D irradianceSampler;
|
|
248
|
+
#endif
|
|
249
|
+
#endif
|
|
250
|
+
#ifdef REFLECTIONMAP_SKYBOX
|
|
251
|
+
varying vec3 vPositionUVW;
|
|
252
|
+
#else
|
|
253
|
+
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
|
254
|
+
varying vec3 vDirectionW;
|
|
255
|
+
#endif
|
|
256
|
+
#endif
|
|
257
|
+
#endif
|
|
258
|
+
#ifdef ENVIRONMENTBRDF
|
|
259
|
+
uniform sampler2D environmentBrdfSampler;
|
|
260
|
+
#endif
|
|
261
|
+
#ifdef SUBSURFACE
|
|
262
|
+
#ifdef SS_REFRACTION
|
|
263
|
+
#ifdef SS_REFRACTIONMAP_3D
|
|
264
|
+
#define sampleRefraction(s,c) textureCube(s,c)
|
|
265
|
+
uniform samplerCube refractionSampler;
|
|
266
|
+
#ifdef LODBASEDMICROSFURACE
|
|
267
|
+
#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)
|
|
268
|
+
#else
|
|
269
|
+
uniform samplerCube refractionSamplerLow;uniform samplerCube refractionSamplerHigh;
|
|
270
|
+
#endif
|
|
271
|
+
#else
|
|
272
|
+
#define sampleRefraction(s,c) texture2D(s,c)
|
|
273
|
+
uniform sampler2D refractionSampler;
|
|
274
|
+
#ifdef LODBASEDMICROSFURACE
|
|
275
|
+
#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)
|
|
276
|
+
#else
|
|
277
|
+
uniform sampler2D refractionSamplerLow;uniform sampler2D refractionSamplerHigh;
|
|
278
|
+
#endif
|
|
279
|
+
#endif
|
|
280
|
+
#endif
|
|
281
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness)
|
|
282
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity)
|
|
283
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity)
|
|
284
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor,_SAMPLERNAME_,translucencyColor)
|
|
285
|
+
#endif
|
|
286
|
+
#ifdef IBL_CDF_FILTERING
|
|
287
|
+
uniform sampler2D icdfSampler;
|
|
288
|
+
#endif
|
|
289
|
+
`;
|
|
290
|
+
e.IncludesShadersStore[r] || (e.IncludesShadersStore[r] = W);
|
|
291
|
+
const t = "subSurfaceScatteringFunctions", X = `bool testLightingForSSS(float diffusionProfile)
|
|
292
|
+
{return diffusionProfile<1.;}`;
|
|
293
|
+
e.IncludesShadersStore[t] || (e.IncludesShadersStore[t] = X);
|
|
294
|
+
const f = "importanceSampling", Y = `vec3 hemisphereCosSample(vec2 u) {float phi=2.*PI*u.x;float cosTheta2=1.-u.y;float cosTheta=sqrt(cosTheta2);float sinTheta=sqrt(1.-cosTheta2);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}
|
|
295
|
+
vec3 hemisphereImportanceSampleDggx(vec2 u,float a) {float phi=2.*PI*u.x;float cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));float cosTheta=sqrt(cosTheta2);float sinTheta=sqrt(1.-cosTheta2);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}
|
|
296
|
+
vec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) {
|
|
297
|
+
float phi=2.*PI*u.x;float sinTheta=pow(u.y,a/(2.*a+1.));float cosTheta=sqrt(1.-sinTheta*sinTheta);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}`;
|
|
298
|
+
e.IncludesShadersStore[f] || (e.IncludesShadersStore[f] = Y);
|
|
299
|
+
const c = "pbrHelperFunctions", k = `#define MINIMUMVARIANCE 0.0005
|
|
300
|
+
float convertRoughnessToAverageSlope(float roughness)
|
|
301
|
+
{return square(roughness)+MINIMUMVARIANCE;}
|
|
302
|
+
float fresnelGrazingReflectance(float reflectance0) {float reflectance90=saturate(reflectance0*25.0);return reflectance90;}
|
|
303
|
+
vec2 getAARoughnessFactors(vec3 normalVector) {
|
|
304
|
+
#ifdef SPECULARAA
|
|
305
|
+
vec3 nDfdx=dFdx(normalVector.xyz);vec3 nDfdy=dFdy(normalVector.xyz);float slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));float geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);float geometricAlphaGFactor=sqrt(slopeSquare);geometricAlphaGFactor*=0.75;return vec2(geometricRoughnessFactor,geometricAlphaGFactor);
|
|
306
|
+
#else
|
|
307
|
+
return vec2(0.);
|
|
308
|
+
#endif
|
|
309
|
+
}
|
|
310
|
+
#ifdef ANISOTROPIC
|
|
311
|
+
#ifdef ANISOTROPIC_LEGACY
|
|
312
|
+
vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {float alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);float alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);return vec2(alphaT,alphaB);}
|
|
313
|
+
vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy,float roughness) {vec3 anisotropicFrameDirection;if (anisotropy>=0.0) {anisotropicFrameDirection=B;} else {anisotropicFrameDirection=T;}
|
|
314
|
+
vec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);vec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);vec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));return anisotropicNormal;}
|
|
315
|
+
#else
|
|
316
|
+
vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {float alphaT=max(mix(alphaG,1.0,anisotropy*anisotropy),MINIMUMVARIANCE);float alphaB=max(alphaG,MINIMUMVARIANCE);return vec2(alphaT,alphaB);}
|
|
317
|
+
vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy,float roughness) {vec3 bentNormal=cross(B,V);bentNormal=normalize(cross(bentNormal,B));float a=square(square(1.0-anisotropy*(1.0-roughness)));bentNormal=normalize(mix(bentNormal,N,a));return bentNormal;}
|
|
318
|
+
#endif
|
|
319
|
+
#endif
|
|
320
|
+
#if defined(CLEARCOAT) || defined(SS_REFRACTION)
|
|
321
|
+
vec3 cocaLambert(vec3 alpha,float distance) {return exp(-alpha*distance);}
|
|
322
|
+
vec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {return cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));}
|
|
323
|
+
vec3 computeColorAtDistanceInMedia(vec3 color,float distance) {return -log(color)/distance;}
|
|
324
|
+
vec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {vec3 clearCoatAbsorption=mix(vec3(1.0),
|
|
325
|
+
cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),
|
|
326
|
+
clearCoatIntensity);return clearCoatAbsorption;}
|
|
327
|
+
#endif
|
|
328
|
+
#ifdef MICROSURFACEAUTOMATIC
|
|
329
|
+
float computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)
|
|
330
|
+
{const float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;float reflectivityLuminance=getLuminance(reflectivityColor);float reflectivityLuma=sqrt(reflectivityLuminance);microSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;return microSurface;}
|
|
331
|
+
#endif
|
|
332
|
+
`;
|
|
333
|
+
e.IncludesShadersStore[c] || (e.IncludesShadersStore[c] = k);
|
|
334
|
+
const l = "pbrDirectLightingSetupFunctions", w = `struct preLightingInfo
|
|
335
|
+
{vec3 lightOffset;float lightDistanceSquared;float lightDistance;float attenuation;vec3 L;vec3 H;float NdotV;float NdotLUnclamped;float NdotL;float VdotH;float LdotV;float roughness;float diffuseRoughness;vec3 surfaceAlbedo;
|
|
336
|
+
#ifdef IRIDESCENCE
|
|
337
|
+
float iridescenceIntensity;
|
|
338
|
+
#endif
|
|
339
|
+
#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
|
|
340
|
+
vec3 areaLightDiffuse;
|
|
341
|
+
#ifdef SPECULARTERM
|
|
342
|
+
vec3 areaLightSpecular;vec4 areaLightFresnel;
|
|
343
|
+
#endif
|
|
344
|
+
#endif
|
|
345
|
+
};preLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N,vec3 posW) {preLightingInfo result;result.lightOffset=lightData.xyz-posW;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);result.L=normalize(result.lightOffset);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);result.LdotV=0.;result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3(0.);return result;}
|
|
346
|
+
preLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {preLightingInfo result;result.lightDistance=length(-lightData.xyz);result.L=normalize(-lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);result.LdotV=dot(result.L,V);result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3(0.);return result;}
|
|
347
|
+
preLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {preLightingInfo result;result.NdotL=dot(N,lightData.xyz)*0.5+0.5;result.NdotL=saturateEps(result.NdotL);result.NdotLUnclamped=result.NdotL;
|
|
348
|
+
#ifdef SPECULARTERM
|
|
349
|
+
result.L=normalize(lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));
|
|
350
|
+
#endif
|
|
351
|
+
result.LdotV=0.;result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3(0.);return result;}
|
|
352
|
+
#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
|
|
353
|
+
#include<ltcHelperFunctions>
|
|
354
|
+
uniform sampler2D areaLightsLTC1Sampler;uniform sampler2D areaLightsLTC2Sampler;preLightingInfo computeAreaPreLightingInfo(sampler2D ltc1,sampler2D ltc2,vec3 viewDirectionW,vec3 vNormal,vec3 vPosition,vec4 lightData,vec3 halfWidth,vec3 halfHeight,float roughness )
|
|
355
|
+
{preLightingInfo result;result.lightOffset=lightData.xyz-vPosition;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);areaLightData data=computeAreaLightSpecularDiffuseFresnel(ltc1,ltc2,viewDirectionW,vNormal,vPosition,lightData.xyz,halfWidth,halfHeight,roughness);
|
|
356
|
+
#ifdef SPECULARTERM
|
|
357
|
+
result.areaLightFresnel=data.Fresnel;result.areaLightSpecular=data.Specular;
|
|
358
|
+
#endif
|
|
359
|
+
result.areaLightDiffuse=data.Diffuse;result.LdotV=0.;result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3(0.);return result;}
|
|
360
|
+
#endif
|
|
361
|
+
`;
|
|
362
|
+
e.IncludesShadersStore[l] || (e.IncludesShadersStore[l] = w);
|
|
363
|
+
const d = "pbrDirectLightingFalloffFunctions", z = `float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)
|
|
364
|
+
{return max(0.,1.0-length(lightOffset)/range);}
|
|
365
|
+
float computeDistanceLightFalloff_Physical(float lightDistanceSquared)
|
|
366
|
+
{return 1.0/maxEps(lightDistanceSquared);}
|
|
367
|
+
float computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)
|
|
368
|
+
{float lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);float factor=lightDistanceSquared*inverseSquaredRange;float attenuation=saturate(1.0-factor*factor);attenuation*=attenuation;lightDistanceFalloff*=attenuation;return lightDistanceFalloff;}
|
|
369
|
+
float computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)
|
|
370
|
+
{
|
|
371
|
+
#ifdef USEPHYSICALLIGHTFALLOFF
|
|
372
|
+
return computeDistanceLightFalloff_Physical(lightDistanceSquared);
|
|
373
|
+
#elif defined(USEGLTFLIGHTFALLOFF)
|
|
374
|
+
return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);
|
|
375
|
+
#else
|
|
376
|
+
return computeDistanceLightFalloff_Standard(lightOffset,range);
|
|
377
|
+
#endif
|
|
378
|
+
}
|
|
379
|
+
float computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)
|
|
380
|
+
{float falloff=0.0;float cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));if (cosAngle>=cosHalfAngle)
|
|
381
|
+
{falloff=max(0.,pow(cosAngle,exponent));}
|
|
382
|
+
return falloff;}
|
|
383
|
+
float computeDirectionalLightFalloff_IES(vec3 lightDirection,vec3 directionToLightCenterW,sampler2D iesLightSampler)
|
|
384
|
+
{float cosAngle=dot(-lightDirection,directionToLightCenterW);float angle=acos(cosAngle)/PI;return texture2D(iesLightSampler,vec2(angle,0.)).r;}
|
|
385
|
+
float computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)
|
|
386
|
+
{const float kMinusLog2ConeAngleIntensityRatio=6.64385618977;
|
|
387
|
+
float concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);vec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);float falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));return falloff;}
|
|
388
|
+
float computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)
|
|
389
|
+
{float cd=dot(-lightDirection,directionToLightCenterW);float falloff=saturate(cd*lightAngleScale+lightAngleOffset);falloff*=falloff;return falloff;}
|
|
390
|
+
float computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)
|
|
391
|
+
{
|
|
392
|
+
#ifdef USEPHYSICALLIGHTFALLOFF
|
|
393
|
+
return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);
|
|
394
|
+
#elif defined(USEGLTFLIGHTFALLOFF)
|
|
395
|
+
return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);
|
|
396
|
+
#else
|
|
397
|
+
return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);
|
|
398
|
+
#endif
|
|
399
|
+
}`;
|
|
400
|
+
e.IncludesShadersStore[d] || (e.IncludesShadersStore[d] = z);
|
|
401
|
+
const s = "hdrFilteringFunctions", K = `#if NUM_SAMPLES
|
|
402
|
+
#if NUM_SAMPLES>0
|
|
403
|
+
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
|
404
|
+
float radicalInverse_VdC(uint bits)
|
|
405
|
+
{bits=(bits<<16u) | (bits>>16u);bits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);bits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);bits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);bits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);return float(bits)*2.3283064365386963e-10; }
|
|
406
|
+
vec2 hammersley(uint i,uint N)
|
|
407
|
+
{return vec2(float(i)/float(N),radicalInverse_VdC(i));}
|
|
408
|
+
#else
|
|
409
|
+
float vanDerCorpus(int n,int base)
|
|
410
|
+
{float invBase=1.0/float(base);float denom =1.0;float result =0.0;for(int i=0; i<32; ++i)
|
|
411
|
+
{if(n>0)
|
|
412
|
+
{denom =mod(float(n),2.0);result+=denom*invBase;invBase=invBase/2.0;n =int(float(n)/2.0);}}
|
|
413
|
+
return result;}
|
|
414
|
+
vec2 hammersley(int i,int N)
|
|
415
|
+
{return vec2(float(i)/float(N),vanDerCorpus(i,2));}
|
|
416
|
+
#endif
|
|
417
|
+
float log4(float x) {return log2(x)/2.;}
|
|
418
|
+
vec3 uv_to_normal(vec2 uv) {vec3 N;vec2 uvRange=uv;float theta=uvRange.x*2.*PI;float phi=uvRange.y*PI;float sinPhi=sin(phi);N.x=cos(theta)*sinPhi;N.z=sin(theta)*sinPhi;N.y=cos(phi);return N;}
|
|
419
|
+
const float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);const float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;const float K=4.;
|
|
420
|
+
#define inline
|
|
421
|
+
vec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo,float diffuseRoughness,vec3 surfaceAlbedo,vec3 inputV
|
|
422
|
+
#if IBL_CDF_FILTERING
|
|
423
|
+
,sampler2D icdfSampler
|
|
424
|
+
#endif
|
|
425
|
+
)
|
|
426
|
+
{vec3 n=normalize(inputN);vec3 result=vec3(0.);
|
|
427
|
+
#ifndef IBL_CDF_FILTERING
|
|
428
|
+
vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);tangent=normalize(cross(tangent,n));vec3 bitangent=cross(n,tangent);mat3 tbn=mat3(tangent,bitangent,n);mat3 tbnInverse=mat3(tangent.x,bitangent.x,n.x,tangent.y,bitangent.y,n.y,tangent.z,bitangent.z,n.z);
|
|
429
|
+
#endif
|
|
430
|
+
float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float omegaP=(4.*PI)/(6.*dim0*dim0);vec3 clampedAlbedo=clamp(surfaceAlbedo,vec3(0.1),vec3(1.0));
|
|
431
|
+
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
|
432
|
+
for(uint i=0u; i<NUM_SAMPLES; ++i)
|
|
433
|
+
#else
|
|
434
|
+
for(int i=0; i<NUM_SAMPLES; ++i)
|
|
435
|
+
#endif
|
|
436
|
+
{vec2 Xi=hammersley(i,NUM_SAMPLES);
|
|
437
|
+
#if IBL_CDF_FILTERING
|
|
438
|
+
vec2 T;T.x=texture2D(icdfSampler,vec2(Xi.x,0.)).x;T.y=texture2D(icdfSampler,vec2(T.x,Xi.y)).y;vec3 Ls=uv_to_normal(vec2(1.0-fract(T.x+0.25),T.y));float NoL=dot(n,Ls);float NoV=dot(n,inputV);
|
|
439
|
+
#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
|
|
440
|
+
float LoV=dot (Ls,inputV);
|
|
441
|
+
#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
|
|
442
|
+
vec3 H=(inputV+Ls)*0.5;float VoH=dot(inputV,H);
|
|
443
|
+
#endif
|
|
444
|
+
#else
|
|
445
|
+
vec3 Ls=hemisphereCosSample(Xi);Ls=normalize(Ls);float NoL=Ls.z;
|
|
446
|
+
vec3 V=tbnInverse*inputV;float NoV=V.z;
|
|
447
|
+
#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
|
|
448
|
+
float LoV=dot (Ls,V);
|
|
449
|
+
#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
|
|
450
|
+
vec3 H=(V+Ls)*0.5;float VoH=dot(V,H);
|
|
451
|
+
#endif
|
|
452
|
+
#endif
|
|
453
|
+
if (NoL>0.) {
|
|
454
|
+
#if IBL_CDF_FILTERING
|
|
455
|
+
float pdf=texture2D(icdfSampler,T).z;vec3 c=textureCubeLodEXT(inputTexture,Ls,0.).rgb;
|
|
456
|
+
#else
|
|
457
|
+
float pdf_inversed=PI/NoL;float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(l,0.,maxLevel);vec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;
|
|
458
|
+
#endif
|
|
459
|
+
#if GAMMA_INPUT
|
|
460
|
+
c=toLinearSpace(c);
|
|
461
|
+
#endif
|
|
462
|
+
vec3 diffuseRoughnessTerm=vec3(1.0);
|
|
463
|
+
#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
|
|
464
|
+
diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;
|
|
465
|
+
#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
|
|
466
|
+
diffuseRoughnessTerm=vec3(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);
|
|
467
|
+
#endif
|
|
468
|
+
#if IBL_CDF_FILTERING
|
|
469
|
+
vec3 light=pdf<1e-6 ? vec3(0.0) : vec3(1.0)/vec3(pdf)*c;result+=NoL*diffuseRoughnessTerm*light;
|
|
470
|
+
#else
|
|
471
|
+
result+=c*diffuseRoughnessTerm;
|
|
472
|
+
#endif
|
|
473
|
+
}}
|
|
474
|
+
result=result*NUM_SAMPLES_FLOAT_INVERSED;
|
|
475
|
+
#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
|
|
476
|
+
result=result/clampedAlbedo;
|
|
477
|
+
#endif
|
|
478
|
+
return result;}
|
|
479
|
+
#define inline
|
|
480
|
+
vec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
|
|
481
|
+
{vec3 n=normalize(inputN);vec3 c=textureCube(inputTexture,n).rgb;
|
|
482
|
+
if (alphaG==0.) {
|
|
483
|
+
#if GAMMA_INPUT
|
|
484
|
+
c=toLinearSpace(c);
|
|
485
|
+
#endif
|
|
486
|
+
return c;} else {vec3 result=vec3(0.);vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);tangent=normalize(cross(tangent,n));vec3 bitangent=cross(n,tangent);mat3 tbn=mat3(tangent,bitangent,n);float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float omegaP=(4.*PI)/(6.*dim0*dim0);float weight=0.;
|
|
487
|
+
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
|
488
|
+
for(uint i=0u; i<NUM_SAMPLES; ++i)
|
|
489
|
+
#else
|
|
490
|
+
for(int i=0; i<NUM_SAMPLES; ++i)
|
|
491
|
+
#endif
|
|
492
|
+
{vec2 Xi=hammersley(i,NUM_SAMPLES);vec3 H=hemisphereImportanceSampleDggx(Xi,alphaG);float NoV=1.;float NoH=H.z;float NoH2=H.z*H.z;float NoL=2.*NoH2-1.;vec3 L=vec3(2.*NoH*H.x,2.*NoH*H.y,NoL);L=normalize(L);if (NoL>0.) {float pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(float(l),0.0,maxLevel);weight+=NoL;vec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;
|
|
493
|
+
#if GAMMA_INPUT
|
|
494
|
+
c=toLinearSpace(c);
|
|
495
|
+
#endif
|
|
496
|
+
result+=c*NoL;}}
|
|
497
|
+
result=result/weight;return result;}}
|
|
498
|
+
#endif
|
|
499
|
+
#endif
|
|
500
|
+
`;
|
|
501
|
+
e.IncludesShadersStore[s] || (e.IncludesShadersStore[s] = K);
|
|
502
|
+
const E = "pbrDirectLightingFunctions", $ = `#define CLEARCOATREFLECTANCE90 1.0
|
|
503
|
+
struct lightingInfo
|
|
504
|
+
{vec3 diffuse;
|
|
505
|
+
#ifdef SS_TRANSLUCENCY
|
|
506
|
+
vec3 diffuseTransmission;
|
|
507
|
+
#endif
|
|
508
|
+
#ifdef SPECULARTERM
|
|
509
|
+
vec3 specular;
|
|
510
|
+
#endif
|
|
511
|
+
#ifdef CLEARCOAT
|
|
512
|
+
vec4 clearCoat;
|
|
513
|
+
#endif
|
|
514
|
+
#ifdef SHEEN
|
|
515
|
+
vec3 sheen;
|
|
516
|
+
#endif
|
|
517
|
+
};float adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {
|
|
518
|
+
#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)
|
|
519
|
+
float lightRoughness=lightRadius/lightDistance;float totalRoughness=saturate(lightRoughness+roughness);return totalRoughness;
|
|
520
|
+
#else
|
|
521
|
+
return roughness;
|
|
522
|
+
#endif
|
|
523
|
+
}
|
|
524
|
+
vec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {return mix(groundColor,lightColor,info.NdotL);}
|
|
525
|
+
#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
|
|
526
|
+
vec3 computeAreaDiffuseLighting(preLightingInfo info,vec3 lightColor) {return info.areaLightDiffuse*lightColor;}
|
|
527
|
+
#endif
|
|
528
|
+
vec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {vec3 diffuseTerm=vec3(1.0/PI);
|
|
529
|
+
#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_LEGACY
|
|
530
|
+
diffuseTerm=vec3(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness));
|
|
531
|
+
#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
|
|
532
|
+
diffuseTerm=vec3(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.diffuseRoughness));
|
|
533
|
+
#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
|
|
534
|
+
vec3 clampedAlbedo=clamp(info.surfaceAlbedo,vec3(0.1),vec3(1.0));diffuseTerm=diffuseBRDF_EON(clampedAlbedo,info.diffuseRoughness,info.NdotL,info.NdotV,info.LdotV);diffuseTerm/=clampedAlbedo;
|
|
535
|
+
#endif
|
|
536
|
+
return diffuseTerm*info.attenuation*info.NdotL*lightColor;}
|
|
537
|
+
#define inline
|
|
538
|
+
vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix,vec3 posW){vec4 strq=textureProjectionMatrix*vec4(posW,1.0);strq/=strq.w;vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;return toLinearSpace(textureColor);}
|
|
539
|
+
#ifdef SS_TRANSLUCENCY
|
|
540
|
+
vec3 computeDiffuseTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {vec3 transmittanceNdotL=vec3(0.);float NdotL=absEps(info.NdotLUnclamped);
|
|
541
|
+
#ifndef SS_TRANSLUCENCY_LEGACY
|
|
542
|
+
if (info.NdotLUnclamped<0.0) {
|
|
543
|
+
#endif
|
|
544
|
+
float wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);float trAdapt=step(0.,info.NdotLUnclamped);transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);
|
|
545
|
+
#ifndef SS_TRANSLUCENCY_LEGACY
|
|
546
|
+
}
|
|
547
|
+
vec3 diffuseTerm=vec3(1.0/PI);
|
|
548
|
+
#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_LEGACY
|
|
549
|
+
diffuseTerm=vec3(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness));
|
|
550
|
+
#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
|
|
551
|
+
diffuseTerm=vec3(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.diffuseRoughness));
|
|
552
|
+
#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
|
|
553
|
+
vec3 clampedAlbedo=clamp(info.surfaceAlbedo,vec3(0.1),vec3(1.0));diffuseTerm=diffuseBRDF_EON(clampedAlbedo,info.diffuseRoughness,info.NdotL,info.NdotV,info.LdotV);diffuseTerm/=clampedAlbedo;
|
|
554
|
+
#endif
|
|
555
|
+
#else
|
|
556
|
+
float diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);
|
|
557
|
+
#endif
|
|
558
|
+
return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;}
|
|
559
|
+
#endif
|
|
560
|
+
#ifdef SPECULARTERM
|
|
561
|
+
vec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 fresnel,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float roughness=max(info.roughness,geometricRoughnessFactor);float alphaG=convertRoughnessToAverageSlope(roughness);
|
|
562
|
+
#ifdef IRIDESCENCE
|
|
563
|
+
fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity);
|
|
564
|
+
#endif
|
|
565
|
+
float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);
|
|
566
|
+
#ifdef BRDF_V_HEIGHT_CORRELATED
|
|
567
|
+
float smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);
|
|
568
|
+
#else
|
|
569
|
+
float smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);
|
|
570
|
+
#endif
|
|
571
|
+
vec3 specTerm=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;}
|
|
572
|
+
#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
|
|
573
|
+
vec3 computeAreaSpecularLighting(preLightingInfo info,vec3 specularColor,vec3 reflectance0,vec3 reflectance90) {vec3 fresnel=specularColor*info.areaLightFresnel.x*reflectance0+( vec3( 1.0 )-specularColor )*info.areaLightFresnel.y*reflectance90;return specularColor*fresnel*info.areaLightSpecular;}
|
|
574
|
+
#endif
|
|
575
|
+
#endif
|
|
576
|
+
#ifdef ANISOTROPIC
|
|
577
|
+
vec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float TdotH=dot(T,info.H);float BdotH=dot(B,info.H);float TdotV=dot(T,V);float BdotV=dot(B,V);float TdotL=dot(T,info.L);float BdotL=dot(B,info.L);float alphaG=convertRoughnessToAverageSlope(info.roughness);vec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);alphaTB=max(alphaTB,square(geometricRoughnessFactor));vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);
|
|
578
|
+
#ifdef IRIDESCENCE
|
|
579
|
+
fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity);
|
|
580
|
+
#endif
|
|
581
|
+
float distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);float smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);vec3 specTerm=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;}
|
|
582
|
+
#endif
|
|
583
|
+
#ifdef CLEARCOAT
|
|
584
|
+
vec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {float NccdotL=saturateEps(dot(Ncc,info.L));float NccdotH=saturateEps(dot(Ncc,info.H));float clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);float alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);float fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnel*=clearCoatIntensity;float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);float kelemenVisibility=visibility_Kelemen(info.VdotH);float clearCoatTerm=fresnel*distribution*kelemenVisibility;return vec4(
|
|
585
|
+
clearCoatTerm*info.attenuation*NccdotL*lightColor,
|
|
586
|
+
1.0-fresnel
|
|
587
|
+
);}
|
|
588
|
+
vec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {vec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);float NdotLRefract=saturateEps(dot(Ncc,LRefract));vec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);return absorption;}
|
|
589
|
+
#endif
|
|
590
|
+
#ifdef SHEEN
|
|
591
|
+
vec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float roughness=max(info.roughness,geometricRoughnessFactor);float alphaG=convertRoughnessToAverageSlope(roughness);float fresnel=1.;float distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);/*#ifdef SHEEN_SOFTER
|
|
592
|
+
float visibility=visibility_CharlieSheen(info.NdotL,info.NdotV,alphaG);
|
|
593
|
+
#else */
|
|
594
|
+
float visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);/* #endif */
|
|
595
|
+
float sheenTerm=fresnel*distribution*visibility;return sheenTerm*info.attenuation*info.NdotL*lightColor;}
|
|
596
|
+
#endif
|
|
597
|
+
`;
|
|
598
|
+
e.IncludesShadersStore[E] || (e.IncludesShadersStore[E] = $);
|
|
599
|
+
const R = "pbrIBLFunctions", q = `#if defined(REFLECTION) || defined(SS_REFRACTION)
|
|
600
|
+
float getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {float microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;float lod=log2(microsurfaceAverageSlopeTexels);return lod;}
|
|
601
|
+
float getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {float lod=log2(cubeMapDimensionPixels)*roughness;return lod;}
|
|
602
|
+
#endif
|
|
603
|
+
#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)
|
|
604
|
+
float environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {float temp=NdotVUnclamped+ambientOcclusion;return saturate(square(temp)-1.0+ambientOcclusion);}
|
|
605
|
+
#endif
|
|
606
|
+
#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)
|
|
607
|
+
float environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) {vec3 reflection=reflect(view,normal);float temp=saturate(1.0+1.1*dot(reflection,geometricNormal));return square(temp);}
|
|
608
|
+
#endif
|
|
609
|
+
#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)
|
|
610
|
+
#define UNPACK_LOD(x) (1.0-x)*255.0
|
|
611
|
+
float getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {float microsurfaceAverageSlope=alphaG;microsurfaceAverageSlope*=sqrt(abs(NdotV));return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);}
|
|
612
|
+
#endif
|
|
613
|
+
`;
|
|
614
|
+
e.IncludesShadersStore[R] || (e.IncludesShadersStore[R] = q);
|
|
615
|
+
const u = "pbrBlockAlbedoOpacity", Z = `struct albedoOpacityOutParams
|
|
616
|
+
{vec3 surfaceAlbedo;float alpha;};
|
|
617
|
+
#define pbr_inline
|
|
618
|
+
albedoOpacityOutParams albedoOpacityBlock(
|
|
619
|
+
in vec4 vAlbedoColor
|
|
620
|
+
#ifdef ALBEDO
|
|
621
|
+
,in vec4 albedoTexture
|
|
622
|
+
,in vec2 albedoInfos
|
|
623
|
+
#endif
|
|
624
|
+
,in float baseWeight
|
|
625
|
+
#ifdef BASE_WEIGHT
|
|
626
|
+
,in vec4 baseWeightTexture
|
|
627
|
+
,in vec2 vBaseWeightInfos
|
|
628
|
+
#endif
|
|
629
|
+
#ifdef OPACITY
|
|
630
|
+
,in vec4 opacityMap
|
|
631
|
+
,in vec2 vOpacityInfos
|
|
632
|
+
#endif
|
|
633
|
+
#ifdef DETAIL
|
|
634
|
+
,in vec4 detailColor
|
|
635
|
+
,in vec4 vDetailInfos
|
|
636
|
+
#endif
|
|
637
|
+
#ifdef DECAL
|
|
638
|
+
,in vec4 decalColor
|
|
639
|
+
,in vec4 vDecalInfos
|
|
640
|
+
#endif
|
|
641
|
+
)
|
|
642
|
+
{albedoOpacityOutParams outParams;vec3 surfaceAlbedo=vAlbedoColor.rgb;float alpha=vAlbedoColor.a;
|
|
643
|
+
#ifdef ALBEDO
|
|
644
|
+
#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)
|
|
645
|
+
alpha*=albedoTexture.a;
|
|
646
|
+
#endif
|
|
647
|
+
#ifdef GAMMAALBEDO
|
|
648
|
+
surfaceAlbedo*=toLinearSpace(albedoTexture.rgb);
|
|
649
|
+
#else
|
|
650
|
+
surfaceAlbedo*=albedoTexture.rgb;
|
|
651
|
+
#endif
|
|
652
|
+
surfaceAlbedo*=albedoInfos.y;
|
|
653
|
+
#endif
|
|
654
|
+
#ifndef DECAL_AFTER_DETAIL
|
|
655
|
+
#include<decalFragment>
|
|
656
|
+
#endif
|
|
657
|
+
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
|
658
|
+
surfaceAlbedo*=vColor.rgb;
|
|
659
|
+
#endif
|
|
660
|
+
#ifdef DETAIL
|
|
661
|
+
float detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);surfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo;
|
|
662
|
+
#endif
|
|
663
|
+
#ifdef DECAL_AFTER_DETAIL
|
|
664
|
+
#include<decalFragment>
|
|
665
|
+
#endif
|
|
666
|
+
#define CUSTOM_FRAGMENT_UPDATE_ALBEDO
|
|
667
|
+
surfaceAlbedo*=baseWeight;
|
|
668
|
+
#ifdef BASE_WEIGHT
|
|
669
|
+
surfaceAlbedo*=baseWeightTexture.r;
|
|
670
|
+
#endif
|
|
671
|
+
#ifdef OPACITY
|
|
672
|
+
#ifdef OPACITYRGB
|
|
673
|
+
alpha=getLuminance(opacityMap.rgb);
|
|
674
|
+
#else
|
|
675
|
+
alpha*=opacityMap.a;
|
|
676
|
+
#endif
|
|
677
|
+
alpha*=vOpacityInfos.y;
|
|
678
|
+
#endif
|
|
679
|
+
#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
|
680
|
+
alpha*=vColor.a;
|
|
681
|
+
#endif
|
|
682
|
+
#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)
|
|
683
|
+
#ifdef ALPHATEST
|
|
684
|
+
#if DEBUGMODE != 88
|
|
685
|
+
if (alpha<ALPHATESTVALUE)
|
|
686
|
+
discard;
|
|
687
|
+
#endif
|
|
688
|
+
#ifndef ALPHABLEND
|
|
689
|
+
alpha=1.0;
|
|
690
|
+
#endif
|
|
691
|
+
#endif
|
|
692
|
+
#endif
|
|
693
|
+
outParams.surfaceAlbedo=surfaceAlbedo;outParams.alpha=alpha;return outParams;}
|
|
694
|
+
`;
|
|
695
|
+
e.IncludesShadersStore[u] || (e.IncludesShadersStore[u] = Z);
|
|
696
|
+
const C = "pbrBlockReflectivity", J = `struct reflectivityOutParams
|
|
697
|
+
{float microSurface;float roughness;float diffuseRoughness;float reflectanceF0;vec3 reflectanceF90;vec3 colorReflectanceF0;vec3 colorReflectanceF90;
|
|
698
|
+
#ifdef METALLICWORKFLOW
|
|
699
|
+
vec3 surfaceAlbedo;float metallic;float specularWeight;vec3 dielectricColorF0;
|
|
700
|
+
#endif
|
|
701
|
+
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
|
|
702
|
+
vec3 ambientOcclusionColor;
|
|
703
|
+
#endif
|
|
704
|
+
#if DEBUGMODE>0
|
|
705
|
+
#ifdef METALLICWORKFLOW
|
|
706
|
+
#ifdef REFLECTIVITY
|
|
707
|
+
vec4 surfaceMetallicColorMap;
|
|
708
|
+
#endif
|
|
709
|
+
vec3 metallicF0;
|
|
710
|
+
#else
|
|
711
|
+
#ifdef REFLECTIVITY
|
|
712
|
+
vec4 surfaceReflectivityColorMap;
|
|
713
|
+
#endif
|
|
714
|
+
#endif
|
|
715
|
+
#endif
|
|
716
|
+
};
|
|
717
|
+
#define pbr_inline
|
|
718
|
+
reflectivityOutParams reflectivityBlock(
|
|
719
|
+
in vec4 reflectivityColor
|
|
720
|
+
#ifdef METALLICWORKFLOW
|
|
721
|
+
,in vec3 surfaceAlbedo
|
|
722
|
+
,in vec4 metallicReflectanceFactors
|
|
723
|
+
#endif
|
|
724
|
+
,in float baseDiffuseRoughness
|
|
725
|
+
#ifdef BASE_DIFFUSE_ROUGHNESS
|
|
726
|
+
,in float baseDiffuseRoughnessTexture
|
|
727
|
+
,in vec2 baseDiffuseRoughnessInfos
|
|
728
|
+
#endif
|
|
729
|
+
#ifdef REFLECTIVITY
|
|
730
|
+
,in vec3 reflectivityInfos
|
|
731
|
+
,in vec4 surfaceMetallicOrReflectivityColorMap
|
|
732
|
+
#endif
|
|
733
|
+
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
|
|
734
|
+
,in vec3 ambientOcclusionColorIn
|
|
735
|
+
#endif
|
|
736
|
+
#ifdef MICROSURFACEMAP
|
|
737
|
+
,in vec4 microSurfaceTexel
|
|
738
|
+
#endif
|
|
739
|
+
#ifdef DETAIL
|
|
740
|
+
,in vec4 detailColor
|
|
741
|
+
,in vec4 vDetailInfos
|
|
742
|
+
#endif
|
|
743
|
+
)
|
|
744
|
+
{reflectivityOutParams outParams;float microSurface=reflectivityColor.a;vec3 surfaceReflectivityColor=reflectivityColor.rgb;
|
|
745
|
+
#ifdef METALLICWORKFLOW
|
|
746
|
+
vec2 metallicRoughness=surfaceReflectivityColor.rg;float ior=surfaceReflectivityColor.b;
|
|
747
|
+
#ifdef REFLECTIVITY
|
|
748
|
+
#if DEBUGMODE>0
|
|
749
|
+
outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;
|
|
750
|
+
#endif
|
|
751
|
+
#ifdef AOSTOREINMETALMAPRED
|
|
752
|
+
vec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);
|
|
753
|
+
#endif
|
|
754
|
+
#ifdef METALLNESSSTOREINMETALMAPBLUE
|
|
755
|
+
metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;
|
|
756
|
+
#else
|
|
757
|
+
metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;
|
|
758
|
+
#endif
|
|
759
|
+
#ifdef ROUGHNESSSTOREINMETALMAPALPHA
|
|
760
|
+
metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;
|
|
761
|
+
#else
|
|
762
|
+
#ifdef ROUGHNESSSTOREINMETALMAPGREEN
|
|
763
|
+
metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;
|
|
764
|
+
#endif
|
|
765
|
+
#endif
|
|
766
|
+
#endif
|
|
767
|
+
#ifdef DETAIL
|
|
768
|
+
float detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);float loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.);float hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));
|
|
769
|
+
#endif
|
|
770
|
+
#ifdef MICROSURFACEMAP
|
|
771
|
+
metallicRoughness.g*=microSurfaceTexel.r;
|
|
772
|
+
#endif
|
|
773
|
+
#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS
|
|
774
|
+
microSurface=1.0-metallicRoughness.g;vec3 baseColor=surfaceAlbedo;outParams.metallic=metallicRoughness.r;outParams.specularWeight=metallicReflectanceFactors.a;float dielectricF0=reflectivityColor.a*outParams.specularWeight;surfaceReflectivityColor=metallicReflectanceFactors.rgb;
|
|
775
|
+
#if DEBUGMODE>0
|
|
776
|
+
outParams.metallicF0=vec3(dielectricF0)*surfaceReflectivityColor;
|
|
777
|
+
#endif
|
|
778
|
+
#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
|
|
779
|
+
outParams.surfaceAlbedo=baseColor.rgb*(vec3(1.0)-vec3(dielectricF0)*surfaceReflectivityColor)*(1.0-outParams.metallic);
|
|
780
|
+
#else
|
|
781
|
+
outParams.surfaceAlbedo=baseColor.rgb;
|
|
782
|
+
#endif
|
|
783
|
+
#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
|
|
784
|
+
{vec3 reflectivityColor=mix(dielectricF0*surfaceReflectivityColor,baseColor.rgb,outParams.metallic);outParams.reflectanceF0=max(reflectivityColor.r,max(reflectivityColor.g,reflectivityColor.b));}
|
|
785
|
+
#else
|
|
786
|
+
#if DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_GLTF
|
|
787
|
+
float maxF0=max(surfaceReflectivityColor.r,max(surfaceReflectivityColor.g,surfaceReflectivityColor.b));outParams.reflectanceF0=mix(dielectricF0*maxF0,1.0,outParams.metallic);
|
|
788
|
+
#else
|
|
789
|
+
outParams.reflectanceF0=mix(dielectricF0,1.0,outParams.metallic);
|
|
790
|
+
#endif
|
|
791
|
+
#endif
|
|
792
|
+
#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
|
|
793
|
+
outParams.reflectanceF90=vec3(outParams.specularWeight);float f90Scale=1.0;
|
|
794
|
+
#else
|
|
795
|
+
float f90Scale=clamp(2.0*(ior-1.0),0.0,1.0);outParams.reflectanceF90=vec3(mix(outParams.specularWeight*f90Scale,1.0,outParams.metallic));
|
|
796
|
+
#endif
|
|
797
|
+
outParams.dielectricColorF0=vec3(dielectricF0*surfaceReflectivityColor);vec3 metallicColorF0=baseColor.rgb;outParams.colorReflectanceF0=mix(outParams.dielectricColorF0,metallicColorF0,outParams.metallic);
|
|
798
|
+
#if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR)
|
|
799
|
+
vec3 dielectricColorF90=surfaceReflectivityColor*vec3(outParams.specularWeight)*vec3(f90Scale);
|
|
800
|
+
#else
|
|
801
|
+
vec3 dielectricColorF90=vec3(outParams.specularWeight*f90Scale);
|
|
802
|
+
#endif
|
|
803
|
+
#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
|
|
804
|
+
vec3 conductorColorF90=surfaceReflectivityColor;
|
|
805
|
+
#else
|
|
806
|
+
#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
|
|
807
|
+
vec3 conductorColorF90=outParams.reflectanceF90;
|
|
808
|
+
#else
|
|
809
|
+
vec3 conductorColorF90=vec3(1.0);
|
|
810
|
+
#endif
|
|
811
|
+
#endif
|
|
812
|
+
outParams.colorReflectanceF90=mix(dielectricColorF90,conductorColorF90,outParams.metallic);
|
|
813
|
+
#else
|
|
814
|
+
#ifdef REFLECTIVITY
|
|
815
|
+
surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;
|
|
816
|
+
#if DEBUGMODE>0
|
|
817
|
+
outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;
|
|
818
|
+
#endif
|
|
819
|
+
#ifdef MICROSURFACEFROMREFLECTIVITYMAP
|
|
820
|
+
microSurface*=surfaceMetallicOrReflectivityColorMap.a;microSurface*=reflectivityInfos.z;
|
|
821
|
+
#else
|
|
822
|
+
#ifdef MICROSURFACEAUTOMATIC
|
|
823
|
+
microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);
|
|
824
|
+
#endif
|
|
825
|
+
#ifdef MICROSURFACEMAP
|
|
826
|
+
microSurface*=microSurfaceTexel.r;
|
|
827
|
+
#endif
|
|
828
|
+
#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE
|
|
829
|
+
#endif
|
|
830
|
+
#endif
|
|
831
|
+
outParams.colorReflectanceF0=surfaceReflectivityColor;outParams.reflectanceF0=max(surfaceReflectivityColor.r,max(surfaceReflectivityColor.g,surfaceReflectivityColor.b));outParams.reflectanceF90=vec3(1.0);
|
|
832
|
+
#if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR)
|
|
833
|
+
outParams.colorReflectanceF90=surfaceReflectivityColor;
|
|
834
|
+
#else
|
|
835
|
+
outParams.colorReflectanceF90=vec3(1.0);
|
|
836
|
+
#endif
|
|
837
|
+
#endif
|
|
838
|
+
microSurface=saturate(microSurface);float roughness=1.-microSurface;float diffuseRoughness=baseDiffuseRoughness;
|
|
839
|
+
#ifdef BASE_DIFFUSE_ROUGHNESS
|
|
840
|
+
diffuseRoughness*=baseDiffuseRoughnessTexture*baseDiffuseRoughnessInfos.y;
|
|
841
|
+
#endif
|
|
842
|
+
outParams.microSurface=microSurface;outParams.roughness=roughness;outParams.diffuseRoughness=diffuseRoughness;return outParams;}
|
|
843
|
+
`;
|
|
844
|
+
e.IncludesShadersStore[C] || (e.IncludesShadersStore[C] = J);
|
|
845
|
+
const S = "pbrBlockAmbientOcclusion", j = `struct ambientOcclusionOutParams
|
|
846
|
+
{vec3 ambientOcclusionColor;
|
|
847
|
+
#if DEBUGMODE>0 && defined(AMBIENT)
|
|
848
|
+
vec3 ambientOcclusionColorMap;
|
|
849
|
+
#endif
|
|
850
|
+
};ambientOcclusionOutParams ambientOcclusionBlock(
|
|
851
|
+
#ifdef AMBIENT
|
|
852
|
+
in vec3 ambientOcclusionColorMap_,
|
|
853
|
+
in vec4 vAmbientInfos
|
|
854
|
+
#endif
|
|
855
|
+
)
|
|
856
|
+
{ambientOcclusionOutParams outParams;vec3 ambientOcclusionColor=vec3(1.,1.,1.);
|
|
857
|
+
#ifdef AMBIENT
|
|
858
|
+
vec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y;
|
|
859
|
+
#ifdef AMBIENTINGRAYSCALE
|
|
860
|
+
ambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);
|
|
861
|
+
#endif
|
|
862
|
+
ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);
|
|
863
|
+
#if DEBUGMODE>0
|
|
864
|
+
outParams.ambientOcclusionColorMap=ambientOcclusionColorMap;
|
|
865
|
+
#endif
|
|
866
|
+
#endif
|
|
867
|
+
outParams.ambientOcclusionColor=ambientOcclusionColor;return outParams;}
|
|
868
|
+
`;
|
|
869
|
+
e.IncludesShadersStore[S] || (e.IncludesShadersStore[S] = j);
|
|
870
|
+
const A = "pbrBlockAlphaFresnel", Q = `#ifdef ALPHAFRESNEL
|
|
871
|
+
#if defined(ALPHATEST) || defined(ALPHABLEND)
|
|
872
|
+
struct alphaFresnelOutParams
|
|
873
|
+
{float alpha;};
|
|
874
|
+
#define pbr_inline
|
|
875
|
+
alphaFresnelOutParams alphaFresnelBlock(
|
|
876
|
+
in vec3 normalW,
|
|
877
|
+
in vec3 viewDirectionW,
|
|
878
|
+
in float alpha,
|
|
879
|
+
in float microSurface
|
|
880
|
+
)
|
|
881
|
+
{alphaFresnelOutParams outParams;float opacityPerceptual=alpha;
|
|
882
|
+
#ifdef LINEARALPHAFRESNEL
|
|
883
|
+
float opacity0=opacityPerceptual;
|
|
884
|
+
#else
|
|
885
|
+
float opacity0=opacityPerceptual*opacityPerceptual;
|
|
886
|
+
#endif
|
|
887
|
+
float opacity90=fresnelGrazingReflectance(opacity0);vec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;
|
|
888
|
+
#ifdef ALPHATEST
|
|
889
|
+
if (outParams.alpha<ALPHATESTVALUE)
|
|
890
|
+
discard;
|
|
891
|
+
#ifndef ALPHABLEND
|
|
892
|
+
outParams.alpha=1.0;
|
|
893
|
+
#endif
|
|
894
|
+
#endif
|
|
895
|
+
return outParams;}
|
|
896
|
+
#endif
|
|
897
|
+
#endif
|
|
898
|
+
`;
|
|
899
|
+
e.IncludesShadersStore[A] || (e.IncludesShadersStore[A] = Q);
|
|
900
|
+
const m = "pbrBlockAnisotropic", ee = `#ifdef ANISOTROPIC
|
|
901
|
+
struct anisotropicOutParams
|
|
902
|
+
{float anisotropy;vec3 anisotropicTangent;vec3 anisotropicBitangent;vec3 anisotropicNormal;
|
|
903
|
+
#if DEBUGMODE>0 && defined(ANISOTROPIC_TEXTURE)
|
|
904
|
+
vec3 anisotropyMapData;
|
|
905
|
+
#endif
|
|
906
|
+
};
|
|
907
|
+
#define pbr_inline
|
|
908
|
+
anisotropicOutParams anisotropicBlock(
|
|
909
|
+
in vec3 vAnisotropy,
|
|
910
|
+
in float roughness,
|
|
911
|
+
#ifdef ANISOTROPIC_TEXTURE
|
|
912
|
+
in vec3 anisotropyMapData,
|
|
913
|
+
#endif
|
|
914
|
+
in mat3 TBN,
|
|
915
|
+
in vec3 normalW,
|
|
916
|
+
in vec3 viewDirectionW
|
|
917
|
+
)
|
|
918
|
+
{anisotropicOutParams outParams;float anisotropy=vAnisotropy.b;vec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);
|
|
919
|
+
#ifdef ANISOTROPIC_TEXTURE
|
|
920
|
+
anisotropy*=anisotropyMapData.b;
|
|
921
|
+
#if DEBUGMODE>0
|
|
922
|
+
outParams.anisotropyMapData=anisotropyMapData;
|
|
923
|
+
#endif
|
|
924
|
+
anisotropyMapData.rg=anisotropyMapData.rg*2.0-1.0;
|
|
925
|
+
#ifdef ANISOTROPIC_LEGACY
|
|
926
|
+
anisotropyDirection.rg*=anisotropyMapData.rg;
|
|
927
|
+
#else
|
|
928
|
+
anisotropyDirection.xy=mat2(anisotropyDirection.x,anisotropyDirection.y,-anisotropyDirection.y,anisotropyDirection.x)*normalize(anisotropyMapData.rg);
|
|
929
|
+
#endif
|
|
930
|
+
#endif
|
|
931
|
+
mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));vec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);vec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));outParams.anisotropy=anisotropy;outParams.anisotropicTangent=anisotropicTangent;outParams.anisotropicBitangent=anisotropicBitangent;outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy,roughness);return outParams;}
|
|
932
|
+
#endif
|
|
933
|
+
`;
|
|
934
|
+
e.IncludesShadersStore[m] || (e.IncludesShadersStore[m] = ee);
|
|
935
|
+
const I = "pbrBlockReflection", ie = `#ifdef REFLECTION
|
|
936
|
+
struct reflectionOutParams
|
|
937
|
+
{vec4 environmentRadiance;vec3 environmentIrradiance;
|
|
938
|
+
#ifdef REFLECTIONMAP_3D
|
|
939
|
+
vec3 reflectionCoords;
|
|
940
|
+
#else
|
|
941
|
+
vec2 reflectionCoords;
|
|
942
|
+
#endif
|
|
943
|
+
#ifdef SS_TRANSLUCENCY
|
|
944
|
+
#ifdef USESPHERICALFROMREFLECTIONMAP
|
|
945
|
+
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
|
|
946
|
+
vec3 irradianceVector;
|
|
947
|
+
#endif
|
|
948
|
+
#endif
|
|
949
|
+
#endif
|
|
950
|
+
};
|
|
951
|
+
#define pbr_inline
|
|
952
|
+
void createReflectionCoords(
|
|
953
|
+
in vec3 vPositionW,
|
|
954
|
+
in vec3 normalW,
|
|
955
|
+
#ifdef ANISOTROPIC
|
|
956
|
+
in anisotropicOutParams anisotropicOut,
|
|
957
|
+
#endif
|
|
958
|
+
#ifdef REFLECTIONMAP_3D
|
|
959
|
+
out vec3 reflectionCoords
|
|
960
|
+
#else
|
|
961
|
+
out vec2 reflectionCoords
|
|
962
|
+
#endif
|
|
963
|
+
)
|
|
964
|
+
{
|
|
965
|
+
#ifdef ANISOTROPIC
|
|
966
|
+
vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal);
|
|
967
|
+
#else
|
|
968
|
+
vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
|
|
969
|
+
#endif
|
|
970
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
971
|
+
reflectionVector.z*=-1.0;
|
|
972
|
+
#endif
|
|
973
|
+
#ifdef REFLECTIONMAP_3D
|
|
974
|
+
reflectionCoords=reflectionVector;
|
|
975
|
+
#else
|
|
976
|
+
reflectionCoords=reflectionVector.xy;
|
|
977
|
+
#ifdef REFLECTIONMAP_PROJECTION
|
|
978
|
+
reflectionCoords/=reflectionVector.z;
|
|
979
|
+
#endif
|
|
980
|
+
reflectionCoords.y=1.0-reflectionCoords.y;
|
|
981
|
+
#endif
|
|
982
|
+
}
|
|
983
|
+
#define pbr_inline
|
|
984
|
+
#define inline
|
|
985
|
+
void sampleReflectionTexture(
|
|
986
|
+
in float alphaG,
|
|
987
|
+
in vec3 vReflectionMicrosurfaceInfos,
|
|
988
|
+
in vec2 vReflectionInfos,
|
|
989
|
+
in vec3 vReflectionColor,
|
|
990
|
+
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
|
991
|
+
in float NdotVUnclamped,
|
|
992
|
+
#endif
|
|
993
|
+
#ifdef LINEARSPECULARREFLECTION
|
|
994
|
+
in float roughness,
|
|
995
|
+
#endif
|
|
996
|
+
#ifdef REFLECTIONMAP_3D
|
|
997
|
+
in samplerCube reflectionSampler,
|
|
998
|
+
const vec3 reflectionCoords,
|
|
999
|
+
#else
|
|
1000
|
+
in sampler2D reflectionSampler,
|
|
1001
|
+
const vec2 reflectionCoords,
|
|
1002
|
+
#endif
|
|
1003
|
+
#ifndef LODBASEDMICROSFURACE
|
|
1004
|
+
#ifdef REFLECTIONMAP_3D
|
|
1005
|
+
in samplerCube reflectionSamplerLow,
|
|
1006
|
+
in samplerCube reflectionSamplerHigh,
|
|
1007
|
+
#else
|
|
1008
|
+
in sampler2D reflectionSamplerLow,
|
|
1009
|
+
in sampler2D reflectionSamplerHigh,
|
|
1010
|
+
#endif
|
|
1011
|
+
#endif
|
|
1012
|
+
#ifdef REALTIME_FILTERING
|
|
1013
|
+
in vec2 vReflectionFilteringInfo,
|
|
1014
|
+
#endif
|
|
1015
|
+
out vec4 environmentRadiance
|
|
1016
|
+
)
|
|
1017
|
+
{
|
|
1018
|
+
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
|
1019
|
+
float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);
|
|
1020
|
+
#elif defined(LINEARSPECULARREFLECTION)
|
|
1021
|
+
float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);
|
|
1022
|
+
#else
|
|
1023
|
+
float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);
|
|
1024
|
+
#endif
|
|
1025
|
+
#ifdef LODBASEDMICROSFURACE
|
|
1026
|
+
reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
|
|
1027
|
+
#ifdef LODINREFLECTIONALPHA
|
|
1028
|
+
float automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);float requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);
|
|
1029
|
+
#else
|
|
1030
|
+
float requestedReflectionLOD=reflectionLOD;
|
|
1031
|
+
#endif
|
|
1032
|
+
#ifdef REALTIME_FILTERING
|
|
1033
|
+
environmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);
|
|
1034
|
+
#else
|
|
1035
|
+
environmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
|
|
1036
|
+
#endif
|
|
1037
|
+
#else
|
|
1038
|
+
float lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;vec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);if (lodReflectionNormalizedDoubled<1.0){environmentRadiance=mix(
|
|
1039
|
+
sampleReflection(reflectionSamplerHigh,reflectionCoords),
|
|
1040
|
+
environmentMid,
|
|
1041
|
+
lodReflectionNormalizedDoubled
|
|
1042
|
+
);} else {environmentRadiance=mix(
|
|
1043
|
+
environmentMid,
|
|
1044
|
+
sampleReflection(reflectionSamplerLow,reflectionCoords),
|
|
1045
|
+
lodReflectionNormalizedDoubled-1.0
|
|
1046
|
+
);}
|
|
1047
|
+
#endif
|
|
1048
|
+
#ifdef RGBDREFLECTION
|
|
1049
|
+
environmentRadiance.rgb=fromRGBD(environmentRadiance);
|
|
1050
|
+
#endif
|
|
1051
|
+
#ifdef GAMMAREFLECTION
|
|
1052
|
+
environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);
|
|
1053
|
+
#endif
|
|
1054
|
+
environmentRadiance.rgb*=vReflectionInfos.x;environmentRadiance.rgb*=vReflectionColor.rgb;}
|
|
1055
|
+
#define pbr_inline
|
|
1056
|
+
#define inline
|
|
1057
|
+
reflectionOutParams reflectionBlock(
|
|
1058
|
+
in vec3 vPositionW
|
|
1059
|
+
,in vec3 normalW
|
|
1060
|
+
,in float alphaG
|
|
1061
|
+
,in vec3 vReflectionMicrosurfaceInfos
|
|
1062
|
+
,in vec2 vReflectionInfos
|
|
1063
|
+
,in vec3 vReflectionColor
|
|
1064
|
+
#ifdef ANISOTROPIC
|
|
1065
|
+
,in anisotropicOutParams anisotropicOut
|
|
1066
|
+
#endif
|
|
1067
|
+
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
|
1068
|
+
,in float NdotVUnclamped
|
|
1069
|
+
#endif
|
|
1070
|
+
#ifdef LINEARSPECULARREFLECTION
|
|
1071
|
+
,in float roughness
|
|
1072
|
+
#endif
|
|
1073
|
+
#ifdef REFLECTIONMAP_3D
|
|
1074
|
+
,in samplerCube reflectionSampler
|
|
1075
|
+
#else
|
|
1076
|
+
,in sampler2D reflectionSampler
|
|
1077
|
+
#endif
|
|
1078
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
1079
|
+
,in vec3 vEnvironmentIrradiance
|
|
1080
|
+
#endif
|
|
1081
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
1082
|
+
,in mat4 reflectionMatrix
|
|
1083
|
+
#endif
|
|
1084
|
+
#ifdef USEIRRADIANCEMAP
|
|
1085
|
+
#ifdef REFLECTIONMAP_3D
|
|
1086
|
+
,in samplerCube irradianceSampler
|
|
1087
|
+
#else
|
|
1088
|
+
,in sampler2D irradianceSampler
|
|
1089
|
+
#endif
|
|
1090
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
1091
|
+
,in vec3 reflectionDominantDirection
|
|
1092
|
+
#endif
|
|
1093
|
+
#endif
|
|
1094
|
+
#ifndef LODBASEDMICROSFURACE
|
|
1095
|
+
#ifdef REFLECTIONMAP_3D
|
|
1096
|
+
,in samplerCube reflectionSamplerLow
|
|
1097
|
+
,in samplerCube reflectionSamplerHigh
|
|
1098
|
+
#else
|
|
1099
|
+
,in sampler2D reflectionSamplerLow
|
|
1100
|
+
,in sampler2D reflectionSamplerHigh
|
|
1101
|
+
#endif
|
|
1102
|
+
#endif
|
|
1103
|
+
#ifdef REALTIME_FILTERING
|
|
1104
|
+
,in vec2 vReflectionFilteringInfo
|
|
1105
|
+
#ifdef IBL_CDF_FILTERING
|
|
1106
|
+
,in sampler2D icdfSampler
|
|
1107
|
+
#endif
|
|
1108
|
+
#endif
|
|
1109
|
+
,in vec3 viewDirectionW
|
|
1110
|
+
,in float diffuseRoughness
|
|
1111
|
+
,in vec3 surfaceAlbedo
|
|
1112
|
+
)
|
|
1113
|
+
{reflectionOutParams outParams;vec4 environmentRadiance=vec4(0.,0.,0.,0.);
|
|
1114
|
+
#ifdef REFLECTIONMAP_3D
|
|
1115
|
+
vec3 reflectionCoords=vec3(0.);
|
|
1116
|
+
#else
|
|
1117
|
+
vec2 reflectionCoords=vec2(0.);
|
|
1118
|
+
#endif
|
|
1119
|
+
createReflectionCoords(
|
|
1120
|
+
vPositionW,
|
|
1121
|
+
normalW,
|
|
1122
|
+
#ifdef ANISOTROPIC
|
|
1123
|
+
anisotropicOut,
|
|
1124
|
+
#endif
|
|
1125
|
+
reflectionCoords
|
|
1126
|
+
);sampleReflectionTexture(
|
|
1127
|
+
alphaG,
|
|
1128
|
+
vReflectionMicrosurfaceInfos,
|
|
1129
|
+
vReflectionInfos,
|
|
1130
|
+
vReflectionColor,
|
|
1131
|
+
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
|
1132
|
+
NdotVUnclamped,
|
|
1133
|
+
#endif
|
|
1134
|
+
#ifdef LINEARSPECULARREFLECTION
|
|
1135
|
+
roughness,
|
|
1136
|
+
#endif
|
|
1137
|
+
#ifdef REFLECTIONMAP_3D
|
|
1138
|
+
reflectionSampler,
|
|
1139
|
+
reflectionCoords,
|
|
1140
|
+
#else
|
|
1141
|
+
reflectionSampler,
|
|
1142
|
+
reflectionCoords,
|
|
1143
|
+
#endif
|
|
1144
|
+
#ifndef LODBASEDMICROSFURACE
|
|
1145
|
+
reflectionSamplerLow,
|
|
1146
|
+
reflectionSamplerHigh,
|
|
1147
|
+
#endif
|
|
1148
|
+
#ifdef REALTIME_FILTERING
|
|
1149
|
+
vReflectionFilteringInfo,
|
|
1150
|
+
#endif
|
|
1151
|
+
environmentRadiance
|
|
1152
|
+
);vec3 environmentIrradiance=vec3(0.,0.,0.);
|
|
1153
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
1154
|
+
#ifdef ANISOTROPIC
|
|
1155
|
+
vec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz;
|
|
1156
|
+
#else
|
|
1157
|
+
vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
|
|
1158
|
+
#endif
|
|
1159
|
+
vec3 irradianceView=vec3(reflectionMatrix*vec4(viewDirectionW,0)).xyz;
|
|
1160
|
+
#if !defined(USE_IRRADIANCE_DOMINANT_DIRECTION) && !defined(REALTIME_FILTERING)
|
|
1161
|
+
#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY
|
|
1162
|
+
float NdotV=max(dot(normalW,viewDirectionW),0.0);irradianceVector=mix(irradianceVector,irradianceView,(0.5*(1.0-NdotV))*diffuseRoughness);
|
|
1163
|
+
#endif
|
|
1164
|
+
#endif
|
|
1165
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
1166
|
+
irradianceVector.z*=-1.0;
|
|
1167
|
+
#endif
|
|
1168
|
+
#ifdef INVERTCUBICMAP
|
|
1169
|
+
irradianceVector.y*=-1.0;
|
|
1170
|
+
#endif
|
|
1171
|
+
#endif
|
|
1172
|
+
#ifdef USESPHERICALFROMREFLECTIONMAP
|
|
1173
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
1174
|
+
environmentIrradiance=vEnvironmentIrradiance;
|
|
1175
|
+
#else
|
|
1176
|
+
#if defined(REALTIME_FILTERING)
|
|
1177
|
+
environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo,diffuseRoughness,surfaceAlbedo,irradianceView
|
|
1178
|
+
#ifdef IBL_CDF_FILTERING
|
|
1179
|
+
,icdfSampler
|
|
1180
|
+
#endif
|
|
1181
|
+
);
|
|
1182
|
+
#else
|
|
1183
|
+
environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
|
|
1184
|
+
#endif
|
|
1185
|
+
#ifdef SS_TRANSLUCENCY
|
|
1186
|
+
outParams.irradianceVector=irradianceVector;
|
|
1187
|
+
#endif
|
|
1188
|
+
#endif
|
|
1189
|
+
#elif defined(USEIRRADIANCEMAP)
|
|
1190
|
+
#ifdef REFLECTIONMAP_3D
|
|
1191
|
+
vec4 environmentIrradiance4=sampleReflection(irradianceSampler,irradianceVector);
|
|
1192
|
+
#else
|
|
1193
|
+
vec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords);
|
|
1194
|
+
#endif
|
|
1195
|
+
environmentIrradiance=environmentIrradiance4.rgb;
|
|
1196
|
+
#ifdef RGBDREFLECTION
|
|
1197
|
+
environmentIrradiance.rgb=fromRGBD(environmentIrradiance4);
|
|
1198
|
+
#endif
|
|
1199
|
+
#ifdef GAMMAREFLECTION
|
|
1200
|
+
environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);
|
|
1201
|
+
#endif
|
|
1202
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
1203
|
+
vec3 Ls=normalize(reflectionDominantDirection);float NoL=dot(irradianceVector,Ls);float NoV=dot(irradianceVector,irradianceView);vec3 diffuseRoughnessTerm=vec3(1.0);
|
|
1204
|
+
#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
|
|
1205
|
+
float LoV=dot (Ls,irradianceView);float mag=length(reflectionDominantDirection)*2.0;vec3 clampedAlbedo=clamp(surfaceAlbedo,vec3(0.1),vec3(1.0));diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;diffuseRoughnessTerm=diffuseRoughnessTerm/clampedAlbedo;diffuseRoughnessTerm=mix(vec3(1.0),diffuseRoughnessTerm,sqrt(clamp(mag*NoV,0.0,1.0)));
|
|
1206
|
+
#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
|
|
1207
|
+
vec3 H=(irradianceView+Ls)*0.5;float VoH=dot(irradianceView,H);diffuseRoughnessTerm=vec3(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);
|
|
1208
|
+
#endif
|
|
1209
|
+
environmentIrradiance=environmentIrradiance.rgb*diffuseRoughnessTerm;
|
|
1210
|
+
#endif
|
|
1211
|
+
#endif
|
|
1212
|
+
environmentIrradiance*=vReflectionColor.rgb*vReflectionInfos.x;
|
|
1213
|
+
#ifdef MIX_IBL_RADIANCE_WITH_IRRADIANCE
|
|
1214
|
+
outParams.environmentRadiance=vec4(mix(environmentRadiance.rgb,environmentIrradiance,alphaG),environmentRadiance.a);
|
|
1215
|
+
#else
|
|
1216
|
+
outParams.environmentRadiance=environmentRadiance;
|
|
1217
|
+
#endif
|
|
1218
|
+
outParams.environmentIrradiance=environmentIrradiance;outParams.reflectionCoords=reflectionCoords;return outParams;}
|
|
1219
|
+
#endif
|
|
1220
|
+
`;
|
|
1221
|
+
e.IncludesShadersStore[I] || (e.IncludesShadersStore[I] = ie);
|
|
1222
|
+
const v = "pbrBlockSheen", ne = `#ifdef SHEEN
|
|
1223
|
+
struct sheenOutParams
|
|
1224
|
+
{float sheenIntensity;vec3 sheenColor;float sheenRoughness;
|
|
1225
|
+
#ifdef SHEEN_LINKWITHALBEDO
|
|
1226
|
+
vec3 surfaceAlbedo;
|
|
1227
|
+
#endif
|
|
1228
|
+
#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
|
|
1229
|
+
float sheenAlbedoScaling;
|
|
1230
|
+
#endif
|
|
1231
|
+
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
|
1232
|
+
vec3 finalSheenRadianceScaled;
|
|
1233
|
+
#endif
|
|
1234
|
+
#if DEBUGMODE>0
|
|
1235
|
+
#ifdef SHEEN_TEXTURE
|
|
1236
|
+
vec4 sheenMapData;
|
|
1237
|
+
#endif
|
|
1238
|
+
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
|
1239
|
+
vec3 sheenEnvironmentReflectance;
|
|
1240
|
+
#endif
|
|
1241
|
+
#endif
|
|
1242
|
+
};
|
|
1243
|
+
#define pbr_inline
|
|
1244
|
+
#define inline
|
|
1245
|
+
sheenOutParams sheenBlock(
|
|
1246
|
+
in vec4 vSheenColor
|
|
1247
|
+
#ifdef SHEEN_ROUGHNESS
|
|
1248
|
+
,in float vSheenRoughness
|
|
1249
|
+
#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
|
1250
|
+
,in vec4 sheenMapRoughnessData
|
|
1251
|
+
#endif
|
|
1252
|
+
#endif
|
|
1253
|
+
,in float roughness
|
|
1254
|
+
#ifdef SHEEN_TEXTURE
|
|
1255
|
+
,in vec4 sheenMapData
|
|
1256
|
+
,in float sheenMapLevel
|
|
1257
|
+
#endif
|
|
1258
|
+
,in float reflectance
|
|
1259
|
+
#ifdef SHEEN_LINKWITHALBEDO
|
|
1260
|
+
,in vec3 baseColor
|
|
1261
|
+
,in vec3 surfaceAlbedo
|
|
1262
|
+
#endif
|
|
1263
|
+
#ifdef ENVIRONMENTBRDF
|
|
1264
|
+
,in float NdotV
|
|
1265
|
+
,in vec3 environmentBrdf
|
|
1266
|
+
#endif
|
|
1267
|
+
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
|
1268
|
+
,in vec2 AARoughnessFactors
|
|
1269
|
+
,in vec3 vReflectionMicrosurfaceInfos
|
|
1270
|
+
,in vec2 vReflectionInfos
|
|
1271
|
+
,in vec3 vReflectionColor
|
|
1272
|
+
,in vec4 vLightingIntensity
|
|
1273
|
+
#ifdef REFLECTIONMAP_3D
|
|
1274
|
+
,in samplerCube reflectionSampler
|
|
1275
|
+
,in vec3 reflectionCoords
|
|
1276
|
+
#else
|
|
1277
|
+
,in sampler2D reflectionSampler
|
|
1278
|
+
,in vec2 reflectionCoords
|
|
1279
|
+
#endif
|
|
1280
|
+
,in float NdotVUnclamped
|
|
1281
|
+
#ifndef LODBASEDMICROSFURACE
|
|
1282
|
+
#ifdef REFLECTIONMAP_3D
|
|
1283
|
+
,in samplerCube reflectionSamplerLow
|
|
1284
|
+
,in samplerCube reflectionSamplerHigh
|
|
1285
|
+
#else
|
|
1286
|
+
,in sampler2D reflectionSamplerLow
|
|
1287
|
+
,in sampler2D reflectionSamplerHigh
|
|
1288
|
+
#endif
|
|
1289
|
+
#endif
|
|
1290
|
+
#ifdef REALTIME_FILTERING
|
|
1291
|
+
,in vec2 vReflectionFilteringInfo
|
|
1292
|
+
#endif
|
|
1293
|
+
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
|
|
1294
|
+
,in float seo
|
|
1295
|
+
#endif
|
|
1296
|
+
#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
|
|
1297
|
+
,in float eho
|
|
1298
|
+
#endif
|
|
1299
|
+
#endif
|
|
1300
|
+
)
|
|
1301
|
+
{sheenOutParams outParams;float sheenIntensity=vSheenColor.a;
|
|
1302
|
+
#ifdef SHEEN_TEXTURE
|
|
1303
|
+
#if DEBUGMODE>0
|
|
1304
|
+
outParams.sheenMapData=sheenMapData;
|
|
1305
|
+
#endif
|
|
1306
|
+
#endif
|
|
1307
|
+
#ifdef SHEEN_LINKWITHALBEDO
|
|
1308
|
+
float sheenFactor=pow5(1.0-sheenIntensity);vec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);float sheenRoughness=sheenIntensity;outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;
|
|
1309
|
+
#ifdef SHEEN_TEXTURE
|
|
1310
|
+
sheenIntensity*=sheenMapData.a;
|
|
1311
|
+
#endif
|
|
1312
|
+
#else
|
|
1313
|
+
vec3 sheenColor=vSheenColor.rgb;
|
|
1314
|
+
#ifdef SHEEN_TEXTURE
|
|
1315
|
+
#ifdef SHEEN_GAMMATEXTURE
|
|
1316
|
+
sheenColor.rgb*=toLinearSpace(sheenMapData.rgb);
|
|
1317
|
+
#else
|
|
1318
|
+
sheenColor.rgb*=sheenMapData.rgb;
|
|
1319
|
+
#endif
|
|
1320
|
+
sheenColor.rgb*=sheenMapLevel;
|
|
1321
|
+
#endif
|
|
1322
|
+
#ifdef SHEEN_ROUGHNESS
|
|
1323
|
+
float sheenRoughness=vSheenRoughness;
|
|
1324
|
+
#ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE
|
|
1325
|
+
#if defined(SHEEN_TEXTURE)
|
|
1326
|
+
sheenRoughness*=sheenMapData.a;
|
|
1327
|
+
#endif
|
|
1328
|
+
#elif defined(SHEEN_TEXTURE_ROUGHNESS)
|
|
1329
|
+
sheenRoughness*=sheenMapRoughnessData.a;
|
|
1330
|
+
#endif
|
|
1331
|
+
#else
|
|
1332
|
+
float sheenRoughness=roughness;
|
|
1333
|
+
#ifdef SHEEN_TEXTURE
|
|
1334
|
+
sheenIntensity*=sheenMapData.a;
|
|
1335
|
+
#endif
|
|
1336
|
+
#endif
|
|
1337
|
+
#if !defined(SHEEN_ALBEDOSCALING)
|
|
1338
|
+
sheenIntensity*=(1.-reflectance);
|
|
1339
|
+
#endif
|
|
1340
|
+
sheenColor*=sheenIntensity;
|
|
1341
|
+
#endif
|
|
1342
|
+
#ifdef ENVIRONMENTBRDF
|
|
1343
|
+
/*#ifdef SHEEN_SOFTER
|
|
1344
|
+
vec3 environmentSheenBrdf=vec3(0.,0.,getBRDFLookupCharlieSheen(NdotV,sheenRoughness));
|
|
1345
|
+
#else*/
|
|
1346
|
+
#ifdef SHEEN_ROUGHNESS
|
|
1347
|
+
vec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness);
|
|
1348
|
+
#else
|
|
1349
|
+
vec3 environmentSheenBrdf=environmentBrdf;
|
|
1350
|
+
#endif
|
|
1351
|
+
/*#endif*/
|
|
1352
|
+
#endif
|
|
1353
|
+
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
|
1354
|
+
float sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);
|
|
1355
|
+
#ifdef SPECULARAA
|
|
1356
|
+
sheenAlphaG+=AARoughnessFactors.y;
|
|
1357
|
+
#endif
|
|
1358
|
+
vec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);sampleReflectionTexture(
|
|
1359
|
+
sheenAlphaG,
|
|
1360
|
+
vReflectionMicrosurfaceInfos,
|
|
1361
|
+
vReflectionInfos,
|
|
1362
|
+
vReflectionColor,
|
|
1363
|
+
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
|
1364
|
+
NdotVUnclamped,
|
|
1365
|
+
#endif
|
|
1366
|
+
#ifdef LINEARSPECULARREFLECTION
|
|
1367
|
+
sheenRoughness,
|
|
1368
|
+
#endif
|
|
1369
|
+
reflectionSampler,
|
|
1370
|
+
reflectionCoords,
|
|
1371
|
+
#ifndef LODBASEDMICROSFURACE
|
|
1372
|
+
reflectionSamplerLow,
|
|
1373
|
+
reflectionSamplerHigh,
|
|
1374
|
+
#endif
|
|
1375
|
+
#ifdef REALTIME_FILTERING
|
|
1376
|
+
vReflectionFilteringInfo,
|
|
1377
|
+
#endif
|
|
1378
|
+
environmentSheenRadiance
|
|
1379
|
+
);vec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);
|
|
1380
|
+
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
|
|
1381
|
+
sheenEnvironmentReflectance*=seo;
|
|
1382
|
+
#endif
|
|
1383
|
+
#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
|
|
1384
|
+
sheenEnvironmentReflectance*=eho;
|
|
1385
|
+
#endif
|
|
1386
|
+
#if DEBUGMODE>0
|
|
1387
|
+
outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;
|
|
1388
|
+
#endif
|
|
1389
|
+
outParams.finalSheenRadianceScaled=
|
|
1390
|
+
environmentSheenRadiance.rgb *
|
|
1391
|
+
sheenEnvironmentReflectance *
|
|
1392
|
+
vLightingIntensity.z;
|
|
1393
|
+
#endif
|
|
1394
|
+
#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
|
|
1395
|
+
outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;
|
|
1396
|
+
#endif
|
|
1397
|
+
outParams.sheenIntensity=sheenIntensity;outParams.sheenColor=sheenColor;outParams.sheenRoughness=sheenRoughness;return outParams;}
|
|
1398
|
+
#endif
|
|
1399
|
+
`;
|
|
1400
|
+
e.IncludesShadersStore[v] || (e.IncludesShadersStore[v] = ne);
|
|
1401
|
+
const N = "pbrBlockClearcoat", ae = `struct clearcoatOutParams
|
|
1402
|
+
{vec3 specularEnvironmentR0;float conservationFactor;vec3 clearCoatNormalW;vec2 clearCoatAARoughnessFactors;float clearCoatIntensity;float clearCoatRoughness;
|
|
1403
|
+
#ifdef REFLECTION
|
|
1404
|
+
vec3 finalClearCoatRadianceScaled;
|
|
1405
|
+
#endif
|
|
1406
|
+
#ifdef CLEARCOAT_TINT
|
|
1407
|
+
vec3 absorption;float clearCoatNdotVRefract;vec3 clearCoatColor;float clearCoatThickness;
|
|
1408
|
+
#endif
|
|
1409
|
+
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
|
1410
|
+
vec3 energyConservationFactorClearCoat;
|
|
1411
|
+
#endif
|
|
1412
|
+
#if DEBUGMODE>0
|
|
1413
|
+
#ifdef CLEARCOAT_BUMP
|
|
1414
|
+
mat3 TBNClearCoat;
|
|
1415
|
+
#endif
|
|
1416
|
+
#ifdef CLEARCOAT_TEXTURE
|
|
1417
|
+
vec2 clearCoatMapData;
|
|
1418
|
+
#endif
|
|
1419
|
+
#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
|
|
1420
|
+
vec4 clearCoatTintMapData;
|
|
1421
|
+
#endif
|
|
1422
|
+
#ifdef REFLECTION
|
|
1423
|
+
vec4 environmentClearCoatRadiance;vec3 clearCoatEnvironmentReflectance;
|
|
1424
|
+
#endif
|
|
1425
|
+
float clearCoatNdotV;
|
|
1426
|
+
#endif
|
|
1427
|
+
};
|
|
1428
|
+
#ifdef CLEARCOAT
|
|
1429
|
+
#define pbr_inline
|
|
1430
|
+
#define inline
|
|
1431
|
+
clearcoatOutParams clearcoatBlock(
|
|
1432
|
+
in vec3 vPositionW
|
|
1433
|
+
,in vec3 geometricNormalW
|
|
1434
|
+
,in vec3 viewDirectionW
|
|
1435
|
+
,in vec2 vClearCoatParams
|
|
1436
|
+
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
|
1437
|
+
,in vec4 clearCoatMapRoughnessData
|
|
1438
|
+
#endif
|
|
1439
|
+
,in vec3 specularEnvironmentR0
|
|
1440
|
+
#ifdef CLEARCOAT_TEXTURE
|
|
1441
|
+
,in vec2 clearCoatMapData
|
|
1442
|
+
#endif
|
|
1443
|
+
#ifdef CLEARCOAT_TINT
|
|
1444
|
+
,in vec4 vClearCoatTintParams
|
|
1445
|
+
,in float clearCoatColorAtDistance
|
|
1446
|
+
,in vec4 vClearCoatRefractionParams
|
|
1447
|
+
#ifdef CLEARCOAT_TINT_TEXTURE
|
|
1448
|
+
,in vec4 clearCoatTintMapData
|
|
1449
|
+
#endif
|
|
1450
|
+
#endif
|
|
1451
|
+
#ifdef CLEARCOAT_BUMP
|
|
1452
|
+
,in vec2 vClearCoatBumpInfos
|
|
1453
|
+
,in vec4 clearCoatBumpMapData
|
|
1454
|
+
,in vec2 vClearCoatBumpUV
|
|
1455
|
+
#if defined(TANGENT) && defined(NORMAL)
|
|
1456
|
+
,in mat3 vTBN
|
|
1457
|
+
#else
|
|
1458
|
+
,in vec2 vClearCoatTangentSpaceParams
|
|
1459
|
+
#endif
|
|
1460
|
+
#ifdef OBJECTSPACE_NORMALMAP
|
|
1461
|
+
,in mat4 normalMatrix
|
|
1462
|
+
#endif
|
|
1463
|
+
#endif
|
|
1464
|
+
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
|
|
1465
|
+
,in vec3 faceNormal
|
|
1466
|
+
#endif
|
|
1467
|
+
#ifdef REFLECTION
|
|
1468
|
+
,in vec3 vReflectionMicrosurfaceInfos
|
|
1469
|
+
,in vec2 vReflectionInfos
|
|
1470
|
+
,in vec3 vReflectionColor
|
|
1471
|
+
,in vec4 vLightingIntensity
|
|
1472
|
+
#ifdef REFLECTIONMAP_3D
|
|
1473
|
+
,in samplerCube reflectionSampler
|
|
1474
|
+
#else
|
|
1475
|
+
,in sampler2D reflectionSampler
|
|
1476
|
+
#endif
|
|
1477
|
+
#ifndef LODBASEDMICROSFURACE
|
|
1478
|
+
#ifdef REFLECTIONMAP_3D
|
|
1479
|
+
,in samplerCube reflectionSamplerLow
|
|
1480
|
+
,in samplerCube reflectionSamplerHigh
|
|
1481
|
+
#else
|
|
1482
|
+
,in sampler2D reflectionSamplerLow
|
|
1483
|
+
,in sampler2D reflectionSamplerHigh
|
|
1484
|
+
#endif
|
|
1485
|
+
#endif
|
|
1486
|
+
#ifdef REALTIME_FILTERING
|
|
1487
|
+
,in vec2 vReflectionFilteringInfo
|
|
1488
|
+
#endif
|
|
1489
|
+
#endif
|
|
1490
|
+
#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
|
|
1491
|
+
,in float frontFacingMultiplier
|
|
1492
|
+
#endif
|
|
1493
|
+
)
|
|
1494
|
+
{clearcoatOutParams outParams;float clearCoatIntensity=vClearCoatParams.x;float clearCoatRoughness=vClearCoatParams.y;
|
|
1495
|
+
#ifdef CLEARCOAT_TEXTURE
|
|
1496
|
+
clearCoatIntensity*=clearCoatMapData.x;
|
|
1497
|
+
#ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE
|
|
1498
|
+
clearCoatRoughness*=clearCoatMapData.y;
|
|
1499
|
+
#endif
|
|
1500
|
+
#if DEBUGMODE>0
|
|
1501
|
+
outParams.clearCoatMapData=clearCoatMapData;
|
|
1502
|
+
#endif
|
|
1503
|
+
#endif
|
|
1504
|
+
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
|
1505
|
+
clearCoatRoughness*=clearCoatMapRoughnessData.y;
|
|
1506
|
+
#endif
|
|
1507
|
+
outParams.clearCoatIntensity=clearCoatIntensity;outParams.clearCoatRoughness=clearCoatRoughness;
|
|
1508
|
+
#ifdef CLEARCOAT_TINT
|
|
1509
|
+
vec3 clearCoatColor=vClearCoatTintParams.rgb;float clearCoatThickness=vClearCoatTintParams.a;
|
|
1510
|
+
#ifdef CLEARCOAT_TINT_TEXTURE
|
|
1511
|
+
#ifdef CLEARCOAT_TINT_GAMMATEXTURE
|
|
1512
|
+
clearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);
|
|
1513
|
+
#else
|
|
1514
|
+
clearCoatColor*=clearCoatTintMapData.rgb;
|
|
1515
|
+
#endif
|
|
1516
|
+
clearCoatThickness*=clearCoatTintMapData.a;
|
|
1517
|
+
#if DEBUGMODE>0
|
|
1518
|
+
outParams.clearCoatTintMapData=clearCoatTintMapData;
|
|
1519
|
+
#endif
|
|
1520
|
+
#endif
|
|
1521
|
+
outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);outParams.clearCoatThickness=clearCoatThickness;
|
|
1522
|
+
#endif
|
|
1523
|
+
#ifdef CLEARCOAT_REMAP_F0
|
|
1524
|
+
vec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);
|
|
1525
|
+
#else
|
|
1526
|
+
vec3 specularEnvironmentR0Updated=specularEnvironmentR0;
|
|
1527
|
+
#endif
|
|
1528
|
+
outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);vec3 clearCoatNormalW=geometricNormalW;
|
|
1529
|
+
#ifdef CLEARCOAT_BUMP
|
|
1530
|
+
#ifdef NORMALXYSCALE
|
|
1531
|
+
float clearCoatNormalScale=1.0;
|
|
1532
|
+
#else
|
|
1533
|
+
float clearCoatNormalScale=vClearCoatBumpInfos.y;
|
|
1534
|
+
#endif
|
|
1535
|
+
#if defined(TANGENT) && defined(NORMAL)
|
|
1536
|
+
mat3 TBNClearCoat=vTBN;
|
|
1537
|
+
#else
|
|
1538
|
+
vec2 TBNClearCoatUV=vClearCoatBumpUV*frontFacingMultiplier;mat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,TBNClearCoatUV,vClearCoatTangentSpaceParams);
|
|
1539
|
+
#endif
|
|
1540
|
+
#if DEBUGMODE>0
|
|
1541
|
+
outParams.TBNClearCoat=TBNClearCoat;
|
|
1542
|
+
#endif
|
|
1543
|
+
#ifdef OBJECTSPACE_NORMALMAP
|
|
1544
|
+
clearCoatNormalW=normalize(clearCoatBumpMapData.xyz *2.0-1.0);clearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);
|
|
1545
|
+
#else
|
|
1546
|
+
clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);
|
|
1547
|
+
#endif
|
|
1548
|
+
#endif
|
|
1549
|
+
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
|
|
1550
|
+
clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));
|
|
1551
|
+
#endif
|
|
1552
|
+
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
|
|
1553
|
+
clearCoatNormalW=clearCoatNormalW*frontFacingMultiplier;
|
|
1554
|
+
#endif
|
|
1555
|
+
outParams.clearCoatNormalW=clearCoatNormalW;outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);float clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);float clearCoatNdotV=absEps(clearCoatNdotVUnclamped);
|
|
1556
|
+
#if DEBUGMODE>0
|
|
1557
|
+
outParams.clearCoatNdotV=clearCoatNdotV;
|
|
1558
|
+
#endif
|
|
1559
|
+
#ifdef CLEARCOAT_TINT
|
|
1560
|
+
vec3 clearCoatVRefract=refract(-viewDirectionW,clearCoatNormalW,vClearCoatRefractionParams.y);outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));
|
|
1561
|
+
#endif
|
|
1562
|
+
#if defined(ENVIRONMENTBRDF) && (!defined(REFLECTIONMAP_SKYBOX) || defined(MS_BRDF_ENERGY_CONSERVATION))
|
|
1563
|
+
vec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);
|
|
1564
|
+
#endif
|
|
1565
|
+
#if defined(REFLECTION)
|
|
1566
|
+
float clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);
|
|
1567
|
+
#ifdef SPECULARAA
|
|
1568
|
+
clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;
|
|
1569
|
+
#endif
|
|
1570
|
+
vec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);vec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);
|
|
1571
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
1572
|
+
clearCoatReflectionVector.z*=-1.0;
|
|
1573
|
+
#endif
|
|
1574
|
+
#ifdef REFLECTIONMAP_3D
|
|
1575
|
+
vec3 clearCoatReflectionCoords=clearCoatReflectionVector;
|
|
1576
|
+
#else
|
|
1577
|
+
vec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;
|
|
1578
|
+
#ifdef REFLECTIONMAP_PROJECTION
|
|
1579
|
+
clearCoatReflectionCoords/=clearCoatReflectionVector.z;
|
|
1580
|
+
#endif
|
|
1581
|
+
clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;
|
|
1582
|
+
#endif
|
|
1583
|
+
sampleReflectionTexture(
|
|
1584
|
+
clearCoatAlphaG,
|
|
1585
|
+
vReflectionMicrosurfaceInfos,
|
|
1586
|
+
vReflectionInfos,
|
|
1587
|
+
vReflectionColor,
|
|
1588
|
+
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
|
1589
|
+
clearCoatNdotVUnclamped,
|
|
1590
|
+
#endif
|
|
1591
|
+
#ifdef LINEARSPECULARREFLECTION
|
|
1592
|
+
clearCoatRoughness,
|
|
1593
|
+
#endif
|
|
1594
|
+
reflectionSampler,
|
|
1595
|
+
clearCoatReflectionCoords,
|
|
1596
|
+
#ifndef LODBASEDMICROSFURACE
|
|
1597
|
+
reflectionSamplerLow,
|
|
1598
|
+
reflectionSamplerHigh,
|
|
1599
|
+
#endif
|
|
1600
|
+
#ifdef REALTIME_FILTERING
|
|
1601
|
+
vReflectionFilteringInfo,
|
|
1602
|
+
#endif
|
|
1603
|
+
environmentClearCoatRadiance
|
|
1604
|
+
);
|
|
1605
|
+
#if DEBUGMODE>0
|
|
1606
|
+
outParams.environmentClearCoatRadiance=environmentClearCoatRadiance;
|
|
1607
|
+
#endif
|
|
1608
|
+
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
|
1609
|
+
vec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);
|
|
1610
|
+
#ifdef HORIZONOCCLUSION
|
|
1611
|
+
#ifdef BUMP
|
|
1612
|
+
#ifdef REFLECTIONMAP_3D
|
|
1613
|
+
float clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);clearCoatEnvironmentReflectance*=clearCoatEho;
|
|
1614
|
+
#endif
|
|
1615
|
+
#endif
|
|
1616
|
+
#endif
|
|
1617
|
+
#else
|
|
1618
|
+
vec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));
|
|
1619
|
+
#endif
|
|
1620
|
+
clearCoatEnvironmentReflectance*=clearCoatIntensity;
|
|
1621
|
+
#if DEBUGMODE>0
|
|
1622
|
+
outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;
|
|
1623
|
+
#endif
|
|
1624
|
+
outParams.finalClearCoatRadianceScaled=
|
|
1625
|
+
environmentClearCoatRadiance.rgb *
|
|
1626
|
+
clearCoatEnvironmentReflectance *
|
|
1627
|
+
vLightingIntensity.z;
|
|
1628
|
+
#endif
|
|
1629
|
+
#if defined(CLEARCOAT_TINT)
|
|
1630
|
+
outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);
|
|
1631
|
+
#endif
|
|
1632
|
+
float fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnelIBLClearCoat*=clearCoatIntensity;outParams.conservationFactor=(1.-fresnelIBLClearCoat);
|
|
1633
|
+
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
|
1634
|
+
outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);
|
|
1635
|
+
#endif
|
|
1636
|
+
return outParams;}
|
|
1637
|
+
#endif
|
|
1638
|
+
`;
|
|
1639
|
+
e.IncludesShadersStore[N] || (e.IncludesShadersStore[N] = ae);
|
|
1640
|
+
const O = "pbrBlockIridescence", oe = `struct iridescenceOutParams
|
|
1641
|
+
{float iridescenceIntensity;float iridescenceIOR;float iridescenceThickness;vec3 specularEnvironmentR0;};
|
|
1642
|
+
#ifdef IRIDESCENCE
|
|
1643
|
+
#define pbr_inline
|
|
1644
|
+
#define inline
|
|
1645
|
+
iridescenceOutParams iridescenceBlock(
|
|
1646
|
+
in vec4 vIridescenceParams
|
|
1647
|
+
,in float viewAngle
|
|
1648
|
+
,in vec3 specularEnvironmentR0
|
|
1649
|
+
#ifdef IRIDESCENCE_TEXTURE
|
|
1650
|
+
,in vec2 iridescenceMapData
|
|
1651
|
+
#endif
|
|
1652
|
+
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
|
|
1653
|
+
,in vec2 iridescenceThicknessMapData
|
|
1654
|
+
#endif
|
|
1655
|
+
#ifdef CLEARCOAT
|
|
1656
|
+
,in float NdotVUnclamped
|
|
1657
|
+
,in vec2 vClearCoatParams
|
|
1658
|
+
#ifdef CLEARCOAT_TEXTURE
|
|
1659
|
+
,in vec2 clearCoatMapData
|
|
1660
|
+
#endif
|
|
1661
|
+
#endif
|
|
1662
|
+
)
|
|
1663
|
+
{iridescenceOutParams outParams;float iridescenceIntensity=vIridescenceParams.x;float iridescenceIOR=vIridescenceParams.y;float iridescenceThicknessMin=vIridescenceParams.z;float iridescenceThicknessMax=vIridescenceParams.w;float iridescenceThicknessWeight=1.;
|
|
1664
|
+
#ifdef IRIDESCENCE_TEXTURE
|
|
1665
|
+
iridescenceIntensity*=iridescenceMapData.x;
|
|
1666
|
+
#endif
|
|
1667
|
+
#if defined(IRIDESCENCE_THICKNESS_TEXTURE)
|
|
1668
|
+
iridescenceThicknessWeight=iridescenceThicknessMapData.g;
|
|
1669
|
+
#endif
|
|
1670
|
+
float iridescenceThickness=mix(iridescenceThicknessMin,iridescenceThicknessMax,iridescenceThicknessWeight);float topIor=1.;
|
|
1671
|
+
#ifdef CLEARCOAT
|
|
1672
|
+
float clearCoatIntensity=vClearCoatParams.x;
|
|
1673
|
+
#ifdef CLEARCOAT_TEXTURE
|
|
1674
|
+
clearCoatIntensity*=clearCoatMapData.x;
|
|
1675
|
+
#endif
|
|
1676
|
+
topIor=mix(1.0,vClearCoatRefractionParams.w-1.,clearCoatIntensity);viewAngle=sqrt(1.0+square(1.0/topIor)*(square(NdotVUnclamped)-1.0));
|
|
1677
|
+
#endif
|
|
1678
|
+
vec3 iridescenceFresnel=evalIridescence(topIor,iridescenceIOR,viewAngle,iridescenceThickness,specularEnvironmentR0);outParams.specularEnvironmentR0=mix(specularEnvironmentR0,iridescenceFresnel,iridescenceIntensity);outParams.iridescenceIntensity=iridescenceIntensity;outParams.iridescenceThickness=iridescenceThickness;outParams.iridescenceIOR=iridescenceIOR;return outParams;}
|
|
1679
|
+
#endif
|
|
1680
|
+
`;
|
|
1681
|
+
e.IncludesShadersStore[O] || (e.IncludesShadersStore[O] = oe);
|
|
1682
|
+
const T = "pbrBlockSubSurface", re = `struct subSurfaceOutParams
|
|
1683
|
+
{vec3 specularEnvironmentReflectance;
|
|
1684
|
+
#ifdef SS_REFRACTION
|
|
1685
|
+
vec3 finalRefraction;vec3 surfaceAlbedo;
|
|
1686
|
+
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
|
1687
|
+
float alpha;
|
|
1688
|
+
#endif
|
|
1689
|
+
float refractionOpacity;
|
|
1690
|
+
#endif
|
|
1691
|
+
#ifdef SS_TRANSLUCENCY
|
|
1692
|
+
vec3 transmittance;float translucencyIntensity;
|
|
1693
|
+
#ifdef REFLECTION
|
|
1694
|
+
vec3 refractionIrradiance;
|
|
1695
|
+
#endif
|
|
1696
|
+
#endif
|
|
1697
|
+
#if DEBUGMODE>0
|
|
1698
|
+
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
|
1699
|
+
vec4 thicknessMap;
|
|
1700
|
+
#endif
|
|
1701
|
+
#ifdef SS_REFRACTION
|
|
1702
|
+
vec4 environmentRefraction;vec3 refractionTransmittance;
|
|
1703
|
+
#endif
|
|
1704
|
+
#endif
|
|
1705
|
+
};
|
|
1706
|
+
#ifdef SUBSURFACE
|
|
1707
|
+
#ifdef SS_REFRACTION
|
|
1708
|
+
#define pbr_inline
|
|
1709
|
+
#define inline
|
|
1710
|
+
vec4 sampleEnvironmentRefraction(
|
|
1711
|
+
in float ior
|
|
1712
|
+
,in float thickness
|
|
1713
|
+
,in float refractionLOD
|
|
1714
|
+
,in vec3 normalW
|
|
1715
|
+
,in vec3 vPositionW
|
|
1716
|
+
,in vec3 viewDirectionW
|
|
1717
|
+
,in mat4 view
|
|
1718
|
+
,in vec4 vRefractionInfos
|
|
1719
|
+
,in mat4 refractionMatrix
|
|
1720
|
+
,in vec4 vRefractionMicrosurfaceInfos
|
|
1721
|
+
,in float alphaG
|
|
1722
|
+
#ifdef SS_REFRACTIONMAP_3D
|
|
1723
|
+
,in samplerCube refractionSampler
|
|
1724
|
+
#ifndef LODBASEDMICROSFURACE
|
|
1725
|
+
,in samplerCube refractionSamplerLow
|
|
1726
|
+
,in samplerCube refractionSamplerHigh
|
|
1727
|
+
#endif
|
|
1728
|
+
#else
|
|
1729
|
+
,in sampler2D refractionSampler
|
|
1730
|
+
#ifndef LODBASEDMICROSFURACE
|
|
1731
|
+
,in sampler2D refractionSamplerLow
|
|
1732
|
+
,in sampler2D refractionSamplerHigh
|
|
1733
|
+
#endif
|
|
1734
|
+
#endif
|
|
1735
|
+
#ifdef ANISOTROPIC
|
|
1736
|
+
,in anisotropicOutParams anisotropicOut
|
|
1737
|
+
#endif
|
|
1738
|
+
#ifdef REALTIME_FILTERING
|
|
1739
|
+
,in vec2 vRefractionFilteringInfo
|
|
1740
|
+
#endif
|
|
1741
|
+
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
|
1742
|
+
,in vec3 refractionPosition
|
|
1743
|
+
,in vec3 refractionSize
|
|
1744
|
+
#endif
|
|
1745
|
+
) {vec4 environmentRefraction=vec4(0.,0.,0.,0.);
|
|
1746
|
+
#ifdef ANISOTROPIC
|
|
1747
|
+
vec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,ior);
|
|
1748
|
+
#else
|
|
1749
|
+
vec3 refractionVector=refract(-viewDirectionW,normalW,ior);
|
|
1750
|
+
#endif
|
|
1751
|
+
#ifdef SS_REFRACTIONMAP_OPPOSITEZ
|
|
1752
|
+
refractionVector.z*=-1.0;
|
|
1753
|
+
#endif
|
|
1754
|
+
#ifdef SS_REFRACTIONMAP_3D
|
|
1755
|
+
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
|
1756
|
+
refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,refractionSize,refractionPosition);
|
|
1757
|
+
#endif
|
|
1758
|
+
refractionVector.y=refractionVector.y*vRefractionInfos.w;vec3 refractionCoords=refractionVector;refractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));
|
|
1759
|
+
#else
|
|
1760
|
+
#ifdef SS_USE_THICKNESS_AS_DEPTH
|
|
1761
|
+
vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*thickness,1.0)));
|
|
1762
|
+
#else
|
|
1763
|
+
vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));
|
|
1764
|
+
#endif
|
|
1765
|
+
vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;
|
|
1766
|
+
#endif
|
|
1767
|
+
#ifdef LODBASEDMICROSFURACE
|
|
1768
|
+
refractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;
|
|
1769
|
+
#ifdef SS_LODINREFRACTIONALPHA
|
|
1770
|
+
float automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);float requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);
|
|
1771
|
+
#else
|
|
1772
|
+
float requestedRefractionLOD=refractionLOD;
|
|
1773
|
+
#endif
|
|
1774
|
+
#if defined(REALTIME_FILTERING) && defined(SS_REFRACTIONMAP_3D)
|
|
1775
|
+
environmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0);
|
|
1776
|
+
#else
|
|
1777
|
+
environmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);
|
|
1778
|
+
#endif
|
|
1779
|
+
#else
|
|
1780
|
+
float lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));float lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;vec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);if (lodRefractionNormalizedDoubled<1.0){environmentRefraction=mix(
|
|
1781
|
+
sampleRefraction(refractionSamplerHigh,refractionCoords),
|
|
1782
|
+
environmentRefractionMid,
|
|
1783
|
+
lodRefractionNormalizedDoubled
|
|
1784
|
+
);} else {environmentRefraction=mix(
|
|
1785
|
+
environmentRefractionMid,
|
|
1786
|
+
sampleRefraction(refractionSamplerLow,refractionCoords),
|
|
1787
|
+
lodRefractionNormalizedDoubled-1.0
|
|
1788
|
+
);}
|
|
1789
|
+
#endif
|
|
1790
|
+
#ifdef SS_RGBDREFRACTION
|
|
1791
|
+
environmentRefraction.rgb=fromRGBD(environmentRefraction);
|
|
1792
|
+
#endif
|
|
1793
|
+
#ifdef SS_GAMMAREFRACTION
|
|
1794
|
+
environmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);
|
|
1795
|
+
#endif
|
|
1796
|
+
return environmentRefraction;}
|
|
1797
|
+
#endif
|
|
1798
|
+
#define pbr_inline
|
|
1799
|
+
#define inline
|
|
1800
|
+
subSurfaceOutParams subSurfaceBlock(
|
|
1801
|
+
in vec3 vSubSurfaceIntensity
|
|
1802
|
+
,in vec2 vThicknessParam
|
|
1803
|
+
,in vec4 vTintColor
|
|
1804
|
+
,in vec3 normalW
|
|
1805
|
+
,in vec3 vSpecularEnvironmentReflectance
|
|
1806
|
+
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
|
1807
|
+
,in vec4 thicknessMap
|
|
1808
|
+
#endif
|
|
1809
|
+
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
|
|
1810
|
+
,in vec4 refractionIntensityMap
|
|
1811
|
+
#endif
|
|
1812
|
+
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
|
|
1813
|
+
,in vec4 translucencyIntensityMap
|
|
1814
|
+
#endif
|
|
1815
|
+
#ifdef REFLECTION
|
|
1816
|
+
#ifdef SS_TRANSLUCENCY
|
|
1817
|
+
,in mat4 reflectionMatrix
|
|
1818
|
+
#ifdef USESPHERICALFROMREFLECTIONMAP
|
|
1819
|
+
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
|
|
1820
|
+
,in vec3 irradianceVector_
|
|
1821
|
+
#endif
|
|
1822
|
+
#if defined(REALTIME_FILTERING)
|
|
1823
|
+
,in samplerCube reflectionSampler
|
|
1824
|
+
,in vec2 vReflectionFilteringInfo
|
|
1825
|
+
#ifdef IBL_CDF_FILTERING
|
|
1826
|
+
,in sampler2D icdfSampler
|
|
1827
|
+
#endif
|
|
1828
|
+
#endif
|
|
1829
|
+
#endif
|
|
1830
|
+
#ifdef USEIRRADIANCEMAP
|
|
1831
|
+
#ifdef REFLECTIONMAP_3D
|
|
1832
|
+
,in samplerCube irradianceSampler
|
|
1833
|
+
#else
|
|
1834
|
+
,in sampler2D irradianceSampler
|
|
1835
|
+
#endif
|
|
1836
|
+
#endif
|
|
1837
|
+
#endif
|
|
1838
|
+
#endif
|
|
1839
|
+
#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
|
|
1840
|
+
,in vec3 surfaceAlbedo
|
|
1841
|
+
#endif
|
|
1842
|
+
#ifdef SS_REFRACTION
|
|
1843
|
+
,in vec3 vPositionW
|
|
1844
|
+
,in vec3 viewDirectionW
|
|
1845
|
+
,in mat4 view
|
|
1846
|
+
,in vec4 vRefractionInfos
|
|
1847
|
+
,in mat4 refractionMatrix
|
|
1848
|
+
,in vec4 vRefractionMicrosurfaceInfos
|
|
1849
|
+
,in vec4 vLightingIntensity
|
|
1850
|
+
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
|
1851
|
+
,in float alpha
|
|
1852
|
+
#endif
|
|
1853
|
+
#ifdef SS_LODINREFRACTIONALPHA
|
|
1854
|
+
,in float NdotVUnclamped
|
|
1855
|
+
#endif
|
|
1856
|
+
#ifdef SS_LINEARSPECULARREFRACTION
|
|
1857
|
+
,in float roughness
|
|
1858
|
+
#endif
|
|
1859
|
+
,in float alphaG
|
|
1860
|
+
#ifdef SS_REFRACTIONMAP_3D
|
|
1861
|
+
,in samplerCube refractionSampler
|
|
1862
|
+
#ifndef LODBASEDMICROSFURACE
|
|
1863
|
+
,in samplerCube refractionSamplerLow
|
|
1864
|
+
,in samplerCube refractionSamplerHigh
|
|
1865
|
+
#endif
|
|
1866
|
+
#else
|
|
1867
|
+
,in sampler2D refractionSampler
|
|
1868
|
+
#ifndef LODBASEDMICROSFURACE
|
|
1869
|
+
,in sampler2D refractionSamplerLow
|
|
1870
|
+
,in sampler2D refractionSamplerHigh
|
|
1871
|
+
#endif
|
|
1872
|
+
#endif
|
|
1873
|
+
#ifdef ANISOTROPIC
|
|
1874
|
+
,in anisotropicOutParams anisotropicOut
|
|
1875
|
+
#endif
|
|
1876
|
+
#ifdef REALTIME_FILTERING
|
|
1877
|
+
,in vec2 vRefractionFilteringInfo
|
|
1878
|
+
#endif
|
|
1879
|
+
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
|
1880
|
+
,in vec3 refractionPosition
|
|
1881
|
+
,in vec3 refractionSize
|
|
1882
|
+
#endif
|
|
1883
|
+
#ifdef SS_DISPERSION
|
|
1884
|
+
,in float dispersion
|
|
1885
|
+
#endif
|
|
1886
|
+
#endif
|
|
1887
|
+
#ifdef SS_TRANSLUCENCY
|
|
1888
|
+
,in vec3 vDiffusionDistance
|
|
1889
|
+
,in vec4 vTranslucencyColor
|
|
1890
|
+
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
|
1891
|
+
,in vec4 translucencyColorMap
|
|
1892
|
+
#endif
|
|
1893
|
+
#endif
|
|
1894
|
+
)
|
|
1895
|
+
{subSurfaceOutParams outParams;outParams.specularEnvironmentReflectance=vSpecularEnvironmentReflectance;
|
|
1896
|
+
#ifdef SS_REFRACTION
|
|
1897
|
+
float refractionIntensity=vSubSurfaceIntensity.x;
|
|
1898
|
+
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
|
1899
|
+
refractionIntensity*=(1.0-alpha);outParams.alpha=1.0;
|
|
1900
|
+
#endif
|
|
1901
|
+
#endif
|
|
1902
|
+
#ifdef SS_TRANSLUCENCY
|
|
1903
|
+
float translucencyIntensity=vSubSurfaceIntensity.y;
|
|
1904
|
+
#endif
|
|
1905
|
+
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
|
1906
|
+
#ifdef SS_USE_GLTF_TEXTURES
|
|
1907
|
+
float thickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;
|
|
1908
|
+
#else
|
|
1909
|
+
float thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;
|
|
1910
|
+
#endif
|
|
1911
|
+
#if DEBUGMODE>0
|
|
1912
|
+
outParams.thicknessMap=thicknessMap;
|
|
1913
|
+
#endif
|
|
1914
|
+
#if defined(SS_REFRACTION) && defined(SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS)
|
|
1915
|
+
#ifdef SS_USE_GLTF_TEXTURES
|
|
1916
|
+
refractionIntensity*=thicknessMap.r;
|
|
1917
|
+
#else
|
|
1918
|
+
refractionIntensity*=thicknessMap.g;
|
|
1919
|
+
#endif
|
|
1920
|
+
#endif
|
|
1921
|
+
#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS)
|
|
1922
|
+
#ifdef SS_USE_GLTF_TEXTURES
|
|
1923
|
+
translucencyIntensity*=thicknessMap.a;
|
|
1924
|
+
#else
|
|
1925
|
+
translucencyIntensity*=thicknessMap.b;
|
|
1926
|
+
#endif
|
|
1927
|
+
#endif
|
|
1928
|
+
#else
|
|
1929
|
+
float thickness=vThicknessParam.y;
|
|
1930
|
+
#endif
|
|
1931
|
+
#if defined(SS_REFRACTION) && defined(SS_REFRACTIONINTENSITY_TEXTURE)
|
|
1932
|
+
#ifdef SS_USE_GLTF_TEXTURES
|
|
1933
|
+
refractionIntensity*=refractionIntensityMap.r;
|
|
1934
|
+
#else
|
|
1935
|
+
refractionIntensity*=refractionIntensityMap.g;
|
|
1936
|
+
#endif
|
|
1937
|
+
#endif
|
|
1938
|
+
#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCYINTENSITY_TEXTURE)
|
|
1939
|
+
#ifdef SS_USE_GLTF_TEXTURES
|
|
1940
|
+
translucencyIntensity*=translucencyIntensityMap.a;
|
|
1941
|
+
#else
|
|
1942
|
+
translucencyIntensity*=translucencyIntensityMap.b;
|
|
1943
|
+
#endif
|
|
1944
|
+
#endif
|
|
1945
|
+
#ifdef SS_TRANSLUCENCY
|
|
1946
|
+
thickness=maxEps(thickness);vec4 translucencyColor=vTranslucencyColor;
|
|
1947
|
+
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
|
1948
|
+
translucencyColor*=translucencyColorMap;
|
|
1949
|
+
#endif
|
|
1950
|
+
vec3 transmittance=transmittanceBRDF_Burley(translucencyColor.rgb,vDiffusionDistance,thickness);transmittance*=translucencyIntensity;outParams.transmittance=transmittance;outParams.translucencyIntensity=translucencyIntensity;
|
|
1951
|
+
#endif
|
|
1952
|
+
#ifdef SS_REFRACTION
|
|
1953
|
+
vec4 environmentRefraction=vec4(0.,0.,0.,0.);
|
|
1954
|
+
#ifdef SS_HAS_THICKNESS
|
|
1955
|
+
float ior=vRefractionInfos.y;
|
|
1956
|
+
#else
|
|
1957
|
+
float ior=vRefractionMicrosurfaceInfos.w;
|
|
1958
|
+
#endif
|
|
1959
|
+
#ifdef SS_LODINREFRACTIONALPHA
|
|
1960
|
+
float refractionAlphaG=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG,NdotVUnclamped);
|
|
1961
|
+
#elif defined(SS_LINEARSPECULARREFRACTION)
|
|
1962
|
+
float refractionRoughness=alphaG;refractionRoughness=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,refractionRoughness);
|
|
1963
|
+
#else
|
|
1964
|
+
float refractionAlphaG=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG);
|
|
1965
|
+
#endif
|
|
1966
|
+
float refraction_ior=vRefractionInfos.y;
|
|
1967
|
+
#ifdef SS_DISPERSION
|
|
1968
|
+
float realIOR=1.0/refraction_ior;float iorDispersionSpread=0.04*dispersion*(realIOR-1.0);vec3 iors=vec3(1.0/(realIOR-iorDispersionSpread),refraction_ior,1.0/(realIOR+iorDispersionSpread));for (int i=0; i<3; i++) {refraction_ior=iors[i];
|
|
1969
|
+
#endif
|
|
1970
|
+
vec4 envSample=sampleEnvironmentRefraction(refraction_ior,thickness,refractionLOD,normalW,vPositionW,viewDirectionW,view,vRefractionInfos,refractionMatrix,vRefractionMicrosurfaceInfos,alphaG
|
|
1971
|
+
#ifdef SS_REFRACTIONMAP_3D
|
|
1972
|
+
,refractionSampler
|
|
1973
|
+
#ifndef LODBASEDMICROSFURACE
|
|
1974
|
+
,refractionSamplerLow
|
|
1975
|
+
,refractionSamplerHigh
|
|
1976
|
+
#endif
|
|
1977
|
+
#else
|
|
1978
|
+
,refractionSampler
|
|
1979
|
+
#ifndef LODBASEDMICROSFURACE
|
|
1980
|
+
,refractionSamplerLow
|
|
1981
|
+
,refractionSamplerHigh
|
|
1982
|
+
#endif
|
|
1983
|
+
#endif
|
|
1984
|
+
#ifdef ANISOTROPIC
|
|
1985
|
+
,anisotropicOut
|
|
1986
|
+
#endif
|
|
1987
|
+
#ifdef REALTIME_FILTERING
|
|
1988
|
+
,vRefractionFilteringInfo
|
|
1989
|
+
#endif
|
|
1990
|
+
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
|
1991
|
+
,refractionPosition
|
|
1992
|
+
,refractionSize
|
|
1993
|
+
#endif
|
|
1994
|
+
);
|
|
1995
|
+
#ifdef SS_DISPERSION
|
|
1996
|
+
environmentRefraction[i]=envSample[i];}
|
|
1997
|
+
#else
|
|
1998
|
+
environmentRefraction=envSample;
|
|
1999
|
+
#endif
|
|
2000
|
+
environmentRefraction.rgb*=vRefractionInfos.x;
|
|
2001
|
+
#endif
|
|
2002
|
+
#ifdef SS_REFRACTION
|
|
2003
|
+
vec3 refractionTransmittance=vec3(refractionIntensity);
|
|
2004
|
+
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
|
2005
|
+
vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambert(volumeAlbedo,thickness);
|
|
2006
|
+
#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)
|
|
2007
|
+
float maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);vec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);environmentRefraction.rgb*=volumeAlbedo;
|
|
2008
|
+
#else
|
|
2009
|
+
vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);
|
|
2010
|
+
#endif
|
|
2011
|
+
#ifdef SS_ALBEDOFORREFRACTIONTINT
|
|
2012
|
+
environmentRefraction.rgb*=surfaceAlbedo.rgb;
|
|
2013
|
+
#endif
|
|
2014
|
+
#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
|
|
2015
|
+
outParams.surfaceAlbedo=surfaceAlbedo*(1.-refractionIntensity);outParams.refractionOpacity=1.0;
|
|
2016
|
+
#else
|
|
2017
|
+
outParams.surfaceAlbedo=surfaceAlbedo;outParams.refractionOpacity=(1.-refractionIntensity);
|
|
2018
|
+
#endif
|
|
2019
|
+
#ifdef UNUSED_MULTIPLEBOUNCES
|
|
2020
|
+
vec3 bounceSpecularEnvironmentReflectance=(2.0*vSpecularEnvironmentReflectance)/(1.0+vSpecularEnvironmentReflectance);outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,vSpecularEnvironmentReflectance,refractionIntensity);
|
|
2021
|
+
#endif
|
|
2022
|
+
#if DEBUGMODE>0
|
|
2023
|
+
outParams.refractionTransmittance=refractionTransmittance;
|
|
2024
|
+
#endif
|
|
2025
|
+
outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;outParams.finalRefraction*=vec3(1.0)-vSpecularEnvironmentReflectance;
|
|
2026
|
+
#if DEBUGMODE>0
|
|
2027
|
+
outParams.environmentRefraction=environmentRefraction;
|
|
2028
|
+
#endif
|
|
2029
|
+
#endif
|
|
2030
|
+
#if defined(REFLECTION) && defined(SS_TRANSLUCENCY)
|
|
2031
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)
|
|
2032
|
+
vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
|
|
2033
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
2034
|
+
irradianceVector.z*=-1.0;
|
|
2035
|
+
#endif
|
|
2036
|
+
#ifdef INVERTCUBICMAP
|
|
2037
|
+
irradianceVector.y*=-1.0;
|
|
2038
|
+
#endif
|
|
2039
|
+
#else
|
|
2040
|
+
vec3 irradianceVector=irradianceVector_;
|
|
2041
|
+
#endif
|
|
2042
|
+
#if defined(USESPHERICALFROMREFLECTIONMAP)
|
|
2043
|
+
#if defined(REALTIME_FILTERING)
|
|
2044
|
+
vec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo,0.0,surfaceAlbedo,irradianceVector
|
|
2045
|
+
#ifdef IBL_CDF_FILTERING
|
|
2046
|
+
,icdfSampler
|
|
2047
|
+
#endif
|
|
2048
|
+
);
|
|
2049
|
+
#else
|
|
2050
|
+
vec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector);
|
|
2051
|
+
#endif
|
|
2052
|
+
#elif defined(USEIRRADIANCEMAP)
|
|
2053
|
+
#ifdef REFLECTIONMAP_3D
|
|
2054
|
+
vec3 irradianceCoords=irradianceVector;
|
|
2055
|
+
#else
|
|
2056
|
+
vec2 irradianceCoords=irradianceVector.xy;
|
|
2057
|
+
#ifdef REFLECTIONMAP_PROJECTION
|
|
2058
|
+
irradianceCoords/=irradianceVector.z;
|
|
2059
|
+
#endif
|
|
2060
|
+
irradianceCoords.y=1.0-irradianceCoords.y;
|
|
2061
|
+
#endif
|
|
2062
|
+
vec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords);
|
|
2063
|
+
#ifdef RGBDREFLECTION
|
|
2064
|
+
refractionIrradiance.rgb=fromRGBD(refractionIrradiance);
|
|
2065
|
+
#endif
|
|
2066
|
+
#ifdef GAMMAREFLECTION
|
|
2067
|
+
refractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb);
|
|
2068
|
+
#endif
|
|
2069
|
+
#else
|
|
2070
|
+
vec4 refractionIrradiance=vec4(0.);
|
|
2071
|
+
#endif
|
|
2072
|
+
refractionIrradiance.rgb*=transmittance;
|
|
2073
|
+
#ifdef SS_ALBEDOFORTRANSLUCENCYTINT
|
|
2074
|
+
refractionIrradiance.rgb*=surfaceAlbedo.rgb;
|
|
2075
|
+
#endif
|
|
2076
|
+
outParams.refractionIrradiance=refractionIrradiance.rgb;
|
|
2077
|
+
#endif
|
|
2078
|
+
return outParams;}
|
|
2079
|
+
#endif
|
|
2080
|
+
`;
|
|
2081
|
+
e.IncludesShadersStore[T] || (e.IncludesShadersStore[T] = re);
|
|
2082
|
+
const L = "pbrBlockNormalGeometric", te = `vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
|
|
2083
|
+
#ifdef NORMAL
|
|
2084
|
+
vec3 normalW=normalize(vNormalW);
|
|
2085
|
+
#else
|
|
2086
|
+
vec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
|
|
2087
|
+
#endif
|
|
2088
|
+
vec3 geometricNormalW=normalW;
|
|
2089
|
+
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
|
|
2090
|
+
geometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW;
|
|
2091
|
+
#endif
|
|
2092
|
+
`;
|
|
2093
|
+
e.IncludesShadersStore[L] || (e.IncludesShadersStore[L] = te);
|
|
2094
|
+
const p = "pbrBlockNormalFinal", fe = `#if defined(FORCENORMALFORWARD) && defined(NORMAL)
|
|
2095
|
+
vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
|
|
2096
|
+
#if defined(TWOSIDEDLIGHTING)
|
|
2097
|
+
faceNormal=gl_FrontFacing ? faceNormal : -faceNormal;
|
|
2098
|
+
#endif
|
|
2099
|
+
normalW*=sign(dot(normalW,faceNormal));
|
|
2100
|
+
#endif
|
|
2101
|
+
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
|
|
2102
|
+
#if defined(MIRRORED)
|
|
2103
|
+
normalW=gl_FrontFacing ? -normalW : normalW;
|
|
2104
|
+
#else
|
|
2105
|
+
normalW=gl_FrontFacing ? normalW : -normalW;
|
|
2106
|
+
#endif
|
|
2107
|
+
#endif
|
|
2108
|
+
`;
|
|
2109
|
+
e.IncludesShadersStore[p] || (e.IncludesShadersStore[p] = fe);
|
|
2110
|
+
const g = "pbrBlockLightmapInit", ce = `#ifdef LIGHTMAP
|
|
2111
|
+
vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
|
|
2112
|
+
#ifdef RGBDLIGHTMAP
|
|
2113
|
+
lightmapColor.rgb=fromRGBD(lightmapColor);
|
|
2114
|
+
#endif
|
|
2115
|
+
#ifdef GAMMALIGHTMAP
|
|
2116
|
+
lightmapColor.rgb=toLinearSpace(lightmapColor.rgb);
|
|
2117
|
+
#endif
|
|
2118
|
+
lightmapColor.rgb*=vLightmapInfos.y;
|
|
2119
|
+
#endif
|
|
2120
|
+
`;
|
|
2121
|
+
e.IncludesShadersStore[g] || (e.IncludesShadersStore[g] = ce);
|
|
2122
|
+
const _ = "pbrBlockGeometryInfo", le = `float NdotVUnclamped=dot(normalW,viewDirectionW);float NdotV=absEps(NdotVUnclamped);float alphaG=convertRoughnessToAverageSlope(roughness);vec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);
|
|
2123
|
+
#ifdef SPECULARAA
|
|
2124
|
+
alphaG+=AARoughnessFactors.y;
|
|
2125
|
+
#endif
|
|
2126
|
+
#if defined(ENVIRONMENTBRDF)
|
|
2127
|
+
vec3 environmentBrdf=getBRDFLookup(NdotV,roughness);
|
|
2128
|
+
#endif
|
|
2129
|
+
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
|
2130
|
+
#ifdef RADIANCEOCCLUSION
|
|
2131
|
+
#ifdef AMBIENTINGRAYSCALE
|
|
2132
|
+
float ambientMonochrome=aoOut.ambientOcclusionColor.r;
|
|
2133
|
+
#else
|
|
2134
|
+
float ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor);
|
|
2135
|
+
#endif
|
|
2136
|
+
float seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);
|
|
2137
|
+
#endif
|
|
2138
|
+
#ifdef HORIZONOCCLUSION
|
|
2139
|
+
#ifdef BUMP
|
|
2140
|
+
#ifdef REFLECTIONMAP_3D
|
|
2141
|
+
float eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
|
|
2142
|
+
#endif
|
|
2143
|
+
#endif
|
|
2144
|
+
#endif
|
|
2145
|
+
#endif
|
|
2146
|
+
`;
|
|
2147
|
+
e.IncludesShadersStore[_] || (e.IncludesShadersStore[_] = le);
|
|
2148
|
+
const D = "pbrBlockReflectance0", de = `float reflectanceF0=reflectivityOut.reflectanceF0;vec3 specularEnvironmentR0=reflectivityOut.colorReflectanceF0;vec3 specularEnvironmentR90=reflectivityOut.colorReflectanceF90;
|
|
2149
|
+
#ifdef ALPHAFRESNEL
|
|
2150
|
+
float reflectance90=fresnelGrazingReflectance(reflectanceF0);specularEnvironmentR90=specularEnvironmentR90*reflectance90;
|
|
2151
|
+
#endif
|
|
2152
|
+
`;
|
|
2153
|
+
e.IncludesShadersStore[D] || (e.IncludesShadersStore[D] = de);
|
|
2154
|
+
const M = "pbrBlockReflectance", se = `#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
|
2155
|
+
vec3 baseSpecularEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(reflectanceF0),reflectivityOut.reflectanceF90,environmentBrdf);
|
|
2156
|
+
#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
|
|
2157
|
+
vec3 metalEnvironmentReflectance=reflectivityOut.specularWeight*getF82Specular(NdotV,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);vec3 dielectricEnvironmentReflectance=getReflectanceFromBRDFLookup(reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90,environmentBrdf);vec3 colorSpecularEnvironmentReflectance=mix(dielectricEnvironmentReflectance,metalEnvironmentReflectance,reflectivityOut.metallic);
|
|
2158
|
+
#else
|
|
2159
|
+
vec3 colorSpecularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,environmentBrdf);
|
|
2160
|
+
#endif
|
|
2161
|
+
#ifdef RADIANCEOCCLUSION
|
|
2162
|
+
colorSpecularEnvironmentReflectance*=seo;
|
|
2163
|
+
#endif
|
|
2164
|
+
#ifdef HORIZONOCCLUSION
|
|
2165
|
+
#ifdef BUMP
|
|
2166
|
+
#ifdef REFLECTIONMAP_3D
|
|
2167
|
+
colorSpecularEnvironmentReflectance*=eho;
|
|
2168
|
+
#endif
|
|
2169
|
+
#endif
|
|
2170
|
+
#endif
|
|
2171
|
+
#else
|
|
2172
|
+
vec3 colorSpecularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));vec3 baseSpecularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,vec3(reflectanceF0),reflectivityOut.reflectanceF90,sqrt(microSurface));
|
|
2173
|
+
#endif
|
|
2174
|
+
#ifdef CLEARCOAT
|
|
2175
|
+
colorSpecularEnvironmentReflectance*=clearcoatOut.conservationFactor;
|
|
2176
|
+
#if defined(CLEARCOAT_TINT)
|
|
2177
|
+
colorSpecularEnvironmentReflectance*=clearcoatOut.absorption;
|
|
2178
|
+
#endif
|
|
2179
|
+
#endif
|
|
2180
|
+
`;
|
|
2181
|
+
e.IncludesShadersStore[M] || (e.IncludesShadersStore[M] = se);
|
|
2182
|
+
const h = "pbrBlockDirectLighting", Ee = `vec3 diffuseBase=vec3(0.,0.,0.);
|
|
2183
|
+
#ifdef SS_TRANSLUCENCY
|
|
2184
|
+
vec3 diffuseTransmissionBase=vec3(0.,0.,0.);
|
|
2185
|
+
#endif
|
|
2186
|
+
#ifdef SPECULARTERM
|
|
2187
|
+
vec3 specularBase=vec3(0.,0.,0.);
|
|
2188
|
+
#endif
|
|
2189
|
+
#ifdef CLEARCOAT
|
|
2190
|
+
vec3 clearCoatBase=vec3(0.,0.,0.);
|
|
2191
|
+
#endif
|
|
2192
|
+
#ifdef SHEEN
|
|
2193
|
+
vec3 sheenBase=vec3(0.,0.,0.);
|
|
2194
|
+
#endif
|
|
2195
|
+
#if defined(SPECULARTERM) && defined(LIGHT0)
|
|
2196
|
+
vec3 coloredFresnel;
|
|
2197
|
+
#endif
|
|
2198
|
+
preLightingInfo preInfo;lightingInfo info;float shadow=1.;
|
|
2199
|
+
float aggShadow=0.;float numLights=0.;
|
|
2200
|
+
#if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
|
|
2201
|
+
vec3 absorption=vec3(0.);
|
|
2202
|
+
#endif
|
|
2203
|
+
`;
|
|
2204
|
+
e.IncludesShadersStore[h] || (e.IncludesShadersStore[h] = Ee);
|
|
2205
|
+
const F = "pbrBlockFinalLitComponents", Re = `aggShadow=aggShadow/numLights;
|
|
2206
|
+
#if defined(ENVIRONMENTBRDF)
|
|
2207
|
+
#ifdef MS_BRDF_ENERGY_CONSERVATION
|
|
2208
|
+
vec3 baseSpecularEnergyConservationFactor=getEnergyConservationFactor(vec3(reflectanceF0),environmentBrdf);vec3 coloredEnergyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);
|
|
2209
|
+
#endif
|
|
2210
|
+
#endif
|
|
2211
|
+
#if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)
|
|
2212
|
+
surfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;
|
|
2213
|
+
#endif
|
|
2214
|
+
#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
|
|
2215
|
+
#ifndef METALLICWORKFLOW
|
|
2216
|
+
#ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION
|
|
2217
|
+
surfaceAlbedo.rgb=(1.-reflectanceF0)*surfaceAlbedo.rgb;
|
|
2218
|
+
#endif
|
|
2219
|
+
#endif
|
|
2220
|
+
#endif
|
|
2221
|
+
#ifdef REFLECTION
|
|
2222
|
+
vec3 finalIrradiance=reflectionOut.environmentIrradiance;
|
|
2223
|
+
#ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION
|
|
2224
|
+
#if defined(METALLICWORKFLOW) || defined(SPECULAR_GLOSSINESS_ENERGY_CONSERVATION)
|
|
2225
|
+
vec3 baseSpecularEnergy=vec3(baseSpecularEnvironmentReflectance);
|
|
2226
|
+
#if defined(ENVIRONMENTBRDF)
|
|
2227
|
+
#ifdef MS_BRDF_ENERGY_CONSERVATION
|
|
2228
|
+
baseSpecularEnergy*=baseSpecularEnergyConservationFactor;
|
|
2229
|
+
#endif
|
|
2230
|
+
#endif
|
|
2231
|
+
finalIrradiance*=clamp(vec3(1.0)-baseSpecularEnergy,0.0,1.0);
|
|
2232
|
+
#endif
|
|
2233
|
+
#endif
|
|
2234
|
+
#if defined(CLEARCOAT)
|
|
2235
|
+
finalIrradiance*=clearcoatOut.conservationFactor;
|
|
2236
|
+
#if defined(CLEARCOAT_TINT)
|
|
2237
|
+
finalIrradiance*=clearcoatOut.absorption;
|
|
2238
|
+
#endif
|
|
2239
|
+
#endif
|
|
2240
|
+
#ifndef SS_APPLY_ALBEDO_AFTER_SUBSURFACE
|
|
2241
|
+
finalIrradiance*=surfaceAlbedo.rgb;
|
|
2242
|
+
#endif
|
|
2243
|
+
#if defined(SS_REFRACTION)
|
|
2244
|
+
finalIrradiance*=subSurfaceOut.refractionOpacity;
|
|
2245
|
+
#endif
|
|
2246
|
+
#if defined(SS_TRANSLUCENCY)
|
|
2247
|
+
finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);finalIrradiance+=subSurfaceOut.refractionIrradiance;
|
|
2248
|
+
#endif
|
|
2249
|
+
#ifdef SS_APPLY_ALBEDO_AFTER_SUBSURFACE
|
|
2250
|
+
finalIrradiance*=surfaceAlbedo.rgb;
|
|
2251
|
+
#endif
|
|
2252
|
+
finalIrradiance*=vLightingIntensity.z;finalIrradiance*=aoOut.ambientOcclusionColor;
|
|
2253
|
+
#endif
|
|
2254
|
+
#ifdef SPECULARTERM
|
|
2255
|
+
vec3 finalSpecular=specularBase;finalSpecular=max(finalSpecular,0.0);vec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;
|
|
2256
|
+
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
|
2257
|
+
finalSpecularScaled*=coloredEnergyConservationFactor;
|
|
2258
|
+
#endif
|
|
2259
|
+
#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
|
|
2260
|
+
finalSpecularScaled*=sheenOut.sheenAlbedoScaling;
|
|
2261
|
+
#endif
|
|
2262
|
+
#endif
|
|
2263
|
+
#ifdef REFLECTION
|
|
2264
|
+
vec3 finalRadiance=reflectionOut.environmentRadiance.rgb;finalRadiance*=colorSpecularEnvironmentReflectance;vec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;
|
|
2265
|
+
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
|
2266
|
+
finalRadianceScaled*=coloredEnergyConservationFactor;
|
|
2267
|
+
#endif
|
|
2268
|
+
#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
|
|
2269
|
+
finalRadianceScaled*=sheenOut.sheenAlbedoScaling;
|
|
2270
|
+
#endif
|
|
2271
|
+
#endif
|
|
2272
|
+
#ifdef SHEEN
|
|
2273
|
+
vec3 finalSheen=sheenBase*sheenOut.sheenColor;finalSheen=max(finalSheen,0.0);vec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;
|
|
2274
|
+
#if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
|
2275
|
+
sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;
|
|
2276
|
+
#if defined(CLEARCOAT_TINT)
|
|
2277
|
+
sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;
|
|
2278
|
+
#endif
|
|
2279
|
+
#endif
|
|
2280
|
+
#endif
|
|
2281
|
+
#ifdef CLEARCOAT
|
|
2282
|
+
vec3 finalClearCoat=clearCoatBase;finalClearCoat=max(finalClearCoat,0.0);vec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;
|
|
2283
|
+
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
|
2284
|
+
finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;
|
|
2285
|
+
#endif
|
|
2286
|
+
#ifdef SS_REFRACTION
|
|
2287
|
+
subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;
|
|
2288
|
+
#ifdef CLEARCOAT_TINT
|
|
2289
|
+
subSurfaceOut.finalRefraction*=clearcoatOut.absorption;
|
|
2290
|
+
#endif
|
|
2291
|
+
#endif
|
|
2292
|
+
#endif
|
|
2293
|
+
#ifdef ALPHABLEND
|
|
2294
|
+
float luminanceOverAlpha=0.0;
|
|
2295
|
+
#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)
|
|
2296
|
+
luminanceOverAlpha+=getLuminance(finalRadianceScaled);
|
|
2297
|
+
#if defined(CLEARCOAT)
|
|
2298
|
+
luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);
|
|
2299
|
+
#endif
|
|
2300
|
+
#endif
|
|
2301
|
+
#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)
|
|
2302
|
+
luminanceOverAlpha+=getLuminance(finalSpecularScaled);
|
|
2303
|
+
#endif
|
|
2304
|
+
#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)
|
|
2305
|
+
luminanceOverAlpha+=getLuminance(finalClearCoatScaled);
|
|
2306
|
+
#endif
|
|
2307
|
+
#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)
|
|
2308
|
+
alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);
|
|
2309
|
+
#endif
|
|
2310
|
+
#endif
|
|
2311
|
+
`;
|
|
2312
|
+
e.IncludesShadersStore[F] || (e.IncludesShadersStore[F] = Re);
|
|
2313
|
+
const P = "pbrBlockFinalUnlitComponents", ue = `vec3 finalDiffuse=diffuseBase;finalDiffuse*=surfaceAlbedo;
|
|
2314
|
+
#if defined(SS_REFRACTION) && !defined(UNLIT)
|
|
2315
|
+
finalDiffuse*=subSurfaceOut.refractionOpacity;
|
|
2316
|
+
#endif
|
|
2317
|
+
#if defined(SS_TRANSLUCENCY) && !defined(UNLIT)
|
|
2318
|
+
finalDiffuse+=diffuseTransmissionBase;
|
|
2319
|
+
#endif
|
|
2320
|
+
finalDiffuse=max(finalDiffuse,0.0);finalDiffuse*=vLightingIntensity.x;vec3 finalAmbient=vAmbientColor;finalAmbient*=surfaceAlbedo.rgb;vec3 finalEmissive=vEmissiveColor;
|
|
2321
|
+
#ifdef EMISSIVE
|
|
2322
|
+
vec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;
|
|
2323
|
+
#ifdef GAMMAEMISSIVE
|
|
2324
|
+
finalEmissive*=toLinearSpace(emissiveColorTex.rgb);
|
|
2325
|
+
#else
|
|
2326
|
+
finalEmissive*=emissiveColorTex.rgb;
|
|
2327
|
+
#endif
|
|
2328
|
+
finalEmissive*= vEmissiveInfos.y;
|
|
2329
|
+
#endif
|
|
2330
|
+
finalEmissive*=vLightingIntensity.y;
|
|
2331
|
+
#ifdef AMBIENT
|
|
2332
|
+
vec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w);
|
|
2333
|
+
#else
|
|
2334
|
+
vec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor;
|
|
2335
|
+
#endif
|
|
2336
|
+
finalAmbient*=aoOut.ambientOcclusionColor;finalDiffuse*=ambientOcclusionForDirectDiffuse;
|
|
2337
|
+
`;
|
|
2338
|
+
e.IncludesShadersStore[P] || (e.IncludesShadersStore[P] = ue);
|
|
2339
|
+
const U = "pbrBlockFinalColorComposition", Ce = `vec4 finalColor=vec4(
|
|
2340
|
+
#ifndef UNLIT
|
|
2341
|
+
#ifdef REFLECTION
|
|
2342
|
+
finalIrradiance +
|
|
2343
|
+
#endif
|
|
2344
|
+
#ifdef SPECULARTERM
|
|
2345
|
+
finalSpecularScaled +
|
|
2346
|
+
#endif
|
|
2347
|
+
#ifdef SHEEN
|
|
2348
|
+
finalSheenScaled +
|
|
2349
|
+
#endif
|
|
2350
|
+
#ifdef CLEARCOAT
|
|
2351
|
+
finalClearCoatScaled +
|
|
2352
|
+
#endif
|
|
2353
|
+
#ifdef REFLECTION
|
|
2354
|
+
finalRadianceScaled +
|
|
2355
|
+
#if defined(SHEEN) && defined(ENVIRONMENTBRDF)
|
|
2356
|
+
sheenOut.finalSheenRadianceScaled +
|
|
2357
|
+
#endif
|
|
2358
|
+
#ifdef CLEARCOAT
|
|
2359
|
+
clearcoatOut.finalClearCoatRadianceScaled +
|
|
2360
|
+
#endif
|
|
2361
|
+
#endif
|
|
2362
|
+
#ifdef SS_REFRACTION
|
|
2363
|
+
subSurfaceOut.finalRefraction +
|
|
2364
|
+
#endif
|
|
2365
|
+
#endif
|
|
2366
|
+
finalAmbient +
|
|
2367
|
+
finalDiffuse,
|
|
2368
|
+
alpha);
|
|
2369
|
+
#ifdef LIGHTMAP
|
|
2370
|
+
#ifndef LIGHTMAPEXCLUDED
|
|
2371
|
+
#ifdef USELIGHTMAPASSHADOWMAP
|
|
2372
|
+
finalColor.rgb*=lightmapColor.rgb;
|
|
2373
|
+
#else
|
|
2374
|
+
finalColor.rgb+=lightmapColor.rgb;
|
|
2375
|
+
#endif
|
|
2376
|
+
#endif
|
|
2377
|
+
#endif
|
|
2378
|
+
finalColor.rgb+=finalEmissive;
|
|
2379
|
+
#define CUSTOM_FRAGMENT_BEFORE_FOG
|
|
2380
|
+
finalColor=max(finalColor,0.0);
|
|
2381
|
+
`;
|
|
2382
|
+
e.IncludesShadersStore[U] || (e.IncludesShadersStore[U] = Ce);
|
|
2383
|
+
const b = "pbrBlockImageProcessing", Se = `#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING)
|
|
2384
|
+
#if !defined(SKIPFINALCOLORCLAMP)
|
|
2385
|
+
finalColor.rgb=clamp(finalColor.rgb,0.,30.0);
|
|
2386
|
+
#endif
|
|
2387
|
+
#else
|
|
2388
|
+
finalColor=applyImageProcessing(finalColor);
|
|
2389
|
+
#endif
|
|
2390
|
+
finalColor.a*=visibility;
|
|
2391
|
+
#ifdef PREMULTIPLYALPHA
|
|
2392
|
+
finalColor.rgb*=finalColor.a;
|
|
2393
|
+
#endif
|
|
2394
|
+
`;
|
|
2395
|
+
e.IncludesShadersStore[b] || (e.IncludesShadersStore[b] = Se);
|
|
2396
|
+
const B = "pbrBlockPrePass", Ae = `float writeGeometryInfo=finalColor.a>ALPHATESTVALUE ? 1.0 : 0.0;
|
|
2397
|
+
#ifdef PREPASS_POSITION
|
|
2398
|
+
gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
|
|
2399
|
+
#endif
|
|
2400
|
+
#ifdef PREPASS_LOCAL_POSITION
|
|
2401
|
+
gl_FragData[PREPASS_LOCAL_POSITION_INDEX]=vec4(vPosition,writeGeometryInfo);
|
|
2402
|
+
#endif
|
|
2403
|
+
#if defined(PREPASS_VELOCITY)
|
|
2404
|
+
vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
|
|
2405
|
+
#elif defined(PREPASS_VELOCITY_LINEAR)
|
|
2406
|
+
vec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w)-(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
|
|
2407
|
+
#endif
|
|
2408
|
+
#ifdef PREPASS_ALBEDO
|
|
2409
|
+
gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(surfaceAlbedo,writeGeometryInfo);
|
|
2410
|
+
#endif
|
|
2411
|
+
#ifdef PREPASS_ALBEDO_SQRT
|
|
2412
|
+
vec3 sqAlbedo=sqrt(surfaceAlbedo);
|
|
2413
|
+
#endif
|
|
2414
|
+
#ifdef PREPASS_IRRADIANCE
|
|
2415
|
+
vec3 irradiance=finalDiffuse;
|
|
2416
|
+
#ifndef UNLIT
|
|
2417
|
+
#ifdef REFLECTION
|
|
2418
|
+
irradiance+=finalIrradiance;
|
|
2419
|
+
#endif
|
|
2420
|
+
#endif
|
|
2421
|
+
#ifdef SS_SCATTERING
|
|
2422
|
+
#ifdef PREPASS_COLOR
|
|
2423
|
+
gl_FragData[PREPASS_COLOR_INDEX]=vec4(finalColor.rgb-irradiance,finalColor.a);
|
|
2424
|
+
#endif
|
|
2425
|
+
irradiance/=sqAlbedo;
|
|
2426
|
+
#else
|
|
2427
|
+
#ifdef PREPASS_COLOR
|
|
2428
|
+
gl_FragData[PREPASS_COLOR_INDEX]=finalColor;
|
|
2429
|
+
#endif
|
|
2430
|
+
float scatteringDiffusionProfile=255.;
|
|
2431
|
+
#endif
|
|
2432
|
+
gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(clamp(irradiance,vec3(0.),vec3(1.)),writeGeometryInfo*scatteringDiffusionProfile/255.);
|
|
2433
|
+
#elif defined(PREPASS_COLOR)
|
|
2434
|
+
gl_FragData[PREPASS_COLOR_INDEX]=vec4(finalColor.rgb,finalColor.a);
|
|
2435
|
+
#endif
|
|
2436
|
+
#ifdef PREPASS_DEPTH
|
|
2437
|
+
gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);
|
|
2438
|
+
#endif
|
|
2439
|
+
#ifdef PREPASS_SCREENSPACE_DEPTH
|
|
2440
|
+
gl_FragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,writeGeometryInfo);
|
|
2441
|
+
#endif
|
|
2442
|
+
#ifdef PREPASS_NORMALIZED_VIEW_DEPTH
|
|
2443
|
+
gl_FragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4(vNormViewDepth,0.0,0.0,writeGeometryInfo);
|
|
2444
|
+
#endif
|
|
2445
|
+
#ifdef PREPASS_NORMAL
|
|
2446
|
+
#ifdef PREPASS_NORMAL_WORLDSPACE
|
|
2447
|
+
gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo);
|
|
2448
|
+
#else
|
|
2449
|
+
gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo);
|
|
2450
|
+
#endif
|
|
2451
|
+
#endif
|
|
2452
|
+
#ifdef PREPASS_WORLD_NORMAL
|
|
2453
|
+
gl_FragData[PREPASS_WORLD_NORMAL_INDEX]=vec4(normalW*0.5+0.5,writeGeometryInfo);
|
|
2454
|
+
#endif
|
|
2455
|
+
#ifdef PREPASS_ALBEDO_SQRT
|
|
2456
|
+
gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqAlbedo,writeGeometryInfo);
|
|
2457
|
+
#endif
|
|
2458
|
+
#ifdef PREPASS_REFLECTIVITY
|
|
2459
|
+
#ifndef UNLIT
|
|
2460
|
+
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularEnvironmentR0,microSurface)*writeGeometryInfo;
|
|
2461
|
+
#else
|
|
2462
|
+
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4( 0.0,0.0,0.0,1.0 )*writeGeometryInfo;
|
|
2463
|
+
#endif
|
|
2464
|
+
#endif
|
|
2465
|
+
`;
|
|
2466
|
+
e.IncludesShadersStore[B] || (e.IncludesShadersStore[B] = Ae);
|
|
2467
|
+
const G = "pbrDebug", me = `#if DEBUGMODE>0
|
|
2468
|
+
if (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) {
|
|
2469
|
+
#if DEBUGMODE==1
|
|
2470
|
+
gl_FragColor.rgb=vPositionW.rgb;
|
|
2471
|
+
#define DEBUGMODE_NORMALIZE
|
|
2472
|
+
#elif DEBUGMODE==2 && defined(NORMAL)
|
|
2473
|
+
gl_FragColor.rgb=vNormalW.rgb;
|
|
2474
|
+
#define DEBUGMODE_NORMALIZE
|
|
2475
|
+
#elif DEBUGMODE==3 && defined(BUMP) || DEBUGMODE==3 && defined(PARALLAX) || DEBUGMODE==3 && defined(ANISOTROPIC)
|
|
2476
|
+
gl_FragColor.rgb=TBN[0];
|
|
2477
|
+
#define DEBUGMODE_NORMALIZE
|
|
2478
|
+
#elif DEBUGMODE==4 && defined(BUMP) || DEBUGMODE==4 && defined(PARALLAX) || DEBUGMODE==4 && defined(ANISOTROPIC)
|
|
2479
|
+
gl_FragColor.rgb=TBN[1];
|
|
2480
|
+
#define DEBUGMODE_NORMALIZE
|
|
2481
|
+
#elif DEBUGMODE==5
|
|
2482
|
+
gl_FragColor.rgb=normalW;
|
|
2483
|
+
#define DEBUGMODE_NORMALIZE
|
|
2484
|
+
#elif DEBUGMODE==6 && defined(MAINUV1)
|
|
2485
|
+
gl_FragColor.rgb=vec3(vMainUV1,0.0);
|
|
2486
|
+
#elif DEBUGMODE==7 && defined(MAINUV2)
|
|
2487
|
+
gl_FragColor.rgb=vec3(vMainUV2,0.0);
|
|
2488
|
+
#elif DEBUGMODE==8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
|
|
2489
|
+
gl_FragColor.rgb=clearcoatOut.TBNClearCoat[0];
|
|
2490
|
+
#define DEBUGMODE_NORMALIZE
|
|
2491
|
+
#elif DEBUGMODE==9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
|
|
2492
|
+
gl_FragColor.rgb=clearcoatOut.TBNClearCoat[1];
|
|
2493
|
+
#define DEBUGMODE_NORMALIZE
|
|
2494
|
+
#elif DEBUGMODE==10 && defined(CLEARCOAT)
|
|
2495
|
+
gl_FragColor.rgb=clearcoatOut.clearCoatNormalW;
|
|
2496
|
+
#define DEBUGMODE_NORMALIZE
|
|
2497
|
+
#elif DEBUGMODE==11 && defined(ANISOTROPIC)
|
|
2498
|
+
gl_FragColor.rgb=anisotropicOut.anisotropicNormal;
|
|
2499
|
+
#define DEBUGMODE_NORMALIZE
|
|
2500
|
+
#elif DEBUGMODE==12 && defined(ANISOTROPIC)
|
|
2501
|
+
gl_FragColor.rgb=anisotropicOut.anisotropicTangent;
|
|
2502
|
+
#define DEBUGMODE_NORMALIZE
|
|
2503
|
+
#elif DEBUGMODE==13 && defined(ANISOTROPIC)
|
|
2504
|
+
gl_FragColor.rgb=anisotropicOut.anisotropicBitangent;
|
|
2505
|
+
#define DEBUGMODE_NORMALIZE
|
|
2506
|
+
#elif DEBUGMODE==20 && defined(ALBEDO)
|
|
2507
|
+
gl_FragColor.rgb=albedoTexture.rgb;
|
|
2508
|
+
#ifndef GAMMAALBEDO
|
|
2509
|
+
#define DEBUGMODE_GAMMA
|
|
2510
|
+
#endif
|
|
2511
|
+
#elif DEBUGMODE==21 && defined(AMBIENT)
|
|
2512
|
+
gl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb;
|
|
2513
|
+
#elif DEBUGMODE==22 && defined(OPACITY)
|
|
2514
|
+
gl_FragColor.rgb=opacityMap.rgb;
|
|
2515
|
+
#elif DEBUGMODE==23 && defined(EMISSIVE)
|
|
2516
|
+
gl_FragColor.rgb=emissiveColorTex.rgb;
|
|
2517
|
+
#ifndef GAMMAEMISSIVE
|
|
2518
|
+
#define DEBUGMODE_GAMMA
|
|
2519
|
+
#endif
|
|
2520
|
+
#elif DEBUGMODE==24 && defined(LIGHTMAP)
|
|
2521
|
+
gl_FragColor.rgb=lightmapColor.rgb;
|
|
2522
|
+
#ifndef GAMMALIGHTMAP
|
|
2523
|
+
#define DEBUGMODE_GAMMA
|
|
2524
|
+
#endif
|
|
2525
|
+
#elif DEBUGMODE==25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)
|
|
2526
|
+
gl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb;
|
|
2527
|
+
#elif DEBUGMODE==26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)
|
|
2528
|
+
gl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb;
|
|
2529
|
+
#define DEBUGMODE_GAMMA
|
|
2530
|
+
#elif DEBUGMODE==27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)
|
|
2531
|
+
gl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0);
|
|
2532
|
+
#elif DEBUGMODE==28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
|
|
2533
|
+
gl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb;
|
|
2534
|
+
#elif DEBUGMODE==29 && defined(SHEEN) && defined(SHEEN_TEXTURE)
|
|
2535
|
+
gl_FragColor.rgb=sheenOut.sheenMapData.rgb;
|
|
2536
|
+
#elif DEBUGMODE==30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)
|
|
2537
|
+
gl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb;
|
|
2538
|
+
#elif DEBUGMODE==31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)
|
|
2539
|
+
gl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb;
|
|
2540
|
+
#elif DEBUGMODE==32 && defined(BUMP)
|
|
2541
|
+
gl_FragColor.rgb=texture2D(bumpSampler,vBumpUV).rgb;
|
|
2542
|
+
#elif DEBUGMODE==40 && defined(SS_REFRACTION)
|
|
2543
|
+
gl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb;
|
|
2544
|
+
#define DEBUGMODE_GAMMA
|
|
2545
|
+
#elif DEBUGMODE==41 && defined(REFLECTION)
|
|
2546
|
+
gl_FragColor.rgb=reflectionOut.environmentRadiance.rgb;
|
|
2547
|
+
#ifndef GAMMAREFLECTION
|
|
2548
|
+
#define DEBUGMODE_GAMMA
|
|
2549
|
+
#endif
|
|
2550
|
+
#elif DEBUGMODE==42 && defined(CLEARCOAT) && defined(REFLECTION)
|
|
2551
|
+
gl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb;
|
|
2552
|
+
#define DEBUGMODE_GAMMA
|
|
2553
|
+
#elif DEBUGMODE==50
|
|
2554
|
+
gl_FragColor.rgb=diffuseBase.rgb;
|
|
2555
|
+
#define DEBUGMODE_GAMMA
|
|
2556
|
+
#elif DEBUGMODE==51 && defined(SPECULARTERM)
|
|
2557
|
+
gl_FragColor.rgb=specularBase.rgb;
|
|
2558
|
+
#define DEBUGMODE_GAMMA
|
|
2559
|
+
#elif DEBUGMODE==52 && defined(CLEARCOAT)
|
|
2560
|
+
gl_FragColor.rgb=clearCoatBase.rgb;
|
|
2561
|
+
#define DEBUGMODE_GAMMA
|
|
2562
|
+
#elif DEBUGMODE==53 && defined(SHEEN)
|
|
2563
|
+
gl_FragColor.rgb=sheenBase.rgb;
|
|
2564
|
+
#define DEBUGMODE_GAMMA
|
|
2565
|
+
#elif DEBUGMODE==54 && defined(REFLECTION)
|
|
2566
|
+
gl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb;
|
|
2567
|
+
#ifndef GAMMAREFLECTION
|
|
2568
|
+
#define DEBUGMODE_GAMMA
|
|
2569
|
+
#endif
|
|
2570
|
+
#elif DEBUGMODE==60
|
|
2571
|
+
gl_FragColor.rgb=surfaceAlbedo.rgb;
|
|
2572
|
+
#define DEBUGMODE_GAMMA
|
|
2573
|
+
#elif DEBUGMODE==61
|
|
2574
|
+
gl_FragColor.rgb=clearcoatOut.specularEnvironmentR0;
|
|
2575
|
+
#define DEBUGMODE_GAMMA
|
|
2576
|
+
#elif DEBUGMODE==62 && defined(METALLICWORKFLOW)
|
|
2577
|
+
gl_FragColor.rgb=vec3(reflectivityOut.metallic);
|
|
2578
|
+
#elif DEBUGMODE==71 && defined(METALLICWORKFLOW)
|
|
2579
|
+
gl_FragColor.rgb=reflectivityOut.metallicF0;
|
|
2580
|
+
#elif DEBUGMODE==63
|
|
2581
|
+
gl_FragColor.rgb=vec3(roughness);
|
|
2582
|
+
#elif DEBUGMODE==64
|
|
2583
|
+
gl_FragColor.rgb=vec3(alphaG);
|
|
2584
|
+
#elif DEBUGMODE==65
|
|
2585
|
+
gl_FragColor.rgb=vec3(NdotV);
|
|
2586
|
+
#elif DEBUGMODE==66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
|
|
2587
|
+
gl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb;
|
|
2588
|
+
#define DEBUGMODE_GAMMA
|
|
2589
|
+
#elif DEBUGMODE==67 && defined(CLEARCOAT)
|
|
2590
|
+
gl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness);
|
|
2591
|
+
#elif DEBUGMODE==68 && defined(CLEARCOAT)
|
|
2592
|
+
gl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV);
|
|
2593
|
+
#elif DEBUGMODE==69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)
|
|
2594
|
+
gl_FragColor.rgb=subSurfaceOut.transmittance;
|
|
2595
|
+
#elif DEBUGMODE==70 && defined(SUBSURFACE) && defined(SS_REFRACTION)
|
|
2596
|
+
gl_FragColor.rgb=subSurfaceOut.refractionTransmittance;
|
|
2597
|
+
#elif DEBUGMODE==72
|
|
2598
|
+
gl_FragColor.rgb=vec3(microSurface);
|
|
2599
|
+
#elif DEBUGMODE==73
|
|
2600
|
+
gl_FragColor.rgb=vAlbedoColor.rgb;
|
|
2601
|
+
#define DEBUGMODE_GAMMA
|
|
2602
|
+
#elif DEBUGMODE==74 && !defined(METALLICWORKFLOW)
|
|
2603
|
+
gl_FragColor.rgb=vReflectivityColor.rgb;
|
|
2604
|
+
#define DEBUGMODE_GAMMA
|
|
2605
|
+
#elif DEBUGMODE==75
|
|
2606
|
+
gl_FragColor.rgb=vEmissiveColor.rgb;
|
|
2607
|
+
#define DEBUGMODE_GAMMA
|
|
2608
|
+
#elif DEBUGMODE==80 && defined(RADIANCEOCCLUSION)
|
|
2609
|
+
gl_FragColor.rgb=vec3(seo);
|
|
2610
|
+
#elif DEBUGMODE==81 && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
|
|
2611
|
+
gl_FragColor.rgb=vec3(eho);
|
|
2612
|
+
#elif DEBUGMODE==82 && defined(MS_BRDF_ENERGY_CONSERVATION)
|
|
2613
|
+
gl_FragColor.rgb=vec3(energyConservationFactor);
|
|
2614
|
+
#elif DEBUGMODE==83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
|
2615
|
+
gl_FragColor.rgb=baseSpecularEnvironmentReflectance;
|
|
2616
|
+
#define DEBUGMODE_GAMMA
|
|
2617
|
+
#elif DEBUGMODE==84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
|
2618
|
+
gl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance;
|
|
2619
|
+
#define DEBUGMODE_GAMMA
|
|
2620
|
+
#elif DEBUGMODE==85 && defined(SHEEN) && defined(REFLECTION)
|
|
2621
|
+
gl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance;
|
|
2622
|
+
#define DEBUGMODE_GAMMA
|
|
2623
|
+
#elif DEBUGMODE==86 && defined(ALPHABLEND)
|
|
2624
|
+
gl_FragColor.rgb=vec3(luminanceOverAlpha);
|
|
2625
|
+
#elif DEBUGMODE==87
|
|
2626
|
+
gl_FragColor.rgb=vec3(alpha);
|
|
2627
|
+
#elif DEBUGMODE==88 && defined(ALBEDO)
|
|
2628
|
+
gl_FragColor.rgb=vec3(albedoTexture.a);
|
|
2629
|
+
#elif DEBUGMODE==89
|
|
2630
|
+
gl_FragColor.rgb=aoOut.ambientOcclusionColor.rgb;
|
|
2631
|
+
#else
|
|
2632
|
+
float stripeWidth=30.;float stripePos=floor(gl_FragCoord.x/stripeWidth);float whichColor=mod(stripePos,2.);vec3 color1=vec3(.6,.2,.2);vec3 color2=vec3(.3,.1,.1);gl_FragColor.rgb=mix(color1,color2,whichColor);
|
|
2633
|
+
#endif
|
|
2634
|
+
gl_FragColor.rgb*=vDebugMode.y;
|
|
2635
|
+
#ifdef DEBUGMODE_NORMALIZE
|
|
2636
|
+
gl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;
|
|
2637
|
+
#endif
|
|
2638
|
+
#ifdef DEBUGMODE_GAMMA
|
|
2639
|
+
gl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);
|
|
2640
|
+
#endif
|
|
2641
|
+
gl_FragColor.a=1.0;
|
|
2642
|
+
#ifdef PREPASS
|
|
2643
|
+
gl_FragData[0]=toLinearSpace(gl_FragColor);
|
|
2644
|
+
gl_FragData[1]=vec4(0.,0.,0.,0.);
|
|
2645
|
+
#endif
|
|
2646
|
+
#ifdef DEBUGMODE_FORCERETURN
|
|
2647
|
+
return;
|
|
2648
|
+
#endif
|
|
2649
|
+
}
|
|
2650
|
+
#endif
|
|
2651
|
+
`;
|
|
2652
|
+
e.IncludesShadersStore[G] || (e.IncludesShadersStore[G] = me);
|
|
2653
|
+
const i = "pbrPixelShader", y = `#define PBR_FRAGMENT_SHADER
|
|
2654
|
+
#define CUSTOM_FRAGMENT_EXTENSION
|
|
2655
|
+
#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
|
|
2656
|
+
#extension GL_OES_standard_derivatives : enable
|
|
2657
|
+
#endif
|
|
2658
|
+
#ifdef LODBASEDMICROSFURACE
|
|
2659
|
+
#extension GL_EXT_shader_texture_lod : enable
|
|
2660
|
+
#endif
|
|
2661
|
+
#define CUSTOM_FRAGMENT_BEGIN
|
|
2662
|
+
#ifdef LOGARITHMICDEPTH
|
|
2663
|
+
#extension GL_EXT_frag_depth : enable
|
|
2664
|
+
#endif
|
|
2665
|
+
#include<prePassDeclaration>[SCENE_MRT_COUNT]
|
|
2666
|
+
precision highp float;
|
|
2667
|
+
#include<oitDeclaration>
|
|
2668
|
+
#ifndef FROMLINEARSPACE
|
|
2669
|
+
#define FROMLINEARSPACE
|
|
2670
|
+
#endif
|
|
2671
|
+
#include<__decl__pbrFragment>
|
|
2672
|
+
#include<pbrFragmentExtraDeclaration>
|
|
2673
|
+
#include<__decl__lightFragment>[0..maxSimultaneousLights]
|
|
2674
|
+
#include<pbrFragmentSamplersDeclaration>
|
|
2675
|
+
#include<imageProcessingDeclaration>
|
|
2676
|
+
#include<clipPlaneFragmentDeclaration>
|
|
2677
|
+
#include<logDepthDeclaration>
|
|
2678
|
+
#include<fogFragmentDeclaration>
|
|
2679
|
+
#include<helperFunctions>
|
|
2680
|
+
#include<subSurfaceScatteringFunctions>
|
|
2681
|
+
#include<importanceSampling>
|
|
2682
|
+
#include<pbrHelperFunctions>
|
|
2683
|
+
#include<imageProcessingFunctions>
|
|
2684
|
+
#include<shadowsFragmentFunctions>
|
|
2685
|
+
#include<harmonicsFunctions>
|
|
2686
|
+
#include<pbrDirectLightingSetupFunctions>
|
|
2687
|
+
#include<pbrDirectLightingFalloffFunctions>
|
|
2688
|
+
#include<pbrBRDFFunctions>
|
|
2689
|
+
#include<hdrFilteringFunctions>
|
|
2690
|
+
#include<pbrDirectLightingFunctions>
|
|
2691
|
+
#include<pbrIBLFunctions>
|
|
2692
|
+
#include<bumpFragmentMainFunctions>
|
|
2693
|
+
#include<bumpFragmentFunctions>
|
|
2694
|
+
#ifdef REFLECTION
|
|
2695
|
+
#include<reflectionFunction>
|
|
2696
|
+
#endif
|
|
2697
|
+
#define CUSTOM_FRAGMENT_DEFINITIONS
|
|
2698
|
+
#include<pbrBlockAlbedoOpacity>
|
|
2699
|
+
#include<pbrBlockReflectivity>
|
|
2700
|
+
#include<pbrBlockAmbientOcclusion>
|
|
2701
|
+
#include<pbrBlockAlphaFresnel>
|
|
2702
|
+
#include<pbrBlockAnisotropic>
|
|
2703
|
+
#include<pbrBlockReflection>
|
|
2704
|
+
#include<pbrBlockSheen>
|
|
2705
|
+
#include<pbrBlockClearcoat>
|
|
2706
|
+
#include<pbrBlockIridescence>
|
|
2707
|
+
#include<pbrBlockSubSurface>
|
|
2708
|
+
void main(void) {
|
|
2709
|
+
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
|
2710
|
+
#include<clipPlaneFragment>
|
|
2711
|
+
#include<pbrBlockNormalGeometric>
|
|
2712
|
+
#include<bumpFragment>
|
|
2713
|
+
#include<pbrBlockNormalFinal>
|
|
2714
|
+
albedoOpacityOutParams albedoOpacityOut;
|
|
2715
|
+
#ifdef ALBEDO
|
|
2716
|
+
vec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);
|
|
2717
|
+
#endif
|
|
2718
|
+
#ifdef BASE_WEIGHT
|
|
2719
|
+
vec4 baseWeightTexture=texture2D(baseWeightSampler,vBaseWeightUV+uvOffset);
|
|
2720
|
+
#endif
|
|
2721
|
+
#ifdef OPACITY
|
|
2722
|
+
vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
|
|
2723
|
+
#endif
|
|
2724
|
+
#ifdef DECAL
|
|
2725
|
+
vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);
|
|
2726
|
+
#endif
|
|
2727
|
+
albedoOpacityOut=albedoOpacityBlock(
|
|
2728
|
+
vAlbedoColor
|
|
2729
|
+
#ifdef ALBEDO
|
|
2730
|
+
,albedoTexture
|
|
2731
|
+
,vAlbedoInfos
|
|
2732
|
+
#endif
|
|
2733
|
+
,baseWeight
|
|
2734
|
+
#ifdef BASE_WEIGHT
|
|
2735
|
+
,baseWeightTexture
|
|
2736
|
+
,vBaseWeightInfos
|
|
2737
|
+
#endif
|
|
2738
|
+
#ifdef OPACITY
|
|
2739
|
+
,opacityMap
|
|
2740
|
+
,vOpacityInfos
|
|
2741
|
+
#endif
|
|
2742
|
+
#ifdef DETAIL
|
|
2743
|
+
,detailColor
|
|
2744
|
+
,vDetailInfos
|
|
2745
|
+
#endif
|
|
2746
|
+
#ifdef DECAL
|
|
2747
|
+
,decalColor
|
|
2748
|
+
,vDecalInfos
|
|
2749
|
+
#endif
|
|
2750
|
+
);vec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;float alpha=albedoOpacityOut.alpha;
|
|
2751
|
+
#define CUSTOM_FRAGMENT_UPDATE_ALPHA
|
|
2752
|
+
#include<depthPrePass>
|
|
2753
|
+
#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
|
|
2754
|
+
ambientOcclusionOutParams aoOut;
|
|
2755
|
+
#ifdef AMBIENT
|
|
2756
|
+
vec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb;
|
|
2757
|
+
#endif
|
|
2758
|
+
aoOut=ambientOcclusionBlock(
|
|
2759
|
+
#ifdef AMBIENT
|
|
2760
|
+
ambientOcclusionColorMap,
|
|
2761
|
+
vAmbientInfos
|
|
2762
|
+
#endif
|
|
2763
|
+
);
|
|
2764
|
+
#include<pbrBlockLightmapInit>
|
|
2765
|
+
#ifdef UNLIT
|
|
2766
|
+
vec3 diffuseBase=vec3(1.,1.,1.);
|
|
2767
|
+
#else
|
|
2768
|
+
vec3 baseColor=surfaceAlbedo;reflectivityOutParams reflectivityOut;
|
|
2769
|
+
#if defined(REFLECTIVITY)
|
|
2770
|
+
vec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);vec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;
|
|
2771
|
+
#ifndef METALLICWORKFLOW
|
|
2772
|
+
#ifdef REFLECTIVITY_GAMMA
|
|
2773
|
+
surfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);
|
|
2774
|
+
#endif
|
|
2775
|
+
surfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;
|
|
2776
|
+
#endif
|
|
2777
|
+
#endif
|
|
2778
|
+
#if defined(MICROSURFACEMAP)
|
|
2779
|
+
vec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;
|
|
2780
|
+
#endif
|
|
2781
|
+
#ifdef METALLICWORKFLOW
|
|
2782
|
+
vec4 metallicReflectanceFactors=vMetallicReflectanceFactors;
|
|
2783
|
+
#ifdef REFLECTANCE
|
|
2784
|
+
vec4 reflectanceFactorsMap=texture2D(reflectanceSampler,vReflectanceUV+uvOffset);
|
|
2785
|
+
#ifdef REFLECTANCE_GAMMA
|
|
2786
|
+
reflectanceFactorsMap=toLinearSpace(reflectanceFactorsMap);
|
|
2787
|
+
#endif
|
|
2788
|
+
metallicReflectanceFactors.rgb*=reflectanceFactorsMap.rgb;
|
|
2789
|
+
#endif
|
|
2790
|
+
#ifdef METALLIC_REFLECTANCE
|
|
2791
|
+
vec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);
|
|
2792
|
+
#ifdef METALLIC_REFLECTANCE_GAMMA
|
|
2793
|
+
metallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);
|
|
2794
|
+
#endif
|
|
2795
|
+
#ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY
|
|
2796
|
+
metallicReflectanceFactors.rgb*=metallicReflectanceFactorsMap.rgb;
|
|
2797
|
+
#endif
|
|
2798
|
+
metallicReflectanceFactors.a*=metallicReflectanceFactorsMap.a;
|
|
2799
|
+
#endif
|
|
2800
|
+
#endif
|
|
2801
|
+
#ifdef BASE_DIFFUSE_ROUGHNESS
|
|
2802
|
+
float baseDiffuseRoughnessTexture=texture2D(baseDiffuseRoughnessSampler,vBaseDiffuseRoughnessUV+uvOffset).r;
|
|
2803
|
+
#endif
|
|
2804
|
+
reflectivityOut=reflectivityBlock(
|
|
2805
|
+
vReflectivityColor
|
|
2806
|
+
#ifdef METALLICWORKFLOW
|
|
2807
|
+
,surfaceAlbedo
|
|
2808
|
+
,metallicReflectanceFactors
|
|
2809
|
+
#endif
|
|
2810
|
+
,baseDiffuseRoughness
|
|
2811
|
+
#ifdef BASE_DIFFUSE_ROUGHNESS
|
|
2812
|
+
,baseDiffuseRoughnessTexture
|
|
2813
|
+
,vBaseDiffuseRoughnessInfos
|
|
2814
|
+
#endif
|
|
2815
|
+
#ifdef REFLECTIVITY
|
|
2816
|
+
,vReflectivityInfos
|
|
2817
|
+
,surfaceMetallicOrReflectivityColorMap
|
|
2818
|
+
#endif
|
|
2819
|
+
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
|
|
2820
|
+
,aoOut.ambientOcclusionColor
|
|
2821
|
+
#endif
|
|
2822
|
+
#ifdef MICROSURFACEMAP
|
|
2823
|
+
,microSurfaceTexel
|
|
2824
|
+
#endif
|
|
2825
|
+
#ifdef DETAIL
|
|
2826
|
+
,detailColor
|
|
2827
|
+
,vDetailInfos
|
|
2828
|
+
#endif
|
|
2829
|
+
);float microSurface=reflectivityOut.microSurface;float roughness=reflectivityOut.roughness;float diffuseRoughness=reflectivityOut.diffuseRoughness;
|
|
2830
|
+
#ifdef METALLICWORKFLOW
|
|
2831
|
+
surfaceAlbedo=reflectivityOut.surfaceAlbedo;
|
|
2832
|
+
#endif
|
|
2833
|
+
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
|
|
2834
|
+
aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
|
|
2835
|
+
#endif
|
|
2836
|
+
#ifdef ALPHAFRESNEL
|
|
2837
|
+
#if defined(ALPHATEST) || defined(ALPHABLEND)
|
|
2838
|
+
alphaFresnelOutParams alphaFresnelOut;alphaFresnelOut=alphaFresnelBlock(
|
|
2839
|
+
normalW,
|
|
2840
|
+
viewDirectionW,
|
|
2841
|
+
alpha,
|
|
2842
|
+
microSurface
|
|
2843
|
+
);alpha=alphaFresnelOut.alpha;
|
|
2844
|
+
#endif
|
|
2845
|
+
#endif
|
|
2846
|
+
#include<pbrBlockGeometryInfo>
|
|
2847
|
+
#ifdef ANISOTROPIC
|
|
2848
|
+
anisotropicOutParams anisotropicOut;
|
|
2849
|
+
#ifdef ANISOTROPIC_TEXTURE
|
|
2850
|
+
vec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;
|
|
2851
|
+
#endif
|
|
2852
|
+
anisotropicOut=anisotropicBlock(
|
|
2853
|
+
vAnisotropy,
|
|
2854
|
+
roughness,
|
|
2855
|
+
#ifdef ANISOTROPIC_TEXTURE
|
|
2856
|
+
anisotropyMapData,
|
|
2857
|
+
#endif
|
|
2858
|
+
TBN,
|
|
2859
|
+
normalW,
|
|
2860
|
+
viewDirectionW
|
|
2861
|
+
);
|
|
2862
|
+
#endif
|
|
2863
|
+
#ifdef REFLECTION
|
|
2864
|
+
reflectionOutParams reflectionOut;
|
|
2865
|
+
#ifndef USE_CUSTOM_REFLECTION
|
|
2866
|
+
reflectionOut=reflectionBlock(
|
|
2867
|
+
vPositionW
|
|
2868
|
+
,normalW
|
|
2869
|
+
,alphaG
|
|
2870
|
+
,vReflectionMicrosurfaceInfos
|
|
2871
|
+
,vReflectionInfos
|
|
2872
|
+
,vReflectionColor
|
|
2873
|
+
#ifdef ANISOTROPIC
|
|
2874
|
+
,anisotropicOut
|
|
2875
|
+
#endif
|
|
2876
|
+
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
|
2877
|
+
,NdotVUnclamped
|
|
2878
|
+
#endif
|
|
2879
|
+
#ifdef LINEARSPECULARREFLECTION
|
|
2880
|
+
,roughness
|
|
2881
|
+
#endif
|
|
2882
|
+
,reflectionSampler
|
|
2883
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
2884
|
+
,vEnvironmentIrradiance
|
|
2885
|
+
#endif
|
|
2886
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
2887
|
+
,reflectionMatrix
|
|
2888
|
+
#endif
|
|
2889
|
+
#ifdef USEIRRADIANCEMAP
|
|
2890
|
+
,irradianceSampler
|
|
2891
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
2892
|
+
,vReflectionDominantDirection
|
|
2893
|
+
#endif
|
|
2894
|
+
#endif
|
|
2895
|
+
#ifndef LODBASEDMICROSFURACE
|
|
2896
|
+
,reflectionSamplerLow
|
|
2897
|
+
,reflectionSamplerHigh
|
|
2898
|
+
#endif
|
|
2899
|
+
#ifdef REALTIME_FILTERING
|
|
2900
|
+
,vReflectionFilteringInfo
|
|
2901
|
+
#ifdef IBL_CDF_FILTERING
|
|
2902
|
+
,icdfSampler
|
|
2903
|
+
#endif
|
|
2904
|
+
#endif
|
|
2905
|
+
,viewDirectionW
|
|
2906
|
+
,diffuseRoughness
|
|
2907
|
+
,baseColor
|
|
2908
|
+
);
|
|
2909
|
+
#else
|
|
2910
|
+
#define CUSTOM_REFLECTION
|
|
2911
|
+
#endif
|
|
2912
|
+
#endif
|
|
2913
|
+
#include<pbrBlockReflectance0>
|
|
2914
|
+
#ifdef SHEEN
|
|
2915
|
+
sheenOutParams sheenOut;
|
|
2916
|
+
#ifdef SHEEN_TEXTURE
|
|
2917
|
+
vec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset);
|
|
2918
|
+
#endif
|
|
2919
|
+
#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
|
2920
|
+
vec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;
|
|
2921
|
+
#endif
|
|
2922
|
+
sheenOut=sheenBlock(
|
|
2923
|
+
vSheenColor
|
|
2924
|
+
#ifdef SHEEN_ROUGHNESS
|
|
2925
|
+
,vSheenRoughness
|
|
2926
|
+
#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
|
2927
|
+
,sheenMapRoughnessData
|
|
2928
|
+
#endif
|
|
2929
|
+
#endif
|
|
2930
|
+
,roughness
|
|
2931
|
+
#ifdef SHEEN_TEXTURE
|
|
2932
|
+
,sheenMapData
|
|
2933
|
+
,vSheenInfos.y
|
|
2934
|
+
#endif
|
|
2935
|
+
,reflectanceF0
|
|
2936
|
+
#ifdef SHEEN_LINKWITHALBEDO
|
|
2937
|
+
,baseColor
|
|
2938
|
+
,surfaceAlbedo
|
|
2939
|
+
#endif
|
|
2940
|
+
#ifdef ENVIRONMENTBRDF
|
|
2941
|
+
,NdotV
|
|
2942
|
+
,environmentBrdf
|
|
2943
|
+
#endif
|
|
2944
|
+
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
|
2945
|
+
,AARoughnessFactors
|
|
2946
|
+
,vReflectionMicrosurfaceInfos
|
|
2947
|
+
,vReflectionInfos
|
|
2948
|
+
,vReflectionColor
|
|
2949
|
+
,vLightingIntensity
|
|
2950
|
+
,reflectionSampler
|
|
2951
|
+
,reflectionOut.reflectionCoords
|
|
2952
|
+
,NdotVUnclamped
|
|
2953
|
+
#ifndef LODBASEDMICROSFURACE
|
|
2954
|
+
,reflectionSamplerLow
|
|
2955
|
+
,reflectionSamplerHigh
|
|
2956
|
+
#endif
|
|
2957
|
+
#ifdef REALTIME_FILTERING
|
|
2958
|
+
,vReflectionFilteringInfo
|
|
2959
|
+
#endif
|
|
2960
|
+
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
|
|
2961
|
+
,seo
|
|
2962
|
+
#endif
|
|
2963
|
+
#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
|
|
2964
|
+
,eho
|
|
2965
|
+
#endif
|
|
2966
|
+
#endif
|
|
2967
|
+
);
|
|
2968
|
+
#ifdef SHEEN_LINKWITHALBEDO
|
|
2969
|
+
surfaceAlbedo=sheenOut.surfaceAlbedo;
|
|
2970
|
+
#endif
|
|
2971
|
+
#endif
|
|
2972
|
+
#ifdef CLEARCOAT
|
|
2973
|
+
#ifdef CLEARCOAT_TEXTURE
|
|
2974
|
+
vec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;
|
|
2975
|
+
#endif
|
|
2976
|
+
#endif
|
|
2977
|
+
#ifdef IRIDESCENCE
|
|
2978
|
+
iridescenceOutParams iridescenceOut;
|
|
2979
|
+
#ifdef IRIDESCENCE_TEXTURE
|
|
2980
|
+
vec2 iridescenceMapData=texture2D(iridescenceSampler,vIridescenceUV+uvOffset).rg*vIridescenceInfos.y;
|
|
2981
|
+
#endif
|
|
2982
|
+
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
|
|
2983
|
+
vec2 iridescenceThicknessMapData=texture2D(iridescenceThicknessSampler,vIridescenceThicknessUV+uvOffset).rg*vIridescenceInfos.w;
|
|
2984
|
+
#endif
|
|
2985
|
+
iridescenceOut=iridescenceBlock(
|
|
2986
|
+
vIridescenceParams
|
|
2987
|
+
,NdotV
|
|
2988
|
+
,specularEnvironmentR0
|
|
2989
|
+
#ifdef IRIDESCENCE_TEXTURE
|
|
2990
|
+
,iridescenceMapData
|
|
2991
|
+
#endif
|
|
2992
|
+
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
|
|
2993
|
+
,iridescenceThicknessMapData
|
|
2994
|
+
#endif
|
|
2995
|
+
#ifdef CLEARCOAT
|
|
2996
|
+
,NdotVUnclamped
|
|
2997
|
+
,vClearCoatParams
|
|
2998
|
+
#ifdef CLEARCOAT_TEXTURE
|
|
2999
|
+
,clearCoatMapData
|
|
3000
|
+
#endif
|
|
3001
|
+
#endif
|
|
3002
|
+
);float iridescenceIntensity=iridescenceOut.iridescenceIntensity;specularEnvironmentR0=iridescenceOut.specularEnvironmentR0;
|
|
3003
|
+
#endif
|
|
3004
|
+
clearcoatOutParams clearcoatOut;
|
|
3005
|
+
#ifdef CLEARCOAT
|
|
3006
|
+
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
|
3007
|
+
vec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;
|
|
3008
|
+
#endif
|
|
3009
|
+
#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
|
|
3010
|
+
vec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);
|
|
3011
|
+
#endif
|
|
3012
|
+
#ifdef CLEARCOAT_BUMP
|
|
3013
|
+
vec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);
|
|
3014
|
+
#endif
|
|
3015
|
+
clearcoatOut=clearcoatBlock(
|
|
3016
|
+
vPositionW
|
|
3017
|
+
,geometricNormalW
|
|
3018
|
+
,viewDirectionW
|
|
3019
|
+
,vClearCoatParams
|
|
3020
|
+
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
|
3021
|
+
,clearCoatMapRoughnessData
|
|
3022
|
+
#endif
|
|
3023
|
+
,specularEnvironmentR0
|
|
3024
|
+
#ifdef CLEARCOAT_TEXTURE
|
|
3025
|
+
,clearCoatMapData
|
|
3026
|
+
#endif
|
|
3027
|
+
#ifdef CLEARCOAT_TINT
|
|
3028
|
+
,vClearCoatTintParams
|
|
3029
|
+
,clearCoatColorAtDistance
|
|
3030
|
+
,vClearCoatRefractionParams
|
|
3031
|
+
#ifdef CLEARCOAT_TINT_TEXTURE
|
|
3032
|
+
,clearCoatTintMapData
|
|
3033
|
+
#endif
|
|
3034
|
+
#endif
|
|
3035
|
+
#ifdef CLEARCOAT_BUMP
|
|
3036
|
+
,vClearCoatBumpInfos
|
|
3037
|
+
,clearCoatBumpMapData
|
|
3038
|
+
,vClearCoatBumpUV
|
|
3039
|
+
#if defined(TANGENT) && defined(NORMAL)
|
|
3040
|
+
,vTBN
|
|
3041
|
+
#else
|
|
3042
|
+
,vClearCoatTangentSpaceParams
|
|
3043
|
+
#endif
|
|
3044
|
+
#ifdef OBJECTSPACE_NORMALMAP
|
|
3045
|
+
,normalMatrix
|
|
3046
|
+
#endif
|
|
3047
|
+
#endif
|
|
3048
|
+
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
|
|
3049
|
+
,faceNormal
|
|
3050
|
+
#endif
|
|
3051
|
+
#ifdef REFLECTION
|
|
3052
|
+
,vReflectionMicrosurfaceInfos
|
|
3053
|
+
,vReflectionInfos
|
|
3054
|
+
,vReflectionColor
|
|
3055
|
+
,vLightingIntensity
|
|
3056
|
+
,reflectionSampler
|
|
3057
|
+
#ifndef LODBASEDMICROSFURACE
|
|
3058
|
+
,reflectionSamplerLow
|
|
3059
|
+
,reflectionSamplerHigh
|
|
3060
|
+
#endif
|
|
3061
|
+
#ifdef REALTIME_FILTERING
|
|
3062
|
+
,vReflectionFilteringInfo
|
|
3063
|
+
#endif
|
|
3064
|
+
#endif
|
|
3065
|
+
#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
|
|
3066
|
+
,(gl_FrontFacing ? 1. : -1.)
|
|
3067
|
+
#endif
|
|
3068
|
+
);
|
|
3069
|
+
#else
|
|
3070
|
+
clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
|
|
3071
|
+
#endif
|
|
3072
|
+
#include<pbrBlockReflectance>
|
|
3073
|
+
subSurfaceOutParams subSurfaceOut;
|
|
3074
|
+
#ifdef SUBSURFACE
|
|
3075
|
+
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
|
3076
|
+
vec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);
|
|
3077
|
+
#endif
|
|
3078
|
+
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
|
|
3079
|
+
vec4 refractionIntensityMap=texture2D(refractionIntensitySampler,vRefractionIntensityUV+uvOffset);
|
|
3080
|
+
#endif
|
|
3081
|
+
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
|
|
3082
|
+
vec4 translucencyIntensityMap=texture2D(translucencyIntensitySampler,vTranslucencyIntensityUV+uvOffset);
|
|
3083
|
+
#endif
|
|
3084
|
+
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
|
3085
|
+
vec4 translucencyColorMap=texture2D(translucencyColorSampler,vTranslucencyColorUV+uvOffset);
|
|
3086
|
+
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE_GAMMA
|
|
3087
|
+
translucencyColorMap=toLinearSpace(translucencyColorMap);
|
|
3088
|
+
#endif
|
|
3089
|
+
#endif
|
|
3090
|
+
#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
|
|
3091
|
+
vec3 vSpecularEnvironmentReflectance=vec3(max(colorSpecularEnvironmentReflectance.r,max(colorSpecularEnvironmentReflectance.g,colorSpecularEnvironmentReflectance.b)));
|
|
3092
|
+
#endif
|
|
3093
|
+
subSurfaceOut=subSurfaceBlock(
|
|
3094
|
+
vSubSurfaceIntensity
|
|
3095
|
+
,vThicknessParam
|
|
3096
|
+
,vTintColor
|
|
3097
|
+
,normalW
|
|
3098
|
+
#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
|
|
3099
|
+
,vSpecularEnvironmentReflectance
|
|
3100
|
+
#else
|
|
3101
|
+
,baseSpecularEnvironmentReflectance
|
|
3102
|
+
#endif
|
|
3103
|
+
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
|
3104
|
+
,thicknessMap
|
|
3105
|
+
#endif
|
|
3106
|
+
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
|
|
3107
|
+
,refractionIntensityMap
|
|
3108
|
+
#endif
|
|
3109
|
+
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
|
|
3110
|
+
,translucencyIntensityMap
|
|
3111
|
+
#endif
|
|
3112
|
+
#ifdef REFLECTION
|
|
3113
|
+
#ifdef SS_TRANSLUCENCY
|
|
3114
|
+
,reflectionMatrix
|
|
3115
|
+
#ifdef USESPHERICALFROMREFLECTIONMAP
|
|
3116
|
+
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
|
|
3117
|
+
,reflectionOut.irradianceVector
|
|
3118
|
+
#endif
|
|
3119
|
+
#if defined(REALTIME_FILTERING)
|
|
3120
|
+
,reflectionSampler
|
|
3121
|
+
,vReflectionFilteringInfo
|
|
3122
|
+
#ifdef IBL_CDF_FILTERING
|
|
3123
|
+
,icdfSampler
|
|
3124
|
+
#endif
|
|
3125
|
+
#endif
|
|
3126
|
+
#endif
|
|
3127
|
+
#ifdef USEIRRADIANCEMAP
|
|
3128
|
+
,irradianceSampler
|
|
3129
|
+
#endif
|
|
3130
|
+
#endif
|
|
3131
|
+
#endif
|
|
3132
|
+
#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
|
|
3133
|
+
,surfaceAlbedo
|
|
3134
|
+
#endif
|
|
3135
|
+
#ifdef SS_REFRACTION
|
|
3136
|
+
,vPositionW
|
|
3137
|
+
,viewDirectionW
|
|
3138
|
+
,view
|
|
3139
|
+
,vRefractionInfos
|
|
3140
|
+
,refractionMatrix
|
|
3141
|
+
,vRefractionMicrosurfaceInfos
|
|
3142
|
+
,vLightingIntensity
|
|
3143
|
+
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
|
3144
|
+
,alpha
|
|
3145
|
+
#endif
|
|
3146
|
+
#ifdef SS_LODINREFRACTIONALPHA
|
|
3147
|
+
,NdotVUnclamped
|
|
3148
|
+
#endif
|
|
3149
|
+
#ifdef SS_LINEARSPECULARREFRACTION
|
|
3150
|
+
,roughness
|
|
3151
|
+
#endif
|
|
3152
|
+
,alphaG
|
|
3153
|
+
,refractionSampler
|
|
3154
|
+
#ifndef LODBASEDMICROSFURACE
|
|
3155
|
+
,refractionSamplerLow
|
|
3156
|
+
,refractionSamplerHigh
|
|
3157
|
+
#endif
|
|
3158
|
+
#ifdef ANISOTROPIC
|
|
3159
|
+
,anisotropicOut
|
|
3160
|
+
#endif
|
|
3161
|
+
#ifdef REALTIME_FILTERING
|
|
3162
|
+
,vRefractionFilteringInfo
|
|
3163
|
+
#endif
|
|
3164
|
+
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
|
3165
|
+
,vRefractionPosition
|
|
3166
|
+
,vRefractionSize
|
|
3167
|
+
#endif
|
|
3168
|
+
#ifdef SS_DISPERSION
|
|
3169
|
+
,dispersion
|
|
3170
|
+
#endif
|
|
3171
|
+
#endif
|
|
3172
|
+
#ifdef SS_TRANSLUCENCY
|
|
3173
|
+
,vDiffusionDistance
|
|
3174
|
+
,vTranslucencyColor
|
|
3175
|
+
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
|
3176
|
+
,translucencyColorMap
|
|
3177
|
+
#endif
|
|
3178
|
+
#endif
|
|
3179
|
+
);
|
|
3180
|
+
#ifdef SS_REFRACTION
|
|
3181
|
+
surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
|
|
3182
|
+
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
|
3183
|
+
alpha=subSurfaceOut.alpha;
|
|
3184
|
+
#endif
|
|
3185
|
+
#endif
|
|
3186
|
+
#else
|
|
3187
|
+
subSurfaceOut.specularEnvironmentReflectance=colorSpecularEnvironmentReflectance;
|
|
3188
|
+
#endif
|
|
3189
|
+
#include<pbrBlockDirectLighting>
|
|
3190
|
+
#include<lightFragment>[0..maxSimultaneousLights]
|
|
3191
|
+
#include<pbrBlockFinalLitComponents>
|
|
3192
|
+
#endif
|
|
3193
|
+
#include<pbrBlockFinalUnlitComponents>
|
|
3194
|
+
#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION
|
|
3195
|
+
#include<pbrBlockFinalColorComposition>
|
|
3196
|
+
#include<logDepthFragment>
|
|
3197
|
+
#include<fogFragment>(color,finalColor)
|
|
3198
|
+
#include<pbrBlockImageProcessing>
|
|
3199
|
+
#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
|
|
3200
|
+
#ifdef PREPASS
|
|
3201
|
+
#include<pbrBlockPrePass>
|
|
3202
|
+
#endif
|
|
3203
|
+
#if !defined(PREPASS) || defined(WEBGL2)
|
|
3204
|
+
gl_FragColor=finalColor;
|
|
3205
|
+
#endif
|
|
3206
|
+
#include<oitFragment>
|
|
3207
|
+
#if ORDER_INDEPENDENT_TRANSPARENCY
|
|
3208
|
+
if (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);} else {backColor+=finalColor;}
|
|
3209
|
+
#endif
|
|
3210
|
+
#include<pbrDebug>
|
|
3211
|
+
#define CUSTOM_FRAGMENT_MAIN_END
|
|
3212
|
+
}
|
|
3213
|
+
`;
|
|
3214
|
+
e.ShadersStore[i] || (e.ShadersStore[i] = y);
|
|
3215
|
+
const Le = { name: i, shader: y };
|
|
3216
|
+
export {
|
|
3217
|
+
Le as pbrPixelShader
|
|
3218
|
+
};
|
|
3219
|
+
//# sourceMappingURL=pbr.fragment-siOdCYqI.js.map
|