Odd behavior from directional lights with webgl

Hi Folks,

I’m getting what I think is some really weird behavior from directional lights when using webgl. Here’s the example sketch. What I can’t figure out is:

  • Quads appear to reflect light opposite to boxes and other primitive shapes
  • Shapes made with beginShape() do not reflect light at all
  • No shapes show color when set with ambientMaterial()

What am I missing here? Would appreciate anyone who can set me straight on directional lighting in webgl.

1 Like

Hi @bluemoon,

Just a few issues to note

  • ambient material only affected by ambient light
  • For vertex you need to set the normal vector
  • quad needs to have the correct vertex orientation

I would recommend to study the reference for each functions you are using … :slight_smile:

Cheers
— mnse

Thank you so much for the response! I thought it might have something to do with normals.

I’ll submit a github issue to update the reference fro ambientMaterial, which currently states:

The ambientMaterial() color is the color the object will reflect under any lighting.

edit: I double checked the reference for beginShape() as well, and there is no mention of normals, a pity.

Let’s see the outcome. Read the same but the current behavior seems to be different.
Maybe someone else has ideas regarding …

Cheers
— mnse

1 Like