Raindrops
From GameStudio Wiki
[edit]
Lite-C:
Material and function to adjust the effect:
//Raindrops
BMAP* Raindrops_bmap = "Raindrops.jpg";
MATERIAL* Raindrops_mat =
{
skin1 = Raindrops_bmap;
effect = "rain_drops.fx";
}
function Raindrops_set_Value(xMovemen,yMovement)
{
Raindrops_mat.skill1 = floatv(xMovemen); //usually 0
Raindrops_mat.skill2 = floatv(yMovement); //very small around 0.01
}
The rain_drops.fx file:
/////////////////////////////////////////////////////////////////////////
///////Raindrops Effect from Sylex 3.0 by Sebastian Leopold (XeXeS)//////
/////////////////////////////////////////////////////////////////////////
// Texturen:
texture TargetMap; // Original Scene
texture mtlSkin1; // Effekttexture 1
// Variablen
float4 vecSkill1; // Effektskills 1-4
float4 vecTime;
sampler postTex = sampler_state
{
texture = (TargetMap);
MinFilter = linear;
MagFilter = linear;
MipFilter = linear;
AddressU = Clamp;
AddressV = Clamp;
};
sampler bumpTex = sampler_state
{
texture = (mtlSkin1);
MinFilter = linear;
MagFilter = linear;
MipFilter = linear;
AddressU = Wrap;
AddressV = Wrap;
};
// Pixelshader
float4 PS_RainDrops(float2 tex0 : TEXCOORD0) : COLOR
{
float2 temp;
temp.x = tex0.x+vecSkill1.x*vecTime.w;
temp.y = tex0.y+vecSkill1.y*vecTime.w;
float2 pixel = tex2D(bumpTex,temp).rg*5;
temp.x = (tex0.x + pixel.x * 0.01f);
temp.y = (tex0.y + pixel.y * 0.01f);
return float4(tex2D(postTex,temp*(1-pixel.x * 0.01f)).rgb,1.0);
}
// Technik 1
technique tech_00
{
pass pass_00
{
PixelShader = compile ps_2_0 PS_RainDrops();
}
}
technique fallback { pass one { } }
You also need this image "Raindrops.jpg":
[edit]
C-Script
Material and function to adjust the effect:
//Raindrops
bmap Raindrops_bmap = <Raindrops.jpg>;
material Raindrops_mat
{
skin1 = Raindrops_bmap;
effect = "rain_drops.fx";
}
function Raindrops_set_Value(xMovemen,yMovement)
{
Raindrops_mat.skill1 = floatv(xMovemen); //usually 0
Raindrops_mat.skill2 = floatv(yMovement); //very small around 0.01
}
The rain_drops.fx file:
/////////////////////////////////////////////////////////////////////////
///////Raindrops Effect from Sylex 3.0 by Sebastian Leopold (XeXeS)//////
/////////////////////////////////////////////////////////////////////////
// Texturen:
texture entSkin1; // Original Scene
texture mtlSkin1; // Effekttexture 1
// Variablen
float4 vecSkill1; // Effektskills 1-4
float4 vecTime;
sampler postTex = sampler_state
{
texture = (entSkin1);
MinFilter = linear;
MagFilter = linear;
MipFilter = linear;
AddressU = Clamp;
AddressV = Clamp;
};
sampler bumpTex = sampler_state
{
texture = (mtlSkin1);
MinFilter = linear;
MagFilter = linear;
MipFilter = linear;
AddressU = Wrap;
AddressV = Wrap;
};
// Pixelshader
float4 PS_RainDrops(float2 tex0 : TEXCOORD0) : COLOR
{
float2 temp;
temp.x = tex0.x+vecSkill1.x*vecTime.w;
temp.y = tex0.y+vecSkill1.y*vecTime.w;
float2 pixel = tex2D(bumpTex,temp).rg*5;
temp.x = (tex0.x + pixel.x * 0.01f);
temp.y = (tex0.y + pixel.y * 0.01f);
return float4(tex2D(postTex,temp*(1-pixel.x * 0.01f)).rgb,1.0);
}
// Technik 1
technique tech_00
{
pass pass_00
{
PixelShader = compile ps_2_0 PS_RainDrops();
}
}
technique tech_01
{
pass pass_00
{
Texture[0] = <entSkin1>;
}
}
You also need this image "Raindrops.jpg":
--Slin 01:35, 11 November 2007 (CET)
