GithubHelp home page GithubHelp logo

pr0g / unity-portal-rendering Goto Github PK

View Code? Open in Web Editor NEW
249.0 13.0 40.0 510 KB

Super small example of using offscreen render targets to achieve a portal effect in Unity

License: MIT License

C# 100.00%
portal unity graphics camera c-sharp

unity-portal-rendering's Introduction

unity-portal-rendering

Overview

Super small example of using off-screen render targets to achieve a portal effect in Unity.

alt text

Info

Please see this accompanying blog post http://tomhulton.blogspot.co.uk/2015/08/portal-rendering-with-offscreen-render.html for an explanation of the techniques involved.

  • UPDATE (2020/07/22,23): Upgraded Unity project, minor desktop camera improvements, fixed minor bug with Teleport.cs, renamed main branch.
  • UPDATE (2019/01/28): Added touch screen camera controls when running on device.
  • UPDATE (2019/01/21): Added teleportation (so moving through a portal will spit you out the other side).

Note: There's an artefact you'll encounter when moving through a portal where the near clip plane of the camera will clip with the portal texture quad. You wouldn't get this if using the portal stencil buffer technique but unfortunately with render buffers there's no clean way around it. The logic can still be applied if you'd like to use it elsewhere.

Controls

Desktop

WASD - Camera forward/backward/strafe
EQ - Camera adjust height
Right Mouse Button + Mouse Move - Look around
C - Cycle between main camera and portal camera views

Device

One Finger, Hold + Move - Look around
One Finger, Double Tap + Hold - Move forward
Two Fingers, Pinch - Move forward/backward
Two Fingers, Pan - Move up/down/left/right (Camera space)
Three Fingers, Tap - Cycle cameras

Extra

I highly recommend checking out this excellent YouTube video on Portals by Sebastian Lague.

It covers quite a few more details that you might need for a full game and also comes with its own GitHub repo.

The video also kindly gives a shout out to the original article posted along with this repo! 😄

unity-portal-rendering's People

Contributors

pkillboredom avatar pr0g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unity-portal-rendering's Issues

Portal view upside down

Each portal's view is upside down, if I try to rotate it 180 degrees so that it becomes normal it stays the same in play mode.

Was it a bug I had while opening the project? Or it's a known bug?

don't render objects between destination camera and frame

Every object that is located between the destination camera and destination portal should be clipped.

A way to do it in opengl:

  • Shader-side (GLSL):
uniform vec4 clip;
...
gl_ClipDistance[0] = dot(clip, gl_Vertex);

  • App-side, communicate the portal plane as the "clip" uniform.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.