Login  Register

Re: Lighting the inside of a cube

Posted by jmaasing on Nov 05, 2014; 9:24am
URL: https://forum.jogamp.org/Lighting-the-inside-of-a-cube-tp4033471p4033490.html

KevinWorkman wrote
I would expect the sides of the cube to get brighter as the light moves closer, and dim as the light moves further away. And this seems to work with one of the sides of the cube:
I haven't done fixed pipeline OpenGL in many years so maybe I don't recall correctly but you are creating a directional light (w=0) - those do not have attenuation so your assumption is wrong.
Also, you are putting a position into x,y,z but they should contain a normalized direction vector. I guess lighting 'works' by accident as long as position is between 0-1, after that all bets are off.

Here is link that probably will answer most questions about lighting in OpenGL 1

http://www.glprogramming.com/red/chapter05.html