What's the best way to visualize/debug raycast rays and normals?

Let’s say I want to debug my raycast ray or some normal vector, as in wanting to visualize them. Is it a better idea to create a vbo of a line which I’d make as many instances (game objects) as I need. Or is there a way I’m able to create a line in only GLSL?

You can render with GL_POINTS and use a geometry shader to turn each point into a line.

you dont need to create a new VBO (or even VAO) if you want to add a new mesh / geometry to your scene
you can just put the vertices into the same buffer where you stored all the other meshes
“mesh” itself doesnt have to be a separate class with its own shader / buffer / you know what …
you can just create a new struct:

struct DrawCall
unsigned int Primitive{GL_TRIANGLES};
unsigned int Offset{0};
unsigned int Count{0};

those are the arguments you would feed to “glDrawArrays(…)”

for each “mesh” (triangle, cube, sphere, monkeyhead, starwars-ship, …):
– load its vertices / texcoords / normals
– put the data into 1 big buffer (or 3 big buffers, 1 for each attribute)
– save the “DrawCall”:
---- Primitive = GL_TRIANGLES (by default)
---- Offset = vertices.size() before loading the mesh data
---- Count = vertices.size() after loading the mesh data


for a new line, put 2 vertices into that buffer and store the drawcall anywhere (for example: std::list<DrawCall> mylistofmodels)

Thanks guys, I’ll work on it tonight :slight_smile: