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

EXRExporter: introduces EXR exporter, initial draft. #19764

Closed
wants to merge 2 commits into from

Conversation

sciecode
Copy link
Contributor

@sciecode sciecode commented Jun 30, 2020

Initial draft of OpenEXR file format exporter.

Relies internally on WebGL gl.readPixels for retrieving render target pixel data information. So it is subject to all of its limitations as well, but it does offer a good support for regular use-cases by default.

OpenEXR expects the pixel data in linear representation, so we are required to apply EOTF ( Electro-Optical Transfer Function ) before exporting the pixel data. It is also in the best interest to decode encoded data ( e.g RGBEEncoding ), currently the supported texture encodings are mentioned below, If requested, I will expand the encoding support.

- LinearEncoding
- sRGBEncoding
- GammaEncoding
- RGBEEncoding
- RGBM7Encoding
- RGBM16Encoding

EXRExporter Documentation
EXRExporter Example

Observation: In working on this pull request I noticed a small inconsistency with PMREMGenerator, when generating a PMREM from a LDR input texture, the result RGB channels will be correct, however the alpha channel will be set to 0 for all pixels. This bears no effect when the output PMREM is used as an envmap, but once you export this to an .exr file, depending on the viewer you might just see an entirely black/transparent image. I'll be addressing this issue in a separated PR. It is a very simple fix.

@sciecode
Copy link
Contributor Author

The current state of this PR does not include an EXRExporter example.

I would like to include one in the final PR, something like exporting PMREMGenerator output or rendered scene HDR snapshot. I'm open to suggestions regarding which workflows to highlight 😄

@mrdoob mrdoob added this to the r119 milestone Jun 30, 2020
@mrdoob
Copy link
Owner

mrdoob commented Jun 30, 2020

No need to do the examples/js/ version for new files 👌

@sciecode
Copy link
Contributor Author

No need to do the examples/js/ version for new files 👌

Oh, I keep forgetting that. Will remove examples/js version and modularize entry 👍

@lokiiarora
Copy link

Hey @sciecode , is this good to go?
I'd love to include this in an internal tool we are building at Scapic .
Noticed you mentioned something about the PMREM Generator inconsistency, is it something that will get affected if we are using .fromScene method.

@sciecode
Copy link
Contributor Author

sciecode commented Jul 27, 2020

@lokiiarora this is pretty much good to go.

I've been running some tests and haven't found any problems related with utilizing the exporter, I'll include a proper example between today/tomorrow, but no changes will be made to the exporter. So if you want to incorporate the current state of the exporter in your current workflow, feel free to do so.

The PMREM inconsistency has already been handled on #19765 and it should be working properly with all methods.

@mrdoob mrdoob modified the milestones: r119, r120 Jul 29, 2020
@mrdoob mrdoob modified the milestones: r120, r121 Aug 25, 2020
@mrdoob mrdoob modified the milestones: r121, r122 Sep 29, 2020
@mrdoob mrdoob modified the milestones: r122, r123 Oct 28, 2020
@mrdoob mrdoob modified the milestones: r123, r124 Nov 25, 2020
@mrdoob mrdoob modified the milestones: r124, r125 Dec 24, 2020
@mrdoob mrdoob modified the milestones: r125, r126 Jan 27, 2021
@mrdoob
Copy link
Owner

mrdoob commented Feb 3, 2021

@sciecode Should we merge this? The PR is still marked as draft.

}

// http://gamedev.stackexchange.com/questions/17326/conversion-of-a-number-from-single-precision-floating-point-representation-to-a/17410#17410
function encodeFloat16( val ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use DataUtils.toHalfFloat() here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

@sciecode
Copy link
Contributor Author

sciecode commented Feb 3, 2021

@sciecode Should we merge this? The PR is still marked as draft.

There are still some adjustments I would like to make, and I should probably update the Deflate usage as discussed on #20941 (comment).

I'll do my best to work on it next weekend, sorry for the long delay.

@mrdoob mrdoob modified the milestones: r126, r127 Feb 23, 2021
@mrdoob mrdoob modified the milestones: r127, r128 Mar 30, 2021
@mrdoob mrdoob modified the milestones: r128, r129 Apr 23, 2021
@mrdoob mrdoob modified the milestones: r129, r130 May 27, 2021
@mrdoob mrdoob modified the milestones: r130, r131 Jun 30, 2021
@mrdoob mrdoob modified the milestones: r131, r132 Jul 28, 2021
@mrdoob mrdoob modified the milestones: r132, r133 Aug 26, 2021
@mrdoob mrdoob modified the milestones: r133, r134 Sep 30, 2021
@mrdoob mrdoob modified the milestones: r134, r135 Oct 28, 2021
@WestLangley
Copy link
Collaborator

/ping @DavidPeicho You can use this to export PMREMs in .exr format.

@mrdoob mrdoob modified the milestones: r135, r136 Nov 26, 2021
@mrdoob mrdoob modified the milestones: r136, r137 Dec 24, 2021
@mrdoob mrdoob modified the milestones: r137, r138 Jan 26, 2022
@elalish
Copy link
Contributor

elalish commented Feb 9, 2022

@sciecode This would be a really nice feature since envMaps are so hard to edit. Not only could you create them from scenes, but you could also do simple things like downsample them based on the minimum roughness in your scene. A nice follow-on would be HDR export. Are you still working on this?

@sciecode
Copy link
Contributor Author

sciecode commented Feb 9, 2022

Yes, I've been getting a few requests to resume development on this exporter. Sorry it took this long, wasn't my intention.

I'll focus on rebasing the commit and making sure the exporter is properly working on both Linear and perceptual sRGB input render targets, just so we can get an initial version of the exporter live. I should have PR ready by the weekend.

@mrdoob mrdoob removed this from the r138 milestone Feb 22, 2022
@mrdoob mrdoob closed this Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants