Two textures one mesh

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
TheSentry
Gnoblar
Posts: 17
Joined: Thu Oct 04, 2012 6:40 pm

Two textures one mesh

Post by TheSentry »

Is there a way of creating a mesh using two different .png?

I want to make all 52 cards for a Blackjack game and I have:

CardSkin
(Attached)

and the faces for the 52 cards that are in one cardstack

I really don't want to have to add the cardskin to each cardface texture -.- that would be a lot of work and a lot wasted memory!

Is there a workaround which I'm not aware of?
I'm using 3dsMax 2013 with the EasyOgreExporter

In my game I have the card object and I'd love to just have different materials for the cards. That should allow me to do:

Code: Select all

m_card.m_mesh.setmaterial("Ass-Heart");
That would be great but I have no clue how to accomplish that :(
You do not have the required permissions to view the files attached to this post.
User avatar
metaldev
Orc Shaman
Posts: 761
Joined: Thu Mar 17, 2005 11:56 pm
Location: Boston
x 15

Re: Two textures one mesh

Post by metaldev »

Your game will probably run a lot faster if you use the same material for all the cards.

My approach would be:
Lay out all the card textures on 1 texture sheet, and UV all the different cards and export them as separate models, and choose them like that.

If you want to do it your way, you need to export 1 card with 2 different materials. In Ogre, you will find that the card has 2 submeshes. You can assign a material to the appropriate submesh.
TheSentry
Gnoblar
Posts: 17
Joined: Thu Oct 04, 2012 6:40 pm

Re: Two textures one mesh

Post by TheSentry »

Do you really think its better to load a 5000x5000 texture to the GPU?

And then i'd have like one material and just choose between the models not the material?
But then i'd have the same cardmesh over and over again?

But thanks i'll give it a try :)
User avatar
metaldev
Orc Shaman
Posts: 761
Joined: Thu Mar 17, 2005 11:56 pm
Location: Boston
x 15

Re: Two textures one mesh

Post by metaldev »

well, my suggestion is best for performance....
but you are right of course, there are other considerations.

I would only include into the texture the relevant parts... the image of the club, and heart, the numbers, the joker etc.... basically the designs on the texture space would be repeated with the UVs. You can probably get it to a 1024 texture by cutting up the geometry of the cards only a little bit.
TheSentry
Gnoblar
Posts: 17
Joined: Thu Oct 04, 2012 6:40 pm

Re: Two textures one mesh

Post by TheSentry »

Right thx ^^

I'd just have to work on optimizing the texture :)

EDIT: I guess the texture size has to be a power of two?
User avatar
metaldev
Orc Shaman
Posts: 761
Joined: Thu Mar 17, 2005 11:56 pm
Location: Boston
x 15

Re: Two textures one mesh

Post by metaldev »

it doesn't HAVE to be.
But it might depending on the hardware (for example some iOS devices won't even displaly non power of 2, as well as some consoles).
Regardless, it is best practice to optimize the way the video card loads the textures in by using power of 2.

good luck :)
TheSentry
Gnoblar
Posts: 17
Joined: Thu Oct 04, 2012 6:40 pm

Re: Two textures one mesh

Post by TheSentry »

Thx :)

I was just asking because I used to work in bare DirectX and there you had to get it to be a power of two ^^ same for XNA...

Wow I have a lot of UVs to do :(
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: Two textures one mesh

Post by syedhs »

I think you can just use maximum 7 textures, but there will be a need for programming for the reasons which will be stated later on in this post:-
The textures:-
1) The texture for the back of your card
2) The texture which contains the 4 card symbols (I dont know if this is the correct way to say it lol) : spade, love etc
3) The additional textures like 'king' and 'queen' card which has the picture of king or queen :D

The programming involved will be:-
1) First you have to know the coordinate of the all the symbols and also the size.
2) Depending on the card, the 3rd texture is supplied (some card doesn't need this).
3) All these information are then fed into shader which does all the rendering.

So total textures would be 1+1+probably up to 5 textures from texture (3) above. I said up to 5 because I didn't look up the cards to find all the unique background image of the cards.
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
TheSentry
Gnoblar
Posts: 17
Joined: Thu Oct 04, 2012 6:40 pm

Re: Two textures one mesh

Post by TheSentry »

Yes I also thought that it would be possible that way but I'd like to keep it really simple because its just a small project for school and I don't want to fiddle that long with getting right coords and stuff just for the cards :)

The solution with one bog texture works just fine :)

But thanks anyway I'm sure that'll help me later ^^