|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.grogra.persistence.ShareableBase de.grogra.rgg.LightModelBase de.grogra.rgg.FluxLightModel
public class FluxLightModel
The FluxLightModel class provides a spectral light model, used to compute the spectral light distribution in the current graph.
The light model is created with one of its constructors.
FluxLightModel lm = new FluxLightModel();
The light model computes the light distribution by simulating many photons through the scene.
The total emitted light power is distributed over all photons.
The user can specify the maximum number of simulated photons using setRayCount(int)
.
The user can also specify a maximum variance for some given power quantum using setTargetVariance(double, double)
.
The simulation will compute the appropriate sample count to achieve the target variance.
Note that this sample count is an overestimation. The light model will select the minimum of both methods as the actual sample count.
Each photon bounces through the scene and any absorbed power is recorded with the objects the photon visits.
Besides absorbed power, the simulation also computes sensed irradiance for sensors.
Simulating many sensors can be quite costly and can be disabled using setEnableSensors(boolean)
.
The user may specify a maximum path depth to limit the duration of the simulation using setDepth(int)
.
When a simulated photon is almost completely absorbed, further simulation adds little value.
Therefore, the user can specify a cutoff power using setCutoffPower(double)
;
As soon as the photon power drops below this threshold, the photon is killed off.
The light model supports three different modes of measuring spectral power.
Either it computes regular RGB, a full discretized spectrum or a few weighted integrals over the spectrum.
The measure mode is set using #lm.setMeasureMode
.
The following code sets the measure mode to RGB.
No further settings are required for this mode. RGB is the default measure mode.
The computed measurements are 3 dimensional vectors with channels r,g and b.
lm.setMeasureMode(RGB);
The following code sets the measure mode to full discretized spectral measurements.
The spectral domain [l,h] is divided into n buckets of equal sized intervals [l + i * (h-l) / n, l + (i + 1) * (h-l) / n].
The simulation computes the absorbed power in each bucket for each measurement.
The dimension of the computed measurements equals the number of buckets.
The user has to specify the spectral domain using setSpectralDomain(int, int)
and the discretization resolution using setSpectralBuckets(int)
.
The user may also supply a continuous spectral importance curve. The curve indicates importance and is used for importance sampling over the continuous spectral domain.
Regions of high importance will receive more samples and get a more accurate estimate.
The spectral importance curve applies to both the discretized measurement mode and the weighted integral mode discussed next. The curve is defined continuously over the whole spectral domain, even though in discrete spectral mode the measured spectra themselves are not continuous.
In the following example, the spectral importance curve shows a peak around 500 nm, resulting in improved measuring accuracy around this wavelength.
Note that the importance curve does not alter the expected outcome of the simulation, only the distribution of variance over the spectral domain.
lm.setMeasureMode(FULL_SPECTRUM);
lm.setSpectralDomain(350,720);
lm.setSpectralBuckets(5);
SpectralCurve importanceCurve = new IrregularSpectralCurve( {350,400,450,500,550,720} , {2,2,5,8,4,2} );
lm.setSpectralImportanceCurve( importanceCurve );
The following code sets the measurement mode to weighted integration.
The simulation computes weighted integrals over the absorbed power for each measurement.
The user has to specify the spectral domain using setSpectralDomain(int, int)
and the weight functions using setSpectralWeightCurves(de.grogra.imp3d.spectral.SpectralCurve[])
.
The user may again specify a spectral importance function.
Note however that in weighted integration mode the light model already uses the weight functions for spectral importance sampling.
lm.setMeasureMode(INTEGRATED_SPECTRUM);
lm.setSpectralDomain(350,720);
SpectralCurves [] weightCurve = {
new IrregularSpectralCurve( {350 , 500 , 510 , 520 , 720} , {0,0,1,0,0} ),
new IrregularSpectralCurve( {350 , 600 , 610 , 620 , 720} , {0,0,1,0,0} )
};
lm.setSpectralWeightCurves( weightCurve );
The simulation is executed using compute()
. By default, first the scene is built after which the light distribution is computed.
lm.compute();
Rebuilding a large scene can be costly. If the user wishes to simulate the same scene multiple times while only modifying the light sources, the user can instruct the simulation to skip the scene build.
// build the scene and compute the distribution
lm.compute(true,true);
// ... modify light sources here
// compute new distribution without rebuilding the scene.
lm.compute(true,false);
For RGB mode simulations, the simulation results can be obtained for each object trough LightModelBase.getAbsorbedPower3d(de.grogra.graph.impl.Node)
and LightModelBase.getSensedIrradiance3d(de.grogra.graph.impl.Node)
.
The user can also get a handle to the corresponding Experiment objects using getAbsorbedPower(de.grogra.graph.impl.Node)
and getSensedIrradiance(de.grogra.graph.impl.Node)
, which contains a mapping from objects to measurements.
Multiple experiment objects can be aggregated into one experiment. The following code computes the total absorbed power over the course of one day.
All static light sources are simulated only once while the contribution of the sun between 4:00 and 22:00 is integrated using the midpoint rule with time steps of 1 hour.
The simulations are aggregated into a single experiment, containing the measured data for one whole day.
// ... enable all static lights
// ... disable the sun
// perform simulation
lm.compute(true,true);
Experiment exp = lm.getAbsorbedPower();
exp.mul( 24 );
// ... disable all static lights
// ... enable the sun
for( int time = 4 ; time < 22 ; time++ )
{
// ... move the sun to its position at [time] + 30 minutes.
// perform simulation
lm.compute(true,false);
// aggregate experiments
Experiment sun_exp = lm.getAbsorbedPower();
exp.aggregate( sun_exp, 1 );
}
// ... use the final aggregates experiment data in exp
Nested Class Summary | |
---|---|
static class |
FluxLightModel.Type
|
Field Summary | |
---|---|
static FluxLightModel.Type |
$TYPE
|
static SCOType.Field |
processor$FIELD
|
Constructor Summary | |
---|---|
FluxLightModel()
Creates a default light model with 30.000 rays per computation and a ray depth of 10. |
|
FluxLightModel(int sampleCount,
int depth)
Creates a light model |
|
FluxLightModel(int sampleCount,
int depth,
double cutoffPower)
Creates a light model |
|
FluxLightModel(int sampleCount,
int depth,
double cutoffPower,
boolean enableSensors)
Creates a light model |
Method Summary | |
---|---|
void |
build()
Rebuild the scene |
void |
compute()
Compute the light distribution |
void |
compute(boolean forceCompute)
Compute the light distribution |
void |
compute(boolean forceCompute,
boolean forceBuild)
(Re-)computes the light distribution in the current graph. |
void |
compute(Spectrum spectrumFactory)
(Re-)computes the light distribution in the current graph. |
void |
compute(Spectrum spectrumFactory,
boolean force)
(Re-)computes the light distribution in the current graph. |
Experiment |
getAbsorbedPower()
Returns the experiment data on absorbed power, computed during the last call to compute() |
Spectrum |
getAbsorbedPower(Node node)
Returns the radiant power in Watts which is absorbed by the surface of the volume of the given node . |
Measurement |
getAbsorbedPowerMeasurement(Node node)
Returns the power absorbed by a node during the last call to compute() |
double |
getCutoffPower()
|
int |
getDepth()
|
ManageableType |
getManageableType()
|
int |
getMaxLambda()
|
FluxLightModelTracer.MeasureMode |
getMeasureMode()
|
int |
getMinLambda()
|
int |
getRayCount()
|
Experiment |
getSensedIrradiance()
Returns the experiment data on sensed irradiance, computed during the last call to compute() |
Spectrum |
getSensedIrradiance(Node node)
Returns the irradiance in Watts per square meter which is sensed by the sensor attached to the volume of the given node . |
Measurement |
getSensedIrradianceMeasurement(Node node)
Returns the irradiance sensed by a node during the last call to compute() |
int |
getSpectralBuckets()
|
SpectralCurve |
getSpectralImportanceCurve()
|
SpectralCurve[] |
getSpectralWeightCurve()
|
boolean |
isSensorsEnabled()
|
void |
setCutoffPower(double minPower)
Sets the maximum neglectable power quantum |
void |
setDepth(int depth)
Sets the maximum ray depth per sample |
void |
setDispersion(boolean dispersion)
Enables dispersion |
void |
setEnableSensors(boolean enableSensors)
Enables the simulation of sensor |
void |
setFlatness(float flatness)
Sets the tessellation flatness for polygonizable objects |
void |
setLayerVisible(int layer,
boolean visible)
sets the visibility of a layer |
void |
setMeasureMode(FluxLightModelTracer.MeasureMode measureMode)
Sets the current measurement mode. |
void |
setMeasureObjectFilter(ObjectFilter measureObjectFilter)
Sets the object filter for filtering measurable objects. |
void |
setRayCount(int sampleCount)
Sets the maximum sample count per simulation |
void |
setSpectralBuckets(int spectralBuckets)
Sets the spectrum discretization resolution in buckets. |
void |
setSpectralDomain(int minLambda,
int maxLambda)
Sets the simulated spectral domain. |
void |
setSpectralImportanceCurve(SpectralCurve importanceCurve)
Sets the spectral importance function, used for spectral importance sampling. |
void |
setSpectralWeightCurves(SpectralCurve[] weightCurves)
Sets the spectral weight functions |
void |
setTargetVariance(double minPower,
double targetVariance)
Sets the required maximum target variance for some minimum measurable power quantum. |
Methods inherited from class de.grogra.rgg.LightModelBase |
---|
getAbsorbedPower3d, getRadiantPower3dFor, getRadiantPowerFor, getSensedIrradiance3d |
Methods inherited from class de.grogra.persistence.ShareableBase |
---|
addReference, appendReferencesTo, fieldModified, getProvider, getStamp, initProvider, manageableReadResolve, manageableWriteReplace, removeReference |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final FluxLightModel.Type $TYPE
public static final SCOType.Field processor$FIELD
Constructor Detail |
---|
public FluxLightModel()
public FluxLightModel(int sampleCount, int depth)
rayCount
- the number of samples per computationdepth
- the maximum ray depthpublic FluxLightModel(int sampleCount, int depth, double cutoffPower)
rayCount
- the number of samples per computationdepth
- the maximum ray depthcutoffPower
- the maximum neglectable power quantumpublic FluxLightModel(int sampleCount, int depth, double cutoffPower, boolean enableSensors)
rayCount
- the number of samples per computationdepth
- the maximum ray depthcutoffPower
- the maximum neglectable power quantumenableSensors
- sensors are simulated if trueMethod Detail |
---|
public void build()
public void compute()
compute
in class LightModelBase
public void compute(boolean forceCompute)
compute
in class LightModelBase
forceCompute
- if true forces recomputation of the light distributionpublic void compute(boolean forceCompute, boolean forceBuild)
forceCompute
- if true forces recomputation of the light distributionforceBuild
- if true forces rebuilding of the scenepublic void compute(Spectrum spectrumFactory)
compute
in class LightModelBase
spectrumFactory
- factrory for spectrum objects, not used in Flux light modelpublic void compute(Spectrum spectrumFactory, boolean force)
compute
in class LightModelBase
spectrumFactory
- factrory for spectrum objects, not used in Flux light modelforce
- if true forces recomputation of the light distributionpublic Experiment getAbsorbedPower()
compute()
public Spectrum getAbsorbedPower(Node node)
LightModelBase
node
. If the node
does not define a volume, the zero spectrum is returned.
getAbsorbedPower
in class LightModelBase
node
- a node of the graph
public Measurement getAbsorbedPowerMeasurement(Node node)
compute()
node
- node for which the absorbed power is returned
public double getCutoffPower()
public int getDepth()
public ManageableType getManageableType()
public int getMaxLambda()
public FluxLightModelTracer.MeasureMode getMeasureMode()
public int getMinLambda()
public int getRayCount()
public Experiment getSensedIrradiance()
compute()
public Spectrum getSensedIrradiance(Node node)
LightModelBase
node
.
If the node
does not define a volume with a sensor,
the zero spectrum is returned.
getSensedIrradiance
in class LightModelBase
node
- a node of the graph
public Measurement getSensedIrradianceMeasurement(Node node)
compute()
node
- node for which the absorbed power is returned
public int getSpectralBuckets()
public SpectralCurve getSpectralImportanceCurve()
public SpectralCurve[] getSpectralWeightCurve()
public boolean isSensorsEnabled()
public void setCutoffPower(double minPower)
minPower
- maximum neglectable power quantumpublic void setDepth(int depth)
depth
- maximum ray depth per samplepublic void setDispersion(boolean dispersion)
dispersion
- true enables dispersionpublic void setEnableSensors(boolean enableSensors)
enableSensors
- true enables the sensorspublic void setFlatness(float flatness)
flatness
- positive flatness parameter with 0 being infinite tessellation.public void setLayerVisible(int layer, boolean visible)
LightModelBase
setLayerVisible
in class LightModelBase
public void setMeasureMode(FluxLightModelTracer.MeasureMode measureMode)
setSpectralDomain(int, int)
. The spectral resolution is specified using
INTEGRATED_SPECTRUM: Measure weighted spectral integrals, specified using setSpectralWeightCurves(de.grogra.imp3d.spectral.SpectralCurve[])
RGB: Measure RGB values
Spectral dispersion only applies to FULL_SPECTRUM and INTEGRATED_SPECTRUM and may be enabled using setDispersion(boolean)
measureMode
- measurement modepublic void setMeasureObjectFilter(ObjectFilter measureObjectFilter)
measureObjectFilter
- Object filterpublic void setRayCount(int sampleCount)
sampleCount
- maximum sample countpublic void setSpectralBuckets(int spectralBuckets)
spectralBuckets
- bucket resolutionpublic void setSpectralDomain(int minLambda, int maxLambda)
minLambda
- lower boundary wavelengthmaxLambda
- upper boundary wavelengthpublic void setSpectralImportanceCurve(SpectralCurve importanceCurve)
importanceCurve
- spectral importance functionspublic void setSpectralWeightCurves(SpectralCurve[] weightCurves)
weightCurves
- array of spectral weight functionspublic void setTargetVariance(double minPower, double targetVariance)
compute()
, the simulation computes the minimum number of samples required
to achieve the maximum target variance #targetVariance on any measurement of at least #minPower for the given scene.
minPower
- minimal measurable power quantumtargetVariance
- maximum target variance
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |