Skip to content

Commit a80e2de

Browse files
committed
make sure PixelParams::thickness is initialized
If screen-space refraction was used enabled but the thickness parameter wasn't explicitly set in the material, it would end-up being uninitialized. Now it's initialized to 0.5 by default, which is the value used for subsurface. Also removed some calculations dependent on thickness being set, as they assumed a thickness of 0.
1 parent 84c68f7 commit a80e2de

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

shaders/src/surface_light_indirect.fs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,7 @@ vec3 evaluateRefraction(
506506

507507
// compute transmission T
508508
#if defined(MATERIAL_HAS_ABSORPTION)
509-
#if defined(MATERIAL_HAS_THICKNESS) || defined(MATERIAL_HAS_MICRO_THICKNESS)
510509
vec3 T = min(vec3(1.0), exp(-pixel.absorption * ray.d));
511-
#else
512-
vec3 T = 1.0 - pixel.absorption;
513-
#endif
514510
#endif
515511

516512
// Roughness remapping so that an IOR of 1.0 means no microfacet refraction and an IOR

shaders/src/surface_shading_lit.fs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,11 @@ void getCommonPixelParams(const MaterialInputs material, inout PixelParams pixel
117117
pixel.transmission = 1.0;
118118
#endif
119119
#if defined(MATERIAL_HAS_ABSORPTION)
120-
#if defined(MATERIAL_HAS_THICKNESS) || defined(MATERIAL_HAS_MICRO_THICKNESS)
121120
pixel.absorption = max(vec3(0.0), material.absorption);
122-
#else
123-
pixel.absorption = saturate(material.absorption);
124-
#endif
125121
#else
126122
pixel.absorption = vec3(0.0);
127123
#endif
128-
#if defined(MATERIAL_HAS_THICKNESS)
124+
#if defined(SHADING_MODEL_SUBSURFACE) || defined(MATERIAL_HAS_REFRACTION)
129125
pixel.thickness = max(0.0, material.thickness);
130126
#endif
131127
#if defined(MATERIAL_HAS_MICRO_THICKNESS) && (REFRACTION_TYPE == REFRACTION_TYPE_THIN)

0 commit comments

Comments
 (0)