how to create smooth lights?

Hi, while fooling around with my first three-dimensional project in OF I encountered some troubles when it comes to lighting. I’ve got a couple of spheres floating around and set up a regular ofLight which I turn on with its enable method. But the shadows it casts on the objects look rather edgy and just black than like a gradient of greys.

I’ve read that this might be due to the lack of vertex normalization, if so can anybody tell me how to apply that to the standard ofSpheres? If not, what else might be causing this? I couldn’t find any simple example file using lights or a good 3D tutorial anywhere :confused:

This is a very general answer, but one would use GLSL shaders to accomplish this goal. A fragment shader would operate on every pixel of your openGL window, and decide what color/brightness each pixel is depending on the position and normal of the rendered polygon fragment at that pixel.

There are many tutorials on how to implement per pixel lighting effects.

Openframeworks implements GLSL with the ofShader object, and everything drawn between the .begin() and .end() methods of that object are subject to the GLSL shaders code. Search around here for examples.

A shader would probably give you the prettiest results.

some more simple fixes that use openGL lighting built into OF would be to use ofSetSmoothLighting(true);
You could also increase the sphere resolution with ofSetSphereResolution(myResolution);

To get normals and tex coords(normalized) the sphere, you can check out some code I adapted for OF from Paul Bourke here:

refer to this function
createSphere(ofVec3f(0, 0, 0), getRadius(), _sphereResolution, _renderMode, 0., TWO_PI, -HALF_PI, HALF_PI );