mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
101.31k stars 35.27k forks source link

GroundedSkybox zenit/nadir visual artifacts #27498

Open hybridherbst opened 7 months ago

hybridherbst commented 7 months ago

Description

The new approach exhibits relatively obvious typical rendering artifacts from "just" sampling a texture on a UVed sphere at the top and bottom:

image image

I think that's why typically a shader is used to sample exact values, instead of relying on UV interpolation to do its thing.

(I understand bringing back a custom shader introduces some of the same complexities on why GroundProjectedSkybox was removed)

cc @elalish

Reproduction steps

  1. Add GroundedSkybox to a scene with a typical radius
  2. Note artifacts

Code

-

Live example

-

Version

r161

Mugen87 commented 7 months ago

Yeah, these artifacts are inevitable when directly projecting an equirectangular texture onto a sphere geometry. But considering the drawbacks of the previous solution (see https://github.com/mrdoob/three.js/issues/27422#issue-2053326206), I doubt we go back to a based shader approach.

If you are not happy with these artifacts, it's best if you use the previous version as a custom class in your app.

hybridherbst commented 7 months ago

I'm not asking to get the vertex shader back that the previous solution did – the artifacts here could probably be solved with a fragment shader that ignores the UVs, similar to how .background does that.

The new version is much easier to control, geometry-wise. Just the artifacts are bad.

Mugen87 commented 7 months ago

I'm not asking to get the vertex shader back that the previous solution did – the artifacts here could probably be solved with a fragment shader that ignores the UVs, similar to how .background does that.

Even if you just need a custom fragment shader, we end up with a shader material again. Not using ShaderMaterial was one of the main reasons for going towards GroundedSkybox, see https://github.com/mrdoob/three.js/issues/27422#issuecomment-1867459020.

Mugen87 commented 7 months ago

Besides, I personally would use GroundedSkybox with special controls settings (e.g. with a maximum polar angle). In this way, the user never sees the artifact at the top. Depending on the loaded 3D object, the bottom artifact isn't visible as well (like in the example) because it is hidden by the object's geometry.

elalish commented 7 months ago

If GroundedSkybox gets pulled into core it could probably share the .background shader. Not sure that'll happen though.

hybridherbst commented 7 months ago

Not sure what the consensus is so far regarding the usage of node-based shaders in examples, but GroundedSkybox could probably use a pretty simple node material to fix the seam issue.