[SOLVED] Material State Changes

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
User avatar
BrightBit
Gremlin
Posts: 158
Joined: Sat Feb 27, 2010 9:55 pm
x 4
Contact:

[SOLVED] Material State Changes

Post by BrightBit »

Hello everyone,

do you guys know Runescape? The models of this browser game are coloured entirely by their material attributes. The artists didn't use textures.

I learned that state changes (in relation to textures, materials, shaders, etc.) can be a performance issue. I understand that changing a whole texture takes time but I don't understand that changing some floats for e.g. the diffuse material attribute would be an impact on performance. So my question is:

Even if a model consists out of for instance 15 different materials (and all these materials got no texture), would that really be that expensive?


Greetings
BrightBit

Edit: Removed image.
Last edited by BrightBit on Tue Sep 07, 2010 6:12 pm, edited 2 times in total.
"Yeah so if you ever need info about anyone [...] Just ask. [...] They 'trust me'. Dumb fucks." - Mark Zuckerberg (Facebook CEO)
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: Material State Changes

Post by betajaen »

Couldn't you have a colour per vertex? If you do it that, with one material, one sub-mesh, it's one batch.
User avatar
BrightBit
Gremlin
Posts: 158
Joined: Sat Feb 27, 2010 9:55 pm
x 4
Contact:

Re: Material State Changes

Post by BrightBit »

Thanks for the fast answer. Are vertex colours also supported on older machines? Especially on computers with graphic cards without programmable shaders?

Nevertheless I'm still curious about the first question. Why does it take that much time for "small" material changes?
"Yeah so if you ever need info about anyone [...] Just ask. [...] They 'trust me'. Dumb fucks." - Mark Zuckerberg (Facebook CEO)
User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
x 3
Contact:

Re: Material State Changes

Post by Praetor »

Vertex colors will be supported on pretty much any machine you can get now, or could get in recent years.

As for the question you had. State changes mean communication to the video card. Since the GPU is a separate from the CPU the communication must go through a bus. The driver can help by being clever with how it sends instructions over, but what it means is each time you tell the GPU to change something to prepare for a draw, commands have to be sent from one component of your computer to another. This is essentially why state changes are "slow."
Game Development, Engine Development, Porting
http://www.darkwindmedia.com
User avatar
_tommo_
Gnoll
Posts: 677
Joined: Tue Sep 19, 2006 6:09 pm
x 5
Contact:

Re: Material State Changes

Post by _tommo_ »

BrightBit wrote:Thanks for the fast answer. Are vertex colours also supported on older machines? Especially on computers with graphic cards without programmable shaders?

Nevertheless I'm still curious about the first question. Why does it take that much time for "small" material changes?
Mario in Mario64 was entirely coloured with vertex colours.
This to say, that vertex colours are supported even where textures aren't ;)
They are also much faster because the vertex data is "already there", while textures have to be explicitly fetched from memory.
OverMindGames Blog
IndieVault.it: Il nuovo portale italiano su Game Dev & Indie Games
User avatar
BrightBit
Gremlin
Posts: 158
Joined: Sat Feb 27, 2010 9:55 pm
x 4
Contact:

Re: Material State Changes

Post by BrightBit »

Thank you guys. Especially Praetor for the answer on state changes.
"Yeah so if you ever need info about anyone [...] Just ask. [...] They 'trust me'. Dumb fucks." - Mark Zuckerberg (Facebook CEO)
Post Reply