Erebus - Real-Time Ray Tracing SDFs; UE4/5 Style DFAO and Soft Shadows [HDRP/URP/BUILT-IN]

Erebus - ‘Epic’ Soft Shadows and AO for Unity3D

By Michael Rochon And Christian Kahler

Technical Preview :

Community Discord : Titan Assets

SDF^3 is a comprehensive shading kit that relies on ray tracing distance fields to achieve a number of effects. The system is based heavily on the DF GI engine found in the Unreal Real Engine Since UE4. The system as of now has a fully realized implementation of the DFAO and Directional Light Soft Shadowing.
The package also includes a suite of tools for converting meshes to SDFs, with encoding options for UVs and Color packing, volume rendering shaders for rendering mesh SDF’s in a variety of manor and a few shaders to enhance the look of traditional meshes using their converted SDF data as well.
Aside from SDF related rendering, the package also includes a number shadowing and AO techniques using terrain heightfields and screen space information.
There’s also plans for handling indirect diffuse lighting and reflections following a similar methodology as lumen.
In-Terms of the full package the current road map is as follows, in descending
order:
1 Release DFAO and DF Shadowing
2. Integrate SDF Path Trace / Reflections an Indirect Diffuse
3.Integrate Hardware Path tracing (RTX)

Intro

Long Range Software Raytraced Shadows and AO

Top Image; All Tracing Effects On Bottom Image ; All Tracing Effects Off


Top Image; All Tracing Effects On Bottom Image ; All Tracing Effects Off

This system was designed with the intent of solving a big problem when it comes to finding a robust GI solution that doesn’t put restrictions on artists while also being an applicable solution for large scale open world building.

From my perspective the only applicable option that didn’t make sacrifices was Unreal’s SDF work. I ended up spending a few years on my off time researching and building up similar tech to what they use to manage SDFs as well as the methods the use to trace them.

Recently I’ve put the final pieces together and I think I can safely say I have a solution that doesn’t compromise and be utilized in practically any rendering scenario, large scale or small and doesn’t hamper on quality in order to get there.

So like UE4s offerings :

This supports any mesh and responds instantly to changes made to them;

Meshes Receiving AO and Soft Shadowing As Well As Contributing

All meshes in the scene above are both receiving and contributing real-time GI. No data is baked, all objects can be moved and the scene will respond accordingly. Shadows ray trace against high resolution instance data, AO traces against high resolution instance data as well, with fall back to a distance field clip map.

Because the system uses SDF in the same vein as unreal, there’s never any worry about object count or density in your scene.

Because it traces against high resolution instance data you will always get a stable, high quality result no matter what transform manipulation objects goes through and regardless of how they are set up or organized in you scene.

Handles large scale scenes with ease;

Even at 2000 meters away, the system can reliably trace instance shadows, and AO.

There isn’t much of a scene size limitation, especially with modern hardware. Even on a 1050gtx, rendering an entire terrains AO an shadows along with it’s vegetation instance keep well with in the 30-40 fps mark running all effect wide open. (Highest quality, no optimizations)

Not only does it handle large render distances well, but it’s also extremely responsive to mass changes made to scenes. Because of how the system works, every tree on this map could be updated in real time with no noticeable effect to the ray tracings performance. This means large scale simulation using rigid objects, like traffic sim, or racing games can utilize this tech as well with no problems, or precession issue otherwise found with voxel-based GI systems.


Final Render with AO Applied and Debug View


AO On Top;
AO Off Bottom;

Above all, we made no compromises to quality. On average our system typically outputs better results than most screen space effects are currently capable of. Offering long range high-detailed traces that never suffer from issues like lack of screen space data or gird resolution found with-in voxel based GI systems.

On top of this, issues like light bleeding and self occlusion should never be a problem. Our system uses high res SDF data for tracing close to instances, ensuring rays never miss a surface.

Render Showcase


Using some primitives to ‘probe’ the AO and shadow receival.


Plays well with other lights in the scene.


With ‘Mid Day’ Lighting Factors


With ‘Late Day’ Dawn/Dusk lighting factors.

Renders Below Are Extremely Outdate; Information is correct though.

Features
Real Time Ray Traced Lighting Derived From SDF Data

So just to show there’s no cheating. :wink: This would be the meat and potatoes. Meshes are converted to SDF’s and baked into an atlas to be used for ray tracing against instances of that object present in the scene. A lower resolution clip is also maintained that is generated around the current rendering view port.

