1

I am learning about raymarching in GLSL, and have drawn basic understanding from http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm and various shaders on the ShaderToy website.

I have created a shader where I use the signed distance function for a torus, and then repeat the shape, apply rotations, and move the camera (see https://www.shadertoy.com/view/MdlcD7)

My issue is that after applying the rotations to the tori, artefacts are being produced on the surfaces. If I remove the rotations (comment out lines 30 & 31 of the shader), then the artefacts no longer appear. Similarly, if I introduce a slight back-stepping factor to the raymarching (by un-commenting part of line 4), then the artefacts are removed. However, if I change the value of this back-stepping factor, then the artefacts return.

My questions are:

1) What is it about the rotations that are causing the artefacts?

2) If the back-stepping is the right way to go, then how do I determine a reliable factor to apply which works with any values I apply to the sdTorus function?

3) If I change from using sdTorus to using the sdBox function (by un-commenting line 32), then how would that change my answers (if at all) to the first two questions?

Many thanks in advance

DatHydroGuy
  • 1,056
  • 3
  • 11
  • 18

0 Answers0