Jump to content

Problem about blendfunction


Recommended Posts

I read wiki about blend functions and it says that overlay is combination of screen and multiply.

However when I try to produce overlay effect with screen and multiply, I can't do it because the screen blending makes something white.

Here is the result:

The base layer is shallow water.

The top layer is cloud rendered with white colour and invisible colour.

 

Overlay result:

8VvgEvz.png

 

Screen + multiply with screen on top of multiply.

n9iwrbT.png

 

I also tried to change the order of screen and multiply layers but it won't work.

 

I want to know how can I produce overlay blending with screen and multiply? Or is overlay a very unique blending that there is no combination that can produce same result?

 

Edited by sunmaggot
Typo

道生一,一生二,二生三,三生萬物。

non-existence made one, one made two, two made three, three made matters.

道可道,非常道;名可名,非常名。

well-defined principles are not eternal principles, names that can be named are not eternal names.

Link to comment
Share on other sites

We do have an 'Overlay' Blending Mode option in the Layer Properties window ;).

 

(But - I have have misunderstood the question.)

 

P.S.  Changing blend modes is tricky and often you get a funny result if you try to change both layers.  Perhaps reading this will help:

https://www.getpaint.net/doc/latest/BlendModes.html

 

Edited by Pixey
added more info

30b8T8B.gif

How I made Jennifer & Halle in Paint.net

My Gallery | My Deviant Art

"Rescuing one animal may not change the world, but for that animal their world is changed forever!" anon.

 
Link to comment
Share on other sites

Thank you for the feedback. 

 

In fact the reason I asked about this is because overlay blending will check every pixel to decide whether it will do screen or multiply. This will add some complications to my project, so if there exists a way of blending that doesn't check every pixel, it will make the problem much easier. 

 

Anyway, I found a way to produce similar result but not as good, but it does not need to check every pixel. 

道生一,一生二,二生三,三生萬物。

non-existence made one, one made two, two made three, three made matters.

道可道,非常道;名可名,非常名。

well-defined principles are not eternal principles, names that can be named are not eternal names.

Link to comment
Share on other sites

8 hours ago, sunmaggot said:

This will add some complications to my project, so if there exists a way of blending that doesn't check every pixel, it will make the problem much easier. 

 

Blend modes, almost by definition, are pixel-by-pixel operations. Each pixel is affected only by pixels in other layers with the same coordinates.

 

Perhaps if you explain what you want to achieve, someone can suggest a way to achieve it.

Link to comment
Share on other sites

As far as I understand it, Overlay is the only Blend mode which uses two different formulas to return a result. But not at the same time.

 

If the upper layer component value is less than 128, the returned value is twice that of Multiply.  Thus where darker colors are present in the upper layer, Overlay acts like Multiply doubled which greatly darkens the already dark colors.

 

If the upper layer component value is greater or equal to 128, the returned result is twice that of the Screen blend.  This makes light portions of the image significantly brighter.

 

image.png

 

This being the case, you won't get the same result by combining Multiply and Screen.

Link to comment
Share on other sites

@MJW

The thing I want to make is some uneven light shining on my map of my game. The overlay blending effect seems very good but it requires me to make a shader that checks every pixel, just like what @Ego Eram Reputo said.

 

Now my solution is using:

GL_DST_COLOR  +   GL_ONE

 

道生一,一生二,二生三,三生萬物。

non-existence made one, one made two, two made three, three made matters.

道可道,非常道;名可名,非常名。

well-defined principles are not eternal principles, names that can be named are not eternal names.

Link to comment
Share on other sites

1 hour ago, sunmaggot said:

Now my solution is using:

GL_DST_COLOR  +   GL_ONE

 

I'm not sure that means. If, as I would haphazardly guess, GL_ONE is is "full on" (i.e, 255) that would just overflow and get clamped, setting the color to white (which I assume means my guess is off the mark).

 

Since I'm not sure what you mean, I shouldn't speculate, but I will anyway. I'd think that if you want uneven light, you could use something like GL_DST_COLOR * (1 + UNEVEN_LIGHT_AMOUNT)., or equivalently GL_DST_COLOR + GL_DST_COLOR * UNEVEN_LIGHT_AMOUNT, assuming that could be done with your shader. That's physically sort of how extra light works: the light gets multiplied by the surface color (which I'm assuming is proportional to the color of the lighted surface, without the extra light). I'm not sure why Overlay Mode would be well-suited to imitating light. Light seems to me to be more like Multiply and Add blend modes.

Link to comment
Share on other sites

@MJW it is the blend function used in LibGDX. 

道生一,一生二,二生三,三生萬物。

non-existence made one, one made two, two made three, three made matters.

道可道,非常道;名可名,非常名。

well-defined principles are not eternal principles, names that can be named are not eternal names.

Link to comment
Share on other sites

5 hours ago, TrevorOutlaw said:

Question for the OP...have you tried the BlendModes plugin?

 

I don't think sunmaggot's question is actually about PDN. it sounds like it's really about a game programming language called LibGDX. I think he just wanted to use some of the graphics concepts from PDN.  (I'm not quite sure why he expected his response that he now uses "GL_DST_COLOR  +  GL_ONE" would be meaningful to anyone here.)

 

EDIT: BTW, the rather poorly written Wikipedia article fails to mention that LibGDX seems to be based on OpenGL -- a pretty fundamental fact! I've never written in OpenGL, but it's a widely used graphics programming language, originally developed by Silicon Graphics.

Link to comment
Share on other sites

I thought you might be interested in looking at Texture Shader.

https://forums.getpaint.net/topic/31964-texture-shader/?do=findComment&comment=529652

 

How about posting your map?

 

  • Like 1
Link to comment
Share on other sites

Ego Eram Reputo, I think game developers might be able to use my height-map plugins, especially the Texture Merger and Texture Smoother. Maybe I'll engage in a little shameless self promotion, and suggest their use them on some game-developer websites where height maps are being discussed.

Link to comment
Share on other sites

5 hours ago, MJW said:

 

I don't think sunmaggot's question is actually about PDN. it sounds like it's really about a game programming language called LibGDX. I think he just wanted to use some of the graphics concepts from PDN.  (I'm not quite sure why he expected his response that he now uses "GL_DST_COLOR  +  GL_ONE" would be meaningful to anyone here.)

 

EDIT: BTW, the rather poorly written Wikipedia article fails to mention that LibGDX seems to be based on OpenGL -- a pretty fundamental fact! I've never written in OpenGL, but it's a widely used graphics programming language, originally developed by Silicon Graphics.

 

It still sounds like the OP was complaining about how PDN computes the overlay mode, which was why I suggested the BlendModes plug-in to see if the OP could find the different blending mode that would work for the OP.

Link to comment
Share on other sites

I don't think sunmaggot was complaining about how PDN computes the Overlay mode.I think he was trying to understand why he couldn't reproduce the same effect by combining Multiply and Screen blending functions. The answer was that they aren't both applied; one or the other is applied.

Link to comment
Share on other sites

Yup, and it's a per-pixel operation. I'm not sure why sunmaggot wants to do it some other way.

Link to comment
Share on other sites

To clarify, I am not complaining, but I want to see if there is a way to do overlay blending without checking every pixel. This is why I attempt to get overlay blending by screen and multiply. It seems overlay is unique blending and is not easy to produce similar effect. 

Edited by sunmaggot

道生一,一生二,二生三,三生萬物。

non-existence made one, one made two, two made three, three made matters.

道可道,非常道;名可名,非常名。

well-defined principles are not eternal principles, names that can be named are not eternal names.

Link to comment
Share on other sites

9 hours ago, sunmaggot said:

I want to see if there is a way to do overlay blending without checking every pixel

 

There isn't. That's how it works. Every pixel in one layer is compared with the same pixel location on the second layer.

 

Perhaps there is something I'm missing? Can you explain exactly what you're trying to achieve and why the Overlay blend mode won't do the job?

Link to comment
Share on other sites

In LibGDX, the default blend function provided in spritebatch class can only perform simple blending modification such as changing the formula of blending. If I want to make overlay blending, I have to write a shader program because of how overlay works. This is why I am looking for a simple algorithm that can produce similar effect. After hours of searching, I ended up finding a website that can let me try the blending. 

 

http://www.andersriggelsen.dk/glblendfunc.php

 

The following chart shows what I am talking about. By modifying blend function, some modifications can be done. 

 

https://goo.gl/images/q3vkpM

 

I use GL_DST_COLOR (source) , GL_ONE (destination) for my blending now and it seems that it can do what I want. This skips shader programming. 

 

The reason I didn't bring up these things before is because I feel like this is not about the original problem anymore. But it makes things confusing, so now I am posting these. 

道生一,一生二,二生三,三生萬物。

non-existence made one, one made two, two made three, three made matters.

道可道,非常道;名可名,非常名。

well-defined principles are not eternal principles, names that can be named are not eternal names.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...