View Full Version : Perfect Cup of Coffee


InfernalDarkness
02 February 2010, 07:16 PM
I'm having a rough time "nailing" a decent coffee material for a personal scene. Sure, it's brown. Sure, it's liquidy. But staring at coffee all the time in real life, and drinking it obviously, doesn't help me with a decent coffee shader. I've tried ramps, phongs, mia_material_xs, and everything I could think of but still not getting far... Using mental ray this time.

Here's a render without any GI I've been using as a starting point. Just focusing on the coffee material itself, and I'll worry about some steam and bubbles later.

http://img508.imageshack.us/img508/4113/coffeecupmr1.jpg

Any thoughts, or successful material setups to make The Bean?

TaKIKO
02 February 2010, 07:52 PM
The simplest things are always the hardest. First off are you trying to replicate straight black coffee or coffee with milk. First thing I notice is that the coffee isnt dark enough and maybe not saturated enough. I would try using the mia_x with a max distance in the advance refraction tab. I dont personally don't suggest having a glass cup I think maybe a porcelain type material would fit nice. But if you stick with the glass cup with the correct refraction can be tricky. I would take a look in the mia_x help doc, they have overview of creating a liquid to glass interaction with the mia_x.

TaKIKO
02 February 2010, 09:14 PM
Also you are going to want to add a little lip to the top surface of your liquid. you will see this with liquids in real life, it will also so give you realistic reflections along the edge of the liquid.

Here's a test scene i did real quick. The most important factor I think is using the max distance in the advance reflection parameter. Your light setup and your reflections play an important role too. If you want to give me your email I'll send you the scene file.

http://img210.imageshack.us/img210/7024/coffeen.jpg

