├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── example-basic ├── Makefile ├── Project.xcconfig ├── addons.make ├── bin │ └── data │ │ ├── .gitkeep │ │ └── basic_form.ply ├── config.make ├── openFrameworks-Info.plist └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example-cached ├── Makefile ├── Project.xcconfig ├── addons.make ├── bin │ └── data │ │ ├── .gitkeep │ │ ├── UVtexture.png │ │ ├── box.ply │ │ ├── donut.ply │ │ ├── material.frag │ │ ├── material.vert │ │ └── pill.ply ├── config.make ├── openFrameworks-Info.plist └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example-vbo ├── Makefile ├── Project.xcconfig ├── addons.make ├── bin │ └── data │ │ ├── .gitkeep │ │ ├── UVtexture.png │ │ ├── material.frag │ │ ├── material.vert │ │ ├── monkey.ply │ │ ├── plane.ply │ │ ├── tube.ply │ │ └── wall.ply ├── config.make ├── openFrameworks-Info.plist └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── images ├── ofxGPULightmapper_demo_1.jpg ├── ofxGPULightmapper_demo_2_mix.jpg ├── ofxGPULightmapper_demo_4.jpg ├── ofxGPULightmapper_demo_4_mix.jpg ├── ofxaddons_thumbnail.png └── trianglepackerUV.jpg └── src ├── ofxGPULightmapper.cpp └── ofxGPULightmapper.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Some general ignore patterns 2 | 3 | */bin/* 4 | !*/bin/data/ 5 | # for bin folder in root 6 | /bin/* 7 | !/bin/data/ 8 | 9 | build/ 10 | obj/ 11 | *.o 12 | Debug*/ 13 | Release*/ 14 | *.mode* 15 | *.app/ 16 | *.pyc 17 | .svn/ 18 | 19 | # IDE-specific ignore patterns (e.g. user-specific files) 20 | 21 | #XCode 22 | *.pbxuser 23 | *.perspective 24 | *.perspectivev3 25 | *.mode1v3 26 | *.mode2v3 27 | #XCode 4 28 | xcuserdata 29 | *.xcworkspace 30 | 31 | #Code::Blocks 32 | *.depend 33 | *.layout 34 | *.cbTemp 35 | 36 | #Visual Studio 37 | *.sdf 38 | *.opensdf 39 | *.suo 40 | ipch/ 41 | 42 | #Eclipse 43 | .metadata 44 | local.properties 45 | .externalToolBuilders 46 | 47 | # OS-specific ignore patterns 48 | 49 | #Linux 50 | *~ 51 | # KDE 52 | .directory 53 | 54 | #OSX 55 | .DS_Store 56 | *.swp 57 | *~.nib 58 | # Thumbnails 59 | ._* 60 | 61 | #Windows 62 | # Windows image file caches 63 | Thumbs.db 64 | # Folder config file 65 | Desktop.ini 66 | 67 | #Android 68 | .csettings 69 | 70 | # Packages 71 | # it's better to unpack these files and commit the raw source 72 | # git has its own built in compression methods 73 | *.7z 74 | *.dmg 75 | *.gz 76 | *.iso 77 | *.jar 78 | *.rar 79 | *.tar 80 | *.zip 81 | 82 | # Logs and databases 83 | *.log 84 | *.sql 85 | *.sqlite 86 | *.vcxproj.filters 87 | *.xcodeproj/ 88 | *.vcproj 89 | 90 | # vscode 91 | .vscode/c_cpp_properties.json 92 | .vscode/launch.json 93 | .vscode/tasks.json 94 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libs/trianglepacker"] 2 | path = libs/trianglepacker 3 | url = git@github.com:ands/trianglepacker.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Nuño de la Serna 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GPU Lightmapper 2 | A simple OpenGL ambient light baker for OpenFrameworks. 3 | 4 | ### About 5 | 6 | **ofxGPULightmapper** combines different techniques to generate fast and smooth ambient shadows and textures. 7 | 8 | 9 | 10 | 11 | ![ofxGPULightmapper_demo_4](./images/ofxGPULightmapper_demo_4.jpg) ![ofxGPULightmapper_demo_4_mix](./images/ofxGPULightmapper_demo_4_mix.jpg) 12 | 13 | 14 | ![ofxGPULightmapper_demo_1](./images/ofxGPULightmapper_demo_1.jpg) ![ofxGPULightmapper_demo_2_mix](./images/ofxGPULightmapper_demo_2_mix.jpg) 15 | 16 | 17 | 18 | ### Usage 19 | 20 | ```c++ 21 | // instance ofxGPULightmapper 22 | ofxGPULightmapper lightmapper; 23 | 24 | ofMesh mesh; // Mesh model 25 | ofNode node; // Model world transformation 26 | ofFbo lightmap; // Lightmap texture 27 | ofLight light; // Sun light 28 | 29 | // set up lightmapper and pass scene draw function 30 | function scene = bind(&ofApp::renderScene, this); 31 | lightmapper.setup(scene, 10); // 10 light pases 32 | 33 | // setup lightmap 34 | lightmapper.allocateFBO(lightmap); 35 | 36 | // Bake scene light into the lightmap using geometry 37 | lightmapper.updateShadowMap(light, {0,0,0}, 0.5, 10, 0.01, 20); 38 | lightmapper.bake(mesh, lightmap, node, sampleCount); 39 | 40 | // Draw geometry with baked light 41 | lightmap.getTextureReference().bind(); 42 | mesh.draw(); 43 | 44 | ``` 45 | 46 | 47 | 48 | #### VBO Mesh, Triangle Packer and UV spaces 49 | 50 | The library can work both with **ofMesh** and **ofVboMesh** being the last one an advantage due the ability to create custom Vertex Buffer. 51 | 52 | For Light baking, it's important that the geometry have a proper UV map. When the assets to be baked have no UV coords or the the UV texture coords are set for a *LUT* or share texture areas, ofxGPULightmapper allows generating a set the coordinates suitable for a Light Map and handles separately the coordinates of the model's textures and the coordinates of the lightmapper. 53 | 54 | ```c++ 55 | // Mesh model [VBO] 56 | ofVboMesh mesh; 57 | // Generate lightmap coords for the model 58 | lightmapper.lightmapPack(mesh); 59 | 60 | /* 61 | * baking 62 | */ 63 | 64 | // Draw geometry with texture and baked light 65 | material.begin(); 66 | material.setUniformTexture("texture", texture, 0); 67 | material.setUniformTexture("lightmap", lightmap.getTextureReference(), 1); 68 | mesh.draw(); 69 | material.end(); 70 | ``` 71 | 72 | ![trianglepackerUV](./images/trianglepackerUV.jpg) 73 | 74 | **Triangle Packer** by @andsz https://github.com/ands/trianglepacker 75 | 76 | 77 | 78 | #### Custom Light direction, AO and light bounces 79 | 80 | For custom control of light direction, utilize the functions *begin/end* `ShadowMap` and *begin/end* `Bake`. The library will manage internally the shadow map and biased matrix. 81 | 82 | This technique is useful for calculating ambient occlusion or performing light bounces. 83 | 84 | ```c++ 85 | /* AO baking */ 86 | ofLight light; 87 | 88 | // For generic AO, light comes from everywhere 89 | glm::vec3 lightDir = glm::sphericalRand(radius); 90 | light.setPosition(lightDir); 91 | 92 | // Update ShadowMap 93 | lightmapper.beginShadowMap(light, 10, 0.01, 100); 94 | { // draw the scene 95 | renderScene(); 96 | } 97 | lightmapper.endShadowMap(); 98 | 99 | // Bake light 100 | lightmapper.beginBake(lightmap, sampleCount); 101 | { // draw geometry 102 | node.transformGL(); 103 | mesh.draw(); 104 | node.restoreTransformGL(); 105 | } 106 | lightmapper.endBake(lightmap); 107 | ``` 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /example-basic/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example-basic/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 | //ICONS - NEW IN 0072 9 | ICON_NAME_DEBUG = icon-debug.icns 10 | ICON_NAME_RELEASE = icon.icns 11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/ 12 | 13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to: 14 | //ICON_FILE_PATH = bin/data/ 15 | 16 | OTHER_CFLAGS = $(OF_CORE_CFLAGS) 17 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS) 18 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 19 | -------------------------------------------------------------------------------- /example-basic/addons.make: -------------------------------------------------------------------------------- 1 | ofxGPULightmapper 2 | -------------------------------------------------------------------------------- /example-basic/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/action-script/ofxGPULightmapper/00cc914ddd47e8892a4fb570f07c99b723ef9ecd/example-basic/bin/data/.gitkeep -------------------------------------------------------------------------------- /example-basic/bin/data/basic_form.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.83.0 - www.blender.org, source file: 'basic_form.blend' 4 | element vertex 96 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | element face 32 14 | property list uchar uint vertex_indices 15 | end_header 16 | -0.174381 0.948414 0.000000 -0.968974 -0.140986 0.203010 0.865674 0.278114 17 | -0.215241 0.587141 -0.445926 -0.968974 -0.140986 0.203010 0.995734 0.015200 18 | -0.121816 0.587141 0.000000 -0.968974 -0.140986 0.203010 0.995734 0.278114 19 | -0.113105 1.174282 -0.552342 0.000000 -0.178339 -0.983969 0.300915 0.852877 20 | 0.215241 0.587141 -0.445926 0.000000 -0.178339 -0.983969 0.563828 0.722817 21 | -0.215241 0.587141 -0.445926 0.000000 -0.178339 -0.983969 0.563828 0.852877 22 | 0.174381 0.948414 0.000000 0.968974 -0.140986 -0.203010 0.849543 0.865674 23 | 0.215241 0.587141 0.445926 0.968974 -0.140986 -0.203010 0.586629 0.995734 24 | 0.121816 0.587141 0.000000 0.968974 -0.140986 -0.203010 0.849543 0.995734 25 | 0.328597 1.319314 0.703160 0.000000 -0.331467 0.943467 0.300915 0.710020 26 | -0.215241 0.587141 0.445926 0.000000 -0.331467 0.943467 0.563828 0.579960 27 | 0.215241 0.587141 0.445926 0.000000 -0.331467 0.943467 0.563828 0.710020 28 | 0.174381 0.225868 0.000000 0.000000 -0.922229 -0.386644 0.722817 0.849543 29 | -0.131789 0.000000 0.538743 0.000000 -0.922229 -0.386644 0.852877 0.586629 30 | -0.174381 0.225868 0.000000 0.000000 -0.922229 -0.386644 0.852877 0.849543 31 | -0.174381 0.948414 0.000000 0.000000 0.884495 -0.466550 0.579960 0.849543 32 | 0.328597 1.319314 0.703160 0.000000 0.884495 -0.466550 0.710020 0.586629 33 | 0.174381 0.948414 0.000000 0.000000 0.884495 -0.466550 0.710020 0.849543 34 | -0.113105 1.174282 -0.552342 0.000000 0.925600 0.378503 0.278114 0.865674 35 | 0.174381 0.948414 0.000000 0.000000 0.925600 0.378503 0.015200 0.995734 36 | 0.113105 1.174282 -0.552342 0.000000 0.925600 0.378503 0.278114 0.995734 37 | 0.383739 0.000000 -0.775719 0.000000 -0.960127 0.279563 0.015200 0.849543 38 | -0.174381 0.225868 0.000000 0.000000 -0.960127 0.279563 0.278114 0.586629 39 | -0.383739 0.000000 -0.775719 0.000000 -0.960127 0.279563 0.278114 0.849543 40 | 0.215241 0.587141 -0.445926 0.968974 -0.140986 0.203010 0.841942 0.861408 41 | 0.174381 0.948414 0.000000 0.968974 -0.140986 0.203010 0.579029 0.991469 42 | 0.121816 0.587141 0.000000 0.968974 -0.140986 0.203010 0.579029 0.861408 43 | -0.215241 0.587141 0.445926 -0.968974 -0.140986 -0.203010 0.861408 0.270514 44 | -0.174381 0.948414 0.000000 -0.968974 -0.140986 -0.203010 0.991469 0.007600 45 | -0.121816 0.587141 0.000000 -0.968974 -0.140986 -0.203010 0.861408 0.007600 46 | -0.215241 0.587141 0.445926 -0.990288 -0.137489 0.020647 0.849543 0.278114 47 | -0.174381 0.225868 0.000000 -0.990288 -0.137489 0.020647 0.586629 0.278114 48 | -0.131789 0.000000 0.538743 -0.990288 -0.137489 0.020647 0.849543 0.015200 49 | 0.215241 0.587141 -0.445926 0.964118 0.156048 0.214768 0.563828 0.563828 50 | 0.174381 0.225868 0.000000 0.964118 0.156048 0.214768 0.300915 0.563828 51 | 0.383739 0.000000 -0.775719 0.964118 0.156048 0.214768 0.563828 0.300915 52 | 0.215241 0.587141 0.445926 0.000000 0.156143 0.987734 0.300915 0.995734 53 | -0.131789 0.000000 0.538743 0.000000 0.156143 0.987734 0.563828 0.865674 54 | 0.131789 0.000000 0.538743 0.000000 0.156143 0.987734 0.563828 0.995734 55 | 0.174381 0.225868 0.000000 0.990288 -0.137489 0.020647 0.841942 0.007600 56 | 0.215241 0.587141 0.445926 0.990288 -0.137489 0.020647 0.579029 0.007600 57 | 0.131789 0.000000 0.538743 0.990288 -0.137489 0.020647 0.579029 0.270514 58 | -0.215241 0.587141 -0.445926 0.000000 0.489726 -0.871876 0.007600 0.841942 59 | 0.383739 0.000000 -0.775719 0.000000 0.489726 -0.871876 0.270514 0.579029 60 | -0.383739 0.000000 -0.775719 0.000000 0.489726 -0.871876 0.007600 0.579029 61 | -0.174381 0.225868 0.000000 -0.964118 0.156048 0.214768 0.556228 0.293315 62 | -0.215241 0.587141 -0.445926 -0.964118 0.156048 0.214768 0.293315 0.293315 63 | -0.383739 0.000000 -0.775719 -0.964118 0.156048 0.214768 0.293315 0.556228 64 | -0.174381 0.948414 0.000000 -0.985588 0.163769 -0.042369 0.278114 0.563828 65 | -0.113105 1.174282 -0.552342 -0.985588 0.163769 -0.042369 0.278114 0.300915 66 | -0.215241 0.587141 -0.445926 -0.985588 0.163769 -0.042369 0.015200 0.563828 67 | -0.113105 1.174282 -0.552342 -0.000000 -0.178339 -0.983969 0.293315 0.991469 68 | 0.113105 1.174282 -0.552342 -0.000000 -0.178339 -0.983969 0.293315 0.861408 69 | 0.215241 0.587141 -0.445926 -0.000000 -0.178339 -0.983969 0.556228 0.861408 70 | 0.174381 0.948414 0.000000 0.981685 -0.093709 -0.165873 0.015200 0.278114 71 | 0.328597 1.319314 0.703160 0.981685 -0.093709 -0.165873 0.278114 0.015200 72 | 0.215241 0.587141 0.445926 0.981685 -0.093709 -0.165873 0.278114 0.278114 73 | 0.328597 1.319314 0.703160 0.000000 -0.331467 0.943467 0.300915 0.278114 74 | -0.328597 1.319314 0.703160 0.000000 -0.331467 0.943467 0.563828 0.278114 75 | -0.215241 0.587141 0.445926 0.000000 -0.331467 0.943467 0.563828 0.015200 76 | 0.174381 0.225868 0.000000 0.000000 -0.922229 -0.386644 0.718551 0.841942 77 | 0.131789 0.000000 0.538743 0.000000 -0.922229 -0.386644 0.718551 0.579029 78 | -0.131789 0.000000 0.538743 0.000000 -0.922229 -0.386644 0.848612 0.579029 79 | -0.174381 0.948414 0.000000 0.000000 0.884495 -0.466550 0.293315 0.270514 80 | -0.328597 1.319314 0.703160 0.000000 0.884495 -0.466550 0.293315 0.007600 81 | 0.328597 1.319314 0.703160 0.000000 0.884495 -0.466550 0.556228 0.007600 82 | -0.113105 1.174282 -0.552342 0.000000 0.925600 0.378503 0.270514 0.861408 83 | -0.174381 0.948414 0.000000 0.000000 0.925600 0.378503 0.007600 0.861408 84 | 0.174381 0.948414 0.000000 0.000000 0.925600 0.378503 0.007600 0.991469 85 | 0.383739 0.000000 -0.775719 0.000000 -0.960127 0.279563 0.575694 0.841942 86 | 0.174381 0.225868 0.000000 0.000000 -0.960127 0.279563 0.575694 0.579029 87 | -0.174381 0.225868 0.000000 0.000000 -0.960127 0.279563 0.705755 0.579029 88 | 0.215241 0.587141 -0.445926 0.985588 0.163769 -0.042369 0.270514 0.293315 89 | 0.113105 1.174282 -0.552342 0.985588 0.163769 -0.042369 0.007600 0.556228 90 | 0.174381 0.948414 0.000000 0.985588 0.163769 -0.042369 0.007600 0.293315 91 | -0.215241 0.587141 0.445926 -0.981685 -0.093709 -0.165873 0.007600 0.007600 92 | -0.328597 1.319314 0.703160 -0.981685 -0.093709 -0.165873 0.007600 0.270514 93 | -0.174381 0.948414 0.000000 -0.981685 -0.093709 -0.165873 0.270514 0.007600 94 | -0.215241 0.587141 0.445926 -0.968974 0.140986 -0.203010 0.710020 0.300915 95 | -0.121816 0.587141 0.000000 -0.968974 0.140986 -0.203010 0.710020 0.563828 96 | -0.174381 0.225868 0.000000 -0.968974 0.140986 -0.203010 0.579960 0.563828 97 | 0.215241 0.587141 -0.445926 0.968974 0.140986 0.203010 0.852877 0.300915 98 | 0.121816 0.587141 0.000000 0.968974 0.140986 0.203010 0.852877 0.563828 99 | 0.174381 0.225868 0.000000 0.968974 0.140986 0.203010 0.722817 0.563828 100 | 0.215241 0.587141 0.445926 -0.000000 0.156143 0.987734 0.293315 0.848612 101 | -0.215241 0.587141 0.445926 -0.000000 0.156143 0.987734 0.293315 0.718551 102 | -0.131789 0.000000 0.538743 -0.000000 0.156143 0.987734 0.556228 0.718551 103 | 0.174381 0.225868 0.000000 0.968974 0.140986 -0.203010 0.848612 0.293315 104 | 0.121816 0.587141 0.000000 0.968974 0.140986 -0.203010 0.718551 0.293315 105 | 0.215241 0.587141 0.445926 0.968974 0.140986 -0.203010 0.718551 0.556228 106 | -0.215241 0.587141 -0.445926 0.000000 0.489726 -0.871876 0.293315 0.705755 107 | 0.215241 0.587141 -0.445926 0.000000 0.489726 -0.871876 0.293315 0.575694 108 | 0.383739 0.000000 -0.775719 0.000000 0.489726 -0.871876 0.556228 0.575694 109 | -0.174381 0.225868 0.000000 -0.968974 0.140986 0.203010 0.705755 0.293315 110 | -0.121816 0.587141 0.000000 -0.968974 0.140986 0.203010 0.575694 0.293315 111 | -0.215241 0.587141 -0.445926 -0.968974 0.140986 0.203010 0.575694 0.556228 112 | 3 0 1 2 113 | 3 3 4 5 114 | 3 6 7 8 115 | 3 9 10 11 116 | 3 12 13 14 117 | 3 15 16 17 118 | 3 18 19 20 119 | 3 21 22 23 120 | 3 24 25 26 121 | 3 27 28 29 122 | 3 30 31 32 123 | 3 33 34 35 124 | 3 36 37 38 125 | 3 39 40 41 126 | 3 42 43 44 127 | 3 45 46 47 128 | 3 48 49 50 129 | 3 51 52 53 130 | 3 54 55 56 131 | 3 57 58 59 132 | 3 60 61 62 133 | 3 63 64 65 134 | 3 66 67 68 135 | 3 69 70 71 136 | 3 72 73 74 137 | 3 75 76 77 138 | 3 78 79 80 139 | 3 81 82 83 140 | 3 84 85 86 141 | 3 87 88 89 142 | 3 90 91 92 143 | 3 93 94 95 144 | -------------------------------------------------------------------------------- /example-basic/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example-basic/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | cc.openFrameworks.${EXECUTABLE_NAME} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | CFBundleIconFile 20 | ${ICON} 21 | NSCameraUsageDescription 22 | This app needs to access the camera 23 | NSMicrophoneUsageDescription 24 | This app needs to access the microphone 25 | 26 | 27 | -------------------------------------------------------------------------------- /example-basic/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | //ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | ofGLFWWindowSettings settings; 8 | settings.setGLVersion(3, 2); 9 | ofCreateWindow(settings); 10 | 11 | 12 | // this kicks off the running of my app 13 | // can be OF_WINDOW or OF_FULLSCREEN 14 | // pass in width and height too: 15 | ofRunApp(new ofApp()); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /example-basic/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup() { 5 | // set up lightmapper and pass scene draw function 6 | function scene = bind(&ofApp::renderScene, this); 7 | bool success = lightmapper.setup(scene); 8 | if (success) ofLog() << "Lightmapper ready"; 9 | 10 | lightmapper.setShadowBias(0.001f); 11 | lightmapper.setContactShadowFactor(0.005); 12 | 13 | // load model 14 | meshForm.load("basic_form.ply"); 15 | 16 | // setup lightmaps 17 | lightmapper.allocateFBO(fboForm); 18 | lightmapper.allocateFBO(fboFloor); 19 | 20 | // set up models position 21 | nodeForm.rotateDeg(90, {0,1,0}); 22 | primFloor.set(5,5); 23 | primFloor.rotateDeg(90, {1,0,0}); 24 | 25 | // camera 26 | cam.setDistance(3.0f); 27 | cam.setNearClip(0.01f); 28 | cam.setFarClip(100.0f); 29 | } 30 | 31 | //-------------------------------------------------------------- 32 | void ofApp::update(){ 33 | // bake 34 | ofLight light; // also works with ofNode 35 | light.setPosition(glm::vec3(4, 2.8, 5)); 36 | light.lookAt(glm::vec3(0,0,0)); 37 | 38 | // compute depth map for shadow 39 | lightmapper.updateShadowMap(light, {0,0,0}, 0.2, 6, 0.1, 11); 40 | 41 | // bake each geometry using its world transformation 42 | lightmapper.bake(meshForm, fboForm, nodeForm, sampleCount); 43 | lightmapper.bake(primFloor.getMesh(), fboFloor, primFloor, sampleCount); 44 | } 45 | 46 | //-------------------------------------------------------------- 47 | void ofApp::draw() { 48 | // forward render scene from camera 49 | ofBackground(30); 50 | ofEnableDepthTest(); 51 | cam.begin(); 52 | { 53 | renderScene(); 54 | } 55 | cam.end(); 56 | 57 | // debug textures 58 | ofDisableDepthTest(); 59 | int mapsize = 400; 60 | lightmapper.getDepthTexture().draw(ofGetWidth()-mapsize,0, mapsize, mapsize); 61 | lightmapper.getDepthTexture(1).draw(ofGetWidth()-mapsize, mapsize, mapsize, mapsize); 62 | fboForm.draw(0, 0, mapsize, mapsize); 63 | fboFloor.draw(0, mapsize, mapsize, mapsize); 64 | 65 | sampleCount++; 66 | } 67 | 68 | //-------------------------------------------------------------- 69 | void ofApp::renderScene() { 70 | // render scene 71 | nodeForm.transformGL(); 72 | fboForm.getTextureReference().bind(); 73 | meshForm.draw(); 74 | fboForm.getTextureReference().unbind(); 75 | nodeForm.restoreTransformGL(); 76 | 77 | fboFloor.getTextureReference().bind(); 78 | primFloor.draw(); 79 | fboFloor.getTextureReference().unbind(); 80 | } 81 | //-------------------------------------------------------------- 82 | void ofApp::keyPressed(int key) { 83 | sampleCount = 0; 84 | } 85 | -------------------------------------------------------------------------------- /example-basic/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxGPULightmapper.h" 5 | 6 | class ofApp : public ofBaseApp{ 7 | 8 | public: 9 | void setup(); 10 | void update(); 11 | void draw(); 12 | void renderScene(); 13 | 14 | void keyPressed(int key); 15 | 16 | ofxGPULightmapper lightmapper; 17 | int sampleCount = 0; 18 | 19 | ofEasyCam cam; 20 | 21 | // ply model [not VBO] It will share texture UV coords and lightmap coords 22 | ofMesh meshForm; 23 | ofPlanePrimitive primFloor; // just using a primitive as floor 24 | 25 | ofNode nodeForm; 26 | 27 | // lightmaps 28 | ofFbo fboForm; 29 | ofFbo fboFloor; 30 | }; 31 | -------------------------------------------------------------------------------- /example-cached/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example-cached/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 | //ICONS - NEW IN 0072 9 | ICON_NAME_DEBUG = icon-debug.icns 10 | ICON_NAME_RELEASE = icon.icns 11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/ 12 | 13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to: 14 | //ICON_FILE_PATH = bin/data/ 15 | 16 | OTHER_CFLAGS = $(OF_CORE_CFLAGS) 17 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS) 18 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 19 | -------------------------------------------------------------------------------- /example-cached/addons.make: -------------------------------------------------------------------------------- 1 | ofxGPULightmapper 2 | -------------------------------------------------------------------------------- /example-cached/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/action-script/ofxGPULightmapper/00cc914ddd47e8892a4fb570f07c99b723ef9ecd/example-cached/bin/data/.gitkeep -------------------------------------------------------------------------------- /example-cached/bin/data/UVtexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/action-script/ofxGPULightmapper/00cc914ddd47e8892a4fb570f07c99b723ef9ecd/example-cached/bin/data/UVtexture.png -------------------------------------------------------------------------------- /example-cached/bin/data/box.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.83.0 - www.blender.org, source file: 'cached.blend' 4 | element vertex 72 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | element face 48 14 | property list uchar uint vertex_indices 15 | end_header 16 | -2.966020 2.966020 2.966020 -1.000000 0.000000 0.000000 0.202118 0.201343 17 | -2.966020 -2.966020 -2.966020 -1.000000 0.000000 0.000000 0.403311 0.402536 18 | -2.966020 -2.966020 2.966020 -1.000000 0.000000 0.000000 0.202118 0.402536 19 | -2.966020 2.966020 -2.966020 0.000000 0.000000 -1.000000 0.604504 0.402536 20 | 2.966020 -2.966020 -2.966020 0.000000 0.000000 -1.000000 0.403311 0.603729 21 | -2.966020 -2.966020 -2.966020 0.000000 0.000000 -1.000000 0.403311 0.402536 22 | 2.966020 -2.732986 2.732986 -0.000000 -0.000000 -1.000000 0.626562 0.022575 23 | -2.672557 2.732986 2.732986 -0.000000 -0.000000 -1.000000 0.441176 0.213815 24 | 2.966020 2.732986 2.732986 -0.000000 -0.000000 -1.000000 0.441176 0.022575 25 | 2.966020 2.966020 2.966020 0.000000 -0.000000 1.000000 0.000925 0.603729 26 | -2.966020 -2.966020 2.966020 0.000000 -0.000000 1.000000 0.202118 0.402536 27 | 2.966020 -2.966020 2.966020 0.000000 -0.000000 1.000000 0.202118 0.603729 28 | 2.966020 -2.966020 -2.966020 0.000000 -1.000000 0.000000 0.403311 0.603729 29 | -2.966020 -2.966020 2.966020 0.000000 -1.000000 0.000000 0.202118 0.402536 30 | -2.966020 -2.966020 -2.966020 0.000000 -1.000000 0.000000 0.403311 0.402536 31 | 1.893034 2.966020 1.893034 0.000000 0.000000 -1.000000 0.179483 0.049937 32 | -1.893034 2.732986 1.893034 0.000000 0.000000 -1.000000 0.010723 0.060324 33 | -1.893034 2.966020 1.893034 0.000000 0.000000 -1.000000 0.010723 0.049937 34 | 2.966020 -2.732986 -2.732986 1.000000 0.000000 0.000000 0.894619 0.891175 35 | 2.966020 2.966020 -2.966020 1.000000 0.000000 0.000000 0.629969 0.901996 36 | 2.966020 2.732986 -2.732986 1.000000 0.000000 0.000000 0.640791 0.891175 37 | 2.966020 -2.732986 2.732986 1.000000 0.000000 -0.000000 0.894619 0.637347 38 | 2.966020 -2.966020 -2.966020 1.000000 0.000000 -0.000000 0.905440 0.901996 39 | 2.966020 2.966020 2.966020 1.000000 -0.000000 0.000000 0.629969 0.626525 40 | 2.966020 2.732986 2.732986 1.000000 -0.000000 0.000000 0.640791 0.637347 41 | 2.966020 -2.966020 2.966020 1.000000 -0.000000 -0.000000 0.905440 0.626525 42 | -2.672557 2.732986 -2.732986 1.000000 -0.000000 0.000000 0.811948 0.399201 43 | -2.672557 -2.732986 2.732986 1.000000 -0.000000 0.000000 0.626562 0.213815 44 | -2.672557 -2.732986 -2.732986 1.000000 -0.000000 0.000000 0.811948 0.213815 45 | 2.966020 -2.732986 -2.732986 0.000000 1.000000 0.000000 0.811948 0.022575 46 | -2.672557 -2.732986 2.732986 0.000000 1.000000 0.000000 0.626562 0.213815 47 | 2.966020 -2.732986 2.732986 0.000000 1.000000 0.000000 0.626562 0.022575 48 | 1.893034 2.732986 -1.893034 0.000000 -1.000000 0.000000 0.783460 0.554049 49 | -2.672557 2.732986 -2.732986 0.000000 -1.000000 0.000000 0.811948 0.399201 50 | 2.966020 2.732986 -2.732986 0.000000 -1.000000 0.000000 0.811948 0.590441 51 | 2.966020 2.732986 -2.732986 0.000000 -0.000000 1.000000 0.997334 0.022575 52 | -2.672557 -2.732986 -2.732986 0.000000 -0.000000 1.000000 0.811948 0.213815 53 | 2.966020 -2.732986 -2.732986 0.000000 -0.000000 1.000000 0.811948 0.022575 54 | -1.893034 2.966020 -1.893034 0.000000 1.000000 0.000000 0.366919 0.164951 55 | -2.966020 2.966020 2.966020 0.000000 1.000000 0.000000 0.202118 0.201343 56 | -1.893034 2.966020 1.893034 0.000000 1.000000 0.000000 0.238509 0.164951 57 | 1.893034 2.966020 -1.893034 -0.000000 1.000000 0.000000 0.366919 0.036541 58 | -2.966020 2.966020 -2.966020 -0.000000 1.000000 0.000000 0.403311 0.201343 59 | 1.893034 2.966020 1.893034 -0.000000 1.000000 -0.000000 0.238509 0.036541 60 | 2.966020 2.966020 -2.966020 -0.000000 1.000000 -0.000000 0.403311 0.000150 61 | 2.966020 2.966020 2.966020 0.000000 1.000000 -0.000000 0.202118 0.000149 62 | -1.893034 2.732986 -1.893034 0.000000 -1.000000 0.000000 0.783460 0.425639 63 | -2.672557 2.732986 2.732986 0.000000 -1.000000 0.000000 0.626562 0.399201 64 | -1.893034 2.966020 -1.893034 0.000000 0.000000 1.000000 0.010723 0.038764 65 | 1.893034 2.732986 -1.893034 0.000000 0.000000 1.000000 0.179483 0.028376 66 | 1.893034 2.966020 -1.893034 0.000000 0.000000 1.000000 0.179483 0.038764 67 | 1.893034 2.966020 -1.893034 -1.000000 -0.000000 -0.000000 0.179483 0.039156 68 | 1.893034 2.732986 1.893034 -1.000000 -0.000000 -0.000000 0.010723 0.049544 69 | 1.893034 2.966020 1.893034 -1.000000 -0.000000 -0.000000 0.010723 0.039156 70 | -1.893034 2.966020 1.893034 1.000000 0.000000 -0.000000 0.010723 0.027983 71 | -1.893034 2.732986 -1.893034 1.000000 0.000000 -0.000000 0.179483 0.017596 72 | -1.893034 2.966020 -1.893034 1.000000 0.000000 -0.000000 0.179483 0.027983 73 | 1.893034 2.732986 1.893034 -0.000000 -1.000000 -0.000000 0.655050 0.554049 74 | 2.966020 2.732986 2.732986 -0.000000 -1.000000 -0.000000 0.626562 0.590441 75 | -2.966020 2.966020 -2.966020 -1.000000 0.000000 0.000000 0.403311 0.201343 76 | 2.966020 2.966020 -2.966020 0.000000 0.000000 -1.000000 0.604504 0.603729 77 | -2.672557 -2.732986 2.732986 0.000000 0.000000 -1.000000 0.626562 0.213815 78 | -2.966020 2.966020 2.966020 0.000000 0.000000 1.000000 0.000925 0.402536 79 | 2.966020 -2.966020 2.966020 0.000000 -1.000000 0.000000 0.202118 0.603729 80 | 1.893034 2.732986 1.893034 0.000000 0.000000 -1.000000 0.179483 0.060324 81 | -2.672557 2.732986 2.732986 1.000000 -0.000000 0.000000 0.626562 0.399201 82 | -2.672557 -2.732986 -2.732986 -0.000000 1.000000 0.000000 0.811948 0.213815 83 | -2.672557 2.732986 -2.732986 0.000000 0.000000 1.000000 0.997334 0.213815 84 | -1.893034 2.732986 1.893034 0.000000 -1.000000 0.000000 0.655050 0.425639 85 | -1.893034 2.732986 -1.893034 0.000000 -0.000000 1.000000 0.010723 0.028376 86 | 1.893034 2.732986 -1.893034 -1.000000 0.000000 0.000000 0.179483 0.049544 87 | -1.893034 2.732986 1.893034 1.000000 0.000000 0.000000 0.010723 0.017596 88 | 3 0 1 2 89 | 3 3 4 5 90 | 3 6 7 8 91 | 3 9 10 11 92 | 3 12 13 14 93 | 3 15 16 17 94 | 3 18 19 20 95 | 3 21 22 18 96 | 3 20 23 24 97 | 3 24 25 21 98 | 3 26 27 28 99 | 3 29 30 31 100 | 3 32 33 34 101 | 3 35 36 37 102 | 3 38 39 40 103 | 3 41 42 38 104 | 3 43 44 41 105 | 3 40 45 43 106 | 3 46 47 33 107 | 3 48 49 50 108 | 3 51 52 53 109 | 3 54 55 56 110 | 3 57 34 58 111 | 3 47 57 58 112 | 3 0 59 1 113 | 3 3 60 4 114 | 3 6 61 7 115 | 3 9 62 10 116 | 3 12 63 13 117 | 3 15 64 16 118 | 3 18 22 19 119 | 3 21 25 22 120 | 3 20 19 23 121 | 3 24 23 25 122 | 3 26 65 27 123 | 3 29 66 30 124 | 3 32 46 33 125 | 3 35 67 36 126 | 3 38 42 39 127 | 3 41 44 42 128 | 3 43 45 44 129 | 3 40 39 45 130 | 3 46 68 47 131 | 3 48 69 49 132 | 3 51 70 52 133 | 3 54 71 55 134 | 3 57 32 34 135 | 3 47 68 57 136 | -------------------------------------------------------------------------------- /example-cached/bin/data/material.frag: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec2 v_texcoord; // pass the texCoord if needed 4 | /*in vec3 v_normal;*/ 5 | in vec3 v_worldPosition; 6 | in vec2 v_lm_texcoord; 7 | 8 | out vec4 outColor; 9 | 10 | uniform sampler2D tex0; 11 | uniform sampler2D tex1; 12 | 13 | uniform vec4 mat_specular; 14 | uniform vec4 mat_emissive; 15 | /*uniform vec4 global_ambient;*/ 16 | 17 | // these are passed in from OF programmable renderer 18 | uniform mat4 modelViewMatrix; 19 | uniform mat4 projectionMatrix; 20 | uniform mat4 textureMatrix; 21 | uniform mat4 modelViewProjectionMatrix; 22 | 23 | 24 | void main (void) { 25 | vec4 tex = texture(tex0, v_texcoord); 26 | vec4 lmTex = texture(tex1, v_lm_texcoord) ; 27 | vec4 localColor = tex * lmTex; 28 | 29 | outColor = clamp( localColor + vec4(0.04), 0.0, 1.0 ); 30 | } 31 | -------------------------------------------------------------------------------- /example-cached/bin/data/material.vert: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | out vec2 v_texcoord; // pass the texCoord if needed 4 | /*out vec3 v_normal;*/ 5 | out vec3 v_worldPosition; 6 | out vec2 v_lm_texcoord; 7 | 8 | in vec4 position; 9 | in vec4 color; 10 | /*in vec4 normal;*/ 11 | in vec2 texcoord; 12 | layout (location = 9) in vec2 t_texcoord; // packed triangle UVs 13 | 14 | // these are passed in from OF programmable renderer 15 | uniform mat4 modelViewMatrix; 16 | uniform mat4 modelMatrix; 17 | uniform mat4 viewMatrix; 18 | uniform mat4 textureMatrix; 19 | uniform mat4 projectionMatrix; 20 | uniform mat4 modelViewProjectionMatrix; 21 | uniform mat4 normalMatrix; 22 | 23 | 24 | void main (void) { 25 | v_worldPosition = (modelMatrix * position).xyz; 26 | 27 | v_texcoord = texcoord; 28 | v_lm_texcoord = t_texcoord; 29 | gl_Position = modelViewProjectionMatrix * position; 30 | } 31 | -------------------------------------------------------------------------------- /example-cached/bin/data/pill.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.83.0 - www.blender.org, source file: 'cached.blend' 4 | element vertex 480 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | element face 160 14 | property list uchar uint vertex_indices 15 | end_header 16 | 0.459228 0.927981 -0.379231 0.601492 0.005515 -0.798860 0.000156 0.862070 17 | 0.423459 -0.937572 -0.419043 0.601492 0.005515 -0.798860 0.443685 0.887696 18 | 0.224464 0.935021 -0.555945 0.601492 0.005515 -0.798860 0.000156 0.945611 19 | 0.588257 0.929153 -0.118437 0.896202 0.012930 -0.443458 0.000156 0.781834 20 | 0.534410 -0.828756 -0.278513 0.896202 0.012930 -0.443458 0.443685 0.826350 21 | 0.459228 0.927981 -0.379231 0.896202 0.012930 -0.443458 0.000156 0.862070 22 | 0.570453 0.927981 0.171144 0.998100 0.005372 0.061388 0.000156 0.703115 23 | 0.583683 -0.937572 0.119286 0.998100 0.005372 0.061388 0.443684 0.731495 24 | 0.588257 0.929153 -0.118437 0.998100 0.005372 0.061388 0.000156 0.781834 25 | 0.468660 0.941811 0.362152 0.882632 0.004566 0.470042 0.000155 0.656202 26 | 0.493604 -0.937572 0.333571 0.882632 0.004566 0.470042 0.443684 0.669014 27 | 0.570453 0.927981 0.171144 0.882632 0.004566 0.470042 0.000156 0.703115 28 | -0.119422 0.927283 0.586481 -0.006249 0.012301 0.999905 0.000155 0.453193 29 | -0.077298 -0.841930 0.608509 -0.006249 0.012301 0.999905 0.443684 0.479839 30 | 0.106745 0.930213 0.587858 -0.006249 0.012301 0.999905 0.000155 0.515673 31 | -0.585998 0.934323 0.119720 -0.924345 0.006784 0.381498 0.000155 0.265751 32 | -0.558071 -0.928715 0.220515 -0.924345 0.006784 0.381498 0.443684 0.316751 33 | -0.499299 0.928154 0.329895 -0.924345 0.006784 0.381498 0.000155 0.328232 34 | -0.588934 0.936454 -0.069541 -0.999877 0.001948 0.015533 0.000155 0.218837 35 | -0.592476 -0.922482 -0.064467 -0.999877 0.001948 0.015533 0.443685 0.231652 36 | -0.585998 0.934323 0.119720 -0.999877 0.001948 0.015533 0.000155 0.265751 37 | -0.421293 0.927283 -0.425127 -0.814371 0.005159 -0.580322 0.000156 0.109549 38 | -0.495501 -0.935021 -0.337547 -0.814371 0.005159 -0.580322 0.443685 0.147850 39 | -0.534864 0.918395 -0.265832 -0.814371 0.005159 -0.580322 0.000156 0.172030 40 | -0.295674 1.026100 -0.496766 -0.500646 0.008903 -0.865606 0.000156 0.062636 41 | -0.275560 -0.922482 -0.528442 -0.500646 0.008903 -0.865606 0.443685 0.076586 42 | -0.421293 0.927283 -0.425127 -0.500646 0.008903 -0.865606 0.000156 0.109549 43 | 0.245190 -1.382331 -0.009920 0.166050 -0.984874 0.049504 0.699258 0.630404 44 | 0.186321 -1.383445 0.165384 0.166050 -0.984874 0.049504 0.713118 0.664006 45 | 0.000000 -1.423172 -0.000000 0.166050 -0.984874 0.049504 0.665684 0.665533 46 | -0.211607 -1.395058 0.027155 -0.140406 -0.987488 -0.071784 0.640163 0.693104 47 | -0.101182 -1.395024 -0.189298 -0.140406 -0.987488 -0.071784 0.631017 0.651471 48 | 0.000000 -1.423172 -0.000000 -0.140406 -0.987488 -0.071784 0.665684 0.665533 49 | 0.186321 -1.383445 0.165384 0.085250 -0.986349 0.140886 0.713118 0.664006 50 | -0.035627 -1.395914 0.212390 0.085250 -0.986349 0.140886 0.684313 0.697278 51 | 0.000000 -1.423172 -0.000000 0.085250 -0.986349 0.140886 0.665684 0.665533 52 | -0.101182 -1.395024 -0.189298 0.006531 -0.988590 -0.150488 0.631017 0.651471 53 | 0.073979 -1.388260 -0.226133 0.006531 -0.988590 -0.150488 0.650898 0.620621 54 | 0.000000 -1.423172 -0.000000 0.006531 -0.988590 -0.150488 0.665684 0.665533 55 | 0.073979 -1.388260 -0.226133 0.159573 -0.982166 -0.099429 0.650898 0.620621 56 | 0.245190 -1.382331 -0.009920 0.159573 -0.982166 -0.099429 0.699258 0.630404 57 | 0.000000 -1.423172 -0.000000 0.159573 -0.982166 -0.099429 0.665684 0.665533 58 | -0.035627 -1.395914 0.212390 -0.117437 -0.987298 0.107008 0.684313 0.697278 59 | -0.211607 -1.395058 0.027155 -0.117437 -0.987298 0.107008 0.640163 0.693104 60 | 0.000000 -1.423172 -0.000000 -0.117437 -0.987298 0.107008 0.665684 0.665533 61 | -0.077298 -0.841930 0.608509 -0.268275 -0.252725 0.929601 0.781265 0.849751 62 | -0.258347 -1.052112 0.499119 -0.268275 -0.252725 0.929601 0.696650 0.816351 63 | -0.047464 -1.043284 0.562378 -0.268275 -0.252725 0.929601 0.752082 0.792712 64 | -0.077298 -0.841930 0.608509 0.106218 -0.207077 0.972542 0.781265 0.849751 65 | -0.047464 -1.043284 0.562378 0.106218 -0.207077 0.972542 0.752082 0.792712 66 | 0.157574 -1.052417 0.538039 0.106218 -0.207077 0.972542 0.792731 0.750615 67 | 0.534410 -0.828756 -0.278513 0.846838 -0.277477 -0.453732 0.752674 0.461611 68 | 0.579876 -0.959493 -0.113705 0.846838 -0.277477 -0.453732 0.782789 0.521313 69 | 0.423459 -0.937572 -0.419043 0.846838 -0.277477 -0.453732 0.689147 0.475741 70 | 0.275382 -1.186667 -0.403577 0.302809 -0.782018 -0.544751 0.654419 0.552087 71 | 0.240443 -1.340998 -0.201447 0.302809 -0.782018 -0.544751 0.676723 0.604107 72 | 0.073979 -1.388260 -0.226133 0.302809 -0.782018 -0.544751 0.650898 0.620621 73 | 0.423459 -0.937572 -0.419043 0.663551 -0.432366 -0.610540 0.689147 0.475741 74 | 0.468173 -1.104713 -0.252083 0.663551 -0.432366 -0.610540 0.716911 0.539654 75 | 0.275382 -1.186667 -0.403577 0.663551 -0.432366 -0.610540 0.654419 0.552087 76 | 0.415246 -1.250032 -0.122178 0.520261 -0.832040 -0.192453 0.716857 0.589261 77 | 0.245190 -1.382331 -0.009920 0.520261 -0.832040 -0.192453 0.699258 0.630404 78 | 0.240443 -1.340998 -0.201447 0.520261 -0.832040 -0.192453 0.676723 0.604107 79 | 0.579876 -0.959493 -0.113705 0.865638 -0.442312 -0.234586 0.782789 0.521313 80 | 0.534588 -1.107134 -0.002443 0.865638 -0.442312 -0.234586 0.769113 0.579247 81 | 0.468173 -1.104713 -0.252083 0.865638 -0.442312 -0.234586 0.716911 0.539654 82 | 0.415246 -1.250032 -0.122178 0.738711 -0.670934 0.064443 0.716857 0.589261 83 | 0.534588 -1.107134 -0.002443 0.738711 -0.670934 0.064443 0.769113 0.579247 84 | 0.437689 -1.194172 0.202134 0.738711 -0.670934 0.064443 0.773953 0.638562 85 | 0.437689 -1.194172 0.202134 0.573224 -0.797675 0.187427 0.773953 0.638562 86 | 0.186321 -1.383445 0.165384 0.573224 -0.797675 0.187427 0.713118 0.664006 87 | 0.245190 -1.382331 -0.009920 0.573224 -0.797675 0.187427 0.699258 0.630404 88 | 0.583683 -0.937572 0.119286 0.875489 -0.422227 0.235041 0.836527 0.579599 89 | 0.437689 -1.194172 0.202134 0.875489 -0.422227 0.235041 0.773953 0.638562 90 | 0.534588 -1.107134 -0.002443 0.875489 -0.422227 0.235041 0.769113 0.579247 91 | 0.493604 -0.937572 0.333571 0.716735 -0.435259 0.544830 0.856407 0.651519 92 | 0.313302 -1.182291 0.375259 0.716735 -0.435259 0.544830 0.778810 0.687049 93 | 0.437689 -1.194172 0.202134 0.716735 -0.435259 0.544830 0.773953 0.638562 94 | 0.321682 -0.890426 0.509432 0.503755 -0.372717 0.779303 0.861970 0.728499 95 | 0.157574 -1.052417 0.538039 0.503755 -0.372717 0.779303 0.792731 0.750615 96 | 0.313302 -1.182291 0.375259 0.503755 -0.372717 0.779303 0.778810 0.687049 97 | -0.047464 -1.043284 0.562378 -0.099457 -0.617954 0.779898 0.752082 0.792712 98 | -0.162673 -1.296075 0.347386 -0.099457 -0.617954 0.779898 0.687647 0.741841 99 | 0.076759 -1.284569 0.387036 -0.099457 -0.617954 0.779898 0.729739 0.718604 100 | -0.258347 -1.052112 0.499119 -0.422804 -0.592357 0.685821 0.696650 0.816351 101 | -0.376932 -1.178402 0.316933 -0.422804 -0.592357 0.685821 0.643939 0.779379 102 | -0.162673 -1.296075 0.347386 -0.422804 -0.592357 0.685821 0.687647 0.741841 103 | -0.376932 -1.178402 0.316933 -0.483592 -0.775475 0.405928 0.643939 0.779379 104 | -0.375050 -1.290006 0.105969 -0.483592 -0.775475 0.405928 0.619357 0.732752 105 | -0.162673 -1.296075 0.347386 -0.483592 -0.775475 0.405928 0.687647 0.741841 106 | -0.376932 -1.178402 0.316933 -0.807612 -0.430097 0.403459 0.643939 0.779379 107 | -0.558071 -0.928715 0.220515 -0.807612 -0.430097 0.403459 0.570945 0.830387 108 | -0.522645 -1.110633 0.097500 -0.807612 -0.430097 0.403459 0.579208 0.768899 109 | -0.592476 -0.922482 -0.064467 -0.908098 -0.410073 -0.084843 0.506124 0.772170 110 | -0.498862 -1.102342 -0.197118 -0.908098 -0.410073 -0.084843 0.537411 0.707149 111 | -0.522645 -1.110633 0.097500 -0.908098 -0.410073 -0.084843 0.579208 0.768899 112 | -0.495501 -0.935021 -0.337547 -0.697556 -0.452360 -0.555684 0.475508 0.686500 113 | -0.297824 -1.106958 -0.445726 -0.697556 -0.452360 -0.555684 0.536721 0.626938 114 | -0.498862 -1.102342 -0.197118 -0.697556 -0.452360 -0.555684 0.537411 0.707149 115 | -0.297824 -1.106958 -0.445726 -0.523090 -0.660728 -0.538345 0.536721 0.626938 116 | -0.164611 -1.296887 -0.342059 -0.523090 -0.660728 -0.538345 0.592617 0.633826 117 | -0.352642 -1.296357 -0.160006 -0.523090 -0.660728 -0.538345 0.589038 0.687099 118 | -0.297824 -1.106958 -0.445726 -0.265413 -0.598663 -0.755750 0.536721 0.626938 119 | 0.008131 -1.186797 -0.489931 -0.265413 -0.598663 -0.755750 0.593798 0.577133 120 | -0.164611 -1.296887 -0.342059 -0.265413 -0.598663 -0.755750 0.592617 0.633826 121 | 0.008131 -1.186797 -0.489931 -0.010786 -0.795994 -0.605208 0.593798 0.577133 122 | 0.073979 -1.388260 -0.226133 -0.010786 -0.795994 -0.605208 0.650898 0.620621 123 | -0.164611 -1.296887 -0.342059 -0.010786 -0.795994 -0.605208 0.592617 0.633826 124 | -0.352642 -1.296357 -0.160006 -0.377794 -0.905577 -0.192877 0.589038 0.687099 125 | -0.101182 -1.395024 -0.189298 -0.377794 -0.905577 -0.192877 0.631017 0.651471 126 | -0.211607 -1.395058 0.027155 -0.377794 -0.905577 -0.192877 0.640163 0.693104 127 | 0.240443 -1.340998 -0.201447 0.295607 -0.932275 -0.208517 0.676723 0.604107 128 | 0.245190 -1.382331 -0.009920 0.295607 -0.932275 -0.208517 0.699258 0.630404 129 | 0.073979 -1.388260 -0.226133 0.295607 -0.932275 -0.208517 0.650898 0.620621 130 | -0.120322 1.395990 0.180074 -0.155057 0.986864 0.045356 0.654538 0.256718 131 | 0.000000 1.423172 -0.000000 -0.155057 0.986864 0.045356 0.665684 0.221844 132 | -0.197863 1.395850 -0.081958 -0.155057 0.986864 0.045356 0.697968 0.239777 133 | 0.164653 1.377910 -0.202228 0.158819 0.983130 -0.090728 0.677955 0.170567 134 | 0.000000 1.423172 -0.000000 0.158819 0.983130 -0.090728 0.665684 0.221844 135 | 0.240720 1.385970 0.018258 0.158819 0.983130 -0.090728 0.634868 0.190128 136 | 0.077963 1.383591 0.232257 0.019139 0.986651 0.161718 0.619297 0.235347 137 | 0.000000 1.423172 -0.000000 0.019139 0.986651 0.161718 0.665684 0.221844 138 | -0.120322 1.395990 0.180074 0.019139 0.986651 0.161718 0.654538 0.256718 139 | -0.025128 1.386121 -0.237422 0.072486 0.984245 -0.161269 0.702690 0.196942 140 | 0.000000 1.423172 -0.000000 0.072486 0.984245 -0.161269 0.665684 0.221844 141 | 0.164653 1.377910 -0.202228 0.072486 0.984245 -0.161269 0.677955 0.170567 142 | 0.240720 1.385970 0.018258 0.142777 0.982513 0.119510 0.634868 0.190128 143 | 0.000000 1.423172 -0.000000 0.142777 0.982513 0.119510 0.665684 0.221844 144 | 0.077963 1.383591 0.232257 0.142777 0.982513 0.119510 0.619297 0.235347 145 | -0.197863 1.395850 -0.081958 -0.075765 0.986392 -0.145913 0.697968 0.239777 146 | 0.000000 1.423172 -0.000000 -0.075765 0.986392 -0.145913 0.665684 0.221844 147 | -0.025128 1.386121 -0.237422 -0.075765 0.986392 -0.145913 0.702690 0.196942 148 | 0.468173 1.104713 -0.252083 0.662045 0.415323 -0.623862 0.639999 0.088391 149 | 0.459228 0.927981 -0.379231 0.662045 0.415323 -0.623862 0.664981 0.030953 150 | 0.257722 1.116557 -0.467530 0.662045 0.415323 -0.623862 0.715557 0.098059 151 | 0.482034 1.184760 -0.085722 0.652510 0.660176 -0.372020 0.610649 0.120785 152 | 0.468173 1.104713 -0.252083 0.652510 0.660176 -0.372020 0.639999 0.088391 153 | 0.273704 1.255308 -0.325933 0.652510 0.660176 -0.372020 0.683143 0.131460 154 | 0.240720 1.385970 0.018258 0.565356 0.793832 -0.224062 0.634868 0.190128 155 | 0.482034 1.184760 -0.085722 0.565356 0.793832 -0.224062 0.610649 0.120785 156 | 0.164653 1.377910 -0.202228 0.565356 0.793832 -0.224062 0.677955 0.170567 157 | 0.482034 1.184760 -0.085722 0.877927 0.398760 -0.265018 0.610649 0.120785 158 | 0.588257 0.929153 -0.118437 0.877927 0.398760 -0.265018 0.575801 0.054140 159 | 0.468173 1.104713 -0.252083 0.877927 0.398760 -0.265018 0.639999 0.088391 160 | 0.266302 1.278968 0.304164 0.562975 0.789316 0.245031 0.580379 0.218845 161 | 0.468169 1.194279 0.113171 0.562975 0.789316 0.245031 0.576676 0.154515 162 | 0.240720 1.385970 0.018258 0.562975 0.789316 0.245031 0.634868 0.190128 163 | -0.003148 1.247345 0.430393 0.251244 0.665340 0.702993 0.593853 0.280799 164 | 0.106689 1.107134 0.523839 0.251244 0.665340 0.702993 0.546443 0.284486 165 | 0.266302 1.278968 0.304164 0.251244 0.665340 0.702993 0.580379 0.218845 166 | -0.194742 1.297770 0.327165 -0.073454 0.835548 0.544485 0.639794 0.296477 167 | -0.003148 1.247345 0.430393 -0.073454 0.835548 0.544485 0.593853 0.280799 168 | 0.077963 1.383591 0.232257 -0.073454 0.835548 0.544485 0.619297 0.235347 169 | -0.250823 1.112106 0.475604 -0.113198 0.450717 0.885461 0.613677 0.344536 170 | -0.119422 0.927283 0.586481 -0.113198 0.450717 0.885461 0.541556 0.370770 171 | 0.106689 1.107134 0.523839 -0.113198 0.450717 0.885461 0.546443 0.284486 172 | -0.472041 1.102008 0.248768 -0.665330 0.398810 0.631100 0.692569 0.355063 173 | -0.499299 0.928154 0.329895 -0.665330 0.398810 0.631100 0.682428 0.415115 174 | -0.250823 1.112106 0.475604 -0.665330 0.398810 0.631100 0.613677 0.344536 175 | -0.472041 1.102008 0.248768 -0.875628 0.310083 0.370303 0.692569 0.355063 176 | -0.585998 0.934323 0.119720 -0.875628 0.310083 0.370303 0.753305 0.393099 177 | -0.499299 0.928154 0.329895 -0.875628 0.310083 0.370303 0.682428 0.415115 178 | -0.405193 1.198617 -0.252889 -0.769596 0.612685 -0.179830 0.769049 0.259192 179 | -0.534523 1.106488 -0.013300 -0.769596 0.612685 -0.179830 0.753396 0.324128 180 | -0.381350 1.298002 -0.016324 -0.769596 0.612685 -0.179830 0.717482 0.282144 181 | -0.295674 1.026100 -0.496766 -0.676496 0.422874 -0.602936 0.822422 0.196430 182 | -0.421293 0.927283 -0.425127 -0.676496 0.422874 -0.602936 0.858473 0.242313 183 | -0.405193 1.198617 -0.252889 -0.676496 0.422874 -0.602936 0.769049 0.259192 184 | -0.224436 1.294213 -0.313676 -0.516767 0.572188 -0.636830 0.744296 0.214766 185 | -0.295674 1.026100 -0.496766 -0.516767 0.572188 -0.636830 0.822422 0.196430 186 | -0.405193 1.198617 -0.252889 -0.516767 0.572188 -0.636830 0.769049 0.259192 187 | -0.025128 1.386121 -0.237422 -0.125242 0.780139 -0.612942 0.702690 0.196942 188 | -0.013339 1.197914 -0.479375 -0.125242 0.780139 -0.612942 0.754268 0.155405 189 | -0.224436 1.294213 -0.313676 -0.125242 0.780139 -0.612942 0.744296 0.214766 190 | -0.224436 1.294213 -0.313676 -0.313815 0.590905 -0.743204 0.744296 0.214766 191 | -0.013339 1.197914 -0.479375 -0.313815 0.590905 -0.743204 0.754268 0.155405 192 | -0.295674 1.026100 -0.496766 -0.313815 0.590905 -0.743204 0.822422 0.196430 193 | -0.025128 1.386121 -0.237422 -0.273640 0.891976 -0.359862 0.702690 0.196942 194 | -0.224436 1.294213 -0.313676 -0.273640 0.891976 -0.359862 0.744296 0.214766 195 | -0.197863 1.395850 -0.081958 -0.273640 0.891976 -0.359862 0.697968 0.239777 196 | 0.077963 1.383591 0.232257 0.375348 0.878606 0.295237 0.619297 0.235347 197 | 0.266302 1.278968 0.304164 0.375348 0.878606 0.295237 0.580379 0.218845 198 | 0.240720 1.385970 0.018258 0.375348 0.878606 0.295237 0.634868 0.190128 199 | 0.224464 0.935021 -0.555945 0.120886 0.009025 -0.992625 0.000156 0.945611 200 | 0.001398 -0.929153 -0.600060 0.120886 0.009025 -0.992625 0.443685 0.982551 201 | -0.068206 0.927490 -0.591656 0.120886 0.009025 -0.992625 0.000157 0.999845 202 | 0.224464 0.935021 -0.555945 0.263875 -0.008750 -0.964517 0.000156 0.945611 203 | 0.266770 -0.947718 -0.527290 0.263875 -0.008750 -0.964517 0.443685 0.937362 204 | 0.001398 -0.929153 -0.600060 0.263875 -0.008750 -0.964517 0.443685 0.982551 205 | 0.224464 0.935021 -0.555945 0.568383 0.000249 -0.822764 0.000156 0.945611 206 | 0.423459 -0.937572 -0.419043 0.568383 0.000249 -0.822764 0.443685 0.887696 207 | 0.266770 -0.947718 -0.527290 0.568383 0.000249 -0.822764 0.443685 0.937362 208 | 0.459228 0.927981 -0.379231 0.785565 -0.001857 -0.618776 0.000156 0.862070 209 | 0.534410 -0.828756 -0.278513 0.785565 -0.001857 -0.618776 0.443685 0.826350 210 | 0.423459 -0.937572 -0.419043 0.785565 -0.001857 -0.618776 0.443685 0.887696 211 | 0.588257 0.929153 -0.118437 0.962965 -0.004949 -0.269582 0.000156 0.781834 212 | 0.579876 -0.959493 -0.113705 0.962965 -0.004949 -0.269582 0.443685 0.781161 213 | 0.534410 -0.828756 -0.278513 0.962965 -0.004949 -0.269582 0.443685 0.826350 214 | 0.588257 0.929153 -0.118437 0.999863 -0.004477 -0.015916 0.000156 0.781834 215 | 0.583683 -0.937572 0.119286 0.999863 -0.004477 -0.015916 0.443684 0.731495 216 | 0.579876 -0.959493 -0.113705 0.999863 -0.004477 -0.015916 0.443685 0.781161 217 | 0.570453 0.927981 0.171144 0.921853 -0.004234 0.387518 0.000156 0.703115 218 | 0.493604 -0.937572 0.333571 0.921853 -0.004234 0.387518 0.443684 0.669014 219 | 0.583683 -0.937572 0.119286 0.921853 -0.004234 0.387518 0.443684 0.731495 220 | 0.336741 0.890828 0.499826 0.241370 0.003193 0.970428 0.000155 0.584808 221 | -0.077298 -0.841930 0.608509 0.241370 0.003193 0.970428 0.443684 0.479839 222 | 0.321682 -0.890426 0.509432 0.241370 0.003193 0.970428 0.443684 0.581297 223 | -0.077298 -0.841930 0.608509 -0.452328 -0.009183 0.891804 0.443684 0.479839 224 | -0.334768 0.927283 0.496137 -0.452328 -0.009183 0.891804 0.000155 0.390712 225 | -0.396457 -0.915550 0.445871 -0.452328 -0.009183 0.891804 0.443684 0.388988 226 | -0.396457 -0.915550 0.445871 -0.812362 -0.008635 0.583089 0.443684 0.388988 227 | -0.499299 0.928154 0.329895 -0.812362 -0.008635 0.583089 0.000155 0.328232 228 | -0.558071 -0.928715 0.220515 -0.812362 -0.008635 0.583089 0.443684 0.316751 229 | -0.592476 -0.922482 -0.064467 -0.942424 -0.007078 -0.334345 0.443685 0.231652 230 | -0.534864 0.918395 -0.265832 -0.942424 -0.007078 -0.334345 0.000156 0.172030 231 | -0.495501 -0.935021 -0.337547 -0.942424 -0.007078 -0.334345 0.443685 0.147850 232 | -0.585998 0.934323 0.119720 -0.992778 -0.008407 0.119672 0.000155 0.265751 233 | -0.592476 -0.922482 -0.064467 -0.992778 -0.008407 0.119672 0.443685 0.231652 234 | -0.558071 -0.928715 0.220515 -0.992778 -0.008407 0.119672 0.443684 0.316751 235 | -0.275560 -0.922482 -0.528442 -0.250462 -0.005008 -0.968113 0.443685 0.076586 236 | -0.068206 0.927490 -0.591656 -0.250462 -0.005008 -0.968113 0.000156 0.015829 237 | 0.001398 -0.929153 -0.600060 -0.250462 -0.005008 -0.968113 0.443685 0.015370 238 | -0.421293 0.927283 -0.425127 -0.655142 -0.009422 -0.755447 0.000156 0.109549 239 | -0.275560 -0.922482 -0.528442 -0.655142 -0.009422 -0.755447 0.443685 0.076586 240 | -0.495501 -0.935021 -0.337547 -0.655142 -0.009422 -0.755447 0.443685 0.147850 241 | 0.266770 -0.947718 -0.527290 0.220053 -0.378542 -0.899046 0.624604 0.484097 242 | 0.008131 -1.186797 -0.489931 0.220053 -0.378542 -0.899046 0.593798 0.577133 243 | 0.001398 -0.929153 -0.600060 0.220053 -0.378542 -0.899046 0.547258 0.516405 244 | -0.077298 -0.841930 0.608509 -0.435380 -0.091100 0.895625 0.781265 0.849751 245 | -0.396457 -0.915550 0.445871 -0.435380 -0.091100 0.895625 0.654782 0.860834 246 | -0.258347 -1.052112 0.499119 -0.435380 -0.091100 0.895625 0.696650 0.816351 247 | 0.321682 -0.890426 0.509432 0.233077 -0.064772 0.970299 0.861970 0.728499 248 | -0.077298 -0.841930 0.608509 0.233077 -0.064772 0.970299 0.781265 0.849751 249 | 0.157574 -1.052417 0.538039 0.233077 -0.064772 0.970299 0.792731 0.750615 250 | 0.008131 -1.186797 -0.489931 0.202577 -0.753219 -0.625799 0.593798 0.577133 251 | 0.275382 -1.186667 -0.403577 0.202577 -0.753219 -0.625799 0.654419 0.552087 252 | 0.073979 -1.388260 -0.226133 0.202577 -0.753219 -0.625799 0.650898 0.620621 253 | -0.352642 -1.296357 -0.160006 -0.788495 -0.609710 -0.080806 0.589038 0.687099 254 | -0.522645 -1.110633 0.097500 -0.788495 -0.609710 -0.080806 0.579208 0.768899 255 | -0.498862 -1.102342 -0.197118 -0.788495 -0.609710 -0.080806 0.537411 0.707149 256 | 0.266770 -0.947718 -0.527290 0.544116 -0.370206 -0.752918 0.624604 0.484097 257 | 0.423459 -0.937572 -0.419043 0.544116 -0.370206 -0.752918 0.689147 0.475741 258 | 0.275382 -1.186667 -0.403577 0.544116 -0.370206 -0.752918 0.654419 0.552087 259 | 0.275382 -1.186667 -0.403577 0.563217 -0.700829 -0.437750 0.654419 0.552087 260 | 0.415246 -1.250032 -0.122178 0.563217 -0.700829 -0.437750 0.716857 0.589261 261 | 0.240443 -1.340998 -0.201447 0.563217 -0.700829 -0.437750 0.676723 0.604107 262 | 0.275382 -1.186667 -0.403577 0.626183 -0.633881 -0.453971 0.654419 0.552087 263 | 0.468173 -1.104713 -0.252083 0.626183 -0.633881 -0.453971 0.716911 0.539654 264 | 0.415246 -1.250032 -0.122178 0.626183 -0.633881 -0.453971 0.716857 0.589261 265 | 0.423459 -0.937572 -0.419043 0.860239 -0.226297 -0.456923 0.689147 0.475741 266 | 0.579876 -0.959493 -0.113705 0.860239 -0.226297 -0.456923 0.782789 0.521313 267 | 0.468173 -1.104713 -0.252083 0.860239 -0.226297 -0.456923 0.716911 0.539654 268 | 0.468173 -1.104713 -0.252083 0.832536 -0.505599 -0.226393 0.716911 0.539654 269 | 0.534588 -1.107134 -0.002443 0.832536 -0.505599 -0.226393 0.769113 0.579247 270 | 0.415246 -1.250032 -0.122178 0.832536 -0.505599 -0.226393 0.716857 0.589261 271 | 0.415246 -1.250032 -0.122178 0.646454 -0.758108 0.085843 0.716857 0.589261 272 | 0.437689 -1.194172 0.202134 0.646454 -0.758108 0.085843 0.773953 0.638562 273 | 0.245190 -1.382331 -0.009920 0.646454 -0.758108 0.085843 0.699258 0.630404 274 | 0.579876 -0.959493 -0.113705 0.958309 -0.285514 0.011204 0.782789 0.521313 275 | 0.583683 -0.937572 0.119286 0.958309 -0.285514 0.011204 0.836527 0.579599 276 | 0.534588 -1.107134 -0.002443 0.958309 -0.285514 0.011204 0.769113 0.579247 277 | 0.583683 -0.937572 0.119286 0.856109 -0.370894 0.359881 0.836527 0.579599 278 | 0.493604 -0.937572 0.333571 0.856109 -0.370894 0.359881 0.856407 0.651519 279 | 0.437689 -1.194172 0.202134 0.856109 -0.370894 0.359881 0.773953 0.638562 280 | 0.437689 -1.194172 0.202134 0.507305 -0.754561 0.416269 0.773953 0.638562 281 | 0.313302 -1.182291 0.375259 0.507305 -0.754561 0.416269 0.778810 0.687049 282 | 0.186321 -1.383445 0.165384 0.507305 -0.754561 0.416269 0.713118 0.664006 283 | 0.493604 -0.937572 0.333571 0.624961 -0.340813 0.702332 0.856407 0.651519 284 | 0.321682 -0.890426 0.509432 0.624961 -0.340813 0.702332 0.861970 0.728499 285 | 0.313302 -1.182291 0.375259 0.624961 -0.340813 0.702332 0.778810 0.687049 286 | 0.313302 -1.182291 0.375259 0.360134 -0.772710 0.522707 0.778810 0.687049 287 | 0.076759 -1.284569 0.387036 0.360134 -0.772710 0.522707 0.729739 0.718604 288 | 0.186321 -1.383445 0.165384 0.360134 -0.772710 0.522707 0.713118 0.664006 289 | 0.313302 -1.182291 0.375259 0.292924 -0.590903 0.751684 0.778810 0.687049 290 | 0.157574 -1.052417 0.538039 0.292924 -0.590903 0.751684 0.792731 0.750615 291 | 0.076759 -1.284569 0.387036 0.292924 -0.590903 0.751684 0.729739 0.718604 292 | 0.157574 -1.052417 0.538039 0.072831 -0.561497 0.824267 0.792731 0.750615 293 | -0.047464 -1.043284 0.562378 0.072831 -0.561497 0.824267 0.752082 0.792712 294 | 0.076759 -1.284569 0.387036 0.072831 -0.561497 0.824267 0.729739 0.718604 295 | -0.162673 -1.296075 0.347386 -0.212927 -0.574876 0.790051 0.687647 0.741841 296 | -0.047464 -1.043284 0.562378 -0.212927 -0.574876 0.790051 0.752082 0.792712 297 | -0.258347 -1.052112 0.499119 -0.212927 -0.574876 0.790051 0.696650 0.816351 298 | -0.258347 -1.052112 0.499119 -0.633934 -0.378049 0.674690 0.696650 0.816351 299 | -0.396457 -0.915550 0.445871 -0.633934 -0.378049 0.674690 0.654782 0.860834 300 | -0.376932 -1.178402 0.316933 -0.633934 -0.378049 0.674690 0.643939 0.779379 301 | -0.396457 -0.915550 0.445871 -0.757203 -0.332139 0.562430 0.654782 0.860834 302 | -0.558071 -0.928715 0.220515 -0.757203 -0.332139 0.562430 0.570945 0.830387 303 | -0.376932 -1.178402 0.316933 -0.757203 -0.332139 0.562430 0.643939 0.779379 304 | -0.376932 -1.178402 0.316933 -0.741623 -0.595668 0.308505 0.643939 0.779379 305 | -0.522645 -1.110633 0.097500 -0.741623 -0.595668 0.308505 0.579208 0.768899 306 | -0.375050 -1.290006 0.105969 -0.741623 -0.595668 0.308505 0.619357 0.732752 307 | -0.558071 -0.928715 0.220515 -0.958995 -0.261180 0.110065 0.570945 0.830387 308 | -0.592476 -0.922482 -0.064467 -0.958995 -0.261180 0.110065 0.506124 0.772170 309 | -0.522645 -1.110633 0.097500 -0.958995 -0.261180 0.110065 0.579208 0.768899 310 | 0.001398 -0.929153 -0.600060 -0.240714 -0.372769 -0.896158 0.547258 0.516405 311 | -0.297824 -1.106958 -0.445726 -0.240714 -0.372769 -0.896158 0.536721 0.626938 312 | -0.275560 -0.922482 -0.528442 -0.240714 -0.372769 -0.896158 0.490472 0.592322 313 | -0.498862 -1.102342 -0.197118 -0.917022 -0.245430 -0.314379 0.537411 0.707149 314 | -0.592476 -0.922482 -0.064467 -0.917022 -0.245430 -0.314379 0.506124 0.772170 315 | -0.495501 -0.935021 -0.337547 -0.917022 -0.245430 -0.314379 0.475508 0.686500 316 | -0.352642 -1.296357 -0.160006 -0.639363 -0.578702 -0.506280 0.589038 0.687099 317 | -0.498862 -1.102342 -0.197118 -0.639363 -0.578702 -0.506280 0.537411 0.707149 318 | -0.297824 -1.106958 -0.445726 -0.639363 -0.578702 -0.506280 0.536721 0.626938 319 | -0.495501 -0.935021 -0.337547 -0.625447 -0.255140 -0.737374 0.475508 0.686500 320 | -0.275560 -0.922482 -0.528442 -0.625447 -0.255140 -0.737374 0.490472 0.592322 321 | -0.297824 -1.106958 -0.445726 -0.625447 -0.255140 -0.737374 0.536721 0.626938 322 | -0.211607 -1.395058 0.027155 -0.394961 -0.858965 0.325860 0.640163 0.693104 323 | -0.162673 -1.296075 0.347386 -0.394961 -0.858965 0.325860 0.687647 0.741841 324 | -0.375050 -1.290006 0.105969 -0.394961 -0.858965 0.325860 0.619357 0.732752 325 | -0.164611 -1.296887 -0.342059 -0.075681 -0.852925 -0.516519 0.592617 0.633826 326 | 0.073979 -1.388260 -0.226133 -0.075681 -0.852925 -0.516519 0.650898 0.620621 327 | -0.101182 -1.395024 -0.189298 -0.075681 -0.852925 -0.516519 0.631017 0.651471 328 | -0.101182 -1.395024 -0.189298 -0.375602 -0.842808 -0.385485 0.631017 0.651471 329 | -0.352642 -1.296357 -0.160006 -0.375602 -0.842808 -0.385485 0.589038 0.687099 330 | -0.164611 -1.296887 -0.342059 -0.375602 -0.842808 -0.385485 0.592617 0.633826 331 | -0.375050 -1.290006 0.105969 -0.549463 -0.835102 -0.026351 0.619357 0.732752 332 | -0.352642 -1.296357 -0.160006 -0.549463 -0.835102 -0.026351 0.589038 0.687099 333 | -0.211607 -1.395058 0.027155 -0.549463 -0.835102 -0.026351 0.640163 0.693104 334 | 0.224464 0.935021 -0.555945 0.161726 0.408000 -0.898544 0.753180 0.053565 335 | -0.013339 1.197914 -0.479375 0.161726 0.408000 -0.898544 0.754268 0.155405 336 | 0.257722 1.116557 -0.467530 0.161726 0.408000 -0.898544 0.715557 0.098059 337 | 0.076759 -1.284569 0.387036 -0.053193 -0.826149 0.560935 0.729739 0.718604 338 | -0.162673 -1.296075 0.347386 -0.053193 -0.826149 0.560935 0.687647 0.741841 339 | -0.035627 -1.395914 0.212390 -0.053193 -0.826149 0.560935 0.684313 0.697278 340 | -0.035627 -1.395914 0.212390 0.147106 -0.874228 0.462694 0.684313 0.697278 341 | 0.186321 -1.383445 0.165384 0.147106 -0.874228 0.462694 0.713118 0.664006 342 | 0.076759 -1.284569 0.387036 0.147106 -0.874228 0.462694 0.729739 0.718604 343 | -0.025128 1.386121 -0.237422 0.145751 0.784320 -0.602991 0.702690 0.196942 344 | 0.164653 1.377910 -0.202228 0.145751 0.784320 -0.602991 0.677955 0.170567 345 | -0.013339 1.197914 -0.479375 0.145751 0.784320 -0.602991 0.754268 0.155405 346 | 0.588257 0.929153 -0.118437 0.927577 0.369020 0.058524 0.575801 0.054140 347 | 0.468169 1.194279 0.113171 0.927577 0.369020 0.058524 0.576676 0.154515 348 | 0.570453 0.927981 0.171144 0.927577 0.369020 0.058524 0.507312 0.115652 349 | 0.164653 1.377910 -0.202228 0.172981 0.771558 -0.612190 0.677955 0.170567 350 | 0.273704 1.255308 -0.325933 0.172981 0.771558 -0.612190 0.683143 0.131460 351 | -0.013339 1.197914 -0.479375 0.172981 0.771558 -0.612190 0.754268 0.155405 352 | -0.013339 1.197914 -0.479375 0.234692 0.680924 -0.693730 0.754268 0.155405 353 | 0.273704 1.255308 -0.325933 0.234692 0.680924 -0.693730 0.683143 0.131460 354 | 0.257722 1.116557 -0.467530 0.234692 0.680924 -0.693730 0.715557 0.098059 355 | 0.257722 1.116557 -0.467530 0.584796 0.266084 -0.766298 0.715557 0.098059 356 | 0.459228 0.927981 -0.379231 0.584796 0.266084 -0.766298 0.664981 0.030953 357 | 0.224464 0.935021 -0.555945 0.584796 0.266084 -0.766298 0.753180 0.053565 358 | 0.273704 1.255308 -0.325933 0.624568 0.521404 -0.581423 0.683143 0.131460 359 | 0.468173 1.104713 -0.252083 0.624568 0.521404 -0.581423 0.639999 0.088391 360 | 0.257722 1.116557 -0.467530 0.624568 0.521404 -0.581423 0.715557 0.098059 361 | 0.164653 1.377910 -0.202228 0.570600 0.776694 -0.266762 0.677955 0.170567 362 | 0.482034 1.184760 -0.085722 0.570600 0.776694 -0.266762 0.610649 0.120785 363 | 0.273704 1.255308 -0.325933 0.570600 0.776694 -0.266762 0.683143 0.131460 364 | 0.468173 1.104713 -0.252083 0.863875 0.264624 -0.428596 0.639999 0.088391 365 | 0.588257 0.929153 -0.118437 0.863875 0.264624 -0.428596 0.575801 0.054140 366 | 0.459228 0.927981 -0.379231 0.863875 0.264624 -0.428596 0.664981 0.030953 367 | 0.240720 1.385970 0.018258 0.642437 0.766295 0.008113 0.634868 0.190128 368 | 0.468169 1.194279 0.113171 0.642437 0.766295 0.008113 0.576676 0.154515 369 | 0.482034 1.184760 -0.085722 0.642437 0.766295 0.008113 0.610649 0.120785 370 | 0.570453 0.927981 0.171144 0.818555 0.405498 0.406865 0.507312 0.115652 371 | 0.379738 1.107134 0.376283 0.818555 0.405498 0.406865 0.531604 0.207652 372 | 0.468660 0.941811 0.362152 0.818555 0.405498 0.406865 0.483965 0.180343 373 | 0.266302 1.278968 0.304164 0.662110 0.616135 0.426600 0.580379 0.218845 374 | 0.379738 1.107134 0.376283 0.662110 0.616135 0.426600 0.531604 0.207652 375 | 0.468169 1.194279 0.113171 0.662110 0.616135 0.426600 0.576676 0.154515 376 | 0.336741 0.890828 0.499826 0.385812 0.314025 0.867489 0.460576 0.240358 377 | 0.106689 1.107134 0.523839 0.385812 0.314025 0.867489 0.546443 0.284486 378 | 0.106745 0.930213 0.587858 0.385812 0.314025 0.867489 0.494349 0.313234 379 | 0.379738 1.107134 0.376283 0.638362 0.282142 0.716164 0.531604 0.207652 380 | 0.336741 0.890828 0.499826 0.638362 0.282142 0.716164 0.460576 0.240358 381 | 0.468660 0.941811 0.362152 0.638362 0.282142 0.716164 0.483965 0.180343 382 | 0.266302 1.278968 0.304164 0.392576 0.564050 0.726452 0.580379 0.218845 383 | 0.106689 1.107134 0.523839 0.392576 0.564050 0.726452 0.546443 0.284486 384 | 0.379738 1.107134 0.376283 0.392576 0.564050 0.726452 0.531604 0.207652 385 | -0.250823 1.112106 0.475604 -0.588812 0.594344 0.547773 0.613677 0.344536 386 | -0.341071 1.284501 0.191542 -0.588812 0.594344 0.547773 0.680507 0.303408 387 | -0.472041 1.102008 0.248768 -0.588812 0.594344 0.547773 0.692569 0.355063 388 | 0.077963 1.383591 0.232257 0.194870 0.769130 0.608658 0.619297 0.235347 389 | -0.003148 1.247345 0.430393 0.194870 0.769130 0.608658 0.593853 0.280799 390 | 0.266302 1.278968 0.304164 0.194870 0.769130 0.608658 0.580379 0.218845 391 | 0.106689 1.107134 0.523839 -0.010135 0.340240 0.940284 0.546443 0.284486 392 | -0.119422 0.927283 0.586481 -0.010135 0.340240 0.940284 0.541556 0.370770 393 | 0.106745 0.930213 0.587858 -0.010135 0.340240 0.940284 0.494349 0.313234 394 | -0.003148 1.247345 0.430393 -0.109841 0.490217 0.864652 0.593853 0.280799 395 | -0.250823 1.112106 0.475604 -0.109841 0.490217 0.864652 0.613677 0.344536 396 | 0.106689 1.107134 0.523839 -0.109841 0.490217 0.864652 0.546443 0.284486 397 | -0.003148 1.247345 0.430393 -0.221433 0.648885 0.727953 0.593853 0.280799 398 | -0.194742 1.297770 0.327165 -0.221433 0.648885 0.727953 0.639794 0.296477 399 | -0.250823 1.112106 0.475604 -0.221433 0.648885 0.727953 0.613677 0.344536 400 | -0.250823 1.112106 0.475604 -0.372713 0.267982 0.888409 0.613677 0.344536 401 | -0.334768 0.927283 0.496137 -0.372713 0.267982 0.888409 0.607996 0.406935 402 | -0.119422 0.927283 0.586481 -0.372713 0.267982 0.888409 0.541556 0.370770 403 | -0.250823 1.112106 0.475604 -0.658805 0.371878 0.653975 0.613677 0.344536 404 | -0.499299 0.928154 0.329895 -0.658805 0.371878 0.653975 0.682428 0.415115 405 | -0.334768 0.927283 0.496137 -0.658805 0.371878 0.653975 0.607996 0.406935 406 | -0.341071 1.284501 0.191542 -0.767357 0.611358 0.193402 0.680507 0.303408 407 | -0.534523 1.106488 -0.013300 -0.767357 0.611358 0.193402 0.753396 0.324128 408 | -0.472041 1.102008 0.248768 -0.767357 0.611358 0.193402 0.692569 0.355063 409 | -0.534864 0.918395 -0.265832 -0.858754 0.411484 -0.305325 0.842990 0.305977 410 | -0.534523 1.106488 -0.013300 -0.858754 0.411484 -0.305325 0.753396 0.324128 411 | -0.405193 1.198617 -0.252889 -0.858754 0.411484 -0.305325 0.769049 0.259192 412 | -0.472041 1.102008 0.248768 -0.876831 0.429350 0.216391 0.692569 0.355063 413 | -0.534523 1.106488 -0.013300 -0.876831 0.429350 0.216391 0.753396 0.324128 414 | -0.585998 0.934323 0.119720 -0.876831 0.429350 0.216391 0.753305 0.393099 415 | -0.534523 1.106488 -0.013300 -0.953996 0.299269 0.018169 0.753396 0.324128 416 | -0.588934 0.936454 -0.069541 -0.953996 0.299269 0.018169 0.800467 0.351493 417 | -0.585998 0.934323 0.119720 -0.953996 0.299269 0.018169 0.753305 0.393099 418 | -0.341071 1.284501 0.191542 -0.426233 0.893615 0.140633 0.680507 0.303408 419 | -0.197863 1.395850 -0.081958 -0.426233 0.893615 0.140633 0.697968 0.239777 420 | -0.381350 1.298002 -0.016324 -0.426233 0.893615 0.140633 0.717482 0.282144 421 | -0.381350 1.298002 -0.016324 -0.521297 0.804258 -0.285339 0.717482 0.282144 422 | -0.224436 1.294213 -0.313676 -0.521297 0.804258 -0.285339 0.744296 0.214766 423 | -0.405193 1.198617 -0.252889 -0.521297 0.804258 -0.285339 0.769049 0.259192 424 | -0.405193 1.198617 -0.252889 -0.763790 0.377616 -0.523480 0.769049 0.259192 425 | -0.421293 0.927283 -0.425127 -0.763790 0.377616 -0.523480 0.858473 0.242313 426 | -0.534864 0.918395 -0.265832 -0.763790 0.377616 -0.523480 0.842990 0.305977 427 | 0.493604 -0.937572 0.333571 0.714764 -0.002271 0.699362 0.443684 0.669014 428 | 0.336741 0.890828 0.499826 0.714764 -0.002271 0.699362 0.000155 0.584808 429 | 0.321682 -0.890426 0.509432 0.714764 -0.002271 0.699362 0.443684 0.581297 430 | -0.295674 1.026100 -0.496766 -0.194309 0.409522 -0.891367 0.822422 0.196430 431 | -0.013339 1.197914 -0.479375 -0.194309 0.409522 -0.891367 0.754268 0.155405 432 | -0.068206 0.927490 -0.591656 -0.194309 0.409522 -0.891367 0.825512 0.117762 433 | -0.197863 1.395850 -0.081958 -0.528940 0.797831 -0.289290 0.697968 0.239777 434 | -0.224436 1.294213 -0.313676 -0.528940 0.797831 -0.289290 0.744296 0.214766 435 | -0.381350 1.298002 -0.016324 -0.528940 0.797831 -0.289290 0.717482 0.282144 436 | -0.120322 1.395990 0.180074 -0.406436 0.841386 0.356200 0.654538 0.256718 437 | -0.341071 1.284501 0.191542 -0.406436 0.841386 0.356200 0.680507 0.303408 438 | -0.194742 1.297770 0.327165 -0.406436 0.841386 0.356200 0.639794 0.296477 439 | -0.120322 1.395990 0.180074 -0.084704 0.847907 0.523334 0.654538 0.256718 440 | -0.194742 1.297770 0.327165 -0.084704 0.847907 0.523334 0.639794 0.296477 441 | 0.077963 1.383591 0.232257 -0.084704 0.847907 0.523334 0.619297 0.235347 442 | 0.336741 0.890828 0.499826 0.353489 -0.025815 0.935082 0.000155 0.584808 443 | 0.106745 0.930213 0.587858 0.353489 -0.025815 0.935082 0.000155 0.515673 444 | -0.077298 -0.841930 0.608509 0.353489 -0.025815 0.935082 0.443684 0.479839 445 | -0.077298 -0.841930 0.608509 -0.386862 0.002270 0.922135 0.443684 0.479839 446 | -0.119422 0.927283 0.586481 -0.386862 0.002270 0.922135 0.000155 0.453193 447 | -0.334768 0.927283 0.496137 -0.386862 0.002270 0.922135 0.000155 0.390712 448 | -0.396457 -0.915550 0.445871 -0.710735 0.004605 0.703444 0.443684 0.388988 449 | -0.334768 0.927283 0.496137 -0.710735 0.004605 0.703444 0.000155 0.390712 450 | -0.499299 0.928154 0.329895 -0.710735 0.004605 0.703444 0.000155 0.328232 451 | -0.592476 -0.922482 -0.064467 -0.964066 0.001112 -0.265661 0.443685 0.231652 452 | -0.588934 0.936454 -0.069541 -0.964066 0.001112 -0.265661 0.000155 0.218837 453 | -0.534864 0.918395 -0.265832 -0.964066 0.001112 -0.265661 0.000156 0.172030 454 | -0.275560 -0.922482 -0.528442 -0.380877 0.011098 -0.924559 0.443685 0.076586 455 | -0.295674 1.026100 -0.496766 -0.380877 0.011098 -0.924559 0.000156 0.062636 456 | -0.068206 0.927490 -0.591656 -0.380877 0.011098 -0.924559 0.000156 0.015829 457 | 0.266770 -0.947718 -0.527290 0.277216 -0.433855 -0.857276 0.624604 0.484097 458 | 0.275382 -1.186667 -0.403577 0.277216 -0.433855 -0.857276 0.654419 0.552087 459 | 0.008131 -1.186797 -0.489931 0.277216 -0.433855 -0.857276 0.593798 0.577133 460 | -0.352642 -1.296357 -0.160006 -0.770087 -0.636000 -0.049692 0.589038 0.687099 461 | -0.375050 -1.290006 0.105969 -0.770087 -0.636000 -0.049692 0.619357 0.732752 462 | -0.522645 -1.110633 0.097500 -0.770087 -0.636000 -0.049692 0.579208 0.768899 463 | 0.001398 -0.929153 -0.600060 -0.230110 -0.387574 -0.892656 0.547258 0.516405 464 | 0.008131 -1.186797 -0.489931 -0.230110 -0.387574 -0.892656 0.593798 0.577133 465 | -0.297824 -1.106958 -0.445726 -0.230110 -0.387574 -0.892656 0.536721 0.626938 466 | -0.211607 -1.395058 0.027155 -0.346311 -0.880046 0.324942 0.640163 0.693104 467 | -0.035627 -1.395914 0.212390 -0.346311 -0.880046 0.324942 0.684313 0.697278 468 | -0.162673 -1.296075 0.347386 -0.346311 -0.880046 0.324942 0.687647 0.741841 469 | 0.224464 0.935021 -0.555945 0.103620 0.363394 -0.925855 0.753180 0.053565 470 | -0.068206 0.927490 -0.591656 0.103620 0.363394 -0.925855 0.825512 0.117762 471 | -0.013339 1.197914 -0.479375 0.103620 0.363394 -0.925855 0.754268 0.155405 472 | 0.588257 0.929153 -0.118437 0.924532 0.378276 0.046349 0.575801 0.054140 473 | 0.482034 1.184760 -0.085722 0.924532 0.378276 0.046349 0.610649 0.120785 474 | 0.468169 1.194279 0.113171 0.924532 0.378276 0.046349 0.576676 0.154515 475 | 0.570453 0.927981 0.171144 0.818639 0.403422 0.408756 0.507312 0.115652 476 | 0.468169 1.194279 0.113171 0.818639 0.403422 0.408756 0.576676 0.154515 477 | 0.379738 1.107134 0.376283 0.818639 0.403422 0.408756 0.531604 0.207652 478 | 0.336741 0.890828 0.499826 0.440199 0.377741 0.814577 0.460576 0.240358 479 | 0.379738 1.107134 0.376283 0.440199 0.377741 0.814577 0.531604 0.207652 480 | 0.106689 1.107134 0.523839 0.440199 0.377741 0.814577 0.546443 0.284486 481 | -0.250823 1.112106 0.475604 -0.566682 0.612118 0.551529 0.613677 0.344536 482 | -0.194742 1.297770 0.327165 -0.566682 0.612118 0.551529 0.639794 0.296477 483 | -0.341071 1.284501 0.191542 -0.566682 0.612118 0.551529 0.680507 0.303408 484 | -0.341071 1.284501 0.191542 -0.765523 0.615238 0.188297 0.680507 0.303408 485 | -0.381350 1.298002 -0.016324 -0.765523 0.615238 0.188297 0.717482 0.282144 486 | -0.534523 1.106488 -0.013300 -0.765523 0.615238 0.188297 0.753396 0.324128 487 | -0.534864 0.918395 -0.265832 -0.884341 0.374972 -0.278095 0.842990 0.305977 488 | -0.588934 0.936454 -0.069541 -0.884341 0.374972 -0.278095 0.800467 0.351493 489 | -0.534523 1.106488 -0.013300 -0.884341 0.374972 -0.278095 0.753396 0.324128 490 | -0.341071 1.284501 0.191542 -0.441581 0.887724 0.130198 0.680507 0.303408 491 | -0.120322 1.395990 0.180074 -0.441581 0.887724 0.130198 0.654538 0.256718 492 | -0.197863 1.395850 -0.081958 -0.441581 0.887724 0.130198 0.697968 0.239777 493 | 0.493604 -0.937572 0.333571 0.722207 -0.000933 0.691676 0.443684 0.669014 494 | 0.468660 0.941811 0.362152 0.722207 -0.000933 0.691676 0.000155 0.656202 495 | 0.336741 0.890828 0.499826 0.722207 -0.000933 0.691676 0.000155 0.584808 496 | 3 0 1 2 497 | 3 3 4 5 498 | 3 6 7 8 499 | 3 9 10 11 500 | 3 12 13 14 501 | 3 15 16 17 502 | 3 18 19 20 503 | 3 21 22 23 504 | 3 24 25 26 505 | 3 27 28 29 506 | 3 30 31 32 507 | 3 33 34 35 508 | 3 36 37 38 509 | 3 39 40 41 510 | 3 42 43 44 511 | 3 45 46 47 512 | 3 48 49 50 513 | 3 51 52 53 514 | 3 54 55 56 515 | 3 57 58 59 516 | 3 60 61 62 517 | 3 63 64 65 518 | 3 66 67 68 519 | 3 69 70 71 520 | 3 72 73 74 521 | 3 75 76 77 522 | 3 78 79 80 523 | 3 81 82 83 524 | 3 84 85 86 525 | 3 87 88 89 526 | 3 90 91 92 527 | 3 93 94 95 528 | 3 96 97 98 529 | 3 99 100 101 530 | 3 102 103 104 531 | 3 105 106 107 532 | 3 108 109 110 533 | 3 111 112 113 534 | 3 114 115 116 535 | 3 117 118 119 536 | 3 120 121 122 537 | 3 123 124 125 538 | 3 126 127 128 539 | 3 129 130 131 540 | 3 132 133 134 541 | 3 135 136 137 542 | 3 138 139 140 543 | 3 141 142 143 544 | 3 144 145 146 545 | 3 147 148 149 546 | 3 150 151 152 547 | 3 153 154 155 548 | 3 156 157 158 549 | 3 159 160 161 550 | 3 162 163 164 551 | 3 165 166 167 552 | 3 168 169 170 553 | 3 171 172 173 554 | 3 174 175 176 555 | 3 177 178 179 556 | 3 180 181 182 557 | 3 183 184 185 558 | 3 186 187 188 559 | 3 189 190 191 560 | 3 192 193 194 561 | 3 195 196 197 562 | 3 198 199 200 563 | 3 201 202 203 564 | 3 204 205 206 565 | 3 207 208 209 566 | 3 210 211 212 567 | 3 213 214 215 568 | 3 216 217 218 569 | 3 219 220 221 570 | 3 222 223 224 571 | 3 225 226 227 572 | 3 228 229 230 573 | 3 231 232 233 574 | 3 234 235 236 575 | 3 237 238 239 576 | 3 240 241 242 577 | 3 243 244 245 578 | 3 246 247 248 579 | 3 249 250 251 580 | 3 252 253 254 581 | 3 255 256 257 582 | 3 258 259 260 583 | 3 261 262 263 584 | 3 264 265 266 585 | 3 267 268 269 586 | 3 270 271 272 587 | 3 273 274 275 588 | 3 276 277 278 589 | 3 279 280 281 590 | 3 282 283 284 591 | 3 285 286 287 592 | 3 288 289 290 593 | 3 291 292 293 594 | 3 294 295 296 595 | 3 297 298 299 596 | 3 300 301 302 597 | 3 303 304 305 598 | 3 306 307 308 599 | 3 309 310 311 600 | 3 312 313 314 601 | 3 315 316 317 602 | 3 318 319 320 603 | 3 321 322 323 604 | 3 324 325 326 605 | 3 327 328 329 606 | 3 330 331 332 607 | 3 333 334 335 608 | 3 336 337 338 609 | 3 339 340 341 610 | 3 342 343 344 611 | 3 345 346 347 612 | 3 348 349 350 613 | 3 351 352 353 614 | 3 354 355 356 615 | 3 357 358 359 616 | 3 360 361 362 617 | 3 363 364 365 618 | 3 366 367 368 619 | 3 369 370 371 620 | 3 372 373 374 621 | 3 375 376 377 622 | 3 378 379 380 623 | 3 381 382 383 624 | 3 384 385 386 625 | 3 387 388 389 626 | 3 390 391 392 627 | 3 393 394 395 628 | 3 396 397 398 629 | 3 399 400 401 630 | 3 402 403 404 631 | 3 405 406 407 632 | 3 408 409 410 633 | 3 411 412 413 634 | 3 414 415 416 635 | 3 417 418 419 636 | 3 420 421 422 637 | 3 423 424 425 638 | 3 426 427 428 639 | 3 429 430 431 640 | 3 432 433 434 641 | 3 435 436 437 642 | 3 438 439 440 643 | 3 441 442 443 644 | 3 444 445 446 645 | 3 447 448 449 646 | 3 450 451 452 647 | 3 453 454 455 648 | 3 456 457 458 649 | 3 459 460 461 650 | 3 462 463 464 651 | 3 465 466 467 652 | 3 468 469 470 653 | 3 471 472 473 654 | 3 474 475 476 655 | 3 477 478 479 656 | -------------------------------------------------------------------------------- /example-cached/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example-cached/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | cc.openFrameworks.${EXECUTABLE_NAME} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | CFBundleIconFile 20 | ${ICON} 21 | NSCameraUsageDescription 22 | This app needs to access the camera 23 | NSMicrophoneUsageDescription 24 | This app needs to access the microphone 25 | 26 | 27 | -------------------------------------------------------------------------------- /example-cached/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | //ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | ofGLFWWindowSettings settings; 8 | settings.setGLVersion(3, 2); 9 | ofCreateWindow(settings); 10 | 11 | 12 | // this kicks off the running of my app 13 | // can be OF_WINDOW or OF_FULLSCREEN 14 | // pass in width and height too: 15 | ofRunApp(new ofApp()); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /example-cached/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup() { 5 | // set up lightmapper and pass scene draw function 6 | function scene = bind(&ofApp::renderScene, this); 7 | bool success = lightmapper.setup(scene, 12); 8 | if (success) ofLog() << "Lightmapper ready"; 9 | 10 | lightmapper.setShadowBias(0.0015f); 11 | lightmapper.setContactShadowFactor(0.005); 12 | 13 | // load models 14 | meshBox.load("box.ply"); 15 | meshDonut.load("donut.ply"); 16 | meshPill.load("pill.ply"); 17 | 18 | // generate lightmap coords for the models 19 | lightmapper.lightmapPack(meshBox, {500,500}); 20 | lightmapper.lightmapPack(meshPill); 21 | lightmapper.lightmapPack(meshDonut); 22 | 23 | // prepare random scene 24 | resetScene(); 25 | 26 | // material 27 | ofDisableArbTex(); 28 | material.load("material"); 29 | texture.load("UVtexture.png"); 30 | 31 | // camera 32 | cam.setDistance(10.0f); 33 | cam.setNearClip(0.01f); 34 | cam.setFarClip(100.0f); 35 | } 36 | 37 | //-------------------------------------------------------------- 38 | void ofApp::update() { 39 | // bake 40 | ofLight light; // also works with ofNode 41 | light.setPosition(glm::vec3(3, 10, -1.4)); 42 | light.lookAt(glm::vec3(0,0,0)); 43 | 44 | if (currentTarget < models.size()) { 45 | auto& model = *models[currentTarget]; 46 | auto& node = transformations.at(currentTarget); 47 | auto& fbo = lightmaps.at(currentTarget); 48 | 49 | // compute depth map for shadow [sharing cache] 50 | lightmapper.updateCachedShadowMap(light, sampleCount, node.getGlobalPosition(), 0.05, 12, 0.01, 20); 51 | 52 | // bake target model 53 | lightmapper.bake(model, fbo, node, sampleCount); 54 | 55 | sampleCount++; 56 | 57 | if (sampleCount >= maxSamples) { 58 | sampleCount = 0; 59 | currentTarget += 1; 60 | } 61 | } 62 | } 63 | 64 | //-------------------------------------------------------------- 65 | void ofApp::draw() { 66 | // forward render scene from camera 67 | ofBackground(30); 68 | ofEnableDepthTest(); 69 | cam.begin(); 70 | { 71 | renderScene(); 72 | } 73 | cam.end(); 74 | 75 | // debug textures 76 | ofDisableDepthTest(); 77 | int mapsize = 300; 78 | lightmapper.getDepthTexture().draw(ofGetWidth()-mapsize,0, mapsize, mapsize); 79 | lightmapper.getDepthTexture(1).draw(ofGetWidth()-mapsize, mapsize, mapsize, mapsize); 80 | } 81 | 82 | //-------------------------------------------------------------- 83 | void ofApp::renderScene() { 84 | // render scene 85 | 86 | material.begin(); 87 | material.setUniformTexture("tex0", texture, 0); 88 | 89 | for (size_t i; i < models.size(); i++) { 90 | auto& model = *models[i]; 91 | auto& node = transformations.at(i); 92 | auto& fbo = lightmaps.at(i); 93 | 94 | node.transformGL(); 95 | material.setUniformTexture("tex1", fbo.getTextureReference(), 1); 96 | model.draw(); 97 | node.restoreTransformGL(); 98 | } 99 | 100 | material.end(); 101 | } 102 | //-------------------------------------------------------------- 103 | void ofApp::keyPressed(int key) { 104 | resetScene(); 105 | } 106 | //-------------------------------------------------------------- 107 | void ofApp::resetScene() { 108 | sampleCount = 0; 109 | currentTarget = 0; 110 | 111 | models.clear(); 112 | transformations.clear(); 113 | lightmaps.clear(); 114 | 115 | size_t nDonuts = (int)ofRandom(4,8); 116 | size_t nPills = (int)ofRandom(3,10); 117 | //nDonuts = 1; 118 | //nPills = 1; 119 | 120 | models.resize(1+nDonuts+nPills); 121 | transformations.resize(1+nDonuts+nPills); 122 | lightmaps.resize(1+nDonuts+nPills); 123 | 124 | models[0] = &meshBox; 125 | ofNode nodeBox; 126 | nodeBox.panDeg(-90); 127 | transformations[0] = nodeBox; 128 | ofFbo fboBox; 129 | lightmaps[0] = fboBox; 130 | lightmapper.allocateFBO(lightmaps.at(0)); 131 | 132 | // random place models on the box 133 | int bxs = 2.3; 134 | for (size_t i = 0; i < nDonuts; i++) { 135 | models[i+1] = &meshDonut; 136 | ofNode node; 137 | node.setScale(ofRandom(0.2, 0.9)); 138 | node.setPosition({ofRandom(-bxs,bxs),ofRandom(-bxs,bxs),ofRandom(-bxs,bxs)}); 139 | auto q = ofQuaternion(ofRandom(360), {1,0,0}, ofRandom(360), {0,1,0}, ofRandom(360), {0,0,1}); 140 | node.rotate(q); 141 | transformations[i+1] = node; 142 | ofFbo fbo; 143 | lightmapper.allocateFBO(fbo); 144 | lightmaps[i+1] = fbo; 145 | } 146 | 147 | for (size_t i = 0; i < nPills; i++) { 148 | models[i+1+nDonuts] = &meshPill; 149 | ofNode node; 150 | node.setScale(ofRandom(0.2, 0.9)); 151 | node.setPosition({ofRandom(-bxs,bxs),ofRandom(-bxs,bxs),ofRandom(-bxs,bxs)}); 152 | auto q = ofQuaternion(ofRandom(360), {1,0,0}, ofRandom(360), {0,1,0}, ofRandom(360), {0,0,1}); 153 | node.rotate(q); 154 | transformations[i+1+nDonuts] = node; 155 | ofFbo fbo; 156 | lightmapper.allocateFBO(fbo); 157 | lightmaps[i+1+nDonuts] = fbo; 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /example-cached/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxGPULightmapper.h" 5 | 6 | class ofApp : public ofBaseApp{ 7 | 8 | public: 9 | void setup(); 10 | void update(); 11 | void draw(); 12 | void renderScene(); 13 | 14 | void keyPressed(int key); 15 | void resetScene(); 16 | 17 | ofxGPULightmapper lightmapper; 18 | int sampleCount = 0; 19 | 20 | ofEasyCam cam; 21 | 22 | // models 23 | ofVboMesh meshBox, meshDonut, meshPill; 24 | 25 | std::vector models; 26 | 27 | std::vector transformations; 28 | 29 | std::vector lightmaps; 30 | 31 | // material 32 | ofShader material; 33 | ofImage texture; 34 | 35 | unsigned int currentTarget = 0, maxSamples = 30*1.5; 36 | }; 37 | -------------------------------------------------------------------------------- /example-vbo/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example-vbo/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 | //ICONS - NEW IN 0072 9 | ICON_NAME_DEBUG = icon-debug.icns 10 | ICON_NAME_RELEASE = icon.icns 11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/ 12 | 13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to: 14 | //ICON_FILE_PATH = bin/data/ 15 | 16 | OTHER_CFLAGS = $(OF_CORE_CFLAGS) 17 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS) 18 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 19 | -------------------------------------------------------------------------------- /example-vbo/addons.make: -------------------------------------------------------------------------------- 1 | ofxGPULightmapper 2 | -------------------------------------------------------------------------------- /example-vbo/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/action-script/ofxGPULightmapper/00cc914ddd47e8892a4fb570f07c99b723ef9ecd/example-vbo/bin/data/.gitkeep -------------------------------------------------------------------------------- /example-vbo/bin/data/UVtexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/action-script/ofxGPULightmapper/00cc914ddd47e8892a4fb570f07c99b723ef9ecd/example-vbo/bin/data/UVtexture.png -------------------------------------------------------------------------------- /example-vbo/bin/data/material.frag: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec2 v_texcoord; // pass the texCoord if needed 4 | /*in vec3 v_normal;*/ 5 | in vec3 v_worldPosition; 6 | in vec2 v_lm_texcoord; 7 | 8 | out vec4 outColor; 9 | 10 | uniform sampler2D tex0; 11 | uniform sampler2D tex1; 12 | 13 | uniform vec4 mat_specular; 14 | uniform vec4 mat_emissive; 15 | /*uniform vec4 global_ambient;*/ 16 | 17 | // these are passed in from OF programmable renderer 18 | uniform mat4 modelViewMatrix; 19 | uniform mat4 projectionMatrix; 20 | uniform mat4 textureMatrix; 21 | uniform mat4 modelViewProjectionMatrix; 22 | 23 | 24 | void main (void) { 25 | vec4 tex = texture(tex0, v_texcoord); 26 | vec4 lmTex = texture(tex1, v_lm_texcoord); 27 | vec4 localColor = tex * lmTex; 28 | 29 | outColor = clamp( localColor, 0.0, 1.0 ); 30 | } 31 | -------------------------------------------------------------------------------- /example-vbo/bin/data/material.vert: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | out vec2 v_texcoord; // pass the texCoord if needed 4 | /*out vec3 v_normal;*/ 5 | out vec3 v_worldPosition; 6 | out vec2 v_lm_texcoord; 7 | 8 | in vec4 position; 9 | in vec4 color; 10 | /*in vec4 normal;*/ 11 | in vec2 texcoord; 12 | layout (location = 9) in vec2 t_texcoord; // packed triangle UVs 13 | 14 | // these are passed in from OF programmable renderer 15 | uniform mat4 modelViewMatrix; 16 | uniform mat4 modelMatrix; 17 | uniform mat4 viewMatrix; 18 | uniform mat4 textureMatrix; 19 | uniform mat4 projectionMatrix; 20 | uniform mat4 modelViewProjectionMatrix; 21 | uniform mat4 normalMatrix; 22 | 23 | 24 | void main (void) { 25 | v_worldPosition = (modelMatrix * position).xyz; 26 | 27 | v_texcoord = texcoord; 28 | v_lm_texcoord = t_texcoord; 29 | gl_Position = modelViewProjectionMatrix * position; 30 | } 31 | -------------------------------------------------------------------------------- /example-vbo/bin/data/plane.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.82 (sub 7) - www.blender.org, source file: 'monkey_test.blend' 4 | element vertex 4 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | element face 2 14 | property list uchar uint vertex_indices 15 | end_header 16 | 4.000000 0.000000 4.000000 -0.000000 1.000000 0.000000 1.000000 0.000000 17 | -4.000000 0.000000 -4.000000 -0.000000 1.000000 0.000000 0.000000 1.000000 18 | -4.000000 0.000000 4.000000 -0.000000 1.000000 0.000000 0.000000 0.000000 19 | 4.000000 0.000000 -4.000000 0.000000 1.000000 0.000000 1.000000 1.000000 20 | 3 0 1 2 21 | 3 0 3 1 22 | -------------------------------------------------------------------------------- /example-vbo/bin/data/tube.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.82 (sub 7) - www.blender.org, source file: 'monkey_test.blend' 4 | element vertex 168 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | element face 96 14 | property list uchar uint vertex_indices 15 | end_header 16 | 0.000000 2.000000 -0.999999 0.258819 0.000000 -0.965926 0.005828 0.994150 17 | 0.500000 0.000000 -0.866025 0.258819 0.000000 -0.965926 0.161741 0.838237 18 | 0.000000 0.000000 -0.999999 0.258819 0.000000 -0.965926 0.005828 0.838237 19 | 0.500000 2.000000 -0.866025 0.707107 0.000000 -0.707107 0.179490 0.343354 20 | 0.866026 0.000000 -0.499999 0.707107 0.000000 -0.707107 0.335403 0.499267 21 | 0.500000 0.000000 -0.866025 0.707107 0.000000 -0.707107 0.335403 0.343354 22 | 0.866026 2.000000 -0.499999 0.965926 0.000000 -0.258819 0.005828 0.829359 23 | 1.000000 0.000000 0.000001 0.965926 0.000000 -0.258819 0.161741 0.673445 24 | 0.866026 0.000000 -0.499999 0.965926 0.000000 -0.258819 0.005828 0.673446 25 | 1.000000 2.000000 0.000001 0.965926 -0.000000 0.258819 0.344282 0.343354 26 | 0.866026 0.000000 0.500001 0.965926 -0.000000 0.258819 0.500195 0.499267 27 | 1.000000 0.000000 0.000001 0.965926 -0.000000 0.258819 0.500195 0.343354 28 | 0.866026 2.000000 0.500001 0.707107 0.000000 0.707107 0.179490 0.508145 29 | 0.500000 0.000000 0.866026 0.707107 0.000000 0.707107 0.335403 0.664059 30 | 0.866026 0.000000 0.500001 0.707107 0.000000 0.707107 0.335403 0.508145 31 | 0.500000 2.000000 0.866026 0.258819 0.000000 0.965926 0.005828 0.664567 32 | 0.000000 0.000000 1.000001 0.258819 0.000000 0.965926 0.161741 0.508654 33 | 0.500000 0.000000 0.866026 0.258819 0.000000 0.965926 0.005828 0.508654 34 | 0.000000 2.000000 1.000001 -0.258819 -0.000000 0.965926 0.344282 0.508145 35 | -0.500000 0.000000 0.866026 -0.258819 -0.000000 0.965926 0.500195 0.664059 36 | 0.000000 0.000000 1.000001 -0.258819 -0.000000 0.965926 0.500195 0.508145 37 | -0.500000 2.000000 0.866026 -0.707107 -0.000000 0.707107 0.509073 0.343354 38 | -0.866025 0.000000 0.500001 -0.707107 -0.000000 0.707107 0.664987 0.499267 39 | -0.500000 0.000000 0.866026 -0.707107 -0.000000 0.707107 0.664987 0.343354 40 | -0.866025 2.000000 0.500001 -0.965926 -0.000000 0.258820 0.509073 0.508145 41 | -1.000000 0.000000 0.000001 -0.965926 -0.000000 0.258820 0.664987 0.664059 42 | -0.866025 0.000000 0.500001 -0.965926 -0.000000 0.258820 0.664987 0.508145 43 | -1.000000 2.000000 0.000001 -0.965926 -0.000000 -0.258819 0.179490 0.672937 44 | -0.866026 0.000000 -0.499999 -0.965926 -0.000000 -0.258819 0.335403 0.828850 45 | -1.000000 0.000000 0.000001 -0.965926 -0.000000 -0.258819 0.335403 0.672937 46 | 0.381899 2.000000 0.661469 -0.258819 0.000000 -0.965926 0.005828 0.499776 47 | 0.000000 0.000000 0.763799 -0.258819 0.000000 -0.965926 0.161741 0.343862 48 | 0.000000 2.000000 0.763799 -0.258819 0.000000 -0.965926 0.005828 0.343862 49 | -0.866026 2.000000 -0.499999 -0.707107 0.000000 -0.707107 0.344282 0.672937 50 | -0.500000 0.000000 -0.866024 -0.707107 0.000000 -0.707107 0.500195 0.828850 51 | -0.866026 0.000000 -0.499999 -0.707107 0.000000 -0.707107 0.500195 0.672937 52 | -0.500000 0.000000 -0.866024 -0.258820 0.000000 -0.965926 0.829778 0.343354 53 | 0.000000 2.000000 -0.999999 -0.258820 0.000000 -0.965926 0.673865 0.499267 54 | 0.000000 0.000000 -0.999999 -0.258820 0.000000 -0.965926 0.829778 0.499267 55 | 0.500000 0.000000 0.866026 -0.000000 -1.000000 0.000000 0.528857 0.082163 56 | 0.661469 0.000000 0.381900 -0.000000 -1.000000 0.000000 0.311366 0.140589 57 | 0.866026 0.000000 0.500001 -0.000000 -1.000000 0.000000 0.361140 0.082163 58 | 0.000000 2.000000 -0.763797 0.000000 1.000000 -0.000000 0.834292 0.287176 59 | 0.500000 2.000000 -0.866025 0.000000 1.000000 -0.000000 0.631396 0.226827 60 | 0.000000 2.000000 -0.999999 0.000000 1.000000 -0.000000 0.812907 0.226914 61 | 0.661469 2.000000 -0.381898 -0.000000 1.000000 0.000000 0.557017 0.287043 62 | 0.381899 2.000000 -0.661468 -0.000000 1.000000 0.000000 0.695654 0.287109 63 | 0.661469 2.000000 -0.381898 0.000000 1.000000 -0.000000 0.556588 0.161423 64 | 1.000000 2.000000 0.000001 0.000000 1.000000 -0.000000 0.630982 0.221628 65 | 0.866026 2.000000 -0.499999 0.000000 1.000000 -0.000000 0.449471 0.221742 66 | 0.661469 2.000000 0.381900 0.000000 1.000000 -0.000000 0.833862 0.161250 67 | 0.763798 2.000000 0.000001 0.000000 1.000000 -0.000000 0.695225 0.161336 68 | 0.381899 2.000000 0.661469 0.000000 1.000000 -0.000000 0.972500 0.161163 69 | 0.866026 2.000000 0.500001 0.000000 1.000000 -0.000000 0.812492 0.221514 70 | 0.000000 2.000000 0.763799 0.000000 1.000000 -0.000000 0.165295 0.226673 71 | 0.500000 2.000000 0.866026 0.000000 1.000000 -0.000000 0.005186 0.286873 72 | 0.381899 2.000000 0.661469 0.000000 1.000000 -0.000000 0.026657 0.226628 73 | -0.381899 2.000000 0.661469 0.000000 1.000000 -0.000000 0.303932 0.226718 74 | 0.000000 2.000000 1.000001 0.000000 1.000000 -0.000000 0.186697 0.286931 75 | -0.661468 2.000000 0.381900 0.000000 1.000000 0.000000 0.442570 0.226763 76 | -0.500000 2.000000 0.866026 0.000000 1.000000 0.000000 0.368208 0.286990 77 | -0.763798 2.000000 0.000001 0.000000 1.000000 0.000000 0.305079 0.221365 78 | -0.866025 2.000000 0.500001 0.000000 1.000000 0.000000 0.551024 0.161402 79 | -0.661468 2.000000 0.381900 0.000000 1.000000 0.000000 0.443716 0.221528 80 | -0.866026 2.000000 -0.499999 -0.000000 1.000000 0.000000 0.188002 0.160976 81 | -1.000000 2.000000 0.000001 -0.000000 1.000000 0.000000 0.369513 0.161189 82 | -0.381899 2.000000 -0.661468 0.000000 1.000000 0.000000 0.027804 0.221040 83 | -0.661469 2.000000 -0.381898 0.000000 1.000000 0.000000 0.166441 0.221202 84 | -0.381899 2.000000 -0.661468 -0.000000 1.000000 -0.000000 0.972930 0.287243 85 | -0.500000 2.000000 -0.866024 -0.000000 1.000000 -0.000000 0.994418 0.227002 86 | 0.763798 0.000000 0.000001 0.000000 -1.000000 0.000000 0.183264 0.140589 87 | 1.000000 0.000000 0.000001 0.000000 -1.000000 0.000000 0.193422 0.082163 88 | 0.661469 2.000000 -0.381898 -0.965926 -0.000000 0.258819 0.509073 0.672937 89 | 0.763798 0.000000 0.000001 -0.965926 -0.000000 0.258819 0.664987 0.828850 90 | 0.763798 2.000000 0.000001 -0.965926 -0.000000 0.258819 0.664987 0.672937 91 | -0.763798 2.000000 0.000001 0.965926 0.000000 0.258819 0.673865 0.508145 92 | -0.661469 0.000000 -0.381898 0.965926 0.000000 0.258819 0.829778 0.664059 93 | -0.661469 2.000000 -0.381898 0.965926 0.000000 0.258819 0.829778 0.508145 94 | 0.000000 2.000000 0.763799 0.258819 0.000000 -0.965926 0.673865 0.672937 95 | -0.381899 0.000000 0.661469 0.258819 0.000000 -0.965926 0.829778 0.828850 96 | -0.381899 2.000000 0.661469 0.258819 0.000000 -0.965926 0.829778 0.672937 97 | 0.763798 2.000000 0.000001 -0.965926 0.000000 -0.258819 0.179490 0.837728 98 | 0.661469 0.000000 0.381900 -0.965926 0.000000 -0.258819 0.335403 0.993642 99 | 0.661469 2.000000 0.381900 -0.965926 0.000000 -0.258819 0.335403 0.837728 100 | -0.661469 2.000000 -0.381898 0.707107 -0.000000 0.707106 0.839262 0.837937 101 | -0.381899 0.000000 -0.661468 0.707107 -0.000000 0.707106 0.995175 0.993850 102 | -0.381899 2.000000 -0.661468 0.707107 -0.000000 0.707106 0.995175 0.837937 103 | 0.000000 2.000000 -0.763797 -0.258819 0.000000 0.965926 0.344282 0.837728 104 | 0.381899 0.000000 -0.661468 -0.258819 0.000000 0.965926 0.500195 0.993642 105 | 0.381899 2.000000 -0.661468 -0.258819 0.000000 0.965926 0.500195 0.837728 106 | -0.381899 2.000000 0.661469 0.707106 -0.000000 -0.707107 0.838656 0.343354 107 | -0.661468 0.000000 0.381900 0.707106 -0.000000 -0.707107 0.994569 0.499267 108 | -0.661468 2.000000 0.381900 0.707106 -0.000000 -0.707107 0.994569 0.343354 109 | 0.661469 2.000000 0.381900 -0.707107 0.000000 -0.707107 0.509073 0.837728 110 | 0.381899 0.000000 0.661469 -0.707107 0.000000 -0.707107 0.664987 0.993642 111 | 0.381899 2.000000 0.661469 -0.707107 0.000000 -0.707107 0.664987 0.837728 112 | -0.381899 2.000000 -0.661468 0.258819 -0.000000 0.965926 0.838656 0.508145 113 | 0.000000 0.000000 -0.763798 0.258819 -0.000000 0.965926 0.994569 0.664059 114 | 0.000000 2.000000 -0.763797 0.258819 -0.000000 0.965926 0.994569 0.508145 115 | 0.381899 2.000000 -0.661468 -0.707107 0.000000 0.707107 0.673865 0.837728 116 | 0.661469 0.000000 -0.381898 -0.707107 0.000000 0.707107 0.829778 0.993642 117 | 0.661469 2.000000 -0.381898 -0.707107 0.000000 0.707107 0.829778 0.837728 118 | -0.661468 2.000000 0.381900 0.965926 0.000000 -0.258819 0.838656 0.672937 119 | -0.763798 0.000000 0.000001 0.965926 0.000000 -0.258819 0.994569 0.828850 120 | -0.763798 2.000000 0.000001 0.965926 0.000000 -0.258819 0.994569 0.672937 121 | 0.866026 0.000000 -0.499999 0.000000 -1.000000 0.000000 0.025705 0.082163 122 | 0.661469 0.000000 -0.381898 0.000000 -1.000000 0.000000 0.055162 0.140589 123 | 0.866026 0.000000 -0.499999 0.000000 -1.000000 0.000000 0.045541 0.069720 124 | 0.381899 0.000000 -0.661468 0.000000 -1.000000 0.000000 0.205545 0.011842 125 | 0.500000 0.000000 -0.866025 0.000000 -1.000000 0.000000 0.156773 0.069720 126 | 0.000000 0.000000 -0.763798 0.000000 -1.000000 0.000000 0.333666 0.011842 127 | 0.000000 0.000000 -0.999999 0.000000 -1.000000 0.000000 0.324514 0.069720 128 | -0.500000 0.000000 -0.866024 0.000000 -1.000000 -0.000000 0.492256 0.069720 129 | -0.381899 0.000000 -0.661468 0.000000 -1.000000 -0.000000 0.461787 0.011842 130 | -0.866026 0.000000 -0.499999 -0.000000 -1.000000 -0.000000 0.738439 0.009125 131 | -0.381899 0.000000 -0.661468 -0.000000 -1.000000 -0.000000 0.878627 0.070580 132 | -0.661469 0.000000 -0.381898 -0.000000 -1.000000 -0.000000 0.752464 0.070580 133 | -0.763798 0.000000 0.000001 0.000000 -1.000000 -0.000000 0.626302 0.070580 134 | -1.000000 0.000000 0.000001 0.000000 -1.000000 -0.000000 0.573261 0.009125 135 | -0.661468 0.000000 0.381900 0.000000 -1.000000 -0.000000 0.500140 0.070580 136 | -0.866025 0.000000 0.500001 0.000000 -1.000000 -0.000000 0.472151 0.009125 137 | -0.500000 0.000000 0.866026 -0.000000 -1.000000 0.000000 0.618382 0.140625 138 | -0.661468 0.000000 0.381900 -0.000000 -1.000000 0.000000 0.539531 0.081995 139 | -0.381899 0.000000 0.661469 -0.000000 -1.000000 0.000000 0.667646 0.081995 140 | 0.000000 0.000000 0.763799 -0.000000 -1.000000 0.000000 0.795762 0.081995 141 | 0.000000 0.000000 1.000001 -0.000000 -1.000000 0.000000 0.786116 0.140625 142 | 0.381899 0.000000 0.661469 -0.000000 -1.000000 0.000000 0.923877 0.081995 143 | 0.500000 0.000000 0.866026 -0.000000 -1.000000 0.000000 0.953851 0.140625 144 | 0.500000 2.000000 -0.866025 0.258819 0.000000 -0.965926 0.161741 0.994150 145 | 0.866026 2.000000 -0.499999 0.707107 0.000000 -0.707107 0.179490 0.499267 146 | 1.000000 2.000000 0.000001 0.965926 0.000000 -0.258819 0.161741 0.829359 147 | 0.866026 2.000000 0.500001 0.965926 0.000000 0.258819 0.344282 0.499267 148 | 0.500000 2.000000 0.866026 0.707107 0.000000 0.707107 0.179490 0.664059 149 | 0.000000 2.000000 1.000001 0.258819 0.000000 0.965926 0.161741 0.664567 150 | -0.500000 2.000000 0.866026 -0.258819 -0.000000 0.965926 0.344282 0.664059 151 | -0.866025 2.000000 0.500001 -0.707107 -0.000000 0.707107 0.509073 0.499267 152 | -0.866025 2.000000 0.500001 -0.965926 0.000000 0.258819 0.509073 0.508145 153 | -1.000000 2.000000 0.000001 -0.965926 0.000000 0.258819 0.509073 0.664059 154 | -1.000000 0.000000 0.000001 -0.965926 0.000000 0.258819 0.664987 0.664059 155 | -0.866026 2.000000 -0.499999 -0.965926 0.000000 -0.258819 0.179490 0.828850 156 | 0.381899 0.000000 0.661469 -0.258819 0.000000 -0.965926 0.161741 0.499776 157 | -0.866026 2.000000 -0.499999 -0.707107 -0.000000 -0.707106 0.344282 0.672937 158 | -0.500000 2.000000 -0.866024 -0.707107 -0.000000 -0.707106 0.344282 0.828850 159 | -0.500000 0.000000 -0.866024 -0.707107 -0.000000 -0.707106 0.500195 0.828850 160 | -0.500000 0.000000 -0.866024 -0.258819 -0.000000 -0.965926 0.829778 0.343354 161 | -0.500000 2.000000 -0.866024 -0.258819 -0.000000 -0.965926 0.673865 0.343354 162 | 0.000000 2.000000 -0.999999 -0.258819 -0.000000 -0.965926 0.673865 0.499267 163 | 0.381899 0.000000 0.661469 0.000000 -1.000000 0.000000 0.439468 0.140589 164 | 0.866026 2.000000 -0.499999 0.000000 1.000000 -0.000000 0.449885 0.226740 165 | 0.500000 2.000000 0.866026 0.000000 1.000000 0.000000 0.994003 0.221401 166 | -0.866025 2.000000 0.500001 0.000000 1.000000 0.000000 0.549718 0.287049 167 | -0.500000 2.000000 -0.866024 -0.000000 1.000000 0.000000 0.006492 0.160763 168 | 0.661469 0.000000 -0.381898 -0.965926 0.000000 0.258819 0.509073 0.828850 169 | -0.763798 0.000000 0.000001 0.965926 -0.000000 0.258819 0.673865 0.664059 170 | 0.000000 0.000000 0.763799 0.258819 -0.000000 -0.965926 0.673865 0.828850 171 | 0.763798 0.000000 0.000001 -0.965926 -0.000000 -0.258819 0.179490 0.993642 172 | -0.661469 0.000000 -0.381898 0.707107 0.000000 0.707106 0.839262 0.993850 173 | 0.000000 0.000000 -0.763798 -0.258819 -0.000000 0.965926 0.344282 0.993642 174 | -0.381899 0.000000 0.661469 0.707106 0.000000 -0.707107 0.838656 0.499267 175 | 0.661469 0.000000 0.381900 -0.707107 0.000000 -0.707107 0.509073 0.993642 176 | -0.381899 2.000000 -0.661468 0.258820 -0.000000 0.965926 0.838656 0.508145 177 | -0.381899 0.000000 -0.661468 0.258820 -0.000000 0.965926 0.838656 0.664059 178 | 0.000000 0.000000 -0.763798 0.258820 -0.000000 0.965926 0.994569 0.664059 179 | 0.381899 0.000000 -0.661468 -0.707107 0.000000 0.707107 0.673865 0.993642 180 | -0.661468 0.000000 0.381900 0.965926 -0.000000 -0.258819 0.838656 0.828850 181 | 0.661469 0.000000 -0.381898 0.000000 -1.000000 0.000000 0.077425 0.011842 182 | -0.500000 0.000000 -0.866024 -0.000000 -1.000000 0.000000 0.903616 0.009125 183 | -0.866025 0.000000 0.500001 0.000000 -1.000000 0.000000 0.450647 0.140625 184 | 3 0 1 2 185 | 3 3 4 5 186 | 3 6 7 8 187 | 3 9 10 11 188 | 3 12 13 14 189 | 3 15 16 17 190 | 3 18 19 20 191 | 3 21 22 23 192 | 3 24 25 26 193 | 3 27 28 29 194 | 3 30 31 32 195 | 3 33 34 35 196 | 3 36 37 38 197 | 3 39 40 41 198 | 3 42 43 44 199 | 3 45 43 46 200 | 3 47 48 49 201 | 3 50 48 51 202 | 3 52 53 50 203 | 3 54 55 56 204 | 3 57 58 54 205 | 3 59 60 57 206 | 3 61 62 63 207 | 3 61 64 65 208 | 3 66 64 67 209 | 3 68 44 69 210 | 3 41 70 71 211 | 3 72 73 74 212 | 3 75 76 77 213 | 3 78 79 80 214 | 3 81 82 83 215 | 3 84 85 86 216 | 3 87 88 89 217 | 3 90 91 92 218 | 3 93 94 95 219 | 3 96 97 98 220 | 3 99 100 101 221 | 3 102 103 104 222 | 3 105 70 106 223 | 3 107 108 109 224 | 3 109 110 111 225 | 3 112 110 113 226 | 3 114 115 116 227 | 3 114 117 118 228 | 3 118 119 120 229 | 3 121 122 123 230 | 3 121 124 125 231 | 3 125 126 127 232 | 3 0 128 1 233 | 3 3 129 4 234 | 3 6 130 7 235 | 3 9 131 10 236 | 3 12 132 13 237 | 3 15 133 16 238 | 3 18 134 19 239 | 3 21 135 22 240 | 3 136 137 138 241 | 3 27 139 28 242 | 3 30 140 31 243 | 3 141 142 143 244 | 3 144 145 146 245 | 3 39 147 40 246 | 3 42 46 43 247 | 3 45 148 43 248 | 3 47 51 48 249 | 3 50 53 48 250 | 3 52 149 53 251 | 3 54 58 55 252 | 3 57 60 58 253 | 3 59 150 60 254 | 3 61 65 62 255 | 3 61 67 64 256 | 3 66 151 64 257 | 3 68 42 44 258 | 3 41 40 70 259 | 3 72 152 73 260 | 3 75 153 76 261 | 3 78 154 79 262 | 3 81 155 82 263 | 3 84 156 85 264 | 3 87 157 88 265 | 3 90 158 91 266 | 3 93 159 94 267 | 3 160 161 162 268 | 3 99 163 100 269 | 3 102 164 103 270 | 3 105 71 70 271 | 3 107 165 108 272 | 3 109 108 110 273 | 3 112 111 110 274 | 3 114 166 115 275 | 3 114 116 117 276 | 3 118 117 119 277 | 3 121 167 122 278 | 3 121 123 124 279 | 3 125 124 126 280 | -------------------------------------------------------------------------------- /example-vbo/bin/data/wall.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.82 (sub 7) - www.blender.org, source file: 'monkey_test.blend' 4 | element vertex 24 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | element face 12 14 | property list uchar uint vertex_indices 15 | end_header 16 | -1.500000 3.000065 0.146439 -1.000000 0.000000 0.000000 0.625000 0.000000 17 | -1.500000 0.000065 -0.150000 -1.000000 0.000000 0.000000 0.375000 0.250000 18 | -1.500000 0.000065 0.146439 -1.000000 0.000000 0.000000 0.375000 0.000000 19 | -1.500000 3.000065 -0.150000 -0.000000 0.000000 -1.000000 0.625000 0.250000 20 | 1.500000 0.000065 -0.150001 -0.000000 0.000000 -1.000000 0.375000 0.500000 21 | -1.500000 0.000065 -0.150000 -0.000000 0.000000 -1.000000 0.375000 0.250000 22 | 1.500000 3.000065 -0.150001 1.000000 0.000000 0.000001 0.625000 0.500000 23 | 1.500000 0.000065 0.146438 1.000000 0.000000 0.000001 0.375000 0.750000 24 | 1.500000 0.000065 -0.150001 1.000000 0.000000 0.000001 0.375000 0.500000 25 | 1.500000 3.000065 0.146438 0.000000 0.000000 1.000000 0.625000 0.750000 26 | -1.500000 0.000065 0.146439 0.000000 0.000000 1.000000 0.375000 1.000000 27 | 1.500000 0.000065 0.146438 0.000000 0.000000 1.000000 0.375000 0.750000 28 | -1.500000 0.000065 -0.150000 0.000000 -1.000000 -0.000000 0.125000 0.500000 29 | 1.500000 0.000065 0.146438 0.000000 -1.000000 -0.000000 0.375000 0.750000 30 | -1.500000 0.000065 0.146439 0.000000 -1.000000 -0.000000 0.125000 0.750000 31 | -1.500000 3.000065 -0.150000 0.000000 1.000000 0.000000 0.875000 0.500000 32 | 1.500000 3.000065 0.146438 0.000000 1.000000 0.000000 0.625000 0.750000 33 | 1.500000 3.000065 -0.150001 0.000000 1.000000 0.000000 0.625000 0.500000 34 | -1.500000 3.000065 -0.150000 -1.000000 0.000000 0.000000 0.625000 0.250000 35 | 1.500000 3.000065 -0.150001 -0.000000 0.000000 -1.000000 0.625000 0.500000 36 | 1.500000 3.000065 0.146438 1.000000 -0.000000 0.000001 0.625000 0.750000 37 | -1.500000 3.000065 0.146439 0.000000 -0.000000 1.000000 0.625000 1.000000 38 | 1.500000 0.000065 -0.150001 -0.000000 -1.000000 -0.000000 0.375000 0.500000 39 | -1.500000 3.000065 0.146439 0.000000 1.000000 0.000000 0.875000 0.750000 40 | 3 0 1 2 41 | 3 3 4 5 42 | 3 6 7 8 43 | 3 9 10 11 44 | 3 12 13 14 45 | 3 15 16 17 46 | 3 0 18 1 47 | 3 3 19 4 48 | 3 6 20 7 49 | 3 9 21 10 50 | 3 12 22 13 51 | 3 15 23 16 52 | -------------------------------------------------------------------------------- /example-vbo/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example-vbo/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | cc.openFrameworks.${EXECUTABLE_NAME} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | CFBundleIconFile 20 | ${ICON} 21 | NSCameraUsageDescription 22 | This app needs to access the camera 23 | NSMicrophoneUsageDescription 24 | This app needs to access the microphone 25 | 26 | 27 | -------------------------------------------------------------------------------- /example-vbo/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | //ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | ofGLFWWindowSettings settings; 8 | settings.setGLVersion(3, 2); 9 | ofCreateWindow(settings); 10 | 11 | 12 | // this kicks off the running of my app 13 | // can be OF_WINDOW or OF_FULLSCREEN 14 | // pass in width and height too: 15 | ofRunApp(new ofApp()); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /example-vbo/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup() { 5 | // set up lightmapper and pass scene draw function 6 | function scene = bind(&ofApp::renderScene, this); 7 | bool success = lightmapper.setup(scene, 5); 8 | if (success) ofLog() << "Lightmapper ready"; 9 | 10 | // load models 11 | meshMonkey.load("monkey.ply"); 12 | meshPlane.load("plane.ply"); 13 | meshTube.load("tube.ply"); 14 | meshWall.load("wall.ply"); 15 | 16 | // generate lightmap coords for the models 17 | lightmapper.lightmapPack(meshMonkey); 18 | //lightmapper.lightmapPack(meshPlane, {800,800}); 19 | lightmapper.lightmapPack(meshTube); 20 | lightmapper.lightmapPack(meshWall, {500,500}); 21 | 22 | 23 | // place them into world 24 | nodeMonkey.setPosition({0,0,0}); 25 | nodeMonkey.setScale({1.4,1.8,1.4}); 26 | nodePlane.setPosition({0,0,0}); 27 | nodeTube.setPosition({2,0,-2.8}); 28 | nodeTube.setScale({1,1.8,1}); 29 | nodeWall.setPosition({-2,0,2.8}); 30 | nodeWall.setScale({1,0.8,1}); 31 | nodeWall.panDeg(30); 32 | 33 | // setup lightmaps 34 | lightmapper.allocateFBO(fboMonkey); 35 | lightmapper.allocateFBO(fboPlane, {800,800}); 36 | lightmapper.allocateFBO(fboTube); 37 | lightmapper.allocateFBO(fboWall, {500,500}); 38 | 39 | // material 40 | ofDisableArbTex(); 41 | material.load("material"); 42 | texture.load("UVtexture.png"); 43 | 44 | // camera 45 | cam.setDistance(3.0f); 46 | cam.setNearClip(0.01f); 47 | cam.setFarClip(100.0f); 48 | } 49 | 50 | //-------------------------------------------------------------- 51 | void ofApp::update() { 52 | // bake 53 | ofLight light; // also works with ofNode 54 | light.setPosition(glm::vec3(-2.52348, 2.79526, 7.84836)); 55 | light.lookAt(glm::vec3(0,0,0)); 56 | 57 | // compute depth map for shadow 58 | lightmapper.updateShadowMap(light, {0,0,0}, 0.2, 12, 0.01, 15); 59 | 60 | // bake each geometry using its world transformation 61 | lightmapper.bake(meshMonkey, fboMonkey, nodeMonkey, sampleCount); 62 | lightmapper.bake(meshPlane, fboPlane, nodePlane, sampleCount); 63 | lightmapper.bake(meshTube, fboTube, nodeTube, sampleCount); 64 | lightmapper.bake(meshWall, fboWall, nodeWall, sampleCount); 65 | } 66 | 67 | //-------------------------------------------------------------- 68 | void ofApp::draw() { 69 | // forward render scene from camera 70 | ofBackground(30); 71 | ofEnableDepthTest(); 72 | cam.begin(); 73 | { 74 | renderScene(); 75 | } 76 | cam.end(); 77 | 78 | // debug textures 79 | ofDisableDepthTest(); 80 | int mapsize = 300; 81 | lightmapper.getDepthTexture().draw(ofGetWidth()-mapsize,0, mapsize, mapsize); 82 | lightmapper.getDepthTexture(1).draw(ofGetWidth()-mapsize, mapsize, mapsize, mapsize); 83 | fboMonkey.draw(0, 0, mapsize, mapsize); 84 | fboPlane.draw(mapsize, 0, mapsize, mapsize); 85 | fboTube.draw(0, mapsize, mapsize, mapsize); 86 | fboWall.draw(mapsize, mapsize, mapsize, mapsize); 87 | 88 | sampleCount++; 89 | } 90 | 91 | //-------------------------------------------------------------- 92 | void ofApp::renderScene() { 93 | // render scene 94 | 95 | nodeMonkey.transformGL(); 96 | material.begin(); 97 | material.setUniformTexture("tex0", texture, 0); 98 | material.setUniformTexture("tex1", fboMonkey.getTextureReference(), 1); 99 | meshMonkey.draw(); 100 | material.end(); 101 | nodeMonkey.restoreTransformGL(); 102 | 103 | nodePlane.transformGL(); 104 | fboPlane.getTextureReference().bind(); 105 | meshPlane.draw(); 106 | fboPlane.getTextureReference().unbind(); 107 | nodePlane.restoreTransformGL(); 108 | 109 | nodeTube.transformGL(); 110 | material.begin(); 111 | material.setUniformTexture("tex0", texture, 0); 112 | material.setUniformTexture("tex1", fboTube.getTextureReference(), 1); 113 | meshTube.draw(); 114 | material.end(); 115 | nodeTube.restoreTransformGL(); 116 | 117 | nodeWall.transformGL(); 118 | material.begin(); 119 | material.setUniformTexture("tex0", texture, 0); 120 | material.setUniformTexture("tex1", fboWall.getTextureReference(), 1); 121 | meshWall.draw(); 122 | material.end(); 123 | nodeWall.restoreTransformGL(); 124 | } 125 | //-------------------------------------------------------------- 126 | void ofApp::keyPressed(int key) { 127 | sampleCount = 0; 128 | } 129 | -------------------------------------------------------------------------------- /example-vbo/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxGPULightmapper.h" 5 | 6 | class ofApp : public ofBaseApp{ 7 | 8 | public: 9 | void setup(); 10 | void update(); 11 | void draw(); 12 | void renderScene(); 13 | 14 | void keyPressed(int key); 15 | 16 | ofxGPULightmapper lightmapper; 17 | int sampleCount = 0; 18 | 19 | ofEasyCam cam; 20 | 21 | // ply models [VBO] 22 | ofVboMesh meshMonkey, meshPlane, meshTube, meshWall; 23 | // model transformatins 24 | ofNode nodeMonkey, nodePlane, nodeTube, nodeWall; 25 | // lightmaps 26 | ofFbo fboMonkey, fboPlane, fboTube, fboWall; 27 | 28 | // material 29 | ofShader material; 30 | ofImage texture; 31 | }; 32 | -------------------------------------------------------------------------------- /images/ofxGPULightmapper_demo_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/action-script/ofxGPULightmapper/00cc914ddd47e8892a4fb570f07c99b723ef9ecd/images/ofxGPULightmapper_demo_1.jpg -------------------------------------------------------------------------------- /images/ofxGPULightmapper_demo_2_mix.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/action-script/ofxGPULightmapper/00cc914ddd47e8892a4fb570f07c99b723ef9ecd/images/ofxGPULightmapper_demo_2_mix.jpg -------------------------------------------------------------------------------- /images/ofxGPULightmapper_demo_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/action-script/ofxGPULightmapper/00cc914ddd47e8892a4fb570f07c99b723ef9ecd/images/ofxGPULightmapper_demo_4.jpg -------------------------------------------------------------------------------- /images/ofxGPULightmapper_demo_4_mix.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/action-script/ofxGPULightmapper/00cc914ddd47e8892a4fb570f07c99b723ef9ecd/images/ofxGPULightmapper_demo_4_mix.jpg -------------------------------------------------------------------------------- /images/ofxaddons_thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/action-script/ofxGPULightmapper/00cc914ddd47e8892a4fb570f07c99b723ef9ecd/images/ofxaddons_thumbnail.png -------------------------------------------------------------------------------- /images/trianglepackerUV.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/action-script/ofxGPULightmapper/00cc914ddd47e8892a4fb570f07c99b723ef9ecd/images/trianglepackerUV.jpg -------------------------------------------------------------------------------- /src/ofxGPULightmapper.cpp: -------------------------------------------------------------------------------- 1 | #include "ofxGPULightmapper.h" 2 | 3 | #define TRIANGLEPACKER_IMPLEMENTATION 4 | //#define TP_DEBUG_OUTPUT 5 | #include "trianglepacker/trianglepacker.h" 6 | 7 | bool ofxGPULightmapper::setup(function scene, unsigned int numPasses) { 8 | this->scene = scene; 9 | this->numPasses = numPasses * 2; 10 | return setup(); 11 | } 12 | 13 | bool ofxGPULightmapper::setup() { 14 | for (int i = 0; i < numPasses; i++) { 15 | // allocate depth FBOs 16 | depthFBO.emplace_back(new ofFbo); 17 | allocateFBO(*depthFBO[i].get(), FBO_DEPTH); 18 | 19 | // set up passes vector 20 | glm::mat4 bm; 21 | lastBiasedMatrix.push_back(bm); 22 | glm::vec3 lpos; 23 | lastLightPos.push_back(lpos); 24 | } 25 | 26 | this->passIndex = 0; 27 | 28 | // compile depth shaders 29 | bool success; 30 | success = depthShader.setupShaderFromSource(GL_VERTEX_SHADER, 31 | R"( 32 | #version 330 33 | uniform mat4 modelViewProjectionMatrix; 34 | in vec4 position; 35 | void main() { 36 | gl_Position = modelViewProjectionMatrix * position; 37 | } 38 | )" 39 | ); 40 | success &= depthShader.setupShaderFromSource(GL_FRAGMENT_SHADER, 41 | R"( 42 | #version 330 43 | out float fragDepth; 44 | void main() { 45 | fragDepth = gl_FragCoord.z; 46 | } 47 | )" 48 | ); 49 | success &= depthShader.linkProgram(); 50 | 51 | 52 | // compile light packer shader 53 | std::string lm_vertexshader = R"( 54 | #version 330 55 | uniform mat4 modelViewProjectionMatrix; 56 | uniform mat4 shadowViewProjectionMatrix; 57 | uniform mat4 modelMatrix; 58 | uniform vec3 light; // shadow light position 59 | uniform int usingPackedTriangles; 60 | uniform float contact_shadow_factor; 61 | in vec4 position; 62 | in vec4 normal; 63 | in vec2 texcoord; 64 | )"; 65 | // trick to ensure same location through shaders 66 | // custom triangle packed UVs 67 | lm_vertexshader += "layout (location = "+std::to_string(LM_TEXCOORDS_LOCATION)+") in vec2 t_texcoord;\n"; 68 | lm_vertexshader += R"( 69 | out vec4 v_shadowPos; 70 | out vec3 v_normal; 71 | out vec2 v_texcoord; 72 | void main() { 73 | // fix contact shadows by moving geometry against light 74 | vec3 pos = position.xyz + normalize(cross(normal.xyz, cross(normal.xyz, light))) * contact_shadow_factor; 75 | v_shadowPos = shadowViewProjectionMatrix * (modelMatrix * vec4(pos, 1)); 76 | v_normal = normal.xyz; 77 | v_texcoord = mix(texcoord, t_texcoord, usingPackedTriangles); 78 | gl_Position = vec4(v_texcoord * 2.0 - 1.0, 0.0, 1.0); 79 | } 80 | )"; 81 | success &= lightmapShader.setupShaderFromSource(GL_VERTEX_SHADER, lm_vertexshader); 82 | // geometry dilation as conservative rasterization 83 | success &= lightmapShader.setupShaderFromSource(GL_GEOMETRY_SHADER_EXT, 84 | R"( 85 | #version 150 86 | #define M_PI 3.1415926535897932384626433832795 87 | layout (triangles) in; 88 | layout (triangle_strip, max_vertices = 9) out; 89 | uniform float texSize; 90 | uniform float dilation; 91 | in vec4 v_shadowPos[3]; 92 | in vec3 v_normal[3]; 93 | in vec2 v_texcoord[3]; 94 | out vec4 f_shadowPos; 95 | out vec3 f_normal; 96 | out vec2 f_texcoord; 97 | float atan2(in float y, in float x) { 98 | bool s = (abs(x) > abs(y)); 99 | return mix(M_PI/2.0 - atan(x,y), atan(y,x), s); 100 | } 101 | void emit(vec4 position, int i) { 102 | gl_Position = position; 103 | f_shadowPos = v_shadowPos[i]; 104 | f_normal = v_normal[i]; 105 | f_texcoord = v_texcoord[i]; 106 | EmitVertex(); 107 | } 108 | void main() { 109 | float hPixel = (1.0/texSize)*dilation; 110 | vec4 vertices[3]; 111 | for (int i = 0; i < 3; i++) { 112 | int i0 = i, i1 = (i+1)%3, i2 = (i+2)%3; 113 | vec4 lp0 = gl_in[i0].gl_Position; 114 | vec4 lp1 = gl_in[i1].gl_Position; 115 | vec4 lp2 = gl_in[i2].gl_Position; 116 | vec2 v0 = normalize(lp0.xy - lp1.xy); 117 | vec2 v1 = normalize(lp2.xy - lp1.xy); 118 | vec2 mixed = -normalize((v0+v1)/2.f); 119 | float angle = atan2(v0.y, v0.x) - atan2(mixed.y, mixed.x); 120 | float vlength = abs(hPixel / sin(angle)); 121 | vec2 offs = mixed * vec2(vlength); 122 | vertices[i1] = vec4(lp1.xy + offs, 0, 1); 123 | } 124 | 125 | /* 126 | * 0 \ 127 | * ^ | original geometry 128 | * / \ | uv coords = original geometry 129 | * 1/___\2___4____6 / 130 | * \ | /| /|\ \ 131 | * \ | / | / | \ | dilation vertices 132 | * \ | / | / | \ | uv coords = original geometry 133 | * \|/___|/___|___\ / 134 | * 3 5 7 8 135 | * 136 | * [0-4] [1-6] [3(2)-8] 137 | */ 138 | 139 | emit(gl_in[0].gl_Position, 0); // 0 140 | emit(gl_in[1].gl_Position, 1); // 1 141 | emit(gl_in[2].gl_Position, 2); // 2 142 | 143 | emit(vertices[2], 2); // 3 144 | emit(gl_in[0].gl_Position, 0); // 4 145 | emit(vertices[0], 0); // 5 146 | emit(gl_in[1].gl_Position, 1); // 6 147 | emit(vertices[1], 1); // 7 148 | emit(vertices[2], 2); // 8 149 | } 150 | )" 151 | ); 152 | success &= lightmapShader.setupShaderFromSource(GL_FRAGMENT_SHADER, 153 | R"( 154 | #version 330 155 | uniform sampler2DShadow shadowMap; 156 | uniform vec3 light; // shadow light position 157 | uniform float sampleCount; 158 | uniform float shadow_bias; // 0.003 159 | in vec4 f_shadowPos; 160 | in vec3 f_normal; 161 | in vec2 f_texcoord; 162 | out vec4 outputColor; 163 | vec3 coords = f_shadowPos.xyz / f_shadowPos.w; 164 | float shadow = 1.0f; 165 | void main() { 166 | coords.y = 1-coords.y; 167 | // check if coords are in shadowMap texture 168 | if (coords.x>0.0 && coords.x<1.0 && coords.y>0.0 && coords.y<1.0) { 169 | shadow = texture(shadowMap, vec3(coords.xy, coords.z - shadow_bias)); 170 | } 171 | outputColor = vec4(vec3(shadow), 1.0 / (1.0 + sampleCount)); 172 | //outputColor = vec4(f_texcoord.x, f_texcoord.y, 0.5,1); 173 | //outputColor = vec4(0,1,0,1); 174 | } 175 | )" 176 | ); 177 | if(ofIsGLProgrammableRenderer()) lightmapShader.bindDefaults(); 178 | success &= lightmapShader.linkProgram(); 179 | //lightmapShader.setGeometryInputType(GL_TRIANGLE_STRIP); 180 | 181 | return success; 182 | } 183 | 184 | void ofxGPULightmapper::beginShadowMap(ofNode& light, float fustrumSize, float nearClip, float farClip) { 185 | // calculate light projection 186 | float left = -fustrumSize / 2.; 187 | float right = fustrumSize / 2.; 188 | float top = fustrumSize / 2.; 189 | float bottom = -fustrumSize / 2.; 190 | auto ortho = glm::ortho(left, right, bottom, top, nearClip, farClip); 191 | auto view = glm::inverse(light.getGlobalTransformMatrix()); 192 | auto viewProjection = ortho * view; 193 | 194 | this->lastBiasedMatrix[passIndex] = this->bias * viewProjection; 195 | this->lastLightPos[passIndex] = light.getPosition(); 196 | 197 | // begin depth render FBO and shader 198 | depthShader.begin(); 199 | depthFBO[passIndex]->begin(OF_FBOMODE_NODEFAULTS); 200 | 201 | ofEnableDepthTest(); 202 | 203 | ofPushView(); 204 | 205 | ofSetMatrixMode(OF_MATRIX_PROJECTION); 206 | ofLoadMatrix(ortho); 207 | 208 | ofSetMatrixMode(OF_MATRIX_MODELVIEW); 209 | ofLoadViewMatrix(view); 210 | 211 | ofViewport(ofRectangle(1,0,depthFBO[passIndex]->getWidth(),depthFBO[passIndex]->getHeight())); 212 | ofClear(0); 213 | } 214 | 215 | void ofxGPULightmapper::endShadowMap() { 216 | // end depth render FBO and shader 217 | depthFBO[passIndex]->end(); 218 | depthShader.end(); 219 | ofPopView(); // pop at the end to prevent trigger update matrix stack 220 | } 221 | 222 | void ofxGPULightmapper::beginBake(ofFbo& fbo, int sampleCount, bool usingPackedTriangles) { 223 | // render shadowMap into texture space 224 | ofDisableDepthTest(); 225 | 226 | // begin lightmap shader and FBO 227 | lightmapShader.begin(); 228 | ofEnableBlendMode(OF_BLENDMODE_ALPHA); 229 | fbo.begin(); 230 | 231 | //glClearColor(0,0,0,0); 232 | //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 233 | 234 | // bind shadow map to texture 235 | lightmapShader.setUniformTexture("shadowMap", this->depthFBO[passIndex]->getDepthTexture(), 0); 236 | // pass the light projection view 237 | lightmapShader.setUniformMatrix4f("shadowViewProjectionMatrix", this->lastBiasedMatrix[passIndex]); 238 | // pass the light position 239 | lightmapShader.setUniform3f("light", this->lastLightPos[passIndex]); 240 | // define if using packed triangle UVs 241 | lightmapShader.setUniform1i("usingPackedTriangles", usingPackedTriangles); 242 | 243 | lightmapShader.setUniform1f("sampleCount", sampleCount); 244 | lightmapShader.setUniform1f("texSize", fbo.getWidth()); 245 | lightmapShader.setUniform1f("dilation", this->geometry_dilation); 246 | lightmapShader.setUniform1f("contact_shadow_factor", this->contact_shadow_factor); 247 | lightmapShader.setUniform1f("shadow_bias", this->shadow_bias); 248 | } 249 | 250 | void ofxGPULightmapper::endBake(ofFbo& fbo) { 251 | fbo.end(); 252 | ofDisableBlendMode(); 253 | lightmapShader.end(); 254 | } 255 | 256 | void ofxGPULightmapper::allocateFBO(ofFbo& fbo, glm::vec2 size) { 257 | lightFboSettings.width = size.x; 258 | lightFboSettings.height = size.y; 259 | allocateFBO(fbo, FBO_LIGHT); 260 | } 261 | 262 | void ofxGPULightmapper::allocateFBO(ofFbo& fbo, FBO_TYPE type) { 263 | switch (type) { 264 | case FBO_TYPE::FBO_DEPTH: 265 | fbo.allocate(depthFboSettings); 266 | fbo.getDepthTexture().setRGToRGBASwizzles(true); 267 | // allow depth texture to compare in glsl 268 | fbo.getDepthTexture().bind(); 269 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); 270 | //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); 271 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LESS); 272 | fbo.getDepthTexture().unbind(); 273 | break; 274 | case FBO_TYPE::FBO_LIGHT: 275 | fbo.allocate(this->lightFboSettings); 276 | break; 277 | } 278 | } 279 | 280 | void ofxGPULightmapper::updateCachedShadowMap(ofNode & light, int sampleCount, glm::vec3 origin, float softness, 281 | float fustrumSize, float nearClip, float farClip) { 282 | for (int i = 0; i < numPasses; i++) { 283 | ofNode nlight; 284 | auto lad = light.getLookAtDir(); 285 | auto pos = light.getPosition(); 286 | float radius = glm::distance(lad, pos); 287 | 288 | int index = sampleCount * numPasses + i; 289 | glm::vec3 lightDir; 290 | if (index >= random_cache.size()) { 291 | lightDir = glm::sphericalRand(radius); 292 | if (i % 2 == 0) 293 | lightDir = light.getPosition() + lightDir*(softness * (1+ofRandomf())/2.0); 294 | 295 | if (lightDir.y < 0) lightDir.y = -lightDir.y; 296 | random_cache.push_back(lightDir); 297 | } else 298 | lightDir = random_cache[index]; 299 | 300 | nlight.setPosition(lightDir + origin); 301 | nlight.lookAt(origin); 302 | 303 | this->passIndex = i; 304 | beginShadowMap(nlight, fustrumSize, nearClip, farClip); 305 | scene(); 306 | endShadowMap(); 307 | } 308 | this->passIndex = 0; 309 | } 310 | 311 | void ofxGPULightmapper::updateShadowMap(ofNode & light, glm::vec3 origin, float softness, 312 | float fustrumSize, float nearClip, float farClip) { 313 | for (int i = 0; i < numPasses; i++) { 314 | ofNode nlight; 315 | auto lad = light.getLookAtDir(); 316 | auto pos = light.getPosition(); 317 | float radius = glm::distance(lad, pos); 318 | glm::vec3 lightDir = glm::sphericalRand(radius); 319 | if (i % 2 == 0) 320 | lightDir = light.getPosition() + lightDir*(softness * (1+ofRandomf())/2.0); 321 | 322 | if (lightDir.y < 0) lightDir.y = -lightDir.y; 323 | nlight.setPosition(lightDir + origin); 324 | nlight.lookAt(origin); 325 | 326 | this->passIndex = i; 327 | beginShadowMap(nlight, fustrumSize, nearClip, farClip); 328 | scene(); 329 | endShadowMap(); 330 | } 331 | this->passIndex = 0; 332 | } 333 | 334 | void ofxGPULightmapper::bake(ofMesh& mesh, ofFbo& fbo, ofNode& node, int sampleCount) { 335 | for (int i = 0; i < numPasses; i++) { 336 | this->passIndex = i; 337 | beginBake(fbo, sampleCount*this->numPasses+i); 338 | node.transformGL(); 339 | mesh.draw(); 340 | node.restoreTransformGL(); 341 | endBake(fbo); 342 | } 343 | this->passIndex = 0; 344 | } 345 | 346 | void ofxGPULightmapper::bake(ofVboMesh& mesh, ofFbo& fbo, ofNode& node, int sampleCount) { 347 | bool usingPackedTriangles = mesh.getVbo().hasAttribute(this->LM_TEXCOORDS_LOCATION); 348 | for (int i = 0; i < numPasses; i++) { 349 | this->passIndex = i; 350 | beginBake(fbo, sampleCount*this->numPasses+i, usingPackedTriangles); 351 | node.transformGL(); 352 | mesh.drawInstanced(OF_MESH_FILL,1); 353 | node.restoreTransformGL(); 354 | endBake(fbo); 355 | } 356 | this->passIndex = 0; 357 | } 358 | 359 | // pack geometry into UV triangles. Generates coords for a LighMap texture. 360 | // Only works if has individual edges. this why getUniqueFaces() 361 | // If not, the mesh would have shared edges pointing to individual geometry on texture coordinate. 362 | bool ofxGPULightmapper::lightmapPack(ofVboMesh& mesh, glm::vec2 size) { 363 | // Re-assign mesh data as independent indices. Not shared vertex anmore. 364 | mesh.setFromTriangles(mesh.getUniqueFaces()); 365 | 366 | int vertexCount = mesh.getNumVertices(); 367 | float scale = 0.0f; 368 | 369 | std::vector triangles; 370 | const float* positions; 371 | int uvCount; 372 | if (mesh.hasIndices()) { 373 | // read vertices as consecutive triangles 374 | auto vertices = mesh.getVertices(); 375 | for (auto& i : mesh.getIndices()) { 376 | triangles.push_back(vertices[i]); 377 | } 378 | 379 | positions = (const float*)triangles.data(); 380 | uvCount = triangles.size(); 381 | 382 | } else { 383 | positions = (const float*)mesh.getVerticesPointer(); 384 | uvCount = vertexCount; 385 | } 386 | 387 | // allocate UVs 388 | std::vector UVs; 389 | UVs.resize(uvCount); 390 | 391 | bool success = tpPackIntoRect( 392 | positions, uvCount, 393 | size.x, size.y, 2, 3, // 2,2 broder, spacing 394 | glm::value_ptr(UVs[0]), &scale 395 | ); 396 | 397 | if (success) { 398 | GLint attLoc1 = lightmapShader.getAttributeLocation("t_texcoord"); // located at LM_TEXCOORDS_LOCATION 399 | // set custom Vertex Color Data 400 | mesh.getVbo().setAttributeData(attLoc1, glm::value_ptr(UVs[0]), 2, uvCount*2, GL_STATIC_DRAW, sizeof(glm::vec2)); 401 | } 402 | 403 | return success; 404 | } 405 | -------------------------------------------------------------------------------- /src/ofxGPULightmapper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "glm/gtc/random.hpp" 5 | 6 | 7 | #include "trianglepacker/trianglepacker.h" 8 | 9 | class ofxGPULightmapper { 10 | public: 11 | ofxGPULightmapper() { 12 | // define depthFBO settings 13 | depthFboSettings.depthStencilAsTexture = true; 14 | depthFboSettings.depthStencilInternalFormat = GL_DEPTH_COMPONENT32; 15 | depthFboSettings.width = 1024; 16 | depthFboSettings.height = 1024; 17 | depthFboSettings.minFilter = GL_NEAREST; 18 | depthFboSettings.maxFilter = GL_NEAREST; 19 | depthFboSettings.numColorbuffers = 0; 20 | depthFboSettings.textureTarget = GL_TEXTURE_2D; 21 | depthFboSettings.useDepth = true; 22 | depthFboSettings.useStencil = false; 23 | depthFboSettings.wrapModeHorizontal = GL_CLAMP_TO_EDGE; 24 | depthFboSettings.wrapModeVertical = GL_CLAMP_TO_EDGE; 25 | 26 | // define lightmapFBO settings 27 | lightFboSettings.depthStencilAsTexture = false; 28 | lightFboSettings.internalformat = GL_RGBA32F_ARB; 29 | lightFboSettings.width = 1024; 30 | lightFboSettings.height = 1024; 31 | lightFboSettings.minFilter = GL_LINEAR; 32 | lightFboSettings.maxFilter = GL_LINEAR; 33 | lightFboSettings.textureTarget = GL_TEXTURE_2D; 34 | lightFboSettings.useDepth = false; 35 | lightFboSettings.useStencil = false; 36 | lightFboSettings.numSamples = 8; 37 | lightFboSettings.wrapModeHorizontal = GL_CLAMP_TO_EDGE; 38 | lightFboSettings.wrapModeVertical = GL_CLAMP_TO_EDGE; 39 | } 40 | bool setup(); 41 | bool setup(function scene, unsigned int numPasses = 1); 42 | 43 | // easy API 44 | void updateShadowMap(ofNode & light, glm::vec3 origin = {0,0,0}, float softness = 0.3, 45 | float fustrumSize = 10, float nearClip = 0.01, float farClip = 100); 46 | 47 | void updateCachedShadowMap(ofNode & light, int sampleCount, glm::vec3 origin = {0,0,0}, float softness = 0.3, 48 | float fustrumSize = 10, float nearClip = 0.01, float farClip = 100); 49 | 50 | void bake(ofMesh& mesh, ofFbo& fbo, ofNode& node, int sampleCount); 51 | void bake(ofVboMesh& mesh, ofFbo& fbo, ofNode& node, int sampleCount); 52 | 53 | // shadow mapping 54 | void beginShadowMap(ofNode & light, float fustrumSize = 10, float nearClip = 0.01, float farClip = 100); 55 | void endShadowMap(); 56 | 57 | // light packing 58 | void allocateFBO(ofFbo& fbo, glm::vec2 size = {1024, 1024}); 59 | void beginBake(ofFbo& fbo, int sampleCount, bool usingPackedTriangles = false); 60 | void endBake(ofFbo& fbo); 61 | 62 | // lightmap pack 63 | bool lightmapPack(ofVboMesh& mesh, glm::vec2 size = {1024, 1024}); 64 | 65 | const ofTexture& getDepthTexture(unsigned int index = 0) const { return depthFBO[index]->getDepthTexture(); } 66 | ofTexture& getDepthTexture(unsigned int index = 0) { return depthFBO[index]->getDepthTexture(); } 67 | 68 | void setShadowBias(float bias) { this->shadow_bias = bias; } 69 | 70 | void setContactShadowFactor(float factor) { this->contact_shadow_factor = factor; } 71 | 72 | 73 | private: 74 | enum FBO_TYPE { 75 | FBO_DEPTH, 76 | FBO_LIGHT 77 | }; 78 | 79 | GLuint LM_TEXCOORDS_LOCATION = 9; 80 | 81 | void allocateFBO(ofFbo& fbo, FBO_TYPE type); 82 | 83 | ofFbo::Settings depthFboSettings; 84 | ofFbo::Settings lightFboSettings; 85 | 86 | std::vector> depthFBO; // scene depth 87 | unsigned int passIndex = 0; 88 | unsigned int numPasses = 1; 89 | 90 | ofShader depthShader; // depth test 91 | ofShader lightmapShader; // shadow mapping 92 | 93 | std::vector random_cache; 94 | 95 | // conservative rasterization. 96 | float geometry_dilation = 2; 97 | 98 | float contact_shadow_factor = 0.02; 99 | 100 | float shadow_bias = 0.003f; 101 | glm::mat4 bias = glm::mat4( 102 | 0.5, 0.0, 0.0, 0.0, 103 | 0.0, 0.5, 0.0, 0.0, 104 | 0.0, 0.0, 0.5, 0.0, 105 | 0.5, 0.5, 0.5, 1.0); 106 | 107 | std::vector lastBiasedMatrix; 108 | std::vector lastLightPos; 109 | 110 | // render scene function 111 | function scene; 112 | 113 | }; 114 | --------------------------------------------------------------------------------