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