[MOD] Realtime Reflections

A curated forum for approved mods. Users are unable to create new topics in this forum but can reply to existing topics. Please message a moderator to have your mod moved into this forum area.
Post Reply
User avatar
Nystul
Posts: 1328
Joined: Mon Mar 23, 2015 8:31 am

Re: Investigations on Realtime Reflections in Unity

Post by Nystul » Mon Dec 14, 2015 1:39 pm

working on improving the ReflectionsMod code again. I am happy with the automap state for the moment so I will be focusing on this code instead since it definitely needs some love again ;)

User avatar
Nystul
Posts: 1328
Joined: Mon Mar 23, 2015 8:31 am

Re: Investigations on Realtime Reflections in Unity

Post by Nystul » Sun Jan 17, 2016 10:33 am

took a look at unity's cinematic effects package for unity 5.3.x and tested ssrr effect. Very cool. Good performance, good quality (although with all the limitations of a ssr approach), lots of parameters that can be tuned. will be a tough decision if it should replace the planar reflections in the reflections mod for indoor environments once dfunity will be updated to use unity 5.3+
reflections of billboards look better (less artifacts) than with kode80-ssr.

User avatar
Interkarma
Posts: 4290
Joined: Sun Mar 22, 2015 1:51 am

Re: Investigations on Realtime Reflections in Unity

Post by Interkarma » Mon Aug 15, 2016 12:14 pm

The cobblestone reflection during rain is awesome! This screenshot doesn't do it justice. I don't think I've noticed this in game until now, and it took me pleasantly by surprise. :)
rainslick.jpg
rainslick.jpg (80.78 KiB) Viewed 2299 times

User avatar
Nystul
Posts: 1328
Joined: Mon Mar 23, 2015 8:31 am

Re: Investigations on Realtime Reflections in Unity

Post by Nystul » Mon Aug 15, 2016 1:28 pm

cool that you like it! :D

User avatar
Nystul
Posts: 1328
Joined: Mon Mar 23, 2015 8:31 am

Re: Investigations on Realtime Reflections in Unity

Post by Nystul » Fri Aug 19, 2016 10:15 am

indoor reflections are once again broken. taking a look at it

edit: found the culprit - fix for outdoor sea reflection bug should only be done outdoors :) - my bad ;)
fixed with next pull request

User avatar
Interkarma
Posts: 4290
Joined: Sun Mar 22, 2015 1:51 am

Re: Investigations on Realtime Reflections in Unity

Post by Interkarma » Fri Aug 19, 2016 11:43 am

Great work, thank you for the fix! :)

User avatar
Nystul
Posts: 1328
Joined: Mon Mar 23, 2015 8:31 am

Re: Investigations on Realtime Reflections in Unity

Post by Nystul » Sat Sep 10, 2016 8:37 pm

it has been a while since I last invested considerable time on the reflections mod.
over the last few weeks I worked on the mod again and I would like to take the time and talk a bit about the things I investigated and the work I did.

Let's start with a screenshot of the reflections inside the mages guild with reflections mod activated:

Image

there is one aspect that I dislike about the reflections in the screenshot - they make the floor too bright. reason is that till now the reflections are done in a surface shader which basically alters the albedo color.
No matter what you do (blending it with the original color or any other operation) it makes surfaces with reflections look different than surfaces without (as unity applies its lighting model).

Another problem with the old implementation is that every floor material needs to be exchanged with a custom material using the surface shader and some custom shader parameters. This worked but it has a major drawback. It is not possible to use the standard unity material anymore and more important one can not just simple change the floor material again. With this proprietary texture injection solution (part of the old reflection mod) a coexistance with a potential future texture replacement mod would not have worked or only with lots of quirks.

So the motivation was to "inject" the reflection computation for floor planes into unity's deferred pipeline so that (1) the lighting would look better and (2) materials with unity's standard shader could be used as floor materials and still get the floor reflections.

So I decided to take a closer look at unity's deferred rendering pipeline and ways to customize it. I learned lots of new techniques including replacement shaders and command buffers.

There were lots of problems but I was able to solve most of them. So I think it is time to show off some progress and talk about the remaining issues:

