-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[rmodels] More performant point cloud rendering with DrawModelPoints()
#4203
Conversation
@satchelfrost Thanks for the addition, please, note that new examples should follow examples template, including the rules and conventions: https://github.com/raysan5/raylib/blob/master/examples/examples_template.c |
DrawModelPoints()
Please, note that the following files should be updated when adding a new example, it's planned to create some script to automatize part of this process but not available yet.
|
Ah, sorry about that, I will make those changes. On a separate note I did some more investigation with the point rendering. On my machine rendering 10,000,000 points, I noticed that when I zoomed in, the frame rate started to drop. Which doesn't really make any sense for a point cloud. So I opened renderdoc and found that even though the points are being shown in the final image, you can actually see the triangles in wireframe in renderdoc. As a test, instead of using rlEnablePointMode(), I modified rlDrawVertexArray() to use GL_POINTS. Visually there is no difference in the final image. But when I zoom in at 10,000,000 points there is no performance drop, and its a solid 60 FPS, and the renderdoc image shows only points being drawn. Also just to see how far I could push it on my machine I was able to get 100,000,000 points at roughly 50 FPS. Kind of looks like a blob though. So my question is given that it is even more performant to just use GL_POINTS instead of just rlEnablePointMode(), would you like me to modify the current code to use this method instead? Perhaps a new function rlDrawVertexArrayPoints()? The current method works and doesn't mess with the API too much, it's just not as performant as it could be. |
@satchelfrost I'm not sure how to address this improvement, not only because it's platform-dependant but also because if |
In that case, I will stick to the previous approach which is still more performant than DrawPoint3D. I've updated the makefiles as well. I still need to figure out how to generate the vcxproj file since I don't use visual studio and it looks like a simple copy paste from one of the other examples won't work because a guid needs to be generated (currently using Linux). If you're okay with the current example then I will make a request on the raylib.com repo for the web version. |
@satchelfrost Thanks for the review! Don't worry about the VS project, I'll try to address it myself. |
Currently, raylib has DrawPoint3D which works well for most things, but has a few issues:
Instead I added a two new functions DrawModelPoints and DrawModelPointsEx. They follow the same pattern as DrawModelWires and DrawModelWiresEx, but instead temporarily sets rlEnablePointMode and rlDisableBackfaceCulling (which it then reverts after calling DrawModel). The following example provided demonstrates the performance difference between DrawModelPoints and DrawPoint3D for various point cloud sizes.
With my card (6700xt) 1,000,000 points are easily rendered @60 FPS using DrawModelPoints, whereas the same example with DrawPoint3D is unusable < 10 FPS. Your mileage may vary depending on the graphics card, but overall DrawModelPoints should be more performant than DrawPoint3D.