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
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/render/buffers.cpp')
-rw-r--r--intern/cycles/render/buffers.cpp74
1 files changed, 54 insertions, 20 deletions
diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index 4cd8b3726d3..f901885e679 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -147,7 +147,7 @@ bool RenderBuffers::copy_from_device()
return true;
}
-bool RenderBuffers::get_denoising_pass_rect(int offset, float exposure, int sample, int components, float *pixels)
+bool RenderBuffers::get_denoising_pass_rect(int type, float exposure, int sample, int components, float *pixels)
{
if(buffer.data() == NULL) {
return false;
@@ -155,19 +155,20 @@ bool RenderBuffers::get_denoising_pass_rect(int offset, float exposure, int samp
float invsample = 1.0f/sample;
float scale = invsample;
- bool variance = (offset == DENOISING_PASS_NORMAL_VAR) ||
- (offset == DENOISING_PASS_ALBEDO_VAR) ||
- (offset == DENOISING_PASS_DEPTH_VAR) ||
- (offset == DENOISING_PASS_COLOR_VAR);
-
- if(offset == DENOISING_PASS_COLOR || offset == DENOISING_PASS_CLEAN) {
- scale *= exposure;
+ bool variance = (type == DENOISING_PASS_NORMAL_VAR) ||
+ (type == DENOISING_PASS_ALBEDO_VAR) ||
+ (type == DENOISING_PASS_DEPTH_VAR) ||
+ (type == DENOISING_PASS_COLOR_VAR);
+
+ float scale_exposure = scale;
+ if(type == DENOISING_PASS_COLOR || type == DENOISING_PASS_CLEAN) {
+ scale_exposure *= exposure;
}
- else if(offset == DENOISING_PASS_COLOR_VAR) {
- scale *= exposure*exposure;
+ else if(type == DENOISING_PASS_COLOR_VAR) {
+ scale_exposure *= exposure*exposure;
}
- offset += params.get_denoising_offset();
+ int offset = type + params.get_denoising_offset();
int pass_stride = params.get_passes_size();
int size = params.width*params.height;
@@ -181,14 +182,14 @@ bool RenderBuffers::get_denoising_pass_rect(int offset, float exposure, int samp
if(components == 1) {
for(int i = 0; i < size; i++, mean += pass_stride, var += pass_stride, pixels++) {
- pixels[0] = max(0.0f, var[0] - mean[0]*mean[0]*invsample)*scale;
+ pixels[0] = max(0.0f, var[0] - mean[0]*mean[0]*invsample)*scale_exposure;
}
}
else if(components == 3) {
for(int i = 0; i < size; i++, mean += pass_stride, var += pass_stride, pixels += 3) {
- pixels[0] = max(0.0f, var[0] - mean[0]*mean[0]*invsample)*scale;
- pixels[1] = max(0.0f, var[1] - mean[1]*mean[1]*invsample)*scale;
- pixels[2] = max(0.0f, var[2] - mean[2]*mean[2]*invsample)*scale;
+ pixels[0] = max(0.0f, var[0] - mean[0]*mean[0]*invsample)*scale_exposure;
+ pixels[1] = max(0.0f, var[1] - mean[1]*mean[1]*invsample)*scale_exposure;
+ pixels[2] = max(0.0f, var[2] - mean[2]*mean[2]*invsample)*scale_exposure;
}
}
else {
@@ -200,14 +201,28 @@ bool RenderBuffers::get_denoising_pass_rect(int offset, float exposure, int samp
if(components == 1) {
for(int i = 0; i < size; i++, in += pass_stride, pixels++) {
- pixels[0] = in[0]*scale;
+ pixels[0] = in[0]*scale_exposure;
}
}
else if(components == 3) {
for(int i = 0; i < size; i++, in += pass_stride, pixels += 3) {
- pixels[0] = in[0]*scale;
- pixels[1] = in[1]*scale;
- pixels[2] = in[2]*scale;
+ pixels[0] = in[0]*scale_exposure;
+ pixels[1] = in[1]*scale_exposure;
+ pixels[2] = in[2]*scale_exposure;
+ }
+ }
+ else if(components == 4) {
+ assert(type == DENOISING_PASS_COLOR);
+
+ /* Since the alpha channel is not involved in denoising, output the Combined alpha channel. */
+ assert(params.passes[0].type == PASS_COMBINED);
+ float *in_combined = buffer.data();
+
+ for(int i = 0; i < size; i++, in += pass_stride, in_combined += pass_stride, pixels += 4) {
+ pixels[0] = in[0]*scale_exposure;
+ pixels[1] = in[1]*scale_exposure;
+ pixels[2] = in[2]*scale_exposure;
+ pixels[3] = saturate(in_combined[3]*scale);
}
}
else {
@@ -218,7 +233,7 @@ bool RenderBuffers::get_denoising_pass_rect(int offset, float exposure, int samp
return true;
}
-bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int components, float *pixels)
+bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int components, float *pixels, const string &name)
{
if(buffer.data() == NULL) {
return false;
@@ -234,6 +249,14 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
continue;
}
+ /* Tell Cryptomatte passes apart by their name. */
+ if(pass.type == PASS_CRYPTOMATTE) {
+ if(pass.name != name) {
+ pass_offset += pass.components;
+ continue;
+ }
+ }
+
float *in = buffer.data() + pass_offset;
int pass_stride = params.get_passes_size();
@@ -370,6 +393,17 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
pixels[3] = f.w*invw;
}
}
+ else if(type == PASS_CRYPTOMATTE) {
+ for(int i = 0; i < size; i++, in += pass_stride, pixels += 4) {
+ 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;
+ pixels[1] = f.y * scale;
+ pixels[2] = f.z;
+ pixels[3] = f.w * scale;
+ }
+ }
else {
for(int i = 0; i < size; i++, in += pass_stride, pixels += 4) {
float4 f = make_float4(in[0], in[1], in[2], in[3]);