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!

Re: Realistic water node

Postby thanhle » Tue Sep 20, 2016 2:05 am

Great work.
DirectX mode works well.

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

Regards
thanhle
 
Posts: 324
Joined: Wed Jun 12, 2013 8:09 am

Re: Realistic water node

Postby Vectrotek » Tue Sep 20, 2016 8:43 am

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

cpp 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..
User avatar
Vectrotek
Competition winner
 
Posts: 1077
Joined: Sat May 02, 2015 5:05 pm
Location: South Africa

Re: Realistic water node

Postby Vectrotek » Tue Sep 20, 2016 9:38 am

Thanks for your input.. These issues are discussed here:
http://irrlicht.sourceforge.net/forum/viewtopic.php?f=2&t=51355&start=15
User avatar
Vectrotek
Competition winner
 
Posts: 1077
Joined: Sat May 02, 2015 5:05 pm
Location: South Africa

Re: Realistic water node

Postby Vectrotek » Mon Sep 26, 2016 10:38 am

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=02575688463998967655

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


Please let me know of problems..
Thanks.. Cheers!
User avatar
Vectrotek
Competition winner
 
Posts: 1077
Joined: Sat May 02, 2015 5:05 pm
Location: South Africa

Re: Realistic water node

Postby Vectrotek » Tue Sep 27, 2016 8:25 pm

Image
But we're not giving up quite yet..
User avatar
Vectrotek
Competition winner
 
Posts: 1077
Joined: Sat May 02, 2015 5:05 pm
Location: South Africa

Re: Realistic water node

Postby Vectrotek » Tue Sep 27, 2016 9:13 pm

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.
User avatar
Vectrotek
Competition winner
 
Posts: 1077
Joined: Sat May 02, 2015 5:05 pm
Location: South Africa

Re: Realistic water node

Postby CuteAlien » Tue Sep 27, 2016 9:46 pm

Changing without breaking stuff is always better. Which patch file are we talking about (link?).
IRC: #irrlicht on irc.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8533
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: Realistic water node

Postby Vectrotek » Tue Sep 27, 2016 10:22 pm

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

2011..

http://irrlicht.sourceforge.net/forum/viewtopic.php?f=2&t=44884&hilit=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.
User avatar
Vectrotek
Competition winner
 
Posts: 1077
Joined: Sat May 02, 2015 5:05 pm
Location: South Africa

Re: Realistic water node

Postby CuteAlien » Wed Sep 28, 2016 9:05 am

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.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8533
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: Realistic water node

Postby Vectrotek » Wed Sep 28, 2016 9:51 am

[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.
User avatar
Vectrotek
Competition winner
 
Posts: 1077
Joined: Sat May 02, 2015 5:05 pm
Location: South Africa

Re: Realistic water node

Postby The_Glitch » Wed Sep 28, 2016 1:43 pm

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.
User avatar
The_Glitch
Competition winner
 
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Realistic water node

Postby Vectrotek » Wed Sep 28, 2016 4:15 pm

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

Re: Realistic water node

Postby Vectrotek » Wed Sep 28, 2016 6:22 pm

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.
User avatar
Vectrotek
Competition winner
 
Posts: 1077
Joined: Sat May 02, 2015 5:05 pm
Location: South Africa

Re: Realistic water node

Postby Vectrotek » Wed Sep 28, 2016 6:25 pm

Thinking..
Last edited by Vectrotek on Thu Sep 29, 2016 8:10 pm, edited 1 time in total.
User avatar
Vectrotek
Competition winner
 
Posts: 1077
Joined: Sat May 02, 2015 5:05 pm
Location: South Africa

Re: Realistic water node

Postby The_Glitch » Wed Sep 28, 2016 8:01 pm

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
cpp 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
cpp 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.
User avatar
The_Glitch
Competition winner
 
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

PreviousNext

Return to Advanced Help

Who is online

Users browsing this forum: No registered users and 1 guest