Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Opaque fluid turns black instead of set color
#1
Hi, it may be something explained somewhere and I missed it, if so I'm sorry. I did search the user manual and forum for answers.

Turning transparency down makes the fluid go darker till it turns black instead of making it the color set in particle emitter.

I tested this behaviour on clean 3D URP template in Unity 2021.3.14f1, Windows. Almost all settings are default, I only set Opaque and Depth texture in renderer, added rendering feature and lowered the transparency. Fluid turns black when lowering opacity in all sample scenes.

I don't know if it's intended behaviour and how to change it I played around with blending modes to no effect). In user manual transparency example shows fluid turning to the color that was set in emitter.

How can I fix/change it? I want the fluid to be almost solid color, only getting transparent when it's thin (for example ketchup).
Reply
#2
(21-11-2022, 12:56 PM)Badger Wrote: Hi, it may be something explained somewhere and I missed it, if so I'm sorry. I did search the user manual and forum for answers.

Turning transparency down makes the fluid go darker till it turns black instead of making it the color set in particle emitter.

I tested this behaviour on clean 3D URP template in Unity 2021.3.14f1, Windows. Almost all settings are default, I only set Opaque and Depth texture in renderer, added rendering feature and lowered the transparency. Fluid turns black when lowering opacity in all sample scenes.

I don't know if it's intended behaviour and how to change it I played around with blending modes to no effect). In user manual transparency example shows fluid turning to the color that was set in emitter.

Hi!

Could reproduce this issue: for some reason, mainLight.distanceAttenuation in 2021 always returns 0 (should return 1, since directional lights do not attenuate with distance). I think this may be a bug in URP, since the current behavior does not make sense.

To fix this, open up Obi/Resources/ObiMaterials/URP/FluidShaderURP.shader, and in line 159 remove remove "mainLight.distanceAttenuation". Make sure the line ends up looking like this:

Code:
half3 diffuse = mainLight.color * (mainLight.shadowAttenuation * NdotL);

(21-11-2022, 12:56 PM)Badger Wrote: How can I fix/change it? I want the fluid to be almost solid color, only getting transparent when it's thin (for example ketchup).

Opcaity doesn't change with thickness, only absorption does. To simulate this you'd need some kind of scattering going on, which the built-in fluid shader doesn't provide.

You can implement a poor-man's scattering by modifying line 175 in the shader this:

Code:
fo.color.rgb = lerp(fo.color.rgb, refraction, _Transparency * saturate(1-volume.a));

This is how a ketchup-like material with scattering would look like when using this:

[Image: oO8oCY7.png]

kind regards,
Reply
#3
Amazing, thank you very much!
Reply