Game Development Community

dev|Pro Game Development Curriculum

CG Dynamic Gamma & Water Upgrade

by Paul Jan · 07/11/2006 (12:43 pm) · 171 comments

Download Code File

I've merged the code files with the sample files because I found the gui was required, and with other changes goes over the 100k limit on uploads - the full file can be downloaded here:
dynamic_gamma.zip

Update (2006/10/29): Torque 1.5 version code here:
Update (2006/11/23): Some more bug fixes added.... dynamic_gamma-1_5.zip
I'll leave the old one up for folks who aren't moving to Torque 1.5. I haven't had the chance to test it as well as I'd like, so let me know if its not working right!


Before/After:
img66.imageshack.us/img66/43/drl1none5jc.th.jpgimg91.imageshack.us/img91/9994/drl13ij.th.jpg

Outdoor Before/After
img114.imageshack.us/img114/8752/drl3none8at.th.jpgimg89.imageshack.us/img89/9531/drl32nn.th.jpg

Night Before/After
img380.imageshack.us/img380/1152/drl5none7iw.th.jpgimg130.imageshack.us/img130/5092/drl53lc.th.jpg

To be honest, the code is a cobbled mess in some places. Still framerate is pretty good, and I've tested it on ATI (radeon 9800) and NV ( 6800 GS) platforms.

It should pretty much be unzip, copy into TLK & recompile. You will still need to install the Nvidia CG libraries as well.

Previous resources and credit where credit is due:

CG Water (Manoel Neto) has not changed from the original resource (adjusted to make DRL work)
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10357

+ Sky::render fix by David Laurie

CG Dynamic Gamma is similar in effect to the DRL 2.0 resource (Alex "Delerium" Scarborough)
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10232
using CG shaders increases performance.

It also takes parts from 5.10 Game Programming Gems 4 "Dynamic Gamma Using Sampled Scene Luminance", and VERC "Real time TRON 2.0" collective.valve-erc.com/index.php?go=tron1

edit (Aug 11, 2006) Fixed bloom-crippling bug.
#81
11/01/2006 (7:31 am)
well i tried it on windows last night, the newest package that paul gave out, it works great
looks fantastic

i havent tried it yet on linux.. i sure hope it works
i also noticed i get the same error about invalid parameter something in the console on windows too, but it works anyway...

can any of you think of any reason why it wouldnt work the same on linux? on the same machine?
#82
11/02/2006 (8:58 am)
well i tried the newest version on linux, which does work for me, on the same machine in windows

soit works in windows
but not on linux, no errors, no crashes, same console log, but no water or lighting effects..

i tested the cg tutorial examples they all work fine for me on linux..

not really sure where to go from here..
#83
11/02/2006 (9:09 am)
What Linux Distro bud? Newest version of Linux means absolutely nothing, the distro such as Fedora, Suse, Ubuntu etc and the version name or number are whats important.
#84
11/02/2006 (11:16 am)
no i mean the newest version of torque, on linux (torque 1.5)

im on ubuntu 6.06
and ive used cg version 1.4.1 and 1.5
#85
11/03/2006 (1:40 pm)
Does the new Cg 1.5 work with this or not?? i have it and tried to compile... but got about 6000 + errors...
i have no idea what could be the cause though...


Regards
#86
11/03/2006 (3:14 pm)
Don't use cg 1.5
#87
11/03/2006 (4:41 pm)
@Bardur Mikladal
You really need to read the post ahead. I clearly stated Do Not use CG 1.5 Beta. because its a beta, it will have issues. Use CG 1.4.1
#88
11/03/2006 (6:19 pm)
its no longer in beta
theres a release version of 1.5
i didnt get any error messages from it on linux, but it also didnt work ;)
havent tried it on windows
#89
11/03/2006 (6:28 pm)
ohh, well none the less it doesnt work with CG 1.5
#90
11/04/2006 (7:47 am)
OK:.!! no i tried it because it was NOT beta... but ok then
Ill try Cg 1.4.1

EDIT: I have tried with Cg 1.4.1 now... and theres no difference... i get this:
Torque Demo - 9043 error(s), 660 warning(s)

and i have done what i understand i should do

I got the older resource (Water + DRL) to work in TGE 1.4 but... but i cant get this to work.. what so ever
I have WinMerged the needed files... i placed a cg folder in the SDK/lib directory (from cg/lib)
I placed a cg folder in ./engine (Engine/cg) and put all the files from cg/GL and CG in there...
did all the "include" - Link stuff... in VS2005

