Doom3 Ambient Light Fix
[ posted 24.02.2008 by rebb ]


This is basically the default Doom3 interaction.vfp, with some changes and additions that improve the way ambient lighting is handled in the Game. I was wondering one day if the awful looks of the D3 ambient light can be helped, and after lots of experimentation and some luck, it boiled down to very few additional Instructions that are needed.
This should make using Ambient Lights much more viable, for example to approximate radiosity effects etc.

Huge thanks go out to the following people for testing and helping me find/squash some annoying bugs :
If you want to use it in your Mod, Map or some other way,
please remember to give credit ;).

Should you find problems, or have suggestions/questions/etc, feel free to contact me.




Update #1
[ posted 16.11.2010 by rebb ]

Just a little update on how things have developed, and some clarifications what this fix is and what it isn't.

First of all, the fix is NOT the shading. The fix is about "detecting" an ambient-light and then putting the according shading in place for it.
How this shading looks and how it is calculated has been changed around a lot over time and there are endless possibilities that can be used for it.

During testing on The DarkMod there have been many different approaches to actually "detecting" if an ambient-light has to be drawn, the earliest versions used simple tests on the normalization cubemap that is being passed into the interaction.vfp by the game.
This worked fine to an extent, but proved problematic on certain hardware.

Eventually i settled on the instruction-slim approach of having a certain Alpha-Channel value inside the lightImage of a light, and testing for this.
This has of course the downside of having to adjust light-images accordingly for it to work, but in most cases those aren't very numerous.

Another approach, similar to the first version, was suggested by Orbweaver and requires sampling the light normalization cubemap twice using a vector and it's opposite, then using the results.

This works, but so far there hasn't been much testing on it regarding possible hardware incompatibilities. You will find both versions below.

Note : These versions only contain a super-simple shading approach, which can be replaced by more sophisticated algorithms.

[ Download ] Light-Projection Image Version

Important : [ Download ] 2-Sample Cubemap Version, suggested by Orbweaver, based on Test-Implementation by Denton






This Image shows the difference between the default Ambient Light Shading and a "fixed" one. There is only a single Ambient Light illuminating the Area.
Notice the super-harsh shading in the default on the Imp and the Player's Hands, aka "Coalmine Effect".