Download

Q about the cost of masked materials/shaders.

Does a masked material with almost no masking going on, cost much less than the same material with alot more masking going on?
If yes, does the masked material with almost no masking going on cost much more than an opaque material?

Edit: In my case, the masked materials would have barely any overdraw, so no need to take that into account.

You can assume that a masked material costs about the same as an opaque material that renders the same mesh with no masking, or more if early Z is important.

IF the mask operation happens very early in the shader, AND the graphics card knows how to optimize this, AND there are a lot of large, connected areas that will get masked (not drawn,) THEN a mask operation may sometimes be faster than it would be to paint all the pixels.

IF on the other hand early Z is important, AND the amount of masking is small, the masked drawing mode may be slower than opaque, and quite similar to the cost of transparency. (Masking should have the benefit of deferred shading, though, IIRC!)

Thanks, looks like a clear explanation… but i cant makes full sense of it, becuase i dont understand some things; what does early z mean? when is and isnt it important?

Well everything you put into a 3d environment has some level of cost as part of the sum total of what is currently being rendered to the selected camera and for the most part the engine handles the optimization requirements as long as you follow the procedural requirements so it can be assumed that Epic has done their part to ensure a high performance curve as far as stock feature sets goes as such as masking goes. As to the need for fit to finish goes less is always better but then you get into the habit of trading quality for what would be assumed to be a unacceptable performance hit and by extension introduce other problems by process that may or may not be of concern as to the desired final result.

So as suggested a single element may or may not impact performance but needs to be evaluated as part of the sum total of all things rendered as part of the project.

To figure out the overall performance curve is easy enough by running a profile of your work in progress.

The result is you will be able to see if an unacceptable performance hit is being generated via the use of masked materials or if the hit is being generated by an associated dependency as part of the sum total of whats being rendered.