I know I may be asking too much in the era of deferred rendering and compiled shaders, but maybe there’s some way to fade out expired entities like in older engines with just some code, rather than having to edit every single material involved.
If you want a smooth transition, I’d add a scala param node to the material, connect it to the opacity and interpolate it via code.
I’m not aware of a way of doing this without manipulating the material.
Another option is to use screen-door fade in the material and just set the MaxDrawDistance on the mesh component to whatever distance you’d like to fade it out.
Thanks for the rundown, but it doesn’t seem likely I’ll bother with adding fades if materials are the only way, there’s maybe 40-50 enemies that I’m looking at and it’s already enough trouble just to hook up their models and death animations and anim trees and all that other boilerplate.
But if they are a material instance constant for all of the enemyes, than its all going to be driven by one shader.
By the way, i am interesred too in a distance based fade for shader example something like the fade in left 4 dead.
Playing with the materials is the only way to do it. But don’t use transparent materials. That will just introduce all kinds of sorting issues and extra rendering instructions. Like Coldscooter recommended, use screen-door fade. Or make a masked material and make your own disappearing effect. And if you don’t do it distance-based, say if you want to make dead bodies disintegrate or something like that, then each pawn should have its own material instance. It wouldn’t be too hard to make all of your enemies disappear the same way if they’re all the same pawn child class and if their meshes all use material instances from the same base material.