Jump to content
  • Advertisement
Sign in to follow this  
BadEggGames

Background color ruins Antialiasing

This topic is 1053 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 am having a new problem with my ray tracer. My Antialiasing is simply shooting 100 random rays at each pixel then averaging. This works great but only when the background color is black or white. As soon as I make it a different color, every edge above the horizon looks fuzzy. Anyone know why this is? I understand that if the sky is black then it adds nothing to the pixel color average and if its white, it adds 1 and averages out. Is there a way to add a color in a way that doesn't ruin anti aliasing?

 

sphere_1440920210684.png

 

sphere_1440919194539.png

 

I should note that this happens to non gradient colored skies too.

Share this post


Link to post
Share on other sites
Advertisement

I'm going to go with overflow in your colors again. Can you post your anti-aliasing code, where it averages the colors.

Share this post


Link to post
Share on other sites

I simply average r,g and b by the amount of rays for each pixel

 

PixelColor.x = PixelColor.x / rays.length;
PixelColor.y = PixelColor.y / rays.length;
PixelColor.z = PixelColor.z / rays.length;


if(PixelColor.x>1){
PixelColor.x=1.0f;
}

if(PixelColor.y>1){
PixelColor.y=1.0f;
}

if(PixelColor.z>1){
PixelColor.z=1.0f;
}

image.drawPixel(x, y, Color.rgba8888(PixelColor.x, PixelColor.y, PixelColor.z, 1));

Share this post


Link to post
Share on other sites

How are you adding them up to obtain PixelColor, though? What color is the blue background in RGB float values? Also, could you try with a purple background color? (not exactly the same color as the middle sphere but something nearby). I'd be somewhat curious to see the result.

Share this post


Link to post
Share on other sites

Interesting, purple background looks smooth:

 

The background color vector is:

 

BackgroundColour = new Vector3(1.0f,0f,0.8705f); //purple

 

If the ray doesn't intersect a sphere or a plane then the background color is added with:

 

PixelColor.add(BackgroundColour);

 

//edit

 

This is weird. I just set the background color back to the gradient, hit compile and this came out:

 

sphere_1440924669142.png

 

 

Exact same code, just restarted android studio. Must be some kind of weird android studio/java/emulator garbage collection thing going on. This development environment has strange outputs if you use it to long. Sorry about that

Share this post


Link to post
Share on other sites

It could be that it was running your old code before you added anti-aliasing or something, dunno. If it works now then cool, looks nice by the way smile.png

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.

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!