• 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
Question by ReiBM · Jun 06, 2014 at 10:49 PM · shadercg

Shader Not Blending Textures on Mobile

Hey all, I was just wondering if anyone had any idea why this shader doesn't work for mobile. The specific line that has problems is : col = lerp(col, c, 0.5);

Whenever it is set to 0 or 1 it will work, however any values in between don't seem to function properly and give me a pink terrain with the error "no subshaders can run on this graphics card"

I am attempting to write the shader for the Android platform at the moment. I haven't ever really done shader programming, so I apologize if it looks horrid.

     Shader "Fog Of War/Terrain" {
         Properties {
             _FOWTex ("Detail", 2D) = "gray" {}
             
             // Textures
                 _Control ("Control (RGBA)", 2D) = "white" {}
             _Splat3 ("Layer 3 (A)", 2D) = "white" {}
             _Splat2 ("Layer 2 (B)", 2D) = "white" {}
             _Splat1 ("Layer 1 (G)", 2D) = "white" {}
             _Splat0 ("Layer 0 (R)", 2D) = "white" {}
         
         }
         SubShader {
             Tags { 
                     "RenderType"="Opaque" 
                     "Queue" = "Geometry-100"
                     "SplatCount" = "4"
                 }
             CGPROGRAM
             #pragma surface surf Lambert
             #pragma target 3.0
             
             #include "UnityCG.cginc"
             
             struct Input {
                 float2 uv_FOWTex;
                 float2 uv_Control : TEXCOORD0;
                 float2 uv_Splat0 : TEXCOORD1;
                 float2 uv_Splat1 : TEXCOORD2;
                 float2 uv_Splat2 : TEXCOORD3;
                 float2 uv_Splat3 : TEXCOORD4;
             };
             
             sampler2D _FOWTex;
             sampler2D _Control;
             sampler2D _Splat0,_Splat1,_Splat2,_Splat3;
             
             void surf (Input IN, inout SurfaceOutput o) {
                 fixed4 splat_control = tex2D (_Control, IN.uv_Control).rgba;
                 float4 col;
                 float4 c;
                 
                 col  = splat_control.r * tex2D (_Splat0, IN.uv_Splat0);
                 col += splat_control.g * tex2D (_Splat1, IN.uv_Splat1);
                 col += splat_control.b * tex2D (_Splat2, IN.uv_Splat2);
                 col += splat_control.a * tex2D (_Splat3, IN.uv_Splat3);
                 c     = tex2D (_FOWTex, IN.uv_FOWTex).aaaa;
                 col = lerp(col, c, 0.5);
                 o.Albedo = col;
                 o.Alpha = 0.0;
             }
             
             ENDCG
         } 
         Dependency "AddPassShader" = "MyShaders/Terrain/Editor/AddPass"
         Dependency "BaseMapShader" = "MyShaders/Terrain/Editor/BaseMap"
     }
Comment

People who like this

0 Show 0
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

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by ReiBM · Jun 07, 2014 at 03:19 PM

I found that after modifying the above

pragma surface surf Lambert

To :

pragma surface surf Lambert decal:add decal:blend alpha

The script works properly.

Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

21 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

Related Questions

How to force the compilation of a shader in Unity? 5 Answers

custom Standard Shader alpha issues. 1 Answer

Forcing Multi-Pass shader to use Deferred passes instead of Forward passes? 1 Answer

How do i turn off "Receive Shadows" and "Cast Shadows" in a Shader Script?? 1 Answer

Vertex Shader Properties Issu 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