• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by z77 · May 05, 2018 at 09:05 AM · shadergraphicsshader programmingmirrorportal

How to make a 'mirror' and/or 'portal'-like Shader Graph?

Hand crafted a portal-system in Unity (standard render pipeline). Some screenshots: http://electricbrain.eu/dev/portal_ex_0.png and http://electricbrain.eu/dev/portal_ex_1.png . WebGL will be the main platform probably.

this portal-system relies on Camera events like OnPreRender, which does not seem to fire anymore in Lightweight Render Pipeline.

So my question has some partial questions: 1. Is it wise to migrate to the new Lightweight Render Pipeline (LWRP) or not? (my projects will probably not finish soon) 2. Camera events, like OnPreCull and OnPreRender will not work in LWRP? 3. Will it be possible to make a 'portal'-system in LWRP? Do I have to write a custom Render Pipeline to facilitate this? (I hope not, seems awfully complex) 4. I figured, if i can make a 'mirror'-shader, it should be possible to make a 'portal' shader in LWRP. So... I googled, but could not find a 'mirror' Shader Graph for LWRP. Suggestions please?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Bunny83 · May 05, 2018 at 09:55 AM

Brackeys portal tutorial should give you some hints how you can implement portals with render textures. Yes this approach is a bit ineffective as it simply renders the whole portal camera view to a rendertexture and just displays a portion of it depending on how much can be seen of the actual portal surface. Though this is the easiest way to implement portals.


There are a few things that can be changed though. He simply offsets the camera just in relation of the other portal. For a general portal system this of course doesn't work. You should use TransformPoint / InverseTransformPoint to map the camera position / orientation to the other portal. Next thing is that the near clipping plane should be adjusted to be right behind the exit portal. He designed his two rooms in a way there's nothing in the way for the portal camera. However you want to clip objects between the portal camera and the exit portal. For this you probably want to use an oblique clipping plane.


Further more it would be possible to set a viewport for the portal camera to only render the AABB area of the portal into the render texture. Of course you would need an off-center projection for this. However this is just an optimisation to cut down how much need to be rendered by the portal camera.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image z77 · May 05, 2018 at 12:48 PM 0
Share

Thanks!

This helped me to refactor my portal-system: not using the OnPreRender event in my MainCamera made my portals compatible with the new 2018 Lightweight render Pipeline, at least, in the Editor...

(The WebGL version just shows a blue screen, but that's another subject. Sigh...)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

146 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is it possible to access other objects in a shader function? 0 Answers

How to edit these shaders file? 1 Answer

Generating a texture through Graphics.Blit with shadergraph 0 Answers

Rewrite shader so that the Sprite-Diffuse shader doesn't take incidence angle into consideration when applying lighting? 1 Answer

Adding a clip() to the default shader? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges