1 Million Raytraced Spheres (C++ / OpenGL) HD

26.10.2020
My goal is to code the DEM program in the 3rd dimension, so I need a way to draw millions of spheres. This program uses a combination of billboarding and raytracing to draw a pixel perfect sphere of a random radius and color at every vertex of a Stanford bunny (1 million vertices). For this size of sphere and on a full HD screen, I can draw more than 3 millions spheres at 60 fps on an old GT650M (alienware laptop). There is no early depth testing or any particular optimization done yet, which is quite promising ! CPU - GPU bandwith is also quite optimized as I only have to send the position of each sphere, its radius, and color. A geometry shader then creates a billboard (4 vertices) of the exact size of the projected sphere, perpendicular to the viewing angle (as you can see it still works properly for extreme field of views where spheres are very oblong on the edges of the screen). The fragment shader then raytraces the sphere onto the billboard (Phong shader) and ensures the z-depth value is also correct. I will test if triangular billboards or screen-aligned billboards are faster. I think this will be marginal.

Похожие видео

Показать еще