Hey everyone,
Im trying to make a lens flare that i can apply to a niagara particle. The effect im trying to achieve if the exact same 2d lightshaft effect you get from using the “lightshafts” in the atmosphere lighting on the sun. I want to attach a radial glow that has this same effect onto a particle that i can move around.
Using Light Shafts in Unreal Engine | Unreal Engine 5.1 Documentation
Im trying to build a material that would achieve this but im a bit out of my element as im still new to writing material shaders. It would essentially be a radial sphere mask or texture that i can apply to my effects to get psuedo 3d light shafts on some effect. My current line of thinking is i need to sample depth buffer, threshold it to be a black and white mask, then somehow sample the mask and create duplicate samples and then blend them together. (similar to the radial blur tutorial) The main element im going for is the self shadowing element, i know the engine lightshafts are a bit more complicated. The goal of this is to be as simple as possible.
I saw this radial blur tutorial and it looks like they both operate under similar principals. This samples the entire screen but i would only want to have the effect within the radial glow, which would be smaller and can move around the screen.
UE4 Tutorial: Radial Blur (Request) - YouTube
Thanks! Any help would be greatly appreciated!
UPDATE: Alright i have gotten a bit further but i am stuck again. I have setup a blueprint to render a material into a render target, but i have 2 issues. My first issue is that the render target only updates if the blueprint is manually moved around. I want it to update every frame. I tried adding the bp to the detail panel in the niagara emitter but that didnt make it update when the emitter was moved.
The second issue is one related to generating this mask texture to input into the render target. I was sampling the scene depth and then doing an “if” to change it into a black and white mask. If the geometry behind the object its white, if its in front, its black. The problem is two fold, one issue is that the render target isnt working with this setup, it just remains black. The other issue is that this material that draws to the render target is sampling the depth from the worldspace position of the object it is applied to. When i have it setup properly, this material wont be assigned to anything in the world so i need a way to sample the depth from the object it is applied to. (in this case a niagara emitter or a 2d plane) I tried adding some geom to the niagara emitter in the details panel but it still wouldnt update the render target. Since i am sampling the scene depth, only translucent materials or post proccess materials can be used. I have tried both with no luck.
I was able to get a custom material node working to do the radial blur on the render target so that side of things is already sorted. Its just these issues im having generating the render target.
here are some pics. The first is the mask im generting for the RT. The second if the mtl setup for this mask. If anyone knows a better way to get this same result i would love to hear it!.