Implement per-light Specular property in DirectionalLight3D

This commit is contained in:
Andrew_Shobbrook 2023-08-18 11:59:57 +10:00 committed by Hugo Locurcio
parent 08508d2e01
commit e42def12d0
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
7 changed files with 9 additions and 6 deletions

View file

@ -98,7 +98,7 @@
[b]Note:[/b] [member light_size] is not affected by [member Node3D.scale] (the light's scale or its parent's scale).
[b]Note:[/b] PCSS for positional lights is only supported in the Forward+ and Mobile rendering methods, not Compatibility.
</member>
<member name="light_specular" type="float" setter="set_param" getter="get_param" default="0.5">
<member name="light_specular" type="float" setter="set_param" getter="get_param" default="1.0">
The intensity of the specular blob in objects affected by the light. At [code]0[/code], the light becomes a pure diffuse light. When not baking emission, this can be used to avoid unrealistic reflections when placing lights above an emissive surface.
</member>
<member name="light_temperature" type="float" setter="set_temperature" getter="get_temperature">

View file

@ -13,6 +13,7 @@
<link title="Faking global illumination">$DOCS_URL/tutorials/3d/global_illumination/faking_global_illumination.html</link>
</tutorials>
<members>
<member name="light_specular" type="float" setter="set_param" getter="get_param" overrides="Light3D" default="0.5" />
<member name="omni_attenuation" type="float" setter="set_param" getter="get_param" default="1.0">
Controls the distance attenuation function for omnilights.
A value of [code]0.0[/code] will maintain a constant brightness through most of the range, but smoothly attenuate the light at the edge of the range. Use a value of [code]2.0[/code] for physically accurate lights as it results in the proper inverse square attenutation.

View file

@ -14,6 +14,7 @@
<link title="Third Person Shooter (TPS) Demo">https://godotengine.org/asset-library/asset/2710</link>
</tutorials>
<members>
<member name="light_specular" type="float" setter="set_param" getter="get_param" overrides="Light3D" default="0.5" />
<member name="shadow_bias" type="float" setter="set_param" getter="get_param" overrides="Light3D" default="0.03" />
<member name="shadow_normal_bias" type="float" setter="set_param" getter="get_param" overrides="Light3D" default="1.0" />
<member name="spot_angle" type="float" setter="set_param" getter="get_param" default="45.0">

View file

@ -2138,7 +2138,7 @@ void main() {
continue;
}
#endif
light_compute(normal, normalize(directional_lights[i].direction), normalize(view), directional_lights[i].size, directional_lights[i].color * directional_lights[i].energy, true, 1.0, f0, roughness, metallic, 1.0, albedo, alpha, screen_uv,
light_compute(normal, normalize(directional_lights[i].direction), normalize(view), directional_lights[i].size, directional_lights[i].color * directional_lights[i].energy, true, 1.0, f0, roughness, metallic, directional_lights[i].specular, albedo, alpha, screen_uv,
#ifdef LIGHT_BACKLIGHT_USED
backlight,
#endif
@ -2440,7 +2440,7 @@ void main() {
#endif // SHADOWS_DISABLED
#ifndef USE_VERTEX_LIGHTING
light_compute(normal, normalize(directional_lights[directional_shadow_index].direction), normalize(view), directional_lights[directional_shadow_index].size, directional_lights[directional_shadow_index].color * directional_lights[directional_shadow_index].energy, true, directional_shadow, f0, roughness, metallic, 1.0, albedo, alpha, screen_uv,
light_compute(normal, normalize(directional_lights[directional_shadow_index].direction), normalize(view), directional_lights[directional_shadow_index].size, directional_lights[directional_shadow_index].color * directional_lights[directional_shadow_index].energy, true, directional_shadow, f0, roughness, metallic, directional_lights[directional_shadow_index].specular, albedo, alpha, screen_uv,
#ifdef LIGHT_BACKLIGHT_USED
backlight,
#endif

View file

@ -545,7 +545,7 @@ void DirectionalLight3D::_validate_property(PropertyInfo &p_property) const {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "light_size" || p_property.name == "light_projector" || p_property.name == "light_specular") {
if (p_property.name == "light_size" || p_property.name == "light_projector") {
// Not implemented in DirectionalLight3D (`light_size` is replaced by `light_angular_distance`).
p_property.usage = PROPERTY_USAGE_NONE;
}
@ -595,6 +595,7 @@ DirectionalLight3D::DirectionalLight3D() :
// Increase the default shadow normal bias to better suit most scenes.
set_param(PARAM_SHADOW_NORMAL_BIAS, 2.0);
set_param(PARAM_INTENSITY, 100000.0); // Specified in Lux, approximate mid-day sun.
set_param(PARAM_SPECULAR, 1.0);
set_shadow_mode(SHADOW_PARALLEL_4_SPLITS);
blend_splits = false;
set_sky_mode(SKY_MODE_LIGHT_AND_SKY);

View file

@ -2351,7 +2351,7 @@ void fragment_shader(in SceneData scene_data) {
#else
directional_lights.data[i].color * directional_lights.data[i].energy * tint,
#endif
true, shadow, f0, orms, 1.0, albedo, alpha, screen_uv,
true, shadow, f0, orms, directional_lights.data[i].specular, albedo, alpha, screen_uv,
#ifdef LIGHT_BACKLIGHT_USED
backlight,
#endif

View file

@ -1647,7 +1647,7 @@ void main() {
light_compute(normal, directional_lights.data[i].direction, view, size_A,
directional_lights.data[i].color * directional_lights.data[i].energy * tint,
true, shadow, f0, orms, 1.0, albedo, alpha, screen_uv,
true, shadow, f0, orms, directional_lights.data[i].specular, albedo, alpha, screen_uv,
#ifdef LIGHT_BACKLIGHT_USED
backlight,
#endif