Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMREMGenerator: Add flipEnvMap. #23158

Merged
merged 4 commits into from
Jan 6, 2022
Merged

PMREMGenerator: Add flipEnvMap. #23158

merged 4 commits into from
Jan 6, 2022

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Jan 6, 2022

Related issue: #23152

Description

#23152 revealed a small issue in PMREMGenerator. When working with cube render targets, the same flip logic for px/nx is required like in the material shaders.

@Mugen87 Mugen87 requested a review from WestLangley January 6, 2022 09:24
@Mugen87 Mugen87 added this to the r137 milestone Jan 6, 2022
@Mugen87
Copy link
Collaborator Author

Mugen87 commented Jan 6, 2022

BTW: This issue was earlier reported at the forum. It's good to have the PMREMGenerator + CubeCamera use case fixed: https://discourse.threejs.org/t/pmremgenerator-cubecamera-and-envmap-mirroring-issues/30389

@Mugen87 Mugen87 merged commit d27daf6 into mrdoob:dev Jan 6, 2022
@Mugen87
Copy link
Collaborator Author

Mugen87 commented Jan 6, 2022

Merging for further testing.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Jan 6, 2022

Updated builds: 3843183

envMap: cubeRenderTarget2.texture,
combine: THREE.MultiplyOperation,
reflectivity: 1
roughness: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would also recommend using a roughness value > 0 (or several values, or adjustable values). The example only worked before for mirrored reflections; now that it uses actual PMREM, it will also work for other roughness values, so we should demonstrate that to help ensure it does not regress.

Copy link
Collaborator

Choose a reason for hiding this comment

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

varying vec3 vOutputDirection;

uniform samplerCube envMap;

void main() {

gl_FragColor = textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) );
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@joshuaellis joshuaellis mentioned this pull request Jan 19, 2022
20 tasks
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.

3 participants