Previous Blog Next Blog
Prev/Next Blog
by date

Working on Implementing Glow Effect (Cg) on TGE

Working on Implementing Glow Effect (Cg) on TGE
Name:Pisal Setthawong
Date Posted:Jun 14, 2006
Rating:4.0 out of 5
Public:YES
Comments:YES
RSS Feed:GarageGames Blog feedor Subscribe with .
Profile Page:View profile page for Pisal Setthawong

Blog post
During the last few weeks, I've been working with proping up my TGE so that I could use Cg to prop up the graphical engine. I'm completely aware that TSE would potentially be a better choice if I wanted to use Shaders, but as the project I'm working on is rather crucial, I need to be sure the game could be delivered as promised. That is why I stuck with TGE and tried to do the best with what tools I had at disposal.

Let me show you the original game screenshots that I've used TGE in:


I do find the results to be pretty decent. Though not state of the art graphics, it wasn't shabby, and looked good to my early trial with a number of casual game players (relatives, friends popping by my home :P).

After presenting that to my customers, I've found the major comment is that they wanted the scene to look more surreal. After talking through it, they wanted some sort of glow effect to make the scene look unreal or like in the game scenes from heaven or hell. Though I attached lights to my player character, that light wasn't enough glow.

I had a few workarounds that I thought about doing. The major problem is that I can't implement things that require too many CPU cycles considering the huge demand at the present. The first I thought to do was to was to add particle effects to the player. That was kind of taking the focus off the point I didn't implement the glow-effect. The other is to double render the player and use different blending options to get the player glow. This method requires more rendering passes, and since the current game is extremely taxing on the CPU/memory, I've decided not to do this. I remember I used to use the DRL resource, and I liked it extremely. However as my game is already using too much CPU, I didn't think I should use it with this project. The last idea that came to mind is to use Cg to implement the glow effect. This is an ideal solution as it places less stress on the CPU as the extra processing is sent to the GPU.

On a side note, I could always simply ignore the request, but since I had time (was a few weeks ahead of schedule) I decided to try to experiment by adding Cg support to TGE.

The first part of was easy. Integrating Cg to any program is easy. There are many resources that point to that in the Internet. I myself also did write a few DirectX + Cg programs before. The next point is to write some vertex/pixel shader programs to create the glow. In this part I used to work with my own Glow effect in RenderMonkey before so that was a huge help. On a sidenote, there are also many useful resources that is useful on this topic and the one that I liked was from the following url: (collective.valve-erc.com/index.php?go=tron1). As I had some parts of this done already, the rest was for me to figure a way to merge it with TGE which seem quite a difficult task at the beginning.

During the first few days of implementing, I had a torrid time getting things right. At times, everything crashed, at times I get things opposite of what I wanted. As noted, the following picture shows alittle about some of the things gone wrong:


After a little more probing, I managed to fix a few more things, though unfortuantely I had the whole picture oversaturated instead of making it look like glowing. Also there were many rendering problems like when the scene became too saturated, the characters all disappeared! Now that is what I call bad programming on my part :P


However after a period of debugging, and going through the rendering engine TGE, things were dawning. The TGE rendering engine is rather decentralized so it takes some time to go through the different parts of the engine to find what I wanted. Anyway, after another sleepless night, programming along with watching the WorldCup, somehow I managed to get things alittle like what I wanted.


From the last pic, there is a slight glow effect with the whole scene which is basically the effect I wanted. Though the effect was created, I don't think it is adequate yet. I believe I need to tweak things comprehensively to make it look better. However, I was more preoccupied of getting things done than actually making it look good since the start, so I guess within the short period of time, that was good enough :P

Anyway, for the future plan, I think about making the Cg support tool I use a little more customizable as I would have to create 2 major themes for the game (heaven scene and hell scene) and it won't be the best of idea to hardcode everything when I need to change parameters and shader programs for every stage.

