Skip to content

PMREMGenerator: Add flipEnvMap.#23158

Merged
Mugen87 merged 4 commits intomrdoob:devfrom
Mugen87:dev19
Jan 6, 2022
Merged

PMREMGenerator: Add flipEnvMap.#23158
Mugen87 merged 4 commits intomrdoob:devfrom
Mugen87:dev19

Conversation

@Mugen87
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator Author

Mugen87 commented Jan 6, 2022

Merging for further testing.

@Mugen87
Copy link
Copy Markdown
Collaborator Author

Mugen87 commented Jan 6, 2022

Updated builds: 3843183

envMap: cubeRenderTarget2.texture,
combine: THREE.MultiplyOperation,
reflectivity: 1
roughness: 0,
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

void main() {

gl_FragColor = textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) );
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
Copy link
Copy Markdown
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