kiryha
02 February 2010, 08:08 AM
It would be grate if you post this file here:)
I`m interesting what parameters make the fluid to looks deep, getting darker witth distance.

ytsejam1976
02 February 2010, 09:32 AM
@Infernal
I have real italian espresso coffee with a cream on the up!

tostao_wayne
02 February 2010, 09:53 AM
and a texture for the top here:

http://area.autodesk.com/downloads/textures?tf=4&where=1&material=55

cgbeige
02 February 2010, 10:12 PM
that shader looks great with the ceramic but isn't he going to need something like a dielectric interface to account for the contact of the two meshes? I haven't done something like this myself but I thought I read about that. The caustics might go wonky otherwise. I dread the day I have to deal with liquid next to glass.

InfernalDarkness
02 February 2010, 01:41 AM
I appreciate all your input, especially on something that should be so simple as coffee!

What's key here for my scene is that the coffee shader works properly with the sun/sky nodes. I know it's not great lighting in this test scene, but if it won't work here, it certainly won't in my main scene.

TaKIKO, yours is brilliant and a gorgeous render! I just need to do that inside a glass coffee cup, which is being a big pain. I've read the help docs extensively but am still having some issues. Here's my latest render, which incorporates the surface tension rim as well:

http://img98.imageshack.us/img98/199/coffeecupmr3.jpg

I'm having a rough time with the glass refraction silliness, even with all ray depths set at 10 throughout (except for FG depth, obviously). But my coffee shader itself still sucks. I'm looking at a real cup of coffee, in a glass mug, right now on my desk. My Maya-coffee sucks, so I switched to a ceramic mug real quick to tuning the coffee shader specifically using Max distance and the mia_x:

http://img148.imageshack.us/img148/9273/coffeecupmr4.jpg

Getting closer, but I still can't get my coffee "black". Using gamma correct nodes on all my color swatches too, except for the ceramic, which is pretty basic obviously. The wood texture is just to check reflections/refractions, I know it's low-res.


ytsejam1976 @Infernal
I have real italian espresso coffee with a cream on the up!

If I hadn't just slammed an entire pot of Cheap Black today, my mouth would be watering!


that shader looks great with the ceramic but isn't he going to need something like a dielectric interface to account for the contact of the two meshes? I haven't done something like this myself but I thought I read about that. The caustics might go wonky otherwise. I dread the day I have to deal with liquid next to glass.

I believe the mia_x handles all the dielectrics already, but could be wrong? Also, I'm using a full piece of geometry in my scene, not just the top surface. Which isn't making things any easier.

I've done wine in bottles and glasses before, and that turned out great. But this coffee is slayin' me! I can't get it dark enough, and can't get any caustic photons to go through the coffee at all. There's not a speck of brown or even yellow in my first render here from caustics, and looking at this glass mug on my desk there should be a LOT of caustics going on, especially in black coffee.

I'm not usually emotional about Maya-work, but this whole incident recalls me to my days a long time ago reading Death Metal Poetry...

http://991.com/newgallery/Henry-Rollins-Black-Coffee-Blue-236042.jpg

Most depressing book I've ever read, and this coffee project is following the poetry closely! (grins)




Edit: after re-reading the help docs, I find that you need to make a third "air transition" shape between the glass and the coffee geometry... But I'm out of steam for now, and I'll get back to this tomorrow... I imagine this is what CGbeige was talking about?

tostao_wayne
02 February 2010, 10:05 AM
hi infernalDarkness, is this coffee enough dark for you??

http://usuarios.multimania.es/heteropterus/imagenes/coffe.jpg

the scene:

http://usuarios.multimania.es/heteropterus/descargas/

chuckie7413
02 February 2010, 11:08 AM
think there is a problem with the link?!?

tostao_wayne
02 February 2010, 11:57 AM
think there is a problem with the link?!?

http://usuarios.multimania.es/heteropterus/descargas/

sorry, now you can acces to the page, the file: cofee.zip


sorry again, i had upload a wrong file, now it's the correct one

sherridge101
02 February 2010, 01:27 PM
Thanks a lot for the file.

How did you achieve the transparent edge to the coffee in the first post?

Cheers,

Steve

tostao_wayne
02 February 2010, 02:44 PM
Thanks a lot for the file.

How did you achieve the transparent edge to the coffee in the first post?

Cheers,

Steve

if you are asking for this effect (is the same coffee shader):

http://usuarios.multimania.es/heteropterus/imagenes/coffe2.jpg

you must to activate "use max distance" under the advanced refraction tab,

a 0.045 max distance and a very dark redbrown color for the color at max distance

sherridge101
02 February 2010, 03:02 PM
Yep, that's the effects.

Cheers

cgbeige
02 February 2010, 03:47 PM
I believe the mia_x handles all the dielectrics already, but could be wrong? Also, I'm using a full piece of geometry in my scene, not just the top surface. Which isn't making things any easier.

Since there's always going to be a gap, however small, between the liquid and the glass meshes, I would think that to get physically accurate results, you'd need to tell the photons not to refract like they are entering air after leaving the liquid and then entering glass and vice versa. You might be fine just skipping it but I would think that this would cause unnatural shadowing and refraction if you didn't account for this dielectric interface. There's a thread that goes into it here (I haven't read it - just noticed them talking about dielectric interfaces and Maya/mental ray/Realflow):

http://www.realflowforum.com/view_topic.php?id=3849

tostao_wayne
02 February 2010, 04:56 PM
two more tests

http://usuarios.multimania.es/heteropterus/imagenes/coffe3.jpg

http://usuarios.multimania.es/heteropterus/imagenes/coffe4.jpg

TaKIKO
02 February 2010, 05:10 PM
As tostao wayne showed using a max distance is the key.

Heres my glass to liquid interaction

http://img709.imageshack.us/img709/5308/coffeetest.jpg

Redsand1080
02 February 2010, 06:45 PM
@TaKIKO: Seriously bad-ass. Did you do the whole 'reversing normals' and changing IOR for different surface thing? For example, one surface for liquid to air, another for liquid to glass and another for air to glass? Really nice, though. All mia_materials?

@tostao_wayne: Really nice work as well! Looks really cool with those bubbles on the top. :)

TaKIKO
02 February 2010, 06:59 PM
Yea I followed the help doc tutorial. Its 3 different pieces of geometry. I did a lot of r&d while working on one of my demo reel assets that had a glass to liquid interaction.

cgbeige
02 February 2010, 07:07 PM
looks great.

InfernalDarkness
02 February 2010, 09:38 PM
Tastao_Wayne and Takiko... You guys are killing me here! I'm starting to wonder if my geometry simply sucks or something, but also my mia_x's aren't doing what they need to be doing. Compared to the wine I made previously, I can't believe how much trouble I'm having. And that wine bottle and wine was much more complex...

Tastao_Wayne, I couldn't get your file to open in Maya 2009. But there was a CRC error in the zip on my end, perhaps I just need to download it again?

Takiko, I'm going to try yours next. Spent a few hours failing at this project last night, and a few more this morning.

I'm also using the three separate geometries here too, per the Help Docs. This technique worked fine with my wine last year, so I don't know what I'm doing wrong. Here's my latest crap renders that aren't working how I want:

http://img708.imageshack.us/img708/4376/coffeecupmr5.jpg

And this one's worse:

http://img246.imageshack.us/img246/1448/coffeecupmr6.jpg

And this one is much better, but my coffee shaders still suck:

http://img715.imageshack.us/img715/9484/coffeecupmr7.jpg


I opened your file Takiko and it works beautifully! Rendered fine and all that. I'm not interested in simply stealing your shaders but hopefully I can see what I'm doing wrong here...

Thanks for all your help everyone, hope to get this nailed today. This is just a personal project (fortunately!) so I'm in no real rush, but more frustrated with myself than anything.

TaKIKO
02 February 2010, 09:53 PM
If you wanna email me the scene I can see whats wrong. If not thats fine. Are the normals for the center liquid geometry facing outwards?

InfernalDarkness
02 February 2010, 12:21 AM
I'll email you my scene if I can't figure it out today. Your scene is very helpful, and very clean too, and I like your light setup as well.

My normals are facing out on the coffee base object (inside glass), facing straight up on the coffee top surface object, and facing out throughout the glass cup. I am having some weird issues with the coffee objects even after deleting all the history, which is kinda why I think my geometry is somehow corrupt. But that doesn't really change the fact that my shader is garbage! (grins)

One thing I see immediately is that your geometry is much cleaner, your rendertimes demolish mine, and the efficiency is great even with thresholds on reflections/refractions, which I had disabled as a "solution" for my shader problems, on the glass and both coffee shaders.

I really appreciate you sharing this with me, and hope to learn how to make this type of coffee shader work!

InfernalDarkness
02 February 2010, 01:25 AM
Takiko: After trying your shaders out I have some different and much better results, but have also come to the conclusion that my coffee cup model is likely at fault here, not just my shaders. Here's my first take, simply using your materials for the glass, coffee center, and coffee top:

http://img515.imageshack.us/img515/874/coffeecupmr8.jpg

Enabling caustics on your materials and tweaking slightly brought me to this result:

http://img33.imageshack.us/img33/2444/coffeecupmr9.jpg

So I'm getting much closer here, and even starting to get some decent caustics just from the sun/sky. I'm going to try recreating my coffee cup to be cleaner and nicer and see if that helps!

TaKIKO
02 February 2010, 01:01 AM
Did you make any progress?

JustLearning
03 March 2010, 12:59 AM
been working on this scene. after getting close to desired results i stumbled onto this thread. i'm using just a plane. getting strange results with the surface tension around the liquid. im sure some of it is just weird final gathering issues. no GI here, just FG. believe me there is definetely a rim modeled on that plane. you can just make it out on the left and right. the liquid plane is reflecting the rim of the cup, but strangely the liquid isnt refectling that bright highlight on the left. any thoughts?

http://danielmatuk.com/temp/tea_new_liquid.jpg

InfernalDarkness
03 March 2010, 06:22 AM
I think it all has to do with the max distance on your material. Here was my best result, please don't mind the horrible steam:

http://img697.imageshack.us/img697/9645/coffeecupmr10web.jpg

JustLearning
03 March 2010, 01:20 PM
yeah something is up with the scene. its weird that the cup would reflect the portal light and not the liquid plane. infernal, could you post your scene by any chance? the previous link someone posted had errors and i couldnt open it. i'm in maya 2008

InfernalDarkness
03 March 2010, 06:17 PM
Also in Maya 2009 here, so I'll find a way to post the .ma and you can have at it!

I assume you're using the mia_material_x for your liquid, as well, though? It took me awhile to nail the max distance in my scene, as my scene's scale was very different than Takiko's.

JustLearning
03 March 2010, 06:22 PM
i believe that i am using the mia_material, not the mia_material_x

mwgriffin
06 June 2010, 09:47 AM
Hey InfernalDarkness I was looking over this thread and I tried to replicate what you were trying to achieve. I had a b*tch of a time doing so. I couldn't for the life of me get my coffee liquid to have any transparency. After a couple hours fiddling with tons of parameters I realized that I needed to reverse my normals. I felt like slapping myself at that point, but I notices that in most of your renders you were getting results that were very similar to mine. I wonder if you had run into the same issue? One suggestion would be to ramp down the reflectivity on the cup, as it seems a little overblown and increasing the roughness. I might also add that you could try increasing the max distance and lowing the reflectivity on the coffee. You've made some good progress so far though!

InfernalDarkness
06 June 2010, 12:34 AM
Thanks for all your input, my friend! I'll keep it in mind next time, but I was very conscious of my normals on the examples posted previously here. On this project, I ended up using a ceramic non-transparent shader to match the pitcher and sugar bowl and plates... But all the glass-practice was worth learning, too!

Kev3D
06 June 2010, 07:14 AM
Just wandered past this thread, found it pretty interesting.

Infernal, were you able to get the coffee to look a lot weaker, even like tea, by really amping up the max distance? I only ask because your coffee still looks a bit solid and was wandering whether this was a stylistic choice or because you were still wrestling with Mental Ray?

Keep in mind that you can go above 1 with the saturation and value of colours in Maya. On occasion, I have found that a value of, say, 1.05 in the saturation of a colour can bring back the saturation that the linear gamma workflow removes.

Are you going to post the final image at some stage, Infernal?

mwgriffin
06 June 2010, 11:10 AM
Hey people! I have had a go at creating a realistic coffee shader. It uses mia_material_x with a layered texture for the refraction falloff color. The layered texture combines granite and fractal shaders to try to achieve the non-uniform look of coffee. Click on them to see a larger size. Hope you like them!



http://files.mwgriffin.com/coffee_white_05.png (http://files.mwgriffin.com/coffee_white_05.png)



http://files.mwgriffin.com/coffee_steam.png (http://files.mwgriffin.com/coffee_steam.png)

InfernalDarkness
06 June 2010, 05:39 PM
Keep in mind that you can go above 1 with the saturation and value of colours in Maya. On occasion, I have found that a value of, say, 1.05 in the saturation of a colour can bring back the saturation that the linear gamma workflow removes.

Yes, you can go above 1.0 for most numerical functions in Maya, but in the case of the mia_materials they are energy-conserving for physical accuracy. So depending on what you're already doing, going beyond the slider won't necessarily change anything. Just so you're aware, my friend!


Hey people! I have had a go at creating a realistic coffee shader. It uses mia_material_x with a layered texture for the refraction falloff color. The layered texture combines granite and fractal shaders to try to achieve the non-uniform look of coffee. Here they are with their respective links for viewing larger sizes. Hope you like them!


Beautiful renders! Looks very clean and realistic.

mwgriffin
06 June 2010, 12:37 PM
Beautiful renders! Looks very clean and realistic.

Hey thanks man! I've made quite a bit of progress on the coffee shader and improving its accuracy. I'm going to post a couple new renders in a few days which will demonstrate the shader's properties as well as an updated version of the second render. I think that the added elements will contribute quite a bit to the scene. I'll keep you guessing what they're going to be. Hint: On element is for realism of the coffee, and the other adds to the theme. :D

chafouin
06 June 2010, 10:49 AM
Hey guys,

I found the thread interesting, with really nice renders, so I decided to give it a try. It's a really simple setup without any texture, so it surely need to be improved. I also have a small problem, I get some occlusion where the liquid meets the cup, you can see it on the ceramic cup render. I don't really how to get rid of it.

http://1.bp.blogspot.com/_2qv_rJq7-rg/TA9wvBa_PZI/AAAAAAAAAPE/MPR9E6Ordx8/s1600/coffeecup_web.jpg

mwgriffin
06 June 2010, 06:26 PM
Hey nice renders mate! How much (if any) is your coffee shader intersecting the ceramic cup?

chafouin
06 June 2010, 07:29 AM
Thanks man :)

The vertices are snapped. The only way to avoid this occlusion is to make the liquid surface a little smaller so it doesn't touch the cup, but it isn't realistic, is it? ;) It's really not a big deal, it's just that I would expect from a completely transparent shader not to cast occlusion/shadows.

mwgriffin
06 June 2010, 05:20 AM
Huh. Yeah that is weird. Hey does anyone have an idea as to how to go about creating a large pile of objects? Should I use rigid bodies? I was playing around with sp3dpaint tool, which is really useful. But unfortunately it doesn't have any way to detect collisions. So other than rigid bodies I can't really come up with a solution. Hand placing them would be a huge waste of time. Each object (notice I'm not saying what it is as I want to keep it a surprise, but you might be able to guess what it is) is fairly complex, so a rigid body simulation will take a very long time. I actually just came up with an idea right now. What if I were to simulate some, then turn those into passive objects, simulate some more, turn those into passive objects, and remove the rigid bodies from the first group and just repeat that. I think that actually might speed it up considerably and not cause maya to crash. I'll give that a go... Any suggestions would be helpful though.

chafouin
06 June 2010, 10:11 AM
How many objects do you want to have? I was assuming you were talking about sugar cubes, but you said it was fairly complex shapes...
Rigid bodies is quite limited, slow and crashes a lot if you don't optimize the simulation with simple collision shapes and of course if you have a lot of objects.
I did try a lot of different dynamics solvers few months ago and the one that was the most efficient and also the fastest was PullDownIt! There is a free version that is interesting if you just need gravity and no other forces.

RagingBull
06 June 2010, 09:30 PM
Sorry, nothing to add YET - but I just wanted to chime in and say what a bloody good thread.
Some absolutely fantastic results too.

I shall give it a go myself, expect mud :argh:

funerium
06 June 2010, 01:48 PM
hi there, i finally started mine, introducing myself really with caustics and all that stuff, but i am getting some troubles, the most visible is the glass/coffee interface dun looks as the help liquid pictures, i followed the help on the mia mat (http://download.autodesk.com/us/maya/2009help/mr/shaders/architectural/arch_mtl.html#parameters) and the glass/liquid part

to sum up i made :


Air-Glass interface (IOR = 1.5/1.0 = 1.5)
Air-Liquid interface (IOR = 1.33/1.0 = 1.33)
Glass-Liquid interface (IOR=1.33/1.5=0.8)
glass normal and liquid ones are pointing in the right sides, i get 3 separates shapes, but scaled @0.999 down due to artefact when the water touched the glass

so the question is : what i missed?
i post some settings if you need some other infos...
thanks

settings (http://img821.imageshack.us/img821/7042/settingsg.jpg)http://img820.imageshack.us/img820/52/tasse4.jpg

CGTalk Moderation
06 June 2010, 01:48 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.


1