Thinking about it, I haven't been putting much thought in that... and my code is a freaking mess, much like a huge bandage wrapper attached with chewing gum to the Torque engine. Hmm... that isn't good is it?

I got to think more about it soon, but considering the Germany vs Poland match is starting soon, I guess I'll postpone that to sometime in the future :P

Recent Blog Posts
List:08/08/08 - Paddlepop the Pyrata - a Postmortem
08/23/07 - Thai Computer Game Museum calls for Developers from Thailand
03/15/07 - To Script or Not To Script
01/11/07 - A Game Down and Another Year to Go
12/01/06 - HeavenHell Project - Updates and MoreScreenShots and Random Rants
10/30/06 - Asian Game Developer Summit @ Singapore from December 9-10, 2006 and Etc.
08/07/06 - My Cg Update and Random Musings
06/14/06 - Working on Implementing Glow Effect (Cg) on TGE

Submit ResourceSubmit your own resources!

Rubes   (Jun 14, 2006 at 18:37 GMT)
I'd love to see something like this. Good luck!

Mathieu   (Jun 14, 2006 at 18:39 GMT)
Very nice .plan! From customer feedback to visual glory.

Joseph Euan   (Jun 14, 2006 at 18:42 GMT)
looks pretty sweet, but did you know theres already a game called Heaven and Hell?

Pisal Setthawong   (Jun 14, 2006 at 18:52 GMT)
@ Joseph
Thanks for the tip.

Actually the game is supposed to be called "Tribuum Kran PajonPai Daeng Narong La Sawang" which is like translated to "The Three Kingdoms and the Adventure Through Heaven and Hell". I have to admit that I have trouble calling that name (or I might even have got the name wrong O_o), that our team just used the nick of it as Heaven and Hell (or Hell and Heaven). To make it even more brief, called it HELL, but that is only a joke - the project isn't that bad and doing something that deals with Good Karma is good for a change :P

DavidRM   (Jun 14, 2006 at 19:22 GMT)
I like it. The glow really adds to the visual theme.

-David

Pisal Setthawong   (Jun 14, 2006 at 20:01 GMT)
I happen to test my modifications with the original StrongHold example.

Below is the original StrongHold with the normal TGE:


Attached next is the TGE with my own Glow Effects appended on:


Hmm... I'm getting color blind O_o
Edited on Jun 14, 2006 20:08 GMT

Michael \"Evic\" Wales   (Jun 14, 2006 at 20:20 GMT)
I thought the first screenshot looked really great - reminds of me of Banjo Kazooie and other worlds that Rare develops.

The glow effect has definitely stepped it up a notch, although I do think it could use some more teaking. Still looks a bit oversaturated to me - almost to bright, I want to squint :D

Neo Binedell   (Jun 14, 2006 at 20:36 GMT)
Heh, looks like the bloom in the DRL 2.0 resource...

Nicely done...

~neo

Alexander "taualex" Gaevoy   (Jun 14, 2006 at 21:14 GMT)   Resource Rating: 5
Great work, Pisal!

It would be great if you find time to write a small tutorial how to ad such things to the TGE rendering pipeline, or even release it as a pack - I'm willing to pay for one. ;)

Aarone   (Jun 14, 2006 at 21:24 GMT)
Yes, a resource (similar to the Cg water resource) would be very nice. I'm loving those screenshots. :)

Paul Jan   (Jun 14, 2006 at 23:18 GMT)
Grin - been working on working in the cg sample from that url for a while now, and good lord its messy. Their blending step initializes 2 pipelines, but their cg code calls for 4. I mostly have it working except the blur step has a tendency to explode into sudden bursts of pure color - I think its because it tries to sample pixels outside the texture area.

What I really want to work in is this: http://developer.nvidia.com/object/convolution_filters.html
The demo is nvidia hardware only, so thats gotta get knocked out of it, but after that, it could replace DRL 2.0 easily.

