New water
by Brian Ramage · in Torque Game Engine Advanced · 04/06/2005 (12:09 pm) · 53 replies
Hey guys, the new water is finally checked in. There's also a new demo directory terrain_water_demo. It contains a very minimal demo mission without a lot of the extra stuff that's in the main demo. Right now it's still running the current terrain, it will be updated with the new terrain when it's ready.
The water isn't in the docs yet, so let me point out a few things.
Most of the water parameters aren't updated in real time, so you'll have to restart the mission for them to take effect. The exceptions to this are the scale of the water, which is how you change its size, and the "gridsize" parameter which indicates the number of meters between verts in the water grid.
The 2.0 pixel shader for the water is a monster, so if you have a Geforce FX5200 or other low end 2.0 shader card, you might want to force it down to 1.1 shaders, or set the "fullReflect" flag to false.
There were a ton of other updates that went up with the water, so let us know if something got broken.
Enjoy!
The water isn't in the docs yet, so let me point out a few things.
Most of the water parameters aren't updated in real time, so you'll have to restart the mission for them to take effect. The exceptions to this are the scale of the water, which is how you change its size, and the "gridsize" parameter which indicates the number of meters between verts in the water grid.
The 2.0 pixel shader for the water is a monster, so if you have a Geforce FX5200 or other low end 2.0 shader card, you might want to force it down to 1.1 shaders, or set the "fullReflect" flag to false.
There were a ton of other updates that went up with the water, so let us know if something got broken.
Enjoy!
About the author
I have over 16 years of professional game development experience at both AAA studios like Dynamix, to indie studios like GarageGames and my own Black Jacket Games. I worked for 5 years at GarageGames as the lead developer on TGEA (precursor to T3D).
#42
terrain_water_demo/server/scripts/shaders.cs (0): Unable to instantiate non-conobject class ShaderData.
and
Bad key in subObject stream!
Anyone else have this problem or know what's causing it?
The waterblock.cpp is also giving me an error when it tries to compile because of this line, where USERDEF is an undeclared identifier.
GFX->setPixelShaderConstF( PC_USERDEF1, (float*)reg, 1 );
04/18/2005 (9:36 pm)
I get an odd problem when I run the water demo. The demo runs, but the water does not display. Looking at the screenshots I can see where it's supposed to be, but I get no water, just the ground texture and the sky. When I go through my console log I'm getting a bunch of:terrain_water_demo/server/scripts/shaders.cs (0): Unable to instantiate non-conobject class ShaderData.
and
Bad key in subObject stream!
Anyone else have this problem or know what's causing it?
The waterblock.cpp is also giving me an error when it tries to compile because of this line, where USERDEF is an undeclared identifier.
GFX->setPixelShaderConstF( PC_USERDEF1, (float*)reg, 1 );
#43
04/19/2005 (5:13 am)
.
#44
the variables you are looking for are defined in example/shaders/shdrConsts.h..
If theyre not in that include file you hosed something in the cvs checkout..
04/19/2005 (7:15 am)
@jc - If your getting a compiler error about something NOT being defined. the build/make process usually ends there..so your running your old exe... hence no water..the variables you are looking for are defined in example/shaders/shdrConsts.h..
If theyre not in that include file you hosed something in the cvs checkout..
#45
04/20/2005 (9:08 pm)
I was still getting the error, but I hard rigged the value and was able to get it to compile. Previously I was assuming that when you downloaded from the CVS that you also snagged the latest executable. Oops. =P
#46
It works fine in the water demo directory but crashes when I try to use it in any mod directory that I make.... so obviously the code is fine and I am missing something in one of the scripts.
Here is what I tried.. any clue what I am missing?:
in materials.cs
1) added lerpalpha line
2) added Sky_Day_Blur02 datablock
3) added the other water custommaterial datablocks
in shader.cs
1) added water shaders
in my mission
1) simply pasted in the water block from the water demo
05/26/2005 (2:34 pm)
I am having the same problem as Kyle way above... I cannot get the waterblock to work without crashing. It works fine in the water demo directory but crashes when I try to use it in any mod directory that I make.... so obviously the code is fine and I am missing something in one of the scripts.
Here is what I tried.. any clue what I am missing?:
in materials.cs
1) added lerpalpha line
2) added Sky_Day_Blur02 datablock
3) added the other water custommaterial datablocks
in shader.cs
1) added water shaders
in my mission
1) simply pasted in the water block from the water demo
#47
05/26/2005 (2:40 pm)
I figured out this problem: my issue was that I had not properly gotten the sky block materials/textures in the materials.cs. It looks like you did that, though, since you mentioned the Sky_Day_Blur02 datablovk which I believe was my issue (sorry I'm fuzzy, I fixed this a bit ago).
#48
Turns out you gave me a clue anyway. Upon looking back at the sky materials (texture) directory I found that I had missed copying over one file (sky_z_pos3.jpg)!! I didn't even notice the cubemap error it was giving me in the console.
Now it works perfectly... all I have to do now is make a cubemap and shader for each sky. It would be really sweet if the sky would automatically make a cubemap out of the dml file that has a standard name (like "skyAutoCubeMap") and I could just put that in my water shaders.
As it stands tho... I think my client is going to have problems controlling bowel movements after they see this!
Thanks again
05/26/2005 (3:05 pm)
Kyle, thanks for the fast response! Turns out you gave me a clue anyway. Upon looking back at the sky materials (texture) directory I found that I had missed copying over one file (sky_z_pos3.jpg)!! I didn't even notice the cubemap error it was giving me in the console.
Now it works perfectly... all I have to do now is make a cubemap and shader for each sky. It would be really sweet if the sky would automatically make a cubemap out of the dml file that has a standard name (like "skyAutoCubeMap") and I could just put that in my water shaders.
As it stands tho... I think my client is going to have problems controlling bowel movements after they see this!
Thanks again
#49
I did notice that as you got farther from the center of the wterblock the water got a little blocky. I don't know if that is a bug in the water or that i am just nuts for making a waterblock that big.
Here is the specs for reference.
06/01/2005 (11:53 am)
The water is awsome. I made a 50000x50000 water block with a grid size of 500(anything bigger caused fog problems) along with the new textures and i got a 119 avg fps. that is just about the same as TGE runs, prehaps a little better. Swwet!I did notice that as you got farther from the center of the wterblock the water got a little blocky. I don't know if that is a bug in the water or that i am just nuts for making a waterblock that big.
Here is the specs for reference.
new WaterBlock() {
position = "85.7772 198.458 53";
rotation = "1 0 0 0";
scale = "50000 50000 500";
waveDir[0] = "0.000000 1.000000";
waveDir[1] = "0.707000 0.707000";
waveDir[2] = "0.500000 0.860000";
waveDir[3] = "0.860000 8.500000";
waveSpeed[0] = "-0.065";
waveSpeed[1] = "0.09";
waveSpeed[2] = "0.04";
waveSpeed[3] = "0.025";
waveTexScale[0] = "7.140000 7.140000";
waveTexScale[1] = "6.250000 12.500000";
waveTexScale[2] = "50.000000 50.000000";
waveTexScale[3] = "0.000000 0.000000";
reflectTexSize = "512";
baseColor = "5 12 22 153";
underwaterColor = "11 31 46 190";
gridSize = "500";
surfMaterial[0] = "Water";
surfMaterial[1] = "Underwater";
surfMaterial[2] = "Water1_1FogPass";
surfMaterial[3] = "WaterBlendMat";
surfMaterial[4] = "WaterFallback1_1";
fullReflect = "1";
clarity = "0.08";
fresnelBias = "0.12";
fresnelPower = "6";
renderFogMesh = "1";
};
#50
06/01/2005 (4:28 pm)
It was not designed to be scaled up that big (50x50 kilometers!?). You will probably run into floating point errors at that size.
#51
06/01/2005 (7:42 pm)
Was just trying to see how big i can make it. Experementing. best way to learn. Would you believe i had the view distance at the same distance. ;)
#52
06/02/2005 (12:32 pm)
Feature request: Wave data can be set for the x/y planes, but not the z? Bah! My new waterfall looks really good with just a minor particle here and there, except the water cannot move down! Hmmm, but then since I rotated the block, it still should be the x or y plane. However, if I take an extremely fast moving river block, rotate it 90, the water will no longer move in the direction it was before, it just kind of bubbles/rolls around like jello.
#53
06/02/2005 (3:58 pm)
The the wave data x/y movement is relative to the plane; it's not in worldspace. That's why when you rotate a waterBlock, the water movement is the same. Should be anyway. If you are running on a 1.1 shader card, the wave data has no effect.
Torque Owner Brian Ramage
Black Jacket Games