Skip to content

Unified skybox and environment#712

Merged
elalish merged 5 commits intomasterfrom
HDRskybox
Aug 21, 2019
Merged

Unified skybox and environment#712
elalish merged 5 commits intomasterfrom
HDRskybox

Conversation

@elalish
Copy link
Contributor

@elalish elalish commented Aug 19, 2019

Fixes #707

This refactors our code so that our skybox shares the same format as our environmentMap, meaning these can now share the same cache. Unfortunately, three.js does not yet read the cubeUV format for its built in skybox, so I built a small custom skybox based on their code. Now our skyboxes are interpolated and fully HDR, but are locked to the 256 cube resolution of our environment maps.

I also updated our lighting & environment example to showcase exposure instead of environment-intensity, since I think it's a more interesting control and it will serve as a form of regression test. I also updated whipple creek to HDR, since I think we should be showcasing primarily HDR content.

@elalish elalish requested a review from cdata August 19, 2019 23:13
@elalish elalish self-assigned this Aug 19, 2019
Copy link
Contributor

@cdata cdata left a comment

Choose a reason for hiding this comment

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

Generally this looks good to go as is. However, I ran into a bug while poking around, where the skybox can become clipped:

breakskysphere

Also, I tried using a separate background image that I gaussian-blurred in Photoshop in order to diminish the effect of the pixelated skybox. To be honest, I found the results rather dissatisfying. Blurring ahead of time still results in a lot of pixelation, but compounds the problem by revealing unsightly seams:

image

It leaves me wondering why we would even give folks a skybox feature if they can only make unsightly skyboxes with it, you know?

this.pivot = new Object3D();
this.pivot.name = 'Pivot';

this.skyboxMesh = this.createSkyboxMesh();
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we could even centralize this a bit so that ModelScene only has a skybox material, and maybe Renderer has a single mesh that can be shared across all instances. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly the mesh is so insignificant, I wouldn't bother. We still need to cache modelScene properly anyway, since it's still leaking shadow textures and such. I think this can fit in nicely there.

};
const skyboxMesh = new Mesh(geometry, material);
// This centers the box on the camera, ensuring the view is not affected by
// the camera's motion, which makes it appear inifitely large, as it should.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

* Loads a WebGLRenderTargetCube from a given URL. The render target in this
* case will be assumed to be used as a skybox.
*/
private[$loadSkyboxFromUrl](url: string, progressTracker?: ProgressTracker):
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

@elalish
Copy link
Contributor Author

elalish commented Aug 20, 2019

The issue with the skybox seams I noticed too; turns out it's a bug I fixed in #710 (I merged them to double check that it's resolved). Good call on the too close part; I have an idea on what's happening there.

@elalish elalish requested a review from cdata August 21, 2019 20:29
@elalish elalish merged commit cebb5ad into master Aug 21, 2019
@cdata
Copy link
Contributor

cdata commented Aug 21, 2019

Much simpler! 😍

@elalish elalish deleted the HDRskybox branch August 21, 2019 21:26
@mrdoob
Copy link
Collaborator

mrdoob commented Aug 21, 2019

I also updated our lighting & environment example to showcase exposure instead of environment-intensity, since I think it's a more interesting control and it will serve as a form of regression test.

That example looks so good now!

@cdata cdata added this to the v0.6.0 milestone Aug 26, 2019
elalish added a commit to elalish/model-viewer that referenced this pull request Feb 4, 2020
 
Unified skybox and environment (google#712)

* built separate skybox

* unified environment and skybox caches

* updated tests

* changed demo from intensity to exposure, upgraded to hdr

* fixed disappearing skybox
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.

HDR environment maps lose HDR when used as skybox texture

3 participants