Creating a soap material
Views
Personal tools
From LuxRender Wiki
This is a tutorial for the soap material I did for my soap scene, written for LuxRender 0.7rc3 or later.
I hope I can show interested people a summary of the creation of the soap from my scene, and on the other hand I may be able to help some with what steps you have to go through before creating something more complex, to achieve your results and ideas rapidly, and not wasting time trying to adjust every single button.
Caution: This is not a tutorial for beginners, I will not explicitly describe where buttons and values are located and how textures should be applied.
Because of license I can't provide any textures I used for this project, only the following two are made by my own from scratch in Photoshop:
All other textures I used have the same style, black/white images with high contrast, some have smooth edges others not. I hope this helps for imagination of the used images.
Contents |
Thoughts about a soap material
Before starting to develop a soap material, you have to have some knowledge about the material. Soap is something organic where light is shining more or less through the object. There are many different kinds of soap and I will describe only the method I used for my soap scene. This means there are several other ways, and even my result isn't the one and only correct method. The differences between soap materials in reality could be:
- Light shining through the object to varying degrees
- Some soap has reflective surfaces
- Some have structures on the surface like fractures, others could have those in the inside as well
First of all you have to search for some photos of the materials you have in mind. These photos could give you a more specific view what you have to do and maybe where the complexity lies. When watching the photos think about what fundamental materials from LuxRender you see on the surface (matte, glossy, matte translucent, mirror, etc.) The more difficult part are objects with a subsurface scattering effect (SSS), where light rays enter into the object and interact with its inner material.
In our soap material we see that light is shining through the object, furthermore light will be more attenuated the more the light travels through the object (thus the thicker our soap is). Regarding LuxRender materials and settings we need a 'mattetranslucent' with 'absorption' activated. The simplest would be to use the SSS model, but LuxRender doesn't support it yet. Therefore we will fake this effect by creating an inner mesh that will take care of the scattering.
The conclusion is that we we will use the following fundamental LuxRender materials/mechanism for our soap:
- mattetranslucent material
- absorption
- matte material for surface variations
- glossy material for shiny reflection
- bump mapping
- second mesh for scattering
Setting up a scene
The purpose of creating a scene isn't merely to get a proper background. More importantly, the scene should place focus to the objects and the topic. In achieving this, light and shadow are equal partners. Only the right interaction of light and shadow brings a nice contrast. The human eye is able to see three dimensional structures more clearly on pictures with a balanced contrast, and it will give the image a improved depth. To follow this idea, think of a simple sphere which will be lit from three different directions with the same light strength. A rendering of this sphere would only show a bright circle, and it would be difficult to see that it's a sphere. But if you use only one light, the balance between bright and dark areas would make it much easier to realize that it is a sphere. Unfortunately it is not always clear what the best light properties are, and there is not only one solution for a specific scene. Some scenes would go best with one, some with two and others with three lights. But using more than three light sources is rarely needed (except when using HDRI).
To set my soap scene into the right spot, I chose a setup with three point lights (with different gain) in a scene like a studio. With the three lights, the scattering effect shows nicely and let the soap look more voluminous.
The scene from the blender window:
To test and tweak the best light setup (gain, color) and to be able to view the light/shadow interaction I used some simple cubes.
The last image uses adjusted settings:
- gamma: 1.9
- vignetting on
- c aberration on
- linear tonemapper
- color space (0.33,0.33)
- light back 9100 kelvin
- light front 4100 kelvin
- light top 6500 kelvin
I'm using these final settings for the following tests as well.
Creating the soap material
It is not a very good idea to create the whole mix material at the beginning, and adjust all buttons and texture channels. On the one hand a complex mix material set could be very confusing, and on the other hand it is a lot more difficult to adjust a specific channel of a material when other materials and channels are also active. So we will create our material tree from the root up to the top.
Mattetranslucent
First of all for the soap material we select a 'mattetranslucent' material and adjust the reflection and transmission values. Here you have to be careful that the reflection and transmission values added together don't get a value higher than one. Otherwise you may get fireflies and your scene will be clearing up much slowly.
- Reflection: 0.3
- Transmission: 0.6
I should mention that when activating absorption the rule of 'reflection+transmission<1' is not that important, because the absorption is able to attenuate the light a lot (also depending on the depth value). Anyhow it is better to go with this rule.
For more variation I created textures for the reflection and transmission channel:
This seems a bit too bright so we adjust the gamma value of both reflection and transmission texture up to '3':
This looks much better, we could consider setting the gamma value higher, but this can be done in the final tweaking later on.
Absorption
Now we activate absorption by selecting an internal and external medium. The external one should be 'world' with its predefined settings. Let's call the internal medium 'soap' with the following settings:
- R: 0.976473
- G: 0.874213
- B: 0.646678
- type: clear
- IOR: constant 2.040
'color' and 'at depth' are set at a depth value of '100 mm'.
The RGB values may be a bit high, but as mentioned in the previous section an absorption means that light will be attenuated through the object, thus these values aren't as dangerous in view of fireflies as the 'normal' reflection and transmission channels. Important is the yellow color I choose. If you look on a real soap than you will see that typically scattered light near top of the surface is brighter and more white. In contrast, light which scattered from the depth of the object becomes a more dirty yellow or brown. For the index of refraction I'm not sure what a normal value for a soap should be. I choose '2' which may be a bit high, but it doesn't influence the result much. Maybe '1.5' or less would be a better choice.
Mix glossy & matte
Now we are ready to take the next step and create our final mix material preset. Next to the SSS effect our soap will have a glossy as well as a matte component. This way we are able to control another matte (non glossy) component on the surface to simulate non reflective parts without a scattering effect from the inner mesh.
So our material set should look like this:
A little tip: Before you switch the main material to a mix, save the current mattetranslucent as LBM file and reload it into the first mix material like the preset above. This saves you the time resetting all values for mattetranslucent. With the button '>' you are able to save and load LuxRender material sets.
Glossy
First of all we want to set up our glossy material, because this will be our second main material beside mattetranslucent:
- Diffuse: 0.45
- Specular: 0.1
- Exponent: 700
Bump mapping
To get some surface roughness we go on with bump mapping, and create a texture for it.
- Bumpmap value: 0.002
To get a fast result if our texture and the bumpmap value fits, we set both mix material amounts to '1' and render the scene in „Direct Lighting“ render preset. This will render the scene only with glossy material and the bump mapping very fast.
Ok, looks good so far. Now we will set two textures, one for specular and one for exponent:
This is the result:
Don't worry about the overexposed areas, the next important steps will reduce them. And on the other hand remember that I'm still using a linear tonemapper with 'fixed' values, so this could be tweaked a bit in the end as well.
Matte
Now we are ready for the settings of the last material. As described above the matte will help us to get better control of non reflective parts and less scattered parts of the object surface.
- Diffuse: 0.55
- Mix amount (of matte and glossy): 0.9
- Texture for mix amount
Setting up the mix amount for mattetranslucent + glossy/matte
The second last important step is to find the right values for mixing the mattetranslucent with the glossy/matte! For this we also use a texture and the following value:
- Mix amount: 0.2
- Texture for mix amount
And don't forget to set „MLT/Bidir Path Tracing“ render preset for this render!
Creating the mesh object for a scattering effect
The last result looks ok but still not really like a soap. The reason is that too much light is shining through the object, making it look empty. As we know the soap has light being scattered through countless surfaces, so we need a second inner mesh to simulate this effect. Note that you have to be careful with this second mesh, the gap between the outer and the inner mesh should be set to the right value. If the gap is too small you will get a lot of fireflies with high absorption color values like I chose in section 3.2! So it is necessary to watch the gap between inner and outer shell as well as setting the absorption color and depth. The situation gets more complicated when using more than one inner mesh for scattering. I tried up to three inner meshes which also reduced the render speed a lot! The inner mesh should also be as simple as possible, and should only follow the outer shell roughly.
And here a render only from the inner shell:
You will notice that the inner one has different material preset. The difference to the outer shell is that I replaced the 'glossy' with a 'glass' material and disabled some diffuse, reflection and transmission texture channels.
Here an image of the final material preset of the outer and inner mesh:
Material preset of the outer mesh:
Material preset of the inner mesh:
Final RENDER, with both meshes:
Conclusion
This tutorial should not cause people to end further tests: there are still a lot of things which could be tweaked and adjusted. But based on the result of working on this scene, I can say that it is almost possible to fake sub-surface-scattering. I'm saying 'almost' because I don't think you are able to fake all kinds of SSS effects.
A big disadvantage of this technique is that you have to use inner meshes for the scattering, and if we want to simulate more complex organic materials we must add a lot more subsurfaces which will reduce the render speed heavily. For materials where one inner mesh is enough, it will be difficult creating materials where a lot of light is shining through the object, because you will see the inner mesh and in most cases this not look too good.
Although this is a nice technique with appropriate results, I'm still looking forward for the SSS implementation in LuxRender.
I hope you enjoyed my tutorial and/or learned something! Any further questions can be asked in the thread of my soap scene!
Cheers, xray
