Home Unreal Engine

How many materials are too many? (Or too complex)

Hey all,

I'm putting together a little project where all the walls are based off a master material I put together so I can just use a few textures for the different walls then vertex paint different details so they don't look repetitive. In that material I also set a lot of control for me so I can change different things (blending, spec, norm, color, bump offset changes, etc).

So I have my master material and I'm trying to figure out how many material instances would be too many. Is it as bad if it's all based on one master material or is calling each one going to hit no matter what?

Also, it shows as red under the shader complexity. I'm not sure how worried about that I should be since the master material is pretty customizable, but then I see everything in the level as red so I thought I'd ask.

Replies

  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Generally speaking, the less you have the better it is, that's the only rule to games honestly.

    Master materials are a double edged swords, they're heavy since you put alot of stuff into it and try to squeeze out as much as you can from a single call, but at the same time, it's cheaper then having mutiple 'different' base materials for compilation reasons.

    Material instances are cheap, the only real weight to them (outside of the base material) is the variables in the instance, if you have alot of switches, etc. But in the end, they're just reference files.

    Since I don't know how complex your shader is, the red doesn't help. The color will generally indicate that 'material x' has passed a certain instruction weight, I think around 256 instructions (half of what you're allowed in DX9 currently) or some number like that.
  • mister_s
    Options
    Offline / Send Message
    Ace-Angel wrote: »
    Generally speaking, the less you have the better it is, that's the only rule to games honestly.

    Master materials are a double edged swords, they're heavy since you put alot of stuff into it and try to squeeze out as much as you can from a single call, but at the same time, it's cheaper then having mutiple 'different' base materials for compilation reasons.

    Material instances are cheap, the only real weight to them (outside of the base material) is the variables in the instance, if you have alot of switches, etc. But in the end, they're just reference files.

    Since I don't know how complex your shader is, the red doesn't help. The color will generally indicate that 'material x' has passed a certain instruction weight, I think around 256 instructions (half of what you're allowed in DX9 currently) or some number like that.

    Yeah, that's the only impression I'm operating under is less is better. Do you (or anyone else who sees this) happen to have any reference material to these types of questions? The UDN is fine, but it's kind of generalized or lacking at times, that or I'm not looking in the right places.

    As far as my shader goes, it's pretty complex. I mean, it isn't a technical feat of brilliance, but it is really customizable so I can make different walls different colors and do different things based on a mixed map I made (scratches, dust, paint, etc).

    I mean, it runs fine for me, but I want to learn good practice the more in depth I get into developing.
  • mAlkAv!An
    Options
    Offline / Send Message
    mAlkAv!An polycounter lvl 5
    Complex master materials can have a noticeable impact on performance. One thing to keep in mind is to never apply the master material itself to any mesh but only its instances.
    Multiple smaller materials likely gonna give your more FPS but need more memory (shader memory, package size), in the end it depends on the the amount of materials/instances.
    What's the size (mb wise) of your current master material?
  • mister_s
    Options
    Offline / Send Message
    My current master is 122 instructions I believe. I have most of the tree set up so I can configure everything on the fly. I do have some Booleans for certain things like bump offset in case I don't need it that drops the instructions down a bit.

    I figured I could use essentially 3 wall textures and a mix map and get more out of it that way than calling in 15 versions of the same textures.

    So my set up is around 20-30 generic modular pieces I've made to do the set design and I can use them as I see fit with the materials.

    Does that sound like an efficient way to work?

    I could probably kill a few instructions, but since this is for a school project and it runs fine for me at the momment I won't mess with it due to time constraints. Like I said, though, I'd like to at least learn a bit more about how UDK handles resources so I can avoid doing anything ridiculous.
  • mister_s
    Options
    Offline / Send Message
    Sorry, apparently I can't read. You asked for size in MB. It's 22MB.
  • Hourences
    Options
    Offline / Send Message
    Hourences polycounter lvl 18
    Size includes textures though, and those textures may be used elsewhere as well etc.

    If you use switches you can disable part of the master material to save instructions.

    122 instructions is doable and not too over the top. I would stick to what you have and go work for workflow speed in this case.
  • cptSwing
    Options
    Offline / Send Message
    cptSwing polycounter lvl 11
    Aren't switches themselves costly though? Ah, t'is complicated!
  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    cptSwing wrote: »
    Aren't switches themselves costly though? Ah, t'is complicated!

    Switches can be a problem in a large project as every switch creates a new shader when the content is cooked. This can cause your shader cache to become overly large in memory which breaks your memory budget.
Sign In or Register to comment.