Can I make global variables without using uniform

wyattbikerwyattbiker Posts: 9Member

I have a global variable in my shader, but I am not interested in exposing in the shader material. Though I do want multiple functions to access it. Is there a way to do that without having to use the uniform keyword? E.g. float temp=2.0;

Answers

  • TwistedTwiglegTwistedTwigleg Posts: 1,049Admin
    Answer ✓

    I think varying variables can be accessed by multiple functions, though I have not written too many shaders before so I could be miss remembering.

  • wyattbikerwyattbiker Posts: 9Member
    edited October 2018

    I had looked at that, but what threw me off is the docs "To send data from vertex to fragment shader, varyings are used. ".
    But you are probably right, in the sense that this could be a workaround. I will have to try it.

    EDIT: So varying is unsuitable. It cannot be initialized in globals and also can only be assigned to in vertex functions.

  • MegalomaniakMegalomaniak Posts: 1,087Admin

    I don't really understand your problem in that this is what uniforms are for.

    I do however feel that ultimately we need, or rather could really use a way to group and organize the uniforms as they are listed in the inspector interface, and yeah while at it having a hint for hiding a uniform from the inspector would be a nice QOL feature as well.

Sign In or Register to comment.