diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-31 03:49:38 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-31 03:49:38 +0400 |
commit | 29f6616d609fbd92cf313b0fdec555c2fcb4ede0 (patch) | |
tree | e0c9500368c5210071cb841ea86f5674b0cf6f25 /intern/cycles/kernel/kernel_film.h | |
parent | 60ff60dcdc9f43891fb8a19e10f9bb7964a539bf (diff) |
Cycles: viewport render now takes scene color management settings into account,
except for curves, that's still missing from the OpenColorIO GLSL shader.
The pixels are stored in a half float texture, converterd from full float with
native GPU instructions and SIMD on the CPU, so it should be pretty quick.
Using a GLSL shader is useful for GPU render because it avoids a copy through
CPU memory.
Diffstat (limited to 'intern/cycles/kernel/kernel_film.h')
-rw-r--r-- | intern/cycles/kernel/kernel_film.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/intern/cycles/kernel/kernel_film.h b/intern/cycles/kernel/kernel_film.h index ba2149cc709..3ef33a2703b 100644 --- a/intern/cycles/kernel/kernel_film.h +++ b/intern/cycles/kernel/kernel_film.h @@ -16,9 +16,8 @@ CCL_NAMESPACE_BEGIN -__device float4 film_map(KernelGlobals *kg, float4 irradiance, int sample) +__device float4 film_map(KernelGlobals *kg, float4 irradiance, float scale) { - float scale = 1.0f/(float)(sample+1); float exposure = kernel_data.film.exposure; float4 result = irradiance*scale; @@ -46,9 +45,9 @@ __device uchar4 film_float_to_byte(float4 color) return result; } -__device void kernel_film_tonemap(KernelGlobals *kg, +__device void kernel_film_convert_to_byte(KernelGlobals *kg, __global uchar4 *rgba, __global float *buffer, - int sample, int x, int y, int offset, int stride) + float sample_scale, int x, int y, int offset, int stride) { /* buffer offset */ int index = offset + x + y*stride; @@ -58,11 +57,25 @@ __device void kernel_film_tonemap(KernelGlobals *kg, /* map colors */ float4 irradiance = *((__global float4*)buffer); - float4 float_result = film_map(kg, irradiance, sample); + float4 float_result = film_map(kg, irradiance, sample_scale); uchar4 byte_result = film_float_to_byte(float_result); *rgba = byte_result; } +__device void kernel_film_convert_to_half_float(KernelGlobals *kg, + __global uchar4 *rgba, __global float *buffer, + float sample_scale, int x, int y, int offset, int stride) +{ + /* buffer offset */ + int index = offset + x + y*stride; + + float4 *in = (__global float4*)(buffer + index*kernel_data.film.pass_stride); + half *out = (half*)rgba + index*4; + float scale = kernel_data.film.exposure*sample_scale; + + float4_store_half(out, in, scale); +} + CCL_NAMESPACE_END |