@@ -97,6 +97,7 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
97
97
private _metallicReflectanceColor : Color3 = Color3 . White ( ) ;
98
98
private _metallicF0Factor = 1 ;
99
99
private _vMetallicReflectanceFactorsName : string ;
100
+ private _baseDiffuseRoughnessName : string ;
100
101
101
102
/**
102
103
* Create a new ReflectionBlock
@@ -271,6 +272,19 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
271
272
} )
272
273
public realTimeFilteringQuality = Constants . TEXTURE_FILTERING_QUALITY_LOW ;
273
274
275
+ /**
276
+ * Base Diffuse Model
277
+ */
278
+ @editableInPropertyPage ( "Diffuse Model" , PropertyTypeForEdition . List , "RENDERING" , {
279
+ notifiers : { update : true } ,
280
+ options : [
281
+ { label : "Lambert" , value : Constants . MATERIAL_DIFFUSE_MODEL_LAMBERT } ,
282
+ { label : "Burley" , value : Constants . MATERIAL_DIFFUSE_MODEL_BURLEY } ,
283
+ { label : "Oren-Nayar" , value : Constants . MATERIAL_DIFFUSE_MODEL_E_OREN_NAYAR } ,
284
+ ] ,
285
+ } )
286
+ public baseDiffuseModel = Constants . MATERIAL_DIFFUSE_MODEL_E_OREN_NAYAR ;
287
+
274
288
/**
275
289
* Defines if the material uses energy conservation.
276
290
*/
@@ -762,6 +776,8 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
762
776
defines . setValue ( "NUM_SAMPLES" , "" + this . realTimeFilteringQuality , true ) ;
763
777
}
764
778
779
+ defines . setValue ( "BASE_DIFFUSE_MODEL" , this . baseDiffuseModel , true ) ;
780
+
765
781
// Advanced
766
782
defines . setValue ( "BRDF_V_HEIGHT_CORRELATED" , true ) ;
767
783
defines . setValue ( "MS_BRDF_ENERGY_CONSERVATION" , this . useEnergyConservation , true ) ;
@@ -1014,13 +1030,21 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
1014
1030
this . _vMetallicReflectanceFactorsName = state . _getFreeVariableName ( "vMetallicReflectanceFactors" ) ;
1015
1031
state . _emitUniformFromString ( this . _vMetallicReflectanceFactorsName , NodeMaterialBlockConnectionPointTypes . Vector4 ) ;
1016
1032
1033
+ this . _baseDiffuseRoughnessName = state . _getFreeVariableName ( "baseDiffuseRoughness" ) ;
1034
+ state . _emitUniformFromString ( this . _baseDiffuseRoughnessName , NodeMaterialBlockConnectionPointTypes . Float ) ;
1035
+
1017
1036
code += `${ state . _declareLocalVar ( "baseColor" , NodeMaterialBlockConnectionPointTypes . Vector3 ) } = surfaceAlbedo;
1018
1037
${ isWebGPU ? "let" : `vec4${ state . fSuffix } ` } vReflectivityColor = vec4${ state . fSuffix } (${ this . metallic . associatedVariableName } , ${ this . roughness . associatedVariableName } , ${ this . indexOfRefraction . associatedVariableName || "1.5" } , 1.0);
1019
1038
reflectivityOut = reflectivityBlock(
1020
1039
vReflectivityColor
1021
1040
#ifdef METALLICWORKFLOW
1022
1041
, surfaceAlbedo
1023
1042
, ${ ( isWebGPU ? "uniforms." : "" ) + this . _vMetallicReflectanceFactorsName }
1043
+ #endif
1044
+ , ${ ( isWebGPU ? "uniforms." : "" ) + this . _baseDiffuseRoughnessName }
1045
+ #ifdef BASE_DIFFUSE_ROUGHNESS
1046
+ , 0.
1047
+ , vec2${ state . fSuffix } (0., 0.)
1024
1048
#endif
1025
1049
#ifdef REFLECTIVITY
1026
1050
, vec3${ state . fSuffix } (0., 0., ${ aoIntensity } )
@@ -1036,6 +1060,7 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
1036
1060
1037
1061
${ state . _declareLocalVar ( "microSurface" , NodeMaterialBlockConnectionPointTypes . Float ) } = reflectivityOut.microSurface;
1038
1062
${ state . _declareLocalVar ( "roughness" , NodeMaterialBlockConnectionPointTypes . Float ) } = reflectivityOut.roughness;
1063
+ ${ state . _declareLocalVar ( "diffuseRoughness" , NodeMaterialBlockConnectionPointTypes . Float ) } = reflectivityOut.diffuseRoughness;
1039
1064
1040
1065
#ifdef METALLICWORKFLOW
1041
1066
surfaceAlbedo = reflectivityOut.surfaceAlbedo;
0 commit comments