• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Discussion The ability to make your own blend modes

Status
Not open for further replies.

matharoo

manualman
GameMaker Dev.
While working with extended blend modes, I sometimes think that it would be really helpful if we could create our own. Like blend modes have 4 values to be multiplied with the R, G, B and A values, a function like this would be cool:
Code:
var bm_half = blendmode_create(0.5, 0.5, 0.5, 0.5);
Of course this is just an example and not what I really want to do with it. Such a function could really prove beneficial.

Also, variables that contain the individual R/G/B/A values from src and dest to be used with the function above:
Code:
var bm_multiply_alpha = blendmode_create(1, 1, 1, src_alpha * dest_alpha);
//or
var bm_multiply_color_next = blendmode_create(src_red * dest_green, src_green * dest_blue, scr_blue * dest_red, 1);
But, I don't know if it's really feasible. Am I asking for something that we're not going to get? I don't know.

What do you think?
 
D

Deleted member 467

Guest
I support this. As a guy who sometimes messes around with blend modes I find that sometimes I would like to make my own. Yes, there is 11 ext blend modes with 132 combos of them (I think I got those numbers right), but sometimes I might want to do a specific thing with them that I just can't do.
 

matharoo

manualman
GameMaker Dev.
I know nearly nothing about shaders, but isn't this something you can do with shaders?
I don't know. Someone with the knowledge of shaders could really help here. But if one can do those things using shaders, then I think it makes blend modes useless, unless blend modes are just a quick way of doing the stuff they can do. Still, they're very limiting.
 
Z

zendraw

Guest
i think you can do those things with shaders, and you have more freedom with shaders, im not a pro with them, but ive messed around a bit and thisis what i think.
 
unless blend modes are just a quick way of doing the stuff they can do. Still, they're very limiting.
Exactly.

Graphics card didn't always have programmable shaders. They had what's called a fixed-function pipeline.

You would send the graphics to the graphics card, and choose one of the blend modes. That was about all you could do.

Shaders give much more flexibility, hence why they are used these days.

Shaders can be a bit tricky to learn, at least I found them hard to understand at first, so your idea is kind of cool.

However, the kind of thing you are asking for could easily be done by writing your own shader, and then making your own function called blendmode_create, which would set the appropriate uniforms and pass them to the shader.

But, you would need to understand shaders in the first place! Catch-22.
 

Mike

nobody important
GMC Elder
This is not the way graphics cards work. You can not just program your own equations into the hardware blender I'm afraid. We expose all the blend modes that the hardware can do, we can't do any more than this.

And yes, this is exactly why shaders exist. You can do anything you like in there. Sure it's hard to get going, but there are now several tutorials to get you going, not least on our blog.

https://www.yoyogames.com/blog/14/shaders-overview-part-1
https://www.yoyogames.com/blog/16/shaders-overview-part-2
https://www.yoyogames.com/blog/17/shaders-overview-part-3
https://www.yoyogames.com/blog/18/shaders-overview-part-4
https://www.yoyogames.com/blog/19/shader-surprise

Also a little on shaders in the shadow tutorial

https://www.yoyogames.com/blog/419/realtime-2d-lighting-in-gamemaker-studio-2-part-1
https://www.yoyogames.com/blog/420/realtime-2d-lighting-in-gamemaker-studio-2-part-2

Lastly, a more complex example showing the wacky things you can do in them....
https://www.yoyogames.com/blog/89/writing-a-zx-spectrum-emulator-in-gamemaker-studio


If you need to do complex or unsupported blending, then you'll need to learn how to use and code shaders. Trust me, it'll be well worth the effort.
 
Status
Not open for further replies.
Top