PDA

View Full Version : OPenGL Flat / Smooth rendering issue



Fblalyon
12-07-2015, 03:26 AM
Hi developpers community.

I use Meslab to create OBJ file from stl cad software.
The Vn vector is not unity vector. Is this normal?

Then When I display it, it is similar to the "smooth" tool rendering of MeshLab.
But in my software i would like to display it as "Flat" tool display of MeshLab.

How could I change the option in my C file to display it as same (which OpenGL function should I desable or enable)?

Thanks to help resolving the issue.

Fred

__bob__
12-07-2015, 03:41 AM
You can recompute a normal per triangle in a geometrie shader... and pass it to the fragment shader...

Fblalyon
12-07-2015, 05:42 AM
You can recompute a normal per triangle in a geometrie shader... and pass it to the fragment shader...

Could be a potential solution but not so nice.

I saw that the same point can be used for different face orientation.
But it should exist a solution that Meshlab use.

..

Fred

__bob__
12-07-2015, 06:15 AM
Or just compute normal per triangle while obj is loading, an put it in your vbos...

GClements
12-07-2015, 09:37 AM
Another option is to compute the face normal in the fragment shader.

If the variable "eye" contains the eye-space position, then


vec3 normal = normalize(cross(dFdx(eye), dFdy(eye)));

gives you the eye-space normal.