by date
Native Ambient Occlusion for Interiors in TGE
Native Ambient Occlusion for Interiors in TGE
| Name: | Ryan Mounts | |
|---|---|---|
| Date Posted: | Jun 25, 2008 | |
| Rating: | 5.0 out of 5 | |
| Public: | YES | |
| Comments: | YES | |
| RSS Feed: | or Subscribe with . | |
| Profile Page: | View profile page for Ryan Mounts |
Blog post
If you've followed any of my blogs at all, you've probably noticed my desire to get more advanced lighting into Torque. So far I've been using 3dsmax to do that with good success. The only problem is that the process can be somewhat time consuming and complicated at times. It'd be much nicer if I could do some simple advance lighting directly inside Torque. I've noticed that ambient occlusion really adds alot to a scene, so that seemed like a good place to start.
So here's some progress from my current endeavor: ambient occlusion for an interior calculated in Torque and added to its lightmap. It's a simple AO algorithm that shoots rays out from each lexel in the lightmap to determine that lexel's occlusion. This AO value is then used to modulate the ambient light.

There are three different quality settings: low, medium, and high. Low shoots 40 rays, Medium shoots 160, and High shoots 360. You can see that there are some artifacts in the corners using the Low setting. Medium got rid of the artifacts and smoothed the result considerably. High didn't change the visual quality much, but the shadowing is slightly smoother where the taller box touches the floor. I haven't profiled this, but approximate relight times for the above images on a Dell Inspiron 8600 laptop/1.5 GHz/512MB RAM were... Low: 5 seconds, Medium: 12 seconds, High: 30 seconds. Looks like Medium is sufficient to get good AO.

Changing the ray length adjusts the "size" of the AO effect. Longer rays will generally result in darker shadowing (more accurate), but will take longer to calculate.
Next I need to expose these parameters to the World Editor and make an option to lock the AO in. That way it won't have to recalculate with every relight. Then I plan on releasing this as a resource. And porting this over to TGEA should only take a few minutes. :)
So here's some progress from my current endeavor: ambient occlusion for an interior calculated in Torque and added to its lightmap. It's a simple AO algorithm that shoots rays out from each lexel in the lightmap to determine that lexel's occlusion. This AO value is then used to modulate the ambient light.

There are three different quality settings: low, medium, and high. Low shoots 40 rays, Medium shoots 160, and High shoots 360. You can see that there are some artifacts in the corners using the Low setting. Medium got rid of the artifacts and smoothed the result considerably. High didn't change the visual quality much, but the shadowing is slightly smoother where the taller box touches the floor. I haven't profiled this, but approximate relight times for the above images on a Dell Inspiron 8600 laptop/1.5 GHz/512MB RAM were... Low: 5 seconds, Medium: 12 seconds, High: 30 seconds. Looks like Medium is sufficient to get good AO.

Changing the ray length adjusts the "size" of the AO effect. Longer rays will generally result in darker shadowing (more accurate), but will take longer to calculate.
Next I need to expose these parameters to the World Editor and make an option to lock the AO in. That way it won't have to recalculate with every relight. Then I plan on releasing this as a resource. And porting this over to TGEA should only take a few minutes. :)
Recent Blog Posts
| List: | 07/16/08 - Resource: Ambient Occlusion for TGEA Interiors 07/11/08 - Resource: Ambient Occlusion for TGE Interiors 06/25/08 - Native Ambient Occlusion for Interiors in TGE 06/17/08 - Custom Lightmaps for TGEA Interiors 04/03/08 - Add Custom Lightmaps to Interiors 01/24/08 - Update: Max2Ctor 1.0.1 01/10/08 - Tutorial: Export 3dsmax directly to Constructor 01/09/08 - Free Resource for 3dsmax Users |
|---|
Submit your own resources!| Stephan (viKKing) Bondier (Jun 25, 2008 at 20:27 GMT) |
Really nice. Awesome work.
| James Brad Barnette (Jun 25, 2008 at 21:03 GMT) |
| Ryan Mounts (Jun 25, 2008 at 21:25 GMT) |
| Apparatus (Jun 26, 2008 at 04:37 GMT) |
| ando (Jun 26, 2008 at 14:44 GMT) |
| Mark Dynna (Jun 26, 2008 at 15:09 GMT) |
| Xavier "eXoDuS" Amado (Jun 28, 2008 at 00:50 GMT) |
Just a thought, it looks very nice. Great work!
| Ryan Mounts (Jun 28, 2008 at 05:15 GMT) |
Edited on Jun 28, 2008 05:16 GMT
| James Brad Barnette (Jun 28, 2008 at 15:32 GMT) |
@ryan:
in the picture of the with it at high above. On the floor on the right hand side the shadow of the small box still seems to be pixelated while all of the other angled stuff appears to be" at least from the picture angle" smooth. Is there any explanation of this or are other edges this way as well and we just cant see them?
one more question is this process fully threaded so that it would take advantage of SMP systems? and is it Video hardware Dependant for its generation or would it work on pretty much anything that is capable of the running the engine
Edited on Jun 28, 2008 15:34 GMT
| Ryan Mounts (Jun 28, 2008 at 16:49 GMT) |
The pixelated shadow you're referring to is a diffuse light shadow cast from the sun, so it doesn't have anything to do with the ambient occlusion code. If you notice, that shadow is exactly the same in every image, since I didn't change the sun. Not really sure why that little section is rougher than the rest.
The algorithm itself is single threaded. This doesn't mean that it wouldn't benefit from SMP systems. I don't know for a fact, but the way the light manager handles queued lighting events is most likely multi-threaded. If so, this would distribute the AO calculations for different interiors to different cores. And no, it's not tied to any video hardware. It should work on anything. :)
Edited on Jun 28, 2008 16:53 GMT
| Stefan Lundmark (Jun 30, 2008 at 11:09 GMT) |
Are you doing these calculations in scene-relighting or somewhere else? Really interesting work!
| Ryan Mounts (Jun 30, 2008 at 13:25 GMT) |
Yup, it's done in the scene relight code.
| Kory James (Jul 09, 2008 at 20:38 GMT) Resource Rating: 5 |
thx
| James Brad Barnette (Jul 09, 2008 at 22:07 GMT) |
| Ryan Mounts (Jul 10, 2008 at 05:39 GMT) |
I think you meant to post in the thread for custom lightmaps in TGEA. The code in this thread hasn't been released yet. The only thing that was changed in the Interior I/O was the four places where "smFileVersion == 0" was changed to "smFileVersion == 1". You might try changing them back to "smFileVersion == 0" and just adding " || smFileVersion == 1" to each of the if-statements. I think that should allow you to load old map2dif files and still leave the backwards compatibility that might have been causing the error.
@James
I just got the persistence part of the code working the way I wanted today in TGE. So I'll try to package it up and post a resource within the next day or two. If you're familiar enough with TGEA, you might be able to port it over yourself. The persistence code was actually very difficult for me to iron out, and I have a feeling TGEA might pose some more problems... so I'm not sure when a TGEA version will be posted.
| Associa (Jul 29, 2008 at 23:02 GMT) Resource Rating: 5 |
You must be a member and be logged in to either append comments or rate this resource.


5.0 out of 5


