Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multi-layer feature #53

Closed
fire opened this issue Dec 17, 2017 · 25 comments
Closed

Add multi-layer feature #53

fire opened this issue Dec 17, 2017 · 25 comments

Comments

@fire
Copy link

fire commented Dec 17, 2017

How do you use multiple layers with this library?

@fire fire changed the title Document how to use multiplayer layers Document how to use multiple layers Dec 17, 2017
@syoyo
Copy link
Owner

syoyo commented Dec 18, 2017

Please describe an issue more precisely.

@fire
Copy link
Author

fire commented Dec 18, 2017

Given I have a exr with n layers, how would you access it from tinyexr?

Test.zip

@fire
Copy link
Author

fire commented Dec 18, 2017

Example questions:

A) Require a list of the layers

B) Allow selection of different layers

C) Accessing the pixel info

We are assuming rgba... but that may not be the case, but for game dev assuming rgba is not that bad.

@syoyo
Copy link
Owner

syoyo commented Dec 18, 2017

OpenEXR specification does not support multilayer, it is stored in multichannel manner.
You may iterate image channels using EXRHeader.num_channels and split channel name into layer string and channel string by .

https://github.com/openexr/openexr/blob/develop/OpenEXR/IlmImf/ImfChannelList.h#L179
https://github.com/tiagoshibata/exrsplit

Currently TinyEXR does not have a support for multilayers, so contribution for the easy-access to multi-layers are always welcome!

@status-open-bounty
Copy link

status-open-bounty commented Jan 18, 2018

Current balance: 0.05 ETH
Tokens: SNT: 680.00
Contract address: 0xddd6e342553766505a4b9adcf9270d30102cb543
QR Code
Network: Mainnet
To claim this bounty sign up at https://openbounty.status.im and make sure to update your Ethereum address in My Payment Details so that the bounty is correctly allocated.
To fund it, send ETH or ERC20/ERC223 tokens to the contract address.

@syoyo
Copy link
Owner

syoyo commented Jan 18, 2018

I have assigned Bounty program to this issue.

Bounty hunter wanted!

Requirements : Load, parse and create data structure of multiple layers. Write a document on multiple layer support in TinyEXR.

@arash009
Copy link

@syoyo I've noticed this issue hasnt had any progress in some time, if you're happy, we'll put in some SNT as well to help increase the bounty value.

@syoyo
Copy link
Owner

syoyo commented Apr 25, 2018

@syoyo I've noticed this issue hasnt had any progress in some time, if you're happy, we'll put in some SNT as well to help increase the bounty value.

Cool! It would be nice! How can we do it?

@arash009
Copy link

We've added some SNT to the bounty as well now!

@syoyo
Copy link
Owner

syoyo commented Apr 25, 2018

@arash009 Awesome!

@akien-mga
Copy link
Contributor

I'd suggest editing the issue title to be clearer, as it's not just about documenting things but adding a multilayer feature to TinyEXR to handle this out of the box (the documentation part for what's currently possible would be what is described in #53 (comment)).

@syoyo syoyo changed the title Document how to use multiple layers Add multi-layer feature Nov 15, 2018
@syoyo
Copy link
Owner

syoyo commented Nov 15, 2018

I'd suggest editing the issue title to be clearer,

I have fixed the title!

@fire
Copy link
Author

fire commented Nov 15, 2018

We discussed about two modes:

  1. merge down all the [layers] using transparency
  2. split into different images based on import

Merge down is harder but is needed by our implementation. Split is easier but requires ui on the implementation.

Comments?

@syoyo
Copy link
Owner

syoyo commented Nov 19, 2018

Split is easier but requires ui on the implementation.

PR for GUI for layer splitting would be appreciated.
You may be interested in libui > https://github.com/andlabs/libui

@usakhelo
Copy link
Contributor

usakhelo commented Dec 9, 2019

Hello @syoyo and @fire,
Is this issue still not resolved? I think I could look into fixing this.
I have few questions if it still makes sense:

  1. Is implementing void layers (&layerNames) and others from ImfChannelList.h a way to fix this?
  2. Should the default way of be taking rgba from first layer?
  3. I also don't quite understand why merging is required, could explain a little please?
    Thanks.

@fire
Copy link
Author

fire commented Dec 9, 2019

Imagine in a game engine, you have the ability to get an exr image.

What do you want to do with it?

You may want to get every single layer stacked and exported as one exr image. How do you do this with multiple layers?

You have multiple choices.

  1. Choose the the first layer
  2. Merge down all the layers so that the transparency falls through all the layers
  3. Choose one out of any number of layers.

This assume the engine only has the ability to have one output rgbafloat in the default configuration.

Channels is a different problem.

@usakhelo
Copy link
Contributor

usakhelo commented Dec 9, 2019

I think I understand now.
I'm coming from CGI background and I've never seen exr layers merged because they usually carry very different information.
Would it make sense to implement just 1 and 3, without merging? Also, when choosing the layer you never know what and how many channels are there. It might be RGB, might be not. I think original ImfChannelList.h implementation makes sense, it just returns whatever there is.

And by default tinyexr can search for RGB channels in all the layers and return first one found.. That would keep it functional with normal and multilayer exr-s.

@usakhelo
Copy link
Contributor

usakhelo commented Dec 9, 2019

One more question: the issue is not only about loading multi-layer images but also about producing them right? Is it possible to produce multi-layer images with tinyexr right now? I thought it might be possible because layers are just channel naming...

Thanks for the explanation @fire

@fire
Copy link
Author

fire commented Dec 9, 2019

These are the original use cases.

This is the photoshop use case.

I have different layers in a document and I want to name them differently but composite them together.

This is the CGI usecase.

I have 4 PBR materials for a 3d mesh.

The first layer is RGBA for the albedo.
The second layer is RGB for ORM (Oculusion, Roughness and Metalness)
The third layer is NORMAL maps.

So this image would contain all the textures for one material.

[Edited for grammar]

@syoyo
Copy link
Owner

syoyo commented Dec 9, 2019

Is it possible to produce multi-layer images with tinyexr right now?

@usakhelo

multi-layer is already supported and you can access channels if you use ParseEXRHeaderFromFile and LoadEXRImageFromFile

https://github.com/syoyo/tinyexr/blob/master/tinyexr.h#L11370

I think it would be better to implement ImfChannelList.h equivalent API(e.g. ChannelListIterator?) on top of it.

More better solution may be adding OpenEXR compatible API > #120

Merging layers would not be an task of TinyEXR.

@usakhelo
Copy link
Contributor

usakhelo commented Dec 9, 2019

Thanks @syoyo and @fire,
I need some time to think and I'll be back with more questions.

@usakhelo
Copy link
Contributor

Hello,
I've made PR with a version of multi-layer support. It's more like minimal version than what ImfChannelList.h provides. I wanted to see if it's the right functionality and get the feedback from you.

@syoyo
Copy link
Owner

syoyo commented Dec 16, 2019

@usakhelo Awesome! merged PR!

@syoyo syoyo closed this as completed Dec 16, 2019
@syoyo
Copy link
Owner

syoyo commented Dec 16, 2019

@usakhelo so you are eligible to receive 0.05 ETH as a bounty. Do you have ETH address?

@usakhelo
Copy link
Contributor

Thanks for fixing the leaks and merging @syoyo !
I don't have ETH address. May be I'll create one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants