CHAI3DCHAI3D

normal Flat Shading, Edge Display and Contour

More
05 Oct 2016 13:41 #1

Hello everyone!

First of all thank you Chai3D team for this awesome lib!

Although I'm stuckd a bit now. I'd like to use flat shading for some of my objects. As far as I know I can achieve this via glShadeModel(FLAT). I see glShadeModel(GL_SMOOTH) in Camera and FrameBuffer classes hardcoded, and no option to change them on a per-object nor on a global level.

Is it an option to subclass Mesh (for example), and in it's overriden render function call glShadeModel(FLAT) before calling it's superclass' render?

Another question. Is it possible to apply culling for edge rendering? Now my model renders correctly, but on top of it the whole "unculled edge object" renders even if culling is enabled. And it doesn't take into account the transparency of the edge color.

And my last question is about how to render just the contour of my object? Is there built in solution for that, or I should use custom shaders?

Thank you, any answer is appreciated and very welcome!

Timo

Please Log in or Create an account to join the conversation.

More
21 Oct 2016 20:13 #2

Hello Timo,

Thank you for all your comments!


I'd like to use flat shading for some of my objects. As far as I know I can achieve this via glShadeModel(FLAT). I see glShadeModel(GL_SMOOTH) in Camera and FrameBuffer classes hardcoded, and no option to change them on a per-object nor on a global level.


Good point! One way to make your models look flat would be to recompute the normals by calling the following methos. This being said, we will further investigate your point.

myMesh->computeAllNormals();


Is it an option to subclass Mesh (for example), and in it's overriden render function call glShadeModel(FLAT) before calling it's superclass' render?


My suggestion would be to simply extend cMesh to include this as an option.


Is it possible to apply culling for edge rendering? Now my model renders correctly, but on top of it the whole "unculled edge object" renders even if culling is enabled. And it doesn't take into account the transparency of the edge color.

The edge rendering does not support culling at this stage. It was mainly be implemented to highlight edges when rendering CAD like object. A small bug was found in the method that computes that and will be corrected in version 3.2 that is due shortly.


And my last question is about how to render just the contour of my object? Is there built in solution for that, or I should use custom shaders?

That would require using shaders indeed! We will add your request to the list of desired features as it is nice for selecting/highlighting objects in a scene.

Please Log in or Create an account to join the conversation.