From 0baf7b5f494cda7f99d28126e14304f4cbe46501 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Wed, 30 Oct 2024 16:23:37 +0200 Subject: [PATCH] EXR: more standard RGBA channel name detection Various EXR images especially from movie assets do not simply have "R" etc as channel names; the convention seems to be to have "layer name", ".", "color channel name". For example, channels in EXR might be "rgb.R", "rgb.G", "rgb.B", which RenderDoc was not detecting previously and displaying an all-black image. --- renderdoc/core/image_viewer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/renderdoc/core/image_viewer.cpp b/renderdoc/core/image_viewer.cpp index 6571637dc..4d5651e34 100644 --- a/renderdoc/core/image_viewer.cpp +++ b/renderdoc/core/image_viewer.cpp @@ -758,10 +758,14 @@ void ImageViewer::RefreshFile() return; } + // Expect R/G/B/A channel names as first char of the string, or + // after the last '.' char. int channels[4] = {-1, -1, -1, -1}; for(int i = 0; i < exrImage.num_channels; i++) { - switch(exrHeader.channels[i].name[0]) + const char *dotPos = strrchr(exrHeader.channels[i].name, '.'); + const char *name = dotPos ? dotPos + 1 : exrHeader.channels[i].name; + switch(name[0]) { case 'R': channels[0] = i; break; case 'G': channels[1] = i; break;