Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Option for Environment's Reflected Light Soruce to be a Different Sky from the Background #3593

Closed
mrjustaguy opened this issue Nov 24, 2021 · 11 comments

Comments

@mrjustaguy
Copy link

Describe the project you are working on

Game with Metalic Surfaces and a Dynamic Sun

Describe the problem or limitation you are having in your project

Ambient Light and Reflections Need to be constant, which can be done for Ambient Light by using Color instead of Background/Sky, however Reflected lighting cannot be specified in a way that is decoupled from the Skybox.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Adding an ability to specify a new separate Sky Resource for Reflected (and Ambient could use it too) Light would allow for a Dynamic Skybox, while keeping Constant Background Lighting when desired.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Add an option for Specifying Skies to the Environment Lighting, If none set, use the one the Background uses.

If this enhancement will not be used often, can it be worked around with a few lines of script?

No way to Workaround atm.

Is there a reason why this should be core and not an add-on in the asset library?

Environment is Core.

@Calinou
Copy link
Member

Calinou commented Nov 25, 2021

In master, the reflected light is dissociated from the ambient light in Environment. However, there is currently no option to use a different sky for reflected light.

Ambient Light and Reflections Need to be constant, which can be done for Ambient Light by using Color instead of Background/Sky

"need" is probably not the correct term, as using a different sky for ambient lighting and reflections isn't physically accurate. If you find ambient light too bright when not using GI, decrease the Sky Contribution property and set a constant ambient light color (which is mixed with the ambient sky light color when Sky Contribution is greater than 0.0).

@mrjustaguy
Copy link
Author

mrjustaguy commented Nov 25, 2021

I think you misunderstood the issue, I don't use the Background Sky for Ambient light, because my background is constantly changing (day/night cycle) and I need Ambient Lighting to be constant, However Metal Surfaces don't get any Ambient Lighting, only Reflected Lighting, so I need Reflected Lighting to be constant too, for which I need to decouple Background Sky from the Sky that is contributing to Reflected Lighting, so that I have a Dynamic Sky and a Static Sky, providing the Backround+No Light and No Background+Light respectively.

One of the Reasons why I cannot use Dynamic Ambient Lighting is Because of mostly-Enclosed Interiors that must have some light, so that they aren't pitch black, and I also can't use Emissive materials, as they fail to provide the level of depth & metallic-ness that ambient lighting does, while Baked Lightmaps again fail to get a proper result, and just increases game size

The Only workaround I can think of is to use GI, however that has the problem of Performance being too costly, not to mention it isn't a part of the Forward Mobile Renderer.

Also, Ambient Light can just set Color, which isn't Physically accurate, and it's still an option, just like setting a separate Sky Material for the AL and RL should be an option (more so for RL, as AL usually works just fine with Color, something that RL wouldn't work well with probably)

@Calinou
Copy link
Member

Calinou commented Nov 25, 2021

The Only workaround I can think of is to use GI, however that has the problem of Performance being too costly, not to mention it isn't a part of the Forward Mobile Renderer.

Look into using ReflectionProbes, which are supported in the Vulkan Mobile backend 🙂

@mrjustaguy
Copy link
Author

that only somewhat gets the desired result, while not being global, and also not really working great with Little lighting in the scene. I mean it is a significant improvement over Nothing, but not as good as Sky Reflected Lighting is for what i'm looking for.

@clayjohn
Copy link
Member

@mrjustaguy Do you have any ideas how this should be exposed in the UI?

Right now the environment can only support one Sky. The Sky is exposed if either the background, reflections, or ambient, use MODE_SKY.

@Zireael07
Copy link

@mrjustaguy: Your use case would be solved if my proposal would be implemented: #148

@mrjustaguy
Copy link
Author

I'd add a Checkbox in Sky, that determines if one Sky is used or two are, and if two are, the 2nd would affect AL & RL if they are set to "Sky" (not background, that should use Sky 1)

I'd Call it something like
"Use Second Sky for Lighting" (Off by default, when On, add another set of Sky options)

@Calinou
Copy link
Member

Calinou commented Dec 14, 2021

I've found a workaround:

  • Add a PanoramaSky to the environment as usual.
  • Add a MeshInstance with a SphereMesh. Create a SpatialMaterial for it, enable Flags > Unshaded and set Parameters > Cull Mode to Front. Load your reflection panorama into the Albedo texture slot.
    • Set the MeshInstance's visibility layers to be only present on Layer 20 (click the dropdown arrow and uncheck all other layers).
  • Add a ReflectionProbe as a sibling of the SphereMesh. Do not place the ReflectionProbe as a child, or the node will be hidden when you hide the SphereMesh that acts as a reflection panorama.
    • Make the ReflectionProbe's extents cover the whole scene (with about 10% of padding on each side). This makes sure that ReflectionProbe blending does not get in the way.
    • Configure the ReflectionProbe's ambient light color to better match the rest of the scene. In the screenshot below, I use a dark gray-blue color.
    • Set the ReflectionProbe's cull mask to only contain Layer 20 (uncheck all other layers).
  • The texture will likely appear too dark due to sRGB conversion. To fix this, select the reflection panorama in the FileSystem dock, go to the import dock, set the compression to Lossless and click Reimport. You may have to play with other settings in the Import dock, but this is what fixed it for me.
  • Configure your Camera node to not render Layer 20 in the visibility section.
  • Hide and reshow the ReflectionProbe to make your changes visible in the editor.

image

In the running project:

2021-12-14_22 01 46

Example project (3.x): different_reflections.zip

@Calinou
Copy link
Member

Calinou commented Dec 20, 2021

@mrjustaguy Would you consider this workaround sufficient? Since I doubt this is a very frequent use case (it's not physically accurate), I'm not sure if it's worth the effort implementing this in core.

I haven't tested it in master yet, but the same approach should work there. However, you will need to keep the ReflectionProbe layers untouched until godotengine/godot#50195 is fixed.

@mrjustaguy
Copy link
Author

Yeah, I've been testing it a bit, and seems to work fine for the use case needed so I think this can be closed, albeit Forward Clustered Renderer might have issues until culling is fixed. Haven't tested how the issue affects this as I am not using that renderer for the project.

@Calinou
Copy link
Member

Calinou commented Jan 16, 2022

For further reference, there is a second way to use different reflections and sky if you don't want to use a ReflectionProbe:

  • Add a PanoramaSky reflection map to the environment. This is the opposite workflow as the one described above.
  • Add a MeshInstance with a SphereMesh (not parented to the Camera). Create a SpatialMaterial for it, enable Flags > Unshaded and set Parameters > Cull Mode to Front. Load your reflection panorama into the Albedo texture slot.
    • Set the SphereMesh's radius to be roughly equal to the Camera's Far property (and double that value for the height to keep proportions).
  • Add a RemoteTransform node as a child of the Camera. Set its Path property to point to the MeshInstance node and uncheck Rotation (so that the background sky does not rotate with the camera).
  • The sky texture will likely appear too dark due to sRGB conversion. To fix this, select the reflection panorama in the FileSystem dock, go to the import dock, set the compression to Lossless and click Reimport. You may have to play with other settings in the Import dock, but this is what fixed it for me.

Example project (3.x): different_reflections_2.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants