Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/kernel_film.h
| Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | ccl_device void kernel_film_convert_to_half_float(KernelGlobals *kg, | ||||
| ccl_global float *buffer, | ccl_global float *buffer, | ||||
| float sample_scale, | float sample_scale, | ||||
| int x, | int x, | ||||
| int y, | int y, | ||||
| int offset, | int offset, | ||||
| int stride) | int stride) | ||||
| { | { | ||||
| /* buffer offset */ | /* buffer offset */ | ||||
| float4 rgba_in; | |||||
| int index = offset + x + y * stride; | int index = offset + x + y * stride; | ||||
| ccl_global float4 *in = (ccl_global float4 *)(buffer + index * kernel_data.film.pass_stride); | int display_pass_stride = kernel_data.film.display_pass_stride; | ||||
| ccl_global half *out = (ccl_global half *)rgba + index * 4; | int display_pass_components = kernel_data.film.display_pass_components; | ||||
| int use_display_sample_scale = (kernel_data.film.display_divide_pass_stride == -1); | |||||
| if (display_pass_components == 4) { | |||||
| ccl_global float4 *in = (ccl_global float4 *)(buffer + display_pass_stride + | |||||
| index * kernel_data.film.pass_stride); | |||||
| float alpha = use_display_sample_scale ? | |||||
| (kernel_data.film.use_display_pass_alpha ? in->w : 1.0f / sample_scale) : | |||||
| 1.0f; | |||||
| rgba_in = make_float4(in->x, in->y, in->z, alpha); | |||||
| int display_divide_pass_stride = kernel_data.film.display_divide_pass_stride; | |||||
| if (display_divide_pass_stride != -1) { | |||||
| ccl_global float4 *divide_in = (ccl_global float4 *)(buffer + display_divide_pass_stride + | |||||
| index * kernel_data.film.pass_stride); | |||||
| if (divide_in->x != 0.0f) { | |||||
| rgba_in.x /= divide_in->x; | |||||
| } | |||||
| if (divide_in->y != 0.0f) { | |||||
| rgba_in.y /= divide_in->y; | |||||
| } | |||||
| if (divide_in->z != 0.0f) { | |||||
| rgba_in.z /= divide_in->z; | |||||
| } | |||||
| } | |||||
| if (kernel_data.film.use_display_exposure) { | |||||
| float exposure = kernel_data.film.exposure; | float exposure = kernel_data.film.exposure; | ||||
| rgba_in *= make_float4(exposure, exposure, exposure, alpha); | |||||
| float4 rgba_in = *in; | } | ||||
| } | |||||
| if (exposure != 1.0f) { | else if (display_pass_components == 1) { | ||||
| rgba_in.x *= exposure; | ccl_global float *in = (ccl_global float *)(buffer + display_pass_stride + | ||||
| rgba_in.y *= exposure; | index * kernel_data.film.pass_stride); | ||||
| rgba_in.z *= exposure; | rgba_in = make_float4(*in, *in, *in, 1.0f / 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); | float4_store_half(out, rgba_in, sample_scale); | ||||
| } | } | ||||
| else { | |||||
| float4_store_half(out, rgba_in, 1.0f); | |||||
| } | |||||
| } | |||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||