DFAO utilizes both the clip map and the high resolution instance data for cone-tracing ambient occlusion into the scene. After the tracing passes finish, bent normals are derived from the traced cones averaged visibility and mix with the the scenes main light directional lights lighting pass. This is what Unreal refers to as ‘Sky Occlusion’, or essentially modifying the input normal when sampling

DF Shadows exclusively cone trace against the instance data which ensures a high enough quality to be usable for production. They’re extremely fast, tracing an entire terrains worth of objects direct light blocking into the view port faster then the built in cascaded shadow system.

DF shadows are better when coupled with PCSS Shadows for handling details close to the camera, namely wind animated foliage and skin meshes. As of now the system will overlay the DF shadows with the results of Unitys making it easy to couple it with other shadow rendering systems available on the market currently. For PCSS support I would recommend NGSS personally.

DFAO
AO derived from instance SDF tracing, SDF clipmap tracing, and height map tracing.

DFAO and Heightfield AO Composition

Like the soft shadowing, DFAO and Heightfield AO both utilize ray tracing against SDF and Height field data to derive accurate, stable large radius AO in any scene.

Currently like unreal, our system traces against both the full res volume data as well as a clipmap.

The instance tracing would be akin to how one would expect RTX tracing to work, just with SDF volumes rather then BVH.

The clip map tracing works roughly the same as other voxel GI setups, with the exception that rather then store voxels, we store distance field values instead.

Like Unreal you can set up the instance tracing to only trace around a small object radius and then continue that trace against the clip map in a later pass, this makes things a lot cheaper to run with out compromising on appearance by much, if at all given how the distances tend to average the further an the source object being sampled is.

Currently like unreal, we trace against the height map injected into the clip as well as against the heightmap itself as a substitute for high resolution instance volume data, so built in terrain is well supported.

All of the AO passes also contribute to the generation of a bentnormals which are injected into the scenes main directional light pass and mixed with original screen space normals, replicating the effect Unreal Refers to as sky occlusion as well as specular occlusion.

SDF Soft Shadows
Soft Shadows Ray Traced From Instance SDF Data and Terrain Heightfield


Shadows operate like unreal, where the softening is governed by a user defined light ‘Cone Angle’ parameter**. On the right a low light angle is used keeping the shadows sharp, on the left a higher light angle is used softening the shadows.**


Supports thousands of meshes and ‘infinite’ range at a fraction of the cost of what traditional cascaded shadow mapping methods would incur. Shadows in this scene use around 4ms of a 1050 GTX)

SDF Convertor And Rendering Tool


I’m also including another package I was working on before. It’s a fully feature mesh to SDF convertor with a bunch of volume rendering shaders. SDF baking also supports something unique, which I haven’t seen, full color and UV baking support. All of the deer in the header image above with the exception of the one visibly wireframe’d are volume rendered using a bunch of different models ranging from legacy diffuse/specular, SSS variants of each as well as a standard rendering model built in.

The convertor as well will handle any mesh and game object hierarchy with settings for every mesh as well as each sub mesh those meshes are composed of for converting your meshes to SDFs for the most optimal tracing of that object.


Mesh Converter Supports Any Game Object Hierarchy and host of comprehensive settings for converting meshes to SDF

I use a similar method as Unreal does for generating SDF versus the conventional shortest distance to the triangle test. This allows for supporting planer geometry and some really nice point clipping using asset/material alpha masks. It also gives a solid metric for determining the interior of a mesh vs not making SDFs from basically anything that I have thrown at. Houses like the one above composed of 200 gameobjects, trees, people, furniture, cars, etc.


Some Shading Options as well as a debugging view for SDF Tweaking

There’s a quite bit more I could go over in regard to the SDF convertor itself, but I’m going to keep it short for now. Gist is though, for prepping your scene data for ray tracing this convertor should definitely have you have covered for that purpose explicitly with pretty minimal effort.

36 Likes

If these are your " starting images " WOW. I am unclear on one point only… can this be used for
real time games ? or is this just for like ray tracing renders like " product shots " ?

In any-case I like the images and I get the definite impression you know what your doing :slight_smile:
Good luck with this project, al-tho I don’t think you need it :wink:

Luv the pic’s, great work!

Hi!
Will this support HDRP?

1 Like

Which render pipeline is this for?
Is this Shadow/AO only?

I heard Lumen uses the same data set to compute GI of all ranges.
Screen Space for short & micro GI, SDF for low-mid ranged GI, and Voxel for long distance GI (Like the horizon and faraway terrains)

You’re just a few steps away, might as well go achieve Lumen before the 4000 engineers at UT does! :stuck_out_tongue:

