0

I've been hacking a very old fixed function pipeline OpenGL 1.x game. I've been intercepting opengl calls and injecting all sorts of modern opengl elements, such that I've achieved new lighting and added post processing shaders (programmable pipeline).

I'd like to generate a shadow map (for real time shadows) for this game which does not currently support this. As I understand, I need to perform multipass rendering which the game currently does not support, and I need one of those passes to use the light source as the camera position, to produce a shadow map.

I was thinking I could double up the draw calls (drawelements and drawarrays) and for one of each call, use gluLookAt to transform the scene to the perspective of the light position, and render this to a framebuffer, and then revert the camera and proceed rendering

I'm not sure i understand the opengl state well enough to do this however, as every use of gluLookAt prior to the individual rendering calls gives me very funky results, even if I supply the current camera position I pull from the modelview matrix. these funky results are just like, some random vertices are in the correct place and many are not, and they are flashing and moving all over the place

I assume I should not be trying to transform the camera at the moment of the individual render call for a vertex array.. but im not sure what to do next because i need two passes.

Question: Is there a specific time during the rendering calls that it makes sense to perform the gluLookAt, or a way to use it to transform the entire scene from within the context of a single rendering call?

The only other thought I have is actually recording all the rendering and matrix transformations in order and replaying them for a second pass.

Zain Syed
  • 443
  • 4
  • 12
  • 1
    Well, while what you try to do is certainly not impossible, you will have to understand (and deal with) potentially every GL state the game is touching. "The only other thought I have is actually recording all the rendering and matrix transformations in order and replaying them for a second pass." if you do that, you need to record all the GL state changes, not just transformations. – derhass Aug 22 '20 at 16:14
  • 2
    Note that I did something similar, not for shadow-mapping, but for stereoscopic and multiview (auto-stereoscopic) rendering . My stuff was based on the [chromium](http://chromium.sourceforge.net/) (not the browser thingy) open source GL interception and distributed rendering framework, which can at least deal quite well with GL 1.x level stuff, and brings components like _packer_ and _unpacker_ (which record GL commands into memory regions and can basically replay them) and also _state tracker_ / _state differencer_. but even using that will be a lot of work. – derhass Aug 22 '20 at 16:19
  • very interesting @derhass thank you for your insight. your project sounds quite analogous to mine mechanically and the chromium tools sound very useful – Zain Syed Aug 22 '20 at 16:23

0 Answers0