I have a material used as a post-process to make everything farther than X distance turn black, while nearby objects are rendered correctly (attached is an image showing how the material is set up).
The issue is that when I add a Niagara effect, the black area also overwrites the Niagara effects (attached are two images, one with the post-process and one without, to better explain the problem).
this is the niagara particle that is placed in front of the player
well, it seems to me that the niagara effect is not writing to the depth buffer i think.
mostly because itâs transparent, but maybe because itâs a particle system.
maybe because itâs translucent. those tiny dots seems to be visible ok.
try changing the material on the bluish flare and the circle at the bottom to be masked opaque.
then use âDitherTemporalAAâ to connect to the OpacityMask.
that will allow you to fake translucency while being opaque.
itâs a trick but maybe it helps.
yes dither is noisy.
dithertemporalaa works in tandem with temporalaa to hide some of that noise. but it is still noisy.
unfortunately i donât really know how to fix that issue.
i donât think you can make translucent materials write to the depth buffer.
i think you might want to rework your post process. since youâre going to encounter that issue with all translucent materials. (that means you canât have anything translucent in the game).
now thatâs a good question. and a good mindset.
iâm not sure, but it comes to mind try using a volumetric fog (or other fogs) with a dark color.
a simple one might do.
but also you can make a complex one with a material. iâd recommend starting with a simple one.
i would hope that unreal has solved this issue in their implementation.
another alternatives which would require your exploration are:
check the stage at which the postprocess and your materials are processed.
you might be able to set the particles to be applied after the postprocess.
thanks for sharing the code.
instead of using an If you could use a step or smooth step. since youâre only thresholding. and could be faster than an if. and simpler.
also i personally recommend using a different arithmetic. thereâs something like an offset and division that gives you a fade instead of a hard cut.
the smoothstep will give you a small fade.
you can do something like
((AWP - CamPos) + Offset )/ Distance > saturate or smooth step
this guy uses that patter a ton, i think he uses it in the video. check it out (it for a different thing but at some point he usses that patterns and explains it (i think, iirc)) https://www.youtube.com/watch?v=-ynkbsCT2Ic
iâm not sure.
thereâs a fog that itâs a simple fog based on distance. youâll have to do some research. it might help.
i think it should work on vr because itâs a trivial fog, but i cant remember if ue exposes it directly.
also check my alternative solution about configuring the stage for the post process and the particles materials.
OOOOOotherwise i just thought of a random approach you can use that might work (please check the postprocess first)
You can set the cull distance to a lower value, then make all materials have a DistanceCullFade or PerInstanceFadeamount to drive a fade out.
and have a solid black bg where things fade into.
also use a cull distance volume.
also iâd recomend on the material to use Opaque/Masked and drive the opacity (mask) through a ditherTemporalAA.
making your materials translucents will make your game much less performant on VR. and also will not write to depth buffer.
itâs a round about way but might work. the problem is that those nodes i think are per mesh, not per vertex. so it will fade kinda like that sonic in saturn (iirc).
the 3rd approach is another roundabout way.
modify your materials to read the depth buffer. or use a node that gets the pixel world position *1
then lerp the mesh color (and maybe other params like specular) to black. so it will âlookâ as if theyâre fading, but theyâre just tinting (which is what the post process does).
the problem will be the light, which might or not reflect. (you can also use a very negative color to see if it absorvs light).
you might have to try this one.
you will need some sort of master material, since the parameters on each material should map almost exactly.
another option would be to use an overlay material and tint there. but the overlay material will incur in another drawcall (afaik) and you donât want that on vr. (but if youâre desperateâŚ)
the overlay material will allow you to avoid modifying the base material.
*1 you can use the same logic you used PixelPos-CamPos+offset/distance>saturate