question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebGLBackground: Rendering issue with Reflector

See original GitHub issue
Description of the problem

While investigating an issue in the forum, I’ve encountered a rendering problem with scene.background.

This fiddle shows how it should look like. Proper reflections of the torus knot and the skybox: https://codepen.io/anon/pen/XqeyBM

But if you set transparent to true on the reflectors material, it looks like this: https://codepen.io/anon/pen/XqeyxR

image

For some reasons, the (white) clear color of the renderer is visible in the reflector’s render target at certain parts. I have found two ways to solve this problem:

  • Don’t use scene.background but manually create the skybox like in this example: https://codepen.io/anon/pen/jxGQQb
  • It does also work if you set depthWrite to true of the shader material in WebGLBackground.

I don’t know so far why these approaches fix the issue but I suppose it has to do something with the way WebGLBackground renders the background.

Note: The reflector is rendered after the background in all these examples.

Three.js version
  • Dev
  • r92
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, …)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mrdoobcommented, Jan 29, 2019

The problem is also visible in the WebVR sandbox demo. As soon as you remove the background, the glitch is gone.

I think #15662 fixed that issue.

1reaction
Mugen87commented, Nov 28, 2018

Yes, it does!!! Yay! 🎉 🙌

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix rendering from a reflector? - Questions - three.js forum
I'm now working with Reflectors, they work ok but when using a skybox the render goes glitchy in the mirror. Any idea of...
Read more >
WebGL Player settings - Unity - Manual
Rendering. Use these settings to customize how Unity renders your game for the WebGL platform. Choose which color space should be used for...
Read more >
WebGL drawArrays generates white background
The problem is that it sometimes renders a triangle on a white background although clear color is set to non-transparent black. (in latest...
Read more >
Getting started with the WebGL renderer | Three.js Cookbook
When you want to create an initial Three.js project that uses WebGL for rendering, you always have to set up the same couple...
Read more >
Creating the Effect of Transparent Glass and Plastic in Three.js
three is an open-source javascript library for rendering 3D ... I think that's transparent, we can see the background colour through it.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found