Just wanted to know if we need to texture map the texture on the model with code or is it better to just import a model with textures already on him? (considering its even possible)

Dani AI

Generated

Short answer to : you do the UV unwrapping and paint/bake the textures in a 3D tool (Blender/Maya/etc.), export the mesh with its UVs, and then either let your engine import the model+textures or write small loader code to bind the textures at runtime. As pointed out, the mesh carries texture coordinates — you normally do not manually hard-code per-vertex UVs inside the game.

Typical, practical workflow:

  1. Unwrap the mesh and create your diffuse/normal/roughness (or full PBR) maps in your DCC tool. Bake where necessary.
  2. Export the model (OBJ/FBX/glTF — note some formats embed textures, some reference external files). Make sure the exporter includes UVs and tangents if you use normal maps.
  3. In the engine or your loader, import the model, load the image files, create GPU textures, assign them to the material/shader, and draw using the mesh UV attributes.

Minimal runtime outline (pseudo-code):

texture = LoadImage("hero_diffuse.png")
UploadToGPU(texture)
shader.bind()
shader.setInt("u_diffuseSampler", 0)
BindTextureUnit(0, texture)
DrawMesh(mesh)   // mesh must carry texcoords

Quick troubleshooting tips:

  • If the texture is stretched or wrong: check the model’s UVs and exporter settings.
  • If nothing shows: confirm the model actually contains texcoords and the material references the correct UV set.
  • Normal map issues often come from missing tangents or wrong space (tangent vs object).
  • For performance use atlases, mipmaps and GPU-compressed textures; for modern asset pipelines consider glTF for predictable exports.

If you use Unity/Unreal, the engine handles most of this; for a custom renderer you must ensure exported UVs and any additional maps (tangents, multiple UV sets) are present and loaded.

You load the model, which usually includes values for the vertex coordinates, the normal vectors, the texture coordinates, and the color values, associate to each vertex. Then, you load the texture corresponding to the model, and you apply both. You never hard-code anything, you write code to load everything from files and apply them (usually with vertex-buffer functions).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.