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 Mr_Edward · Mar 03, 2016 at 07:21 PM · shaderspritetransparentunlitunlit transparent

Unlit Speed tree Bilboard shader

Hi there!

I'm attempting to modify the speedtree billboard shader to not recieve any lighting. I would like it to react like an unlit shader. Since I'm not too experienced with shader programming, I have been unable to achieve what I want, even after experimenting for quite a while.

I don't know how difficult it is to do this, but I can imagine that it's actually quite simple.

I really hope that somebody knows what I could do to achieve this.

I'll paste the SpeedTree Billboard Shader below:

Thanks :)

 Shader "Nature/SpeedTree Billboard Unlit"
 {
     Properties
     {
         _Color ("Main Color", Color) = (1,1,1,1)
         _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0)
         _HueVariation ("Hue Variation", Color) = (1.0,0.5,0.0,0.1)
         _Shininess ("Shininess", Range (0.01, 1)) = 0.078125
         _MainTex ("Base (RGB)", 2D) = "white" {}
         _BumpMap ("Normalmap", 2D) = "bump" {}
         _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
         [MaterialEnum(None,0,Fastest,1)] _WindQuality ("Wind Quality", Range(0,1)) = 0
     }
     
     // targeting SM3.0+
     SubShader
     {
         Tags
         {
             "Queue"="AlphaTest"
             "IgnoreProjector"="True"
             "RenderType"="TransparentCutout"
             "DisableBatching"="LODFading"
         }
         LOD 400
         Cull Off
 
         CGPROGRAM
             #pragma surface surf Lambert vertex:SpeedTreeBillboardVert nolightmap addshadow
             #pragma target 3.0
             #pragma multi_compile __ LOD_FADE_CROSSFADE
             #pragma multi_compile __ BILLBOARD_FACE_CAMERA_POS
             #pragma shader_feature EFFECT_BUMP
             #pragma shader_feature EFFECT_HUE_VARIATION
             #define ENABLE_WIND
             #include "SpeedTreeBillboardCommon_Unlit.cginc"
 
             void surf(Input IN, inout SurfaceOutput OUT)
             {
                 SpeedTreeFragOut o;
                 SpeedTreeFrag(IN, o);
                 SPEEDTREE_COPY_FRAG(OUT, o)
             }
         ENDCG
 
         Pass
         {
             Tags { "LightMode" = "Vertex" }
 
             CGPROGRAM
                 #pragma vertex vert
                 #pragma fragment frag
                 #pragma target 3.0
                 #pragma multi_compile_fog
                 #pragma multi_compile __ LOD_FADE_CROSSFADE
                 #pragma multi_compile __ BILLBOARD_FACE_CAMERA_POS
                 #pragma shader_feature EFFECT_HUE_VARIATION
                 #define ENABLE_WIND
                 #include "SpeedTreeBillboardCommon_Unlit.cginc"
 
                 struct v2f
                 {
                     float4 vertex    : SV_POSITION;
                     UNITY_FOG_COORDS(0)
                     Input data        : TEXCOORD1;
                 };
 
                 v2f vert(SpeedTreeBillboardData v)
                 {
                     v2f o;
                     SpeedTreeBillboardVert(v, o.data);
                     o.data.color.rgb *= ShadeVertexLightsFull(v.vertex, v.normal, 4, true);
                     o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                     UNITY_TRANSFER_FOG(o,o.vertex);
                     return o;
                 }
 
                 fixed4 frag(v2f i) : SV_Target
                 {
                     SpeedTreeFragOut o;
                     SpeedTreeFrag(i.data, o);
                     fixed4 c = fixed4(o.Albedo, o.Alpha);
                     UNITY_APPLY_FOG(i.fogCoord, c);
                     return c;
                 }
             ENDCG
         }
     }
 
     // targeting SM2.0: Cross-fading, Hue variation and Camera-facing billboard are turned off for less instructions
     SubShader
     {
         Tags
         {
             "Queue"="AlphaTest"
             "IgnoreProjector"="True"
             "RenderType"="TransparentCutout"
         }
         LOD 400
         Cull Off
 
         CGPROGRAM
             #pragma surface surf Lambert vertex:SpeedTreeBillboardVert nolightmap
             #pragma shader_feature EFFECT_BUMP
             #include "SpeedTreeBillboardCommon_Unlit.cginc"
 
             void surf(Input IN, inout SurfaceOutput OUT)
             {
                 SpeedTreeFragOut o;
                 SpeedTreeFrag(IN, o);
                 SPEEDTREE_COPY_FRAG(OUT, o)
             }
         ENDCG
 
         Pass
         {
             Tags { "LightMode" = "Vertex" }
 
             CGPROGRAM
                 #pragma vertex vert
                 #pragma fragment frag
                 #pragma multi_compile_fog
                 #include "SpeedTreeBillboardCommon_Unlit.cginc"
 
                 struct v2f 
                 {
                     float4 vertex    : SV_POSITION;
                     UNITY_FOG_COORDS(0)
                     Input data        : TEXCOORD1;
                 };
 
                 v2f vert(SpeedTreeBillboardData v)
                 {
                     v2f o;
                     SpeedTreeBillboardVert(v, o.data);
                     o.data.color.rgb *= ShadeVertexLightsFull(v.vertex, v.normal, 2, false);
                     o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                     UNITY_TRANSFER_FOG(o,o.vertex);
                     return o;
                 }
 
                 fixed4 frag(v2f i) : SV_Target
                 {
                     SpeedTreeFragOut o;
                     SpeedTreeFrag(i.data, o);
                     fixed4 c = fixed4(o.Albedo, o.Alpha);
                     UNITY_APPLY_FOG(i.fogCoord, c);
                     return c;
                 }
             ENDCG
         }
     }
 
     FallBack "Transparent/Cutout/VertexLit"
 }
 
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 $$anonymous$$ · May 12, 2017 at 03:47 AM 0
Share
  1. What shader I can choose for this code? Standart surface? Unlit? Compute?

  2. I has lot errors in Unityty 5.5.3

  3. If I setup this shader and it will work properly, can I change main color from script? Because Standart SpeedTree Bilboard do not chage color in runtime. rend.material.color= new Color don't work.

avatar image madfish-od · Nov 03, 2017 at 12:15 PM 0
Share

link text

unlitbillboard.txt (3.8 kB)
avatar image madfish-od · Nov 03, 2017 at 12:16 PM 0
Share

This one can do a trick I belive

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

63 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

Related Questions

unity renders all my points in white 0 Answers

Unlit Transparent Cutout shader that can switch between two textures 0 Answers

Render Texture causing sprite transparency errors 1 Answer

Making a color transparent in shaders 1 Answer

Unlit Texture Transparent Shader 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