|
|
After years of procrastinating, I finally did it: I compared various
models of glass/water interface.
Five models are attached. After I started work, it occurred to me that
the demo would be clearer if I used colored glass and beer. However, I
do not know the IOR of beer, so I'm calling it unsweetened green tea,
which is essentially water. (Besides, bubbles and foam would just
complicate the demo.) The colors are modeled entirely by interior fading.
The leftmost image is a naive construction with coincident surfaces. No
more need be said.
In the second from the left, the water overlaps the glass.
Surprisingly, this killed the coloring of the water--totally
unacceptable. It left weird highlights that don't show up in real life,
and whose render blocks took a long time to complete.
The middle image has a tiny space between the water and the glass. This
is a vast improvement. However, there are some unrealistic double
reflections, and dubious highlights around the top surface of the water.
The second image from the right uses a solution which I have vaguely
imagined for years, but never managed to hammer out until now: clipping
the section of the glass where it contacts the water.
The rightmost image uses the technique that Le Forgeron published in the
wiki. The technique makes sense on paper, but there are a few problems
with the resulting image that I cannot explain:
- The green of the glass shows strongly at the top surface of the
water. This seems unlikely given how little green shows through
the actual glass.
- Where the straw enters the water, it appears bent at a sharper
angle than in the other images, as if POV-Ray were using the IOR of
the glass instead of the water.
- More subtly, the glass above the water is less green than in the
other images, and the reflection of the straw in the glass is much
weaker.
These problems suggest that cutaway_textures does not work on interiors
the way I (and presumably Jerome?) would expect it to.
The wiki example has an unspecified material for the air. I have
omitted one because an interior would seem to be redundant, and a
texture would defeat the cutaway_textures. If these assumptions are
wrong, please let me know.
----------[BEGIN CODE EXCERPT]----------
// +kkff5
#version 3.71;
#ifndef (Test) #declare Test = frame_number; #end
#include "ior.inc"
#declare RGLASS = 0.6;
#declare RWATER = 0.55;
#declare YTOP = 2;
#declare YSURFACE = 1.4;
#declare YBOTTOM = 0;
#declare YFLOOR = 0.15;
#declare RSTRAW = 0.075;
#declare EPSILON = 0.001;
#declare Straw = cylinder
{ 0, 3 * y, RSTRAW open
pigment
{ radial color_map
{ [0.3 rgb <0.7, 0, 0.07>]
[0.3 rgb 0.8]
}
frequency 4
rotate 0.35 * 90 * y
}
finish { diffuse 1 ambient sotd_c_Ambient }
}
#declare t_Clear = texture
{ pigment { rgbf 1 }
finish
{ fresnel conserve_energy
reflection { 0 1 }
specular albedo 1
roughness 0.0001
}
}
#declare m_Glass = material
{ texture { t_Clear }
interior
{ ior iorGlass
fade_color rgb <0.1, 0.9, 0.5>
fade_distance 0.5
fade_power 1000
}
}
#declare m_Water = material
{ texture { t_Clear }
interior
{ ior 1.33
fade_color rgb <0.95, 0.75, 0.05>
fade_distance 0.5
fade_power 1000
}
}
#switch (Test)
#case (1)
#declare Glass_of_water = union
{ difference
{ cylinder { YBOTTOM * y, YTOP * y, RGLASS }
cylinder { YFLOOR * y, (YTOP + EPSILON) * y, RWATER }
hollow
material { m_Glass }
}
cylinder
{ YFLOOR * y, YSURFACE * y, RWATER
hollow
material { m_Water }
}
}
#break
#case (2)
#declare Glass_of_water = union
{ difference
{ cylinder { YBOTTOM * y, YTOP * y, RGLASS }
cylinder { YFLOOR * y, (YTOP + EPSILON) * y, RWATER }
hollow
material { m_Glass }
}
cylinder
{ (YFLOOR - EPSILON) * y, YSURFACE * y, RWATER + EPSILON
hollow
material { m_Water }
}
}
#break
#case (3)
#declare Glass_of_water = union
{ difference
{ cylinder { YBOTTOM * y, YTOP * y, RGLASS }
cylinder { YFLOOR * y, (YTOP + EPSILON) * y, RWATER }
hollow
material { m_Glass }
}
cylinder
{ (YFLOOR + EPSILON) * y, YSURFACE * y, RWATER - EPSILON
hollow
material { m_Water }
}
}
#break
#case (4)
#declare Glass_of_water = union
{ difference
{ cylinder { YBOTTOM * y, YTOP * y, RGLASS }
cylinder { YFLOOR * y, (YTOP + EPSILON) * y, RWATER }
clipped_by
{ cylinder
{ (YFLOOR - EPSILON) * y, YSURFACE * y, RWATER + EPSILON
inverse
}
}
hollow
material { m_Glass }
}
cylinder
{ YFLOOR * y, YSURFACE * y, RWATER
hollow
material { m_Water }
}
}
#break
#case (5)
#declare Glass_of_water = difference
{ union
{ cylinder
{ YBOTTOM * y, YTOP * y, RGLASS
hollow
material { m_Glass }
}
cylinder
{ YFLOOR * y, (YSURFACE + EPSILON) * y, RWATER
hollow
material { m_Water }
}
}
cylinder // air
{ YSURFACE * y, (YTOP + EPSILON) * y, RWATER + EPSILON
hollow
}
cutaway_textures
hollow
}
#break
#end
union
{ object
{ Glass_of_water
photons { target collect off reflection on refraction on }
}
object
{ Straw
translate -RSTRAW * x
rotate degrees (-atan2 (2 * (RWATER - RSTRAW), YTOP - YFLOOR)) * z
translate <2 * RSTRAW - RWATER, YFLOOR, 0>
}
}
-----------[END CODE EXCERPT]-----------
Notes:
1. The environment is provided by my personal prefab render rig, thus,
that code is not shown.
2. The assumed_gamma for this scene is 1.0.
3. The identifier sotd_c_Ambient is declared by my render rig, so the
soda straw will not parse as-is. Since I used radiosity for this
render, the value is irrelevant, but it was calculated to be rgb
0.26735.
4. There is a tiny space between the glass and the checkered plane.
No sense in having the render rig create its own coincident
surface!
5. Photon spacing was set at 0.002.
6. The sole reason for #version 3.71 was finish-level fresnel. For
similar effects in 3.7.0, you will need to use different textures
for the glass and the water. Move the fresnel keyword inside the
reflection block, and set specular albedo 0.053 for the glass and
specular albedo 0.026 for the water.
6a. If you are using 3.6.*, delete the #include "ior.inc" line, use
specular 67 and ior 1.5233 for the glass, and use specular 32
for the water. (Better yet, upgrade.)
Post a reply to this message
Attachments:
Download 'glass+water_montage.jpg' (124 KB)
Preview of image 'glass+water_montage.jpg'
|
|