Manually set normal vectors are ignored for backface culling

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Manually set normal vectors are ignored for backface culling

Schorsch
Hi there,

if I set the vertices' normal vectors manually during creation of a GeometryArray, should those normal vectors not be used for the backface culling, too?
However, when I enable backface culling, java3d seems to determine the normals automatically (right-hand-rule, anti-clockwise vertices order, etc.) and apply those normals regardless of the previously manually set normal vectors. Is that a bug or have I missed anything?

See the small sample file attached, which visualizes the problem.
CullingTest.java

My difficulty is that I have a lot of legacy code which sets the normal vectors manually and now I want to render these objects with correct backface culling.

Thanks a lot in advance,
Schorsch
Reply | Threaded
Open this post in threaded view
|

Re: Manually set normal vectors are ignored for backface culling

gouessej
Administrator
Hi

Maybe I'm wrong but I don't expect Java3D to use the normals with the backface culling. You can look at this example:
http://www.java2s.com/Code/Java/3D/TwistStripAppdemonstratesbackfaceculling.htm
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Manually set normal vectors are ignored for backface culling

Schorsch
Hi Julien,

thanks for your answer. You could be right about the culling. However, in the example you linked no normals are set manually. There I would indeed expect Java3D to do the backface culling based on some automated behaviour. My original question was about the case when there are manually defined normals.

I might be mistaken, but what sense does it make to provide a setter-method for manual normal vectors if these are not used by the API?
It could be, though, that the normals are only used for picking, but then rendering and picking would treat the geometries somehow differently. Would that make sense?

I'm a bit doubtful here. Do you see my point?

Are there any users out there who successfully use manual normal calculation, e.g. for distinguishing between inner walls and outer walls for geometrical objects?
Reply | Threaded
Open this post in threaded view
|

Re: Manually set normal vectors are ignored for backface culling

gouessej
Administrator
The normals are used for the lightning, not for the backface culling. It depends rather on the winding, the order of the vertices. Actually, understanding Java based scenegraphs is easier with a strong knowledge of computer graphics and OpenGL when you really want to understand what happens behind the hood. I understand that it can be a bit frustrating.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Manually set normal vectors are ignored for backface culling

Schorsch
Ah, okay. I forgot about lighting. Okay, then I can see the purpose of setting normals manually. Thanks for the clarification.
By the way, I don't find Java3D frustrating at all. I actually do like the idea behind the scenegraph. It's just that I have all those noob questions. ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Manually set normal vectors are ignored for backface culling

gouessej
Administrator
The normals are very useful for the bump mapping.
Julien Gouesse | Personal blog | Website