Module gpuFlux

Class IORShader

java.lang.Object
de.grogra.persistence.ShareableBase
de.grogra.gpuflux.imp3d.shading.IORShader
All Implemented Interfaces:
Scattering, Shader, Manageable, Shareable, Scattering, Shader

public class IORShader extends ShareableBase implements Shader
  • Field Details

  • Constructor Details

    • IORShader

      public IORShader()
    • IORShader

      public IORShader(float iorA, float iorB, Shader inputShader)
      Constructor
      Parameters:
      iorA - first term in Cauchy's equation
      iorB - second term in Cauchy's equation
      inputShader - input shader
  • Method Details

    • getManageableType

      public ManageableType getManageableType()
      Specified by:
      getManageableType in interface Manageable
    • getIorA

      public float getIorA()
    • setIorA

      public void setIorA(float value)
    • getIorB

      public float getIorB()
    • setIorB

      public void setIorB(float value)
    • getInputshader

      public Shader getInputshader()
    • setInputshader

      public void setInputshader(Shader value)
    • getFlags

      public int getFlags()
      Specified by:
      getFlags in interface Scattering
    • getAverageColor

      public int getAverageColor()
      Description copied from interface: Scattering
      Returns an average color for the scattering entity. This color is used for simplified graphical representations of the corresponding objects.
      Specified by:
      getAverageColor in interface Scattering
      Returns:
      an average color in Java's default sRGB color space, encoded as an int (0xAARRGGBB).
    • generateRandomRays

      public void generateRandomRays(Environment env, Vector3f out, Spectrum specOut, RayList rays, boolean adjoint, Random random)
      Description copied from interface: Scattering
      Pseudorandomly generates, for the given input, a set of scattered rays. The scattered rays are generated such that they can be used for a Monte Carlo integration of a function f(ω;ν) over cos θ BSDF(ωi, νi; ωo, νo) in the following way:
      • If adjoint is false, out = ωo describes the direction of an outgoing light ray. In this case, the integration is with respect to ωi. Let g(ω, ν; out, μ) = BSDF(ω, ν; out, μ)
      • Otherwise, adjoint is true. In this case, out = ωi describes the direction of an outgoing importance ray (an inverse light ray). Now the integration is with respect to ωo. Let g(ω, ν; out, μ) = BSDF(out, μ; ω, ν)
      Let di and si denote the directions and spectra of the N generated rays (N = rays.size). Then, for every frequency ν the sum
      1 / N ∑i si(ν) f(di; ν)
      is an unbiased estimate for the integral
      ∫ cos θ f(ω; ν) g(ω, ν; out, μ) specOut(μ) dμ dω
      θ is the angle between the surface normal and ω. The domain of integration is the whole sphere, since the bidirectional scattering distribution includes both reflection and transmission (BSDF = BRDF + BTDF).

      If this Scattering instance is in fact a Light source, adjoint is true, and the BSDF is defined as BSDF(out, μ; ω, ν) = L1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted radiance at env.point, see Emitter. In this case, out is not used.

      If this Scattering instance is in fact a Sensor, adjoint is false, and the BSDF is defined as BSDF(ω, ν; out, μ) = W1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted importance at env.point, see Emitter. In this case, out is not used.

      Let pω be the probability density used for the ray direction (measured with respect to solid angle ω), then the field directionDensity of the ray i is set to pω(di). For ideal specular reflection or transmission, or for directional lights or sensors, pω is not a regular function, the value directionDensity will be set to a multiple of Scattering.DELTA_FACTOR.

      The ray properties which are not mentioned in the given formulas are neither used nor modified. These are the origin and its density.

      Specified by:
      generateRandomRays in interface Scattering
      Parameters:
      env - the environment for scattering
      out - the direction unit vector of the outgoing ray (i.e., pointing away from the surface)
      specOut - the spectrum of the outgoing ray
      rays - the rays to be generated
      adjoint - represents out a light ray or an importance ray?
      random - pseudorandom generator
      See Also:
    • computeBSDF

      public float computeBSDF(Environment env, Vector3f in, Spectrum specIn, Vector3f out, boolean adjoint, Spectrum bsdf)
      Description copied from interface: Scattering
      Evaluates bidirectional scattering distribution function for given input.

      The computed spectrum is an integral over the spectrum of the following product:

      |cos θ| BSDF(ωi, νi; ωo, νo)
      where BSDF is the bidirectional scattering distribution function (= BRDF + BTDF) at the point env.point, ωi the (negated) direction of the incoming light ray, νi the frequency where the incoming ray is sampled, ωo the direction of the outgoing light ray, νo the frequency where the outgoing ray is sampled, and θ the angle between the surface normal and out.

      If adjoint is false, in and out describe true light rays from light sources to sensors. In this case, ωi = in, ωo = out, and the integral is

      bsdf(ν) = |cos θ| ∫ BSDF(in, νi; out, ν) specIni) dνi
      Otherwise, adjoint is true. in and out then describe importance rays (inverse light rays from sensors to light sources). In this case, ωi = out, ωo = in, and the integral is
      bsdf(ν) = |cos θ| ∫ BSDF(out, ν; in, νo) specIno) dνo

      If this Scattering instance is in fact a Light source, adjoint is false, and the BSDF is defined as BSDF(in, μ; ω, ν) = L1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted radiance at env.point, see Emitter. In this case, in is not used.

      If this Scattering instance is in fact a Sensor, adjoint is true, and the BSDF is defined as BSDF(ω, ν; in, μ) = W1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted importance at env.point, see Emitter. In this case, in is not used.

      The computation should be physically valid. This excludes, e.g., ambient or emissive light contributions.

      The returned value is the value of the probability density pω that would be calculated by Scattering.generateRandomRays(de.grogra.ray.physics.Environment, javax.vecmath.Vector3f, de.grogra.ray.physics.Spectrum, de.grogra.ray.util.RayList, boolean, java.util.Random) if the ray happened to be one of the randomly generated rays.

      Specified by:
      computeBSDF in interface Scattering
      Parameters:
      env - the environment for scattering
      in - the (negated) direction unit vector of the incoming ray (i.e., pointing away from the surface)
      specIn - the spectrum of the incoming ray
      out - the direction unit vector of the outgoing ray (i.e., pointing away from the surface)
      adjoint - light ray or importance ray?
      bsdf - the computed spectrum of the outgoing ray will be placed in here
      Returns:
      the value of the probability density for the ray direction
    • shade

      public void shade(Environment env, RayList in, Vector3f out, Spectrum specOut, Tuple3d color)
      Description copied from interface: Shader
      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.

      Specified by:
      shade in interface Shader
      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

      public void computeMaxRays(Environment env, Vector3f in, Spectrum specIn, Ray reflected, Tuple3f refVariance, Ray transmitted, Tuple3f transVariance)
      Description copied from interface: Shader
      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 Shader.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.

      Specified by:
      computeMaxRays in interface Shader
      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

      public boolean isTransparent()
      Specified by:
      isTransparent in interface Shader
    • accept

      public void accept(ShaderVisitor visitor)
      Specified by:
      accept in interface Shader