The program raytrace_cl_cpp.exe can be used as a standalone raytracer for point-clouds.
raytrace_cl_cpp.exe configfile cachelistfile ouputfile scenefile anim
Example: raytrace_cl_cpp.exe "C:\Users\Per\Documents\StyrofoamIFS\user.config" "C:\Users\Per\Documents\StyrofoamIFS\cache\_raytrace_cl_parameters.txt" "C:\Users\Per\Documents\StyrofoamIFS\autosave\autosave_test.png" "C:\Users\Per\Documents\StyrofoamIFS\ifs\lo-res.scene" 0
configfile is the path to the xml-file file that StyrofoamIFS automatically creates. It contains the dialog-options. In a normal run, the file is called user.config and is saved directly in the StyrofoamIFS folder.
cachelistfile is the path to file conataining the list of cache-files that should be raytraced. In a normal run, the file is called _raytrace_cl_parameters.txt and is saved in the cache folder.
ouputfile is the path to the png file that will be created. In a normal run, the file is called autosave_todays date.png and is saved in the autosave folder. Png is the only format supported.
scenefile is the path to the scene file that will be used for raytracing. This file is manually edited by you in a normal run. StyrofoamIFS comes with a few examples. In a normal run these are placed in the ifs folder. See documentation of .scene files for more info.
anim is the value of the parameter anim that can be used in the .scene file. This must be a numerical integer value. See documentation of .scene files for more info.
A note of caution.
The configfile and the scenefile are read as parameters and the last parameter with a given name will take precedence.
Parameters in the scenfile take precedence over parameters in the configfile.
There are exceptions to this, some parameters are treated as arrays (eg. lightsources).
The configfile is a xml-file and will be created the first time you start StyrofoamIFS if not present already. It contains the options selected in the StyrofoamIFS dialog. The parameters marked in reddish bold is used by the raytracer.
cl_iter is the number of points in the point-cloud that will be considered during each call to opencl/cuda. Set to 0 to consider all points in the cache-file during each call. This was an attempt to not get Windows to reset the graphics-drivers when it hasn't responded in time (2 seconds by default). It turns out that even if I set this value quite low, during a long run, something not related to this program will happen and get included in those 2 seconds and still cause a reset and subsequent crash.
cuda Set to 0 to use opencl, 1 to use cuda.
opencl_platform is the platform set in the dialog. Only used for OpenCL.
opencl_device is the device set in the dialog. Only used for OpenCL.
pic_width is the width of the output image set from the dialog.
pic_height is the height of the output image set from the dialog.
pic_width_offset is the offset of the current subframe, use when rendering large images that needs to be split up. Set to 0 if not using subframes.
pic_height_offset is the offset of the current subframe, use when rendering large images that needs to be split up. Set to 0 if not using subframes.
pic_width_total is the total width of the final image, use when rendering large images that needs to be split up. Set to same value as pic_width if not using subframes.
pic_height_total is the total height of the final image, use when rendering large images that needs to be split up. Set to same value as pic_height if not using subframes.
This is a text-file that contains the list of point-cloud cache files that should be rendered. It is possible to manually edit this file and then use the Retrace-button from the main dialog. This lets you for example copy the result of one run to a separate cache-folder, make a new run, and then add the paths to the previous files here and render both results in the same scene.
The cache-files are binary files normally created by create_ifs_cache_cpp.exe and each file consists of a stand-alone container of a point-cloud.
Each file is divided into five sections. The header is required, the other sections can be of size 0.
The spheres are divided in groups of nearby points contained in bounding spheres.
All spheres must be contained in a corresponding bounding sphere in the bounding_spheres section.
Half-floats are used in the bounding_spehres, spheres and colors sections to minimize memory usage (the cache-files are loaded to graphics memory).
Half-floats is supported inherently in OpenCL and Cuda and I use the implementation in glm to read and write half-floats.
To store bounding sphere radiuses there is a rewritten variant used that rounds the half-float values up so that no spheres contained inside gets missed.
header |
bounding_spheres |
bounding_ref |
spheres |
colors |
struct bank_header {
unsigned int bcount;
unsigned int count;
glm::vec4 bounding_sphere;
glm::vec4 color_reflection;
unsigned int mask;
float sphere_size;
}
enum { REFLECTION = 1, SPHERE_SIZE = 2, COLOR = 4 };
bit 0, REFLECTION: If this bit is set then the colors-section contains reflection-values.x | y | z | radius |
If the SPHERE_SIZE bit is 0 | ||
offset x | offset y | offset z |
If the SPHERE_SIZE bit is 1 | |||
offset x | offset y | offset z | radius |
If the REFLECTION bit is 0 and the COLOR bit is 0 |
The colors section is not used. |
If the REFLECTION bit is 1 and the COLOR bit is 0 |
reflection-value |
If the REFLECTION bit is 0 and the COLOR bit is 1 | ||
red | green | blue |
If the REFLECTION bit is 1 and the COLOR bit is 1 | |||
red | green | blue | reflection-value |