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 / Plane Portals

Author
Message
Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 22nd Jul 2010 02:39 Edited at: 25th Aug 2010 14:49
Latest Version

========================================================
ORIGINAL POST
========================================================

Flat portals made famous by the game "Portal".



YOUTUBE VIDEO

This version has two linked portals that can be moved and rotated, and you can fly into one and come out of the other.

I append my project folder. This contains an exe as well as the code and media.

Currently this requires the EZRotate dll to compile, but hopefully everybody should be able to try the exe.

Next up I want to put portals within portals, requiring more camera views to be rendered per frame. Currently the 2 extra cameras have the same resolution as the final screen. Rendering a large number of views like this through a sequence of portals would mean very low framerates.

I have adapted DmitryK's code to be able to render a rectangular "patch" of a given camera view, and this works. Now the surprisingly hard task is to write code to find the smallest rectangle to cover a portal on screen.

I'm done with this at least for this week, but finishing it is top of my list of DBP things to do.

Attachments

Login to view attachments
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 22nd Jul 2010 03:37
Very nice! The transition when crossing the threshold is perfect. Good job.

Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 22nd Jul 2010 03:45
Thanks dude. BTW, did you get my email?
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 22nd Jul 2010 15:54
Ah yes, I'll be sending some stuff your way.

Zyronagon
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location: USA
Posted: 22nd Jul 2010 18:24
Oh man, that's AWESOME.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 23rd Jul 2010 01:34
First spherical portals, and now plane portals What's next? Cylindrical portals?

TheComet

Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 23rd Jul 2010 04:21
Quote: "Oh man, that's AWESOME. "

Thanks very much.

Quote: "First spherical portals, and now plane portals What's next? Cylindrical portals?"

That could work. Oh man. I have enough unfinished projects as it is.
C0wbox
18
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 23rd Jul 2010 04:24 Edited at: 23rd Jul 2010 04:38
Make squarular portals !!!! Or cuboidular portals xD

Or just make a universal portal engine that takes all polygons on an object and creates portals out of them.

That way you could have a planar input portal, and a cuboid output portal, and anything you put in, would come out 6 times in varying sizes depending on the face sizes. !!!!!!1



...or you could just, not do that because that would be really silly and as useless as the sausage maker you can buy for PlayDoh

Attachments

Login to view attachments
Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 23rd Jul 2010 04:38 Edited at: 23rd Jul 2010 04:42
LOL. That's food for thought. I quite like the idea of a multiplying portal. Not sure what would happen if you went the other way. If you went through and became six of you, would the others be AI controlled?

I was pondering making the portal sizes different, so going one way would make you bigger, the other smaller. Also a mirror inversion portal where you could go through it and the world would be left handed and the writing would be backwards.

Hopefully someone will be able to take my code and build on it. I just want to keep this relatively simple and finish it, because my time on Earth is finite and I have games about spaceships and tanks and stuff to make.

I imagine Playdoh sausages taste like balls.

edit: Impressive drawing skills! Are the faces different aspect ratios? The player could go in, and fat and thin mutant copies could come out.
C0wbox
18
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 23rd Jul 2010 05:08
! (That was drawn in Paint first and just touched up with some feathered-edge gradients in GIMP... xD)

Yeah each instance of a cloned object would be orientated according to any face and scaled to the ratio of input-face:output-face.

But I mean, come on, you can't honestly see this being conceivable, even in a portal game... - Imagine how you'd get an object to go from the cuboid to the plane? Or from a cuboid to a sphere or something... xD

This is where the idea breaks down and just becomes another one of those "Yeh we could do that but not this part" ideas.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 23rd Jul 2010 13:04
Portals of different sizes could work though, even if a multiplying portal wouldn't

It could be that for some areas you need to be very small, and for some you need to be large so you have to go through the right portals to get to the correct size

[b]
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 23rd Jul 2010 13:11
The way I see it, different sized portals are physically impossible, because they are an intersection. They have to be the same size. But the virtual world is different, so there it would be possible

As to the multiplying portal... I have no idea what would come out if you reversed it

TheComet

Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 23rd Jul 2010 23:00
Quote: "Portals of different sizes could work though, even if a multiplying portal wouldn't

It could be that for some areas you need to be very small, and for some you need to be large so you have to go through the right portals to get to the correct size"

Yeah. You might need to be large to jump over a gap or something. The mirror inversion portal would be useful if you had a keycard or a key to use in a lock.

Quote: "The way I see it, different sized portals are physically impossible, because they are an intersection. They have to be the same size. But the virtual world is different, so there it would be possible "

Like Diggsey says, I don't think there's anything wrong with having differently sized portals from a game physics perspective. Of course in real like they'd violate laws of nature:for example you can't change the size of atoms, but this is portals we're talking about.

I think if someone wanted to do a game with some originalish Portal gimmicks, Alice in PortalLand with mirror (Looking Glass) portals and size changing (Eat Me and Drink Me) portals might be a good idea.

Quote: "As to the multiplying portal... I have no idea what would come out if you reversed it"

