Page 1 of 1

Subtractive blending on darkness skills

Posted: Sat Apr 20, 2013 3:26 am
by Umbrall
This is nothing but a trivial visual effect but subtractive blending could work really well with some skills and show magical darkness better than current, multiplicative (for 0 0 0 it is) version. Also because I want to use it for my stuff and it's trivial to code (perhaps I could submit something myself maybe)

Re: Subtractive blending on darkness skills

Posted: Sat Apr 20, 2013 4:20 am
by nate
I understand that it should be possible with shaders, although I've never managed to figure them out myself-- if you manage to do it, I'd love to hear about what you figure out!

Re: Subtractive blending on darkness skills

Posted: Mon Apr 22, 2013 12:20 am
by Umbrall
Wouldn't you just put
glBlendEquation(GL_FUNC_SUBTRACT);
?

Re: Subtractive blending on darkness skills

Posted: Mon Apr 22, 2013 12:45 am
by nate
lol, I dunno :) Where would you put that? Are you figuring on doing it in C? If that functionality already exists, it would seem a shame to duplicate it; DG wouldn't implement it since it's already implemented, and few would play a forked ToME. (Not that it would be inexcusable or anything-- I'm guilty of plenty of duplication when I'm just too damned lazy to figure out how DG implemented something :) )

I don't know nothing about it, just repeating what I've heard-- that this is possible with shaders-- hence my eagerness for a lesson :)

Re: Subtractive blending on darkness skills

Posted: Mon Apr 22, 2013 12:50 am
by Umbrall
Actually it should be reverse subtract anyway. We're subtracting the src (particle) from the dst (everything). Though I'm not sure about the blend func.

So, into particles.c line 183:
else if (ps->blend_mode == BLEND_SUBTRACTIVE) {glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE); glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);}

line 44:
#define BLEND_SUBTRACTIVE 2

line 534:
lua_pushstring(L, "BLEND_SUBTRACTIVE");
lua_pushnumber(L, BLEND_SUBTRACTIVE);
lua_rawset(L, -3);

I think that's it

It doesn't already exist it only handles additive blending currently.

Re: Subtractive blending on darkness skills

Posted: Mon Apr 22, 2013 7:55 am
by darkgod
Can you test that ? it makes my screen go black ;)

Re: Subtractive blending on darkness skills

Posted: Mon Apr 22, 2013 11:24 pm
by Umbrall
the blendEquation probably needs to be set back to the default after drawing. I don't know how easily I can test, I don't have any environment for C++ set up right now. Was worth a shot with the blind untested code.