Multiple UVmaps & Textures on Models

Blitz3D Forums/Blitz3D Beginners Area/Multiple UVmaps & Textures on Models

Imperium(Posted 2012) [#1]
Here goes another modeling question...

Should any special consideration be made if I am working on a advanced vehicle model which has 3 separate UV maps? For example I have a separate UVmap with texture for both the body. wheels, and weapon turret.

Would this be the proper code?
atv=LoadATV( "atvvehicle.3ds" )
LoadMesh( "atvbody.tga" )
LoadMesh( "atvwheels.tga" )
LoadMesh( "atvextratga" )
;----------------------------------------

Preview:


Last edited 2012
note: Faces is actually 1757. Had some unneeded geometry hiding inside the model.

Last edited 2012


Yasha(Posted 2012) [#2]
One model has up to two UV maps. Every vertex in the model forms part of each map (I don't know offhand if .3ds supports two maps, .b3d definitely does). The only reason for using more than one map is to overlay multiple textures over the same piece of geometry, e.g. a lightmap over a chunk of environment.

As I said in the other thread, there is no such thing as a "UV map with texture". UV maps are not extricable from the model in this engine.

As for the code... the last three lines are wrong; I don't know what the LoadATV function does since it's presumably one of yours. LoadMesh loads geometry: a TGA stores image data so this is guaranteed to fail. You're also not storing the return value anywhere; B3D tries as far as possible to avoid commands that rely on context (such as what the last loaded mesh was), so no code like this will ever achieve anything except to leak memory as the handles of the newly loaded resources are immediately lost.

The correct way to use textures is as follows:

Local mesh = ...    ;However you get your mesh
Local tex = LoadTexture("myTex.png", flags)    ;Store the handle of the newly loaded resource or it will be lost!
EntityTexture mesh, tex    ;Apply the texture "tex" to the mesh "mesh"
FreeTexture tex    ;Relinquish control of the texture's memory when you're done manipulating it (it will be deleted for real when no more meshes are still using it)


...assuming you aren't going with the other strategy of applying the texture in the editor and not manipulating it in code at all, which is generally a better way unless you actually have something you need to do with the texture in code (perhaps you need to modify it for some reason).

Applying a second texture to a model will remove the first one, unless you either:

1) apply it on a new layer using the extra "index" parameter to EntityTexture. This is only advised if you actually want to blend two textures over the same piece of geometry.

2) apply it to a different surface (this can only be done using Brushes and is a little more involved).

In your case, it sounds like you really only want the one texture, since there are no areas of overlap if I understand correctly.

Last edited 2012


Imperium(Posted 2012) [#3]
My University strictly taught us how to use Unreal UDK. (for better or worse) So the way Blitz3d handles materials/textures is still very foreign to me. Additionally I'm also very disgusted with the instructors lack of expertise teaching the game design classes. (Half of what they teach us is wrong!) That aside my experience in using Maya and Unreal showed that every Mesh had to have a UV map. Otherwise how do you set the size of the texture that will wrap around the model? How will the textures even be placed properly?

I want to keep the texture resolution low for now so 512x512 is the limit. Its impossible to achieve an acceptable level of detail at that resolution using only one UV map stretched over the entire model. One reason I like exporting the UVmaps is so I can take the model into Mudbox and paint on textures.


Last edited 2012


Yasha(Posted 2012) [#4]
You have recognised correctly that every engine has a different way of representing things, which is kinda the problem here:

The point I've been trying to get across is that Blitz3D does not store UV information with texture information. UVs are an integral part of the geometry (they are vertex properties, just as XYZ are vertex properties), and can only be loaded or modified using geometry functions. They range from 0.0 to 1.0 only, wrapping around if they go outside this range (i.e. proportion of total texture size), so things like the size of the texture are not in any way connected to or represented in UV information (this system lets you e.g. swap out your 512px texture for 256 or 1024 scaled versions on-the-fly with them correctly applying themselves automatically).

I'm sorry I can't really answer the question of how to do what you want to do, because I'm terrible with things like textures (I hate all hand-generated artwork with passion: all my art is procedural! -hopefully someone else will give a better answer), but I hope I can get across that B3D simply doesn't handle this stuff in the same way as your editing tools do: the way you're used to thinking about handling textures has no parallel; talking about UV maps as a separate thing doesn't translate into a meaningful B3D concept. There is no built-in facility for handling whole maps outside of meshes.

Last edited 2012


Kryzon(Posted 2012) [#5]
I don't think you'll be able to use textures that way - it would take 3 UV channels, and we don't have access to that many.
You need to pack all that stuff into a single UV channel, preferably. Then you can leave the second UV channel for special uses like shadows, decals, textured lighting etc.

There's room for a lot of optimization.
- That first UV screen with the blue background, you probably used automated unwrapping. Try using primitive unwrapping (box, cylinder, sphere etc.) and work your way through each element\group of your mesh. This saves space and gets rid of seams (read below).
- You'd be surprised with how many UV faces you can merge\weld and get away with. You should invest more time in this - all those tires and the beams, you can weld all those faces together into single shapes for each kind of element. Everything that's duplicate can be optimized.
Those parts don't need individual detail, and you can save a lot of texture space for more important parts like the top of the ATV that needs extra detail for being so exposed.
- Have as many 'continuous' face collections as possible - that is, weld\stitch as many faces together as you can.
Every separate face adds more seams to your mesh, something you should avoid having as it makes the texture harder to paint, to look contiguous. It is very annoying.
Artists tend to purposely leave seams running through more hidden parts of meshes, like below or at exactly the sides, following the corners. It's kinda hard to explain by text, but you should try to leave the seams running through where the "material" in real life would have seams as well (say, the edges of that ATV's hull). In human meshes you can leave seams running below the arms and through the insides of the legs - parts you don't have that much focus on.

You can find some very friendly mapping tutorials at Psionic's:
http://www.psionic.pwp.blueyonder.co.uk/tutorials/lowpoly/zuvm.html
http://www.psionic.pwp.blueyonder.co.uk/tutorials/lowpoly/zskin.html
http://www.psionic.pwp.blueyonder.co.uk/tutorials/lowpoly/guv1.html
http://www.psionic3d.co.uk/?page_id=171

PS: In reality -and for my surprise- Direct3D and\or OpenGL, under fixed-function, allow you to have a total of 8 UV channels per mesh.
I'm assuming that for compatibility with older cards Blitz3D went with just the 2.


Imperium(Posted 2012) [#6]
I definitely abused the automatic mapping tool lol. The problem when I start doing a UV manually I take forever to perfect it. Right now my entire game concept is in the alpha stage so everything is just a quick mock up. Basically I'm seeing how fast I can get thinks to work the way I want in Blitz3d and later tweak the assets properly. Normally when I UVmap a model I do the front, sides, top, then bottom. It is a pain at times fighting seams but practice makes perfect. Now it's easy to see my idea of using multiple UVs is the wrong approach and not applicable for Blitz3d.

You've been a great help to me Yasha! No worries! Thanks for those links Kryzon they will certainly prove useful without me needing to crack open one of my auto-desk bibles.

Just stumbled across this:
RoadKill UV
http://www.pullin-shapes.co.uk/page8.htm
http://www.roadkillpro.com/Roadkill_Professional_Maya_Manual.pdf

Last edited 2012


Matty(Posted 2012) [#7]
Actually they're not quite right.

A model, or entity can be made up of multiple meshes each with its own texture and uv map.

Yes it is true that blitz can only have two UV coordinate sets for a single surface (a collection of vertices that share brush properties).

But - in a single model you can have separate meshes with their own brush/texture properties.

So for example when you do loadmesh("mymesh.b3d") that model could have a wheel with its own uv and texture information, an interior with its own texture, a body with its own texture - and all of this would take a single UV coordinate set on each mesh within the model.

I think there is some amount of confusion and accidental misinformation going on here. Multiple uv coordinate sets for a single surface is really used for blending purposes - often for example with lightmaps for environments or detail maps.

Perhaps I can explain the concept a little more using standard blitz3d terminology:

The command loadmesh returns a handle to an entity.
That entity is of type "mesh" which may be made up of 1 to n surfaces.
A surface is a collection of vertices and triangles which share a brush. A brush can have up to 8 textures, color, shininess, and these textures are applied one on top of the other with blendmodes of multiply, additive, multiplyx2 and alpha. These 8 textures may belong to one of two UV coordinate sets.

Just to repeat, the brush - which contains texturing information, is applied to a surface. A surface is a collection of vertices and triangles. And a surface, or multiple surfaces, belong to an entity of type mesh.

Now the command loadanimmesh does the same thing - except that it allows a model which has been exported in b3d format with multiple mesh, bone and pivot entities to be accessed such that the individual meshes, bones and pivots are accessible from within blitz3d.

So for example depending on how your vehicle is designed in your modeling app -

if loadmesh is used:

The model is loaded as a single entity. There may be more than one surface, with a brush attached for each. The wheels may belong to a single surface with their own texture and brush properties. The body may belong to a single surface with their own texture and brush properties, The turret may belong to a single surface with its own texture and brush properties. All of this will belong to a single entity, and be handled by a reference to a single entity.

if loadanimmesh is used:

The model is loaded as multiple entities accessible with the getchildren command. So for example the body may be the root entity with its own surface and brush properties. The wheels may well be individual entities which can be manipulated (once the child entity is retrieved using getchildren). The turret may be an individual entity as well. All the brush / surface information will be related to the individual entities in this case.

Hope that is a little clearer.


Imperium(Posted 2012) [#8]
Wow, thanks for taking the time to iron out the details. As soon as I finish reworking my models I will take another stab at this.

The design is somewhat reminiscent of the APC in Aliens. But I fear it looks more like the new bat mobile. Despite the fortified look the vehicles intended purpose is mainly exploration. Hence the crash rails offering added protection during the event of a roll over.

Aliens APC

Last edited 2012


RemiD(Posted 2012) [#9]
I see there is also a command "BrushTexture()"

Which means you can probably use 1 mesh with several surfaces, 1 brush with 1 texture on each surface.
With this approach, you can define the UV coordinates of each vertex of each surface as you want in your UVMapping software, and then retrieve each surface in Blitz3d with GetSurface(), and then use LoadTexture(), BrushTexture(), PaintSurface() to put the correct texture on the correct surface.

But to do this you have to use a UVMapping software that allows you to hide/show the UVMapped vertices by surface, else it will be really confusing.

I have not tried it but given the description of these commands, it should work.

Last edited 2012