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 /
  • Help Room /
avatar image
0
Question by Herman1981 · Jan 23, 2018 at 04:47 PM · animationshadereffect

Multiple Shader passes: create scrolling Matrix effect

Hello anybody out there,

For my VR project I would like to use a (simple) Matrix effect. I would like to create a hallway which looks like this from the movie The Matrix:

alt text

I created a test where I applied 4 materials to the Mesh Renderer of a cube. With a simple script I was able to animate it and get the following result (this level of result is fine for this project):

alt text

But Unity gives me the warning to use multiple shader passes instead (because perfomance costs). I'm kind of new to shaders in Unity. Always used imagetextures.
Is this scrolling effect possible to make with multiple shader passes? And where to begin? Can someone point me in the right direction? Maybe even some basic code?

Thanks in advance! (PS: I also saw this online but although they did a great job, it's not the result I would like to achieve.

large-matrix-blu-ray7.jpg (236.3 kB)
matrix.gif (524.3 kB)
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
0

Answer by Herman1981 · Jan 25, 2018 at 08:26 AM

I managed to achieve the desired effect for a matrix-effect-shader with the following shader, copy-and-pasted together from several scripts (most credit goes out to @DMinsky):

 Shader "Custom/TestShader03" {
     Properties{
         _MainTex("Base (RGB)", 2D) = "white" {}
         _MainTex2("Text 2 (RGB)", 2D) = "white" {}
         _MainTex3("Text 3 (RGB)", 2D) = "white" {}
         _MainTex4("Text 4 (RGB)", 2D) = "white" {}
 
         _MainTex1_YScrollSpeed("Y Scroll Speed", Float) = 1
         _MainTex2_YScrollSpeed("Y Scroll Speed", Float) = 1
         _MainTex3_YScrollSpeed("Y Scroll Speed", Float) = 1
         _MainTex4_YScrollSpeed("Y Scroll Speed", Float) = 1
     }
 
     SubShader{
         AlphaTest GEqual[_Cuttoff]
 
         Tags{ "RenderType" = "Opaque" }
         LOD 200
  
         CGPROGRAM
         #pragma surface surf Lambert
  
         sampler2D _MainTex;
         sampler2D _MainTex2;
         sampler2D _MainTex3;
         sampler2D _MainTex4;
 
         float _MainTex1_YScrollSpeed;
         float _MainTex2_YScrollSpeed;
         float _MainTex3_YScrollSpeed;
         float _MainTex4_YScrollSpeed;
  
         struct Input {
             float2 uv_MainTex;
             float2 uv_MainTex2;
             float2 uv_MainTex3;
             float2 uv_MainTex4;

         };
  
         void surf(Input IN, inout SurfaceOutput o) {
             
             fixed2 scrollUV_1 = IN.uv_MainTex;
             fixed yScrollValue_1 = -_MainTex1_YScrollSpeed * _Time.x;
             scrollUV_1 += fixed2(0, yScrollValue_1);
 
             fixed2 scrollUV_2 = IN.uv_MainTex2;
             fixed yScrollValue_2 = -_MainTex2_YScrollSpeed * _Time.x;
             scrollUV_2 += fixed2(0, yScrollValue_2);
 
             fixed2 scrollUV_3 = IN.uv_MainTex3;
             fixed yScrollValue_3 = -_MainTex3_YScrollSpeed * _Time.x;
             scrollUV_3 += fixed2(0, yScrollValue_3);
 
             fixed2 scrollUV_4 = IN.uv_MainTex4;
             fixed yScrollValue_4 = -_MainTex4_YScrollSpeed * _Time.x;
             scrollUV_4 += fixed2(0, yScrollValue_4);
 
             half4 tex = tex2D(_MainTex, scrollUV_1);
             half4 tex2 = tex2D(_MainTex2, scrollUV_2);
             half4 tex3 = tex2D(_MainTex3, scrollUV_3);
             half4 tex4 = tex2D(_MainTex4, scrollUV_4);
 
             half3 temp1 = lerp (tex.rgb, tex2.rgb, tex2.a*1);
             half3 temp2 = lerp (temp1, tex3.rgb, tex3.a*1);
             half3 c = lerp (temp2, tex4.rgb, tex4.a*1);
 
             o.Albedo = c.rgb;
 
         }
         ENDCG
     }
     FallBack "Diffuse" 
 }


It works pretty well, but I would like to have more control of the tile-size of the texture. I tried to set it to worldscale, ending up with scroll effects going far to fast, far to dense or acting totally weird.

I think the problem is the combination with the lerp function? Offcourse this is due to my lack of shader-knowledge, but I'm catching up. But in this case I would like to get a push in the right direction. Anybody?

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
avatar image
0

Answer by alexweno · Oct 21, 2018 at 10:35 AM

Hello! Have you manage to tile it world scale please?

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

276 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 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

Simulate a neuron firing effect? 1 Answer

Can I make a dynamic wave ui with shader ? 0 Answers

How to use shader to control the rendering of each text character(letter)? Or, how to correctly pass custom data into vert/frag? 0 Answers

Texture overlay in sphere? 0 Answers

Problem with an Outline shader's depth 0 Answers


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