Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zone collision octree rendering #10

Closed
ughman opened this issue Apr 21, 2015 · 4 comments
Closed

Zone collision octree rendering #10

ughman opened this issue Apr 21, 2015 · 4 comments

Comments

@ughman
Copy link
Member

ughman commented Apr 21, 2015

CrashEdit should support a default-off toggleable option to render the collidable geometry used in zones.

I already have an uncommitted implementation of this using immediate mode, with terrible performance. GL display lists help this somewhat, but not enough to be very useful. VBO's may be able to get much better performance, and non-VBO-capable hardware is not going to be powerful enough to get even one FPS on immediate mode anyway.

I'd also like to look into ways of using fragment shaders. Perhaps a quad could be rendered across the entire screen, and a fragment shader could do the octree walk for each fragment? Not sure about the math involved or the potential performance issues, since the kind of conditional execution it will take might be pretty bad on GPU hardware. We'll see.

@warenhuis
Copy link

With what ease can these octrees be edited?

@ughman
Copy link
Member Author

ughman commented May 13, 2016

Not really sure what the best way would be to do it, perhaps flatten the tree into a 3d bitmap and then replicate the kind of behavior you'd see in a voxel editor, whatever that looks like exactly I'm not sure. One thing to note is the octrees have a specified resolution in their headers, so you don't have to walk the tree first to find your target bitmap resolution.

@ughman
Copy link
Member Author

ughman commented May 13, 2016

Also, I've been thinking about how to properly render this data recently, and I think the fastest way is probably to generate a bunch of 2d textures, one for every x value, one for every y, one for every z, and render them as double-sided quads. Like say you have a 128x64x256 collision area. That's 129 64x256 textures (one for every x value including 128 and 0) which you would render as 64x256 quads at the given x positions. Same thing with the y and z axis as well. The advantage to this setup is it's more in line with how GPU's deal with this kind of thing, plus it can be done in opengl 1.1 which means you get nearly universal support since windows will emulate 1.1 and mesa will emulate at least 2.0 I believe.

Downside is you don't really get the wireframe rendering like you see in crashutils, though that could be implemented as an optional mode for opengl 2.0 using shaders

@ManDude
Copy link
Collaborator

ManDude commented Mar 4, 2024

Implemented using shaders with okay-to-not-great performance (right now we upload around (1^x + 1) * (1^y + 1) * (1^z + 1) * 2 * 2 triangles for fill more and around ((1^x * 1^y) + (1^x * 1^z) + (1^y * 1^z)) * 4 lines for wireframe mode) and inability to render non-max-depth nodes correctly. Perfectly usable however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants