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

fixed cubemap dynamic example and small PMREMs #23428

Merged
merged 1 commit into from
Feb 4, 2022
Merged

Conversation

elalish
Copy link
Contributor

@elalish elalish commented Feb 4, 2022

Related issue: #23322 (comment)

The example was yet another victim of textures not containing their dimensions; a simple fix, but I'd really like to see three's API improved here. I also optimized it a bit, which revealed an actual PMREM bug for smaller input sizes, which is here fixed as well.

@mrdoob mrdoob added this to the r138 milestone Feb 4, 2022
@mrdoob mrdoob merged commit 2d75b4a into mrdoob:dev Feb 4, 2022
@mrdoob
Copy link
Owner

mrdoob commented Feb 4, 2022

Thanks!

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 5, 2022

The example was yet another victim of textures not containing their dimensions

#23433 should fix this issue for cube render targets in general.

@@ -73,19 +73,23 @@

//

cubeRenderTarget1 = new THREE.WebGLCubeRenderTarget( 256 );
const envSize = 64; // minimum size for roughness >= 0.1
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Mugen87 @elalish I think it would be better, as an example, to do this:

const envSize = 256; // the minimum size if roughness >= 0.1 is 64

Are the default WebGLCubeRenderTarget options the ones you want?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess 64 was used so we have at least one use case with a small sized environment map. TBH, I'm not sure which value is better. Both setups makes sense.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since users copy these patterns, I suggest we set it to a recommended size -- not to an edge case for testing.

Copy link
Contributor Author

@elalish elalish Feb 7, 2022

Choose a reason for hiding this comment

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

Actually, I changed it here on purpose. Yes, this did catch an error, but more importantly, there's nothing special about 256. We've actually found most of our users preferring smaller envMaps to get reasonable HDR downloads (since they're PNGs internally). 256 is required for roughness >= 0.05, while 64 is for roughness >= 0.1; I consider that to be a very worthwhile trade in performance (both GPU cache and download) for the vast majority of users.

Copy link
Owner

Choose a reason for hiding this comment

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

I think it would be good to document this.

@elalish what are the roughness ranges for 32, 128 and 512?

envmap size roughness
32 ???
64 >= 0.1
128 ???
256 >= 0.05
512 ???

Once we complete the table we could add it to the docs:
https://threejs.org/docs/?q=pmrem#api/en/extras/PMREMGenerator

Copy link
Contributor Author

Choose a reason for hiding this comment

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

roughness = ( 2 ^ ( -0.5 * mip ) ) / 1.16, where dimension is 2 ^ mip. So:

  • 16: mip 4: roughness 0.21
  • 32: mip 5: roughness 0.15
  • 64: mip 6: roughness 0.11
  • 128: mip 7: roughness 0.076
  • 256: mip 8: roughness 0.054
  • 512: mip 9: roughness 0.038
  • 1024: mip 10: roughness 0.027

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.

4 participants