Module raytracer

Interface Shader

All Superinterfaces:
Scattering
All Known Subinterfaces:
Shader
All Known Implementing Classes:
AlgorithmSwitchShader, IORShader, Material, MaterialRef, Phong, RGBAShader, ShaderRef, SideSwitchShader, SunSkyLight, SwitchShader

public interface Shader extends Scattering
A Shader instance represents a surface shader which calculates the color of an outgoing light ray at a given point as a function of geometrical and optical properties, namely local and global point coordinates, canonical uv-coordinates, surface tangent vectors, outgoing ray direction, index of refraction, and a list of incident light rays, consisting of color and direction.
Author:
Ole Kniemeyer
  • Field Details

  • Method Details

    • shade

      void shade(Environment env, RayList in, Vector3f out, Spectrum specOut, Tuple3d color)
      Computes color of outgoing light ray for given input. The computed value is, for each color component j = R, G, B, the following sum over all incident rays k:
      k |cos θk| BSDFjk, out) ck,j
      where BSDFj is the bidirectional scattering distribution function (= BRDF + BTDF) at the point env.point, ωk and ck the direction and color of ray k, and θk the angle between the surface normal and ωk.

      The computation may include physically invalid contributions, which may not fit into the formula above, e.g., ambient or emissive light contributions.

      Parameters:
      env - the environment for scattering
      in - the incoming rays
      out - the direction unit vector of the outgoing ray (i.e., pointing away from the surface)
      specOut - spectrum of outgoing ray
      color - the output color will be placed in here
    • computeMaxRays

      void computeMaxRays(Environment env, Vector3f in, Spectrum specIn, Ray reflected, Tuple3f refVariance, Ray transmitted, Tuple3f transVariance)
      Computes, for the given input, the reflected and transmitted importance rays for which the reflection/transmission probability densities (integrated over the spectrum) attain a maximum. The reflection probability density (measured with respect to solid angle) for the outgoing importance direction (i.e., incoming light direction) ω, given a fixed incident direction in, is
      pr(ω) = cos θ BRDF(ω, in) / R
      where BRDF is the bidirectional reflectivity distribution function, θ the angle between the surface normal and ω, and R the total reflectivity for the incident direction, i.e., the integral over cos θ BRDF(ω, in). The transmission probability density is defined correspondingly.

      The color-fields are set to the total reflectivity/transparency for the incident direction for each color component R, G, B. Thus, for physically plausible BRDF/BTDF, the component-wise sum of reflected.color and transmitted.color lies in the interval [0, 1], and the difference to 1 is the amount absorbed.

      The color may be zero if there is no reflected or transmitted ray, respectively, i.e., if the surface is fully transparent, opaque, or absorbing. The origin-fields of the rays will never be set.

      The computed variances are defined to be, for each color component, (approximations for) the angular mean quadratic deviations of the densities from the returned maximal ray directions. E.g., for perfect reflection/transmission, these variances are zero, whereas for a perfect lambertian reflector, the variance of reflection is ∫ cos θ (1 / π) θ2 dω = (π2 - 4) / 8. This is the value of LAMBERTIAN_VARIANCE.

      The ray properties which are not mentioned are neither used nor modified. These are the origin and its density, and the direction density.

      Parameters:
      env - the environment for scattering
      in - the (negated) direction unit vector of the incoming ray (i.e., pointing away from the surface)
      specIn - spectrum of incoming ray
      reflected - the reflected ray with maximal probability
      refVariance - the angular mean quadratic deviation from reflected
      transmitted - the transmitted ray with maximal probability
      transVariance - the angular mean quadratic deviation from transmitted
    • isTransparent

      boolean isTransparent()