Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 tarahugger · Aug 06, 2014 at 10:33 AM · shadershaderlabtree creatorwindzonealphablend

Blended Edges on Tree Creator Leaves

I need help with making Tree Creator trees to not look so pixelated. The default TreeCreator shaders appear to have hard edges because they just clip/cull if below a certain alpha.

I can get the look i want with various other shaders such as 'Mobile>Particles>VertexLit Blended' or the Alpha+Cutoff technique found here >> ShaderLab syntax: Alpha testing

But... those are static and won't animate with a WindZone because they don't include the vertex transforms like in TreeCreatorLeavesOptimized shader.

Update: Made some real progress on this problem and its mostly working; what sort of improvements can be made here? can it be done without the second pass? Also, is there a way i can reference the native Tree.cginc so i don't have to copy it into the project

alt textalt text

 Shader "Nature/Tree Creator Leaves Blended" {
 Properties {
 
     // Required by Tree Creator
     _Color ("Main Color", Color) = (1,1,1,1)
     _TranslucencyColor ("Translucency Color", Color) = (0.73,0.85,0.41,1) // (187,219,106,255)
     _TranslucencyViewDependency ("View dependency", Range(0,1)) = 0.7
     _ShadowStrength("Shadow Strength", Range(0,1)) = 0.8
     _ShadowOffsetScale ("Shadow Offset Scale", Float) = 1
 
     _Color ("Main Color", Color) = (1,1,1,1)
     _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
     _TranslucencyMap ("Translucency (A)", 2D) = "white" {}
     _BumpSpecMap ("Normalmap (GA) Spec (R) Shadow Offset (B)", 2D) = "bump" {}    
     _ShadowTex ("Shadow (RGB)", 2D) = "white" {}    
     
     // These are here only to provide default values
     _Scale ("Scale", Vector) = (1,1,1,1)
     _SquashAmount ("Squash", Float) = 1        
 
     _Cutoff ("Alpha cutoff", Range(0,1)) = 0.65
     _BlendCutoff ("Blend cutoff", Range(0,1)) = 0.7    
 
 }
 
 SubShader { 
 
     Tags { "IgnoreProjector"="True" "RenderType"="Transparent" }
     LOD 200
     Blend SrcAlpha OneMinusSrcAlpha
 
     CGPROGRAM
     #pragma surface surf TreeLeaf alphatest:_Cutoff vertex:TreeVertLeaf addshadow nolightmap
     #pragma exclude_renderers flash
     #pragma glsl_no_auto_normalization
     #include "Tree.cginc"
 
     sampler2D _MainTex;
     sampler2D _BumpSpecMap;
     sampler2D _TranslucencyMap;
 
     struct Input {
         float2 uv_MainTex;
         fixed4 color : COLOR;
     };
 
     void surf (Input IN, inout LeafSurfaceOutput o) {
         fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
         o.Albedo = c.rgb * _Color.rgb * IN.color.a;
         fixed4 trngls = tex2D (_TranslucencyMap, IN.uv_MainTex);
         o.Translucency = trngls.b;
         o.Gloss = trngls.a * _Color.r;
         o.Alpha = c.a;
         half4 norspc = tex2D (_BumpSpecMap, IN.uv_MainTex);
         o.Specular = norspc.r;
         o.Normal = UnpackNormalDXT5nm(norspc);        
     }
     ENDCG
     
     Tags { "Queue" = "Transparent" }         
     ZWrite off
     ZTest Less
     Blend One One
 
     CGPROGRAM
     #pragma surface surf2 TreeLeaf alpha vertex:TreeVertLeaf addshadow nolightmap
     #pragma exclude_renderers flash
     #pragma glsl_no_auto_normalization
     #include "Tree.cginc"
 
     sampler2D _MainTex;
     sampler2D _BumpSpecMap;
     sampler2D _TranslucencyMap;
     fixed _Cutoff;
     fixed _BlendCutoff;        
 
     struct Input {
         float2 uv_MainTex;
         fixed4 color : COLOR;
     };
 
     void surf2 (Input IN, inout LeafSurfaceOutput o) {
         fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
         o.Albedo = c.rgb * _Color.rgb * IN.color.a;
         fixed4 trngls = tex2D (_TranslucencyMap, IN.uv_MainTex);
         o.Translucency = trngls.b;
         o.Gloss = trngls.a * _Color.r;
         o.Alpha = c.a * _BlendCutoff;
         half4 norspc = tex2D (_BumpSpecMap, IN.uv_MainTex);
         o.Specular = norspc.r;
         o.Normal = UnpackNormalDXT5nm(norspc);        
     }
     ENDCG
     
 }
 
 Dependency "OptimizedShader" = "Hidden/Nature/Tree Creator Leaves Optimized"
 FallBack "Diffuse"
 }


anim.gif (183.5 kB)
untitled-3.jpg (90.7 kB)
Comment
Add comment · Show 1
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 tarahugger · Aug 07, 2014 at 09:24 PM 1
Share

In case this helps anyone else trying to work with the Tree Creator. I have attached a tool that makes sure the shader is set to the one you want (attached). You just have to put the script Tree$$anonymous$$aterialOverride onto the tree and pick the shader you want to use.

[1]: /storage/temp/30595-treeutility.zip

treeutility.zip (12.8 kB)

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

2 People are following this question.

avatar image avatar image

Related Questions

Disabling a Pass or Subshader Programmatically 0 Answers

Curve shader with lights 0 Answers

In ShaderLab, how could you get the colour of the texture you're rendering to? 0 Answers

Blending/Fading Camera & Pixel Shader 1.1 0 Answers

Use texture to determine shading? 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