Fake SSGI in Eevee

Some experiments for getting SSR to reflect diffuse materials for SSGI like effect. Works in viewport in Eevee. Just replacing principled shader with node group that has a gloss shader that uses the some of the same inputs and roughness mapped to a more diffuse range and then optionally mixing 50% to a empty shader to same brightness level as normal principled shader.

SSGI:

SSGI Disabled:

SSGI with no brightness change from original:

SSGI with spotlights and emissives:

Lighting from one emissive mesh:

And the node setup (some of that is unnecessary, some some setups work better for scenes, some for skin):

I was hoping to create a addon that would replace all the principled BSDFs with the nodegroup, but it was bit more complex than I imagined. Didn’t help that most of the relevant examples of similar scripts were pre 2.8.

47 Likes

Test with bit more complex materials:

7 Likes

With the megascans used in UE5 demo (only with lowest quality lod and 2k textures):

15 Likes

Excellent, very good idea!
thanks for displaying the node, I will try to reproduce it when I find time for that.

SSGI_V3_DemoScene.blend (986.2 KB)

Here’s the test scene for the latest node group I did. Haven’t touched it for a while so I’m not 100% all values are at the best defaults or nodes are cleaned up.

There are problems with things looking too metallic and normals being too harsh on skin as they don’t get blurred. The workaround in that file is just to change the normals to neutral if there’s any bigger value in SSS input.

5 Likes

This is amazing, however having to modify every single material for it to work is a dealbreaker. @hypersomniac should definitely implement it as Eevee native feature.

1 Like

There are also couple of cases where you need to have non linked copies of the nodegroups as in some cases it fails to produce expected result, so you need to slightly tweak values based on assets, making it even worse. Having it implemented correctly as actual diffuse bounce light it shoudn’t have any of those issues. Based on my experience in UE4 with SSGI works great with lower fidelity GI techniques (also with irradiance volumes?) as it fills in the details they miss.

Interesting.have looked at the nodes.At the Energy Conserving framed mixshader the 2nd slot is not connected,atm you get 50% black mixed in.

Maybe you can render a full reflection pass in cycles and compositing it with the eevee render?

Thank you very much for sharing this,
gave it quick try and loving it, no time to dig into it more today but will definitely follow this thread.
Great contribution to the community!

@pixelgrip That 50% black is actually intended as I used add shader instead of mix for flexibility while testing. Add shader by itself gives too bright results.

Looking at this now I way too many problems with it, as there are quite a lot of inputs that don’t look as they should, fixing the handling of them case by case seems kinda counter productive, might as well try to create a uber shader from ground up, as was my inital idea, but I think I had trouble with getting the SSS behave in a similar fashion. Still, finding a old pbr ubershader and tweaking that might have better results.

I also took a look at Eevee SSR shader code while I was messing around with this, even tough that is way way too advanced to even have a shot at understanding it, I kinda found the relevant sections, but I didn’t get where or how in code it was that it was decided that what gets written into specular roughness buffer.

2 Likes

That’s exactly what I was thinking. I am using SSGI in UE4 too and it’s great. Given the simplicity of the implementation, there’s really no excuse to not have it in Eevee.

I wonder what the Eevee dev would say to this method,this could be hardcoded as Eevee render option with tweaking sliders.Maybe even more effective.

2 Likes

Spent a good part of the weekend trying to understand eevees source code.
Managed to turn diffuse node into a glossy node and then eventually get SSR working on it.

Doing it with notepad++ and no source control definately isn’t the way to do it, so I guess I have to learn how to this properly.

8 Likes

it seems like you found a secret door…

1 Like

Here you can see how the shaderfiles are builded
https://wiki.blender.org/wiki/User:OmarSquircleArt/GSoC2019/Documentation/Adding_A_New_Shading_Node

you can download visual studio community for free

maybe its a good idea to post your ideas to the devs in the user feedback thread

1 Like

Converted principled, diffuse to use glossy closures. Not sure if there’s much point to touch translucent.

Next step would be to try to edit blender\source\blender\draw\engines\eevee\shaders\lit_surface_frag.glsl diffuse closures to include SSR in physcially plausible way and then switch diffuse and principled back to diffuse closure.

I could share the current build, but I don’t think there’s much practical use for it.

1 Like

Some more testing with custom build:

I ran into a problem. Since I needed to edit some of the files that are used when creating the nodes then you still need to replace the principled node with another principled node, doesn’t work with just opening the scene.

If someone knows if there’s a way to recreate/reload nodes then that would fix it. If there isn’t then the build is about as useful as a node group.

2 Likes

This is really good. Good luck for finish this !
My try, working good.

3 Likes

like i written before,the best would be if you post your ideas at the dev talk forum.The devs selfs can give you tips at first hand.

6 Likes

I haven’t looked extensively at all the categories there, but I’m hesitant to take up developer time for a hack that probably will only work situationally. As for a proper implementation, I sure can’t do it, so it would be pretty much a feature request.