Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions doc/classes/Environment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@
<member name="ssr_max_steps" type="int" setter="set_ssr_max_steps" getter="get_ssr_max_steps" default="64">
The maximum number of steps for screen-space reflections. Higher values are slower.
</member>
<member name="tonemap_agx_contrast" type="float" setter="set_tonemap_agx_contrast" getter="get_tonemap_agx_contrast" default="1.25">
Increasing [member tonemap_agx_contrast] will make dark values darker and bright values brighter. Produces a higher quality result than [member adjustment_contrast] without any additional performance cost, but is only available when using the [constant TONE_MAPPER_AGX] tonemapper.
</member>
<member name="tonemap_agx_white" type="float" setter="set_tonemap_agx_white" getter="get_tonemap_agx_white" default="16.29">
The white reference value for tonemapping, which indicates where bright white is located in the scale of values provided to the tonemapper. For photorealistic lighting, it is recommended to set [member tonemap_agx_white] to at least [code]6.0[/code]. Higher values result in less blown out highlights, but may make the scene appear lower contrast. [member tonemap_agx_white] is the same as [member tonemap_white], but is only effective with the [constant TONE_MAPPER_AGX] tonemapper. See also [member tonemap_exposure].
[b]Note:[/b] When using the Mobile renderer with [member Viewport.use_hdr_2d] disabled, [member tonemap_agx_white] is ignored and a white value of [code]2.0[/code] will always be used instead.
</member>
<member name="tonemap_exposure" type="float" setter="set_tonemap_exposure" getter="get_tonemap_exposure" default="1.0">
Adjusts the brightness of values before they are provided to the tonemapper. Higher [member tonemap_exposure] values result in a brighter image. See also [member tonemap_white].
[b]Note:[/b] Values provided to the tonemapper will also be multiplied by [code]2.0[/code] and [code]1.8[/code] for [constant TONE_MAPPER_FILMIC] and [constant TONE_MAPPER_ACES] respectively to produce a similar apparent brightness as [constant TONE_MAPPER_LINEAR].
Expand All @@ -323,8 +330,8 @@
The tonemapping mode to use. Tonemapping is the process that "converts" HDR values to be suitable for rendering on an LDR display. (Godot doesn't support rendering on HDR displays yet.)
</member>
<member name="tonemap_white" type="float" setter="set_tonemap_white" getter="get_tonemap_white" default="1.0">
The white reference value for tonemapping, which indicates where bright white is located in the scale of values provided to the tonemapper. For photorealistic lighting, recommended values are between [code]6.0[/code] and [code]8.0[/code]. Higher values result in less blown out highlights, but may make the scene appear lower contrast. See also [member tonemap_exposure].
[b]Note:[/b] [member tonemap_white] is ignored when using [constant TONE_MAPPER_LINEAR] or [constant TONE_MAPPER_AGX].
The white reference value for tonemapping, which indicates where bright white is located in the scale of values provided to the tonemapper. For photorealistic lighting, it is recommended to set [member tonemap_white] to at least [code]6.0[/code]. Higher values result in less blown out highlights, but may make the scene appear lower contrast. [member tonemap_agx_white] will be used instead when using the [constant TONE_MAPPER_AGX] tonemapper. See also [member tonemap_exposure].
[b]Note:[/b] [member tonemap_white] must be set to [code]2.0[/code] or lower on the Mobile renderer to produce bright images.
</member>
<member name="volumetric_fog_albedo" type="Color" setter="set_volumetric_fog_albedo" getter="get_volumetric_fog_albedo" default="Color(1, 1, 1, 1)">
The [Color] of the volumetric fog when interacting with lights. Mist and fog have an albedo close to [code]Color(1, 1, 1, 1)[/code] while smoke has a darker albedo.
Expand Down Expand Up @@ -431,8 +438,7 @@
[b]Note:[/b] This tonemapping operator is called "ACES Fitted" in Godot 3.x.
</constant>
<constant name="TONE_MAPPER_AGX" value="4" enum="ToneMapper">
Uses a film-like tonemapping curve and desaturates bright values for a more realistic appearance. Better than other tonemappers at maintaining the hue of colors as they become brighter. The slowest tonemapping option.
[b]Note:[/b] [member tonemap_white] is fixed at a value of [code]16.29[/code], which makes [constant TONE_MAPPER_AGX] unsuitable for use with the Mobile rendering method.
Uses an adjustable film-like tonemapping curve and desaturates bright values for a more realistic appearance. Better than other tonemappers at maintaining the hue of colors as they become brighter. The slowest tonemapping option.
</constant>
<constant name="GLOW_BLEND_MODE_ADDITIVE" value="0" enum="GlowBlendMode">
Adds the glow effect to the scene.
Expand Down
11 changes: 9 additions & 2 deletions doc/classes/RenderingServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,14 @@
Sets the variables to be used with the "tonemap" post-process effect. See [Environment] for more details.
</description>
</method>
<method name="environment_set_tonemap_agx_contrast">
<return type="void" />
<param index="0" name="env" type="RID" />
<param index="1" name="agx_contrast" type="float" />
<description>
See [member Environment.tonemap_agx_contrast] for more details.
</description>
</method>
<method name="environment_set_volumetric_fog">
<return type="void" />
<param index="0" name="env" type="RID" />
Expand Down Expand Up @@ -5509,8 +5517,7 @@
[b]Note:[/b] This tonemapping operator is called "ACES Fitted" in Godot 3.x.
</constant>
<constant name="ENV_TONE_MAPPER_AGX" value="4" enum="EnvironmentToneMapper">
Uses a film-like tonemapping curve and desaturates bright values for a more realistic appearance. Better than other tonemappers at maintaining the hue of colors as they become brighter. The slowest tonemapping option.
[b]Note:[/b] [member Environment.tonemap_white] is fixed at a value of [code]16.29[/code], which makes [constant ENV_TONE_MAPPER_AGX] unsuitable for use with the Mobile rendering method.
Uses an adjustable film-like tonemapping curve and desaturates bright values for a more realistic appearance. Better than other tonemappers at maintaining the hue of colors as they become brighter. The slowest tonemapping option.
</constant>
<constant name="ENV_SSR_ROUGHNESS_QUALITY_DISABLED" value="0" enum="EnvironmentSSRRoughnessQuality">
Lowest quality of roughness filter for screen-space reflections. Rough materials will not have blurrier screen-space reflections compared to smooth (non-rough) materials. This is the fastest option.
Expand Down
9 changes: 6 additions & 3 deletions drivers/gles3/rasterizer_scene_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2380,9 +2380,12 @@ void RasterizerSceneGLES3::render_scene(const Ref<RenderSceneBuffers> &p_render_
}

tonemap_ubo.exposure = environment_get_exposure(render_data.environment);
tonemap_ubo.white = environment_get_white(render_data.environment);
tonemap_ubo.tonemapper = int32_t(environment_get_tone_mapper(render_data.environment));

RendererEnvironmentStorage::TonemapParameters params = environment_get_tonemap_parameters(render_data.environment, false);
tonemap_ubo.tonemapper_params[0] = params.tonemapper_params[0];
tonemap_ubo.tonemapper_params[1] = params.tonemapper_params[1];
tonemap_ubo.tonemapper_params[2] = params.tonemapper_params[2];
tonemap_ubo.tonemapper_params[3] = params.tonemapper_params[3];
tonemap_ubo.brightness = environment_get_adjustments_brightness(render_data.environment);
tonemap_ubo.contrast = environment_get_adjustments_contrast(render_data.environment);
tonemap_ubo.saturation = environment_get_adjustments_saturation(render_data.environment);
Expand Down Expand Up @@ -2840,7 +2843,7 @@ void RasterizerSceneGLES3::_render_post_processing(const RenderDataGLES3 *p_rend
glow_hdr_bleed_threshold = environment_get_glow_hdr_bleed_threshold(p_render_data->environment);
glow_hdr_bleed_scale = environment_get_glow_hdr_bleed_scale(p_render_data->environment);
glow_hdr_luminance_cap = environment_get_glow_hdr_luminance_cap(p_render_data->environment);
srgb_white = environment_get_white(p_render_data->environment);
srgb_white = environment_get_white(p_render_data->environment, false);
}

if (glow_enabled) {
Expand Down
4 changes: 2 additions & 2 deletions drivers/gles3/rasterizer_scene_gles3.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,14 @@ class RasterizerSceneGLES3 : public RendererSceneRender {

struct TonemapUBO {
float exposure = 1.0;
float white = 1.0;
int32_t tonemapper = 0;
int32_t pad = 0;

int32_t pad2 = 0;
float tonemapper_params[4] = { 0.0, 0.0, 0.0, 0.0 };
float brightness = 1.0;
float contrast = 1.0;
float saturation = 1.0;
int32_t pad3 = 0;
};
static_assert(sizeof(TonemapUBO) % 16 == 0, "Tonemap UBO size must be a multiple of 16 bytes");

Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/shaders/effects/post.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void main() {
color.rgb *= s4ao(uv_interp); // The USE_SSAO_X controls the number of samples.
#endif

color.rgb = apply_tonemapping(color.rgb, white);
color.rgb = apply_tonemapping(color.rgb);

#ifdef USE_BCS
// Apply brightness:
Expand Down
4 changes: 2 additions & 2 deletions drivers/gles3/shaders/scene.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2534,7 +2534,7 @@ void main() {
// Tonemap before writing as we are writing to an sRGB framebuffer
frag_color.rgb *= exposure;
#ifdef APPLY_TONEMAPPING
frag_color.rgb = apply_tonemapping(frag_color.rgb, white);
frag_color.rgb = apply_tonemapping(frag_color.rgb);
#endif
frag_color.rgb = linear_to_srgb(frag_color.rgb);

Expand Down Expand Up @@ -2806,7 +2806,7 @@ void main() {
// Tonemap before writing as we are writing to an sRGB framebuffer
additive_light_color *= exposure;
#ifdef APPLY_TONEMAPPING
additive_light_color = apply_tonemapping(additive_light_color, white);
additive_light_color = apply_tonemapping(additive_light_color);
#endif
additive_light_color = linear_to_srgb(additive_light_color);

Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/shaders/sky.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void main() {

color *= exposure;
#ifdef APPLY_TONEMAPPING
color = apply_tonemapping(color, white);
color = apply_tonemapping(color);
#endif
color = linear_to_srgb(color);

Expand Down
Loading