Liuye Zhao@ZJU:~$Hi there!
Back to Showcase
Glass Bunny preview

Showcase Detail

Glass Bunny

Beautiful Glass Bunny with different color

glassbunny

The source cuda code can be found here, which you should noted is that the stb_image.h, stb_image_write.h and the stanford-bunny.obj must be placed at the same file level.

1. Rendering Equation

1.1 Radiance and Solid Angle

  • Radiance : the energy density at point along direction , and the most fundamental quantity in rendering.
  • Hemispherical integration domain: the hemisphere above the surface normal , denoted .
  • Cosine term: , representing projected-area foreshortening due to the angle between incident direction and normal.

1.2 Surface Rendering Equation (Kajiya)

A common form for opaque surfaces is:

Where:

  • : outgoing radiance
  • : emitted radiance
  • : BSDF (a unified form covering BRDF/BTDF)
  • : incident radiance (recursively contributed by other scene points)

The challenge for glass is that contains both reflection and transmission, and ideal glass is delta-distributed, so it cannot be handled directly with ordinary continuous PDFs.

2. Interface Physics of Liuli (Dielectric Glass)

Glass is usually modeled as a non-conductive dielectric. At the interface, three events may occur:

  1. Fresnel reflection
  2. Refraction (Snell)
  3. Possible total internal reflection (TIR)

2.1 Snell’s Law

  • : index of refraction on incident side (air is about 1.0)
  • : index of refraction on transmitted side (glass is commonly 1.45~1.55)

2.2 Fresnel Term

Exact dielectric Fresnel (parallel/perpendicular polarization):

In practice, Schlick’s approximation is widely used:

2.3 Total Internal Reflection

When traveling from a higher IOR medium to a lower one, if the refraction angle has no real solution, then and only reflection remains.

3. Glass “Color” Comes from Volumetric Absorption: Beer-Lambert

Ideally, non-absorbing glass is effectively colorless. Colored liuli comes from the medium absorption coefficient (per RGB channel):

  • : geometric distance traveled by light inside glass
  • : transmittance (per channel)

In path tracing, whenever “the previous segment is inside glass,” multiply throughput by .

This is why controls glass tint strength in many implementations.

4. Liuli BSDF: From Ideal to Rough

4.1 Ideal Smooth Glass (Specular Delta)

An ideal interface has only two discrete directions:

  • Specular reflection direction
  • Refraction direction

It can be written in delta form (schematically):

is the measure-conversion term for transmission (related to ). In many practical implementations, this is absorbed via event sampling probability + throughput update.

Corresponding sampling:

  • Sample reflection with probability
  • Sample transmission with probability
  • Under TIR, force reflection

4.2 Rough Glass

Real liuli surfaces have microstructure, so microfacet models are used:

  • Normal distribution function (commonly GGX/Beckmann)
  • Geometric masking-shadowing term
  • Fresnel term

Rough glass includes:

  1. Microfacet reflection BRDF
  2. Microfacet transmission BTDF

Characteristics:

  • Highlights/caustics become more diffuse instead of razor sharp
  • Noise convergence strongly depends on the sampling strategy (BSDF-only sampling is often still noisy)

5. Decomposing Lighting Integral: Direct + Indirect

Split the rendering equation into:

  • : direct contribution from visible light sources at current point (can use NEE)
  • : recursive bounce contribution

For glass scenes, relying only on “randomly bouncing into light” is very noisy, especially with small area lights and caustic paths. So typically:

  1. Perform NEE on diffuse / non-delta vertices
  2. Use MIS to combine BSDF sampling and light sampling

6. Path Tracing Estimator (Monte Carlo)

Let path throughput be . Update at each hit :

If inside glass, also apply absorption:

Final pixel estimate:

7. NEE (Next Event Estimation)

At current point , sample light point directly:

Where:

  • is visibility (shadow ray)
  • If an area light is sampled in area measure first, convert area PDF to solid-angle PDF:

8. MIS (Multiple Importance Sampling)

When the same integral can be estimated by two strategies (light sampling / BSDF sampling), MIS reduces variance.

Common Power Heuristic:

Then:

  • Multiply light-sampling contribution by
  • Multiply BSDF-hit-light contribution by

This is more stable when lights are small, BSDFs are sharp, or both are complex.

9. Russian Roulette (Unbiased Path Termination)

Deep paths are expensive, so after bounce >= 3 a survival test is usually applied:

  • If terminated: break
  • If survived:

This keeps the estimator unbiased while significantly reducing average path length.

10. Engineering-Level Denoising

Glass + area light often produces high-frequency bright speckle noise (fireflies). Common combinations:

  1. Physics-level variance reduction
  • NEE + MIS
  • Better BSDF/light sampling
  • Higher spp while camera is still
  1. Statistical denoising
  • Firefly clamp (limit extreme samples)
  • Joint bilateral / temporal accumulation / A-Trous
  1. Perceptual post-process
  • Perform filtering in HDR domain before tonemapping to avoid color shift

Note: clamping introduces slight bias, but greatly improves usability and is common in interactive preview.

11. Practical Parameter Ranges (Liuli)

  • : 1.45~1.55 (typical glass)
  • : 0~2 (depends on model scale)
  • : 0.02~0.15 (common micro-frosted liuli range)
  • : 8~12
  • : higher when camera is still, lower while moving

If model scale changes significantly, recalibrate first, otherwise color can become too strong or too weak.