I am trying to attain a metaball liquid effect with a liquid physics asset I am making for Unity. I have 1000's of particles being simulated. I then render each of those particles as one particle in the Unity shruiken particle renderer. They are rendered as with alpha and transparent. Using mobile\particles\alphablended shader
here is the image used
I then render all this to a render texture and have a shader that reads this render texture and draws the final liquid on a mesh. Shader code is like this..
half4 frag (v2f i) : COLOR
{
half4 texcol,finalColor;
finalColor = tex2D (_MainTex, i.uv);
if(finalColor.a < _botmcut)
{
finalColor.a = 0;
}
else
{
finalColor.a *= _constant;
}
return finalColor;
}
If the overall alpha is below a certain value, then draw 0 alpha.
Here,s what the render texture looks like...
So far so good, btw those two white balls are sprites using the same texture and the same shader as the shruiken particles.
Now the alpha values look fine in the render texture, and in the editor.. But the values being read by the shader from the shruiken particles are wrong, this is my issue. here is an image showing the alpha values as read by the shader in where red = alpha.
You can see the two sprites are fine, their alpha values are adding together, whereas the shruiken ones are wrong, it looks like the raw alpha value of each particle is drawing over the one behind it.. so the space in between particles tends to have very low alpha value, where it should be high (and it looks high in editor and in render texture)
I had this exact solution working perfectly before a long time ago using the old ellipsoid particle emitter (which has been removed, forcing me to switch to shruiken) ... Also this would render perfectly if I used 1000's of sprites but there would be performance cost there.
My quesions are...
Is there any alternative to the unity shruiken particle system for drawing lots of little sprites like this? I just could just switch to any alternative as a workaround.
Do you think there is any setting I could change on the shruiken system to fix this issue (its pretty much all default atm.)
Ok, so for some reason, this built-in shader has the problem.. Mobile\Particles\Alphablended but this built-in shader does not.. Sprites\Default
switching the material I'm using in the shruiken particle system to the built-in Sprites\default shader fixed my problem.