Posts

Showing posts with the label quad

Compute Shaders, particle system with quads, using Frag/Vert shader to draw

This is more or less the same as the last wall of code. However this time, we are using the Graphics draw to draw a quad, which consists of Four points, Two triangles. We need to adjust our buffer and create a new struct for this, as well as initialise our arrays in a specific way to ensure the quads are facing the correct direction.   As mentioned, our new Struct - Vertex stores a position, UV value and life. We're going to use the Compute Shader to calculate the postion of each particle-  but then draw a quad at that position. We set the specific values for the vertices in the compute shader too. (the UVs don't change for each quad, so we set that value in the C# script)     //Triangle 1 - bot left, top left, top right     vertexBuffer[index].position.x = p.position.x - halfSize;     vertexBuffer[index].position.y = p.position.y - halfSize;     vertexBuffer[index].position.z = p.position.z;     vertex...