meeper
07-12-2010, 11:27 AM
Hi everyone,
I've been developing scientific visualization software under OpenGL for quite a number of years. Recently, I thought it might be a good idea to try to upgrade my old school fixed-pipeline and basic scenegraph skills to something a bit newer. I'll tackle OpenGL 3.0+ shortly, but at the moment I'm trying to experiment with some different methodologies for storing matrix/vertex data.
I've been using GL rotate/translate to build my modelview matrix, then sending my vertex data down the pipe to be rendered. If I need to perform a lookup or intersection test, then I extract the modelview matrix from OpenGL, apply that matrix to each of my vertices (which often count into the tens of millions), and then perform the operation.
While this works flawlessly, I'm sure there's a better way to do it. So I thought a good first step would be to build the modelview myself, manipulate each vertex in my software and then send the modified vertices off to opengl. I figured this would have the twin benefits of being offloadable to another thread while essentially giving me the ability to perform geometry operations for free (of course the operations themselves still have cost, but the setup is free).
Fundamentally this works. All of my basic functionality works fine -- objects (lines, triangles, etc) are drawn correctly, textured, etc. Unfortunately, my fixed-pipeline lighting no longer works as intended. Previously I would:
1) Set my lighting position
2) Perform my modelview transforms using the API's translate/rotate/look-at routines
3) Render my scene
I've tried a few hacky fixes, but really I'm just bumbling around hoping to land on the correct solution. Right now, I've got the equivalent of:
1) Define modelview identity
2) Build modelview by multiplying camera rotations/translations
3) Update vertices (normals and light positions, too) by transforming their original positions by the modelview matrix
4) Specifying the light position via glLightv (using the modified light position as transformed by my modelview matrix)
5) Enabling light/etc
6) Render my scene
Lighting is noticable, but changes radically according to camera angle. I don't remember seeing lighting like this since I first started bumbling around with lighting.
Anyone have any thoughts? Either on the lighting issue or my attempts to improving a basic scene? Am I barking up the wrong tree by moving the computations out of GL and into my own software?
Many thanks
I've been developing scientific visualization software under OpenGL for quite a number of years. Recently, I thought it might be a good idea to try to upgrade my old school fixed-pipeline and basic scenegraph skills to something a bit newer. I'll tackle OpenGL 3.0+ shortly, but at the moment I'm trying to experiment with some different methodologies for storing matrix/vertex data.
I've been using GL rotate/translate to build my modelview matrix, then sending my vertex data down the pipe to be rendered. If I need to perform a lookup or intersection test, then I extract the modelview matrix from OpenGL, apply that matrix to each of my vertices (which often count into the tens of millions), and then perform the operation.
While this works flawlessly, I'm sure there's a better way to do it. So I thought a good first step would be to build the modelview myself, manipulate each vertex in my software and then send the modified vertices off to opengl. I figured this would have the twin benefits of being offloadable to another thread while essentially giving me the ability to perform geometry operations for free (of course the operations themselves still have cost, but the setup is free).
Fundamentally this works. All of my basic functionality works fine -- objects (lines, triangles, etc) are drawn correctly, textured, etc. Unfortunately, my fixed-pipeline lighting no longer works as intended. Previously I would:
1) Set my lighting position
2) Perform my modelview transforms using the API's translate/rotate/look-at routines
3) Render my scene
I've tried a few hacky fixes, but really I'm just bumbling around hoping to land on the correct solution. Right now, I've got the equivalent of:
1) Define modelview identity
2) Build modelview by multiplying camera rotations/translations
3) Update vertices (normals and light positions, too) by transforming their original positions by the modelview matrix
4) Specifying the light position via glLightv (using the modified light position as transformed by my modelview matrix)
5) Enabling light/etc
6) Render my scene
Lighting is noticable, but changes radically according to camera angle. I don't remember seeing lighting like this since I first started bumbling around with lighting.
Anyone have any thoughts? Either on the lighting issue or my attempts to improving a basic scene? Am I barking up the wrong tree by moving the computations out of GL and into my own software?
Many thanks