Skip to content

Commit

Permalink
Fix undeclared identifier error in NodeMaterial shader
Browse files Browse the repository at this point in the history
  • Loading branch information
Starryi committed Nov 1, 2023
1 parent c2de504 commit 8d7012f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Expand Up @@ -371,11 +371,15 @@ export class LightBlock extends NodeMaterialBlock {

if (this.light) {
state.compilationString += state._emitCodeFromInclude("lightFragment", comments, {
replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }],
replaceStrings: [
{ search: /{X}/g, replace: this._lightId.toString() },
{ search: /vPositionW/g, replace: worldPosVariableName + ".xyz" },
],
});
} else {
state.compilationString += state._emitCodeFromInclude("lightFragment", comments, {
repeatKey: "maxSimultaneousLights",
replaceStrings: [{ search: /vPositionW/g, replace: worldPosVariableName + ".xyz" }],
});
}

Expand Down
Expand Up @@ -1116,9 +1116,7 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
state._emitFunctionFromInclude("imageProcessingDeclaration", comments);
state._emitFunctionFromInclude("imageProcessingFunctions", comments);

state._emitFunctionFromInclude("shadowsFragmentFunctions", comments, {
replaceStrings: [{ search: /vPositionW/g, replace: worldPosVarName + ".xyz" }],
});
state._emitFunctionFromInclude("shadowsFragmentFunctions", comments);

state._emitFunctionFromInclude("pbrDirectLightingSetupFunctions", comments, {
replaceStrings: [{ search: /vPositionW/g, replace: worldPosVarName + ".xyz" }],
Expand Down Expand Up @@ -1331,11 +1329,15 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {

if (this.light) {
state.compilationString += state._emitCodeFromInclude("lightFragment", comments, {
replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }],
replaceStrings: [
{ search: /{X}/g, replace: this._lightId.toString() },
{ search: /vPositionW/g, replace: worldPosVarName + ".xyz" },
],
});
} else {
state.compilationString += state._emitCodeFromInclude("lightFragment", comments, {
repeatKey: "maxSimultaneousLights",
replaceStrings: [{ search: /vPositionW/g, replace: worldPosVarName + ".xyz" }],
});
}

Expand Down

0 comments on commit 8d7012f

Please sign in to comment.