Hello everyone! Due to popular demand finally I’m releasing project sources of the Unity3D Indie Portal Effect. In two words, the technique is based on using multiple cameras (3 in this case) and then selectively drawing just Z-values of the portal gates in the 1st pass so that they leave opening in the rest of geometry due to Z-test. This is followed by the 2nd and 3rd passes which clear Z-values of the portal gates and allow the scene to be drawn in the openings from 2 other cameras. The order of drawing things is managed by camera ordering and render queues ordering. On top of that there is a script positioning the 2 helper cameras appropriately relative to the portal gates and to the main camera. Walking through the portals is handled separately by the teleportation script. Currently it works only for the player but there’s been some effort to teleport rigid bodies as well. I hope you make some really cool games/demos/etc. with this, I’d like to think, smart technique. It requires no stencil, no render to texture, just plain old shaders and multiple cameras. Pretty neat, huh? I insist you let me know if you create something with this technique!!! I’m very very curious to see it put to good use!!! Giving me some credit also wouldn’t hurt 😉 Enjoy!
Binary (Win32): unity_portal_effect.zip
Project Sources: unity_portal_effect_source.zip
Dude, thank you so much for this. And thank you so much for giving it away for free. I’ll put you on my game’s credits. 🙂
No problem. Let me know when your game is released : )
Hi
I am creating a game with Unity. I want use your “Portal”-Package and I want to put your Name, how you said, in the Credits, but I doesnt find your Name on this Website. Can you tell me your name please? 🙂
Sure, it’s well hidden on the very bottom right of the page. My name is StanisÅ‚aw Adaszewski : ) Thanks in advance and all the good luck with your game.
Thanks 🙂
I will post a Link, when it is finished
Hi, I played around with the portal effect, and it awesome!
Just wondering is it possible to have more than 1 set of portal facing different direction? Basically I’m trying to have 4 ‘windows’ on each side of a cube which I can look through it. Each windows will consist 4 different world.
I want to incorporate this with Vuforia AR, which could look awesome if its achievable.
Thanks!
Yep, it can totally be done but requires encapsulating this portal functionality into some class that will create the portal/camera pairs automatically and assure the global order of rendering. Otherwise you can add more cameras and portals by hand but it will quickly become bothersome, e.g. if you add one more cube you will yet again have to add more portals/cameras. This is just a demo of the technique, done with a Portal-like game in mind (i.e. one pair of portals at a time).
Hi, Algoholic! I seem to be having trouble with your package. Do you mind giving me a hand? The portals don’t render correctly (the cameras are looking at wrong directions) if the portals are not face to face each other. Please e-mail me. Thank you!
Thanks for the answer. Just a final one. How to I fix the Clipping issue? Say if I place the cube towards a portal. And when I view it in another portal, it has clipping issue on the cube. When I rotate around, part of the cube will be clipped. I tried to change the the Near and Far Clipping planes as well the FOV, it still had the issue.
Sorry that I need to ask here. Sometimes I have to ask some obvious stupid question in order to learn.
Thanks.
You should use a custom clipping plane defined by the portal surface. Since Unity’s built-in shaders do not support clipping planes in the demo I actually do a little bit of near clipping plane adjustment to imitate a custom one but of course as you play around you will see the artifacts. The only way around this is to write your own shader including the custom clipping plane functionality.
Or actually you could go with the same trick that portal uses (i.e. writing to depth buffer) but fill the rest of the screen (apart from the portal) with z=0 so that nothing gets drawn there.
I might release a paid version of this package with all the enhancements mentioned so far. Let me know if you’d be interested in buying it.
Of course, I speak too late. I bought Unity 5. You have to Unity 5 Projects.
Hi, Stanislaw.
Your project is very helpful, and the idea to achieve this effect is just excellent, but I seem to have problems replicating your scene. How do you deal with which camera is rendered on which plane? Because for me always the one of additional cameras with a higher depth will get rendered on both planes :/
Make sure you have a second, identical mesh under the main one with the FillZ shader, or whatever it was. That needs to be active on one of the portals. Then make another camera parented to the main camers, set the depth to the camera’s, minus one, and then set it to Depth Only. Have the second mesh on the PortalHelpers2 layer, and make the new camera only render that layer.
Hi guys. and thanks for the great assets! 🙂
For those who are seeing clipping artifacts… I sort of know why. from the looks of it, it is using a straight camera with the default matrix, which probably won’t look right. I will see if I can reverse the matrix, so an actual reflection appears! 😉
Of course, this is only useful for mirrors, but it will help remove weird stuff… 🙂
I LOVE YOU !!! 🙂
Throwing assets from unity_portal_effect_source.zip in unity,an error has occurred.May be something i did wrong or really was a mistake in the script.I know how to make teleport,but i need to know how to make agencies to show, what can be seen in a different portal.I hope for your help.Sry for bad english.
I’m trying to make a doctor who game, so this is essential for the bigger on the inside effect, but I can’t seem to make it work, please help!
Does this work on Unity Free?
Very interesting technique.
Do you think it would be faster than render to texture?
Thanks.
Hmm it should be comparable. The only thing is with a texture you can render to a smaller one and here we’re always using full resolution.
Hello! I love your package, thank you very much for putting it out for free 😀
But i’m having trouble setting it up. I can’t figure out which script goes where, which mesh goes where, which shader goes where etc… I hope you can help me. Regards 🙂
Hi.I am agree with what said Terminal.I can’t figure out too whis script goes where.Please help us)
Hi,I am a beginer for Unity3d from China. Your portal’s tutorial is perfect,but it puzzled me too much. Can you give a detailed tutorial on Youtube? Thank you very much for your wonderful work.
Very nice and thanks for sharing !
I’m trying to figure it out 🙂 and have one question:
At the end of the FillScreen script you are changing the MeshFilter vertices. I can’t figure out what you are doing, it seems that rendering of that mesh are turned off…
Your effect is perfect for what i’m try to do.
Where can i download the sample ?
Thanks and regards
Emmanuel
Find them just above… Thanks a lot to share
Very nice and thanks for sharing !
Thank you so much!!
Greetings I am so delighted I found your blog, I really found
you by accident, while I was searching on Google
for something else, Anyhow I am here now and would just like to
say cheers for a remarkable post and a all round entertaining blog
(I also love the theme/design), I don’t have time to go through it all at the moment but I have saved it
and also added in your RSS feeds, so when I have time I will
be back to read a lot more, Please do keep up the excellent jo.
Analog Versus Acid Music Studio
The name of this writer is Dewey and he feels comfortable when people use complete name. To play lacross is the thing she loves most almost all. After being the particular his project for years he became a person’s resources aide. Missouri is where I’ve been living plus i don’t keep in mind changing one.
Since the depth is set by using time and speed in the return echo/sound wave. This scale will read in mV (millivolts) so just one particular.5V would be displayed as one thousand five hundred.
It’s wonderful that you are getting ideas from this paragraph as well as from our dialogue made at this
place.
You have made some good points there. I checked on the internet to learn more about the
issue and found most individuals will go along with your
views on this web site.
I’m gone to convey my little brother, that he should
also pay a visit this web site on regular basis to obtain updated
from most up-to-date reports.
My brother suggested I would possibly like this website.
He was once totally right. This post truly made my day.
You can not imagine simply how so much time I had spent for this
information! Thanks!
Hi! I’m at work browsing your blog from my new iphone!
Just wanted to say I love reading through your blog and look forward
to all your posts! Keep up the great work!
It’s very trouble-free to find out any matter on web as compared to books, as I found this piece of writing at this website.
I like what you guys are usually up too. Such clever work and reporting!
Keep up the awesome works guys I’ve added you guys to blogroll.
It’s hard to come by knowledgeable people about this
topic, however, you sound like you know what
you’re talking about! Thanks
This piece of writing will assist the internet visitors for building up new blog or even a
weblog from start to end.
What’s up to every single one, it’s genuinely a good for me
to pay a quick visit this web site, it consists of useful Information.
It’s remarkable in favor of me to have a website, which is useful designed for my experience.
thanks admin
Good web site you have here.. It’s difficult to find good quality
writing like yours these days. I really appreciate people like you!
Take care!!
Hey There. I found your blog using msn. This
is a really well written article. I’ll make sure to bookmark
it and return to read more of your useful information.
Thanks for the post. I will definitely return.
Hi, after reading this amazing article i am also happy to share my familiarity here with friends.
Hi all, here every person is sharing such experience, so it’s
pleasant to read this web site, and I used
to go to see this website every day.
Very nice post. I just stumbled upon your weblog and wanted to mention that I
have really enjoyed browsing your blog posts. After all I
will be subscribing on your feed and I’m hoping you write once more very soon!