godotengine / godot

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

Physical sky material missing the sun disk #65921

Open ghost opened 2 years ago

ghost commented 2 years ago

Godot version

4.0 beta 1

System information

Windows 11

Issue description

PhysicalSkyMaterial doesn't have a sun disk. So the sun disk scale property doesn't affect anything.

Workaround: Convert PhysicalSkyMaterial to shader material. Replace LIGHT0_SIZE constant with 0.1

float sunAngularDiameterCos = cos(LIGHT0_SIZE * sun_disk_scale);
float sunAngularDiameterCos2 = cos(LIGHT0_SIZE * sun_disk_scale*0.5);
float sunAngularDiameterCos = cos(0.1 * sun_disk_scale);
float sunAngularDiameterCos2 = cos(0.1 * sun_disk_scale*0.5);

My guess is something with the LIGHT0_SIZE.

Steps to reproduce

Minimal reproduction project

Sun.zip

Calinou commented 2 years ago

Sun Disk Scale multiplies the DirectionalLight3D's Angular Distance property. By default, this is 0 for performance reasons (as rendering PCSS shadows is expensive).

I suppose Sun Disk Scale should be replaced with Sun Disk Size Offset instead, which would add/subtract to the light's size. This way, you can use a non-zero light size even if the light's actual angular distance is 0.

JohanAR commented 1 year ago

If someone is going to change the sun algorithm, would it be possible to make it much brighter without increasing the light source's energy? Looks a bit dull for a sun IMO

Calinou commented 1 year ago

@JohanAR Increasing the DirectionalLight3D's angular distance should make the sun more visible as I mentioned. If you don't want to increase its angular distance for performance reasons, you could alter the actual sun disk size right now using a custom sky shader (by creating a custom shader from the current sky shader using the Convert to ShaderMaterial resource dropdown option).

JohanAR commented 1 year ago

@Calinou I converted it to a shadermaterial, and changed sun disc scale to sun disc offset like you previously suggested. But I think the resulting sun looks a bit too gray, even when high up in the sky. Using the colour picker I get the value #eeebe2. So in my custom shader I multiplied L0 with 5.0 to make it brighter

Calinou commented 1 year ago

cc @clayjohn

MaretaDagostino commented 4 months ago

Please ignore my commit above, it does not contain any code useful here! This was automatically generated by Github from a temporary commit in my repository. I will implement another shader with modifiable clouds, moon, stars as I used in Godot 3.5 before.