-
-
Notifications
You must be signed in to change notification settings - Fork 36k
EXRExporter: Add support for exporting textures (EDIT). #26681
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
Conversation
/ping @sciecode |
Thank you for the ping Mugen87. While vertical strip cubemaps aren't uncommon, even Unity allows for different cubemap layouts. This PR enforces this set configuration for all uses of cubemap RenderTargets - which maybe not be what other users want. I considered this situation back when I first implemented the exporter, but decided it was best if users themselves handled how cubemaps should be flatten; by constructing the final RenderTarget in user-space. If there's sufficient demand, perhaps we could implement a dedicated API to handle some of the cases. But I don't believe this proposed solution is universal enough in it's current implementation. |
However we should inform the user of this limitation when trying to read from a cubeTexture, it shouldn't just crash on them. |
I do agree. So for the moment a simple error with explicit message about cubeTexture may be enough. However, i'm wondering if the EXRExporter could accept any textures, or buffers, instead of a render target as an input. @sciecode Conversely, I think now that the best way to export cubemaps is to use a dedicated render target used in conjonction with a dedicated shader that will encore the pixels according to the different existing standard layout. |
It would be good to have an example for each type of exporter so adding |
Yes, I do believe so. Specifically a Would you like to work on this PR @jniac, or you'd prefer if I did it? |
I can do it myself, following the same style you used (very simple class methods calling pure functions with explicit names), then you'll check if it's ok for you. I'm wondering what could be the name of the new function. If This will even allows a Should we rename |
Sure, feel free to ping and I'll review the changes. I'm famously bad at naming APIs 😆 So perhaps @Mugen87 and others could help us with that. My only concern with The name I'm not particular about any of this, we should just try to minimize changes as to avoid confusion by users, but whatever others agree on, is fine with me. |
Let's avoid to question the I would prefer to keep exporter.parse( renderer, renderTarget ); However, the exporter also supports textures like so: exporter.parse( texture ); I would do the same for |
Now that #26810 has been merged (🎉 ), how should we proceed with this PR? |
We can close it I think. I made an example for exporting cube texture into various formats (equirectangular + horizontal stripe for now) but it's a separate topic. So we can close this one. Could you tell me if it is worth integrating such an example? If so, i can complete the example, clean the code and create a new PR. |
Okay!
I'm not very familiar with the EXR standard so I'm not sure how to proceed with cube map conventions. But I admit it could be useful for other devs to see how stripe or cross layouts are created. I'm okay with whatever @sciecode thinks is best. |
OpenEXR spec defines an envmap hint attribute for equirectangular & vertical-stripe envmaps, however this attribute is mostly ignored by most loaders, and completely stripped out by all editing software that I've used. So, it should really be up to user which cubemap convention they want, as the file will be treated as plain data in almost every case.
Since we expect the user to generate their own preferred data-layout, showcasing how to generate different layouts could indeed be useful. I think we should just add cross layout to your example, as Mugen suggested. |
This is a quick fix to allow EXRExport to export cube texture as a single vertical strip (compatible with Unity).
The exporter currently crashes because no face index is specified when calling
renderer.readRenderTargetPixels(...)
but face index is required here to access the right "sub" framebuffer from the array.There is still an open question:
How to dispose the data? Actually faces are processed in the following order +X, -X, +Y, -Y, +Z, -Z
In order to be compatible with Unity, the data should be flipped vertically face by face over the Y axis.
Unity preview:
But, if the thumbnail looks OK in Unity, the strip looks weird otherwise:
So maybe with more documentation, a more general solution may be written.
References:
cube texture Khronos