UV Mapping with SurfaceTool

kis3lorikis3lori Posts: 7Member

How do I go about adding per-face UV coordinates using the SurfaceTool?
I get the add_uv adds the UV coordinate to the next vertex. But what if two sides linked to a vertex need to have completely different UV coordinates?

Comments

  • TwistedTwiglegTwistedTwigleg Posts: 1,715Admin

    I think in Godot you have to have multiple vertices at the same position if you want to have different UV coordinates on different faces. Almost everything I can find on Google, searching Godot specific or not, points to duplicating the vertices as the solution to having adjacent faces with difference UV coordinates.

    There is a way to have per-face UV coordinates, as software like Blender does this, but unfortunately I do not know enough to about stuff like this to guess.
    (Side note: Welcome to the forums)

  • wombatstampedewombatstampede Posts: 149Member
    edited October 7

    Yes, absolutely right. If you i.e. unwrap UVs (here: follow quads) of a cube in blender then you'll see some "identical" vertices on different locations in the UV-Map (when viewed in the UV editor). These need to be duplicated. Indexed vertices won't help as you can't attach an UV to the index (only to the vertex).

    There exists (among other attributes) also a UV2. One might be tempted to try this out. But #1: you need to write your own shader to use it and #2: UV2 might also be used by other features (like baked shadows/lighting).

    Depending on your needs own shaders might help in this case anyway if there's a way to calculate the required UVs by other means.

  • kis3lorikis3lori Posts: 7Member

    Ok, I think I got it.

    This means a bit more work on my side with vertices but at least I know how to do it.
    I was thinking that since Blender can do this it also exports it in some manner but maybe at export blender splits the vertices as well.

    I could also make my own shaders but for this case I would like to keep using the SpatialMaterial.
    This will allow me to easily use more complex materials (with normal map, displacement map, etc.)

    Thank you very much!

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file