|
Download texture_baker/README.md from Tejasf/Fast-3D: direct link, hf CLI and curl.
- Browser
- Download file 778 Bytes
-
https://huggingface.co/spaces/Tejasf/Fast-3D/resolve/main/texture_baker/README.md
- Command line
-
hf download hf://spaces/Tejasf/Fast-3D/texture_baker/README.md
-
curl -L -o README.md https://huggingface.co/spaces/Tejasf/Fast-3D/resolve/main/texture_baker/README.md
778 Bytes
A newer version of the Gradio SDK is available: 6.31.0
Texture baker
Small texture baker which rasterizes barycentric coordinates to a tensor. It also implements an interpolation module which can be used to bake attributes to textures then.
Usage
The baker can quickly bake vertex attributes to the a texture atlas based on the UV coordinates. It supports baking on the CPU and GPU.
from texture_baker import TextureBaker
mesh = ...
uv = mesh.uv # num_vertex, 2
triangle_idx = mesh.faces # num_faces, 3
vertices = mesh.vertices # num_vertex, 3
tb = TextureBaker()
# First get the barycentric coordinates
rast = tb.rasterize(
uv=uv, face_indices=triangle_idx, bake_resolution=1024
)
# Then interpolate vertex attributes
position_bake = tb.interpolate(attr=vertices, rast=rast, face_indices=triangle_idx)