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 Discussion / Reflective surfaces

Author
Message
HWT
20
Years of Service
User Offline
Joined: 1st Apr 2005
Location: Earth
Posted: 8th Apr 2005 04:24
Hi there

I was wondering , is it possible to create reflective surfaces in DBC like a mirror for instance?

If so, can some one please tell me how

Thankyou

HelloWorld Tommorrow
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 8th Apr 2005 13:27
HWT,

A reflective surface in DarkBasic can be 'faked'. Though, an actual raytraced mirror is not possible, unfortunately. There is an example in the codebase$ created by another individual programmer, which fakes a reflective surface on an airplane.

Simply, the plane model is loaded twice, the second one scaled up a bit and given an environment map as it's texture. The first has the plane's regular texture. The second model is 'ghosted' and faded a bit, and it's texture is rotated when the model is rotated.

Search for, I believe, 'chrome effect' within the codebase$.

+NanoBrain+
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 8th Apr 2005 19:18
Ooooo yeah

I saw the chrome effect, it rulez0r'd

Now, I tell ya NanoBrain, if you don't stop being so useful, you're going to end up being a *shudders* M-O-D

Mr Blanky - This Time, It's Personal
HWT
20
Years of Service
User Offline
Joined: 1st Apr 2005
Location: Earth
Posted: 8th Apr 2005 19:32 Edited at: 9th Apr 2005 06:40
Thankyou Nanobrain

EDIT: So there's no way to make a reflective surface at all?

HelloWorld Tommorrow
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 10th Apr 2005 10:54
HWT,

Correct. Only a 'faked' reflection is possible. However, I would recommend you to experiment with the methods used in the 'chrome effect' demo. They may just be satisfying enough for you. Have you taken a look at the demo, yet?

+NanoBrain+
HWT
20
Years of Service
User Offline
Joined: 1st Apr 2005
Location: Earth
Posted: 11th Apr 2005 07:59
Yes I have Nanobrain and thanks for your advice

I was thinking along the lines of a mirror. Would that be possible (in any way at all)? Maybe copy and pasting the objects only inverted

HelloWorld Tommorrow
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 11th Apr 2005 14:15 Edited at: 11th Apr 2005 14:17
HWT,

Yes, 'copying and pasting' is a do-able method. For instance, there is a mirror in the room which needs to reflect everything within it. For the static reflection of the mirror, create the room and it's static objects on one side of it, and then recreate it on the other side, as you mentioned, inverted.

For animate objects, in DarkBasic, you will need to have an inverted version of your model, in most cases. If your character is facing north ^ and the mirror is to the east >, and he kicks his left leg upwards, his mirrored image should kick up it's right leg in sync. If the character on the left side rotates counter-clockwise, the character on the right side should rotate clockwise. In code this could be accomplished by:
Then you implement the angle values into your characters' movement code.

In conclusion, it will be a bit more on your processor, due to the need to add an extra object and extra lines of code for each and every object which will be 'reflected' in the mirror. Also, you would have to build any rooms around the 'reflected' rooms, if the need to build in that area came about. Although, you do have the ability to hide the 'reflected' room and show another room in it's place, when entered into.

+NanoBrain+
Robot
20
Years of Service
User Offline
Joined: 27th May 2004
Location:
Posted: 12th Apr 2005 01:21
would it be possible to position the camera at the mirror position get the image of what it sees and then texture a plain with the image you get and move the camera back to it's previous position?

The happenings of tommorow are behind us now
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 12th Apr 2005 03:35 Edited at: 12th Apr 2005 03:38
Robot,

I'm sure it is possible to use such a method to create the reflection effect. However, frame rate would be sliced in half, possibly more, due to processing the bitmap, loading a texture and retexturing the mirror every frame. Also, it would take more than just positioning the camera at the mirror and creating a texture from it's captured bitmap. Though tough, with a bit of math and of comparing the player's position to the mirror's position and angle, and then rotating and repositioning the camera, a good effect can be achieved, in theory. As I have time, I will experiment with this topic and give any information I find notable.

+NanoBrain+
TEH_CODERER
21
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 12th Apr 2005 03:36
Yep but it is damn slow and a bit of a nuisance. In DBP it is easy as you have multiple cameras.

HWT
20
Years of Service
User Offline
Joined: 1st Apr 2005
Location: Earth
Posted: 12th Apr 2005 06:43
Thanks Nanobrain

While you're working on that method, I'll experiment with copying and flipping the objects

Good Luck!
P.S. I see that DarkGame SDK has a feature called "true reflections" - do you know if this is true with DBP also?

HelloWorld Tommorrow
Baggers
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Yonder over dem dere hills
Posted: 12th Apr 2005 07:24
Yeah us Dbpro'ers have reflection mapping, though it does tend to munch on framerate so never forget clever work arounds as they can save lots of speed !
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 12th Apr 2005 08:24 Edited at: 12th Apr 2005 08:26
Baggers,

Thank you for your input. It's good to know that DBP carries such a feature. Do you know any specifics on 'reflection mapping', as to what method it uses to create reflections, raytracing etc?

+NanoBrain+

Login to post a reply

Server time is: 2025-05-23 08:38:15
Your offset time is: 2025-05-23 08:38:15