Real-time foam/soap suds shader?

Hey guys, I was wondering if anyone’s ever spotted a good working example of expanding foam/soap suds in a game. It’s important that no flipbooks be involved, just geo, shaders and perhaps maybe particles.

How would you approach something like this? Just thinking about it makes my head hurt, what with all the overlapping refraction, transparency, etc…

1 Like

I’d approach it by faking it. No refraction, no transparency.

Playing with Worley noise and mapping it to the roughness / smoothness / specular / whatever should do the trick. Also, make the inner bubble part dark by inverting the noise mask and using that to lerp between two not very contrasted values, like 0.96 and 0.88 for example. I’d also avoid harsh or contrasty shadows, as that could help with the GI / SSS feeling.

For the specific reference you shared, I’d also fake the “deformation” and the wiggle using a decent polycount mesh with a bit more resolution in the holes, and maybe faking their creation by using a skeletal mesh with bones that make the foam go in and out. But then I’d also use triplanar uv mapping so the animated holes wont give any problems.

About the particles, I can hardly see any in the reference. But maybe making some bubbles popping out would look nice.

Would you like me to recreate it and share it with you?

Cheers!

1 Like

Well! If you’re up for it I definitely won’t say no to that. Looking forward to seeing what you come up with!

1 Like

Give me a couple days as I’m a bit busy right now! :coffee:

Well, talk of the devil… I was just playing Mario + Rabbids on Switch last night and lo and behold…

foam

This is actually pretty good and I’ve already begun to attempt to recreate something similar. I’ll post it as soon as I have something that looks half decent.