PDA

View Full Version : What's the best way to visualize/debug raycast rays and normals?



hashbrown
09-21-2016, 05:07 PM
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?

GClements
09-21-2016, 07:08 PM
You can render with GL_POINTS and use a geometry shader to turn each point into a line.

john_connor
09-22-2016, 06:38 AM
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

https://www.opengl.org/wiki/Vertex_Specification_Best_Practices#Size_of_a_buff er_object

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

hashbrown
09-22-2016, 07:13 AM
Thanks guys, I'll work on it tonight :)