Subtractive blending on darkness skills

All new ideas for the upcoming releases of ToME 4.x.x should be discussed here

Moderator: Moderator

Post Reply
Message
Author
Umbrall
Thalore
Posts: 153
Joined: Sat Feb 23, 2013 7:53 pm

Subtractive blending on darkness skills

#1 Post 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)

nate
Wyrmic
Posts: 261
Joined: Fri Jan 18, 2013 8:35 am

Re: Subtractive blending on darkness skills

#2 Post 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!
Proud father of Fx4fx and Chronometer add-ons; proud mother of Fated add-on

Umbrall
Thalore
Posts: 153
Joined: Sat Feb 23, 2013 7:53 pm

Re: Subtractive blending on darkness skills

#3 Post by Umbrall »

Wouldn't you just put
glBlendEquation(GL_FUNC_SUBTRACT);
?

nate
Wyrmic
Posts: 261
Joined: Fri Jan 18, 2013 8:35 am

Re: Subtractive blending on darkness skills

#4 Post 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 :)
Proud father of Fx4fx and Chronometer add-ons; proud mother of Fated add-on

Umbrall
Thalore
Posts: 153
Joined: Sat Feb 23, 2013 7:53 pm

Re: Subtractive blending on darkness skills

#5 Post 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.

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Subtractive blending on darkness skills

#6 Post by darkgod »

Can you test that ? it makes my screen go black ;)
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Umbrall
Thalore
Posts: 153
Joined: Sat Feb 23, 2013 7:53 pm

Re: Subtractive blending on darkness skills

#7 Post 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.

Post Reply