- Home /
fragment Shader -> get the current pixel color int the color Buffer :D
hi, im tring to do a refraction shader,and i can find info about how to get the current pixel color, so i can use it to change the color of other pixel.
plz help !! :D
ty for reading! cya
Answer by tanoshimi · Dec 29, 2014 at 07:43 PM
What do you mean by the "current pixel color"?
You can't access the value in the colour buffer at the point a fragment shader runs, because at that time it may not be known. And, if it were known, it would be unreliable - fragment shaders run in parallel and you wouldn't know which other operations that also affect this fragment had already run. Why do you need to know this value? To "change" pixel colours, what you generally do is specify both the output colour from a fragment shader and the appropriate BlendOp as to how it should be combined with the existing colour value in the buffer.
Or do you mean the pixel colour determined by a previous pass? If so, you can render the first pass to a texture, and then lookup that pixel from the texture using tex2Dfetch.
i want to do a refractive shader so i have queeque in transparent, and them i just need the color of the pixel that im running the fragment program, so i can grab it and change it, by doing a shift position of simply do a blend like:
uniform _Color col;
frag(){
return (_Color + CURRENTPIXELCOLOR)* 0.5;
} //CURRENTPIXELCOLOR = to the color pixel(in the colorBuffer) that it´s running the frag program
~
can u tell me how can i get this ->CURRENTPIXELCOLOR
if this is totally "non-sense", can u write a simple transperancy shader to demonstra, plz :D
sorry for the englis:D
Like I said, "CURRENTPIXELCOLOR" doesn't make sense, unless you're talking about a previous pass?