How to change uvs in godot?
Asked Answered
P

5

0

Ive got these duplicate billboard meshes with pixel art in 3D space and Id like to tweak the uv coordinates of them so that the pixels align. This can be done in blender like so:

I figured I could just align them perfectly in blender and then export to godot, however godot is ever so slightly off:

I think the best solution is to actually adjust the uvs in godot.
Is that possible? Can it be done in the shader? If I can adjust the uvs of indivual verticies in the shader then I could copy those adjustments back to blender and bank them into the model.

Peninsula answered 22/9, 2022 at 0:37 Comment(0)
R
0

Sorry, Godot does not include a UV editor. Probably best to do this in Blender. You could modify UVs with a shader, it depends on what you are doing. But it will likely be easier and faster (performance wise) do just author the content in Blender the way you want.

Rogovy answered 22/9, 2022 at 2:11 Comment(0)
C
0

You could use meshdatatool perhaps, but that means doing it in code, on cpu. You could create a custom shader and translate(+/-) the UV coordinates, but it's rather wasteful to go for a custom shader just for that. Best would probably still be to just go back to blender and adjust it there.

Rather I have to wonder if

Peninsula however godot is ever so slightly off:

could this be the case because you've scaled it too smol and are running into floating point precision issues?

Cervix answered 22/9, 2022 at 10:13 Comment(0)
P
0

Cervix Rogovy Thank you. Maybe something is wrong with scaling? My display scale is at 1.
If I were to do it in the shader how would I be able to change individual uvs?
I can move all uv vertices at once in the fragment shader like so:

vec2 modified_uv = UV;
modified_uv.x += uv_offset_x;
modified_uv.y += uv_offset_y;
vec4 albedo_tex = texture(texture_albedo, modified_uv);

but how would I move only the top vertex? or only the bottom vertex coordinates?

I would just use a temporary shader to figure out the perfect offset and then go back to blender and type in the offset so it would not effect performance.

Peninsula answered 22/9, 2022 at 16:26 Comment(0)
R
0

Honestly, I don't understand what's going on in that image, but it doesn't look like native resolution.

Rogovy answered 22/9, 2022 at 16:49 Comment(0)
C
0

Peninsula but how would I move only the top vertex? or only the bottom vertex coordinates?

You would have to create some kind of black and white mask in your shader to multiply your translation factor by.

Cervix answered 22/9, 2022 at 20:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.