Create a glass with Blender and Mitsuba
Filippo Veniero explains how use the Mitsuba render engine to obtain a physically accurate glass render in Blender, complete with water, bubbles and a straw.
In this tutorial I'll show you how to use Mitsuba in Blender to create a physically correct glass cup. Mitsuba is an open source, physically-based renderer, runs on Linux, Mac OS X, Windows and is extremely modular. Many rendering techniques are available (direct illumination, path tracer, bidirectional path trace, photon map and so on). It supports volume rendering and the most commonly used scattering models (rough glass, plastic, metal).
Download the Mitsuba software and the plug-in for Blender. Now install Mitsuba, unzip the plug-in and copy the folder called Mitsuba into Blender/2.69/scripts/addons.
Modeling the glass
Open Blender and enable Mitsuba (File > User Preferences > Addons). Change the render engine from Blender to Mitsuba and write the path of the executable file in the Executable Path field.
Delete the default cube and add a circle of 16 vertices. Enter Edit mode and extrude along the Z axis and scale just a little. Close the bottom of the glass and model the inside, then add Subdivision Surface modifier (level 2) and set the Shading to smooth. Call this mesh 'Glass'.
Modeling the glass
Create the water
In Edit mode, select the vertices inside the glass and separate them ( P > by selection ). Call this part 'water'. Now select the vertices of the first edge loop, duplicate and separate them: call this new mesh 'water_top'. Close them by extruding and scaling and don't forget the meniscus (the curve in the upper surface of the liquid against the side of the glass). Check the mesh's Normals – it's very important that they are consistent and face the same direction!
Add bubbles and straw
On another layer, create 2 or 3 bubbles and add them to a group called bubbles. Duplicate the water mesh, scale it just a little and add a particles system. Set Type as Hair and Emit From Faces. In the render tab of the particles system, deselect Emitters and add the bubbles group. Now add a circle ( with 8 vertices) and extrude along the Z axis. Add some Loop Cut and set Subdivision Surface to level 2 and solidify modifier. In Object mode, set shading as smooth and put it inside the glass.
Add a plane as in the image below, enter Edit mode and Unwrap. In Object mode, add a new diffuse material and then add a floor texture in the Texture tab. Come back into material tab, click on the T button (at the right of the reflectance color) and select the floor texture. Select the glass and add a dielectric material: set interior IOR as 1.49 and exterior as 1.00. Select the water, add another dielectric material (interior IOR 1.49 and exterior 1.33 – and be sure that the Normals are oriented the same as the image below).
Enter interior IOR 1.33 and exterior 1.00 for the top of the water, and interior IOR 1.00, exterior 1.49 for the bubbles. Select the straw and add a white plastic material, then add a red plastic material and (in Edit mode) assign it to the right faces.
Scene and render settings
For this render we'll use a photon mapping integrator, which works better in a closed room, so add some planes (assign diffuse material) around the scene as in the image below, set the camera and add a sphere inside the scene (emission material).
In the render tab choose Photon Mapper and press F12 to start the render. If the result is too noisy try to increase the photon number and/or samples (in my work I used 96 pixels-per-samples).
Top tip: Post-production with Gimp
Open the image with Gimp, adjust the curves then duplicate the layer. Add a Gaussian blur (20-pixels) on the new layer and set blend mode to ADD.