Shaded lighting rather than full on/off


#1

Hi
this should be straightforward but I can’t seem to be able to get a lighting/material combination that has shading (i.e. with angle between mesh normals and light source)
I’m using the programmable renderer (4.3) and have setup a really basic scene with a cube in the center, a camera, a light which rotates around the cube and a basic diffuse material.

As the light rotates around the cube the faces of the cube are either fully lit (100% of the diffuse color) or not lit at all (0% diffuse color) there is no fading in between as you would expect. They just switch on then off.

The following’s in my setup, along with setting up the basic positions and parameters of camera, material diffuse color etc:

ofEnableLighting();
ofEnableDepthTest();
ofSetSmoothLighting(true);

The in my update call I’m changing the position of the light:

light.setPosition(ofVec3f(cos(ofGetElapsedTimef()*lightSpeed)*lightRadius, 0, sin(ofGetElapsedTimef()*lightSpeed)*lightRadius))

My draw() call:

camera.begin();
light.enable();
material.begin();
cube.draw();
material.end();
light.disable();
camera.end();

This produces either fully on or off shading on my cube.

Is this to do with per-fragment lighting? I’m sure I’ve had this working on other OF projects I’ve worked on but even after stripping it back to the basic elements I can’t seem to find the right setting for shading with lights/materials.

Anyone know how to fix this please?