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
5 changes: 3 additions & 2 deletions internal/RendererCPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,13 @@ void Ray::Cpu::Renderer<SIMDPolicy>::RenderScene(const SceneBase &scene, RegionC
std::shared_lock<std::shared_timed_mutex> scene_lock(s.mtx_);

const camera_t &cam = s.cams_[s.current_cam()._index];
const float cam_exposure = std::pow(2.0f, cam.exposure);

++region.iteration;

cache_grid_params_t cache_grid_params;
memcpy(cache_grid_params.cam_pos_curr, cam.origin, 3 * sizeof(float));
cache_grid_params.exposure = std::pow(2.0f, cam.exposure);
cache_grid_params.exposure = cam_exposure;

const scene_data_t sc_data = {s.env_,
s.mesh_instances_.empty() ? nullptr : &s.mesh_instances_[0],
Expand Down Expand Up @@ -575,7 +576,7 @@ void Ray::Cpu::Renderer<SIMDPolicy>::RenderScene(const SceneBase &scene, RegionC
tonemap_params.view_transform = cam.view_transform;
tonemap_params.inv_gamma = (1.0f / cam.gamma);

Ref::fvec4 exposure = std::pow(2.0f, cam.exposure);
Ref::fvec4 exposure = cam_exposure;
exposure.set<3>(1.0f);

const float variance_threshold =
Expand Down
7 changes: 3 additions & 4 deletions internal/RendererDX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ void Ray::Dx::Renderer::RenderScene(const SceneBase &scene, RegionContext &regio
++region.iteration;

const Ray::camera_t &cam = s.cams_[s.current_cam()._index];
const float cam_exposure = std::pow(2.0f, cam.exposure);

// TODO: Use common command buffer for all uploads
if (cam.filter != filter_table_filter_ || cam.filter_width != filter_table_width_) {
Expand Down Expand Up @@ -347,7 +348,7 @@ void Ray::Dx::Renderer::RenderScene(const SceneBase &scene, RegionContext &regio

cache_grid_params_t cache_grid_params;
memcpy(cache_grid_params.cam_pos_curr, cam.origin, 3 * sizeof(float));
cache_grid_params.exposure = std::pow(2.0f, cam.exposure);
cache_grid_params.exposure = cam_exposure;

#if !RUN_IN_LOCKSTEP
if (ctx_->in_flight_fence(ctx_->backend_frame)->GetCompletedValue() < ctx_->fence_values[ctx_->backend_frame]) {
Expand Down Expand Up @@ -637,13 +638,11 @@ void Ray::Dx::Renderer::RenderScene(const SceneBase &scene, RegionContext &regio
{ // prepare result
DebugMarker _(ctx_.get(), cmd_buf, "Ray::Prepare Result");

const float exposure = std::pow(2.0f, cam.exposure);

// factor used to compute incremental average
const float mix_factor = 1.0f / float(region.iteration);
const float half_mix_factor = 1.0f / float((region.iteration + 1) / 2);

kernel_MixIncremental(cmd_buf, mix_factor, half_mix_factor, rect, region.iteration, exposure, temp_buf0_,
kernel_MixIncremental(cmd_buf, mix_factor, half_mix_factor, rect, region.iteration, cam_exposure, temp_buf0_,
temp_buf1_, temp_depth_normals_buf_, required_samples_buf_, full_buf_, half_buf_,
base_color_buf_, depth_normals_buf_);
}
Expand Down
7 changes: 3 additions & 4 deletions internal/RendererVK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ void Ray::Vk::Renderer::RenderScene(const SceneBase &scene, RegionContext &regio
++region.iteration;

const Ray::camera_t &cam = s.cams_[s.current_cam()._index];
const float cam_exposure = std::pow(2.0f, cam.exposure);

// TODO: Use common command buffer for all uploads
if (cam.filter != filter_table_filter_ || cam.filter_width != filter_table_width_) {
Expand Down Expand Up @@ -396,7 +397,7 @@ void Ray::Vk::Renderer::RenderScene(const SceneBase &scene, RegionContext &regio

cache_grid_params_t cache_grid_params;
memcpy(cache_grid_params.cam_pos_curr, cam.origin, 3 * sizeof(float));
cache_grid_params.exposure = std::pow(2.0f, cam.exposure);
cache_grid_params.exposure = cam_exposure;

CommandBuffer cmd_buf = {};
if (external_cmd_buf_.vk_cmd_buf) {
Expand Down Expand Up @@ -690,13 +691,11 @@ void Ray::Vk::Renderer::RenderScene(const SceneBase &scene, RegionContext &regio
{ // prepare result
DebugMarker _(ctx_.get(), cmd_buf, "Prepare Result");

const float exposure = std::pow(2.0f, cam.exposure);

// factor used to compute incremental average
const float mix_factor = 1.0f / float(region.iteration);
const float half_mix_factor = 1.0f / float((region.iteration + 1) / 2);

kernel_MixIncremental(cmd_buf, mix_factor, half_mix_factor, rect, region.iteration, exposure, temp_buf0_,
kernel_MixIncremental(cmd_buf, mix_factor, half_mix_factor, rect, region.iteration, cam_exposure, temp_buf0_,
temp_buf1_, temp_depth_normals_buf_, required_samples_buf_, full_buf_, half_buf_,
base_color_buf_, depth_normals_buf_);
}
Expand Down