├── .github ├── FUNDING.yml └── workflows │ └── ci.yml ├── profile ├── res ├── logo.png └── preview.jpg ├── automation ├── Makefile └── git-hooks │ └── commit-msg ├── src ├── frontend │ ├── gui │ │ ├── opengl.h │ │ ├── config.h │ │ ├── state.cc │ │ ├── gui.h │ │ ├── action.h │ │ ├── state.h │ │ ├── fsutil.h │ │ ├── background.frag │ │ ├── imgui_extra.h │ │ ├── shader.h │ │ ├── graphics.cc │ │ └── workspace.h │ └── cli │ │ ├── argparse.h │ │ ├── setup.h │ │ └── argdefs.h ├── xtcore │ ├── macro.h │ ├── math │ │ ├── hitrecord.cc │ │ ├── ray.cc │ │ ├── surface.cc │ │ ├── ray.h │ │ ├── surface.h │ │ ├── plane.h │ │ ├── sphere.h │ │ ├── triangle.h │ │ ├── hitrecord.h │ │ └── aabb.h │ ├── status.h │ ├── timestamp.h │ ├── feature.h │ ├── loader.h │ ├── filter │ │ ├── desaturate.cc │ │ └── desaturate.h │ ├── config.h │ ├── sampler.cc │ ├── xtcore.h │ ├── memutil.tml │ ├── timeutil.h │ ├── filter.h │ ├── extrude.h │ ├── profiler.h │ ├── bresenham.h │ ├── emitter.h │ ├── object.h │ ├── sampler_gradient.cc │ ├── matdefs.h │ ├── camera │ │ ├── cubemap.h │ │ ├── erp.h │ │ ├── ods.h │ │ ├── erp.cc │ │ ├── ods.cc │ │ ├── perspective.h │ │ └── cubemap.cc │ ├── aa_sample.cc │ ├── sampler_gradient.h │ ├── sampler_erp.h │ ├── sampler_col.cc │ ├── integrator │ │ ├── stencil │ │ │ ├── integrator.h │ │ │ └── integrator.cc │ │ ├── wireframe │ │ │ ├── integrator.h │ │ │ └── integrator.cc │ │ ├── depth │ │ │ ├── integrator.h │ │ │ └── integrator.cc │ │ ├── embree │ │ │ ├── integrator.h │ │ │ └── integrator.cc │ │ ├── ao │ │ │ ├── integrator.h │ │ │ └── integrator.cc │ │ ├── uv │ │ │ ├── integrator.h │ │ │ └── integrator.cc │ │ ├── normal │ │ │ ├── integrator.h │ │ │ └── integrator.cc │ │ ├── emission │ │ │ ├── integrator.h │ │ │ └── integrator.cc │ │ └── pathtracer │ │ │ └── integrator.h │ ├── midi.h │ ├── sampler_col.h │ ├── sampler.h │ ├── xtcore.cc │ ├── strpool.h │ ├── camera.h │ ├── sampler_erp.cc │ ├── aa.h │ ├── util │ │ └── raygraph.h │ ├── material │ │ ├── emissive.cc │ │ ├── phong.h │ │ ├── lambert.h │ │ ├── emissive.h │ │ ├── dielectric.h │ │ ├── blinnphong.h │ │ ├── dielectric.cc │ │ ├── lambert.cc │ │ └── phong.cc │ ├── sampler_cubemap.h │ ├── extrude.cc │ ├── aa_sample.h │ ├── sampler_tex.h │ ├── bvh.h │ ├── integrator.h │ ├── bresenham.cc │ ├── timeutil.cc │ ├── mesh.h │ ├── profiler.cc │ ├── integrator.cc │ ├── strpool.cc │ ├── sampler_tex.cc │ ├── octree.h │ ├── context.h │ ├── sampler_cubemap.cc │ ├── material.h │ └── midi.cc └── util │ ├── bash │ └── autocomplete │ │ └── xtcli │ └── blender │ └── xtracer_implicit.py ├── util ├── ods2anaglyph.sh └── mkvideo.sh ├── configure ├── lib ├── nmesh │ ├── plane.h │ ├── invnormals.h │ ├── icosahedron.h │ ├── cone.h │ ├── invnormals.cc │ ├── obj.h │ ├── transform.h │ ├── buffer.h │ ├── cone.cc │ └── transform.cc ├── nplatform │ ├── fs.h │ ├── dlloader.h │ ├── timer.h │ ├── dlloader.c │ ├── fs.c │ └── byteorder.c ├── nimg │ ├── desaturate.h │ ├── luminance.h │ ├── solidcol.h │ ├── transform.h │ ├── yuv4mpeg2.h │ ├── sample.h │ ├── diff.h │ ├── luminance.cc │ ├── xor.h │ ├── conversion.h │ ├── checkerboard.h │ ├── desaturate.cc │ ├── genetic.h │ ├── xor.cc │ ├── solidcol.cc │ ├── img.h │ ├── coldef.h │ ├── rasteriser.h │ ├── checkerboard.cc │ ├── buffer.h │ ├── pixel.h │ ├── conversion.c │ ├── ppm.h │ ├── transform.cc │ ├── pixmap.h │ ├── pixmap.cc │ ├── sample.cc │ ├── genetic_algo.cc │ ├── yuv4mpeg2.c │ ├── color.cc │ ├── pixel.inl │ └── diff.cc ├── nmath │ ├── quadratic.h │ ├── types.h │ ├── prime.h │ ├── quadratic.cc │ ├── prng.h │ ├── vector.cc │ ├── matrix.inl │ ├── mutil.h │ └── sample.h └── ncf │ ├── declspec.h │ └── expreval.h ├── scene ├── 0.1-empty.scn ├── 3.5.3.scn ├── 3.5.2.scn ├── 3.5.1.scn ├── 3.2.scn ├── 9.1.scn ├── 3.1.scn ├── 7.2.scn ├── 3.0.scn ├── 7.1.scn ├── 7.5.scn ├── 1.1-reflective_sphere.scn ├── 6.1-stereographic_projection.scn ├── 7.7.scn ├── 1.2-reflective_icosahedron.scn ├── 7.6.scn ├── 1.2-reflective_plane.scn └── 7.9.scn ├── .gitignore ├── ext ├── remotery │ ├── vis │ │ ├── extern │ │ │ └── BrowserLib │ │ │ │ ├── Core │ │ │ │ └── Code │ │ │ │ │ ├── Core.js │ │ │ │ │ ├── LocalStore.js │ │ │ │ │ └── Animation.js │ │ │ │ └── WindowManager │ │ │ │ └── Code │ │ │ │ ├── Label.js │ │ │ │ ├── Container.js │ │ │ │ └── WindowManager.js │ │ └── Code │ │ │ ├── ThreadFrame.js │ │ │ ├── DataViewReader.js │ │ │ ├── PixelTimeRange.js │ │ │ └── TitleWindow.js │ └── lib │ │ └── RemoteryMetal.mm ├── nanosvg │ └── LICENSE.txt ├── cpp-httplib │ └── LICENSE ├── imgui │ └── LICENSE └── tinyobj │ └── LICENSE ├── .travis.yml └── LICENSE /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | #patreon: 4rknova 2 | #ko_fi: nikospapadopoulos 3 | -------------------------------------------------------------------------------- /profile: -------------------------------------------------------------------------------- 1 | valgrind --tool=callgrind ./bin/xtracer_gui 2 | kcachegrind 3 | -------------------------------------------------------------------------------- /res/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4rknova/xtracer/HEAD/res/logo.png -------------------------------------------------------------------------------- /res/preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4rknova/xtracer/HEAD/res/preview.jpg -------------------------------------------------------------------------------- /automation/Makefile: -------------------------------------------------------------------------------- 1 | all: git_hooks 2 | 3 | git_hooks: 4 | mkdir -p ../.git/hooks 5 | chmod +x git-hooks/* 6 | cp git-hooks/* ../.git/hooks/ 7 | -------------------------------------------------------------------------------- /src/frontend/gui/opengl.h: -------------------------------------------------------------------------------- 1 | #ifndef XT_OPENGL_H_INCLUDED 2 | #define XT_OPENGL_H_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | #endif /* XT_OPENGL_H_INCLUDED */ 8 | -------------------------------------------------------------------------------- /src/xtcore/macro.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_MACRO_H_INCLUDED 2 | #define XTCORE_MACRO_H_INCLUDED 3 | 4 | #define UNUSED(expr) {do{(void)(expr);}while(0);} 5 | 6 | #endif /* XTCORE_MACRO_H_INCLUDED */ 7 | -------------------------------------------------------------------------------- /src/xtcore/math/hitrecord.cc: -------------------------------------------------------------------------------- 1 | #include "hitrecord.h" 2 | 3 | namespace xtcore { 4 | 5 | hit_record_t::hit_record_t() 6 | : t(INFINITY) 7 | {} 8 | 9 | } /* namespace xtcore */ 10 | -------------------------------------------------------------------------------- /util/ods2anaglyph.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | convert -crop 100%x50% $1 cropped_%d.png 4 | composite -stereo 0:0 cropped_0.png cropped_1.png anaglyph.png 5 | #compare -metric mae cropped_0.png cropped_1.png test.png 6 | -------------------------------------------------------------------------------- /src/frontend/gui/config.h: -------------------------------------------------------------------------------- 1 | #ifndef XT_CONFIG_H_INCLUDED 2 | #define XT_CONFIG_H_INCLUDED 3 | 4 | #define WINDOW_DEFAULT_WIDTH (1920) 5 | #define WINDOW_DEFAULT_HEIGHT (1080) 6 | 7 | #endif /* XT_CONFIG_H_INCLUDED */ 8 | -------------------------------------------------------------------------------- /src/xtcore/status.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_STATUS_H_INCLUDED 2 | #define XTCORE_STATUS_H_INCLUDED 3 | 4 | typedef enum STATUS 5 | { 6 | STATUS_OK 7 | , STATUS_ERROR 8 | 9 | } Status; 10 | 11 | #endif /* XTCORE_STATUS_H_INCLUDED */ 12 | -------------------------------------------------------------------------------- /src/xtcore/timestamp.h: -------------------------------------------------------------------------------- 1 | #ifndef XT_TIMESTAMP_H_INCLUDED 2 | #define XT_TIMESTAMP_H_INCLUDED 3 | 4 | namespace xtracer { 5 | 6 | typedef float timestamp_t; 7 | 8 | } /* namespace xtracer */ 9 | 10 | #endif /* XT_TIMESTAMP_H_INCLUDED */ 11 | -------------------------------------------------------------------------------- /src/xtcore/feature.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_FEATURE_H_INCLUDED 2 | #define XTCORE_FEATURE_H_INCLUDED 3 | 4 | #define FEATURE_INCLUDED (1) 5 | #define FEATURE_EXCLUDED (0) 6 | #define FEATURE_IS_INCLUDED(X) (X == FEATURE_INCLUDED) 7 | 8 | #endif /* XTCORE_FEATURE_H_INCLUDED */ 9 | -------------------------------------------------------------------------------- /src/xtcore/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_LOADER_H_INCLUDED 2 | #define XTCORE_LOADER_H_INCLUDED 3 | 4 | namespace XTCore { 5 | 6 | load_ncf(Scene *scene, const char* filename); 7 | 8 | } /* namespace XTCore */ 9 | 10 | 11 | #endif /* XTCORE_LOADER_H_INCLUDED */ 12 | -------------------------------------------------------------------------------- /src/xtcore/filter/desaturate.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "desaturate.h" 3 | 4 | namespace xtcore { 5 | namespace filter { 6 | 7 | void Desaturate::render(Pixmap *p) 8 | { 9 | nimg::filter::desaturate(p); 10 | } 11 | 12 | } /* namespace filter */ 13 | } /* namespace xtcore */ 14 | -------------------------------------------------------------------------------- /src/xtcore/config.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_CONFIG_H 2 | #define XTCORE_CONFIG_H 3 | 4 | #include "feature.h" 5 | 6 | /* Optional features */ 7 | #define FEATURE_PROFILER (FEATURE_EXCLUDED) 8 | #define FEATURE_MIDI (FEATURE_EXCLUDED) 9 | #define FEATURE_EMBREE (FEATURE_EXCLUDED) 10 | 11 | #endif /* XTCORE_CONFIG_H */ 12 | -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | DIR_RES="./src/xtcore/res/" 2 | OUT_LICENSE="$DIR_RES/license.h" 3 | mkdir -p $DIR_RES 4 | xxd -i ./LICENSE | sed 's/unsigned char/const char/g' | sed 's/\([0-9a-f]\)$/\0, 0x00/' > $OUT_LICENSE 5 | xxd -i ./res/logo.png ./src/frontend/gui/logo.h 6 | BUILD=Debug 7 | make -C ./automation 8 | cmake -DCMAKE_BUILD_TYPE=$BUILD ./CMakeLists.txt 9 | -------------------------------------------------------------------------------- /util/mkvideo.sh: -------------------------------------------------------------------------------- 1 | mkdir png 2 | 3 | for i in $1.ppm; 4 | do j=${i/ppm/png}; 5 | echo $j; 6 | convert $i -depth 8 $j; 7 | mv $j ./png/; 8 | done 9 | 10 | ffmpeg -i ./png/%05d.png -vcodec libx264 -preset slow -b:v 20000k -maxrate 20000k -bufsize 5000k -threads 0 -f mp4 output.mp4 11 | ffmpeg -i output.mp4 -f mpeg output.mpg -------------------------------------------------------------------------------- /src/xtcore/sampler.cc: -------------------------------------------------------------------------------- 1 | #include "sampler.h" 2 | 3 | #define DEFAULT_FILTERING FILTERING_BILINEAR 4 | 5 | namespace xtcore { 6 | namespace sampler { 7 | 8 | ISampler::ISampler() 9 | : filtering(DEFAULT_FILTERING) 10 | {} 11 | 12 | ISampler::~ISampler() 13 | {} 14 | 15 | } /* namespace sampler */ 16 | } /* namespace xtcore */ 17 | -------------------------------------------------------------------------------- /lib/nmesh/plane.h: -------------------------------------------------------------------------------- 1 | #ifndef NMESH_PLANE_H_INCLUDED 2 | #define NMESH_PLANE_H_INCLUDED 3 | 4 | #include "structs.h" 5 | 6 | namespace nmesh { 7 | namespace generator { 8 | 9 | void plane(object_t *obj, size_t resolution = 1); 10 | 11 | } /* namespace generator */ 12 | } /* namespace nmesh */ 13 | 14 | #endif /* NMESH_PLANE_H_INCLUDED */ 15 | -------------------------------------------------------------------------------- /src/xtcore/xtcore.h: -------------------------------------------------------------------------------- 1 | #ifndef XT_XTCORE_H_INCLUDED 2 | #define XT_XTCORE_H_INCLUDED 3 | 4 | namespace xtcore { 5 | 6 | const char *get_version(); 7 | const char *get_license(); 8 | 9 | int init(); // Initialize subsystems 10 | int deinit(); // Release subsystems 11 | 12 | } /* namespace xtcore */ 13 | 14 | #endif /* XT_XTCORE_H_INCLUDED */ 15 | -------------------------------------------------------------------------------- /lib/nmesh/invnormals.h: -------------------------------------------------------------------------------- 1 | #ifndef NMESH_INVNORMALS_H_INCLUDED 2 | #define NMESH_INVNORMALS_H_INCLUDED 3 | 4 | #include "structs.h" 5 | 6 | namespace nmesh { 7 | namespace mutator { 8 | 9 | void invert_normals(object_t *obj); 10 | 11 | } /* namespace mutator */ 12 | } /* namespace nmesh */ 13 | 14 | #endif /* NMESH_INVNORMALS_H_INCLUDED */ 15 | -------------------------------------------------------------------------------- /lib/nplatform/fs.h: -------------------------------------------------------------------------------- 1 | #ifndef NPLATFORM_FS_H_INCLUDED 2 | #define NPLATFORM_FS_H_INCLUDED 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif /* __cplusplus */ 7 | 8 | int np_scan_directory(const char* path, void(*f)(const char *)); 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif /* __cplusplus */ 13 | 14 | #endif /* NPLATFORM_FS_H_INCLUDED */ 15 | 16 | -------------------------------------------------------------------------------- /src/xtcore/math/ray.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ray.h" 3 | 4 | namespace xtcore { 5 | 6 | Ray::Ray(const Vector3f &org, const Vector3f &dir) 7 | : origin(org), direction(dir.normalized()) 8 | {} 9 | 10 | Ray::Ray() 11 | : origin(Vector3f(0,0,0)), direction(Vector3f(0,0,1)) 12 | {} 13 | 14 | } /* namespace xtcore */ 15 | -------------------------------------------------------------------------------- /lib/nmesh/icosahedron.h: -------------------------------------------------------------------------------- 1 | #ifndef NMESH_ICOSAHEDRON_H_INCLUDED 2 | #define NMESH_ICOSAHEDRON_H_INCLUDED 3 | 4 | #include "structs.h" 5 | 6 | namespace nmesh { 7 | namespace generator { 8 | 9 | void icosahedron(object_t *obj); 10 | 11 | } /* namespace generator */ 12 | } /* namespace nmesh */ 13 | 14 | #endif /* NMESH_ICOSAHEDRON_H_INCLUDED */ 15 | -------------------------------------------------------------------------------- /src/xtcore/memutil.tml: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_MEMORY_TML_INCLUDED 2 | #define XTCORE_MEMORY_TML_INCLUDED 3 | 4 | namespace xtcore { 5 | namespace memory { 6 | 7 | template 8 | void safe_delete(T*p) { 9 | delete p; 10 | p = 0; 11 | } 12 | 13 | } /* namespace memory */ 14 | } /* namespace xtcore */ 15 | 16 | #endif /* XTCORE_MEMORY_TML_INCLUDED */ 17 | -------------------------------------------------------------------------------- /lib/nimg/desaturate.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_DESATURATE_H_INCLUDED 2 | #define NIMG_DESATURATE_H_INCLUDED 3 | 4 | #include "color.h" 5 | #include "pixmap.h" 6 | 7 | namespace nimg { 8 | namespace filter { 9 | 10 | void desaturate(Pixmap *p); 11 | 12 | } /* namespace filter */ 13 | } /* namespace nimg */ 14 | 15 | #endif /* NIMG_DESATURATE_H_INCLUDED */ 16 | -------------------------------------------------------------------------------- /src/frontend/gui/state.cc: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #include "state.h" 3 | 4 | namespace gui { 5 | 6 | textures_t::textures_t() 7 | : logo(0) 8 | {} 9 | 10 | window_t::window_t() 11 | : width(WINDOW_DEFAULT_WIDTH) 12 | , height(WINDOW_DEFAULT_HEIGHT) 13 | {} 14 | 15 | state_t::state_t() 16 | : workspace(0) 17 | {} 18 | 19 | } /* namespace gui */ 20 | -------------------------------------------------------------------------------- /lib/nmesh/cone.h: -------------------------------------------------------------------------------- 1 | #ifndef NMESH_CONE_H_INCLUDED 2 | #define NMESH_CONE_H_INCLUDED 3 | 4 | #include "structs.h" 5 | 6 | namespace nmesh { 7 | namespace generator { 8 | 9 | void cone(object_t *obj, float height, float radius, size_t resolution = 3); 10 | 11 | } /* namespace generator */ 12 | } /* namespace nmesh */ 13 | 14 | #endif /* NMESH_CONE_H_INCLUDED */ 15 | -------------------------------------------------------------------------------- /lib/nmath/quadratic.h: -------------------------------------------------------------------------------- 1 | #ifndef NMATH_QUADRATIC_H_INCLUDED 2 | #define NMATH_QUADRATIC_H_INCLUDED 3 | 4 | #include 5 | #include "precision.h" 6 | 7 | namespace nmath { 8 | 9 | bool solve_quadratic(const scalar_t a, const scalar_t b, const scalar_t c, scalar_t &x0, scalar_t &x1); 10 | 11 | } /* namespace nmath */ 12 | 13 | #endif /* NMATH_QUADRATIC_H_INCLUDED */ 14 | -------------------------------------------------------------------------------- /lib/ncf/declspec.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBNCF_DECLSPEC_H_INCLUDED 2 | #define LIBNCF_DECLSPEC_H_INCLUDED 3 | 4 | #ifdef _MSC_VER 5 | #ifdef LIBNCF_EXPORT 6 | #define DECLSPEC __declspec(dllexport) 7 | #else 8 | #define DECLSPEC __declspec(dllimport) 9 | #endif 10 | 11 | #else 12 | #define DECLSPEC 13 | 14 | #endif 15 | 16 | #endif /* LIBNCF_DECLSPEC_H_INCLUDED */ 17 | -------------------------------------------------------------------------------- /src/xtcore/timeutil.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUX_TIMEUTIL_HPP_INCLUDED 2 | #define FLUX_TIMEUTIL_HPP_INCLUDED 3 | 4 | #include 5 | 6 | void convert_mlseconds(double mlsecs, unsigned int &days, 7 | unsigned int &hours, unsigned int &mins, 8 | float &secs); 9 | 10 | void print_time_breakdown(std::string &str, double mlsecs); 11 | 12 | #endif /* FLUX_TIMEUTIL_HPP_INCLUDED */ 13 | -------------------------------------------------------------------------------- /lib/nimg/luminance.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_LUMINANCE_H_INCLUDED 2 | #define NIMG_LUMINANCE_H_INCLUDED 3 | 4 | #include "color.h" 5 | 6 | namespace nimg { 7 | namespace eval { 8 | 9 | float luminance(const ColorRGBf &color); 10 | float luminance(const ColorRGBAf &color); 11 | 12 | } /* namespace eval */ 13 | } /* namespace nimg */ 14 | 15 | #endif /* NIMG_LUMINANCE_H_INCLUDED */ 16 | -------------------------------------------------------------------------------- /lib/nmesh/invnormals.cc: -------------------------------------------------------------------------------- 1 | #include "invnormals.h" 2 | 3 | namespace nmesh { 4 | namespace mutator { 5 | 6 | void invert_normals(object_t *obj) 7 | { 8 | if (!obj) return; 9 | 10 | for (size_t i = 0; i < obj->attributes.n.size(); ++i) { 11 | obj->attributes.n[i] = -obj->attributes.n[i]; 12 | } 13 | } 14 | 15 | } /* namespace mutator */ 16 | } /* namespace nmesh */ 17 | -------------------------------------------------------------------------------- /lib/nimg/solidcol.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_SOLIDCOL_H_INCLUDED 2 | #define NIMG_SOLIDCOL_H_INCLUDED 3 | 4 | #include "pixmap.h" 5 | 6 | namespace nimg { 7 | namespace generator { 8 | 9 | int solid_color(Pixmap &map, const unsigned int width, const unsigned int height, ColorRGBAf &col); 10 | 11 | } /* namespace generator */ 12 | } /* namespace nimg */ 13 | 14 | #endif /* NIMG_SOLIDCOL_H_INCLUDED */ 15 | -------------------------------------------------------------------------------- /lib/nimg/transform.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_TRANSFORM_H_INCLUDED 2 | #define NIMG_TRANSFORM_H_INCLUDED 3 | 4 | #include 5 | #include "pixmap.h" 6 | 7 | namespace nimg { 8 | namespace transform { 9 | 10 | bool flip_horizontal (Pixmap *map); 11 | bool flip_vertical (Pixmap *map); 12 | 13 | } /* namespace transform */ 14 | } /* namespace nimg */ 15 | 16 | #endif /* NIMG_TRANSFORM_H_INCLUDED */ 17 | -------------------------------------------------------------------------------- /lib/nimg/yuv4mpeg2.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_YUV4MPEG2_H_INCLUDED 2 | #define NIMG_YUV4MPEG2_H_INCLUDED 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | void start_video(const char *file, int width, int height, int frame_rate); 9 | void write_frame(const char *file, int width, int height, float *rgb); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | 15 | #endif /* NIMG_YUV4MPEG2_H_INCLUDED */ 16 | -------------------------------------------------------------------------------- /lib/nmath/types.h: -------------------------------------------------------------------------------- 1 | #ifndef NMATH_TYPES_H_INCLUDED 2 | #define NMATH_TYPES_H_INCLUDED 3 | 4 | #include "precision.h" 5 | 6 | namespace nmath { 7 | 8 | /* C++ equivalents - Forward declarations */ 9 | class Vector2f; 10 | class Vector3f; 11 | class Vector4f; 12 | 13 | class Matrix3x3f; 14 | class Matrix4x4f; 15 | 16 | } /* namespace nmath */ 17 | 18 | #endif /* NMATH_TYPES_H_INCLUDED */ 19 | -------------------------------------------------------------------------------- /src/xtcore/filter.h: -------------------------------------------------------------------------------- 1 | #ifndef XT_FILTER_H_INCLUDED 2 | #define XT_FILTER_H_INCLUDED 3 | 4 | #include 5 | 6 | using nimg::Pixmap; 7 | 8 | namespace xtcore { 9 | namespace filter { 10 | 11 | class IFilter 12 | { 13 | public: 14 | virtual void render(Pixmap *p) = 0; 15 | }; 16 | 17 | } /* namespace filter */ 18 | } /* namespace xtcore */ 19 | 20 | #endif /* XT_FILTER_H_INCLUDED */ 21 | -------------------------------------------------------------------------------- /src/xtcore/extrude.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_EXTRUDE_H_INCLUDED 2 | #define XTCORE_EXTRUDE_H_INCLUDED 3 | 4 | #include 5 | #include "sampler_cubemap.h" 6 | 7 | namespace xtcore { 8 | namespace auxiliary { 9 | 10 | void extrude(nmesh::object_t *obj, xtcore::sampler::Cubemap *cb); 11 | 12 | } /* namespace auxiliary */ 13 | } /* namespace auxiliary */ 14 | 15 | #endif /* XTCORE_EXTRUDE_H_INCLUDED */ 16 | -------------------------------------------------------------------------------- /src/xtcore/profiler.h: -------------------------------------------------------------------------------- 1 | #ifndef XT_PROFILER_H_INCLUDED 2 | #define XT_PROFILER_H_INCLUDED 3 | 4 | #include "config.h" 5 | 6 | namespace xtcore { 7 | namespace profiler { 8 | 9 | void init(); 10 | void log(const char *tag); 11 | void start(const char *message); 12 | void end(); 13 | void deinit(); 14 | 15 | } /* namespace profiler */ 16 | } /* namespace xtcore */ 17 | 18 | #endif /* XT_PROFILER_H_INCLUDED */ 19 | -------------------------------------------------------------------------------- /src/xtcore/bresenham.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_BRESENHAM_H_INCLUDED 2 | #define XTCORE_BRESENHAM_H_INCLUDED 3 | 4 | #include 5 | #include "tile.h" 6 | 7 | namespace xtcore { 8 | namespace render { 9 | 10 | void bresenham(int x0, int y0, int x1, int y1, nimg::ColorRGBAf &color, tile_t &tile); 11 | 12 | } /* namespace render */ 13 | } /* namespace xtcore */ 14 | 15 | #endif /* XTCORE_BRESENHAM_H_INCLUDED */ 16 | -------------------------------------------------------------------------------- /lib/nmesh/obj.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_OBJ_HPP_INCLUDED 2 | #define XTCORE_OBJ_HPP_INCLUDED 3 | 4 | #include 5 | 6 | namespace nmesh { 7 | namespace io { 8 | namespace import { 9 | 10 | int obj(const char *file, nmesh::object_t &obj, const char *dir = 0); 11 | 12 | } /* namespace import */ 13 | } /* namespace io */ 14 | } /* namespace nmesh */ 15 | 16 | #endif /* XTCORE_OBJ_HPP_INCLUDED */ 17 | -------------------------------------------------------------------------------- /lib/nimg/sample.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_SAMPLE_H_INCLUDED 2 | #define NIMG_SAMPLE_H_INCLUDED 3 | 4 | #include "color.h" 5 | #include "pixmap.h" 6 | 7 | namespace nimg { 8 | namespace sample { 9 | 10 | ColorRGBAf nearest (const Pixmap &map, double u, double v); 11 | ColorRGBAf bilinear (const Pixmap &map, double u, double v); 12 | 13 | } /* namespace sample */ 14 | } /* namespace nimg */ 15 | 16 | #endif /* NIMG_SAMPLE_H_INCLUDED */ 17 | -------------------------------------------------------------------------------- /lib/nplatform/dlloader.h: -------------------------------------------------------------------------------- 1 | #ifndef XTRACER_DLLOADER_H_INCLUDED 2 | #define XTRACER_DLLOADER_H_INCLUDED 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif /* __cplusplus */ 7 | 8 | void* load_library (const char *dlpath); 9 | void* load_function (void *lib, const char *fname); 10 | int free_library (void *lib); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif /* __cplusplus */ 15 | 16 | #endif /* XTRACER_DLLOADER_H_INCLUDED */ 17 | -------------------------------------------------------------------------------- /scene/0.1-empty.scn: -------------------------------------------------------------------------------- 1 | title = Empty Scene 2 | descr = A simple empty scene that renders the environment map 3 | versn = 1.0 4 | 5 | data = data 6 | path_cubemap = /image/envmap/hdr 7 | 8 | environment = { 9 | type = erp 10 | config = { 11 | source = /studio_small_03_2k.hdr 12 | } 13 | } 14 | 15 | camera = { 16 | erp = { 17 | type = erp 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/xtcore/filter/desaturate.h: -------------------------------------------------------------------------------- 1 | #ifndef XT_FILTER_DESATURATE_H_INCLUDED 2 | #define XT_FILTER_DESATURATE_H_INCLUDED 3 | 4 | #include "filter.h" 5 | 6 | namespace xtcore { 7 | namespace filter { 8 | 9 | class Desaturate : public IFilter 10 | { 11 | public: 12 | virtual void render(Pixmap *p); 13 | }; 14 | 15 | } /* namespace filter */ 16 | } /* namespace xtcore */ 17 | 18 | #endif /* XT_FILTER_DESATURATE_H_INCLUDED */ 19 | -------------------------------------------------------------------------------- /lib/nimg/diff.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_DIFF_H_INCLUDED 2 | #define NIMG_DIFF_H_INCLUDED 3 | 4 | #include "pixmap.h" 5 | 6 | #define EPS 0.001 7 | 8 | namespace nimg { 9 | namespace eval { 10 | 11 | int diff(const Pixmap &src, const Pixmap &dst, const float threshold = EPS); 12 | float diff_euclid(const Pixmap &src, const Pixmap &dst); 13 | 14 | } /* namespace eval */ 15 | } /* namespace nimg */ 16 | 17 | #endif /* NIMG_DIFF_H_INCLUDED */ 18 | -------------------------------------------------------------------------------- /lib/nimg/luminance.cc: -------------------------------------------------------------------------------- 1 | #include "luminance.h" 2 | 3 | namespace nimg { 4 | namespace eval { 5 | 6 | float luminance(const ColorRGBf &color) 7 | { 8 | return 0.2126 * color.r() + 0.7152 * color.g() + 0.0722 * color.b(); 9 | } 10 | 11 | float luminance(const ColorRGBAf &color) 12 | { 13 | return 0.2126 * color.r() + 0.7152 * color.g() + 0.0722 * color.b(); 14 | } 15 | 16 | } /* namespace eval */ 17 | } /* namespace nimg */ 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | scene/data 2 | bin/ 3 | media/ 4 | temp/ 5 | *.o 6 | *.pc 7 | *.ppm 8 | *.png 9 | *.jpg 10 | *.hdr 11 | *.swp 12 | *.old 13 | CMakeCache.txt 14 | CMakeLists.txt.user 15 | CMakeFiles/ 16 | Testing/ 17 | cmake_install.cmake 18 | CTestTestfile.cmake 19 | Makefile 20 | imgui.ini 21 | .cmake 22 | .idea 23 | install_manifest.txt 24 | 25 | # procedurally generated source code 26 | src/xtcore/license.h 27 | 28 | # other files 29 | *.cbp 30 | 31 | -------------------------------------------------------------------------------- /src/xtcore/emitter.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_EMITTER_H_INCLUDED 2 | #define XTCORE_EMITTER_H_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | namespace xtcore { 8 | namespace asset { 9 | 10 | typedef struct { 11 | nmath::Vector3f position; 12 | nimg::ColorRGBf intensity; 13 | 14 | } emitter_t; 15 | 16 | } /* namespace asset */ 17 | } /* namespace xtcore */ 18 | 19 | #endif /* XTCORE_EMITTER_H_INCLUDED */ 20 | -------------------------------------------------------------------------------- /src/xtcore/math/surface.cc: -------------------------------------------------------------------------------- 1 | #include "macro.h" 2 | #include "surface.h" 3 | 4 | namespace xtcore { 5 | namespace asset { 6 | 7 | ISurface::ISurface() 8 | : uv_scale(Vector2f(1,1)) 9 | {} 10 | 11 | ISurface::~ISurface() 12 | {} 13 | 14 | nmath::scalar_t ISurface::distance(nmath::Vector3f p) const 15 | { 16 | UNUSED(p) 17 | return INFINITY; 18 | } 19 | 20 | } /* namespace asset */ 21 | } /* namespace xtcore */ 22 | -------------------------------------------------------------------------------- /src/util/bash/autocomplete/xtcli: -------------------------------------------------------------------------------- 1 | xtracer_cli() 2 | { 3 | local cur prev opts 4 | COMPREPLY=() 5 | cur="${COMP_WORDS[COMP_CWORD]}" 6 | prev="${COMP_WORDS[COMP_CWORD-1]}" 7 | opts="-version -help -renderer -threads -res -rdepth -samples -tile_size -aa -cam -outdir -mod" 8 | 9 | if [[ ${cur} == -* ]] ; then 10 | COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) 11 | return 0 12 | fi 13 | } 14 | complete -F _xtracer xtracer 15 | 16 | -------------------------------------------------------------------------------- /src/xtcore/object.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_OBJECT_H_INCLUDED 2 | #define XTCORE_OBJECT_H_INCLUDED 3 | 4 | #include "strpool.h" 5 | 6 | namespace xtcore { 7 | namespace asset { 8 | 9 | class Object 10 | { 11 | public: 12 | HASH_UINT64 surface; 13 | HASH_UINT64 material; 14 | 15 | // IMaterial *ptr_material; 16 | // ISurface *ptr_surface; 17 | }; 18 | 19 | } /* namespace asset */ 20 | } /* namespace xtcore */ 21 | 22 | #endif /* XTCORE_OBJECT_H_INCLUDED */ 23 | -------------------------------------------------------------------------------- /src/xtcore/math/ray.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_RAY_H_INCLUDED 2 | #define XTCORE_RAY_H_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | using nmath::Vector3f; 8 | 9 | namespace xtcore { 10 | 11 | class Ray 12 | { 13 | public: 14 | Ray(); 15 | Ray(const Vector3f &org, const Vector3f &dir); 16 | 17 | Vector3f origin, direction; 18 | }; 19 | 20 | } /* namespace xtcore */ 21 | 22 | #endif /* XTCORE_RAY_H_INCLUDED */ 23 | -------------------------------------------------------------------------------- /ext/remotery/vis/extern/BrowserLib/Core/Code/Core.js: -------------------------------------------------------------------------------- 1 | 2 | // TODO: requires function for checking existence of dependencies 3 | 4 | 5 | function namespace(name) 6 | { 7 | // Ensure all nested namespaces are created only once 8 | 9 | var ns_list = name.split("."); 10 | var parent_ns = window; 11 | 12 | for (var i in ns_list) 13 | { 14 | var ns_name = ns_list[i]; 15 | if (!(ns_name in parent_ns)) 16 | parent_ns[ns_name] = { }; 17 | 18 | parent_ns = parent_ns[ns_name]; 19 | } 20 | } -------------------------------------------------------------------------------- /lib/nimg/xor.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_XOR_H_INCLUDED 2 | #define NIMG_XOR_H_INCLUDED 3 | 4 | #include "pixmap.h" 5 | 6 | namespace nimg { 7 | namespace generator { 8 | 9 | // RETURN CODES: 10 | // 0. Everything went well. 11 | // 1. Width or Height is 0. 12 | // 2. Failed to initialize the Image. 13 | int xortex(Pixmap &map, const unsigned int width, const unsigned int height); 14 | 15 | } /* namespace generator */ 16 | } /* namespace nimg */ 17 | 18 | #endif /* NIMG_XOR_H_INCLUDED */ 19 | -------------------------------------------------------------------------------- /lib/nimg/conversion.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_CONVERSION_H_INCLUDED 2 | #define NIMG_CONVERSION_H_INCLUDED 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | void rgb_to_ycbcr (float r, float g, float b, float *y, float *cb, float *cr); 9 | void rgb_to_ycgco (float r, float g, float b, float *y, float *cg, float *co); 10 | void rgb_to_yuv (float r, float g, float b, float *y, float * u, float * v); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif /* NIMG_CONVERSION_H_INCLUDED */ 17 | -------------------------------------------------------------------------------- /src/xtcore/sampler_gradient.cc: -------------------------------------------------------------------------------- 1 | #include "sampler_gradient.h" 2 | 3 | namespace xtcore { 4 | namespace sampler { 5 | 6 | /* Test colors 7 | ** a: (1.0,1.0,1.0) 8 | ** b: (0.5,0.7,1.0) 9 | */ 10 | 11 | nimg::ColorRGBf Gradient::sample(const nmath::Vector3f &tc) const 12 | { 13 | nmath::Vector3f dir = tc.normalized(); 14 | 15 | float t = 0.5f * dir.y + 1.0; // remap to [0, 1] 16 | return (1.0 - t) * a + t * b; 17 | } 18 | 19 | } /* namespace sampler */ 20 | } /* namespace xtcore */ 21 | 22 | -------------------------------------------------------------------------------- /lib/ncf/expreval.h: -------------------------------------------------------------------------------- 1 | #ifndef NCF_EXPREVAL_H_INCLUDED 2 | #define NCF_EXPREVAL_H_INCLUDED 3 | 4 | namespace ncf { 5 | 6 | enum STATUS { 7 | STATUS_OK 8 | , STATUS_ERR_PARENTHESIS 9 | , STATUS_ERR_SYNTAX 10 | , STATUS_ERR_DIV_BY_ZERO 11 | }; 12 | 13 | struct result_t 14 | { 15 | STATUS status; 16 | double number; 17 | 18 | result_t(STATUS err, double num = 0); 19 | }; 20 | 21 | result_t eval(char *expression); 22 | 23 | } /* namespace ncf */ 24 | 25 | #endif /* NCF_EXPREVAL_H_INCLUDED */ 26 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: 4 | push: 5 | branches: [ develop ] 6 | pull_request: 7 | branches: [ develop ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout code 14 | uses: actions/checkout@v2 15 | - name: Install dependencies 16 | run: sudo apt update && sudo apt install -y libgl1-mesa-dev libglx-mesa0 libglew-dev libglfw3-dev libasound2-dev 17 | - name: Build 18 | run: cmake ./CMakeLists.txt && make 19 | -------------------------------------------------------------------------------- /src/xtcore/matdefs.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_MATDEFS_H_INCLUDED 2 | #define XTCORE_MATDEFS_H_INCLUDED 3 | 4 | #define MAT_SAMPLER_AMBIENT "ambient" 5 | #define MAT_SAMPLER_DIFFUSE "diffuse" 6 | #define MAT_SAMPLER_SPECULAR "specular" 7 | #define MAT_SAMPLER_EMISSIVE "emissive" 8 | 9 | #define MAT_SCALART_REFLECTANCE "reflectance" 10 | #define MAT_SCALART_TRANSPARENCY "transparency" 11 | #define MAT_SCALART_EXPONENT "exponent" 12 | #define MAT_SCALART_IOR "ior" 13 | 14 | #endif /* XTCORE_MATDEFS_H_INCLUDED */ 15 | -------------------------------------------------------------------------------- /src/xtcore/camera/cubemap.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_CUBEMAP_H_INCLUDED 2 | #define XTCORE_CUBEMAP_H_INCLUDED 3 | 4 | #include 5 | #include "math/ray.h" 6 | #include "camera.h" 7 | 8 | namespace xtcore { 9 | namespace camera { 10 | 11 | class Cubemap : public xtcore::asset::ICamera 12 | { 13 | public: 14 | const char* get_type() const; 15 | Ray get_primary_ray(float x, float y, float width, float height); 16 | }; 17 | 18 | } /* namespace camera */ 19 | } /* namespace xtcore */ 20 | 21 | #endif /* XTCORE_CUBEMAP_H_INCLUDED */ 22 | -------------------------------------------------------------------------------- /lib/nimg/checkerboard.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_CHECKERBOARD_H_INCLUDED 2 | #define NIMG_CHECKERBOARD_H_INCLUDED 3 | 4 | #include "pixmap.h" 5 | 6 | namespace nimg { 7 | namespace generator { 8 | 9 | // RETURN CODES: 10 | // 0. Everything went well. 11 | // 1. Width or Height is 0. 12 | // 2. Failed to initialize the Image. 13 | int checkerboard(Pixmap &map, const unsigned int width, const unsigned int height, 14 | ColorRGBAf &a, ColorRGBAf &b); 15 | 16 | } /* namespace generator */ 17 | } /* namespace nimg */ 18 | 19 | #endif /* NIMG_CHECKERBOARD_H_INCLUDED */ 20 | -------------------------------------------------------------------------------- /src/xtcore/aa_sample.cc: -------------------------------------------------------------------------------- 1 | #include "aa_sample.h" 2 | 3 | namespace xtcore { 4 | namespace antialiasing { 5 | 6 | void sample_set_t::push(sample_rgba_t &s) 7 | { 8 | m_samples.push(s); 9 | } 10 | 11 | void sample_set_t::pop(sample_rgba_t &s) 12 | { 13 | s = m_samples.front(); 14 | m_samples.pop(); 15 | } 16 | 17 | size_t sample_set_t::count() 18 | { 19 | return m_samples.size(); 20 | } 21 | 22 | void sample_set_t::clear() 23 | { 24 | while(m_samples.size() > 0) m_samples.pop(); 25 | } 26 | 27 | } /* namespace antialiasing */ 28 | } /* namespace xtcore */ 29 | -------------------------------------------------------------------------------- /src/xtcore/sampler_gradient.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_SAMPLER_GRADIENT_H_INCLUDED 2 | #define XTCORE_SAMPLER_GRADIENT_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include "sampler.h" 7 | 8 | namespace xtcore { 9 | namespace sampler { 10 | 11 | class Gradient : public ISampler 12 | { 13 | public: 14 | nimg::ColorRGBf a; 15 | nimg::ColorRGBf b; 16 | 17 | nimg::ColorRGBf sample(const nmath::Vector3f &tc) const; 18 | }; 19 | 20 | } /* namespace sampler */ 21 | } /* namespace xtcore */ 22 | 23 | #endif /* XTCORE_SAMPLER_GRADIENT_H_INCLUDED */ 24 | -------------------------------------------------------------------------------- /lib/nmath/prime.h: -------------------------------------------------------------------------------- 1 | #ifndef NMATH_PRIME_H_INCLUDED 2 | #define NMATH_PRIME_H_INCLUDED 3 | 4 | #include "defs.h" 5 | 6 | namespace nmath { 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif /* __cplusplus */ 11 | 12 | static inline int isPrime(unsigned long i); 13 | static inline unsigned long getNextPrime(unsigned long i); 14 | static inline unsigned long getPrevPrime(unsigned long i); 15 | 16 | #ifdef __cplusplus 17 | } /* extern "C" */ 18 | #endif 19 | 20 | } /* namespace nmath */ 21 | 22 | #include "prime.inl" 23 | 24 | #endif /* NMATH_PRIME_H_INCLUDED */ 25 | -------------------------------------------------------------------------------- /lib/nimg/desaturate.cc: -------------------------------------------------------------------------------- 1 | #include "luminance.h" 2 | #include "desaturate.h" 3 | #include 4 | namespace nimg { 5 | namespace filter { 6 | 7 | void desaturate(Pixmap *p) 8 | { 9 | if (!p) return; 10 | 11 | for (size_t y = 0; y < p->height(); ++y) { 12 | for (size_t x = 0; x < p->width(); ++x) { 13 | ColorRGBf col = p->pixel_ro(x, y); 14 | float val = nimg::eval::luminance(col); 15 | p->pixel(x, y) = ColorRGBf(val, val, val); 16 | } 17 | } 18 | } 19 | 20 | } /* namespace filter */ 21 | } /* namespace nimg */ 22 | -------------------------------------------------------------------------------- /src/frontend/cli/argparse.h: -------------------------------------------------------------------------------- 1 | #ifndef XTRACER_ARGPARSE_H_INCLUDED 2 | #define XTRACER_ARGPARSE_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | using xtcore::render::params_t; 9 | 10 | int setup(int argc, char** argv 11 | , std::string &renderer 12 | , std::string &outdir 13 | , std::string &scene 14 | , std::list &modifiers 15 | , HASH_UINT64 &camera 16 | , params_t ¶ms); 17 | 18 | #endif /* XTRACER_ARGPARSE_H_INCLUDED */ 19 | -------------------------------------------------------------------------------- /src/xtcore/sampler_erp.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_SAMPLER_ERP_H_INCLUDED 2 | #define XTCORE_SAMPLER_ERP_H_INCLUDED 3 | 4 | #include 5 | #include "sampler_tex.h" 6 | #include "sampler.h" 7 | 8 | namespace xtcore { 9 | namespace sampler { 10 | 11 | class ERP : public ISampler 12 | { 13 | public: 14 | int load(const char *file); 15 | 16 | nimg::ColorRGBf sample(const nmath::Vector3f &tc) const; 17 | 18 | private: 19 | Texture2D m_texture; 20 | }; 21 | 22 | } /* namespace sampler */ 23 | } /* namespace xtcore */ 24 | 25 | #endif /* XTCORE_SAMPLER_ERP_H_INCLUDED */ 26 | -------------------------------------------------------------------------------- /src/frontend/cli/setup.h: -------------------------------------------------------------------------------- 1 | #ifndef XTRACER_SETUP_H_INCLUDED 2 | #define XTRACER_SETUP_H_INCLUDED 3 | 4 | #define XTRACER_SETUP_DEFAULT_AA 1 /* Default anti-aliasing level. */ 5 | #define XTRACER_SETUP_DEFAULT_FB_WIDTH 640 /* Default framebuffer width. */ 6 | #define XTRACER_SETUP_DEFAULT_FB_HEIGHT 480 /* Default framebuffer height. */ 7 | #define XTRACER_SETUP_DEFAULT_SAMPLES 1 /* Default sample count */ 8 | 9 | #define XTRACER_SETUP_DEFAULT_THREAD_COUNT 0 /* Default thread count (0: auto-detect). */ 10 | 11 | #endif /* XTRACER_SETUP_H_INCLUDED */ 12 | -------------------------------------------------------------------------------- /src/xtcore/sampler_col.cc: -------------------------------------------------------------------------------- 1 | #include "macro.h" 2 | #include "sampler_col.h" 3 | 4 | namespace xtcore { 5 | namespace sampler { 6 | 7 | SolidColor::SolidColor() 8 | {} 9 | 10 | SolidColor::~SolidColor() 11 | {} 12 | 13 | void SolidColor::get(nimg::ColorRGBf &color) 14 | { 15 | color = m_color; 16 | } 17 | 18 | void SolidColor::set(nimg::ColorRGBf &color) 19 | { 20 | m_color = color; 21 | } 22 | 23 | nimg::ColorRGBf SolidColor::sample(const nmath::Vector3f &uvw) const 24 | { 25 | UNUSED(uvw) 26 | return m_color; 27 | } 28 | 29 | } /* namespace sampler */ 30 | } /* namespace xtcore */ 31 | -------------------------------------------------------------------------------- /src/xtcore/camera/erp.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_ERP_H_INCLUDED 2 | #define XTCORE_ERP_H_INCLUDED 3 | 4 | #include 5 | #include "math/ray.h" 6 | #include "camera.h" 7 | 8 | using nmath::Vector3f; 9 | 10 | namespace xtcore { 11 | namespace camera { 12 | 13 | class ERP : public xtcore::asset::ICamera 14 | { 15 | public: 16 | Vector3f orientation; 17 | 18 | const char* get_type() const; 19 | 20 | Ray get_primary_ray(float x, float y, float width, float height); 21 | }; 22 | 23 | } /* namespace camera */ 24 | } /* namespace xtcore */ 25 | 26 | #endif /* XTCORE_ERP_H_INCLUDED */ 27 | -------------------------------------------------------------------------------- /src/frontend/gui/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef XT_GUI_H_INCLUDED 2 | #define XT_GUI_H_INCLUDED 3 | 4 | #include "workspace.h" 5 | #include "state.h" 6 | 7 | namespace gui { 8 | 9 | void mm_tileorder (workspace_t *ws); 10 | void mm_resolution (workspace_t *ws); 11 | void mm_export (workspace_t *ws); 12 | void mm_renderer (workspace_t *ws); 13 | void mm_zoom (workspace_t *ws); 14 | 15 | void render_main_menu(state_t *state); 16 | 17 | void container(state_t *state); 18 | 19 | void init(state_t *state); 20 | void draw_widgets(state_t *state); 21 | 22 | } /* namespace gui */ 23 | 24 | #endif /* XT_GUI_H_INCLUDED */ 25 | -------------------------------------------------------------------------------- /src/xtcore/integrator/stencil/integrator.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_INTEGRATOR_STENCIL_H_INCLUDED 2 | #define XTCORE_INTEGRATOR_STENCIL_H_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | namespace xtcore { 8 | namespace integrator { 9 | namespace stencil { 10 | 11 | class Integrator : public xtcore::render::IIntegrator 12 | { 13 | public: 14 | virtual void render_tile(xtcore::render::tile_t *tile); 15 | }; 16 | 17 | } /* namespace stencil */ 18 | } /* namespace integrator */ 19 | } /* namespace xtcore */ 20 | 21 | #endif /* XTCORE_INTEGRATOR_STENCIL_H_INCLUDED */ 22 | -------------------------------------------------------------------------------- /lib/nimg/genetic.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_GENETIC_H_INCLUDED 2 | #define NIMG_GENETIC_H_INCLUDED 3 | 4 | #include 5 | #include "pixmap.h" 6 | #include "rasteriser.h" 7 | 8 | namespace nimg { 9 | namespace genetic_algorithms { 10 | 11 | int init_seed(unsigned int seed); 12 | int tri(const Pixmap &src, Pixmap &dst, const float threshold); 13 | int tri(const Pixmap &src, Pixmap &dst 14 | , std::vector triangles 15 | , const float threshold 16 | , const size_t budget); 17 | 18 | } /* namespace genetic_algorithms */ 19 | } /* namespace nimg */ 20 | 21 | #endif /* NIMG_GENETIC_H_INCLUDED */ 22 | -------------------------------------------------------------------------------- /lib/nmesh/transform.h: -------------------------------------------------------------------------------- 1 | #ifndef NMESH_TRANSFORM_H_INCLUDED 2 | #define NMESH_TRANSFORM_H_INCLUDED 3 | 4 | #include 5 | #include "structs.h" 6 | 7 | namespace nmesh { 8 | namespace mutator { 9 | 10 | void scale (object_t &object, nmath::scalar_t x, nmath::scalar_t y, nmath::scalar_t z); 11 | void translate(object_t &object, nmath::scalar_t x, nmath::scalar_t y, nmath::scalar_t z); 12 | void rotate (object_t &object, nmath::scalar_t x, nmath::scalar_t y, nmath::scalar_t z); 13 | 14 | } /* namespace mutator */ 15 | } /* namespace nmesh */ 16 | 17 | #endif /* NMESH_TRANSFORM_H_INCLUDED */ 18 | -------------------------------------------------------------------------------- /src/xtcore/integrator/wireframe/integrator.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_INTEGRATOR_WIREFRAME_H_INCLUDED 2 | #define XTCORE_INTEGRATOR_WIREFRAME_H_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | namespace xtcore { 8 | namespace integrator { 9 | namespace wireframe { 10 | 11 | class Integrator : public xtcore::render::IIntegrator 12 | { 13 | public: 14 | virtual void render_tile(xtcore::render::tile_t *tile); 15 | }; 16 | 17 | } /* namespace wireframe */ 18 | } /* namespace integrator */ 19 | } /* namespace xtcore */ 20 | 21 | #endif /* XTCORE_INTEGRATOR_WIREFRAME_H_INCLUDED */ 22 | -------------------------------------------------------------------------------- /src/xtcore/midi.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_MIDI_H_INCLUDED 2 | #define XTCORE_MIDI_H_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | namespace xtcore { 8 | namespace midi { 9 | 10 | typedef struct { 11 | int port; 12 | std::string name; 13 | } device_t; 14 | 15 | typedef struct { 16 | std::vector devices; 17 | } devices_t; 18 | 19 | int init(); 20 | int deinit(); 21 | int detect(devices_t *devs); 22 | int open(device_t *dev); 23 | int close(device_t *dev); 24 | int read(device_t *dev); 25 | 26 | } /* namespace midi */ 27 | } /* namespace xtcore */ 28 | 29 | #endif /* XTCORE_MIDI_H_INCLUDED */ 30 | -------------------------------------------------------------------------------- /ext/remotery/vis/extern/BrowserLib/WindowManager/Code/Label.js: -------------------------------------------------------------------------------- 1 | 2 | namespace("WM"); 3 | 4 | 5 | WM.Label = (function() 6 | { 7 | var template_html = "
"; 8 | 9 | 10 | function Label(x, y, text) 11 | { 12 | // Create the node 13 | this.Node = DOM.Node.CreateHTML(template_html); 14 | 15 | // Allow position to be optional 16 | if (x != null && y != null) 17 | DOM.Node.SetPosition(this.Node, [x, y]); 18 | 19 | this.SetText(text); 20 | } 21 | 22 | 23 | Label.prototype.SetText = function(text) 24 | { 25 | if (text != null) 26 | this.Node.innerHTML = text; 27 | } 28 | 29 | 30 | return Label; 31 | })(); -------------------------------------------------------------------------------- /scene/3.5.3.scn: -------------------------------------------------------------------------------- 1 | title = Cornell Box 2 | descr = Cornell Box 3 | versn = 0.5 4 | 5 | data = data/geometry/graphics.cs.williams.edu 6 | 7 | environment = { 8 | type = gradient 9 | config = { 10 | a = col3(1.0,1.0,1.0) 11 | b = col3(0.7,0.8,1.0) 12 | } 13 | } 14 | 15 | camera = { 16 | default = { 17 | type = thin-lens 18 | fov = 45 19 | position = vec3(0,1,4) 20 | target = vec3(0,1,0) 21 | up = vec3(0,1,0) 22 | } 23 | } 24 | 25 | object = { 26 | scene = { 27 | source = /cornell/CornellBox-Sphere.obj 28 | prefix = cornell_ 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/xtcore/integrator/depth/integrator.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_INTEGRATOR_DEPTH_H_INCLUDED 2 | #define XTCORE_INTEGRATOR_DEPTH_H_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | using nimg::ColorRGBf; 8 | using nimg::Pixmap; 9 | 10 | namespace xtcore { 11 | namespace integrator { 12 | namespace depth { 13 | 14 | class Integrator : public xtcore::render::IIntegrator 15 | { 16 | public: 17 | void render_tile(xtcore::render::tile_t *tile); 18 | }; 19 | 20 | } /* namespace depth */ 21 | } /* namespace integrator */ 22 | } /* namespace xtcore */ 23 | 24 | #endif /* XTCORE_INTEGRATOR_DEPTH_H_INCLUDED */ 25 | -------------------------------------------------------------------------------- /src/xtcore/sampler_col.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_SAMPLER_COLOR_H_INCLUDED 2 | #define XTCORE_SAMPLER_COLOR_H_INCLUDED 3 | 4 | #include "sampler.h" 5 | 6 | namespace xtcore { 7 | namespace sampler { 8 | 9 | class SolidColor : public ISampler 10 | { 11 | public: 12 | SolidColor(); 13 | virtual ~SolidColor(); 14 | 15 | void set(nimg::ColorRGBf &color); 16 | void get(nimg::ColorRGBf &color); 17 | virtual nimg::ColorRGBf sample(const nmath::Vector3f &uvw) const; 18 | 19 | private: 20 | nimg::ColorRGBf m_color; 21 | }; 22 | 23 | } /* namespace sampler */ 24 | } /* namespace xtcore */ 25 | 26 | #endif /* XTCORE_SAMPLER_COLOR_H_INCLUDED */ 27 | -------------------------------------------------------------------------------- /lib/nmath/quadratic.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "quadratic.h" 3 | 4 | namespace nmath { 5 | 6 | bool solve_quadratic(const scalar_t a, const scalar_t b, const scalar_t c, scalar_t &x0, scalar_t &x1) 7 | { 8 | scalar_t d = b * b - 4.f * a * c; 9 | 10 | if (d < 0.f) return false; 11 | else if (d == 0.f) x0 = x1 = - 0.5 * b / a; 12 | else { 13 | scalar_t q = (b > 0) 14 | ? -0.5 * (b + nmath_sqrt(d)) 15 | : -0.5 * (b - nmath_sqrt(d)); 16 | 17 | x0 = q / a; 18 | x1 = c / q; 19 | } 20 | 21 | if (x0 > x1) std::swap(x0, x1); 22 | 23 | return true; 24 | } 25 | 26 | } /* namespace nmath */ 27 | -------------------------------------------------------------------------------- /ext/remotery/vis/extern/BrowserLib/Core/Code/LocalStore.js: -------------------------------------------------------------------------------- 1 | 2 | namespace("LocalStore"); 3 | 4 | 5 | LocalStore.Set = function(class_name, class_id, variable_id, data) 6 | { 7 | if (typeof(Storage) != "undefined") 8 | { 9 | var name = class_name + "_" + class_id + "_" + variable_id; 10 | localStorage[name] = JSON.stringify(data); 11 | } 12 | } 13 | 14 | 15 | LocalStore.Get = function(class_name, class_id, variable_id, default_data) 16 | { 17 | if (typeof(Storage) != "undefined") 18 | { 19 | var name = class_name + "_" + class_id + "_" + variable_id; 20 | var data = localStorage[name] 21 | if (data) 22 | return JSON.parse(data); 23 | } 24 | 25 | return default_data; 26 | } -------------------------------------------------------------------------------- /src/xtcore/camera/ods.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_ODS_H_INCLUDED 2 | #define XTCORE_ODS_H_INCLUDED 3 | 4 | #include 5 | #include "math/ray.h" 6 | #include "camera.h" 7 | 8 | #define XT_CAM_DEFAULT_IPD 0.064f // 6.4 cm 9 | 10 | using nmath::Vector3f; 11 | 12 | namespace xtcore { 13 | namespace camera { 14 | 15 | class ODS : public xtcore::asset::ICamera 16 | { 17 | public: 18 | float ipd; 19 | Vector3f orientation; 20 | 21 | ODS(); 22 | const char* get_type() const; 23 | 24 | Ray get_primary_ray(float x, float y, float width, float height); 25 | }; 26 | 27 | } /* namespace camera */ 28 | } /* namespace xtcore */ 29 | 30 | #endif /* XTCORE_ODS_H_INCLUDED */ 31 | -------------------------------------------------------------------------------- /src/xtcore/sampler.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_SAMPLER_H_INCLUDED 2 | #define XTCORE_SAMPLER_H_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | using nmath::Vector3f; 8 | using nimg::ColorRGBf; 9 | 10 | namespace xtcore { 11 | namespace sampler { 12 | 13 | enum FILTERING 14 | { 15 | FILTERING_NEAREST 16 | , FILTERING_BILINEAR 17 | }; 18 | 19 | class ISampler 20 | { 21 | public: 22 | ISampler(); 23 | virtual ~ISampler(); 24 | virtual ColorRGBf sample(const Vector3f &uvw) const = 0; 25 | 26 | FILTERING filtering; 27 | }; 28 | 29 | } /* namespace sampler */ 30 | } /* namespace xtcore */ 31 | 32 | #endif /* XTCORE_SAMPLER_H_INCLUDED */ 33 | -------------------------------------------------------------------------------- /src/xtcore/xtcore.cc: -------------------------------------------------------------------------------- 1 | #include "xtcore.h" 2 | #include "config.h" 3 | #include "profiler.h" 4 | #include "strpool.h" 5 | #include "midi.h" 6 | #include "res/license.h" 7 | 8 | namespace xtcore { 9 | 10 | const char *get_version() 11 | { 12 | return XTCORE_VERSION; 13 | } 14 | 15 | const char *get_license() 16 | { 17 | return __LICENSE; 18 | } 19 | 20 | int init() 21 | { 22 | xtcore::pool::str::init(); 23 | xtcore::profiler::init(); 24 | //xtcore::midi::init(); 25 | return 0; 26 | } 27 | 28 | int deinit() 29 | { 30 | xtcore::profiler::deinit(); 31 | xtcore::pool::str::release(); 32 | xtcore::midi::deinit(); 33 | return 0; 34 | } 35 | 36 | } /* namespace xtcore */ 37 | -------------------------------------------------------------------------------- /src/xtcore/strpool.h: -------------------------------------------------------------------------------- 1 | #ifndef XT_STRPOOL_H_INCLUDED 2 | #define XT_STRPOOL_H_INCLUDED 3 | 4 | #define HASH_ID_INVALID (0) 5 | 6 | #include 7 | #define HASH_UINT32 uint32_t 8 | #define HASH_UINT64 uint64_t 9 | 10 | #define HASH_ID HASH_UINT64 11 | 12 | namespace xtcore { 13 | namespace pool { 14 | namespace str { 15 | 16 | void init(); 17 | void release(); 18 | 19 | HASH_ID add(const char *str); // Add new string 20 | void del(HASH_ID id); // Remove existing string 21 | char const* get(HASH_ID id); // Get string from hash 22 | 23 | } /* namespace str */ 24 | } /* namespace pool */ 25 | } /* namespace xtcore */ 26 | 27 | #endif /* XT_STRPOOL_H_INCLUDED */ 28 | -------------------------------------------------------------------------------- /scene/3.5.2.scn: -------------------------------------------------------------------------------- 1 | title = Cornell Box 2 | descr = Cornell Box 3 | versn = 0.5 4 | 5 | data = data 6 | path_model = /geometry/graphics.cs.williams.edu 7 | path_cubemap = /image/envmap/hdr 8 | 9 | environment = { 10 | type = erp 11 | config = { 12 | source = /studio_small_03_2k.hdr 13 | } 14 | } 15 | 16 | camera = { 17 | default = { 18 | type = thin-lens 19 | fov = 120 20 | position = vec3(0,1,2) 21 | target = vec3(0,1,0) 22 | up = vec3(0,1,0) 23 | } 24 | } 25 | 26 | object = { 27 | scene = { 28 | source = /cornell/CornellBox-Glossy.obj 29 | prefix = cornell_ 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/xtcore/camera.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_CAMERA_H_INCLUDED 2 | #define XTCORE_CAMERA_H_INCLUDED 3 | 4 | #include "math/ray.h" 5 | 6 | using nmath::Vector3f; 7 | 8 | namespace xtcore { 9 | namespace asset { 10 | 11 | class ICamera 12 | { 13 | public: 14 | Vector3f position; 15 | 16 | virtual ~ICamera() {}; 17 | virtual Ray get_primary_ray(float x, float y, float width, float height) = 0; 18 | virtual const char* get_type() const = 0; 19 | }; 20 | 21 | } /* namespace asset */ 22 | } /* namespace xtcore */ 23 | 24 | #include "camera/perspective.h" 25 | #include "camera/erp.h" 26 | #include "camera/ods.h" 27 | #include "camera/cubemap.h" 28 | 29 | #endif /* XTCORE_CAMERA_H_INCLUDED */ 30 | -------------------------------------------------------------------------------- /src/xtcore/sampler_erp.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "sampler_erp.h" 4 | 5 | namespace xtcore { 6 | namespace sampler { 7 | 8 | int ERP::load(const char *file) 9 | { 10 | return m_texture.load(file); 11 | } 12 | 13 | nimg::ColorRGBf ERP::sample(const nmath::Vector3f &tc) const 14 | { 15 | nmath::Vector3f dir = tc.normalized(); 16 | 17 | float theta = acos(dir.y); 18 | float phi = atan2(dir.x, -dir.z); 19 | 20 | float u = 0.5f + phi / nmath::PI_DOUBLE; 21 | float v = theta / nmath::PI; 22 | 23 | nmath::Vector3f coords(u, v, 0); 24 | return m_texture.sample(coords); 25 | } 26 | 27 | } /* namespace sampler */ 28 | } /* namespace xtcore */ 29 | 30 | -------------------------------------------------------------------------------- /lib/nimg/xor.cc: -------------------------------------------------------------------------------- 1 | #include "color.h" 2 | #include "xor.h" 3 | 4 | namespace nimg { 5 | namespace generator { 6 | 7 | int xortex(Pixmap &map, const unsigned int width, const unsigned int height) 8 | { 9 | if (!width || !height) 10 | return 1; 11 | 12 | if(map.init(width, height)) 13 | return 2; 14 | 15 | for(unsigned int j = 0; j < map.height(); j++) { 16 | for(unsigned int i = 0; i < map.width(); i++) { 17 | float val = (float)(i ^ j) / 255.0f; 18 | ColorRGBAf &pixel = map.pixel(i, j); 19 | 20 | pixel.r(val); 21 | pixel.g(val); 22 | pixel.b(val); 23 | pixel.a(1.0f); 24 | } 25 | } 26 | 27 | return 0; 28 | } 29 | 30 | } /* namespace generator */ 31 | } /* namespace nimg */ 32 | -------------------------------------------------------------------------------- /lib/nimg/solidcol.cc: -------------------------------------------------------------------------------- 1 | #include "solidcol.h" 2 | 3 | namespace nimg { 4 | namespace generator { 5 | 6 | int solid_color(Pixmap &map, const unsigned int width, const unsigned int height, ColorRGBAf &col) 7 | { 8 | if (!width || ! height) return 1; 9 | 10 | if (map.init(width, height)) return 2; 11 | 12 | for (unsigned int j = 0; j < map.height(); ++j) { 13 | for (unsigned int i = 0; i < map.width(); ++i) { 14 | 15 | ColorRGBAf &pixel = map.pixel(i, j); 16 | pixel.r(col.r()); 17 | pixel.g(col.g()); 18 | pixel.b(col.b()); 19 | pixel.a(col.a()); 20 | } 21 | } 22 | 23 | return 0; 24 | } 25 | 26 | } /* namespace generator */ 27 | } /* namespace nimg */ 28 | -------------------------------------------------------------------------------- /lib/nimg/img.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_IMG_H_INCLUDED 2 | #define NIMG_IMG_H_INCLUDED 3 | 4 | #include "pixmap.h" 5 | 6 | namespace nimg { 7 | namespace io { 8 | namespace load { 9 | 10 | int image(const char *filename, Pixmap &map); 11 | 12 | } /* namespace load */ 13 | 14 | namespace save { 15 | 16 | int exr(const char *filename, Pixmap &map); 17 | int png(const char *filename, Pixmap &map); 18 | int jpg(const char *filename, Pixmap &map); 19 | int bmp(const char *filename, Pixmap &map); 20 | int tga(const char *filename, Pixmap &map); 21 | int hdr(const char *filename, Pixmap &map); 22 | 23 | } /* namespace save */ 24 | 25 | } /* namespace io */ 26 | } /* namespace nimg */ 27 | 28 | #endif /* NIMG_IMG_H_INCLUDED */ 29 | -------------------------------------------------------------------------------- /src/xtcore/aa.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_AA_H_INCLUDED 2 | #define XTCORE_AA_H_INCLUDED 3 | 4 | #include 5 | #include "tile.h" 6 | #include "aa_sample.h" 7 | 8 | namespace xtcore { 9 | namespace antialiasing { 10 | 11 | void gen_samples_grid (sample_set_t &samples, nmath::Vector2f pixel, size_t level); 12 | void gen_samples_random (sample_set_t &samples, nmath::Vector2f pixel, size_t level); 13 | 14 | enum SAMPLE_DISTRIBUTION 15 | { 16 | SAMPLE_DISTRIBUTION_GRID 17 | , SAMPLE_DISTRIBUTION_RANDOM 18 | }; 19 | 20 | void produce(xtcore::render::tile_t *tile, SAMPLE_DISTRIBUTION sd, size_t level, size_t samples); 21 | 22 | } /* namespace antialiasing */ 23 | } /* namespace xtcore */ 24 | 25 | #endif /* XTCORE_AA_H_INCLUDED */ 26 | -------------------------------------------------------------------------------- /lib/nmath/prng.h: -------------------------------------------------------------------------------- 1 | #ifndef NMATH_PRNG_H_INCLUDED 2 | #define NMATH_PRNG_H_INCLUDED 3 | 4 | #include "vector.h" 5 | #include "types.h" 6 | 7 | namespace nmath { 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif /* __cplusplus */ 12 | 13 | /* returns a random number between min and max using the C built-in PRNG in uniform manner */ 14 | static inline scalar_t prng_c(const scalar_t a, const scalar_t b); 15 | 16 | /* Multiply with carry method by George Marsaglia */ 17 | static inline scalar_t prng_multiplyWithCarry(const scalar_t a, const scalar_t b); 18 | 19 | #ifdef __cplusplus 20 | } /* extern "C" */ 21 | #endif 22 | 23 | } /* namespace nmath */ 24 | 25 | #include "prng.inl" 26 | 27 | #endif /* NMATH_PRNG_H_INCLUDED */ 28 | -------------------------------------------------------------------------------- /ext/remotery/vis/extern/BrowserLib/WindowManager/Code/Container.js: -------------------------------------------------------------------------------- 1 | 2 | namespace("WM"); 3 | 4 | 5 | WM.Container = (function() 6 | { 7 | var template_html = "
"; 8 | 9 | 10 | function Container(x, y, w, h) 11 | { 12 | // Create a simple container node 13 | this.Node = DOM.Node.CreateHTML(template_html); 14 | this.SetPosition(x, y); 15 | this.SetSize(w, h); 16 | } 17 | 18 | 19 | Container.prototype.SetPosition = function(x, y) 20 | { 21 | this.Position = [ x, y ]; 22 | DOM.Node.SetPosition(this.Node, this.Position); 23 | } 24 | 25 | 26 | Container.prototype.SetSize = function(w, h) 27 | { 28 | this.Size = [ w, h ]; 29 | DOM.Node.SetSize(this.Node, this.Size); 30 | } 31 | 32 | 33 | return Container; 34 | })(); -------------------------------------------------------------------------------- /src/frontend/gui/action.h: -------------------------------------------------------------------------------- 1 | #ifndef XTGUI_GUI_ACTION_H_INCLUDED 2 | #define XTGUI_GUI_ACTION_H_INCLUDED 3 | 4 | #include "state.h" 5 | #include "workspace.h" 6 | 7 | namespace action { 8 | 9 | enum IMG_FORMAT 10 | { 11 | IMG_FORMAT_EXR 12 | , IMG_FORMAT_HDR 13 | , IMG_FORMAT_PNG 14 | , IMG_FORMAT_JPG 15 | , IMG_FORMAT_BMP 16 | , IMG_FORMAT_TGA 17 | }; 18 | 19 | int render (workspace_t *ws); 20 | int load (workspace_t *ws); 21 | int close (gui::state_t *state, workspace_t *ws); 22 | int write_raygraph (const char *filepath, workspace_t *ws); 23 | int write (IMG_FORMAT format, const char *filepath, workspace_t *ws); 24 | 25 | void quit(); 26 | 27 | } /* namespace action */ 28 | 29 | #endif /* XTGUI_GUI_ACTION_H_INCLUDED */ 30 | -------------------------------------------------------------------------------- /src/frontend/gui/state.h: -------------------------------------------------------------------------------- 1 | #ifndef XTGUI_GUI_STATE_H 2 | #define XTGUI_GUI_STATE_H 3 | 4 | #include 5 | #include "opengl.h" 6 | #include "workspace.h" 7 | 8 | namespace gui { 9 | 10 | struct network_t 11 | { 12 | bool is_listening; 13 | }; 14 | 15 | struct textures_t 16 | { 17 | GLuint logo; 18 | GLuint render; 19 | 20 | textures_t(); 21 | }; 22 | 23 | struct window_t 24 | { 25 | int width; 26 | int height; 27 | 28 | window_t(); 29 | }; 30 | 31 | struct state_t 32 | { 33 | network_t network; 34 | textures_t textures; 35 | window_t window; 36 | workspace_t *workspace; 37 | 38 | std::vector workspaces; 39 | state_t(); 40 | }; 41 | 42 | } /* namespace gui */ 43 | 44 | #endif /* XTGUI_GUI_STATE_H */ 45 | -------------------------------------------------------------------------------- /src/xtcore/camera/erp.cc: -------------------------------------------------------------------------------- 1 | #include "erp.h" 2 | 3 | namespace xtcore { 4 | namespace camera { 5 | 6 | const char* ERP::get_type() const 7 | { 8 | return "Equirectangular Projection"; 9 | } 10 | 11 | Ray ERP::get_primary_ray(float x, float y, float width, float height) 12 | { 13 | Ray ray; 14 | // Calculate theta & phi angles 15 | float phi = (x / width ) * nmath::PI * 2.f; 16 | float theta = (y / height) * nmath::PI; 17 | 18 | ray.origin = position; 19 | ray.direction = nmath::Vector3f(sin(theta) * cos(phi), cos(theta), sin(theta) * sin(phi)); 20 | 21 | nmath::Matrix4x4f m; 22 | m.rotate(orientation); 23 | ray.direction.transform(m); 24 | 25 | return ray; 26 | } 27 | 28 | } /* namespace camera */ 29 | } /* namespace xtcore */ 30 | -------------------------------------------------------------------------------- /ext/remotery/vis/Code/ThreadFrame.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | ThreadFrame = (function() 4 | { 5 | function ThreadFrame(message) 6 | { 7 | // Persist the required message data 8 | this.NbSamples = message.nb_samples; 9 | this.SampleDigest = message.sample_digest; 10 | this.Samples = message.samples; 11 | 12 | // Calculate the frame start/end times 13 | this.StartTime_us = 0; 14 | this.EndTime_us = 0; 15 | var nb_root_samples = this.Samples.length; 16 | if (nb_root_samples > 0) 17 | { 18 | var last_sample = this.Samples[nb_root_samples - 1]; 19 | this.StartTime_us = this.Samples[0].us_start; 20 | this.EndTime_us = last_sample.us_start + last_sample.us_length; 21 | } 22 | 23 | this.Length_us = this.EndTime_us - this.StartTime_us; 24 | } 25 | 26 | 27 | return ThreadFrame; 28 | })(); 29 | -------------------------------------------------------------------------------- /src/xtcore/util/raygraph.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_RAYGRAPH_H_INCLUDED 2 | #define XTCORE_RAYGRAPH_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | using nmath::Vector3f; 9 | using nimg::ColorRGBAf; 10 | 11 | namespace xtcore { 12 | namespace raygraph { 13 | 14 | struct sample_t 15 | { 16 | Vector3f position; 17 | ColorRGBAf color; 18 | }; 19 | 20 | struct path_t 21 | { 22 | std::vector samples; 23 | }; 24 | 25 | struct bundle_t 26 | { 27 | std::vector paths; 28 | }; 29 | 30 | struct raygraph_t 31 | { 32 | std::vector bundles; 33 | }; 34 | 35 | int write(const char *filepath, const raygraph_t &raygraph); 36 | 37 | } /* namespace raygraph */ 38 | } /* namespace xtcore */ 39 | 40 | #endif /* XTCORE_RAYGRAPH_H_INCLUDED */ 41 | -------------------------------------------------------------------------------- /lib/nimg/coldef.h: -------------------------------------------------------------------------------- 1 | 2 | // These grays are useful for fine-tuning lighting color values 3 | // and for other areas where subtle variations of grays are needed. 4 | // PERCENTAGE GRAYS: 5 | #declare Gray05 = White*0.05 6 | #declare Gray10 = White*0.10 7 | #declare Gray15 = White*0.15 8 | #declare Gray20 = White*0.20 9 | #declare Gray25 = White*0.25 10 | #declare Gray30 = White*0.30 11 | #declare Gray35 = White*0.35 12 | #declare Gray40 = White*0.40 13 | #declare Gray45 = White*0.45 14 | #declare Gray50 = White*0.50 15 | #declare Gray55 = White*0.55 16 | #declare Gray60 = White*0.60 17 | #declare Gray65 = White*0.65 18 | #declare Gray70 = White*0.70 19 | #declare Gray75 = White*0.75 20 | #declare Gray80 = White*0.80 21 | #declare Gray85 = White*0.85 22 | #declare Gray90 = White*0.90 23 | #declare Gray95 = White*0.95 24 | 25 | // OTHER GRAYS 26 | -------------------------------------------------------------------------------- /scene/3.5.1.scn: -------------------------------------------------------------------------------- 1 | title = Cornell Box 2 | descr = Cornell Box 3 | versn = 0.5 4 | 5 | data = data/geometry/graphics.cs.williams.edu 6 | 7 | environment = { 8 | type = gradient 9 | config = { 10 | a = col3(1.0,1.0,1.0) 11 | b = col3(0.7,0.8,1.0) 12 | } 13 | } 14 | 15 | camera = { 16 | default = { 17 | type = thin-lens 18 | fov = 45 19 | position = vec3(0,1,5) 20 | target = vec3(0,1,0) 21 | up = vec3(0,1,0) 22 | aperture = 0 23 | flength = 175 24 | } 25 | 26 | ods = { 27 | type = ods 28 | ipd = 1.5 29 | position = vec3(0, 1, 5) 30 | } 31 | } 32 | 33 | object = { 34 | scene = { 35 | source = /cornell/CornellBox-Original.obj 36 | prefix = cornell_ 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/xtcore/math/surface.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_SURFACE_H_INCLUDED 2 | #define XTCORE_SURFACE_H_INCLUDED 3 | 4 | #include 5 | #include "math/hitrecord.h" 6 | #include "aabb.h" 7 | #include "ray.h" 8 | 9 | namespace xtcore { 10 | namespace asset { 11 | 12 | class ISurface 13 | { 14 | public: 15 | ISurface(); 16 | virtual ~ISurface(); 17 | 18 | virtual bool intersection(const Ray &ray, hit_record_t* i_info) const = 0; 19 | virtual nmath::scalar_t distance(nmath::Vector3f p) const; 20 | virtual void calc_aabb() = 0; 21 | 22 | virtual Vector3f point_sample() const = 0; 23 | virtual Ray ray_sample() const = 0; 24 | 25 | AABB3 aabb; 26 | Vector2f uv_scale; 27 | }; 28 | 29 | } /* namespace asset */ 30 | } /* namespace xtcore */ 31 | 32 | #endif /* XTCORE_SURFACE_H_INCLUDED */ 33 | -------------------------------------------------------------------------------- /src/xtcore/integrator/embree/integrator.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_INTEGRATOR_EMBREE_H_INCLUDED 2 | #define XTCORE_INTEGRATOR_EMBREE_H_INCLUDED 3 | 4 | #include 5 | 6 | #if FEATURE_IS_INCLUDED(FEATURE_EMBREE) 7 | 8 | #include 9 | #include 10 | 11 | namespace xtcore { 12 | namespace integrator { 13 | namespace embree { 14 | 15 | class Integrator : public xtcore::render::IIntegrator 16 | { 17 | RTCDevice m_device; 18 | RTCScene m_scene; 19 | 20 | public: 21 | void setup_auxiliary(); 22 | void clean_auxiliary(); 23 | void render_tile(xtcore::render::tile_t *tile); 24 | }; 25 | 26 | } /* namespace embree */ 27 | } /* namespace integrator */ 28 | } /* namespace xtcore */ 29 | 30 | #endif /* FEATURE_EMBREE */ 31 | 32 | #endif /* XTCORE_INTEGRATOR_EMBREE_H_INCLUDED */ 33 | -------------------------------------------------------------------------------- /lib/nimg/rasteriser.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_RASTERISER_H_INCLUDED 2 | #define NIMG_RASTERISER_H_INCLUDED 3 | 4 | #include "pixmap.h" 5 | 6 | namespace nimg { 7 | namespace painter { 8 | 9 | typedef struct { 10 | float x, y, z; 11 | } vec3_t; 12 | 13 | typedef struct { 14 | vec3_t v; 15 | ColorRGBAf c; 16 | } vertex_t; 17 | 18 | typedef struct { 19 | vertex_t a, b, c; 20 | } triangle_t; 21 | 22 | typedef struct { 23 | vertex_t a, b; 24 | } edge_t; 25 | 26 | void draw_line(Pixmap &map, 27 | ColorRGBAf &c0, float x0, float y0, 28 | ColorRGBAf &c1, float x1, float y1); 29 | 30 | void draw_triangle(Pixmap &map, triangle_t tri); 31 | void fill_triangle(Pixmap &map, triangle_t tri); 32 | 33 | } /* namespace painter */ 34 | } /* namespace nimg */ 35 | 36 | #endif /* NIMG_RASTERISER_H_INCLUDED */ 37 | -------------------------------------------------------------------------------- /src/xtcore/material/emissive.cc: -------------------------------------------------------------------------------- 1 | #include "macro.h" 2 | #include "emissive.h" 3 | 4 | namespace xtcore { 5 | namespace asset { 6 | namespace material { 7 | 8 | bool Emissive::shade( 9 | ColorRGBf &intensity 10 | , const ICamera *camera 11 | , const emitter_t *emitter 12 | , const hit_record_t &hit_record) const 13 | { 14 | UNUSED(camera) 15 | UNUSED(emitter) 16 | intensity = get_sample(MAT_SAMPLER_EMISSIVE , hit_record.texcoord); 17 | return false; 18 | } 19 | 20 | bool Emissive::sample_path( 21 | hit_result_t &hit_result 22 | , const hit_record_t &hit_record 23 | ) const 24 | { 25 | hit_result.intensity = get_sample("emissive", hit_record.texcoord); 26 | return false; 27 | } 28 | 29 | } /* namespace material */ 30 | } /* namespace asset */ 31 | } /* namespace xtcore */ 32 | -------------------------------------------------------------------------------- /src/xtcore/integrator/ao/integrator.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_INTEGRATOR_AO_H_INCLUDED 2 | #define XTCORE_INTEGRATOR_AO_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using nimg::ColorRGBf; 17 | using nimg::Pixmap; 18 | 19 | namespace xtcore { 20 | namespace integrator { 21 | namespace ao { 22 | 23 | class Integrator : public xtcore::render::IIntegrator 24 | { 25 | public: 26 | virtual void render_tile(xtcore::render::tile_t *tile); 27 | }; 28 | 29 | } /* namespace ao */ 30 | } /* namespace integrator */ 31 | } /* namespace xtcore */ 32 | 33 | #endif /* XTCORE_INTEGRATOR_AO_H_INCLUDED */ 34 | -------------------------------------------------------------------------------- /src/xtcore/sampler_cubemap.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_SAMPLER_CUBEMAP_H_INCLUDED 2 | #define XTCORE_SAMPLER_CUBEMAP_H_INCLUDED 3 | 4 | #include 5 | #include "sampler_tex.h" 6 | #include "sampler.h" 7 | 8 | namespace xtcore { 9 | namespace sampler { 10 | 11 | enum CUBEMAP_FACE 12 | { 13 | CUBEMAP_FACE_LEFT 14 | , CUBEMAP_FACE_RIGHT 15 | , CUBEMAP_FACE_TOP 16 | , CUBEMAP_FACE_BOTTOM 17 | , CUBEMAP_FACE_FRONT 18 | , CUBEMAP_FACE_BACK 19 | }; 20 | 21 | class Cubemap : public ISampler 22 | { 23 | public: 24 | int load(const char *file, CUBEMAP_FACE face); 25 | 26 | nimg::ColorRGBf sample(const nmath::Vector3f &tc) const; 27 | 28 | private: 29 | Texture2D m_textures[6]; // The 6 faces for the cubemap 30 | }; 31 | 32 | } /* namespace sampler */ 33 | } /* namespace xtcore */ 34 | 35 | #endif /* XTCORE_SAMPLER_CUBEMAP_H_INCLUDED */ 36 | -------------------------------------------------------------------------------- /src/xtcore/integrator/uv/integrator.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_INTEGRATOR_UV_H_INCLUDED 2 | #define XTCORE_INTEGRATOR_UV_H_INCLUDED 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | using nimg::ColorRGBf; 18 | using nimg::Pixmap; 19 | 20 | namespace xtcore { 21 | namespace integrator { 22 | namespace uv { 23 | 24 | class Integrator : public xtcore::render::IIntegrator 25 | { 26 | public: 27 | virtual void render_tile(xtcore::render::tile_t *tile); 28 | }; 29 | 30 | } /* namespace uv */ 31 | } /* namespace integrator */ 32 | } /* namespace xtcore */ 33 | 34 | #endif /* XTCORE_INTEGRATOR_UV_H_INCLUDED */ 35 | -------------------------------------------------------------------------------- /lib/nimg/checkerboard.cc: -------------------------------------------------------------------------------- 1 | #include "color.h" 2 | #include "checkerboard.h" 3 | 4 | namespace nimg { 5 | namespace generator { 6 | 7 | int checkerboard(Pixmap &map, const unsigned int width, const unsigned int height, 8 | ColorRGBAf &a, ColorRGBAf &b) 9 | { 10 | if (!width || !height) return 1; 11 | 12 | if (map.init(width, height)) return 2; 13 | 14 | for (unsigned int j = 0; j < map.height(); ++j) { 15 | for (unsigned int i = 0; i < map.width(); ++i) { 16 | 17 | bool y = (j < map.height() / 2); 18 | bool x = (i < map.width() / 2); 19 | 20 | ColorRGBAf val = (x ^ y ? a : b); 21 | ColorRGBAf &pixel = map.pixel(i, j); 22 | 23 | pixel.r(val.r()); 24 | pixel.g(val.g()); 25 | pixel.b(val.b()); 26 | pixel.a(val.r()); 27 | } 28 | } 29 | 30 | return 0; 31 | } 32 | 33 | } /* namespace generator */ 34 | } /* namespace nimg */ 35 | -------------------------------------------------------------------------------- /src/xtcore/integrator/normal/integrator.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_INTEGRATOR_NORMAL_H_INCLUDED 2 | #define XTCORE_INTEGRATOR_NORMAL_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using nimg::ColorRGBf; 17 | using nimg::Pixmap; 18 | 19 | namespace xtcore { 20 | namespace integrator { 21 | namespace normal { 22 | 23 | class Integrator : public xtcore::render::IIntegrator 24 | { 25 | public: 26 | virtual void render_tile(xtcore::render::tile_t *tile); 27 | }; 28 | 29 | } /* namespace normal */ 30 | } /* namespace integrator */ 31 | } /* namespace xtcore */ 32 | 33 | #endif /* XTCORE_INTEGRATOR_NORMAL_H_INCLUDED */ 34 | -------------------------------------------------------------------------------- /src/xtcore/extrude.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "extrude.h" 5 | 6 | namespace xtcore { 7 | namespace auxiliary { 8 | 9 | void extrude(nmesh::object_t *obj, xtcore::sampler::Cubemap *cb) 10 | { 11 | if (!obj || !cb) return; 12 | 13 | for (size_t i = 0; i < obj->attributes.v.size(); i+=3) { 14 | nmath::Vector3f pos(obj->attributes.v[i ] 15 | , obj->attributes.v[i+1] 16 | , obj->attributes.v[i+2]); 17 | 18 | nmath::Vector3f dir = pos.normalized(); 19 | nimg::ColorRGBf c = cb->sample(pos); 20 | nmath::Vector3f p = 10. * dir * c.r(); 21 | 22 | obj->attributes.v[i ] = p.x; 23 | obj->attributes.v[i+1] = p.y; 24 | obj->attributes.v[i+2] = p.z; 25 | } 26 | } 27 | 28 | } /* namespace auxiliary */ 29 | } /* namespace auxiliary */ 30 | -------------------------------------------------------------------------------- /src/xtcore/aa_sample.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_AA_SAMPLE_H_INCLUDED 2 | #define XTCORE_AA_SAMPLE_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace xtcore { 9 | namespace antialiasing { 10 | 11 | struct sample_rgba_t 12 | { 13 | nmath::scalar_t weight; // Contribution 14 | nmath::Vector2f pixel; // Pixel indices 15 | nmath::Vector2f coords; // Sample coordinates 16 | 17 | size_t priority; // Layer 18 | nimg::ColorRGBAf value; // Rendered value 19 | }; 20 | 21 | struct sample_set_t { 22 | 23 | void push(sample_rgba_t &s); 24 | void pop (sample_rgba_t &s); 25 | void clear(); 26 | size_t count(); 27 | 28 | private: 29 | std::queue m_samples; 30 | }; 31 | 32 | } /* namespace antialiasing */ 33 | } /* namespace xtcore */ 34 | 35 | #endif /* XTCORE_AA_SAMPLE_H_INCLUDED */ 36 | -------------------------------------------------------------------------------- /src/xtcore/math/plane.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_PLANE_H_INCLUDED 2 | #define XTCORE_PLANE_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include "surface.h" 7 | #include "ray.h" 8 | 9 | #define XTCORE_PLANE_DEFAULT_DISTANCE 1.0 10 | 11 | using nmath::scalar_t; 12 | using nmath::Vector3f; 13 | 14 | namespace xtcore { 15 | namespace surface { 16 | 17 | class Plane: public xtcore::asset::ISurface 18 | { 19 | public: 20 | Plane(); 21 | 22 | bool intersection(const Ray &ray, hit_record_t* i_hit_record) const; 23 | nmath::scalar_t distance(nmath::Vector3f p) const; 24 | void calc_aabb(); 25 | 26 | Vector3f point_sample() const; 27 | Ray ray_sample() const; 28 | 29 | Vector3f normal; 30 | scalar_t offset; 31 | }; 32 | 33 | } /* namespace surface */ 34 | } /* namespace xtcore */ 35 | 36 | #endif /* XTCORE_PLANE_H_INCLUDED */ 37 | -------------------------------------------------------------------------------- /src/xtcore/integrator/emission/integrator.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_INTEGRATOR_EMISSION_H_INCLUDED 2 | #define XTCORE_INTEGRATOR_EMISSION_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using nimg::ColorRGBf; 17 | using nimg::Pixmap; 18 | 19 | namespace xtcore { 20 | namespace integrator { 21 | namespace emission { 22 | 23 | class Integrator : public xtcore::render::IIntegrator 24 | { 25 | public: 26 | virtual void render_tile(xtcore::render::tile_t *tile); 27 | }; 28 | 29 | } /* namespace emission */ 30 | } /* namespace integrator */ 31 | } /* namespace xtcore */ 32 | 33 | #endif /* XTCORE_INTEGRATOR_EMISSION_H_INCLUDED */ 34 | -------------------------------------------------------------------------------- /lib/nmesh/buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef BUFFER_HPP_INCLUDED 2 | #define BUFFER_HPP_INCLUDED 3 | 4 | namespace nmesh { 5 | 6 | template 7 | class Buffer 8 | { 9 | public: 10 | Buffer(); 11 | Buffer(const Buffer &rhs); 12 | Buffer &operator =(const Buffer &rhs); 13 | virtual ~Buffer(); 14 | 15 | int init(const unsigned int count); 16 | void clear(); 17 | 18 | unsigned int count() const; 19 | 20 | T& operator[] (const unsigned int idx); 21 | const T& operator[] (const unsigned int idx) const; 22 | 23 | private: 24 | void release(); 25 | 26 | unsigned int m_count; 27 | // The following is a default value that will be used if 28 | // an index based access request is made on an uninitialized 29 | // buffer. 30 | T m_single_object; 31 | T *m_data; 32 | }; 33 | 34 | } /* namespace nmesh */ 35 | 36 | #include "buffer.tml" 37 | 38 | #endif /* BUFFER_HPP_INCLUDED */ 39 | -------------------------------------------------------------------------------- /src/xtcore/sampler_tex.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_SAMPLER_TEX_H_INCLUDED 2 | #define XTCORE_SAMPLER_TEX_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | #include "sampler.h" 8 | 9 | using nmath::Vector3f; 10 | using nimg::ColorRGBf; 11 | using nimg::Pixmap; 12 | 13 | namespace xtcore { 14 | namespace sampler { 15 | 16 | class Texture2D : public ISampler 17 | { 18 | public: 19 | int load(const char *file); 20 | int load(const Pixmap &map); 21 | 22 | void set_filtering(FILTERING filtering); 23 | 24 | virtual ColorRGBf sample(const Vector3f &tc) const; 25 | 26 | void flip_horizontal(); 27 | void flip_vertical(); 28 | 29 | Texture2D(); 30 | virtual ~Texture2D(); 31 | 32 | private: 33 | FILTERING m_filtering; 34 | Pixmap m_map; 35 | }; 36 | 37 | } /* namespace sampler */ 38 | } /* namespace xtcore */ 39 | 40 | #endif /* XTCORE_SAMPLER_TEX_H_INCLUDED */ 41 | -------------------------------------------------------------------------------- /src/xtcore/bvh.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_BVH_H_INCLUDED 2 | #define XTCORE_BVH_H_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | namespace xtcore { 8 | namespace spatial { 9 | namespace bvh { 10 | /* 11 | using nmath::Vector3f; 12 | using nmesh::object_t; 13 | 14 | typedef struct { 15 | Vector3f aabb_min; 16 | Vector3f aabb_max; 17 | 18 | uint child_left; 19 | uint prim_first; 20 | uint prim_count; 21 | 22 | bool is_leaf(); 23 | } node_t; 24 | 25 | template 26 | typedef struct { 27 | node_t *nodes; 28 | uint node_idx_root; 29 | uint nodes_used; 30 | 31 | std::vector data; 32 | std::vector indices; 33 | } bvh_t; 34 | 35 | void build(bvh_t &bvh, object_t &object); 36 | 37 | void convert(ISurface) 38 | */ 39 | } /* namespace bvh */ 40 | } /* namespace spatial */ 41 | } /* namespace xtcore */ 42 | 43 | #endif /* XTCORE_BVH_H_INCLUDED */ 44 | 45 | -------------------------------------------------------------------------------- /ext/nanosvg/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-14 Mikko Mononen memon@inside.org 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | 19 | -------------------------------------------------------------------------------- /lib/nimg/buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef BUFFER_H_INCLUDED 2 | #define BUFFER_H_INCLUDED 3 | 4 | #include 5 | 6 | namespace nimg { 7 | namespace util { 8 | 9 | template 10 | class Buffer 11 | { 12 | public: 13 | Buffer(); 14 | Buffer(const Buffer &rhs); 15 | Buffer &operator =(const Buffer &rhs); 16 | virtual ~Buffer(); 17 | 18 | int init(size_t count); 19 | void clear(); 20 | 21 | size_t count() const; 22 | 23 | T& operator[] (size_t idx); 24 | const T& operator[] (size_t idx) const; 25 | 26 | private: 27 | void release(); 28 | 29 | size_t m_count; 30 | // The following is a default value that will be used if 31 | // an index based access request is made on an uninitialized 32 | // buffer. 33 | T m_single_object; 34 | T *m_data; 35 | }; 36 | 37 | } /* namespace util */ 38 | } /* namespace nimg */ 39 | 40 | #include "buffer.tml" 41 | 42 | #endif /* BUFFER_H_INCLUDED */ 43 | -------------------------------------------------------------------------------- /src/xtcore/integrator/pathtracer/integrator.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_INTEGRATOR_PATHTRACER_H_INCLUDED 2 | #define XTCORE_INTEGRATOR_PATHTRACER_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using nimg::ColorRGBf; 15 | using nimg::Pixmap; 16 | 17 | namespace xtcore { 18 | namespace integrator { 19 | namespace pathtracer { 20 | 21 | class Integrator : public xtcore::render::IIntegrator 22 | { 23 | public: 24 | virtual void render_tile(xtcore::render::tile_t *tile); 25 | nimg::ColorRGBf eval(size_t depth, hit_result_t &in); 26 | }; 27 | 28 | } /* namespace pathtracer */ 29 | } /* namespace integrator */ 30 | } /* namespace xtcore */ 31 | 32 | #endif /* XTCORE_INTEGRATOR_PATHTRACER_H_INCLUDED */ 33 | -------------------------------------------------------------------------------- /src/xtcore/math/sphere.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_SPHERE_H_INCLUDED 2 | #define XTCORE_SPHERE_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include "surface.h" 7 | #include "ray.h" 8 | 9 | using nmath::Vector3f; 10 | 11 | namespace xtcore { 12 | namespace surface { 13 | 14 | #define XTCORE_SPHERE_DEFAULT_RADIUS 1.0 15 | 16 | class Sphere: public xtcore::asset::ISurface 17 | { 18 | public: 19 | Sphere(); 20 | Sphere(const Vector3f &org, scalar_t rad); 21 | 22 | bool intersection(const Ray &ray, hit_record_t* i_hit_record) const; 23 | nmath::scalar_t distance(nmath::Vector3f p) const; 24 | void calc_aabb(); 25 | 26 | Vector3f point_sample() const; 27 | Ray ray_sample() const; 28 | 29 | Vector3f origin; 30 | scalar_t radius; 31 | }; 32 | 33 | } /* namespace surface */ 34 | } /* namespace xtcore */ 35 | 36 | #endif /* XTCORE_SPHERE_H_INCLUDED */ 37 | -------------------------------------------------------------------------------- /src/xtcore/integrator.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_INTEGRATOR_H_INCLUDED 2 | #define XTCORE_INTEGRATOR_H_INCLUDED 3 | 4 | #include "tile.h" 5 | #include "context.h" 6 | 7 | namespace xtcore { 8 | namespace render { 9 | 10 | class IIntegrator 11 | { 12 | public: 13 | IIntegrator(); 14 | virtual ~IIntegrator(); 15 | 16 | void setup(context_t &context); 17 | void render(); 18 | 19 | virtual void setup_auxiliary(); 20 | virtual void clean_auxiliary(); 21 | virtual void render_tile(tile_t *tile) = 0; 22 | 23 | xtcore::render::context_t *ctx; 24 | }; 25 | 26 | } /* namespace render */ 27 | } /* namespace xtcore */ 28 | 29 | #include "integrator/stencil/integrator.h" 30 | #include "integrator/depth/integrator.h" 31 | #include "integrator/normal/integrator.h" 32 | #include "integrator/uv/integrator.h" 33 | #include "integrator/emission/integrator.h" 34 | #include "integrator/pathtracer/integrator.h" 35 | #include "integrator/ao/integrator.h" 36 | 37 | #endif /* XTCORE_INTEGRATOR_H_INCLUDED */ 38 | -------------------------------------------------------------------------------- /src/xtcore/material/phong.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_MAT_PHONG_H_INCLUDED 2 | #define XTCORE_MAT_PHONG_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include "math/hitrecord.h" 7 | #include "material.h" 8 | 9 | using nmath::Vector3f; 10 | using nimg::ColorRGBf; 11 | using xtcore::asset::ICamera; 12 | 13 | namespace xtcore { 14 | namespace asset { 15 | namespace material { 16 | 17 | class Phong : public xtcore::asset::IMaterial 18 | { 19 | public: 20 | virtual bool shade( 21 | ColorRGBf &intensity 22 | , const ICamera *camera 23 | , const emitter_t *emitter 24 | , const hit_record_t &hit_record) const; 25 | 26 | virtual bool sample_path( 27 | hit_result_t &hit_result 28 | , const hit_record_t &hit_record 29 | ) const; 30 | }; 31 | 32 | } /* namespace material */ 33 | } /* namespace asset */ 34 | } /* namespace xtcore */ 35 | 36 | #endif /* XTCORE_MAT_PHONG_H_INCLUDED */ 37 | -------------------------------------------------------------------------------- /src/xtcore/math/triangle.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_TRIANGLE_H_INCLUDED 2 | #define XTCORE_TRIANGLE_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | #include "surface.h" 8 | #include "ray.h" 9 | 10 | namespace xtcore { 11 | namespace surface { 12 | 13 | class Triangle: public xtcore::asset::ISurface 14 | { 15 | public: 16 | Triangle(); 17 | 18 | bool intersection(const Ray &ray, hit_record_t* i_hit_record) const; 19 | nmath::scalar_t distance(nmath::Vector3f p) const; 20 | void calc_aabb(); 21 | Vector3f calc_normal() const; 22 | Vector3f calc_barycentric(const Vector3f &p) const; 23 | 24 | Vector3f point_sample() const; 25 | Ray ray_sample() const; 26 | 27 | Vector3f v[3]; // position 28 | Vector3f n[3]; // normal 29 | Vector2f tc[3]; // texcoords 30 | }; 31 | 32 | } /* namespace surface */ 33 | } /* namespace xtcore */ 34 | 35 | #endif /* XTCORE_TRIANGLE_H_INCLUDED */ 36 | -------------------------------------------------------------------------------- /src/xtcore/material/lambert.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_MAT_LAMBERT_H_INCLUDED 2 | #define XTCORE_MAT_LAMBERT_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include "math/hitrecord.h" 7 | #include "material.h" 8 | 9 | using nmath::Vector3f; 10 | using nimg::ColorRGBf; 11 | using xtcore::asset::ICamera; 12 | 13 | namespace xtcore { 14 | namespace asset { 15 | namespace material { 16 | 17 | class Lambert : public xtcore::asset::IMaterial 18 | { 19 | public: 20 | virtual bool shade( 21 | ColorRGBf &intensity 22 | , const ICamera *camera 23 | , const emitter_t *emitter 24 | , const hit_record_t &hit_record) const; 25 | 26 | virtual bool sample_path( 27 | hit_result_t &hit_result 28 | , const hit_record_t &hit_record 29 | ) const; 30 | }; 31 | 32 | } /* namespace material */ 33 | } /* namespace asset */ 34 | } /* namespace xtcore */ 35 | 36 | #endif /* XTCORE_MAT_LAMBERT_H_INCLUDED */ 37 | -------------------------------------------------------------------------------- /src/xtcore/math/hitrecord.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_HITRECORD_H_INCLUDED 2 | #define XTCORE_HITRECORD_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "ray.h" 9 | 10 | #define HASH_UINT32 uint32_t 11 | #define HASH_UINT64 uint64_t 12 | #define HASH_ID HASH_UINT64 13 | 14 | using nmath::scalar_t; 15 | using nmath::Vector3f; 16 | using nimg::ColorRGBf; 17 | 18 | namespace xtcore { 19 | 20 | struct hit_result_t 21 | { 22 | scalar_t ior; // Index of refraction 23 | ColorRGBf intensity; // Light attenuation 24 | Ray ray; 25 | }; 26 | 27 | struct hit_record_t 28 | { 29 | hit_record_t(); 30 | 31 | Vector3f normal; 32 | Vector3f point; 33 | Vector3f texcoord; 34 | Vector3f incident_direction; 35 | scalar_t t; 36 | scalar_t ior; 37 | HASH_ID id_object; 38 | }; 39 | 40 | } /* namespace xtcore */ 41 | 42 | #endif /* XTCORE_HITRECORD_H_INCLUDED */ 43 | -------------------------------------------------------------------------------- /src/xtcore/material/emissive.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_MAT_EMISSIVE_H_INCLUDED 2 | #define XTCORE_MAT_EMISSIVE_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include "math/hitrecord.h" 7 | #include "material.h" 8 | 9 | using nmath::Vector3f; 10 | using nimg::ColorRGBf; 11 | using xtcore::asset::ICamera; 12 | 13 | namespace xtcore { 14 | namespace asset { 15 | namespace material { 16 | 17 | class Emissive : public xtcore::asset::IMaterial 18 | { 19 | public: 20 | virtual bool shade( 21 | ColorRGBf &intensity 22 | , const ICamera *camera 23 | , const emitter_t *emitter 24 | , const hit_record_t &hit_record) const; 25 | 26 | virtual bool sample_path( 27 | hit_result_t &hit_result 28 | , const hit_record_t &hit_record 29 | ) const; 30 | }; 31 | 32 | } /* namespace material */ 33 | } /* namespace asset */ 34 | } /* namespace xtcore */ 35 | 36 | #endif /* XTCORE_MAT_EMISSIVE_H_INCLUDED */ 37 | -------------------------------------------------------------------------------- /src/xtcore/camera/ods.cc: -------------------------------------------------------------------------------- 1 | #include "ods.h" 2 | 3 | namespace xtcore { 4 | namespace camera { 5 | 6 | ODS::ODS() 7 | : ipd(XT_CAM_DEFAULT_IPD) 8 | {} 9 | 10 | const char* ODS::get_type() const 11 | { 12 | return "Omni-Directional Stereo"; 13 | } 14 | 15 | Ray ODS::get_primary_ray(float x, float y, float width, float height) 16 | { 17 | Ray ray; 18 | float h = height * .5f; 19 | float scale = ipd * .5f * ((y < h) ? -1 : 1); 20 | if (y > h) y = y - h; 21 | 22 | // Calculate theta & phi angles 23 | float theta = (x / width) * 2.f * nmath::PI; 24 | float phi = nmath::PI * .5f - (y / h) * nmath::PI; 25 | 26 | ray.origin = nmath::Vector3f(cos(theta), 0, sin(theta)) * scale + position; 27 | ray.direction = nmath::Vector3f(sin(theta) * cos(phi), sin(phi), -cos(theta) * cos(phi)); 28 | 29 | nmath::Matrix4x4f m; 30 | m.rotate(orientation); 31 | ray.direction.transform(m); 32 | 33 | return ray; 34 | } 35 | 36 | } /* namespace camera */ 37 | } /* namespace xtcore */ 38 | -------------------------------------------------------------------------------- /src/xtcore/material/dielectric.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_MAT_DIELECTRIC_H_INCLUDED 2 | #define XTCORE_MAT_DIELECTRIC_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include "math/hitrecord.h" 7 | #include "material.h" 8 | 9 | using nmath::Vector3f; 10 | using nimg::ColorRGBf; 11 | using xtcore::asset::ICamera; 12 | 13 | namespace xtcore { 14 | namespace asset { 15 | namespace material { 16 | 17 | class Dielectric : public xtcore::asset::IMaterial 18 | { 19 | public: 20 | virtual bool shade( 21 | ColorRGBf &intensity 22 | , const ICamera *camera 23 | , const emitter_t *emitter 24 | , const hit_record_t &hit_record) const; 25 | 26 | virtual bool sample_path( 27 | hit_result_t &hit_result 28 | , const hit_record_t &hit_record 29 | ) const; 30 | }; 31 | 32 | } /* namespace material */ 33 | } /* namespace asset */ 34 | } /* namespace xtcore */ 35 | 36 | #endif /* XTCORE_MAT_DIELECTRIC_H_INCLUDED */ 37 | -------------------------------------------------------------------------------- /lib/nmath/vector.cc: -------------------------------------------------------------------------------- 1 | #include "vector.h" 2 | 3 | #ifdef __cplusplus 4 | 5 | namespace nmath { 6 | 7 | Vector2f::Vector2f(scalar_t aX, scalar_t aY): x(aX), y(aY){} 8 | Vector2f::Vector2f(const Vector2f& v): x(v.x), y(v.y){} 9 | Vector2f::Vector2f(const Vector3f& v): x(v.x), y(v.y){} 10 | Vector2f::Vector2f(const Vector4f& v): x(v.x), y(v.y){} 11 | Vector3f::Vector3f(scalar_t aX, scalar_t aY, scalar_t aZ): x(aX), y(aY), z(aZ){} 12 | Vector3f::Vector3f(const Vector3f& v): x(v.x), y(v.y), z(v.z){} 13 | Vector3f::Vector3f(const Vector2f& v): x(v.x), y(v.y), z(0.0f){} 14 | Vector3f::Vector3f(const Vector4f& v): x(v.x), y(v.y), z(v.z){} 15 | Vector4f::Vector4f(scalar_t aX, scalar_t aY, scalar_t aZ, scalar_t aW): x(aX), y(aY), z(aZ), w(aW){} 16 | Vector4f::Vector4f(const Vector4f& v): x(v.x), y(v.y), z(v.z), w(v.w){} 17 | Vector4f::Vector4f(const Vector2f& v): x(v.x), y(v.y), z(0.0f), w(0.0f){} 18 | Vector4f::Vector4f(const Vector3f& v): x(v.x), y(v.y), z(v.z), w(0.0f){} 19 | 20 | #endif /* __cplusplus */ 21 | 22 | } /* namespace nmath */ 23 | -------------------------------------------------------------------------------- /src/xtcore/material/blinnphong.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_MAT_BLINN_PHONG_H_INCLUDED 2 | #define XTCORE_MAT_BLINN_PHONG_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include "math/hitrecord.h" 7 | #include "material.h" 8 | 9 | using nmath::Vector3f; 10 | using nimg::ColorRGBf; 11 | using xtcore::asset::ICamera; 12 | 13 | namespace xtcore { 14 | namespace asset { 15 | namespace material { 16 | 17 | class BlinnPhong : public xtcore::asset::IMaterial 18 | { 19 | public: 20 | virtual bool shade( 21 | ColorRGBf &intensity 22 | , const ICamera *camera 23 | , const emitter_t *emitter 24 | , const hit_record_t &hit_record) const; 25 | 26 | 27 | virtual bool sample_path( 28 | hit_result_t &hit_result 29 | , const hit_record_t &hit_record 30 | ) const; 31 | }; 32 | 33 | } /* namespace material */ 34 | } /* namespace asset */ 35 | } /* namespace xtcore */ 36 | 37 | #endif /* XTCORE_MAT_BLINN_PHONG_H_INCLUDED */ 38 | -------------------------------------------------------------------------------- /src/xtcore/material/dielectric.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "macro.h" 3 | #include "lambert.h" 4 | 5 | namespace xtcore { 6 | namespace asset { 7 | namespace material { 8 | 9 | bool Dielectric::shade( 10 | ColorRGBf &intensity 11 | , const ICamera *camera 12 | , const emitter_t *emitter 13 | , const hit_record_t &hit_record) const 14 | { 15 | UNUSED(camera) 16 | UNUSED(emitter) 17 | UNUSED(hit_record) 18 | intensity = ColorRGBf(0.f,0.f,0.f); 19 | return true; 20 | } 21 | 22 | bool Dielectric::sample_path( 23 | hit_result_t &hit_result 24 | , const hit_record_t &hit_record 25 | ) const 26 | { 27 | float mat_ior = get_scalar("ior"); 28 | hit_result.ray.origin = hit_record.point + hit_record.normal * EPSILON; 29 | hit_result.ray.direction = hit_record.incident_direction.refracted(hit_record.normal, hit_result.ior, mat_ior); 30 | return true; 31 | } 32 | 33 | } /* namespace material */ 34 | } /* namespace asset */ 35 | } /* namespace xtcore */ 36 | -------------------------------------------------------------------------------- /src/frontend/cli/argdefs.h: -------------------------------------------------------------------------------- 1 | #ifndef XTRACER_ARGDEFS_H_INCLUDED 2 | #define XTRACER_ARGDEFS_H_INCLUDED 3 | 4 | #define XT_SETUP_DEFAULT_MAX_RDEPTH 3 5 | 6 | #define XT_ARG_PREFIX "-" 7 | 8 | #define XT_ARG_RENDERER XT_ARG_PREFIX "renderer" /* Select renderer */ 9 | #define XT_ARG_THREADS XT_ARG_PREFIX "threads" /* Number of threads to use. */ 10 | #define XT_ARG_RESOLUTION XT_ARG_PREFIX "res" /* Framebuffer resolution. */ 11 | #define XT_ARG_MAX_RDEPTH XT_ARG_PREFIX "rdepth" /* Maximum recursion depth. */ 12 | #define XT_ARG_SAMPLES XT_ARG_PREFIX "samples" /* Number of samples for reflections. */ 13 | #define XT_ARG_TILESIZE XT_ARG_PREFIX "tile_size" /* Size of square tile unit to render */ 14 | #define XT_ARG_ANTIALIASING XT_ARG_PREFIX "aa" /* Antialiasing level. */ 15 | #define XT_ARG_ACTIVE_CAMERA XT_ARG_PREFIX "cam" /* Active camera name. */ 16 | #define XT_ARG_OUTDIR XT_ARG_PREFIX "outdir" /* Output directory. */ 17 | #define XT_ARG_MOD XT_ARG_PREFIX "mod" /* Apply a modifier */ 18 | 19 | #endif /* XTRACER_ARGDEFS_H_INCLUDED */ 20 | -------------------------------------------------------------------------------- /src/xtcore/bresenham.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "bresenham.h" 3 | 4 | namespace xtcore { 5 | namespace render { 6 | 7 | void bresenham(int x0, int y0, int x1, int y1, nimg::ColorRGBAf &color, tile_t &tile) 8 | { 9 | bool steep = false; 10 | 11 | if (std::abs(x0-x1) < std::abs(y0-y1)) { 12 | std::swap(x0, y0); 13 | std::swap(x1, y1); 14 | steep = true; 15 | } 16 | 17 | if (x0 > x1) { 18 | std::swap(x0, x1); 19 | std::swap(y0, y1); 20 | } 21 | 22 | int dx = x1-x0; 23 | int dy = y1-y0; 24 | int derror2 = std::abs(dy)*2; 25 | int error2 = 0; 26 | 27 | int y = y0; 28 | 29 | for (int x=x0; x<=x1; ++x) { 30 | if (steep) { 31 | tile.write(y, x, color); 32 | } else { 33 | tile.write(x, y, color); 34 | } 35 | error2 += derror2; 36 | if (error2 > dx) { 37 | y += (y1>y0?1:-1); 38 | error2 -= dx*2; 39 | } 40 | } 41 | } 42 | 43 | } /* namespace render */ 44 | } /* namespace xtcore */ 45 | -------------------------------------------------------------------------------- /src/frontend/gui/fsutil.h: -------------------------------------------------------------------------------- 1 | #ifndef XT_FSUTIL_H_INCLUDED 2 | #define XT_FSUTIL_H_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | namespace util { 8 | namespace filesystem { 9 | 10 | const char PATH_DELIMITER = '/'; 11 | 12 | enum FS_ENTRY_TYPE 13 | { 14 | FS_ENTRY_TYPE_UNKNOWN = 0x01 15 | , FS_ENTRY_TYPE_SPECIAL_DIR_CURRENT = 0x02 16 | , FS_ENTRY_TYPE_SPECIAL_DIR_PARENT = 0x04 17 | , FS_ENTRY_TYPE_DIRECTORY = 0x08 18 | , FS_ENTRY_TYPE_FILE = 0x10 19 | }; 20 | 21 | struct fs_entry_t 22 | { 23 | std::string path; 24 | std::string name; 25 | FS_ENTRY_TYPE type; 26 | }; 27 | 28 | typedef std::vector fsvec; 29 | 30 | void decompose_path(const char *path, std::string &base, std::string &file, const char delim = PATH_DELIMITER); 31 | int ls(fsvec &fsv, const char *path); 32 | bool file_exists(const char *filepath); 33 | bool has_extension(fs_entry_t *entry, const char *extension); 34 | 35 | } /* namespace filesystem */ 36 | } /* namespace util */ 37 | 38 | #endif /* XT_FSUTIL_H_INCLUDED */ 39 | -------------------------------------------------------------------------------- /lib/nimg/pixel.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_PIXEL_H_INCLUDED 2 | #define NIMG_PIXEL_H_INCLUDED 3 | 4 | #include 5 | #include "precision.h" 6 | #include "defs.h" 7 | 8 | namespace nimg { 9 | namespace util { 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif /* __cplusplus */ 14 | 15 | /* 16 | NOTES: 17 | All the functions below operate on a big endian format. 18 | */ 19 | 20 | typedef uint32_t pixel32_t; 21 | 22 | static inline pixel32_t rgba_c_to_pixel32(unsigned char r, unsigned char g, unsigned char b, unsigned char a); 23 | static inline pixel32_t rgba_f_to_pixel32(scalar_t r, scalar_t g, scalar_t b, scalar_t a); 24 | 25 | static inline unsigned char get_pixel32_r(pixel32_t c); 26 | static inline unsigned char get_pixel32_g(pixel32_t c); 27 | static inline unsigned char get_pixel32_b(pixel32_t c); 28 | static inline unsigned char get_pixel32_a(pixel32_t c); 29 | 30 | #ifdef __cplusplus 31 | } /* extern "C" */ 32 | #endif /* __cplusplus */ 33 | 34 | } /* namespace util */ 35 | } /* namespace nimg */ 36 | 37 | #include "pixel.inl" 38 | 39 | #endif /* XTRACER_PIXEL_H_INCLUDED */ 40 | -------------------------------------------------------------------------------- /src/xtcore/camera/perspective.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_PERSPECTIVE_H_INCLUDED 2 | #define XTCORE_PERSPECTIVE_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include "math/ray.h" 7 | #include "camera.h" 8 | 9 | #define XT_CAM_DEFAULT_FOV M_PI / 4 10 | #define XT_CAM_DEFAULT_PROJECTION PERSPECTIVE_PROJECTION_PERSPECTIVE 11 | #define XT_CAM_DEFAULT_EYE PERSPECTIVE_EYE_MONO 12 | 13 | using nmath::Vector3f; 14 | using nmath::Matrix4x4f; 15 | 16 | namespace xtcore { 17 | namespace camera { 18 | 19 | class Perspective : public xtcore::asset::ICamera 20 | { 21 | public: 22 | Vector3f target; 23 | Vector3f up; 24 | float fov; 25 | float aperture; 26 | float flength; 27 | 28 | Perspective(); 29 | const char* get_type() const; 30 | 31 | void calculate_transform(Matrix4x4f &mat); 32 | Ray get_primary_ray(float x, float y, float width, float height); 33 | 34 | private: 35 | Matrix4x4f m_transform; 36 | }; 37 | 38 | } /* namespace camera */ 39 | } /* namespace xtcore */ 40 | 41 | #endif /* XTCORE_PERSPECTIVE_H_INCLUDED */ 42 | -------------------------------------------------------------------------------- /lib/nplatform/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUX_TIMER_HPP_INCLUDED 2 | #define FLUX_TIMER_HPP_INCLUDED 3 | 4 | #if defined(_WIN32) 5 | #define WIN64_LEAN_AND_MEAN 6 | #define WIN32_LEAN_AND_MEAN 7 | #define NOMINMAX 8 | #include 9 | #elif defined(__linux) || defined(__unix) || defined (__posix) 10 | #include 11 | #else 12 | #error "Unspecified or unsupported platform." 13 | #endif /* _WIN32 */ 14 | 15 | class Timer 16 | { 17 | public: 18 | Timer(); 19 | ~Timer(); 20 | 21 | void start(); 22 | void resume(); 23 | void stop(); 24 | 25 | double get_time_in_sec(); 26 | double get_time_in_mlsec(); 27 | double get_time_in_mcsec(); 28 | 29 | private: 30 | double m_stime; 31 | double m_etime; 32 | bool m_stopped; 33 | 34 | #if defined(_WIN32) 35 | LARGE_INTEGER m_freq; 36 | LARGE_INTEGER m_scount; 37 | LARGE_INTEGER m_ecount; 38 | 39 | #elif defined(__linux) || defined(__unix) || defined (__posix) 40 | timeval m_scount; 41 | timeval m_ecount; 42 | 43 | #endif /* _WIN32 */ 44 | }; 45 | 46 | #endif /* FLUX_TIMER_HPP_INCLUDED */ 47 | -------------------------------------------------------------------------------- /lib/nimg/conversion.c: -------------------------------------------------------------------------------- 1 | #include "conversion.h" 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | // ref: http://www.equasys.de/colorconversion.html 8 | 9 | void rgb_to_ycbcr(float r, float g, float b, float *y, float *cb, float *cr) 10 | { 11 | float k0 = 16./255.; 12 | float k1 = 128./255.; 13 | *y = (r * 0.257 + g * 0.504 + b * 0.098) + k0; // Luminance 14 | *cb = (r * -0.148 + g * -0.291 + b * 0.439) + k1; // Chrominance Red 15 | *cr = (r * 0.439 + g * -0.368 + b * -0.071) + k1; // Chrominance Blue 16 | } 17 | 18 | void rgb_to_ycgco(float r, float g, float b, float *y, float *cg, float *co) 19 | { 20 | *y = .25 * r + .50 * g + .25 * b; // Luminance 21 | *cg = -.25 * r + .50 * g - .25 * b; // Chrominance Green 22 | *co = .50 * r - .50 * g; // Chrominance Orange 23 | } 24 | 25 | void rgb_to_yuv(float r, float g, float b, float *y, float *u, float *v) 26 | { 27 | *y = .299 * r + .587 * g + .114 * b; // Luma 28 | *u =-.147 * r - .289 * g + .436 * b; // Delta Blue 29 | *v = .615 * r - .515 * g - .100 * b; // Delta Red 30 | } 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /src/xtcore/timeutil.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "timeutil.h" 3 | 4 | void convert_mlseconds(double mlsecs 5 | , size_t &days 6 | , size_t &hours 7 | , size_t &mins 8 | , float &secs) 9 | { 10 | unsigned int total_msec = (unsigned int)(mlsecs); 11 | unsigned int total_secs = (unsigned int)(mlsecs / 1000.f); 12 | 13 | days = (unsigned int)(total_secs) / 86400; 14 | hours = (unsigned int)(total_secs / 3600) - (days * 24); 15 | mins = (unsigned int)(total_secs / 60) - (days * 1440) - (hours * 60); 16 | secs = (float)(total_secs % 60) + (((float)total_msec / 1000.f) - (float)total_secs); 17 | } 18 | 19 | void print_time_breakdown(std::string &str, double mlsecs) 20 | { 21 | size_t d = 0 // days 22 | , h = 0 // hours 23 | , m = 0; // minutes 24 | float s = 0; // seconds 25 | 26 | convert_mlseconds(mlsecs, d, h, m, s); 27 | 28 | std::stringstream ss; 29 | 30 | if (d > 0) ss << d << " days "; 31 | if (h > 0) ss << h << " hours "; 32 | if (m > 0) ss << m << " minutes "; 33 | if (s > 0) ss << s << " seconds "; 34 | 35 | str = ss.str(); 36 | } 37 | -------------------------------------------------------------------------------- /lib/nmath/matrix.inl: -------------------------------------------------------------------------------- 1 | #ifndef NMATH_MATRIX_INL_INCLUDED 2 | #define NMATH_MATRIX_INL_INCLUDED 3 | 4 | #ifndef NMATH_MATRIX_H_INCLUDED 5 | #error "matrix.h must be included before matrix.inl" 6 | #endif /* NMATH_MATRIX_H_INCLUDED */ 7 | 8 | #include 9 | 10 | namespace nmath { 11 | 12 | inline scalar_t *Matrix3x3f::operator [](int index) 13 | { 14 | return data[index < 9 ? index : 8]; 15 | } 16 | 17 | inline const scalar_t *Matrix3x3f::operator [](int index) const 18 | { 19 | return data[index < 9 ? index : 8]; 20 | } 21 | 22 | inline void Matrix3x3f::reset_identity() 23 | { 24 | memcpy(data, identity.data, 9 * sizeof(scalar_t)); 25 | } 26 | 27 | inline scalar_t *Matrix4x4f::operator [](int index) 28 | { 29 | return data[index < 16 ? index : 15]; 30 | } 31 | 32 | inline const scalar_t *Matrix4x4f::operator [](int index) const 33 | { 34 | return data[index < 16 ? index : 15]; 35 | } 36 | 37 | inline void Matrix4x4f::reset_identity() 38 | { 39 | memcpy(data, identity.data, 16 * sizeof(scalar_t)); 40 | } 41 | 42 | } /* namespace nmath */ 43 | 44 | #endif /* NMATH_MATRIX_INL_INCLUDED */ 45 | -------------------------------------------------------------------------------- /ext/cpp-httplib/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 yhirose 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /lib/nimg/ppm.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_PPM_H_INCLUDED 2 | #define NIMG_PPM_H_INCLUDED 3 | 4 | #include "pixmap.h" 5 | 6 | namespace nimg { 7 | namespace io { 8 | namespace load { 9 | // RESTRICTIONS: 10 | // Only images with a pixel component maximum value of 11 | // 255 are supported. This is the most common format. 12 | // 13 | // RETURN CODES: 14 | // 0. Everything went well. 15 | // 1. Filename is NULL. 16 | // 2. File I/O error. 17 | // 3. Invalid format. 18 | // 4. Corrupted file. 19 | // 5. Failed to initialize the Image. 20 | int ppm_raw(const char *filename, Pixmap &map); 21 | 22 | } /* namespace load */ 23 | 24 | namespace save { 25 | // RESTRICTIONS: 26 | // Only images with a pixel component maximum value of 27 | // 255 are supported. This is the most common format. 28 | // 29 | // RETURN CODES: 30 | // 0. Everything went well. 31 | // 1. Filename is NULL. 32 | // 2. File I/O error. 33 | // 3. Nothing to export. Width or height is 0. 34 | int ppm_raw(const char *filename, const Pixmap &map); 35 | 36 | } /* namespace save */ 37 | } /* namespace io */ 38 | } /* namespace nimg */ 39 | 40 | #endif /* NIMG_PPM_H_INCLUDED */ 41 | -------------------------------------------------------------------------------- /src/xtcore/mesh.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_MESH_H_INCLUDED 2 | #define XTCORE_MESH_H_INCLUDED 3 | 4 | #include 5 | #include "math/surface.h" 6 | #include "math/triangle.h" 7 | #include "math/ray.h" 8 | #include "octree.h" 9 | #include "structs.h" 10 | 11 | #define LIMITS_MAX_ITEMS_PER_NODE 10 12 | #define LIMITS_MAX_DEPTH 10 13 | 14 | using nmath::Vector3f; 15 | using nmesh::shape_t; 16 | using nmesh::attrib_t; 17 | using nmesh::object_t; 18 | 19 | namespace xtcore { 20 | namespace surface { 21 | 22 | class Mesh: public xtcore::asset::ISurface 23 | { 24 | public: 25 | Mesh(); 26 | ~Mesh(); 27 | 28 | bool intersection(const Ray &ray, hit_record_t *i_hit_record) const; 29 | nmath::scalar_t distance(nmath::Vector3f p) const; 30 | void calc_aabb(); 31 | void build_octree(shape_t &shape, attrib_t &attributes); 32 | void build_octree(object_t &object); 33 | 34 | Vector3f point_sample() const; 35 | Ray ray_sample() const; 36 | 37 | private: 38 | Octree m_octree; 39 | }; 40 | 41 | } /* namespace surface */ 42 | } /* namespace xtcore */ 43 | 44 | #endif /* XTCORE_MESH_H_INCLUDED */ 45 | -------------------------------------------------------------------------------- /ext/imgui/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2015 Omar Cornut and ImGui contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ext/tinyobj/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2012-2016 Syoyo Fujita and many contributors. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /lib/nimg/transform.cc: -------------------------------------------------------------------------------- 1 | #include "transform.h" 2 | 3 | namespace nimg { 4 | namespace transform { 5 | 6 | bool flip_horizontal(Pixmap *map) { 7 | if (!map) return false; 8 | 9 | size_t w = map->width(); 10 | size_t h = map->height(); 11 | 12 | for (size_t j = 0; j < h; ++j) { 13 | for (size_t i = 0; i < w / 2; ++i) { 14 | size_t k = w - 1 - i; 15 | ColorRGBAf val_a = map->pixel_ro(i, j); 16 | ColorRGBAf val_b = map->pixel_ro(k, j); 17 | map->pixel(i,j) = val_b; 18 | map->pixel(k,j) = val_a; 19 | } 20 | } 21 | 22 | return true; 23 | } 24 | 25 | bool flip_vertical(Pixmap *map) { 26 | if (!map) return false; 27 | 28 | size_t w = map->width(); 29 | size_t h = map->height(); 30 | 31 | for (size_t j = 0; j < h / 2; ++j) { 32 | for (size_t i = 0; i < w; ++i) { 33 | size_t k = h - 1 - j; 34 | ColorRGBAf val_a = map->pixel_ro(i, j); 35 | ColorRGBAf val_b = map->pixel_ro(i, k); 36 | map->pixel(i,j) = val_b; 37 | map->pixel(i,k) = val_a; 38 | } 39 | } 40 | return true; 41 | } 42 | 43 | } /* namespace transform */ 44 | } /* namespace nimg */ 45 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | compiler: clang 3 | 4 | os: 5 | - linux 6 | 7 | before_install: 8 | - if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get update; fi 9 | - if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install -y --no-install-recommends cmake libglew-dev libxrandr-dev libxi-dev libxxf86vm-dev libasound-dev; fi 10 | - if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install -qq g++-4.8 gcc-4.8 libglew-dev libfreetype6-dev libharfbuzz-dev libxmu-dev libxi-dev libxrandr-dev libxinerama-dev libxcursor-dev; fi 11 | - if [ $TRAVIS_OS_NAME == linux ]; then wget -O glfw-3.2.1.zip https://github.com/glfw/glfw/archive/3.2.1.zip; fi 12 | - if [ $TRAVIS_OS_NAME == linux ]; then unzip glfw-3.2.1.zip; fi 13 | - if [ $TRAVIS_OS_NAME == linux ]; then cd glfw-3.2.1; fi 14 | - if [ $TRAVIS_OS_NAME == linux ]; then cmake -DBUILD_SHARED_LIBS=ON -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_DOCS=OFF -DCMAKE_INSTALL_PREFIX=/usr -DLIB_SUFFIX=/x86_64-linux-gnu; fi 15 | - if [ $TRAVIS_OS_NAME == linux ]; then make; fi 16 | - if [ $TRAVIS_OS_NAME == linux ]; then sudo make install; fi 17 | - if [ $TRAVIS_OS_NAME == linux ]; then cd ..; fi 18 | 19 | script: 20 | - ./configure 21 | - make 22 | -------------------------------------------------------------------------------- /scene/3.2.scn: -------------------------------------------------------------------------------- 1 | title = Conference Room 2 | description = Conference Room 3 | version = 0.5 4 | 5 | data = data 6 | model = /geometry/graphics.cs.williams.edu/conference 7 | 8 | camera = { 9 | default = { 10 | type = ods 11 | ipd = 3.2 12 | position = vec3(200,300,-450) 13 | } 14 | 15 | cam0 = { 16 | type = thin-lens 17 | fov = 60 18 | position = vec3(-500,400,100) 19 | target = vec3(0,150,0) 20 | up = vec3(0,1,0) 21 | } 22 | } 23 | 24 | geometry = { 25 | light = { 26 | type = sphere 27 | position = vec3(400,400,0) 28 | radius = 2.5 29 | } 30 | } 31 | 32 | material = { 33 | light = { 34 | type = lambert 35 | 36 | properties = { 37 | samplers = { 38 | emissive = { 39 | type = color 40 | value = col3(1,1,1) 41 | } 42 | } 43 | } 44 | } 45 | } 46 | 47 | object = { 48 | 3dmodel = { 49 | source = /conference.obj 50 | prefix = conf_ 51 | } 52 | 53 | light = { 54 | geometry = light 55 | material = light 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/nplatform/dlloader.c: -------------------------------------------------------------------------------- 1 | #include "dlloader.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #if defined(__linux) || defined(__unix) || defined (__posix) 8 | #include 9 | #include 10 | #elif defined (_WIN32) 11 | #include 12 | #else 13 | #error Target platform is not supported 14 | #endif 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif /* __cplusplus */ 19 | 20 | void* load_library(const char *dlpath) 21 | { 22 | #if defined(_MSC_VER) 23 | return (void*)LoadLibrary(dlpath); 24 | #elif defined(__GNUC__) 25 | return dlopen(dlpath, RTLD_NOW); 26 | #endif 27 | } 28 | 29 | void* load_function(void *lib, const char *fname) 30 | { 31 | #if defined(_MSC_VER) 32 | return (void*)GetProcAddress((HINSTANCE)lib, fname); 33 | #elif defined(__GNUC__) 34 | return dlsym(lib, fname); 35 | #endif 36 | } 37 | 38 | int free_library(void *lib) 39 | { 40 | #if defined(_MSC_VER) 41 | /* FreeLibrary will return non-zero value on success. */ 42 | return FreeLibrary((HINSTANCE)lib) != 0 ? 0 : 1; 43 | #elif defined(__GNUC__) 44 | /* dlclose will return 0 on success. */ 45 | return dlclose(lib); 46 | #endif 47 | } 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif /* __cplusplus */ 52 | -------------------------------------------------------------------------------- /src/xtcore/profiler.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "macro.h" 4 | #include "profiler.h" 5 | 6 | namespace xtcore { 7 | namespace profiler { 8 | 9 | #if FEATURE_IS_INCLUDED(FEATURE_PROFILER) 10 | Remotery* g_rmt; 11 | #endif /* FEATURE_PROFILER */ 12 | 13 | void init() 14 | { 15 | #if FEATURE_IS_INCLUDED(FEATURE_PROFILER) 16 | rmt_CreateGlobalInstance(&g_rmt); 17 | #endif /* FEATURE_PROFILER */ 18 | 19 | } 20 | 21 | void log(const char *message) 22 | { 23 | #if FEATURE_IS_INCLUDED(FEATURE_PROFILER) 24 | if (message) rmt_LogText(message); 25 | #else 26 | UNUSED(message); 27 | #endif /* FEATURE_PROFILER */ 28 | } 29 | 30 | void start(const char *tag) 31 | { 32 | #if FEATURE_IS_INCLUDED(FEATURE_PROFILER) 33 | rmt_BeginCPUSampleDynamic(tag, 0); 34 | #else 35 | UNUSED(tag); 36 | #endif /* FEATURE_PROFILER */ 37 | } 38 | 39 | void end() 40 | { 41 | #if FEATURE_IS_INCLUDED(FEATURE_PROFILER) 42 | rmt_EndCPUSample(); 43 | #endif /* FEATURE_PROFILER */ 44 | } 45 | 46 | void deinit() 47 | { 48 | #if FEATURE_IS_INCLUDED(FEATURE_PROFILER) 49 | rmt_DestroyGlobalInstance(g_rmt); 50 | #endif /* FEATURE_PROFILER */ 51 | } 52 | 53 | } /* namespace profiler */ 54 | } /* namespace xtcore */ 55 | 56 | -------------------------------------------------------------------------------- /src/xtcore/integrator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "integrator.h" 3 | 4 | namespace xtcore { 5 | namespace render { 6 | 7 | IIntegrator::IIntegrator() 8 | : ctx(0) 9 | {} 10 | 11 | IIntegrator::~IIntegrator() 12 | {} 13 | 14 | void IIntegrator::setup(context_t &context) 15 | { 16 | ctx = &context; 17 | } 18 | 19 | void IIntegrator::setup_auxiliary() 20 | { 21 | // Do nothing 22 | } 23 | 24 | void IIntegrator::clean_auxiliary() 25 | { 26 | // Do nothing 27 | } 28 | 29 | void IIntegrator::render() 30 | { 31 | if (!ctx) return; 32 | 33 | xtcore::render::params_t *p = &(ctx->params); 34 | xtcore::asset::ICamera *cam = ctx->scene.get_camera(p->camera); 35 | 36 | if (!cam) return; 37 | 38 | size_t count = ctx->tiles.size(); 39 | 40 | if (p->threads) omp_set_num_threads(p->threads); 41 | 42 | #pragma omp parallel for schedule(dynamic) 43 | for (size_t i = 0; i < count; ++i) { 44 | xtcore::render::tile_t *tile = &(ctx->tiles[i]); 45 | tile->init(); 46 | 47 | xtcore::antialiasing::produce(tile, p->sample_distribution, p->aa, p->samples); 48 | 49 | render_tile(tile); 50 | 51 | tile->submit(); 52 | } 53 | } 54 | 55 | } /* namespace render */ 56 | } /* namespace xtcore */ 57 | -------------------------------------------------------------------------------- /src/frontend/gui/background.frag: -------------------------------------------------------------------------------- 1 | STRINGIFY ( 2 | 3 | uniform vec2 iWindowResolution; 4 | const float iTime = 25.154; 5 | 6 | float hash(vec3 p) { 7 | return fract(sin(dot(p,vec3(127.1,311.7, 321.4)))*43758.5423); 8 | } 9 | 10 | float noise(in vec3 p) 11 | { 12 | p.z += 0.25*(cos(iTime + p.x) + sin(iTime + p.y)); 13 | vec3 i = floor(p); 14 | vec3 f = fract(p); 15 | f *= f * (3.-2.*f); 16 | vec2 c = vec2(0,1); 17 | return mix( 18 | mix(mix(hash(i + c.xxx), hash(i + c.yxx),f.x), 19 | mix(hash(i + c.xyx), hash(i + c.yyx),f.x), 20 | f.y), 21 | mix(mix(hash(i + c.xxy), hash(i + c.yxy),f.x), 22 | mix(hash(i + c.xyy), hash(i + c.yyy),f.x), 23 | f.y), 24 | f.z); 25 | } 26 | 27 | float fbm(in vec3 p) 28 | { 29 | return .5000 * noise(1. * p) 30 | + .2500 * noise(2. * p) 31 | + .1250 * noise(4. * p); 32 | + .0625 * noise(8. * p); 33 | } 34 | 35 | void main() 36 | { 37 | vec2 uv = vec2(iWindowResolution.y - gl_FragCoord.y, gl_FragCoord.x) * 0.0005; 38 | vec3 p = 1.5 * vec3(uv.x,uv.y,uv.x*uv.y); 39 | vec3 col = fbm(p) * mix(vec3(.4,.42,.4), vec3(.4,.4,.55), p); 40 | col += 0.3 * hash(uv.yyx * (cos(iTime) + sin(iTime))) * .1; 41 | col *= smoothstep(0.01, 3.5, iTime); 42 | 43 | gl_FragColor = vec4(col, 1); 44 | } 45 | 46 | ); 47 | -------------------------------------------------------------------------------- /lib/nplatform/fs.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if defined(__linux) || defined(__unix) || defined (__posix) 4 | #include 5 | #elif defined (_WIN32) 6 | #include 7 | #else 8 | #error Target platform is not supported 9 | #endif 10 | 11 | #include "fs.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif /* __cplusplus */ 16 | 17 | int np_scan_directory(const char *path, void(*f)(const char*)) 18 | { 19 | #if defined(_MSC_VER) 20 | WIN32_FIND_DATA fdFile; 21 | HANDLE hFind = NULL; 22 | 23 | if((hFind = FindFirstFile(sPath, &fdFile)) != INVALID_HANDLE_VALUE) { 24 | do { 25 | if ( strcmp(fdFile.cFileName, "." ) != 0 26 | && strcmp(fdFile.cFileName, "..") != 0) { 27 | f(sPath); 28 | } 29 | } 30 | while (FindNextFile(hFind, &fdFile)); 31 | FindClose(hFind); 32 | return 0; 33 | } 34 | 35 | #elif defined(__GNUC__) 36 | DIR *d; 37 | struct dirent *dir; 38 | d = opendir(path); 39 | if (d) { 40 | while ((dir = readdir(d)) != 0) { 41 | if ( strcmp(dir->d_name, "." ) != 0 42 | && strcmp(dir->d_name, "..") != 0) { 43 | f(dir->d_name); 44 | } 45 | } 46 | closedir(d); 47 | return 0; 48 | } 49 | #endif 50 | 51 | return 1; 52 | } 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif /* __cplusplus */ 57 | -------------------------------------------------------------------------------- /src/xtcore/integrator/stencil/integrator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "integrator.h" 4 | 5 | namespace xtcore { 6 | namespace integrator { 7 | namespace stencil { 8 | 9 | void Integrator::render_tile(xtcore::render::tile_t *tile) 10 | { 11 | xtcore::asset::ICamera *cam = ctx->scene.get_camera(ctx->params.camera); 12 | 13 | while (tile->samples.count() > 0) { 14 | xtcore::antialiasing::sample_rgba_t aa_sample; 15 | tile->samples.pop(aa_sample); 16 | 17 | nimg::ColorRGBAf color_pixel; 18 | tile->read(aa_sample.pixel.x, aa_sample.pixel.y, color_pixel); 19 | 20 | Ray ray = cam->get_primary_ray( 21 | aa_sample.coords.x 22 | , aa_sample.coords.y 23 | , (float)(ctx->params.width) 24 | , (float)(ctx->params.height) 25 | ); 26 | 27 | xtcore::hit_record_t hit_record; 28 | bool found_hit = ctx->scene.intersection(ray, hit_record); 29 | 30 | if (found_hit) color_pixel = nimg::ColorRGBAf(1, 1, 1, color_pixel.a() + aa_sample.weight); 31 | 32 | tile->write(floor(aa_sample.pixel.x), floor(aa_sample.pixel.y), color_pixel); 33 | } 34 | } 35 | 36 | } /* namespace stencil */ 37 | } /* namespace integrator */ 38 | } /* namespace xtcore */ 39 | -------------------------------------------------------------------------------- /src/xtcore/strpool.cc: -------------------------------------------------------------------------------- 1 | #define STRPOOL_IMPLEMENTATION 2 | #include "log.h" 3 | #include "strpool.h" 4 | #define STRPOOL_U32 HASH_UINT32 5 | #define STRPOOL_U64 HASH_UINT64 6 | #include 7 | 8 | #define LOG_DEBUG_PREFIX "xtcore::pool::str::" 9 | 10 | namespace xtcore { 11 | namespace pool { 12 | namespace str { 13 | 14 | strpool_t pool; // Global string pool 15 | 16 | void init() 17 | { 18 | strpool_config_t conf = strpool_default_config; 19 | strpool_init(&pool, &conf); 20 | } 21 | 22 | void release() 23 | { 24 | strpool_term(&pool); 25 | } 26 | 27 | HASH_ID add(const char *str) 28 | { 29 | size_t len = strlen(str); 30 | HASH_ID id = strpool_inject(&pool, str, (int)len); 31 | strpool_incref(&pool, id); 32 | Log::handle().post_debug(LOG_DEBUG_PREFIX "add [%i] %s", strpool_getref(&pool, id), str); 33 | return id; 34 | } 35 | 36 | void del(HASH_ID id) 37 | { 38 | int count = strpool_decref(&pool, id); 39 | if (count == 0) { 40 | Log::handle().post_debug(LOG_DEBUG_PREFIX "del %s", strpool_cstr(&pool,id)); 41 | strpool_discard(&pool, id); 42 | } 43 | } 44 | 45 | char const* get(HASH_ID id) 46 | { 47 | return strpool_cstr(&pool, id); 48 | } 49 | 50 | } /* namespace str */ 51 | } /* namespace pool */ 52 | } /* namespace xtcore */ 53 | -------------------------------------------------------------------------------- /src/xtcore/integrator/wireframe/integrator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "integrator.h" 4 | 5 | namespace xtcore { 6 | namespace integrator { 7 | namespace wireframe { 8 | 9 | void Integrator::render_tile(xtcore::render::tile_t *tile) 10 | { 11 | xtcore::asset::ICamera *cam = ctx->scene.get_camera(ctx->params.camera); 12 | 13 | while (tile->samples.count() > 0) { 14 | xtcore::antialiasing::sample_rgba_t aa_sample; 15 | tile->samples.pop(aa_sample); 16 | 17 | nimg::ColorRGBAf color_pixel; 18 | tile->read(aa_sample.pixel.x, aa_sample.pixel.y, color_pixel); 19 | 20 | Ray ray = cam->get_primary_ray( 21 | aa_sample.coords.x 22 | , aa_sample.coords.y 23 | , (float)(ctx->params.width) 24 | , (float)(ctx->params.height) 25 | ); 26 | 27 | xtcore::hit_record_t hit_record; 28 | bool found_hit = ctx->scene.intersection(ray, hit_record); 29 | 30 | if (found_hit) color_pixel = nimg::ColorRGBAf(1, 1, 1, color_pixel.a() + aa_sample.weight); 31 | 32 | tile->write(floor(aa_sample.pixel.x), floor(aa_sample.pixel.y), color_pixel); 33 | } 34 | } 35 | 36 | } /* namespace wireframe */ 37 | } /* namespace integrator */ 38 | } /* namespace xtcore */ 39 | -------------------------------------------------------------------------------- /lib/nmesh/cone.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "structs.h" 4 | #include "cone.h" 5 | 6 | namespace nmesh { 7 | namespace generator { 8 | 9 | 10 | // Ref: https://www.danielsieger.com/blog/2021/05/03/generating-primitive-shapes.html 11 | void cone(object_t *obj, float height, float radius, size_t resolution) 12 | { 13 | if (!obj) return; 14 | 15 | std::vector *c = &(obj->attributes.v); 16 | 17 | for (size_t i = 0; i < resolution; ++i) { 18 | float r = float(i) * nmath::PI * 2.0 / resolution; 19 | float x = nmath_cos(r) * radius; 20 | float z = nmath_sin(r) * radius; 21 | c->push_back(x); 22 | c->push_back(0.0); 23 | c->push_back(z); 24 | } 25 | 26 | c->push_back( 0.0); 27 | c->push_back( 0.0); 28 | c->push_back( 0.0); 29 | 30 | c->push_back(0.0); 31 | c->push_back(height); 32 | c->push_back(0.0); 33 | 34 | nmesh::shape_t shape; 35 | obj->shapes.push_back(shape); 36 | /* 37 | // generate triangular faces 38 | for (size_t i = 0; i < resolution; ++i) { 39 | size_t = (i + 1) % resolution; 40 | f.v = c->size() - 1; 41 | obj->shapes[0].mesh.indices.push_back(f); 42 | 43 | 44 | } 45 | */ 46 | } 47 | 48 | } /* namespace generator */ 49 | } /* namespace nmesh */ 50 | -------------------------------------------------------------------------------- /ext/remotery/vis/Code/DataViewReader.js: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // Simple wrapper around DataView that auto-advances the read offset and provides 4 | // a few common data type conversions specific to this app 5 | // 6 | DataViewReader = (function () 7 | { 8 | function DataViewReader(data_view, offset) 9 | { 10 | this.DataView = data_view; 11 | this.Offset = offset; 12 | } 13 | 14 | DataViewReader.prototype.GetUInt32 = function () 15 | { 16 | var v = this.DataView.getUint32(this.Offset, true); 17 | this.Offset += 4; 18 | return v; 19 | } 20 | 21 | DataViewReader.prototype.GetUInt64 = function () 22 | { 23 | var v = this.DataView.getFloat64(this.Offset, true); 24 | this.Offset += 8; 25 | return v; 26 | } 27 | 28 | DataViewReader.prototype.GetStringOfLength = function (string_length) 29 | { 30 | var string = ""; 31 | for (var i = 0; i < string_length; i++) 32 | { 33 | string += String.fromCharCode(this.DataView.getInt8(this.Offset)); 34 | this.Offset++; 35 | } 36 | 37 | return string; 38 | } 39 | 40 | DataViewReader.prototype.GetString = function () 41 | { 42 | var string_length = this.GetUInt32(); 43 | return this.GetStringOfLength(string_length); 44 | } 45 | 46 | return DataViewReader; 47 | })(); 48 | -------------------------------------------------------------------------------- /src/xtcore/material/lambert.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "macro.h" 3 | #include "lambert.h" 4 | 5 | namespace xtcore { 6 | namespace asset { 7 | namespace material { 8 | 9 | bool Lambert::shade( 10 | ColorRGBf &intensity 11 | , const ICamera *camera 12 | , const emitter_t *emitter 13 | , const hit_record_t &hit_record) const 14 | { 15 | UNUSED(camera) 16 | 17 | Vector3f light_dir = emitter->position - hit_record.point; 18 | light_dir.normalize(); 19 | 20 | nmath::scalar_t d = dot(light_dir, hit_record.normal); 21 | 22 | if (d > 0) { 23 | intensity += emitter->intensity * 24 | d * get_sample(MAT_SAMPLER_DIFFUSE , hit_record.texcoord); 25 | } 26 | 27 | return true; 28 | } 29 | 30 | bool Lambert::sample_path( 31 | hit_result_t &hit_result 32 | , const hit_record_t &hit_record 33 | ) const 34 | { 35 | hit_result.ray.origin = hit_record.point + hit_record.normal * EPSILON; 36 | hit_result.ray.direction = nmath::sample::diffuse(hit_record.normal).normalized(); 37 | hit_result.intensity = get_sample("diffuse", hit_record.texcoord) 38 | * dot(hit_record.normal, hit_result.ray.direction); 39 | return true; 40 | } 41 | 42 | } /* namespace material */ 43 | } /* namespace asset */ 44 | } /* namespace xtcore */ 45 | -------------------------------------------------------------------------------- /lib/nimg/pixmap.h: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_PIXMAP_H_INCLUDED 2 | #define NIMG_PIXMAP_H_INCLUDED 3 | 4 | #include 5 | #include "buffer.h" 6 | #include "color.h" 7 | 8 | namespace nimg { 9 | 10 | // For visual studio: 11 | // Disable " needs to have dll-interface to be used by clients" 12 | // This warning refers to STL member variables which are private and 13 | // therefore can be safely ignored. 14 | #pragma warning(push) 15 | #pragma warning(disable : 4251) // unreferenced formal parameter 16 | 17 | class Pixmap 18 | { 19 | public: 20 | Pixmap(); 21 | Pixmap(const Pixmap &img); 22 | Pixmap &operator =(const Pixmap &img); 23 | ~Pixmap(); 24 | 25 | // NOTES: 26 | // If the user sets one or both of the dimensions as 0 27 | // it is equivalent to resetting the buffer as total size is 0. 28 | // RETURN CODES: 29 | // 0. Everything went well. 30 | // 1. Failed to initialize pixels. 31 | int init(size_t w, size_t h); 32 | 33 | size_t width() const; 34 | size_t height() const; 35 | 36 | const ColorRGBAf &pixel_ro(size_t x, size_t y) const; 37 | ColorRGBAf &pixel (size_t x, size_t y); 38 | 39 | private: 40 | size_t m_width, m_height; 41 | mutable util::Buffer m_pixels; 42 | }; 43 | 44 | #pragma warning (pop) 45 | 46 | } /* namespace nimg */ 47 | 48 | #endif /* NIMG_TEXTURE_H_INCLUDED */ 49 | -------------------------------------------------------------------------------- /src/frontend/gui/imgui_extra.h: -------------------------------------------------------------------------------- 1 | #ifndef XTGUI_IMGUI_EXTRA_H_INCLUDED 2 | #define XTGUI_IMGUI_EXTRA_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); } 9 | static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x-rhs.x, lhs.y-rhs.y); } 10 | 11 | void slider_float (const char *name, float &val, float a, float b); 12 | void slider_int (const char *name, size_t &val, size_t a, size_t b); 13 | 14 | void textedit_float (const char *name, float &val, float step, float lim_min = 0.f, float lim_max = std::numeric_limits::max()); 15 | void textedit_double (const char *name, double &val, float step, float lim_min = 0.f, float lim_max = std::numeric_limits::max()); 16 | void textedit_int (const char *name, size_t &val, int step, int lim_mix = 0 , int lim_max = std::numeric_limits::max()); 17 | void textedit_float2 (const char *name, nmath::Vector2f &vec, float step, float width = 250); 18 | void textedit_float3 (const char *name, nmath::Vector3f &vec, float step, float width = 250); 19 | 20 | void not_yet_implemented(); 21 | 22 | namespace ImGui { 23 | bool GoxTab(const char *text, float width, bool *v); 24 | } 25 | 26 | #endif /* XTGUI_IMGUI_EXTRA_H_INCLUDED */ 27 | -------------------------------------------------------------------------------- /automation/git-hooks/commit-msg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2.7 2 | import sys, os, re 3 | from subprocess import check_output 4 | 5 | # Collect the parameters 6 | commit_msg_filepath = sys.argv[1] 7 | 8 | # Figure out which branch we're on 9 | branch = check_output(['git', 'symbolic-ref', '--short', 'HEAD']).strip() 10 | print "commit-msg: On branch '%s'" % branch 11 | 12 | with open(commit_msg_filepath, 'r') as f: 13 | content = f.read(); 14 | # Check the commit message 15 | result = re.match('ISSUE-([0-9]+):(.*?)\n(.*\n?.*)', content) 16 | 17 | # Pattern is not matched 18 | if not result: 19 | print "commit-msg: ERROR! Invalid commit message format" 20 | print "format:" 21 | print " ISSUE-##: Short description" 22 | print " Longer description" 23 | sys.exit(1) 24 | 25 | issue = result.group(1) 26 | desc_short = result.group(2).strip().capitalize() 27 | desc_long = result.group(3).strip().capitalize() 28 | 29 | if not desc_short: 30 | print "commit-msg: ERROR! Invalid commit message format" 31 | print "Empty title string" 32 | sys.exit(1) 33 | if not desc_long: 34 | print "commit-msg: ERROR! Invalid commit message format" 35 | print "Empty long description string" 36 | sys.exit(1) 37 | 38 | with open(commit_msg_filepath, 'w') as file: 39 | file.write(desc_short + '\n\n' + desc_long + '\n\n') 40 | file.write('Fixes https://github.com/4rknova/xtracer/issues/' + issue + '\n') 41 | -------------------------------------------------------------------------------- /src/xtcore/sampler_tex.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "sampler_tex.h" 5 | #include "log.h" 6 | #include 7 | 8 | namespace xtcore { 9 | namespace sampler { 10 | 11 | Texture2D::Texture2D() 12 | : m_filtering(FILTERING_NEAREST) 13 | {} 14 | 15 | Texture2D::~Texture2D() 16 | {} 17 | 18 | void Texture2D::set_filtering(FILTERING filtering) 19 | { 20 | m_filtering = filtering; 21 | } 22 | 23 | int Texture2D::load(const char *file) 24 | { 25 | int res = nimg::io::load::image(file, m_map); 26 | Log::handle().post_message("Loading texture %s (%i)", file, res); 27 | return res; 28 | } 29 | 30 | int Texture2D::load(const nimg::Pixmap &map) 31 | { 32 | m_map = map; 33 | return 0; 34 | } 35 | 36 | nimg::ColorRGBf Texture2D::sample(const nmath::Vector3f &tc) const 37 | { 38 | switch (m_filtering) { 39 | case FILTERING_NEAREST : return nimg::sample::nearest (m_map, tc.x, tc.y); 40 | case FILTERING_BILINEAR : return nimg::sample::bilinear (m_map, tc.x, tc.y); 41 | } 42 | 43 | return nimg::ColorRGBf(0,0,0); 44 | } 45 | 46 | void Texture2D::flip_horizontal() 47 | { 48 | nimg::transform::flip_horizontal(&m_map); 49 | } 50 | 51 | void Texture2D::flip_vertical() 52 | { 53 | nimg::transform::flip_vertical(&m_map); 54 | } 55 | 56 | } /* namespace sampler */ 57 | } /* namespace xtcore */ 58 | -------------------------------------------------------------------------------- /scene/9.1.scn: -------------------------------------------------------------------------------- 1 | title = Sponza Atrium 2 | descr = Sponza Atrium 3 | versn = 0.1 4 | 5 | data = data/geometry/ 6 | 7 | environment = { 8 | type = gradient 9 | config = { 10 | a = col3(1,1,1) 11 | b = col3(0.5,0.7,1.0) 12 | } 13 | } 14 | 15 | camera = { 16 | ods = { 17 | type = ods 18 | ipd = 1. 19 | position = vec3(0,10,0) 20 | } 21 | 22 | default = { 23 | type = cubemap 24 | position = vec3(0,10,0) 25 | } 26 | 27 | cam0 = { 28 | type = thin-lens 29 | fov = 60 30 | position = vec3(-5,5,0) 31 | target = vec3( 5,7,0) 32 | up = vec3(0,1,0) 33 | } 34 | } 35 | 36 | geometry = { 37 | light = { 38 | type = sphere 39 | position = vec3(0,10,0) 40 | radius = .1 41 | } 42 | } 43 | 44 | material = { 45 | light = { 46 | type = emissive 47 | 48 | properties = { 49 | samplers = { 50 | emissive = { 51 | type = color 52 | value = col3(1,1,1) 53 | } 54 | } 55 | } 56 | } 57 | } 58 | 59 | object = { 60 | 3dmodel = { 61 | source = /graphics.cs.williams.edu/dabrovic-sponza/sponza.obj 62 | prefix = sponza_ 63 | } 64 | 65 | light = { 66 | geometry = light 67 | material = light 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /ext/remotery/vis/Code/PixelTimeRange.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | PixelTimeRange = (function() 4 | { 5 | function PixelTimeRange(start_us, span_us, span_px) 6 | { 7 | this.Span_px = span_px; 8 | this.Set(start_us, span_us); 9 | } 10 | 11 | 12 | PixelTimeRange.prototype.Set = function(start_us, span_us) 13 | { 14 | this.Start_us = start_us; 15 | this.Span_us = span_us; 16 | this.End_us = this.Start_us + span_us; 17 | this.usPerPixel = this.Span_px / this.Span_us; 18 | } 19 | 20 | 21 | PixelTimeRange.prototype.SetStart = function(start_us) 22 | { 23 | this.Start_us = start_us; 24 | this.End_us = start_us + this.Span_us; 25 | } 26 | 27 | 28 | PixelTimeRange.prototype.SetEnd = function(end_us) 29 | { 30 | this.End_us = end_us; 31 | this.Start_us = end_us - this.Span_us; 32 | } 33 | 34 | 35 | PixelTimeRange.prototype.SetPixelSpan = function(span_px) 36 | { 37 | this.Span_px = span_px; 38 | this.usPerPixel = this.Span_px / this.Span_us; 39 | } 40 | 41 | 42 | PixelTimeRange.prototype.PixelOffset = function(time_us) 43 | { 44 | return Math.floor((time_us - this.Start_us) * this.usPerPixel); 45 | } 46 | 47 | 48 | PixelTimeRange.prototype.PixelSize = function(time_us) 49 | { 50 | return Math.floor(time_us * this.usPerPixel); 51 | } 52 | 53 | 54 | PixelTimeRange.prototype.Clone = function() 55 | { 56 | return new PixelTimeRange(this.Start_us, this.Span_us, this.Span_px); 57 | } 58 | 59 | 60 | return PixelTimeRange; 61 | })(); 62 | -------------------------------------------------------------------------------- /lib/nimg/pixmap.cc: -------------------------------------------------------------------------------- 1 | #include "pixmap.h" 2 | 3 | namespace nimg { 4 | 5 | Pixmap::Pixmap() 6 | : m_width (0) 7 | , m_height(0) 8 | {} 9 | 10 | Pixmap::Pixmap(const Pixmap &img) 11 | { 12 | if (&img == this) return; 13 | 14 | m_pixels = img.m_pixels; 15 | m_width = img.width(); 16 | m_height = img.height(); 17 | } 18 | 19 | Pixmap &Pixmap::operator =(const Pixmap &img) 20 | { 21 | if (&img == this) 22 | return *this; 23 | 24 | m_pixels = img.m_pixels; 25 | m_width = img.width(); 26 | m_height = img.height(); 27 | 28 | return *this; 29 | } 30 | 31 | Pixmap::~Pixmap() 32 | {} 33 | 34 | size_t Pixmap::width() const 35 | { 36 | return m_width; 37 | } 38 | 39 | size_t Pixmap::height() const 40 | { 41 | return m_height; 42 | } 43 | 44 | const ColorRGBAf &Pixmap::pixel_ro(size_t x, size_t y) const 45 | { 46 | size_t nx = x >= m_width ? m_width - 1 : x; 47 | size_t ny = y >= m_height ? m_height - 1 : y; 48 | 49 | return m_pixels[ny * m_width + nx]; 50 | } 51 | 52 | ColorRGBAf &Pixmap::pixel(size_t x, size_t y) 53 | { 54 | size_t nx = x >= m_width ? m_width - 1 : x; 55 | size_t ny = y >= m_height ? m_height - 1 : y; 56 | 57 | return m_pixels[ny * m_width + nx]; 58 | } 59 | 60 | int Pixmap::init(size_t w, size_t h) 61 | { 62 | if (m_pixels.init(w*h)) return 1; 63 | 64 | m_width = w; 65 | m_height = h; 66 | 67 | return 0; 68 | } 69 | 70 | } /* namespace nimg */ 71 | -------------------------------------------------------------------------------- /ext/remotery/vis/extern/BrowserLib/WindowManager/Code/WindowManager.js: -------------------------------------------------------------------------------- 1 | 2 | namespace("WM"); 3 | 4 | 5 | WM.WindowManager = (function() 6 | { 7 | function WindowManager() 8 | { 9 | // An empty list of windows under window manager control 10 | this.Windows = [ ]; 11 | } 12 | 13 | 14 | WindowManager.prototype.AddWindow = function(title, x, y, width, height, parent_node) 15 | { 16 | // Create the window and add it to the list of windows 17 | var wnd = new WM.Window(this, title, x, y, width, height, parent_node); 18 | this.Windows.push(wnd); 19 | 20 | // Always bring to the top on creation 21 | wnd.SetTop(); 22 | 23 | return wnd; 24 | } 25 | 26 | 27 | WindowManager.prototype.SetTopWindow = function(top_wnd) 28 | { 29 | // Bring the window to the top of the window list 30 | var top_wnd_index = this.Windows.indexOf(top_wnd); 31 | if (top_wnd_index != -1) 32 | this.Windows.splice(top_wnd_index, 1); 33 | this.Windows.push(top_wnd); 34 | 35 | // Set a CSS z-index for each visible window from the bottom up 36 | for (var i in this.Windows) 37 | { 38 | var wnd = this.Windows[i]; 39 | if (!wnd.Visible) 40 | continue; 41 | 42 | // Ensure there's space between each window for the elements inside to be sorted 43 | var z = (parseInt(i) + 1) * 10; 44 | wnd.Node.style.zIndex = z; 45 | 46 | // Notify window that its z-order has changed 47 | wnd.NotifyChange(); 48 | } 49 | } 50 | 51 | 52 | return WindowManager; 53 | 54 | })(); -------------------------------------------------------------------------------- /lib/nimg/sample.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "sample.h" 4 | 5 | namespace nimg { 6 | namespace sample { 7 | 8 | ColorRGBAf nearest(const Pixmap &map, double u, double v) 9 | { 10 | u = u < 0 ? 0 : (u > 1 ? u - floor(u) : u); 11 | v = v < 0 ? 0 : (v > 1 ? v - floor(v) : v); 12 | 13 | size_t x = (size_t)(u * (float)map.width()); 14 | size_t y = (size_t)(v * (float)map.height()); 15 | 16 | return map.pixel_ro(x, y); 17 | } 18 | 19 | ColorRGBAf bilinear(const Pixmap &map, double u, double v) 20 | { 21 | size_t w = map.width(); 22 | size_t h = map.height(); 23 | 24 | float fu = u * w; 25 | float fv = v * h; 26 | 27 | // find which pixels participate 28 | int u1 = ((int)fu) % w; 29 | int v1 = ((int)fv) % h; 30 | int u2 = (u1 + 1) % w; 31 | int v2 = (v1 + 1) % h; 32 | 33 | // calculate fractional parts of u and v 34 | float fracu = fu - floorf(fu); 35 | float fracv = fv - floorf(fv); 36 | 37 | // calculate weight factors 38 | float w1 = (1 - fracu) * (1 - fracv); 39 | float w2 = fracu * (1 - fracv); 40 | float w3 = (1 - fracu) * fracv; 41 | float w4 = fracu * fracv; 42 | 43 | // fetch four texels 44 | ColorRGBAf c1 = map.pixel_ro(u1, v1); 45 | ColorRGBAf c2 = map.pixel_ro(u2, v1); 46 | ColorRGBAf c3 = map.pixel_ro(u1, v2); 47 | ColorRGBAf c4 = map.pixel_ro(u2, v2); 48 | 49 | // scale and sum the four colors 50 | return c1 * w1 + c2 * w2 + c3 * w3 + c4 * w4; 51 | } 52 | 53 | } /* namespace sample */ 54 | } /* namespace nimg */ 55 | -------------------------------------------------------------------------------- /ext/remotery/lib/RemoteryMetal.mm: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #import 7 | 8 | 9 | // Store command buffer in thread-local so that each thread can point to its own 10 | void SetCommandBuffer(id command_buffer) 11 | { 12 | NSMutableDictionary* thread_data = [[NSThread currentThread] threadDictionary]; 13 | thread_data[@"rmtMTLCommandBuffer"] = command_buffer; 14 | } 15 | id GetCommandBuffer() 16 | { 17 | NSMutableDictionary* thread_data = [[NSThread currentThread] threadDictionary]; 18 | return thread_data[@"rmtMTLCommandBuffer"]; 19 | } 20 | 21 | 22 | void _rmt_BindMetal(id command_buffer) 23 | { 24 | SetCommandBuffer(command_buffer); 25 | } 26 | 27 | 28 | void _rmt_UnbindMetal() 29 | { 30 | SetCommandBuffer(0); 31 | } 32 | 33 | 34 | // Needs to be in the same lib for this to work 35 | unsigned long long rmtMetal_usGetTime(); 36 | 37 | 38 | static void SetTimestamp(void* data) 39 | { 40 | *((unsigned long long*)data) = rmtMetal_usGetTime(); 41 | } 42 | 43 | 44 | void rmtMetal_MeasureCommandBuffer(unsigned long long* out_start, unsigned long long* out_end, unsigned int* out_ready) 45 | { 46 | id command_buffer = GetCommandBuffer(); 47 | [command_buffer addScheduledHandler:^(id ){ SetTimestamp(out_start); }]; 48 | [command_buffer addCompletedHandler:^(id ){ SetTimestamp(out_end); *out_ready = 1; }]; 49 | } 50 | -------------------------------------------------------------------------------- /lib/nmath/mutil.h: -------------------------------------------------------------------------------- 1 | #ifndef NMATH_MUTIL_H_INCLUDED 2 | #define NMATH_MUTIL_H_INCLUDED 3 | 4 | #include "precision.h" 5 | 6 | namespace nmath { 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif /* __cplusplus */ 11 | 12 | static inline scalar_t max (scalar_t x, scalar_t y); 13 | static inline scalar_t max3 (scalar_t x, scalar_t y, scalar_t z); 14 | static inline scalar_t max4 (scalar_t x, scalar_t y, scalar_t z, scalar_t w); 15 | static inline scalar_t min (scalar_t x, scalar_t y); 16 | static inline scalar_t min3 (scalar_t x, scalar_t y, scalar_t z); 17 | static inline scalar_t min4 (scalar_t x, scalar_t y, scalar_t z, scalar_t w); 18 | static inline scalar_t sign (scalar_t x); 19 | 20 | /* Angle conversion */ 21 | static inline scalar_t degree_to_radian(const scalar_t r); 22 | static inline scalar_t radian_to_degree(const scalar_t d); 23 | 24 | /* Clamping */ 25 | static inline scalar_t saturate(const scalar_t value); 26 | static inline scalar_t clamp_min(const scalar_t value, const scalar_t min); 27 | static inline scalar_t clamp_max(const scalar_t value, const scalar_t max); 28 | static inline scalar_t clamp(const scalar_t value, const scalar_t a, const scalar_t b); 29 | 30 | /* Check if an integer is a power of 2 */ 31 | static inline int is_power_of_2(const int v); 32 | 33 | #ifdef __cplusplus 34 | } /* extern "C" */ 35 | #endif /* __cplusplus */ 36 | 37 | } /* namespace nmath */ 38 | 39 | #include "mutil.inl" 40 | 41 | #endif /* NMATH_MUTIL_H_INCLUDED */ 42 | -------------------------------------------------------------------------------- /scene/3.1.scn: -------------------------------------------------------------------------------- 1 | title = Sponza Atrium 2 | descr = Sponza Atrium 3 | versn = 0.6 4 | 5 | data = data 6 | model = /geometry/graphics.cs.williams.edu/dabrovic-sponza 7 | 8 | environment = { 9 | type = gradient 10 | config = { 11 | a = col3(1.0,1.0,1.0) 12 | b = col3(0.7,0.8,1.0) 13 | } 14 | } 15 | 16 | camera = { 17 | default = { 18 | type = thin-lens 19 | fov = 45 20 | position = vec3(0,2,0) 21 | target = vec3(1,2,0) 22 | up = vec3(0,1,0) 23 | aperture = 0.001 24 | flength = 0.1 25 | } 26 | 27 | ods = { 28 | type = ods 29 | ipd = 1.5 30 | position = vec3(0, 2, 0) 31 | } 32 | } 33 | 34 | geometry = { 35 | sat1 = { 36 | type = sphere 37 | radius = 0.01 38 | 39 | position = { 40 | x = 1 41 | y = 1 42 | z = 0 43 | } 44 | 45 | intensity = { 46 | r = 1 47 | g = 1 48 | b = 1 49 | } 50 | } 51 | } 52 | 53 | material = { 54 | light = { 55 | type = lambert 56 | 57 | properties = { 58 | samplers = { 59 | emissive = { 60 | type = color 61 | value = col3(1,1,1) 62 | } 63 | } 64 | } 65 | } 66 | } 67 | 68 | object = { 69 | sponza = { 70 | source = /sponza.obj 71 | prefix = sponza_ 72 | } 73 | 74 | l0 = { 75 | geometry = sat1 76 | material = light 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/util/blender/xtracer_implicit.py: -------------------------------------------------------------------------------- 1 | bl_info = { 2 | "name" : "Xtracer / Implicit Geometry", 3 | "author": "Nikos Papadopoulos", 4 | "version": (1, 0, 0), 5 | "blender": (2, 72, 0), 6 | "location": "Add > Mesh", 7 | "description": "Create implicit geometry.", 8 | "warning": "", 9 | "wiki_url": "", 10 | "tracker_url": "", 11 | "category": "Add Mesh" 12 | } 13 | 14 | 15 | import bpy 16 | import bmesh 17 | import math 18 | from mathutils import * 19 | 20 | class OBJECT_OT_implicit_sphere(bpy.types.Operator): 21 | bl_idname = "mesh.implicit_sphere" 22 | bl_label = "Add Implicit Sphere" 23 | bl_options = {'REGISTER', 'UNDO'} 24 | bl_description = "Add an implicit sphere" 25 | def execute(self, context): 26 | return{'FINISHED'} 27 | 28 | class OBJECT_OT_implicit_plane(bpy.types.Operator): 29 | bl_idname = "mesh.implicit_plane" 30 | bl_label = "Add Implicit Plane" 31 | bl_options = {'REGISTER', 'UNDO'} 32 | bl_description = "Add a implicit plane" #tooltip 33 | def execute(self, context): 34 | return{'FINISHED'} 35 | 36 | def menu_item(self, context): 37 | self.layout.operator(OBJECT_OT_implicit_sphere.bl_idname, text="Implicit Sphere", icon="PLUGIN") 38 | self.layout.operator(OBJECT_OT_implicit_plane.bl_idname, text="Implicit Plane", icon="PLUGIN") 39 | 40 | 41 | def register(): 42 | bpy.utils.register_module(__name__) 43 | bpy.types.INFO_MT_add.append(menu_item) 44 | 45 | 46 | def unregister(): 47 | bpy.utils.unregister_module(__name__) 48 | bpy.types.INFO_MT_add.remove(menu_item) 49 | 50 | 51 | if __name__ == "__main__": 52 | register() 53 | -------------------------------------------------------------------------------- /scene/7.2.scn: -------------------------------------------------------------------------------- 1 | title = Scanned Face 2 | descr = 3d scan by TEN24 (http://www.3dscanstore.com/) 3 | versn = 0.1 4 | 5 | path_data = data 6 | path_geometry = /geometry/graphics.cs.williams.edu/fireplace_room 7 | 8 | environment = { 9 | type = gradient 10 | config = { 11 | a = col3(1,1,1) 12 | b = col3(0.5,0.7,1.0) 13 | } 14 | } 15 | 16 | camera = { 17 | default = { 18 | type = thin-lens 19 | fov = 45 20 | position = vec3(0,1,1.5) 21 | target = vec3(0,0,0) 22 | up = vec3(0,1,0) 23 | aperture = 0 24 | flength = 200 25 | } 26 | 27 | ods = { 28 | type = ods 29 | ipd = .1 30 | position = vec3(3,1,0) 31 | orientation = vec3(0,3.14,0) 32 | } 33 | } 34 | 35 | geometry = { 36 | sat1 = { 37 | type = sphere 38 | radius = 0.01 39 | 40 | position = { 41 | x = 3 42 | y = 1 43 | z = 0 44 | } 45 | } 46 | } 47 | 48 | material = { 49 | light = { 50 | type = lambert 51 | 52 | properties = { 53 | samplers = { 54 | emissive = { 55 | type = color 56 | value = col3(1,1,1) 57 | } 58 | } 59 | } 60 | } 61 | } 62 | 63 | object = { 64 | head = { 65 | source = /fireplace_room.obj 66 | prefix = living_room_ 67 | } 68 | 69 | l0 = { 70 | geometry = sat1 71 | material = light 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /scene/3.0.scn: -------------------------------------------------------------------------------- 1 | title = Sponza Atrium (Crytek) 2 | descr = Sponza Atrium (Crytek) 3 | versn = 0.6 4 | 5 | data = data 6 | model = /geometry/graphics.cs.williams.edu/crytek-sponza 7 | 8 | environment = { 9 | type = gradient 10 | config = { 11 | a = col3(1.0,1.0,1.0) 12 | b = col3(0.7,0.8,1.0) 13 | } 14 | } 15 | 16 | camera = { 17 | default = { 18 | type = thin-lens 19 | fov = 45 20 | position = vec3(0,2,0) 21 | target = vec3(1,2,0) 22 | up = vec3(0,1,0) 23 | aperture = 0.001 24 | flength = 0.1 25 | } 26 | 27 | ods = { 28 | type = ods 29 | ipd = 1.5 30 | position = vec3(0, 2, 0) 31 | } 32 | } 33 | 34 | geometry = { 35 | sat1 = { 36 | type = sphere 37 | radius = 0.01 38 | 39 | position = { 40 | x = 1 41 | y = 1 42 | z = 0 43 | } 44 | 45 | intensity = { 46 | r = 1 47 | g = 1 48 | b = 1 49 | } 50 | } 51 | } 52 | 53 | material = { 54 | light = { 55 | type = lambert 56 | 57 | properties = { 58 | samplers = { 59 | emissive = { 60 | type = color 61 | value = col3(1,1,1) 62 | } 63 | } 64 | } 65 | } 66 | } 67 | 68 | object = { 69 | sponza = { 70 | source = /sponza.obj 71 | prefix = sponza_ 72 | } 73 | 74 | l0 = { 75 | geometry = sat1 76 | material = light 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /lib/nimg/genetic_algo.cc: -------------------------------------------------------------------------------- 1 | #if defined (NIMG_TEST) 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | int test(int argc, char **argv) 14 | { 15 | if (argc != 4) return 1; 16 | nimg::Pixmap src, dst; 17 | int load_err = nimg::io::load::image(argv[1], src); 18 | 19 | if (load_err) { printf("\nerr:%i\n",load_err); return 2; } 20 | dst.init(src.width(), src.height()); 21 | srand(time(NULL)); 22 | nimg::genetic_algorithms::init_seed(time(NULL)); 23 | 24 | float curr = nimg::eval::diff_euclid(src, dst); 25 | float target = atof(argv[2]); 26 | float step = atof(argv[3]); 27 | float iter = curr; 28 | int gen = 0; 29 | 30 | for (; target < iter; iter -= step ) { 31 | gen += nimg::genetic_algorithms::tri(src, dst, iter); 32 | curr = nimg::eval::diff_euclid(src, dst); 33 | 34 | printf("\rGen %4d -> %0.3f", gen, curr); fflush(stdout); 35 | nimg::io::save::png(std::string(argv[1]).append("_res.png").c_str(), dst); 36 | } 37 | /* 38 | std::vector triangles; 39 | gen += nimg::Genetic::tri(src, dst, triangles, target, (size_t)step); 40 | curr = nimg::eval::diff_euclid(src, dst); 41 | printf("\rGen %4d -> %0.3f %f", gen, curr, target); fflush(stdout); 42 | */ 43 | nimg::io::save::png(std::string(argv[1]).append("_res.png").c_str(), dst); 44 | return 0; 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /lib/nmath/sample.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of libnmath. 4 | 5 | sample.h 6 | Sampling functions 7 | 8 | Copyright (C) 2012 9 | Papadopoulos Nikolaos 10 | 11 | This program is free software; you can redistribute it and/or 12 | modify it under the terms of the GNU Lesser General Public 13 | License as published by the Free Software Foundation; either 14 | version 3 of the License, or (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU Lesser General Public License for more details. 20 | 21 | You should have received a copy of the GNU Lesser General 22 | Public License along with this program; if not, write to the 23 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | Boston, MA 02110-1301 USA 25 | 26 | */ 27 | 28 | #ifndef NMATH_SAMPLE_H_INCLUDED 29 | #define NMATH_SAMPLE_H_INCLUDED 30 | 31 | #include "precision.h" 32 | #include "vector.h" 33 | 34 | namespace nmath { 35 | namespace sample { 36 | 37 | inline Vector3f sphere(); 38 | inline Vector3f hemisphere(const Vector3f &normal, const Vector3f &direction); 39 | inline Vector3f lobe(const Vector3f &normal, const Vector3f &direction, const scalar_t exponent); 40 | inline Vector3f diffuse(const Vector3f &normal); 41 | 42 | } /* namespace sample */ 43 | } /* namespace nmath */ 44 | 45 | #include "sample.inl" 46 | 47 | #endif /* NMATH_SAMPLE_H_INCLUDED */ 48 | -------------------------------------------------------------------------------- /scene/7.1.scn: -------------------------------------------------------------------------------- 1 | title = Scanned Face 2 | descr = 3d scan by TEN24 (http://www.3dscanstore.com/) 3 | versn = 0.1 4 | 5 | path_data = data 6 | path_geometry = /geometry/graphics.cs.williams.edu/crytek-sponza 7 | 8 | environment = { 9 | type = gradient 10 | config = { 11 | a = col3(1,1,1) 12 | b = col3(0.5,0.7,1.0) 13 | } 14 | } 15 | 16 | camera = { 17 | default = { 18 | type = thin-lens 19 | fov = 45 20 | position = vec3(0,1,1.5) 21 | target = vec3(0,1,1.1) 22 | up = vec3(0,1,0) 23 | aperture = 0 24 | flength = 200 25 | } 26 | 27 | ods = { 28 | type = ods 29 | ipd = .1 30 | position = vec3(0,1,1.5) 31 | } 32 | } 33 | 34 | geometry = { 35 | sat1 = { 36 | type = sphere 37 | radius = 0.01 38 | 39 | position = { 40 | x = 0 41 | y = 0.5 42 | z = 0.5 43 | } 44 | 45 | intensity = { 46 | r = 1 47 | g = 1 48 | b = 1 49 | } 50 | } 51 | } 52 | 53 | material = { 54 | light = { 55 | type = lambert 56 | 57 | properties = { 58 | samplers = { 59 | emissive = { 60 | type = color 61 | value = col3(1,1,1) 62 | } 63 | } 64 | } 65 | } 66 | } 67 | 68 | object = { 69 | head = { 70 | source = /sponza.obj 71 | prefix = living_room_ 72 | } 73 | 74 | l0 = { 75 | geometry = sat1 76 | material = light 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2010, Nikos Papadopoulos 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /src/xtcore/integrator/normal/integrator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "integrator.h" 5 | 6 | namespace xtcore { 7 | namespace integrator { 8 | namespace normal { 9 | 10 | void Integrator::render_tile(xtcore::render::tile_t *tile) 11 | { 12 | xtcore::asset::ICamera *cam = ctx->scene.get_camera(ctx->params.camera); 13 | 14 | while (tile->samples.count() > 0) { 15 | xtcore::antialiasing::sample_rgba_t sample; 16 | tile->samples.pop(sample); 17 | 18 | xtcore::hit_record_t hit_record; 19 | 20 | nimg::ColorRGBAf color_pixel; 21 | 22 | tile->read(sample.pixel.x, sample.pixel.y, color_pixel); 23 | 24 | nmath::Vector3f acc_normal = nmath::Vector3f(color_pixel.r(), color_pixel.g(), color_pixel.b()); 25 | acc_normal = acc_normal * 2.0f - 1.0f; 26 | 27 | xtcore::Ray ray = cam->get_primary_ray( 28 | sample.coords.x, sample.coords.y 29 | , (float)(ctx->params.width) 30 | , (float)(ctx->params.height)); 31 | 32 | if (ctx->scene.intersection(ray, hit_record)) { 33 | nmath::Vector3f new_normal = (hit_record.normal + acc_normal) * 0.5f; 34 | acc_normal = (new_normal.normalized() + 1.0f) * 0.5f; 35 | } 36 | 37 | color_pixel = nimg::ColorRGBAf(acc_normal.x, acc_normal.y, acc_normal.z, 1.0f); 38 | tile->write(floor(sample.pixel.x), floor(sample.pixel.y), color_pixel); 39 | } 40 | } 41 | 42 | } /* namespace normal */ 43 | } /* namespace integrator */ 44 | } /* namespace xtcore */ 45 | -------------------------------------------------------------------------------- /scene/7.5.scn: -------------------------------------------------------------------------------- 1 | title = Scanned Soldier 2 | descr = 3d scan by TEN24 (http://www.3dscanstore.com/) 3 | versn = 0.5 4 | 5 | data = data 6 | path_model = /geometry/sketchfab/war_of_the_tripods 7 | 8 | environment = { 9 | type = gradient 10 | config = { 11 | a = col3(1,1,1) 12 | b = col3(0.5,0.7,1.0) 13 | } 14 | } 15 | 16 | camera = { 17 | default = { 18 | type = thin-lens 19 | fov = 45 20 | position = vec3(0,0.1,0) 21 | target = vec3(0,0.2,-1) 22 | up = vec3(0,1,0) 23 | aperture = 0 24 | flength = 0 25 | } 26 | 27 | ods = { 28 | type = ods 29 | ipd = 0.01 30 | position = vec3(0, 1, 0) 31 | orientation = vec3(0,180,0) 32 | } 33 | } 34 | 35 | geometry = { 36 | sat1 = { 37 | type = sphere 38 | radius = 0.1 39 | 40 | position = { 41 | x = 0 42 | y = 0.8 43 | z = 0 44 | } 45 | 46 | intensity = { 47 | r = 1 48 | g = 1 49 | b = 1 50 | } 51 | } 52 | } 53 | 54 | material = { 55 | light = { 56 | type = emissive 57 | properties = { 58 | samplers = { 59 | emissive = { 60 | type = color 61 | value = col3(1,1,1) 62 | } 63 | } 64 | } 65 | } 66 | } 67 | 68 | object = { 69 | geo = { 70 | source = /war_of_the_tripods.obj 71 | prefix = scn_ 72 | } 73 | 74 | # l0 = { 75 | # geometry = sat1 76 | # material = light 77 | # } 78 | } 79 | -------------------------------------------------------------------------------- /src/xtcore/octree.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_OCTREE_H_INCLUDED 2 | #define XTCORE_OCTREE_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include "math/aabb.h" 7 | #include "math/ray.h" 8 | #include "math/hitrecord.h" 9 | 10 | namespace xtcore { 11 | 12 | template 13 | class OctreeItem 14 | { 15 | public: 16 | AABB3 aabb; 17 | T data; 18 | }; 19 | 20 | template 21 | class OctreeNode 22 | { 23 | public: 24 | OctreeNode(); 25 | size_t count_items(); 26 | 27 | AABB3 aabb; 28 | std::list*> items; 29 | OctreeNode *child[8]; 30 | }; 31 | 32 | template 33 | class Octree 34 | { 35 | public: 36 | Octree(); 37 | ~Octree(); 38 | 39 | void clear(); 40 | void build(); 41 | void add(const AABB3 &aabb, const T &data); 42 | OctreeItem *intersection(const Ray &ray, hit_record_t *point) const; 43 | 44 | void max_items_per_node(size_t count); 45 | void max_depth(size_t depth); 46 | size_t max_items_per_node(); 47 | size_t max_depth(); 48 | 49 | AABB3 bbox(); 50 | 51 | private: 52 | OctreeItem *r_intersection(OctreeNode *node, const Ray &ray, hit_record_t *point) const; 53 | void subdivide(OctreeNode *node, size_t level); 54 | void release(OctreeNode *node); // Release a sub-tree. 55 | 56 | OctreeNode *m_root; 57 | AABB3 m_aabb; 58 | std::vector > m_items; 59 | 60 | size_t m_max_items_per_node;// Maximum number of items per node. 61 | size_t m_max_depth; // Maximum tree depth. 62 | }; 63 | 64 | } /* namespace xtcore */ 65 | 66 | #include "octree.tml" 67 | 68 | #endif /* XTCORE_BUFFER_H_INCLUDED */ 69 | -------------------------------------------------------------------------------- /lib/nimg/yuv4mpeg2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "yuv4mpeg2.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | // Format details: 11 | // https://wiki.multimedia.cx/index.php?title=YUV4MPEG2 12 | 13 | #define HID "YUV4MPEG2 " 14 | 15 | void start_video(const char *file, int width, int height, int frame_rate) 16 | { 17 | FILE *f = fopen(file, "wb"); 18 | fprintf(f, "%s", HID); 19 | fprintf(f, "W%i ", width); 20 | fprintf(f, "H%i ", height); 21 | fprintf(f, "F%i:1 ", frame_rate); 22 | fprintf(f, "Ip "); 23 | fprintf(f, "A1:1 "); 24 | fprintf(f, "C444"); 25 | fprintf(f, "\n"); 26 | fclose(f); 27 | } 28 | 29 | #define MIN(a,b) (a > b ? b : a) 30 | 31 | void write_frame(const char *file, int width, int height, float *rgb) 32 | { 33 | FILE *f = fopen(file, "ab"); 34 | fseek(f, 0, SEEK_END); 35 | fprintf(f, "FRAME\n"); 36 | 37 | int pc1 = width * height; 38 | int pc2 = pc1 * 2; 39 | int sz = pc1 * 3; 40 | 41 | unsigned char *buffer = (char*)malloc(sz*sizeof(unsigned char)); 42 | for (int i = 0; i < sz; i+=3) { 43 | float r = rgb[i], g = rgb[i+1], b = rgb[i+2], y = 0, cb = 0, cr = 0; 44 | rgb_to_ycbcr(r, g, b, &y, &cb, &cr); 45 | int idx = i / 3; 46 | buffer[idx ] = MIN(255, (char)(y * 255.)); 47 | buffer[idx + pc1] = MIN(255, (char)(cb * 255.)); 48 | buffer[idx + pc2] = MIN(255, (char)(cr * 255.)); 49 | } 50 | fwrite(buffer, sizeof(char), sz, f); 51 | fclose(f); 52 | free(buffer); 53 | } 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /ext/remotery/vis/extern/BrowserLib/Core/Code/Animation.js: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // Very basic linear value animation system, for now. 4 | // 5 | 6 | 7 | namespace("Anim"); 8 | 9 | 10 | Anim.Animation = (function() 11 | { 12 | var anim_hz = 60; 13 | 14 | 15 | function Animation(anim_func, start_value, end_value, time, end_callback) 16 | { 17 | // Setup initial parameters 18 | this.StartValue = start_value; 19 | this.EndValue = end_value; 20 | this.ValueInc = (end_value - start_value) / (time * anim_hz); 21 | this.Value = start_value; 22 | this.Complete = false; 23 | this.EndCallback = end_callback; 24 | 25 | // Cache the update function to prevent recreating the closure 26 | var self = this; 27 | this.AnimFunc = anim_func; 28 | this.AnimUpdate = function() { Update(self); } 29 | 30 | // Call for the start value 31 | this.AnimUpdate(); 32 | } 33 | 34 | 35 | function Update(self) 36 | { 37 | // Queue up the next frame immediately 38 | var id = window.setTimeout(self.AnimUpdate, 1000 / anim_hz); 39 | 40 | // Linear step the value and check for completion 41 | self.Value += self.ValueInc; 42 | if (Math.abs(self.Value - self.EndValue) < 0.01) 43 | { 44 | self.Value = self.EndValue; 45 | self.Complete = true; 46 | 47 | if (self.EndCallback) 48 | self.EndCallback(); 49 | 50 | window.clearTimeout(id); 51 | } 52 | 53 | // Pass to the animation function 54 | self.AnimFunc(self.Value); 55 | } 56 | 57 | 58 | return Animation; 59 | })(); 60 | 61 | 62 | Anim.Animate = function(anim_func, start_value, end_value, time, end_callback) 63 | { 64 | return new Anim.Animation(anim_func, start_value, end_value, time, end_callback); 65 | } 66 | -------------------------------------------------------------------------------- /src/frontend/gui/shader.h: -------------------------------------------------------------------------------- 1 | #ifndef XTGUI_SHADER_H_INCLUDED 2 | #define XTGUI_SHADER_H_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | class Shader { 8 | private: 9 | bool compiled; 10 | 11 | public: 12 | unsigned int shader; 13 | 14 | Shader(unsigned int type); 15 | ~Shader(); 16 | 17 | void set_source(const char *src); 18 | 19 | bool compile(); 20 | bool is_compiled() const; 21 | 22 | bool load(const char *fname); 23 | }; 24 | 25 | class Program { 26 | private: 27 | std::vector shaders; 28 | bool linked; 29 | 30 | public: 31 | unsigned int prog; 32 | 33 | Program(); 34 | ~Program(); 35 | 36 | void add_shader(Shader *shader); 37 | bool link(); 38 | 39 | bool load(const char *vsfname, const char *psfname); 40 | 41 | int get_uniform_location(const char *name); 42 | int get_attribute_location(const char *name); 43 | 44 | void set_uniform(const char *name, int val); 45 | void set_uniform(const char *name, float val); 46 | void set_uniform(const char *name, const nmath::Vector2f &v); 47 | void set_uniform(const char *name, const nmath::Vector3f &v); 48 | void set_uniform(const char *name, const nmath::Vector4f &v); 49 | void set_uniform(const char *name, const nmath::Matrix4x4f &mat); 50 | 51 | void set_uniform(int loc, int val); 52 | void set_uniform(int loc, float val); 53 | void set_uniform(int loc, const nmath::Vector2f &v); 54 | void set_uniform(int loc, const nmath::Vector3f &v); 55 | void set_uniform(int loc, const nmath::Vector4f &v); 56 | void set_uniform(int loc, const nmath::Matrix4x4f &mat); 57 | }; 58 | 59 | bool bind_program(const Program *prog); 60 | 61 | #endif /* XTGUI_SHADER_H_INCLUDED */ 62 | -------------------------------------------------------------------------------- /src/xtcore/integrator/uv/integrator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "integrator.h" 5 | 6 | namespace xtcore { 7 | namespace integrator { 8 | namespace uv { 9 | 10 | void Integrator::render_tile(xtcore::render::tile_t *tile) 11 | { 12 | xtcore::asset::ICamera *cam = ctx->scene.get_camera(ctx->params.camera); 13 | 14 | while (tile->samples.count() > 0) { 15 | xtcore::antialiasing::sample_rgba_t sample; 16 | tile->samples.pop(sample); 17 | 18 | xtcore::hit_record_t hit_record; 19 | 20 | nimg::ColorRGBAf color_pixel; 21 | 22 | tile->read(sample.pixel.x, sample.pixel.y, color_pixel); 23 | 24 | nmath::Vector3f acc_uv = nmath::Vector3f(color_pixel.r(), color_pixel.g(), color_pixel.b()); 25 | nmath::scalar_t alpha = color_pixel.a(); 26 | 27 | nmath::scalar_t alpha_sample = 0.f; 28 | 29 | xtcore::Ray ray = cam->get_primary_ray( 30 | sample.coords.x, sample.coords.y 31 | , (float)(ctx->params.width) 32 | , (float)(ctx->params.height)); 33 | 34 | if (ctx->scene.intersection(ray, hit_record)) { 35 | acc_uv += (hit_record.texcoord * 0.5f + 0.5f) * sample.weight; 36 | alpha_sample += sample.weight; 37 | } 38 | 39 | color_pixel = nimg::ColorRGBAf(acc_uv.x, acc_uv.y, acc_uv.z, 0.); 40 | color_pixel.a(alpha + sample.weight * alpha_sample); 41 | tile->write(floor(sample.pixel.x), floor(sample.pixel.y), color_pixel); 42 | } 43 | } 44 | 45 | } /* namespace uv */ 46 | } /* namespace integrator */ 47 | } /* namespace xtcore */ 48 | -------------------------------------------------------------------------------- /lib/nimg/color.cc: -------------------------------------------------------------------------------- 1 | #include "color.h" 2 | 3 | namespace nimg { 4 | 5 | // ColorRGBf 6 | ColorRGBf::ColorRGBf(const float r, const float g, const float b) 7 | : m_r(r < 0.f ? 0.f : r), 8 | m_g(g < 0.f ? 0.f : g), 9 | m_b(b < 0.f ? 0.f : b) 10 | {} 11 | 12 | ColorRGBf::ColorRGBf(const ColorRGBf &rhs) 13 | : m_r(rhs.r()), m_g(rhs.g()), m_b(rhs.b()) 14 | {} 15 | 16 | ColorRGBf::ColorRGBf(const ColorRGBAf &rhs) 17 | : m_r(rhs.r()), m_g(rhs.g()), m_b(rhs.b()) 18 | {} 19 | 20 | void ColorRGBf::operator=(const ColorRGBAf &rhs) 21 | { 22 | m_r = rhs.r(); 23 | m_g = rhs.g(); 24 | m_b = rhs.b(); 25 | } 26 | 27 | void ColorRGBf::operator=(const ColorRGBf &rhs) 28 | { 29 | m_r = rhs.r(); 30 | m_g = rhs.g(); 31 | m_b = rhs.b(); 32 | } 33 | 34 | // ColorRGBAf 35 | ColorRGBAf::ColorRGBAf(const float r, const float g, const float b, const float a) 36 | : m_r(r < 0.f ? 0.f : r), 37 | m_g(g < 0.f ? 0.f : g), 38 | m_b(b < 0.f ? 0.f : b), 39 | m_a(a < 0.f ? 0.f : (a > 1.f ? 1.f : a)) 40 | {} 41 | 42 | ColorRGBAf::ColorRGBAf(const ColorRGBAf &rhs) 43 | : m_r(rhs.r()), m_g(rhs.g()), m_b(rhs.b()), m_a(rhs.a()) 44 | {} 45 | 46 | ColorRGBAf::ColorRGBAf(const ColorRGBf &rhs) 47 | : m_r(rhs.r()), m_g(rhs.g()), m_b(rhs.b()), m_a(1.0f) 48 | {} 49 | 50 | void ColorRGBAf::operator=(const ColorRGBf &rhs) 51 | { 52 | m_r = rhs.r(); 53 | m_g = rhs.g(); 54 | m_b = rhs.b(); 55 | m_a = 1.0f; 56 | } 57 | 58 | void ColorRGBAf::operator=(const ColorRGBAf &rhs) 59 | { 60 | m_r = rhs.r(); 61 | m_g = rhs.g(); 62 | m_b = rhs.b(); 63 | m_a = rhs.a(); 64 | } 65 | 66 | } /* namespace nimg */ 67 | -------------------------------------------------------------------------------- /scene/1.1-reflective_sphere.scn: -------------------------------------------------------------------------------- 1 | title = Reflective Sphere 2 | description = A sphere reflecting the environment 3 | version = 1.0 4 | 5 | data = data 6 | env = /image/envmap/humus/Park 7 | 8 | camera = { 9 | default = { 10 | type = ods 11 | ipd = 1.5 12 | } 13 | 14 | front = { 15 | type = thin-lens 16 | up = vec3(0,1,0) 17 | position = vec3(0,0,-100) 18 | target = vec3(0,0, 100) 19 | fov = 90 20 | } 21 | } 22 | 23 | geometry = { 24 | ball = { 25 | type = sphere 26 | radius = 50 27 | position = vec3(0,0,100) 28 | } 29 | } 30 | 31 | material = { 32 | ball = { 33 | type = blinn_phong 34 | properties = { 35 | samplers = { 36 | diffuse = { 37 | type = color 38 | value = col3(0,1,0) 39 | } 40 | 41 | specular = { 42 | type = color 43 | value = col3(1,1,1) 44 | } 45 | } 46 | 47 | scalars = { 48 | reflectance = 1 49 | exponent = 90 50 | } 51 | } 52 | } 53 | } 54 | 55 | environment = { 56 | type = cubemap 57 | config = { 58 | posy = /posy.jpg 59 | negy = /negy.jpg 60 | negx = /negx.jpg 61 | posx = /posx.jpg 62 | posz = /posz.jpg 63 | negz = /negz.jpg 64 | } 65 | } 66 | 67 | object = { 68 | ball = { 69 | geometry = ball 70 | material = ball 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /scene/6.1-stereographic_projection.scn: -------------------------------------------------------------------------------- 1 | title = DOF 2 | descr = Depth of field 3 | versn = 0.4 4 | 5 | environment = { 6 | } 7 | 8 | camera = { 9 | default = { 10 | type = thin-lens 11 | fov = 45 12 | position = vec3(0,2,-3) 13 | target = vec3(0,0,0) 14 | up = vec3(0,1,0) 15 | aperture = 0 16 | flength = 0 17 | } 18 | } 19 | 20 | geometry = { 21 | geo = { 22 | type = mesh 23 | source = data/geometry/yobi3d/streographic_projection.obj 24 | } 25 | 26 | floor = { 27 | type = plane 28 | normal = { 29 | y = 1 30 | } 31 | distance = 0 32 | } 33 | 34 | l0 = { 35 | type = sphere 36 | radius = 0.01 37 | position = { 38 | x = 0 39 | y = 1 40 | z = 0 41 | } 42 | } 43 | } 44 | 45 | material = { 46 | plastic = { 47 | type = lambert 48 | 49 | properties = { 50 | samplers = { 51 | diffuse = { 52 | type = color 53 | value = col3(1,1,1) 54 | } 55 | 56 | } 57 | } 58 | } 59 | 60 | light = { 61 | type = emissive 62 | properties = { 63 | samplers = { 64 | emissive = { 65 | type = color 66 | value = col3(1,1,1) 67 | } 68 | } 69 | } 70 | } 71 | } 72 | 73 | object = { 74 | floor = { 75 | geometry = floor 76 | material = plastic 77 | } 78 | geo = { 79 | geometry = geo 80 | material = plastic 81 | } 82 | light = { 83 | geometry = l0 84 | material = light 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/xtcore/integrator/emission/integrator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "integrator.h" 6 | 7 | namespace xtcore { 8 | namespace integrator { 9 | namespace emission { 10 | 11 | void Integrator::render_tile(xtcore::render::tile_t *tile) 12 | { 13 | xtcore::asset::ICamera *cam = ctx->scene.get_camera(ctx->params.camera); 14 | 15 | while (tile->samples.count() > 0) { 16 | xtcore::antialiasing::sample_rgba_t sample; 17 | tile->samples.pop(sample); 18 | 19 | xtcore::hit_record_t hit_record; 20 | 21 | nimg::ColorRGBAf color_pixel; 22 | 23 | tile->read(sample.pixel.x, sample.pixel.y, color_pixel); 24 | 25 | nimg::ColorRGBf acc_emission = nimg::ColorRGBf(color_pixel.r(), color_pixel.g(), color_pixel.b()); 26 | 27 | xtcore::Ray ray = cam->get_primary_ray( 28 | sample.coords.x, sample.coords.y 29 | , (float)(ctx->params.width) 30 | , (float)(ctx->params.height)); 31 | 32 | if (ctx->scene.intersection(ray, hit_record)) { 33 | HASH_UINT64 matid = ctx->scene.m_objects[hit_record.id_object]->material; 34 | xtcore::asset::IMaterial *mat = ctx->scene.m_materials[matid]; 35 | if (mat) { 36 | acc_emission += mat->get_sample("emissive", hit_record.texcoord) * sample.weight; 37 | } 38 | } 39 | 40 | color_pixel = acc_emission; 41 | tile->write(floor(sample.pixel.x), floor(sample.pixel.y), color_pixel); 42 | } 43 | } 44 | 45 | } /* namespace emission */ 46 | } /* namespace integrator */ 47 | } /* namespace xtcore */ 48 | -------------------------------------------------------------------------------- /src/xtcore/context.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_CONTEXT_H_INCLUDED 2 | #define XTCORE_CONTEXT_H_INCLUDED 3 | 4 | #include "strpool.h" 5 | #include "nimg/pixmap.h" 6 | #include "scene.h" 7 | #include "tile.h" 8 | #include "aa.h" 9 | #include "util/raygraph.h" 10 | 11 | using nimg::Pixmap; 12 | using nimg::ColorRGBf; 13 | using xtcore::raygraph::raygraph_t; 14 | 15 | namespace xtcore { 16 | namespace render { 17 | 18 | struct params_t 19 | { 20 | size_t width; // Width of frame 21 | size_t height; // Height of frame 22 | size_t threads; // Number of threads 23 | size_t samples; // Number of samples 24 | size_t aa; // Level of Screen Space Anti-Aliasing 25 | size_t rdepth; // Maximum recursion depth 26 | size_t tile_size; // Tile size for framebuffers segmentation 27 | 28 | xtcore::render::TILE_ORDER tile_order; 29 | xtcore::antialiasing::SAMPLE_DISTRIBUTION sample_distribution; 30 | 31 | HASH_UINT64 camera; 32 | 33 | params_t(); 34 | }; 35 | 36 | struct context_t 37 | { 38 | Scene scene; 39 | Tileset tiles; 40 | params_t params; 41 | 42 | /* init: Initialize context buffers 43 | ** Note that any change to params 44 | ** does not automatically modify 45 | ** those buffers and init should 46 | ** be called again 47 | */ 48 | void init(); 49 | 50 | context_t(); 51 | }; 52 | 53 | /* export: Assembles the context tiles and copies the data 54 | ** to the respective container. 55 | */ 56 | void assemble(Pixmap &pixmap, const context_t &context); 57 | void assemble(raygraph_t &raygraph, const context_t &context); 58 | 59 | } /* namespace render */ 60 | } /* namespace xtcore */ 61 | 62 | #endif /* XTCORE_CONTEXT_H_INCLUDED */ 63 | -------------------------------------------------------------------------------- /src/xtcore/math/aabb.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_BBOX_H_INCLUDED 2 | #define XTCORE_BBOX_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include "ray.h" 7 | 8 | using nmath::Vector2f; 9 | using nmath::Vector3f; 10 | 11 | namespace xtcore { 12 | 13 | class AABB2 14 | { 15 | public: 16 | AABB2(); 17 | AABB2(const Vector2f& a, const Vector2f& b); 18 | 19 | inline bool contains(const Vector2f& p) const; // returns true if the given point is within the bounds of the box, else false 20 | inline Vector2f center() const; // returns the center coordinates of the box 21 | 22 | inline void augment(const Vector2f& v); // augments the bounding box to include the given vector 23 | inline void augment(const AABB2& b); // augments the bounding box to include the given bounding box 24 | 25 | Vector2f min, max; 26 | }; 27 | 28 | class AABB3 29 | { 30 | public: 31 | AABB3(); 32 | AABB3(const Vector3f& a, const Vector3f& b); 33 | 34 | inline bool contains(const Vector3f& p) const; // returns true if the given point is within the bounds of the box, else false 35 | inline bool contains(const AABB3 &aabb) const; 36 | inline Vector3f center() const; // returns the center coordinates of the box 37 | 38 | inline void augment(const Vector3f& v); // augments the bounding box to include the given vector 39 | inline void augment(const AABB3& b); // augments the bounding box to include the given bounding box 40 | 41 | bool intersection(const Ray &ray) const; 42 | 43 | Vector3f min, max; 44 | }; 45 | 46 | } /* namespace xtcore */ 47 | 48 | #include "aabb.inl" 49 | 50 | #endif /* XTCORE_BBOX_H_INCLUDED */ 51 | -------------------------------------------------------------------------------- /scene/7.7.scn: -------------------------------------------------------------------------------- 1 | title = Scanned Face 2 | descr = 3d scan by TEN24 (http://www.3dscanstore.com/) 3 | versn = 0.1 4 | 5 | path_data = data 6 | path_geometry = /geometry/graphics.cs.williams.edu/sportsCar 7 | 8 | environment = { 9 | type = gradient 10 | config = { 11 | a = col3(1,1,1) 12 | b = col3(0.5,0.7,1.0) 13 | } 14 | } 15 | 16 | camera = { 17 | default = { 18 | type = thin-lens 19 | fov = 45 20 | position = vec3(5,2,5) 21 | target = vec3(0,1,0) 22 | up = vec3(0,1,0) 23 | aperture = 0 24 | flength = 200 25 | } 26 | 27 | close = { 28 | type = thin-lens 29 | fov = 45 30 | position = vec3(0,11,20) 31 | target = vec3(0,9,3) 32 | up = vec3(0,1,0) 33 | aperture = 0 34 | flength = 150 35 | } 36 | 37 | ods = { 38 | type = ods 39 | ipd = 1.5 40 | position = vec3(0, 50,100) 41 | } 42 | } 43 | 44 | geometry = { 45 | sat1 = { 46 | type = sphere 47 | radius = 50 48 | 49 | position = { 50 | x = 88 51 | y = 15 52 | z = 170 53 | } 54 | 55 | intensity = { 56 | r = 1 57 | g = 1 58 | b = 1 59 | } 60 | } 61 | } 62 | 63 | material = { 64 | light = { 65 | type = lambert 66 | 67 | properties = { 68 | samplers = { 69 | emissive = { 70 | type = color 71 | value = col3(1,1,1) 72 | } 73 | } 74 | } 75 | } 76 | } 77 | 78 | object = { 79 | head = { 80 | source = /sportsCar.obj 81 | } 82 | 83 | l0 = { 84 | geometry = sat1 85 | material = light 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /scene/1.2-reflective_icosahedron.scn: -------------------------------------------------------------------------------- 1 | title = Reflective icosahedron 2 | description = An icosahedron reflecting the environment 3 | version = 1.0 4 | 5 | data = data 6 | env = /image/envmap/humus/VancouverConventionCentre 7 | 8 | camera = { 9 | ods = { 10 | type = ods 11 | ipd = 1.5 12 | position = vec3(0,0,-75) 13 | } 14 | 15 | default = { 16 | type = thin-lens 17 | up = vec3(0,1,0) 18 | position = vec3(10,-15,-40) 19 | target = vec3(0,0,0) 20 | fov = 45 21 | } 22 | } 23 | 24 | geometry = { 25 | ball = { 26 | type = mesh 27 | source = gen(icosahedron) 28 | modifiers = { 29 | scale = vec3(10,10,10) 30 | } 31 | } 32 | } 33 | 34 | material = { 35 | ball = { 36 | type = blinn_phong 37 | properties = { 38 | samplers = { 39 | diffuse = { 40 | type = color 41 | value = col3(0,1,0) 42 | } 43 | 44 | specular = { 45 | type = color 46 | value = col3(1,1,1) 47 | } 48 | } 49 | 50 | scalars = { 51 | reflectance = 1 52 | exponent = 900 53 | } 54 | } 55 | } 56 | } 57 | 58 | environment = { 59 | type = cubemap 60 | config = { 61 | posy = /posy.jpg 62 | negy = /negy.jpg 63 | negx = /negx.jpg 64 | posx = /posx.jpg 65 | posz = /posz.jpg 66 | negz = /negz.jpg 67 | } 68 | } 69 | 70 | object = { 71 | ball = { 72 | geometry = ball 73 | material = ball 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /scene/7.6.scn: -------------------------------------------------------------------------------- 1 | title = Scanned Face 2 | descr = 3d scan by TEN24 (http://www.3dscanstore.com/) 3 | versn = 0.1 4 | 5 | path_data = data 6 | path_geometry = /geometry/gl.ict.usc.edu/digital_emily 7 | 8 | environment = { 9 | type = gradient 10 | config = { 11 | a = col3(1,1,1) 12 | b = col3(0.5,0.7,1.0) 13 | } 14 | } 15 | 16 | camera = { 17 | default = { 18 | type = thin-lens 19 | fov = 45 20 | position = vec3(0,11,25) 21 | target = vec3(0,9,3) 22 | up = vec3(0,1,0) 23 | aperture = 0 24 | flength = 200 25 | } 26 | 27 | close = { 28 | type = thin-lens 29 | fov = 45 30 | position = vec3(0,11,20) 31 | target = vec3(0,9,3) 32 | up = vec3(0,1,0) 33 | aperture = 0 34 | flength = 150 35 | } 36 | 37 | ods = { 38 | type = ods 39 | ipd = 1.5 40 | position = vec3(0, 50,100) 41 | } 42 | } 43 | 44 | geometry = { 45 | sat1 = { 46 | type = sphere 47 | radius = 50 48 | 49 | position = { 50 | x = 88 51 | y = 15 52 | z = 170 53 | } 54 | 55 | intensity = { 56 | r = 1 57 | g = 1 58 | b = 1 59 | } 60 | } 61 | } 62 | 63 | material = { 64 | light = { 65 | type = lambert 66 | 67 | properties = { 68 | samplers = { 69 | emissive = { 70 | type = color 71 | value = col3(1,1,1) 72 | } 73 | } 74 | } 75 | } 76 | } 77 | 78 | object = { 79 | head = { 80 | source = /Emily_2_1_mod.obj 81 | prefix = emily_ 82 | } 83 | 84 | l0 = { 85 | geometry = sat1 86 | material = light 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /lib/nimg/pixel.inl: -------------------------------------------------------------------------------- 1 | #ifndef NIMG_PIXEL_INL_INCLUDED 2 | #define NIMG_PIXEL_INL_INCLUDED 3 | 4 | #ifndef NIMG_PIXEL_H_INCLUDED 5 | error "pixel.h must be included before pixel.inl" 6 | #endif /* NIMG_PIXEL_H_INCLUDED */ 7 | 8 | namespace nimg { 9 | namespace util { 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif /* __cplusplus */ 14 | 15 | static inline pixel32_t rgba_c_to_pixel32(unsigned char r, unsigned char g, unsigned char b, unsigned char a) 16 | { 17 | return (pixel32_t)(((uint32_t)r << 24) + ((uint32_t)g << 16) + ((uint32_t)b << 8) + (uint32_t)a); 18 | } 19 | 20 | static inline pixel32_t rgba_f_to_pixel32(scalar_t r, scalar_t g, scalar_t b, scalar_t a) 21 | { 22 | pixel32_t pix = 0; 23 | 24 | /* Do some basic tone mapping. */ 25 | scalar_t fmax = 0.0f; 26 | fmax = r > fmax ? r : fmax; 27 | fmax = g > fmax ? g : fmax; 28 | fmax = b > fmax ? b : fmax; 29 | 30 | scalar_t scale = 1.0f; 31 | 32 | if (fmax > 1.0f) { 33 | scale = 1.f / fmax; 34 | } 35 | 36 | scalar_t cr = r * scale * 255.0f; 37 | scalar_t cg = g * scale * 255.0f; 38 | scalar_t cb = b * scale * 255.0f; 39 | 40 | pix = rgba_c_to_pixel32((char)cr, (char)cg, (char)cb, (char)ca); 41 | return pix; 42 | } 43 | 44 | static inline unsigned char get_pixel32_r(pixel32_t c) 45 | { 46 | return (c & 0xFF000000) >> 24; 47 | } 48 | 49 | static inline unsigned char get_pixel32_g(pixel32_t c) 50 | { 51 | return (c & 0x00FF0000) >> 16; 52 | } 53 | 54 | static inline unsigned char get_pixel32_b(pixel32_t c) 55 | { 56 | return (c & 0x0000FF00) >> 8; 57 | } 58 | 59 | static inline unsigned char get_pixel32_a(pixel32_t c) 60 | { 61 | return c & 0x000000FF; 62 | } 63 | 64 | #ifdef __cplusplus 65 | } /* extern "C" */ 66 | #endif /* __cplusplus */ 67 | 68 | } /* namespace util */ 69 | } /* namespace nimg */ 70 | 71 | #endif /* NIMG_PIXEL_INL_INCLUDED */ 72 | -------------------------------------------------------------------------------- /ext/remotery/vis/Code/TitleWindow.js: -------------------------------------------------------------------------------- 1 | 2 | TitleWindow = (function() 3 | { 4 | function TitleWindow(wm, settings, server, connection_address) 5 | { 6 | this.Settings = settings; 7 | 8 | this.Window = wm.AddWindow("     Remotery", 10, 10, 100, 100); 9 | this.Window.ShowNoAnim(); 10 | 11 | this.PingContainer = this.Window.AddControlNew(new WM.Container(4, -13, 10, 10)); 12 | DOM.Node.AddClass(this.PingContainer.Node, "PingContainer"); 13 | 14 | this.EditBox = this.Window.AddControlNew(new WM.EditBox(10, 5, 300, 18, "Connection Address", connection_address)); 15 | 16 | // Setup pause button 17 | this.PauseButton = this.Window.AddControlNew(new WM.Button("Pause", 5, 5, { toggle: true })); 18 | this.PauseButton.SetOnClick(Bind(OnPausePressed, this)); 19 | 20 | server.AddMessageHandler("PING", Bind(OnPing, this)); 21 | } 22 | 23 | 24 | TitleWindow.prototype.SetConnectionAddressChanged = function(handler) 25 | { 26 | this.EditBox.SetChangeHandler(handler); 27 | } 28 | 29 | 30 | TitleWindow.prototype.WindowResized = function(width, height) 31 | { 32 | this.Window.SetSize(width - 2 * 10, 50); 33 | this.PauseButton.SetPosition(width - 80, 5); 34 | } 35 | 36 | 37 | function OnPausePressed(self) 38 | { 39 | self.Settings.IsPaused = self.PauseButton.IsPressed(); 40 | if (self.Settings.IsPaused) 41 | self.PauseButton.SetText("Paused"); 42 | else 43 | self.PauseButton.SetText("Pause"); 44 | } 45 | 46 | 47 | function OnPing(self, server) 48 | { 49 | // Set the ping container as active and take it off half a second later 50 | DOM.Node.AddClass(self.PingContainer.Node, "PingContainerActive"); 51 | window.setTimeout(Bind(function(self) 52 | { 53 | DOM.Node.RemoveClass(self.PingContainer.Node, "PingContainerActive"); 54 | }, self), 500); 55 | } 56 | 57 | 58 | return TitleWindow; 59 | })(); -------------------------------------------------------------------------------- /src/xtcore/sampler_cubemap.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "sampler_cubemap.h" 4 | 5 | namespace xtcore { 6 | namespace sampler { 7 | 8 | int Cubemap::load(const char *file, CUBEMAP_FACE face) 9 | { 10 | return m_textures[face].load(file); 11 | } 12 | 13 | nimg::ColorRGBf Cubemap::sample(const nmath::Vector3f &tc) const 14 | { 15 | nmath::Vector3f dir = tc.normalized(); 16 | 17 | CUBEMAP_FACE face = CUBEMAP_FACE_TOP; 18 | float u = 0.f, v = 0.f; 19 | 20 | if ((nmath_abs(dir.x) >= nmath_abs(dir.y)) && (nmath_abs(dir.x) >= nmath_abs(dir.z))) { 21 | if (dir.x > 0.0f) { face = CUBEMAP_FACE_RIGHT; u = (dir.z / dir.x+ 1.0f) * 0.5f; v = 1.f - (dir.y / dir.x+ 1.0f) * 0.5f; } 22 | else if (dir.x < 0.0f) { face = CUBEMAP_FACE_LEFT; u = (dir.z / dir.x+ 1.0f) * 0.5f; v = (dir.y / dir.x+ 1.0f) * 0.5f; } 23 | } 24 | else if ((nmath_abs(dir.y) >= nmath_abs(dir.x)) && (nmath_abs(dir.y) >= nmath_abs(dir.z))) { 25 | if (dir.y > 0.0f) { face = CUBEMAP_FACE_TOP; u = (dir.x / dir.y+ 1.0f) * 0.5f; v = 1.f - (dir.z / dir.y+ 1.0f) * 0.5f; } 26 | else if (dir.y < 0.0f) { face = CUBEMAP_FACE_BOTTOM; u = 1.- (dir.x / dir.y+ 1.0f) * 0.5f; v = 1.f - (dir.z / dir.y+ 1.0f) * 0.5f; } 27 | } 28 | else if ((nmath_abs(dir.z) >= nmath_abs(dir.x)) && (nmath_abs(dir.z) >= nmath_abs(dir.y))) { 29 | if (dir.z > 0.0f) { face = CUBEMAP_FACE_BACK; u = 1.- (dir.x / dir.z+ 1.0f) * 0.5f; v = 1.f - (dir.y / dir.z+ 1.0f) * 0.5f; } 30 | else if (dir.z < 0.0f) { face = CUBEMAP_FACE_FRONT; u = 1.- (dir.x / dir.z+ 1.0f) * 0.5f; v = (dir.y / dir.z+ 1.0f) * 0.5f; } 31 | } 32 | 33 | nmath::Vector3f coords(u, v, 0); 34 | return m_textures[face].sample(coords); 35 | } 36 | 37 | } /* namespace sampler */ 38 | } /* namespace xtcore */ 39 | 40 | -------------------------------------------------------------------------------- /scene/1.2-reflective_plane.scn: -------------------------------------------------------------------------------- 1 | title = Reflective icosahedron 2 | description = An icosahedron reflecting the environment 3 | version = 1.0 4 | 5 | data = data 6 | env = /image/envmap/humus/VancouverConventionCentre 7 | 8 | camera = { 9 | ods = { 10 | type = ods 11 | ipd = 1.5 12 | position = vec3(0,0,-75) 13 | } 14 | 15 | default = { 16 | type = thin-lens 17 | up = vec3(0,1,0) 18 | position = vec3(4,-6,-8) 19 | target = vec3(0,0,0) 20 | fov = 45 21 | } 22 | } 23 | 24 | geometry = { 25 | ball = { 26 | type = mesh 27 | source = gen(plane) 28 | properties = { 29 | resolution = 10 30 | } 31 | modifiers = { 32 | scale = vec3(10,10,10) 33 | } 34 | } 35 | } 36 | 37 | material = { 38 | ball = { 39 | type = blinn_phong 40 | properties = { 41 | samplers = { 42 | diffuse = { 43 | type = color 44 | value = col3(0,1,0) 45 | } 46 | 47 | specular = { 48 | type = color 49 | value = col3(1,1,1) 50 | } 51 | } 52 | 53 | scalars = { 54 | reflectance = 1 55 | exponent = 128 56 | } 57 | } 58 | } 59 | } 60 | 61 | environment = { 62 | type = cubemap 63 | config = { 64 | posy = /posy.jpg 65 | negy = /negy.jpg 66 | negx = /negx.jpg 67 | posx = /posx.jpg 68 | posz = /posz.jpg 69 | negz = /negz.jpg 70 | } 71 | } 72 | 73 | object = { 74 | ball = { 75 | geometry = ball 76 | material = ball 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /lib/nmesh/transform.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "transform.h" 4 | 5 | namespace nmesh { 6 | namespace mutator { 7 | 8 | void translate(object_t &object, nmath::scalar_t x, nmath::scalar_t y, nmath::scalar_t z) 9 | { 10 | for (size_t i=0; i < object.attributes.v.size(); i+=3) { 11 | object.attributes.v[i ] += x; 12 | object.attributes.v[i+1] += y; 13 | object.attributes.v[i+2] += z; 14 | } 15 | } 16 | 17 | void scale(object_t &object, nmath::scalar_t x, nmath::scalar_t y, nmath::scalar_t z) 18 | { 19 | for (size_t i=0; i < object.attributes.v.size(); i+=3) { 20 | object.attributes.v[i ] *= x; 21 | object.attributes.v[i+1] *= y; 22 | object.attributes.v[i+2] *= z; 23 | } 24 | } 25 | 26 | void rotate(object_t &object, nmath::scalar_t x, nmath::scalar_t y, nmath::scalar_t z) 27 | { 28 | nmath::Matrix4x4f mat; 29 | mat.set_rotation(nmath::Vector3f(x, y, z)); 30 | 31 | for (size_t i=0; i < object.attributes.v.size(); i+=3) { 32 | nmath::Vector3f v(object.attributes.v[i ] 33 | , object.attributes.v[i+1] 34 | , object.attributes.v[i+2]); 35 | 36 | v.transform(mat); 37 | 38 | object.attributes.v[i ] = v.x; 39 | object.attributes.v[i+1] = v.y; 40 | object.attributes.v[i+2] = v.z; 41 | } 42 | 43 | for (size_t i=0; i < object.attributes.n.size(); i+=3) { 44 | nmath::Vector3f n(object.attributes.n[i ] 45 | , object.attributes.n[i+1] 46 | , object.attributes.n[i+2]); 47 | 48 | n.transform(mat); 49 | 50 | object.attributes.n[i ] = n.x; 51 | object.attributes.n[i+1] = n.y; 52 | object.attributes.n[i+2] = n.z; 53 | } 54 | } 55 | 56 | } /* namespace mutator */ 57 | } /* namespace nmesh */ 58 | -------------------------------------------------------------------------------- /src/xtcore/camera/cubemap.cc: -------------------------------------------------------------------------------- 1 | #include "cubemap.h" 2 | 3 | /* Cubemap Vertical Strip 4 | ** The faces are ordered as: +x -x +y -y +z -z 5 | **/ 6 | 7 | using nmath::scalar_t; 8 | using nmath::Vector3f; 9 | using nmath::Matrix4x4f; 10 | 11 | namespace xtcore { 12 | namespace camera { 13 | 14 | const char* Cubemap::get_type() const 15 | { 16 | return "Cubemap Projection"; 17 | } 18 | 19 | Ray Cubemap::get_primary_ray(float x, float y, float width, float height) 20 | { 21 | Ray ray; 22 | 23 | size_t face_size = (size_t)(height) / 6; 24 | size_t face = (size_t)(y) / face_size; 25 | 26 | Vector3f rx, ry, rz, up, camdir; 27 | 28 | switch(face) { 29 | case 0: camdir = Vector3f( 1, 0, 0); up = Vector3f(0, 1, 0); break; 30 | case 1: camdir = Vector3f(-1, 0, 0); up = Vector3f(0, 1, 0); break; 31 | case 2: camdir = Vector3f( 0, 1, 0); up = Vector3f(0, 0,-1); break; 32 | case 3: camdir = Vector3f( 0,-1, 0); up = Vector3f(0, 0, 1); break; 33 | case 4: camdir = Vector3f( 0, 0, 1); up = Vector3f(0, 1, 0); break; 34 | case 5: camdir = Vector3f( 0, 0,-1); up = Vector3f(0, 1, 0); break; 35 | } 36 | 37 | y -= (float)(face * face_size); 38 | 39 | ray.origin = position; 40 | ray.direction.x = (2.f * (scalar_t)x / (scalar_t)width ) - 1.f; 41 | ray.direction.y = (2.f * (scalar_t)y / (scalar_t)face_size) - 1.f; 42 | ray.direction.z = 1.f; 43 | ray.direction.normalize(); 44 | 45 | rz = camdir; 46 | rx = cross(up, rz); 47 | rx.normalize(); 48 | ry = cross(rx, rz); 49 | ry.normalize(); 50 | 51 | Matrix4x4f mat(rx.x, ry.x, rz.x, 0, 52 | rx.y, ry.y, rz.y, 0, 53 | rx.z, ry.z, rz.z, 0, 54 | 0, 0, 0, 1); 55 | 56 | ray.direction.transform(mat); 57 | ray.direction.normalize(); 58 | 59 | return ray; 60 | } 61 | 62 | } /* namespace camera */ 63 | } /* namespace xtcore */ 64 | -------------------------------------------------------------------------------- /src/frontend/gui/graphics.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define NANOSVG_IMPLEMENTATION 4 | #include "nanosvg/nanosvg.h" 5 | #include 6 | 7 | namespace gui { 8 | namespace graphics { 9 | 10 | typedef struct { 11 | NSVGimage *img; 12 | } graphic_t; 13 | 14 | int load(graphic_t *vec, const char *src, float size) 15 | { 16 | if (!vec) return -1; 17 | size_t length = strlen(src); 18 | char *copy = (char*)malloc(sizeof(char) * (length + 1 ) ); 19 | for (size_t i = 0; i < length; ++i) copy[i] = (char)(src[i]); 20 | copy[length] = 0; 21 | vec->img = nsvgParse(copy, "px", size); 22 | free(copy); 23 | return 0; 24 | } 25 | 26 | int kill(graphic_t *vec) 27 | { 28 | if (!vec) return -1; 29 | nsvgDelete(vec->img); 30 | return 0; 31 | } 32 | 33 | void draw(NSVGimage *image, float position_x, float position_y) 34 | { 35 | ImVec2 pos = ImVec2(position_x, position_y); 36 | ImDrawList* draw_list = ImGui::GetWindowDrawList(); 37 | 38 | for (NSVGshape *shape = image->shapes; shape != NULL; shape = shape->next) { 39 | for (NSVGpath *path = shape->paths; path != NULL; path = path->next) { 40 | for (int i = 0; i < path->npts-1; i += 3) { 41 | float* p = &path->pts[i*2]; 42 | 43 | ImColor col = ImColor(shape->stroke.color); 44 | col.Value.w = shape->opacity * 255.f; 45 | 46 | draw_list->AddBezierCurve(ImVec2(pos.x + p[0], pos.y + p[1]) 47 | ,ImVec2(pos.x + p[2], pos.y + p[3]) 48 | ,ImVec2(pos.x + p[4], pos.y + p[5]) 49 | ,ImVec2(pos.x + p[6], pos.y + p[7]) 50 | ,col, shape->strokeWidth, 4); 51 | } 52 | } 53 | } 54 | 55 | ImGui::InvisibleButton("", ImVec2(image->width, image->height)); 56 | } 57 | 58 | } /* namespace graphics */ 59 | } /* namespace gui */ 60 | -------------------------------------------------------------------------------- /src/xtcore/material.h: -------------------------------------------------------------------------------- 1 | #ifndef XTCORE_MATERIAL_H_INCLUDED 2 | #define XTCORE_MATERIAL_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include "math/hitrecord.h" 7 | #include "math/ray.h" 8 | #include "sampler.h" 9 | #include "camera.h" 10 | #include "matdefs.h" 11 | #include "emitter.h" 12 | 13 | using nmath::Vector3f; 14 | using nimg::ColorRGBf; 15 | using xtcore::sampler::ISampler; 16 | 17 | namespace xtcore { 18 | namespace asset { 19 | 20 | class IMaterial 21 | { 22 | public: 23 | IMaterial(); 24 | virtual ~IMaterial(); 25 | 26 | bool is_emissive() const; 27 | 28 | virtual bool shade( 29 | ColorRGBf &intensity 30 | , const ICamera *cam 31 | , const emitter_t *emitter 32 | , const hit_record_t &hit_record) const = 0; 33 | 34 | virtual bool sample_path( 35 | hit_result_t &hit_result 36 | , const hit_record_t &hit_record 37 | ) const = 0; 38 | 39 | float get_scalar(const char *name) const; 40 | ColorRGBf get_sample(const char *name, const Vector3f &tc) const; 41 | float& get_scalar_by_index (size_t idx, std::string *name=0); 42 | ISampler* get_sampler_by_index (size_t idx, std::string *name=0); 43 | 44 | size_t get_scalar_count() const; 45 | size_t get_sampler_count() const; 46 | 47 | int add_sampler (const char *name, ISampler *sampler); 48 | int add_scalar (const char *name, float scalar); 49 | int purge_sampler (const char *name); 50 | int purge_scalar (const char *name); 51 | 52 | private: 53 | std::map m_scalars; 54 | std::map m_samplers; 55 | 56 | }; 57 | 58 | } /* namespace asset */ 59 | } /* namespace xtcore */ 60 | 61 | #include "material/lambert.h" 62 | #include "material/phong.h" 63 | #include "material/blinnphong.h" 64 | #include "material/emissive.h" 65 | #include "material/dielectric.h" 66 | 67 | #endif /* XTCORE_MATERIAL_H_INCLUDED */ 68 | -------------------------------------------------------------------------------- /src/xtcore/integrator/depth/integrator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "integrator.h" 5 | #include "util/raygraph.h" 6 | 7 | namespace xtcore { 8 | namespace integrator { 9 | namespace depth { 10 | 11 | void Integrator::render_tile(xtcore::render::tile_t *tile) 12 | { 13 | xtcore::asset::ICamera *cam = ctx->scene.get_camera(ctx->params.camera); 14 | 15 | while (tile->samples.count() > 0) { 16 | xtcore::antialiasing::sample_rgba_t sample; 17 | tile->samples.pop(sample); 18 | 19 | nimg::ColorRGBAf color_pixel; 20 | 21 | tile->read(sample.pixel.x, sample.pixel.y, color_pixel); 22 | 23 | xtcore::hit_record_t hit_record; 24 | 25 | xtcore::Ray ray = cam->get_primary_ray( 26 | sample.coords.x, sample.coords.y 27 | , (float)(ctx->params.width) 28 | , (float)(ctx->params.height) 29 | ); 30 | 31 | float depth = 0.f; 32 | 33 | bool found_hit = ctx->scene.intersection(ray, hit_record); 34 | 35 | if (found_hit) { 36 | depth = 1. / log((ray.origin - hit_record.point).length()); 37 | depth = color_pixel.r() + depth * sample.weight; 38 | color_pixel = nimg::ColorRGBAf(depth, depth, depth, 1); 39 | } 40 | 41 | color_pixel.a(1); 42 | 43 | raygraph::path_t path; 44 | raygraph::sample_t sample0, sample1; 45 | 46 | sample0.position = ray.origin; 47 | sample1.position = hit_record.point; 48 | sample1.color = color_pixel; 49 | path.samples.emplace_back(std::move(sample0)); 50 | path.samples.emplace_back(std::move(sample1)); 51 | tile->raygraph_bundle.paths.emplace_back(std::move(path)); 52 | 53 | tile->write(floor(sample.pixel.x), floor(sample.pixel.y), color_pixel); 54 | } 55 | } 56 | 57 | } /* namespace depth */ 58 | } /* namespace integrator */ 59 | } /* namespace xtcore */ 60 | -------------------------------------------------------------------------------- /lib/nimg/diff.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "luminance.h" 5 | #include "diff.h" 6 | 7 | namespace nimg { 8 | namespace eval { 9 | 10 | int diff(const Pixmap &src, const Pixmap &dst, const float threshold) 11 | { 12 | if ( src.width() != dst.width() 13 | || src.height() != dst.height() 14 | ) return -1; 15 | 16 | int res = 0; 17 | 18 | for (size_t j = 0; j < src.height(); ++j) { 19 | for (size_t i = 0; i < src.width(); ++i) { 20 | 21 | ColorRGBAf val_src = src.pixel_ro(i, j); 22 | ColorRGBAf val_dst = dst.pixel_ro(i, j); 23 | 24 | ColorRGBAf dist = val_src - val_dst; 25 | 26 | if ( fabs(dist.r()) > threshold 27 | || fabs(dist.g()) > threshold 28 | || fabs(dist.b()) > threshold 29 | || fabs(dist.a()) > threshold 30 | ) ++res; 31 | } 32 | } 33 | 34 | return res; 35 | } 36 | 37 | float diff_euclid(const Pixmap &src, const Pixmap &dst) 38 | { 39 | if ( src.width() != dst.width() 40 | || src.height() != dst.height() 41 | ) return -1; 42 | 43 | std::vector val; 44 | 45 | for (size_t j = 0; j < src.height(); ++j) { 46 | for (size_t i = 0; i < src.width(); ++i) { 47 | 48 | ColorRGBAf val_src = src.pixel_ro(i, j); 49 | ColorRGBAf val_dst = dst.pixel_ro(i, j); 50 | 51 | float a = luminance(val_src); 52 | float b = luminance(val_dst); 53 | 54 | float res = fabs(a - b); 55 | 56 | val.push_back(res); 57 | } 58 | } 59 | 60 | std::vector::iterator it = val.begin(); 61 | std::vector::iterator et = val.end(); 62 | 63 | float total = 0; 64 | for (; it != et; ++it) { 65 | total += (*it); 66 | } 67 | 68 | float res = sqrtf(total); 69 | 70 | return res; 71 | } 72 | 73 | } /* namespace eval */ 74 | } /* namespace nimg */ 75 | -------------------------------------------------------------------------------- /lib/nplatform/byteorder.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of xtracer. 4 | 5 | byteorder.c 6 | Endianness related functions 7 | 8 | Copyright (C) 2008, 2010 9 | Papadopoulos Nikolaos 10 | 11 | This library is free software; you can redistribute it and/or 12 | modify it under the terms of the GNU Lesser General Public 13 | License as published by the Free Software Foundation; either 14 | version 3 of the License, or (at your option) any later version. 15 | 16 | This library is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | Lesser General Public License for more details. 20 | 21 | You should have received a copy of the GNU Lesser General 22 | Public License along with this library; if not, write to the 23 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | Boston, MA 02110-1301 USA 25 | 26 | */ 27 | 28 | #include "byteorder.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif /* __cplusplus */ 33 | 34 | short endian() /* returns the machine endianess code */ 35 | { 36 | union 37 | { 38 | uint32_t i; 39 | uint8_t c[4]; 40 | } bint = {0x01020304}; 41 | 42 | switch (bint.c[0]) 43 | { 44 | case 0x01: return ENDIAN_BIG; 45 | case 0x04: return ENDIAN_LITTLE; 46 | } 47 | return ENDIAN_UNKNOWN; 48 | } 49 | 50 | #define ENDIAN_STRING_UNKNOWN "Unknown" 51 | #define ENDIAN_STRING_LITTLE "Little" 52 | #define ENDIAN_STRING_BIG "Big" 53 | 54 | char* endian_string() 55 | { 56 | switch (endian()) 57 | { 58 | case ENDIAN_BIG: return ENDIAN_STRING_BIG; 59 | case ENDIAN_LITTLE: return ENDIAN_STRING_LITTLE; 60 | } 61 | return ENDIAN_STRING_UNKNOWN; 62 | } 63 | 64 | #ifdef __cplusplus 65 | } /* extern */ 66 | #endif /* __cplusplus */ 67 | -------------------------------------------------------------------------------- /src/xtcore/integrator/ao/integrator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "integrator.h" 5 | 6 | namespace xtcore { 7 | namespace integrator { 8 | namespace ao { 9 | 10 | #define MAX_DISTANCE 100.0f 11 | 12 | void Integrator::render_tile(xtcore::render::tile_t *tile) 13 | { 14 | xtcore::asset::ICamera *cam = ctx->scene.get_camera(ctx->params.camera); 15 | 16 | while (tile->samples.count() > 0) { 17 | xtcore::antialiasing::sample_rgba_t sample; 18 | tile->samples.pop(sample); 19 | 20 | xtcore::hit_record_t hit_record; 21 | 22 | nimg::ColorRGBAf color_pixel; 23 | 24 | tile->read(sample.pixel.x, sample.pixel.y, color_pixel); 25 | 26 | nmath::Vector3f acc_ao = nmath::Vector3f(color_pixel.r(), color_pixel.g(), color_pixel.b()); 27 | 28 | xtcore::Ray ray = cam->get_primary_ray( 29 | sample.coords.x, sample.coords.y 30 | , (float)(ctx->params.width) 31 | , (float)(ctx->params.height)); 32 | 33 | float w = 1.0f; 34 | 35 | if (ctx->scene.intersection(ray, hit_record)) { 36 | Ray ao_ray; 37 | ao_ray.direction = nmath::sample::hemisphere(hit_record.normal, hit_record.normal); 38 | ao_ray.origin = hit_record.point + hit_record.normal * EPSILON; 39 | 40 | xtcore::hit_record_t ao_hit_record; 41 | 42 | if (ctx->scene.intersection(ao_ray, ao_hit_record)) { 43 | float dist = (ao_hit_record.point - ao_ray.origin).length(); 44 | w = nmath::min(dist, MAX_DISTANCE) / MAX_DISTANCE; 45 | } 46 | } 47 | 48 | acc_ao += w * sample.weight; 49 | 50 | color_pixel = nimg::ColorRGBAf(acc_ao.x, acc_ao.y, acc_ao.z, 1.f); 51 | tile->write(floor(sample.pixel.x), floor(sample.pixel.y), color_pixel); 52 | } 53 | } 54 | 55 | } /* namespace ao */ 56 | } /* namespace integrator */ 57 | } /* namespace xtcore */ 58 | -------------------------------------------------------------------------------- /src/frontend/gui/workspace.h: -------------------------------------------------------------------------------- 1 | #ifndef XTGUI_GUI_WORKSPACE_H_INCLUDED 2 | #define XTGUI_GUI_WORKSPACE_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "graph.h" 13 | #include "opengl.h" 14 | 15 | #define DEFAULT_GAMMA (2.2) 16 | 17 | enum WS_STATUS 18 | { 19 | WS_STATUS_INVALID 20 | , WS_STATUS_LOADED 21 | , WS_STATUS_PROCESSING 22 | }; 23 | 24 | enum WS_RMODE 25 | { 26 | WS_RMODE_SINGLE 27 | , WS_RMODE_CONTINUOUS 28 | }; 29 | 30 | struct ws_handler_t : public xtcore::render::tile_event_handler_t 31 | { 32 | ws_handler_t(std::mutex *m); 33 | std::queue tiles; 34 | std::mutex *mut; 35 | void handle_event(xtcore::render::tile_t *tile); 36 | xtcore::render::tile_t *pop(); 37 | }; 38 | 39 | struct workspace_t 40 | { 41 | WS_STATUS status; 42 | GLuint texture; 43 | float zoom_multiplier; 44 | std::string source_file; 45 | xtcore::render::IIntegrator *integrator; 46 | xtcore::render::context_t context; 47 | 48 | void load(); 49 | void prepare(); 50 | void render(); 51 | void update(); 52 | void setup_callbacks(); 53 | 54 | bool is_idle(); 55 | bool is_rendering(); 56 | 57 | float progress; 58 | 59 | int block_begin(void *p); 60 | int block_done(void *p); 61 | 62 | ws_handler_t handler_init; 63 | ws_handler_t handler_done; 64 | 65 | std::mutex m; 66 | 67 | float gamma; 68 | 69 | Timer timer; 70 | 71 | bool clear_buffer; 72 | bool show_tile_updates; 73 | 74 | WS_RMODE rmode; 75 | 76 | workspace_t(); 77 | ~workspace_t(); 78 | 79 | 80 | // Editor 81 | ImVec2 scroll_position; 82 | gui::graph::graph_t graph; 83 | }; 84 | 85 | #endif /* XTGUI_GUI_WORKSPACE_H_INCLUDED */ 86 | -------------------------------------------------------------------------------- /scene/7.9.scn: -------------------------------------------------------------------------------- 1 | title = Scanned Face 2 | descr = 3d scan by TEN24 (http://www.3dscanstore.com/) 3 | versn = 0.1 4 | 5 | path_data = data 6 | path_geometry = /geometry/ten24/Free+Head 7 | 8 | environment = { 9 | type = gradient 10 | config = { 11 | a = col3(1,1,1) 12 | b = col3(0.5,0.7,1.0) 13 | } 14 | } 15 | 16 | camera = { 17 | default = { 18 | type = thin-lens 19 | fov = 45 20 | position = vec3(0,110,250) 21 | target = vec3(0,90,30) 22 | up = vec3(0,1,0) 23 | aperture = 10 24 | flength = 200 25 | } 26 | 27 | close = { 28 | type = thin-lens 29 | fov = 45 30 | position = vec3(0,110,200) 31 | target = vec3(0,90,30) 32 | up = vec3(0,1,0) 33 | aperture = 15 34 | flength = 150 35 | } 36 | 37 | ods = { 38 | type = ods 39 | ipd = 1.5 40 | position = vec3(0, 50,100) 41 | } 42 | } 43 | 44 | geometry = { 45 | sat1 = { 46 | type = sphere 47 | radius = 50 48 | 49 | position = { 50 | x = 88 51 | y = 15 52 | z = 170 53 | } 54 | 55 | intensity = { 56 | r = 1 57 | g = 1 58 | b = 1 59 | } 60 | } 61 | } 62 | 63 | material = { 64 | light = { 65 | type = lambert 66 | 67 | properties = { 68 | samplers = { 69 | emissive = { 70 | type = color 71 | value = col3(1,1,1) 72 | } 73 | } 74 | } 75 | } 76 | } 77 | 78 | object = { 79 | head = { 80 | geometry = head 81 | material = head 82 | } 83 | 84 | l0 = { 85 | geometry = sat1 86 | material = light 87 | } 88 | 89 | head = { 90 | source = /Repack/Head.OBJ 91 | prefix = head_ 92 | } 93 | 94 | jacket = { 95 | source = /Repack/Jacket.OBJ 96 | prefix = jacket_ 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/xtcore/material/phong.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "macro.h" 5 | #include "phong.h" 6 | 7 | namespace xtcore { 8 | namespace asset { 9 | namespace material { 10 | 11 | bool Phong::shade( 12 | ColorRGBf &intensity 13 | , const ICamera *camera 14 | , const emitter_t *emitter 15 | , const hit_record_t &hit_record) const 16 | { 17 | Vector3f light_dir = (emitter->position - hit_record.point).normalized(); 18 | 19 | nmath::scalar_t d = nmath::max(0, dot(light_dir, hit_record.normal)); 20 | 21 | Vector3f ray = (camera->position - hit_record.point).normalized(); 22 | 23 | Vector3f r = (light_dir.reflected(hit_record.normal)).normalized(); 24 | 25 | nmath::scalar_t rmv = nmath::max(0, dot(r, ray)); 26 | 27 | intensity += emitter->intensity * 28 | ( (d * get_sample(MAT_SAMPLER_DIFFUSE, hit_record.texcoord)) 29 | + (get_sample(MAT_SAMPLER_SPECULAR, hit_record.texcoord) * pow((long double)rmv, (long double)get_scalar(MAT_SCALART_EXPONENT))) 30 | ); 31 | 32 | return true; 33 | } 34 | 35 | bool Phong::sample_path( 36 | hit_result_t &hit_result 37 | , const hit_record_t &hit_record 38 | ) const 39 | { 40 | hit_result.ray.origin = hit_record.point + hit_record.normal * EPSILON; 41 | scalar_t s = get_scalar("reflectance"); 42 | scalar_t k = nmath::prng_c(0.0f, 1.0f); 43 | 44 | if (k > s) { 45 | hit_result.intensity = get_sample("diffuse", hit_record.texcoord); 46 | hit_result.ray.direction = nmath::sample::diffuse(hit_record.normal); 47 | } 48 | else { 49 | hit_result.intensity = get_sample("specular", hit_record.texcoord); 50 | scalar_t exp = get_scalar("exponent"); 51 | hit_result.ray.direction = nmath::sample::lobe(hit_record.normal, -hit_record.incident_direction, exp); 52 | } 53 | 54 | return true; 55 | } 56 | 57 | } /* namespace material */ 58 | } /* namespace asset */ 59 | } /* namespace xtcore */ 60 | -------------------------------------------------------------------------------- /src/xtcore/midi.cc: -------------------------------------------------------------------------------- 1 | #include "rtmidi/RtMidi.h" 2 | #include "memutil.tml" 3 | #include "config.h" 4 | #include "log.h" 5 | #include "midi.h" 6 | 7 | namespace xtcore { 8 | namespace midi { 9 | 10 | #if FEATURE_IS_INCLUDED(FEATURE_MIDI) 11 | #error "This should not happen" 12 | RtMidiIn *_midiin = 0; 13 | 14 | int init() 15 | { 16 | try { _midiin = new RtMidiIn(); } 17 | catch (RtMidiError &error) { 18 | Log::handle().post_error("%s", error.std::exception::what()); 19 | return -1; 20 | } 21 | 22 | return 0; 23 | } 24 | 25 | int deinit() 26 | { 27 | xtcore::memory::safe_delete(_midiin); 28 | return 0; 29 | } 30 | 31 | int detect(devices_t *devs) 32 | { 33 | if (!devs ) return -3; 34 | if (!_midiin) return -2; 35 | 36 | size_t ports = _midiin->getPortCount(); 37 | for (size_t i = 0; i < ports; ++i) { 38 | device_t dev; 39 | devs->devices.push_back(dev); 40 | device_t *d = &(devs->devices.back()); 41 | 42 | d->port = i+1; 43 | try { d->name = _midiin->getPortName(i); } 44 | catch (RtMidiError &error) { 45 | Log::handle().post_error("%s", error.std::exception::what()); 46 | return -1; 47 | } 48 | } 49 | 50 | return 0; 51 | } 52 | 53 | int open(device_t *dev) 54 | { 55 | if (!dev ) return -3; 56 | if (!_midiin) return -2; 57 | 58 | _midiin->openPort(dev->port); 59 | 60 | // Don't ignore sysex, timing, or active sensing messages. 61 | _midiin->ignoreTypes(false, false, false); 62 | 63 | return 0; 64 | } 65 | 66 | int close(device_t *dev) 67 | { 68 | if (!dev ) return -3; 69 | if (!_midiin) return -2; 70 | 71 | _midiin->closePort(); 72 | 73 | return 0; 74 | } 75 | 76 | #else 77 | 78 | int init() { return 0; } 79 | int deinit() { return 0; } 80 | int detect(devices_t*) { return 0; } 81 | int open(device_t*) { return 0; } 82 | int close(device_t*) { return 0; } 83 | int read(device_t*) { return 0; } 84 | 85 | #endif /* FEATURE_MIDI */ 86 | 87 | } /* namespace midi */ 88 | } /* namespace xtcore */ 89 | -------------------------------------------------------------------------------- /src/xtcore/integrator/embree/integrator.cc: -------------------------------------------------------------------------------- 1 | #include "integrator.h" 2 | 3 | #if FEATURE_IS_INCLUDED(FEATURE_EMBREE) 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace xtcore { 16 | namespace integrator { 17 | namespace embree { 18 | 19 | void Integrator::setup_auxiliary() 20 | { 21 | // create Embree device at application startup 22 | m_device = rtcNewDevice(0); 23 | // create scene 24 | m_scene = rtcNewScene(m_device); 25 | } 26 | 27 | void Integrator::clean_auxiliary() 28 | { 29 | // release objects 30 | rtcReleaseScene(m_scene); 31 | rtcReleaseDevice(m_device); 32 | } 33 | 34 | void Integrator::render_tile(xtcore::render::tile_t *tile) 35 | { 36 | xtcore::asset::ICamera *cam = ctx->scene.get_camera(ctx->params.camera); 37 | 38 | while (tile->samples.count() > 0) { 39 | xtcore::antialiasing::sample_rgba_t sample; 40 | tile->samples.pop(sample); 41 | 42 | nimg::ColorRGBAf color_pixel; 43 | nimg::ColorRGBf color_sample; 44 | 45 | tile->read(sample.pixel.x, sample.pixel.y, color_pixel); 46 | 47 | xtcore::hit_record_t hit_record; 48 | 49 | xtcore::Ray ray = cam->get_primary_ray( 50 | sample.coords.x, sample.coords.y 51 | , (float)(ctx->params.width) 52 | , (float)(ctx->params.height) 53 | ); 54 | 55 | float embree = 0.f; 56 | 57 | if (ctx->scene.intersection(ray, hit_record)) { 58 | embree = 1. / log((ray.origin - hit_record.point).length()); 59 | } 60 | 61 | color_sample += nimg::ColorRGBf(embree, embree, embree) * (1. / ctx->params.samples); 62 | tile->write(floor(sample.pixel.x), floor(sample.pixel.y), nimg::ColorRGBf(color_pixel) + color_sample * sample.weight); 63 | } 64 | } 65 | 66 | } /* namespace embree */ 67 | } /* namespace integrator */ 68 | } /* namespace xtcore */ 69 | 70 | #endif /* FEATURE_EMBREE */ 71 | --------------------------------------------------------------------------------