Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2020-04-07 00:19:01 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-04-07 00:23:48 +0300
commite05552f7c4ac27faa510048e8c010e4323acb569 (patch)
tree93c69c0ddbc296f610cbf39959ecf8c9f0963bb5 /intern
parent29b87b5615f60919977f2e383e8fdf30bdf498fb (diff)
Revert "Fix T74572: adaptive sampling not scaling render passes correctly"
This reverts commit 82a8da0ec38a70efde4a91957824c67d0e60b8ad. It was completely wrong. Fixes T75388.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/render/buffers.cpp89
-rw-r--r--intern/cycles/render/film.cpp3
-rw-r--r--intern/cycles/render/film.h1
3 files changed, 37 insertions, 56 deletions
diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index 22db8e875dc..2d89fb9ffba 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -165,35 +165,6 @@ bool RenderBuffers::copy_from_device()
return true;
}
-static const float *get_sample_count_pass(const vector<Pass> &passes, device_vector<float> &buffer)
-{
- int sample_offset = 0;
-
- for (const Pass &pass : passes) {
- if (pass.type != PASS_SAMPLE_COUNT) {
- sample_offset += pass.components;
- }
- else {
- return buffer.data() + sample_offset;
- }
- }
-
- return NULL;
-}
-
-static float get_pixel_pass_scale(const float rcp_sample,
- const float *sample_count,
- const int i,
- const int pass_stride)
-{
- if (sample_count) {
- return 1.0f / fabsf(sample_count[i * pass_stride]);
- }
- else {
- return rcp_sample;
- }
-}
-
bool RenderBuffers::get_denoising_pass_rect(
int type, float exposure, int sample, int components, float *pixels)
{
@@ -289,7 +260,22 @@ bool RenderBuffers::get_pass_rect(
return false;
}
- const float *sample_count = get_sample_count_pass(params.passes, buffer);
+ float *sample_count = NULL;
+ if (name == "Combined") {
+ int sample_offset = 0;
+ for (size_t j = 0; j < params.passes.size(); j++) {
+ Pass &pass = params.passes[j];
+ if (pass.type != PASS_SAMPLE_COUNT) {
+ sample_offset += pass.components;
+ continue;
+ }
+ else {
+ sample_count = buffer.data() + sample_offset;
+ break;
+ }
+ }
+ }
+
int pass_offset = 0;
for (size_t j = 0; j < params.passes.size(); j++) {
@@ -307,8 +293,8 @@ bool RenderBuffers::get_pass_rect(
float *in = buffer.data() + pass_offset;
int pass_stride = params.get_passes_size();
- const float rcp_sample = 1.0f / (float)sample;
- const float pass_exposure = (pass.exposure) ? exposure : 1.0f;
+ float scale = (pass.filter) ? 1.0f / (float)sample : 1.0f;
+ float scale_exposure = (pass.exposure) ? scale * exposure : scale;
int size = params.width * params.height;
@@ -326,36 +312,28 @@ bool RenderBuffers::get_pass_rect(
if (type == PASS_DEPTH) {
for (int i = 0; i < size; i++, in += pass_stride, pixels++) {
float f = *in;
- pixels[0] = (f == 0.0f) ? 1e10f : f;
- }
- }
- else if (type == PASS_OBJECT_ID || type == PASS_MATERIAL_ID) {
- for (int i = 0; i < size; i++, in += pass_stride, pixels++) {
- pixels[0] = *in;
+ pixels[0] = (f == 0.0f) ? 1e10f : f * scale_exposure;
}
}
else if (type == PASS_MIST) {
for (int i = 0; i < size; i++, in += pass_stride, pixels++) {
- const float scale = get_pixel_pass_scale(rcp_sample, sample_count, i, pass_stride);
- const float f = *in;
- pixels[0] = saturate(f * scale);
+ float f = *in;
+ pixels[0] = saturate(f * scale_exposure);
}
}
#ifdef WITH_CYCLES_DEBUG
else if (type == PASS_BVH_TRAVERSED_NODES || type == PASS_BVH_TRAVERSED_INSTANCES ||
type == PASS_BVH_INTERSECTIONS || type == PASS_RAY_BOUNCES) {
for (int i = 0; i < size; i++, in += pass_stride, pixels++) {
- const float scale = get_pixel_pass_scale(rcp_sample, sample_count, i, pass_stride);
- const float f = *in;
+ float f = *in;
pixels[0] = f * scale;
}
}
#endif
else {
for (int i = 0; i < size; i++, in += pass_stride, pixels++) {
- const float scale = get_pixel_pass_scale(rcp_sample, sample_count, i, pass_stride);
- const float f = *in;
- pixels[0] = f * scale * pass_exposure;
+ float f = *in;
+ pixels[0] = f * scale_exposure;
}
}
}
@@ -389,7 +367,7 @@ bool RenderBuffers::get_pass_rect(
float3 f = make_float3(in[0], in[1], in[2]);
float3 f_divide = make_float3(in_divide[0], in_divide[1], in_divide[2]);
- f = safe_divide_even_color(f * pass_exposure, f_divide);
+ f = safe_divide_even_color(f * exposure, f_divide);
pixels[0] = f.x;
pixels[1] = f.y;
@@ -399,9 +377,7 @@ bool RenderBuffers::get_pass_rect(
else {
/* RGB/vector */
for (int i = 0; i < size; i++, in += pass_stride, pixels += 3) {
- const float scale = get_pixel_pass_scale(rcp_sample, sample_count, i, pass_stride);
- const float scale_exposure = scale * pass_exposure;
- const float3 f = make_float3(in[0], in[1], in[2]);
+ float3 f = make_float3(in[0], in[1], in[2]);
pixels[0] = f.x * scale_exposure;
pixels[1] = f.y * scale_exposure;
@@ -449,9 +425,7 @@ bool RenderBuffers::get_pass_rect(
}
else if (type == PASS_CRYPTOMATTE) {
for (int i = 0; i < size; i++, in += pass_stride, pixels += 4) {
- const float scale = get_pixel_pass_scale(rcp_sample, sample_count, i, pass_stride);
- const float4 f = make_float4(in[0], in[1], in[2], in[3]);
-
+ float4 f = make_float4(in[0], in[1], in[2], in[3]);
/* x and z contain integer IDs, don't rescale them.
y and w contain matte weights, they get scaled. */
pixels[0] = f.x;
@@ -462,9 +436,12 @@ bool RenderBuffers::get_pass_rect(
}
else {
for (int i = 0; i < size; i++, in += pass_stride, pixels += 4) {
- const float scale = get_pixel_pass_scale(rcp_sample, sample_count, i, pass_stride);
- const float scale_exposure = scale * pass_exposure;
- const float4 f = make_float4(in[0], in[1], in[2], in[3]);
+ if (sample_count && sample_count[i * pass_stride] < 0.0f) {
+ scale = (pass.filter) ? -1.0f / (sample_count[i * pass_stride]) : 1.0f;
+ scale_exposure = (pass.exposure) ? scale * exposure : scale;
+ }
+
+ float4 f = make_float4(in[0], in[1], in[2], in[3]);
pixels[0] = f.x * scale_exposure;
pixels[1] = f.y * scale_exposure;
diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp
index c29810d1494..baf02901123 100644
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@ -76,6 +76,7 @@ void Pass::add(PassType type, vector<Pass> &passes, const char *name)
Pass pass;
pass.type = type;
+ pass.filter = true;
pass.exposure = false;
pass.divide_type = PASS_NONE;
if (name) {
@@ -92,6 +93,7 @@ void Pass::add(PassType type, vector<Pass> &passes, const char *name)
break;
case PASS_DEPTH:
pass.components = 1;
+ pass.filter = false;
break;
case PASS_MIST:
pass.components = 1;
@@ -112,6 +114,7 @@ void Pass::add(PassType type, vector<Pass> &passes, const char *name)
case PASS_OBJECT_ID:
case PASS_MATERIAL_ID:
pass.components = 1;
+ pass.filter = false;
break;
case PASS_EMISSION:
diff --git a/intern/cycles/render/film.h b/intern/cycles/render/film.h
index 0fe4fe89d5e..aae8fb404b0 100644
--- a/intern/cycles/render/film.h
+++ b/intern/cycles/render/film.h
@@ -42,6 +42,7 @@ class Pass {
public:
PassType type;
int components;
+ bool filter;
bool exposure;
PassType divide_type;
string name;