Hello friends
I’ve had several cases where I have volumes that I want to affect shaders - aka allowing the shader to check if a vertex/pixel is inside a volume, and doing whatever I want to do if that is the case.
However, my current solution is pretty ugly, I’d say - it involves unraveling a for loop, which feels incredibly wrong. Essentially I have a volume manager that saves arrays of volume sizes and positions to a shader global variable. Then in the shader, I loop the volumes size/positions.
Is there a better way to do this?
Josh
How many overlap there is from one mesh with the volumes?
You could probably have a spatial partioning based on the minimal amount of overlap per volume (just like it’s done per light)
I’d be fine with the one volume per mesh. How does this spatial partitioning thing work in shaders?
Nah you do it before the shader, then you passed it to the shader, so now it only have one set of data. That’s basically the rendering pipeline, we sort object on cpu, and only pass relevant data together to gpu. Basically in this case you would expose the volume parameter (say position and radius if spherical), and pass it by code before rendering.
Interesting. How would I go through all objects that have that shader?
Why not loop through the objects with a certain material, or better, have the object register if seen onto a list. Or simply design object so they have a flag or created inside the proper list. Depending of either they are static or not, you can also register then in spatial partition (like zone you have define, when they enter they register to that, then before rendering you check the zone and then look at what it contain. etc …