Novice lighting question

Novice lighting question

Post by Matthew Harmo » Fri, 07 May 1999 04:00:00



I have a 3D app I want to port to OpenGL.  Currently, I do my own lighting,
but I want to understand how/when OpenGL does its lighting calculations to
make future ports easier.  I currently light verts in "world" space.  Not
the most efficient, but easy to implement.  So, my question is...

Does OpenGL perform lighting in "model" space - i.e. prior to any
transformations?  If this is so, I have to take my world-space positions of
lights and transform them back into "model" space - correct?!?

or

Does OpenGL light verts in "view" space - i.e. after the modelview transform
is applied.  This would require either 1) positioning lights in model space
(assuming OpenGL transforms them into view space) or 2) positioning lights
in view space.

Thanks in advance for any insight.

 
 
 

Novice lighting question

Post by Leath Mull » Sat, 08 May 1999 04:00:00



>Does OpenGL light verts in "view" space - i.e. after the modelview transform
>is applied.  This would require either 1) positioning lights in model space
>(assuming OpenGL transforms them into view space) or 2) positioning lights
>in view space.

OpenGL does light in view space... so you would have to modify your engine
slightly to account for this change...

Leathal.

 
 
 

Novice lighting question

Post by Matthew Harmo » Sat, 08 May 1999 04:00:00


Thanks.  That's what I figured.  I wanted to move my lighting to model space
to avoid transforming normals, but I may stick with OpenGL's scheme to
maintain some degree of interoperability and make use of geometry
acceleration.

Also, I assume OpenGL transforms the lights about the modelView matrix?  In
other words, I specify them in model space.  Is this correct?  If so, when
does OpenGL actually transform the lights - right when they are specified?

Thanks again,

Matt


>OpenGL does light in view space... so you would have to modify your engine
>slightly to account for this change...

>Leathal.

 
 
 

Novice lighting question

Post by Angus Dorbi » Sat, 08 May 1999 04:00:00


OpenGL stores light positions in eye space (what you call view space)
and that's where it does the calculations. However you can specify the
lights in any space you like. Lights get transformed through the
modelview matrix to position them in eye space so the space you compute
for lights depends on when you position them.

So, to specify lights in eye space (view space) you position them with
an identity matrix on the modelview stack. To position them in world
space you apply them after the viewing transformation has been applied
to the modelview stack. To position them relative to an object under
transformation (object space) you position the light after the object
model matrix has been multiplied with the view matrix on the modelview
stack.

Bottom line is that there's enough flexibility there for OpenGL to
accommodate how YOU want to specify light sources, so don't worry too
much about where you position them now, it's relatively straightforward
to switch this in OpenGL when you do the port.

Cheers,Angus.


> I have a 3D app I want to port to OpenGL.  Currently, I do my own lighting,
> but I want to understand how/when OpenGL does its lighting calculations to
> make future ports easier.  I currently light verts in "world" space.  Not
> the most efficient, but easy to implement.  So, my question is...

> Does OpenGL perform lighting in "model" space - i.e. prior to any
> transformations?  If this is so, I have to take my world-space positions of
> lights and transform them back into "model" space - correct?!?

> or

> Does OpenGL light verts in "view" space - i.e. after the modelview transform
> is applied.  This would require either 1) positioning lights in model space
> (assuming OpenGL transforms them into view space) or 2) positioning lights
> in view space.

> Thanks in advance for any insight.

--
"Microsoft's system was like a forest that hadn't had a controlled
 burn in decades, just waiting for one person with a match to turn
 it into a disaster. Melissa was Microsoft's fault. They left their
 system wide open to this sort of abuse, they knew it could happen
 and did nothing." -- Bruce Perens

For advanced 3D graphics Performer + OpenGL based examples and tutors:
http://www.dorbie.com/

 
 
 

Novice lighting question

Post by Angus Dorbi » Sat, 08 May 1999 04:00:00




> >Does OpenGL light verts in "view" space - i.e. after the modelview transform
> >is applied.  This would require either 1) positioning lights in model space
> >(assuming OpenGL transforms them into view space) or 2) positioning lights
> >in view space.

> OpenGL does light in view space... so you would have to modify your engine
> slightly to account for this change...

> Leathal.

The first part is accurate, the second part is not really the right
conclusion though, see my post.

Cheers,Angus.

--
"Microsoft's system was like a forest that hadn't had a controlled
 burn in decades, just waiting for one person with a match to turn
 it into a disaster. Melissa was Microsoft's fault. They left their
 system wide open to this sort of abuse, they knew it could happen
 and did nothing." -- Bruce Perens

For advanced 3D graphics Performer + OpenGL based examples and tutors:
http://www.dorbie.com/

 
 
 

Novice lighting question

Post by Leath Mull » Tue, 11 May 1999 04:00:00



>> OpenGL does light in view space... so you would have to modify your engine
>> slightly to account for this change...
>The first part is accurate, the second part is not really the right
>conclusion though, see my post.

Oh ok, I sorta thought the guy was doing his lighting pretty much the same
way I do the lighting now, which means he needs to place the lights at a
different position within his OpenGL code... which is where 'slightly' came
into it... :)

Leathal.

 
 
 

1. Novice questions

I see the main of your project.
If you want to use free software for your game, maybe you should try Rhino
it can produce some 3D meshes in 3ds format. Then using conv3ds.exe to
export your mesh into a .x format that Direct3D could understand.
conv3ds.exe
ships with the DirectX SDK since release 3 (I think). But personally I
would
not have the goal of making a game right now, if I where you I would
concentrate
my efforts in making a box on the screen with Direct3D or OpenGL...

I know VB but I use it at work to program database aplications and DLL for
interfacing with ASP. I know Microsoft will make it easier including VB
support
but I will still program in C/C++ to (try) program games. I prefer C or C++
because it is faster with graphics but I will never try to raytrace the
images
of the games (too heavy).

In a 3D game you have to program everything:
the camera, the scene, the objects, a program structure with event handlers
etc.. and the use of a 3D engine if you do not have too much patience.
POV is not a good program to use to make a game, it is a rendering software
that makes great still images. If you have more question I will try to
answer you
the best that I can.

Philippe

2. Distance 3D Polyhedra

3. POVRay and alfa-channels: novice question

4. Memory problem in MAX

5. Continuing questions of a rendering novice.

6. Activation failed: Error -2

7. Novice Visualization Questions - POV-Ray/3D Studio

8. Merry Christmas

9. Novice Illustrator question

10. Novice Question

11. Novice animation questions

12. Graphics novice question