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 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
Add comment · Show 2
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 dan_wipf · Mar 28, 2019 at 12:41 PM 0
Share

can you post links or the two single shaders?

avatar image BarbySenpai · Apr 01, 2019 at 07:31 AM 0
Share

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"
 }


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

235 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

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

A Blend Shader That Uses Vertex Information 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