Game Development Community

Mirrors used as relfective water?

by arteria3d · in Torque Game Engine · 12/20/2004 (4:03 pm) · 26 replies

I notice in the TGE demo - that there is a mirror on the wall. Can we scale these and use them for reflective water?


Steve

About the author

Owner of uk based Ltd company ArteriaMediaLtd. with a trading name of Arteria3d Website;arteria3d.com

Page «Previous 1 2
#2
12/20/2004 (8:05 pm)
Not really. TSE has support for reflective water, though.
#3
12/20/2004 (8:44 pm)
Someone made reflective water with the same method the mirrors use to reflect. You could try to do the same.
#4
12/21/2004 (5:16 am)
The guys over that are making the poacher game did a good job with it. you can find the linkhere

Just keep out of the flame war if you can
#5
12/21/2004 (5:22 am)
Hi that link takes me to gareg games homepage - i have typed in Poacher - but doesnt come up with anything?
#6
12/21/2004 (5:17 pm)
He's missing a question mark... www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6757 is what you want.
#7
12/28/2004 (6:24 am)
Thanks been.
Umm, I did that on purpose 'cause the front page is, um, awsome

Yeah thats it
#8
12/28/2004 (7:41 am)
I did this with just some minor modifications to stock 1.3. Just dropped a giant map with a mirror under the water and scaled it.

There were a couple of problems:

1. the "are you in water" check would cause the system to act like it was in water if you were inside the *reflected* water block. This was an easy C++ fix. (I can post the changes later tonight, if you want).

2. Very occasionally, the reflected map would disappear. I believe this was an error with the visibility code (terrain occlusion, or something else?) I didn't bother fixing this, but I'm still looking into it.

The results were very good - looked nice, especially with moving water over the top of the reflection. (I can upload a jpg if someone is interested).

The frame rate (as expected) was cut almost in half.
#9
12/28/2004 (7:43 am)
Thanks Jmac - please do post the fix and pic!! Looiking forward to it

If it kills the frame rate, might be good to use it for small features, like small ponds etc, just to add that extra bit of eye candy

Cant wait!!!

Steve
#10
12/28/2004 (4:13 pm)
Ok - here is the pic. I was using the screenshot to demonstrate a sorting error, so there is a red arrow pointing at the tree, but the pic still shows the reflective water:

www.metalearth.com/mirrorwater.jpg
#11
12/28/2004 (4:15 pm)
Wow that is cool Jmac. Can u please explain how u got this to work. In the TGE DEMO, i tried to siimply lay the mirror flat thats in the hut, put it outside on the terrain and scale it, but it never reflected anything.

I note, u mentioned there are some alterations to make. Can u please explain..

Much apreciated

Steve
#12
12/28/2004 (4:28 pm)
The changes are as follows (it's kind of hackish...)

in the file MirrorSubObject.cc add:

int gInMirror = 0;

after the includes.

and in the same file, in the function MirrorSubObject::openPortal, add this as the first line of the function:

gInMirror ++;

also in the same file, in the function MirrorSubObject::closePortal, add this as the last line of the function:

gInMirror --;


in fluidrender.cc add this after the includes

extern int gInMirror;


in the function fluid::Render

find this line:

RunQuadTree( EyeSubmerged );


and replace it with this block of code:

if(gInMirror)
{
bool bt=false;
RunQuadTree( bt );
}
else
{
RunQuadTree( EyeSubmerged );
}
#13
12/28/2004 (4:29 pm)
Thankyou! Cant wait to try it out in a mo

Steve
#14
12/28/2004 (4:32 pm)
Stevie - I made a new mirror, that was 2048x2048 in size, so it wouldn't have to scale it so much. While you're doing it, you'll probably want to set the flags on the map to turn off collision boxes (so you can go under the water, and not walk on it) - I don't remember what they are, but it's been posted on here before. Then just Put the mirror under the water, make sure the "reflective" side is up, and then adjust the water transparency so it shows through.
#15
12/28/2004 (4:34 pm)
Thanks again. Are u using this in your games at the moment?

I am surprised that this has never been added to torque as a main feature.
#16
12/28/2004 (4:40 pm)
No, not at the moment. I'm thinking about adding it though. I really did it just to see if it would work. There is one other problem - the mirror doesn't get lit, so your guy can turn completely dark if you step on it (not sure if that only happens if in the lighting pack or not).

This is actually a problem I need to fix anyway, because bad shading can happen when you step on any map (for example, running across a dock can give your character a strobe light like effect, because it alternately lights from the map and the terrain below it (when you step over a hole) I was thinking to add a parameter to the map itself "light character" and if it's set to 0, I wouldn ignore the map in the lighting check.
#17
12/28/2004 (4:55 pm)
JMac,

Awesome! I was thinking of how to make that reflections in the water, and here it is. I would love to see this.
Does the reflected images distort with the waves? (I have to ask before trying it myself ;-) )
#18
12/28/2004 (6:06 pm)
No, it doesn't distort. But the moving texture on the water gives a nice effect anyway.
#19
12/28/2004 (7:06 pm)
Can anyone post their performance hit on this one thankyou.
#20
12/29/2004 (3:54 am)
I got the code working - and i am using the mirror from the torque demo. When i try to scale it, the reflection stops apearing on the mirror. is this cos i am trying to scale it? and should i simply load it into quark and scale it there for it to work?

Steve
Page «Previous 1 2