Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Ray Tracing. HOW??????????

Author
Message
Armeggadon
23
Years of Service
User Offline
Joined: 10th Apr 2003
Location: United States
Posted: 8th May 2003 04:07 Edited at: 8th May 2003 04:08
i'm trying to make a mirror for use in a game i want to make. but how do i do ray tracing(if you dont know what that is it's the reflection off the mirror) the only thing i can do is give the mirror a picture and when you move within x range of the mirror the picture on the mirror moves but this doesn't always work because no matter how far away from the mirror you are its the same image. and it doesn't even look real(in a real mirror the angle of the wall in the mirror would change becasue the angle of the view changes) if someone knows how to do this plz tell me. thx.

Current Status: learning MORE about dbpro
I consider myself: newb
Richard Davey
Retired Moderator
24
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 8th May 2003 04:18
To be honest, you're going to have to fake this effect. There is a good reason why commercial games don't have "ray tracing" in them - it's too expensive! (processor wise, not $$$).

It'll take some research, but one method would be to have 2 cameras and a plain object. The plain is your "mirror", the second camera is directly infront of it looking out into the scene (play with the FOV to get the right shape) and you grab what this camera sees and texture the plain with the resulting image. Voila - a pretty decent camera effect.

Failing that - the reflection command in DBPro will work, although it's a primitive stencil buffer effect, it'll give the result you want. Very CPU heavy though.

Cheers,

Rich

"Gentlemen, we are about to short-circuit the Universe!"
andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 8th May 2003 04:20 Edited at: 8th May 2003 04:20
You could have a camera inside the mirror and then texture the mirror with that image.

[Edit]
Oh well, Rich replied first.

"All programmers are playwrites and all computers are lousy actors" -Anon
APEXnow
Retired Moderator
23
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 8th May 2003 04:25 Edited at: 8th May 2003 04:26
The camera idea is potentially feasible but you would have to consider the distance and angle of the player from the mirror to aim the camera in the opposite direction, and the texture would need to be flipped horizontally to achieve a realistic effect. The other issue is that if the camera goes behind the mirror, you'll get the mirror object in the way.

"Man who looses key to woman's appartment...... He get no nookie" - A wise chinese man.
APEXnow
Retired Moderator
23
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 8th May 2003 04:28
I thought about using a similar technique for giving the illusion of portals, like the ones you see in Unreal and other Portal based engines.

"Man who looses key to woman's appartment...... He get no nookie" - A wise chinese man.
Armeggadon
23
Years of Service
User Offline
Joined: 10th Apr 2003
Location: United States
Posted: 8th May 2003 05:08
i hadn't thought of the camera idea. thx for the idea and i'll try it out.

Current Status: learning MORE about dbpro
I consider myself: newb
Jason Leigh
23
Years of Service
User Offline
Joined: 7th May 2003
Location: United States
Posted: 8th May 2003 08:54
One classic way of doing reflections is to clone the geometry to the otherside of the mirror. Ie you draw 2 copies of the object, one in front of the mirror and one behind. The one behind would be a version that is scaled by -1 in the direction perpendicular to the mirror. The mirror is then simply implemented as a semi-transparent polygon with a specular material to give the illusion of glass.

Note this trick only works if you can't actually look around to the back of the mirror. For that you will have to implement 3D clipping around the mirror. But if you have a mirror that's mounted on a wall, or a puddle of water on the ground, then this technique will work.
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 8th May 2003 13:54 Edited at: 8th May 2003 13:55
if you want to achieve this effect realtime you're gonna have to wait for patch5 and the DirectX9 extentions ... all i'm gonna say
(and yes this is because as Rich said it is too expensive processing wise without them for realtime)

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Armeggadon
23
Years of Service
User Offline
Joined: 10th Apr 2003
Location: United States
Posted: 9th May 2003 00:10
ok thx for the help ill try your suggestions. the camera thing seems to work as long as you dont closely examine the mirror(its not perfect but its pretty good)

Current Status: learning MORE about dbpro
I consider myself: newb

Login to post a reply

Server time is: 2026-07-11 12:02:42
Your offset time is: 2026-07-11 12:02:42