0 votes


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.

in Engine by (12 points)
edited by

1 Answer

0 votes

Try useing a cube mesh?

by (561 points)

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 =) )

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.