MacOS: Enable support for EDR rendering #105662

Merged
Brecht Van Lommel merged 26 commits from Jason-Fielder/blender:macos_EDR_support into main 2023-08-09 14:25:23 +02:00
4 changed files with 21 additions and 2 deletions
Showing only changes of commit 214c20dce0 - Show all commits

View File

@ -169,9 +169,16 @@ vec4 OCIO_ProcessColor(vec4 col, vec4 col_overlay)
* merge UI using alpha blending in the correct color space. */
if (parameters.use_overlay) {
col.rgb = pow(col.rgb, vec3(parameters.exponent * 2.2));
vec4 clamped_col = clamp(col, 0.0, 1.0);
if (!parameters.use_extended) {
/* if we're not using an extended colour space, clamp the color 0..1 */
col = clamp(col, 0.0, 1.0);
col = clamped_col;
}
else {
/* When using extended colorspace, interpolate towards clamped color to improve display of
* alpha-blended overlays. */
col = mix(col, clamped_col, col_overlay.a);
}
col *= 1.0 - col_overlay.a;
col += col_overlay; /* Assumed unassociated alpha. */

View File

@ -451,9 +451,11 @@ static void gpu_viewport_draw_colormanaged(GPUViewport *viewport,
GPU_batch_program_set_imm_shader(batch);
}
else {
GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE);
GPU_batch_uniform_1i(batch, "overlay", do_overlay_merge);
GPU_batch_uniform_1i(batch, "display_transform", display_colorspace);
GPU_batch_uniform_1i(batch, "use_extended", U.gpu_flag & USER_GPU_FLAG_HDR_ENABLED);
}
GPU_texture_bind(color, 0);

View File

@ -36,7 +36,16 @@ void main()
vec4 overlay_col = texture(overlays_texture, texCoord_interp.xy);
if (overlay) {
fragColor = clamp(fragColor, 0.0, 1.0);
vec4 clamped_col = clamp(fragColor, 0.0, 1.0);
if (!use_extended) {
/* Only clamp color if we are not using an extended display colorspace. */
fragColor = clamped_col;
}
else {
/* When using extended colorspace, interpolate towards clamped color to avoid over-brightened
* overlays. */
fragColor = mix(fragColor, clamped_col, overlay_col.a);
}
fragColor *= 1.0 - overlay_col.a;
fragColor += overlay_col;
}

View File

@ -17,6 +17,7 @@ GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_overlays_merge)
.push_constant(Type::MAT4, "ModelViewProjectionMatrix")
.push_constant(Type::BOOL, "display_transform")
.push_constant(Type::BOOL, "overlay")
.push_constant(Type::BOOL, "use_extended")
/* Sampler slots should match OCIO's. */
.sampler(0, ImageType::FLOAT_2D, "image_texture")
.sampler(1, ImageType::FLOAT_2D, "overlays_texture")