- All Known Implementing Classes:
AlgorithmSwitchShader
,AmbientLight
,Camera
,DirectionalLight
,IORShader
,LightBase
,Material
,MaterialRef
,Parallelogram
,Phong
,PhysicalLight
,PointLight
,RGBAShader
,SensorNode
,ShaderRef
,SideSwitchShader
,Sky
,SpectralLight
,SpotLight
,SunSkyLight
,SunSkyToDirectionalLightWrapper
,SwitchShader
Scattering
instance represents a scattering entity:
Either a surface Shader
, a Light
source,
or a Sensor
. Methods are provided that a
Monte Carlo-based raytracer needs for lighting calculations. This allows
for any desired bidirectional scattering
distribution functions (BSDF) in implementations of Scattering
.- Author:
- Ole Kniemeyer
-
Field Summary
Modifier and TypeFieldDescriptionstatic final float
A largefloat
value (1010) used as a common factor for representing non-zero values of δ-distributions.static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionfloat
computeBSDF
(Environment env, Vector3f in, Spectrum specIn, Vector3f out, boolean adjoint, Spectrum bsdf) Evaluates bidirectional scattering distribution function for given input.void
generateRandomRays
(Environment env, Vector3f out, Spectrum specOut, RayList rays, boolean adjoint, Random random) Pseudorandomly generates, for the given input, a set of scattered rays.int
Returns an average color for the scattering entity.int
getFlags()
-
Field Details
-
NEEDS_TRANSFORMATION
static final int NEEDS_TRANSFORMATION- See Also:
-
NEEDS_POINT
static final int NEEDS_POINT- See Also:
-
NEEDS_NORMAL
static final int NEEDS_NORMAL- See Also:
-
NEEDS_TANGENTS
static final int NEEDS_TANGENTS- See Also:
-
NEEDS_UV
static final int NEEDS_UV- See Also:
-
IS_NON_OPAQUE
static final int IS_NON_OPAQUE- See Also:
-
RANDOM_RAYS_GENERATE_ORIGINS
static final int RANDOM_RAYS_GENERATE_ORIGINS- See Also:
-
MIN_UNUSED_FLAG
static final int MIN_UNUSED_FLAG- See Also:
-
DELTA_FACTOR
static final float DELTA_FACTORA largefloat
value (1010) used as a common factor for representing non-zero values of δ-distributions.- See Also:
-
-
Method Details
-
getFlags
int getFlags() -
getAverageColor
int getAverageColor()Returns an average color for the scattering entity. This color is used for simplified graphical representations of the corresponding objects.- Returns:
- an average color in Java's default sRGB color space, encoded as an int (0xAARRGGBB).
-
generateRandomRays
void generateRandomRays(Environment env, Vector3f out, Spectrum specOut, RayList rays, boolean adjoint, Random random) 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
isfalse
,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
istrue
. 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
, μ; ω, ν)
rays.size
). Then, for every frequency ν the sum1 / N ∑i si(ν) f(di; ν) is an unbiased estimate for the integral∫ cos θ f(ω; ν) g(ω, ν; θ 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).out
, μ)specOut
(μ) dμ dωIf this
Scattering
instance is in fact aLight
source,adjoint
istrue
, and the BSDF is defined as BSDF(out
, μ; ω, ν) = L1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted radiance atenv.point
, seeEmitter
. In this case,out
is not used.If this
Scattering
instance is in fact aSensor
,adjoint
isfalse
, and the BSDF is defined as BSDF(ω, ν;out
, μ) = W1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted importance atenv.point
, seeEmitter
. 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 valuedirectionDensity
will be set to a multiple ofDELTA_FACTOR
.The ray properties which are not mentioned in the given formulas are neither used nor modified. These are the origin and its density.
- Parameters:
env
- the environment for scatteringout
- the direction unit vector of the outgoing ray (i.e., pointing away from the surface)specOut
- the spectrum of the outgoing rayrays
- the rays to be generatedadjoint
- representsout
a light ray or an importance ray?random
- pseudorandom generator- See Also:
-
If
-
computeBSDF
float computeBSDF(Environment env, Vector3f in, Spectrum specIn, Vector3f out, boolean adjoint, Spectrum bsdf) 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 pointenv.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 andout
.If
adjoint
isfalse
,in
andout
describe true light rays from light sources to sensors. In this case, ωi =in
, ωo =out
, and the integral isbsdf
(ν) = |cos θ| ∫ BSDF(in
, νi;out
, ν)specIn
(νi) dνiadjoint
istrue
.in
andout
then describe importance rays (inverse light rays from sensors to light sources). In this case, ωi =out
, ωo =in
, and the integral isbsdf
(ν) = |cos θ| ∫ BSDF(out
, ν;in
, νo)specIn
(νo) dνoIf this
Scattering
instance is in fact aLight
source,adjoint
isfalse
, and the BSDF is defined as BSDF(in
, μ; ω, ν) = L1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted radiance atenv.point
, seeEmitter
. In this case,in
is not used.If this
Scattering
instance is in fact aSensor
,adjoint
istrue
, and the BSDF is defined as BSDF(ω, ν;in
, μ) = W1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted importance atenv.point
, seeEmitter
. 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
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.- Parameters:
env
- the environment for scatteringin
- the (negated) direction unit vector of the incoming ray (i.e., pointing away from the surface)specIn
- the spectrum of the incoming rayout
- 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
-