Materials - How many samples/instructions is too many? - State of the art


More idle curiosity but when I pick apart various projects I can see some materials, their sample counts get into the 30’s, 40’s, etc. For sure things look great; you can take apart the paragon stuff and see materials with 10’s on the VS and many 10’s on the PS.

How much is too much do people find? What’s a ‘generally acceptable’ amount of samples on a good/decent material? I know I can make mine look as good as I want them too and I’m not too-too concerned with performance since I’m the sort that is always looking to scrounge an instruction or too, but moreso I’m curious what other’s run as their ‘mainline’ or what their state of the art is.

I sometimes wonder if I use too-few samples and could have opportunity to add a few more as I feel I can do a lot with just a few. I tend towards ‘a bit of math goes a long way’ but then I also recall some feedback I read once from Epic devs that actually push using samples (vs samplers!) over a little-bit-o’-math.

Thoughts, feedback, direction, suggestions? What have others experiences been like?

EDIT: for reference: Current state of the art - Album on Imgur

How much is too much? Does it show white on the material complexity view, if so, its pretty expensive to run, if its red, you might want to lighten it a touch but its fine, if its dark green, its good, if its light green, its running pretty fast,

LOL, I know the shader-view but that is primarily instruction count. I can gauge performance in other ways too as well as relative FPS, I was more asking just what’s actually done from a practical experience.

If your asking whats actually done, it varies extremely, from thousands in some rare cases, to just 110~ in basic deferred shaders, simply, test it, or go as low as possible to achieve the effect you want.

Not talking instruction-count, talking texture samples. Did you read what I wrote?

“their sample counts get into the 30’s, 40’s, etc. For sure things look great; you can take apart the paragon stuff and see materials with 10’s on the VS and many 10’s on the PS.”

More looking at texture-samples but I get the instruction-count.

As Sjoerd De Jong says in one of his courses on the Unreal Engine learning platform, around 100-200 is acceptable. The fact is that the more pixels your shader cover, the more is expensive. So it’s not only the instructions count, but the time that the shader is invoked matter as well.

Anyway, giving numbers in these situations is always a “it depends on” thing, even for texture samples.

Performance of a shader is not a direct function of instruction count or number of texture fetches. You can take 120 texture samples in vertex shader and 240 in pixel shader and still be well within modest budgets. It is all relative and should be viewed on per case basis. Regarding imgur link, I can definitely say that what is shown on the pictures is too heavy on shader complexity, as judged versus quality of visuals it delivers.

So if I read your response correctly, this line:

Texture Lookups (Est.): VS(12), PS(37)

Would be able to have VS(1xx), PS(2xx) in a usable material? To level-set, where would I go to see a material such as that in action? I’m not trying to sound snarky or trite, but everything I looked at so far had far less; picking apart samples from Paragon, other content provided by the community, as well as marketplace products. I’ve not seen anything near the counts you quote; where is this in practice so I could see/appreciate what I could expect (bang/buck).

I’m a noodler/neophyte, I’m not expecting AAA work as an indie dev, but I did want to explore what one might reasonably expect from something put into practice…

… just a tip.
if you want to quickly find out what Not to do in materials, make yourself a water material on a mesh with base quads set 1m apart.
Start off with summing basic sine functions, transition into implementing gerstner.

for sake of practicality experiment on default lit, transition to translucent only after you are happy and need to fix the look and bench performance.

You can literally spend well over 3 months trying to get water to look just right and balancing performance.
I believe it really teaches what not to do, since you can get drops of up to 60FPS from adding 1 instruction into the pixel shader… :stuck_out_tongue:

240 and 120 is pretty low. If your game is hyper-minimalistic you can get away with 800 instruction shaders, and on forward rendering that amount is to be expected.

1 math instruction dropping 60 frames? The only time i could imagine that happening is in ridiculous, unusable resolutions like 32K with 4X SSAA, or with 200 layers of overdraw, and if you have 200 layers of overdraw, you may want to do something slightly different than what you are doing currently.

No need to go that far. Transparency at 4k can do this if you try and modify every pizel on screen too…

Count-wise, yeah, trying to keep it under 500 across the board. My transparent water maxxed out around 700 (my upper budget). However, the question was about samples in particular; seems to be getting lost in the conversation.

[USER=“3140864”]MostHost LA[/USER] → I did the water thing for 3 months, so I hear ya. More just making sure “I still got 120fps? yep! I’m good (so far)…”. Thanks again for the input.

Yep, you did read it correct. You can be fine with hundreds of texture fetches and you can be off with just 1.

So, to ask the question (lol) where might I see what such an investment might look like?

Granted, I’m not expecting to be a master material maker… I’ve taken my fair share of tutorials, taken apart a decent amount of the content Epic provides, things on the market like Brushify but for sake of level-setting, where is something that expensive in practice? Not to disbelieve but to get a sense of bang/buck?

Things like Brushify use the landscape layer system and come out ~100 instructions less than what I built but I end up with much less FPS overall. Based on suggestions here, I ditched the landscape layer system and use material-blends which ends up on more samplers/instructions but a massive performance improvement (really epic? how’s that work)…

My basic setup is mostly a triplanar+triplanar detail to a slope-sensitive XY mapped material+detail textures. Just that gets me up to 20 samples on the PS. Add in a few other paintable layers and some grass-map maths and you get what you see. It’s more functional in terms of world-building vs looks as I was attempting to keep samplers as low as possible. Now, I hear 100’s and I wonder where I, well not went wrong, but went too conservative or maybe my math is not proper/efficient. So, again, not to suggest disbelieve but more Holy-Moly, what does 100’s of samples actually add up to?

My guess is that the landscape blends use more expensive operations all the time even if not actually in use.
like the issue where an IF statement compiles and calculates both of the IF statement branches all the time even if only one is in use.
Also, height blending is obviously more expensive then alpha blend.
The way I blend the layers manually is closer to an alpha blend (which you can manually pass through the heightmap like they probably do for the node).
That said, you can use less samples and get decent performance even with the layer blend / height blend.

its more about balance when it comes to the landscape.

As far as “what can carry that many instructions” anything that needs to look good without having a need for performance.
Essentially single frame renders and/or cinematics that can be rendered frame by frame and sped up after all frames are rendered.

You know, you have certainly seen it. Normally it is done when you are an AAA company, showcase a game at GDC, but then ship out Duck Hunt :stuck_out_tongue:

At the end of the day if it looks like I want, does what I want, and runs performant enough, it’s a success.

Insofar as the landscape-node logic, my guess was much the same; that it incurs close-to-or-maximum cost all the time and you can ‘just’ load it up w/layers w/o apparent cumulative cost, but it’s more up front vs what I am actually throwing at it. The landscape nodes also seem to ‘hide’ instruction count given they cannot assume a value for a given layer-alpha so I guessing mine is more true-to-life; lol.

Everyone, thanks for the input.