#For example the documentation says that
1 messages Β· Page 1 of 1 (latest)
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?
Material variants are a workflow tool, not related to optimization
Just like prefab variants
2022.1.
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?
Material instances are no different from duplicating a material in the project window
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?
Basically yes
The purpose of "materials" is so you can have surfaces with different shader properties, such as texture or color
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.
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
SRPs?
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.
Scriptable Render Pipelines such as URP and HDRP
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.
The main thing is you won't know the performance impact of anything for certain before you implement it and profile it
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."
It's fundamentally not very possible to even know what you need to optimize before you know what needs to be rendered
Thats a thing you have to figure out on your own.
If your style fits well with tiling materials, you are fine with creating like 20 materials and use them all over again and again.
If you do like a stylized handpainted style like i do, you want to combine as many Objects as possible in one Material / Texture.
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
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
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.
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?
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
Basically
With limited experience you can't accurately identify what mistakes are the "horrible" ones and you often focus on fixing the wrong things while even more severe ones slip by
That's why profiling is important
They don't have to be variants of a material but that's the gist of it
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
This depends on what changes you do. You can use the same material and just change the color via script at runtime.
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?
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
Your project uses SRP batching so I recommend reading how that works
Most optimization tips you can find are not really applicable to it
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.
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
Thank you both for your help. It's a grim bunch of answers, but it is indeed answers, and I appriciate that.
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
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.
For many questions there are no right answers in game-dev i think π