#For example the documentation says that

1 messages Β· Page 1 of 1 (latest)

little hinge
#

You want to use one Material on several Objects but with different textures?

clear pewter
#

I want to know what good optimization practices are for materials in general

#

Right now, my project is early enough in development that I can change things around and make different decisions

#

But I can't find good answers on whether I should be messing around with material instancing, variant materials, or just not care at all about material optimization

#

At present

#

my game uses Material Variants of a base material

#

and the variants just change the colors of the material right now, but later might implement different textures, overlays, and color ramps and the like

#

But I can roll back that decision depending on what my options are

#

Does that make any sense at all?

loud gorge
#

Material variants are a workflow tool, not related to optimization

#

Just like prefab variants

little hinge
#

Since now, i doesnt even know that Material Variants exist.. lol!

#

Since when? πŸ˜„

loud gorge
#

2022.1.

clear pewter
#

Information is hard for me to obtain. How do Material Instances play into this?

#

I.E, using a single material, but using a script to assign per object values?

loud gorge
#

Material instances are no different from duplicating a material in the project window

clear pewter
#

Then how do you have textures for the objects in your game without just having new materials for all of them? Is it unavoidable without doing extremely esoteric things?

loud gorge
#

Basically yes

#

The purpose of "materials" is so you can have surfaces with different shader properties, such as texture or color

clear pewter
#

I have to admit, that's horrifically demoralizing, considering I've heard that materials are the devil, and if you use more than a dozen of them on screen at a time, you've already gone too far.

loud gorge
#

The reason you can't find consistent answers to optimization questions is because there are none
It's all relative to your render pipeline, build target, hardware and everything else you might be rendering

#

"Materials are the devil" may be true in some circumstances but by no means all

#

For example SRPs are much better at dealing with materials than built-in RP is

clear pewter
#

SRPs?

little hinge
#

Well, you have to do the brain-work before creating the material in Unity ^^
You want to combine different Models in one Material, if possible.
Means, if you create a bunch of boxes, you have to know this already in your 3D-Workflow and think into the future, where you want to use just one material for all of the boxes.

loud gorge
clear pewter
#

Ok, I'm using HDRP, for context.

#

Right now, how my objects in my game work is that I've got multiple materials on each object for their colors, but the objects all share materials often. So a brick material is used on all the buildings, the same wood material is used on all wood, ect.

loud gorge
#

The main thing is you won't know the performance impact of anything for certain before you implement it and profile it

clear pewter
#

I've been debating whether or not I should just bite the bullet and use baked textures per object

#

but it sounds like it's just a hopeless problem anyway in my current circumstances, if the answer really is just "If something goes wrong, bungle around and hope you can find a way to fix it."

loud gorge
#

It's fundamentally not very possible to even know what you need to optimize before you know what needs to be rendered

little hinge
loud gorge
#

There's also ways to compile shared megatextures but you can't do that before you know what textures need to go into it

#

Over time with experience you learn some tricks to avoid future headaches, but regardless you don't want to spend all your time optimizing before you have a game

clear pewter
#

So basically, I have to make the horrible mistakes and fix them later, instead of trying to avoid them in the first place, which, I'll admit, was the worst case scenario.

#

But

#

on the bright side

#

I guess this means I can just make color ramps per material

little hinge
#

But, as far as i figured out, its more important to reduce the amount of different shaders, because unity will combine drawcalls for Materials with the same shader.

clear pewter
#

What does that MEAN though?

#

What materials share shaders?

#

when does a material stop sharing shaders?

#

If I make a material, and then duplicate it and change it from red to blue

#

does that still use the same shader?

little hinge
#

Yes

#

You are using the Standard Lit shader, when you didnt change the shader

clear pewter
#

Ok, so as long as most or all of my materials are variants of a single base material with a single shader with the features I need, I'm good to go?

#

I.E, make sure I have all the qualities I need in one material, and make variants of it that just tweak the settings

loud gorge
loud gorge
clear pewter
#

Well, all the features I need in 99% of cases are all just variants of a single basic featureset

#

so I might as well make them variant materials

little hinge
loud gorge
#

Mixing different types of shaders isn't the end of the world either
How do you think games have lit shaders and particle shaders on screen at the same time?

clear pewter
#

Oh, no

#

that wasn't what I was worried about, neccecarily

#

Obviously a couple of shaders are fine

#

I'm using a fullscreen shader for my pixel palette already

#

that's why it's mostly unimportant what my materials look like beyond certain basic features

#

Any really fancy effects would just be lost under the pixels anyway

#

so all I need is a texture, a color ramp, and a screenspace dithering texture.

#

for whatever material I'm using

loud gorge
#

Your project uses SRP batching so I recommend reading how that works
Most optimization tips you can find are not really applicable to it

clear pewter
#

Either way, it sounds like the answer to my question is "do what thou will shall be the whole of the law" at this stage.

loud gorge
#

At this point you don't really know what you need to be worried about
And nobody else can tell you that either because they don't know what your project needs to show on screen

clear pewter
#

Thank you both for your help. It's a grim bunch of answers, but it is indeed answers, and I appriciate that.

little hinge
#

I were at the same point you are now a few years ago πŸ˜„

#

Its overwhelming

#

But at some point it makes "click" and you got it

clear pewter
#

Not overwhelming so much as annoying. I definitely don't like needing to ask for people's time here so often for such simple questions, but I keep running into problems that google has no answers for.

little hinge
#

For many questions there are no right answers in game-dev i think πŸ˜„