Skip to content

Commit 3580a82

Browse files
author
Mike Bond
committed
Remove albedo being passed through to irradiance calc
1 parent e57a3f6 commit 3580a82

22 files changed

+20
-40
lines changed

packages/dev/core/src/Engines/constants.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,9 @@ export class Constants {
443443
*/
444444
public static readonly MATERIAL_CounterClockWiseSideOrientation = 1;
445445

446-
public static readonly MATERIAL_DIFFUSE_ROUGHNESS_LAMBERT = 0;
446+
public static readonly MATERIAL_DIFFUSE_ROUGHNESS_OPENPBR = 0;
447447
public static readonly MATERIAL_DIFFUSE_ROUGHNESS_BURLEY = 1;
448-
public static readonly MATERIAL_DIFFUSE_ROUGHNESS_OPENPBR = 2;
448+
public static readonly MATERIAL_DIFFUSE_ROUGHNESS_LAMBERT = 2;
449449

450450
/**
451451
* Nothing

packages/dev/core/src/Materials/Node/Blocks/PBR/reflectionBlock.ts

-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@ export class ReflectionBlock extends ReflectionTextureBaseBlock {
461461
#endif
462462
#endif
463463
, diffuseRoughness
464-
, surfaceAlbedo
465464
);
466465
#endif\n`;
467466

packages/dev/core/src/Shaders/ShadersInclude/hdrFilteringFunctions.fx

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
//
185185

186186
#define inline
187-
vec3 irradiance(samplerCube inputTexture, vec3 inputN, vec2 filteringInfo, float diffuseRoughness, vec3 inputV, vec3 surfaceAlbedo
187+
vec3 irradiance(samplerCube inputTexture, vec3 inputN, vec2 filteringInfo, float diffuseRoughness, vec3 inputV
188188
#ifdef IBL_CDF_FILTERING
189189
, sampler2D icdfSampler
190190
#endif
@@ -250,7 +250,7 @@
250250

251251
vec3 diffuseRoughnessTerm = vec3(1.0);
252252
#if BASE_DIFFUSE_ROUGHNESS_MODEL == 0
253-
diffuseRoughnessTerm = diffuseBRDF_EON(surfaceAlbedo, diffuseRoughness, NoL, NoV) * PI;
253+
diffuseRoughnessTerm = diffuseBRDF_EON(vec3(1.0), diffuseRoughness, NoL, NoV) * PI;
254254
#elif BASE_DIFFUSE_ROUGHNESS_MODEL == 1
255255
diffuseRoughnessTerm = vec3(diffuseBRDF_Burley(NoL, NoV, VoH, diffuseRoughness) * PI);
256256
#endif

packages/dev/core/src/Shaders/ShadersInclude/lightFragment.fx

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
preInfo.roughness = adjustRoughnessFromLightProperties(roughness, light{X}.vLightSpecular.a, preInfo.lightDistance);
7676
#endif
7777
preInfo.diffuseRoughness = diffuseRoughness;
78-
preInfo.surfaceAlbedo = surfaceAlbedo;
7978

8079
#ifdef IRIDESCENCE
8180
preInfo.iridescenceIntensity = iridescenceIntensity;

packages/dev/core/src/Shaders/ShadersInclude/pbrBlockFinalLitComponents.fx

-3
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ aggShadow = aggShadow / numLights;
4040
finalIrradiance += subSurfaceOut.refractionIrradiance;
4141
#endif
4242

43-
// Irradiance already include the surface albedo if using OpenPBR's ORN model.
44-
#if BASE_DIFFUSE_ROUGHNESS_MODEL != 0
4543
finalIrradiance *= surfaceAlbedo.rgb;
46-
#endif
4744
finalIrradiance *= vLightingIntensity.z;
4845
finalIrradiance *= aoOut.ambientOcclusionColor;
4946
#endif

packages/dev/core/src/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents.fx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// _____________________________ Diffuse ________________________________________
22
vec3 finalDiffuse = diffuseBase;
3-
#if !defined(SS_TRANSLUCENCY) && BASE_DIFFUSE_ROUGHNESS_MODEL != 0
3+
#if !defined(SS_TRANSLUCENCY)
44
// When translucency is enabled, the final diffuse term is computed in the computeDiffuseAndTransmittedLighting function, we should not multiply it by the albedo here.
5-
// finalDiffuse already includes the surface albedo if using OpenPBR's ORN model.
65
finalDiffuse *= surfaceAlbedo.rgb;
76
#endif
87
finalDiffuse = max(finalDiffuse, 0.0);

packages/dev/core/src/Shaders/ShadersInclude/pbrBlockReflection.fx

+2-6
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@
207207
, in sampler2D icdfSampler
208208
#endif
209209
, in float diffuseRoughness
210-
, in vec3 surfaceAlbedo
211210
#endif
212211
)
213212
{
@@ -282,17 +281,14 @@
282281
environmentIrradiance = vEnvironmentIrradiance;
283282
#else
284283
#if defined(REALTIME_FILTERING)
285-
// Add diffuse roughness logic to irradiance() function.
286-
// This will include V and NdotV as well as the diffuse roughness.
287-
// For prefiltering, V=N.
288284
// Note that irradianceVector is NOT the same as normalW. It has been rotated into the space of the cubemap.
289-
environmentIrradiance = irradiance(reflectionSampler, irradianceVector, vReflectionFilteringInfo, diffuseRoughness, irradianceView, surfaceAlbedo
285+
environmentIrradiance = irradiance(reflectionSampler, irradianceVector, vReflectionFilteringInfo, diffuseRoughness, irradianceView
290286
#ifdef IBL_CDF_FILTERING
291287
, icdfSampler
292288
#endif
293289
);
294290
#else
295-
// Add approximation to computeEnvironmentIrradiance that includes diffuse roughness and NdotV
291+
// TODO - Add approximation to computeEnvironmentIrradiance that includes diffuse roughness and NdotV
296292
environmentIrradiance = computeEnvironmentIrradiance(irradianceVector);
297293
#endif
298294

packages/dev/core/src/Shaders/ShadersInclude/pbrBlockSubSurface.fx

+1-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ struct subSurfaceOutParams
493493

494494
#if defined(USESPHERICALFROMREFLECTIONMAP)
495495
#if defined(REALTIME_FILTERING)
496-
vec3 refractionIrradiance = irradiance(reflectionSampler, -irradianceVector, vReflectionFilteringInfo, diffuseRoughness, normalW, vec3(1.0)
496+
vec3 refractionIrradiance = irradiance(reflectionSampler, -irradianceVector, vReflectionFilteringInfo, 0.0, irradianceVector
497497
#ifdef IBL_CDF_FILTERING
498498
, icdfSampler
499499
#endif

packages/dev/core/src/Shaders/ShadersInclude/pbrDirectLightingFunctions.fx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ vec3 computeDiffuseLighting(preLightingInfo info, vec3 lightColor) {
4545
#if BASE_DIFFUSE_ROUGHNESS_MODEL == 1
4646
diffuseTerm = vec3(diffuseBRDF_Burley(info.NdotL, info.NdotV, info.VdotH, info.diffuseRoughness));
4747
#elif BASE_DIFFUSE_ROUGHNESS_MODEL == 0
48-
diffuseTerm = diffuseBRDF_EON(info.surfaceAlbedo, info.diffuseRoughness, info.NdotL, info.NdotV);
48+
diffuseTerm = diffuseBRDF_EON(vec3(1.0), info.diffuseRoughness, info.NdotL, info.NdotV);
4949
#endif
5050
return diffuseTerm * info.attenuation * info.NdotL * lightColor;
5151
}

packages/dev/core/src/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.fx

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ struct preLightingInfo
2020
// TODO: the code would probably be leaner with material properties out of the structure.
2121
float roughness;
2222
float diffuseRoughness;
23-
vec3 surfaceAlbedo;
2423

2524
#ifdef IRIDESCENCE
2625
float iridescenceIntensity;

packages/dev/core/src/Shaders/hdrIrradianceFiltering.fragment.fx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ uniform float hdrScale;
1313
varying vec3 direction;
1414

1515
void main() {
16-
vec3 color = irradiance(inputTexture, direction, vFilteringInfo, 1.0, direction, vec3(1.0)
16+
vec3 color = irradiance(inputTexture, direction, vFilteringInfo, 1.0, direction
1717
#ifdef IBL_CDF_FILTERING
1818
, icdfTexture
1919
#endif

packages/dev/core/src/Shaders/pbr.fragment.fx

-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ void main(void) {
322322
, icdfSampler
323323
#endif
324324
, diffuseRoughness
325-
, surfaceAlbedo
326325
#endif
327326
);
328327
#else

packages/dev/core/src/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.fx

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
//
158158
//
159159

160-
fn irradiance(inputTexture: texture_cube<f32>, inputSampler: sampler, inputN: vec3f, filteringInfo: vec2f, diffuseRoughness: f32, inputV: vec3f, surfaceAlbedo: vec3f
160+
fn irradiance(inputTexture: texture_cube<f32>, inputSampler: sampler, inputN: vec3f, filteringInfo: vec2f, diffuseRoughness: f32, inputV: vec3f
161161
#ifdef IBL_CDF_FILTERING
162162
, icdfSampler: texture_2d<f32>, icdfSamplerSampler: sampler
163163
#endif
@@ -221,7 +221,7 @@
221221

222222
var diffuseRoughnessTerm: vec3f = vec3f(1.0);
223223
#if BASE_DIFFUSE_ROUGHNESS_MODEL == 0
224-
diffuseRoughnessTerm = diffuseBRDF_EON(surfaceAlbedo, diffuseRoughness, NoL, NoV) * PI;
224+
diffuseRoughnessTerm = diffuseBRDF_EON(vec3f(1.0), diffuseRoughness, NoL, NoV) * PI;
225225
#elif BASE_DIFFUSE_ROUGHNESS_MODEL == 1
226226
diffuseRoughnessTerm = vec3f(diffuseBRDF_Burley(NoL, NoV, VoH, diffuseRoughness) * PI);
227227
#endif

packages/dev/core/src/ShadersWGSL/ShadersInclude/lightFragment.fx

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
preInfo.roughness = adjustRoughnessFromLightProperties(roughness, light{X}.vLightSpecular.a, preInfo.lightDistance);
7676
#endif
7777
preInfo.diffuseRoughness = diffuseRoughness;
78-
preInfo.surfaceAlbedo = surfaceAlbedo;
7978

8079
#ifdef IRIDESCENCE
8180
preInfo.iridescenceIntensity = iridescenceIntensity;

packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.fx

-3
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ aggShadow = aggShadow / numLights;
4040
finalIrradiance += subSurfaceOut.refractionIrradiance;
4141
#endif
4242

43-
// Irradiance already include the surface albedo if using OpenPBR's ORN model.
44-
#if BASE_DIFFUSE_ROUGHNESS_MODEL != 0
4543
finalIrradiance *= surfaceAlbedo.rgb;
46-
#endif
4744
finalIrradiance *= uniforms.vLightingIntensity.z;
4845
finalIrradiance *= aoOut.ambientOcclusionColor;
4946
#endif

packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.fx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// _____________________________ Diffuse ________________________________________
22
var finalDiffuse: vec3f = diffuseBase;
3-
#if !defined(SS_TRANSLUCENCY) && BASE_DIFFUSE_ROUGHNESS_MODEL != 0
3+
#if !defined(SS_TRANSLUCENCY)
44
// When translucency is enabled, the final diffuse term is computed in the computeDiffuseAndTransmittedLighting function, we should not multiply it by the albedo here.
5-
// finalDiffuse already includes the surface albedo if using OpenPBR's ORN model.
65
finalDiffuse *= surfaceAlbedo.rgb;
76
#endif
87
finalDiffuse = max(finalDiffuse, vec3f(0.0));

packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockReflection.fx

+1-2
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@
234234
, icdfSamplerSampler: sampler
235235
#endif
236236
, diffuseRoughness: f32
237-
, surfaceAlbedo: vec3f
238237
#endif
239238
) -> reflectionOutParams
240239
{
@@ -311,7 +310,7 @@
311310
environmentIrradiance = vEnvironmentIrradiance;
312311
#else
313312
#if defined(REALTIME_FILTERING)
314-
environmentIrradiance = irradiance(reflectionSampler, reflectionSamplerSampler, irradianceVector, vReflectionFilteringInfo, diffuseRoughness, irradianceView, surfaceAlbedo
313+
environmentIrradiance = irradiance(reflectionSampler, reflectionSamplerSampler, irradianceVector, vReflectionFilteringInfo, diffuseRoughness, irradianceView
315314
#ifdef IBL_CDF_FILTERING
316315
, icdfSampler
317316
, icdfSamplerSampler

packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.fx

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ struct subSurfaceOutParams
517517

518518
#if defined(USESPHERICALFROMREFLECTIONMAP)
519519
#if defined(REALTIME_FILTERING)
520-
var refractionIrradiance: vec3f = irradiance(reflectionSampler, reflectionSamplerSampler, -irradianceVector, vReflectionFilteringInfo, diffuseRoughness, normalW, vec3f(1.0)
520+
var refractionIrradiance: vec3f = irradiance(reflectionSampler, reflectionSamplerSampler, -irradianceVector, vReflectionFilteringInfo, 0.0, irradianceVector
521521
#ifdef IBL_CDF_FILTERING
522522
, icdfSampler
523523
, icdfSamplerSampler

packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.fx

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn computeDiffuseLighting(info: preLightingInfo, lightColor: vec3f) -> vec3f {
3939
#if BASE_DIFFUSE_ROUGHNESS_MODEL == 1
4040
diffuseTerm = vec3f(diffuseBRDF_Burley(info.NdotL, info.NdotV, info.VdotH, info.diffuseRoughness));
4141
#elif BASE_DIFFUSE_ROUGHNESS_MODEL == 0
42-
diffuseTerm = diffuseBRDF_EON(info.surfaceAlbedo, info.diffuseRoughness, info.NdotL, info.NdotV);
42+
diffuseTerm = diffuseBRDF_EON(vec3f(1.0), info.diffuseRoughness, info.NdotL, info.NdotV);
4343
#endif
4444
return diffuseTerm * info.attenuation * info.NdotL * lightColor;
4545
}
@@ -68,7 +68,7 @@ fn computeProjectionTextureDiffuseLighting(projectionLightTexture: texture_2d<f3
6868
#if BASE_DIFFUSE_ROUGHNESS_MODEL == 1
6969
diffuseTerm = diffuseBRDF_Burley(NdotL, info.NdotV, info.VdotH, info.diffuseRoughness);
7070
#elif BASE_DIFFUSE_ROUGHNESS_MODEL == 0
71-
diffuseTerm = diffuseBRDF_EON(vec3(1.0), info.diffuseRoughness, NdotL, info.NdotV).x;
71+
diffuseTerm = diffuseBRDF_EON(vec3f(1.0), info.diffuseRoughness, NdotL, info.NdotV).x;
7272
#endif
7373
// Note: we use a Lambert BRDF for the transmitted term.
7474
return (transmittanceNdotL / PI + (1.0 - transmittanceIntensity) * diffuseTerm * surfaceAlbedo * info.NdotL) * info.attenuation * lightColor;

packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.fx

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ struct preLightingInfo
1818
VdotH: f32,
1919
roughness: f32,
2020
diffuseRoughness: f32,
21-
surfaceAlbedo: vec3f,
2221

2322
#ifdef IRIDESCENCE
2423
iridescenceIntensity: f32

packages/dev/core/src/ShadersWGSL/hdrIrradianceFiltering.fragment.fx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ varying direction: vec3f;
1616

1717
@fragment
1818
fn main(input: FragmentInputs) -> FragmentOutputs {
19-
var color: vec3f = irradiance(inputTexture, inputTextureSampler, input.direction, uniforms.vFilteringInfo, 1.0, input.direction, vec3f(1.0)
19+
var color: vec3f = irradiance(inputTexture, inputTextureSampler, input.direction, uniforms.vFilteringInfo, 1.0, input.direction
2020
#ifdef IBL_CDF_FILTERING
2121
, icdfTexture, icdfTextureSampler
2222
#endif

packages/dev/core/src/ShadersWGSL/pbr.fragment.fx

+2-3
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
312312
, icdfSamplerSampler
313313
#endif
314314
, diffuseRoughness
315-
, surfaceAlbedo
316315
#endif
317316
);
318317
#else
@@ -373,7 +372,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
373372
, reflectionHighSamplerSampler
374373
#endif
375374
#ifdef REALTIME_FILTERING
376-
, vReflectionFilteringInfo
375+
, uniforms.vReflectionFilteringInfo
377376
#endif
378377
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
379378
, seo
@@ -554,7 +553,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
554553
#if defined(REALTIME_FILTERING)
555554
, reflectionSampler
556555
, reflectionSamplerSampler
557-
, vReflectionFilteringInfo
556+
, uniforms.vReflectionFilteringInfo
558557
#ifdef IBL_CDF_FILTERING
559558
, icdfSampler
560559
, icdfSamplerSampler

0 commit comments

Comments
 (0)