Edward F. Maurina III   (Jun 14, 2006 at 23:36 GMT)
Nice. I found the images inspirational. That is, as I looked at the last image (in original post), your textures with the little squigly lines started me thinking about dynamic texturing effects and how it would be cool to associate them with an enemy or NPC. Then as that enemy/NPC approached you would see this effect start up in the terrain. Sort of like an advance warning system.

I know you're focussing on glow, but this is where my brain started to go. Keep up the good work.

Hall Of Worlds - For Gamers
EdM|GPGT


PS - I also noticed the counter from the GPGT lesson kit. I'm glad to see that stuff getting used. :)
Edited on Jun 14, 2006 23:37 GMT

Paul Jan   (Jun 15, 2006 at 00:21 GMT)
One note about glow - the very excellent tron implementation uses an alpha channel to render only the glow sources.

http://www.gamasutra.com/features/20040526/james_pfv.htm

Alex Scarborough   (Jun 15, 2006 at 02:13 GMT)
@Pisal: Starter.fps will look better with glow if you disable the TLK overbright.

@Paul: Making the DRL bloom (and DRL in general really) use shaders massively improves FPS. Try it out. It makes a fun weekend project. As for using alpha channel as a mask for a glow shader, keep in mind that on nVidia cards you must specifically request destination alpha, and you'll need to do a bit of tweaking in winWindow.cc to prevent Torque from overriding your pixel format with destination alpha.

Paul Jan   (Jun 15, 2006 at 03:32 GMT)
I finally got my version of the glow effect working. Right now with a quartersize buffer its a 25% fps hit.

For some reason the half-life version is using vertexs to perform the blur step, and I could only get texcoord0 to work, not texcoord1+. So I scrapped their blur cg code and built my own.

Also with all the cg work that people are doing, there needs to be a generic resource for loading cg - theres a lot of copy, paste and rename going on.


With glow


Without glow
Edited on Jun 15, 2006 03:39 GMT

Aun Arinyasak   (Jun 15, 2006 at 07:50 GMT)
Great work ! ! !

Hope to see more of your game Krub :)

Pisal Setthawong   (Jun 15, 2006 at 09:13 GMT)
@Alexander "taualex" Gaevoy
The resource isn't complete at the moment. Its still in the early beta stages and is rather dangerous to implement considering that I haven't tested it in thouroughly. Anyway once it is done and after some little more strenous testing, I plan to release the resource soon.

@ Aaron Ellis
I believe the Water resource for TGE is done with Cg also if I'm not mistaken. If I'm not mistaken there is a person who has integrated the Water Resource with DRL 2.0 resource that Alex "Delerium" Scarborough worked with and that could be a winning combo for your project :)

@Paul Jan
Thanks for the tip on Cg! Regarding Cg resources, haven't put much thought in it. I was just thinking about proping up my engine and figuring how to make it easier for me customize things on my project.

@Edward F. Maurina III
The book was great reference guide to Torque! Tells everyone here to buy a copy!
p.s. I was hoping someday for an autographed copy of the Game Programmer's Guide to Torque :P

@ Alex "Delerium" Scarborough
Thanks for the tip! I haven't thought much about the TLK, will make sure to go through it :)
Edited on Jun 15, 2006 09:28 GMT

Alexander "taualex" Gaevoy   (Jun 15, 2006 at 21:18 GMT)   Resource Rating: 5
@Pisal: Thanks.


@ Alex "Delerium" Scarborough
Is DRL now shader driven? I wonder if it will be possible to have a shader bloom and motion blur effects?

Alex Scarborough   (Jun 15, 2006 at 23:07 GMT)
@Alexander "taualex" Gaevoy: No, DRL isn't shader driven. However, making it shader driven would drastically improve performance and open the door to a lot of cool effects.

Pisal Setthawong   (Jun 17, 2006 at 14:55 GMT)
Dear Paul Jan, I was planning to have a chat with you. I was wondering how could I contact you considering there are no public details that I can contact you? Could you email me your contact? Thanks!

You must be a member and be logged in to either append comments or rate this resource.