Skip to content

Commit 26c9b41

Browse files
committed
Properly support alpha
1 parent 216aa75 commit 26c9b41

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/materials/PhysicalPathTracingMaterial.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export class PhysicalPathTracingMaterial extends MaterialBase {
273273
|| useAlphaTest && albedo.a < alphaTest
274274
275275
// opacity
276-
|| ! useAlphaTest && albedo.a < rand()
276+
|| material.transparent && ! useAlphaTest && albedo.a < rand()
277277
)
278278
) {
279279
@@ -580,7 +580,7 @@ export class PhysicalPathTracingMaterial extends MaterialBase {
580580
|| useAlphaTest && albedo.a < alphaTest
581581
582582
// opacity
583-
|| ! useAlphaTest && albedo.a < rand()
583+
|| material.transparent && ! useAlphaTest && albedo.a < rand()
584584
) {
585585
586586
vec3 point = rayOrigin + rayDirection * dist;

src/shader/shaderStructs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export const shaderMaterialStructs = /* glsl */ `
8181
int sheenRoughnessMap;
8282
8383
bool vertexColors;
84+
bool transparent;
8485
8586
mat3 mapTransform;
8687
mat3 metalnessMapTransform;
@@ -192,6 +193,7 @@ export const shaderMaterialStructs = /* glsl */ `
192193
m.matte = bool( s14.r );
193194
m.castShadow = ! bool( s14.g );
194195
m.vertexColors = bool( s14.b );
196+
m.transparent = bool( s14.a );
195197
196198
uint firstTextureTransformIdx = i + 15u;
197199

src/uniforms/MaterialsTexture.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ export class MaterialsTexture extends DataTexture {
368368
index ++; // matte
369369
index ++; // shadow
370370
floatArray[ index ++ ] = Number( m.vertexColors ); // vertexColors
371-
index ++;
371+
floatArray[ index ++ ] = Number( m.transparent ); // transparent
372372

373373
// map transform 15
374374
index += writeTextureMatrixToArray( m, 'map', floatArray, index );

0 commit comments

Comments
 (0)