Gamestudio Links
Zorro Links
Newest Posts
blogherenowcenter
by 3s05bmmc. 06/05/24 06:08
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,377 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19057 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
water/caustics distortion fx with material matrix #181738
02/03/08 13:35
02/03/08 13:35
Joined: Aug 2005
Posts: 1,012
germany, dresden
ulf Offline OP
Serious User
ulf  Offline OP
Serious User

Joined: Aug 2005
Posts: 1,012
germany, dresden
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!

Last edited by ulf; 02/03/08 13:44.
Re: water/caustics distortion fx with material matrix [Re: ulf] #181739
02/04/08 11:14
02/04/08 11:14
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
Ohr!- da kommt doch tatsächlich ma einer aus Dresden^^ da versuch ich gleich mal zu helfen. Du willst also eine animierte Caustic-Textur!? Darüber hab ich mir schon paar Gedanken gemacht, aber bei den vielen die ich hab hatte ich noch keine Zeit die Theorie umzusetzen. ALSO ich würde das so machen:
wie du ja bestimmt weißt kann man Sprites animieren indem man die Frames in einer Bitmap aneinanderhängt-wie bei .wad files. So - man baue sich also so ein animiertes "Causticssprite" legt dieses jenes vor einen View, lässt es sich dort animieren und rendert dies dann einfach in Echtzeit in eine Textur deines Terrains, welche du dann als Caustcstextur verwenden möchtest.
Du musst aber aufpassen das das Sprite exakt vor dem View liegt von dem du die Textur holst - vor allem wenn du die sie noch kacheln willst...sonst sieht man dann nen Saum um jede Kachel.
Das ist natürlich nur reine Theorie, aber funzen müsstes natürlich. Kann sein das es noch nen einfacheren Weg gibt - hab mich noch nicht ernsthaft damit auseinander gesetzt.

Hoffe ich konnte dir helfen - Hummel.

Last edited by Hummel; 02/04/08 11:47.
Re: water/caustics distortion fx with material mat [Re: Hummel] #181740
02/04/08 11:29
02/04/08 11:29
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Ich würde den caustics generator nehmen, der eine echte caustics animation generiert und dann die in deinen Effekt einbauen:

http://www.lysator.liu.se/~kand/caustics/

Ich hab da mal das Sample-Video hochgeladen:
http://www.youtube.com/watch?v=h-qP_RcAXv4

Noch nen schönen Tag, Christian

Last edited by HeelX; 02/04/08 11:43.
Re: water/caustics distortion fx with material mat [Re: HeelX] #181741
02/04/08 11:52
02/04/08 11:52
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
Das mit der animiereten Textur is schon klar, aber ich dachte immer das geht nur mit sprites und .wad files!? Das Youtube vid hat mich auf eine andere Idee gebracht - man könnte die caustics-textur (nicht animiert) auch einfach mit ner Normalmap, die man drüber laufen lässt, verzerren.

Re: water/caustics distortion fx with material mat [Re: Hummel] #181742
02/04/08 12:33
02/04/08 12:33
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Du kannst die einzelnen frames ja auch als DDS textur (damit das schön klein bleibt) in die skins packen und durchschalten.

Re: water/caustics distortion fx with material mat [Re: HeelX] #181743
02/04/08 13:57
02/04/08 13:57
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
man hat doch aba nur 4 Skins-oder hab ich da irgendwas verpasst?
Dann hätte man nur noch die andren 4, welche man als ausgelagerte Texturen in Effekten verwenden kann-bei nem Terrain allerdings braucht man für ne ordentliche Darstellung schon einige Grafiken...und währen 4 frames nicht zu wenige für ne flüssige Animation?

Last edited by Hummel; 02/04/08 14:00.
Re: water/caustics distortion fx with material mat [Re: Hummel] #181744
02/04/08 14:02
02/04/08 14:02
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Hummel, weshalb willst du denn im Shader die Skins wechseln

Re: water/caustics distortion fx with material mat [Re: Slin] #181745
02/04/08 14:29
02/04/08 14:29
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
ne will ich doch gar nich^^ da haste irgendwas falsch verstanden...ich wollte ein animiertes Sprite vor nen View legen und von dem dann die Animation in ne Textur rendern-damit würde man nur eine Skin vom Terrain für ne animierte Skin verbrauchen und hätte demnach mehr Texturen für Multitexturing und Normalmapping und solche Sachen übrig. Und wenn man nun die einzelnen Frames von der Animation in die Skins des Terrains legen würde, wie HeelX vorschlug, hätte man noch weniger andere Grafiken übrig-falls nicht mittlerweile die Begrenzung auf 4 Skins und 4 externe Texturen aufgehoben wurde.

Re: water/caustics distortion fx with material mat [Re: Hummel] #181746
02/04/08 14:41
02/04/08 14:41
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Du hast mich nicht richtig verstanden und Heelx auch nicht
man kann einfach per ent_setskin den entity skin der caustic textur jedenframe ändern (bzw den pointer auf eine andere bmap zeigen lassen, was nähmlich sehr schnell ist).
Deine Variante ist dagegen recht aufwändig umzusetzen und kostet relativ viel performence.
ulf hat es getestet und es funktioniert angeblich jetzt sehr gut mit ent_setskin

Re: water/caustics distortion fx with material mat [Re: Slin] #181747
02/04/08 14:54
02/04/08 14:54
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Hummel, the texture limit is per entity per frame. And since every frame only needs 1 animation frame, you only need to use up 1 texture.

I would create a texture array with each index pointing to another frame in the animation. Then use a variable to store how far in the animation you are (anim += 5 * time_step;), and take the integer part of it as index in the array: mtl.skin1 = texArray[integer(anim)];.

Page 1 of 2 1 2

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1