Facepunch / sbox-issues

177 stars 12 forks source link

Allow Directional Light to automatically align with 2D Skybox #6962

Open chrisspieler opened 1 week ago

chrisspieler commented 1 week ago

What can't you do?

I can't easily align a Directional Light in a scene with a 2D Skybox in the same scene.

How would you like it to work?

Directional Light should have a new property named SourceSkybox.

Whenever SourceSkybox is set, a worldspace Rotation pointing away from the brightest point in the sky (e.g. the sun or moon) should be calculated. Each frame, the WorldRotation of the GameObject that holds the Directional Light component should update so that light appears to shine from that point in the skybox.

Oh, and I guess you could make the LightColor automatically match as well.

What have you tried?

Manually rotating the directional light and eyeballing whether the shadows look correct.

Additional context

No response

samzanemesis commented 1 week ago

I don't understand or see much a point in this

chrisspieler commented 1 week ago

I don't understand or see much a point in this

It might be going too far to automatically rotate the light to match the sky. I was thinking too much about my specific use case.

What would definitely be useful is a method/button on directional light components that would come up with lighting that matches what's seen in the scene's skybox.

I view this feature request as the scene editor equivalent of the "Estimate lighting from HDR skybox" command that already existed in Hammer for light_environment entities.

Right now when I add sunlight/moonlight to a scene, appropriate settings for the light will depend on what the skybox texture looks like.

  1. I have to use my eyes to manually adjust the rotation of the directional light so that shadows line up with the light in the skybox.
  2. I have to use my eyes to manually adjust the color of the light so that it's as warm, cool, bright, or dark as the light in the skybox.

And in some hypothetical future where we have real-time soft shadows:

  1. I'd have to use my eyes to manually adjust how sharp or fuzzy shadows are to match the sunny/overcast conditions of the skybox.
    • Hammer already estimates this information to set "Sun Angle" for use with baked lighting.

I believe that all of this could be automated, and it would solve a minor annoyance I run in to virtually every time I add a skybox and a directional light to a scene.

This is not a mission-critical feature for anyone, but it is a convenient feature that already has a working implementation in Hammer.