Question

Im a beginner in cocos2d.

Im working on a line drawing app in which I draw lines of various colors. I've implemented it and the problem Im facing is color blending. On the line edges, in order to do anti aliasing, fade out color is applied on them. When I draw another line over it, the lines look not that much good i.e the overlay of the blending is visible as fading out color as in the image Edge blending.

I tried using {GL_ONE, GL_ONE_MINUS_SRC_ALPHA} and {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA} as the blend functions and also tried some others, but couldn't get the correct blending. I can't solve this for the last three days. Can some one help me to sort this out??

Was it helpful?

Solution

If your goal is that two lines that touch should appear to be a single solid object, with a faded edge around the common shape, I don't think any simple blending mode can achieve that effect.

One way to do it might be to draw all the lines to an external framebuffer using just a flat solid color (no edge fade), and then try to apply a blur or edge detection shader over that framebuffer, to put edges around the combined shape.

Might be difficult if you're a beginner, but it should give you some terms to start researching if you're interested.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top