0 votes

For fun I am attempting to make a minecraft style clone and in order to get the performance right I want to create large sections of blocks as a singular mesh. Being as they would have different textures I would combine the textures into a single texture sheet / atlas texture and then specify the proper UV coordinates to give the proper texture to that face of the mesh.

When I try to use SurfaceTool.AddUv instead of selecting coordinates in the UV, it appears to be scaling the entire UV. On a test texture sheet of 4 32x32 textures resulting in a 64x64 sheet passing UVs between Vector2(0,0) and Vector2(1,1) produces the entire texture sheet. I can isolate a single cell of the sheet by using Vector2(0,0) and Vector2(0.5,0.5), but being as it seems to be scaling it is impossible to isolate any other cells in the texture sheet.

Ideally I would have figured I could pass in the X,Y coordinates like such: AddUv(new Vector2(0,0)) to AddUV(new Vector2(32,32)), but this results in a scaled output and not a selection of a part of the UV. I haven't dealt with UVs in code before so I realize I'm probably missing something or doing something wrong.

Image Example ( I realize the texture is being flipped from the resource. That is because I assigned the UVs in reverse order, but does not change the outcome described above ) :
enter image description here

in Engine by (18 points)

1 Answer

0 votes

Someone on reddit was able to answer this for me! I had a misunderstanding of how the UV coordinates were being set.

https://www.reddit.com/r/godot/comments/jf2gb7/surfacetool_adduv_not_working_as_expected/g9iha1m?utm_source=share&utm_medium=web2x&context=3

by (18 points)
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 Frequently asked questions and 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 [email protected] with your username.