Originally posted by polerin
View Post
Lets say that you make a material that has several hundred instructions in it. It's a pretty complicated material. It has scalars that can control the tint of the material, the scale of the normals, invert the normals, adjust the specularity and opacity, etc...
You make an instance of it and place it on your brick wall.
You then make a child instance of that one and tint it with some extra red, and make the normals more choppy so that it looks more like clay bricks.
Here is how it is handled:
The first time the material is loaded, the full (Several hundreds) instruction material is stored and loaded.
When the child instance is loaded, it only references the existing material (Already loaded) and performs only those instructions that you changed. In this case, tinting and multiplying your rg channels of your Normal. Only a very few instructions. All of the unchanged instructions (Such as your fresnel) are refrenced and not re-loaded. So they take up 0 extra space in memory.
So, what I've done is created a 'Master' material that is probably way too complicated for most people to want to use for every little thing. Then make child instances along certain branches. I have one for foliage that has certain preset options for spec and such that is common among most of my foliage. The first time a foliage mesh is loaded, it makes that change. Every other foliage mesh does not need to re-do that math because they are all child instances of my foliage instance.
Actually computing what effect something like a fresnel would have on several different shaped meshes would still require some juice, but only a fraction of the amount needed to load in all of the process of how to fresnel and following the full material and loading it all into memory(RAM or GPU).
I use a several hundred instruction count material for nearly everything in my mod and I've never found any FPS loss. Because the instruction count is way less than the piles of materials would have if the PC had to load each one of them individually. The total draw is much less as long as you use enough instances to make it worth it.
Something simpler, such as making a basic material that can be tinted and instanced would only be a few instructions to begin with, and the instances would be nearly free after that. You could make an autumn shaded forest of reds and yellows and greens and browns and only need a single material.
EDIT:
So, something like an IF to control a fresnel would always only take up the initial space in memory no matter how many times you used it or turned it on or off. Each instance that changed the output of the IF statement from what its parent instance used would re-compute that leg of instructions (And not the unused leg), but would not need to re-load it into memory. Thus making it much faster and more efficient.
Leave a comment: