Game Development Community

TGE water upgrades

by Manoel Neto · in Torque Game Engine · 04/22/2006 (5:58 pm) · 53 replies

I opened this thread to stop hijacking that other one in the TSE public forums.

We had to prototype a watersports game, and chose TGE over TSE, adding shader support to the waterblock render, since that way the game wouldn't require a shader capable GPU, but would display a nicer water on supporting hardware, to prevent the game from looking too dated.

I took the "bumpmapped interiors" resource as a start point to add CG shaders support to TGE, modified the fluidRender to load and use vertex and fragment shaders, and modified the GameTSCtrl so I could use a smaller one, placed behind the main GameTSCtrl, to render the reflection to a texture. But with some changes on the .CG files, it's possible to use the ol' spherical map instead of a scene reflection, if performance is a concern.

It looks like the TSE water in motion, with 3 major differences:
- There's no refraction (would bring the performance further down, but could be added).
- No specular yet (easy to add by passing the light direction to the shader).
- It uses the depth mask, just like normal waterblocks (fake depth cueing).

I will post this as a resource, and got as far as take it apart from my own codebase and install it in a TLK source tree. There's only a couple bugs and commenting I need to sort out before it becomes usable.

Screenies:
img480.imageshack.us/img480/7094/tgewatershader017dl.jpgimg480.imageshack.us/img480/6541/tgewatershader034xe.jpgimg480.imageshack.us/img480/7264/tgewatershader027cy.jpg
The CG support was implemented on the windows build only (we aren't really making multi-platform games yet), but CG is supposed to be multi-platform, so people experienced in working on OSX and Linux could get it to work in those platforms as well.
#21
04/26/2006 (8:58 am)
Frame rate hit?
#22
04/26/2006 (9:18 am)
Sorry for understatement if you are talking to me. I had a brain operation a year and half ago, so I am still learn things again. I attend to stay away from big words and fancy sentence right now because I missspell the words or sentences does not make sense, but I m working on it hopefully one day I will be 100 percent again.
#23
04/26/2006 (12:19 pm)
Can't wait to get this upgrade resource :D Great job, Manoel! Btw. I figured that water is one of the most important parts these days - it has to be good in order for a game to be good (at least in the opinion of many, many players out there). So this is a real step forward into the right direction. Combined with the bumpmapped interiors it will make TGE look far more up to date.
Unfortunately I am lost when it comes to graphics programming. I've been programming in C++ for almost 7 years now, but the graphics programming part...well...I leave it to those who can do it.
Just a simple idea (for those who don't have an up to date graphics card)...there should be a script-command/variable to en/disable this water effect somehow ;)
#24
04/27/2006 (4:33 am)
When this resource will be available to us?
and I hope I wont need TLK :P (only TGE)

and where did you get that nice bloomy-effect?
#25
04/27/2006 (1:21 pm)
Oh, Please, please let us have it, please. I can't afford TSE, I don't even think
it will run good on my 1.3ghz with 512mb ? Will TSE run on that ?

I would like to learn Cg but I think my brain would be spegetti :(

Is there a simple shader tut on TGE and cg ? I think this would be a good one !
#26
04/27/2006 (1:22 pm)
@Juha
TLK has a Bloom resource as well as a couple of other handy "wow" effect resources.
#27
04/28/2006 (4:27 am)
Oh... well.. i think i'm going to save up for TSE and put all the "wow" resources in it :P
#28
04/28/2006 (7:27 am)
Okay, the resource was uploaded. Now waiting for it to get reviewed, so the url might not work for a while:

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10357

I tried my best at explaining the install process, I hope it works ok.
#29
04/28/2006 (7:36 am)
Cheers Manoel, great work !!!

I'll have a look at this next week, and give it a shot in our game.

I salute you, you've made me a very happy man 8)
#30
04/28/2006 (7:47 am)
Fantastic!,

Thanks for all of the work Manoel, I am sure you see this put to good you by many.
#31
04/28/2006 (11:38 am)
Well, if anyone comes up with improvements and bug fixes for this (like adding the missing features), I'll update the resource with them.
#32
04/28/2006 (12:09 pm)
Excellent work Manoel - amongst the hundreds of excellent resources here there is a small handful that I believe would be considered 'must-have'... You can add this resource to that list. Good stuff!
#33
04/28/2006 (3:30 pm)
Thank you Manoel - This is an excellent resource and easily one of the best ones out there.
#34
04/28/2006 (6:19 pm)
I just go it working - I needed to copy the CG.dll file into the torque folder in order for it to run, is that normal?

It works well, though, and looks great. I'm on a Radeon 9600XT and received no performance hit @ 1440*900*32

Now I'll try to add variable adjustments for the opaqueness of the water...
#35
04/29/2006 (11:48 am)
I'll add the notice about CG.dll to the resource. I forgot about that (since I have Maya installed in my machine at work, TGE happily loaded Maya's CG.dll file).
#36
04/29/2006 (9:19 pm)
C:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : fatal error C1004: unexpected end of file found

Error executing cl.exe.
Creating browse info file...
BSCMAKE: error BK1506 : cannot open file SDK\engine\out.VC6.DEBUG\fluidRender.sbr': No such file or directory
Error executing bscmake.exe.

I have no Idea what cause these errors please help.
#37
04/29/2006 (11:22 pm)
Read the resource install instructions again, they have been updated. You need to do this:

Important: you also need to open cgGL.h in the "Cg/include" folder and replace this:
#include <GL/gl.h>

By this:
#include <dgl/dgl.h>
#38
04/30/2006 (9:44 am)
I have change my cgGL.h with the change above. I still get the same error. I have no idea what cause this unless I some wrong with include paths. I am using Microsoft VC.6 and clean version of TGE 1.4..
#39
04/30/2006 (10:34 am)
I get the same errors with Microsoft VC++.NET 2003 edition and clean version of TGE 1.4 and I changed the ch.h thingy
#40
04/30/2006 (10:44 am)
What did you change in ch.h? James.