1 Like

I think this is more like a copy of SDF shadow tech from UE4 + some additional features. Though, the description is a bit ambiguous. I’ve read it twice and still don’t fully understand what exactly will this asset do when it’s released:)

Thanks! It’s all real time. No baking aside from the instance SDF it self. Like for every model in your scene ull need to bake an SDF to represent it. (1 SDF can be used for all references of that model in the scene)

It’s designed with real time gaming in mind. I run it and develop it mainly on a 1050 gtx mobile GPU. the scene with shadows avgs around 2.3 million polys per frame and I’m managing 50-70 fps with more leg room for optimizing. That would be with all the effects on, Heightfield ray tracing for shadows and AO, SDF raytracing for shadows and AO as well. Generally the soft shadows are faster actually then the cascaded shadow mapper that’s built into Unity by default, the AO is a lil more impactful given it fires 9 rays per pixel. Ill get some stats soon, i dont want to jump the gun and do benches 50 times though given I know theirs some obvious optimization I should do first. But yah it’s definitely real time. :slight_smile:

At the moment is just shadows and AO. :slight_smile:

Yah, for half of it’s functionality Lumen does use Distance Fields for ray tracing in software. I’m actually planning to implement all of the software stuff they’re doing. Just don’t want to bite off more then I can chew until I get something out. You’re right though saying it would be a few steps at this point. I could do bounce indirect easy, reflections even easier. I might even mess with reflections given it’s sooo trivial. But the bounce stuff, i was gonna approach it similar and use number of techniques. Screen space, Heightfield and distance field along with RSM as an option, kind of adding on as I go.

We’re planning to support HDRP but there is still more work to be done there which Im getting to as I move this into an HDRP supported scene that’s prettier. But HDRP for sure, that’s personally why I wanted this, lol.

Yah, I’m going to try and clarify a bit more. Umm it is UE4 DFAO and DF Shadows. So it’s all ray traced in real-time and it utilizes baked distance field data stored in a scene atlas file. It supports all terrains and instances in a scene. The work flow would be similar to how unreal manages this as well as the AO and light shadow settings.

I am planning do to most, if not all of what’s covered in the Lumen software ray tracing bits which utilizes distance field sfrom what I gathered. Like bounced indirect and reflections should be trivial to account for and I do have color support for converted objects to SDF with these two things in mind.

7 Likes

I have not been this excited by a new asset in a long time … but this… man…
You could end up pulling back people from UE4 with your plans here.

The future looks exciting again :slight_smile: Real time, real quality … yes!

:eyes: did you single handedly solve one of the biggest limitations for rendering run-time/dynamic scenes in Unity?

Funnily enough this is a topic that seems to have been coming up a lot lately - there’s definitely a lot of projects that would really benefit from this. Is there any way to support you during development?

2 Likes

Amazing work! If there’s a need for beta testing, we’d be happy to sign up for it!

Its normal that “Modders” community does better job than devs themself…Cyberpunk, Skyrim, Unity.

I am impressed, will gladly pay good money for production system :slight_smile:

It’s a real shame with Nanite coming in UE5 I can’t bring myself to pursue realistic graphics in Unity anymore because this looks really dang good. Great to have it as an option though. I had actually experimented with implementing SDF shadows/reflections in Unity myself a while back but this blows my experiment out of the water lol.

1 Like

Looks impressive. Does the scene-SDF have to be baked in editor, or can it be generated/updated at runtime? (Eg to support dynamic scene changes or objects being added/removed)

What kind of resolution/memory cost is required for the SDF of a large scene?

It would be neat if this is a modular system that can be easily plugged into custom Render Pipelines via command buffers.

I know, nanite and lumen makes the switch to Unreal so much more compelling. I just don’t see either feature ever getting implemented for Unity as it would have to be by individuals making the asset. Tho this asset makes a valiant attempt at implementing the distance field features they had in UE4. Maybe sometime down the line someone will create global distance fields to do lumen like GI idk.

2 Likes

I have a huge update.

Over the weekend before heading back home I set up the global SDF, added bent normal support and added in some stuff to take advantage of global SDF data.

I got the Global SDF baking working in realtime, clip maps follow the camera. I set up most of the culling and stuff compute wise for updating the clips efficiently. As of now though im just brute forcing the entire clip when the cam moves which is surprisingly responsive. I need to take advantage of wrap addresses though to manage the updates properly and will properly hold off on that while i polish the AO effects now. Which look alot better.

