PDA

View Full Version : fragment program (arbfp1.0) Blur effect



matchStickMan
12-10-2008, 01:54 AM
Hi guys,

My question is quite simple. I want to create a small blur fragment program.

To get the current fragment, I do:

TEMP texfrag;
TEX texfrag, fragment.texcoord[0], texture[0], 2D;


My question is, how do i get the neighbouring fragments?


If I do:

TEX texfrag, fragment.texcoord[1], texture[0], 2D;

My image gets darker, indicating that the fragment is black.


If I do:

TEX texfrag, fragment.texcoord[0] + 1, texture[0], 2D;

The program refuses to compile. :p


If anyone can help, that'd be nice.

tnx guys.

mfort
12-10-2008, 02:29 AM
# compute coordinate of next texture sample
ADD texfrag, fragment.texcoord[0], {XOFFSET,0,0,0};
# sample texture at next position
TEX texfrag, texfrag, texture[0], 2D;


XOFFSET is not 1 ! it is 1 / texture width

or compute the next sample position in vertex shader and pass it in another texture coordinate, for example fragment.texcoord[1]

matchStickMan
12-14-2008, 09:08 PM
Hi mfort,

Sorry for the late reply. I was attending SIGGRAPH Asia.

Your code works wonderfully! Thank-you very much. :)

matchStickMan
12-15-2008, 12:46 AM
Hi again guys,

I have coded a few fragment programs but I have never coded a vertex program before.

I'm have some problems calculating the offset.

In other words, how do i find out where the neighboring fragment will be?

I should find the texture width and perform an RCP with it. But which vertex variable gives me that value.

Please help.