Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Color shifting using "FadeThrough" method  (Read 3935 times)

0 Members and 1 Guest are viewing this topic.

sharkgod999

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • View Profile
    • The Salty Sea Cove
Color shifting using "FadeThrough" method
« on: November 14, 2007, 05:07:51 AM »

I've been trying to shift the hue of a scene for sometime to no avail. So I searched the forum and found this post: http://forum.dead-code.org/index.php?topic=542.0. Well, I've tried the prescribed method and the scene shifts hues. However, the colors that fades-in are opaque. So, I lose the entities visibility in the scene. and end up with a blank screen that shifts hue. Also, if I set the alpha of the fade-in to say 100, I get a hazy image.
Logged
Freedom - Free = DUMB!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Color shifting using "FadeThrough" method
« Reply #1 on: November 27, 2007, 06:09:05 PM »

Could you elaborate what exactly do you want to achieve? You can change the hue of a color using the relatively new HSL conversion functions.

Code: WME Script
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

sharkgod999

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • View Profile
    • The Salty Sea Cove
Re: Color shifting using "FadeThrough" method
« Reply #2 on: November 27, 2007, 07:17:57 PM »

Well, I was trying to make the background slowly shift hue, but like I said the "FadeThrough" method wasn't what I thought. So, I wrote this little piece of code. It works. However, I'm using a gray-scale image and this results in some moments where the gray will come through. I've tried the new HSL and it seems to make the following: h = 0, s = 0, l = 255. Which gives no colorization at all. ::slug I'll put the code for the HSL at the end of the post after the RGB example. Thanks for any help in advance.

RGB Color Shifting
Code: [Select]
var r = 0;
var g = 0;
var b = 0;

var myent = this.GetNode("background");

var timer = 0;
 
var lr = 255;
var lg = 0;
var lb = 0;

var done = true; 

////////////////////////////////////////////////////////////////////////////////
method SetColor(ent,red,green,blue,alpha)
{
  ent.AlphaColor = RGB(red,green,blue,alpha);
}


while(true)
{
  if(done == true)
  {
// Set the next color
    r = Random(0,255);
    g = Random(0,255);
    b = Random(0,255);

    done = false;

    Game.Msg("New Color - r:"+r+" - g:"+g+" - b:"+b+"");
    Game.LOG("New Color - r:"+r+" - g:"+g+" - b:"+b+"");
  }
 
  if(lr != r && lg != g && lb != b)
  {
    if(lr < r)
  lr = lr + 1;
else if(lr > r)
  lr = lr - 1;

if(lg < g)
  lg = lg + 1;
else if(lg > g)
  lg = lg - 1;

if(lb < b)
  lb = lb + 1;
else if(lb > b)
  lb = lb - 1;
  }
  else
  {
done = true;
  }
   
  SetColor(myent,lr,lg,lb,255);
 
  Game.Msg("Current Color - r:"+lr+" - g:"+lg+" - b:"+lb+"");
   
  Sleep(100);
}

Here's the HSL attempt
Code: [Select]
var hue = 0;

var myent = this.GetNode("background");

var color = 255;

while(true)
{
hue = hue + 1;
if(hue > 255)
hue = 0;

color = MakeHSL(hue,255,255);

// myent.AlphaColor = RGB(GetRValue(color),GetGValue(color),GetBValue(color),255);
myent.AlphaColor = color;

Game.Msg("Hue "+hue+" Background Color - r:"+GetRValue(myent.AlphaColor)+" - g:"+GetGValue(myent.AlphaColor)+" - b:"+GetBValue(myent.AlphaColor)+"");
Game.Msg("Attempted Color - H:"+GetHValue(color)+" - S:"+GetSValue(color)+" - L:"+GetLValue(color)+"");
Game.Msg(""+color+"");

Sleep(100);
}
Logged
Freedom - Free = DUMB!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Color shifting using "FadeThrough" method
« Reply #3 on: November 28, 2007, 07:56:47 PM »

I've tried the new HSL and it seems to make the following: h = 0, s = 0, l = 255. Which gives no colorization at all. ::slug
Yes, that's how the HSL color model works. Luminance of 255 is white, luminance of 0 is black. You can experiment with HSL using a color picker in some drawing program. Perhaps you want to be changing the luminance component, not hue? I'm still not sure what effect you're after.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

sharkgod999

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • View Profile
    • The Salty Sea Cove
Re: Color shifting using "FadeThrough" method
« Reply #4 on: November 30, 2007, 06:49:13 AM »

The problem I keep running into is I can't change the Hue or Saturation at all. Am I doing any thing wrong or is there a problem with MakeHSL()? I'm trying to make a background entity change color. It's a plaid backdrop.
Logged
Freedom - Free = DUMB!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Color shifting using "FadeThrough" method
« Reply #5 on: December 01, 2007, 10:17:57 AM »

Well, for example the following code will change the light intensity of an entity:

Code: WME Script
  1.   var H = GetHValue(this.AlphaColor);
  2.   var S = GetSValue(this.AlphaColor);
  3.   var SomeEntity = Scene.GetNode("OldGuy");
  4.  
  5.   for(var i=5; i<25; i=i+1)
  6.   {
  7.     SomeEntity.AlphaColor = MakeHSL(H, S, i*10);
  8.     Sleep(500);
  9.   }
  10.  
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

sharkgod999

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • View Profile
    • The Salty Sea Cove
Re: Color shifting using "FadeThrough" method
« Reply #6 on: December 03, 2007, 02:36:44 AM »

Ah ha, I've got it. I guess if I set the Luminescence to 255 I get I white image. But If I lower the L value I get a colorization effect. Many thanks all.  ::rock
Logged
Freedom - Free = DUMB!
 

Page created in 0.056 seconds with 24 queries.