-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
WebGLCubeUVMaps: Add support for render targets. #23152
Conversation
@Mugen87 So far, this appears to be working for me.
It appears that is appropriate now, since the PMREM render target always has the same parameters regardless of the inputs.
Me, too. Perhaps you should also compare with a cube environment map just in case. In fact the |
Wow, I'm impressed the performance is decent for a PMREM per frame too! I mean, I did try to make it as fast as I could, and it may well be that converting to halfFloats sped it up significantly. I too would love to see some frame rate comparisons. My comment was about bringing back the old mipmaps-as-PMREM solution that was in three.js before my PMREMGenerator and was removed during @WestLangley's simplification. However, if this is adequately fast, then perhaps there's no need. Would be good to test a WebXR example with lighting estimation as well. |
@Mugen87 Should I merge this so we have some time to test performance? |
Yes, that sounds good. We still need to fix the WebXR example with lighting estimation. |
this.isRenderTargetTexture = false; // indicates whether a texture belongs to a render target or not | ||
this.needsPMREMUpdate = false; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am inclined to think these properties should be "private", since they are for renderer-use only.
this.__isRenderTargetTexture = false;
this.__needsPMREMUpdate = false;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edit: I'm assuming it should be a double-underscore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on how user or third-party code is developed both flags are actually required.
isRenderTargetTexture
is just the pendant to all other is*
properties and required for type checks. Besides, users have to set needsPMREMUpdate
to true
(similar to other needsUpdate
flags) if they are using a dynamic render target as an env map applied to PBR materials and author the render target's data by themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually thinking about suggesting something like RenderTargetTexture
(which extends from Texture
) in order to work a bit easier with this type of texture. However, this idea is not yet mature^^.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, lets test performance in the meantime.
Thanks! |
@mrdoob build required |
Done 👍 |
@Mugen87 Do the reflections look correct in your test cases? |
After a closer look, it seems the reflections along the x axis are flipped. Let me file a PR to fix this issue. |
@Mugen87 any plans for a sample to share? |
In #23158, I've updated |
I tested my page, and the performance is quite ok. I found there still is a framebuffer of |
@elalish Do you think it's okay to remove the following line and add it to three.js/src/extras/PMREMGenerator.js Line 198 in ed1e47b
|
@Mugen87 The PMREM shaders used to be disposed of when they are used only once. Last I checked, they are not. Maybe there is a way to determine when disposal is appropriate... |
@Mugen87 Yes, that sounds good to me. @WestLangley I believe those shaders all get disposed when the |
@Mugen87 Do you think if it's ok about adding a extra parameter to |
It is called in
|
I'm not sure about the dimensions but other render target parameters should not be configurable by the user, IMO. |
@Mugen87 OK, thanks! Maybe my use case is not very common. Generating a realtime enviroment map can use CubeCamera now. I just guess using |
Fixed #22236.
Description
This PR adds support for render targets in
WebGLCubeUVMaps
. That means the render targets of cube cameras can now be used with PBR materials.@elalish I've have enhanced
PMREMGenerator
such that it is possible to reuse existing render targets for the conversion process. I'm not sure how to implement the details of #22236 (comment) though.TBH, it surprised me that the conversion per frame has such a decent performance (tested with
webgl_materials_cubemap_dynamic
and PBR materials). I had this different in mind when testing last year.