- All Implemented Interfaces:
Manageable
,Shareable
,Emitter
,Scattering
,Sensor
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Camera.Type
protected float
static final SCOType.Field
protected float
static final SCOType.Field
protected Projection
static final SCOType.Field
protected SharedObjectProvider
protected final Matrix4d
static final SCOType.Field
Fields inherited from interface de.grogra.ray.physics.Scattering
DELTA_FACTOR, IS_NON_OPAQUE, MIN_UNUSED_FLAG, NEEDS_NORMAL, NEEDS_POINT, NEEDS_TANGENTS, NEEDS_TRANSFORMATION, NEEDS_UV, RANDOM_RAYS_GENERATE_ORIGINS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
appendReferencesTo
(List out) double
completeRay
(Environment env, Point3d vertex, Ray out) float
computeBSDF
(Environment env, Vector3f in, Spectrum specIn, Vector3f out, boolean adjoint, Spectrum bsdf) Evaluates bidirectional scattering distribution function for given input.double
computeExitance
(Environment env, Spectrum exitance) Evaluates the exitance function for given input.static Camera
static Camera
static Camera
static Camera
static Camera
static Camera
static Camera
static Camera
void
fieldModified
(PersistenceField field, int[] indices, Transaction t) void
generateRandomOrigins
(Environment env, RayList out, Random rnd) Pseudorandomly generates, for the given input, a set of origins for this emitter.void
generateRandomRays
(Environment env, Vector3f out, Spectrum specOut, RayList rays, boolean adjoint, Random rnd) Pseudorandomly generates, for the given input, a set of scattered rays.int
Returns an average color for the scattering entity.int
getFlags()
void
Determines the ray which starts at the camera and goes through the specified point on the image plane of the camera.float
getScaleAt
(double x, double y, double z) Computes an estimate for the scaling factor from 3D world coordinates at(x, y, z)
to 2D coordinates on the camera plane.float
getScaleAt
(float z) Computes an estimate for the scaling factor from view coordinates around a depth ofz
to 2D coordinates on the camera plane.int
getStamp()
Returns a stamp for this object.float[]
getUVForVertex
(Environment env, Point3d vertex) void
Computes the transformation from view coordinates (= camera coordinates, not world coordinates!)Returns the world-to-view transformation of this camera.float
getZFar()
float
getZNear()
void
initProvider
(SharedObjectProvider provider) boolean
projectView
(float px, float py, float pz, Tuple2f point2D, boolean checkClip) boolean
projectWorld
(double px, double py, double pz, Tuple2f point2D) void
void
setProjection
(Projection value) void
setTransformation
(Matrix4d value) void
setZFar
(float maxZ) void
setZNear
(float minZ) void
update()
-
Field Details
-
minZ
protected float minZ -
maxZ
protected float maxZ -
projection
-
transformation
-
$TYPE
-
minZ$FIELD
-
maxZ$FIELD
-
projection$FIELD
-
transformation$FIELD
-
sop
-
-
Constructor Details
-
Camera
public Camera() -
Camera
-
-
Method Details
-
getManageableType
- Specified by:
getManageableType
in interfaceManageable
-
getProjection
-
setProjection
-
getTransformation
-
setTransformation
-
createPerspective
-
createParallel
-
createTopView
-
createBottomView
-
createLeftView
-
createRightView
-
createFrontView
-
createBackView
-
getProvider
- Specified by:
getProvider
in interfaceShareable
-
appendReferencesTo
- Specified by:
appendReferencesTo
in interfaceShareable
-
fieldModified
- Specified by:
fieldModified
in interfaceManageable
-
getStamp
public int getStamp()Description copied from interface:Manageable
Returns a stamp for this object. Each modification to this object increments the stamp. The initial stamp is non-negative.- Specified by:
getStamp
in interfaceManageable
- Returns:
- a stamp
-
update
public void update() -
manageableReadResolve
- Specified by:
manageableReadResolve
in interfaceManageable
-
manageableWriteReplace
- Specified by:
manageableWriteReplace
in interfaceManageable
-
getZNear
public float getZNear()- Specified by:
getZNear
in classCameraBase
-
getZFar
public float getZFar()- Specified by:
getZFar
in classCameraBase
-
setZNear
public void setZNear(float minZ) -
setZFar
public void setZFar(float maxZ) -
getWorldToViewTransformation
Description copied from class:CameraBase
Returns the world-to-view transformation of this camera. It transforms world coordinates to view coordinates (= camera coordinates).- Specified by:
getWorldToViewTransformation
in classCameraBase
- Returns:
- world-to-view transformation
-
getViewToClipTransformation
Computes the transformation from view coordinates (= camera coordinates, not world coordinates!) to clip coordinates.- Parameters:
m
- the transformation is placed in here
-
projectWorld
-
projectView
-
getScaleAt
public float getScaleAt(double x, double y, double z) Description copied from class:CameraBase
Computes an estimate for the scaling factor from 3D world coordinates at(x, y, z)
to 2D coordinates on the camera plane.- Specified by:
getScaleAt
in classCameraBase
- Parameters:
x
- x world coordinatey
- y world coordinatez
- z world coordinate- Returns:
- scaling factor of camera projection at location
-
getScaleAt
public float getScaleAt(float z) Description copied from class:CameraBase
Computes an estimate for the scaling factor from view coordinates around a depth ofz
to 2D coordinates on the camera plane.- Specified by:
getScaleAt
in classCameraBase
- Parameters:
z
- z view coordinate- Returns:
- scaling factor of camera projection at location
-
getRay
Description copied from class:CameraBase
Determines the ray which starts at the camera and goes through the specified point on the image plane of the camera.- Specified by:
getRay
in classCameraBase
- Parameters:
x
- the x-coordinate on the image planey
- the y-coordinate on the image planeorigin
- the origin of the ray, in world coordinatesdirection
- the direction of the ray, in world coordinates
-
computeExitance
Description copied from interface:Emitter
Evaluates the exitance function for given input. The computed value is the spectrum of the radiant exitance (emitted power per area) L0j(x, ν) at the pointenv.point
in case of light sources, or the corresponding function W0j(x, ν) in case of sensors.The returned value is the value of the probability density px that would be calculated by
Emitter.generateRandomOrigins(de.grogra.ray.physics.Environment, de.grogra.ray.util.RayList, java.util.Random)
ifenv.point
happened to be one of the randomly generated origins.- Specified by:
computeExitance
in interfaceEmitter
- Parameters:
env
- the environment for scatteringexitance
- the exitance values will be placed in here- Returns:
- the value of the probability density for the ray origin
-
generateRandomOrigins
Description copied from interface:Emitter
Pseudorandomly generates, for the given input, a set of origins for this emitter. They are generated such that they can be used for Monte Carlo-based photon tracing algorithms in the following way.At first, we consider the case where the emitter is in fact a light source. Let L(x, ω, ν) be the emitted spectral radiance for the frequency ν at the light's surface point x in direction ω. The radiant exitance (emitted spectral power per area) at x is defined as
L0(x, ν) = ∫ cos θ L(x, ω, ν) dω where θ is the angle between the surface normal and ω. Now the directional distribution of the emitted radiance at x can be described by the densityL1(x, ω, ν) = L(x, ω, ν) / L0(x, ν) so that the radiance is split intoL(x, ω, ν) = L0(x, ν) L1(x, ω, ν) Let oi and si denote the origins and spectra of the N generated rays (N =rays.size
). Then for a function f(x, ν) which is to be integrated over the light surface, the sum1 / N ∑i si(ν) f(oi, ν) is an unbiased estimate for the integral∫ L0(x, ν) f(x, ν) dA The integral ranges over the whole surface A of the light source. As a consequence, the spectrum of a ray is to be considered as the ray's radiant spectral power.Now if the emitter is a sensor, let W(x, ω, ν) be the emitted spectral importance for frequency ν at the sensors's surface point x in direction ω. The quantities W0(x, ν) and W1(x, ω, ν) are defined similarly to the case of light sources:
W0(x, ν) = ∫ cos θ W(x, ω, ν) dω The formulas for light sources are valid for sensors if the L-quantites are replaced by the corresponding W-quantities.
W(x, ω, ν) = W0(x) W1(x, ω, ν)Let px be the probability density used for the ray origin, then the field
originDensity
is set to px(oi) for each ray. For emitters which are concentrated at a single point (e.g., point lights) px is not a regular function, the valueoriginDensity
will be set to a multiple ofScattering.DELTA_FACTOR
.The ray properties which are not mentioned in the given formulas are neither used nor modified. These are the direction and its density.
- Specified by:
generateRandomOrigins
in interfaceEmitter
- Parameters:
env
- the environmentout
- the outgoing rays to be generatedrnd
- pseudorandom generator
-
getFlags
public int getFlags()- Specified by:
getFlags
in interfaceScattering
-
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 interfaceScattering
- 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 rnd) 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
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 ofScattering.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 interfaceScattering
- 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?rnd
- pseudorandom generator- See Also:
-
If
-
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 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
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 interfaceScattering
- 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
-
completeRay
- Specified by:
completeRay
in interfaceEmitter
-
getUVForVertex
- Specified by:
getUVForVertex
in interfaceSensor
-