Sampling From _GrabTex using Point Sampling

Hi

Is there a way to set “FilterMode” of _GrabTex to Point Sampling ?
Currently in my refraction shader the scene color behind refraction object get a little blurred because of Bilinear sampling, which makes some artifact in my shader.

Bump

You can make sure to only sample from the center of the pixels by modifying the distortion UVs.

1 Like

hey

Thanks for reply, yeah im already doing this :

float2 pixel =  1 / _ScreenParams.xy;

refrOffset -= (refrOffset % pixel);

But why should i pay that in my fragment shader ?! isnt setting sampling mode cheaper than this ?

Cg, the shader language Unity’s ShaderLab is based off of, has a tex2Dfetch which allows you to sample a specific pixel value, but Unity doesn’t seem to support this. In GLSL you can do texelFetch, and in HLSL you can do Sample.Load, but both require #pragma target 4.0. Though I think % needs that too for direct3d.

Really the few math operations aren’t going to be a noticeable performance impact over the cost of the grab pass.

1 Like