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

Nice shiny variable reflections

Sign in to follow this  


It seems that shaders are the easy bit of graphics programming nowadays, knocking a few equations into GLSL took less than a day (even if I did pinch some old code fragments). Even the glue code in the actual app was pretty simple - my GLSL framework is proving to be ridiculously simple to setup, which is good as that was the whole idea. [grin]

What I've got now is a frozen pond in my village, with the reflections fuzzy and vauge on the snow, but sharp on the pool surface and pathway.

The reflected objects are drawn into a reflection texture, then the ground sprites are drawn, then the reflection is blended over the top with the reflection shader. The reflection shader does a variable blur (just the usual growable disc filter) based on a 'sharpness' texture, which is manually created to specify where the reflections should be sharp and where not. The sharpness also affects the transparency of the reflection, so sharp reflections are more visible than fuzzy ones.

You can see how the larger snowball has a sharp reflection on the pool but fuzzy otherwise. I've not finished tweeking it yet, I might make the snow reflections a little bolder. And after that I've got to write a GL 1.1 fallback path and use that when GLSL isn't available.
Sign in to follow this  


Recommended Comments

Looks really good. I really ought to learn about some of this shader stuff.

Stupid question, but is this game based on OpenGL, or what?

Share this comment

Link to comment
GLSL shaders are really easy once you've got the hang of them - the shader code is practically C with some vector extensions. The only awkward bit is the glue code needed in the app, but you can hide a lot of that with a few useful utility functions.

Yes, the whole game is written in OpenGL. I dread to think how graphically different this would look if it was written in a regular 2d API - pretty much all the rendering would have to visually change in one way or another.

Share this comment

Link to comment
Very good looking. Question: are you going to post the shader code? If not, has anything changed in terms of blurring? Still using the same Poisson disc as posted earlier? Thanks!

Share this comment

Link to comment
The shader code is pretty much the same. The only differences are that I've removed the greyscale tinting, and that the blur amount is now per-pixel from a seperate texture rather than being per-vertex.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!