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

Fix void checks in Geometry Buffers #14998

Merged
merged 1 commit into from
Apr 17, 2024
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
42 changes: 24 additions & 18 deletions packages/dev/core/src/Rendering/geometryBufferRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,113 +428,119 @@ export class GeometryBufferRenderer {
// for PBR materials: cf. https://doc.babylonjs.com/features/featuresDeepDive/materials/using/masterPBR
if (material.getClassName() === "PBRMetallicRoughnessMaterial") {
// if it is a PBR material in MetallicRoughness Mode:
if (material.metallicRoughnessTexture !== null) {
if (material.metallicRoughnessTexture) {
defines.push("#define ORMTEXTURE");
defines.push(`#define REFLECTIVITY_UV${material.metallicRoughnessTexture.coordinatesIndex + 1}`);
defines.push("#define METALLICWORKFLOW");
needUv = true;
metallicWorkflow = true;
}
if (material.metallic !== null) {
// null or undefined
if (material.metallic != null) {
defines.push("#define METALLIC");
defines.push("#define METALLICWORKFLOW");
metallicWorkflow = true;
}
if (material.roughness !== null) {
// null or undefined
if (material.roughness != null) {
defines.push("#define ROUGHNESS");
defines.push("#define METALLICWORKFLOW");
metallicWorkflow = true;
}
if (metallicWorkflow) {
if (material.baseTexture !== null) {
if (material.baseTexture) {
defines.push("#define ALBEDOTEXTURE");
defines.push(`#define ALBEDO_UV${material.baseTexture.coordinatesIndex + 1}`);
if (material.baseTexture.gammaSpace) {
defines.push("#define GAMMAALBEDO");
}
needUv = true;
}
if (material.baseColor !== null) {
if (material.baseColor) {
defines.push("#define ALBEDOCOLOR");
}
}
} else if (material.getClassName() === "PBRSpecularGlossinessMaterial") {
// if it is a PBR material in Specular/Glossiness Mode:
if (material.specularGlossinessTexture !== null) {
if (material.specularGlossinessTexture) {
defines.push("#define SPECULARGLOSSINESSTEXTURE");
defines.push(`#define REFLECTIVITY_UV${material.specularGlossinessTexture.coordinatesIndex + 1}`);
needUv = true;
if (material.specularGlossinessTexture.gammaSpace) {
defines.push("#define GAMMAREFLECTIVITYTEXTURE");
}
} else {
if (material.specularColor !== null) {
if (material.specularColor) {
defines.push("#define REFLECTIVITYCOLOR");
}
}
if (material.glossiness !== null) {
// null or undefined
if (material.glossiness != null) {
defines.push("#define GLOSSINESS");
}
} else if (material.getClassName() === "PBRMaterial") {
// if it is the bigger PBRMaterial
if (material.metallicTexture !== null) {
if (material.metallicTexture) {
defines.push("#define ORMTEXTURE");
defines.push(`#define REFLECTIVITY_UV${material.metallicTexture.coordinatesIndex + 1}`);
defines.push("#define METALLICWORKFLOW");
needUv = true;
metallicWorkflow = true;
}
if (material.metallic !== null) {
// null or undefined
if (material.metallic != null) {
defines.push("#define METALLIC");
defines.push("#define METALLICWORKFLOW");
metallicWorkflow = true;
}

if (material.roughness !== null) {
// null or undefined
if (material.roughness != null) {
defines.push("#define ROUGHNESS");
defines.push("#define METALLICWORKFLOW");
metallicWorkflow = true;
}

if (metallicWorkflow) {
if (material.albedoTexture !== null) {
if (material.albedoTexture) {
defines.push("#define ALBEDOTEXTURE");
defines.push(`#define ALBEDO_UV${material.albedoTexture.coordinatesIndex + 1}`);
if (material.albedoTexture.gammaSpace) {
defines.push("#define GAMMAALBEDO");
}
needUv = true;
}
if (material.albedoColor !== null) {
if (material.albedoColor) {
defines.push("#define ALBEDOCOLOR");
}
} else {
// SpecularGlossiness Model
if (material.reflectivityTexture !== null) {
if (material.reflectivityTexture) {
defines.push("#define SPECULARGLOSSINESSTEXTURE");
defines.push(`#define REFLECTIVITY_UV${material.reflectivityTexture.coordinatesIndex + 1}`);
if (material.reflectivityTexture.gammaSpace) {
defines.push("#define GAMMAREFLECTIVITYTEXTURE");
}
needUv = true;
} else if (material.reflectivityColor !== null) {
} else if (material.reflectivityColor) {
defines.push("#define REFLECTIVITYCOLOR");
}
if (material.microSurface !== null) {
// null or undefined
if (material.microSurface != null) {
defines.push("#define GLOSSINESS");
}
}
} else if (material.getClassName() === "StandardMaterial") {
// if StandardMaterial:
if (material.specularTexture !== null) {
if (material.specularTexture) {
defines.push("#define REFLECTIVITYTEXTURE");
defines.push(`#define REFLECTIVITY_UV${material.specularTexture.coordinatesIndex + 1}`);
if (material.specularTexture.gammaSpace) {
defines.push("#define GAMMAREFLECTIVITYTEXTURE");
}
needUv = true;
}
if (material.specularColor !== null) {
if (material.specularColor) {
defines.push("#define REFLECTIVITYCOLOR");
}
}
Expand Down