Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How Is the Fluid Renderer Constructed?
#1
Hi,

I'm trying to work my way through the Fluid Renderer to build something similar with slightly more things to edit.

It seems that what's happening is it's taking the base material ("Fluid Material"), and adding the colour from the "Colour Material", but I can't see where that combination is happening. Any ideas?

Thanks.
Reply
#2
(22-05-2019, 12:28 PM)Komsur Wrote: Hi,

I'm trying to work my way through the Fluid Renderer to build something similar with slightly more things to edit.

It seems that what's happening is it's taking the base material ("Fluid Material"), and adding the colour from the "Colour Material", but I can't see where that combination is happening. Any ideas?

Thanks.

Hi there,

There's a basic description of how it works internally here:
http://obi.virtualmethodstudio.com/tutor...ering.html

The combination you're referring to takes place in step 2: particle color (rgb) and thickness (a) are rendered to a full screen texture using the "Colour Material".

Each particle can have a different color, when rendering into this texture. The particle color is the result of multiplying the ObiParticleRenderer's "color" and the color value for that particle in the emitter's "colors" array. How the color of each particle is blended with the other particles depends on the Colour Material. Usual choices are multiplicative (FluidColorsBlend.shader) and alpha blended (FluidColorsOpaque.shader).

This color/thickness buffer is sampled in step 4, when rendering the final image (happens in FluidDielectric.shader).

The rendering pipeline is a bit involved (specially the ellipsoid rendering math, which is based on this article:https://tu-dresden.de/ing/informatik/smt/cgv/ressourcen/dateien/publikationen/2003/siewdc/ellipsoid.pdf). You can however use the methods in ObiEllipsoids.cginc as they are, you probably don't need to modify them at all.

let me know if I can be of further help.
Reply
#3
(23-05-2019, 07:57 AM)josemendez Wrote: Hi there,

There's a basic description of how it works internally here:
http://obi.virtualmethodstudio.com/tutor...ering.html

The combination you're referring to takes place in step 2: particle color (rgb) and thickness (a) are rendered to a full screen texture using the "Colour Material".

Each particle can have a different color, when rendering into this texture. The particle color is the result of multiplying the ObiParticleRenderer's "color" and the color value for that particle in the emitter's "colors" array. How the color of each particle is blended with the other particles depends on the Colour Material. Usual choices are multiplicative (FluidColorsBlend.shader) and alpha blended (FluidColorsOpaque.shader).

This color/thickness buffer is sampled in step 4, when rendering the final image (happens in FluidDielectric.shader).

The rendering pipeline is a bit involved (specially the ellipsoid rendering math, which is based on this article:https://tu-dresden.de/ing/informatik/smt/cgv/ressourcen/dateien/publikationen/2003/siewdc/ellipsoid.pdf). You can however use the methods in ObiEllipsoids.cginc as they are, you probably don't need to modify them at all.

let me know if I can be of further help.
Hi,
Thanks for the reply!

I was wondering if it would be possible to apply this sort of thing to a static asset. I see that Obi is converting particles to geometry, but I have a static asset that I'd like to apply the Obi shaders to, creating the "honey" effect, whilst also emitting Obi particles around it. Would this be possible?
Reply
#4
(23-05-2019, 08:02 AM)Komsur Wrote: Hi,
Thanks for the reply!

I was wondering if it would be possible to apply this sort of thing to a static asset. I see that Obi is converting particles to geometry, but I have a static asset that I'd like to apply the Obi shaders to, creating the "honey" effect, whilst also emitting Obi particles around it. Would this be possible?

Possible, but costly. You'd need to somehow voxelize the mesh, generate particles for each voxel, then render them as ellipsoids in each of the fluid buffers, and have the fluid renderer use them. This system is designed to render particle volumes, not meshes.

Why not using a reflection/refraction shader on the mesh directly? This would be both easier and far more performant. Though you could write your own, there's some in the store that would do the job:
https://assetstore.unity.com/packages/vf...ader-76954
https://assetstore.unity.com/packages/vf...ader-94848

(Note that I'm not affiliated with any of these, I just did a quick search for refractive/glass shaders)
Reply