Image
it does not look too spectacular but you can see that the floor now is lighted similarly as the walls. But keep in mind that it uses now unity's standard shader on all floor materials.

one issue you can see in the image is one of the remaining "problems" (it is not really a bug or problem just a consequence of the light rig used in indoor scenes by DFTFU):
it is the reflection of one of the 3 directional lights used in the light rig that ends up in the light probe buffer and is drawn (indeed all 3 lights can be found when walking around the indoor environment) - this issue is not a problem of the floor reflections, it is intended behaviour by unity since every directional light gets rendered in the light probe buffer - if DFUnity would have any default texture with some metallic amount and smoothness < 1 one would see the light reflections on those surfaces.

@interkarma: the question now from myself would be: is this lightrig really necessary? - I mean 3 directional lights are not really realistic - in indoor scenes there should only be spot and point lights in my opinion.
I also realized that e.g. castle daggerfall imports/create lights at light source positions (e.g. torches) but it looks that for buildings no lights are created for the light sources.
there is no easy way to prevent lights to end up in the light probe buffers unfortunately.

nevertheless I think it is already in a pretty good state - will take me some more weeks to finish and polish it ;)

User avatar
Interkarma
Posts: 4290
Joined: Sun Mar 22, 2015 1:51 am

Re: Investigations on Realtime Reflections in Unity

Post by Interkarma » Sun Sep 11, 2016 12:39 am

Hey, looking good!

The interior light rig just gives us something less flat than pure ambient (which is all that Daggerfall uses, you're right DF doesn't use point lights in interiors). I also use a heavy ambient light in interiors to keep the basic look, the extra lights just give some variety to shading on walls. Turn off the light rig while playing to see what I mean. I'm not married to it and happy to change. It's more of a "that will do for now, on to gameplay" setup.

You might have noticed that I dropped the three-point rig for exteriors some time back. I now use a single directional light (the sun) and a "day sphere" point light centred on player that gently illuminates a wide radius, scaled by sunlight intensity. This is actually very subtle outside in daylight but serves to brighten up otherwise darkly illuminated areas (like under eaves and gables) where sunlight cannot bounce to without fully procedural GI. This works surprisingly well and is very cheap.

Happy to look at other options for interiors as well. :)

User avatar
Nystul
Posts: 1328
Joined: Mon Mar 23, 2015 8:31 am

Re: Investigations on Realtime Reflections in Unity

Post by Nystul » Sun Sep 11, 2016 3:23 pm

Interkarma wrote:Hey, looking good!
thanks ;)
Interkarma wrote: The interior light rig just gives us something less flat than pure ambient (which is all that Daggerfall uses, you're right DF doesn't use point lights in interiors). I also use a heavy ambient light in interiors to keep the basic look, the extra lights just give some variety to shading on walls. Turn off the light rig while playing to see what I mean. I'm not married to it and happy to change. It's more of a "that will do for now, on to gameplay" setup.
yeah I know - and yes - turning the lightrig off results in a pretty dark scene. so I absolutely understand the reasons why you put it in. maybe we find an even better solution though.
Interkarma wrote: You might have noticed that I dropped the three-point rig for exteriors some time back. I now use a single directional light (the sun) and a "day sphere" point light centred on player that gently illuminates a wide radius, scaled by sunlight intensity. This is actually very subtle outside in daylight but serves to brighten up otherwise darkly illuminated areas (like under eaves and gables) where sunlight cannot bounce to without fully procedural GI. This works surprisingly well and is very cheap.

Happy to look at other options for interiors as well. :)
I like the new outdoor approach ;) thanks for pointing that out.

User avatar
Nystul
Posts: 1328
Joined: Mon Mar 23, 2015 8:31 am

Re: Investigations on Realtime Reflections in Unity

Post by Nystul » Mon Sep 12, 2016 12:53 pm

I think I have found a possible solution for a replacement for the indoor lightrig:
in the lighting window there is the property "ambient source". If set to color one can specify a "ambient color" property. DFUnity seems to set this automatically to a pretty dark color. If you set it to full white, this gives similar lighting conditions without the lightrig compared to the lightrig approach.

See these comparison screenshots:

lightrig:

Image


ambient color white, disabled lightrig:

Image

Post Reply