GLSL alpha rendering bug in Texture Paint?

Hi,

I’m trying to use Texture Paint in Blender like Photoshop, where I have one background layer with the base texture, and on top of that there is an empty layer for details (alpha is zero initially). I do this so that I can easily paint/erase strokes on the detail layer without modifying the base texture on the background layer. I have gotten this Photoshop like scheme to work using GLSL shading and “Texture Paint Layer Manager” addon that comes with Blender.

There is one bug however that makes this unusable: There is something wrong with the alpha blending, as white color appears in the edges of the opaque parts (where alpha channel blends from 0 to 1). In the below image the base texture on the background layer is brownish, while I have drawn the black and turquoise brush strokes on the details layer. Observe the unwanted white edges.


I have not found any blend mode combination or other setting that would fix this (so that the top layer would appear just like in Photoshop or any layer based paint program). I had to add an emissive layer so that GLSL wouldn’t render the material black, but the problem is not related to that it seems, as disabling the emissive layer and adding a scene light doesn’t make the problem disappear.

Please let me know how to circumvent this issue, or fix the bug, as this kind of layered painting (with alpha channel) is very useful for artists.

You are painting into a texture, so in the UV/image editor check the premultiplied option to get better edge blending. Will it help your case enough to fix the problem? No idea. Much depends on your brush, I think.

You have some very pixelated area there - are you sure your unwrap is giving enough pixel space to the area being painted? If not, you will have some errors because you are trying to paint into a very small area.

Try upscaling your image to 2x the original size and painting again, if that helps then you will be on your way to understanding what is going on.

Changing from ‘straight’ to premultiplied option did not fix the problem.

In the above screencap I’ve zoomed very close to highlight the issue. My texture is already 4096x4096. The issue persists even if I paint on areas where the UV triangles cover more pixels.
There is something funny with the alpha blending. The RGBA image of the details layer is displayed correctly in the UV/Image editor, but when rendered with GLSL in the 3d view, alpha blended areas have white edges:


Upgrade to 2.69 and try again. I have to ask why your brush is coming out like pixels, is that intentional or a byproduct of the area not having enough pixels? Only time I had this issue was when stenciling, and it looks like you are doing just that in your stack - the layer Emissive might be causing the white border. Disable ‘Emissive’ texture layer and see if that is connected to the problem.

Here is my own findings after testing, got the pixelated brush from low size and flat curve

Attachments


Thanks for your help Craig Jones.
Yes, the brush size was 1 and I had a lot of polygons so each polygon covered relatively few pixels.
I found out more information about the issue, and it’s not related to the emissive property.
I recreated the problem in this simple toy example:



The background layer in my screencap has the default “UV Grid” texture. I created the foreground layer by painting wide vertical stripes in black, white, and red. I then erased alpha from the center of the foreground layer (revealing the UV Grid of the background layer). Finally I drew horizontal strokes with a narrow brush with black, blue, and white color.

As you can see from the screencap, the UV/Image Editor displays the narrow brush strokes correctly, but in the GLSL view the strokes have different color edges, where the actual stroke color is blended with the RGB values that were previously drawn there (black, white, red). This definitely is some kind of alpha blend issue. Enabling the ‘Stencil’ toggle in the foreground texture reduces the problem, but doesn’t fix it completely.

Merry christmas everyone :slight_smile:

I think it has to do with the fact you use a 1 pixel brush and have pressure turned on for Strength - the variance is causing the program to try to interpolate maybe, and giving the added pixel border. Turn off the pressure for strength and see if that still happens then. If not, I am sure then you can submit a bug report with a few packed images like the file you have there.

Yeah, I’ll submit a bug report. Thanks for your feedback Craig!