How to control orientation and scale of texture maps?

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

I need to set the albedo texture of certain objects in my project at runtime - sort of like skinning an object or customizable billboards. The actual objects are simply square tiles with beveled edges that I need to stretch my user selected images to cover edge to edge, and while I can rotate the tiles after the image is applied it would be nice to have the option of applying the texture in the required orientation to start with.

How are texture maps aligned and scaled in godot?

This depends on the UV-mapping of the mesh (tile) you are using. Nothing special about this in Godot. You usually control the UV mapping in the 3D editor. But you can also edit UVs using the MeshDataTool (remove a surface, edit it and add it again):
MeshDataTool — Godot Engine (stable) documentation in English

This can be helpful if you want to automatically assign UVs for certain materials.
Each vertice has one or multiple UVs which index (from 0…1) the x/y position of that point in the texture.

For vertices which have multiple UVs (i.e. adjacent materials or “loops”) you usually have multiple vertices on the same place (or in different surfaces).

Or you can write some shader and do the texture lookup depending on your own criteria in the fragment shader.

SpatialMaterial also allows a limited control over UV mapping via uv1_offset and uv1_scale. Maybe it’ll suffice to put negative values in parts of the scale.

For albedo it’ll usually be uv1. UV2 are for other purposes like lighting/ao/emission or custom use in shaders.

wombatstampede | 2020-03-23 12:07