Yeah dude I'm clueless about that one as well.
Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 29th Jul 2010 23:12
Stuck with a fairly big problem. Spent ages trying to debug. Seems problem is that set camera clip doesn't work right on objects rendered with a shader! Upon searching the forum, it seems that a number of other people have had this problem, but no solutions are given.

The only workaround I can see is rendering EVERYTHING in my world via a shader. Pretty cruddy when combined with how if you have objects share a shader, they have to all use the same technique and constants, and if you load a separate identical shader for every object you use up load of memory and it takes all day to load. AAAARRGH. Just wanted to vent.

I got portals in my portals though. Tempted to just chuck it all in.
Jeff032
17
Years of Service
User Offline
Joined: 13th Aug 2007
Location:
Posted: 30th Jul 2010 00:41
I believe that set camera clip uses part of the fixed function pipeline, which would explain why it doesn't work with shaders.

For the objects that do use shaders, you should be able to implement your own clipping.

So you wouldn't need to render everything with a shader.

Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 30th Jul 2010 01:31 Edited at: 30th Jul 2010 01:55
Is it possible to turn off clipping for the shader object when the camera clip is on for the rest of the scene?

The trouble is that I do need to clip the rest of the scene (currently not drawn with shaders). I use set camera clip, and this screws up the shader objects.
OldPMan
TGC Store Seller
16
Years of Service
User Offline
Joined: 10th Aug 2008
Location:
Posted: 30th Jul 2010 01:41
pancake. cool stuff portals. I like it. good job.

.....already beside..... for all
C0wbox
18
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 30th Jul 2010 03:56
Lol, what the hell?

Quote: "pancake."

Am I missing something?

Shadowtroid
14
Years of Service
User Offline
Joined: 23rd Dec 2009
Location: nope
Posted: 30th Jul 2010 17:02 Edited at: 30th Jul 2010 17:02
Have you ever heard of MSPaint Adventures?

They have a story there called Problem Sleuth...Anyway, there's a lot of puzzle-solving via portals of different aspect rations and sizes, and all that stuff.

Maybe for the multiplying portal, it wouldn't be a multiplying portal, but a dividing portal. Like so:



Wow that looks like crap but you get my point.

Attachments

Login to view attachments
Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 30th Jul 2010 19:44
Quote: "good job."


Thanks dude.

Quote: "Am I missing something?"

Pancakes? Sorry but the pancakes are a lie.

I like the dividing portal.

Progress report - Getting camera clip to work for shaders is easy - just change the flag from 1 to 3. Now need to make everything shaded. No big deal since I made some simple shaders earlier. Just a chore.
Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 31st Jul 2010 03:47
Whole world is now shaded. Clipping works right. Plus with the shader, it looks a little bit prettier.



Trouble now is that it's crushingly slow (framerate=9fps!!), and this is only 1 portal in another portal. The reason it's really slow is that it's rendering a full screen for each view into a portal, of which usually only a small fraction is visible.

I have a plan to fix this though. Hopefully can get that done next week.
OldPMan
TGC Store Seller
16
Years of Service
User Offline
Joined: 10th Aug 2008
Location:
Posted: 31st Jul 2010 11:43
Sorry guys, "pancake" no value, and meet, it just as an additive to the word we have in Russia as a delight. Once again I apologize if disconcerted.

.....already beside..... for all
C0wbox
18
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 31st Jul 2010 13:32
xD! That's an awesome language concept.

All languages should have random words instead of the meanings

Like the phrase to soap something instead of to wash it.
To cheese, instead of to eat.
To shoes, instead of to run/walk.

RedFlames
17
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 31st Jul 2010 20:20
Quote: "
xD! That's an awesome language concept.

All languages should have random words instead of the meanings

Like the phrase to soap something instead of to wash it.
To cheese, instead of to eat.
To shoes, instead of to run/walk.
"

Ever heard of idioms?
Although "pancake" does seem like a weird one... xD

Example from wikipedia:
Quote: "In the English expression 'to kick the bucket', a listener knowing only the meanings of 'kick' and 'bucket' would be unable to deduce the expression's true meaning: 'to die'."


I didn't know that one either... and i really hope I'm not talking b*llsh*t right now

Sooo anyways, on Topic:
The shader is really nice, i just had a little bug when using it. I'll try to replicate it, but it had to do with turning one or both portals upside down. And i had them opposite of each other, so you could run in one direction "infinitly". When the portals were close to each other, and one was upside down ( i think) you would end up at some point "outside" the portals (not in between where you should be).
Sorry if the description is kinda unclear.
Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 1st Aug 2010 01:55
Pancake means you're delighted? I'm delighted by that. Pancake!

Quote: "i just had a little bug when using it. I'll try to replicate it, but it had to do with turning one or both portals upside down. And i had them opposite of each other, so you could run in one direction "infinitly". When the portals were close to each other, and one was upside down ( i think) you would end up at some point "outside" the portals (not in between where you should be).
Sorry if the description is kinda unclear. "

Thanks for the feedback. What's happening is that it's mistakenly detecting travelling through one portal twice in successive frames. I fixed this but the version in the first post still has the bug.

