
Hi, I'm looking for a basic lighting configuration for a solid modeller I'm building. I don't need anything elaborate; I just want to set a color and get reasonable shading. I followed the guidelines from http://www.opengl.org/wiki/How_lighting_works, but my scenes are left only black and white (http://funhdl.org/ball.jpg). Are there any specifics to the Haskell API to properly configure lighting? Here are the lighting commands I call during program init: position (Light 0) $= Vertex4 1 1 0 1 ambient (Light 0) $= Color4 0 0 0 1 diffuse (Light 0) $= Color4 1 1 1 1 specular (Light 0) $= Color4 1 1 1 1 lightModelAmbient $= Color4 0.2 0.2 0.2 1 lighting $= Enabled light (Light 0) $= Enabled colorMaterial $= Enabled colorMaterial $= Just (FrontAndBack, AmbientAndDiffuse) materialSpecular FrontAndBack $= Color4 1 1 1 1 materialEmission FrontAndBack $= Color4 0 0 0 1 During a frame redraw, the only lighting functions called are disabling and enabling lighting to draw the coordinate system. Any ideas or recommendations? BTW, I also raised this question to the opengl forum: http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=263558 -Tom

colorMaterial $= Enabled colorMaterial $= Just (FrontAndBack, AmbientAndDiffuse)
Something's wrong. I don't think that should typecheck. IIUC setting colorMaterial to Just or Nothing enables or disables it respectively. A number of different things could be going wrong. To simplify things: * Set the light source position to Vector4 1 1 0 0 <-- note the last zero This makes the light source infinite, which is a simpler lighting model. * Turn the specular lighting to zero, also for a simpler lighting model. (When you use specular and point lighting at the same time, you usually also want to enable lightModelLocalViewer, but hold off until you have the basics working.) * Turn colorMaterial off, and just use a plain blue sphere (e.g. glutSolidSphere). * Follow the advice on the other thread about enabling GL_NORMALIZE. As you turn off features, you should see something conspicuous that illuminates (sorry) the problem. Once you have a scene that looks reasonable, you can start re-enabling features one by one. Friendly, --Lane

On Tue, Sep 8, 2009 at 1:23 PM, Christopher Lane Hinson
colorMaterial $= Enabled colorMaterial $= Just (FrontAndBack, AmbientAndDiffuse)
Something's wrong. I don't think that should typecheck. IIUC setting colorMaterial to Just or Nothing enables or disables it respectively.
Yes, this is a type error. I forgot to remove it. Normalizing the normals and shutting off specular improved the scene the most. Thanks!
A number of different things could be going wrong. To simplify things:
* Set the light source position to Vector4 1 1 0 0 <-- note the last zero This makes the light source infinite, which is a simpler lighting model.
* Turn the specular lighting to zero, also for a simpler lighting model.
(When you use specular and point lighting at the same time, you usually also want to enable lightModelLocalViewer, but hold off until you have the basics working.)
* Turn colorMaterial off, and just use a plain blue sphere (e.g. glutSolidSphere).
* Follow the advice on the other thread about enabling GL_NORMALIZE.
As you turn off features, you should see something conspicuous that illuminates (sorry) the problem.
Once you have a scene that looks reasonable, you can start re-enabling features one by one.
Friendly, --Lane
participants (2)
-
Christopher Lane Hinson
-
Tom Hawkins