This delicious gummy candy was done for the second challenge at shaders.xyz...but I missed the deadline! (apparently...) Let me share some of the tricks I used for achieving the image with RenderMan.
Since the candy is extremely closeup and accuracy is important, I wanted to have realistic caustics instead of transparent shadows, which are more efficient but not physical. For this we are using RenderMan's bi-directional path tracer (VCM), which will give us photon-based caustics.
To generate caustics, we need to turn on "Trace Light Paths" in our Dome Light, so that it emits photons.
For faster (but biased) convergence, I used photon guiding, by setting it to 0.9 in the integrator settings. This fractional value will leave a little bit of brute-force caustic generation.
I knew I needed to do several layers of sugar, so I used Pixar Layer Surface for the candy material, which will give me more flexibility. Since the candy came with nice UVs, I started with a simple color base in Mudbox...
One thing to keep in mind is color vibrancy when combining refraction and subsurface effects, or else we risk blowing out color. For this, I made sure none of my base colors where absolute primary colors to avoid over exposure.
We're assigning the painted color texture to the refraction color and the subsurface color and using the gain to control the intensity of each of these shading attributes. Using the right Mean Free Path Distance is very important, or else we risk the rays going through the surface or not penetrating enough to have a considerable effect.
I chose to use Jensen Dipole as the subsurface model, as it has a gummier look. We're using Diffuse Computation to optimize render times a bit without compromising quality, as well as turning on Double Sided for added shading luminance, which helps bring our candy to life.
When the DMFP is too large, we might get inverted colors.
Adding interior (volumetric) shading was essential to reaching a gummy feel, we need to make sure we're scattering the right color, or we can make our candy look unpleasing.
The sugar is all procedural, made primarily from Voronoise and Worley patterns blended together at different intensities. I'm also heavily remapping them to achieve the right contrast for the sugar grains, so that I can isolate the BXDF layers without affecting the underlying gummy material.
Sugar is very similar to rough glass, so we are using SSS and refraction with high roughness to create the larger sugar cubes. This is masked by a remapped version of the same map, giving us a total of 3 layers.
We're also heavily using displacements to bring out the most realism possible in the candy and mixing in some bump mapping for the finer sugar detail.
I also generated some LPEs to do some slight color correction in post, two of the more relevant ones were transmissive and subsurface. I used these LPEs to generate B/W mattes which I then used to add some subtle saturation, hue and contrast changes to the gummy candy.
I've also added a bit of soft glow for extra deliciousness.
Crack open the Maya scene and have fun dissecting the shading network!