Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
2
Question by TranceDreams · Mar 04, 2018 at 10:51 AM · lightingshadersbackfaceunlit transparent

How to make Legacy Transparent Cutout Softedge unlit shader.... lit?

Hello. I love the legacy soft-edge cutout unlit shader, but how do you make it "lit" ? I just want it to allow tinting to match the lighting of the level, now that I have a night and day script.

My characters are 2d. I need soft-edges, flat coloring, and to show backfaces.

I found this script that keeps things cutout, keeps the color flat, show backfaces, and tints based on global lighting which is darn close to what I'm looking for, but it has no soft-edging like the original shader.

You can test it against the original legacy shader to see what I'm talking about. Just darken the over lighting in the level like your making it night time.

How do I adjust this? thanks

  Shader "Characters" {
       Properties {
           _Color ("Main Color", Color) = (1,1,1,1)
           _MainTex ("Main Texture", 2D) = "white" {  }
           _Cutoff ("Alpha cutoff", Float) = 0.5
           _BaseLight ("Base Light", Float) = 0.5
           _AO ("Amb. Occlusion", Float) = 0
           _Occlusion ("Dir Occlusion", Float) = 0
           
           // These are here only to provide default values
           [HideInInspector] _TreeInstanceColor ("TreeInstanceColor", Vector) = (1,1,1,1)
           [HideInInspector] _TreeInstanceScale ("TreeInstanceScale", Vector) = (1,1,1,1)
           [HideInInspector] _SquashAmount ("Squash", Float) = 1
       }
       
       SubShader {
           Tags {
               "Queue" = "Transparent"
               "IgnoreProjector"="True"
               "RenderType" = "TreeTransparentCutout"
               "DisableBatching"="True"
           }
           Cull Off
           ColorMask RGB
           
           Pass {
               Lighting On
           
               CGPROGRAM
               #pragma vertex leaves
               #pragma fragment frag
               #pragma multi_compile_fog
               #include "UnityBuiltin2xTreeLibrary.cginc"
               
               sampler2D _MainTex;
               fixed _Cutoff;
               
               fixed4 frag(v2f input) : SV_Target
               {
                   fixed4 c = tex2D( _MainTex, input.uv.xy);
                   c.rgb *= input.color.rgb;
                   
                   clip (c.a - _Cutoff);
                   UNITY_APPLY_FOG(input.fogCoord, c);
                   return c;
               }
               ENDCG
           }
           
           Pass {
               Name "ShadowCaster"
               Tags { "LightMode" = "ShadowCaster" }
               
               CGPROGRAM
               #pragma vertex vert
               #pragma fragment frag
               #pragma multi_compile_shadowcaster
               #include "UnityCG.cginc"
               #include "TerrainEngine.cginc"
               
               struct v2f { 
                   V2F_SHADOW_CASTER;
                   float2 uv : TEXCOORD1;
               };
               
               struct appdata {
                   float4 vertex : POSITION;
                   float3 normal : NORMAL;
                   fixed4 color : COLOR;
                   float4 texcoord : TEXCOORD0;
               };
               v2f vert( appdata v )
               {
                   v2f o;
                   TerrainAnimateTree(v.vertex, v.color.w);
                   TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
                   o.uv = v.texcoord;
                   return o;
               }
               
               sampler2D _MainTex;
               fixed _Cutoff;
                       
               float4 frag( v2f i ) : SV_Target
               {
                   fixed4 texcol = tex2D( _MainTex, i.uv );
                   clip( texcol.a - _Cutoff );
                   SHADOW_CASTER_FRAGMENT(i)
               }
               ENDCG    
           }
       }
       
       // This subshader is never actually used, but is only kept so
       // that the tree mesh still assumes that normals are needed
       // at build time (due to Lighting On in the pass). The subshader
       // above does not actually use normals, so they are stripped out.
       // We want to keep normals for backwards compatibility with Unity 4.2
       // and earlier.
       SubShader {
           Tags {
               "Queue" = "Transparent-99"
               "IgnoreProjector"="True"
               "RenderType" = "TransparentCutout"
           }
           Cull Off
           ColorMask RGB
           Pass {
               Tags { "LightMode" = "Vertex" }
               AlphaTest GEqual [_Cutoff]
               Lighting On
               Material {
                   Diffuse [_Color]
                   Ambient [_Color]
               }
               SetTexture [_MainTex] { combine primary * texture DOUBLE, texture }
           }        
       }
   
       Dependency "BillboardShader" = "Hidden/Nature/Tree Soft Occlusion Leaves Rendertex"
       Fallback Off
   }



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

104 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

Related Questions

Character Realism 1 Answer

Shader to get shadows after baking but do not change color of texture 0 Answers

[3D] How to make lighting doesn't affect on character ? 2 Answers

How to fix this point light bug in surface shader? 1 Answer

Lighting and shadows for LineRenderer 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