playMaker

Author Topic: Blend Color action needed?![SOLVED]  (Read 4046 times)

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Blend Color action needed?![SOLVED]
« on: May 04, 2013, 04:56:56 AM »
What I'm wanting to do is blend two arrays of colors, having tried many methods I've concluded a new action would be needed. Unless im missing something with the 'animate color' or 'Ease color' actions.

What is missing is a Blend color action! for example

set Color1
set Color2
set blend amount (0-1)

so for example a Red blended with a Yellow at a blend amount of 0.5 would be an orange.
Possible?
« Last Edit: May 07, 2013, 02:14:43 AM by jeanfabre »

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Blend Color action needed?!
« Reply #1 on: May 05, 2013, 10:53:51 AM »
I believe that you can actually achieve this... but, the method that sticks out in my head is a little complex since it basically means you have to extract the RGBA values, store them as floats, do the appropriate maths on them (average, aka, add them together, divide by two) and then use the resulting values to recombine into an RGBA value you can then feed into a colour action.

the pertinent actions you'd want to use for the colour values would be the Get/Set Color RGBA actions in the Color subsection (*chuckles* kinda feels odd for me spelling it like that... *shrugs* but what can i say, i'm a crazy canadian :D)

So, maybe state one will have an idle waiting for you to tell it to go... then the next state will extract the value from the colour variables you want (two different variables in your variables tab) then extracting the RGBA into floats (you'd need to declare eight of them... four for each colour variable) do the maths (add together then divide by two) and then recombine them in the next state and do what you need there.

As for a system to determine the amount of blending... well, i'd have to do a bit of testing before i'd comment on that specifically but i'm sure it's possible... but, the maths involved aren't really coming to me very well (i'm an artist, not a brain. :lol:)

... so, i guess i'm just going to spit-ball here.

So, you have a value you want to blend... so, a from 0-1. I don't know how you're going to interact with it but that should not be hard to do (i'm also assuming you already have a system to control the value of the blend.)

so, from there, i'd probably want to take the values of the colours... once they're separated into individual floats, maybe multiply values of the first colours by the blend amount... and multiply the second colours by the opposite (so, take the blend value and subtract it from 1) and then combine the two together? (maybe averaging, i'm not sure... this is where my math knowledge is getting really shaky.) i'm sure this would be a really beefy state to be in so maybe if the blend needs to change, have an idle state detect when that float value has changed, then run through the algorithm, send off the results, then return to the idle state (i'd probably want to add in a microsecond pause or a next-frame-event... but i'm finicky/OCD like that and that might be completely extraneous to what you'd need.)

if anyone is better at the maths here, please, please let me know if i'm getting it wrong. I suspect I am but as i said before, i'm an artist, not a brain.

Also... did some testing... the colour get/set actions work with values from 0-1 as well... so, the maths should still hold up for extracting and comparing... but it might be a head-trip converting the typical 256 value that most people think of when they think of colour values in computer systems.
« Last Edit: May 05, 2013, 11:08:35 AM by Red »

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Blend Color action needed?!
« Reply #2 on: May 05, 2013, 07:39:45 PM »
Being an artist also I figured more 'artistic' actions is what Playmaker actually needs but I'm sure the above could result in a solution.

I have another method that I'll try out today. This system is already getting very beefy, but it's loading the color values from a text file as floats anyways so wouldn't be extremely hard to throw some maths at it. This is where I think converting the color (RGB) to a vector3 and using a Lerp would do the trick. It's just a lot of converting back and forth for something I may what to be doing everyframe...... on ios :) (typical artist pushing the limits to do something that looks nice)
« Last Edit: May 05, 2013, 08:26:57 PM by LampRabbit »

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Blend Color action needed?!
« Reply #3 on: May 05, 2013, 08:16:02 PM »
I have another method that I'll try out today. This system is already getting very beefy, but it's loading the color values from a text file as floats anyways so wouldn't be extremely hard to throw some maths at it. This is where I think converting the color (RGB) to a vector3 and using a Lerp would to the trick. Its just a lot of converting back and forth for something I may what to be doing everyframe...... ok ios :) (typical artist pushing the limits to do something that looks nice)

okay, using a vector3 lerp to calculate it took me by surprise! if it works, let me know! (that's actually pretty clever if you ask me.)

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Blend Color action needed?!
« Reply #4 on: May 06, 2013, 04:44:46 AM »
Turn's out that wasent hard at all! Just a little ott for what it needs to be, would still be great to get an action for performance reasons.

Red and yellow make orange at a lerp of 0.5!!! Now I can (fingers crossed) make my game awesome looking as per my maya scene!