Skip to content

Commit

Permalink
Merge pull request #15768 from BabylonJS/nme-crash
Browse files Browse the repository at this point in the history
Fix various issues
  • Loading branch information
sebavan authored Nov 4, 2024
2 parents 8a06790 + f46e3e7 commit 4704059
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .build/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"versionDefinition": "patch",
"preid": "rc",
"nonce": 285
}
"nonce": 286
}
28 changes: 18 additions & 10 deletions packages/dev/core/src/Materials/Node/Blocks/Input/inputBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,35 +574,43 @@ export class InputBlock extends NodeMaterialBlock {
return;
}

if (state.attributes.indexOf(this.declarationVariableName) !== -1) {
return;
}
const alreadyDeclared = state.attributes.indexOf(this.declarationVariableName) !== -1;

state.attributes.push(this.declarationVariableName);
if (!alreadyDeclared) {
state.attributes.push(this.declarationVariableName);
}

if (attributeInFragmentOnly[this.name]) {
if (attributeAsUniform[this.name]) {
state._emitUniformFromString(this.declarationVariableName, this.type, define);
if (!alreadyDeclared) {
state._emitUniformFromString(this.declarationVariableName, this.type, define);
}
if (state.shaderLanguage === ShaderLanguage.WGSL) {
this._prefix = `uniforms.`;
}
} else {
state._emitVaryingFromString(this.declarationVariableName, this.type, define);
if (!alreadyDeclared) {
state._emitVaryingFromString(this.declarationVariableName, this.type, define);
}
if (state.shaderLanguage === ShaderLanguage.WGSL) {
this._prefix = `fragmentInputs.`;
}
}
} else {
if (define) {
if (define && !alreadyDeclared) {
state._attributeDeclaration += this._emitDefine(define);
}
if (state.shaderLanguage === ShaderLanguage.WGSL) {
state._attributeDeclaration += `attribute ${this.declarationVariableName}: ${state._getShaderType(this.type)};\n`;
if (!alreadyDeclared) {
state._attributeDeclaration += `attribute ${this.declarationVariableName}: ${state._getShaderType(this.type)};\n`;
}
this._prefix = `vertexInputs.`;
} else {
state._attributeDeclaration += `attribute ${state._getShaderType(this.type)} ${this.declarationVariableName};\n`;
if (!alreadyDeclared) {
state._attributeDeclaration += `attribute ${state._getShaderType(this.type)} ${this.declarationVariableName};\n`;
}
}
if (define) {
if (define && !alreadyDeclared) {
state._attributeDeclaration += `#endif\n`;
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/dev/core/src/Materials/Node/nodeMaterial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,9 @@ export class NodeMaterial extends PushMaterial {
* Get a string representing the shaders built by the current node graph
*/
public get compiledShaders() {
if (!this._buildWasSuccessful) {
this.build();
}
return `// Vertex shader\n${this._vertexCompilationState.compilationString}\n\n// Fragment shader\n${this._fragmentCompilationState.compilationString}`;
}

Expand Down

0 comments on commit 4704059

Please sign in to comment.