QodotPlugin / qodot-plugin

(LEGACY) Quake .map support for Godot 3.x
MIT License
960 stars 70 forks source link

Godot UV and Trenchbroom texture scale missmatch #133

Closed kelo221 closed 2 years ago

kelo221 commented 2 years ago

The UV scale must be set extremely low to make the textures reasonably sized. Is this a bug or am I missing something? I'd to make the tiles not leave a small gap, but Godot does not allow diving the UV to the required accuracy. image image image image

Shfty commented 2 years ago

Don't use SpatialMaterial's UV scale for this. That applies inside the shader, and your UVs should be 'correct' long before they get to the GPU. Scaling is also a bad way to do this, since it's multiplicative and therefore painful to make accurate at extreme values.

The idiomatic way to align textures is to do it inside your map editor (ex. TrenchBroom), as map units correspond to texel units and thus allow for the pixel-perfect alignment you're looking for.

You can use the Inverse Scale Factor on QodotMap to scale the incoming map geometry on build, so you can figure out an appropriate texel density using TB units, and then alter the physical size to best suit your Godot-side implementation.