Realistic water node

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Re: Realistic water node

Post by thanhle »

Great work.
DirectX mode works well.

I can't get openGL to to render on both intel and nvidia graphic card.

Regards
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Realistic water node

Post by Vectrotek »

For the GL code, try replacing all the code in "GL_0001_VERT_WATER.glsl" with...

Code: Select all

 
 
 // Based on code by Elvman.
 
 //uniform mat4 View;
 uniform mat4   M05WorldViewProjection;
 uniform mat4   M24WorldReflectionViewProj;
 uniform float  WaveLength;
 uniform float  Time;
 uniform float  WindForce;
 uniform vec2   WindDirection;
 // Vertex shader output structure
 varying vec2 bumpMapTexCoord;
 varying vec2 bumpMapTexCoord02;
 varying vec3 refractionMapTexCoord;
 varying vec3 reflectionMapTexCoord;
 varying vec3 position3D;
// varying vec3 VertexGLPosition;
 
 //----------------- --- -- - 
 void main()
  {// color = gl_Color; // We may later want to see what we can do with this..
   // Transform position to clip space..
   vec4 pos = M05WorldViewProjection * gl_Vertex;
   gl_Position = pos;
   // VertexGLPosition  = vec3(M01World * vec4(gl_Vertex.xyz,1)).xyz;
   // Calculate Wave Coords..
   bumpMapTexCoord = gl_MultiTexCoord0.xy / WaveLength + (Time * WindForce * WindDirection);
   // Old code..
   // WindDirection.x *= 1.333;
   // WindDirection.y *= 0.777;
   // New code..
   vec2 SecondWindDir = WindDirection; // Avoid assigning a uniform any values..
   SecondWindDir.x *= 1.333;
   SecondWindDir.y *= 0.777;
   
   // bumpMapTexCoord02 = gl_MultiTexCoord0.xy / WaveLength + (Time * WindForce * -WindDirection);
   bumpMapTexCoord02 = gl_MultiTexCoord0.xy / WaveLength + (Time * WindForce * -SecondWindDir);
   
   // Refraction texcoords..
   refractionMapTexCoord.x = 0.5 * (pos.w + pos.x);
   refractionMapTexCoord.y = 0.5 * (pos.w + pos.y);
   refractionMapTexCoord.z = pos.w;
   // Reflection texcoords..
   pos = M24WorldReflectionViewProj * gl_Vertex;
   reflectionMapTexCoord.x = 0.5 * (pos.w + pos.x);
   reflectionMapTexCoord.y = 0.5 * (pos.w + pos.y);
   reflectionMapTexCoord.z = pos.w;
   // position of the vertex
   position3D = gl_Vertex.xyz;
  }
  
 // END.. 
 
 
I'd like to know if it made a difference.

I see that some systems are more fussy than others when it comes to assigning uniforms..
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Realistic water node

Post by Vectrotek »

Thanks for your input.. These issues are discussed here:
http://irrlicht.sourceforge.net/forum/v ... 5&start=15
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Realistic water node

Post by Vectrotek »

There are important things going on in the Discussion Forums so I thought I'd return here and post a small update..

O.K. Three small downloads for those who compiled the water program and want to see a much better version.

Fixed quite a lot of things mainly in Smart Shaders and Post Processing..
Also changed all GLSL Shader Files to have "#version 120" and fixed lerp() issues..
Exactly the same result but better code..

Very small downloads..

Replace all the CPP FILES..
http://s000.tinyupload.com/?file_id=025 ... 3998967655

Replace the SHADER FILES..
http://s000.tinyupload.com/?file_id=069 ... 3827767813


Please let me know of problems..
Thanks.. Cheers!
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Realistic water node

Post by Vectrotek »

Image
But we're not giving up quite yet..
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Realistic water node

Post by Vectrotek »

I speak under correction here..
While trying to "hand code" the CUBE MAP PATCH into Irrlicht 1.8.4, I noticed something..

(by hand because line number "@@ +s and @@ -s" seems to have changed during the years so automatic
patching could possibly result in bogus adds and deletes?)

Adding this patch looks like more like "replaceing" than "adding" which is fine, but..

Wouldn't it be better to try and implement such a patch as a Completely "Additive" style patch
so that all existing programs prior to such a patch would still work, even with, the new cube-map support in the engine?

I mean, if cube-map support could have been added as brand new classes etc, then wouldn't
it simplify a major transition to Ittlicht 9.x a little easier.

Like I said, I don't really know the full mechanics of this patch, (or of Irrlicht for that matter) yet.
I've done about 10% of the patch sofar, but as I go along it's beginning to look like the patch is REPLACING things
that, most likely already have been used quite a lot like "ITexture"..

Wouldn't it have been simpler to just have "ITexture" AND "ITexture2D" and in future when
it is decided that "ITexture" is out and "ITexture2D" is in, the transition would be less painfull?

Again, I'm probably barking up the wrong tree, but I think it would have been cool if I could run the
example for cube-map while still safely being able to compile and run older legacy stuff?
(a good example of "losing" by "replacing" is some cool X-Effects things)

Any way, I'm still trying to implement the cube map patch and maybe as I learn, perhaps implement
a patch that works purely "additively" instead of "replacing" important legacy stuff..

Opinion?

Message to myself.. Look at the SF Project page..
Last edited by Vectrotek on Thu Sep 29, 2016 8:20 pm, edited 1 time in total.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Realistic water node

Post by CuteAlien »

Changing without breaking stuff is always better. Which patch file are we talking about (link?).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Realistic water node

Post by Vectrotek »

Hi Cutealien! I see the night-owls are at it..

2011..

http://irrlicht.sourceforge.net/forum/v ... it=cubemap

This one is too old.. I should have known all about trunk etc by this time!
Last edited by Vectrotek on Thu Sep 29, 2016 8:11 pm, edited 1 time in total.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Realistic water node

Post by CuteAlien »

Ok. Was asking because I know Nadro did add some cubemap support in trunk a few months ago. I haven't worked yet with it, so that's one area I'm not much familiar with so far.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Realistic water node

Post by Vectrotek »

[edit] I should be looking at the trunk and later patches like The_Glitch said below..
Last edited by Vectrotek on Thu Sep 29, 2016 8:20 pm, edited 3 times in total.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Realistic water node

Post by The_Glitch »

Yeah Vectrotek cubemap support is in the trunk version I downloaded and have been messing around with it. I've ran into some issues with it not to much testing though.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Realistic water node

Post by Vectrotek »

Image
Last edited by Vectrotek on Thu Sep 29, 2016 8:09 pm, edited 1 time in total.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Realistic water node

Post by Vectrotek »

This is how one suffers if one doesn't take good advice..
Image
Last edited by Vectrotek on Thu Sep 29, 2016 8:18 pm, edited 1 time in total.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Realistic water node

Post by Vectrotek »

Thinking..
Last edited by Vectrotek on Thu Sep 29, 2016 8:10 pm, edited 1 time in total.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Realistic water node

Post by The_Glitch »

I might be wrong but nadro added it to the trunk it's in the api now it's not a patch. You load the cubemap like any other texture and in your shader you use

Code: Select all

texCUBE
// directx or opengl.

I've had some issue loading the .pvr texture and nadro said direct3d9 does not support it but you can load the cubemap textures in dds and maybe another format.

Odd thing is my .dds cubemap shows the texture seams.

But if you use the function

Code: Select all

 cubemap = driver->addTextureCubemap() 
it works fine there are no visible texture seams. I need to do more test to rule out if it's my error or not.


You have to use a svn program to download the trunk version and compile it.
Post Reply