• entries
  • comments
  • views

Image Quality

Sign in to follow this  


So, back on the HDRI stuff again...

Thanks to Ysaneya's comment to one of my previous entries, I realised that trying to "roll my own" filtering algorithm was a nice learning exercise, but not really useful. So I got rid of it and put a simple bilinear filtering function in:
//g_rcp_bloom_tex_w is a float constant indicating the reciprocal of the width
//g_rcp_bloom_tex_h is a float constant indicating the reciprocal of the height
// -----
float xWeight = frac( t.x / g_rcp_bloom_tex_w ) - 0.5;
float xDir = xWeight;
xWeight = abs( xWeight );
xDir /= xWeight;
xDir *= g_rcp_bloom_tex_w;

float yWeight = frac( t.y / g_rcp_bloom_tex_h ) - 0.5;
float yDir = yWeight;
yWeight = abs( yWeight );
yDir /= yWeight;
yDir *= g_rcp_bloom_tex_h;

// sample the bloom texture for the 4 relevant pixels
float4 b = ((1.0f - xWeight) * (1.0f - yWeight)) * tex2D( tex2, t );
b += (xWeight * (1.0f - yWeight)) * tex2D( tex2, t + float2( xDir, 0.0f ) );
b += (yWeight * (1.0f - xWeight)) * tex2D( tex2, t + float2( 0.0f, yDir ) );
b += (xWeight * yWeight) * tex2D( tex2, t + float2( xDir, yDir ) );

It's based on a couple of articles - one at (deceased [sad]) flipcode and one from wikipedia - that showed the correct weights to use. The rest of the implementation I cooked up on my own - so there could well be something better kicking around [grin]

I'm very happy with the results:
Sign in to follow this  


Recommended Comments

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