Thanks for the comprehensive answer; this makes it a lot clearer!

So, what I (maybe) need to handle is point 2. in your previous answer in actual 
client EXRs. Would you happen to have an EXR sample containing RGBA, and 
specular and diffuse light? That would be great ?

Radu Arjocu<http://www.masstech.com>
________________________________
From: Oiio-dev <[email protected]> on behalf of Larry 
Gritz <[email protected]>
Sent: Thursday, September 17, 2020 01:55
To: OpenImageIO developers <[email protected]>
Subject: Re: [Oiio-dev] How to merge layers of multi-layer EXRs?

Well, you already have R, G, B, A, right? So what is there to merge? Do you not 
simply want to *extract* the R,G,B,A that you have? You would do that with

    oiiotool allchannels.exr -ch R,G,B,A -o justrgba.exr

(or justrgba.tif, if your point is to extract it to a different format)

Layers (or for that matter, "parts" in multi-part exr, which is the modern way 
to do all of this, layers being just a way to try to group channels before 
parts were available) are generally used in two ways:

1. Things that don't meaningfully combine at all -- for example one layer/part 
for RGBA, and another for motion vectors.

2. Things that combine by addition -- for example, one layer for RGBA, a second 
layer containing just the specular light, and a third containing just the 
diffuse light (with RGBA = specular + diffuse).

Layers or parts are never, to the best of my knowledge, used to store things 
that are supposed to composite (in the "over" sense), and there is no way to 
represent an ordering. In fact, in what I believe was a grave mis-design, 
OpenEXR stores channels in *alphabetical* sorted order, without the option of 
specifying any other ordering of the channels within the file.

Presence of a Z channel does not make the file deep; it's fine to have a flat 
file with a Z channel. Although if the file is deep, it is in theory required 
to have a Z channel. The thing that makes it deep is the presence of multiple 
(and potentially differing numbers of) samples in each pixel. Flat files have 
just one sample per pixel. That's the difference.

If you had Z/Zback channels in each layer, then you could certainly do a depth 
merge of them, since these channels would imply a front-to-back order (per 
pixel, not of whole layers). But I've never heard of people doing this. You'd 
just use a deep file if this is what you were trying to store in the file.


On Sep 16, 2020, at 12:47 PM, Radu Arjocu 
<[email protected]<mailto:[email protected]>> wrote:

I am talking about "multi-layer" which is a single "part" with many channels 
that are logically grouped togheter in layers. Right now I'm interested in the 
EXR case, with its rules of naming layers -- which I think I understand. For 
simplicity, let's assume a single EXR view and the following channels:

R, G, B, A, shape1.R, shape1.G, shape1.B, shape1.A, shape2.R, shape2.G, 
shape2.B, shape2.A

The layers would be: the (default) nameless layer and respectively the "shape1" 
and "shape2" layers.

So, what I want to know is how to merge these 3 layers into 1 layer (containing 
only RGBA), for viewing the end result!? What layer is in front of another, or 
at the back? That's what I meant  with "the order in which to merge [the 
layers]" -- determining which layer is more at the front or at the back.

As I understand OpenEXR, the depth channels (Z & ZBack) correspond to the deep 
pixels (for all channels of a pixel), and don't reveal which layer is at the 
front or back. Am I missing something? Can the Z & ZBack channels apper on 
non-deep (/flat) EXRs and are they used to tell the depth of layer channels on 
a per pixel basis -- so my example would need Z, shape1.Z and shape2.Z?

Radu Arjocu

________________________________
From: Oiio-dev 
<[email protected]<mailto:[email protected]>>
 on behalf of Larry Gritz <[email protected]<mailto:[email protected]>>
Sent: Wednesday, September 16, 2020 20:23
To: OpenImageIO developers 
<[email protected]<mailto:[email protected]>>
Subject: Re: [Oiio-dev] How to merge layers of multi-layer EXRs?

Are you talking about a "multi-part" exr (what OIIO calls multi-subimage), or 
are you talking about "multi-layer" which is a single "part" with many channels 
but that just follows a convention for how to name those channels so that they 
can be grouped easily by an application?

If you just want a single RGBA image in the end, then are you just talking 
about simply extracting the RGBA channels for export to another format?

"flatten" just composites the multiple depth samples within each pixel of a 
deep image to a single per-channel value. But it does not affect which channels 
are in which "part" of a multi-part image.


On Sep 16, 2020, at 7:45 AM, Radu Arjocu 
<[email protected]<mailto:[email protected]>> wrote:

Hello,

Being relatively new to the OpenEXR format, I have a couple of questions 
regarding multi-layer EXR:

1) What is the (optimal) way to go if I want to merge/compose all the layers of 
an EXR (say flat image for simplicity) into a single layer (RGBA-only 
channels), so that I can convert it to another format and rescale it as needed 
for quick viewing ? -- just like viewing thumbnails, but probably at a higher 
resolution.

I understand that I have to manually determine what the layers are and their 
respective channels, but I don't know (especially) the order in which to merge 
them.  NOTE: I use the terminology "flat image" to refer to non-deep images 
(since "flattening" is used by OIIO to denote this operation) and 
"merge"/"compose" for rendering multi-layers into a single layer; but other SW 
use "flattening" to refer to the merge/compose operation.

2) How do I treat "special" channels like effects, vectors etc. in the scenario 
at point 1?

3) Does using the `flatten()` function for deep and multi-layer images (EXRs) 
also merge the layers or not? I assume not, but I cannot verify this, since I 
don't have an EXR sample. I would greatly appreciate if someone has a sample 
like this.

Thank you,
Radu 
Arjocu<https://protect2.fireeye.com/v1/url?k=c25e4a02-9cd1f486-c2592a0e-86801c117383-76c7f1f405a319a7&q=1&e=975968e2-8694-4935-af42-44e261a41663&u=http%3A%2F%2Fwww.masstech.com%2F>
_______________________________________________
Oiio-dev mailing list
[email protected]<mailto:[email protected]>
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org<https://protect2.fireeye.com/v1/url?k=82a4ba62-dc2b04e6-82a3da6e-86801c117383-ba9b89b8c2796bf7&q=1&e=975968e2-8694-4935-af42-44e261a41663&u=http%3A%2F%2Flists.openimageio.org%2Flistinfo.cgi%2Foiio-dev-openimageio.org>

--
Larry Gritz
[email protected]<mailto:[email protected]>




_______________________________________________
Oiio-dev mailing list
[email protected]<mailto:[email protected]>
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org<https://protect2.fireeye.com/v1/url?k=81d90246-df4cfd2b-81de624a-868753e36a0a-df8d00a39770c900&q=1&e=cfc8ed92-b4cf-4c13-8842-2ea4c66eb587&u=http%3A%2F%2Flists.openimageio.org%2Flistinfo.cgi%2Foiio-dev-openimageio.org>

--
Larry Gritz
[email protected]<mailto:[email protected]>




_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to