Blending mode changes in v4?

I’m porting some code from v.3 to v.4.

Got some scribbling environment, where I have a sheet that can be scribbled over, but it should not be allowed to scribble outside it.
For that purpose, I have a png picture of a blank sheet, but with some transparency around the (uneven) edges (would post a screen if it were possible :frowning:) .

RenderTexture, of the size of the sheet pic, rendering:

  • Sprite with the sheet pic + blend func src=ONE, dst=ZERO
  • Draw Node with blend fun src=DST_ALPHA, dst=ONE_MINUS_SRC_ALPHA

It worked in v.3 - the scribbles only showed up on the sheet and disappeared around the edges where the png is transparent. It doesn’t work in v.4 - the scribbles are visible all over the square png area, regardless of the png’s alpha value.

In fact, any changes I make to DrawNode’s blending function don’t seem to have any effect. Even if I set src to ZERO, scribbles still show up.

What’s changed? Or do I misunderstand something crucial about blending (not an expert on OpenGL)? :frowning:

This isn’t related to the specific bug you have encountered, but more so to how the input is handled. Would boundary checking help, where you don’t draw anything when the input coordinates are outside your drawing area?

But that would require a pixel-based check, wouldn’t it? Off the top of my head now, I can’t picture the solution in my mind. You don’t mean a shader, do you?

Anyway, I’ve just managed to quickly get it working by reverting the order of rendering (first the draw node, then the sprite) and changing the blend function to:
DrawNode: src=ONE, dst=ZERO
Sprite: src = ONE_MINUS_DST_ALPHA, dst = SRC_ALPHA

This is not the first time that the DrawNode needs to come first. But why? Why does it work while the other solution doesn’t? Can anyone explain it to me? Looks like I’m lacking some basic knowledge.

That would depend on the shape of your drawing area. If it’s a rectangle, then it should just be a matter of checking if the input position is within the boundary of that rectangle. A circular area would also be relatively trivial to handle as well. For anything more complex than that then yes, you’re correct, a pixel check would be required.