three-gpu-pathtracer 0.0.14 → 0.0.16
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/LICENSE +21 -21
- package/README.md +1004 -981
- package/build/index.module.js +7413 -6902
- package/build/index.module.js.map +1 -1
- package/build/index.umd.cjs +7446 -6933
- package/build/index.umd.cjs.map +1 -1
- package/package.json +73 -73
- package/src/core/DynamicPathTracingSceneGenerator.js +119 -119
- package/src/core/MaterialReducer.js +256 -256
- package/src/core/PathTracingRenderer.js +346 -346
- package/src/core/PathTracingSceneGenerator.js +69 -69
- package/src/core/QuiltPathTracingRenderer.js +223 -223
- package/src/detectors/CompatibilityDetector.js +38 -0
- package/src/detectors/MaterialCompileDetector.js +50 -0
- package/src/detectors/PrecisionDetector.js +85 -0
- package/src/detectors/PrecisionMaterial.js +160 -0
- package/src/index.js +40 -36
- package/src/materials/MaterialBase.js +56 -56
- package/src/materials/debug/GraphMaterial.js +243 -243
- package/src/materials/fullscreen/AlphaDisplayMaterial.js +50 -48
- package/src/materials/fullscreen/BlendMaterial.js +67 -67
- package/src/materials/fullscreen/DenoiseMaterial.js +142 -142
- package/src/materials/fullscreen/GradientMapMaterial.js +82 -0
- package/src/materials/pathtracing/LambertPathTracingMaterial.js +296 -296
- package/src/materials/pathtracing/PhysicalPathTracingMaterial.js +118 -196
- package/src/materials/pathtracing/glsl/attenuateHit.glsl.js +177 -179
- package/src/materials/pathtracing/glsl/cameraUtils.glsl.js +84 -81
- package/src/materials/pathtracing/glsl/directLightContribution.glsl.js +93 -0
- package/src/materials/pathtracing/glsl/getSurfaceRecord.glsl.js +323 -317
- package/src/materials/pathtracing/glsl/renderStructs.glsl.js +50 -0
- package/src/materials/pathtracing/glsl/traceScene.glsl.js +52 -54
- package/src/materials/surface/AmbientOcclusionMaterial.js +207 -207
- package/src/materials/surface/FogVolumeMaterial.js +23 -23
- package/src/objects/EquirectCamera.js +13 -13
- package/src/objects/PhysicalCamera.js +42 -28
- package/src/objects/PhysicalSpotLight.js +25 -14
- package/src/objects/ShapedAreaLight.js +22 -12
- package/src/shader/bsdf/bsdfSampling.glsl.js +499 -490
- package/src/shader/bsdf/fog.glsl.js +22 -23
- package/src/shader/bsdf/ggx.glsl.js +102 -102
- package/src/shader/bsdf/iridescence.glsl.js +135 -135
- package/src/shader/bsdf/sheen.glsl.js +98 -98
- package/src/shader/common/arraySamplerTexelFetch.glsl.js +25 -25
- package/src/shader/common/bvhAnyHit.glsl.js +76 -76
- package/src/shader/common/fresnel.glsl.js +98 -98
- package/src/shader/common/intersectShapes.glsl.js +62 -62
- package/src/shader/common/math.glsl.js +81 -81
- package/src/shader/common/utils.glsl.js +116 -116
- package/src/shader/rand/pcg.glsl.js +57 -57
- package/src/shader/rand/sobol.glsl.js +256 -256
- package/src/shader/sampling/equirectSampling.glsl.js +62 -62
- package/src/shader/sampling/lightSampling.glsl.js +223 -223
- package/src/shader/sampling/shapeSampling.glsl.js +86 -86
- package/src/shader/structs/cameraStruct.glsl.js +13 -13
- package/src/shader/structs/equirectStruct.glsl.js +13 -14
- package/src/shader/structs/fogMaterialBvh.glsl.js +62 -62
- package/src/shader/structs/lightsStruct.glsl.js +78 -78
- package/src/shader/structs/materialStruct.glsl.js +207 -207
- package/src/textures/GradientEquirectTexture.js +35 -35
- package/src/textures/ProceduralEquirectTexture.js +75 -75
- package/src/uniforms/AttributesTextureArray.js +35 -35
- package/src/uniforms/EquirectHdrInfoUniform.js +269 -277
- package/src/uniforms/FloatAttributeTextureArray.js +169 -169
- package/src/uniforms/IESProfilesTexture.js +100 -100
- package/src/uniforms/LightsInfoUniformStruct.js +212 -212
- package/src/uniforms/MaterialsTexture.js +503 -503
- package/src/uniforms/PhysicalCameraUniform.js +36 -36
- package/src/uniforms/RenderTarget2DArray.js +97 -97
- package/src/uniforms/utils.js +30 -30
- package/src/utils/BlurredEnvMapGenerator.js +116 -116
- package/src/utils/GeometryPreparationUtils.js +214 -214
- package/src/utils/IESLoader.js +325 -325
- package/src/utils/SobolNumberMapGenerator.js +80 -80
- package/src/utils/UVUnwrapper.js +101 -101
- package/src/utils/macroify.js +9 -9
- package/src/workers/PathTracingSceneWorker.js +42 -42
|
@@ -1,207 +1,207 @@
|
|
|
1
|
-
export const materialStructGLSL = /* glsl */ `
|
|
2
|
-
|
|
3
|
-
struct Material {
|
|
4
|
-
|
|
5
|
-
vec3 color;
|
|
6
|
-
int map;
|
|
7
|
-
|
|
8
|
-
float metalness;
|
|
9
|
-
int metalnessMap;
|
|
10
|
-
|
|
11
|
-
float roughness;
|
|
12
|
-
int roughnessMap;
|
|
13
|
-
|
|
14
|
-
float ior;
|
|
15
|
-
float transmission;
|
|
16
|
-
int transmissionMap;
|
|
17
|
-
|
|
18
|
-
float emissiveIntensity;
|
|
19
|
-
vec3 emissive;
|
|
20
|
-
int emissiveMap;
|
|
21
|
-
|
|
22
|
-
int normalMap;
|
|
23
|
-
vec2 normalScale;
|
|
24
|
-
|
|
25
|
-
float clearcoat;
|
|
26
|
-
int clearcoatMap;
|
|
27
|
-
int clearcoatNormalMap;
|
|
28
|
-
vec2 clearcoatNormalScale;
|
|
29
|
-
float clearcoatRoughness;
|
|
30
|
-
int clearcoatRoughnessMap;
|
|
31
|
-
|
|
32
|
-
int iridescenceMap;
|
|
33
|
-
int iridescenceThicknessMap;
|
|
34
|
-
float iridescence;
|
|
35
|
-
float iridescenceIor;
|
|
36
|
-
float iridescenceThicknessMinimum;
|
|
37
|
-
float iridescenceThicknessMaximum;
|
|
38
|
-
|
|
39
|
-
vec3 specularColor;
|
|
40
|
-
int specularColorMap;
|
|
41
|
-
|
|
42
|
-
float specularIntensity;
|
|
43
|
-
int specularIntensityMap;
|
|
44
|
-
bool thinFilm;
|
|
45
|
-
|
|
46
|
-
vec3 attenuationColor;
|
|
47
|
-
float attenuationDistance;
|
|
48
|
-
|
|
49
|
-
int alphaMap;
|
|
50
|
-
|
|
51
|
-
bool castShadow;
|
|
52
|
-
float opacity;
|
|
53
|
-
float alphaTest;
|
|
54
|
-
|
|
55
|
-
float side;
|
|
56
|
-
bool matte;
|
|
57
|
-
|
|
58
|
-
float sheen;
|
|
59
|
-
vec3 sheenColor;
|
|
60
|
-
int sheenColorMap;
|
|
61
|
-
float sheenRoughness;
|
|
62
|
-
int sheenRoughnessMap;
|
|
63
|
-
|
|
64
|
-
bool vertexColors;
|
|
65
|
-
bool flatShading;
|
|
66
|
-
bool transparent;
|
|
67
|
-
bool fogVolume;
|
|
68
|
-
|
|
69
|
-
mat3 mapTransform;
|
|
70
|
-
mat3 metalnessMapTransform;
|
|
71
|
-
mat3 roughnessMapTransform;
|
|
72
|
-
mat3 transmissionMapTransform;
|
|
73
|
-
mat3 emissiveMapTransform;
|
|
74
|
-
mat3 normalMapTransform;
|
|
75
|
-
mat3 clearcoatMapTransform;
|
|
76
|
-
mat3 clearcoatNormalMapTransform;
|
|
77
|
-
mat3 clearcoatRoughnessMapTransform;
|
|
78
|
-
mat3 sheenColorMapTransform;
|
|
79
|
-
mat3 sheenRoughnessMapTransform;
|
|
80
|
-
mat3 iridescenceMapTransform;
|
|
81
|
-
mat3 iridescenceThicknessMapTransform;
|
|
82
|
-
mat3 specularColorMapTransform;
|
|
83
|
-
mat3 specularIntensityMapTransform;
|
|
84
|
-
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
mat3 readTextureTransform( sampler2D tex, uint index ) {
|
|
88
|
-
|
|
89
|
-
mat3 textureTransform;
|
|
90
|
-
|
|
91
|
-
vec4 row1 = texelFetch1D( tex, index );
|
|
92
|
-
vec4 row2 = texelFetch1D( tex, index + 1u );
|
|
93
|
-
|
|
94
|
-
textureTransform[0] = vec3(row1.r, row2.r, 0.0);
|
|
95
|
-
textureTransform[1] = vec3(row1.g, row2.g, 0.0);
|
|
96
|
-
textureTransform[2] = vec3(row1.b, row2.b, 1.0);
|
|
97
|
-
|
|
98
|
-
return textureTransform;
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
Material readMaterialInfo( sampler2D tex, uint index ) {
|
|
103
|
-
|
|
104
|
-
uint i = index * 45u;
|
|
105
|
-
|
|
106
|
-
vec4 s0 = texelFetch1D( tex, i + 0u );
|
|
107
|
-
vec4 s1 = texelFetch1D( tex, i + 1u );
|
|
108
|
-
vec4 s2 = texelFetch1D( tex, i + 2u );
|
|
109
|
-
vec4 s3 = texelFetch1D( tex, i + 3u );
|
|
110
|
-
vec4 s4 = texelFetch1D( tex, i + 4u );
|
|
111
|
-
vec4 s5 = texelFetch1D( tex, i + 5u );
|
|
112
|
-
vec4 s6 = texelFetch1D( tex, i + 6u );
|
|
113
|
-
vec4 s7 = texelFetch1D( tex, i + 7u );
|
|
114
|
-
vec4 s8 = texelFetch1D( tex, i + 8u );
|
|
115
|
-
vec4 s9 = texelFetch1D( tex, i + 9u );
|
|
116
|
-
vec4 s10 = texelFetch1D( tex, i + 10u );
|
|
117
|
-
vec4 s11 = texelFetch1D( tex, i + 11u );
|
|
118
|
-
vec4 s12 = texelFetch1D( tex, i + 12u );
|
|
119
|
-
vec4 s13 = texelFetch1D( tex, i + 13u );
|
|
120
|
-
vec4 s14 = texelFetch1D( tex, i + 14u );
|
|
121
|
-
|
|
122
|
-
Material m;
|
|
123
|
-
m.color = s0.rgb;
|
|
124
|
-
m.map = int( round( s0.a ) );
|
|
125
|
-
|
|
126
|
-
m.metalness = s1.r;
|
|
127
|
-
m.metalnessMap = int( round( s1.g ) );
|
|
128
|
-
m.roughness = s1.b;
|
|
129
|
-
m.roughnessMap = int( round( s1.a ) );
|
|
130
|
-
|
|
131
|
-
m.ior = s2.r;
|
|
132
|
-
m.transmission = s2.g;
|
|
133
|
-
m.transmissionMap = int( round( s2.b ) );
|
|
134
|
-
m.emissiveIntensity = s2.a;
|
|
135
|
-
|
|
136
|
-
m.emissive = s3.rgb;
|
|
137
|
-
m.emissiveMap = int( round( s3.a ) );
|
|
138
|
-
|
|
139
|
-
m.normalMap = int( round( s4.r ) );
|
|
140
|
-
m.normalScale = s4.gb;
|
|
141
|
-
|
|
142
|
-
m.clearcoat = s4.a;
|
|
143
|
-
m.clearcoatMap = int( round( s5.r ) );
|
|
144
|
-
m.clearcoatRoughness = s5.g;
|
|
145
|
-
m.clearcoatRoughnessMap = int( round( s5.b ) );
|
|
146
|
-
m.clearcoatNormalMap = int( round( s5.a ) );
|
|
147
|
-
m.clearcoatNormalScale = s6.rg;
|
|
148
|
-
|
|
149
|
-
m.sheen = s6.a;
|
|
150
|
-
m.sheenColor = s7.rgb;
|
|
151
|
-
m.sheenColorMap = int( round( s7.a ) );
|
|
152
|
-
m.sheenRoughness = s8.r;
|
|
153
|
-
m.sheenRoughnessMap = int( round( s8.g ) );
|
|
154
|
-
|
|
155
|
-
m.iridescenceMap = int( round( s8.b ) );
|
|
156
|
-
m.iridescenceThicknessMap = int( round( s8.a ) );
|
|
157
|
-
m.iridescence = s9.r;
|
|
158
|
-
m.iridescenceIor = s9.g;
|
|
159
|
-
m.iridescenceThicknessMinimum = s9.b;
|
|
160
|
-
m.iridescenceThicknessMaximum = s9.a;
|
|
161
|
-
|
|
162
|
-
m.specularColor = s10.rgb;
|
|
163
|
-
m.specularColorMap = int( round( s10.a ) );
|
|
164
|
-
|
|
165
|
-
m.specularIntensity = s11.r;
|
|
166
|
-
m.specularIntensityMap = int( round( s11.g ) );
|
|
167
|
-
m.thinFilm = bool( s11.b );
|
|
168
|
-
|
|
169
|
-
m.attenuationColor = s12.rgb;
|
|
170
|
-
m.attenuationDistance = s12.a;
|
|
171
|
-
|
|
172
|
-
m.alphaMap = int( round( s13.r ) );
|
|
173
|
-
|
|
174
|
-
m.opacity = s13.g;
|
|
175
|
-
m.alphaTest = s13.b;
|
|
176
|
-
m.side = s13.a;
|
|
177
|
-
|
|
178
|
-
m.matte = bool( s14.r );
|
|
179
|
-
m.castShadow = ! bool( s14.g );
|
|
180
|
-
m.vertexColors = bool( int( s14.b ) & 1 );
|
|
181
|
-
m.flatShading = bool( int( s14.b ) & 2 );
|
|
182
|
-
m.fogVolume = bool( int( s14.b ) & 4 );
|
|
183
|
-
m.transparent = bool( s14.a );
|
|
184
|
-
|
|
185
|
-
uint firstTextureTransformIdx = i + 15u;
|
|
186
|
-
|
|
187
|
-
m.mapTransform = m.map == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx );
|
|
188
|
-
m.metalnessMapTransform = m.metalnessMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 2u );
|
|
189
|
-
m.roughnessMapTransform = m.roughnessMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 4u );
|
|
190
|
-
m.transmissionMapTransform = m.transmissionMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 6u );
|
|
191
|
-
m.emissiveMapTransform = m.emissiveMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 8u );
|
|
192
|
-
m.normalMapTransform = m.normalMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 10u );
|
|
193
|
-
m.clearcoatMapTransform = m.clearcoatMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 12u );
|
|
194
|
-
m.clearcoatNormalMapTransform = m.clearcoatNormalMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 14u );
|
|
195
|
-
m.clearcoatRoughnessMapTransform = m.clearcoatRoughnessMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 16u );
|
|
196
|
-
m.sheenColorMapTransform = m.sheenColorMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 18u );
|
|
197
|
-
m.sheenRoughnessMapTransform = m.sheenRoughnessMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 20u );
|
|
198
|
-
m.iridescenceMapTransform = m.iridescenceMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 22u );
|
|
199
|
-
m.iridescenceThicknessMapTransform = m.iridescenceThicknessMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 24u );
|
|
200
|
-
m.specularColorMapTransform = m.specularColorMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 26u );
|
|
201
|
-
m.specularIntensityMapTransform = m.specularIntensityMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 28u );
|
|
202
|
-
|
|
203
|
-
return m;
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
`;
|
|
1
|
+
export const materialStructGLSL = /* glsl */ `
|
|
2
|
+
|
|
3
|
+
struct Material {
|
|
4
|
+
|
|
5
|
+
vec3 color;
|
|
6
|
+
int map;
|
|
7
|
+
|
|
8
|
+
float metalness;
|
|
9
|
+
int metalnessMap;
|
|
10
|
+
|
|
11
|
+
float roughness;
|
|
12
|
+
int roughnessMap;
|
|
13
|
+
|
|
14
|
+
float ior;
|
|
15
|
+
float transmission;
|
|
16
|
+
int transmissionMap;
|
|
17
|
+
|
|
18
|
+
float emissiveIntensity;
|
|
19
|
+
vec3 emissive;
|
|
20
|
+
int emissiveMap;
|
|
21
|
+
|
|
22
|
+
int normalMap;
|
|
23
|
+
vec2 normalScale;
|
|
24
|
+
|
|
25
|
+
float clearcoat;
|
|
26
|
+
int clearcoatMap;
|
|
27
|
+
int clearcoatNormalMap;
|
|
28
|
+
vec2 clearcoatNormalScale;
|
|
29
|
+
float clearcoatRoughness;
|
|
30
|
+
int clearcoatRoughnessMap;
|
|
31
|
+
|
|
32
|
+
int iridescenceMap;
|
|
33
|
+
int iridescenceThicknessMap;
|
|
34
|
+
float iridescence;
|
|
35
|
+
float iridescenceIor;
|
|
36
|
+
float iridescenceThicknessMinimum;
|
|
37
|
+
float iridescenceThicknessMaximum;
|
|
38
|
+
|
|
39
|
+
vec3 specularColor;
|
|
40
|
+
int specularColorMap;
|
|
41
|
+
|
|
42
|
+
float specularIntensity;
|
|
43
|
+
int specularIntensityMap;
|
|
44
|
+
bool thinFilm;
|
|
45
|
+
|
|
46
|
+
vec3 attenuationColor;
|
|
47
|
+
float attenuationDistance;
|
|
48
|
+
|
|
49
|
+
int alphaMap;
|
|
50
|
+
|
|
51
|
+
bool castShadow;
|
|
52
|
+
float opacity;
|
|
53
|
+
float alphaTest;
|
|
54
|
+
|
|
55
|
+
float side;
|
|
56
|
+
bool matte;
|
|
57
|
+
|
|
58
|
+
float sheen;
|
|
59
|
+
vec3 sheenColor;
|
|
60
|
+
int sheenColorMap;
|
|
61
|
+
float sheenRoughness;
|
|
62
|
+
int sheenRoughnessMap;
|
|
63
|
+
|
|
64
|
+
bool vertexColors;
|
|
65
|
+
bool flatShading;
|
|
66
|
+
bool transparent;
|
|
67
|
+
bool fogVolume;
|
|
68
|
+
|
|
69
|
+
mat3 mapTransform;
|
|
70
|
+
mat3 metalnessMapTransform;
|
|
71
|
+
mat3 roughnessMapTransform;
|
|
72
|
+
mat3 transmissionMapTransform;
|
|
73
|
+
mat3 emissiveMapTransform;
|
|
74
|
+
mat3 normalMapTransform;
|
|
75
|
+
mat3 clearcoatMapTransform;
|
|
76
|
+
mat3 clearcoatNormalMapTransform;
|
|
77
|
+
mat3 clearcoatRoughnessMapTransform;
|
|
78
|
+
mat3 sheenColorMapTransform;
|
|
79
|
+
mat3 sheenRoughnessMapTransform;
|
|
80
|
+
mat3 iridescenceMapTransform;
|
|
81
|
+
mat3 iridescenceThicknessMapTransform;
|
|
82
|
+
mat3 specularColorMapTransform;
|
|
83
|
+
mat3 specularIntensityMapTransform;
|
|
84
|
+
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
mat3 readTextureTransform( sampler2D tex, uint index ) {
|
|
88
|
+
|
|
89
|
+
mat3 textureTransform;
|
|
90
|
+
|
|
91
|
+
vec4 row1 = texelFetch1D( tex, index );
|
|
92
|
+
vec4 row2 = texelFetch1D( tex, index + 1u );
|
|
93
|
+
|
|
94
|
+
textureTransform[0] = vec3(row1.r, row2.r, 0.0);
|
|
95
|
+
textureTransform[1] = vec3(row1.g, row2.g, 0.0);
|
|
96
|
+
textureTransform[2] = vec3(row1.b, row2.b, 1.0);
|
|
97
|
+
|
|
98
|
+
return textureTransform;
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
Material readMaterialInfo( sampler2D tex, uint index ) {
|
|
103
|
+
|
|
104
|
+
uint i = index * 45u;
|
|
105
|
+
|
|
106
|
+
vec4 s0 = texelFetch1D( tex, i + 0u );
|
|
107
|
+
vec4 s1 = texelFetch1D( tex, i + 1u );
|
|
108
|
+
vec4 s2 = texelFetch1D( tex, i + 2u );
|
|
109
|
+
vec4 s3 = texelFetch1D( tex, i + 3u );
|
|
110
|
+
vec4 s4 = texelFetch1D( tex, i + 4u );
|
|
111
|
+
vec4 s5 = texelFetch1D( tex, i + 5u );
|
|
112
|
+
vec4 s6 = texelFetch1D( tex, i + 6u );
|
|
113
|
+
vec4 s7 = texelFetch1D( tex, i + 7u );
|
|
114
|
+
vec4 s8 = texelFetch1D( tex, i + 8u );
|
|
115
|
+
vec4 s9 = texelFetch1D( tex, i + 9u );
|
|
116
|
+
vec4 s10 = texelFetch1D( tex, i + 10u );
|
|
117
|
+
vec4 s11 = texelFetch1D( tex, i + 11u );
|
|
118
|
+
vec4 s12 = texelFetch1D( tex, i + 12u );
|
|
119
|
+
vec4 s13 = texelFetch1D( tex, i + 13u );
|
|
120
|
+
vec4 s14 = texelFetch1D( tex, i + 14u );
|
|
121
|
+
|
|
122
|
+
Material m;
|
|
123
|
+
m.color = s0.rgb;
|
|
124
|
+
m.map = int( round( s0.a ) );
|
|
125
|
+
|
|
126
|
+
m.metalness = s1.r;
|
|
127
|
+
m.metalnessMap = int( round( s1.g ) );
|
|
128
|
+
m.roughness = s1.b;
|
|
129
|
+
m.roughnessMap = int( round( s1.a ) );
|
|
130
|
+
|
|
131
|
+
m.ior = s2.r;
|
|
132
|
+
m.transmission = s2.g;
|
|
133
|
+
m.transmissionMap = int( round( s2.b ) );
|
|
134
|
+
m.emissiveIntensity = s2.a;
|
|
135
|
+
|
|
136
|
+
m.emissive = s3.rgb;
|
|
137
|
+
m.emissiveMap = int( round( s3.a ) );
|
|
138
|
+
|
|
139
|
+
m.normalMap = int( round( s4.r ) );
|
|
140
|
+
m.normalScale = s4.gb;
|
|
141
|
+
|
|
142
|
+
m.clearcoat = s4.a;
|
|
143
|
+
m.clearcoatMap = int( round( s5.r ) );
|
|
144
|
+
m.clearcoatRoughness = s5.g;
|
|
145
|
+
m.clearcoatRoughnessMap = int( round( s5.b ) );
|
|
146
|
+
m.clearcoatNormalMap = int( round( s5.a ) );
|
|
147
|
+
m.clearcoatNormalScale = s6.rg;
|
|
148
|
+
|
|
149
|
+
m.sheen = s6.a;
|
|
150
|
+
m.sheenColor = s7.rgb;
|
|
151
|
+
m.sheenColorMap = int( round( s7.a ) );
|
|
152
|
+
m.sheenRoughness = s8.r;
|
|
153
|
+
m.sheenRoughnessMap = int( round( s8.g ) );
|
|
154
|
+
|
|
155
|
+
m.iridescenceMap = int( round( s8.b ) );
|
|
156
|
+
m.iridescenceThicknessMap = int( round( s8.a ) );
|
|
157
|
+
m.iridescence = s9.r;
|
|
158
|
+
m.iridescenceIor = s9.g;
|
|
159
|
+
m.iridescenceThicknessMinimum = s9.b;
|
|
160
|
+
m.iridescenceThicknessMaximum = s9.a;
|
|
161
|
+
|
|
162
|
+
m.specularColor = s10.rgb;
|
|
163
|
+
m.specularColorMap = int( round( s10.a ) );
|
|
164
|
+
|
|
165
|
+
m.specularIntensity = s11.r;
|
|
166
|
+
m.specularIntensityMap = int( round( s11.g ) );
|
|
167
|
+
m.thinFilm = bool( s11.b );
|
|
168
|
+
|
|
169
|
+
m.attenuationColor = s12.rgb;
|
|
170
|
+
m.attenuationDistance = s12.a;
|
|
171
|
+
|
|
172
|
+
m.alphaMap = int( round( s13.r ) );
|
|
173
|
+
|
|
174
|
+
m.opacity = s13.g;
|
|
175
|
+
m.alphaTest = s13.b;
|
|
176
|
+
m.side = s13.a;
|
|
177
|
+
|
|
178
|
+
m.matte = bool( s14.r );
|
|
179
|
+
m.castShadow = ! bool( s14.g );
|
|
180
|
+
m.vertexColors = bool( int( s14.b ) & 1 );
|
|
181
|
+
m.flatShading = bool( int( s14.b ) & 2 );
|
|
182
|
+
m.fogVolume = bool( int( s14.b ) & 4 );
|
|
183
|
+
m.transparent = bool( s14.a );
|
|
184
|
+
|
|
185
|
+
uint firstTextureTransformIdx = i + 15u;
|
|
186
|
+
|
|
187
|
+
m.mapTransform = m.map == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx );
|
|
188
|
+
m.metalnessMapTransform = m.metalnessMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 2u );
|
|
189
|
+
m.roughnessMapTransform = m.roughnessMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 4u );
|
|
190
|
+
m.transmissionMapTransform = m.transmissionMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 6u );
|
|
191
|
+
m.emissiveMapTransform = m.emissiveMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 8u );
|
|
192
|
+
m.normalMapTransform = m.normalMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 10u );
|
|
193
|
+
m.clearcoatMapTransform = m.clearcoatMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 12u );
|
|
194
|
+
m.clearcoatNormalMapTransform = m.clearcoatNormalMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 14u );
|
|
195
|
+
m.clearcoatRoughnessMapTransform = m.clearcoatRoughnessMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 16u );
|
|
196
|
+
m.sheenColorMapTransform = m.sheenColorMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 18u );
|
|
197
|
+
m.sheenRoughnessMapTransform = m.sheenRoughnessMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 20u );
|
|
198
|
+
m.iridescenceMapTransform = m.iridescenceMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 22u );
|
|
199
|
+
m.iridescenceThicknessMapTransform = m.iridescenceThicknessMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 24u );
|
|
200
|
+
m.specularColorMapTransform = m.specularColorMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 26u );
|
|
201
|
+
m.specularIntensityMapTransform = m.specularIntensityMap == - 1 ? mat3( 0 ) : readTextureTransform( tex, firstTextureTransformIdx + 28u );
|
|
202
|
+
|
|
203
|
+
return m;
|
|
204
|
+
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
`;
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { Color, Vector3 } from 'three';
|
|
2
|
-
import { ProceduralEquirectTexture } from './ProceduralEquirectTexture.js';
|
|
3
|
-
|
|
4
|
-
const _direction = new Vector3();
|
|
5
|
-
export class GradientEquirectTexture extends ProceduralEquirectTexture {
|
|
6
|
-
|
|
7
|
-
constructor( resolution = 512 ) {
|
|
8
|
-
|
|
9
|
-
super( resolution, resolution );
|
|
10
|
-
|
|
11
|
-
this.topColor = new Color().set( 0xffffff );
|
|
12
|
-
this.bottomColor = new Color().set( 0x000000 );
|
|
13
|
-
this.exponent = 2;
|
|
14
|
-
this.generationCallback = ( polar, uv, coord, color ) => {
|
|
15
|
-
|
|
16
|
-
_direction.setFromSpherical( polar );
|
|
17
|
-
|
|
18
|
-
const t = _direction.y * 0.5 + 0.5;
|
|
19
|
-
color.lerpColors( this.bottomColor, this.topColor, t ** this.exponent );
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
copy( other ) {
|
|
26
|
-
|
|
27
|
-
super.copy( other );
|
|
28
|
-
|
|
29
|
-
this.topColor.copy( other.topColor );
|
|
30
|
-
this.bottomColor.copy( other.bottomColor );
|
|
31
|
-
return this;
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
|
1
|
+
import { Color, Vector3 } from 'three';
|
|
2
|
+
import { ProceduralEquirectTexture } from './ProceduralEquirectTexture.js';
|
|
3
|
+
|
|
4
|
+
const _direction = new Vector3();
|
|
5
|
+
export class GradientEquirectTexture extends ProceduralEquirectTexture {
|
|
6
|
+
|
|
7
|
+
constructor( resolution = 512 ) {
|
|
8
|
+
|
|
9
|
+
super( resolution, resolution );
|
|
10
|
+
|
|
11
|
+
this.topColor = new Color().set( 0xffffff );
|
|
12
|
+
this.bottomColor = new Color().set( 0x000000 );
|
|
13
|
+
this.exponent = 2;
|
|
14
|
+
this.generationCallback = ( polar, uv, coord, color ) => {
|
|
15
|
+
|
|
16
|
+
_direction.setFromSpherical( polar );
|
|
17
|
+
|
|
18
|
+
const t = _direction.y * 0.5 + 0.5;
|
|
19
|
+
color.lerpColors( this.bottomColor, this.topColor, t ** this.exponent );
|
|
20
|
+
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
copy( other ) {
|
|
26
|
+
|
|
27
|
+
super.copy( other );
|
|
28
|
+
|
|
29
|
+
this.topColor.copy( other.topColor );
|
|
30
|
+
this.bottomColor.copy( other.bottomColor );
|
|
31
|
+
return this;
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClampToEdgeWrapping,
|
|
3
|
-
Color,
|
|
4
|
-
DataTexture,
|
|
5
|
-
EquirectangularReflectionMapping,
|
|
6
|
-
FloatType,
|
|
7
|
-
LinearFilter,
|
|
8
|
-
RepeatWrapping,
|
|
9
|
-
RGBAFormat,
|
|
10
|
-
Spherical,
|
|
11
|
-
Vector2,
|
|
12
|
-
} from 'three';
|
|
13
|
-
|
|
14
|
-
const _uv = new Vector2();
|
|
15
|
-
const _coord = new Vector2();
|
|
16
|
-
const _polar = new Spherical();
|
|
17
|
-
const _color = new Color();
|
|
18
|
-
export class ProceduralEquirectTexture extends DataTexture {
|
|
19
|
-
|
|
20
|
-
constructor( width, height ) {
|
|
21
|
-
|
|
22
|
-
super(
|
|
23
|
-
new Float32Array( width * height * 4 ),
|
|
24
|
-
width, height, RGBAFormat, FloatType, EquirectangularReflectionMapping,
|
|
25
|
-
RepeatWrapping, ClampToEdgeWrapping, LinearFilter, LinearFilter,
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
this.generationCallback = null;
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
update() {
|
|
33
|
-
|
|
34
|
-
this.dispose();
|
|
35
|
-
this.needsUpdate = true;
|
|
36
|
-
|
|
37
|
-
const { data, width, height } = this.image;
|
|
38
|
-
for ( let x = 0; x < width; x ++ ) {
|
|
39
|
-
|
|
40
|
-
for ( let y = 0; y < height; y ++ ) {
|
|
41
|
-
|
|
42
|
-
_coord.set( width, height );
|
|
43
|
-
|
|
44
|
-
_uv.set( x / width, y / height );
|
|
45
|
-
_uv.x -= 0.5;
|
|
46
|
-
_uv.y = 1.0 - _uv.y;
|
|
47
|
-
|
|
48
|
-
_polar.theta = _uv.x * 2.0 * Math.PI;
|
|
49
|
-
_polar.phi = _uv.y * Math.PI;
|
|
50
|
-
_polar.radius = 1.0;
|
|
51
|
-
|
|
52
|
-
this.generationCallback( _polar, _uv, _coord, _color );
|
|
53
|
-
|
|
54
|
-
const i = y * width + x;
|
|
55
|
-
const i4 = 4 * i;
|
|
56
|
-
data[ i4 + 0 ] = _color.r;
|
|
57
|
-
data[ i4 + 1 ] = _color.g;
|
|
58
|
-
data[ i4 + 2 ] = _color.b;
|
|
59
|
-
data[ i4 + 3 ] = 1.0;
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
copy( other ) {
|
|
68
|
-
|
|
69
|
-
super.copy( other );
|
|
70
|
-
this.generationCallback = other.generationCallback;
|
|
71
|
-
return this;
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
ClampToEdgeWrapping,
|
|
3
|
+
Color,
|
|
4
|
+
DataTexture,
|
|
5
|
+
EquirectangularReflectionMapping,
|
|
6
|
+
FloatType,
|
|
7
|
+
LinearFilter,
|
|
8
|
+
RepeatWrapping,
|
|
9
|
+
RGBAFormat,
|
|
10
|
+
Spherical,
|
|
11
|
+
Vector2,
|
|
12
|
+
} from 'three';
|
|
13
|
+
|
|
14
|
+
const _uv = new Vector2();
|
|
15
|
+
const _coord = new Vector2();
|
|
16
|
+
const _polar = new Spherical();
|
|
17
|
+
const _color = new Color();
|
|
18
|
+
export class ProceduralEquirectTexture extends DataTexture {
|
|
19
|
+
|
|
20
|
+
constructor( width, height ) {
|
|
21
|
+
|
|
22
|
+
super(
|
|
23
|
+
new Float32Array( width * height * 4 ),
|
|
24
|
+
width, height, RGBAFormat, FloatType, EquirectangularReflectionMapping,
|
|
25
|
+
RepeatWrapping, ClampToEdgeWrapping, LinearFilter, LinearFilter,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
this.generationCallback = null;
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
update() {
|
|
33
|
+
|
|
34
|
+
this.dispose();
|
|
35
|
+
this.needsUpdate = true;
|
|
36
|
+
|
|
37
|
+
const { data, width, height } = this.image;
|
|
38
|
+
for ( let x = 0; x < width; x ++ ) {
|
|
39
|
+
|
|
40
|
+
for ( let y = 0; y < height; y ++ ) {
|
|
41
|
+
|
|
42
|
+
_coord.set( width, height );
|
|
43
|
+
|
|
44
|
+
_uv.set( x / width, y / height );
|
|
45
|
+
_uv.x -= 0.5;
|
|
46
|
+
_uv.y = 1.0 - _uv.y;
|
|
47
|
+
|
|
48
|
+
_polar.theta = _uv.x * 2.0 * Math.PI;
|
|
49
|
+
_polar.phi = _uv.y * Math.PI;
|
|
50
|
+
_polar.radius = 1.0;
|
|
51
|
+
|
|
52
|
+
this.generationCallback( _polar, _uv, _coord, _color );
|
|
53
|
+
|
|
54
|
+
const i = y * width + x;
|
|
55
|
+
const i4 = 4 * i;
|
|
56
|
+
data[ i4 + 0 ] = _color.r;
|
|
57
|
+
data[ i4 + 1 ] = _color.g;
|
|
58
|
+
data[ i4 + 2 ] = _color.b;
|
|
59
|
+
data[ i4 + 3 ] = 1.0;
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
copy( other ) {
|
|
68
|
+
|
|
69
|
+
super.copy( other );
|
|
70
|
+
this.generationCallback = other.generationCallback;
|
|
71
|
+
return this;
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
}
|