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.

Postby agamemnus » Wed Mar 09, 2011 9:50 pm

???

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.
agamemnus
 
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Re: Blood & Water Effects [Irrlicht 1.7.1]

Postby Sinsemilla » Mon Jan 09, 2012 5:22 pm

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:
Sinsemilla
 
Posts: 20
Joined: Mon Jan 09, 2012 5:07 pm

Re: Blood & Water Effects [Irrlicht 1.7.1]

Postby aaammmsterdddam » Tue Jan 10, 2012 7:02 am

whoah! this is really nice!
but what about transparecy? It looks too opaque in my eyes.... ^^*
(n^(n-n))-1
aaammmsterdddam
 
Posts: 520
Joined: Mon Oct 24, 2011 10:03 pm

Re: Blood & Water Effects [Irrlicht 1.7.1]

Postby jorgerosa » Wed Jan 11, 2012 6:36 am

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. :)
User avatar
jorgerosa
Competition winner
 
Posts: 91
Joined: Wed Jun 30, 2010 8:44 am
Location: Portugal

Re: Blood & Water Effects [Irrlicht 1.7.1]

Postby smso » Wed Jan 11, 2012 4:28 pm

water_vs.glsl

cpp 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

cpp 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;
 
 
 
}
 
smso
 
Posts: 217
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: Blood & Water Effects [Irrlicht 1.7.1]

Postby Sinsemilla » Thu Jan 12, 2012 3:15 am

@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 :

cpp 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.
Sinsemilla
 
Posts: 20
Joined: Mon Jan 09, 2012 5:07 pm

Re: Blood & Water Effects [Irrlicht 1.7.1]

Postby slavka » Sat Aug 25, 2012 1:10 pm

for Irrlicht 1.8.0-alpha
modify CBloodShader::createMaterial

from
cpp Code: Select all
 
            matBlood = gpu->addHighLevelShaderMaterialFromFiles
            (
                matBloodShader, "vertexMain", EVST_VS_2_0,
                matBloodShader, "pixelMain",  EPST_PS_2_0,
                this, EMT_TRANSPARENT_ALPHA_CHANNEL
            );
 

to
cpp Code: Select all
 
            matBlood = gpu->addHighLevelShaderMaterialFromFiles
            (
                matBloodShader, "vertexMain", EVST_VS_2_0,
                matBloodShader, "pixelMain",  EPST_PS_2_0,
                this, EMT_TRANSPARENT_ALPHA_CHANNEL_REF
            );
 
slavka
 
Posts: 1
Joined: Sat Aug 25, 2012 1:06 pm

Previous

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 1 guest