Texturing individual faces on a single model

It seems like this is going to be harder than I had assumed! I’ve looked over the ‘ground multi-texturing’ thread down below (that’s essentially my goal) but I think I need something a little more precise than that.

I’m reading a model format which pairs up textures with individual faces (not vertexes or entire meshes like Panda3D seems to prefer). For example each poly is stored like this:

Texture/Vertex/Vertex/Vertex (one row for each triangle)

Ideally I’d do the same in P3d - apply a jpg texture to each face (smoothing/blending isn’t important), but this seems problematic after reading through the texturing part of the manual. I’m not sure multi-texturing will cut it because I have 5-10 different textures I’ll need to apply, and I’ve read that there’s a hardware limit to that technique (may be other issues too since the textures can change per-face).

So what are my options? This doesn’t need to look pretty as it’s not for a game (rather a game mod-editor). Basically I need a way to visually distinguish which “texture” each face has applied to it (this can be changed by the user in fact) and non-visually re-save the file format pairing up textures with faces. Whew!

Could/should I use shaders instead? Any ideas?

The EGG format does allow assigning texture(s) per-face.
In the EGG file it looks like this:

<Polygon> {
  <TRef> { Shadow_Map_01.png }
  <TRef> { briefcase.png }
  <VertexRef> { 68 69 70 71 <Ref> { SHP-box_01.geo-ORG } }
}

Are you wanting to change the texture assignment at runtime?

Yes (textures can be re-assigned at run time), and also I’m loading the mesh manually (procedurally) at run time. That part is done, now I need to determine a good way of indicating face texture types to the user (and later be able to save them to disk).

Basically this is a highly specialized 3d modeler (map editor). (Textures and vertex positions should be editable to reshape the model.)

Hmm - if the egg format allows this, that is encouraging. There must be some procedural way of doing this, just haven’t located it yet.

Thanks

Found a solution that’ll do for now. Basically I had to create unique vertexes for every face (allowing me to color them all the same for each face), so I have solid, color-coded faces. Looks pretty cool but I’ll probably want to actually texture these polys at some point.

To do this I imagine I’ll need to apply appropriate uv texture coords to each face’s set of vertices? Meh, doesn’t sound too difficult… :slight_smile: Need to read up on texturing more…

For the record, you can’t apply a different texture to each face of a mesh, unless you split the different faces out into their own meshes. This is exactly what the egg loader does when you define an egg file with a different texture for each face.

As long as you do this at load time (e.g. via an egg file), it is easy to do.

David

Ahh, I see. That’ll be an issue if I use real textures, I’m working with about 20-25k faces here. I have to be able to load and save at run time as well, otherwise the whole thing is kinda pointless.

Solid coloring like I have is probably good enough but I’m not 100% sure yet.

I know having 20,000 meshes would kill any hardware out there, but does that rule only apply when displaying a part of those meshes, or does it apply when they are merely “in” the 3d renderer tree (even if not visible in the camera)?

There has to be a way to do this though, this tool is for a game which renders terrain just like I’ve described with 20,000 faces…

The way I understand it all faces with the same textures would be part of the same mesh. So you might have 50 different textures (therefore 50 meshes), and the faces are divided amongst those meshes depending on which texture is assigned to them.

Illustration for the confused. Yeah, a lot of triangles. I guess this works but a “textured mode” would be nice too.

The rule applies to the meshes that are actually sent to the graphics card in any given frame, which is generally only those which are in front of the camera (or whose bounding volume extends partially in front of the camera). Still, if you have 20,000 individual objects, there are probably going to be more than a few hundred visible at any given time; and the general target is 300-600 visible objects.

This is true if they are loaded that way from the beginning (e.g. if they were all part of one mesh in the egg file, with different textures on different faces). In this case the egg loader will split them out into the minimum number of objects, which will be one object per unique texture. But this makes it impossible to reassign textures at runtime. It is also true if you are able to flatten them together at runtime, e.g. with a flattenStrong() call, which makes runtime reassignment possible, but clumsy.

Many of your design issues sound similar to a problem already explored in considerable depth in this thread.

David

This thought did occur to me (although it might make my job much harder when I start modifying things), but can you have a mesh covering areas like what’s above? Some of the faces would be completely separate from the other faces.

Long thread! I’ll read through it, thanks!

In your example you might be best just applying one texture to the whole mesh, and modifying the pixels in the texture as you go.

David

If you are able to modify the UVs (texture coordinates) the same way you are setting the colours, then you could put all of your textures into a large texture sheet and move the UVs to the desired sample on the texture sheet.

That’d be great if it works, that’s what I was talking about above, mapping texture coords on a single texture to vertices. I’ve much more experience with modeling than with texturing so I wasn’t even sure if texturing could work like that. Got some reading to do now. :slight_smile:

Thanks again,

Based on some quick tests it seems that single-texture solution will work. Going to put off actually implementing it and just go with solid color for now, so I can move to other stuff. :slight_smile: