tutorials:light-modeling-first-steps
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorials:light-modeling-first-steps [2025/01/08 21:58] – created MH | tutorials:light-modeling-first-steps [2025/06/02 20:13] (current) – MH | ||
---|---|---|---|
Line 9: | Line 9: | ||
* GPUFlux, a GPU-based implementation | * GPUFlux, a GPU-based implementation | ||
- | While they are both implementing | + | While they are both integrating |
In the following, we focus on the three channel RGB versions of both the CPU and GPU implementations. | In the following, we focus on the three channel RGB versions of both the CPU and GPU implementations. | ||
+ | |||
+ | To set up a light model basically three steps are needed. | ||
+ | |||
+ | * Definition/ | ||
+ | * Running the light model | ||
+ | * Checking the scene objects for their light absorption | ||
+ | |||
+ | In GroIMP/XL, this can be done as following: | ||
+ | |||
+ | For the Twilight (CPU-based) implementation: | ||
+ | |||
+ | <code java> | ||
+ | import de.grogra.ray.physics.Spectrum; | ||
+ | |||
+ | //constants for the light model: number of rays and maximal recursion depth | ||
+ | const int RAYS = 1000000; | ||
+ | const int DEPTH = 10; | ||
+ | |||
+ | // | ||
+ | protected void init() { | ||
+ | |||
+ | //create the actual 3D scene | ||
+ | [ | ||
+ | Axiom ==> Box(0.1, | ||
+ | LightNode.(setLight(new SpotLight().(setPower(100), | ||
+ | ] | ||
+ | |||
+ | //make sure the changes on the graph are applied... | ||
+ | {derive();} | ||
+ | //so that we directly can continue and work on the graph | ||
+ | |||
+ | |||
+ | // initialize the light model | ||
+ | LightModel CPU_LM = new LightModel(RAYS, | ||
+ | |||
+ | CPU_LM.compute(); | ||
+ | |||
+ | //check the scene objects for their light absorption | ||
+ | Spectrum ms; | ||
+ | [ | ||
+ | x:Box::> { ms = CPU_LM.getAbsorbedPower(x); | ||
+ | ] | ||
+ | print(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Direct after saving the code, the light model will be executed and the following will be printed in the XL Console Window: | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | |||
+ | While in the above example the object is black, what means that all incoming radiation is absorbed (and nothing reflected), the line below will shange the object colour to some orange | ||
+ | |||
+ | <code java> | ||
+ | Axiom ==> Box(0.1, | ||
+ | </ | ||
+ | |||
+ | what means that all of red and 50% of green are reflected while all blue radiation is absorbed as the resulting output confirms. | ||
+ | |||
+ | |||
+ | {{ : | ||
+ | |||
+ | |||
+ | For the GPUFlux (GPU-based) implementation: | ||
+ | |||
+ | <code java> | ||
+ | import de.grogra.gpuflux.tracer.FluxLightModelTracer.MeasureMode; | ||
+ | import de.grogra.gpuflux.scene.experiment.Measurement; | ||
+ | |||
+ | //constants for the light model: number of rays and maximal recursion depth | ||
+ | const int RAYS = 1000000; | ||
+ | const int DEPTH = 10; | ||
+ | |||
+ | // | ||
+ | protected void init() { | ||
+ | |||
+ | //create the actual 3D scene | ||
+ | [ | ||
+ | Axiom ==> Box(0.1, | ||
+ | LightNode.(setLight(new SpotLight().(setPower(100), | ||
+ | ] | ||
+ | |||
+ | //make sure the changes on the graph are applied... | ||
+ | {derive();} | ||
+ | //so that we directly can continue and work on the graph | ||
+ | |||
+ | |||
+ | // initialize the light model | ||
+ | FluxLightModel GPU_LM = new FluxLightModel(RAYS, | ||
+ | GPU_LM.setMeasureMode(MeasureMode.RGB); | ||
+ | |||
+ | GPU_LM.compute(); | ||
+ | |||
+ | //check the scene objects for their light absorption | ||
+ | Measurement ms; | ||
+ | [ | ||
+ | x:Box::> { ms = GPU_LM.getAbsorbedPowerMeasurement(x); | ||
+ | ] | ||
+ | print(" | ||
+ | } | ||
+ | </ | ||
To be continued... | To be continued... |
tutorials/light-modeling-first-steps.1736369915.txt.gz · Last modified: 2025/01/08 21:58 by MH