How to avoid seam on cube mesh ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Patate


I am trying to use a viewport to render a 3x2 cubemap around the Godot cube mesh, but a weird artifact appears on the edge. What do i need to do in order to avoid it?

The viewport (in a 3x2 resolution) has a colorrect with the following code :

void fragment(){
// UV range is now u[0:+3],v[0:2]
vec2 r_uv = UV * vec2(3, 2);
// UV now repeat u[0:+1],v[0:+1] in a 3x2 layout
vec2 t_uv = fract(r_uv);
// UV now goes u[-1:+1],v[-1:+1] in a 3x2 layout
vec2 c_uv = (t_uv - .5) * 2f;

COLOR = vec4(c_uv, 0, 1);

This is a simplified code, just splitting the texture in a 3x2 cubemap layout. Then I apply the viewport texture to a cube mesh.

Here are a few screenshot of the seam, in unshaded and wireframe :
Seam in unshaded view
Seam in wireframe view

As far as I can understand, the vertices on the edge share the same UV coordinates with an edge on another side.
If this is correct, is there a way to prevent it from happening?
Maybe overriding the way vertices read UV? Or is there a way to clamp the coordinates?
Or am i missing something?

(I am using the viewport to procedurally generate a planet map and the cube to render it (thus avoiding the distorsions arond the primitive sphere pole))

I forgot to add a screenshot of the viewport texture :
Texture rendered by the viewport (with face postion added)
EDIT2 : changed ‘primitive cube’ to ‘cube mesh’ in title and question.

:bust_in_silhouette: Reply From: Merlin1846

Try useing a cube mesh?

Yes, sorry, by primitive cube i meant cube mesh.
The exact setup is a meshInstance with a cube mesh and a material with a viewport as albedo.
(so i changed the wording of my question =) )

Patate | 2020-02-06 01:55