<p>You can use the depth buffer to ensure that the second time you get on a point the pixels aren't written. </p>

<p>You start with the maximum depth value and each new path (that you want to add to the existing drawn image) you decrement the depth.</p>

CC BY-SA 3.0
2016-03-02T09:51:44.850Z
2016-03-02T09:51:44.850Z
ratchet freak
<p>I am trying to implement svg rendering by opengl using meshes. 
In paths with opacity less than 1, the color of overlapping strokes add up. </p>

<p><a href="https://i.sstatic.net/rarVy.png" rel="noreferrer"><img src="https://i.sstatic.net/rarVy.png" alt="![enter image description here"></a></p>

<p>But it should be like this</p>

<p><a href="https://i.sstatic.net/M9PbX.png" rel="noreferrer"><img src="https://i.sstatic.net/M9PbX.png" alt="enter image description here"></a></p>

<p>the opengl calls are:</p>

<pre><code>    glDepthMask(false);
    glEnable(GL20.GL_BLEND);
    glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    ....
    glDrawArrays(....);
    ....
    glDepthMask(true);
</code></pre>

<p>is there any opengl calls, shader or other method to have same transparent value around the whole stroke without modifying the geometry of the shape?</p>

<opengl><image-processing><vector-graphics>
SVG opengl implementation - strokes overlap on transparency
user3902333
# SVG opengl implementation - strokes overlap on transparency

(Asked by: username_0 on 2016-03-02)

I am trying to implement svg rendering by opengl using meshes.
In paths with opacity less than 1, the color of overlapping strokes add up.

[![![enter image description here](https://i.sstatic.net/rarVy.png)](https://i.sstatic.net/rarVy.png)

But it should be like this

[![enter image description here](https://i.sstatic.net/M9PbX.png)](https://i.sstatic.net/M9PbX.png)

the opengl calls are:

```
    glDepthMask(false);
    glEnable(GL20.GL_BLEND);
    glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    ....
    glDrawArrays(....);
    ....
    glDepthMask(true);

```

is there any opengl calls, shader or other method to have same transparent value around the whole stroke without modifying the geometry of the shape?

**Tags:** opengl, image-processing, vector-graphics


---

## 1 answers

### Answer by username_1 on 2016-03-02. Score: 3 | Accepted answer

You can use the depth buffer to ensure that the second time you get on a point the pixels aren't written.

You start with the maximum depth value and each new path (that you want to add to the existing drawn image) you decrement the depth.


---

