What is the difference between tex2D() and SAMPLE_TEXTURE2D? I am trying to create a four corner pin post processing effect, and my lines come out curved with SAMPLE_TEXTURE2D, but are good and straight when I use tex2D() in an ImageEffect.
Motivation for using a custum post processing effect instead of an ImageEffect is because ImageEffects dont seem to work when using HDRP (OnRenderImage() is never called), and I want to use ShaderGraph for other parts of the app. I should also mention my shader knowledge is pretty limited so feel free to point out any newb mistakes
Here is my simple fragment shader
float4 Frag(VaryingsDefault i) : SV_Target
{
float2 uv = i.texcoord;
uv.x *= 1 / (uv.y*_URx + 1);
return SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv); //Compiles, but produces curved lines instead of the desired straight ones
//return tex2D(_MainTex, uv); //Doesnt compile here, but produces good straight lines
}
There are, but none are going to be used unless you’re explicity setting them on the interpolated value definitions, and even then they wouldn’t have much effect during a blit() or similar full screen screen aligned geomerty.
However the math you’re using confuses me a bit. Specifically I don’t think the + 1 is correct.
My guess is that the + 1 is so that he dosnt get a 0 in the denominator. He is extending the ux.x but i dont see the purpose of this without some images.
Where did that ShaderLibrary API repo go? I can’t find it. I’m trying to find the definition of
SAMPLE_TEXTURE2D, and then hopefully something similar that wraps
tex2Dlod.