Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question "Unexpected token 'cubemap_float'" in custom node

Discussion in 'Shader Graph' started by AlanRStagner, Dec 1, 2019.

  1. AlanRStagner

    AlanRStagner

    Joined:
    Jan 9, 2018
    Posts:
    11
    I'm trying to create a simple graph that just samples a cubemap with the object's normals and displays the value. After realizing that the built-in "Sample Cubemap" node automatically applies reflection that I can't seem to turn off (which seems like a really bizarre/bad decision to me??? but I digress), I thought to myself "fine, I'll just write a custom function to do this instead".

    But, well.... :\

    shadergraph_syntaxerror.png

    I get this. I have no idea how I'm supposed to fix this, this is a pretty unhelpful error message. Any clue what's going on here?
     
    Alex-CG and Raptosauru5 like this.
  2. AlanRStagner

    AlanRStagner

    Joined:
    Jan 9, 2018
    Posts:
    11
    OK so I figured out that this is related to having a space in the "Name" field. I'm guessing it just naively tries to construct a function name from that field without trying to do any error checking or sanitizing at all.
    My code was also wrong, naturally, but the error was completely unrelated to that. Actually, now that I'm digging in, the custom node's UX in general is... pretty severely lacking, tbh.

    • Supplying a malformed name field results in unhelpful error messages. The name field should be sanity checked before it tries to just dump it into a shader file as-is.
    • Not supplying a name results in an auto-generated function name (good), but also prepends all inputs and outputs with that function name without telling you and will as a result throw errors on trying to reference them by the names you defined (bad). Honestly, this should *either* give me an error if I supply no name, or it shouldn't auto-rename the variables and prevent me from referencing them.
     
    Alex-CG and Raptosauru5 like this.