├── .gitignore ├── example-cornelbox ├── Makefile ├── Project.xcconfig ├── addons.make ├── bin │ └── data │ │ ├── cornell_box.ecs │ │ ├── cornell_box.mtl │ │ └── cornell_box.obj ├── config.make ├── ofxEmbreeCornellBox.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── ofxSpineExample Debug.xcscheme │ │ └── ofxSpineExample Release.xcscheme ├── openFrameworks-Info.plist └── src │ ├── main.cpp │ ├── testApp.cpp │ └── testApp.h ├── example-crown ├── Makefile ├── Project.xcconfig ├── addons.make ├── bin │ └── data │ │ └── readme.txt ├── config.make ├── ofxEmbreeExampleCrown.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── ofxSpineExample Debug.xcscheme │ │ └── ofxSpineExample Release.xcscheme ├── openFrameworks-Info.plist └── src │ ├── main.cpp │ ├── testApp.cpp │ └── testApp.h ├── example-materials ├── Makefile ├── Project.xcconfig ├── addons.make ├── bin │ └── data │ │ └── NewSquirrel.3ds ├── config.make ├── ofxEmbreeMaterial.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── ofxSpineExample Debug.xcscheme │ │ └── ofxSpineExample Release.xcscheme ├── openFrameworks-Info.plist └── src │ ├── main.cpp │ ├── testApp.cpp │ └── testApp.h ├── example-ofmesh ├── Makefile ├── Project.xcconfig ├── addons.make ├── bin │ └── data │ │ └── lines.ppm ├── config.make ├── ofxEmbreeOFMesh.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── ofxSpineExample Debug.xcscheme │ │ └── ofxSpineExample Release.xcscheme ├── openFrameworks-Info.plist └── src │ ├── main.cpp │ ├── testApp.cpp │ └── testApp.h ├── libs └── embree │ ├── include │ ├── image │ │ └── image.h │ ├── lexers │ │ ├── parsestream.h │ │ ├── stream.h │ │ ├── streamfilters.h │ │ ├── stringstream.h │ │ └── tokenstream.h │ ├── loaders │ │ ├── loaders.h │ │ ├── obj_loader.h │ │ ├── xml_loader.h │ │ └── xml_parser.h │ ├── math │ │ ├── affinespace.h │ │ ├── bbox.h │ │ ├── col3.h │ │ ├── col3f_sse.h │ │ ├── linearspace3.h │ │ ├── math.h │ │ ├── permutation.h │ │ ├── quaternion.h │ │ ├── random.h │ │ ├── vec2.h │ │ ├── vec3.h │ │ ├── vec3b_sse.h │ │ ├── vec3f_sse.h │ │ ├── vec3i_sse.h │ │ └── vec4.h │ ├── renderer │ │ ├── api │ │ │ ├── data.h │ │ │ ├── datastream.h │ │ │ ├── device.h │ │ │ ├── framebuffer.h │ │ │ ├── handle.h │ │ │ ├── instance.h │ │ │ ├── parms.h │ │ │ ├── render_device.h │ │ │ ├── scene.h │ │ │ ├── swapchain.h │ │ │ └── variant.h │ │ ├── brdfs │ │ │ ├── brdf.h │ │ │ ├── compositedbrdf.h │ │ │ ├── conductor.h │ │ │ ├── dielectric.h │ │ │ ├── dielectriclayer.h │ │ │ ├── lambertian.h │ │ │ ├── microfacet.h │ │ │ ├── microfacet │ │ │ │ ├── anisotropic_beckmann_distribution.h │ │ │ │ ├── anisotropic_power_cosine_distribution.h │ │ │ │ ├── beckmann_distribution.h │ │ │ │ ├── fresnel.h │ │ │ │ └── power_cosine_distribution.h │ │ │ ├── minnaert.h │ │ │ ├── optics.h │ │ │ ├── reflection.h │ │ │ ├── specular.h │ │ │ ├── transmission.h │ │ │ └── velvety.h │ │ ├── cameras │ │ │ ├── camera.h │ │ │ ├── depthoffieldcamera.h │ │ │ └── pinholecamera.h │ │ ├── default.h │ │ ├── filters │ │ │ ├── boxfilter.h │ │ │ ├── bsplinefilter.h │ │ │ └── filter.h │ │ ├── integrators │ │ │ ├── integrator.h │ │ │ └── pathtraceintegrator.h │ │ ├── lights │ │ │ ├── ambientlight.h │ │ │ ├── directionallight.h │ │ │ ├── distantlight.h │ │ │ ├── hdrilight.h │ │ │ ├── light.h │ │ │ ├── pointlight.h │ │ │ ├── spotlight.h │ │ │ └── trianglelight.h │ │ ├── materials │ │ │ ├── dielectric.h │ │ │ ├── material.h │ │ │ ├── matte.h │ │ │ ├── matte_textured.h │ │ │ ├── medium.h │ │ │ ├── metal.h │ │ │ ├── metallicpaint.h │ │ │ ├── mirror.h │ │ │ ├── obj.h │ │ │ ├── plastic.h │ │ │ ├── thindielectric.h │ │ │ └── velvet.h │ │ ├── renderers │ │ │ ├── debugrenderer.h │ │ │ ├── integratorrenderer.h │ │ │ ├── progress.h │ │ │ └── renderer.h │ │ ├── samplers │ │ │ ├── distribution1d.h │ │ │ ├── distribution2d.h │ │ │ ├── patterns.h │ │ │ ├── sample.h │ │ │ ├── sampler.h │ │ │ └── shapesampler.h │ │ ├── shapes │ │ │ ├── differentialgeometry.h │ │ │ ├── shape.h │ │ │ ├── sphere.h │ │ │ ├── triangle.h │ │ │ ├── trianglemesh.h │ │ │ └── trianglemesh_normals.h │ │ ├── textures │ │ │ ├── nearestneighbor.h │ │ │ └── texture.h │ │ └── tonemappers │ │ │ ├── defaulttonemapper.h │ │ │ └── tonemapper.h │ ├── rtcore │ │ ├── bvh2 │ │ │ ├── bvh2.h │ │ │ ├── bvh2_builder.h │ │ │ └── bvh2_intersector.h │ │ ├── bvh4 │ │ │ ├── bvh4.h │ │ │ ├── bvh4_builder.h │ │ │ └── bvh4_intersector.h │ │ ├── bvh4mb │ │ │ ├── bvh4mb.h │ │ │ ├── bvh4mb_builder.h │ │ │ └── bvh4mb_intersector.h │ │ ├── common │ │ │ ├── accel.h │ │ │ ├── alloc.h │ │ │ ├── atomic_set.h │ │ │ ├── basenode.h │ │ │ ├── default.h │ │ │ ├── heuristic_binning.h │ │ │ ├── heuristic_spatial.h │ │ │ ├── heuristics.h │ │ │ ├── hit.h │ │ │ ├── intersector.h │ │ │ ├── primref.h │ │ │ ├── primrefalloc.h │ │ │ ├── primrefblock.h │ │ │ ├── primrefgen.h │ │ │ ├── ray.h │ │ │ ├── splitter.h │ │ │ ├── splitter_fallback.h │ │ │ ├── splitter_parallel.h │ │ │ ├── stack_item.h │ │ │ └── stat.h │ │ └── triangle │ │ │ ├── triangle.h │ │ │ ├── triangle1.h │ │ │ ├── triangle1_intersector1_moeller.h │ │ │ ├── triangle1i.h │ │ │ ├── triangle1i_intersector1_moeller.h │ │ │ ├── triangle1i_intersector1_pluecker.h │ │ │ ├── triangle1v.h │ │ │ ├── triangle1v_intersector1_moeller.h │ │ │ ├── triangle1v_intersector1_pluecker.h │ │ │ ├── triangle1xfm.h │ │ │ ├── triangle1xfm_intersector1_moeller.h │ │ │ ├── triangle4.h │ │ │ ├── triangle4_intersector1_moeller.h │ │ │ ├── triangle4i.h │ │ │ ├── triangle4i_intersector1_moeller.h │ │ │ ├── triangle4i_intersector1_moeller_mb.h │ │ │ ├── triangle4i_intersector1_pluecker.h │ │ │ ├── triangle4i_intersector1_pluecker_mb.h │ │ │ ├── triangle4v.h │ │ │ ├── triangle4v_intersector1_moeller.h │ │ │ ├── triangle4v_intersector1_pluecker.h │ │ │ ├── triangle4xfm.h │ │ │ ├── triangle4xfm_intersector1_moeller.h │ │ │ ├── triangle8.h │ │ │ ├── triangle8_intersector1_moeller.h │ │ │ └── triangles.h │ ├── simd │ │ ├── avx.h │ │ ├── avxb.h │ │ ├── avxf.h │ │ ├── avxi.h │ │ ├── immintrin_emu.h │ │ ├── pairb.h │ │ ├── pairf.h │ │ ├── pairi.h │ │ ├── simd.h │ │ ├── smmintrin_emu.h │ │ ├── sse.h │ │ ├── sse_special.h │ │ ├── sseb.h │ │ ├── ssef.h │ │ └── ssei.h │ └── sys │ │ ├── constants.h │ │ ├── filename.h │ │ ├── intrinsics.h │ │ ├── library.h │ │ ├── platform.h │ │ ├── ref.h │ │ ├── stl │ │ ├── array2d.h │ │ ├── string.h │ │ └── vector.h │ │ ├── sync │ │ ├── atomic.h │ │ ├── barrier.h │ │ ├── condition.h │ │ └── mutex.h │ │ ├── sysinfo.h │ │ ├── taskscheduler.h │ │ ├── taskscheduler_standard.h │ │ └── thread.h │ └── lib │ └── osx32 │ ├── libimage.a │ ├── liblexers.a │ ├── libloaders.a │ ├── librenderer.a │ ├── librtcore.a │ └── libsys.a ├── ofxaddons_thumbnail.png ├── readme.md └── src ├── Camera.cpp ├── Camera.h ├── Materials.cpp ├── Materials.h ├── Renderer.cpp ├── Renderer.h ├── Vhandle.h ├── ofxEmbree.cpp └── ofxEmbree.h /.gitignore: -------------------------------------------------------------------------------- 1 | example-crown/bin/data/crown/* 2 | 3 | # OS-specific ignore patterns 4 | 5 | #Linux 6 | /*/*/Makefile 7 | /*/*/config.make 8 | # Leave Android files in until project generation works 9 | !/android/*/Makefile 10 | !/android/*/config.make 11 | 12 | #Android 13 | /*/*/test link 14 | !/android/*/.cproject 15 | !/android/*/.project 16 | !/android/*/.settings 17 | 18 | 19 | # Some general ignore patterns 20 | 21 | build/ 22 | obj/ 23 | *.o 24 | Debug*/ 25 | Release*/ 26 | *.mode* 27 | *.app/ 28 | *.pyc 29 | .svn/ 30 | 31 | # IDE-specific ignore patterns 32 | 33 | #XCode 34 | *.pbxuser 35 | *.perspective 36 | *.perspectivev3 37 | *.mode1v3 38 | *.mode2v3 39 | #XCode 4 40 | xcuserdata 41 | *.xcworkspace 42 | 43 | #Code::Blocks 44 | *.depend 45 | *.layout 46 | 47 | #Visual Studio 48 | *.sdf 49 | *.opensdf 50 | *.suo 51 | *.pdb 52 | ipch/ 53 | 54 | #Eclipse 55 | .metadata 56 | local.properties 57 | .externalToolBuilders 58 | 59 | # OS-specific ignore patterns 60 | 61 | #Linux 62 | *~ 63 | # KDE 64 | .directory 65 | .AppleDouble 66 | 67 | #OSX 68 | .DS_Store 69 | *.swp 70 | *~.nib 71 | # Thumbnails 72 | ._* 73 | 74 | #Windows 75 | # Windows image file caches 76 | Thumbs.db 77 | # Folder config file 78 | Desktop.ini 79 | 80 | #Android 81 | .csettings 82 | /libs/openFrameworksCompiled/project/android/paths.make 83 | 84 | # Miscellaneous 85 | .mailmap 86 | 87 | -------------------------------------------------------------------------------- /example-cornelbox/Makefile: -------------------------------------------------------------------------------- 1 | include config.make 2 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 3 | -------------------------------------------------------------------------------- /example-cornelbox/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | 10 | OFX_EMBREE_HEADERS = "$(OF_PATH)/addons/ofxEmbree/libs/embree/include" "$(OF_PATH)/addons/ofxEmbree/libs/embree/include/renderer" 11 | 12 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) $(OFX_EMBREE_HEADERS) 13 | -------------------------------------------------------------------------------- /example-cornelbox/addons.make: -------------------------------------------------------------------------------- 1 | ofxEmbree -------------------------------------------------------------------------------- /example-cornelbox/bin/data/cornell_box.ecs: -------------------------------------------------------------------------------- 1 | -i cornell_box.obj 2 | -quadlight 213 548.77 227 130 0 0 0 0 105 50 50 50 3 | -vp 278 273 -800 -vi 278 273 0 -vu 0 1 0 -fov 37 4 | -renderer pathtracer { depth = 2 } 5 | 6 | 7 | -------------------------------------------------------------------------------- /example-cornelbox/bin/data/cornell_box.mtl: -------------------------------------------------------------------------------- 1 | newmtl white 2 | Ka 0 0 0 3 | Kd 1 1 1 4 | Ks 0 0 0 5 | 6 | newmtl red 7 | Ka 0 0 0 8 | Kd 1 0 0 9 | Ks 0 0 0 10 | 11 | newmtl green 12 | Ka 0 0 0 13 | Kd 0 1 0 14 | Ks 0 0 0 15 | 16 | newmtl blue 17 | Ka 0 0 0 18 | Kd 0 0 1 19 | Ks 0 0 0 20 | 21 | newmtl light 22 | Ka 20 20 20 23 | Kd 1 1 1 24 | Ks 0 0 0 25 | -------------------------------------------------------------------------------- /example-cornelbox/bin/data/cornell_box.obj: -------------------------------------------------------------------------------- 1 | # original cornell box data 2 | 3 | mtllib cornell_box.mtl 4 | 5 | o floor 6 | usemtl white 7 | v 552.8 0.0 0.0 8 | v 0.0 0.0 0.0 9 | v 0.0 0.0 559.2 10 | v 549.6 0.0 559.2 11 | 12 | v 130.0 0.0 65.0 13 | v 82.0 0.0 225.0 14 | v 240.0 0.0 272.0 15 | v 290.0 0.0 114.0 16 | 17 | v 423.0 0.0 247.0 18 | v 265.0 0.0 296.0 19 | v 314.0 0.0 456.0 20 | v 472.0 0.0 406.0 21 | 22 | f 1 2 3 4 23 | f 8 7 6 5 24 | f 12 11 10 9 25 | 26 | o light 27 | usemtl light 28 | v 343.0 548.0 227.0 29 | v 343.0 548.0 332.0 30 | v 213.0 548.0 332.0 31 | v 213.0 548.0 227.0 32 | #f -4 -3 -2 -1 33 | 34 | o ceiling 35 | usemtl white 36 | v 556.0 548.8 0.0 37 | v 556.0 548.8 559.2 38 | v 0.0 548.8 559.2 39 | v 0.0 548.8 0.0 40 | f -4 -3 -2 -1 41 | 42 | o back_wall 43 | usemtl white 44 | v 549.6 0.0 559.2 45 | v 0.0 0.0 559.2 46 | v 0.0 548.8 559.2 47 | v 556.0 548.8 559.2 48 | f -4 -3 -2 -1 49 | 50 | o front_wall 51 | usemtl blue 52 | v 549.6 0.0 0 53 | v 0.0 0.0 0 54 | v 0.0 548.8 0 55 | v 556.0 548.8 0 56 | #f -1 -2 -3 -4 57 | 58 | o green_wall 59 | usemtl green 60 | v 0.0 0.0 559.2 61 | v 0.0 0.0 0.0 62 | v 0.0 548.8 0.0 63 | v 0.0 548.8 559.2 64 | f -4 -3 -2 -1 65 | 66 | o red_wall 67 | usemtl red 68 | v 552.8 0.0 0.0 69 | v 549.6 0.0 559.2 70 | v 556.0 548.8 559.2 71 | v 556.0 548.8 0.0 72 | f -4 -3 -2 -1 73 | 74 | o short_block 75 | usemtl white 76 | 77 | v 130.0 165.0 65.0 78 | v 82.0 165.0 225.0 79 | v 240.0 165.0 272.0 80 | v 290.0 165.0 114.0 81 | f -4 -3 -2 -1 82 | 83 | v 290.0 0.0 114.0 84 | v 290.0 165.0 114.0 85 | v 240.0 165.0 272.0 86 | v 240.0 0.0 272.0 87 | f -4 -3 -2 -1 88 | 89 | v 130.0 0.0 65.0 90 | v 130.0 165.0 65.0 91 | v 290.0 165.0 114.0 92 | v 290.0 0.0 114.0 93 | f -4 -3 -2 -1 94 | 95 | v 82.0 0.0 225.0 96 | v 82.0 165.0 225.0 97 | v 130.0 165.0 65.0 98 | v 130.0 0.0 65.0 99 | f -4 -3 -2 -1 100 | 101 | v 240.0 0.0 272.0 102 | v 240.0 165.0 272.0 103 | v 82.0 165.0 225.0 104 | v 82.0 0.0 225.0 105 | f -4 -3 -2 -1 106 | 107 | o tall_block 108 | usemtl white 109 | 110 | v 423.0 330.0 247.0 111 | v 265.0 330.0 296.0 112 | v 314.0 330.0 456.0 113 | v 472.0 330.0 406.0 114 | f -4 -3 -2 -1 115 | 116 | usemtl white 117 | v 423.0 0.0 247.0 118 | v 423.0 330.0 247.0 119 | v 472.0 330.0 406.0 120 | v 472.0 0.0 406.0 121 | f -4 -3 -2 -1 122 | 123 | v 472.0 0.0 406.0 124 | v 472.0 330.0 406.0 125 | v 314.0 330.0 456.0 126 | v 314.0 0.0 456.0 127 | f -4 -3 -2 -1 128 | 129 | v 314.0 0.0 456.0 130 | v 314.0 330.0 456.0 131 | v 265.0 330.0 296.0 132 | v 265.0 0.0 296.0 133 | f -4 -3 -2 -1 134 | 135 | v 265.0 0.0 296.0 136 | v 265.0 330.0 296.0 137 | v 423.0 330.0 247.0 138 | v 423.0 0.0 247.0 139 | f -4 -3 -2 -1 140 | 141 | -------------------------------------------------------------------------------- /example-cornelbox/config.make: -------------------------------------------------------------------------------- 1 | # add custom variables to this file 2 | 3 | # OF_ROOT allows to move projects outside apps/* just set this variable to the 4 | # absoulte path to the OF root folder 5 | 6 | OF_ROOT = ../../.. 7 | 8 | 9 | # USER_CFLAGS allows to pass custom flags to the compiler 10 | # for example search paths like: 11 | # USER_CFLAGS = -I src/objects 12 | 13 | USER_CFLAGS = 14 | 15 | # USER_LDFLAGS allows to pass custom flags to the linker 16 | # for example libraries like: 17 | # USER_LD_FLAGS = libs/libawesomelib.a 18 | 19 | USER_LDFLAGS = 20 | 21 | 22 | # use this to add system libraries for example: 23 | # USER_LIBS = -lpango 24 | 25 | USER_LIBS = 26 | 27 | 28 | # change this to add different compiler optimizations to your project 29 | 30 | USER_COMPILER_OPTIMIZATION = -march=native -mtune=native -Os 31 | 32 | 33 | EXCLUDE_FROM_SOURCE="bin,.xcodeproj,obj,.git" 34 | -------------------------------------------------------------------------------- /example-cornelbox/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /example-cornelbox/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 512, 512, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /example-cornelbox/src/testApp.cpp: -------------------------------------------------------------------------------- 1 | #include "testApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void testApp::setup(){ 5 | 6 | cam.setup(ofPoint(278, 273, 200)); 7 | cam.setDistance(600); 8 | cam.setFov(55); 9 | 10 | renderer.setup(cam); 11 | renderer.loadScene("cornell_box.obj"); 12 | renderer.addQuadLight(ofPoint(213, 548.77, 227), ofPoint(130, 0, 0), ofPoint(0, 0, 105), ofColor(50, 50, 50)); 13 | renderer.setRecursionDepth(20); 14 | renderer.buildScene(); 15 | } 16 | 17 | void testApp::update(){ 18 | 19 | cam.update(); 20 | 21 | renderer.update(); 22 | renderer.renderGL(); 23 | } 24 | 25 | void testApp::draw(){ 26 | 27 | renderer.draw(0, 0); 28 | 29 | string stats; 30 | stats += "FPS : " + ofToString(ofGetFrameRate()) + "\n"; 31 | stats += "Last render time : " + ofToString(renderer.getLastRenderTime()*1000, 0) + "ms" + "\n"; 32 | stats += "Accumulated passes : " + ofToString(renderer.getAccumulation()) + "\n"; 33 | stats += "Accumulated time : " + ofToString(renderer.getAccumulatedTime(), 0) + "s"; 34 | ofDrawBitmapStringHighlight(stats, 10, 20, ofColor(0,0,0,80), ofColor::white); 35 | } 36 | 37 | void testApp::keyPressed(int key){ 38 | switch(key){ 39 | case 'f': 40 | ofToggleFullscreen(); 41 | break; 42 | case ' ': { 43 | //"Matte", "Plastic", "Dielectric", "ThinDielectric", "Mirror", "Metal", "MetallicPaint", "MatteTextured", "Obj" 44 | //ofxEmbree::Material mat("glass"); 45 | //renderer.addSphere(mat.embreeMat(), ofPoint(278, 273, 200), 50); 46 | } 47 | break; 48 | default: 49 | break; 50 | } 51 | } 52 | 53 | void testApp::windowResized(int w, int h){ 54 | renderer.setSize(w, h); 55 | } 56 | 57 | void testApp::mouseDragged(int x, int y, int button){ 58 | renderer.reset(); 59 | } 60 | 61 | void testApp::mouseReleased(int x, int y, int button){ 62 | renderer.reset(); 63 | } -------------------------------------------------------------------------------- /example-cornelbox/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxEmbree.h" 5 | 6 | class testApp : public ofBaseApp{ 7 | 8 | public: 9 | void setup(); 10 | void update(); 11 | void draw(); 12 | void keyPressed (int key); 13 | void windowResized(int w, int h); 14 | 15 | void mouseDragged(int x, int y, int button); 16 | void mouseReleased(int x, int y, int button); 17 | 18 | private: 19 | 20 | ofxEmbree::Renderer renderer; 21 | ofxEmbree::Camera cam; 22 | }; 23 | -------------------------------------------------------------------------------- /example-crown/Makefile: -------------------------------------------------------------------------------- 1 | include config.make 2 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 3 | -------------------------------------------------------------------------------- /example-crown/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | 10 | OFX_EMBREE_HEADERS = "$(OF_PATH)/addons/ofxEmbree/libs/embree/include" "$(OF_PATH)/addons/ofxEmbree/libs/embree/include/renderer" 11 | 12 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) $(OFX_EMBREE_HEADERS) 13 | -------------------------------------------------------------------------------- /example-crown/addons.make: -------------------------------------------------------------------------------- 1 | ofxEmbree -------------------------------------------------------------------------------- /example-crown/bin/data/readme.txt: -------------------------------------------------------------------------------- 1 | Please download the "Imperial Crown of Austria Scene" here : 2 | http://software.intel.com/sites/default/files/article/183323/crown0413.zip 3 | 4 | And extract the content in a folder named "crown" 5 | 6 | More information over there : 7 | http://embree.github.io/ -------------------------------------------------------------------------------- /example-crown/config.make: -------------------------------------------------------------------------------- 1 | # add custom variables to this file 2 | 3 | # OF_ROOT allows to move projects outside apps/* just set this variable to the 4 | # absoulte path to the OF root folder 5 | 6 | OF_ROOT = ../../.. 7 | 8 | 9 | # USER_CFLAGS allows to pass custom flags to the compiler 10 | # for example search paths like: 11 | # USER_CFLAGS = -I src/objects 12 | 13 | USER_CFLAGS = 14 | 15 | # USER_LDFLAGS allows to pass custom flags to the linker 16 | # for example libraries like: 17 | # USER_LD_FLAGS = libs/libawesomelib.a 18 | 19 | USER_LDFLAGS = 20 | 21 | 22 | # use this to add system libraries for example: 23 | # USER_LIBS = -lpango 24 | 25 | USER_LIBS = 26 | 27 | 28 | # change this to add different compiler optimizations to your project 29 | 30 | USER_COMPILER_OPTIMIZATION = -march=native -mtune=native -Os 31 | 32 | 33 | EXCLUDE_FROM_SOURCE="bin,.xcodeproj,obj,.git" 34 | -------------------------------------------------------------------------------- /example-crown/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /example-crown/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 600, 720, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /example-crown/src/testApp.cpp: -------------------------------------------------------------------------------- 1 | #include "testApp.h" 2 | 3 | void testApp::setup() { 4 | 5 | cam.setup(ofPoint(3.72811, 87.9981, -82.1874)); 6 | cam.setDistance(1200); 7 | cam.setFov(10); 8 | cam.setRadius(5); 9 | 10 | renderer.setup(cam); 11 | renderer.setSize(ofGetWidth(), ofGetHeight()); 12 | renderer.loadScene("crown/crown_by_martin_lubich.xml"); 13 | renderer.loadBackPlate("crown/background.ppm"); 14 | renderer.addHDRILight("crown/light_tent_by_lightmapltd.pfm", ofColor(1,1,1)); 15 | renderer.setGamma(1.7); 16 | renderer.setSamplePerPixel(1); 17 | renderer.setRecursionDepth(20); 18 | renderer.buildScene(); 19 | } 20 | 21 | void testApp::update(){ 22 | 23 | cam.update(); 24 | 25 | renderer.update(); 26 | renderer.renderGL(); 27 | } 28 | 29 | void testApp::draw(){ 30 | 31 | renderer.draw(0, 0); 32 | 33 | string stats; 34 | stats += "FPS : " + ofToString(ofGetFrameRate()) + "\n"; 35 | stats += "Last render time : " + ofToString(renderer.getLastRenderTime()*1000, 0) + "ms" + "\n"; 36 | stats += "Accumulated passes : " + ofToString(renderer.getAccumulation()) + "\n"; 37 | stats += "Accumulated time : " + ofToString(renderer.getAccumulatedTime(), 0) + "s"; 38 | ofDrawBitmapStringHighlight(stats, 10, 20, ofColor(0,0,0,80), ofColor::white); 39 | } 40 | 41 | void testApp::keyPressed(int key){ 42 | switch(key){ 43 | case 'f': 44 | ofToggleFullscreen(); 45 | break; 46 | default: 47 | break; 48 | } 49 | } 50 | 51 | void testApp::windowResized(int w, int h){ 52 | renderer.setSize(w, h); 53 | } 54 | 55 | void testApp::mouseDragged(int x, int y, int button){ 56 | renderer.reset(); 57 | } 58 | 59 | void testApp::mouseReleased(int x, int y, int button){ 60 | renderer.reset(); 61 | } -------------------------------------------------------------------------------- /example-crown/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxEmbree.h" 5 | 6 | class testApp : public ofBaseApp{ 7 | 8 | public: 9 | void setup(); 10 | void update(); 11 | void draw(); 12 | void keyPressed (int key); 13 | void windowResized(int w, int h); 14 | 15 | void mouseDragged(int x, int y, int button); 16 | void mouseReleased(int x, int y, int button); 17 | 18 | private: 19 | 20 | ofxEmbree::Renderer renderer; 21 | ofxEmbree::Camera cam; 22 | }; 23 | -------------------------------------------------------------------------------- /example-materials/Makefile: -------------------------------------------------------------------------------- 1 | include config.make 2 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 3 | -------------------------------------------------------------------------------- /example-materials/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | 10 | OFX_EMBREE_HEADERS = "$(OF_PATH)/addons/ofxEmbree/libs/embree/include" "$(OF_PATH)/addons/ofxEmbree/libs/embree/include/renderer" 11 | 12 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) $(OFX_EMBREE_HEADERS) 13 | -------------------------------------------------------------------------------- /example-materials/addons.make: -------------------------------------------------------------------------------- 1 | ofxEmbree -------------------------------------------------------------------------------- /example-materials/bin/data/NewSquirrel.3ds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyrildiagne/ofxEmbree/2fd9e66cbaa27ecfffa625344a8b042ded739498/example-materials/bin/data/NewSquirrel.3ds -------------------------------------------------------------------------------- /example-materials/config.make: -------------------------------------------------------------------------------- 1 | # add custom variables to this file 2 | 3 | # OF_ROOT allows to move projects outside apps/* just set this variable to the 4 | # absoulte path to the OF root folder 5 | 6 | OF_ROOT = ../../.. 7 | 8 | 9 | # USER_CFLAGS allows to pass custom flags to the compiler 10 | # for example search paths like: 11 | # USER_CFLAGS = -I src/objects 12 | 13 | USER_CFLAGS = 14 | 15 | # USER_LDFLAGS allows to pass custom flags to the linker 16 | # for example libraries like: 17 | # USER_LD_FLAGS = libs/libawesomelib.a 18 | 19 | USER_LDFLAGS = 20 | 21 | 22 | # use this to add system libraries for example: 23 | # USER_LIBS = -lpango 24 | 25 | USER_LIBS = 26 | 27 | 28 | # change this to add different compiler optimizations to your project 29 | 30 | USER_COMPILER_OPTIMIZATION = -march=native -mtune=native -Os 31 | 32 | 33 | EXCLUDE_FROM_SOURCE="bin,.xcodeproj,obj,.git" 34 | -------------------------------------------------------------------------------- /example-materials/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /example-materials/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 800, 600, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /example-materials/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxAssimpModelLoader.h" 5 | #include "ofxEmbree.h" 6 | 7 | class testApp : public ofBaseApp{ 8 | 9 | public: 10 | 11 | void setup(); 12 | void exit(); 13 | void update(); 14 | void draw(); 15 | void keyPressed (int key); 16 | void windowResized(int w, int h); 17 | void mouseDragged(int x, int y, int button); 18 | void mouseReleased(int x, int y, int button); 19 | 20 | void addGround(); 21 | void addSquirrels(); 22 | void addMesh(Device::RTMaterial material, ofPoint pos); 23 | 24 | bool bEmbreeRender; 25 | 26 | private: 27 | 28 | ofxEmbree::Renderer renderer; 29 | ofxEmbree::Camera cam; 30 | ofxEmbree::Materials materials; 31 | 32 | ofPlanePrimitive * ground; 33 | map meshMap; 34 | }; 35 | -------------------------------------------------------------------------------- /example-ofmesh/Makefile: -------------------------------------------------------------------------------- 1 | include config.make 2 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 3 | -------------------------------------------------------------------------------- /example-ofmesh/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | 10 | OFX_EMBREE_HEADERS = "$(OF_PATH)/addons/ofxEmbree/libs/embree/include" "$(OF_PATH)/addons/ofxEmbree/libs/embree/include/renderer" 11 | 12 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) $(OFX_EMBREE_HEADERS) 13 | -------------------------------------------------------------------------------- /example-ofmesh/addons.make: -------------------------------------------------------------------------------- 1 | ofxEmbree -------------------------------------------------------------------------------- /example-ofmesh/bin/data/lines.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyrildiagne/ofxEmbree/2fd9e66cbaa27ecfffa625344a8b042ded739498/example-ofmesh/bin/data/lines.ppm -------------------------------------------------------------------------------- /example-ofmesh/config.make: -------------------------------------------------------------------------------- 1 | # add custom variables to this file 2 | 3 | # OF_ROOT allows to move projects outside apps/* just set this variable to the 4 | # absoulte path to the OF root folder 5 | 6 | OF_ROOT = ../../.. 7 | 8 | 9 | # USER_CFLAGS allows to pass custom flags to the compiler 10 | # for example search paths like: 11 | # USER_CFLAGS = -I src/objects 12 | 13 | USER_CFLAGS = 14 | 15 | # USER_LDFLAGS allows to pass custom flags to the linker 16 | # for example libraries like: 17 | # USER_LD_FLAGS = libs/libawesomelib.a 18 | 19 | USER_LDFLAGS = 20 | 21 | 22 | # use this to add system libraries for example: 23 | # USER_LIBS = -lpango 24 | 25 | USER_LIBS = 26 | 27 | 28 | # change this to add different compiler optimizations to your project 29 | 30 | USER_COMPILER_OPTIMIZATION = -march=native -mtune=native -Os 31 | 32 | 33 | EXCLUDE_FROM_SOURCE="bin,.xcodeproj,obj,.git" 34 | -------------------------------------------------------------------------------- /example-ofmesh/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /example-ofmesh/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 1000, 500, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /example-ofmesh/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxEmbree.h" 5 | 6 | typedef map SphereMap; 7 | typedef map MeshMap; 8 | 9 | using namespace ofxEmbree; 10 | 11 | class testApp : public ofBaseApp{ 12 | 13 | public: 14 | 15 | void setup(); 16 | void exit(); 17 | void update(); 18 | void draw(); 19 | void keyPressed (int key); 20 | void windowResized(int w, int h); 21 | void mouseDragged(int x, int y, int button); 22 | void mouseReleased(int x, int y, int button); 23 | 24 | void addSphere(ofPoint pos, float radius); 25 | void addSphereNatively(ofPoint pos, float radius); 26 | void addBox(ofPoint pos, ofPoint rot); 27 | void addGround(); 28 | 29 | private: 30 | 31 | Renderer renderer; 32 | Camera cam; 33 | Materials materials; 34 | 35 | SphereMap spheresMap; 36 | MeshMap meshMap; 37 | }; 38 | -------------------------------------------------------------------------------- /libs/embree/include/lexers/streamfilters.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_STREAM_FILTERS_H__ 18 | #define __EMBREE_STREAM_FILTERS_H__ 19 | 20 | #include "stream.h" 21 | 22 | namespace embree 23 | { 24 | /* removes all line comments from a stream */ 25 | class LineCommentFilter : public Stream 26 | { 27 | public: 28 | LineCommentFilter (const FileName& fileName, const std::string& lineComment) 29 | : cin(new FileStream(fileName)), lineComment(lineComment) {} 30 | LineCommentFilter (Ref > cin, const std::string& lineComment) 31 | : cin(cin), lineComment(lineComment) {} 32 | 33 | ParseLocation location() { return cin->loc(); } 34 | 35 | int next() 36 | { 37 | /* look if the line comment starts here */ 38 | for (size_t j=0; jpeek() != lineComment[j]) { cin->unget(j); goto not_found; } 40 | cin->get(); 41 | } 42 | /* eat all characters until the end of the line (or file) */ 43 | while (cin->peek() != '\n' && cin->peek() != EOF) cin->get(); 44 | 45 | not_found: 46 | return cin->get(); 47 | } 48 | 49 | private: 50 | Ref > cin; 51 | std::string lineComment; 52 | }; 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /libs/embree/include/lexers/stringstream.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_STRING_STREAM_H__ 18 | #define __EMBREE_STRING_STREAM_H__ 19 | 20 | #include "stream.h" 21 | 22 | namespace embree 23 | { 24 | /*! simple tokenizer that produces a string stream */ 25 | class StringStream : public Stream 26 | { 27 | public: 28 | StringStream(const Ref >& cin, const std::string& seps = "\n\t\r ", 29 | const std::string& endl = "", bool multiLine = false); 30 | public: 31 | ParseLocation location() { return cin->loc(); } 32 | std::string next(); 33 | private: 34 | __forceinline bool isSeparator(int c) const { return isSepMap[c]; } 35 | private: 36 | Ref > cin; /*! source character stream */ 37 | bool isSepMap[256]; /*! map for fast classification of separators */ 38 | std::string endl; /*! the token of the end of line */ 39 | bool multiLine; /*! whether to parse lines wrapped with \ */ 40 | }; 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /libs/embree/include/loaders/loaders.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_LOADERS_H__ 18 | #define __EMBREE_LOADERS_H__ 19 | 20 | #include "obj_loader.h" 21 | #include "xml_loader.h" 22 | 23 | namespace embree 24 | { 25 | Device::RTImage loadImage (const FileName& fileName, Device* device); 26 | Device::RTTexture loadTexture(const FileName& fileName, Device* device); 27 | std::vector loadScene (const FileName& fileName, Device* device); 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /libs/embree/include/loaders/obj_loader.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_OBJ_LOADER_H__ 18 | #define __EMBREE_OBJ_LOADER_H__ 19 | 20 | #include 21 | #include "sys/filename.h" 22 | #include "renderer/api/device.h" 23 | 24 | namespace embree 25 | { 26 | std::vector loadOBJ(const FileName &fileName, Device *device); 27 | } 28 | 29 | #endif // __EMBREE_OBJ_LOADER_H__ 30 | 31 | -------------------------------------------------------------------------------- /libs/embree/include/loaders/xml_loader.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_XML_LOADER_H__ 18 | #define __EMBREE_XML_LOADER_H__ 19 | 20 | #include "renderer/api/device.h" 21 | #include "sys/filename.h" 22 | 23 | namespace embree 24 | { 25 | std::vector loadXML(const FileName &fileName, Device* device); 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libs/embree/include/math/permutation.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_PERMUTATION_H__ 18 | #define __EMBREE_PERMUTATION_H__ 19 | 20 | #include "sys/platform.h" 21 | #include "random.h" 22 | 23 | #include 24 | 25 | namespace embree 26 | { 27 | /*! Random permutation. */ 28 | class Permutation 29 | { 30 | public: 31 | 32 | /*! Creates a random permutation. Uses system random number generator. */ 33 | Permutation(int size) 34 | { 35 | elts = size; 36 | perm = new int[elts]; 37 | for (int i=0; i()%elts]); 39 | } 40 | 41 | /*! Creates a random permutation. Random number generator is provided as argument. */ 42 | Permutation(int size, Random& rng) 43 | { 44 | elts = size; 45 | perm = new int[elts]; 46 | for (int i=0; i= 0 && i < elts); 63 | return perm[i]; 64 | } 65 | 66 | private: 67 | int elts; //!< Size of the permutation. 68 | int* perm; //!< Array storing the permutation. 69 | }; 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /libs/embree/include/math/random.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_RANDOM_H__ 18 | #define __EMBREE_RANDOM_H__ 19 | 20 | #include "math.h" 21 | 22 | namespace embree 23 | { 24 | class Random 25 | { 26 | public: 27 | 28 | __forceinline Random(const int seed = 27) { 29 | setSeed(seed); 30 | } 31 | 32 | __forceinline void setSeed(const int s) 33 | { 34 | const int a = 16807; 35 | const int m = 2147483647; 36 | const int q = 127773; 37 | const int r = 2836; 38 | int j, k; 39 | 40 | if (s == 0) seed = 1; 41 | else if (s < 0) seed = -s; 42 | else seed = s; 43 | 44 | for (j = 32+7; j >= 0; j--) { 45 | k = seed / q; 46 | seed = a*(seed - k*q) - r*k; 47 | if (seed < 0) seed += m; 48 | if (j < 32) table[j] = seed; 49 | } 50 | state = table[0]; 51 | } 52 | 53 | __forceinline int getInt() 54 | { 55 | const int a = 16807; 56 | const int m = 2147483647; 57 | const int q = 127773; 58 | const int r = 2836; 59 | 60 | int k = seed / q; 61 | seed = a*(seed - k*q) - r*k; 62 | if (seed < 0) seed += m; 63 | int j = state / (1 + (2147483647-1) / 32); 64 | state = table[j]; 65 | table[j] = seed; 66 | 67 | return state; 68 | } 69 | 70 | __forceinline int getInt (int limit) { return getInt() % limit; } 71 | __forceinline float getFloat ( ) { return min(getInt() / 2147483647.0f, 1.0f - float(ulp)); } 72 | __forceinline double getDouble( ) { return min(getInt() / 2147483647.0 , 1.0 - double(ulp)); } 73 | 74 | private: 75 | int seed; 76 | int state; 77 | int table[32]; 78 | }; 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/api/data.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_DATA_H__ 18 | #define __EMBREE_DATA_H__ 19 | 20 | #include "default.h" 21 | 22 | namespace embree 23 | { 24 | /*! Data container. */ 25 | class Data : public RefCount 26 | { 27 | public: 28 | 29 | Data (size_t bytes) : bytes(bytes) { 30 | ptr = alignedMalloc(bytes); 31 | } 32 | 33 | Data (size_t bytes, const void* ptr_i, bool copy = true) : bytes(bytes) { 34 | if (copy) { 35 | ptr = alignedMalloc(bytes); 36 | memcpy(ptr,ptr_i,bytes); 37 | } else { 38 | ptr = (void*)ptr_i; 39 | } 40 | } 41 | 42 | ~Data () { 43 | alignedFree(ptr); ptr = NULL; 44 | bytes = 0; 45 | } 46 | 47 | __forceinline const char* map() const { return (const char*)ptr; } 48 | __forceinline char* map() { return ( char*)ptr; } 49 | 50 | size_t size() { return bytes; } 51 | 52 | private: 53 | void* ptr; 54 | size_t bytes; 55 | }; 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/api/datastream.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_DATA_STREAM_H__ 18 | #define __EMBREE_DATA_STREAM_H__ 19 | 20 | #include "default.h" 21 | 22 | namespace embree 23 | { 24 | /*! A data stream. */ 25 | class DataStream : public RefCount 26 | { 27 | public: 28 | 29 | DataStream (const Ref& ptr, size_t elements, size_t stride, size_t ofs) 30 | : ptr(ptr), elements(elements), stride(stride), ofs(ofs) {} 31 | 32 | __forceinline size_t size() { return elements; } 33 | 34 | __forceinline Vec2f getVec2f(size_t i) { 35 | float* p = (float*)(ptr->map()+i*stride+ofs); 36 | return Vec2f(p[0],p[1]); 37 | } 38 | 39 | __forceinline Vec3f getVec3f(size_t i) { 40 | float* p = (float*)(ptr->map()+i*stride+ofs); 41 | return Vec3f(p[0],p[1],p[2]); 42 | } 43 | 44 | __forceinline Vec3i getVec3i(size_t i) { 45 | int* p = (int*)(ptr->map()+i*stride+ofs); 46 | return Vec3i(p[0],p[1],p[2]); 47 | } 48 | 49 | private: 50 | Ref ptr; //!< Data buffer containing the stream. 51 | size_t elements; //!< Number of elements in the stream. 52 | size_t stride; //!< Stride in bytes between stream elements. 53 | size_t ofs; //!< Start offset of first element in stream. 54 | }; 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/api/instance.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_INSTANCE_H__ 18 | #define __EMBREE_INSTANCE_H__ 19 | 20 | #include "shapes/shape.h" 21 | #include "materials/material.h" 22 | #include "lights/light.h" 23 | 24 | namespace embree 25 | { 26 | /*! Shape instance. A shape instance is a shape with attached 27 | * material and area light. */ 28 | class Instance : public RefCount 29 | { 30 | public: 31 | 32 | /*! Shape instance constructor. */ 33 | Instance (size_t id, /*!< User ID of the instance. */ 34 | const Ref& shape, /*!< Shape of the instance. */ 35 | const Ref& material, /*!< Material attached to the shape. */ 36 | const Ref& light) /*!< Area light attached to the shape. */ 37 | : id(id), shape(shape), material(material), light(light) {} 38 | 39 | /*! Post intersection for the instance. The instance is 40 | * responsible for setting the material and area light, while the 41 | * shape for interpolating shading data. */ 42 | __forceinline void postIntersect(const Ray& ray, DifferentialGeometry& dg) const { 43 | dg.material = material.ptr; 44 | dg.light = light.ptr; 45 | shape->postIntersect(ray,dg); 46 | } 47 | 48 | public: 49 | size_t id; //!< User ID of the instance. 50 | Ref shape; //!< Shape of the instance. 51 | Ref material; //!< Material attached to the shape. 52 | Ref light; //!< Area light attached to the shape. 53 | }; 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/api/scene.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BACKEND_SCENE_H__ 18 | #define __EMBREE_BACKEND_SCENE_H__ 19 | 20 | #include "instance.h" 21 | #include "lights/light.h" 22 | #include "shapes/differentialgeometry.h" 23 | 24 | /*! include interface to ray tracing core */ 25 | #include "rtcore/common/accel.h" 26 | #include "rtcore/common/intersector.h" 27 | 28 | namespace embree 29 | { 30 | /*! Scene holding all geometry and lights. */ 31 | class BackendScene : public RefCount 32 | { 33 | public: 34 | 35 | /*! Construction of empty scene. */ 36 | BackendScene () {} 37 | 38 | /*! Adds a light to the scene. */ 39 | void add(const Ref& light) { 40 | allLights.push_back(light); 41 | if (Ref envlight = dynamic_cast(light.ptr)) envLights.push_back(envlight); 42 | } 43 | 44 | /*! Adds a shape instance to the scene. */ 45 | size_t add(const Ref& instance) { 46 | geometry.push_back(instance); 47 | return geometry.size()-1; 48 | } 49 | 50 | /*! Helper to call the post intersector of the shape instance, 51 | * which will call the post intersector of the shape. */ 52 | __forceinline void postIntersect(const Ray& ray, DifferentialGeometry& dg) const { 53 | if (dg) geometry[dg.id0]->postIntersect(ray,dg); 54 | } 55 | 56 | void setAccel(Ref accel) { 57 | this->accel = accel; 58 | this->intersector = accel->queryInterface (); 59 | } 60 | 61 | public: 62 | std::vector > allLights; //!< All lights of the scene 63 | std::vector > envLights; //!< Environemnt lights of the scene 64 | std::vector > geometry; //!< Geometries of the scene 65 | Ref accel; //!< Acceleration structure over geometry 66 | Ref intersector; 67 | }; 68 | } 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/brdfs/conductor.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_CONDUCTOR_BRDF_H__ 18 | #define __EMBREE_CONDUCTOR_BRDF_H__ 19 | 20 | #include "brdfs/brdf.h" 21 | #include "brdfs/optics.h" 22 | 23 | namespace embree 24 | { 25 | /*! BRDF of a perfectly polished metal. */ 26 | class Conductor : public BRDF 27 | { 28 | public: 29 | 30 | /*! Conductor BRDF constructor. \param R is the reflectivity 31 | * coefficient \param eta the real part of the refraction index 32 | * and \param k the imaginary part of the refraction index */ 33 | __forceinline Conductor(const Col3f& R, const Col3f& eta, const Col3f& k) 34 | : BRDF(SPECULAR_REFLECTION), R(R), eta(eta), k(k) {} 35 | 36 | __forceinline Col3f eval(const Vec3f& wo, const DifferentialGeometry& dg, const Vec3f& wi) const { 37 | return zero; 38 | } 39 | 40 | Col3f sample(const Vec3f& wo, const DifferentialGeometry& dg, Sample3f& wi, const Vec2f& s) const { 41 | wi = reflect(wo,dg.Ns); 42 | return R * fresnelConductor(dot(wo,dg.Ns),eta,k); 43 | } 44 | 45 | float pdf(const Vec3f& wo, const DifferentialGeometry& dg, const Vec3f& wi) const { 46 | return zero; 47 | } 48 | 49 | private: 50 | Col3f R; //!< Reflectivity coefficient 51 | Col3f eta; //!< Real part of refraction index 52 | Col3f k; //!< Imaginary part of refraction index 53 | }; 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/brdfs/minnaert.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_MINNAERT_BRDF_H__ 18 | #define __EMBREE_MINNAERT_BRDF_H__ 19 | 20 | #include "brdfs/brdf.h" 21 | #include "brdfs/optics.h" 22 | 23 | namespace embree 24 | { 25 | /*! Minnaert BRDF. For backscattering materials (e.g. dust, fabric) 26 | * The BRDF has a reflectance parameter that determines the color of 27 | * the surface and a parameter to determine the amount of backscattering. */ 28 | class Minnaert : public BRDF 29 | { 30 | public: 31 | 32 | /*! Minnaert BRDF constructor. This is a diffuse reflection BRDF. */ 33 | __forceinline Minnaert(const Col3f& R, const float b) : BRDF(DIFFUSE_REFLECTION), R(R), b(b) {} 34 | 35 | __forceinline Col3f eval(const Vec3f& wo, const DifferentialGeometry& dg, const Vec3f& wi) const { 36 | float cosThetaI = clamp(dot(wi,dg.Ns)); 37 | float backScatter = powf(clamp(dot(wo,wi)), b); 38 | return R * backScatter * cosThetaI / float(pi); 39 | } 40 | 41 | Col3f sample(const Vec3f& wo, const DifferentialGeometry& dg, Sample3f& wi, const Vec2f& s) const { 42 | return eval(wo, dg, wi = cosineSampleHemisphere(s.x,s.y,dg.Ns)); 43 | } 44 | 45 | float pdf(const Vec3f& wo, const DifferentialGeometry& dg, const Vec3f& wi) const { 46 | return cosineSampleHemispherePDF(wi,dg.Ns); 47 | } 48 | 49 | private: 50 | 51 | /*! The reflectance parameter. The vale 0 means no reflection, 52 | * and 1 means full reflection. */ 53 | Col3f R; 54 | 55 | /*! The amount of backscattering. A value of 0 means lambertian 56 | * diffuse, and inf means maximum backscattering. */ 57 | float b; 58 | }; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/brdfs/reflection.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_REFLECTION_BRDF_H__ 18 | #define __EMBREE_REFLECTION_BRDF_H__ 19 | 20 | #include "brdfs/brdf.h" 21 | #include "brdfs/optics.h" 22 | 23 | namespace embree 24 | { 25 | /*! BRDF of a perfect mirror. */ 26 | class Reflection : public BRDF 27 | { 28 | public: 29 | 30 | /*! Reflection BRDF constructor. This is a specular reflection 31 | * BRDF. \param R is the reflectivity of the mirror. */ 32 | __forceinline Reflection(const Col3f& R) : BRDF(SPECULAR_REFLECTION), R(R) {} 33 | 34 | __forceinline Col3f eval(const Vec3f& wo, const DifferentialGeometry& dg, const Vec3f& wi) const { 35 | return zero; 36 | } 37 | 38 | Col3f sample(const Vec3f& wo, const DifferentialGeometry& dg, Sample3f& wi, const Vec2f& s) const { 39 | wi = reflect(wo,dg.Ns); 40 | return R; 41 | } 42 | 43 | float pdf(const Vec3f& wo, const DifferentialGeometry& dg, const Vec3f& wi) const { 44 | return zero; 45 | } 46 | 47 | private: 48 | 49 | /*! reflectivity of the mirror */ 50 | Col3f R; 51 | }; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/brdfs/specular.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_SPECULAR_BRDF_H__ 18 | #define __EMBREE_SPECULAR_BRDF_H__ 19 | 20 | #include "brdfs/brdf.h" 21 | #include "brdfs/optics.h" 22 | 23 | namespace embree 24 | { 25 | /*! Specular Phong BRDF. The cosine of the angle between incoming 26 | * ray direction and reflection direction is raised to some power 27 | * to approximate a glossy reflection. */ 28 | class Specular : public BRDF 29 | { 30 | public: 31 | 32 | /*! Specular BRDF constructor. */ 33 | __forceinline Specular(const Col3f& R, float exp) : BRDF(GLOSSY_REFLECTION), R(R), exp(exp) {} 34 | 35 | __forceinline Col3f eval(const Vec3f& wo, const DifferentialGeometry& dg, const Vec3f& wi) const { 36 | Vec3f r = reflect(wo,dg.Ns); 37 | if (dot(r,wi) < 0) return zero; 38 | return R * (exp+2) * (1.0f/(2.0f*float(pi))) * pow(dot(r,wi),exp) * clamp(dot(wi,dg.Ns)); 39 | } 40 | 41 | Col3f sample(const Vec3f& wo, const DifferentialGeometry& dg, Sample3f& wi, const Vec2f& s) const { 42 | return eval(wo, dg, wi = powerCosineSampleHemisphere(s.x,s.y,reflect(wo,dg.Ns),exp)); 43 | } 44 | 45 | float pdf(const Vec3f& wo, const DifferentialGeometry& dg, const Vec3f& wi) const { 46 | return powerCosineSampleHemispherePDF(wi,reflect(wo,dg.Ns),exp); 47 | } 48 | 49 | private: 50 | 51 | /*! The reflectivity parameter. The range is [0,1] where 0 means 52 | * no reflection at all, and 1 means full reflection. */ 53 | Col3f R; 54 | 55 | /*! The exponent that determines the glossiness. The range is 56 | * [0,infinity[ where 0 means a diffuse surface, and the 57 | * specularity increases towards infinity. */ 58 | float exp; 59 | }; 60 | } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/brdfs/transmission.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_TRANSMISSION_BRDF_H__ 18 | #define __EMBREE_TRANSMISSION_BRDF_H__ 19 | 20 | #include "brdfs/brdf.h" 21 | #include "brdfs/optics.h" 22 | 23 | namespace embree 24 | { 25 | /*! BRDF of transmissive material. */ 26 | class Transmission : public BRDF 27 | { 28 | public: 29 | 30 | /*! Transmissive BRDF constructor. \param T is the transmission coefficient */ 31 | __forceinline Transmission(const Col3f& T) : BRDF(SPECULAR_TRANSMISSION), T(T) {} 32 | 33 | __forceinline Col3f eval(const Vec3f& wo, const DifferentialGeometry& dg, const Vec3f& wi) const { 34 | return zero; 35 | } 36 | 37 | Col3f sample(const Vec3f& wo, const DifferentialGeometry& dg, Sample3f& wi, const Vec2f& s) const { 38 | wi = -wo; return T; 39 | } 40 | 41 | float pdf(const Vec3f& wo, const DifferentialGeometry& dg, const Vec3f& wi) const { 42 | return zero; 43 | } 44 | 45 | private: 46 | 47 | /*! Transmission coefficient of the material. The range is [0,1] 48 | * where 0 means total absorption and 1 means total 49 | * transmission. */ 50 | Col3f T; 51 | }; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/brdfs/velvety.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_VELVETY_BRDF_H__ 18 | #define __EMBREE_VELVETY_BRDF_H__ 19 | 20 | #include "brdfs/brdf.h" 21 | #include "brdfs/optics.h" 22 | 23 | namespace embree 24 | { 25 | /*! Velvety BRDF. For materials with horizon scattering (velvet, peach, etc.) 26 | * The BRDF has a reflectance parameter that determines the color of 27 | * the surface and a parameter to determine the falloff of horizon scattering. */ 28 | class Velvety : public BRDF 29 | { 30 | public: 31 | 32 | /*! Velvety BRDF constructor. This is a diffuse reflection BRDF. */ 33 | __forceinline Velvety(const Col3f& R, const float f, const BRDFType type = DIFFUSE_REFLECTION) : BRDF(type), R(R), f(f) {} 34 | 35 | __forceinline Col3f eval(const Vec3f& wo, const DifferentialGeometry& dg, const Vec3f& wi) const { 36 | float cosThetaO = clamp(dot(wo,dg.Ns)); 37 | float cosThetaI = clamp(dot(wi,dg.Ns)); 38 | float sinThetaO = sqrtf(1.0f - cosThetaO); 39 | float horizonScatter = powf(sinThetaO, f); 40 | return R * horizonScatter * cosThetaI / float(pi); 41 | } 42 | 43 | Col3f sample(const Vec3f& wo, const DifferentialGeometry& dg, Sample3f& wi, const Vec2f& s) const { 44 | return eval(wo, dg, wi = cosineSampleHemisphere(s.x,s.y,dg.Ns)); 45 | } 46 | 47 | float pdf(const Vec3f& wo, const DifferentialGeometry& dg, const Vec3f& wi) const { 48 | return cosineSampleHemispherePDF(wi,dg.Ns); 49 | } 50 | 51 | private: 52 | 53 | /*! The reflectance parameter. The vale 0 means no reflection, 54 | * and 1 means full reflection. */ 55 | Col3f R; 56 | 57 | /*! The falloff of horizon scattering. 0 no falloff, 58 | * and inf means maximum falloff. */ 59 | float f; 60 | }; 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/cameras/camera.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_CAMERA_H__ 18 | #define __EMBREE_CAMERA_H__ 19 | 20 | #include "api/parms.h" 21 | #include "rtcore/common/ray.h" 22 | 23 | namespace embree 24 | { 25 | /*! Interface to different camera models. */ 26 | class Camera : public RefCount { 27 | ALIGNED_CLASS 28 | public: 29 | 30 | /*! Virtual interface destructor. */ 31 | virtual ~Camera() {} 32 | 33 | /*! Computes a primary ray for a pixel. */ 34 | virtual void ray(const Vec2f& pixel, /*!< The pixel location on the on image plane in the range from 0 to 1. */ 35 | const Vec2f& sample, /*!< The lens sample in [0,1) for depth of field. */ 36 | Ray& ray_o) /*!< To return the ray. */ const = 0; 37 | 38 | /*! Field of view. */ 39 | float angle; 40 | }; 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/cameras/depthoffieldcamera.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_DEPTH_OF_FIELD_CAMERA_H__ 18 | #define __EMBREE_DEPTH_OF_FIELD_CAMERA_H__ 19 | 20 | #include "pinholecamera.h" 21 | 22 | namespace embree 23 | { 24 | /*! Implements a depth of field camera model. */ 25 | class DepthOfFieldCamera : public PinholeCamera 26 | { 27 | public: 28 | 29 | /*! Construction from parameter container. */ 30 | DepthOfFieldCamera (const Parms& parms) : PinholeCamera(parms) { 31 | lensRadius = parms.getFloat("lensRadius",0.0f); 32 | focalDistance = parms.getFloat("focalDistance"); 33 | focalDistance /= length(0.5f*xfm.l.vx + 0.5f*xfm.l.vy + xfm.l.vz); 34 | } 35 | 36 | void ray(const Vec2f& pixel, const Vec2f& sample, Ray& ray_o) const 37 | { 38 | Vec2f lens = uniformSampleDisk(sample,lensRadius); 39 | Vec3f begin = xfmPoint(localToWorld, Vec3f(lens.x,lens.y,0.0f)); 40 | Vec3f end = xfm.p + focalDistance*(pixel.x*xfm.l.vx + (1.0f-pixel.y)*xfm.l.vy + xfm.l.vz); 41 | new (&ray_o) Ray(begin, normalize(end - begin)); 42 | } 43 | 44 | private: 45 | float lensRadius; //!< radius of the lens 46 | float focalDistance; //!< distance of the focal plane 47 | }; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/cameras/pinholecamera.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_PINHOLE_CAMERA_H__ 18 | #define __EMBREE_PINHOLE_CAMERA_H__ 19 | 20 | #include "camera.h" 21 | 22 | namespace embree 23 | { 24 | /*! Implements the pinhole camera model. */ 25 | class PinholeCamera : public Camera 26 | { 27 | public: 28 | 29 | /*! Construction from parameter container. */ 30 | PinholeCamera(const Parms& parms) { 31 | localToWorld = parms.getTransform("local2world"); 32 | angle = parms.getFloat("angle",64.0f); 33 | float aspectRatio = parms.getFloat("aspectRatio",1.0f); 34 | Vec3f W = xfmVector(localToWorld, Vec3f(-0.5f*aspectRatio,-0.5f,0.5f*rcp(tanf(deg2rad(0.5f*angle))))); 35 | xfm = AffineSpace3f(aspectRatio*localToWorld.l.vx,localToWorld.l.vy,W,localToWorld.p); 36 | } 37 | 38 | void ray(const Vec2f& pixel, const Vec2f& sample, Ray& ray_o) const { 39 | new (&ray_o) Ray(xfm.p,normalize(pixel.x*xfm.l.vx + (1.0f-pixel.y)*xfm.l.vy + xfm.l.vz)); 40 | } 41 | 42 | protected: 43 | AffineSpace3f localToWorld; //!< transformation from camera space to world space 44 | AffineSpace3f xfm; //!< special transformation to generate rays 45 | }; 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/default.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_DEFAULT_H__ 18 | #define __EMBREE_DEFAULT_H__ 19 | 20 | #include "sys/platform.h" 21 | #include "sys/ref.h" 22 | #include "sys/intrinsics.h" 23 | #include "sys/stl/vector.h" 24 | #include "sys/stl/string.h" 25 | 26 | #include "math/math.h" 27 | #include "math/vec2.h" 28 | #include "math/vec3.h" 29 | #include "math/vec4.h" 30 | #include "math/col3.h" 31 | #include "math/affinespace.h" 32 | 33 | #include "simd/simd.h" 34 | 35 | #include "sys/thread.h" 36 | #include "sys/sync/atomic.h" 37 | #include "sys/sync/barrier.h" 38 | 39 | namespace embree 40 | { 41 | typedef Vec2 sse2b; 42 | typedef Vec3 sse3b; 43 | typedef Vec2 sse2i; 44 | typedef Vec3 sse3i; 45 | typedef Vec2 sse2f; 46 | typedef Vec3 sse3f; 47 | } 48 | 49 | #include "samplers/sample.h" 50 | #include "samplers/shapesampler.h" 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/filters/boxfilter.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BOX_FILTER_H__ 18 | #define __EMBREE_BOX_FILTER_H__ 19 | 20 | #include "filters/filter.h" 21 | 22 | namespace embree 23 | { 24 | /*! Implements a simple box filter. */ 25 | class BoxFilter : public Filter 26 | { 27 | public: 28 | 29 | /*! Constructs a box filter of specified half width. */ 30 | BoxFilter (const float halfWidth = 0.5f) 31 | : Filter(1.414213562f * halfWidth, 2.0f * halfWidth, 2.0f * halfWidth, uint32(ceil(halfWidth - 0.5f))), halfWidth(halfWidth) {} 32 | 33 | float eval(const Vec2f distanceToCenter) const { 34 | if (fabsf(distanceToCenter.x) <= halfWidth && fabsf(distanceToCenter.y) <= halfWidth) return 1.0f; 35 | else return 0.0f; 36 | } 37 | private: 38 | float halfWidth; //!< Half the width of the box filter 39 | }; 40 | } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/filters/bsplinefilter.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BSPLINE_FILTER_H__ 18 | #define __EMBREE_BSPLINE_FILTER_H__ 19 | 20 | #include "filters/filter.h" 21 | 22 | namespace embree 23 | { 24 | /*! Implements a B-Spline filter. */ 25 | class BSplineFilter : public Filter 26 | { 27 | public: 28 | BSplineFilter () : Filter(2.0f,4.0f,4.0f,2) { init(); } 29 | 30 | float eval(const Vec2f distanceToCenter) const 31 | { 32 | float d = length(distanceToCenter); 33 | if (d > 2.0f) return 0.0f; 34 | else if (d < 1.0f) { 35 | float t = 1.0f - d; 36 | return ((((-3.0f*t)+3.0f)*t+3.0f)*t+1.0f)/6.0f; 37 | } 38 | else { 39 | float t = 2.0f - d; 40 | return t*t*t/6.0f; 41 | } 42 | } 43 | }; 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/filters/filter.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_FILTER_H__ 18 | #define __EMBREE_FILTER_H__ 19 | 20 | #include "samplers/distribution2d.h" 21 | 22 | namespace embree 23 | { 24 | /*! Interface to pixel filters. */ 25 | class Filter : public RefCount 26 | { 27 | public: 28 | 29 | /*! Constructs a filter interface. */ 30 | Filter(float radius, float width, float height, int32 border, uint32 tableSize = 256) 31 | : radius(radius), width(width), height(height), border(border), tableSize(tableSize) {} 32 | 33 | /*! Initializes the automatic importance sampling feature. */ 34 | void init(); 35 | 36 | /*! Filters need a virtual destructor. */ 37 | virtual ~Filter() {} 38 | 39 | /*! Evaluates the filter at some location relative to the pixel center. */ 40 | virtual float eval(const Vec2f distanceToCenter) const = 0; 41 | 42 | /*! Draws a filter sample. */ 43 | virtual Vec2f sample(const Vec2f uv) const; 44 | 45 | public: 46 | const float radius; //!< Radius of the filter 47 | const float width; //!< Width of the filter 48 | const float height; //!< Height of the filter 49 | const int32 border; //!< Number of border pixels of the filter 50 | 51 | private: 52 | const uint32 tableSize; //!< Size of the table used to approximate sampling. 53 | Distribution2D distribution; //!< Distribution for automatic sampling. 54 | }; 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/integrators/integrator.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_INTEGRATOR_H__ 18 | #define __EMBREE_INTEGRATOR_H__ 19 | 20 | #include "rtcore/common/ray.h" 21 | #include "api/scene.h" 22 | #include "samplers/sampler.h" 23 | 24 | namespace embree 25 | { 26 | /*! Interface to different integrators. The task of the integrator 27 | * is to compute the incoming radiance along some ray. */ 28 | class Integrator : public RefCount { 29 | ALIGNED_CLASS 30 | public: 31 | 32 | /*! Integrators need a virtual destructor. */ 33 | virtual ~Integrator() {} 34 | 35 | /*! Allows the integrator to register required samples at the sampler. */ 36 | virtual void requestSamples(Ref& samplerFactory, const Ref& scene) {} 37 | 38 | /*! Computes the radiance arriving at the origin of the ray from 39 | * the ray direction. */ 40 | virtual Col3f Li(const Ray& ray, /*!< Ray to compute the radiance along. */ 41 | const Ref& scene, /*!< Scene geometry and lights. */ 42 | const PrecomputedSample& sample, /*!< Sampler used to generate (pseudo) random numbers. */ 43 | size_t& numRays /*!< Used to count the number of rays shot. */) = 0; 44 | }; 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/lights/ambientlight.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_AMBIENT_LIGHT_H__ 18 | #define __EMBREE_AMBIENT_LIGHT_H__ 19 | 20 | #include "lights/light.h" 21 | 22 | namespace embree 23 | { 24 | /*! Implements an ambient light. An ambient light behaves like a 25 | * uniform environment map. */ 26 | class AmbientLight : public EnvironmentLight 27 | { 28 | /*! Construction from radiance. */ 29 | AmbientLight (const Col3f& L) : L(L) { } 30 | 31 | public: 32 | 33 | /*! Construction from parameter container. */ 34 | AmbientLight (const Parms& parms) { 35 | L = parms.getCol3f("L"); 36 | } 37 | 38 | Ref transform(const AffineSpace3f& xfm) const { 39 | return new AmbientLight(L); 40 | } 41 | 42 | Col3f Le(const Vec3f& wo) const { 43 | return L; 44 | } 45 | 46 | Col3f eval(const DifferentialGeometry& dg, const Vec3f& wi) const { 47 | return L; 48 | } 49 | 50 | Col3f sample(const DifferentialGeometry& dg, Sample3f& wi, float& tMax, const Vec2f& s) const { 51 | wi = cosineSampleHemisphere(s.x, s.y, dg.Ns); 52 | tMax = inf; 53 | return L; 54 | } 55 | 56 | float pdf(const DifferentialGeometry& dg, const Vec3f& wi) const { 57 | return cosineSampleHemispherePDF(wi,dg.Ns); 58 | } 59 | 60 | private: 61 | Col3f L; //!< Radiance (W/(m^2*sr)) 62 | }; 63 | } 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/lights/directionallight.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_DIRECTIONAL_LIGHT_H__ 18 | #define __EMBREE_DIRECTIONAL_LIGHT_H__ 19 | 20 | #include "lights/light.h" 21 | 22 | namespace embree 23 | { 24 | /*! Implements a directional light. */ 25 | class DirectionalLight : public Light 26 | { 27 | /*! Construction from members. */ 28 | DirectionalLight (const Vec3f& _wo, const Col3f& E) 29 | : _wo(normalize(_wo)), E(E) { } 30 | 31 | public: 32 | 33 | /*! Construction from parameter container. */ 34 | DirectionalLight (const Parms& parms) { 35 | _wo = -normalize(parms.getVec3f("D")); 36 | E = parms.getCol3f("E"); 37 | } 38 | 39 | Ref transform(const AffineSpace3f& xfm) const { 40 | return new DirectionalLight(xfmVector(xfm,_wo),E); 41 | } 42 | 43 | Col3f sample(const DifferentialGeometry& dg, Sample3f& wi, float& tMax, const Vec2f& s) const { 44 | wi = _wo; tMax = inf; return E; 45 | } 46 | 47 | float pdf(const DifferentialGeometry& dg, const Vec3f& wi) const { 48 | return zero; 49 | } 50 | 51 | private: 52 | Vec3f _wo; //!< inverse light direction 53 | Col3f E; //!< Irradiance (W/m^2) 54 | }; 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/lights/hdrilight.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_HDRI_LIGHT_H__ 18 | #define __EMBREE_HDRI_LIGHT_H__ 19 | 20 | #include "lights/light.h" 21 | #include "image/image.h" 22 | #include "samplers/distribution2d.h" 23 | 24 | namespace embree 25 | { 26 | /*! Implements a texture mapped environment light. */ 27 | class HDRILight : public EnvironmentLight 28 | { 29 | /*! construction from members */ 30 | HDRILight(const AffineSpace3f& local2world, unsigned width, unsigned height, 31 | const Col3f& L, const Ref& pixels, const Ref& distribution) 32 | : local2world(local2world), world2local(rcp(local2world)), width(width), height(height), 33 | L(L), pixels(pixels), distribution(distribution) {} 34 | 35 | public: 36 | 37 | /*! Construction from parameter container. */ 38 | HDRILight (const Parms& parms); 39 | 40 | Ref transform(const AffineSpace3f& xfm) const { 41 | return new HDRILight(xfm * local2world,width,height,L,pixels,distribution); 42 | } 43 | 44 | Col3f Le (const Vec3f& wo) const; 45 | Col3f eval (const DifferentialGeometry& dg, const Vec3f& wi) const; 46 | Col3f sample(const DifferentialGeometry& dg, Sample3f& wi, float& tMax, const Vec2f& s) const; 47 | float pdf (const DifferentialGeometry& dg, const Vec3f& wi) const; 48 | bool precompute() const { return true; } 49 | 50 | private: 51 | AffineSpace3f local2world; //!< Transformation from light space into world space 52 | AffineSpace3f world2local; //!< Transformation from world space into light space 53 | unsigned width, height; //!< Width and height of the used image. 54 | Col3f L; //!< Scaling factor for the image. 55 | Ref pixels; //!< The image mapped to the environment. 56 | Ref distribution; //!< The 2D distribution used to importance sample the image. 57 | }; 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/lights/pointlight.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_POINT_LIGHT_H__ 18 | #define __EMBREE_POINT_LIGHT_H__ 19 | 20 | #include "lights/light.h" 21 | 22 | namespace embree 23 | { 24 | /*! Implements a point light source. */ 25 | class PointLight : public Light 26 | { 27 | /*! Construction from position and intensity. */ 28 | PointLight (const Vec3f& P, const Col3f& I) : P(P), I(I) {} 29 | 30 | public: 31 | 32 | /*! Construction from parameter container. */ 33 | PointLight (const Parms& parms) { 34 | P = parms.getVec3f("P",zero); 35 | I = parms.getCol3f("I",zero); 36 | } 37 | 38 | Ref transform(const AffineSpace3f& xfm) const { 39 | return new PointLight(xfmPoint(xfm,P),I); 40 | } 41 | 42 | Col3f sample(const DifferentialGeometry& dg, Sample3f& wi, float& tMax, const Vec2f& s) const 43 | { 44 | Vec3f d = P - dg.P; 45 | float distance = length(d); 46 | wi = Sample3f(d / distance, distance*distance); 47 | tMax = distance; 48 | return I; 49 | } 50 | 51 | float pdf(const DifferentialGeometry& dg, const Vec3f& wi) const { 52 | return zero; 53 | } 54 | 55 | private: 56 | Vec3f P; //!< Position of the point light 57 | Col3f I; //!< Radiant intensity (W/sr) 58 | }; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/lights/spotlight.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_SPOT_LIGHT_H__ 18 | #define __EMBREE_SPOT_LIGHT_H__ 19 | 20 | #include "lights/light.h" 21 | 22 | namespace embree 23 | { 24 | /*! Implements a spot light source. */ 25 | class SpotLight : public Light 26 | { 27 | /*! Construction from position, direction, intensity and opening angles. */ 28 | SpotLight(const Vec3f& P, const Vec3f& _D, const Col3f& I, float cosAngleMin, float cosAngleMax) 29 | : P(P), _D(_D), I(I), cosAngleMin(cosAngleMin), cosAngleMax(cosAngleMax) {} 30 | 31 | public: 32 | 33 | /*! Construction from parameter container. */ 34 | SpotLight (const Parms& parms) { 35 | P = parms.getVec3f("P"); 36 | _D = -normalize(parms.getVec3f("D")); 37 | I = parms.getCol3f("I"); 38 | cosAngleMin = cosf(deg2rad(parms.getFloat("angleMin"))); 39 | cosAngleMax = cosf(deg2rad(parms.getFloat("angleMax"))); 40 | } 41 | 42 | Ref transform(const AffineSpace3f& xfm) const { 43 | return new SpotLight(xfmPoint(xfm,P),xfmVector(xfm,_D),I,cosAngleMin,cosAngleMax); 44 | } 45 | 46 | Col3f sample(const DifferentialGeometry& dg, Sample3f& wi, float& tMax, const Vec2f& s) const 47 | { 48 | Vec3f d = P - dg.P; 49 | float distance = length(d); 50 | wi = Sample3f(d * rcp(distance), distance*distance); 51 | tMax = distance; 52 | return I*clamp((dot(wi.value,_D) - cosAngleMax)*rcp(cosAngleMin - cosAngleMax)); 53 | } 54 | 55 | float pdf (const DifferentialGeometry& dg, const Vec3f& wi) const { 56 | return zero; 57 | } 58 | 59 | private: 60 | Vec3f P; //!< Position of the spot light 61 | Vec3f _D; //!< Negative light direction of the spot light 62 | Col3f I; //!< Radiant intensity (W/sr) 63 | float cosAngleMin, cosAngleMax; //!< Linear falloff region 64 | }; 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/materials/matte.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_MATTE_H__ 18 | #define __EMBREE_MATTE_H__ 19 | 20 | #include "materials/material.h" 21 | #include "brdfs/lambertian.h" 22 | 23 | namespace embree 24 | { 25 | /*! Implements a diffuse material. */ 26 | class Matte : public Material 27 | { 28 | public: 29 | 30 | /*! Construction from parameters. */ 31 | Matte (const Parms& parms) { 32 | reflectance = parms.getCol3f("reflectance",one); 33 | } 34 | 35 | void shade(const Ray& ray, const Medium& currentMedium, const DifferentialGeometry& dg, CompositedBRDF& brdfs) const { 36 | brdfs.add(NEW_BRDF(Lambertian)(reflectance)); 37 | } 38 | 39 | private: 40 | 41 | /*! Diffuse reflectance of the surface. The range is from 0 42 | * (black) to 1 (white). */ 43 | Col3f reflectance; 44 | }; 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/materials/matte_textured.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_MATTE_TEXTURED_H__ 18 | #define __EMBREE_MATTE_TEXTURED_H__ 19 | 20 | #include "materials/material.h" 21 | #include "brdfs/lambertian.h" 22 | #include "textures/texture.h" 23 | 24 | namespace embree 25 | { 26 | /*! Implements a diffuse and textured material.*/ 27 | class MatteTextured : public Material 28 | { 29 | public: 30 | 31 | /*! Construction from parameters. */ 32 | MatteTextured (const Parms& parms) 33 | { 34 | Kd = parms.getTexture("Kd"); 35 | s0 = parms.getVec2f("s0",Vec2f(0.0f,0.0f)); 36 | ds = parms.getVec2f("ds",Vec2f(1.0f,1.0f)); 37 | } 38 | 39 | void shade(const Ray& ray, const Medium& currentMedium, const DifferentialGeometry& dg, CompositedBRDF& brdfs) const { 40 | if (Kd) brdfs.add(NEW_BRDF(Lambertian)(Kd->get(ds*dg.st+s0))); 41 | } 42 | 43 | private: 44 | Vec2f s0; //!< Offset for texture coordinates. 45 | Vec2f ds; //!< Scaling for texture coordinates. 46 | Ref Kd; //!< Texture mapped to the surface. 47 | }; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/materials/medium.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_MEDIUM_H__ 18 | #define __EMBREE_MEDIUM_H__ 19 | 20 | #include "default.h" 21 | 22 | namespace embree 23 | { 24 | /*! Medium description. The integrator tracks the current medium for 25 | * computing volumetric effects. */ 26 | class Medium { 27 | public: 28 | 29 | /*! Medium constructor. */ 30 | __forceinline Medium (const Col3f& transmission = one, float eta = one) 31 | : transmission(transmission), eta(eta) {} 32 | 33 | /*! Builds a vacuum. */ 34 | static Medium Vacuum() { 35 | return Medium(one, one); 36 | } 37 | 38 | /*! Comparision of two media. */ 39 | __forceinline bool operator==(const Medium& m) const { 40 | return transmission == m.transmission && eta == m.eta; 41 | } 42 | 43 | public: 44 | Col3f transmission; //!< Transmissivity of medium. 45 | float eta; //!< Refraction index of medium. 46 | }; 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/materials/metal.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_METAL_H__ 18 | #define __EMBREE_METAL_H__ 19 | 20 | #include "materials/material.h" 21 | #include "brdfs/conductor.h" 22 | #include "brdfs/microfacet.h" 23 | 24 | namespace embree 25 | { 26 | /*! Implements a rough metal material. The metal is modelled by a 27 | * microfacet BRDF with a fresnel term for metals and a power 28 | * cosine distribution for different roughness of the material. */ 29 | class Metal : public Material 30 | { 31 | typedef Microfacet MicrofacetMetal; 32 | public: 33 | 34 | /*! Construction from parameters. */ 35 | Metal (const Parms& parms) { 36 | reflectance = parms.getCol3f("reflectance",one); 37 | eta = parms.getCol3f("eta",Col3f(1.4f)); 38 | k = parms.getCol3f("k",Col3f(0.0f)); 39 | roughness = parms.getFloat("roughness",0.01f); 40 | rcpRoughness = rcp(roughness); 41 | } 42 | 43 | void shade(const Ray& ray, const Medium& currentMedium, const DifferentialGeometry& dg, CompositedBRDF& brdfs) const 44 | { 45 | /*! handle the special case of a specular metal through a special BRDF */ 46 | if (roughness == 0.0f) 47 | brdfs.add(NEW_BRDF(Conductor)(reflectance, eta, k)); 48 | 49 | /*! otherwise use the microfacet BRDF model */ 50 | else 51 | brdfs.add(NEW_BRDF(MicrofacetMetal)(reflectance, FresnelConductor(eta,k), PowerCosineDistribution(rcpRoughness,dg.Ns))); 52 | } 53 | 54 | private: 55 | Col3f reflectance; //!< Reflectivity of the metal 56 | Col3f eta; //!< Real part of refraction index 57 | Col3f k; //!< Imaginary part of refraction index 58 | float roughness; //!< Roughness parameter. The range goes from 0 (specular) to 1 (diffuse). 59 | float rcpRoughness;//!< Reciprocal roughness parameter. 60 | }; 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/materials/mirror.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_MIRROR_H__ 18 | #define __EMBREE_MIRROR_H__ 19 | 20 | #include "materials/material.h" 21 | #include "brdfs/reflection.h" 22 | 23 | namespace embree 24 | { 25 | /*! Implements a mirror material. The reflected light can be 26 | * modulated with a mirror reflectivity. */ 27 | class Mirror : public Material 28 | { 29 | public: 30 | 31 | /*! Construction from parameters. */ 32 | Mirror(const Parms& parms) { 33 | reflectance = parms.getCol3f("reflectance",one); 34 | } 35 | 36 | void shade(const Ray& ray, const Medium& currentMedium, const DifferentialGeometry& dg, CompositedBRDF& brdfs) const { 37 | brdfs.add(NEW_BRDF(Reflection)(reflectance)); 38 | } 39 | 40 | private: 41 | Col3f reflectance; //!< Reflectivity of the mirror 42 | }; 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/materials/thindielectric.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_THIN_DIELECTRIC_H__ 18 | #define __EMBREE_THIN_DIELECTRIC_H__ 19 | 20 | #include "brdfs/dielectric.h" 21 | #include "materials/material.h" 22 | 23 | namespace embree 24 | { 25 | /*! Implements a thin dielectricum material. The model uses a 26 | * dielectric reflection BRDF and thin dielectric transmission 27 | * BRDF. */ 28 | class ThinDielectric : public Material 29 | { 30 | public: 31 | 32 | /*! Construction from parameters. */ 33 | ThinDielectric(const Parms& parms) { 34 | transmission = parms.getCol3f("transmission",one); 35 | eta = parms.getFloat("eta",1.4f); 36 | thickness = parms.getFloat("thickness",0.1f); 37 | } 38 | 39 | void shade(const Ray& ray, const Medium& currentMedium, const DifferentialGeometry& dg, CompositedBRDF& brdfs) const { 40 | brdfs.add(NEW_BRDF(DielectricReflection)(1.0f, eta)); 41 | brdfs.add(NEW_BRDF(ThinDielectricTransmission)(1.0f, eta, transmission, thickness)); 42 | } 43 | 44 | private: 45 | Col3f transmission; //!< Transmission coefficient of material. 46 | float eta; //!< Refraction index of material. 47 | float thickness; //!< Thickness of material layer. 48 | }; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/renderers/progress.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_PROGRESS_H__ 18 | #define __EMBREE_PROGRESS_H__ 19 | 20 | #include "default.h" 21 | #include "sys/sync/atomic.h" 22 | #include "sys/sync/mutex.h" 23 | 24 | namespace embree 25 | { 26 | /*! prints progress during rendering */ 27 | class Progress 28 | { 29 | public: 30 | Progress (size_t num = 0); 31 | void start(); 32 | void next(); 33 | void end(); 34 | private: 35 | void drawEmptyBar(); 36 | private: 37 | MutexSys mutex; //!< Mutex to protect progress output 38 | size_t curElement; //!< Number of elements processed 39 | size_t numElements; //!< Total number of elements to process 40 | size_t numDrawn; //!< Number of progress characters drawn 41 | ssize_t terminalWidth; //!< Width of terminal window in characters 42 | }; 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/renderers/renderer.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_RENDERER_H_ 18 | #define __EMBREE_RENDERER_H_ 19 | 20 | #include "api/device.h" 21 | #include "api/parms.h" 22 | #include "api/scene.h" 23 | #include "api/swapchain.h" 24 | #include "tonemappers/tonemapper.h" 25 | #include "cameras/camera.h" 26 | 27 | namespace embree 28 | { 29 | /*! Renderer interface definition. */ 30 | class Renderer : public RefCount { 31 | ALIGNED_CLASS 32 | public: 33 | 34 | /*! tile size to use for rendering */ 35 | enum { TILE_SIZE = 16 }; 36 | 37 | /*! Renderers need a virtual destructor. */ 38 | virtual ~Renderer() {} 39 | 40 | /*! Renders a single frame. */ 41 | virtual void renderFrame(const Ref& camera, /*!< Camera to render from. */ 42 | const Ref& scene, /*!< Scene to render. */ 43 | const Ref& toneMapper, /*!< Tonemapper to use. */ 44 | Ref > film, /*!< Framebuffer to render into. */ 45 | int accumulate) = 0; /*!< Accumulation mode. */ 46 | 47 | }; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/samplers/distribution1d.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_DISTRIBUTION_1D_H__ 18 | #define __EMBREE_DISTRIBUTION_1D_H__ 19 | 20 | #include "default.h" 21 | 22 | namespace embree 23 | { 24 | /*! 1D probability distribution. The probability distribution 25 | * function (PDF) can be initialized with arbitrary data and be 26 | * sampled. */ 27 | class Distribution1D 28 | { 29 | public: 30 | 31 | /*! Default construction. */ 32 | Distribution1D(); 33 | 34 | /*! Construction from distribution array f. */ 35 | Distribution1D(const float* f, const size_t size); 36 | 37 | /*! Destruction. */ 38 | ~Distribution1D(); 39 | 40 | /*! Initialized the PDF and CDF arrays. */ 41 | void init(const float* f, const size_t size); 42 | 43 | public: 44 | 45 | /*! Draws a sample from the distribution. \param u is a random 46 | * number to use for sampling */ 47 | Sample1f sample(const float u) const; 48 | 49 | /*! Returns the probability density a sample would be drawn from location p. */ 50 | float pdf(const float p) const; 51 | 52 | private: 53 | size_t size; //!< Number of elements in the PDF 54 | float* PDF; //!< Probability distribution function 55 | float* CDF; //!< Cumulative distribution function (required for sampling) 56 | }; 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/samplers/distribution2d.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_DISTRIBUTION_2D_H__ 18 | #define __EMBREE_DISTRIBUTION_2D_H__ 19 | 20 | #include "distribution1d.h" 21 | 22 | namespace embree 23 | { 24 | /*! 2D probability distribution. The probability distribution 25 | * function (PDF) can be initialized with arbitrary data and be 26 | * sampled. */ 27 | class Distribution2D : public RefCount 28 | { 29 | public: 30 | 31 | /*! Default construction. */ 32 | Distribution2D(); 33 | 34 | /*! Construction from 2D distribution array f. */ 35 | Distribution2D(const float** f, const size_t width, const size_t height); 36 | 37 | /*! Destruction. */ 38 | ~Distribution2D(); 39 | 40 | /*! Initialized the PDF and CDF arrays. */ 41 | void init(const float** f, const size_t width, const size_t height); 42 | 43 | public: 44 | 45 | /*! Draws a sample from the distribution. \param u is a pair of 46 | * random numbers to use for sampling */ 47 | Sample2f sample(const Vec2f& u) const; 48 | 49 | /*! Returns the probability density a sample would be drawn from 50 | * location p. */ 51 | float pdf(const Vec2f& p) const; 52 | 53 | private: 54 | size_t width; //!< Number of elements in x direction 55 | size_t height; //!< Number of elements in y direction 56 | Distribution1D yDist; //!< Distribution to select between rows 57 | Distribution1D* xDists; //!< One 1D Distribution per row 58 | }; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/samplers/patterns.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_PATTERNS_H__ 18 | #define __EMBREE_PATTERNS_H__ 19 | 20 | #include "default.h" 21 | #include "sys/stl/array2d.h" 22 | #include "math/permutation.h" 23 | 24 | namespace embree 25 | { 26 | /*! Create a set of n jittered 1D samples, using the provided 27 | * random number generator. */ 28 | __forceinline void jittered(float* samples, const uint32 n, Random& rng) 29 | { 30 | float scale = 1.0f / n; 31 | Permutation permutation(n, rng); 32 | for (uint32 i = 0; i < n; i++) { 33 | samples[permutation[i]] = (float(i) + rng.getFloat()) * scale; 34 | } 35 | } 36 | 37 | /*! Create a set of n multi-jittered 2D samples, using the provided 38 | * random number generator. */ 39 | void multiJittered(Vec2f* samples, const uint32 n, Random& rng) 40 | { 41 | uint32 b = (uint32)sqrtf(float(n)); 42 | Array2D grid(b,b); 43 | 44 | vector_t numbers(b); 45 | for (uint32 i = 0; i < b; i++) 46 | numbers[i] = i; 47 | 48 | for (uint32 i = 0; i < b; i++) { 49 | numbers.shuffle(rng); 50 | for (uint32 j = 0; j < b; j++) { 51 | ((Vec2f**)grid)[i][j][0] = float(i)/float(b) + (numbers[j]+rng.getFloat())/float(b*b); 52 | } 53 | } 54 | 55 | for (uint32 i = 0; i < b; i++) { 56 | numbers.shuffle(rng); 57 | for (uint32 j = 0; j < b; j++) { 58 | ((Vec2f**)grid)[j][i][1] = float(i)/float(b) + (numbers[j]+rng.getFloat())/float(b*b); 59 | } 60 | } 61 | 62 | uint32 counter = 0; 63 | Permutation permutation(n, rng); 64 | for (uint32 i = 0; i < b; i++) 65 | for (uint32 j = 0; j < b; j++) 66 | samples[permutation[counter++]] = grid.get(i,j); 67 | } 68 | } 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/samplers/sample.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_SAMPLE_H__ 18 | #define __EMBREE_SAMPLE_H__ 19 | 20 | #include "default.h" 21 | 22 | namespace embree 23 | { 24 | /*! Sample representation. A sample has a location and a probability 25 | * density it got sampled with. */ 26 | template struct Sample 27 | { 28 | __forceinline Sample () {} 29 | __forceinline Sample ( const Sample& other ) { value = other.value; pdf = other.pdf; } 30 | __forceinline Sample& operator=( const Sample& other ) { value = other.value; pdf = other.pdf; return *this; } 31 | 32 | __forceinline Sample (const T& value, float pdf = one) : value(value), pdf(pdf) {} 33 | 34 | __forceinline operator const T&( ) const { return value; } 35 | __forceinline operator T&( ) { return value; } 36 | 37 | public: 38 | T value; //!< location of the sample 39 | float pdf; //!< probability density of the sample 40 | }; 41 | 42 | /*! output operator */ 43 | template __forceinline std::ostream& operator<<(std::ostream& cout, const Sample& s) { 44 | return cout << "{ value = " << s.value << ", pdf = " << s.pdf << "}"; 45 | } 46 | 47 | /*! shortcuts for common sample types */ 48 | typedef Sample Sample1i; 49 | typedef Sample Sample1f; 50 | typedef Sample Sample2f; 51 | typedef Sample Sample3f; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/shapes/differentialgeometry.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_DIFFERENTIAL_GEOMETRY_H__ 18 | #define __EMBREE_DIFFERENTIAL_GEOMETRY_H__ 19 | 20 | #include "rtcore/common/hit.h" 21 | 22 | namespace embree 23 | { 24 | /*! Contains additional shading information for hit points. */ 25 | struct DifferentialGeometry : public Hit 26 | { 27 | /*! Default construction. */ 28 | __forceinline DifferentialGeometry() 29 | : material(NULL), light(NULL) {} 30 | 31 | /*! Default construction. */ 32 | __forceinline DifferentialGeometry(const Hit& hit) 33 | : Hit(hit), material(NULL), light(NULL) {} 34 | 35 | public: 36 | class Material* material; //!< pointer to material of hit shape instance 37 | class AreaLight* light; //!< pointer to area light of hit shape instance 38 | 39 | public: 40 | Vec3f P; //!< Hit location in world coordinates. 41 | Vec3f Ng; //!< Normalized geometric normal. 42 | Vec3f Ns; //!< Normalized shading normal. 43 | Vec2f st; //!< Hit location in surface parameter space. 44 | float error; //!< Intersection error factor. 45 | }; 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/shapes/shape.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_SHAPE_H__ 18 | #define __EMBREE_SHAPE_H__ 19 | 20 | #include "default.h" 21 | #include "api/parms.h" 22 | #include "api/data.h" 23 | #include "rtcore/common/ray.h" 24 | #include "rtcore/common/accel.h" 25 | #include "differentialgeometry.h" 26 | 27 | namespace embree 28 | { 29 | /*! Interface to different shapes. A shape is the smallest geometric 30 | * primitive materials and area lights can be assigned to. */ 31 | class Shape : public RefCount { 32 | ALIGNED_CLASS 33 | public: 34 | 35 | /*! Shape virtual destructor. */ 36 | virtual ~Shape() {} 37 | 38 | /*! Instantiates a new shape by transforming this shape to a different location. */ 39 | virtual Ref transform(const AffineSpace3f& xfm) const = 0; 40 | 41 | /*! Counts the number of triangles required for extraction. */ 42 | virtual size_t numTriangles() const = 0; 43 | 44 | /*! Counts the number of vertices required for extraction. */ 45 | virtual size_t numVertices() const = 0; 46 | 47 | /*! Extracts triangles for spatial index structure. */ 48 | virtual BBox3f extract(size_t id, BuildTriangle* triangles, size_t& numTriangles, BuildVertex* vertices, size_t& numVertices) const = 0; 49 | 50 | /*! Performs interpolation of shading vertex parameters. */ 51 | virtual void postIntersect(const Ray& ray, DifferentialGeometry& dg) const = 0; 52 | }; 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/shapes/trianglemesh.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_TRIANGLE_MESH_H__ 18 | #define __EMBREE_TRIANGLE_MESH_H__ 19 | 20 | #include "shapes/shape.h" 21 | 22 | namespace embree 23 | { 24 | /*! Implements a triangle mesh. The mesh supports optional 25 | * vertex normals and texture coordinates. */ 26 | class TriangleMesh : public Shape 27 | { 28 | public: 29 | 30 | /*! Creation of best mesh via API */ 31 | struct Handle { 32 | static Ref create(const Parms& parms); 33 | }; 34 | 35 | /*! Triangle indices description. */ 36 | struct Triangle { 37 | __forceinline Triangle () {} 38 | __forceinline Triangle (const Vec3i& tri) : v0(tri.x), v1(tri.y), v2(tri.z) {} 39 | __forceinline Triangle (uint32 v0, uint32 v1, uint32 v2) : v0(v0), v1(v1), v2(v2) {} 40 | uint32 v0; //!< index of first triangle vertex 41 | uint32 v1; //!< index of second triangle vertex 42 | uint32 v2; //!< index of third triangle vertex 43 | }; 44 | 45 | protected: 46 | TriangleMesh() { } 47 | 48 | public: 49 | 50 | /*! Construction from parameter container. */ 51 | TriangleMesh (const Parms& parms); 52 | 53 | public: 54 | Ref transform(const AffineSpace3f& xfm) const; 55 | size_t numTriangles() const; 56 | size_t numVertices () const; 57 | BBox3f extract(size_t id, BuildTriangle* triangles, size_t& numTriangles, BuildVertex* vertices, size_t& numVertices) const; 58 | void postIntersect(const Ray& ray, DifferentialGeometry& dg) const; 59 | 60 | public: 61 | vector_t position; //!< Position array. 62 | vector_t motion; //!< Motion array. 63 | vector_t normal; //!< Normal array (can be empty). 64 | vector_t texcoord; //!< Texture coordinates array (can be empty). 65 | vector_t triangles; //!< Triangle indices array. 66 | }; 67 | } 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/shapes/trianglemesh_normals.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_TRIANGLE_MESH_WITH_NORMALS_H__ 18 | #define __EMBREE_TRIANGLE_MESH_WITH_NORMALS_H__ 19 | 20 | #include "shapes/shape.h" 21 | 22 | namespace embree 23 | { 24 | /*! Triangle mesh that only supports vertex normals. */ 25 | class TriangleMeshWithNormals : public Shape 26 | { 27 | public: 28 | 29 | /*! Vertex description. */ 30 | struct Vertex { 31 | Vec3f p; //!< vertex position 32 | Vec3f n; //!< vertex normal 33 | }; 34 | 35 | /*! Triangle indices description. */ 36 | struct Triangle { 37 | __forceinline Triangle () {} 38 | __forceinline Triangle (const Vec3i& tri) : v0(tri.x), v1(tri.y), v2(tri.z) {} 39 | __forceinline Triangle (uint32 v0, uint32 v1, uint32 v2) : v0(v0), v1(v1), v2(v2) {} 40 | uint32 v0; //!< index of first triangle vertex 41 | uint32 v1; //!< index of second triangle vertex 42 | uint32 v2; //!< index of third triangle vertex 43 | }; 44 | 45 | private: 46 | TriangleMeshWithNormals() {} 47 | 48 | public: 49 | 50 | /*! Construction from parameter container. */ 51 | TriangleMeshWithNormals (const Parms& parms); 52 | 53 | public: 54 | Ref transform(const AffineSpace3f& xfm) const; 55 | size_t numTriangles() const; 56 | size_t numVertices () const; 57 | BBox3f extract(size_t id, BuildTriangle* triangles, size_t& numTriangles, BuildVertex* vertices, size_t& numVertices) const; 58 | void postIntersect(const Ray& ray, DifferentialGeometry& dg) const; 59 | 60 | public: 61 | vector_t vertices; //!< Vertex array (positions and normals). 62 | vector_t triangles; //!< Triangle indices array. 63 | }; 64 | } 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/textures/nearestneighbor.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_NEAREST_NEIGHBOR_H__ 18 | #define __EMBREE_NEAREST_NEIGHBOR_H__ 19 | 20 | #include "image/image.h" 21 | #include "textures/texture.h" 22 | 23 | namespace embree 24 | { 25 | /*! Implements an image mapped texture with nearest neighbor 26 | * lookup. */ 27 | class NearestNeighbor : public Texture 28 | { 29 | public: 30 | 31 | /*! Construction from image. */ 32 | NearestNeighbor (const Ref& image) 33 | : image(image) { 34 | } 35 | 36 | /*! Construction from parameters. */ 37 | NearestNeighbor (const Parms& parms) { 38 | image = parms.getImage("image"); 39 | } 40 | 41 | Col3f get(const Vec2f& p) const { 42 | float s1 = p.x-floor(p.x), t1 = p.y-floor(p.y); 43 | int si = (int)(s1*float(image->width)), ti = (int)(t1*float(image->height)); 44 | int ix = clamp(si, int(0), int(image->width-1)); 45 | int iy = clamp(ti, int(0), int(image->height-1)); 46 | return image->get(ix,iy); 47 | } 48 | 49 | private: 50 | Ref image; //!< Image mapped to surface. 51 | }; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/textures/texture.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_TEXTURE_H__ 18 | #define __EMBREE_TEXTURE_H__ 19 | 20 | #include "default.h" 21 | 22 | namespace embree 23 | { 24 | /*! Interface for different textures. Textures implement a mapping 25 | * from a surface point to a color. */ 26 | class Texture : public RefCount { 27 | ALIGNED_CLASS 28 | public: 29 | 30 | /*! Texture virtual destructor. */ 31 | virtual ~Texture() {}; 32 | 33 | /*! Returns the color for a surface point p. \param p is the 34 | * location to query the color for. The range is 0 to 1. */ 35 | virtual Col3f get(const Vec2f& p) const = 0; 36 | }; 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/tonemappers/defaulttonemapper.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_DEFAULT_TONEMAPPER_H__ 18 | #define __EMBREE_DEFAULT_TONEMAPPER_H__ 19 | 20 | #include "tonemappers/tonemapper.h" 21 | 22 | namespace embree 23 | { 24 | /*! Default tonemapper. Performs gamma correction and vignette effect. */ 25 | class DefaultToneMapper : public ToneMapper { 26 | ALIGNED_CLASS 27 | public: 28 | 29 | /*! Default tonemapper constructor. */ 30 | DefaultToneMapper (const Parms& parms) 31 | { 32 | gamma = parms.getFloat("gamma",1.0f); 33 | rcpGamma = rcp(gamma); 34 | vignetting = parms.getBool("vignetting",false); 35 | } 36 | 37 | /*! Evaluates the tonemapper, */ 38 | virtual void eval (Ref& dst, const Ref& src, Vec2i start, Vec2i end) const 39 | { 40 | int width = (int)src->getWidth(); 41 | int height = (int)src->getHeight(); 42 | for (ssize_t y=start.y; y<=end.y; y++) { 43 | for (ssize_t x=start.x; x<=end.x; x++) { 44 | const Vec4f& a0 = src->get(x,y); 45 | Col3f color0 = Col3f(a0.x,a0.y,a0.z) * rcp(a0.w); 46 | if (gamma != 1.0f) { 47 | color0 = pow(color0,rcpGamma); 48 | } 49 | if (vignetting) { 50 | float d = length((Vec2f(float(x),float(y)) - 0.5f*Vec2f(float(width),float(height))) * rcp(0.5f*float(width))); 51 | color0 *= powf(cosf(d*0.5f),3.0f); 52 | } 53 | dst->get(x,y) = Vec4f(color0.r,color0.g,color0.b,1.0f); 54 | } 55 | } 56 | } 57 | 58 | private: 59 | float gamma; //!< Gamma value. 60 | float rcpGamma; //!< Reciprocal gamma value. 61 | bool vignetting; //!< Add a vignetting effect. 62 | }; 63 | } 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /libs/embree/include/renderer/tonemappers/tonemapper.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_TONEMAPPER_H__ 18 | #define __EMBREE_TONEMAPPER_H__ 19 | 20 | #include "api/parms.h" 21 | #include "api/framebuffer.h" 22 | 23 | namespace embree 24 | { 25 | /*! Interface to different tonemappers. */ 26 | class ToneMapper : public RefCount { 27 | ALIGNED_CLASS 28 | public: 29 | 30 | /*! Tonemappers need a virtual destructor. */ 31 | virtual ~ToneMapper() {} 32 | 33 | /*! Evaluates the tonemapper, */ 34 | virtual void eval ( Ref& dst, /*!< source buffer. */ 35 | const Ref& src, /*!< target buffer. */ 36 | Vec2i start, /*!< first pixel to process */ 37 | Vec2i end /*!< last pixel to process */) const 38 | { 39 | } 40 | }; 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /libs/embree/include/rtcore/bvh2/bvh2_intersector.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH2_INTERSECTOR_H__ 18 | #define __EMBREE_BVH2_INTERSECTOR_H__ 19 | 20 | #include "bvh2.h" 21 | #include "../common/intersector.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH2 Traverser. Single ray traversal implementation for a binary BVH. */ 26 | template 27 | class BVH2Intersector : public Intersector 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector::Triangle Triangle; 31 | typedef typename BVH2::Base Base; 32 | typedef typename BVH2::Node Node; 33 | 34 | public: 35 | BVH2Intersector (const Ref& bvh) : bvh(bvh) {} 36 | void intersect(const Ray& ray, Hit& hit) const; 37 | bool occluded (const Ray& ray) const; 38 | 39 | private: 40 | Ref bvh; 41 | }; 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /libs/embree/include/rtcore/bvh4/bvh4_intersector.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4_INTERSECTOR_H__ 18 | #define __EMBREE_BVH4_INTERSECTOR_H__ 19 | 20 | #include "bvh4.h" 21 | #include "../common/intersector.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH4 Traverser. Single ray traversal implementation for a Quad BVH. */ 26 | template 27 | class BVH4Intersector : public Intersector 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector::Triangle Triangle; 31 | typedef typename BVH4::Base Base; 32 | typedef typename BVH4::Node Node; 33 | 34 | public: 35 | BVH4Intersector (const Ref& bvh) : bvh(bvh) {} 36 | void intersect(const Ray& ray, Hit& hit) const; 37 | bool occluded (const Ray& ray) const; 38 | 39 | private: 40 | Ref bvh; 41 | }; 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /libs/embree/include/rtcore/bvh4mb/bvh4mb_intersector.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4MB_INTERSECTOR_H__ 18 | #define __EMBREE_BVH4MB_INTERSECTOR_H__ 19 | 20 | #include "bvh4mb.h" 21 | #include "../common/intersector.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH4MB Traverser. Single ray traversal implementation for a Quad BVH. */ 26 | template 27 | class BVH4MBIntersector : public Intersector 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector::Triangle Triangle; 31 | typedef typename BVH4MB::Base Base; 32 | typedef typename BVH4MB::Node Node; 33 | 34 | public: 35 | BVH4MBIntersector (const Ref& bvh) : bvh(bvh) {} 36 | void intersect(const Ray& ray, Hit& hit) const; 37 | bool occluded (const Ray& ray) const; 38 | 39 | private: 40 | Ref bvh; 41 | }; 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /libs/embree/include/rtcore/common/default.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_RTCORE_DEFAULT_H__ 18 | #define __EMBREE_RTCORE_DEFAULT_H__ 19 | 20 | #include "sys/platform.h" 21 | #include "sys/ref.h" 22 | #include "sys/intrinsics.h" 23 | #include "sys/sync/atomic.h" 24 | #include "sys/stl/vector.h" 25 | #include "sys/stl/string.h" 26 | #include "sys/taskscheduler.h" 27 | 28 | #include "math/math.h" 29 | #include "math/vec2.h" 30 | #include "math/vec3.h" 31 | #include "math/vec4.h" 32 | #include "math/bbox.h" 33 | #include "math/affinespace.h" 34 | 35 | #include "simd/simd.h" 36 | 37 | #include "stat.h" 38 | 39 | namespace embree 40 | { 41 | typedef Vec2 sse2b; 42 | typedef Vec3 sse3b; 43 | typedef Vec2 sse2i; 44 | typedef Vec3 sse3i; 45 | typedef Vec2 sse2f; 46 | typedef Vec3 sse3f; 47 | 48 | typedef Vec2 avx2b; 49 | typedef Vec3 avx3b; 50 | typedef Vec2 avx2i; 51 | typedef Vec3 avx3i; 52 | typedef Vec2 avx2f; 53 | typedef Vec3 avx3f; 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /libs/embree/include/rtcore/common/hit.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_HIT_H__ 18 | #define __EMBREE_HIT_H__ 19 | 20 | #include "../common/default.h" 21 | 22 | namespace embree 23 | { 24 | /*! Hit information. Stores all information about a hit. */ 25 | struct Hit 26 | { 27 | /*! Default constructor creates invalid hit. */ 28 | Hit () : id0(-1), id1(-1), t(inf) {}; 29 | 30 | /*! Tests if we hit something. */ 31 | __forceinline operator bool() const { return id0 != -1; } 32 | 33 | public: 34 | int id0; //!< 1st primitive ID 35 | int id1; //!< 2nd primitive ID 36 | float u; //!< Barycentric u coordinate of hit 37 | float v; //!< Barycentric v coordinate of hit 38 | float t; //!< Distance of hit 39 | }; 40 | 41 | /*! Outputs hit to to stream. */ 42 | inline std::ostream& operator<<(std::ostream& cout, const Hit& hit) { 43 | return cout << "{ id0 = " << hit.id0 << ", id1 = " << hit.id1 << ", " 44 | << "u = " << hit.u << ", v = " << hit.v << ", t = " << hit.t << " }"; 45 | } 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /libs/embree/include/rtcore/common/intersector.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_INTERSECTOR_H__ 18 | #define __EMBREE_INTERSECTOR_H__ 19 | 20 | #include "ray.h" 21 | #include "hit.h" 22 | 23 | namespace embree 24 | { 25 | /*! Single ray interface to the traverser. A closest intersection 26 | * point of a ray with the geometry can be found. A ray can also be 27 | * tested for occlusion by any geometry. */ 28 | class Intersector : public RefCount { 29 | public: 30 | 31 | /*! name for this interface */ 32 | static const char* const name; 33 | 34 | /*! A virtual destructor is required. */ 35 | virtual ~Intersector() {} 36 | 37 | /*! Intersects the ray with the geometry and returns the hit 38 | * information. */ 39 | virtual void intersect(const Ray& ray, /*!< Ray to shoot. */ 40 | Hit& hit /*!< Hit result. */) const = 0; 41 | 42 | /*! Tests the ray for occlusion with the scene. */ 43 | virtual bool occluded (const Ray& ray /*!< Ray to test occlusion for. */) const = 0; 44 | }; 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /libs/embree/include/rtcore/common/primref.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_PRIM_REF_H__ 18 | #define __EMBREE_PRIM_REF_H__ 19 | 20 | #include "default.h" 21 | 22 | namespace embree 23 | { 24 | /*! A primitive reference stores the bounds of the primitive and its ID. */ 25 | struct __align(16) PrimRef 26 | { 27 | __forceinline PrimRef () {} 28 | __forceinline PrimRef (const BBox3f& bounds, size_t id) { 29 | assert(!bounds.empty() || id == size_t(-1)); 30 | lower = bounds.lower; 31 | upper = bounds.upper; 32 | #if defined(__X86_64__) 33 | lower.a = (unsigned) (id >> 0); 34 | upper.a = (unsigned) (id >> 32); 35 | #else 36 | lower.a = id; 37 | #endif 38 | } 39 | 40 | __forceinline size_t id() const { 41 | #if defined(__X86_64__) 42 | return (size_t(unsigned(upper.a)) << 32) | size_t(unsigned(lower.a)); 43 | #else 44 | return lower.a; 45 | #endif 46 | } 47 | 48 | __forceinline const BBox3f bounds() const { 49 | return BBox3f(lower,upper); 50 | } 51 | 52 | public: 53 | Vec3fa lower; 54 | Vec3fa upper; 55 | }; 56 | 57 | /*! Outputs primitive reference to a stream. */ 58 | inline std::ostream& operator<<(std::ostream& cout, const PrimRef& ref) { 59 | return cout << "{ lower = " << ref.lower << ", upper = " << ref.upper << ", id = " << ref.id() << " }"; 60 | } 61 | } 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /libs/embree/include/rtcore/common/primrefblock.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_PRIM_REF_BLOCK_H__ 18 | #define __EMBREE_PRIM_REF_BLOCK_H__ 19 | 20 | #include "primref.h" 21 | #include "atomic_set.h" 22 | 23 | namespace embree 24 | { 25 | /*! Data of a block. */ 26 | class PrimRefBlock 27 | { 28 | public: 29 | 30 | /*! Element type */ 31 | typedef PrimRef T; 32 | 33 | /*! Number of primitive references inside a block */ 34 | //static const size_t blockSize = 127; 35 | //static const size_t blockSize = 511; 36 | static const size_t blockSize = 1023; 37 | //static const size_t blockSize = 2047; 38 | 39 | /*! default constructor */ 40 | PrimRefBlock () : num(0) {} 41 | 42 | /*! frees the block */ 43 | __forceinline void clear(size_t n = 0) { num = n; } 44 | 45 | /*! return base pointer */ 46 | __forceinline PrimRef* base() { return ptr; } 47 | 48 | /*! returns number of elements */ 49 | __forceinline size_t size() const { return num; } 50 | 51 | /*! inserts a primitive reference */ 52 | __forceinline bool insert(const PrimRef& ref) { 53 | if (unlikely(num >= blockSize)) return false; 54 | ptr[num++] = ref; 55 | return true; 56 | } 57 | 58 | /*! access the i-th primitive reference */ 59 | __forceinline PrimRef& operator[] (size_t i) { return ptr[i]; } 60 | __forceinline const PrimRef& operator[] (size_t i) const { return ptr[i]; } 61 | 62 | /*! access the i-th primitive reference */ 63 | __forceinline PrimRef& at (size_t i) { return ptr[i]; } 64 | __forceinline const PrimRef& at (size_t i) const { return ptr[i]; } 65 | 66 | private: 67 | PrimRef ptr[blockSize]; //!< Block with primitive references 68 | size_t num; //!< Number of primitive references in block 69 | char align[sizeof(PrimRef)-sizeof(size_t)]; 70 | }; 71 | } 72 | #endif 73 | 74 | -------------------------------------------------------------------------------- /libs/embree/include/rtcore/common/ray.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_RAY_H__ 18 | #define __EMBREE_RAY_H__ 19 | 20 | #include "../common/default.h" 21 | 22 | namespace embree 23 | { 24 | /*! Ray structure. Contains all information about a ray including 25 | * precomputed reciprocal direction. */ 26 | struct Ray 27 | { 28 | /*! Default construction does nothing. */ 29 | __forceinline Ray() {} 30 | 31 | /*! Constructs a ray from origin, direction, and ray segment. Near 32 | * has to be smaller than far. */ 33 | __forceinline Ray(const Vec3f& org, const Vec3f& dir, float near = zero, float far = inf, float time = zero) 34 | : org(org), dir(dir), rdir(rcp_safe(dir)), near(near), far(far), time(time) {} 35 | 36 | public: 37 | Vec3f org; //!< Ray origin 38 | Vec3f dir; //!< Ray direction 39 | Vec3f rdir; //!< Reciprocal ray direction 40 | float near; //!< Start of ray segment 41 | float far; //!< End of ray segment 42 | float time; //!< Time of this ray for motion blur. 43 | }; 44 | 45 | /*! Outputs ray to stream. */ 46 | inline std::ostream& operator<<(std::ostream& cout, const Ray& ray) { 47 | return cout << "{ org = " << ray.org << ", dir = " << ray.dir << ", rdir = " << ray.rdir << ", near = " << ray.near << ", far = " << ray.far << ", time = " << ray.time << " }"; 48 | } 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /libs/embree/include/rtcore/common/splitter.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_SPLITTER_H__ 18 | #define __EMBREE_SPLITTER_H__ 19 | 20 | #include "accel.h" 21 | #include "primrefalloc.h" 22 | #include "primrefblock.h" 23 | 24 | namespace embree 25 | { 26 | /*! Splits a list of build primitives into two lists using a single thread. */ 27 | template 28 | class Splitter 29 | { 30 | typedef typename Heuristic::Split Split; 31 | typedef typename Heuristic::PrimInfo PrimInfo; 32 | 33 | public: 34 | /*! the constructor directly performs the split */ 35 | Splitter (const TaskScheduler::ThreadInfo& thread, PrimRefAlloc* alloc, const BuildTriangle* triangles, const Vec3fa* vertices, 36 | atomic_set& prims, const PrimInfo& pinfo, const Split& psplit); 37 | 38 | /*! perform specified split */ 39 | void split(const TaskScheduler::ThreadInfo& thread, PrimRefAlloc* alloc, const BuildTriangle* triangles, const Vec3fa* vertices, 40 | atomic_set& prims, const PrimInfo& pinfo, const Split& split); 41 | 42 | /*! perform specified spatial split */ 43 | void split_spatial(const TaskScheduler::ThreadInfo& thread, PrimRefAlloc* alloc, const BuildTriangle* triangles, const Vec3fa* vertices, 44 | atomic_set& prims, const PrimInfo& pinfo, const Split& split); 45 | 46 | /* output data */ 47 | public: 48 | atomic_set lprims; //!< left primitive list 49 | atomic_set rprims; //!< right primitive list 50 | PrimInfo linfo; //!< left bounding information of primitives 51 | PrimInfo rinfo; //!< right bounding information of primitives 52 | Split lsplit; //!< best split for left primitives 53 | Split rsplit; //!< best split for right primitives 54 | }; 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /libs/embree/include/rtcore/common/splitter_fallback.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_SPLITTER_FALLBACK_H__ 18 | #define __EMBREE_SPLITTER_FALLBACK_H__ 19 | 20 | #include "accel.h" 21 | #include "primrefalloc.h" 22 | #include "primrefblock.h" 23 | 24 | namespace embree 25 | { 26 | /*! Splits a list of build primitives into two arbitrary lists. */ 27 | template 28 | class FallBackSplitter 29 | { 30 | typedef typename Heuristic::Split Split; 31 | typedef typename Heuristic::PrimInfo PrimInfo; 32 | 33 | public: 34 | 35 | /*! enforce some object median split */ 36 | static void split(const TaskScheduler::ThreadInfo& thread, PrimRefAlloc* alloc, const BuildTriangle* triangles, const Vec3fa* vertices, 37 | PrimRefBlockList& prims, const PrimInfo& pinfo, 38 | PrimRefBlockList& lprims_o, PrimInfo& linfo_o, Split& lsplit_o, 39 | PrimRefBlockList& rprims_o, PrimInfo& rinfo_o, Split& rsplit_o); 40 | }; 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /libs/embree/include/rtcore/common/stat.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************* *\ 2 | INTEL CORPORATION PROPRIETARY INFORMATION 3 | This software is supplied under the terms of a license agreement or 4 | nondisclosure agreement with Intel Corporation and may not be copied 5 | or disclosed except in accordance with the terms of that agreement. 6 | Copyright (C) 2009 Intel Corporation. All Rights Reserved. 7 | \* ************************************************************************* */ 8 | 9 | #ifndef __EMBREE_STAT_H__ 10 | #define __EMBREE_STAT_H__ 11 | 12 | #include "default.h" 13 | 14 | /* Makros to gather statistics */ 15 | #ifdef __USE_STAT_COUNTERS__ 16 | #define STAT(x) x 17 | #define STAT3(s,x,y,z) \ 18 | STAT(Stat::get().code .s+=x); \ 19 | STAT(Stat::get().active.s+=y); \ 20 | STAT(Stat::get().all .s+=z); 21 | #else 22 | #define STAT(x) 23 | #define STAT3(s,x,y,z) 24 | #endif 25 | 26 | namespace embree 27 | { 28 | /*! Gathers ray tracing statistics. */ 29 | class Stat 30 | { 31 | public: 32 | 33 | Stat (); 34 | ~Stat (); 35 | 36 | class Counters 37 | { 38 | public: 39 | Counters () { 40 | clear(); 41 | } 42 | 43 | void clear() { 44 | memset(this,0,sizeof(Counters)); 45 | } 46 | 47 | public: 48 | 49 | union { 50 | 51 | struct { 52 | 53 | /* per packet and per ray stastics */ 54 | struct { 55 | /* normal and shadow ray statistics */ 56 | struct { 57 | size_t travs; 58 | size_t trav_nodes; 59 | size_t trav_leaves; 60 | size_t trav_tris; 61 | } normal, shadow; 62 | } all, active, code; 63 | }; 64 | 65 | size_t data[32]; 66 | }; 67 | }; 68 | 69 | public: 70 | 71 | static __forceinline Counters& get() { 72 | return instance.cntrs; 73 | } 74 | 75 | static void clear() { 76 | instance.cntrs.clear(); 77 | } 78 | 79 | static void print(std::ostream& cout); 80 | 81 | private: 82 | Counters cntrs; 83 | private: 84 | static Stat instance; 85 | }; 86 | } 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /libs/embree/include/rtcore/triangle/triangle.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_ACCEL_TRIANGLE_H__ 18 | #define __EMBREE_ACCEL_TRIANGLE_H__ 19 | 20 | #include "../common/default.h" 21 | #include "../common/atomic_set.h" 22 | #include "../common/primrefblock.h" 23 | 24 | namespace embree 25 | { 26 | struct TriangleType 27 | { 28 | /*! constructs the triangle type */ 29 | TriangleType (const char* name, size_t bytes, size_t blockSize, bool needVertices, int intCost) 30 | : name(name), bytes(bytes), blockSize(blockSize), needVertices(needVertices), intCost(intCost) {} 31 | 32 | /*! Computes the number of blocks required to store a number of triangles. */ 33 | virtual size_t blocks(size_t x) const = 0; 34 | 35 | /*! Returns the number of stored triangles. */ 36 | virtual size_t size(const char* This) const = 0; 37 | 38 | /*! Computes the area of the triangle. */ 39 | virtual float area(const char* This, const Vec3fa* vertices) const = 0; 40 | 41 | /*! Packs triangle taken from primitive list. */ 42 | virtual void pack(char* This, atomic_set::block_iterator_unsafe& prims, const BuildTriangle* triangles, const Vec3fa* vertices) const = 0; 43 | 44 | /*! Computes the bounds of timestep t0 and t1 of a moving triangle. */ 45 | virtual std::pair bounds(char* This, const Vec3fa* vertices) const { return std::pair(empty,empty); } 46 | 47 | std::string name; //!< name of this triangle type 48 | size_t bytes; //!< number of bytes of the triangle data 49 | size_t blockSize; //!< block size 50 | bool needVertices; //!< determines if we need the vertex array 51 | int intCost; //!< cost of one ray/triangle intersection 52 | }; 53 | } 54 | 55 | #endif 56 | 57 | 58 | -------------------------------------------------------------------------------- /libs/embree/include/simd/avx.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_AVX_H__ 18 | #define __EMBREE_AVX_H__ 19 | 20 | #include "simd/sse.h" 21 | 22 | #if defined(__AVX__) 23 | #include 24 | #else 25 | #include "immintrin_emu.h" 26 | #endif 27 | 28 | /* fix incompatibity issue of GCC and ICC immintrin.h */ 29 | #if defined(__INTEL_COMPILER) || defined(__EMU_M256_AVXIMMINTRIN_EMU_H__) 30 | __forceinline __m256 _mm256_maskload_ps (float const *ptr, __m256 mask) { 31 | return _mm256_maskload_ps(ptr, _mm256_castps_si256(mask)); 32 | } 33 | __forceinline void _mm256_maskstore_ps (float *ptr, __m256 mask, __m256 data) { 34 | _mm256_maskstore_ps(ptr, _mm256_castps_si256(mask), data); 35 | } 36 | #elif !defined(_MSC_VER) && !defined(__UNIX__) 37 | __forceinline __m256 _mm256_maskload_ps (float const *ptr, __m256i mask) { 38 | return _mm256_maskload_ps(ptr, _mm256_castsi256_ps(mask)); 39 | } 40 | __forceinline void _mm256_maskstore_ps (float *ptr, __m256i mask, __m256 data) { 41 | _mm256_maskstore_ps(ptr, _mm256_castsi256_ps(mask), data); 42 | } 43 | #endif 44 | 45 | #include "simd/avxb.h" 46 | #include "simd/avxi.h" 47 | #include "simd/avxf.h" 48 | 49 | #define BEGIN_ITERATE_AVXB(valid_i,id_o) { \ 50 | int _valid_t = movemask(valid_i); \ 51 | while (_valid_t) { \ 52 | int id_o = __bsf(_valid_t); \ 53 | _valid_t = __btc(_valid_t,id_o); 54 | #define END_ITERATE_AVXB } } 55 | 56 | #define BEGIN_ITERATE_AVXI(valid_i,obj_i,valid_o,obj_o) { \ 57 | int _valid_t = movemask(valid_i); \ 58 | while (_valid_t) { \ 59 | int obj_o = obj_i[__bsf(_valid_t)]; \ 60 | avxb valid_o = valid_i & (obj_i == broadcast(&obj_i[__bsf(_valid_t)])); \ 61 | _valid_t ^= movemask(valid_o); 62 | #define END_ITERATE_AVXI } } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /libs/embree/include/simd/simd.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************* *\ 2 | INTEL CORPORATION PROPRIETARY INFORMATION 3 | This software is supplied under the terms of a license agreement or 4 | nondisclosure agreement with Intel Corporation and may not be copied 5 | or disclosed except in accordance with the terms of that agreement. 6 | Copyright (C) 2009 Intel Corporation. All Rights Reserved. 7 | \* ************************************************************************* */ 8 | 9 | #ifndef __EMBREE_SIMD_H__ 10 | #define __EMBREE_SIMD_H__ 11 | 12 | #include "math/math.h" 13 | #include "simd/pairb.h" 14 | #include "simd/pairi.h" 15 | #include "simd/pairf.h" 16 | 17 | /* we require SSE for simd4 types */ 18 | #include "simd/sse.h" 19 | namespace embree 20 | { 21 | typedef sseb simd4b; 22 | typedef ssei simd4i; 23 | typedef ssef simd4f; 24 | } 25 | 26 | /* we choose between AVX and 2x SSE for simd8 types */ 27 | #if defined(__AVX__) 28 | #include "simd/avx.h" 29 | #define AVX_ZERO_UPPER() _mm256_zeroupper() 30 | namespace embree 31 | { 32 | typedef avxb simd8b; 33 | typedef avxi simd8i; 34 | typedef avxf simd8f; 35 | } 36 | #else 37 | #define AVX_ZERO_UPPER() 38 | namespace embree 39 | { 40 | typedef pairb avxb; 41 | typedef pairi avxi; 42 | typedef pairf avxf; 43 | 44 | typedef pairb simd8b; 45 | typedef pairi simd8i; 46 | typedef pairf simd8f; 47 | } 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /libs/embree/include/sys/library.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_LIBRARY_H__ 18 | #define __EMBREE_LIBRARY_H__ 19 | 20 | #include "platform.h" 21 | 22 | namespace embree 23 | { 24 | /*! type for shared library */ 25 | typedef struct opaque_lib_t* lib_t; 26 | 27 | /*! loads a shared library */ 28 | lib_t openLibrary(const std::string& file); 29 | 30 | /*! returns address of a symbol from the library */ 31 | void* getSymbol(lib_t lib, const std::string& sym); 32 | 33 | /*! unloads a shared library */ 34 | void closeLibrary(lib_t lib); 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /libs/embree/include/sys/stl/array2d.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_ARRAY2D_H__ 18 | #define __EMBREE_ARRAY2D_H__ 19 | 20 | #include "../platform.h" 21 | 22 | namespace embree 23 | { 24 | template 25 | class Array2D 26 | { 27 | public: 28 | Array2D() : sizeX(0), sizeY(0), data(NULL) {} 29 | 30 | Array2D(size_t sizeX, size_t sizeY) : sizeX(sizeX), sizeY(sizeY) { 31 | data = new T*[sizeX]; 32 | for (size_t x = 0; x < sizeX; x++) 33 | data[x] = new T[sizeY]; 34 | } 35 | 36 | ~Array2D() { 37 | for (size_t x = 0; x < sizeX; x++) 38 | delete[] data[x]; 39 | delete[] data; 40 | } 41 | 42 | operator const T**() const { return const_cast(data); } 43 | operator T**() { return data; } 44 | const T& get(const size_t x, const size_t y) const { return data[x][y]; } 45 | T& get(const size_t x, const size_t y) { return data[x][y]; } 46 | void set(const size_t x, const size_t y, const T& value) { data[x][y] = value; } 47 | 48 | private: 49 | size_t sizeX; 50 | size_t sizeY; 51 | T** data; 52 | }; 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /libs/embree/include/sys/stl/string.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_STRING_H__ 18 | #define __EMBREE_STRING_H__ 19 | 20 | #include "../platform.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace std 29 | { 30 | string strlwr(const string& s); 31 | string strupr(const string& s); 32 | 33 | template __forceinline string stringOf( T const& v) { 34 | stringstream s; s << v; return s.str(); 35 | } 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libs/embree/include/sys/sync/atomic.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_ATOMIC_H__ 18 | #define __EMBREE_ATOMIC_H__ 19 | 20 | #include "../intrinsics.h" 21 | 22 | namespace embree 23 | { 24 | struct Atomic { 25 | protected: 26 | Atomic( const Atomic& ); // don't implement 27 | Atomic& operator =( const Atomic& ); // don't implement 28 | 29 | public: 30 | __forceinline Atomic( void ) : data(0) {} 31 | __forceinline Atomic( const atomic_t data ) : data(data) {} 32 | __forceinline Atomic& operator =( const atomic_t input ) { data = input; return *this; } 33 | __forceinline operator atomic_t() const { return data; } 34 | 35 | public: 36 | __forceinline atomic_t sub( const atomic_t input ) { return atomic_add(&data,-input) - input; } 37 | __forceinline atomic_t add( const atomic_t input ) { return atomic_add(&data, input) + input; } 38 | __forceinline friend atomic_t operator +=( Atomic& value, const atomic_t input ) { return atomic_add(&value.data, input) + input; } 39 | __forceinline friend atomic_t operator ++( Atomic& value ) { return atomic_add(&value.data, 1) + 1; } 40 | __forceinline friend atomic_t operator --( Atomic& value ) { return atomic_add(&value.data, -1) - 1; } 41 | __forceinline friend atomic_t operator ++( Atomic& value, int ) { return atomic_add(&value.data, 1); } 42 | __forceinline friend atomic_t operator --( Atomic& value, int ) { return atomic_add(&value.data, -1); } 43 | __forceinline friend atomic_t cmpxchg ( Atomic& value, const atomic_t v, const atomic_t c) { return atomic_cmpxchg(&value.data,v,c); } 44 | 45 | private: 46 | volatile atomic_t data; 47 | }; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /libs/embree/include/sys/sync/barrier.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BARRIER_H__ 18 | #define __EMBREE_BARRIER_H__ 19 | 20 | #include "condition.h" 21 | 22 | namespace embree 23 | { 24 | /*! system barrier using operating system */ 25 | class BarrierSys 26 | { 27 | public: 28 | 29 | void init(size_t count) { 30 | this->count = 0; 31 | this->full_size = count; 32 | } 33 | 34 | int wait() 35 | { 36 | count_mutex.lock(); 37 | count++; 38 | 39 | if (count == full_size) { 40 | count = 0; 41 | cond.broadcast(); 42 | count_mutex.unlock(); 43 | return 1; 44 | } 45 | 46 | cond.wait(count_mutex); 47 | count_mutex.unlock(); 48 | return 0; 49 | } 50 | 51 | protected: 52 | size_t count, full_size; 53 | MutexSys count_mutex; 54 | ConditionSys cond; 55 | }; 56 | 57 | /* default barrier type */ 58 | class Barrier : public BarrierSys {}; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /libs/embree/include/sys/sync/condition.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_CONDITION_H__ 18 | #define __EMBREE_CONDITION_H__ 19 | 20 | #include "mutex.h" 21 | 22 | namespace embree 23 | { 24 | class ConditionSys 25 | { 26 | public: 27 | ConditionSys( void ); 28 | ~ConditionSys( void ); 29 | void wait( class MutexSys& mutex ); 30 | void broadcast( void ); 31 | 32 | protected: 33 | void* cond; 34 | }; 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /libs/embree/include/sys/sync/mutex.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_MUTEX_H__ 18 | #define __EMBREE_MUTEX_H__ 19 | 20 | #include "../platform.h" 21 | #include "atomic.h" 22 | 23 | namespace embree 24 | { 25 | /*! system mutex */ 26 | class MutexSys { 27 | friend class ConditionSys; 28 | public: 29 | 30 | MutexSys( void ); 31 | ~MutexSys( void ); 32 | 33 | void lock( void ); 34 | void unlock( void ); 35 | 36 | protected: 37 | void* mutex; 38 | 39 | MutexSys( const MutexSys& ); // don't implement 40 | MutexSys& operator =( const MutexSys& ); // don't implement 41 | }; 42 | 43 | /*! spinning mutex */ 44 | class MutexActive { 45 | public: 46 | __forceinline MutexActive( void ) : $lock(LOCK_IS_FREE) {} 47 | void lock ( void ); 48 | __forceinline void unlock( void ) { 49 | __memory_barrier(); // compiler must not schedule loads and stores around this point 50 | $lock = LOCK_IS_FREE; 51 | } 52 | protected: 53 | enum ${ LOCK_IS_FREE = 0, LOCK_IS_TAKEN = 1 }; 54 | Atomic $lock; 55 | 56 | MutexActive( const MutexActive& ); // don't implement 57 | MutexActive& operator =( const MutexActive& ); // don't implement 58 | }; 59 | 60 | /*! safe mutex lock and unlock helper */ 61 | template class Lock { 62 | public: 63 | Lock (Mutex& mutex) : mutex(mutex) { mutex.lock(); } 64 | ~Lock() { mutex.unlock(); } 65 | protected: 66 | Mutex& mutex; 67 | Lock( const Lock& ); // don't implement 68 | Lock& operator =( const Lock& ); // don't implement 69 | }; 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /libs/embree/include/sys/sysinfo.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_SYSINFO_H__ 18 | #define __EMBREE_SYSINFO_H__ 19 | 20 | #include "sys/platform.h" 21 | 22 | namespace embree 23 | { 24 | enum CPUModel { 25 | CPU_UNKNOWN, 26 | CPU_CORE1, 27 | CPU_CORE2, 28 | CPU_CORE_NEHALEM, 29 | CPU_CORE_SANDYBRIDGE 30 | }; 31 | 32 | /*! get the full path to the running executable */ 33 | std::string getExecutableFileName(); 34 | 35 | /*! return platform name */ 36 | std::string getPlatformName(); 37 | 38 | /*! return the name of the CPU */ 39 | std::string getCPUVendor(); 40 | 41 | /*! get microprocessor model */ 42 | CPUModel getCPUModel(); 43 | 44 | /*! return the number of logical threads of the system */ 45 | size_t getNumberOfLogicalThreads(); 46 | 47 | /*! returns the size of the terminal window in characters */ 48 | int getTerminalWidth(); 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /libs/embree/include/sys/taskscheduler.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_TASKSCHEDULER_H__ 18 | #define __EMBREE_TASKSCHEDULER_H__ 19 | 20 | #include "sys/platform.h" 21 | #include "ref.h" 22 | 23 | namespace embree 24 | { 25 | /*! Interface to different task scheduler implementations. */ 26 | class TaskScheduler : public RefCount 27 | { 28 | public: 29 | 30 | /*! Task queues */ 31 | enum QUEUE { GLOBAL_FRONT, GLOBAL_BACK }; 32 | 33 | /*! thread and core ID struct */ 34 | struct ThreadInfo 35 | { 36 | ThreadInfo () : id(0) {} 37 | ThreadInfo (size_t id) : id(id) {} 38 | size_t id; // thread ID from 0 to getNumberOfLogicalThreads()-1 39 | }; 40 | 41 | /*! the run function executed for each work item of the task */ 42 | typedef void (*runFunction)(const ThreadInfo& thread, void* ptr, size_t elt); 43 | 44 | /*! complete function executed at the end of the task */ 45 | typedef void (*completeFunction)(const ThreadInfo& thread, void* ptr); 46 | 47 | /*! returns the number of threads used */ 48 | virtual size_t getNumThreads() const = 0; 49 | 50 | /*! starts the tasking system */ 51 | virtual void start() = 0; 52 | 53 | /*! stops the tasking system and waits for all tasks to finish */ 54 | virtual void stop() = 0; 55 | 56 | /*! adds a task */ 57 | virtual void addTask(const ThreadInfo& thread, QUEUE queue, 58 | runFunction run, void* runData, size_t elts = 1, 59 | completeFunction complete = NULL, void* completeData = NULL, 60 | const char* name = NULL) = 0; 61 | }; 62 | 63 | extern TaskScheduler* scheduler; 64 | } 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /libs/embree/include/sys/thread.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_THREAD_H__ 18 | #define __EMBREE_THREAD_H__ 19 | 20 | #include "platform.h" 21 | 22 | namespace embree 23 | { 24 | /*! type for thread */ 25 | typedef struct opaque_thread_t* thread_t; 26 | 27 | /*! signature of thread start function */ 28 | typedef void (*thread_func)(void*); 29 | 30 | /*! creates a hardware thread running on specific logical thread */ 31 | thread_t createThread(thread_func f, void* arg, size_t stack_size = 0, ssize_t threadID = -1); 32 | 33 | /*! set affinity of the calling thread */ 34 | void setAffinity(ssize_t affinity); 35 | 36 | /*! the thread calling this function gets yielded */ 37 | void yield(); 38 | 39 | /*! waits until the given thread has terminated */ 40 | void join(thread_t tid); 41 | 42 | /*! destroy handle of a thread */ 43 | void destroyThread(thread_t tid); 44 | 45 | /*! type for handle to thread local storage */ 46 | typedef struct opaque_tls_t* tls_t; 47 | 48 | /*! creates thread local storage */ 49 | tls_t createTls(); 50 | 51 | /*! set the thread local storage pointer */ 52 | void setTls(tls_t tls, void* const ptr); 53 | 54 | /*! return the thread local storage pointer */ 55 | void* getTls(tls_t tls); 56 | 57 | /*! destroys thread local storage identifier */ 58 | void destroyTls(tls_t tls); 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /libs/embree/lib/osx32/libimage.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyrildiagne/ofxEmbree/2fd9e66cbaa27ecfffa625344a8b042ded739498/libs/embree/lib/osx32/libimage.a -------------------------------------------------------------------------------- /libs/embree/lib/osx32/liblexers.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyrildiagne/ofxEmbree/2fd9e66cbaa27ecfffa625344a8b042ded739498/libs/embree/lib/osx32/liblexers.a -------------------------------------------------------------------------------- /libs/embree/lib/osx32/libloaders.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyrildiagne/ofxEmbree/2fd9e66cbaa27ecfffa625344a8b042ded739498/libs/embree/lib/osx32/libloaders.a -------------------------------------------------------------------------------- /libs/embree/lib/osx32/librenderer.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyrildiagne/ofxEmbree/2fd9e66cbaa27ecfffa625344a8b042ded739498/libs/embree/lib/osx32/librenderer.a -------------------------------------------------------------------------------- /libs/embree/lib/osx32/librtcore.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyrildiagne/ofxEmbree/2fd9e66cbaa27ecfffa625344a8b042ded739498/libs/embree/lib/osx32/librtcore.a -------------------------------------------------------------------------------- /libs/embree/lib/osx32/libsys.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyrildiagne/ofxEmbree/2fd9e66cbaa27ecfffa625344a8b042ded739498/libs/embree/lib/osx32/libsys.a -------------------------------------------------------------------------------- /ofxaddons_thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyrildiagne/ofxEmbree/2fd9e66cbaa27ecfffa625344a8b042ded739498/ofxaddons_thumbnail.png -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | Integration of Intel's Embree photo-realistic raytracing engine in openFrameworks 2 | 3 | **Warning :** This addon is still in alpha state. API and functionalities are expected to change. 4 | 5 | **Materials Example :** 6 | ![alt text](http://farm8.staticflickr.com/7405/9177154399_65f92d71a3_b.jpg "ofxEmbree-MaterialsExample") 7 | 8 | **ofMesh Example :** 9 | ![alt text](http://farm6.staticflickr.com/5531/9158283499_e34af1cee3_b.jpg "ofxEmbree-OFMeshesExample") 10 | 11 | **Crown Example :** 12 | ![alt text](http://farm6.staticflickr.com/5502/9153358074_3f63afc52d_c.jpg "ofxEmbree-CrownExample") 13 | 14 | Crown model courtesy of [Martin Lubich](http://www.loramel.net/). 15 | 16 | For more informations, check out : 17 | http://embree.github.io/ 18 | -------------------------------------------------------------------------------- /src/Camera.h: -------------------------------------------------------------------------------- 1 | // 2 | // Camera.h 3 | // ofxEmbree 4 | // 5 | // Created by kikko_fr on 6/27/13. 6 | // 7 | // 8 | 9 | #ifndef __ofxEmbree__Camera__ 10 | #define __ofxEmbree__Camera__ 11 | 12 | #include "ofMain.h" 13 | 14 | namespace ofxEmbree { 15 | 16 | class Camera : public ofCamera { 17 | 18 | public: 19 | 20 | Camera(); 21 | virtual ~Camera(); 22 | 23 | void setup(ofNode &target); 24 | void setup(ofPoint targetPt); 25 | void update(); 26 | 27 | void setTarget(ofNode &target); 28 | ofNode& getTarget(); 29 | ofPoint getTargetPos(); 30 | 31 | void setDistance(float distance); 32 | 33 | float getRadius(); 34 | void setRadius(float radius); 35 | 36 | void setLongitude(float value); 37 | float getLongitude(); 38 | 39 | void setLatitude(float value); 40 | float getLatitude(); 41 | 42 | float distance; 43 | 44 | protected: 45 | 46 | void mousePressed(ofMouseEventArgs& ev); 47 | void mouseDragged(ofMouseEventArgs& ev); 48 | void mouseReleased(ofMouseEventArgs& ev); 49 | 50 | ofNode* target; 51 | 52 | ofPoint initMouse, initLongLat; 53 | float sensitivity; 54 | float longitude, latitude; 55 | float dlong, dlat; 56 | 57 | float radius; 58 | }; 59 | } 60 | 61 | #endif /* defined(__ofxEmbreeExample__Camera__) */ 62 | -------------------------------------------------------------------------------- /src/Materials.h: -------------------------------------------------------------------------------- 1 | // 2 | // Material.h 3 | // ofxEmbree-Crown 4 | // 5 | // Created by kikko on 6/27/13. 6 | // 7 | // 8 | 9 | #ifndef __ofxEmbree__Materials__ 10 | #define __ofxEmbree__Materials__ 11 | 12 | #include "ofMain.h" 13 | #include "renderer/api/device.h" 14 | #include "math/vec2.h" 15 | #include "VHandle.h" 16 | 17 | using namespace embree; 18 | 19 | namespace ofxEmbree { 20 | 21 | class Materials { 22 | 23 | public: 24 | 25 | #define STATIC_ static const char * 26 | STATIC_ MATTE; 27 | STATIC_ PLASTIC; 28 | STATIC_ DIELECTRIC; 29 | STATIC_ GLASS; 30 | STATIC_ THIN_DIELECTRIC; 31 | STATIC_ THIN_GLASS; 32 | STATIC_ MIRROR; 33 | STATIC_ METAL; 34 | STATIC_ METALLIC_PAINT; 35 | STATIC_ MATTE_TEXTURED; 36 | STATIC_ OBJ; 37 | STATIC_ VELVET; 38 | #undef STATIC_ 39 | 40 | Materials(){} 41 | virtual ~Materials(){} 42 | 43 | void add(string name, string type); 44 | void add(string name, Device::RTMaterial mat); 45 | 46 | void setProp(string name, string pname, int p); 47 | void setProp(string name, string pname, Vec2i p); 48 | void setProp(string name, string pname, float p); 49 | void setProp(string name, string pname, ofVec2f p); 50 | void setProp(string name, string pname, ofVec3f p); 51 | void setProp(string name, string pname, ofVec4f p); 52 | void setProp(string name, string pname, ofFloatColor p); 53 | 54 | void update(string name); 55 | 56 | Device::RTMaterial get(string name); 57 | 58 | /* some default / standard materials */ 59 | 60 | Device::RTMaterial white(); 61 | Device::RTMaterial gold(); 62 | Device::RTMaterial glass(); 63 | Device::RTMaterial mirror(); 64 | // the next ones get cached based on color so it can fill up the memory quite quickly if continuously generated 65 | // however if you disable the cache you have to retain the instance yourself with a Handle<> 66 | Device::RTMaterial matte(ofFloatColor color, bool bCache=true); 67 | Device::RTMaterial mettalicPaint(ofFloatColor color, bool bCache=true); 68 | Device::RTMaterial velvet(ofFloatColor color, bool bCache=true); 69 | Device::RTMaterial plastic(ofFloatColor color, bool bCache=true); 70 | 71 | const map > & getMap() { return materialMap; } 72 | 73 | protected: 74 | 75 | map > materialMap; 76 | }; 77 | } 78 | 79 | #endif /* defined(__ofxEmbree__Materials__) */ 80 | -------------------------------------------------------------------------------- /src/Vhandle.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2012 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_VHANDLE_H__ 18 | #define __EMBREE_VHANDLE_H__ 19 | 20 | #include "sys/constants.h" 21 | #include "renderer/api/device.h" 22 | 23 | namespace embree 24 | { 25 | extern Device* g_device; 26 | 27 | //////////////////////////////////////////////////////////////////////////////// 28 | /// Automatic reference counting for Embree Handles 29 | //////////////////////////////////////////////////////////////////////////////// 30 | 31 | template 32 | class Handle 33 | { 34 | public: 35 | 36 | __forceinline Handle ( void ) : handle(NULL) {} 37 | __forceinline Handle (NullTy) : handle(NULL) {} 38 | __forceinline Handle( Type const input ) : handle(input) {} 39 | 40 | __forceinline Handle( const Handle& input ) : handle(input.handle) { 41 | if (handle) g_device->rtIncRef(handle); 42 | } 43 | 44 | __forceinline ~Handle( void ) { 45 | if (handle) g_device->rtDecRef(handle); 46 | } 47 | 48 | __forceinline Handle& operator =( const Handle& input ) 49 | { 50 | if (input.handle) g_device->rtIncRef(input.handle); 51 | if (handle) g_device->rtDecRef(handle); 52 | handle = input.handle; 53 | return *this; 54 | } 55 | 56 | __forceinline Handle& operator =( NullTy ) { 57 | if (handle) g_device->rtDecRef(handle); 58 | handle = NULL; 59 | return *this; 60 | } 61 | 62 | __forceinline operator bool() const { return handle != NULL; } 63 | __forceinline operator Type() const { return handle; } 64 | 65 | private: 66 | Type handle; 67 | }; 68 | } 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /src/ofxEmbree.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // ofxEmbree.cpp 3 | // ofxEmbreeOFMesh 4 | // 5 | // Created by kikko on 6/29/13. 6 | // 7 | // 8 | 9 | #include "ofxEmbree.h" 10 | 11 | namespace embree { 12 | 13 | Device * g_device = NULL; 14 | } -------------------------------------------------------------------------------- /src/ofxEmbree.h: -------------------------------------------------------------------------------- 1 | // 2 | // ofxEmbree.h 3 | // ofxEmbree 4 | // 5 | // Created by kikko_fr on 6/27/13. 6 | // 7 | // 8 | 9 | #ifndef ofxEmbreeExample_ofxEmbree_h 10 | #define ofxEmbreeExample_ofxEmbree_h 11 | 12 | #include "sys/platform.h" 13 | #include "sys/filename.h" 14 | #include "sys/ref.h" 15 | #include "lexers/streamfilters.h" 16 | #include "lexers/parsestream.h" 17 | #include "loaders/loaders.h" 18 | #include "math/math.h" 19 | #include "math/vec2.h" 20 | #include "math/vec3.h" 21 | #include "math/vec4.h" 22 | #include "math/col3.h" 23 | #include "math/affinespace.h" 24 | #include "image/image.h" 25 | #include "renderer/api/device.h" 26 | #include "renderer/api/handle.h" 27 | 28 | #include "Renderer.h" 29 | #include "Camera.h" 30 | #include "Material.h" 31 | #include "Vhandle.h" 32 | 33 | namespace ofxEmbree { 34 | 35 | inline embree::Vec3f toEmbree(ofPoint pt) { 36 | return embree::Vec3f(pt.x, pt.y, pt.z); 37 | } 38 | 39 | inline embree::Col3f toEmbree(ofColor col) { 40 | return embree::Col3f(col.r, col.g, col.b); 41 | } 42 | } 43 | 44 | #endif 45 | --------------------------------------------------------------------------------