Fully Functional Portals in Unity URP

Поделиться
HTML-код
  • Опубликовано: 20 дек 2024

Комментарии • 122

  • @PhoeniixFiire
    @PhoeniixFiire 3 года назад +12

    After a lot of headache and troubleshooting, I discovered that the only reason the checkphere in fixoverhangs works in your project is because you are using a meshcollider for your levelgeom. Checksphere returns false when inside meshcolliders because they are one sided and only register collisions when an object "enters" them, not the other way around. So when I tried implementing this solution in my project, the placement was not working right, because I'm using box colliders. This caused it to break out of the loop immediately and stop checking as soon as it found a collider, which caused my portals to overhang on the right side of top of boxes. So basically, your code is always failing this check unless it happens to find another portal, or the position is just such that it finds the edge of a wall, but otherwise is always doing the raycast.

  • @__dane__
    @__dane__ 3 года назад +20

    Really well done. I think the amount of time you spend on more lengthy tutorials like this shows in the quality of the work

    • @danielilett
      @danielilett  3 года назад +3

      Thanks, I appreciate it! :D

  • @koyomojo
    @koyomojo 3 года назад +9

    Man, i love your tuts. So clear, so direct.
    Much respect!

    • @danielilett
      @danielilett  3 года назад +1

      Thanks! I try to write the tutorials as if I'm explaining the video to myself, so it helps me reinforce what I've learned. If you're finding them clear and direct, I'm glad :D

  • @_knightgames
    @_knightgames 15 дней назад

    this is superb as always, thank you for the awesome tutorials!

  • @ultmatepotato
    @ultmatepotato 3 года назад +3

    I havent used it yet but maaan , ineeded this . Never subscribed to any channel this fast
    EDIT:it works! And its realy COOL!

  • @XevianLight
    @XevianLight 3 года назад +14

    Thank you so much! I can’t believe this was uploaded only 3 weeks ago. I was starting to think recursive portals were going to be impossible in the URP.

    • @danielilett
      @danielilett  3 года назад +3

      Thanks! I actually tried this a while back in URP and if I remember correctly, I used to just get error messages saying recursive rendering is not supported. I don't know when that changed!

  • @maindepth8830
    @maindepth8830 2 года назад

    this completely flew right over my head

  • @szappy
    @szappy 2 года назад +1

    Wow this video was great and very informative on how to make portals and every detail that goes into making something seemingly so simple happen. I'm also willing to bet that there are a good few other potential solutions to making a portal!

  • @halbzwilling
    @halbzwilling 3 года назад +1

    Thanks for sharing! Awesome breakdown ✌️

    • @danielilett
      @danielilett  3 года назад

      You're welcome, I had tons of fun putting it together :D

  • @MeanLemur24432
    @MeanLemur24432 Год назад +2

    How do you change it to the built in pipeline?

  • @mitchellharder7670
    @mitchellharder7670 3 года назад +5

    Amazing, although do you know how one would convert this into the other render pipelines?

    • @danielilett
      @danielilett  3 года назад

      I'm unsure exactly how to do this, but I would probably start by checking what camera rendering callbacks exist on other pipelines and figure out which ones are roughly the same as the ones I used for URP. Most of the code can stay the same. The shader might need to be rewritten too - it samples the portal camera textures in screenspace.
      This video/project was based on a version I did for the built-in pipeline a while back, which you can find here if you're interested in the changes between versions: github.com/daniel-ilett/shaders-portal
      Good luck if you plan to convert it yourself! :)

    • @mitchellharder7670
      @mitchellharder7670 3 года назад

      @@danielilett This new one works way better, although I'm still having trouble with just setting up the portal shooting ability on my existing player character, and going through the portal without breaking my camera. It seems like the scripts you have here all tie back to the floating ball player chr you have in your sample scenes, so I have to untangle the code to make it work. Do you have a process for setting this up on other characters properly?

    • @danielilett
      @danielilett  3 года назад

      I didn't cover it in the video, but I had to put in a lot of work to automatically correct the camera orientation when you travel through the portal. It ended up being one of the trickier parts of the whole thing actually.
      For the portal shooting, you should be good so long as you raycast from the camera position forwards, but mask out your player object so that you don't immediately 'shoot' yourself.
      For travelling through the portal, it's more in-depth. Positioning the player relative to the other portal should be simple enough, but collisions and rotating the camera will probably need to be custom-written depending on your specific character shape/setup, so I don't really have a process to follow I'm afraid.

  • @PRodi_
    @PRodi_ 3 года назад +5

    Great Tutorial! btw. do you know how to make the same effect for VR in URP???

    • @danielilett
      @danielilett  3 года назад +1

      I'm afraid I don't have a VR headset so I can't try this out myself! I also don't know much about how both eyes get rendered in VR, but I think it's more complicated than just taking a single snapshot of the scene and pasting a texture onto the portal surface. You kind of need each eye to see separate textures on the portal surface, so *in theory* I think you could layer two portals on top of each other and render one to each eye with slightly different textures applied. If there's a way to take a stereo snapshot with a camera and get two render textures out, one for each eye, I'd start there.
      PS. If you actually got this working in VR, the code I wrote to correct the camera rotation after travelling through a portal is probably very nauseating, so you might want to tweak it!

    • @PRodi_
      @PRodi_ 3 года назад +1

      ​@@danielilett Big thx for your answer! btw. try Oculus Quest 2 it is absolutely fantastic VR device with XR2 chip on board!

    • @danielilett
      @danielilett  3 года назад +1

      Maybe one day I'll grab one! I get asked a surprising amount about VR effects so I'd really like the chance to make a tutorial one day :D

    • @PRodi_
      @PRodi_ 3 года назад +2

      @@danielilett I can't wait for your VR tutorials!!! :D

    • @danielilett
      @danielilett  3 года назад +1

      Thanks! It'll probably be a long time before I can do anything in VR, but I'm happy that there's interest.

  • @fluubs8388
    @fluubs8388 3 года назад +2

    I attempted to add my own player movement with rigidbodies but it doesn't seem to work.

  • @guidoquiros2892
    @guidoquiros2892 3 года назад

    Thanks for share. Wonderfull tutorial

  • @giztin
    @giztin 3 года назад +3

    So I’m planning on making a vr game, and I was wondering if these portals would work with the strange physics that is virtual reality?

    • @danielilett
      @danielilett  3 года назад +3

      I don't have access to a VR headset to test anything out, so take this answer with a pinch of salt. But I think, technically, rendering the portals would be possible. If you're asking whether it will be possible to launch a player through the portals in VR, then I also think that would be feasible, but you would have to modify the code quite considerably, because currently I swivel the camera round pretty quickly as you travel through a portal, which would probably result in extremely sick players. From a gameplay standpoint, it would probably be quite difficult to reorient the camera when travelling through the portal while avoiding sickness but also without players losing their sense of direction.

    • @giztin
      @giztin 3 года назад +1

      @@danielilett ah ok, no problem :)

  • @Sorz1v0
    @Sorz1v0 8 месяцев назад +1

    Hej, Great tutorial. Quick question how is the performance of this on a meta quest VR. How can it be optimized to work on these mobil VR hardware? I heard they are not happy with multiple cameras in the scene?

  • @frostdracony
    @frostdracony 3 года назад +7

    Really, really interesting, thanks for the whole work! I started to learn the Unity engine not long ago and I find this a bit hard, but this still is interesting to me! Now, if I want to use your code to experiment with or to use it into a game, may I? I saw that it has a MIT License, but I always want to ask before taking

    • @danielilett
      @danielilett  3 года назад +3

      Of course, feel free to modify and use it - that's why I release it under the MIT license :) Best of luck learning Unity and I hope you can learn something from this video/project :D

    • @frostdracony
      @frostdracony 3 года назад +1

      @@danielilett Thanks!

  • @sillybilly-qg9yt
    @sillybilly-qg9yt 3 года назад +2

    is there anyway you could make this work on the newer unity versions?

    • @danielilett
      @danielilett  3 года назад +1

      Which Unity version and which render pipeline are you trying to make this work on?

    • @sillybilly-qg9yt
      @sillybilly-qg9yt 3 года назад +1

      @@danieliletti was trying to make this work on 2021.1 and what do you mean by pipeline?

    • @danielilett
      @danielilett  3 года назад

      I'll take a look at the code in 2021.1! There's every chance something has changed since 2019.4 that breaks the effect.
      Basically, this (probably) won't work on HDRP or the built-in render pipeline without tweaking.

    • @MimsTwo
      @MimsTwo 2 года назад

      @@danielilett I'm trying it on HDRP and haven't had any errors yet, although there doesn't seem to be an HDRenderPipeline.RenderSingleCamera() method. But it does seem to have a RecursiveRendering class, perhaps this could be used to replace some of this code with built-in code?

    • @danielilett
      @danielilett  2 года назад +1

      @@MimsTwo I don't use HDRP really, but the last time I tried converting this project to HDRP, it didn't play nice with recursive rendering at all. At a quick glance, the RecursiveRendering class seems to be used for ray tracing so that the light rays can reflect off multiple surfaces. Maybe there's something in there that would help you but as I say, I don't use HDRP much.

  • @Hyphen3372
    @Hyphen3372 3 года назад +1

    how can i use a custom rb controller with the portals i cant shoot portals

  • @deezdev9540
    @deezdev9540 3 года назад +1

    i wanna replace the player controller with and fps player controller though, like i wanna have gravity

    • @L0g0Z0g0
      @L0g0Z0g0 3 года назад +1

      i too but i don't know how

  • @takeowatanabe8763
    @takeowatanabe8763 2 года назад +1

    Someone know if there is something like the recursive rendering but for not URP projects?

    • @danielilett
      @danielilett  2 года назад

      I actually made this portal effect in the built-in pipeline a while before updating it for URP, so you can see the differences in the code here: github.com/daniel-ilett/shaders-portal
      I made it back in Unity 2019.2, so I'm not sure if it will break in later versions. Off the top of my head, can't think of anything that would break, but there's always the risk with updating versions!

    • @takeowatanabe8763
      @takeowatanabe8763 2 года назад

      @@danielilett This is perfect!!! Thank u very much!!!!

  • @innovativename5268
    @innovativename5268 3 года назад +1

    It don't works for me, if i start the game in Playmode, My Camera shakes and everything breakes

  • @endxrseeker5051
    @endxrseeker5051 3 года назад

    man made this at 12:00 at night XD

  • @bigmancozmo
    @bigmancozmo 3 года назад +1

    ok i was doing it right but it gave me an error saying "Universal" didn't exist in "UnityEngine.Rendering"

  • @BloodMoon547
    @BloodMoon547 10 месяцев назад

    Just a small stupid question, what do I put in the placement mask and my layerMask ? When I add a layer to à GameObject, the GameObject disappears.

  • @joooosl
    @joooosl 3 года назад +1

    Sorry for getting on your nerves, but I really can't figure out how to do a grabbing mechanic, working with the portals. When I make a simple grabbing mechanic, the cube I'm trying to grab floats back to the original Position of the cube. I think I have to do like a fake player, and as soon as the Cube goes through the Portal, the grab position changes to the other player. But I don't know how to do that....

  • @MS-nb2zg
    @MS-nb2zg 10 месяцев назад

    so what do i do in the editor?

  • @dekira3545
    @dekira3545 2 года назад

    thank you, amazing!!

  • @MakingStuffWithEvan
    @MakingStuffWithEvan 4 месяца назад

    Would it work in HDRP?

  • @cicero31415
    @cicero31415 10 месяцев назад

    I am having an issue, I get Screen position out of view frustum (screen pos 881.000000, 0.000000, 1000.000000) (Camera rect 0 0 881 386) error, how should I fix it. I have the portal camera under the portal elements. If you know how to fix send how to.

  • @Sharkz-iz6yf
    @Sharkz-iz6yf 3 года назад

    i downloaded the project, the portals work but there is no texture of camera for it

  • @shayegan.
    @shayegan. Год назад

    Hey man thank you for your perfect instruction. I just wanna ask in VR scene if user wants to teleport wherever he wants, and first he points at the location and interacts with the trigger, and after that, he doesn’t teleport there at the moment but first, the portal camera which actually is like picture-in-picture pops up in the left corner of the screen, and the user can see the desired location and can tilt their head to the left or right or up and down to see what is going on over there, and then, if they decide to teleport over there, the portal camera smoothly transitions to the main camera, so the user won’t feel just popping there in the designated location. what are the steps to implement something like this?

  • @SeanGauseOfficial
    @SeanGauseOfficial 2 года назад

    How would I fade to a solid color for each recursive render? So it doesn't just stop suddenly after the 7th portal, for example.

  • @watercat1248
    @watercat1248 7 месяцев назад

    I don't know how you do that but i have different question
    Do you have plan to make toutoria for how to make mirror's i don't nessery need to reflective everything on the map im able to make refection to work perfectly on static object with multiple ways
    Like fake room on the other side for example.
    The stuff i want to reflect it's the moving object like the player for example those the stuff im not able to figure out how to make.
    Any suggestions ?
    My game is multiplayer I'm not able to make something like duplicate Player because if do that i will have to do that on every Player something that it's not phisable in my Case.

  • @sliceggjd
    @sliceggjd 2 года назад

    do you know how to mske it an fps body instead of free look camera?

    • @atheris7653
      @atheris7653 2 года назад

      im looking for this too.
      can u let me know if u found it?

  • @upkejzer8522
    @upkejzer8522 Год назад

    2 protips for URP:
    1. Use Shader Graph with sampletex2D and screenpos nodes. It is easier.
    2. RenderPipelineManager.beginCameraRendering invokes for each camera-> player, portals, even editor. Because each of these are rendered automatically. So using RenderSingleCamera is redundant.

  • @TheWasian
    @TheWasian Год назад

    I've been messing around with this project and I cannot seem to get objects to go through the portals what should i do?

  • @kiranrajput4167
    @kiranrajput4167 3 года назад

    Hey, can you please tell me how to setup all these scripts? by set up i mean which script goes where, what should be assigned in the variables etc

  • @kanka2122
    @kanka2122 Год назад

    Shader not showing , i copied from project , anyone know the reason ?

  • @Coolness7423
    @Coolness7423 2 года назад

    Whenever "Portal" is mentioned it comes up with
    The type or namespace name 'Portal' could not be found

    • @Coolness7423
      @Coolness7423 2 года назад

      Like in the code it recognises it but Unity doesn't
      (Im on version 2020.3 btw)

  • @quanliu1239
    @quanliu1239 Год назад

    the shader does not work in unity 2021. it shows nothing. do anyone know how to fix this please?

  • @KastingShadows
    @KastingShadows 3 года назад

    do you think this could work in vr?

    • @danielilett
      @danielilett  3 года назад

      I think the basic strategy should work, but I don't have any experience with VR myself. All the code to do with placing the portals and move through them should still work the same - but the rendering code would need to change. It might be as easy as a different function call to render the portal cameras, or the shader might need changing a bit - but I'm not sure I'm afraid!

  • @dododavido9240
    @dododavido9240 Год назад

    wow that's cool everything works like I used your asset and the player flies there I don't know what to do help!

  • @Adrian_Reed
    @Adrian_Reed Год назад

    You are amazing!🎉

  • @L0g0Z0g0
    @L0g0Z0g0 3 года назад +1

    How to make physical player

  • @alexfu1734
    @alexfu1734 3 года назад

    Hi! I wonder how this can work on gameObject with CharacterController

  • @ishkyousuke7477
    @ishkyousuke7477 3 года назад

    Is it possible to use shader graph for this?

    • @danielilett
      @danielilett  3 года назад

      Most of the heavy lifting for this effect is done by the scripting rather than the shader, so a potential Shader Graph version wouldn't need that many nodes - but I think you should be able to use it. You'd end up sending the portal camera render textures to the material like this video already does, and the graph should sample those in screen-space. Just note that in my shader code implementation, I use a stencil buffer (which Shader Graph doesn't support), but that's only to cut out part of the orange or blue portal shape. If you use a different method to make the outer portal ring then a stencil isn't necessary.

  • @zwarriorx3407
    @zwarriorx3407 8 месяцев назад

    what type of shader

  • @FHBStudio
    @FHBStudio Год назад

    The original portal probably used portal bullets to solve for the infinite ray before deciding there was no need to shoot portals through portals anyway, and the portal bullet is a remnant of that. It's not present in portal 2 so they did it using ray casting only in that game.

  • @bigmancozmo
    @bigmancozmo 3 года назад +1

    finally another person who still uses 2019.4 lol

  • @HoisinDuckWrap
    @HoisinDuckWrap 3 года назад

    yo i fly.... is this a bug or a built in? also if i add an actual player model, they cant go through the portal? HELP please

  • @shenshaw5345
    @shenshaw5345 2 года назад

    Could I use this in hdrp?

  • @nicolasc3183
    @nicolasc3183 3 года назад

    Thanks man, this one is so helpful.
    The only problem I got is with this line of code:
    Quaternion relativeRot = Quaternion.Inverse(inTransform.rotation) * cameraTransform.rotation;
    How did that achieve what we want with out fliping the camera upside-down?

  • @treerexonyt
    @treerexonyt 2 года назад

    How do you put it on unity?

  • @joooosl
    @joooosl 3 года назад

    Amazing work. But for some reason the portal itself is way to small, but the box collider is normal size. After changing the size, the portal placement does not work anymore.

    • @danielilett
      @danielilett  3 года назад

      Hmm, strange! Are you able to give me more information - such as Unity and URP version, and did you clone the GitHub repo? :)

    • @joooosl
      @joooosl 3 года назад

      @@danielilett Ok, fixed it. IDK what was happening, but now it works!

  • @cb3ezy
    @cb3ezy 7 месяцев назад

    Is it for URP, if not please teach me how to edit it for URP, or make it URP for us.

    • @danielilett
      @danielilett  7 месяцев назад

      Yeah, it's for URP!

    • @cb3ezy
      @cb3ezy 7 месяцев назад

      @@danielilett cool, thanks man!

  • @starbuck3980
    @starbuck3980 Год назад

    Downloaded your project and doesnt work in Unity 2021.3, also dont know why you made the player move all the time, which is quite annoying and when i press the mouse i just go through wall but there is not any portal

  • @netherofficial
    @netherofficial Год назад

    How to convert it to HDRP?

  • @spatendeamon8250
    @spatendeamon8250 3 года назад +1

    Great Tutorial, but I have a problem with the Recursive Rendering. The portal effect works, but whenever the portals are facing each other and you look through a Portal, the Portal in the Portal is displayed as black, instead of the Recursion effect. I copied the Portal shader and the Script for the portal camera from GitHub and don't know how to fix it.

    • @danielilett
      @danielilett  3 года назад +1

      Huh, strange. Can you let me know which version of Unity and URP you're using? And do you get any errors in the console at all? :)

    • @spatendeamon8250
      @spatendeamon8250 3 года назад +1

      @@danielilett I use Unity 2021.1.1f1 URP. I don't get any Errors in the console. I downloaded your Project on GitHub and Updated it to the same version I use and yours is working.

    • @spatendeamon8250
      @spatendeamon8250 3 года назад +2

      @@danielilett I fixed it by Enable Post Processing on the Portal Camera.

    • @danielilett
      @danielilett  3 года назад

      Ah good! Thanks for letting me know what the fix is - if anyone else has the same problem I can let them know :)

  • @PortalGamer680
    @PortalGamer680 Год назад

    my portals are not rendering at all

  • @ItsJordonSC
    @ItsJordonSC 2 года назад

    Hello Daniel! I know this video is a year old but I'm having issue with the Portal Camera script! C# is recognizing the variable "[SerializeField]
    private Portal[] portals = new Portal[2];" But when I go back into unity I get the following error "The type or namespace name 'Portal' could not be found (are you missing a using directive or an assembly reference?)" If you have an idea on how to fix it I would love to know! Cheers
    EDIT: I fixed it!

    • @lienne04
      @lienne04 Год назад

      Hello, I have same problem..so how did you fix that? Could you share to me?

    • @ItsJordonSC
      @ItsJordonSC Год назад

      @@lienne04 I'm so sorry but this was 8 months ago so I physically cannot remember how I fixed it

    • @lienne04
      @lienne04 Год назад

      @@ItsJordonSC oh..never mind! thanks for your reply.

    • @aaronbenson5410
      @aaronbenson5410 Год назад

      @@lienne04 if ur still having this problem, the fix is just making the "Portal" script

    • @DeagleAssault
      @DeagleAssault Год назад

      @@aaronbenson5410 thx mate

  • @L-Andreas-2003
    @L-Andreas-2003 3 года назад +1

    Valve create "mini demention" for realistic physics in game

  • @cheesepop7175
    @cheesepop7175 2 года назад

    seamless

  • @Sharkz-iz6yf
    @Sharkz-iz6yf 3 года назад

    Assets\Scripts\PortalPlacement.cs(15,13): error CS0246: The type or namespace name 'Crosshair' could not be found (are you missing a using directive or an assembly reference?)
    &
    Assets\Scripts\PortalPlacement.cs(9,13): error CS0246: The type or namespace name 'PortalPair' could not be found (are you missing a using directive or an assembly reference?)
    :( what do I do?

    • @L0g0Z0g0
      @L0g0Z0g0 3 года назад

      You may not copied or downloaded this scripts, they are also in package

  • @shernoreg
    @shernoreg 2 года назад

    Toma comentario toma like parabéns

  • @scratcharas1234yt
    @scratcharas1234yt 2 года назад

    Can you give me the codes?

  • @Cryptifical
    @Cryptifical 2 года назад

    my timestamp 3:32 / 18:25

  • @skald-0_09
    @skald-0_09 Год назад

    🥰

  • @sourdoughbread952
    @sourdoughbread952 Год назад

    you don't explain it step by step or in chronological order, you just show the code. i don't know what to do first, what the portal is. i don't know what i should attach most of the scripts to. this is soo hard

    • @danielilett
      @danielilett  Год назад +1

      Hey, you can download the whole project on GitHub which should help clarify which objects should have which scripts attached: github.com/daniel-ilett/portals-urp

    • @sourdoughbread952
      @sourdoughbread952 Год назад

      @@danielilett i don't even know how to set up the scene before creating the scripts and which scripts to make first

    • @sourdoughbread952
      @sourdoughbread952 Год назад

      @@danielilett doesn't work

  • @b1tfl1p
    @b1tfl1p 11 месяцев назад

    The problem I have with this tutorial is the assumption that I want to download your repo instead of building this from scratch. This is unironically the only functional portal code I've found for urp but the problem is I can't build this directly into my project. At least personally, I'm not a fan of this style of tutorial.

    • @b1tfl1p
      @b1tfl1p 11 месяцев назад

      It makes me feel more like a student in a lecture than it does an someone who's involved and actively learning

    • @danielilett
      @danielilett  11 месяцев назад +1

      I get comments like this occasionally and they confuse me. This is the only functional portal code you've found for URP but you wanna get picky about the specific way I chose to make the tutorial? Sorry, but for a mechanic this complicated, it's always going to require some work to integrate into your own project and work around whatever idiosyncracies are particular to that exact project. This tutorial explains pretty much all the parts *except* integrating into your own work.

  • @somethings-c6j
    @somethings-c6j 2 года назад

    nice 666

  • @underbelly69
    @underbelly69 Год назад

    subscribed - anyone tried this in VR for quest2