<p>I have a very weird problem in my raytracer. I have been following along with Ray Tracing in one Weekend by Peter Shirley. I have a very weird problem with artifacts in my renders. This is an image of the artifacts (I moved one sphere so that it is easy to see):<a href="https://i.sstatic.net/ZffkK.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ZffkK.png" alt="enter image description here" /></a></p>
<p>This has been a big problem, and I can't quite figure out why it is like so. I ran some tests and found out that this is not because of normal calculations, or random floating point calculations. I am just starting to learn computer graphics, and would like some help with this. If anybody had a similar problem, please tell me how I could fix it.</p>

CC BY-SA 4.0
2022-05-22T20:39:25.417Z
Offset the intersection by epsilon along the normal before tracing the next ray. Epsilon can be 0.0001 for example (but it usually depends on the scene, if 0.0001 is not enoigh, then try something larger). The rings are due to floating point error - the intersection ending up under the surface, and the scattered ray ends up intersecting the same surface where it is supposed to start from.
lightxbulb
CC BY-SA 4.0
2022-05-22T22:31:24.947Z
I tried to subtract 0.00001 from the ray length, and the artifacts went away, but now the image is too bright
UrbanSkeleton
CC BY-SA 4.0
2022-05-22T22:46:20.567Z
Nevermind, I made a mistake where I increased the amount of light a child ray can "have"
UrbanSkeleton
CC BY-SA 4.0
2022-05-22T23:14:39.787Z
Changing tmin is less robust than an offset along the normal, since it is dependent on the angle between the scattered ray and the normal.The standard recommendation is an epsilon offset of the ray origin along the normal. There are more involved techniques described in pbrt and ray tracing gems, but they are rather tedious.
lightxbulb
<raytracing>
How do I get rid of the Artifacts in my Ray tracer?
UrbanSkeleton
# How do I get rid of the Artifacts in my Ray tracer?

(Asked by: username_0 on 2022-05-22)

I have a very weird problem in my raytracer. I have been following along with Ray Tracing in one Weekend by Peter Shirley. I have a very weird problem with artifacts in my renders. This is an image of the artifacts (I moved one sphere so that it is easy to see):[![enter image description here](https://i.sstatic.net/ZffkK.png)](https://i.sstatic.net/ZffkK.png)

This has been a big problem, and I can't quite figure out why it is like so. I ran some tests and found out that this is not because of normal calculations, or random floating point calculations. I am just starting to learn computer graphics, and would like some help with this. If anybody had a similar problem, please tell me how I could fix it.

**Tags:** raytracing

> **Comments:**
> **username_1**: Offset the intersection by epsilon along the normal before tracing the next ray. Epsilon can be 0.0001 for example (but it usually depends on the scene, if 0.0001 is not enoigh, then try something larger). The rings are due to floating point error - the intersection ending up under the surface, and the scattered ray ends up intersecting the same surface where it is supposed to start from.  
> **username_0**: I tried to subtract 0.00001 from the ray length, and the artifacts went away, but now the image is too bright  
> **username_0**: Nevermind, I made a mistake where I increased the amount of light a child ray can "have"  
> **username_1**: Changing tmin is less robust than an offset along the normal, since it is dependent on the angle between the scattered ray and the normal.The standard recommendation is an epsilon offset of the ray origin along the normal. There are more involved techniques described in pbrt and ray tracing gems, but they are rather tedious.  

---

## 0 answers

