0
À l'étude
Depth Blend Display Bug when in Isometric view.
So today I was working on a SF particle shader with soft particles to plug into Unity's shuriken particle system and I stumbled upon this bug where particles don't display properly.
This bug only happens in Editor scene view and only in Isometric scene camera.
I am using deferred camera and soft particles enabled.
So far I only seem to notice this happen with Shuriken,
This bug only happens in Editor scene view and only in Isometric scene camera.
I am using deferred camera and soft particles enabled.
So far I only seem to notice this happen with Shuriken,
This is the shader I am testing with:
This is the expected and correct result (Currently in Perspective mode):
Service d'assistance aux clients par UserEcho
This is the expected and correct result (Currently in Perspective mode):
This is the result in Isometric Mode:
I removed the Depth Blend:
This is the result in Isometric with out depth blend:
This bug only happens when you don't have the particle system selected. When it is in focus, it works fine.
This is caused by not declaring #pragma multi_compile_particles and using #ifdef SOFTPARTICLES_ON in the shader code.
depth blend cannot be used in isometric editor view and hence SOFTPARTICLES_ON is not defined when in isometric view.
After adding the ifdef tags to the depth blend sections of the code it will solve this problem.
Right now I have to manually add them in after compiling the shader.
Hope you can incorporate this into future versions.
Pass {
Name "ForwardBase"
Tags {
"LightMode"="ForwardBase"
}
Blend One One
Cull Off
ZWrite Off
Lighting Off
Fog {Color (0,0,0,0)}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_FORWARDBASE
#include "UnityCG.cginc"
//#pragma multi_compile_fwdbase
#pragma multi_compile_particles
#pragma exclude_renderers xbox360 ps3 flash d3d11_9x
#pragma target 3.0
uniform sampler2D _CameraDepthTexture;
uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
uniform float4 _TintColor;
uniform float _Softness01;
struct VertexInput {
float4 vertex : POSITION;
float2 texcoord0 : TEXCOORD0;
float4 vertexColor : COLOR;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
float4 vertexColor : COLOR;
#ifdef SOFTPARTICLES_ON
float4 projPos : TEXCOORD1;
#endif
};
VertexOutput vert (VertexInput v) {
VertexOutput o;
o.uv0 = v.texcoord0;
o.vertexColor = v.vertexColor;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
#ifdef SOFTPARTICLES_ON
o.projPos = ComputeScreenPos (o.pos);
COMPUTE_EYEDEPTH(o.projPos.z);
#endif
return o;
}
fixed4 frag(VertexOutput i) : COLOR {
#ifdef SOFTPARTICLES_ON
float sceneZ = max(0,LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))) - _ProjectionParams.g);
float partZ = max(0,i.projPos.z - _ProjectionParams.g);
#endif
////// Lighting:
////// Emissive:
float2 node_856 = i.uv0;
float4 node_2 = tex2D(_MainTex,TRANSFORM_TEX(node_856.rg, _MainTex));
float4 node_782 = i.vertexColor;
float3 emissive = (node_2.rgb*node_2.a*(_TintColor.rgb*node_782.rgb*node_782.a*2.0));
#ifdef SOFTPARTICLES_ON
emissive *=saturate((sceneZ-partZ)/_Softness01);
#endif
float3 finalColor = emissive;
/// Final Color:
return fixed4(finalColor,1);
}
ENDCG
}