Waves
From GameStudio Wiki
[edit]
Lite-C:
Material and function to adjust the effect:
//Wavedisortion of the Screen
MATERIAL* ScreenWaves_mat =
{
effect = "screenwaves.fx";
}
function ScreenWaves_set_Value(Speed,Amplitude)
{
ScreenWaves_mat.skill1 = floatv(Speed); // can be around 20
ScreenWaves_mat.skill2 = floatv(Amplitude); // should be around 0.01
}
The screenwaves.fx file:
/////////////////////////////////////////////////
/////The Screen gets disorted through waves./////
/////////////////////////////////////////////////
texture TargetMap;
float4 vecSkill1;
float4 vecTime;
sampler postTex = sampler_state
{
texture = (TargetMap);
MinFilter = linear;
MagFilter = linear;
MipFilter = linear;
AddressU = Clamp;
AddressV = Clamp;
};
float4 Waves_PS( float2 Tex : TEXCOORD0 ) : COLOR0
{
float4 Color;
Tex.y += (sin(Tex.x*vecTime.w*vecSkill1[0])*vecSkill1[1]);
Color = tex2D( postTex, Tex.xy);
Color.a = 1.0;
return Color;
}
technique tech_00
{
pass pass_00
{
VertexShader = null;
PixelShader = compile ps_2_0 Waves_PS();
}
}
technique fallback { pass one { } }
[edit]
C-Script
Material and function to adjust the effect:
//Wavedisortion of the Screen
material ScreenWaves_mat
{
effect = "screenwaves.fx";
}
function ScreenWaves_set_Value(Speed,Amplitude)
{
ScreenWaves_mat.skill1 = floatv(Speed); // can be around 20
ScreenWaves_mat.skill2 = floatv(Amplitude); // should be around 0.01
}
The screenwaves.fx file:
/////////////////////////////////////////////////
/////The Screen gets disorted through waves./////
/////////////////////////////////////////////////
texture entSkin1;
float4 vecSkill1;
float4 vecTime;
sampler postTex = sampler_state
{
texture = (entSkin1);
MinFilter = linear;
MagFilter = linear;
MipFilter = linear;
AddressU = Clamp;
AddressV = Clamp;
};
float4 Waves_PS( float2 Tex : TEXCOORD0 ) : COLOR0
{
float4 Color;
Tex.y += (sin(Tex.x*vecTime.w*vecSkill1[0])*vecSkill1[1]);
Color = tex2D( postTex, Tex.xy);
Color.a = 1.0;
return Color;
}
technique tech_00
{
pass pass_00
{
VertexShader = null;
PixelShader = compile ps_2_0 Waves_PS();
}
}
technique tech_01
{
pass pass_00
{
Texture[0] = <entSkin1>;
}
}
--Slin 01:23, 11 November 2007 (CET)
