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

Broken environment reflections when using render to texture #7183

Open
MAG-AdrianMeredith opened this issue Dec 8, 2024 · 4 comments
Open
Assignees
Labels
area: graphics Graphics related issue bug

Comments

@MAG-AdrianMeredith
Copy link
Contributor

MAG-AdrianMeredith commented Dec 8, 2024

Description

When rendering a model with a secondary camera into a renderTarget, the reflections are broken.

I was able to reproduce this using a totally clean checkout against latest main and v2.1.0. Weirdly enough the same code running on the examples website seems to work???

Steps to Reproduce

  1. load the examples app locally
  2. load up the render to texture example
  3. load a model with shiny parts

and add ContainerHandler + Basis
4. See that the model in the render to textures is super shiny and totally broken

@mvaligursky
Copy link
Contributor

Interestingly this seems to work on WebGPU for me, only the WebGL has the issue.

@mvaligursky
Copy link
Contributor

If I comment out this line from the example, all is fine. Need to investigte:

        // flipY: !app.graphicsDevice.isWebGPU,

@mvaligursky
Copy link
Contributor

Learnings as I investigate this:

  • it happens on both WebGL and WebGPU, if we set flipY to true on the render target. The issue is related to the flipping. We currently do the flipping by mirroring the projection matrix along the Y.
  • The issue comes from fresnel calculation. We do this:
dReflection.rgb *= getFresnel(
    dot(dViewDirW, litArgs_worldNormal), litArgs_gloss, litArgs_specularity
);

If I comment out this block, both rendering's match. So the problem is the fresnel term is incorrect in the texture. Could be either problem with viewDir, or with worldNormal.

@mvaligursky
Copy link
Contributor

passing -litArgs_worldNormal to that function instead of litArgs_worldNormal solves this. Just need to figure out a generic solution, other implications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue bug
Projects
None yet
Development

No branches or pull requests

3 participants