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 /
avatar image
0
Question by andrewlaboy · Jan 03, 2019 at 03:37 AM · shader

How do I combine these two shaders?

        #include "UnityCG.cginc"
             #pragma glsl_no_auto_normalizationShader "TSF/Base1" 

{ Properties { [MaterialToggle(_TEX_ON)] _DetailTex ("Enable Detail texture", Float) = 0 //1 _MainTex ("Detail", 2D) = "white" {} //2 _ToonShade ("Shade", 2D) = "white" {} //3 [MaterialToggle(_COLOR_ON)] _TintColor ("Enable Color Tint", Float) = 0 //4 _Color ("Base Color", Color) = (1,1,1,1) //5
[MaterialToggle(_VCOLOR_ON)] _VertexColor ("Enable Vertex Color", Float) = 0//6
_Brightness ("Brightness 1 = neutral", Float) = 1.0 //7
}

 Subshader 
 {
     Tags { "RenderType"="Opaque" }
     LOD 250
     ZWrite On
        Cull Back
     Lighting Off
     Fog { Mode Off }
     
     Pass 
     {
         Name "BASE"
         CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #pragma fragmentoption ARB_precision_hint_fastest
             #pragma multi_compile _TEX_OFF _TEX_ON
             #pragma multi_compile _COLOR_OFF _COLOR_ON

             
             #if _TEX_ON
             sampler2D _MainTex;
             half4 _MainTex_ST;
             #endif
             
             struct appdata_base0 
             {
                 float4 vertex : POSITION;
                 float3 normal : NORMAL;
                 float4 texcoord : TEXCOORD0;
             };
             
              struct v2f 
              {
                 float4 pos : SV_POSITION;
                 #if _TEX_ON
                 half2 uv : TEXCOORD0;
                 #endif
                 half2 uvn : TEXCOORD1;
              };
            
             v2f vert (appdata_base0 v)
             {
                 v2f o;
                 o.pos = UnityObjectToClipPos ( v.vertex );
                 float3 n = mul((float3x3)UNITY_MATRIX_IT_MV, normalize(v.normal));
                 normalize(n);
                 n = n * float3(0.5,0.5,0.5) + float3(0.5,0.5,0.5);
                 o.uvn = n.xy;
                  #if _TEX_ON
                 o.uv = TRANSFORM_TEX ( v.texcoord, _MainTex );
                 #endif
                 return o;
             }

               sampler2D _ToonShade;
             fixed _Brightness;
             
             #if _COLOR_ON
             fixed4 _Color;
             #endif
             
             fixed4 frag (v2f i) : COLOR
             {
                 #if _COLOR_ON
                 fixed4 toonShade = tex2D( _ToonShade, i.uvn )*_Color;
                 #else
                 fixed4 toonShade = tex2D( _ToonShade, i.uvn );
                 #endif
                 
                 #if _TEX_ON
                 fixed4 detail = tex2D ( _MainTex, i.uv );
                 return  toonShade * detail*_Brightness;
                 #else
                 return  toonShade * _Brightness;
                 #endif
             }
         ENDCG
     }
 }
 Fallback "Legacy Shaders/Diffuse"

}

Shader "TeleportFade/Standerd" { Properties { _Color("Color", Color) = (1,1,1,1) _MainTex("Albedo (RGB)", 2D) = "white" {} _Glossiness("Smoothness", Range(0,1)) = 0.5 _Metallic("Metallic", Range(0,1)) = 0.0 _FadeTex("Fade Texture", 2D) = "white" {} _RisePower("Rise Power", Float) = 0.1 _TwistPower("Twist Power", Float) = 0.0 _SpreadPower("Spread Power", Float) = 1.0 _Brightness ("Brightness 1 = neutral", Float) = 1.0
_ParticleColor("Particle Color", Color) = (0.0,0.3,0.8,1) _FadeRate("Fade Rate", Range(0, 1)) = 0.5 _ObjectHeight("Object Height", Float) = 2.0 _ObjectFadeHeight("Object Fade Height", Float) = 0.2 _ObjectBasePos("Object Base Position", Vector) = (0,0,0,0) } SubShader { Tags { "RenderType"="Opaque" } LOD 200

     CGPROGRAM
     // Physically based Standard lighting model, and enable shadows on all light types
     #pragma surface surf Standard fullforwardshadows vertex:vert

     // Use shader model 3.0 target, to get nicer looking lighting
     #pragma target 3.0

     sampler2D _MainTex;
     sampler2D _FadeTex;

     struct Input {
         float2 uv_MainTex;
         float4 packedData;
     };

     half _Glossiness;
     half _Metallic;
     fixed4 _Color;

     half _FadeRate;
     half _ObjectFadeHeight;
     half _RisePower;
     half _SpreadPower;
     half _TwistPower;
     fixed4 _ParticleColor;
     half _ObjectHeight;
     float4 _ObjectBasePos;

     void vert(inout appdata_full v, out Input data)
     {
         UNITY_INITIALIZE_OUTPUT(Input, data);
         float4 worldPos = mul(unity_ObjectToWorld, v.vertex);
         float height = lerp(_ObjectHeight, -_ObjectFadeHeight, _FadeRate);
         float warpRate = saturate((worldPos.y - (height + _ObjectBasePos.y)) / _ObjectFadeHeight);
         warpRate *= warpRate;
         worldPos.y += warpRate * _RisePower;
         float2 dir = worldPos.xz - _ObjectBasePos.xz;
         float rot = warpRate * _TwistPower;
         worldPos.x = cos(rot) * dir.x - sin(rot) * dir.y;
         worldPos.z = sin(rot) * dir.x + cos(rot) * dir.y;
         worldPos.xz *= _SpreadPower * warpRate + 1.0;
         worldPos.xz += _ObjectBasePos.xz;
         v.vertex = mul(unity_WorldToObject, worldPos);

         data.packedData.z = warpRate;
         data.packedData.xw = UnityObjectToClipPos(v.vertex).xw;
     }

     void surf (Input IN, inout SurfaceOutputStandard o) {
         half2 uv;
         uv.x = _ScreenParams.x * IN.packedData.x / IN.packedData.w / 128.0;
         uv.y = saturate(IN.packedData.z - 0.01);
         fixed4 fadeColor = tex2D(_FadeTex, uv);
         clip(fadeColor.r - 0.1);
         // Albedo comes from a texture tinted by color
         fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
         o.Albedo = c.rgb;
         // Metallic and smoothness come from slider variables
         o.Metallic = _Metallic;
         o.Smoothness = _Glossiness;
         o.Emission = _ParticleColor.rgb * _ParticleColor.a * saturate(IN.packedData.z * 2.0);
         o.Alpha = c.a;
     }
     ENDCG
 }
 FallBack "Diffuse"

}

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

156 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

Related Questions

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

How to make transparent object without seeing back parts and keeping emission, specular highlights and reflections 0 Answers

How to not require normals in a surface shader 1 Answer

Sequential shaders. Pass the output color of a shader to the next one. 0 Answers

Unity - Simple Water 3 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