Blood & Water Effects [Irrlicht 1.7.1]

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

???

http://img140.imageshack.us/i/aproblem.png/

ATI X600XT.

Separately, assuming I even get this working:

* The plane is incorrect. I need to change the axis (rotate on X 90 degrees) How do I do this?
* I need to make the plane go from (0,0) to (sizex, sizey) instead of increase the size in all directions. How do I do this?

Thanks.
Sinsemilla
Posts: 38
Joined: Mon Jan 09, 2012 5:07 pm

Re: Blood & Water Effects [Irrlicht 1.7.1]

Post by Sinsemilla »

Hi together,

I would like to use this very promising water shader in my Project. Can anybody upload the OpenGL (GLSL) version of the water shader please? The file has been deleted on the original link :( and I can't find it anywhere else. Unfortunately it's also not contained in IrrExt.

Anyways this is a very nice work. :wink:
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: Blood & Water Effects [Irrlicht 1.7.1]

Post by Cube_ »

whoah! this is really nice!
but what about transparecy? It looks too opaque in my eyes.... ^^*
"this is not the bottleneck you are looking for"
jorgerosa
Competition winner
Posts: 117
Joined: Wed Jun 30, 2010 8:44 am
Location: Portugal
Contact:

Re: Blood & Water Effects [Irrlicht 1.7.1]

Post by jorgerosa »

Sinsemilla wrote:... water shader in my Project. Can anybody upload the OpenGL (GLSL) version of the water shader...
http://www.4shared.com/zip/ieIR7rmp/jorge.html
Open first the included main.cpp file for more details. Hope this helps. :)
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: Blood & Water Effects [Irrlicht 1.7.1]

Post by smso »

water_vs.glsl

Code: Select all

uniform mat4 mWorld;
 
uniform vec4 CamPos;
 
uniform float Time;
 
uniform float sinWave;
 
 
 
varying vec4 waterPos;
 
varying vec3 MultiVar;
 
varying vec3 worldView;
 
varying vec2 texCoords;
 
 
 
 
 
void main()
{
 
    vec4 position=ftransform();
 
    gl_Position=position;
 
    waterPos=gl_Vertex*mWorld;
 
   
 
    MultiVar.y=Time/10000.0;
 
 
 
    if(sinWave>0.0) {
 
        MultiVar.x=(sin((position.x/3.0)+(Time*10.0/10000.0)))+(cos((position.z/3.0)+(Time*10.0/10000.0)));
 
        gl_Position.y+=MultiVar.x;
 
    }
 
 
 
    MultiVar.z=CamPos.y;
 
 
 
    worldView=CamPos.xyz-(mWorld*gl_Vertex).xyz;
 
    texCoords=(gl_MultiTexCoord0.xy+0.5)/2.0+vec2(MultiVar.y, MultiVar.y);
 
        texCoords.x=texCoords.x+sin(MultiVar.x*5.0)*(5.0/1000.0);
 
    texCoords.y=texCoords.y+cos(MultiVar.x*5.0)*(5.0/1000.0);
 
}

water_ps.glsl

Code: Select all

uniform mat4 mWorldViewProjP;
 
uniform float sinWaveP;
 
uniform float refractionP;
 
uniform float seaLevel;
 
uniform sampler2D ReflectionTexture;
 
uniform sampler2D NormalMap;
 
uniform sampler2D DUDVMap;
 
 
 
 
 
varying vec4 waterPos;
 
varying vec3 MultiVar;
 
varying vec3 worldView;
 
varying vec2 texCoords;
 
 
 
void main()
{
 
 
 
    vec4 projCoord=mWorldViewProjP*waterPos;
 
    projCoord.x=(projCoord.x/projCoord.w)/2.0+0.5;
 
    projCoord.y=(projCoord.y/projCoord.w)/2.0+0.5;
 
 
 
    if(sinWaveP>0.0) {
 
 
 
        projCoord.x+=sin(MultiVar.x*5.0)*(2.0/1000.0);
 
        projCoord.y+=cos(MultiVar.x*5.0)*(2.0/1000.0);
 
        
 
 
 
    }
 
 
 
    if(refractionP>0.0) {
 
 
 
        vec4 DUDVoffset=texture2D(DUDVMap, texCoords);
 
        projCoord.x+=(DUDVoffset.x/40.0)-(1.0/80.0);
 
        projCoord.y+=(DUDVoffset.y/40.0)-(1.0/80.0);
 
 
 
    }
 
 
 
    projCoord=clamp(projCoord, 0.001, 0.999);
 
 
 
    vec4 normal=vec4(0.0,1.0,0.0,0.0);
 
 
 
    if (MultiVar.z < seaLevel)
 
    {
 
        projCoord.y=1.0-projCoord.y;
 
        }
 
        
 
    projCoord.y=projCoord.y*(-1.0);
 
    vec4 refTex=texture2D(ReflectionTexture, projCoord.xy);
 
 
 
    float facing=(1.0-max(dot(normalize(worldView), normalize(normal.xyz)), 0.0));
 
    vec4 MultCol=vec4(0.4,0.7,1.0,0.0);
 
 
 
    refTex=(refTex+vec4(0.0,0.0,0.1,0.0))*MultCol;
 
 
 
    vec4 norMap=texture2D(NormalMap, texCoords);
 
    float lightComp=1.0-max(dot(normalize(norMap.xyz), normalize(abs(worldView))),0.0);
 
 
 
    vec4 finalCol=refTex;
 
 
 
    if(MultiVar.z<seaLevel) finalCol*=0.8;
 
 
 
    finalCol.a=0.6+(facing/2.0);
 
    finalCol+=lightComp;
 
 
 
    gl_FragColor=finalCol;
 
 
 
}
 
Sinsemilla
Posts: 38
Joined: Mon Jan 09, 2012 5:07 pm

Re: Blood & Water Effects [Irrlicht 1.7.1]

Post by Sinsemilla »

@jorgerosa: Thx for the link :D , i managed to download your code after a few more or less random clicks on that page (what language is this? :shock:).
However, your main.cpp is unfotunately empty :

Code: Select all

 
#include <irrlicht.h>             // Declare Irrlicht
 
 
#include "CWaterSurface.h"        // For ocean effects.
#include "CWaterShader.h"         // For ocean effects.
// #include "CBloodEffect.h"
// #include "CBloodShader.h"
 
 
/// RESULT:
/// http://irrlicht.sourceforge.net/forum/viewtopic.php?f=9&t=39624&p=232219#p232219
 
 
 
int main(char ** args)
{
 
 
}
 
Anyways, your code looks very interesting, i will have to study it a while.

@smso: Thx to you also.
slavka
Posts: 1
Joined: Sat Aug 25, 2012 1:06 pm

Re: Blood & Water Effects [Irrlicht 1.7.1]

Post by slavka »

for Irrlicht 1.8.0-alpha
modify CBloodShader::createMaterial

from

Code: Select all

 
            matBlood = gpu->addHighLevelShaderMaterialFromFiles
            (
                matBloodShader, "vertexMain", EVST_VS_2_0,
                matBloodShader, "pixelMain",  EPST_PS_2_0,
                this, EMT_TRANSPARENT_ALPHA_CHANNEL
            );
 
to

Code: Select all

 
            matBlood = gpu->addHighLevelShaderMaterialFromFiles
            (
                matBloodShader, "vertexMain", EVST_VS_2_0,
                matBloodShader, "pixelMain",  EPST_PS_2_0,
                this, EMT_TRANSPARENT_ALPHA_CHANNEL_REF
            );
 
Post Reply