tutorials:basic-spectral-light-modeling
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:basic-spectral-light-modeling [2025/06/04 08:43] – MH | tutorials:basic-spectral-light-modeling [2025/06/04 14:08] (current) – MH | ||
---|---|---|---|
Line 86: | Line 86: | ||
<code java> | <code java> | ||
+ | import de.grogra.gpuflux.scene.experiment.Measurement; | ||
+ | |||
Measurement spectrum = LM.getAbsorbedPowerMeasurement(x); | Measurement spectrum = LM.getAbsorbedPowerMeasurement(x); | ||
float absorbedPower = spectrum.integrate(); | float absorbedPower = spectrum.integrate(); | ||
Line 137: | Line 139: | ||
<code java> | <code java> | ||
+ | import de.grogra.gpuflux.imp3d.spectral.SpectralCurve; | ||
+ | import de.grogra.gpuflux.imp3d.spectral.IrregularSpectralCurve; | ||
+ | |||
const float[] WAVELENGTHS = {380, 410, 420, 450, 465, 480, 490, 600, 620, 630, 640, 655, 660, 670, 690, 700, 720}; | const float[] WAVELENGTHS = {380, 410, 420, 450, 465, 480, 490, 600, 620, 630, 640, 655, 660, 670, 690, 700, 720}; | ||
- | const AMPLITUDES = {0.05, 0.1, 0.4, 0.63, 0.25, 0.15, 0.05, 0.01, 0.1, 0.3, 0.4, 0.85, 0.75, 0.95, 0.6, 0.25, 0.1}; | + | const float[] |
- | const ChannelSPD | + | const SpectralCurve |
</ | </ | ||
Line 155: | Line 160: | ||
{{ : | {{ : | ||
- | |||
Since these spectral curve classes all implement the same // | Since these spectral curve classes all implement the same // | ||
<code java> | <code java> | ||
+ | import de.grogra.gpuflux.imp3d.spectral.SpectralCurve; | ||
+ | import de.grogra.gpuflux.imp3d.spectral.IrregularSpectralCurve; | ||
+ | import de.grogra.gpuflux.imp3d.shading.ChannelSPD; | ||
+ | |||
//user defined spectral curve, applied to an IrregularSpectralCurve | //user defined spectral curve, applied to an IrregularSpectralCurve | ||
float[] WAVELENGTHS = {380, 485, 490, 610, 615, 720}; | float[] WAVELENGTHS = {380, 485, 490, 610, 615, 720}; | ||
Line 177: | Line 185: | ||
ChannelSPD REG_SPD = new ChannelSPD(new CIENormSpectralCurve(Attributes.CIE_NORM_D55)); | ChannelSPD REG_SPD = new ChannelSPD(new CIENormSpectralCurve(Attributes.CIE_NORM_D55)); | ||
- | // a black body spectral curve with a temperature of 5000K | + | //a black body spectral curve with a temperature of 5000K |
ChannelSPD REG_SPD = new ChannelSPD(new BlackbodySpectralCurve(5000)); | ChannelSPD REG_SPD = new ChannelSPD(new BlackbodySpectralCurve(5000)); | ||
</ | </ | ||
Line 187: | Line 195: | ||
<code java> | <code java> | ||
import de.grogra.gpuflux.imp3d.objects.SpectralLight; | import de.grogra.gpuflux.imp3d.objects.SpectralLight; | ||
- | import de.grogra.gpuflux.imp3d.shading.ChannelSPD; | + | import de.grogra.gpuflux.imp3d.spectral.SpectralCurve; |
import de.grogra.gpuflux.imp3d.spectral.IrregularSpectralCurve; | import de.grogra.gpuflux.imp3d.spectral.IrregularSpectralCurve; | ||
Line 193: | Line 201: | ||
const float[] WAVELENGTHS = {380, 485, 490, 610, 615, 720}; | const float[] WAVELENGTHS = {380, 485, 490, 610, 615, 720}; | ||
const float[] AMPLITUDES = {0, | const float[] AMPLITUDES = {0, | ||
+ | const SpectralCurve TEST_SPD = new IrregularSpectralCurve(WAVELENGTHS, | ||
+ | |||
module MyLamp extends LightNode() { | module MyLamp extends LightNode() { | ||
{ | { | ||
setLight( | setLight( | ||
- | new SpectralLight(new IrregularSpectralCurve(WAVELENGTHS, | + | new SpectralLight(TEST_SPD).( |
setPower(100), | setPower(100), | ||
setLight(new PointLight()) | setLight(new PointLight()) | ||
Line 210: | Line 220: | ||
</ | </ | ||
+ | Note: // | ||
Within the // | Within the // | ||
Line 230: | Line 241: | ||
{ | { | ||
setLight( | setLight( | ||
- | new SpectralLight( | + | new SpectralLight( new CIENormSpectralCurve(Attributes.CIE_NORM_D65) ).( |
- | | + | |
- | | + | |
setPower(100), | setPower(100), | ||
setLight(new PointLight()) | setLight(new PointLight()) | ||
Line 244: | Line 253: | ||
Using the SPD, we define the light ' | Using the SPD, we define the light ' | ||
- | In the above example, a PointLight is used as light source to emit the wanted spectrum. In the next step, we will continue and show how to define and use user-defined light emission pattern. The keyword here is **PLD** = **P**hysical **L**ight **D**istribution. | + | In the above example, a //PointLight// is used as light source to emit the wanted spectrum. In the next step, we will continue and show how to define and use user-defined light emission pattern. The keyword here is **PLD** = **P**hysical **L**ight **D**istribution. |
This is especially helpful or necessary for any definition of artificial light sources, such as those found in greenhouses, | This is especially helpful or necessary for any definition of artificial light sources, such as those found in greenhouses, | ||
Line 322: | Line 331: | ||
<code java> | <code java> | ||
- | float[] WAVELENGTHS = {380, 485, 490, 610, 615, 720}; | + | import de.grogra.gpuflux.imp3d.shading.ChannelSPD; |
- | float[] AMPLITUDES = {0, | + | import de.grogra.gpuflux.imp3d.spectral.IrregularSpectralCurve; |
- | ChannelSPD GREEN_SPD = new ChannelSPD(new IrregularSpectralCurve(WAVELENGTHS, | + | import de.grogra.gpuflux.imp3d.spectral.RGBSpectralCurve; |
+ | import de.grogra.gpuflux.imp3d.spectral.ConstantSpectralCurve; | ||
- | ChannelSPD RED_SPD | + | static float[] WAVELENGTHS |
- | ChannelSPD | + | static float[] AMPLITUDES = {0,0,1,1,0,0}; |
+ | static | ||
- | // shader definition as global variable | + | static ChannelSPD RED_SPD = new ChannelSPD(new RGBSpectralCurve(0.8, |
+ | static ChannelSPD CONST_SPD = new ChannelSPD(new ConstantSpectralCurve(0.25)); | ||
+ | |||
+ | //shader definition as global variable | ||
Phong myShader0 = new Phong(); | Phong myShader0 = new Phong(); | ||
static { | static { | ||
Line 336: | Line 350: | ||
} | } | ||
- | //as a module that is interpreted as Box | + | //and use of the global shader within |
module TestBox ==> { | module TestBox ==> { | ||
} Box(0.001, | } Box(0.001, | ||
- | + | //or define the shader | |
- | //within a module that extends a Box | + | |
module TestBox extends Box(0.001, | module TestBox extends Box(0.001, | ||
| | ||
Line 365: | Line 378: | ||
- | ==== Sensor nodes ==== | ||
- | |||
- | To monitor light distributions with a scene without interfering, | ||
- | |||
- | Note: The size of the sensor node directly correlates with the probability of got hit by a light ray. For a very small sphere the probability to got hit by a light ray is relatively low, so the number of light rays simulated by the light model needs to be much larger to get repayable results. Therefore, better not to use very small sensor nodes. | ||
- | |||
- | Note: The colour of the sensor node determines which wavelengths should be observed. The default value is white, what stands for monitor all colours. If, for instance, the sensor colour is set to red, only red spectra will be sensed. | ||
- | |||
- | Note: The output of a sensor node is normalized to absorbed radiance per square meter, independent of the actual size of the sensor. | ||
- | |||
- | Note: Sensor nodes can be enabled and disabled for the light model using the LM.setEnableSensors(true/ | ||
- | |||
- | <code java> | ||
- | // create a 5cm, white sensor node | ||
- | Axiom ==> SensorNode().(setRadius(0.05), | ||
- | |||
- | //check what the sensor node has sensed | ||
- | x: | ||
- | Measurement spectrum = lm.getSensedIrradianceMeasurement(x); | ||
- | float absorbedPower = spectrum.integrate(); | ||
- | ... | ||
- | } | ||
- | </ | ||
Line 413: | Line 403: | ||
</ | </ | ||
+ | GroIMP supports the inport of ' | ||
==== Example ==== | ==== Example ==== |
tutorials/basic-spectral-light-modeling.1749019429.txt.gz · Last modified: 2025/06/04 08:43 by MH