Resource: Ambient Occlusion for TGEA Interiors
by Ryan Mounts · 07/16/2008 (10:18 am) · 59 comments
NOTICE: Resource updated 8/4/08.
Link to TGEA AO Resource
Well, as I figured, the ambient occlusion code was very simple to port over from TGE, but the lightmap persistence and caching took a little more work. Hopefully everyone will find this useful. This is a feature that I've been wanting to see in Torque for a long time, so I'm pretty excited to see it coming together.
For those of you who have already looked at the TGE version of this resource, I suggest at least reading over the Persistence and Caching section again, because the TGEA version behaves slightly differently.
As before, if anyone finds/fixes any bugs, enhances performance, or makes interesting modifications to this resource, please share!
Pics: Side-by-side comparisons of two identical interiors, one with AO and one without. In the first pic, there are two small boxes in the Cornell box on the right, I promise! :) You just can't see them because the ambient light is constant and the textures are a single color. This just illustrates how much visual "pop" AO can add to an interior.


(Church dif created by Benjamin Naulls, of course)
Link to TGEA AO Resource
Well, as I figured, the ambient occlusion code was very simple to port over from TGE, but the lightmap persistence and caching took a little more work. Hopefully everyone will find this useful. This is a feature that I've been wanting to see in Torque for a long time, so I'm pretty excited to see it coming together.
For those of you who have already looked at the TGE version of this resource, I suggest at least reading over the Persistence and Caching section again, because the TGEA version behaves slightly differently.
As before, if anyone finds/fixes any bugs, enhances performance, or makes interesting modifications to this resource, please share!
Pics: Side-by-side comparisons of two identical interiors, one with AO and one without. In the first pic, there are two small boxes in the Cornell box on the right, I promise! :) You just can't see them because the ambient light is constant and the textures are a single color. This just illustrates how much visual "pop" AO can add to an interior.


