Skip to content
Snippets Groups Projects
Commit bb52e2d6 authored by Lukas Werner's avatar Lukas Werner
Browse files

Better documentation and added one for visibility function

parent 4599ccfa
Branches
Tags
No related merge requests found
......@@ -171,7 +171,7 @@ int main( int argc, char ** argv )
WALBERLA_LOG_INFO_ON_ROOT("*** RAYTRACER ***");
//! [Raytracer Init]
std::function<ShadingParameters(const BodyID body)> customShadingFunction = [](const BodyID body) {
std::function<ShadingParameters (const BodyID body)> customShadingFunction = [](const BodyID body) {
if (body->getTypeID() == Sphere::getStaticTypeID()) {
return processRankDependentShadingParams(body).makeGlossy();
}
......
......@@ -93,31 +93,48 @@ functions so you do not have to extract all the information yourself and save it
\snippet 02_ConfinedGasExtended.cpp SQL Save
\section tutorial_pe_02_raytracing Image Output
Using a raytracer snapshots of the simulation can be generated each timestep and output as PNG files.
Setting up the Raytracer can be done by reading a config object, as it is done in the tutorial:
Using the pe::raytracing::Raytracer you can generate images of the simulation for each timestep and output them as PNG files.
Setup the raytracer by reading a config object and optionally supply a shading and a visibility function,
as it is done in the second pe tutorial. The shading function will be called during rendering for each body
to apply user defined coloring to bodies, the visibility function to determine if a body should be visible or not.
\snippet 02_ConfinedGasExtended.cpp Raytracer Init
Alternatively it can also be entirely setup in code:
Alternatively it may also be setup entirely in code:
\code
Lighting lighting(Vec3(-12, 12, 12),
Color(1, 1, 1),
Color(1, 1, 1),
Color(real_t(0.4), real_t(0.4), real_t(0.4)));
Raytracer raytracer(forest, storageID, globalBodyStorage, ccdID,
640, 480,
real_t(49.13), 2,
Vec3(-25, 10, 10), Vec3(-5, 10, 10), Vec3(0, 0, 1),
lighting,
Color(real_t(0.1), real_t(0.1), real_t(0.1)),
radius,
customShadingFunction);
640, 480,
real_t(49.13), 2,
Vec3(-25, 10, 10), Vec3(-5, 10, 10), Vec3(0, 0, 1),
lighting,
Color(real_t(0.1), real_t(0.1), real_t(0.1)),
radius,
customShadingFunction;
\endcode
To apply custom coloring to bodies, you can supply a user defined function which returns a ShadingParameters struct for
a given BodyID. For an overview over predefined shading functions, visit the file ShadingFunctions.h.
After the configuration is done, images can be generated each timestep by calling Raytracer::generateImage<BodyTuple>()
which will be output to the specified directory.
\snippet 02_ConfinedGasExtended.cpp Image Output
For further information see the documentation for the classes Raytracer and Lighting, the ShadingParameters class and
ShadingFunctions.h file may also be useful.
To hide certain bodies during rendering, the visibility function will be called with a BodyID as its sole argument
and should return true if the object is supposed to be visible, false if not:
\code
// [...]
std::function<bool (const BodyID body)> customVisibilityFunction = [](const BodyID body) {
if (body->getTypeID() == Plane::getStaticTypeID()) {
// hide all planes
return false;
}
return true;
};
Raytracer raytracer(forest, storageID, globalBodyStorage, ccdID,
cfg->getBlock("Raytracing"),
customShadingFunction,
customVisibilityFunction);
\endcode
For an overview over predefined shading functions, visit the file ShadingFunctions.h.
For further information see the documentation for the classes pe::raytracing::Raytracer, pe::raytracing::Lighting and
pe::raytracing::Color, the pe::raytracing::ShadingParameters struct and ShadingFunctions.h file may also be useful.
*/
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment