Sign in to follow this  
psycoding

texture filtering

Recommended Posts

If I use a filter, anisotropic or tri/bilinear, I only have the pixels of the current triangle to work with in my triangle mapper. If a pixel is near an edge, the filter kernel may go outside the triangle, how to get these pixels outside of the current triangle ? Artifacts do occur if they are not taken into account, so how to treat them ? how is it done in games ? may sound curious to some people, but I'm writing my renderer completely from low level..

Share this post


Link to post
Share on other sites
Maybe i dont understand your question correctly but anisotropic or tri/bilinear filtering has nothing to do with triangle, it's just the way how neightbour texels taken into account when texel taken from texture is not mapping perfectly to current pixel on screen.

Share this post


Link to post
Share on other sites
If I understand your question, there are a number of ways you can handle this. Assume you have a sample [5694738] and a kernel (1/9)[12321].

1) You can clamp the edge values so that every pixel past the edge has the same value as the pixel at the edge.
Visually (| is the boundary of the sample):
sample---555|5694738|888
kernel---------------12|321

2) You can reflect the edge values.
965|5694738|837
-----------12|321

3 You can disregard the parts that cross the boundary and renormalize the kernel.
|5694738|
-------12|
(Except now the kernel weight is 1/3 instead of 1/9)

I hope that makes sense.

Ok, it keeps removing spaces that I put in. Disregard the '-'s and line up the '|'s on the right edge of the sample.

Share this post


Link to post
Share on other sites
In graphics hardware, rasterization happens in 2x2 pixel blocks called quads. That way every pixel has at least one up-down neighbor and one left-right neighbor, so derivatives can be computed on a per-quad basis.

Share this post


Link to post
Share on other sites

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

Sign in to follow this