Forums » Suggestions
Specular lighting on OpenGL?
I recently had a chance to play VO with Direct3d, and was surprised to note specular lighting. OpenGL's default specular lighting implementation doesn't work well with textures, however, it's very simple to implement. Simply re-render the entire scene with glDepthFunc(GL_EQUAL) with textures and all lighting values but specular off / black, and using glBlendFunc(GL_ONE, GL_ONE) (if memory serves me).
-:sigma.SB
-:sigma.SB
What do you mean by the default specular lighting not working well with textures? It just applies specular lighting added to the modulated texture color (in the default lighting model; identical to the fixed function pipeline for DirectX). Your suggestion would use a second pass to accomplish the same thing. The only advantage your model would have would be to apply a specular map on single-texture hardware (dual-texture hardware could do it in a single pass by blending the 2nd texture). Even then, if you're on hardware with only one TMU, chances are the performance hit of a second pass would pretty much kill your framerate.
--mcn
--mcn
If it works without any significant performance hit on my Rage Mobility Mach64, it will work well on the minimum system for the game.
OpenGL's default specular lighting is simply added to the LIGHTING value of the pixel, pre-texturing, whereas a second rendering pass with additive blending is not. It would render the hilite as an additional value as seen with D3D rather than a modulated value as seen with OpenGL. The general consensus around the VO community (as far as I have been able to determine) is that VO looks better under Direct3d, and since the only difference I saw was in the lighting model...
Plus, additive blending is very VERY fast, especially on the older hardware which would otherwise get a performance hit.
As for the multiple TMU business... that is one aspect of OpenGL I have yet to become very familiar with. Not that AFAIK it would even apply in this case, since the second rendering pass we would be applying is NOT a texture.
-:sigma.SB
OpenGL's default specular lighting is simply added to the LIGHTING value of the pixel, pre-texturing, whereas a second rendering pass with additive blending is not. It would render the hilite as an additional value as seen with D3D rather than a modulated value as seen with OpenGL. The general consensus around the VO community (as far as I have been able to determine) is that VO looks better under Direct3d, and since the only difference I saw was in the lighting model...
Plus, additive blending is very VERY fast, especially on the older hardware which would otherwise get a performance hit.
As for the multiple TMU business... that is one aspect of OpenGL I have yet to become very familiar with. Not that AFAIK it would even apply in this case, since the second rendering pass we would be applying is NOT a texture.
-:sigma.SB
Well, a 2-TMU card (or 4 or 8 or whatever they're up to now) doesn't have to have a texture in either of the TMUs...or any for that matter. It's just a way of doing multiple passes in a single pass, thus saving on the writes to video mem (1 instead of multiple). Look up multitexturing and you'll see it. The upper stage could easily be configured for additive specular w/o a texture.
As far as the lighting model, that sounded really weird that OGL would do that, but I looked it up and apparently in the 1.0 spec it is indeed modulating all the lighting by the textel. Strange. However, apparently there's an extension in 1.1 (that became standard in 1.2) to enable the specular-added-after-texture-modulation like D3D does, which is probably why I wasn't ever aware of the original spec, since it makes very little sense to do it that way. Without the extension, however, your method (or using a multitexturing version) would be quite adequate.
Also, bear in mind that some of the comments about OGL vs D3D in terms of visual quality might be partially related to the shader support, since it's kinda hard under OGL 1.3 compared to DX8/9, although once the major vendors start rolling out OGL 2.0-compliant drivers, that shouldn't be an issue anymore.
-mcn
As far as the lighting model, that sounded really weird that OGL would do that, but I looked it up and apparently in the 1.0 spec it is indeed modulating all the lighting by the textel. Strange. However, apparently there's an extension in 1.1 (that became standard in 1.2) to enable the specular-added-after-texture-modulation like D3D does, which is probably why I wasn't ever aware of the original spec, since it makes very little sense to do it that way. Without the extension, however, your method (or using a multitexturing version) would be quite adequate.
Also, bear in mind that some of the comments about OGL vs D3D in terms of visual quality might be partially related to the shader support, since it's kinda hard under OGL 1.3 compared to DX8/9, although once the major vendors start rolling out OGL 2.0-compliant drivers, that shouldn't be an issue anymore.
-mcn
SPECtacULAR!
*rolls eyes*
--mcn
--mcn
OGL 1.2 has real specular lighting? COOL. Now, if only I could install OGL 1.2 or better on one of my dev machines... >_<
-:sigma.SB
-:sigma.SB
All the drivers from nVidia and ATI have been OGL 1.2-compliant for quite some time. As for other chipsets...well, you get what you pay for :)
--mcn
--mcn