Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ugly render on clouds

I'm trying to implement the code from this tutorial, but in much greater proportions (radius = 100000 units).

I don't know if the size matters but on my earth render the clouds have a strange render. As the tutorial does, I'm using two spheres and three textures (earth map, bump map, clouds).

Here the result (that's worse if the clouds are closer): Earth

More the clouds are closer of the planet surface, more this glitch is visible. If the clouds are sufficiently far (but that's not realistic) the problem disappears completely.

What can I do?

like image 356
Morgan Touverey Quilling Avatar asked Sep 12 '26 11:09

Morgan Touverey Quilling


2 Answers

Use logarithmic depth buffer instead of the linear one. This is a very simple change, just enable logarithmicDepthBuffer when you create your THREE.WebGLRenderer like so:

var renderer = new THREE.WebGLRenderer({ antialias: true, logarithmicDepthBuffer: true});

Here's an example you can have a look at: http://threejs.org/examples/#webgl_camera_logarithmicdepthbuffer

Using polygonOffset as suggested by LJ_1102 is a possibility, but it shouldn't be necessary.

like image 106
travnik Avatar answered Sep 13 '26 23:09

travnik


What you're experiencing is z-fighting due to insufficient depth buffer resolution.

You basically have three options to counteract this:

  1. Write / use a multi-texture shader that renders all three textures on one sphere.

  2. Increase the distance between the sphere faces. / Decrease the distance between your near and far clipping planes.

  3. Use polygonOffset and the POLYGON_OFFSET_FILL renderstate to offset depth values written by your outer sphere. Read more about polygonOffset here.

like image 34
LJᛃ Avatar answered Sep 14 '26 01:09

LJᛃ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!