Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 K-16Games · Jul 22, 2018 at 05:21 AM · shadertexturetransparencyalphaflow

Add transparency to this shader?

I have a basic shader that uses a flow map to distort an image over time, following a few tutorials I found. I'd like to add transparency, or find a way to use a texture with transparency on this shader to create layers of clouds or water. Nothing fancy. Is there a way to modify this script without breaking it?

 Shader "Plexus/BasicFlowMap" {
     Properties {
         _MainTex ("Base (RGB)", 2D) = "white" {}
         _FlowMap ("Flow Map", 2D) = "grey" {}
         _Speed ("Speed", Range(-1, 1)) = 0.2
     }
  
     SubShader {
         Pass {
             Tags { "RenderType"="Opaque" }
        
             CGPROGRAM
             #pragma vertex vert keepalpha
             #pragma fragment frag
             #include "UnityCG.cginc"
  
             struct v2f {
                 float4 pos : SV_POSITION;
                 fixed2 uv : TEXCOORD0;
             };
  
             sampler2D _MainTex;
             sampler2D _FlowMap;
             fixed _Speed;
  
             fixed4 _MainTex_ST;
  
             v2f vert(appdata_base IN) {
                 v2f o;
                 o.pos = UnityObjectToClipPos(IN.vertex);
                 o.uv = TRANSFORM_TEX(IN.texcoord, _MainTex);
                 return o;
             }
        
             fixed4 frag(v2f v) : COLOR {
                 fixed4 c;
                 half3 flowVal = (tex2D(_FlowMap, v.uv) * 2 - 1) * _Speed;
  
                 float dif1 = frac(_Time.y * 0.25 + 0.5);
                 float dif2 = frac(_Time.y * 0.25);
  
                 half lerpVal = abs((0.5 - dif1)/0.5);
  
                 half4 col1 = tex2D(_MainTex, v.uv - flowVal.xy * dif1);
                 half4 col2 = tex2D(_MainTex, v.uv - flowVal.xy * dif2);
  
                 c = lerp(col1, col2, lerpVal);
                 return c;
             }
  
             ENDCG
         }
     }
     FallBack "Diffuse"
 }
Comment
Add comment · Show 1
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 K-16Games · Jul 22, 2018 at 05:21 AM 0
Share

I am very new at building shaders... Thought I'd take a dive.

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

157 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

Related Questions

(c#) Transparency Problem - Toggle not Gradient 1 Answer

Alpha problem with textures on a plane 2 Answers

Making a cutout semi-transparent? 1 Answer

Render transparent material without double occlusion 2 Answers

Alpha as Illumination AND Transparency? 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