godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.21k stars 21.22k forks source link

Screen space reflection with roughness does not blur across object edges (fixed in `master`) #25112

Open cjxgm opened 5 years ago

cjxgm commented 5 years ago

Godot version: 3.1 beta1

OS/device including version: Windows, Linux

Issue description:

image As shown in the image, the ground has a roughness of 0 (left) and 0.3 (right) with SSR enabled. Details inside objects get blurred when roughness is large (as shown in green circles) as expected, but object edges does not get blurred (as shown in red circles).

Blurred object edges are expected.

Steps to reproduce: Enable SSR in default_env, add a ground mesh, add a spatial material with metalness set to 1 and roughness set to non-zero. Add any mesh to be reflected.

CptPotato commented 5 years ago

This is probably due to the limitations of screenspace reflections. If the ray gets occluded or off-screen it cannot gather any information which results in missing reflections.

cjxgm commented 5 years ago

This is definitely not the limitations of screen space reflections, but the limitations of the particular implementation (conetracing?) of godot.

For example, in Blender Eevee, SSR is correct: image

puchik commented 5 years ago

I've done some fiddling and hopefully this can be of some use:

When you progressively increase roughness, notice how a faint blur starts to appear around the objects (around 4 or 5 it becomes noticeable). It's almost as if roughness works BUT the non-rough version is being drawn below the rough one.

compare

Even to achieve this effect though, you need to have another object (or have "max steps" high enough so the sky gets reflected) behind it to work. Otherwise, it is completely sharp on the edges.

compare2

You can also pitch the camera down, and once you get to just barely on top of reflective surface...:

  1. The roughness seems to actually work properly.
  2. Once you remove the object behind it, you get artifacts (if max steps is high) OR completely sharp reflection (if max steps is not high enough). The lower you go, the worse this gets.
    • Notice how in the artifacts, it seems to alternate between sharp and blurry.

compare3

Here as well, in alternating artifact lines you can see how the red cube's reflection is being blurred out

Basically, if you have an object behind it and you're at a low angle, it almost works (except for the very faint outline you can still see in the rightmost picture here and still relatively pronounced shape).

18395 mentions artifacts that sound similar but the video is gone so I'm not sure if it's the same. In this case disabling roughness doesn't help, but may cause the lines to be less visible sometimes.

Just some things I observed and am hoping can be useful!

.zip of all the pics ssr_roughness.zip

Zireael07 commented 5 years ago

It's the same artifacts as in my issue, and since you said the video is gone, I will close it in favor of this one!

adriansnetlis commented 5 years ago

ssr-glossy-color ssr-rough-nocolor Another thing I wanted to note is that, as visible in the images(first image roughness=0.01, second image roughness=0.3), with increased roughness the reflections loose color. At higher roughness values the reflections can become totally unusable.

Calinou commented 5 years ago

@adriansnetlis Please open a separate issue for this, as this appears to be unrelated to the issue reported in the first post.

adriansnetlis commented 5 years ago

30989

But I do believe they're at least related since both are issues with SSR wrongly handling roughness.

KoBeWi commented 4 years ago

Can anyone still reproduce this bug in Godot 3.2.3 or any later release?

If yes, please ensure that an up-to-date Minimal Reproduction Project (MRP) is included in this report (a MRP is a zipped Godot project with the minimal elements necessary to reliably trigger the bug). You can upload ZIP files in an issue comment with a drag and drop.

puchik commented 4 years ago

image

Still reproducible in 3.2.3

ssr-edge-fade-broken.zip

Calinou commented 3 years ago

As per https://github.com/godotengine/godot/issues/49402#issuecomment-856240838, true rough reflections are supported in the master branch's Vulkan renderer (nonwithstanding this bug).

puchik commented 3 years ago

You could apply a post process blur to the screen space reflection before applying it. I've used a change like that in a project and some custom builds, but it's kind of hacky and not really physically accurate (but it was good enough for me). I'll probably put it up as a patch or something but I don't know if that's a good solution for the actual engine source code.

Maybe someone else has some fancy (not quick'n'dirty'hacky) post process blur ideas?