Author Topic: Water Shader Textures  (Read 12432 times)

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Water Shader Textures
« on: January 09, 2011, 09:13:08 pm »
I'm trying to play with the wiki's NormalMap shader. I have a water plane. The example adds two textures, "stones" and "normals" to the TextureManager. Seeing as how I don't know what the textures look like, or what mine should (I would like the water plane's vertices to distort up and down such that it looks remotely like water) I don't know what textures to load. Any help is appreciated.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Water Shader Textures
« Reply #1 on: January 10, 2011, 08:24:36 am »
It's a standard texture map and a normal map. The resources for the advanced example contain such a combination. You can find plenty of other examples on the net as well. But keep in mind that when using shaders, you'll loose all fixed function support, i.e. lighting, shadow mapping, projective texturing, fogging...all won't work unless you reproduce the required calculations in your shaders.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Water Shader Textures
« Reply #2 on: January 10, 2011, 04:40:28 pm »
Fortunately, the ReflectionHelper has been failing me anyway, so I've nothing to lose. :p Anyway, am I supposed to lose the texture as well (because I have been)?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Water Shader Textures
« Reply #3 on: January 10, 2011, 05:25:40 pm »
You get all you do in the shader, everything else is lost. The example shaders in the wiki of course do texturing, or otherwise, it wouldn't make much sense. Also keep in mind that some hatdware/drivers simply fail with shaders...like some Intel chips.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Water Shader Textures
« Reply #4 on: January 10, 2011, 05:28:51 pm »
Btw: What went wrong with the ReflectionHelper? Its supposed to work even on the lowest chips like crap from Intel and a Geforce2 MX...i've tested both.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Water Shader Textures
« Reply #5 on: January 10, 2011, 05:43:19 pm »
The program hangs. I've waited for as much as 20 minutes.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Water Shader Textures
« Reply #6 on: January 10, 2011, 07:19:15 pm »
About the shader, I noticed it strips the sphere. Is that necessary (I'm trying to determine why my plane is losing its texture)?

EDIT: Anyhow, removing strip() didn't solve the texture disappearance problem. And yes, I'm setting the right texture in the shader.

EDIT2: Got the texture back by removing compile()! Is that necessary (other than to speed it up)?
« Last Edit: January 10, 2011, 07:29:14 pm by AGP »

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Water Shader Textures
« Reply #7 on: January 10, 2011, 07:30:35 pm »
So now that I got my texture, how do I animate this thing? Do I have to keep replacing the normal texture (and is that the best way to achieve movement)?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Water Shader Textures
« Reply #8 on: January 10, 2011, 11:51:04 pm »
Removing compile()-call will disable shader support. You can't use shaders on uncompiled objects. If your texture doesn't appear when compiling it, you are doing something wrong with the shader or shaders aren't supported by your hardware/driver (some Intel OpenGL drivers don't support GLSL shaders even if the hardware should be able to handle them). You should get some information in the log if that happens. Maybe you can post the log when using compile and shaders?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Water Shader Textures
« Reply #9 on: January 10, 2011, 11:53:18 pm »
About the hang with the ReflectionHelper: Seems to be a threading issue in your code. You have to be careful of what you do in which thread when using the AWLGLCanvas, or you'll make one thread wait for the drawing thread which is blocked...which results in an infinite wait. If you can create a simple test case, i can have a closer look.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Water Shader Textures
« Reply #10 on: January 11, 2011, 02:30:48 am »
It can't be a threading issue since there's a total of two lines referencing it, and the game loop is where render() draw() and display() are called. And even a GeForce 9800 is producing the message "shadow-mapping is not supported." In my opinion, based on these two facts alone (not a threading thing and the GeForce 9800 message) there's something wrong with both ShadowHelper and the ReflectionHelper.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Water Shader Textures
« Reply #11 on: January 11, 2011, 07:32:16 am »
Nope, it's not. I have thousands of screen shots from different machines from all over world provided by the Robombs feedback function that show nice shadows. The only plattforms that have trouble doing it correctly are some SiS "gpus" and some linux drivers that go crazy on the shadows. Apart from that, everything works fine.
If shadow mapping doesn't work on a GeForce 9800, check your drivers. Maybe you are using the stock Windows drivers or some other obscure one (which OS btw?).
As said, a log output might help.

And it may very well be a threading issue of some kind, because the AWTGLRenderer has to do it's own threading stuff in the background which might interfere with whatever you are doing. Without a test case, i can't do anything...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Water Shader Textures
« Reply #12 on: January 11, 2011, 12:49:12 pm »
EDIT: Anyhow, removing strip() didn't solve the texture disappearance problem. And yes, I'm setting the right texture in the shader.
Remember that the shader needs a light source to work with. Without one, everything will be black.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Water Shader Textures
« Reply #13 on: January 11, 2011, 02:35:19 pm »
I'll see about a test case, but the output is nearly 10 thousand lines lomg.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Water Shader Textures
« Reply #14 on: January 11, 2011, 08:19:45 pm »
Very interesting development: this shader works compiled and stripped, yours doesn't. http://forum.bonzaisoftware.com/viewthread.php?tid=10