Skip to content

Conversation

AxiomeCG
Copy link
Contributor

Related issue: closes #26246

Description

This branch contains the ongoing process of update for the examples about postprocessing that I'm working on with the stream.

@AxiomeCG
Copy link
Contributor Author

By default I've used the old LUTPass for the webgl_postprocessing_3dlut example. postprocessing seems to have 1D and 3D LUT but not 2D, it is why I stayed on the old one. I need to understand better the implications before moving totally to the postprocessing effect. But still, it is using a custom pass for the LUT, so it is still coherent with the postprocessing pipeline requirements.

If anyone has a different feeling about this example, we can work something out, but for now I'm just trying to preserve the capabilities of the examples.


camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
params.use2DLut ? lutMap[ params.lut ].texture : lutMap[ params.lut ].texture3D;

Check warning

Code scanning / CodeQL

Expression has no effect

This expression has no effect.

camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
params.use2DLut ? lutMap[ params.lut ].texture : lutMap[ params.lut ].texture3D;

Check warning

Code scanning / CodeQL

Expression has no effect

This expression has no effect.

camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
params.use2DLut ? lutMap[ params.lut ].texture : lutMap[ params.lut ].texture3D;

Check warning

Code scanning / CodeQL

Expression has no effect

This expression has no effect.
Comment on lines +19 to +20
"three/addons/": "./jsm/",
"postprocessing": "https://esm.sh/postprocessing"
Copy link
Contributor

Choose a reason for hiding this comment

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

This bundles its own copy of three.js. Maybe use another CDN which isn't so helpful like unpkg.com?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With unpkg, I did not manage to get it work somehow. It searches the three dependency unfortunately. I'm no expert in importmap, if you have a quick fix, I would be glad to change it

20230613_200718.jpg

20230613_200722.jpg

Thank you in advance !

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you may have to point unpkg to the ESM file explicitly, otherwise it's serving CJS. For example:

"postprocessing": "https://unpkg.com/postprocessing@6.33.0/build/index.js"


const effect3 = new ShaderPass( GammaCorrectionShader );
const gammaCorrectionMaterialShader = new THREE.ShaderMaterial( GammaCorrectionShader );
const effect3 = new PP.ShaderPass( gammaCorrectionMaterialShader, 'tDiffuse' );
Copy link
Collaborator

Choose a reason for hiding this comment

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

When using postprocessing, GammaCorrectionShader should be omitted. The package handles renderer.outputColorSpace automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, will fix it. Thank you for the insight ! 🤝

lutPass = new LUTPass();
composer.addPass( lutPass );
const gammaShaderMaterial = new THREE.ShaderMaterial( GammaCorrectionShader );
composer.addPass( new PP.ShaderPass( gammaShaderMaterial, 'tDiffuse' ) );
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing the Gamma Correction pass here results in a different visual:
See the comparison below :

With gamma correction pass

With gamma correction pass

Without gamma correction pass

Without gamma correction pass

Original example from threejs.org

Original example from threejs.org

The fact that the LUT pass is fed with the gamma correction pass output is meaningful for the final result. The outputColorSpace occurs at the end of the pipeline. For this example, I think we should keep the intermediary gamma correction pass.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah good call – yes, if the LUT requires sRGB input then we should use OutputPass before the LUT. Possibly there are other ways to handle this in postprocessing but we don't need to consider that now. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for helping me shape this PR the postprocessing way, I'm learning a lot too 👌

…n pmdrs postprocessing library and happening through outputColorSpace (mrdoob#26246)
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.

Post Processing: Use the pmdrs postprocessing library in examples
3 participants