Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 Datates · Jun 17, 2014 at 05:15 PM · camerarotationeffectviewportinverted

Rotation of a camera viewport

I want to have the top half of a level have a white background and grey objects, and the bottom half is inverted with a grey background and white objects. This is merely a visual effect.

I made a small example with some rigidbodies to clarify what I mean:

Game is paused

Game is started

It is the same objects, but created using 2 cameras and 2 layers.

The top camera cannot see the layer "Grey", and the bottom camera cannot see the layer "White". There are some problems with this method though:

  • I want this effect to be rotated freely, but I haven't been capable of finding a way to rotate a viewport - fx, instead of having the border between the two colors being a horizontal line, it could be rotated to 45 degrees, making some of the upper half grey and some of the bottom half white.

  • For every visual object in the game, there has to be created a duplicate - one white and one grey (mildly annoying, but I can live with it).

Does anyone have an idea of how this effect can be done? Or is it just impossible to rotate a viewport? If it is possible, how big of an performance impact would it have?

Comment
Add comment · Show 4
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 PouletFrit · Jun 17, 2014 at 08:52 PM 1
Share

You could use target textures and rotate theses

avatar image Datates · Jun 17, 2014 at 09:02 PM 0
Share

Unfortunately, it appears target textures are Pro only.

I have, however, been pretty successful by using an inversion shader on the top half - http://forum.unity3d.com/threads/invert-colors-shader.205244/

avatar image PouletFrit · Jun 18, 2014 at 04:11 AM 0
Share

Another possibility if you work with shader would be to modify your shader at runtime by creating a new temporary shader with a string... but I have no idea how bad on performance it could be.

avatar image tomekkie2 · Jun 18, 2014 at 06:32 AM 0
Share

Look at the clipping or crosssection shaders here: http://forum.unity3d.com/threads/simple-cross-section-shader.34508/ and just for the given global space coordinates apply inversion in similar way like clipping is applied here. Then expose the boundary plane in the shader parameters and manipulate with them over time.

   Shader "Diffuse/HalfInvert" {
     Properties {
       _Color ("$$anonymous$$ain Color", Color) = (1,1,1,1)
       _$$anonymous$$ainTex ("Texture", 2D) = "white" {}
       
       _BoundaryPlane ("BoundaryPlane (x, y, z)", vector) = (0,1,0)
       _CentrePoint ("CentrePoint (x, y, z)", vector) = (0,0,0)
       _BoundaryOffset ("BoundaryOffset",float) = 0
     }
     
     
     SubShader {
         Tags { "RenderType"="Opaque" }
         LOD 200
 
           Cull Back
           
           CGPROGRA$$anonymous$$
           #pragma surface surf BlinnPhong
           #pragma debug
           fixed4 _LowerColor;
           fixed4 _Color;
           fixed3 _BoundaryPlane;
           fixed3 _CentrePoint;
           float _BoundaryOffset;
           
           struct Input {
               float2 uv_$$anonymous$$ainTex;
               float3 worldPos;
           };
           sampler2D _$$anonymous$$ainTex;
           
           void surf (Input IN, inout SurfaceOutput o) {
                   fixed4 tex = tex2D(_$$anonymous$$ainTex, IN.uv_$$anonymous$$ainTex);
               if (_BoundaryOffset -dot((IN.worldPos - _CentrePoint),_BoundaryPlane)>0){
                   //fixed4 tex = tex2D(_$$anonymous$$ainTex, IN.uv_$$anonymous$$ainTex);
                   o.Albedo = tex.rgb * _Color.rgb;
                   o.Alpha = tex.a * _Color.a;
               }else{
                   o.Albedo = (1,1,1) - tex.rgb * _Color.rgb;
                   o.Alpha = tex.a * _Color.a;
               }
               
           }
           ENDCG
 
     } 
 
     Fallback "Diffuse"
   }

0 Replies

· Add your reply
  • Sort: 

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.

Follow this Question

Answers Answers and Comments

22 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

Related Questions

Why the control with gyroscope inverted when I make 180 degrees turn? 1 Answer

rotate the camera in the z axis 1 Answer

Rotating a plane so that its top is parallel to the camera viewport 1 Answer

Multiple cameras with different viewport rotations 2 Answers

possible to set rotation of camera viewport? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges