I’m taking a graphics class (Ed Angel’s book) and have thus far used only simple shaders. I want to expand into more complicated shaders that actually store most of the data they need on the GPU rather than updating that data from the CPU each frame. This particular program is an agent based model with thousands of triangles moving on a grid.
Thus I want to store data in the shader that changes each time through the DrawArrays pipeline. I believe I will only need two ARRAY_BUFFERs. One would be thousands of identical triangles at the origin pointing “up”. The other would be integer indices into the on-GPU storage which contains position and heading, and each DrawArrays calculates new values for that data.
So my first “hello shader” will store on-GPU the position and heading of the many triangles, and update those values each time DrawArrays is run.
I know that I can store arrays of floats etc, and even structs in the shader. I’m told, however, it might be better to use texture memory.
So my post is to find an example of such a stunt, or pointers/suggestions as to how to do this.