Heres a error snipped:
:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(102) : warning C4005: 'GL_ALL_ATTRIB_BITS' : macro redefinition
c:\bardurm\torque game engine\sdk\engine\platformwin32\gl_types.h(714) : see previous definition of 'GL_ALL_ATTRIB_BITS'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(117) : warning C4005: 'GL_ZERO' : macro redefinition
c:\bardurm\torque game engine\sdk\engine\platformwin32\gl_types.h(366) : see previous definition of 'GL_ZERO'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(118) : warning C4005: 'GL_ONE' : macro redefinition
c:\bardurm\torque game engine\sdk\engine\platformwin32\gl_types.h(367) : see previous definition of 'GL_ONE'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(138) : warning C4005: 'GL_TRUE' : macro redefinition
c:\bardurm\torque game engine\sdk\engine\platformwin32\gl_types.h(166) : see previous definition of 'GL_TRUE'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(139) : warning C4005: 'GL_FALSE' : macro redefinition
c:\bardurm\torque game engine\sdk\engine\platformwin32\gl_types.h(165) : see previous definition of 'GL_FALSE'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(214) : warning C4005: 'GL_NONE' : macro redefinition
c:\bardurm\torque game engine\sdk\engine\platformwin32\gl_types.h(457) : see previous definition of 'GL_NONE'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(298) : warning C4005: 'GL_NO_ERROR' : macro redefinition
c:\bardurm\torque game engine\sdk\engine\platformwin32\gl_types.h(685) : see previous definition of 'GL_NO_ERROR'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(968) : warning C4005: 'GL_CLIENT_ALL_ATTRIB_BITS' : macro redefinition
c:\bardurm\torque game engine\sdk\engine\platformwin32\gl_types.h(761) : see previous definition of 'GL_CLIENT_ALL_ATTRIB_BITS'


Does anyone have a Step-by-Step explenation how to do it... i dont understand the readme file 100%
Sorry guys to be such a bugger...

Thanks

Regards
#91
11/05/2006 (11:24 am)
get the new version for 1.5, and use it on 1.5, works fine

i think the old version is for 1.4.0 which i dont think you can even download anymore
#92
11/05/2006 (11:35 am)
I used the TGE 1.5 version of this resource.. This here: "dynamic_gamma-1_5.zip"
And i tried it with Cg 1.5... And Cg 1.4.1... and i got Exactly the same errors (or almost)

Hope there is anything that anyone of you know of, that can help me get it to work

Regards
#93
11/05/2006 (12:54 pm)
here is some more screen shots of TGE 1.5 Modified
i126.photobucket.com/albums/p117/seijisota/TGE/screenshot_007-00007.jpgi126.photobucket.com/albums/p117/seijisota/TGE/screenshot_019-00015.jpgi126.photobucket.com/albums/p117/seijisota/TGE/screenshot_007-00008.jpgi126.photobucket.com/albums/p117/seijisota/TGE/screenshot_007-00002.jpg
more:
s126.photobucket.com/albums/p117/seijisota/TGE/?sc=1&addtype=local
#94
11/05/2006 (12:56 pm)
VERY IMPORTANT
Quote:
Installing the source changes:

First you'll need the CG toolkit. You can get it here:
developer.nvidia.com/object/cg_toolkit.html

After installing it you must modify the TGE project to include the Cg/lib and Cg/include folders to the library paths and the include paths, respectively.

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

#include
By this:

#include
Otherwise you'll get loads of compile errors.
#95
11/05/2006 (3:35 pm)
T Squared... Nice pictures.. i guess you mean TGEA... or is that really TGE with the TGEA org?:.... VERY NICE!!

And the "VERY IMPORTANT" is what i have done... i HAVE changed "#include " to dlg/dgl.h
and i HAVE included those files cg/lib and cg/include/gl & cg

I used this method (By Gavin Bunney):
Note: this is from the old Water thread

-----------------------------------------------------------------------------------------------------------------------------------

This is just a simple way to remove the need to install the NVIDIA CG platform on your dev machines, through adding it to the torque directories; will assume that the NVIDIA CG is installed under C:\Program Files\NVIDIA Corporation\Cg\

Step 1: lib
-------------
1. Create a new directory under the lib directory (in your torque directory) called cg and copy all the files in C:\Program Files\NVIDIA Corporation\Cg\lib (will be 5 files) to the new directory.

