There was a weird white line at the edge of my sphere UV when I import texture with mipmap
It disappear when I disable mipmap
What is this?
There was a weird white line at the edge of my sphere UV when I import texture with mipmap
It disappear when I disable mipmap
What is this?
My guess is the position of your UV, but since this is sphere i guess it is something with your texture.
Is your texture filled by color only on UV islands or do you have blurred edges?
Look at the image, left one does not have anyting beside on the UV islands, right one has background color to hide seems.
It’s bilinear filtering and mip mapping with out adequate padding on UV seams. You usually want to keep a good 4~8 pixels of padding around the edges of UV seams with that edge’s color.
Try taking your texture in Photoshop, scale it down to 25%, then scale it back up to the original size using bilinear upscaling. Use that new texture in your modelling program to get a sense of what mipmapping will do.
I have try tinkering with UV padding but no it’s use. Turn out it was this problem
Just figure out it actually have tex2D sampler LOD for this. I need to control LOD by myself with my self generated UV
I prefer using tex2Dgrad as I find it’s easier to use, once you understand how to use it at least.
The other potentially even easier option is this:
http://vcg.isti.cnr.it/~tarini/no-seams/
For your case, I’m guessing you’re calculating equilateral projection for the UVs in the fragment shader. You’d need to calculate at least the uv.x twice, like this:
float x_atan = atan(x, z) / (2.0 * UNITY_PI);
float xA = x_atan + 0.5;
float xB = frac(x_atan + 1.0) - 0.5;
float2 uv = float2(
fwidth(xA) < fwidth(xB) ? xA : xB,
acos(-y) / UNITY_PI
);
fixed4 col = tex2D(_MainTex, uv);
@bgolus I think it was a problem of texture 2D lookup node of shadergraph itself so only calculating UV don’t solve this. I even try to clamp the UV to 0.01-0.99 and the artifact still occur
Shader Graph is just generating normal HLSL, there’s nothing special or unique about its Sample Texture 2D node vs the tex2D() function.
Because if the issues is the one in that forum post you linked to, clamping won’t solve the main problem.
In the case of the post the above quote is in response to, that person was taking a continuous UV and using a modulo on it. This introduces a discontinuity within the UVs that the derivatives see as a sudden, very high rate of change. In your case, if you’re generating UVs in the fragment shader using atan(), that function produces a value range from -π to +π, which you would then scale to a 0.0 to 1.0 range. You’re not using a frac() or a modulo, but there’s still an inherent discontinuity in the value as it wraps around causing the same problem. The trick in the code above is within the 2x2 pixel quads where the sudden discontinuity appears instead of using the normal UV that goes from from 1.0 to 0.0 it uses a continuous UV with a range from 0.5 to 1.5, so for that edge it’s a continuous 1.0 to 1.01.
Here’s the Shader Graph equivalent layout:

And here it is with the original “broken” setup:

(Note: The texture needs to be set to Wrap Mode: Repeat, and not Clamp for the above to work properly)