Load scene (OBJ), textures and wrap modes

I’m loading scenes as OBJ files with large texture maps, two observations

  1. There does not seem any way to clamp textures rather than the default wrap of textures. This basically stops me from abutting adjacent texture maps due to colour interpolation for texture coordinates of 0 (or 1) with the texture at 1 (or 0).

  2. OBJ does not put limits on the size of textures. Every program I’ve tried (Maya, MeshLab, Blender, Nira) allows me load 32768 pixel textures as jpegs. The highest I can go in Vuo (at least as powers of 2) is 16384. I’m prepared to accept that 32768 is not allowed for some reason, but it should be documented.

The attached is 4 pieces, the texture size of the top-left corner is 32768, top-right is 16384, bottom half is 8K and 4K.

Vuo’s Fetch Scene node defaults to repeating textures since that’s what 3D mesh authors typically expect, but the Change Wrap Mode node can change it to clamp or mirror.

The texture size limit is imposed by the GPU (not Vuo) — see OpenGL Driver Monitor > Monitors > Renderer Info > OpenGL Limits > Textures > MAX_TEXTURE_SIZE; for OpenGL it’s typically 16384 but may be less on some GPUs; see also Metal Feature Set Tables > Maximum 2D texture width and height.

Some applications automatically scale down textures that are larger than the GPU allows. Currently Vuo doesn’t do that; instead it refuses to load such textures. (If you’re interested in that, or other ways of processing textures beyond the GPU limits, feel free to create a feature request.)

We’ll look into adding information on texture size limits to the documentation.

@pbourke emailed:

Thanks, and yes I was aware of gpu texture limits.

Regarding clamp or wrap, I am aware of the Change Wrap Mode node but that can’t be applied to loaded OBJ files with textures, can it?

It can — here’s an example. For the purpose of demonstration, the cube .obj file has texture coordinates ranging from -0.5 to 1.5 (instead of the typical 0 to 1). The composition retextures the cube using each of Change Wrap Mode’s 4 different modes.

cube-texturecoordinates.zip (2.42 KB)

This has bitten me again and I don’t think the above suggestion helps, apologies if I didn’t understand the proposed solution.

The attached composition views an OBJ file with 4 sections each with their own texture. I have zoomed into one shared edge pair. The texture coordinates are created so that the transitions will be seamless, assuming clamping. But with wrapping the edge of each piece is averaged with the opposite edge of the same piece resulting in the observed seam. I don’t believe there are easy ways to solve this without having clamping support.

I attach also two images showing the result of wrapping and clamping, in software that allows one to switch between the two. This is mainly to prove that my texture coordinates have been created correctly.

You said “3D mesh authors typically expect” … not sure I agree, certainly not in the case of this author. :-)

clamp test.zip (3.08 MB)

To change from wrapping (the default) to clamping, you’ll need to pass each texture through Change Wrap Mode. Since the textures are loaded along with the .obj by Fetch Scene, that means reloading the textures from the image files, changing their wrap modes, and re-applying them to the scene object. The attached composition demonstrates.

clamp_test2.zip (3.08 MB)

Ahhhh, excellent!