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.

Work in Progress / Spherical Portals

Author
Message
Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 1st Apr 2010 04:08 Edited at: 1st Apr 2010 23:09
A fun thing I made.


A magical portal, yesterday.

Video

Please find project file with code, executable and media attatched as a self extracting zip file. Here is the code for quick reference:


What it is
Two spherical portals. You look into one and see out of the other. If you fly into one, you fly out of the other.

From a distance, the view through a portal is distorted. Get close and the perspective becomes flatter, such that as you pass through the portal, your view does not "jump". Also, if you see something else go through the portal, it also does not "jump", but is seen to move continuously.

Instructions
Use mouse to look, and mouseclick to fly forwards (left click) and back (right click). 1 and 2 number keys switch between two portal "versions", changing where the viewpoint in the out portal is.

(version 1 (default) makes the line of sight better approximate a straight path going through the portal. Version 2 means only a hemisphere of view is ever seen through the portal. Both versions converge as the portal is approached.)

Improvements
There are a many improvements that can be made to this. The camera resolution could be made dependent on distance from portals, and whether portals are visible. Also, very close to the portal, only the "front" camera view is seen. Much of the view seen by the 4 "sideways" portal cameras is not required at any time. For distant portals, cameras could be rendered, and vertexdata for the portal object set every few frames.

Currently all 5 portal cameras are rendered at fixed resolution, every frame, and for only the portal closest the player. Without improving this system, it would be required to make the two portals not visible in the same frame.

It would also be fun to play around with moving and rotating portals, and incorporating them into a demo with collsion, gravity etc. I've been wanting to try out 3rd party collision detection stuff, and playing more with Cartography Shop so might give this a bash.

