Wednesday, March 18, 2009 at 2:49 PM |  

Tada!

I know, I know.. Not the best shot to be proud of. But its the best shot at showcasing every single graphical feature we have in our game right now; HDR, Refraction, Shadow, Paging Geom, Baked AO (somewhat like light map but independent of light source), fuzzy holo and lens flare.

Yes, this post is more about the refraction than anything else. Getting refraction up was a real pain. Took me a few days of frustrations and hitting Ogre bug(s) before I got it working more or less. The FPS isn't too happy on my machine though. 8600GTS just doesn't cut it for such fillrate intensive feature. I'm getting about 40-50fps when every feature is turned on (shadow at lowest setting). I've yet to test it on the more powerful 9800GT, but I bet it'll be blazing fast. :)

The trick behind refraction is that it's a postprocessing feature. Thanks to Ogre's nifty compositor system, It allowed me to build this pretty much from a simple compositor script and a handful of materials and shader files.

What I did was basically tell compositor to render the scene in what I call the refraction pass. What happens here is that instead of rendering the scene with the basic materials, we render them with special refraction materials which sets the refraction and depth info into a temporary render texture. This is done by ordering the compositor pass to use a custom material scheme.

After this is done, the render texture is then used to distort the real scene texture base on the offset and depth info. Not too complicated. :)

However this technique has it's quirks and problems. Attempt at using it for effects like stained glass results in ugly distortion of the tinting. Stacking them up over one another will most definitely turn it into a muddle of crappy distorted glasses.

Still, this effect has it's use in many other cases. For one, we intend to use it for simple water based effect like the shot above. Uh.. yeah, it's not going to look like that, I'll be changing it to the proper shader later. :P

The second effect, which we will be using a lot, is heat haze and shield distortion. This will definitely spice up things. Hehe :D

Aside from this, there's still more to deal with. To get this working I had to work around a problem with the PCZSM(portal scene manager) that I was using. It was a bug that causes compositor to not function properly. I've yet to figure out how to solve that. Hopefully I can solve that soon and move on. There's already tons of things in my todo list and it's piling up! :(

That's it. I'm done. Shader programming should be a full time job. Sheesh.

P.S. I know I didn't really properly explain the whole process of the refraction shader. But I'll leave that to the imagination of any reader who intends to add refraction into their system. :) It's not that hard to figure it out.
Posted by Lf3T-Hn4D

2 comments:

Alex Delderfield (AD-Edge) said...

Looking great guys!

Cant wait to see the heat haze and other special effects, going to be awesome.

Keep up the good work,
Alex

March 25, 2009 at 5:23 AM  
Lf3T-Hn4D said...

Thanks :D Getting this comment thing working was pretty confusing. I'm glad I've finally got it working.

March 25, 2009 at 5:41 AM  

Post a Comment

Liquid Rock Games and Project Aftershock. All Rights Reserved.