-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Diffuse Roughness support #16253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Diffuse Roughness support #16253
Changes from 33 commits
29e67a2
80d16d0
e9ce268
fdb02fd
7c4de63
914d254
6614545
19af1f5
6515d9f
09dfefe
19943bb
6f6c9f4
8a002b8
f964985
7b79ce1
7f9e792
220c783
b4159da
4680584
499de22
39d557c
70afee7
0080252
ad5a6ed
522ba17
3aa0836
dc805f7
4dce91f
ad4bbc6
11215b5
0b31a55
9b5bca6
38a3b82
1e5d962
36965f6
11a6e33
a346f2e
bd8ba81
d4c2ce8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,7 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock { | |
private _metallicReflectanceColor: Color3 = Color3.White(); | ||
private _metallicF0Factor = 1; | ||
private _vMetallicReflectanceFactorsName: string; | ||
private _baseDiffuseRoughnessName: string; | ||
|
||
/** | ||
* Create a new ReflectionBlock | ||
|
@@ -270,6 +271,19 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock { | |
}) | ||
public realTimeFilteringQuality = Constants.TEXTURE_FILTERING_QUALITY_LOW; | ||
|
||
/** | ||
* Base Diffuse Roughness Model | ||
*/ | ||
@editableInPropertyPage("Diffuse Roughness Model", PropertyTypeForEdition.List, "RENDERING", { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following my previous remark, maybe this should simply be called "Diffuse Model". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, yeah, that's a good point. I like that more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
notifiers: { update: true }, | ||
options: [ | ||
{ label: "Lambert", value: Constants.MATERIAL_DIFFUSE_ROUGHNESS_LAMBERT }, | ||
{ label: "Burley", value: Constants.MATERIAL_DIFFUSE_ROUGHNESS_BURLEY }, | ||
{ label: "Oren-Nayar", value: Constants.MATERIAL_DIFFUSE_ROUGHNESS_E_OREN_NAYAR }, | ||
], | ||
}) | ||
public baseDiffuseRoughnessModel = Constants.MATERIAL_DIFFUSE_ROUGHNESS_E_OREN_NAYAR; | ||
|
||
/** | ||
* Defines if the material uses energy conservation. | ||
*/ | ||
|
@@ -761,6 +775,8 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock { | |
defines.setValue("NUM_SAMPLES", "" + this.realTimeFilteringQuality, true); | ||
} | ||
|
||
defines.setValue("BASE_DIFFUSE_ROUGHNESS_MODEL", this.baseDiffuseRoughnessModel, true); | ||
|
||
// Advanced | ||
defines.setValue("BRDF_V_HEIGHT_CORRELATED", true); | ||
defines.setValue("MS_BRDF_ENERGY_CONSERVATION", this.useEnergyConservation, true); | ||
|
@@ -1013,13 +1029,21 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock { | |
this._vMetallicReflectanceFactorsName = state._getFreeVariableName("vMetallicReflectanceFactors"); | ||
state._emitUniformFromString(this._vMetallicReflectanceFactorsName, NodeMaterialBlockConnectionPointTypes.Vector4); | ||
|
||
this._baseDiffuseRoughnessName = state._getFreeVariableName("baseDiffuseRoughness"); | ||
state._emitUniformFromString(this._baseDiffuseRoughnessName, NodeMaterialBlockConnectionPointTypes.Float); | ||
|
||
code += `${state._declareLocalVar("baseColor", NodeMaterialBlockConnectionPointTypes.Vector3)} = surfaceAlbedo; | ||
${isWebGPU ? "let" : `vec4${state.fSuffix}`} vReflectivityColor = vec4${state.fSuffix}(${this.metallic.associatedVariableName}, ${this.roughness.associatedVariableName}, ${this.indexOfRefraction.associatedVariableName || "1.5"}, 1.0); | ||
reflectivityOut = reflectivityBlock( | ||
vReflectivityColor | ||
#ifdef METALLICWORKFLOW | ||
, surfaceAlbedo | ||
, ${(isWebGPU ? "uniforms." : "") + this._vMetallicReflectanceFactorsName} | ||
#endif | ||
, ${(isWebGPU ? "uniforms." : "") + this._baseDiffuseRoughnessName} | ||
#ifdef BASE_DIFFUSE_ROUGHNESS | ||
, 0. | ||
, vec2${state.fSuffix}(0., 0.) | ||
#endif | ||
#ifdef REFLECTIVITY | ||
, vec3${state.fSuffix}(0., 0., ${aoIntensity}) | ||
|
@@ -1035,6 +1059,7 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock { | |
|
||
${state._declareLocalVar("microSurface", NodeMaterialBlockConnectionPointTypes.Float)} = reflectivityOut.microSurface; | ||
${state._declareLocalVar("roughness", NodeMaterialBlockConnectionPointTypes.Float)} = reflectivityOut.roughness; | ||
${state._declareLocalVar("diffuseRoughness", NodeMaterialBlockConnectionPointTypes.Float)} = reflectivityOut.diffuseRoughness; | ||
|
||
#ifdef METALLICWORKFLOW | ||
surfaceAlbedo = reflectivityOut.surfaceAlbedo; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit counter intuitive to have both "ROUGHNESS" and "LAMBERT" in the same name, given that the Lambert model is for perfectly flat diffuse surface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Maybe
MATERIAL_DIFFUSE_ROUGHNESS_NONE
is better?