Creating Spiritual (Glowing/Transparent/Opaque) Characters

Started by Ian Moone, Sun 02/01/2011 15:21:46

Previous topic - Next topic

Ian Moone

Hi guys, I've just discovered AGS (dollar late and short it appears) and I'd consider myself very comfortable with programming but lacking on the graphical side.

My problem is I'd like to solicit feedback on best practice/approaches on how I can go about simulating the effect of a glowing character (angel, ghost etc).

Several characteristics I can conjure up:

1. certain pixels in the character will be transparent. Obviously, the magenta pixel can be used for this purpose.
2. pixels around the character should change to a brighter tint and retain the content of the background.
3. Is there a way to have certain elements of a character opaque? I see a transparency property..not sure if I'm on the right path here.
4. An effect where a character have multiple versions of a pixel to alternate between non transparent to transparent (opaque/glowing attributes)...perhaps switching out the character with a timer? I see a transparency function for a character but I am not sure if I should do this programatically or make it part of the character animation. If it is in the character animation, I'm not sure how I can apply the glowing/tint to surrounding pixels OUTSIDE of the immediate character's area.

I apologize as I'm sure there may be APIs I should know to do this but I'm also soliciting approaches on how BEST to accomplish this to save time. Being that I'm posting in the Beginner's section should soften the blow.  ;D

Thanks!

Calin Leafshade

well AGS does support alpha channels for characters so you have a couple of choices

a) just make the character semi opaque. Simple and easy.

b) programatically cycle the opacity with a sine function so it fades in and out. Relatively easy but still effective

c) use alpha channels within the animations to cycle the transparency however you like.
This method has a number of problems. If a character were to change animations then their transparency would appear to jump as they flicked to a different frame loop.

d) completely program the effect yourself.
AGS doesnt provide the tools to do this out of the box since it cant directly edit the alpha channel. However i wrote a plugin called AGSBlend, which can be found on the forums. This allows direct pixel access to the alpha channel of a sprite which means you can essentially code any effect you like. It also has a box blur and additive blend function in the plugin left over from some bloom tests so you could construct something pretty funky. Add a subtle particle effect and you're away!

Ian Moone

Thanks for the quick feedback--very much appreciated. Since I'm still on training wheels, let's go with door A or B. Once I've chewed on those for a while...I may be back for particle effects etc help  ;D

For clarification...for option A...are you refering to the transparency/opaqness properties I saw in the AGS manual?

For option B...could you clarify where I should  be reading about the sine function? I see math functions related to sin/cosine/tangents etc, but I suspect this isn't what you are referring to.

Any information you can refer me in regards to the alpha cycle in the animations in the AGS manual is appreciated. Is this the DynamicSpite functions and properties you are referring to? I've also downloaded a few modules/plugins and will be experimenting with a few as my journey into AGS continues; I will take a look at AGSBlend thanks.  Time to brew a cup and just read the entire AGS doc top to bottom.  :o

I'll post some results in the Critiques Lounge when I have a protptype together...this will be my first character performance.

Calin Leafshade

Quote from: Ian Moone on Sun 02/01/2011 21:35:09
For clarification...for option A...are you refering to the transparency/opaqness properties I saw in the AGS manual?

yea basically
Code: ags

cCharacter.Transparency = 50; // 0 = opaque, 100 = completely transparent


Quote
For option B...could you clarify where I should  be reading about the sine function? I see math functions related to sin/cosine/tangents etc, but I suspect this isn't what you are referring to.

basically i mean you assign the transparency values based on a sinewave curve.
a sine wave curve looks like ~ (kind of)

youd have a counter that cycles from 0 to 360 (for the sinewave) and every frame assign the characters transparency value to a value based on the sine function of your counter.

Quote
Any information you can refer me in regards to the alpha cycle in the animations in the AGS manual is appreciated. Is this the DynamicSpite functions and properties you are referring to? I've also downloaded a few modules/plugins and will be experimenting with a few as my journey into AGS continues; I will take a look at AGSBlend thanks.  Time to brew a cup and just read the entire AGS doc top to bottom.  :o

When i said animations in the sprites I literally meant *in* the sprite values with no progamming intervention at all.
but as i said above this method has issues.

Ian Moone

Thanks for the info and clarification on option B (I actually made an A in statistics LOL). One last question and I'll get busy...where do I put the code for the transparency within the animation cycles? The script for the character? And I suspect there is a property that tells me where in the animation cycle we are at?

Now that I'm thinking about it...we don't want to use the animation sequence...we want to use TIME since we want this effect to be constantly changing REGARDLESS of what is animating on the character itself.

Calin Leafshade

there is a function in your global script called repeatedly_execute_always()

This function runs once every game frame (40fps by default)

so inside this function you can apply your opacity values to the character.

just to illustrate that:

Code: ags


function repeatedly_execute_always(){

cCharacter.Transparency = Random(50);

}



this would make the character cCharacter's transparency get set to a random value between 0 and 50 every frame.

Ian Moone

Great thanks for the tip. It seems the GLOBAL script is where a lot of the magic happens...I hope this doesn't result in some epilepsy  :o

SMF spam blocked by CleanTalk