Conversation
cdata
left a comment
There was a problem hiding this comment.
Looking good, just want to kick the tires on it a little
src/three-components/TextureUtils.ts
Outdated
| // Apply PMREM to HDR textures, which if loaded from file have | ||
| // RGBEEncoding, and if generated are HalfFloatType | ||
| if (environmentMap.encoding === RGBEEncoding || | ||
| environmentMap.type === HalfFloatType) { |
There was a problem hiding this comment.
Woah, we weren't even applying PMREM to the generated map? That... doesn't seem right...
|
Marked as breaking because as of this change we turn on @elalish what do you think about adding an escape hatch for folks who might need to migrate? I'm thinking something along the lines of a |
|
Well, dusting off my PM hat, I'd ask if we know of any situations where this behavior is worse (less physically accurate) than the current behavior? Also, for the sake of our own testing and maintenance, I think it's important that we reduce the number of rendering paths we expose. Better to do that now so that we can get the bug reports and fix them before our stable release. |
|
The proposal would be to give folks an off-ramp and then remove the flag entirely in a subsequent version. The risk of not doing it is that you lose those users entirely when they feel left behind/blind-sided without a transition path into the future. |
|
I think there are too many serious rendering bugs that this fixes to warrant keeping the old path open. I'm also concerned about the dev burden it will put on us to try and keep up both paths as we improve the rendering in 0.5. |
|
I think we should wait for v0.5.0 as a matter of timeliness. v0.4.0 has been lingering too long, and our partners need some incremental improvements to become unblocked. I'm also worried that without low-barrier migration path accompanying this change, we could inadvertently hurt the uptake of v0.4.0. v0.5.0 will give us the time to live with this change for a bit before shipping it to users. Keep in mind that we can start landing v0.5.0 changes as soon as v0.4.0 goes out. |
…into remove_pmrem_flag
…into remove_pmrem_flag
|
Just had a thought as I filed #649 : if we fix this first, we'll cut the number of PMREM generation passes by about half in the tests. Maybe we should go ahead and fix this early in case it wins us some wiggle room in Safari. |
|
Let's give this another shot now that #649 is fixed. |
jsantell
left a comment
There was a problem hiding this comment.
I wonder if using spherical harmonics is a potential option for performance. Could provide a gist explaining how to generate it, achieving correct indirect illumination with no initial runtime overhead.
Are there any big installs of MV not using PMREM? While this would be a breaking change, it is at least an opinionated nudge in the direction of correct PBR. Although not everyone has HDR versions to their environments. When I was looking before, I couldn't find any info on 'simulating' HDR with an LDR image, but increasing brightness seems "OK"
src/features/environment.ts
Outdated
| this.stageLightIntensity, illuminationRole); | ||
| scene.model.setEnvironmentMapIntensity(environmentIntensity); | ||
| scene.model.setEnvironmentMapIntensity( | ||
| this.environmentIntensity * 0.65); |
There was a problem hiding this comment.
I understand this magic number was in here before this PR, but what model is it based on? Either way, maybe define as a constant
There was a problem hiding this comment.
I've removed this in a follow-on PR.
elalish
left a comment
There was a problem hiding this comment.
Thanks, I just reviewed your caching change, and it looks a lot better. I just have one question about a potential race condition.
| const hdrLoader = new RGBELoader(); | ||
|
|
||
| const $environmentMapCache = Symbol('environmentMapCache'); | ||
| const $skyboxCache = Symbol('skyboxCache'); |
There was a problem hiding this comment.
👍 It didn't occur to me that we could make the caches private members, but now I see that TextureUtils is owned by Renderer, which is global. Nice!
| url: string, | ||
| progressTracker?: ProgressTracker): Promise<WebGLRenderTarget> { | ||
| if (!this[$environmentMapCache].has(url)) { | ||
| const skyboxLoads = this[$loadSkyboxFromUrl](url, progressTracker); |
There was a problem hiding this comment.
Considering this is all async now, doesn't this mean that when I have a skybox url, but not an environment url (and no cache yet) that it will load the skybox twice, because the skybox cache won't be set yet when this function goes looking for it?
There was a problem hiding this comment.
The cache will be populated synchronously (relative to this line). The trick is that we populate it with a promise for the eventual value, and that promise can be looked up and awaitd in parallel by other routines trying to load from the same URL.
|
Ah, very cool. Thanks for the explanation!
…On Fri, Jul 12, 2019 at 9:08 AM Christopher Joel ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/three-components/TextureUtils.ts
<#591 (comment)>
:
> + this[$environmentMapCache].set(url, environmentMapLoads);
+ }
+
+ return this[$environmentMapCache].get(url)!;
+ }
+
+ /**
+ * Loads a skybox from a given URL, then PMREM is applied to the
+ * skybox texture and the resulting WebGLRenderTarget is returned,
+ * with the assumption that it will be used as an environment map.
+ */
+ private[$loadEnvironmentMapFromSkyboxUrl](
+ url: string,
+ progressTracker?: ProgressTracker): Promise<WebGLRenderTarget> {
+ if (!this[$environmentMapCache].has(url)) {
+ const skyboxLoads = this[$loadSkyboxFromUrl](url, progressTracker);
The cache will be populated synchronously (relative to this line). The
trick is that we populate it with a promise for the eventual value, and
that promise can be looked up and awaitd in parallel by other routines
trying to load from the same URL.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#591>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMS2LBRNAXPDVAH7BZFBLDP7CT6NANCNFSM4HR6I7JQ>
.
|
elalish
left a comment
There was a problem hiding this comment.
LGTM; any idea why the tests aren't passing the CI anymore?
|
|
||
| // We should only ever generate this map once, and we will not be using | ||
| // the environment map as a skybox, so go ahead and dispose of all | ||
| // interstitial artifacts: |
There was a problem hiding this comment.
Is it true that we don't use the generated environment map as a skybox? I'm not sure why that hadn't occurred to me before. Maybe I should update our fidelity tests accordingly.
There was a problem hiding this comment.
I think that it's fine to let the fidelity tests have a skybox. This is the existing behavior when specifying a background-image, so it is expected. We can change this behavior if we want 🤷♂ but let's file an issue to discuss it?
| if (skybox != null) { | ||
| skybox.dispose(); | ||
| } | ||
| } |
There was a problem hiding this comment.
This for loop could be a method to skip the repetition.
| "clientOptions": { | ||
| "mochaOptions": { | ||
| "timeout": 90000 | ||
| "timeout": 180000 |
There was a problem hiding this comment.
This actually didn't help as I recall, so we could probably revert it. Up to you.
There was a problem hiding this comment.
It's arbitrarily high either way. No harm in keeping it this high.
* generated environment map now RGBM16 * switched RGBM16 to RGBE * started gaussianBlur * gaussianBlur compiles * gaussian blur functional * gaussianBlur properly parameterized * target caching works * removed extraneous cache, cleaned up generation * Reuse renderer in tests * switched cubeGenerators * reuse renderer in TextureUtils-spec * addressing feedback * generated environment map now RGBM16 * switched RGBM16 to RGBE * started gaussianBlur * gaussianBlur compiles * gaussian blur functional * gaussianBlur properly parameterized * switched cubeGenerators * reuse renderer in TextureUtils-spec * addressing feedback * fixed IE11 shader bug
cdata
left a comment
There was a problem hiding this comment.
Regarding khronos-MetalRoughSpheres-LDR: it's notable that Filament w/ LDR seems more illuminated than <model-viewer>. What can we do to bring these two cases closer together?
This has been an awesome thread of work to follow 🙌 great job. Just a few loose ends to tie up, I think.
| environment entirely. Defaults to 1.</p> | ||
| </li> | ||
| <li> | ||
| <div>experimental-pmrem</div> |
| @property({type: String, attribute: 'background-color'}) | ||
| backgroundColor: string = DEFAULT_BACKGROUND_COLOR; | ||
|
|
||
| @property({type: Boolean, attribute: 'experimental-pmrem'}) |
|
|
||
| scene.configureStageLighting( | ||
| this.stageLightIntensity, illuminationRole); | ||
| scene.model.setEnvironmentMapIntensity(environmentIntensity); |
| // The renderer can retain state, so these tests have the possibility of | ||
| // getting different results in different orders. However, our use of the | ||
| // renderer *should* always return its state to what it was before to avoid | ||
| // this kind of problem (and many other headaches). |
| suite('generating an environment map and skybox', () => { | ||
| let textures: {skybox: WebGLRenderTargetCube|null, environmentMap: Texture}| | ||
| let textures: | ||
| {environmentMap: WebGLRenderTarget, skybox: WebGLRenderTargetCube|null}| |
There was a problem hiding this comment.
Let's import the type we created for this and use it here.
| const hdrLoader = new RGBELoader(); | ||
|
|
||
| const $environmentMapCache = Symbol('environmentMapCache'); | ||
| const $skyboxCache = Symbol('skyboxCache'); |
|
|
||
| // We should only ever generate this map once, and we will not be using | ||
| // the environment map as a skybox, so go ahead and dispose of all | ||
| // interstitial artifacts: |
There was a problem hiding this comment.
I think that it's fine to let the fidelity tests have a skybox. This is the existing behavior when specifying a background-image, so it is expected. We can change this behavior if we want 🤷♂ but let's file an issue to discuss it?
| "width": 1536, | ||
| "height": 1536 | ||
| } | ||
| }, |
| @@ -0,0 +1,38 @@ | |||
| <!-- | |||
| /* | |||
| * Copyright 2018 Google Inc. All Rights Reserved. | |||
| "clientOptions": { | ||
| "mochaOptions": { | ||
| "timeout": 90000 | ||
| "timeout": 180000 |
There was a problem hiding this comment.
It's arbitrarily high either way. No harm in keeping it this high.
|
This PR includes several threads of work by @elalish , the descriptions for which I am quoting here for posterity:
|
src/three-components/TextureUtils.ts
Outdated
| } | ||
| var gammaOutput = this.renderer.gammaOutput; | ||
| var toneMapping = this.renderer.toneMapping; | ||
| var toneMappingExposure = this.renderer.toneMappingExposure; |
There was a problem hiding this comment.
In modern JS, there are few good reasons to use var ever. Use const or let instead (in this case probably const).
|
Regarding illumination, I did play with this a bit, and chose to match the lightroom renders instead, since that's our default. Honestly, it bothers me that we still need exposure = 0.8 just to get the skyboxes to match. We should be able to find an equation to match that exactly. Then we can continue with trying to more accurately match their model illumination, but given the Filament HDR bug I found, I don't want to work on that until it's fixed, because I'd guess their fix may affect LDR lighting as well. |
Remove experimental-pmrem flag (google#591) * removed pmrem attribute * removed pmrem attribute from non-code files * default environment map now uses PMREM * fixed tests * using PMREM for all cases, fixing google#565 * increasing sauce timeout to 3min * target caching works * removed extraneous cache, cleaned up generation * added LDR and HDR environment tests * updated goldens * Reuse renderer in tests (google#668) * Refactor envmap / skybox generation * default stage light to zero, removed hemisphere light (google#674) * Switch environment generation from HalfFloat to RGBE (google#670) * generated environment map now RGBM16 * switched RGBM16 to RGBE * started gaussianBlur * gaussianBlur compiles * gaussian blur functional * gaussianBlur properly parameterized * target caching works * removed extraneous cache, cleaned up generation * Reuse renderer in tests * switched cubeGenerators * reuse renderer in TextureUtils-spec * addressing feedback * generated environment map now RGBM16 * switched RGBM16 to RGBE * started gaussianBlur * gaussianBlur compiles * gaussian blur functional * gaussianBlur properly parameterized * switched cubeGenerators * reuse renderer in TextureUtils-spec * addressing feedback * fixed IE11 shader bug * addressing feedback * Remove accidental render target disposal
Fixes #565
Fixes #601
Fixes #396
Fixes #648
Fixes #574
Fixes #336
Fixes #616
Fixes #346
Fixes #647
Fixes #637
The only real trouble with bug #587 is that our HDR environment maps really don't work at all without pmrem. Additionally, #565 can be solved by turning on PMREM for the generated enviroment map, and #601 can be solved by turning on PMREM for LDR environment maps. Given all of that, this PR removes the experimental-pmrem flag and instead enables PMREM in all cases, which has the nice side effect of simplifying both the API and the code.
The only downside is a performance hit. However, we plan to look into improving our rendering in the near future, and I believe we can attain what PMREM has been doing with a simpler and faster algorithm.