help about make a water effect in the screen

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Tr3nT
Posts: 65
Joined: Thu Nov 29, 2007 5:19 pm

help about make a water effect in the screen

Post by Tr3nT »

Hi guys...
I found a quite old thread talking about a raindrop effect

http://irrlicht.sourceforge.net/phpBB2/ ... ater+glass

but that i wanted to do is the same effect of the raindrops but that influence the camera(like a post process effect)
there is something of this kind in the forum? i found none like this....
it's hard to do???
thans for the help.....
kamikaze942
Posts: 52
Joined: Wed Mar 03, 2010 7:11 pm

Post by kamikaze942 »

well i don't have a server or web address to upload screenshots, but i've managed to develop a particle system for rain, not all that difficult using the the screenfx tutorial. but you want rain to fall on the camera? like little raindrops you see on the cameras for live sporting events? maybe you should draw a 2D image on the camera, or alter the particle system and place it directly place it in front of the camera.
Kamikaze
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

I think you'd need some kind of post-processing for the raindrops to achieve that kind of effect.

If you're new to that kind of stuff, you'll want to first learn the basics of pixel shaders. I use HLSL, but you can also program shaders in GLSL (for Open GL), Cg (you'll need a plug-in to use Cg shaders in Irrlicht), or Assembly. Once how you know how shaders work, here's the basics for doing post-processing:
  1. Render the scene to a Render Target Texture
  2. Create a quad (a pair of triangles) and set the texture of that quad to the RTT you just rendered
  3. Apply your post-processing shader material type to that quad
  4. Render that quad to the screen, which will display it after applying your post-processing
Tr3nT
Posts: 65
Joined: Thu Nov 29, 2007 5:19 pm

Post by Tr3nT »

thanks slavik262....i need a thing of that kind.....

can you tell me a good resource/tutorial to learn a bit how to use HLSL???
or also GLSL?
because it's new for me.....

or does anyone know someone that has done something like this raindrop effect????
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

A friend who is a professional game developer taught me HLSL, but here are a few tutorials I picked up along the way. None of them except the first are for Irrlicht, but the Irrlicht side of things isn't bad at all. Just look at the shaders example.

http://www.irrlicht3d.org/pivot/entry.php?id=158 (make sure you see part 2. Don't be weirded out that the shader is stored in a char array - in Irrlicht you can either do this or save it in a file.)
http://blogs.microsoft.co.il/blogs/tami ... orial.aspx
http://www.riemers.net/eng/Tutorials/Di ... uction.php

A few notes:
  • Basically you're going to want to use tex2D to sample your input texture and do something to determine an output in the pixel shader.
  • For post-processing, you don't usually need to worry about a vertex shader.
  • Just remember that tex2D takes an input of UV coordinates (normalized from 0 to 1), not pixel coordinates.
  • Irrlicht will automatically set your sampler (texture) variables in your shader if you declare them to the correct register. To declare the first texture, do

    Code: Select all

    sampler2D tex0 : register(s0)
    This declares the texture variable to the first texture register, s0. The second texture in a material is found at s1, and so on.
  • Things like COLOR and TEXCOORD are called semantics. They help the shader compiler know what the variables mean. Your pixel shader will always return a COLOR (for the pixel it's outputting).
  • Don't worry about "Techniques" or "Passes." Irrlicht does this automatically for you. All you need to write is your shader function(s).
Last edited by slavik262 on Tue May 25, 2010 11:34 am, edited 1 time in total.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

I've thought about this before, basically you draw a normal map/offset map on an RTT of a rain drop (And move it around etc), and use the RTT to distort the screen.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

Dumb question - if you want to render a normal map of everything in your scene, do you have to set the material of each mesh in the scene to a shader that outputs a normal as a color, then switch them all back after you render?
Tr3nT
Posts: 65
Joined: Thu Nov 29, 2007 5:19 pm

Post by Tr3nT »

i'm sorry i have to ask again...
i don't understant the steps i have to do...
and i've tried to find good resources but i fail......

the RTT must be a texture of something...right?
i thought it was a thing that needed only the texture....and using the glsl i could manipolate the screen using only the texture....

the code of the glsl in only this:

Code: Select all

uniform mat4 mWorld;
uniform vec4 CamPos;
uniform float TexMul, AlphaAdjust;
varying vec4 GlassPos;
varying vec2 TexCoord;
varying float VAlpha;

void main()
{
	VAlpha = gl_Color.a * AlphaAdjust;

    TexCoord = gl_MultiTexCoord0.xy;
    GlassPos = ftransform();
	
    gl_Position = GlassPos;
}
than it changes only the alpha channel???
i don' understand well...

[/list]
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

Hmm... I don't use GLSL, but at a glance it looks like you're not setting a color output. Can anyone who knows GLSL help out here?
Post Reply