• 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 YoungDeveloper · Jul 08, 2015 at 10:20 PM · shaderstandard

Standard shader texture blend

I want to implement two texture, normal and color fade on top of the unity 5 standard shader. I created new standard shader clone and made new shader editor for it. In shader itself i created required properties.

alt text

From this point i am lost, i tried to create texture, color and normal lerp using various approaches. But it just doesn't looks like anythings changing. Similar approach worked on custom shader though.

 Pass
         {
             Name "DEFERRED"
             Tags { "LightMode" = "Deferred" }
 
             CGPROGRAM
             #pragma target 3.0
             // TEMPORARY: GLES2.0 temporarily disabled to prevent errors spam on devices without textureCubeLodEXT
             #pragma exclude_renderers nomrt gles
             
 
             // -------------------------------------
 
             #pragma shader_feature _NORMALMAP
             #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
             #pragma shader_feature _EMISSION
             #pragma shader_feature _METALLICGLOSSMAP
             #pragma shader_feature ___ _DETAIL_MULX2
             #pragma shader_feature _PARALLAXMAP
 
             #pragma multi_compile ___ UNITY_HDR_ON
             #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
             #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
             #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
             
             #pragma vertex vertDeferred
             #pragma fragment fragDeferred
 
             #include "UnityStandardCore.cginc"
 
 
             //sampler2D _MainTex;
             sampler2D _MainTex1;
             fixed4 _Color1;
             float _Blend;
 
 
             struct Input {
                 float2 uv_MainTex;
                 //float2 uv_BumpMap;
             };
 
             void surf (Input IN, inout SurfaceOutputStandard o) {
               fixed4 t1  = tex2D( _MainTex, IN.uv_MainTex ) * _Color;
               fixed4 t2  = tex2D ( _MainTex1, IN.uv_MainTex ) * _Color1;
 
               o.Albedo  = lerp( t1, t2, _Blend );
           }

I started to learn and work with shader just now, pardon me if i dont jump on the wagon on the first time.

Comment
Add comment · Show 3
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 _Gkxd · Jul 08, 2015 at 10:30 PM 0
Share

I believe this shader will fail to compile, since you're using _$$anonymous$$ainTex but it's commented out.

You also need the line fixed4 _Color; somewhere if you want to use _Color in the fragment shader.

Edit:

I didn't realize that you were writing a surface shader. Surface shaders are something that Unity uses to generate vertex and fragment shaders, so it's harder to deter$$anonymous$$e what's going wrong when things do go wrong.

If you do want a simple shader that can blend textures I suggest writing a vertex and fragment shader from scratch, though this shader wouldn't have all the functionality that the standard shader has. The Unity documentation on this is pretty good if you do decide to go this route.

Sorry for misunderstanding.

avatar image YoungDeveloper · Jul 08, 2015 at 10:34 PM 0
Share

I had/was the same question. Color and $$anonymous$$ainTex are defined in properties, if i sample them here i **get redefinition of '$$anonymous$$ainTex' at line 189 (on d3d11)** Note, that this would work under ordinary shader, i could sample them without any problems.

edit: Yeah, i had no problems writing a simple blend using vertex and fragment, but i'd really like a good looking shader like unity 5 one ;)

avatar image DjEmix · Mar 03, 2016 at 01:45 PM 1
Share

Hello!! Can you finish the shader? I am looking for one standard shader with two textures blender but I don't find anything. Do your shader works?

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.

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

23 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

Related Questions

Please help me resolve these errors related to shaders. 0 Answers

Unity 5, uv not working in standard shader 3 Answers

Has line on the edge of the mesh when use fade shader. Any idea how to solve? 0 Answers

Unity standard shader source? 1 Answer

How to convert Legacy/Particles/Alpha Blended to Standard?And How to configure the standard option? 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