2. Open up Visual Studio and open the Project Properties for the Torque Demo project (right-click in Solution Explorer, down to Properties).

3. Under Linker -> General there is a listing of Additional Library Directories. Add ../lib/cg; to the front of this edit box.


Step 2: Include Files
--------------------------
1. Create a new directory under .\engine\ (in your torque directory) called cg and copy all files in the C:\Program Files\NVIDIA Corporation\Cg\include\Cg and in C:\Program Files\NVIDIA Corporation\Cg\include\GL into the new directory. You will then have 12 files in the directory of .\engine\cg

2. Back in Visual Studio, right-click on Source Files (under the Torque Demo project) and Add a New Folder. Name this new folder cg.

3. Right-click on the new folder (cg) and goto Add Existing Item. Navigate to the .\engine\cg directory and add all the files in that directory.

-----------------------------------------------------------------------------------------------------------------------------------

Does this method still comply with this new updated resource?
If not... how should i do it??

Regards
#96
11/05/2006 (5:05 pm)
@Bardur Mikladal
Those are TGE 1.4 and 1.5 Shots. not TGEA. as you can see. the normal maps have been removed. but on image 2. you can see some fake bump maps.

The method you stated above, is not really a good way of doing that. All that will do. is spend extra time, just to increase the file size of your exe. Now. delete everything. Reinstall a CLEAN build. and toss in Paul's file into the project. and do the following steps.

Okay. lets presume you are using VS2005 aka vs8

1. Open Torque SDK.sln
2. Tools -> Options
3. Break down "Projects and Solutions" -> VC++ Directories
4. You will see a drop down menu that says "Executable Files"
5. Drop it down, go to includes. and type in "C:\Program Files\NVIDIA Corporation\Cg\include"
6. Drop it down, go to libary and type in "C:\Program Files\NVIDIA Corporation\Cg\lib"
7. Hit okay, and compile

Use this method to link any API.

BTW. i hope this was a typo "dlg/dgl.h" because it's "dgl/dgl.h"
#97
11/06/2006 (12:47 am)
hehe.... thought it was TGE... but that is utterly sweet!

And yes it was a typo... ;)

Thanks for that info!... i have been kinda ... slow on how to include files and all that... i know how to include.. but not what and where... but this explains it all!..

THANKS

Regards
#98
11/06/2006 (11:44 am)
Hi

errors are forever:

Well i did every thing this time... execpt one thing that im unsure about..
And i STILL get those errors (I use VS 2005)
First i did what you told me about including... all fine there.. i added all the scripts provided and files
and then tried to compile... but yeah i still get those errors
And one more thing... when you say "then throw paul's FILE in there" i asume you mean the zip.. or the Content of the zip file or is it here im doing it wrong?

This is something from the readme that i dont get (i have tried to searched and all that... but cant find these files and what to do with them):
_______________________________________________________________
Now do a visual merge of your codebase with the ones from the archive!!!! ??

(The ones in the archive are taken from 8/24 HEAD)
dgl\materialPropertyMap.cc
dgl\materialPropertyMap.h
interiors\interior.cc
interiors\interior.h
interiors\interiorInstance.cc
interiors\interiorRender.cc

When you finially get it to compile...

In your game directory (example) directory put CG\2TUfp20dot3.cg
I also have cgc.exe in that same directory
________________________________________________________

What is this last bit... i dont get it.. sorry

Thanks

Regards
#99
11/07/2006 (10:50 am)
Works great. Had a problem with CG 1.1 switched to 1.4 and voila works wonderful.
Thanks from ATOMIX Productions
#100
11/07/2006 (9:53 pm)
OK IT WORKS ON LINUX... geeeeeeeeeeeezzzzzzz
after all the different things i tried and went thru ;)

it turns out it was cause the CG directory in example was "CG" instead of "cg"
shoulda guessed it was something like that a long time ago

so incase anyone is curious, this can all work on linux, and does. there were mostly several case sensativity issues
a couple minor compiler issues (something about GBitmap::BitmapFormat::RGB needs to instead be GBitmap::RGB)

also the includes need to be changed from cg\ whatever, to cg/ (which works on windows too btw)

fantastic, thanks for the great resource :)

works with CG 1.5 on linux btw


and linking issues, the code does some bizzare stuff to dynamically link in gl calls at runtime, for linux i skipped all that and linked everything normally and it worked