PDA

View Full Version : How to access the neighbor texel of a texel in the fragment program?



zhq424
11-30-2003, 08:50 PM
We can use TexCoord to access the texture and get a value stored in the texture. In fragment program shader, wo can use TEX/TXB/TXP instruction to access a texture. But how to get a texel's neighbor texel? Please advise me.

Ysaneya
11-30-2003, 11:14 PM
That's pretty easy: sample the same texture but with texture coordinates offseted by one pixel in the direction you want to access to.

For example, if you render a quad on TMU0 with a 256x256 texture T and tex coords [0,0]->[1,1], if you want to access the right neighboor pixel on TMU1, bind T with tex coords [du,0]->[1+du,1] with du=1/256.

Y.

zhq424
12-01-2003, 12:38 AM
Thanks!
I want to use CubeMapping for generate the point light shadow. The problem is when I do not sample a pixel's neightbor poxel, the shadow border is artificial. So I want to sample the neightbor pixel of the cube_map texture, such as the up, down, left, right pixel of the pixel.
How to resolve it?