PDA

View Full Version : Render quality and number of vertices



Slookeur
03-27-2017, 03:58 AM
Dear all,
thanks in advance for reading this.
I am coding a modern OpenGL application to visualize 3d atomic models (molecules,
periodic systems ...) for chemistry and condense matter physics.
I started to work on this few years ago, the first version of my program was in old OpenGL
now I am updating it to modern OpenGL.
I come with a question regarding the quality of the rendering of the OpenGL window,
In the following example I draw 3D cylinders and 3D spheres using instanced drawing, in this model
to render the bonds I only draw one cylinder, then I translate/scale/rotate it properly in the vertex shader
to render all bonds, same goes for the sphere to render the atoms.
As you can see it works just fine, and the efficiency of the method is amazing and I can render
models with hundreds of thousand of atoms smoothly. However I noticed something weird,
that somehow the quality of the rendering seems to be dependent on the number of vertices (objects, atoms and bonds) in the scene,
obviously the number of triangles is the most important parameter but not the only one ... please see the attached snapshots:

To render the spheres in the scene I am using 50x50 vertices, and 2x50 for the cylinders (GL_TRIANGLE_STRIP in both cases)

1) In this test model I load: 96 atoms, 512 half bonds, : ~ 291200 vertices:

2) I zoom in to focus on one selected atom and it surrounding, at this scale the result is impeccable:

3) I reset the view and use the builder in my program to increase the number of boxes
(I am simply doing replicas in the 3 direction of space) here I choose to do 20x20x20 replicas,
see the result bellow, the original box is highlighted.
In that scene there are 768000 atoms, 4096000 half-bonds, and thus: 291200x20x20x20 = 2329600000 vertices
quite a lot, yet it works, but something weird appears ...

4) I zoom in again on that particular area of the model I picked before and there is a decrease in quality in particular
in the areas where 3D objects (spheres/cylinders) superpose ...

Can somebody explain to me what I see ?

Note 1: In the same window I can decrease the number of replicas back to the original box, zoom again
and see that the result is back to impeccable.

Note 2: the older version of my program still works fine (old OpenGL, using display list with glutsphere and glutcylinders),
I can do the same things, the rendering will take much much longer, but at the end of the process when I zoom in on the 20x20x20
boxes model, the results remains perfect, like for the single box model, and obviously I use same graphic card, driver and else.

Thanks in advance for you lights on the matter.


Sorry but I am not able to insert images on this website, I always receive the 'not appropriate image format' message when I try to,
and this even if I follow precisely the recommendations in the advanced -> Manage attachment dialog.
Therefore I decided to create a similar post on Stackoverflow (there I can insert images easily) at:

http://stackoverflow.com/questions/43045125/opengl-rendering-quality-vs-number-of-vertices