EXR Metadata

220 views
Skip to first unread message

Michael Wortmann

unread,
Jan 29, 2020, 12:11:22 PM1/29/20
to OSL Developers
Hi,

I am trying to access exr metadata with getattribute.

I am doing this:

string exp;
int check = gettextureinfo(filetex, "exr/exif/2/FNumber", exp);

This works but if I add 

if (check>0)
   outcolor = color(1,0,0);

I receive an error unspecified OIIO error.

I am not understanding why the return value check is resulting in an error, I thought it's 0 or 1 (depending on success)?

The value stored in the exr data is 9/1 so I assume it would be returned as a string, not a number.

I am using MTOA / Maya 2018.4

Any thoughts on this?

Thanks,

Michael


Larry Gritz

unread,
Jan 29, 2020, 1:56:32 PM1/29/20
to 'Michael Wortmann' via OSL Developers
It would be clarifying if you told us exactly what the error message said, as well as more of the shader source code, and an inventory of what metadata is in the file ("oiiotool -info -v myfile.exr" or "exrheader myfile.exr").

But here's what I suspect is happening, based on the clues so far:

    string exp;
    int check = gettextureinfo(filetex, "exr/exif/2/FNumber", exp);
    // No further use of exp or check...

If neither check nor exp is used later in the shader, OSL will recognize that the gettextureinfo call is unnecessary and eliminate it. So even if it *would* be an error if it executed, it will not execute, so no error would be reported.

If you actually use `check` or `exp` later in the shader (in computations that are not themselves recognized as unnecessary), then it will do the gettextureinfo call, and so if that generates an error, you will see it.

I'm going to guess (without seeing the error message or knowing exactly what the metadata in the file is) that either that metadata does not exist in the file with that name, or it is not of type string.

-- lg


--
You received this message because you are subscribed to the Google Groups "OSL Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osl-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osl-dev/da2c98d3-c514-41bb-809f-8557d769942a%40googlegroups.com.

--
Larry Gritz




Michael Wortmann

unread,
Jan 30, 2020, 9:34:33 AM1/30/20
to OSL Developers
Hi Larry,

thanks for explaining the code optimisation, that's very helpful. I used the oiiotool and I got the name wrong. Works like a charm now.

Thank you!

Michael 

Michael Wortmann

unread,
Jan 31, 2020, 5:24:47 AM1/31/20
to OSL Developers
Hi,

I am still running into that error if the queried metadata is not available. It works if the metadata is present. I am expecting gettextureinfo to return 0 if the metadata is not found but I am receiving an error from oiio.

int check 0;
string strvalF;
check = gettextureinfo(filetex, "exif/2/FNumber", strvalF);
if (!check)
        error("No data present");

Error is:
[texturesys] unspecified OIIO error (filename = "filename.exr")

My own error catch is not appearing. Any ideas what I got wrong? Please let me know if I missed to post necessary data.

Michael

Larry Gritz

unread,
Jan 31, 2020, 6:26:39 PM1/31/20
to 'Michael Wortmann' via OSL Developers
That feels like maybe an error... let me try to reproduce on my end.

What version of OSL are you using?

-- lg
--
Larry Gritz




Larry Gritz

unread,
Feb 1, 2020, 8:35:32 PM2/1/20
to OSL Developers List
I can't seem to reproduce this behavior.

Aside: this is assuming that the error isn't 
int check 0;
I'm assuming this is a cut and paste error in the email, so I changed your example to "int check = 0;"

When I try with a file that does not exist, I get something like this:

$ oslc test.osl && testshade test
Compiled test.osl -> test.oso
ERROR: Shader error [test]: Invalid image file "none.exr": Could not open file "none.exr"
ERROR: Shader error [test]: No data present

So nonexistant file gets an error all the way from the texture system, reported through the renderer (as expected), as well as the error called by your shader.

When I try with a file that exists, but just doesn't contain the requested metadata, I get:

$ oslc test.osl && testshade test
Compiled test.osl -> test.oso
ERROR: Shader error [test]: No data present

that's just the error directly called by your shader. Nothing else from the texture system or OSL internals (such as RendererServices::get_texture_info).

So some things to ponder:

1. Which renderer/version? Can you reproduce via our 'testshade' as I tried to do?
2. Which version of OSL?
3. Do you know which version of OIIO is being used for the texture system?

I'm also intrigued by the error message you quoted. The string "unspecified OIIO error" does not appear anywhere in the current OSL or OIIO source code! So I'm wondering if this is coming from code in your renderer?


On Jan 31, 2020, at 2:24 AM, 'Michael Wortmann' via OSL Developers <osl...@googlegroups.com> wrote:

--
You received this message because you are subscribed to the Google Groups "OSL Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osl-dev+u...@googlegroups.com.

Michael Wortmann

unread,
Feb 3, 2020, 4:25:59 AM2/3/20
to OSL Developers
Hi Larry,

I am using OIIOtool version 1.6.18 not sure if this is the same in the MTOA/Arnold version I use.

Renderer is Arnold Core 5.3.1.1 with MTOA 3.2.2 - 1a5c9f0a running in Maya 2018.4

What I found is that I can get my error message to appear if I update the renderer in IPR after it failed the first time. This seems to be some weird MTOA/Arnold behaviour but that seems to work. I guess my renderer stops when the OIIO error happens and if I force it to continue it proceeds to my own error.

I will try to setup the test.osl later and report.

Thanks,

Michael

Michael Wortmann

unread,
Feb 4, 2020, 12:08:42 PM2/4/20
to OSL Developers
Quick update, I can't run test shade and test render in my env at the moment, need to wait for support.

Error in MTOA is still happening. I will get back as soon as I have run the tests.

M

Michael Wortmann

unread,
Feb 21, 2020, 4:05:04 AM2/21/20
to OSL Developers
Hi,

I tested again and when I run test shade (OSL 1.8.15) I only receive the error generated from my shader. So this seems to be a problem related to MTOA.

Another thing I noticed is that metadata queries only work on exrs, not on JPGs (Exif data specifically). Is that the case?

Thanks,

Michael

Larry Gritz

unread,
Feb 21, 2020, 12:04:39 PM2/21/20
to OSL Developers List
It should work fine for JPEGs. But you do need to spell it right. Try `oiiotool -info -v myjpeg.jpg` to see what metadata is present in the file and how those names will appear to the underlying OIIO texture engine. See also https://openimageio.readthedocs.io/en/release-2.1.11.0/stdmetadata.html

OSL 1.8 is pretty old, though, and I have not checked before writing this whether there are any related bugs in that version that might affect retrieving metadata.
--
Larry Gritz




Michael Wortmann

unread,
Feb 24, 2020, 4:26:24 AM2/24/20
to OSL Developers
Hi,

it's working great with JPGs. I assumed the metadata to be named the same as I copied it from JPGs to EXRs before. All working now, thank you.

M
Reply all
Reply to author
Forward
0 new messages