Conversation
…into remove_pmrem_flag
…into remove_pmrem_flag
* 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
…del-viewer into newPMREM
|
@cdata I have a strange problem with the current state of this branch. Try loading examples/lighting-and-environment.html: I get a black render for the second one down the page (the rest are fine), and sometimes even a white skybox. However, if I comment out all the others, then this one renders just fine. I assume I've messed up a cache or dispose or something, but I haven't found it. A second set of eyes would be much appreciated. |
|
@mrdoob This is more FYI than requesting a code review, but I thought you might be interested in where I'm headed as far as updating PMREM and the MeshStandardMaterial. Also, onBeforeCompile is great, but it would be nice if the uniforms were more accessible / extensible. Maybe I'm missing something? |
|
I wouldn't rely too much in Glad to see that you're reworking the PMREM code. Feel free to propose the change upstream whenever you think is ready. WestLangley and others will be able to take a good look. |
cdata
left a comment
There was a problem hiding this comment.
This is looking very promising. I had tons of feedback, but most of it is minor stuff.
| const gltf = cloneGltf(await cache.get(url)!); | ||
| const model = gltf.scene ? gltf.scene : null; | ||
|
|
||
| // This is a patch to three's handling of PMREM environments. |
There was a problem hiding this comment.
Is there a better description of what this actually does somewhere?
There was a problem hiding this comment.
Yeah, I'm working on a doc, but it's not going to fit in a comment.
| }; | ||
|
|
||
| return renderTarget; | ||
| return cubeUVTarget; |
There was a problem hiding this comment.
If I understand the implementation correctly, this means you are sharing the same render target instance for all environment maps. That probably explains why you were only getting one working environment map.
| @@ -0,0 +1,135 @@ | |||
| export default /* glsl */ ` | |||
There was a problem hiding this comment.
There seems to be some pretty inconsistent indentation here. Is it possible to align it with cube_uv_reflection_fragment?
There was a problem hiding this comment.
I left it intentionally with unchanged formatting from the three.js version since I only changed two lines and this makes the diff a lot nicer.
| let offset = 0; | ||
| for (let i = 0; i <= maxLods; i++) { | ||
| const sizeLod = Math.pow(2, i); | ||
| const renderTarget = new WebGLRenderTargetCube(sizeLod, sizeLod, params); |
There was a problem hiding this comment.
Do we create an extra WebGLRenderTargetCube here and throw it away in the case that i === maxLods?
cdata
left a comment
There was a problem hiding this comment.
Look great, works great. Ship it!
| * (PMREM) from a cubeMap environment texture. This allows different levels of | ||
| * blur to be quickly accessed based on material roughness. It is packed into a | ||
| * special CubeUV format that allows us to perform custom interpolation so that | ||
| * we can support nonlinear formats such as RGBE. |
| export const generatePMREM = | ||
| (cubeTarget: WebGLRenderTargetCube, renderer: WebGLRenderer): | ||
| WebGLRenderTarget => { | ||
| const {cubeUVRenderTarget, cubeLods, meshes} = setup(cubeTarget); |
| renderer.gammaOutput = gammaOutput; | ||
|
|
||
| cubeLods.forEach((target) => { | ||
| target.dispose(); |
There was a problem hiding this comment.
Do we need to do any disposal of meshes here? Or are we explicitly relying on them not being disposed (on account of internal caching side-effects in Three.js)?
There was a problem hiding this comment.
I'm not relying on it. Honestly I wasn't sure what needed disposal besides renderTargets.
| (cubeTarget: WebGLRenderTargetCube, renderer: WebGLRenderer): | ||
| WebGLRenderTarget => { | ||
| const {cubeUVRenderTarget, cubeLods, meshes} = setup(cubeTarget); | ||
| // This hack in necessary for now because CubeUV is not really a |
New PMREM (google#684) * 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) * added new PMREMGenerator * modified MeshStandardShader to show it can work * 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 * added envmap chunk * updated three's shaders * fixed shaders * shaders compile * fixed all WebGL errors * PMREMGenerator now takes any encoding of input texture * fixed several shader bugs * fixed mipmap generation * fixed maxLod * PMREM mostly working * recreate intermediate targets * fixed mipmap level selection * minor cleanup * addressing feedback * refactored PMREM * cleanup * dispose of temp materials * removed envMap hack * removed android sauce test
Fixes #671
Really, the point of this change is to change PMREM to not have sparkles anymore and to be faster. In this PR, it basically makes the rendering mirror the case where you use an HDR floating-point environment with three's Standard Material, but now it can work with an RGBE texture, thus requiring no special gl extensions. That handles very HDR environments well, but does a poor job on roughness > ~0.2. I'm working on a new method to improve that.
This PR demonstrates the method I found to extend the Standard Material, but it does not show the diffs for the shader chunks (since it has nothing to compare them to here). The only changes to envmap_physical_pars_fragment.glsl.js were lines 31 and 92. cube_uv_reflection_fragment.glsl.js on the other hand, was completely rewritten. PMREMGenerator.ts pulls many ideas from PMREMGenerator.js and PMREMCubeUVPacker.js in three, but is also a rewrite.