Ambient Light not working

Hi all,

I have a viewer with some geometry that is illuminated when using directional lights, but when I use an ambient light the geometry is black.

The code is as simple as:

Handle_V3d_AmbientLight ambient = new V3d_AmbientLight (my_viewer, Quantity_NOC_WHITE);
my_viewer->SetLightOn ();

But no light is working. If I create V3d_DirectionalLight instead of ambient light it works like a charm. Any ideas?

Thank you,
Marc.

JuryS's picture

Hi, Marc.
Make some change with OpenGl_LightBox.cxx in function

static void bind_light(TEL_LIGHT *lptr, int *gl_lid)

Here you are find some lines:
if (lptr->type != TLightAmbient)
{
glEnable(*gl_lid);
(*gl_lid)++;
}

Also, you are really don't need create Ambient light, if you are see the function, because you can create head light, witch can be shown on you change angle of view with glMatrix.

And some thinks around creating light. Here is Standard Boolean value for creating light index in Graphic Driver. We know that Standard Boolean is not bool, it's unsigned int, be careful with creating new lighting...

m.costa's picture

Hi Yuriy,

I see... It can't work :).

I created a headlight and I thing it's pretty much what I need.

Thank you!

Forum supervisor's picture

Dear Marc,

Ambient light in OCCT doesn't introduce any lighting source.
It only controls the ambient color. OpenGL code just do it:

glLightModelfv(GL_LIGHT_MODEL_AMBIENT, data_amb);

If you will create both directional light and ambient light you will see the difference between Quantity_NOC_RED and Quantity_NOC_WHITE for ambient light.

Handle(V3d_Viewer) theViewer;
theViewer->SetLightOn (new V3d_DirectionalLight (theViewer, V3d_Zneg, Quantity_NOC_WHITE, Standard_True));
theViewer->SetLightOn (new V3d_AmbientLight (theViewer, Quantity_NOC_RED));

Regards.