tutorials:light-modeling-first-steps
Differences
This shows you the differences between two versions of the page.
tutorials:light-modeling-first-steps [2025/01/08 21:58] – created MH | tutorials:light-modeling-first-steps [2025/01/22 16:04] (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 = GPU_LM.getAbsorbedPower(x); | ||
+ | ] | ||
+ | print(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | 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