Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Not good enough.

Sign in to follow this  


Flushed with success at the screen distortion effects (final screenshots comming soon [grin]) I set about trying to do a reflection effect.

Initially I thought I'd use the same basic code, but unfortunately the precision is an issue - the distortion is tweeked to get maximum precicion in a small area. Trying to do a mirror (which may be reflecting something on the other side of the screen) means the precision goes to hell and I get texturing artifacts everywhere. So reflection has to be something else.

So I knocked up a quick test scene, and basic reflection is simple - render flipped scene to texture, draw that back in the final image. Nice sharp reflections, but this time I'm after an icy reflection. Current progress looks something like this:

Basically this is a growable poisson disc blur, so reflections stay sharp at the feet but get blurrier as they get further away. Couple this with a gradual tint towards greyscale as the final step.

Unfortunately even with 16 samples the growable blur doesn't give very good quality. It's not terribly smooth and if you want it to be really blurry then you get all sorts of stair-steps and repeating artifacts. It's also not nearly as prominant as I'd like, I think just a regular separable blur would give much better results for less cost (although it's need two passes, and you don't get to have variable blur).

I'm not convinced on the greyscale tint either. I can't find a good middle ground between subtle and not visible and visible but too over the top.

I'm going to try another approach - a small, fixed blur combined with a small amount of distortion (probably something simple like a sine wave to start with). Then I might just blend an ice texture (if I can find one) over the top and see how that looks.
Sign in to follow this  


Recommended Comments

Wow, that's really nice. I like the blurred ice reflections; I'm interested in a decent ice reflection for my current game, Ice Slider. At present all I'm doing is a standard reflection - no blurring, although in my case it's complicated by the fact I can't just flip and re-render the whole scene due to the angle I've chosen.

How much extra processing time is taken up by the blurring process?

Share this comment

Link to comment
It's hard to judge the performance because I've got very little else going on - no real logic, and just a handful of sprites (so no particles or anything else taking up rendering time). But I get +200fps easily and I'm rendering it to half of a 800x600 screen (thats a lot of pixels!).

Basically theres two halves to it - the render to texture, then the render back to the screen. Since you're already doing reflection you've already got the overhead of the extra drawing I guess, so theres just the FBO management to add on top. FBOs are pretty damn fast I'm finding, so I don't think that will cost you much.

The second half means using a shader to draw it back to the screen. Complexity-wise it's pretty simple, but it does involve sampling the original texture 16 times for the blur. While this seems to be plenty fast on my system, it's probably the bottleneck on slower cards. The rest of the effect (greyscale tint, variable blur) is trivial in terms of calculations.

Of course the nice thing with the blur is it's easy to trade quality for performance. Dropping the number of samples is easy (easiest to write two or three versions by hand IMHO). I'm currently using a half-size texture to draw the reflections too, but you could use a quater or even an eighth if you want to get some speed back.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!