Browse Source

Improve camera exposure functions

master
C. J. Howard 2 years ago
parent
commit
d339153bd5
6 changed files with 28 additions and 11 deletions
  1. +1
    -1
      src/game/menu.hpp
  2. +3
    -2
      src/game/state/nuptial-flight.cpp
  3. +2
    -1
      src/render/passes/material-pass.cpp
  4. +2
    -1
      src/render/passes/sky-pass.cpp
  5. +7
    -2
      src/scene/camera.cpp
  6. +13
    -4
      src/scene/camera.hpp

+ 1
- 1
src/game/menu.hpp View File

@ -35,7 +35,7 @@ static constexpr float4 active_color{1.0f, 1.0f, 1.0f, 1.0f};
static constexpr float4 inactive_color{1.0f, 1.0f, 1.0f, 0.5f};
/// Opacity of the menu background.
static constexpr float bg_opacity = 2.0f / 3.0f;
static constexpr float bg_opacity = 2.0f / 4.0f;
/// Padding of the mouseover bounds, as a percentage of the font size.
static constexpr float mouseover_padding = 0.1f;

+ 3
- 2
src/game/state/nuptial-flight.cpp View File

@ -115,7 +115,7 @@ nuptial_flight::nuptial_flight(game::context& ctx):
// Queue fade in
ctx.fade_transition_color->set_value({1, 1, 1});
ctx.function_queue.push(std::bind(&screen_transition::transition, ctx.fade_transition, 5.0f, true, math::lerp<float, float>, true, nullptr));
ctx.function_queue.push(std::bind(&screen_transition::transition, ctx.fade_transition, 5.0f, true, ease<float>::out_sine, true, nullptr));
// Queue control setup
ctx.function_queue.push(std::bind(&nuptial_flight::enable_controls, this));
@ -217,7 +217,8 @@ void nuptial_flight::setup_camera()
ctx.entity_registry->assign<entity::component::constraint_stack>(camera_eid, constraint_stack);
}
ctx.surface_camera->set_exposure(-14.0f);
float ev100 = 14.5f;
ctx.surface_camera->set_exposure(ev100);
}
void nuptial_flight::enable_controls()

+ 2
- 1
src/render/passes/material-pass.cpp View File

@ -133,7 +133,8 @@ void material_pass::render(const render::context& ctx, render::queue& queue) con
clip_depth[1] = ctx.camera->get_clip_far_tween().interpolate(ctx.alpha);
float log_depth_coef = 2.0f / std::log2(clip_depth[1] + 1.0f);
float camera_exposure = std::exp2(ctx.camera->get_exposure_tween().interpolate(ctx.alpha));
float camera_exposure = std::exp2(-ctx.camera->get_exposure_tween().interpolate(ctx.alpha));
//float camera_exposure = ctx.camera->get_exposure_tween().interpolate(ctx.alpha);
int active_material_flags = 0;

+ 2
- 1
src/render/passes/sky-pass.cpp View File

@ -105,7 +105,8 @@ void sky_pass::render(const render::context& ctx, render::queue& queue) const
float4x4 projection = camera.get_projection_tween().interpolate(ctx.alpha);
float4x4 view_projection = projection * view;
float4x4 model_view_projection = projection * model_view;
float exposure = std::exp2(camera.get_exposure_tween().interpolate(ctx.alpha));
float exposure = std::exp2(-camera.get_exposure_tween().interpolate(ctx.alpha));
//float exposure = camera.get_exposure_tween().interpolate(ctx.alpha);
// Interpolate observer altitude
float observer_altitude = observer_altitude_tween.interpolate(ctx.alpha);

+ 7
- 2
src/scene/camera.cpp View File

@ -144,9 +144,14 @@ void camera::set_orthographic(float clip_left, float clip_right, float clip_bott
view_frustum.set_matrix(view_projection[1]);
}
void camera::set_exposure(float exposure)
void camera::set_exposure(float ev100)
{
this->exposure[1] = exposure;
exposure[1] = ev100;
}
void camera::set_exposure(float f_number, float speed, float iso)
{
exposure[1] = std::log2((f_number * f_number) / speed * 100.0f / iso);
}
void camera::set_compositor(render::compositor* compositor)

+ 13
- 4
src/scene/camera.hpp View File

@ -78,11 +78,20 @@ public:
void set_orthographic(float clip_left, float clip_right, float clip_bottom, float clip_top, float clip_near, float clip_far);
/**
* Sets the camera's exposure.
* Sets the camera's ISO 100 exposure value directly
*
* @param exposure Exposure factor.
* @param ev100 ISO 100 exposure value.
*/
void set_exposure(float exposure);
void set_exposure(float ev100);
/**
* Sets the camera's ISO 100 exposure value given exposure settings.
*
* @param f_number F-number.
* @param speed Shutter speed, in seconds.
* @param iso ISO sensitivity value.
*/
void set_exposure(float f_number, float speed, float iso);
void set_compositor(render::compositor* compositor);
void set_composite_index(int index);
@ -113,7 +122,7 @@ public:
/// Returns the camera's view frustum.
const view_frustum_type& get_view_frustum() const;
/// Returns the camera's exposure.
/// Returns the camera's ISO 100 exposure value.
float get_exposure() const;
const render::compositor* get_compositor() const;

Loading…
Cancel
Save