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:
authorPatrick Mours <pmours@nvidia.com>2020-01-10 16:56:39 +0300
committerPatrick Mours <pmours@nvidia.com>2020-01-10 18:30:13 +0300
commit1cb938ef2c927d062439f06416bbf0bf8446625b (patch)
treee17865c5e0176d3c1a4b2b1376e6c83e0be48c81 /intern/cycles/kernel/kernel_film.h
parent1d149f6746a00cb49df202b1c49fcff4264dd226 (diff)
Cycles: Fix viewport rendering when displaying as byte and not half float
Commit rB7e61e597253f3ca75f2fb86a57212ca750ffbbe8 broke viewport rendering when not displaying as halfs. This fixes that by actually using the `scale` parameter that is passed into `film_map` and also de-duplicates code around it. Differential Revision: https://developer.blender.org/D6557
Diffstat (limited to 'intern/cycles/kernel/kernel_film.h')
-rw-r--r--intern/cycles/kernel/kernel_film.h33
1 files changed, 11 insertions, 22 deletions
diff --git a/intern/cycles/kernel/kernel_film.h b/intern/cycles/kernel/kernel_film.h
index 7a974e9d852..fc3a6152b79 100644
--- a/intern/cycles/kernel/kernel_film.h
+++ b/intern/cycles/kernel/kernel_film.h
@@ -70,12 +70,12 @@ ccl_device float4 film_map(KernelGlobals *kg, float4 rgba_in, float scale)
float4 result;
/* conversion to srgb */
- result.x = color_linear_to_srgb(rgba_in.x);
- result.y = color_linear_to_srgb(rgba_in.y);
- result.z = color_linear_to_srgb(rgba_in.z);
+ result.x = color_linear_to_srgb(rgba_in.x * scale);
+ result.y = color_linear_to_srgb(rgba_in.y * scale);
+ result.z = color_linear_to_srgb(rgba_in.z * scale);
/* clamp since alpha might be > 1.0 due to russian roulette */
- result.w = saturate(rgba_in.w);
+ result.w = saturate(rgba_in.w * scale);
return result;
}
@@ -108,19 +108,12 @@ ccl_device void kernel_film_convert_to_byte(KernelGlobals *kg,
bool use_display_sample_scale = (kernel_data.film.display_divide_pass_stride == -1);
float4 rgba_in = film_get_pass_result(kg, buffer, sample_scale, index, use_display_sample_scale);
- rgba += index;
-
/* map colors */
- if (use_display_sample_scale) {
- float4 float_result = film_map(kg, rgba_in, sample_scale);
- uchar4 byte_result = film_float_to_byte(float_result);
- *rgba = byte_result;
- }
- else {
- float4 float_result = film_map(kg, rgba_in, 1.0);
- uchar4 byte_result = film_float_to_byte(float_result);
- *rgba = byte_result;
- }
+ float4 float_result = film_map(kg, rgba_in, use_display_sample_scale ? sample_scale : 1.0f);
+ uchar4 uchar_result = film_float_to_byte(float_result);
+
+ rgba += index;
+ *rgba = uchar_result;
}
ccl_device void kernel_film_convert_to_half_float(KernelGlobals *kg,
@@ -134,16 +127,12 @@ ccl_device void kernel_film_convert_to_half_float(KernelGlobals *kg,
{
/* buffer offset */
int index = offset + x + y * stride;
+
bool use_display_sample_scale = (kernel_data.film.display_divide_pass_stride == -1);
float4 rgba_in = film_get_pass_result(kg, buffer, sample_scale, index, use_display_sample_scale);
ccl_global half *out = (ccl_global half *)rgba + index * 4;
- if (use_display_sample_scale) {
- float4_store_half(out, rgba_in, sample_scale);
- }
- else {
- float4_store_half(out, rgba_in, 1.0f);
- }
+ float4_store_half(out, rgba_in, use_display_sample_scale ? sample_scale : 1.0f);
}
CCL_NAMESPACE_END