Search Unity

(Solved) Sampling issues with tex2Dlod in vertex shader

Discussion in 'Shaders' started by tcjkant, Jun 14, 2019.

  1. tcjkant

    tcjkant

    Joined:
    Jan 12, 2019
    Posts:
    15
    I've been having some issues with using tex2Dlod on a texture with bilinear filtering in the vertex shader. I've noticed this before but it's become an issue with trying to get a cheap noise calculation working.

    I am using the basic approach here:
    https://www.shadertoy.com/view/XslGRr

    I am able to get the basics working fine, but there seem to be errors in the interpolation that will lead to vertices jittering almost imperceptibly when displaced with the noise. The jitters seem like not a huge deal but they really mess with the ability to calculate real time normals from noise-displaced geo.

    As a test, I put the exact same data that went into the texture into a structured buffer, and did the bilinear interpolation manually in the shader. This works flawlessly, but is more expensive since I'm not relying on the hardware interpolation and have to throw a bunch of lerps into the shader. However, the fact that interpolating values retrieved from a buffer across vertices works in one instance makes me think there should be no reason why a texture sample shouldn't be able to be interpolated in the same manner.

    Any ideas as to why the texture sample isn't interpolating properly from the vertex shader? Thanks!

    EDIT: Other bits of info - the texture is set to linear color, project color space is Gamma.
     
    Last edited: Jun 14, 2019
  2. tcjkant

    tcjkant

    Joined:
    Jan 12, 2019
    Posts:
    15