Game Development Community

Water Shader on a Barrel

by Andrew Mac · in Torque 3D Professional · 09/13/2013 (8:36 pm) · 4 replies

I just decided to have a little fun and see if I could make an object made of water. Maybe I'm approaching this wrong but I made a custom material and took the properties from WaterMat expecting it to apply the shader to the object. I also tried some code from the documentation with no luck. Both of them produce the same thing:

i.imgur.com/SGqUDzH.png
Here's the material code:

singleton CustomMaterial(untitled_polymshSG)
{
   mapTo = "polymshSG";

   sampler["prepassTex"] = "#prepass";
   sampler["reflectMap"] = "$reflectbuff";
   sampler["refractBuff"] = "$backbuff";
   
   shader = WaterShader;
   stateBlock = WaterStateBlock;
   version = 3.0;
   
   useAnisotropic[0] = true;
};

#1
09/16/2013 (6:01 am)
Good question. Wish I knew anything about the material system to be able to help out! All I can actually do is bump this thread...
#2
09/16/2013 (6:24 am)
I'm guessing the water shader is pulling a color from the surrounding environment, since it's sand everywhere.

I'm really just humoring the idea of making water-based weapons. For instance a water gun. I could fake it with particles, not sure how good it would look. I could also "fake" it with meshes that look like water. My ideal solution though would be a mesh projectile with a water shader on it so maybe I can get a little reflection/refraction.

Unfortunately I have limited experience with shaders so I'm really just taking stabs in the dark.
#3
09/17/2013 (2:07 am)
@Andrew I think the water blocks passes some data to the shader in the prepRenderImage callback. Thats probably why it wont work by just applying the shader.

Edit: Also you prolly have to look into the "Water" renderPassMgr

Edit edit: You'll prolly also want to look into this line:
setShaderParams( state, mat, matParams );
where matParams is:
WaterMatParams matParams = mMatParamHandles[matIdx];
That could also have something to do with it.
#4
09/17/2013 (2:26 pm)
You know, that looks like the default level fog color....