AcademySoftwareFoundation/MaterialX

GLSL code generation fails if identifiers start with numbers

Closed this issue · 2 comments

Issue

Identifiers which start with numbers are not being sanitized properly for GLSL. This may be true for other languages like MSL.

Example

<?xml version="1.0"?>
<materialx version="1.39">
  <surfacematerial name="surfacematerial" type="material" xpos="16.782608" ypos="-0.844828">
    <input name="surfaceshader" type="surfaceshader" nodename="1_node" />
  </surfacematerial>
  <standard_surface name="1_node" type="surfaceshader" xpos="12.471014" ypos="-1.482759" />
</materialx>

Workflow

This was created using the node editor, with these errors:

Error in compiling fragment shader:
0(1898) : error C0000: syntax error, unexpected integer constant, expecting ';' or '(' at token "<int-const>"
0(1899) : error C0000: syntax error, unexpected identifier, expecting ')' at token "_node_out"
0(1900) : error C0000: syntax error, unexpected identifier, expecting ',' or ')' at token "_node_out"

It would be nice if these strings were disallowed based on shading language but a different issue.

@kwokcb This sounds like a familiar topic, and I think it may be a subset of this GitHub Issue from October?

#2045

Ah. Your correct. Closing this as a duplicate.