Models
Models were made in Cartography Shop. I used CSG with convex objects (it advises you don't ever do this!) and made a cool mess.

Anyway I hope someone finds this useful or interesting. Please make something with it if you feel so inclined.

Attachments

Login to view attachments
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 1st Apr 2010 09:10 Edited at: 1st Apr 2010 09:11
Wow, the transition is really good. There were only a few times I could see a very slight jump in the perspective as I passed through a portal, and it was only in the bottom corners of the screen.

Great work, keep it up.


TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 1st Apr 2010 11:51
That's awesome!

Any chance we get to see the source?

TheComet

Dia
19
Years of Service
User Offline
Joined: 16th Jan 2005
Location:
Posted: 1st Apr 2010 16:23 Edited at: 1st Apr 2010 16:24
THAT...is pretty damned clever

as fate would have it, I just dug out the orange box a few days ago and played through Portal again for old time's sake.

For your next version, all you need to do is put a little semi transparent plane around the portals with blue and orange glow effects

p.s. the source is included in the download

This is not the Sig you are looking for....
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 1st Apr 2010 16:38
Quote: "p.s. the source is included in the download"


All I can download is an exe... Where again?

TheComet

Kryogenik
14
Years of Service
User Offline
Joined: 22nd Sep 2009
Location: Heidelberg, Germany
Posted: 1st Apr 2010 18:52
That is the coolest thing I've ever seen

Codesurge is so awesome, thanks Hyrichter.
draknir_
17
Years of Service
User Offline
Joined: 19th Oct 2006
Location: Netherlands
Posted: 1st Apr 2010 19:40
Absolutely superb work. Looks great
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 1st Apr 2010 22:03
@Dr Tank

There's a cool discussion going on here:

http://forum.thegamecreators.com/?m=forum_read&i=2

Do you think you could try and intersect the two portals to see what happens?

TheComet

JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 1st Apr 2010 22:29 Edited at: 1st Apr 2010 22:31
Quote: "Do you think you could try and intersect the two portals to see what happens?"


Are you trying to destroy the universe!?

Mr..Dr. Tank:
Ever thought of adding a time lapse with the portals? Say look through one portal, and it's actually 10s in the past. Look through the other and it's actually 10s into the future.


TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 1st Apr 2010 22:51
Quote: "Ever thought of adding a time lapse with the portals? Say look through one portal, and it's actually 10s in the past. Look through the other and it's actually 10s into the future."


Are YOU trying to destroy the universe?!

That makes it possible to meet yourself in the future or the past... And you can't know what you will be doing in the future.

TheComet

JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 1st Apr 2010 23:17
Alternate realities.


Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 1st Apr 2010 23:40
Quote: "Wow, the transition is really good. There were only a few times I could see a very slight jump in the perspective as I passed through a portal, and it was only in the bottom corners of the screen."

The transition can be made a bit nicer. I cheated a bit. To get around the problem of finite near camera range (it won't draw stuff that is too close to the camera), you go through the portal a little bit before you get to it. Hence in the code, the two slightly different portal radii:

This is a cheap fix. Better would be to "squish" the sphere a bit when you get close. You should be able to position yourself such that you can see equal halves of each side of the portal. But you can't as is.

Quote: "Any chance we get to see the source?"

I added source to the first post so you can see without downloading. The attached exe is a self extracting archive, containing a folder comprising the game executable, with dba, dbpro files and media. I should probably start using zip, rar or something.

Quote: "as fate would have it, I just dug out the orange box a few days ago and played through Portal again for old time's sake.

For your next version, all you need to do is put a little semi transparent plane around the portals with blue and orange glow effects "

Portal is a really cool game. I probably wouldn't have thought to do this without playing that. I pondered doing some portal portals, but without cheating (like portals at the end of long corridors), I can't see how i'd do it in DBP. You can't AFAIK move the centre of perspective. I might have a play with the zwrite, read etc commands and see what tricks can be done. Maybe it's possible. Don't know. I might try some flashy stuff to go around the portal spheres. Electrical effect, wobbly water or something.

Quote: "That is the coolest thing I've ever seen "

Quote: "Absolutely superb work. Looks great "

Well obviously I must rule. Seriously thanks a lot guys. It's nice to hear such nice things.

Quote: "Do you think you could try and intersect the two portals to see what happens?"

Hmm. Not sure. With these portals, you can't really do it, or the topography remains the same. However, because the space "in" these portals is nothing, you could move them together and basically they'd just "seal up", to be a single sphere you jump from the surface to the opposite side, and the topography for that is different. That's what would happen in this engine if you just put the two portals in the same spot.

With the Valve's Portal portals, I think even if you tried to put one in sideways, you'd see it going through itself, preventing from you putting it in.

Quote: "
Ever thought of adding a time lapse with the portals? Say look through one portal, and it's actually 10s in the past. Look through the other and it's actually 10s into the future."

um..

Quote: "That makes it possible to meet yourself in the future or the past... And you can't know what you will be doing in the future."


This. The game engine can't know what you're going to do before you do it. However, if you had some kind of maximum speed of information transfer (like the speed of light), you could do that i think. I'd like to try making something with relativity, speed of light etc! But not today.

Actually with this demo it wouldn't be too hard to do, seeing as you're the only thing in the world that doesn't do anything that isn't predetermined. You wouldn't need to do anything fancy. Could be a fun thing to add.

Also, maybe there are other fun ways around this. Games don't have to be realistic. I believe other games have played with the whole time travel thing. Braid? Not played that yet, but hear good things.

Anyway glad people like this. Want to work more on it, but am working the next few days. Want to play more with CShop, make some distinct levels. Then I can have ambient sounds for each and then they can be emmitted from the portal. Nice. Plenty of other things to try, but ideas are welcome.

Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 1st Apr 2010 23:44
Quote: "Alternate realities. "

Now that's a nice idea! The same thing but different. Like Silent Hill, or a "fake" time machine (in which it's not possible to go back in time then "wait" until you're back in the future).

Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 5th Apr 2010 19:19 Edited at: 6th Apr 2010 04:20
Have since fixed the problem where you "jump" though the portal. Now you can get pretty much exactly on the portal, and see half of each world. Makes the wobbly texture mapping problem more apparent though. Maybe I can improve it.

Realised I have made a mistake! When you travel through the portal, you should roll by 180 degrees so that every part of your "body" will move to the "opposite" side of the sphere. Have now fixed! Used EZrotate for this. Needed to go beyond using simple FPS style rotation and elevation. Now uses freeflight, but with added "auto levelling", which is pretty cool. Gets around FPS wierd controls when looking nearly straight up or down too.

New Video

Now the game is kind of wierd in that when you fly into a portal from the side, the roll means you come out upside down! Then the auto leveling rolls you the right way up. Pretty fun. I can turn one portal upside down to kind of fix this.

Next to make better levels in CShop and learning to use Sparky's collision DLL. Wish I had done so earlier. Seems to be really good.

JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 6th Apr 2010 15:44
I actually like the spin when you come through a portal. The transitions look a lot better and I couldn't see any wobbly texture, but that might be the low resolution video.

Also like how you have two different worlds now. Very cool. Now you just need to combine this with your hyperspehre for some insanity.


Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 7th Apr 2010 03:30 Edited at: 7th Apr 2010 03:32
Quote: "The transitions look a lot better and I couldn't see any wobbly texture, but that might be the low resolution video."

Trust me, the wobbly textures are really apparent when you get close to the sphere. They are mainly due to how DirectX interpolates textures across polygons. There are a few ways within DB that I can improve this, but it will still be there.

For whatever reason, I've decided the next thing i'm going to be doing is learning shaders. Have made a bit of headway. It seems I could do the portal with a shader and avoid distortion completely.

Not going to be quick or easy, but there are loads of things I could use shaders for that I've wanted to do in DBP before, but haven't managed. W fogging. Infinite lights. Normal mapping. Diffuse light maps. Overexposure. I've dipped my toes into the water and shaders do seem hard, but I feel I will be able to do it.

Quote: "Also like how you have two different worlds now. Very cool. Now you just need to combine this with your hypersphere for some insanity."

That would be sweet. So many things i'd like to tie together, but it would take forever. When my skills are better I can have a go at making my magnum opus.

KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 7th Apr 2010 20:37
Very nice effect. Loved both of the videos.

Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 9th Apr 2010 04:45
Thanks dude. You're too kind.

I haven't abandoned this. Still reading about shaders. From looking at the examples in the "Ultimate Shader Pack" - especially projective texturing, cube mapping, it seems likely i can make this work much better with a shader. If so, I will also be able to make a much smoother "spherical camera" like I posted a while ago. Which is cool.

Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 20th Apr 2010 03:50
Have made a shader version. On the plus side, it looks much smoother, and there is no vertex manipulation in DBP.

However, it's not terribly fast. Also problem in that it appears you can't easily make the central image higher resolution than the 4 around the edge.

I imagine a best solution might be a hybrid of the 2 methods, with 5 objects with separate textures (as in the non shader version), but with shaders. That way you get the bespoke texture mapping, but without having to use cube maps which may be the source of the slowness. I probably won't bother because there's not much point and i have other stuff to do!

I used a shader "trick" with a dummy 0th texture to get dynamic cubemapping to work. Perhaps i'm being stupid and it's not really required. I'll ask on the shader thread.

Please find attached archive file including source, exe compiled by me, with media and shader. For quick reference here's the code and shader:

code:


shader:


Attachments

Login to view attachments
Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 8th May 2010 05:02
I made an updated version a while ago and forgot to post here. Pretty much exactly the same, but figured out how to specify the right textures from the shader and avoid the nasty workaround from the last version. Also the line "normalize(Out.Pos);" in the shader does nothing since it should return a variable! Thanks to Green Gandalf in the ultimate shader thread for alerting me to my noobality.

Quick reference:

code:


shader:


I'm drawing a line under this project now.

____________________________________________________________________

Attachments

Login to view attachments
Bizar Guy
19
Years of Service
User Offline
Joined: 20th Apr 2005
Location: Bostonland
Posted: 8th May 2010 23:47
A line?

Like taking a break?

anyways, was pretty cool. Would be nice to see in a game sometime.

Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 9th May 2010 03:45
I mean i'm basically done with this project, at least for the time being. I could refine the demo, but it would be largely aimless and a waste of time. Got so many other demos, games on my list of stuff to make and stuff to learn, and only so many hours in the day. Currently my coding time is spent on learning shaders. Am playing with terrain at the mo.

I'd like to see this in a game someday too but I'm unlikely to get around to that soon. Would be awesome if someone reads this and does something with it. If anyone feels so inclined, I'd be happy to spend some time providing explanations, diagrams, better comments, or helping to port/debug etc.

Now you mention it a break would be nice too. I should really be applying for jobs.
Guyra
18
Years of Service
User Offline
Joined: 10th Nov 2005
Location: Norway
Posted: 20th Jun 2010 11:49
This is seriously one of the most awesome things I've seen on these forum! Great work!
Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 15th Jul 2010 16:45
Wow thanks very much.
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 18th Jul 2010 06:49 Edited at: 18th Jul 2010 06:50
Hey Tank, trying to send you an email but can't find it. :p So can you drop me one, like to send you something.

joshlmooney(at)gmail.com

Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 18th Jul 2010 20:54
Exciting! I sent you an email.

I took a break for a bit but now coding again. Currently coding planar portals a la Portal. Going pretty well. Unoptimised version should be done soon and I will post a Work In Progress.

Login to post a reply

Server time is: 2024-04-26 12:20:52
Your offset time is: 2024-04-26 12:20:52