32 return [seed = 1337]()
mutable {
return seed++; };
47 if (!hdriPath.empty()) {
63 for (
Size iteration = 0; iteration < fixed.iterationLimit &&
shouldContinue; ++iteration) {
65 this->refine(params, iteration, fb);
67 const bool isFinal = (iteration == fixed.iterationLimit - 1);
71 output.
update(std::move(bitmap), {}, isFinal);
84 return sqrt(2.f * x) - 1.f;
86 return 1.f -
sqrt(1.f - 2.f * (x - 0.5f));
92 const float x = 0.5f +
sampleTent(
float(rng())) * halfWidth;
93 const float y = 0.5f +
sampleTent(
float(rng())) * halfWidth;
103 const Size level = 1 <<
max(
int(fixed.subsampling) -
int(iteration), 0);
106 actSize.
x = size.
x / level +
sgn(size.
x % level);
107 actSize.
y = size.
y / level +
sgn(size.
y % level);
110 const bool first = (iteration == 0);
114 Size(bitmap.size().y),
116 [
this, &bitmap, ¶ms, level, first](
Size y, ThreadData& data) {
117 if (!shouldContinue && !first) {
120 for (
Size x = 0; x <
Size(bitmap.size().x); ++x) {
133 if (!shouldContinue && !first) {
140 for (
Size y = 0; y <
Size(full.size().y); ++y) {
141 for (
Size x = 0; x <
Size(full.size().x); ++x) {
142 full[
Pixel(x, y)] = bitmap[
Pixel(x / level, y / level)];
150 if (fixed.enviro.hdri.empty()) {
151 return fixed.enviro.color;
157 return fixed.enviro.hdri.eval(uvw);
Defines projection transforming 3D particles onto 2D screen.
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
INLINE float sampleTent(const float x)
INLINE Coords sampleTent2d(const Size level, const float halfWidth, UniformRng &rng)
constexpr INLINE T max(const T &f1, const T &f2)
INLINE T sqrt(const T f)
Return a squared root of a value.
INLINE int sgn(const T val)
constexpr Float PI
Mathematical constants.
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
Tool to measure time spent in functions and profile the code.
#define MEASURE_SCOPE(name)
INLINE void parallelFor(IScheduler &scheduler, const Size from, const Size to, TFunctor &&functor)
Executes a functor concurrently from all available threads.
INLINE SphericalCoords cartensianToSpherical(const Vector &v)
Converts vector in cartesian coordinates to spherical coordinates.
BasicVector< Float > Vector
const Bitmap< Rgba > & getBitmap() const
void accumulate(const Bitmap< Rgba > &pass)
void override(Bitmap< Rgba > &&pass)
INLINE TValue get(const GuiSettingsId id) const
virtual Pixel getSize() const =0
Returns the current resolution of the camera.
virtual Optional< CameraRay > unproject(const Coords &coords) const =0
Returns a ray in particle coordinates corresponding to given coordinates in the image plane.
virtual void render(const RenderParams ¶ms, Statistics &stats, IRenderOutput &output) const final
Draws particles into the bitmap, given the data provided in initialize.
virtual Rgba shade(const RenderParams ¶ms, const CameraRay &ray, ThreadData &data) const =0
Rgba getEnviroColor(const CameraRay &ray) const
ThreadLocal< ThreadData > threadData
SharedPtr< IScheduler > scheduler
IRaytracer(SharedPtr< IScheduler > scheduler, const GuiSettings &gui)
std::atomic_bool shouldContinue
virtual void update(const Bitmap< Rgba > &bitmap, Array< Label > &&labels, const bool isFinal)=0
May be called once after render finishes or multiple times for progressive renderers.
Wrapper of type value of which may or may not be present.
INLINE Type & value()
Returns the reference to the stored value.
Object representing a path on a filesystem.
Non-owning wrapper of pointer.
Object holding various statistics about current run.
@ COLORMAP_LOGARITHMIC_FACTOR
@ RAYTRACE_ITERATION_LIMIT
@ PARTICLE_RADIUS
Displayed radius of particle in units of smoothing length.
@ SURFACE_LEVEL
Value of iso-surface being constructed; lower value means larget bodies.
@ SURFACE_SUN_INTENSITY
Intentity of the sun.
@ SURFACE_AMBIENT
Ambient color for surface renderer.
AutoPtr< IColorMap > getColorMap(const GuiSettings &settings)
Ray given by origin and target point.
Parameters of the rendered image.
struct RenderParams::@36 volume
Parameters of volumetric renderer.
Rgba background
Background color of the rendered image.
struct RenderParams::@33 particles
Parameters of the particle renderer.
AutoPtr< ICamera > camera
Camera used for rendering.
bool showKey
If true, a color palette and a distance scale is included in the image.
struct RenderParams::@35 surface
Parameters of rendered surface.
struct RenderParams::@37 contours
void initialize(const GuiSettings &gui)
Sets up parameters using values stored in settings.
float compressionFactor
Compression factor of the logarithmic tonemapper.
float filterWidth
Width of the image reconstruction filter.