I also added some tests to my pixel culling stuff to hopefully cull out more instance cone tracing rays and focus those on the Global SDF data and got a much better pixel culling system in place. Not that anyone cares about this though lol, kind of proud i got this set up. It was a real SOB.

Got some bent normals coming at yaaa to, all my ao tests use the same rays, like unreal for any given pixel and then once all the ao is calculated the rays are converged and we generate a bent normal. Ive really wanted this for awhile personally so, really happy to say im pretty much wrapping up the entire algo as far as it was outlined with these additions. I should be able to get these alooot cleaner but not bad for now.

So with all of this, we’re getting alot nicer AO. I have to fix a few things with the global tracing but, yaaaah. Im pretty intimate with unreal, and i think im there now in regards having what i need to meet the quality they deliver, just need to polish my mathz now, lol. I do alot of things differently in terms of converting between spaces, but i follow a very similar execution order for each effect, cull instances to screen/volume, cull instances to pixels, trace pixels/sample, etc kind of thing. So hoping this will be not half assed attempt but the entire algo they initially presented completed.

And last but not least

So now that i have the global SDF working, getting sooooo much nice AO. i could cryyy lol. Still some biasing issues but yaaaaaaah. Im gonna have to redo the entire main post which makes me sad. I know once i sort out the global sdf trace, this will look ten times better. Im also not using any screen space AO here, pushing the instance cone tracing towards high frquancy stuff is really bring out the small details.

Anyways, i have recruited someone to help out, their going to focus mainly on bounce GI integrating other effects into system as well as preparing and polishing everything for release.

Would also like to apologize had a bit of a hectic week with some personal stuff and a whole lot of work to catch up on yesterday. This weekend i plan to sit down and finalize the ao calcs and clean the global sdf stuff, so i figure by monday i should have the entire main post re-done to reflect where the system is at now. I sort of jumped the gun and should have waited. I spent alot of time trying to understand the instance tracing bits of the system as that to me just seem crazy impossible when i first looked at this so when i got that working I was a lil to pumped to post my results lol.

Anyways, the response has been pretty amazing! Thanks everyone for the support. I really hope we can deliver something to fill a major need in this community. I love Unity, Unity taught me how to program like i have bias towards this community that pushed me to set this up vs just jumping ship. But i mean that’s also what i love about unity. I have yet to find a task that I cant accomplish with this engine super conveniently. And I mean this was alot of fun to set up. Anyways thanks again, and thank you Unity, lol. I’d be nothing without you. <3

9 Likes

Hey man,

I actually did the global SDF this weekend and it’s pretty similar to how unreal handles it. Like culling for optimal updates, injects heights and SDF instances in realtimes, no baking.

I would need to add support for moving objects. Which is super doable, just not sure if i would i would manage to get that in first release. So the alternative would be that objects like cars and stuff would use the cone tracing against the SDF isntance data store in the atlas, the highest quality stuff, and just wouldnt be account for in the global sdf trace bits to start. I think unreal has an option like this where u can say u want to ignore fast moving obejcts to avoid having to freuantly track and update the global sdf clips.

I should also mention the costs are not crazy

I use 4 clips in my clip map like unreal at 128^3 rhalf format and then 500^3 SDF atlas thing. U can adjust that atlas though. And the resolutions are referring to 3D textures. So the scene would use one chunk of the Atlas for cone tracing high frequancy AO, then it falls back to the clip maps which is like a big baked version of all the SDFs.

Its funny that u mention that command buffer thing, the whole system is utilizing them now. I need them for injecting shadows and also generating and overriding screen space normals with the bent ones so Im hoping getting it working with hdrp and the srp will be not to hard, though i kind of read some sads about overriding the screen space normals and i hope i can still mess with the screen space shadow mask. Ive been doing alot of work with the builtin old school stuff on account of work at the studio that employs me and havent had much time with any of the new pipelines since they we’re first released, so thats gonna be fun… lol But yah, ive switched the code from manually blitting to rts to doing it from command buffers and its trivial to get that going either way, just hoping it doesnt get hacky with normals and shadow overriding.

2 Likes

I like all the stuff you are doing!

2 Likes

Yah, I kind of cry when I look at just anything unreal. They have megascans, we have robot kyle… Kind of hoping to bridge a gap here though. I dont think ill ever be able to compete with epic whole team of engineers but I got another guy coming on board whos good a graphics stuff and plan is to focus on more general GI now that all the core functionality is in place. Like we could do bounce GI against the SDF pretty easy now tweaking the AO stuff, just need a really good light blocker metric for figuring out what pixels are receiving direct light which i really wanted to give alot of love cause that would make alot of things possible on it’s own. But yah, I will say i am going to work towards Lumen distance field stuff like unreal, just its alot to bite off to commit to that as well right now.

