This patch includes a re-written RB_CalcEnvironmentTexCoords() to just use pure OpenGL calls to initiate environment mapping, instead of the current cpu-based implementation. As a bonus, a new tcGen type, 'reflection' causes the engine to initiate OpenGL reflection mapping, which is good for water surfaces and anything else that needs a flat reflection.
There is something wrong. When applying this patch, reflections depend on the view direction instead of solely on location. Check it out, padgallery_dl is a good map to test this, go to the bottom of the map and look at the exit, don't move, but change the direction you're looking into. You'll see, the reflections will move when you look another way.
Also, this depends on OpenGL functionality I am not sure whether existant in early OpenGL versions. Also, OpenGL 3.0 deprecates the glTexGen function:
http://www.opengl.org/wiki/Mathematics_of_glTexGen
I am sorry, I will have to deny this patch.
Created attachment 2197[details]
Updated patch to provide optional switching between old method and new.
Deprecated or not, it is still a feature in OpenGL 1.x, which will be supported by hardware drivers indefinitely. OpenGL 3.0 should be irrelevant in this case because Quake 3 itself would be nowhere near 3.0-compliant if its graphics functions weren't re-implemented in software instead of pure OpenGL calls anyway.
Currently, most of the renderer consists of graphics capabilities that OpenGL 1.x featured but Carmack implemented in software instead. He did not trust the driver developers to have fully compliant drivers. However, today graphics drivers for all major graphics accelerators support OpenGL 1.x enough to perform the functions used in this patch.
The view-based reflection is apparently the 'correct' way it is supposed to be done. Consider this: if you look at a reflective object, it changes its reflection just by your view angle changing. You don't have to move around it to get it to change reflection.
The main reason I took it upon myself to write this patch is because of an apparent problem in the Quake 3 renderer causing it to lose performance at a faster rate than expected when many environment-mapped surfaces are in a single scene.
Admittedly the Quake 3 software-based environment mapping technique yields nicer-looking results, but of course at the cost of performance. I have created a new version of the patch that allows the user to choose the software-driven method or the hardware-accelerated method.
>> The view-based reflection is apparently the 'correct' way it is supposed to be
>> done. Consider this: if you look at a reflective object, it changes its
>> reflection just by your view angle changing. You don't have to move around it
>> to get it to change reflection.
Have you actually stood in front of a mirror? Because I think real life would disagree with that assessment. I have prepared a video for demonstration. The first part is the old quake3 behaviour, the second one is what it looks like after your patch.
http://thilo.tjps.eu/download/videos/q3_reflectionbug.avi
This is not the way it's supposed to be.
Created attachment 2188 [details] OpenGL environment mapping patch
Created attachment 2189 [details] This updated patch corrects the missing 'reflection' texgen parm.
Created attachment 2197 [details] Updated patch to provide optional switching between old method and new. Deprecated or not, it is still a feature in OpenGL 1.x, which will be supported by hardware drivers indefinitely. OpenGL 3.0 should be irrelevant in this case because Quake 3 itself would be nowhere near 3.0-compliant if its graphics functions weren't re-implemented in software instead of pure OpenGL calls anyway. Currently, most of the renderer consists of graphics capabilities that OpenGL 1.x featured but Carmack implemented in software instead. He did not trust the driver developers to have fully compliant drivers. However, today graphics drivers for all major graphics accelerators support OpenGL 1.x enough to perform the functions used in this patch. The view-based reflection is apparently the 'correct' way it is supposed to be done. Consider this: if you look at a reflective object, it changes its reflection just by your view angle changing. You don't have to move around it to get it to change reflection. The main reason I took it upon myself to write this patch is because of an apparent problem in the Quake 3 renderer causing it to lose performance at a faster rate than expected when many environment-mapped surfaces are in a single scene. Admittedly the Quake 3 software-based environment mapping technique yields nicer-looking results, but of course at the cost of performance. I have created a new version of the patch that allows the user to choose the software-driven method or the hardware-accelerated method.