Top edge ghost on tiled texture

Godot Version

v4.3.stable.official [77dcf97d8]

Question

I need a shader that I will skew a repeating texture. I’ve got the skew working fine on a single repeat and on a texture that repeats both horizontally and vertically. However, I’d like to also apply it to a texture that only repeats horizontally, and in that case I get a ghostly line at the top:

I figure this is probably related to the fact that I’m using mipmaps, but everything looks like poo without them, so turning that off is a no go. I could also just shave the bottom pixel off the art, but that’s hacky and lame.

I’m currently repeating by setting the Canvas Item property ‘texture’ to repeat and manipulating the rect in my sprite2d. A possible solution would be tiling in the shader before applying my skew (this seems like a thing I should be able to do), but I haven’t been able to find a tutorial on how. Another solution would be something that clips some number of pixels from the top, but again, not sure how I’d do that. Advice (or another strategy) would be much appreciated.

Here is the shader code for completeness:

shader_type canvas_item;

void vertex() {
	float skew_radians = (30.0 * PI) / 180.0;
	vec2 skewed_coord = vec2(VERTEX.x / 2.0, VERTEX.y + ((VERTEX.x) * tan(skew_radians) / 2.0));
	VERTEX = skewed_coord;
}

Did you ever find a fix to the problem? I’d love to try and help out, but I’m currently unable to reproduce it as you described:

Could you possibly upload a minimum reproducible example?

I worked around it. I ended up with the problem because I was trying to standardize my texture sizes, but when I let go of that it became a non-issue. The problem had to do with mipmaps blending the top edge, which was transparent, and the bottom edge which was not. I honestly don’t think it was solvable. Vagaries of floating point numbers and all that… Unfortunately, I think that’s the answer to the other question I have open, too. The GPU says, “Sorry, but repeating shaders just don’t play nice unless you have filtering set to linear”.

But don’t feel like you haven’t helped me, you have! Working on your issue gave me a new angle on a problem I was having with blending textures. I wanted a ‘hard light’ blend across two sprites, both with repeats and mip maping (or they looked like poo), and it was giving me no end of headaches. However, I just got a decent facsimile made in photoshop using only add and subtract, which means its reproduceable with render modes (just like your problem!). You helped without knowing it!

Thanks for the explanation! A lot of this is new to me, and it’s been really helpful to see how other people tackle these problems.

And I’m so glad our discussion in the other thread was helpful to you too. It was a learning experience all around!

1 Like