If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Bath foam surface

hi all!

I've been working on a new personal project and it call's for bath foam. After a few days of wrecking my brain how to do it this is what i got. It does need a bit more specular maybe and a few tweaks like that, but what i really need help with is the way to get that shifting of colors in reflection that is so characteristic to bubble foam, like in the example image i've attached. Any idea how to do that? tnx!!

Agreed with Tobian, good progress so far! To add specular colouration, I think the easiest solution is to feed a Turbulence texture into a Gradient input, then simply add the desired colours as keys. Pipe the gradient output (which should look like a wild collection of rainbow colours by now) into the colour input of your specular shader of choice, and viola = instant rainbow highlights. Using your existing normals or the DPkit Bump to Normal node to influence individual shaders (such as a secondary gradient node with input set to incidence), you can get a lot fancier, but this is usually where I start.

Quick test render...

If you use normals instead of geometry to create the illusion of bubbles, you can more easily invert the normals to simulate back-reflections by adding a few additional specular nodes. The attached image uses basic Lightwave procedurals along with DPkit bump to normal conversion to create the look with shading handled by one sub-surface scattering and four specular nodes (2 blinn for primary spec, 2 phong for rainbow colouration). The individual bubbles can be displaced as well, but it's just faster to render it smooth.

Something to note - the shadowing gets weird when the geometry fades out at minimal distances. I tried double-sided at one point, but it didn't seem to make a difference. May have to try again at some point, cause it's kinda bugging me...

Thanks! It was a fun little test to work on. I posted a render to YouTube with a few more details on how the shader was developed, along with a quick image sequence of tests showing the development progress and a turntable of the results.

Glad you like it! Bubble displacement certainly looks better in some ways, less so in others - because I'm using inverted normals to shade the back of each bubble, displacing the larger bubbles means the back reflections get...weird. I'll post an example once I get a chance to render one out (currently waiting on some heavy duty video encoding on a different project).

Tnx for the replys guys, and for your inputs!
Tobian- tnx, ill try that!
Off- i will give your idea a go as well, tnx!
Iaian7- tnx a lot for taking time on this one! I love your shader, but i would like to keep the displacement! i'll try your idea with the rainbow gradient! Btw, any chance i could get that surface of yours?
Tnx again!

I definitely think with only minimal expansion that would be a great article for 3D World or LightWIKI. Just expand a bit on each sentence for knuckleheads like me (e.g.: must there be actual Thickness for the Thickness node to operate???) and WALLAGH! Article.