Closed Aeva closed 7 years ago
Adding this feature should be fairly easy, especially because of the refactoring done as part of #196. The steps are something like so:
I came up with a better keyword for this while figuring out what to do with #203:
attribute/uniform vec3 position;
I like this version because syntax highlighting still works in github :)
Probably going to go with this for now, because it is more compact:
in/uniform vec3 position;
Started working on this in the "instancing" branch from "fast_graph".
Things to do next:
Actually setting up the buffers for instancing is the scope of another issue (possibly #246).
This is an example of how the syntax might look:
And this is an example of how the compiler output might look:
The variable
_instanced_render
would be used to control when instancing is active, in which case the instanced variables would be populated from their respective attribute (or attributes, in the case of mat3 and mat4s). When it is false, the respective uniforms are referenced instead.The generated uniforms would alias back to the expected value so that the application interface stays sensible. The attributes should not be handled per object, but rather be disabled by default and explicitly enabled when instancing is needed and be disabled afterwards - or there could be some kind of explicit mechanism for enabling instancing vis disabling it to eliminate state changes.