Question by 
               BarbySenpai · Mar 28, 2019 at 11:41 AM · 
                shadershadersshader programmingshader writingcombine  
              
 
              Combine 2 Shaders,Combine 2 shaders
Hi,
I am trying to combine two Shaders into one so that I can modify the movement of the object and have its own light. I have managed to compile it without errors but it does not work and it only shows a white light but it does not give light. Something strange. I'm not an expert of #C but i'm trying to do my best
I'm trying to do this in for magic leap (Unity 2018.1.9MLTP10)
Code:
 Shader "2Shaders/Prueba2Shaders"
 {Properties
 {
     _Tess("Tessellation", Range(1,8)) = 4
     _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
 _NoiseScale("Noise Scale", float) = 1
 _NoiseFrequency("Noise Frequency", float) = 1
 _NoiseOffset("Noise Offset", Vector) = (0,0,0,0)
 _EmissionColor("Emission Color", Color) = (0,0,0)
 _Threshold("Threshold", Range(0., 1.)) = 1.
 _SecondaryText("Emissive Map", 2D) = "white" {}
 }
     SubShader{
     Tags{ "RenderType" = "Opaque" }
     LOD 100
     Cull Off
     ZWrite On
 
      CGPROGRAM
 #pragma enable_d3d11_debug_symbols
 #pragma surface surf Standard fullforwardshadows tessellate:tess vertex:vert
 
 #pragma target 4.6
 
 #include "noiseSimplex.cginc"
 
     struct appdata {
     float4 vertex : POSITION;
     float3 normal : NORMAL;
     float2 texcoord : TEXCOORD0;
 };
 
 sampler2D _MainTex;
 
 struct Input
 {
     float2 uv_MainTex;
 };
 
 float _Tess;
 half _Glossiness;
 half _Metallic;
 fixed4 _Color;
 
 float _NoiseScale, _NoiseFrequency;
 float4 _NoiseOffset;
 
 float4 tess()
 {
     return _Tess;
 }
 
 void vert(inout appdata v)
 {
     float noise = _NoiseScale * snoise(float3(v.vertex.x + _NoiseOffset.x, v.vertex.y + _NoiseOffset.y, v.vertex.z + _NoiseOffset.z) * _NoiseFrequency);
     v.vertex.y += noise;
 }
 
 void surf(Input IN, inout SurfaceOutputStandard o) {
     fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
     o.Albedo = c.rgb;
     o.Metallic = _Metallic;
     o.Smoothness = _Glossiness;
 }
 #ifdef SHADER_API_D3D11
 
 SubShader
 {
     Tags{ "RenderType" = "Emissive" }
     
 #include "UnityCG.cginc"
 #ifdef SHADER_API_D3D11
 
     struct v2f {
     float4 pos : SV_POSITION;
     fixed4 col : COLOR0;
     float2 uv : TEXCOORD0;
 };
 
 fixed4 _Color;
 fixed4 _LightColor0;
 float _Diffuse;
 
 sampler2D _MainTex;
 float4 _MainTex_ST;
 
 v2f vert(appdata_base v) {
     v2f o;
     o.pos = UnityObjectToClipPos(v.vertex);
     float3 worldNormal = normalize(mul(v.normal, (float3x3)unity_WorldToObject));
     float3 lightDir = normalize(_WorldSpaceLightPos0.xyz);
     float NdotL = max(0.0, dot(worldNormal, lightDir));
     fixed4 diff = _Color * NdotL * _LightColor0 * _Diffuse;
     o.col = diff;
     o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
     return o;
 }
 
 float4 _EmissionColor;
 float _Threshold;
 
 fixed4 frag(v2f i) : SV_Target{
     fixed3 emi = tex2D(_MainTex, i.uv).r * _EmissionColor.rgb * _Threshold;
 i.col.rgb += emi;
 return i.col;
 }
 }
 ENDCG
 }
     }
 
              
               Comment
              
 
               
              Sure, The emission shader --> http://www.shaderslab.com/demo-79---diffuse-and-emission.html $$anonymous$$oving shader -->
 Shader "Nieto/NoiseGround"
 {
     Properties
     {
         _Tess("Tessellation", Range(1,8)) = 4
         _Color("Color",Color) = (1,1,1,1)
         _$$anonymous$$ainTex("Albedo (RGB)", 2D) = "white" {}
     _Glossiness("Smoothness", Range(0,1)) = 0.5
         _$$anonymous$$etallic("$$anonymous$$etallic", Range(0,1)) = 0.0
         _NoiseScale("Noise Scale", float) = 1
         _NoiseFrequency("Noise Frequency", float) = 1
         _NoiseOffset("Noise Offset", Vector) = (0,0,0,0)
     }
         SubShader
     {
         Tags{ "RenderType" = "Opaque" }
 
         CGPROGRA$$anonymous$$
 #pragma surface surf Standard fullforwardshadows tessellate:tess vertex:vert
 
 #pragma target 4.6
 
 #include "noiseSimplex.cginc"
 
         struct appdata {
         float4 vertex : POSITION;
         float3 normal : NOR$$anonymous$$AL;
         float2 texcoord : TEXCOORD0;
     };
 
     sampler2D _$$anonymous$$ainTex;
 
     struct Input
     {
         float2 uv_$$anonymous$$ainTex;
     };
 
     float _Tess;
     half _Glossiness;
     half _$$anonymous$$etallic;
     fixed4 _Color;
 
     float _NoiseScale, _NoiseFrequency;
     float4 _NoiseOffset;
 
     float4 tess()
     {
         return _Tess;
     }
 
     void vert(inout appdata v)
     {
         float noise = _NoiseScale * snoise(float3(v.vertex.x + _NoiseOffset.x, v.vertex.y + _NoiseOffset.y, v.vertex.z + _NoiseOffset.z) * _NoiseFrequency);
         v.vertex.y += noise;
     }
 
     void surf(Input IN, inout SurfaceOutputStandard o) {
         fixed4 c = tex2D(_$$anonymous$$ainTex, IN.uv_$$anonymous$$ainTex) * _Color;
         o.Albedo = c.rgb;
         o.$$anonymous$$etallic = _$$anonymous$$etallic;
         o.Smoothness = _Glossiness;
     }
     ENDCG
 
     }
         FallBack "Diffuse"
 }
                 Your answer
 
             Follow this Question
Related Questions
Add fog to vertex shader 0 Answers
Converted ShaderToy shader showing up black 1 Answer
Metallic material decomposing light in rainbow spectre? 0 Answers
_Time in Image Effects 0 Answers