You can see what's happening in the code. Travelling through a portal is detected when the player is on the opposite side to the portal than in the previous frame, and also within a square "pipe" through that portal. If portal A is "pointing" at or away from portal B, and you travel through A, ending up at B, then the next frame the program might think you should go "through" A again, which is distant. Anyway it's fixed now.

Also I've been pondering and figure that if I can suss out how to set DB's draw order, it should be possible to do a version without using shaders at all.

That can wait for later though. Next job is the optimisation I talked about earlier. When the framerate isn't horrible I'll up another demo.
OldPMan
TGC Store Seller
16
Years of Service
User Offline
Joined: 10th Aug 2008
Location:
Posted: 1st Aug 2010 02:00
yes -> I'm delighted by that. Pancake!

.....already beside..... for all
Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 5th Aug 2010 03:25 Edited at: 6th Aug 2010 03:14
Making good progress!

Have code for selecting a small box to render around portals onscreen, and can "skew" camera matrix to render only this view. Have a shader that projects this onto portal objects.

Framerate is reasonably OK. About 30fps, although this depends on overall resolution etc. Basically I think it's pretty reasonable.

Now to add series of portals within portals, with culling system, and tidy up.
Shadowtroid
14
Years of Service
User Offline
Joined: 23rd Dec 2009
Location: nope
Posted: 6th Aug 2010 14:06
Quote: "Now to add series of portals within portals, with culling system, and tidy up. "


Remember my comment on the video. If you could make it possible to just reuse part of the texture on the first and just repeat that over and over.

However, if the portals are at different angles that could make it a problem...

Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 6th Aug 2010 23:01
I remember. I think a general system (including portals at different angles) could be realised by texturing the repeated image on a series of planes, with a transparent square in the middle for the portal, then take a pic with these objects and paste it onto the deepest properly rendered portal.

However, it's a big job, and I will probably put this on the back burner after the next step, since I have a load of other stuff I want to do.
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 8th Aug 2010 07:59 Edited at: 8th Aug 2010 08:00
Really cool! Someone needs to implement "speedy thing goes in, speedy thing comes out" mechanics.

Also...
[hijack]
Dr Tank, I heard you got a doctors in physics... and I need some help on my n-body code. Can you check out my thread I posted in the Dark GDK forums and/or e-mail me at neurofuzzy(at)gmx(dot)com. I'm pretty sure the problem is that when two bodies collide, I change their velocity and position but not acceleration, but I'm not sure how to change their acceleration based on acceleration velocity and mass
[/hijack]


Is't life, I ask, is't even prudence, to bore thyself and bore thy students?
Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 9th Aug 2010 01:36 Edited at: 14th Aug 2010 05:11
Making good progress on this. Have an large number of portals within portals, and the framerate is acceptable. Now need to tidy up.

About your physics woes- I'll post my thoughts to your thread.
Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 16th Aug 2010 03:09 Edited at: 19th Aug 2010 04:00
Almost done with this. Pic shows a kind of worst case scenario for bad framerate. If you restrict the portals to not getting that close to eachother, it will never go that low anyway.



Have added visible player object. That was a pain to get working right! Have added shots that will go through the portal. Next going to add smoother movement with momentum. Then will tidy up code and post another demo.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 16th Aug 2010 13:24
Can't you add a rendering limit of the portal images?

Anyway, looks great, keep it up ^^ Do you think you can make a game of some kind out of this?

TheComet

Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 16th Aug 2010 18:13
There is a rendering limit. At the moment the limit is about 10 cameras in each portal, but in the screeny above, fewer are rendered because they're not all needed. Within this limit, the strongest factor determining the framerate is the number of pixels rendered.

The rendered images can be smaller. Currently it draws a big enough rectangle on screen to cover a sphere that encloses the portal, as this is simple to code. Imagine can improve framerate by a factor of about 2 at times, but it's not too bad as is.

A game is a lot of work. After I've finished this demo, I'll probably concentrate on some other unfinished projects, but I'll keep this in mind and note down ideas, and maybe toy with some stuff I might need, like 3rd party collision and physics, FPS controls. Also hopefully I can make the code sufficiently neat and understandable that someone else might do something with it.
Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 24th Aug 2010 20:15
Attached is new version. Improvements to original: less unnecessary rendering, portals in portals, smooth movement, shooting, preset portal setups, works with different screen ratios.

Video

Code should be tidied and better commented: it works fine now but don't feel bad if you don't understand it! I will post a "clean" version at some point.

Note that some things are calculated when they are not needed. I should go though certain parts of the code (eg part starting at 944). Will bring negligible improvement in speed.

More substantial improvements can be made to the "tightness" of the "culling" system, but at the price of simplicity. Framerate boost could be substantial in some instances, but it's fine as is.

Taking a break from this project for a while.

Attachments

Login to view attachments
zzz
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: Sweden
Posted: 25th Aug 2010 01:28
This project is so much awesome! Keep it up!

draknir_
18
Years of Service
User Offline
Joined: 19th Oct 2006
Location: Netherlands
Posted: 25th Aug 2010 05:46
Very cool! I'm looking forward to seeing your code

Login to post a reply

Server time is: 2024-11-24 13:33:45
Your offset time is: 2024-11-24 13:33:45