I hate how tempting it is though, for bounce lighting it would take like a week to get something going. Reflections would be really easy to, especially on the global SDF now thats in place and im already tracing from it fine.

6 Likes

Just wanted to give a quick update. Been waiting awhile to have everything working efficiently enough to focus on my AO generation. It wasn’t bad-ish before but it was sort of place holder with the intent on tweaking the calcs there after all the SDF management, culling and I guess now the clip map is done.

Anyways messed around this morning, and I mean it’s ao so got it working prettty good. Id say im basically done that part, everything is nice and smooth and the global SDF helps alooooot. Just a few screen where it’s at now. I find it’s miles better personally.




I also got bent normals looking pretty nice, it’s pretty cool what they do for the actual lighting calcs done by unity. Like take this point like in a forest for example.

The top image has the bent normals turned off. It’s pretty apparent that the light does not care that are trees blocking it’s path to surrounding objects. With them on though you get some nice light blockage for essentially free. So it’s not just toning them out it out naively using the AO magnitude calculated by the ray trace, it’s also adjusting the screen space normals to account for how surrounding objects would block light as well and using this when handling the differed lighting stuff.

I also made a short video of the all the effects in action pretty quick. Nothing special but figured something with directional light changing would show off everything together half a**'d pretty well. Been extremely busy on my end as a of late.

I personally love the shadow fading coming off mountains in the distance. That alone always makes me sooo happy. All objects use DF shadows cone traced against the instance, so shadows dont use the global SDF at all and should never need to. They run at like 1.3 ms even when viewing the entire terrain in the viewport.

The AO is on for the heightfield, instance cone tracing and global distance field, could have messed with the lighting and settings a bit better, but anywhoooo. Hope you guys enjoy ! <3

Edit; Dont mind the fidgetty-ness in the video. Capture software sucks and i was using a mouse pad lol.

10 Likes

Those bent normals are tasty.

Got some big updates!

Been cleaning the code in my spare time and there’s been some issues AO calcs admittedly. So I set out to fix that. I ended making a debugging shader where i could teach each effect isolated to a single instance. After which I ended up looking on shader toy because that what you do, and came across the popular SDF cone tracing example.

Turns out it’s the same code Unreal actually uses with the exception that they use a different falloff/distance fade metric. Not that anything fancy but yah, so this set up reallllly line up with unreal now in a not ethnically bad way. Just all using the same code here… from shader toy! But yah after debugging I found issues with some scaling and conversion between spaces causing artifacts and then baaam!

That unreal AO… :') After getting this done i then applied to the global / clip map data tracing and the instance cone tracing and we’re looking alot better! :slight_smile: I also redid the heightfield AO and thats waaaaay better.

I knew i was gonna need this to, so while cleaning on a whim i set up a bunch of crap to get more heightfield/terrain data and made a super super big blocker texture! and light map! lol. :smile:

Unreal does something totally differnt for heightfield GI. I ended up applying RSM inside the heightfield texture space and got some really sick results though, which ill definetly be including!

I really enjoy this effect, soooo simple yet soo satisfying… I set pretty intense intense on purpose, haha. U can def play around with that to find the sweet spot though.


So now the AO effects math wise are complete, Shadows are complete in all shapes and forms. 90 percent of the system has been cleaned up. Whats needed for something more like unreals height-field GI and a good chunk of their new SDF tracing stuff, like the indirect lighting would be really simple to manage, i could probably do it in a weekend that how simple it would be now given the light map stuff is really what was holding that back. The main focus as of now though is getting the down sampling and upscaling back in for the AO. Doing a final clean up and getting to people to test and mess around with.

I’m really going to need to update the entire main post now… But yah, defo at the quality id want. It’s nice to know as well im sourcing the same cone tracing stuff as unreal as well. That should ensure the lighting is pretty close even for a one man job like this system has been. I also think Im going to focus on adding hard ware ray tracing after the initial release as a big focus. I think in the two weeks id need to get this close to release I could have GI from the clipmap and instance cone tracing working which would cover all the software ray tracing bits unreal covers.

Anyways quality has gotten really better. I put way to much emphasis on setting up all the data versus actually tracing some results with it i guess, haha.

Also had a bit of a long week. A little later today, ill take time to properly respond to everyones posts and DMs.

12 Likes