Possible Bug? Character.Tint and Luminance

Started by Janik, Tue 18/10/2005 06:10:49

Previous topic - Next topic

Janik

Hi,

I'm trying to code a script where the brightness of the player changes smoothly with position (getting closer to a light source and such). So, instead of using a region's LightLevel, I am using the Character.Tint function call. But I can't get it to do what I want (that is, no color change, just a luminance change).

The game is 32-bit color, the sprite was also 32-bit with alpha channel. Here is what I have tried (LuminanceInt here varies from 0 to 100 depending on position of the player):

player.Tint(255, 255, 255, 0, LuminanceInt); //No change at all
player.Tint(255, 255, 255, 1, LuminanceInt); //No change at all either
player.Tint(255, 255, 255, 100, LuminanceInt); //The lighting works as intended - but all colors are gone!
player.Tint(0,0,0, 0, LuminanceInt); //No change at all
player.Tint(0,0,0, 1, LuminanceInt); //No change at all
player.Tint(0,0,0, 100, LuminanceInt); //Again, the luminance changes but all colors are gone.
player.Tint(0,0,0, 50, LuminanceInt); //Works half-way: Half the color is gone, and setting Luminance to 0 is only half-brightness.

This does not seem to correspond to the manual:
QuoteThe LUMINANCE parameter allows you to adjust the brightness of the sprites at the same time. It ranges from 0-100. Passing 100 will draw the sprites at normal brightness. Lower numbers will darken the images accordingly, right down to 0 which will draw everything black.

Any ideas? Am I missing something?
Play pen and paper D&D? Then try DM Genie - software for Dungeons and Dragons!

Gilbert

hmmm odd, can you try importing a sprite without alpha channel and see if the result is the same?

Pumaman

You cannot achieve a luminance-only effect with the Character.Tint function, because the Tint function works like this:

1. Take copy of sprite
2. Darken sprite according to luminance setting
3. Colourise sprite according to RGB settings
4. Draw the new sprite over the original sprite with SATURATION% transparency.

Therefore, if you pass SATURATION as 0 or 1, it will have virtually no impact on the sprite.

But equally, if you pass it as 100, it will completely colourise the sprite too.

Janik

Ok, at least I'm not crazy!  ;D

You can probably guess what's coming - would it be possible to add an option to the Tint call to skip the colourise step? Something like:

Character.Tint(int red, int green, int blue, int saturation, int luminance, optional int luminanceonly)

So that by setting luminanceonly to 1 (or true), the RGB values would be ignored and only the luminance + saturation would do anything?

Thanks!
Play pen and paper D&D? Then try DM Genie - software for Dungeons and Dragons!

Elliott Hird



SMF spam blocked by CleanTalk