hey there, with the help of slin i was able to get some caustics effect on the terrain working. i use a simple terrain with 1 terrain texture in skin1(alpha channel defines information where the caustics should be displayed on the terrain) and 1 caustics texture in skin2(also with alpha channel).
then the caustics texture is displayed on the terrain, where it should be and is moved with litec code and the material transformation matrix. however i only was able to move it down, and a little bit left/right. its not really scaling / distorting like it should, it just does some little sinus movement. i have too little knowledge with this yet, so a bit help would be great.
what i want to achieve is to distort the caustics texture like the water textures in the gamestudio standard.wad files. like you had those block water in the good old days in quake like games, where one texture was distorted so it looked like lava, water...
look at the screen to see what i mean.
this is the shader code caustics.fx from slin
Code:
float4x4 matMtl;
texture entSkin1;
texture entSkin2;
texture entSkin3;
technique Caustics
{
pass p1
{
AlphaBlendEnable = False;
AlphaTestEnable = False;
ZEnable = True;
ZWriteEnable = True;
Texture[0] = <entSkin1>;
Texture[1] = <entSkin2>;
Texture[2] = <entSkin2>;
Texture[3] = <entSkin3>;
ColorArg1[0] = Texture;
ResultArg[0] = Temp;
ColorOp[0] = SelectArg1;
TexCoordIndex[0] = 0;
ColorArg1[1] = Temp;
ColorArg2[1] = Texture;
ColorOp[1] = Modulate;
AlphaArg1[1] = Temp;
AlphaArg2[1] = Texture;
AlphaOp[1] = Modulate;
TexCoordIndex[1] = 0;
TextureTransformFlags[1] = Count2;
TextureTransform[1] = <matMtl>;
ColorArg1[2] = Texture;
ColorArg2[2] = Temp;
ColorOp[2] = BlendCurrentAlpha;
TexCoordIndex[2] = 0;
TextureTransformFlags[2] = Count2;
TextureTransform[2] = <matMtl>;
ColorArg1[3] = Current;
ColorOp[3] = SelectArg1;
AlphaArg1[3] = Texture;
AlphaOp[3] = SelectArg1;
}
}
and this is how the caustics texture is moved over the terrain via litec.
Code:
function env_Caustics()
{
my.material = mtl_caustics;
reset(my, DYNAMIC);
if(!my.skill1)
{
my.skill1 = 1;
}
float i = 0;
var seed = random(360);
while(1)
{
i += my.skill1*time_step*0.0006;
mat_identity(mtl_caustics.matrix);
mtl_caustics.matrix32 = i;
// streckung
mtl_caustics.matrix11 = 8 + sin(total_ticks+seed)*0.1;
mtl_caustics.matrix22 = 8 + sin(total_ticks)*0.1;
wait(1);
}
}
right now, it just moves down via matrix32, and a bit left/right via matrix11 and matrix22 wich should do scaling...
but i want it too look like the water in the standard.wad file, so it looks more like real caustics wich behave just like that(wobbling,distortion,scaling effect). how could i achieve that? is it possible to recreate that behaviour with the litec code or only via shader? hope you know what i mean
thanks for any help!