(Church dif created by Benjamin Naulls, of course)
About the author
#2
Now all we need is AO for dts and players '-)
07/16/2008 (10:27 am)
Wow, thats really impressive. What kindof performance hit does this entail? Now all we need is AO for dts and players '-)
#3
Edit: I believe congratz is spelt with a t, not a d...
07/16/2008 (10:35 am)
Congratulation Ryan! You just made my day! Thanks for sharing such an awsome resource.Edit: I believe congratz is spelt with a t, not a d...
#4
There is no performance hit in-game because the AO is baked into the interior's lightmap. All calculations are done "offline," so to speak, during the scene relight.
07/16/2008 (10:35 am)
@ JamesThere is no performance hit in-game because the AO is baked into the interior's lightmap. All calculations are done "offline," so to speak, during the scene relight.
#5
Is there any way to include pre-compiled AO cache files? Or move a lot of the calculations over into map2DIF?
Thanks for your hard work... I've been wanting AO for quite some time!
07/16/2008 (10:54 am)
We tested the TGE version yesterday. It looks nice, but I'm concerned about the sheer length of time it takes to light the first time. Is there any way to include pre-compiled AO cache files? Or move a lot of the calculations over into map2DIF?
Thanks for your hard work... I've been wanting AO for quite some time!
#6
Yeah, I too noticed that the re-light time drastically increases. I'm gonna try it on my 3GB RAM / quad core tomorrow, just to see how long it would take to relight on a map with every difs on high. What I plan to do is, before release, render the final lightmap and then remove the scene lighter from the mission download. That way no players will accidenally end up waiting an eternity for their game to load.
07/16/2008 (11:47 am)
@EricYeah, I too noticed that the re-light time drastically increases. I'm gonna try it on my 3GB RAM / quad core tomorrow, just to see how long it would take to relight on a map with every difs on high. What I plan to do is, before release, render the final lightmap and then remove the scene lighter from the mission download. That way no players will accidenally end up waiting an eternity for their game to load.
#7
07/16/2008 (11:48 am)
Very cool that this you have made this for TGEA too. You can expect some modifications to this from me soon, I love looking at these things and seeing how they work :-)
#8
Yeah, it would be nice to be able to bake the AO at dif creation time if you were going to drop dozens of the same interior into a scene and didn't really care if the AO interacted with objects in the world. Then you'd only have to do the calculation once.
I don't remember what the lightmap code looks like in map2dif, but it's probably similar enough to the engine that the AO code could be dropped in there. I'll look into it when I get a chance. It'd be nice if it could be added to Constructor where you could tweak the AO and see it before export... plus you could use the internal exporter. Maybe Jaimi would be up for that! ;)
Also, relight times will be affected by the "light_geometry_scale" (it basically controls the resolution of your lightmap) and the number of LODs, since AO will get calculated for each LOD. Unless you have REALLY high resolution lightmaps or an annoyingly splotchy area, you shouldn't really need to go above Low quality. A good method for adding AO to a scene with many interiors is to use the filtered relight instead of the full. Don't worry, once an AO enabled interior is out of range of the filtered relight, it will still keep its lightmap. This way you can update only one or two interiors at a time, allowing for quicker feedback.
07/16/2008 (11:54 am)
@EricYeah, it would be nice to be able to bake the AO at dif creation time if you were going to drop dozens of the same interior into a scene and didn't really care if the AO interacted with objects in the world. Then you'd only have to do the calculation once.
I don't remember what the lightmap code looks like in map2dif, but it's probably similar enough to the engine that the AO code could be dropped in there. I'll look into it when I get a chance. It'd be nice if it could be added to Constructor where you could tweak the AO and see it before export... plus you could use the internal exporter. Maybe Jaimi would be up for that! ;)
Also, relight times will be affected by the "light_geometry_scale" (it basically controls the resolution of your lightmap) and the number of LODs, since AO will get calculated for each LOD. Unless you have REALLY high resolution lightmaps or an annoyingly splotchy area, you shouldn't really need to go above Low quality. A good method for adding AO to a scene with many interiors is to use the filtered relight instead of the full. Don't worry, once an AO enabled interior is out of range of the filtered relight, it will still keep its lightmap. This way you can update only one or two interiors at a time, allowing for quicker feedback.
#9
I'm sure using only DIF-baked lights instead of sgLights would probably speed it up some too. They don't seem to be taken account of anyway, so it may as well be done in the DIF.
Do you think could take a snapshot of either of those same scenes from the same angle with the AO settings reversed? Just for a better comparison?
07/16/2008 (12:58 pm)
Thanks Ryan. I didn't realize that "Low" may work well enough. Indeed, anything would probably be better than nothing.I'm sure using only DIF-baked lights instead of sgLights would probably speed it up some too. They don't seem to be taken account of anyway, so it may as well be done in the DIF.
Do you think could take a snapshot of either of those same scenes from the same angle with the AO settings reversed? Just for a better comparison?
#10
07/16/2008 (1:15 pm)
Rated 5. Great resource.
#11
07/16/2008 (1:38 pm)
Here's the top pic with AO settings reversed (Distance = 3, Quality = Low, Multiplier = 1).
#12
07/16/2008 (2:09 pm)
Awsome work Ryan, can some kind person provide this on a clean 1.7.1 for a none coding artist like myself. I would love to toy with it :)
#13
is it me or is the quality of the effect better in TGEA? At least that is the way it looks from the screen shots
07/16/2008 (2:37 pm)
Ryan You are the man!is it me or is the quality of the effect better in TGEA? At least that is the way it looks from the screen shots
#14
07/16/2008 (3:59 pm)
Ryan, You are the man x2!
#16
07/17/2008 (6:34 am)
Just wanted to give you some kudos on this. Nice addition.
#17
The only snag is it seems to favor having ambient shadows going up instead of going down, it just looks a bit odd.
07/17/2008 (11:00 am)
Thanks for the clean build Ryan, I have tested this a few times, it works great and looks fantastic, it is a massive improvement. The only snag is it seems to favor having ambient shadows going up instead of going down, it just looks a bit odd.
#18
Ando,
could you elaborate on that a bit ? Maybe a screenshot ?
07/17/2008 (11:16 am)
> it seems to favor having ambient shadows going up instead of going downAndo,
could you elaborate on that a bit ? Maybe a screenshot ?
#20
edit: Never mind, just tried this out for myself with several relights and different settings, it is definately darker on top.
07/17/2008 (12:45 pm)
That is pretty strange, I don't see any reason that the AO would do that... edit: Never mind, just tried this out for myself with several relights and different settings, it is definately darker on top.
Torque Owner Ryan Mounts
CornerstoneViz