Conversation
|
@cdata I have a very strange problem I don't understand here. When I run check-fidelity, the environments are 90 degrees off (I'm looking at the ceiling). When I run them in the viewer directly, they're fine. Can you reproduce this behavior? I can't imagine what could cause it. |
|
@cdata @mrdoob I'm totally baffled here. Outside of puppeteer, all of the fidelity tests work great. Inside of puppeteer, my PMREM environments end up quite wrong, and it seems that the position attribute I'm passing into my RawShaderMaterial is getting stretched by a factor of 2. If I switch one line in my vertex shader to |
|
@cdata @mrdoob I finally figured it out! It was a DPR issue. When running offscreen renders I had neglected to set the pixel ratio back to one, hence why it only affected macbooks and puppeteer. It didn't occur to me that there was a scaling factor that applied to render target dimensions but not viewport dimensions. |
cdata
left a comment
There was a problem hiding this comment.
Let's keep the changes simple for now. We'll want to bang on it a little before the release, but let's try to get it landed.
| return material; | ||
| }; | ||
|
|
||
| export const environmentScene = (): Scene => { |
There was a problem hiding this comment.
Let's slightly re-write this as a class that inherits from Scene. The body of the function would instead become the body of the constructor.
| new WebGLRenderTarget(3 * sizeMax, offsetY, params); | ||
| cubeUVRenderTarget.texture.name = 'PMREMCubeUVPacker.cubeUv'; | ||
| cubeUVRenderTarget.texture.mapping = CubeUVReflectionMapping; | ||
| fromDefault(): WebGLRenderTarget { |
| uniforms.inputEncoding.value = encodings[cubeLods[i].texture.encoding]; | ||
| } | ||
| }; | ||
| fromScene( |
| class MipmapShader extends RawShaderMaterial { | ||
| constructor() { | ||
| super({ | ||
| fromEquirectangular(equirectangular: Texture): WebGLRenderTarget { |
There was a problem hiding this comment.
I know this method already existed, but please add some docs!
| const samples = 1 + Math.floor(STANDARD_DEVIATIONS * sigmaPixels); | ||
|
|
||
| if (samples > MAX_SAMPLES) { | ||
| console.log( |
There was a problem hiding this comment.
console.warn seems more appropriate here. Also, it would probably be easier to read with string interpolation:
console.warn(`sigmaRadians, ${sigmaRadians}, is too large and will clip, as it requested ${samples} samples when the maximum is set to ${MAX_SAMPLES}`);| const $blur = Symbol('blur'); | ||
| const $halfBlur = Symbol('halfBlur'); | ||
|
|
||
| export class PMREMGenerator { |
There was a problem hiding this comment.
Can you move the docs related to this class so that they appear right above the class declaration?
| import ModelViewerElementBase from './model-viewer-base.js'; | ||
| import {FocusVisiblePolyfillMixin} from './utilities/focus-visible.js'; | ||
|
|
||
| // Uncomment these lines to export PMREM textures in Glitch: |
cdata
left a comment
There was a problem hiding this comment.
This is some crazy magic ✨🎩🐇✨
|
Wow! Looking incredible! |
|
The mip checker boarding seems to still be happening: See here: |
|
@pushmatrix Indeed, this is only the first part of the fix. What I fixed here was the roughness mapping (wetness) and PMREM performance. Aliasing is next, stay tuned. |
|
@elalish I can confirm things do look significantly less wet! :D |
* simplified PMREM layout * refactored PMREMGenerator * using new PMREM for input environments * NewPMREM starting to work * newPMREM working * minMip 3->4 * fixed skybox aliasing * don't blur over the poles * environment generation working * cleanup * fixed tests * more cleanup * reverting exports * fixed some blur math * fixed IE bug * removed forked three files * fixed DPR issue * addressing feedback * updated goldens






Fixes #724
Well, I doubt this will completely fix #724, but we'll see. Mostly this is a refactor to improve and speed up PMREM. I condensed five shaders into one, which reduces our compile time significantly (a major contributor to first-environment startup time). I also reduced the number of draw calls by a factor of 3, which significantly reduced the time to run environment generation (a major contributor to next-environment startup time). This has the added benefit of anti-aliasing our skyboxes a bit, since I replaced three's EquirectangularToCubemap function.