Search Unity

Question Heightmap artifacts in SampleTexture2D node

Discussion in 'Shader Graph' started by XJonOneX, Feb 18, 2024.

  1. XJonOneX

    XJonOneX

    Joined:
    Dec 19, 2017
    Posts:
    113
    I'm feeding a Texture2D of heightmap data to my shader, however I'm getting some artifacts at the top and bottom edges. (I'm not concerned with the sides)

    This is the top part of the heightmap after it's been exported to a png:
    HeightmapTileError2.png

    In my script, the next line of code after generating the data, feeds it to a Texture2D property on my shader.

    However, it has the artifacts in the SampleTexture2D node:
    HeightmapTileError1.png
    This SampleTexture2d node is the start of my shader. With the .png file not showing the artifacts, I'm inclined to believe my heightmap generation code is functioning properly.

    Any ideas?

    [Edit]
    I should also mention that the heightmap texture is 101x101 and corrilates to vertex data on my terrain mesh. I'm transforming the data to a 1024x1024 texture, but again, I see the artifacts at the very first node...
    [/Edit]

    [Edit2]
    Upon further inspection, it seems like it might be some kind of tiling thing...
    [/Edit2]
     
    Last edited: Feb 18, 2024
  2. XJonOneX

    XJonOneX

    Joined:
    Dec 19, 2017
    Posts:
    113
    I got it resolved using a SamplerState node, connecting that to the SampleTexture2D Sampler(SS) input, and setting Wrap to Clamp.