Cube not illuminated by a light source #1252
-
Hello I have a small problem with my light source. I have 2 cubes, one built with the osg::Box class (the green cube) and the other built by hand (the red cube). As you can see only the underside of the green cube is illuminated by my light source but not the handmade red cube. This may be due to the normal of my red cube? I am open to any explanation the code of the red cube: ` osg::ref_ptrosg::Vec3Array vertices = new osg::Vec3Array(8);
and the code for my light source: ` osg::ref_ptrosg::Light light = new osg::Light;
Thanks in advance :) Daoudou |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can't light a cube with a single normal, it'll just light from single direction. You'll need to use per vertex normals, and duplication the vertices for each face to enable you to set up the normals. This is a bit awkward but it's down to the way that modern (last 20 years :-) now manage vertex shaders, even GL fixed function pipeline maps to this. |
Beta Was this translation helpful? Give feedback.
You can't light a cube with a single normal, it'll just light from single direction.
You'll need to use per vertex normals, and duplication the vertices for each face to enable you to set up the normals. This is a bit awkward but it's down to the way that modern (last 20 years :-) now manage vertex shaders, even GL fixed function pipeline maps to this.