For anyone who wants to modify the shader to tweak the shading functionality, I will explain how the shading process works, though i personally not recommend.
The files used for fluid shading are in Assets/SSF_Particle2Fluid_ShaderUtil/Shaders/FluidRender.shader
The whole process can be divided into the following steps:
We first filter out the pixels that are not blocked by the fluid particles and return them to the previously rendered color.
half4 color = SAMPLE_TEXTURE2D_X_LOD(_BlitTexture, sampler_LinearRepeat, uv, _BlitMipLevel);
#if UNITY_REVERSED_Z
real depth = SampleSceneDepth(uv);
#else
// Adjust z to match NDC for OpenGL
real depth = lerp(UNITY_NEAR_CLIP_VALUE, 1, SampleSceneDepth(UV));
#endif
float sceneEyeDepth = LinearEyeDepth(depth, _ZBufferParams);
if(fluidEyeDepth <= 0.0f || fluidEyeDepth > 1000.0f ||sceneEyeDepth < fluidEyeDepth) {
return color;
}
Based on the above parameters, you can play with the shader to create different effects.
For example, I first made a blinn-phong rendering
// Calculate non-transparent color, using old model
Light mainLight = GetMainLight();
// the light direction is also expect to be a inverse since we care its relative angle to the normal
// so its world direction should be considered to treate inversely
float3 lightDir = -mul(unity_MatrixV, float4(mainLight.direction, 0.0)).xyz;
float3 specular = LightingSpecular(mainLight.color,lightDir,fluidEyeNormal,viewDir,specularColor,smoothness*32);
float3 diffuse = LightingLambert(mainLight.color,lightDir,fluidEyeNormal)*diffuseColor.rgb;
float3 ambient = ambientColor.rgb;
float3 finalColorNonTransparent = ambient + diffuse + specular;
In addition, you can use parameters such as thickness, fluid color, IOR, smoothness, etc. to create water rendering effects that include refraction and reflection: