Auto-exposure speed

This commit is contained in:
luboslenco 2019-05-01 10:52:42 +02:00
parent 6be8d83cfc
commit d05641b4a3
6 changed files with 15 additions and 12 deletions

View File

@ -284,12 +284,12 @@ void main() {
#endif
#ifdef _CExposure
fragColor.rgb *= compoExposureStrength;
fragColor.rgb += fragColor.rgb * compoExposureStrength;
#endif
#ifdef _AutoExposure
float expo = 2.0 - clamp(length(textureLod(histogram, vec2(0.5, 0.5), 0).rgb), 0.0, 1.0);
fragColor.rgb *= pow(expo, autoExposureStrength);
fragColor.rgb *= pow(expo, autoExposureStrength * 2.0);
#endif
#ifdef _CToneFilmic

View File

@ -1,13 +1,14 @@
#version 450
#include "compiled.inc"
uniform sampler2D tex;
in vec2 texCoord;
out vec4 fragColor;
void main() {
const float speed = 0.01;
fragColor.a = speed;
fragColor.a = 0.01 * autoExposureSpeed;
fragColor.rgb = textureLod(tex, vec2(0.5, 0.5), 0.0).rgb +
textureLod(tex, vec2(0.2, 0.2), 0.0).rgb +
textureLod(tex, vec2(0.8, 0.2), 0.0).rgb +

View File

@ -157,7 +157,7 @@ def build():
wrd.compo_defs += '_CGrain'
if rpdat.arm_sharpen:
wrd.compo_defs += '_CSharpen'
if bpy.data.scenes[0].cycles.film_exposure != 1.0:
if bpy.data.scenes[0].view_settings.exposure != 0.0:
wrd.compo_defs += '_CExposure'
if rpdat.arm_fog:
wrd.compo_defs += '_CFog'

View File

@ -33,7 +33,7 @@ def update_preset(self, context):
rpdat.rp_ssgi = 'SSAO'
rpdat.rp_ssr = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_autoexposure = False
rpdat.rp_motionblur = 'Off'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_texture_filter = 'Anisotropic'
@ -65,7 +65,7 @@ def update_preset(self, context):
rpdat.rp_ssgi = 'Off'
rpdat.rp_ssr = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_autoexposure = False
rpdat.rp_motionblur = 'Off'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_texture_filter = 'Linear'
@ -100,7 +100,7 @@ def update_preset(self, context):
rpdat.rp_ssr = True
rpdat.arm_ssr_half_res = False
rpdat.rp_bloom = True
rpdat.rp_eyeadapt = False
rpdat.rp_autoexposure = False
rpdat.rp_motionblur = 'Off'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_material_model = 'Full'
@ -133,7 +133,7 @@ def update_preset(self, context):
rpdat.rp_ssgi = 'Off'
rpdat.rp_ssr = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_autoexposure = False
rpdat.rp_motionblur = 'Off'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_texture_filter = 'Linear'
@ -277,7 +277,6 @@ class ArmRPListItem(bpy.types.PropertyGroup):
],
name="SSGI", description="Screen space global illumination", default='SSAO', update=update_renderpath)
rp_bloom: BoolProperty(name="Bloom", description="Bloom processing", default=False, update=update_renderpath)
rp_eyeadapt: BoolProperty(name="Eye Adaptation", description="Auto-exposure based on histogram", default=False, update=update_renderpath)
rp_motionblur: EnumProperty(
items=[('Off', 'Off', 'Off'),
('Camera', 'Camera', 'Camera'),
@ -438,6 +437,7 @@ class ArmRPListItem(bpy.types.PropertyGroup):
arm_shadowmap_split: FloatProperty(name="Cascade Split", description="Split factor for cascaded shadow maps, higher factor favors detail on close surfaces", default=0.8, update=assets.invalidate_shader_cache)
arm_shadowmap_bounds: FloatProperty(name="Cascade Bounds", description="Multiply cascade bounds to capture bigger area", default=1.0, update=assets.invalidate_compiled_data)
arm_autoexposure_strength: FloatProperty(name="Auto Exposure Strength", default=1.0, update=assets.invalidate_shader_cache)
arm_autoexposure_speed: FloatProperty(name="Auto Exposure Speed", default=1.0, update=assets.invalidate_shader_cache)
arm_ssrs_ray_step: FloatProperty(name="Step", default=0.01, update=assets.invalidate_shader_cache)
# Compositor
arm_letterbox: BoolProperty(name="Letterbox", default=False, update=assets.invalidate_shader_cache)

View File

@ -1031,6 +1031,7 @@ class ARM_PT_RenderPathCompositorPanel(bpy.types.Panel):
col = layout.column()
col.enabled = rpdat.rp_autoexposure
col.prop(rpdat, 'arm_autoexposure_strength', text='Strength')
col.prop(rpdat, 'arm_autoexposure_speed', text='Speed')
layout.prop(rpdat, 'arm_lens_texture')
layout.prop(rpdat, 'arm_lut_texture')

View File

@ -521,6 +521,7 @@ const int volumSteps = """ + str(rpdat.arm_volumetric_light_steps) + """;
if rpdat.rp_autoexposure:
f.write(
"""const float autoExposureStrength = """ + str(rpdat.arm_autoexposure_strength) + """;
const float autoExposureSpeed = """ + str(rpdat.arm_autoexposure_speed) + """;
""")
# Compositor
@ -544,9 +545,9 @@ const int volumSteps = """ + str(rpdat.arm_volumetric_light_steps) + """;
"""const float compoSharpenStrength = """ + str(round(rpdat.arm_sharpen_strength * 100) / 100) + """;
""")
if bpy.data.scenes[0].cycles.film_exposure != 1.0:
if bpy.data.scenes[0].view_settings.exposure != 0.0:
f.write(
"""const float compoExposureStrength = """ + str(round(bpy.data.scenes[0].cycles.film_exposure * 100) / 100) + """;
"""const float compoExposureStrength = """ + str(round(bpy.data.scenes[0].view_settings.exposure * 100) / 100) + """;
""")
if rpdat.arm_fog: