Two textures one mesh

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

Two textures one mesh

Post by TheSentry » Tue Oct 30, 2012 11:56 am

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 :(
Attachments
CardSkin.png
CardSkin for all cards
CardSkin.png (12.85 KiB) Viewed 2195 times
0 x

User avatar
metaldev
Orc Shaman
Posts: 761
Joined: Thu Mar 17, 2005 11:56 pm
Location: Boston
Contact:

Re: Two textures one mesh

Post by metaldev » Tue Oct 30, 2012 2:09 pm

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.
0 x

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

Re: Two textures one mesh

Post by TheSentry » Tue Oct 30, 2012 3:31 pm

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 :)
0 x

User avatar
metaldev
Orc Shaman
Posts: 761
Joined: Thu Mar 17, 2005 11:56 pm
Location: Boston
Contact:

Re: Two textures one mesh

Post by metaldev » Tue Oct 30, 2012 3:45 pm

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.
0 x

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

Re: Two textures one mesh

Post by TheSentry » Tue Oct 30, 2012 5:15 pm

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?
0 x

User avatar
metaldev
Orc Shaman
Posts: 761
Joined: Thu Mar 17, 2005 11:56 pm
Location: Boston
Contact:

Re: Two textures one mesh

Post by metaldev » Tue Oct 30, 2012 8:00 pm

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 :)
0 x

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

Re: Two textures one mesh

Post by TheSentry » Tue Oct 30, 2012 10:15 pm

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 :(
0 x

User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2702
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 3

Re: Two textures one mesh

Post by syedhs » Thu Nov 01, 2012 12:55 am

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.
0 x
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 » Thu Nov 01, 2012 12:26 pm

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 ^^
0 x

Post Reply