Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple2DFluid Look w/ DieletricFluid Shader
#2
(30-10-2019, 06:27 AM)goldenmommy Wrote: Hi! Just started diving in w/ this great asset.  With Simple2DFluid, the fluid is rendered on top of all other objects in the scene so you would, for example, see the fluid through even an opaque bucket.  With DieletricFluid this is not the case and this is how I would like my rendering to behave.  However I am unable to replicate the exact quality of the Simple2DFluid w/ DieletricFluid even messing with the cloudiness level.  Is there any way to either get DielectricFluid to look like Simple2DFluid or to have Simple2DFluid render "behind" opaque objects in the scene?

Hi,

The simple fluid shader is trivial, all it does is multiply the background (refracted image) with a color. So simply modify the dielectric one to do the same. Here's the modified fragment shader for DielectricFluidShader:

Code:
fout frag (v2f i)
{
    fout fo;
    fo.color = fixed4(0,0,0,1);

    float3 eyePos,eyeNormal, worldPos, worldNormal, worldView;
    float thickness = SetupEyeSpaceFragment(i.uv,eyePos,eyeNormal);
    GetWorldSpaceFragment(eyePos,eyeNormal,worldPos,worldNormal,worldView);

    fo.color.rgb = tex2D(_Refraction, i.uv) * _CloudinessColor.rgb;

    OutputFragmentDepth(eyePos,fo);
    return fo;
}

In this case, the color being multiplied is the cloudiness color. Here's the result:

[Image: u2jrO0M.png]
Reply


Messages In This Thread
RE: Simple2DFluid Look w/ DieletricFluid Shader - by josemendez - 30-10-2019, 08:25 AM