# Problem when transparent points overlap

**URL:** <https://discourse.threejs.org/t/problem-when-transparent-points-overlap/18754>\
**Category:** Questions\
**Tags:** points\
**Created:** [September 16, 2020, 10:41am UTC](https://discourse.threejs.org/t/problem-when-transparent-points-overlap/18754 "2020-09-16T10:41:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![theoavoyne](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/theoavoyne/32/14871_2.png) [@theoavoyne](https://discourse.threejs.org/u/theoavoyne)\
**Post date:** [September 16, 2020, 10:41am UTC](https://discourse.threejs.org/t/problem-when-transparent-points-overlap/18754/1 "2020-09-16T10:41:48Z")

</div>

Hi there,

I’m quite new using three.js. I have a bunch of points which I apply a texture to. These textures use transparency.

Here’s what happen:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/2X/9/900413b51ac0ad5673ae59beb47b5c8870b12f05.jpeg)

As you can see, sometimes it works great (the point is transparent) and sometimes it seems that the point is opaque (i.e. we can’t see the other one that’s behind it).

Any idea how I can fix this?

Also, any idea how I can fix the pixelated look of the edges of the circles? I have set `antialias: true` in the renderer but it’s not doing anything.

Here’s my code:

```
const texture = new THREE.TextureLoader().load(PointPNG);

const material = new THREE.PointsMaterial({
  color: 0x0000ff,
  map: texture,
  size: 50,
  alphaTest: 0.1,
  transparent: true,
});

```

Cheers !

---

<div class="post-metadata">

**Author:** ![Fyrestar](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/fyrestar/32/52793_2.png) [@Fyrestar](https://discourse.threejs.org/u/Fyrestar)\
**Post date:** [September 16, 2020, 11:00am UTC](https://discourse.threejs.org/t/problem-when-transparent-points-overlap/18754/2 "2020-09-16T11:00:49Z")

</div>

The points need to be sorted before each render call in order to properly blend by alpha, except if you use additive blending then the order doesn’t matter.

---

<div class="post-metadata">

**Author:** ![theoavoyne](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/theoavoyne/32/14871_2.png) [@theoavoyne](https://discourse.threejs.org/u/theoavoyne)\
**Post date:** [September 16, 2020, 11:11am UTC](https://discourse.threejs.org/t/problem-when-transparent-points-overlap/18754/3 "2020-09-16T11:11:26Z")

</div>

Thanks for your reply. I tried adding `blending: THREE.AdditiveBlending` to `PointsMaterial`, but it doesn’t seem to solve the problem:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/2X/f/fd6c23c597eb9051dd36f6dd1e4dc075422eaa86.jpeg)

---

<div class="post-metadata">

**Author:** ![Fyrestar](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/fyrestar/32/52793_2.png) [@Fyrestar](https://discourse.threejs.org/u/Fyrestar)\
**Post date:** [September 16, 2020, 11:18am UTC](https://discourse.threejs.org/t/problem-when-transparent-points-overlap/18754/4 "2020-09-16T11:18:29Z")

</div>

Oh yes you need to disable depth test `depthTest: false`.

---

<div class="post-metadata">

**Author:** ![theoavoyne](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/theoavoyne/32/14871_2.png) [@theoavoyne](https://discourse.threejs.org/u/theoavoyne)\
**Post date:** [September 16, 2020, 12:06pm UTC](https://discourse.threejs.org/t/problem-when-transparent-points-overlap/18754/5 "2020-09-16T12:06:56Z")

</div>

The problem is that I have other objects in the scene and this causes my points to go over all of these.

---

<div class="post-metadata">

**Author:** ![Fyrestar](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/fyrestar/32/52793_2.png) [@Fyrestar](https://discourse.threejs.org/u/Fyrestar)\
**Post date:** [September 16, 2020, 12:28pm UTC](https://discourse.threejs.org/t/problem-when-transparent-points-overlap/18754/6 "2020-09-16T12:28:41Z")

</div>

I see, then you need sorting anyway. You can store each point in an array where you update a distance property (distance to camera), sort the array by it and write the positions by the sorted array to the points geometry position attribute, so you can use any kind of blending correctly and keep depth testing enabled.

---

<div class="post-metadata">

**Author:** ![theoavoyne](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/theoavoyne/32/14871_2.png) [@theoavoyne](https://discourse.threejs.org/u/theoavoyne)\
**Post date:** [September 16, 2020, 3:11pm UTC](https://discourse.threejs.org/t/problem-when-transparent-points-overlap/18754/7 "2020-09-16T15:11:11Z")

</div>

Thank’s a lot for your time! Why can’t three.js compute this for me as it does for any other object?

---

<div class="post-metadata">

**Author:** ![Fyrestar](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/fyrestar/32/52793_2.png) [@Fyrestar](https://discourse.threejs.org/u/Fyrestar)\
**Post date:** [September 16, 2020, 4:19pm UTC](https://discourse.threejs.org/t/problem-when-transparent-points-overlap/18754/8 "2020-09-16T16:19:21Z")

</div>

It’s a specific usecase and there are couple ways to sort and deal with sorting or updating multiple attributes, for alphaTest only cases it wouldn’t be even necessary to sort.

---

<div class="post-metadata">

**Author:** ![Usnul](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/usnul/32/2355_2.png) [@Usnul](https://discourse.threejs.org/u/Usnul)\
**Post date:** [September 17, 2020, 12:24am UTC](https://discourse.threejs.org/t/problem-when-transparent-points-overlap/18754/9 "2020-09-17T00:24:40Z")

</div>

Sorting is the only way, there are other options that you could explore, but not my knowledge all other ways such as order-independent transparency have too many other requirements to make them truly viable.

I use sorting in my [particle engine](https://discourse.threejs.org/t/particle-engine/8044) too, for pretty much the same reasons.
