Pulsating

From GameStudio Wiki

Jump to: navigation, search

Lite-C:


Material and function to adjust the effect:

//Pulsating
MATERIAL* Pulsating_mat =
{
	effect = "pulsating.fx";
}

function Pulsating_set_Value(Speed,Range)	//The following values could be used for breathing
{
	Pulsating_mat.skill1 = floatv(Speed);	//0.25
	Pulsating_mat.skill2 = floatv(Range);	//0.01
}

The pulsating.fx file:

float4 vecSkill1;
float4 vecTime;


texture TargetMap;
sampler postTex = sampler_state
{
   texture = (TargetMap);
   MinFilter = linear;
   MagFilter = linear;
   MipFilter = linear;
   AddressU = clamp;
   AddressV = clamp;
};


float4 Pulsing_PS(float2 TexCoord : TEXCOORD0)	:	COLOR
{
	TexCoord -= 0.5;
	TexCoord *= 1-(sin(vecTime.w*vecSkill1.x)*vecSkill1.y+vecSkill1.y)*0.5;
	TexCoord += 0.5;
	
	float4 Color = tex2D(postTex,TexCoord);

	return Color;
}

technique fallback { pass one { } }


C-Script


Material and function to adjust the effect:

//Pulsating
material Pulsating_mat
{
	effect = "pulsating.fx";
}

function Pulsating_set_Value(Speed,Range)	//The following values could be used for breathing
{
	Pulsating_mat.skill1 = floatv(Speed);	//0.25
	Pulsating_mat.skill2 = floatv(Range); //0.01
}

The pulsating.fx file:

float4 vecSkill1;
float4 vecTime;


texture entSkin1;
sampler postTex = sampler_state
{
   texture = (entSkin1);
   MinFilter = linear;
   MagFilter = linear;
   MipFilter = linear;
   AddressU = clamp;
   AddressV = clamp;
};


float4 Pulsing_PS(float2 TexCoord : TEXCOORD0)	:	COLOR
{
	TexCoord -= 0.5;
	TexCoord *= 1-(sin(vecTime.w*vecSkill1.x)*vecSkill1.y+vecSkill1.y)*0.5;
	TexCoord += 0.5;
	
	float4 Color = tex2D(postTex,TexCoord);

	return Color;
}

technique Main
{
	pass p001
	{
		VertexShader = null;
		PixelShader = compile ps_2_0 Pulsing_PS();
	}
}

--Slin 01:08, 11 November 2007 (CET)

Personal tools