# Antialiasing problem : thin light reflections on objects edges look jagged

**URL:** <https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713>\
**Category:** Questions\
**Tags:** antialiasing, post-processing, animation, geometry\
**Created:** [October 11, 2021, 11:47am UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713 "2021-10-11T11:47:41Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pedronimo](https://avatars.discourse-cdn.com/v4/letter/p/b782af/32.png) [@Pedronimo](https://discourse.threejs.org/u/Pedronimo)\
**Post date:** [October 11, 2021, 11:47am UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713/1 "2021-10-11T11:47:41Z")

</div>

![bottleproject_flickering](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/a/0/a0661b80720a01118c61c2a9af5bd703bc2ea618.jpeg)

Does anyone have an idea to apply antialias in this case ?  
[https://codepen.io/Pierre33300/pen/MWoNKxv](https://codepen.io/Pierre33300/pen/MWoNKxv)

Aliasing is very disturbing when the objects are animated, especially when the reflect of the light is on the objects edges. It looks jagged and twinkling. Is there a way to fix it ?  
I tried with smaaPass, taa, fxaa, webGLmultisampleRenderTarget but nothing works 😩  
[https://codepen.io/Pierre33300/pen/MWoNKxv](https://codepen.io/Pierre33300/pen/MWoNKxv)

---

<div class="post-metadata">

**Author:** ![Vasanth\_Kumar](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/vasanth_kumar/32/32965_2.png) [@Vasanth\_Kumar](https://discourse.threejs.org/u/Vasanth_Kumar)\
**Post date:** [October 11, 2021, 1:51pm UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713/2 "2021-10-11T13:51:48Z")

</div>

Disable receiveShadow for the model. It helped me. Please try if it works.

model.traverse(o =\> {  
if (o.isMesh) {  
o.castShadow = true;  
o.receiveShadow = false;  
o.material = stmtl;  
}

---

<div class="post-metadata">

**Author:** ![Pedronimo](https://avatars.discourse-cdn.com/v4/letter/p/b782af/32.png) [@Pedronimo](https://discourse.threejs.org/u/Pedronimo)\
**Post date:** [October 11, 2021, 3:00pm UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713/3 "2021-10-11T15:00:39Z")

</div>

Thanks for your help 😉 but no, it doesn’t work

---

<div class="post-metadata">

**Author:** ![gkjohnson](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/gkjohnson/32/2298_2.png) [@gkjohnson](https://discourse.threejs.org/u/gkjohnson)\
**Post date:** [October 15, 2021, 3:11pm UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713/4 "2021-10-15T15:11:52Z")

</div>

A couple things that come to mind that you could try:

- Blur the environment map a little bit
- Generate mipmaps / use PMREMGenerator for the environment map
- Render image at a higher resolution and downsample – of course this will be a bit performance intensive

---

<div class="post-metadata">

**Author:** ![looeee](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/looeee/32/59_2.png) [@looeee](https://discourse.threejs.org/u/looeee)\
**Post date:** [October 16, 2021, 6:26am UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713/5 "2021-10-16T06:26:43Z")

</div>

In my experience this is usually caused by wrong settings for metalness/roughness. You’re modeling glass, so metalness should be zero - metal should always be 1 for metals and 0 for anything else. Roughness can be any value between 0 and 1, but no material will ever be perfectly smooth so try a value like 0.1 and work down from there.

---

<div class="post-metadata">

**Author:** ![Pedronimo](https://avatars.discourse-cdn.com/v4/letter/p/b782af/32.png) [@Pedronimo](https://discourse.threejs.org/u/Pedronimo)\
**Post date:** [October 16, 2021, 8:54pm UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713/6 "2021-10-16T20:54:57Z")

</div>

Ok, why not, I’m gonna try this.  
Thank you for your help, I’ll let you know if it works.

---

<div class="post-metadata">

**Author:** ![Pedronimo](https://avatars.discourse-cdn.com/v4/letter/p/b782af/32.png) [@Pedronimo](https://discourse.threejs.org/u/Pedronimo)\
**Post date:** [October 16, 2021, 9:04pm UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713/7 "2021-10-16T21:04:21Z")

</div>

Thank you for your answer.  
Yes, I know that the metalness should be zero but there are metallic part in the labels and I have to activate it. Or else, it’s not realistic. I don’t know how to do it otherwise.  
I use substancepainter to make textures and export them in pbr. May be it’s not a good workflow.  
The same textures works perfectly in blender, but I have to “cheat” to make them work in Three.js.  
To ensure that the textures wasn’t the reason of the problem, I tried this simple textures and geometry, and the problem persists. You can see it here : [https://codepen.io/PGAA/pen/MWoNKxv?editors=0010](https://codepen.io/PGAA/pen/MWoNKxv?editors=0010)

---

<div class="post-metadata">

**Author:** ![looeee](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/looeee/32/59_2.png) [@looeee](https://discourse.threejs.org/u/looeee)\
**Post date:** [October 17, 2021, 5:33am UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713/8 "2021-10-17T05:33:07Z")

</div>

Hmm, even with the envmap disabled (only the `DirectionalLight` in the scene) there are certain camera angles that show this issue.It looks physically incorrect to me, possibly some value getting blown out in the shader.

I’m talking about the bright jagged white line down the right side of the big cylinder . Zoom in to see it clearly - and if you move the camera even a fraction, or animate the model, it flickers in and out. @Mugen87, @gkjohnson, @donmccurdy what do you guys think about this? Is it an error in the shader?

 ![2021-10-17 12_26_13-Aliasing — Mozilla Firefox](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/e/5/e584781478f02a85aa1bf376b06e49d273b03f0d.png)

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [October 17, 2021, 8:23am UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713/9 "2021-10-17T08:23:23Z")

</div>

I’ve noticed this effect with other models, too. I did not have the time to investigate the issue in more detail yet but at first glance the behavior looks buggy to me.

---

<div class="post-metadata">

**Author:** ![Etienne](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/etienne/32/17680_2.png) [@Etienne](https://discourse.threejs.org/u/Etienne)\
**Post date:** [October 17, 2021, 4:27pm UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713/10 "2021-10-17T16:27:33Z")

</div>

not sure this is three related as it seems to occur with other engines:

> **[r/godot - How to remove choppy white artifacts surrounding sphere meshes when...](https://www.reddit.com/r/godot/comments/oehq1d/how_to_remove_choppy_white_artifacts_surrounding/)**
>
> 8 votes and 4 comments so far on Reddit

also found this shader which seems to deal with same side effect:

> **[Shadertoy](https://www.shadertoy.com/view/WssyR7)**

---

<div class="post-metadata">

**Author:** ![D13](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@D13](https://discourse.threejs.org/u/D13)\
**Post date:** [October 17, 2021, 4:37pm UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713/11 "2021-10-17T16:37:01Z")

</div>

Yep, I changed to PhysicalMaterial and used shininess settings at 2000 and a clearCoat to try and see if getting more light on the edge would make it stop flickering. It doesn’t. Its across materials. It does smooth out the line anti-aliasing some but the flicker continues. I think its in the lighting itself. It seems like its updating 2 different aspects of the lighting at a different timing.

---

<div class="post-metadata">

**Author:** ![Pedronimo](https://avatars.discourse-cdn.com/v4/letter/p/b782af/32.png) [@Pedronimo](https://discourse.threejs.org/u/Pedronimo)\
**Post date:** [October 17, 2021, 7:18pm UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713/12 "2021-10-17T19:18:46Z")

</div>

Thank you for your interest. I hope you will have time soon to help to resolve it. 😉

---

<div class="post-metadata">

**Author:** ![looeee](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/looeee/32/59_2.png) [@looeee](https://discourse.threejs.org/u/looeee)\
**Post date:** [October 18, 2021, 3:16am UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713/13 "2021-10-18T03:16:10Z")

</div>

> [@Etienne](#):
>
> not sure this is three related as it seems to occur with other engines:

Yeah, I have seen this referenced before when using PBR materials with low roughness - specular aliasing/firefly pattern are the usual names I think.

One suggestion that comes up is to use TAA instead of MSAA.

EDIT: specular antialiasing from The Order 1886 seems to get referenced a lot - they claim it can be done at no runtime cost which would make it a better solution than TAA. Doesn’t look especially simple to implement though and would take some study to see whether it would fit the three.js PBR model.

[s2013\_pbs\_rad\_notes.pdf (selfshadow.com)](https://blog.selfshadow.com/publications/s2013-shading-course/rad/s2013_pbs_rad_notes.pdf)

---

<div class="post-metadata">

**Author:** ![Pedronimo](https://avatars.discourse-cdn.com/v4/letter/p/b782af/32.png) [@Pedronimo](https://discourse.threejs.org/u/Pedronimo)\
**Post date:** [October 18, 2021, 7:18am UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713/14 "2021-10-18T07:18:59Z")

</div>

Thanks to Etienne, the render is much better now (postprocessing ssaaRenderPass). You can take a look here : [https://codepen.io/PGAA/pen/ffd222a0ccc75ab96ac6824fccc957d2?editors=0010](https://codepen.io/PGAA/pen/ffd222a0ccc75ab96ac6824fccc957d2?editors=0010)  
However :

- thin lines are still jagging when the reflections are very thin on the bottle (when we turn 180° around the objets). But it’s much better anyway.
- the render is now very contrasted and dark (I usually use rendertarget with postprocessing to get color fidelity before and after postprocessing). I don’t know how to fix it for the moment.

---

<div class="post-metadata">

**Author:** ![looeee](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/looeee/32/59_2.png) [@looeee](https://discourse.threejs.org/u/looeee)\
**Post date:** [October 18, 2021, 8:26am UTC](https://discourse.threejs.org/t/antialiasing-problem-thin-light-reflections-on-objects-edges-look-jagged/30713/15 "2021-10-18T08:26:28Z")

</div>

> [@Pedronimo](#):
>
> Thanks to Etienne, the render is much better now (postprocessing ssaaRenderPass).

Did you try TAA? It should also work here with less of a performance hit than SSAA.
