Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Kalbytron · Jan 13, 2016 at 07:13 PM · textureeffectparallax

How to make a portal effect texture?

I have seen games that has --> this <-- type of effect. I like how it parallaxes as the player moves as it creates this large space within a small space. *cough *TARDIS *cough So does anyone know what this effect is called and how do you create this effect?

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

2 Replies

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

Answer by Eno-Khaon · Jan 13, 2016 at 11:42 PM

Well, the effect in your picture (I honestly haven't actually seen it in motion, but I'm 90% sure I know what the effect is) can be reproduced in a multitude of ways... all of which require shader support.

So, I'll go over a general two ways in which that can be reproduced:

1) The area "beyond the portal" as it were, is presented as a Cubemap. The coordinate of the Cubemap read to be displayed on-screen would be determined by the camera direction to the pixel multiplied by an additional depth scalar (a float added to the shader). This would make the effect appear to be under the surface of the plane at any effective distance. An example of a cubemap reflection can be found here, but in this case, this would be a change from texCUBE(_Cube, IN.worldRefl).rgb to an effective texCUBE(_Cube, normalize(IN.viewDir) * scale).rgb.

2) Use two objects. The first object is the "portal" to display the "image" of the plane beneath it. It actually doesn't need to render anything. All it needs to do is have its position in the Rendering Queue changed. The second object is the "image" through the portal. It's simply a plane placed underneath, where its shader comes in the Rendering Queue after regular objects, but before the "portal". Then, set the "ZTest" on this shader to "Greater" (default is LEqual, or less than or equal).

Either of these can be modified by utilizing RenderTextures instead of preset images, but RenderTextures, cubes especially, are fairly computationally expensive to use.

Comment
Add comment · Show 8 · 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 Kalbytron · Jan 13, 2016 at 11:58 PM 0
Share

So on the first option, I can create a cubemap, apply to the modified shader, make a material with the shader, paste onto a plane, and it will guaranteed me an awesome effect? I'll be testing this after I post.

avatar image Kalbytron · Jan 14, 2016 at 12:11 AM 0
Share

How do I initialize "scale"? I don't write shader scripts often.

avatar image Eno-Khaon Kalbytron · Jan 14, 2016 at 12:15 AM 0
Share

To just borrow the Cubemap Reflection surface shader example:

 Shader "Custom/Portal" {
     Properties {
       _$$anonymous$$ainTex ("Texture", 2D) = "white" {}
       _Cube ("Cubemap", CUBE) = "" {}
       _Scale ("Cubemap Depth Scale", float) = 1.0
     }
     SubShader {
       Tags { "RenderType" = "Opaque" }
       CGPROGRA$$anonymous$$
       #pragma surface surf Lambert
       struct Input {
           float2 uv_$$anonymous$$ainTex;
           float3 viewDir;
       };
       sampler2D _$$anonymous$$ainTex;
       samplerCUBE _Cube;
       float _Scale;
       void surf (Input IN, inout SurfaceOutput o) {
           o.Albedo = tex2D (_$$anonymous$$ainTex, IN.uv_$$anonymous$$ainTex).rgb * 0.5;
           o.Emission = texCUBE (_Cube, IN.viewDir * _Scale).rgb;
       }
       ENDCG
     } 
     Fallback "Diffuse"
   }

Adding _Scale to the properties at the top and in the middle where it's declared as a "float" value are all that are needed to add customizable variables to shaders.

avatar image Sir-Gatlin Eno-Khaon · Mar 01, 2017 at 10:07 PM 0
Share

This Worked great when the camera is moving around. I am building it for a vr app and am trying to make my buttons look like a parallaxing image when your view moves and am wondering how to manipulate this to accomplish that

avatar image Kalbytron · Jan 14, 2016 at 01:40 AM 0
Share

$$anonymous$$y goodness it works. Now what I need to do next is to add content inside the portal. I have read up that it is one texture recolored, layered a couple of times (which gives the parallax effect), rotated and moves forward very slowly. Although the scale seems to have no effect. How is that suppose to work?

avatar image Eno-Khaon Kalbytron · Jan 14, 2016 at 04:58 AM 0
Share

Oh, wow. $$anonymous$$y head wasn't on straight when I was trying to think of that one. I had an idea and really didn't think it through before posting it.

Okay, well, its usage can still be implemented...

So with a few changes..,

 Shader "Custom/Portal" {
      Properties {
        _$$anonymous$$ainTex ("Texture", 2D) = "white" {}
        _Cube ("Cubemap", CUBE) = "" {}
        _Scale ("Cubemap Depth Scale", float) = 1.0
      }
      SubShader {
        Tags { "RenderType" = "Opaque" }
        CGPROGRA$$anonymous$$
        #pragma surface surf Lambert
        struct Input {
            float2 uv_$$anonymous$$ainTex;
            float3 viewDir;
            float3 worldNormal;
        };
        sampler2D _$$anonymous$$ainTex;
        samplerCUBE _Cube;
        float _Scale;
        void surf (Input IN, inout SurfaceOutput o) {
            o.Albedo = tex2D (_$$anonymous$$ainTex, IN.uv_$$anonymous$$ainTex).rgb * 0.5;
            float3 cubeDirection = lerp(-IN.worldNormal, IN.viewDir, _Scale);
            o.Emission = texCUBE (_Cube, cubeDirection).rgb;
        }
        ENDCG
      } 
      Fallback "Diffuse"
    }

Okay, so what I did was take the cubemap coordinates and give them a range by interpolating between straight up/down and the direction the camera's looking: If you're looking at a flat plane, a scale value of 0 will appear to be one solid color. A scale of 1 will be what you currently see. Therefore, increasing the scale will appear to increase the depth of the image (for real, this time).

I completely forgot to think that one through the first time around...

avatar image Kalbytron Eno-Khaon · Jan 14, 2016 at 05:32 AM 0
Share

You know what, it works. Though I noticed that "cubeDirection" is suppose to be a "float3" var. I like the warped star effect when the scale is set to 0.5 (I think IN.worldNormal is suppose to be positive).

Hey I appreciate the help you have given. Shaders really are a neat thing to play around.

Show more comments
avatar image
0

Answer by thesleeve · Jan 14, 2016 at 10:38 AM

Do some research on non-Euclidian geometry. I know it's possible in Unity, but I have no idea how to do it. Here's an example in Unity that I found doing a quick search. http://puu.sh/bqHLQ/3671e5dcc7.gif

Comment
Add comment · 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

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

36 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

Related Questions

Using shaders for text effects (TextMesh) 0 Answers

Trying to achieve this color effect 0 Answers

Image Effects on MovieTexture 0 Answers

Muzzle Flash 1 Answer

Procedural or Animated Textur in AirAttack Zeppelin Wreck (IphoneGame)? 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