Sign in to follow this  
sunmaggot

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

After 5 minutes playing around ... it's got to be the algorithms of the different blend modes ? 

I've never thought about it before with whatever programme, because they 'just work' when you choose a blend mode 

 

I don't mind admitting,  the nitty gritty of it all is over my head

 

Edited by welshblue

Share this post


Link to post
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. 

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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

 

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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?

Share this post


Link to post
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. 

Share this post


Link to post
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.

Sign in to follow this