02_user_tutorials:04_light_modelling:light-modeling-first-steps
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| 02_user_tutorials:04_light_modelling:light-modeling-first-steps [2025/01/24 15:51] – removed - external edit (Unknown date) 127.0.0.1 | 02_user_tutorials:04_light_modelling:light-modeling-first-steps [2025/01/24 15:51] (current) – ↷ Links adapted because of a move operation tim2 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ==== First steps on light modelling ==== | ||
| + | |||
| + | |||
| + | This tutorial we show you the basics on how to do light modelling in GroIMP. For some more theoretical background pleas refer to the [[02_user_tutorials: | ||
| + | |||
| + | GroIMP integrates two two main light model implementations, | ||
| + | |||
| + | * Twilight, a CPU-based implementation | ||
| + | * GPUFlux, a GPU-based implementation | ||
| + | |||
| + | While they are both integrating various renderer and light model 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... | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
