<p>I am currently experiencing a very obvious artifact that occurs when looking at objects on very grazing angles</p>

<p>Here is a picture of the artifact:
<a href="https://i.sstatic.net/ZNQL3.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ZNQL3.png" alt="artifact"></a></p>

<p>I noticed that the issue was coming from my implementation of Cook-Torrance's Specular BRDF. </p>

<p>Here is the equation for the Cook-Torrance Specular BRDF: 
<a href="https://i.sstatic.net/0wcIZ.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/0wcIZ.jpg" alt="Cook-Torrance Specular BRDF"></a></p>

<p>More specifically, calculating the denominator is causing the issue:</p>

<pre><code>float denominator = 4 * max(dot(viewDir, normal), 0.0) * max(dot(lightDir, normal), 0.0) + 0.001;  // Prevents any division by zero
</code></pre>

<p>When I change the calculation of dot(viewDir, normal) to dot(halfway, normal), the artifact disappears:</p>

<pre><code>float denominator = 4 * max(dot(halfway, normal), 0.0) * max(dot(lightDir, normal), 0.0) + 0.001;  // Prevents any division by zero
</code></pre>

<p>But this equation is no longer correct. I was wondering if anyone knows why my implementation causes these artifacts?</p>

<p>If you want to see my fragment shader you can find the code here:</p>

<p><a href="https://github.com/Ershany/Arcane-Engine/blob/WIP_PBR/Arcane%20Engine%20Core/src/shaders/pbr_model.frag" rel="nofollow noreferrer">https://github.com/Ershany/Arcane-Engine/blob/WIP_PBR/Arcane%20Engine%20Core/src/shaders/pbr_model.frag</a></p>

<p>Thank you!</p>

CC BY-SA 4.0
2018-11-08T17:04:25.793Z
I made that post awhile back and was asking for help with my normal mapping code, which I discovered wasn't the issue. I actually located the issue now and I am asking for feedback on why this is occurring.
Brady Jessup
CC BY-SA 4.0
2018-11-08T17:05:25.273Z
It's fine, just update your original question with the new information you found.
Julien Guertault
<brdf><specular>
Cook-Torrance Specular BRDF Artifact
Brady Jessup
# Cook-Torrance Specular BRDF Artifact

(Asked by: username_0 on 2018-11-08)

I am currently experiencing a very obvious artifact that occurs when looking at objects on very grazing angles

Here is a picture of the artifact:
[![artifact](https://i.sstatic.net/ZNQL3.png)](https://i.sstatic.net/ZNQL3.png)

I noticed that the issue was coming from my implementation of Cook-Torrance's Specular BRDF.

Here is the equation for the Cook-Torrance Specular BRDF:
[![Cook-Torrance Specular BRDF](https://i.sstatic.net/0wcIZ.jpg)](https://i.sstatic.net/0wcIZ.jpg)

More specifically, calculating the denominator is causing the issue:

```
float denominator = 4 * max(dot(viewDir, normal), 0.0) * max(dot(lightDir, normal), 0.0) + 0.001;  // Prevents any division by zero

```

When I change the calculation of dot(viewDir, normal) to dot(halfway, normal), the artifact disappears:

```
float denominator = 4 * max(dot(halfway, normal), 0.0) * max(dot(lightDir, normal), 0.0) + 0.001;  // Prevents any division by zero

```

But this equation is no longer correct. I was wondering if anyone knows why my implementation causes these artifacts?

If you want to see my fragment shader you can find the code here:

<https://github.com/Ershany/Arcane-Engine/blob/WIP_PBR/Arcane%20Engine%20Core/src/shaders/pbr_model.frag>

Thank you!

**Tags:** brdf, specular

> **Comments:**
> **username_0**: I made that post awhile back and was asking for help with my normal mapping code, which I discovered wasn't the issue. I actually located the issue now and I am asking for feedback on why this is occurring.  
> **username_1**: It's fine, just update your original question with the new information you found.  

---

## 0 answers

