UV Movement

Posted By: ShoreVietam

UV Movement - 08/09/06 14:38

hi there

I just try some stuff and need a constant U/V movement, but the article/ tutorial in the wiki covering this has been deleted and I can't find information about doing U/V Movement within a shader (only one of 2 textures has to be shifted).

If someone knows it, please tell me, thanks. ^.^"

I'll share it, too, if it works.



Edit: Got it, only some tweaking left. :-]
Posted By: ShoreVietam

Smothly blendet streaming water - 08/09/06 17:00

My shader is finished, yay!

Here's how it looks like, I think everyone has seen it in games before.
Water floating around a stone or something else:



If you want to use it just download the resources including the wdl file, the .fx file, a demo model and pictures how to build the alpha map of your own water stream.
I got the best visual results by placing the model a few quants below the water.

Doublealpha.exe ~ 66.7 KB Selfextracing WinRAR Archive




Posted By: Uhrwerk

Re: Smothly blendet streaming water - 08/09/06 17:23

Would you mind posting a little vid in order to show, what the effect exactly does? I understand in base what you wanted to achieve, but I'm in doubt if I should use a ps/vs 2.0 effect for such an "easy" eyecandy...
Posted By: ShoreVietam

Re: Smothly blendet streaming water - 08/09/06 18:21

Here you go!

Video at youtube


I'm open for better solutions, but I think it is not that heavy with a small 32x128 texture and a hand full of polys doing some texture multiplications?
Posted By: Uhrwerk

Re: Smothly blendet streaming water - 08/09/06 21:08

I don't know if this solution is fast or not. I haven't got my feets wet in shader stuff. The thing that bothers me, is that you require a ps/vs 2.0 capable graphics card to see the effect in action.

However, the effect looks really nice. Thank you for making the video so fast and last but not least for the contribution itself.

regards, Zeitwerk.
Posted By: ShoreVietam

Re: Smothly blendet streaming water - 08/10/06 06:21

I just tested something, you could reduce VS to 1.0, but PS 2.0 is needed to shift the texture.

I'm sure the way I made it is more complicated than how it could be made, but I'm not really inter shader programming...

However you could make smooth waterfalls, too.
I'll use it until I (or maybe someone else) find a better solution.




Posted By: Alexander Esslinger

Re: Smothly blendet streaming water - 08/10/06 12:15

When you need ps2.0 you're using complicated dependant texture-reads - by altering the texture coordinates in the vertex-shader you can use ps1.1.

But you can also use the directx renderstates:


FX-file Code:
matrix matMtl;
texture entSkin1;
texture entSkin2;

Technique shift_uv
{
Pass p0
{
Texture[0] = <entSkin1>;
Texture[1] = <entSkin2>;

TextureTransform[1] = <matMtl>;
TextureTransformFlags[1] = Count2;

ColorOp[0] = SelectArg1;
ColorArg1[0] = Texture;
ColorOp[1] = Add;
ColorArg1[1] = Texture;
ColorArg2[1] = Current;

ColorOp[2] = Disable;
}
}




C-script Code:
..
var phi = 0;
while(1)
{
phi += 1*time;
mat_identity(mtl_shiftuv.matrix);
mtl_shiftuv.matrix13 = floatd(phi,255); // x-direction
mtl_shiftuv.matrix23 = floatd(phi,255); // y-direction
wait(1);
}
..


Posted By: ShoreVietam

Re: Smothly blendet streaming water - 08/12/06 12:16

I fear I don't know enough about shaders to understand it, yet.

I gotta look a couple of things up to understand it.




Posted By: ShoreVietam

Re: Smothly blendet streaming water - 08/12/06 20:23

Got it.

That's the ticked, tomorrow I'll upload an updated version:
(The cost is the necessity of 2 tga textures)

Code:
matrix matMtl;
texture entSkin1;
texture entSkin2;

Technique fluid_shift
{
Pass p0
{
Texture[0] = <entSkin2>;
Texture[1] = <entSkin1>;

TextureTransform[1] = <matMtl>;
TextureTransformFlags[1] = Count2;

ColorArg1[0] = Texture;
ColorArg1[1] = Current;
ColorOp[1] = Modulate;
ColorArg2[1] = Texture;

AlphaArg1[0] = Texture;
AlphaOp[0] = SelectArg1;

AlphaArg1[1] = Current;
AlphaOp[1] = Modulate;
AlphaArg2[1] = Texture;

ColorOp[2] = Disable;
AlphaOp[2] = Disable;
}
}


Posted By: ShoreVietam

Smothly blendet streaming water (FFP) - 08/13/06 10:06

With thanks to Alexander I finished the new code yesterday.

Now I put all new data into the WinRAR archive which can be downloaded now.
It uses Fixed Function Pipeline now and thus should run on non-shader graphic cards, too, right?



(@Alexander: Ich wohne in Esslingen )




© 2024 lite-C Forums