sampler3D color correction produces odd outline

I’ve been playing around with 3D textures to produce color effects, but the edges of 2D textures with a 3D texture pass produce odd extra coloring artifacts, especially when not horizontal or vertical. Attached I have an image of two shaders with the same texture, the first one the default texture unlit and the second the same texture sampled through the identity 3D texture.


This seems to be also the case with the PostProcessing 3D LUT, ShaderGraph, and on a second tested computer.

Does anyone know how to fix this?

5139089–508688–3dSampler.shader (1.11 KB)

Nothing wrong with the shader. But you need to disable the mipmaps on your 3D texture.

GPUs determine the appropriate mipmap to use when sampling a texture by how much its UVs change within each 2x2 pixel group. At the edge of a color change, the color value from the original texture is changing significantly, thus the “UVs” for the 3D texture are changing significantly, and it’s dropping to a lower mip map. Since you’re going from white (1,1,1) to a solid color or black (0,0,0), ands UVs use the largest change within the pixel quad to determine the mip map, you’re always sampling from the smallest mip. So basically a 1x1 middle grey.

1 Like

That worked! Just had to change that boolean in the constructor. Thanks for your help and for all your other posts helping other people (that also later helped me)