5th March 2006, 01:18 PM | #1 |
Junior Member
Junior member
Join Date: Mar 2006
Posts: 2
|
OpenGL two sided lighting model
I am hacking the AC3D loader for OpenSceneGraph again. One thing I am thinking of doing is enabling two sided lighting for two sided surfaces.
I recommend AC3D as my modeller of choice to all our users. But I get grief from them about black surfaces. I am getting tired of telling them to make all surfaces one sided and then flip them the right way round! (By the way - a preference setting for one sided surfaces as default would be nice!) So, is two sided lighting for two sided surfaces the correct behaviour for AC3D loaders in the OpenGL world? It looks like the 3d display in AC3D itself does this. However all of the examples for parsing the AC3D file format only use the two sided flag to control back face culling. Any guidance gratefully received! Roger |
5th March 2006, 03:24 PM | #2 |
Administrator
Professional user
Join Date: Jun 2003
Posts: 4,565
|
> But I get grief from them about black surfaces. I am getting tired of telling them to make all surfaces one sided and then flip them the right way round!
Get them to show normals and check that they are all facing how they want them. Press 'n' to show-normals. Reverse normals with Surface->flip-normal. Black surfaces may be due to polygons not being handled by the other code (the sample AC3D loader won't handle them). AC3D internally supports concave polygons (e.g. a single polygon 'C' shape) which is a bit more involved to code. In AC3D, objects that don't need to have two-sided surfaces are set to single sided e.g. spheres. single surfaces and 2d shapes have two-sided by default. I don't feel a global setting makes sense here but as always, we are open to ideas. The attribute for 1S/2s is set in .ac files in the surface flag. |
5th March 2006, 09:38 PM | #3 |
Junior Member
Junior member
Join Date: Mar 2006
Posts: 2
|
Andy,
Thanks for the quick response. But I think you misunderstood what I was asking. I probably was not precise enough in my question. Your sample code for the parsing the ac3d file format and rendering in OpenGL always uses one sided lighting. Therefore when models are directionally lit one side of a two sided surface looks dark, even though in the 3d display in ac3d it is rendered lit. My question is - Should 2 sided surfaces imported from ac3d files and rendered in OpenGL have the OpenGL 2 sided lighting attribute set on them. I know this may appear obvious, but I just want to check before I turn it on because it will cause a big performance hit. |
6th March 2006, 04:06 AM | #4 |
Administrator
Professional user
Join Date: Jun 2003
Posts: 4,565
|
My apologies, Yes, you should use two-sided lighting and cull backfaces for single sided surfaces.
Andy |
|
|