[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vr / w / wg] [i / ic] [r9k] [s4s] [cm / hm / lgbt / y] [3 / aco / adv / an / asp / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / qst / sci / soc / sp / tg / toy / trv / tv / vp / wsg / wsr / x] [Settings] [Home]
Board
Settings Home
/3/


File: softBrushComp.jpg (66.70 KB, 921x840)
66.70 KB
66.70 KB JPG
Using OpenGL and C++ I render partially transparent brush textures on mousemove as seen on the left and get the following result which I don't want. I want the result on the right, from photoshop, which uses the same texture.

In my application I hold the mouse down and basically generate points with the Bresenham algorithm. Then, I render the soft brush texture at each point.

I expect the program to add my textures together, but I get darkening and banding around each texture.

I also use the following GL settings.
>glEnable(GL_BLEND);
>glBlendEquation(GL_FUNC_ADD);
>glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);


Do I have a problem with incorrect blend modes or transparency sorting or both ?
>>
using bresenham to render points seems pretty pointless, bresenham operates at a per-pixel level. If your "brush texture" is larger than one pixel, just linearly interpolate it along the stroke and stamp it as you go along with a small delta. That's the normal way to go.

secondly, you should know that there are two different ways of blending a brush, "buildup" and "wash". I think in PS it's hardcoded for each brush what is used, but krita lets you set it for each brush individually, try it out to understand what the difference looks like visually. The gist is that "wash" blends (with the desired blending mode) each of the stamped brush textures onto the image individually. "buildup" on the other hand draws secretly onto a secondary texture, and blends the brush stamps with eachother always using the "normal" blending mode. Then the entire texture gets blended onto the image using the desired blending mode. Once you end the stroke, the texture is blended onto the image for real.

I'm pretty sure you're using wash when you really want buildup.

Whether transparency sorting is a thing you need to care about depends on how you render. with a zbuffer or without? If stuff just comes in "layers" rather than "z-positions" no sorting is really necessary as such.

I've never touched the BlendFunc() functions, I'd just leave them on whatever the default is. I don't think alpha should be a relevant concern for additive blending; if you want a pixel on the brush to be "transparent", just make it black.
>>
File: hard edge.png (11.89 KB, 491x397)
11.89 KB
11.89 KB PNG
>>502064
>using bresenham to render points seems pretty pointless, bresenham operates at a per-pixel level. If your "brush texture" is larger than one pixel, just linearly interpolate it along the stroke and stamp it as you go along with a small delta. That's the normal way to go.

Thanks for the tip

>you should know that there are two different ways of blending a brush, "buildup" and "wash". I think in PS it's hardcoded for each brush what is used, but krita lets you set it for each brush individually, try it out to understand what the difference looks like visually. The gist is that "wash" blends (with the desired blending mode) each of the stamped brush textures onto the image individually.
Yes I've seen this and I want to get a "wash" going for soft brushes. I've been able to mimic hard brush "wash" from krita/PS as seen in this attachment using a different algorithm. However, it doesn't work with partial transparency.

>Whether transparency sorting is a thing you need to care about depends on how you render. with a zbuffer or without? If stuff just comes in "layers" rather than "z-positions" no sorting is really necessary as such.
For this example I render the brush strokes with XY translation and scale to a FBO.

>I don't think alpha should be a relevant concern for additive blending; if you want a pixel on the brush to be "transparent", just make it black.
The brush texture is underneath the "soft brush" red text. It's white fading to black which was created by the photoshop radial gradient tool. This was copied into the alpha channel and saved as tga.



Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.