The problem: particle effects are rendering in front of trees
Searched forums, someone said "Use particle shader cutout" - shader doesn't exist. Transparent cutout shader does exist. Doesn't have blending I want and all the options for it look tacky, but it does render in the correct order.
Downloaded base shaders, transparent shaders aren't included so I can't see how the cutout actually works to add it to the additive(soft) shader that looks good.
Tried Ztesting, tried the alpha testing examples in the reference, tried resetting the queue so it would render afterwards. Failed. Failed. Failed.
I have seen several other requests for this, but no answers as to where to find it, checked the wiki and none of the listed shaders seem to solve the problem so I'm asking again.
Is there a shader that successfully renders the alpha(soft) particle shader with the transparent cutout shaders such that the particles from the particle emitter render behind the soft-occluding leaves from the trees? Or is there something I can do with the shader I've tried to play with so that it will succesfully do this?
I have to admit to being a bit surprised that setting the Queue all the way down to background still rendered my particle effects in front of the trees, especially since the leaf shaders are queued at transparent - 99, but I must not fully understand the rendering pipeline (highly probable).
You say your using trees. If these trains are paint effects generated you maya need to convert them to nurbs or polys and should solve your problem without having to mess around with particle shaders.
I had a similar problem where paint effects trees kept rendering infront of a fountain is was rendering as particle spray. after trying to split it up into render passes and failing again and again and again, I converted the trees to nurbs and hey presto everything solved.
Sorry if this doesnt help. I know that particle shaders in maya are a bitch to solve problems with and I know a lot of people who dont bother rendering particles in maya, they use stuff like krakatoa or renderman.
I read somewhere, that the BillboardTree.shader in the Bootcamp Demo had already solved this problem so I compared the shader from the demo to the unity5 shader I have in my project, the only differences are two lines so I made the changes & the particles treat the billboard trees like the mesh trees now. here is the shader with the code alterations which are commented. this has been fully tested & is working in my game.
Shader "Hidden/TerrainEngine/BillboardTree" {
Properties {
_MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
}
SubShader {
Tags { "Queue" = "Transparent-100" "IgnoreProjector"="True" "RenderType"="TreeBillboard" }
Pass {
ColorMask rgb
Blend SrcAlpha OneMinusSrcAlpha
//ZWrite Off//COMMENTED THIS OUT, THIS IS THE CHANGE
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "UnityCG.cginc"
#include "TerrainEngine.cginc"
struct v2f {
float4 pos : SV_POSITION;
fixed4 color : COLOR0;
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
};
v2f vert (appdata_tree_billboard v) {
v2f o;
TerrainBillboardTree(v.vertex, v.texcoord1.xy, v.texcoord.y);
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uv.x = v.texcoord.x;
o.uv.y = v.texcoord.y > 0;
o.color = v.color;
UNITY_TRANSFER_FOG(o,o.pos);
return o;
}
sampler2D _MainTex;
fixed4 frag(v2f input) : SV_Target
{
fixed4 col = tex2D( _MainTex, input.uv);
col.rgb *= input.color.rgb;
clip(col.a - 0.0001);//ADDED - 0.0001 TO THIS, THIS IS THE CHANGE
UNITY_APPLY_FOG(input.fogCoord, col);
return col;
}
ENDCG
}
}
Fallback Off
}