<p>Hey guys i was trying to render this scene with shadows. The spheres do not have any acne...but the floor and the walls seem to still have the shadow acne problem...
<a href="https://i.sstatic.net/FmjTMJVo.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/FmjTMJVo.jpg" alt="enter image description here" /></a></p>
<p>This is the code i have for IsShadowed:
bool IsShadowed(World w, Entity point) {
// Vector from point to light source
Entity v = Subtract(w.light.position, point);</p>
<pre><code>// Magnitude of that vector and it's direction
float distance = Magnitude(v);
Entity direction = Normalize(v);

// Create a ray from the point to the light source
Ray r(point, direction);

// Get list of intersections in the path of the ray
std::vector&lt;Intersection&gt; intersections = IntersectWorld(w, r);

Intersection h = Hit(intersections);
if (h.t != INFINITY &amp;&amp; h.t &lt; distance)
    return true;
else
    return false;
</code></pre>
<p>}</p>
<p>I am then calling this function in while calculating the color at the hit to determine whether the point is under shadow or not.</p>
<p>Could someone please help me with this issue</p>
<p>Thanks in advance!!</p>

CC BY-SA 4.0
2024-10-17T07:40:24.590Z
The problem seems to be that the ray starts at the point on the surface. Therefore, the first point of intersection may be the wall itself. There are several ways to solve this problem: 1: Move the point slightly in the normal direction of the surface. 2: Save the surface ID to the ray so that an intersection point with this ID is ignored. However, this can lead to problems if 2 surfaces touch each other. ...
Thomas
CC BY-SA 4.0
2024-10-17T08:24:05.353Z
@Thomas, Thanks for the help. I did move the point along the normal slightly above the surface by scaling the normal by 0.00001 and adding it the point, and it worked for the Spheres not the Walls and the floor. I increased the scaling factor to 0.01 which then seemed to work perfect. Since i had made those walls from largely scaled spheres, i needed a larger scaling factor.
Nemizis
<raytracing><shadow>
Issue regarding shadow acne (Ray Tracing)
Nemizis
# Issue regarding shadow acne (Ray Tracing)

(Asked by: username_0 on 2024-10-17)

Hey guys i was trying to render this scene with shadows. The spheres do not have any acne...but the floor and the walls seem to still have the shadow acne problem...
[![enter image description here](https://i.sstatic.net/FmjTMJVo.jpg)](https://i.sstatic.net/FmjTMJVo.jpg)

This is the code i have for IsShadowed:
bool IsShadowed(World w, Entity point) {
// Vector from point to light source
Entity v = Subtract(w.light.position, point);

```
// Magnitude of that vector and it's direction
float distance = Magnitude(v);
Entity direction = Normalize(v);

// Create a ray from the point to the light source
Ray r(point, direction);

// Get list of intersections in the path of the ray
std::vector<Intersection> intersections = IntersectWorld(w, r);

Intersection h = Hit(intersections);
if (h.t != INFINITY && h.t < distance)
    return true;
else
    return false;

```

}

I am then calling this function in while calculating the color at the hit to determine whether the point is under shadow or not.

Could someone please help me with this issue

Thanks in advance!!

**Tags:** raytracing, shadow

> **Comments:**
> **username_1**: The problem seems to be that the ray starts at the point on the surface. Therefore, the first point of intersection may be the wall itself. There are several ways to solve this problem: 1: Move the point slightly in the normal direction of the surface. 2: Save the surface ID to the ray so that an intersection point with this ID is ignored. However, this can lead to problems if 2 surfaces touch each other. ...  
> **username_0**: @username_1, Thanks for the help. I did move the point along the normal slightly above the surface by scaling the normal by 0.00001 and adding it the point, and it worked for the Spheres not the Walls and the floor. I increased the scaling factor to 0.01 which then seemed to work perfect. Since i had made those walls from largely scaled spheres, i needed a larger scaling factor.  

---

## 0 answers

