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 wasicool7 · Dec 19, 2016 at 11:51 PM · shadertexturecolor

Unity2D: Remove Shader Colour

Hi, I have a shader that I found to help me with a battle transition, I've done all my scripting for it; and it does work, I only have one problem with the shader I found, which is the colour. I want to remove the colour within the shader or at least make it transparent so that the natural texture colour can show! I tried removing anything to do with colour in the shader script, but I got an error and it also made my shader pink! It would me much appreciated if anyone can help me! Thank you :)

The error:

Shader error in 'Hidden/BattleTransitions': 'lerp': no matching 2 parameter intrinsic function; Possible intrinsic functions are: lerp(float|half|min10float|min16float, float|half|min10float|min16float, float|half|min10float|min16float) at line 104 (on d3d11) Compiling Vertex program Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING

The Script:

    Shader "Hidden/BattleTransitions"
    {
      Properties
      {
       _MainTex("Texture", 2D) = "white" {}
     _  TransitionTex("Transition Texture", 2D) = "white" {}
     _Color("Screen Color", Color) = (1,1,1,1)
     _Cutoff("Cutoff", Range(0, 1)) = 0
     [MaterialToggle] _Distort("Distort", Float) = 0
     _Fade("Fade", Range(0, 1)) = 0
 }

     SubShader
     {
         // No culling or depth
         Cull Off ZWrite Off ZTest Always

         Pass
         {
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag

             #include "UnityCG.cginc"

             struct appdata
             {
                 float4 vertex : POSITION;
                 float2 uv : TEXCOORD0;
             };

             struct v2f
             {
                 float2 uv : TEXCOORD0;
                 float2 uv1 : TEXCOORD1;
                 float4 vertex : SV_POSITION;
             };

             float4 _MainTex_TexelSize;

             v2f simplevert(appdata v)
             {
                 v2f o;
                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                 o.uv = v.uv;
                 return o;
             }

             v2f vert(appdata v)
             {
                 v2f o;
                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                 o.uv = v.uv;
                 o.uv1 = v.uv;

                 #if UNITY_UV_STARTS_AT_TOP
                 if (_MainTex_TexelSize.y < 0)
                     o.uv1.y = 1 - o.uv1.y;
                 #endif

                 return o;
             }

             sampler2D _TransitionTex;
             int _Distort;
             float _Fade;

             sampler2D _MainTex;
             float _Cutoff;
             fixed4 _Color;

             fixed4 simplefrag(v2f i) : SV_Target
             {
                 if (i.uv.x < _Cutoff)
                     return _Color;

                 return tex2D(_MainTex, i.uv);
             }

             fixed4 simplefragopen(v2f i) : SV_Target
             {
                 if (0.5 - abs(i.uv.y - 0.5) < abs(_Cutoff) * 0.5)
                     return _Color;

                 return tex2D(_MainTex, i.uv);
             }

             fixed4 simpleTexture(v2f i) : SV_Target
             {
                 fixed4 transit = tex2D(_TransitionTex, i.uv);

                 if (transit.b < _Cutoff)
                     return _Color;

                 return tex2D(_MainTex, i.uv);
             }

             fixed4 frag(v2f i) : SV_Target
             {
                 fixed4 transit = tex2D(_TransitionTex, i.uv1);

                 fixed2 direction = float2(0,0);
                 if(_Distort)
                     direction = normalize(float2((transit.r - 0.5) * 2, (transit.g - 0.5) * 2));

                 fixed4 col = tex2D(_MainTex, i.uv + _Cutoff * direction);

                 if (transit.b < _Cutoff)
                     return col = lerp(col, _Color, _Fade);

                 return col;
             }                    
             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

118 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

Related Questions

Using Texture as HDR color? 2 Answers

Need help to combine shaders, is this possible? 0 Answers

Solid color texture or adding a color property to shader? 1 Answer

Tint Multiple Textures Separately 1 Answer

Small bug? on ShaderGraph 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