# How do I make MSAA affect my post-process outline shader

**URL:** <https://forum.babylonjs.com/t/how-do-i-make-msaa-affect-my-post-process-outline-shader/55406>\
**Category:** Questions\
**Tags:** postprocessing, antialiasing\
**Created:** [December 16, 2024, 5:11pm UTC](https://forum.babylonjs.com/t/how-do-i-make-msaa-affect-my-post-process-outline-shader/55406 "2024-12-16T17:11:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fazil47](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/fazil47/32/38879_2.png) [@fazil47](https://forum.babylonjs.com/u/fazil47)\
**Post date:** [December 16, 2024, 5:11pm UTC](https://forum.babylonjs.com/t/how-do-i-make-msaa-affect-my-post-process-outline-shader/55406/1 "2024-12-16T17:11:11Z")

</div>

Playground link: [https://playground.babylonjs.com/#9465JA#7](https://playground.babylonjs.com/#9465JA#7)

I’m drawing an outline around scene objects by feeding the depth buffer output to a post-process shader which uses a Sobel filter to get outlines, and I’m using Gaussian blurring to make it smoother. But I’m still getting jaggies, and MSAA doesn’t seem to affect the outline. How do I get smooth outlines?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [December 16, 2024, 5:37pm UTC](https://forum.babylonjs.com/t/how-do-i-make-msaa-affect-my-post-process-outline-shader/55406/2 "2024-12-16T17:37:57Z")

</div>

MSAA won’t help because AA is applied when triangles are rendered, and in your case aliasing occurs because of your custom shader.

Blurring just the sobel value won’t help much, aliasing occurs mostly because of the hard step between Sobel/No Sobel, that is `edgeDetection = step(outlineThreshold, sobel);`. You can try to use a `smoothstep` function instead of `step`:

> **[Babylon.js Playground](https://playground.babylonjs.com/#9465JA%238)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

This helps a little:

- With `step`:  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/1/11dcfb77886b9a37cf422cc65d688de97f348a6e.png)
- With `smoothstep`  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/b/1/b1c7f296a793cdbefa146cb2a4bdab60a1340a67.png)

You can also use a AA post-process, like FXAA.

---

<div class="post-metadata">

**Author:** ![fazil47](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/fazil47/32/38879_2.png) [@fazil47](https://forum.babylonjs.com/u/fazil47)\
**Post date:** [December 16, 2024, 5:48pm UTC](https://forum.babylonjs.com/t/how-do-i-make-msaa-affect-my-post-process-outline-shader/55406/3 "2024-12-16T17:48:16Z")

</div>

~~I’d tried those two things, it doesn’t help a lot (and FXAA was giving me performance issues in my private scene). Looks like I’ll have to take another approach, but thanks for your help~~

Edit: Not sure why, but FXAA performs pretty decently now. Just using FXAA is good enough.
