Skip to content
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

NME PBR: Add full support for image processing #10248

Merged
merged 1 commit into from Apr 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.ts
Expand Up @@ -672,6 +672,10 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
defines.setValue("ENVIRONMENTBRDF_RGBD", false);
}

if (defines._areImageProcessingDirty && nodeMaterial.imageProcessingConfiguration) {
nodeMaterial.imageProcessingConfiguration.prepareDefines(defines);
}

if (!defines._areLightsDirty) {
return;
}
Expand Down Expand Up @@ -710,11 +714,17 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
}
}

public isReady() {
public isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines) {
if (this._environmentBRDFTexture && !this._environmentBRDFTexture.isReady()) {
return false;
}

if (defines._areImageProcessingDirty && nodeMaterial.imageProcessingConfiguration) {
if (!nodeMaterial.imageProcessingConfiguration.isReady()) {
return false;
}
}

return true;
}

Expand Down Expand Up @@ -761,6 +771,10 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
const metallicF90 = this._metallicF0Factor;

effect.setColor4(this._vMetallicReflectanceFactorsName, TmpColors.Color3[0], metallicF90);

if (nodeMaterial.imageProcessingConfiguration) {
nodeMaterial.imageProcessingConfiguration.bind(effect);
}
}

private _injectVertexCode(state: NodeMaterialBuildState) {
Expand Down Expand Up @@ -952,6 +966,18 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
state._emitExtension("lod", "#extension GL_EXT_shader_texture_lod : enable", "defined(LODBASEDMICROSFURACE)");
state._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");

// Image processing uniforms
state.uniforms.push("exposureLinear");
state.uniforms.push("contrast");
state.uniforms.push("vInverseScreenSize");
state.uniforms.push("vignetteSettings1");
state.uniforms.push("vignetteSettings2");
state.uniforms.push("vCameraColorCurveNegative");
state.uniforms.push("vCameraColorCurveNeutral");
state.uniforms.push("vCameraColorCurvePositive");
state.uniforms.push("txColorTransform");
state.uniforms.push("colorTransformSettings");

//
// Includes
//
Expand All @@ -968,6 +994,7 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
state._emitFunctionFromInclude("helperFunctions", comments);
state._emitFunctionFromInclude("importanceSampling", comments);
state._emitFunctionFromInclude("pbrHelperFunctions", comments);
state._emitFunctionFromInclude("imageProcessingDeclaration", comments);
state._emitFunctionFromInclude("imageProcessingFunctions", comments);

state._emitFunctionFromInclude("shadowsFragmentFunctions", comments, {
Expand Down