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.
Page«First 1 2 3 Next»
#41
04/30/2006 (10:55 am)
Sorry, cgGl.h
#42
04/30/2006 (3:16 pm)
@ Thomas Einsporn, when or do you plan or releasing the resoures for your awsome bloom effects?
#43
05/30/2006 (11:49 am)
Hey Manoel Neto, Do you have a release for TGE 1.4 and TLK 1.4. doesnt seem to work on 1.4. with a clean build it compile fine, i just get this message when i try to open a mission "Error, GL not in canonical state on exit" also can you release an executable of this as well. i want to see it in action.
#44
05/30/2006 (11:59 am)
@T Squared

It works fine with TLK/TGE 1.4, take another look at your merge. As I recall aren't you also trying to get Bumpmapping working also? If so, I'd tackle one at a time (and definitely the water resource first, since it is, in my opinion the far greater bang for your buck update).

-Alan
Really Really Good Things Studio
#45
05/30/2006 (12:03 pm)
@Alan James
ya, the bumpmap isnt a big concern, and i also am having big troubles with that. so like you said. i am focusing on the water update first.

For the merge. i just took the files directly from the zip to a clean 1.4 build. Compiles fine like i said, but it just wont let me in the mission. did you have to do any modification to the code to get it to work?
#46
05/30/2006 (12:07 pm)
@Alan James
ya, the bumpmap isnt a big concern, and i also am having big troubles with that. so like you said. i am focusing on the water update first.

For the merge. i just took the files directly from the zip to a clean 1.4 build. Compiles fine like i said, but it just wont let me in the mission. did you have to do any modification to the code to get it to work?
#47
05/30/2006 (12:08 pm)
@T - pretty sure you're encountering some non-stockness in your existing codebase.

there's discussion in the resource post about people having trouble w/ non-canonical state stuff.
#48
05/30/2006 (12:12 pm)
Okay. i just noticed there a steps of code that needs to be moded to get it to work. in Alex's steps. i'm a bit confused, on where to put the code in Step 2. it says "Somewhere before the Cg shader is bound.", but you cant really just toss those method calls anywhere can you? where did you place them? like a line number would be great. or can you post online your mod files.
#49
05/30/2006 (12:16 pm)
@T Squared,

No modifications that I recall at all on a clean build. I had to do *ALOT* to get it to work with my current build, but that includes TLK, DRL, Bumpmapping, Transparent Interiors, yada, yada, yada...you get the picture.

The other question is this a release build or debug? 'Cause to be honest I'm currently having troubles with debug, but not release, I just haven't had the time to chase it down. and it has to do with canonical state errors as I recall. But if it's in the debug you're having trouble and these errors, I won't be much help at the moment because I haven't nailed them down either.

- Alan
#50
05/30/2006 (12:29 pm)
@T Squared

Around 236ish in fluidRender.cc:

// MM: Added completely new multi-texturing section.

	// Don't write into the Depth Buffer.
	glDepthMask	( GL_FALSE);
[b]
glClientActiveTextureARB(GL_TEXTURE3_ARB);
			glActiveTextureARB	(GL_TEXTURE3_ARB);
			glEnableClientState ( GL_VERTEX_ARRAY );
			glEnableClientState ( GL_TEXTURE_COORD_ARRAY );
			glBindTexture       ( GL_TEXTURE_2D, m_BaseTexture.getGLName() );
			glVertexPointer     ( 3, GL_FLOAT, sizeof(vertex), &(m_pVertex[0].XYZ) );
			glTexCoordPointer   ( 2, GL_FLOAT, sizeof(vertex), &(m_pVertex[0].UV1) );
			glColor4f			( 1.0f,1.0f,1.0f, m_Opacity );
			glEnable            ( GL_TEXTURE_2D );
			glMatrixMode        ( GL_TEXTURE );
			glPushMatrix        ();
			glLoadIdentity      ();
			glTranslatef        ( BaseDriftX, BaseDriftY, 0.0f );[/b]

	// MM: Let's cull backfaces.

That's where I put it. Hope that helps. Also check the bumpmapped interior thread, if you already haven't I did post (hopefully) a little help to you and Michael over there on that problem.

Good Luck!
- Alan
#51
05/30/2006 (12:29 pm)
@Orion Elenzil
I followed there methods to fix the bug, but still, same error.
Can someone upload a resource of a working version of the water upgrade. for 1.4
#52
05/30/2006 (12:36 pm)
I havent looked at this resouce yet, but using this resouce as a starter how hard would it be to add shaders to all renderable items instead of just water?
#53
05/30/2006 (12:51 pm)
Okay, i got past the error, by putting this dglSetCanonicalState(); below line 703 in waterblock.cc.

But now the water is all screwed up.

http://e2g.50webs.com/error.jpg

*edit
doh, like everyone else, i didnt realize that you had to set the normal map texture in the editor. thanks guys for all your help
Page«First 1 2 3 Next»