Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 Dolzen · Jul 29, 2015 at 08:27 PM · shadershadow

Make this shader receive and cast shadow? Can anyone help me thanks!

Hello everyone! I have this simple shader which blend between textures depending on vertex positions, but it's Unlit, I'm not a shader expert is there a way to make this shader receive and cast shadows? thanks!

 Shader "Custom/blend" {
         Properties {
             _Tex0 ("Tex 0", 2D) = "white" {}
             _Tex1 ("Tex 1", 2D) = "white" {}
             _Tex2 ("Tex 2", 2D) = "white" {}
             _Tex3 ("Tex 3", 2D) = "white" {}
             _Tex4 ("Tex 4", 2D) = "white" {}
             _Tex5 ("Tex 5", 2D) = "white" {}
             _Tex6 ("Tex 6", 2D) = "white" {}
 
             _Blend0to1and1to2 ("Blend between 0 and 1, 1 and 2", Vector) = (0,1,2,3)
             _Blend2to3and3to4 ("Blend between 2 and 3, 3 and 4", Vector) = (0,1,2,3)
             _Blend4to5and5to6 ("Blend between 4 and 5, 5 and 6", Vector) = (0,1,2,3)
            
         }
         SubShader {
             Lighting Off
             Fog { Mode Off }
             Pass {
                 Blend SrcAlpha OneMinusSrcAlpha
                 CGPROGRAM
                     #pragma vertex vert
                     #pragma fragment frag
                     #include "UnityCG.cginc"
                     #pragma target 3.0
                     sampler2D _Tex0;
                     sampler2D _Tex1;
                     sampler2D _Tex2;
                     sampler2D _Tex3;
                     sampler2D _Tex4;
                     sampler2D _Tex5;
                     sampler2D _Tex6;
                     float4 _Blend0to1and1to2;
                     float4 _Blend2to3and3to4;
                     float4 _Blend4to5and5to6;
                     uniform float4 _Tex0_ST;
            
                     struct v2f {
                         float4 pos : SV_POSITION;
                         float2 uv : TEXCOORD0;
                         float4 col : COLOR;
                     };
                    
                     v2f vert (appdata_base vInput) {
                         v2f OUT;
                         OUT.pos = mul (UNITY_MATRIX_MVP, vInput.vertex);
                         OUT.uv = TRANSFORM_TEX(vInput.texcoord, _Tex0);
                         OUT.col = length(vInput.vertex);
                         return OUT;
                     }
                    
                     half4 frag (v2f fInput) : COLOR {
                         half4 c0 = tex2D (_Tex0, fInput.uv);
                         half4 c1 = tex2D (_Tex1, fInput.uv);
                         half4 c2 = tex2D (_Tex2, fInput.uv);
                         half4 c3 = tex2D (_Tex3, fInput.uv);
                         half4 c4 = tex2D (_Tex4, fInput.uv);
                         half4 c5 = tex2D (_Tex5, fInput.uv);
                         half4 c6 = tex2D (_Tex6, fInput.uv);
      
                         if (fInput.col.x < _Blend0to1and1to2.x) return c0;
                         
                         if (fInput.col.x > _Blend0to1and1to2.x && fInput.col.x < _Blend0to1and1to2.y) return lerp(c0,c1,((fInput.col.x - _Blend0to1and1to2.x)/(_Blend0to1and1to2.y-_Blend0to1and1to2.x)));
                         if (fInput.col.x > _Blend0to1and1to2.y && fInput.col.x < _Blend0to1and1to2.z) return c1;
                         if (fInput.col.x > _Blend0to1and1to2.z && fInput.col.x < _Blend0to1and1to2.w) return lerp(c1,c2,((fInput.col.x - _Blend0to1and1to2.z)/(_Blend0to1and1to2.w-_Blend0to1and1to2.z)));
                         
                         if (fInput.col.x > _Blend0to1and1to2.w && fInput.col.x < _Blend2to3and3to4.x) return c2;
                         
                         if (fInput.col.x > _Blend2to3and3to4.x && fInput.col.x < _Blend2to3and3to4.y) return lerp(c2,c3,((fInput.col.x - _Blend2to3and3to4.x)/(_Blend2to3and3to4.y-_Blend2to3and3to4.x)));
                         if (fInput.col.x > _Blend2to3and3to4.y && fInput.col.x < _Blend2to3and3to4.z) return c3;
                         if (fInput.col.x > _Blend2to3and3to4.z && fInput.col.x < _Blend2to3and3to4.w) return lerp(c3,c4,((fInput.col.x - _Blend2to3and3to4.z)/(_Blend2to3and3to4.w-_Blend2to3and3to4.z)));
                         
                         if (fInput.col.x > _Blend2to3and3to4.w && fInput.col.x < _Blend4to5and5to6.x) return c4;
                         
                         if (fInput.col.x > _Blend4to5and5to6.x && fInput.col.x < _Blend4to5and5to6.y) return lerp(c4,c5,((fInput.col.x - _Blend4to5and5to6.x)/(_Blend4to5and5to6.y-_Blend4to5and5to6.x)));
                         if (fInput.col.x > _Blend4to5and5to6.y && fInput.col.x < _Blend4to5and5to6.z) return c5;
                         if (fInput.col.x > _Blend4to5and5to6.z && fInput.col.x < _Blend4to5and5to6.w) return lerp(c5,c6,((fInput.col.x - _Blend4to5and5to6.z)/(_Blend4to5and5to6.w-_Blend4to5and5to6.z)));
                         
                         return c6;
                        
      
                     }
                 ENDCG
             }
         }
     }
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

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

2 People are following this question.

avatar image avatar image

Related Questions

Help with making a water shader receive light 1 Answer

how to add shadows to billboard shader help.... 2 Answers

Why won't my transparent with shader allow me to change the opacity 1 Answer

Unity Water Shadows? 0 Answers

HDRP + VR not working in 2020.1.0f1? 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