Jump to content
  • Advertisement
Sign in to follow this  

[SOLVED] Anti-Aliasing and Deferred Rendering problem

This topic is 3080 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

I've implemented deferred rendering using glsl and fbo's and I'm trying to implement the AA filter in the SBGAMES2005 tutorial but I'm getting weird results from it:

The pixel shader is just a straight conversion from the filter in the tutorial:

#version 120

varying vec2 texCoord;

uniform sampler2D colourTex;
uniform sampler2D normalTex;

uniform vec2 pixelSize = vec2(24,24);
uniform float weight = 0.8;

vec2 delta[8];

void main()
delta[0] = vec2(-1,1);
delta[1] = vec2(1,-1);
delta[2] = vec2(-1,1);
delta[3] = vec2(1,1);
delta[4] = vec2(-1,0);
delta[5] = vec2(1,0);
delta[6] = vec2(0,-1);
delta[7] = vec2(0,1);

vec4 tex = texture2D(normalTex, texCoord);
float factor = 0.0f;

for(int i=0; i < 4; ++i)
vec4 t = texture2D(normalTex, texCoord + delta*pixelSize);
t -= tex;
factor += dot(t,t);
factor = min(1.0,factor)*weight;

vec4 colour = vec4(0.0,0.0,0.0,0.0);

for(int i=0; i < 8; ++i)
colour += texture2D(colourTex, texCoord + delta*pixelSize*factor);

colour += 2.0 * texture2D(colourTex, texCoord);

gl_FragColor = colour*(1.0/10.0);

I'm not sure where I'm going wrong here, anyone got any ideas? I've tried changing the "pixelSize" and "weight" variables but they obviously don't change the result image.

[Edited by - HackSlash on July 10, 2010 10:22:26 AM]

Share this post

Link to post
Share on other sites
The line uniform vec2 pixelSize = vec2(24,24); seams wrong to me. Texture coords for samplers 2D range from 0.0 to 1.0, so with this pixel size you read outside the bounds of the texture (and with GL_REPEAT,you will have really awkward results).
Try something like pixelSize = vec2(1.0 / screenWidth, 1.0 / screenHeight).

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!