├── LICENSE ├── README.md ├── dep ├── freeglut │ ├── inc │ │ └── GL │ │ │ ├── freeglut.h │ │ │ ├── freeglut_ext.h │ │ │ ├── freeglut_std.h │ │ │ └── glut.h │ └── lib │ │ └── libfreeglut.a ├── glew │ ├── inc │ │ └── GL │ │ │ ├── glew.h │ │ │ ├── glxew.h │ │ │ └── wglew.h │ └── lib │ │ └── libglew.a └── glm │ └── inc │ └── glm │ ├── CMakeLists.txt │ ├── common.hpp │ ├── detail │ ├── _features.hpp │ ├── _fixes.hpp │ ├── _noise.hpp │ ├── _swizzle.hpp │ ├── _swizzle_func.hpp │ ├── _vectorize.hpp │ ├── dummy.cpp │ ├── func_common.hpp │ ├── func_common.inl │ ├── func_exponential.hpp │ ├── func_exponential.inl │ ├── func_geometric.hpp │ ├── func_geometric.inl │ ├── func_integer.hpp │ ├── func_integer.inl │ ├── func_matrix.hpp │ ├── func_matrix.inl │ ├── func_packing.hpp │ ├── func_packing.inl │ ├── func_trigonometric.hpp │ ├── func_trigonometric.inl │ ├── func_vector_relational.hpp │ ├── func_vector_relational.inl │ ├── glm.cpp │ ├── intrinsic_common.hpp │ ├── intrinsic_common.inl │ ├── intrinsic_exponential.hpp │ ├── intrinsic_exponential.inl │ ├── intrinsic_geometric.hpp │ ├── intrinsic_geometric.inl │ ├── intrinsic_integer.hpp │ ├── intrinsic_integer.inl │ ├── intrinsic_matrix.hpp │ ├── intrinsic_matrix.inl │ ├── intrinsic_trigonometric.hpp │ ├── intrinsic_trigonometric.inl │ ├── intrinsic_vector_relational.hpp │ ├── intrinsic_vector_relational.inl │ ├── precision.hpp │ ├── setup.hpp │ ├── type_float.hpp │ ├── type_gentype.hpp │ ├── type_gentype.inl │ ├── type_half.hpp │ ├── type_half.inl │ ├── type_int.hpp │ ├── type_mat.hpp │ ├── type_mat.inl │ ├── type_mat2x2.hpp │ ├── type_mat2x2.inl │ ├── type_mat2x3.hpp │ ├── type_mat2x3.inl │ ├── type_mat2x4.hpp │ ├── type_mat2x4.inl │ ├── type_mat3x2.hpp │ ├── type_mat3x2.inl │ ├── type_mat3x3.hpp │ ├── type_mat3x3.inl │ ├── type_mat3x4.hpp │ ├── type_mat3x4.inl │ ├── type_mat4x2.hpp │ ├── type_mat4x2.inl │ ├── type_mat4x3.hpp │ ├── type_mat4x3.inl │ ├── type_mat4x4.hpp │ ├── type_mat4x4.inl │ ├── type_vec.hpp │ ├── type_vec.inl │ ├── type_vec1.hpp │ ├── type_vec1.inl │ ├── type_vec2.hpp │ ├── type_vec2.inl │ ├── type_vec3.hpp │ ├── type_vec3.inl │ ├── type_vec4.hpp │ ├── type_vec4.inl │ ├── type_vec4_avx.inl │ ├── type_vec4_avx2.inl │ └── type_vec4_sse2.inl │ ├── exponential.hpp │ ├── ext.hpp │ ├── fwd.hpp │ ├── geometric.hpp │ ├── glm.hpp │ ├── gtc │ ├── bitfield.hpp │ ├── bitfield.inl │ ├── color_space.hpp │ ├── color_space.inl │ ├── constants.hpp │ ├── constants.inl │ ├── epsilon.hpp │ ├── epsilon.inl │ ├── integer.hpp │ ├── integer.inl │ ├── matrix_access.hpp │ ├── matrix_access.inl │ ├── matrix_integer.hpp │ ├── matrix_inverse.hpp │ ├── matrix_inverse.inl │ ├── matrix_transform.hpp │ ├── matrix_transform.inl │ ├── noise.hpp │ ├── noise.inl │ ├── packing.hpp │ ├── packing.inl │ ├── quaternion.hpp │ ├── quaternion.inl │ ├── random.hpp │ ├── random.inl │ ├── reciprocal.hpp │ ├── reciprocal.inl │ ├── round.hpp │ ├── round.inl │ ├── type_precision.hpp │ ├── type_precision.inl │ ├── type_ptr.hpp │ ├── type_ptr.inl │ ├── ulp.hpp │ ├── ulp.inl │ ├── vec1.hpp │ └── vec1.inl │ ├── gtx │ ├── associated_min_max.hpp │ ├── associated_min_max.inl │ ├── bit.hpp │ ├── bit.inl │ ├── closest_point.hpp │ ├── closest_point.inl │ ├── color_space.hpp │ ├── color_space.inl │ ├── color_space_YCoCg.hpp │ ├── color_space_YCoCg.inl │ ├── common.hpp │ ├── common.inl │ ├── compatibility.hpp │ ├── compatibility.inl │ ├── component_wise.hpp │ ├── component_wise.inl │ ├── dual_quaternion.hpp │ ├── dual_quaternion.inl │ ├── euler_angles.hpp │ ├── euler_angles.inl │ ├── extend.hpp │ ├── extend.inl │ ├── extented_min_max.hpp │ ├── extented_min_max.inl │ ├── fast_exponential.hpp │ ├── fast_exponential.inl │ ├── fast_square_root.hpp │ ├── fast_square_root.inl │ ├── fast_trigonometry.hpp │ ├── fast_trigonometry.inl │ ├── gradient_paint.hpp │ ├── gradient_paint.inl │ ├── handed_coordinate_space.hpp │ ├── handed_coordinate_space.inl │ ├── hash.hpp │ ├── hash.inl │ ├── integer.hpp │ ├── integer.inl │ ├── intersect.hpp │ ├── intersect.inl │ ├── io.hpp │ ├── io.inl │ ├── log_base.hpp │ ├── log_base.inl │ ├── matrix_cross_product.hpp │ ├── matrix_cross_product.inl │ ├── matrix_decompose.hpp │ ├── matrix_decompose.inl │ ├── matrix_interpolation.hpp │ ├── matrix_interpolation.inl │ ├── matrix_major_storage.hpp │ ├── matrix_major_storage.inl │ ├── matrix_operation.hpp │ ├── matrix_operation.inl │ ├── matrix_query.hpp │ ├── matrix_query.inl │ ├── matrix_transform_2d.hpp │ ├── matrix_transform_2d.inl │ ├── mixed_product.hpp │ ├── mixed_product.inl │ ├── norm.hpp │ ├── norm.inl │ ├── normal.hpp │ ├── normal.inl │ ├── normalize_dot.hpp │ ├── normalize_dot.inl │ ├── number_precision.hpp │ ├── number_precision.inl │ ├── optimum_pow.hpp │ ├── optimum_pow.inl │ ├── orthonormalize.hpp │ ├── orthonormalize.inl │ ├── perpendicular.hpp │ ├── perpendicular.inl │ ├── polar_coordinates.hpp │ ├── polar_coordinates.inl │ ├── projection.hpp │ ├── projection.inl │ ├── quaternion.hpp │ ├── quaternion.inl │ ├── range.hpp │ ├── raw_data.hpp │ ├── raw_data.inl │ ├── rotate_normalized_axis.hpp │ ├── rotate_normalized_axis.inl │ ├── rotate_vector.hpp │ ├── rotate_vector.inl │ ├── scalar_multiplication.hpp │ ├── scalar_relational.hpp │ ├── scalar_relational.inl │ ├── simd_mat4.hpp │ ├── simd_mat4.inl │ ├── simd_quat.hpp │ ├── simd_quat.inl │ ├── simd_vec4.hpp │ ├── simd_vec4.inl │ ├── spline.hpp │ ├── spline.inl │ ├── std_based_type.hpp │ ├── std_based_type.inl │ ├── string_cast.hpp │ ├── string_cast.inl │ ├── transform.hpp │ ├── transform.inl │ ├── transform2.hpp │ ├── transform2.inl │ ├── type_aligned.hpp │ ├── type_aligned.inl │ ├── vector_angle.hpp │ ├── vector_angle.inl │ ├── vector_query.hpp │ ├── vector_query.inl │ ├── wrap.hpp │ └── wrap.inl │ ├── integer.hpp │ ├── mat2x2.hpp │ ├── mat2x3.hpp │ ├── mat2x4.hpp │ ├── mat3x2.hpp │ ├── mat3x3.hpp │ ├── mat3x4.hpp │ ├── mat4x2.hpp │ ├── mat4x3.hpp │ ├── mat4x4.hpp │ ├── matrix.hpp │ ├── packing.hpp │ ├── simd │ └── platform.h │ ├── trigonometric.hpp │ ├── vec2.hpp │ ├── vec3.hpp │ ├── vec4.hpp │ └── vector_relational.hpp ├── student ├── AABB.h ├── BoxMesh.h ├── Camera.h ├── FPS.h ├── Framebuffer.h ├── Light.h ├── ModernOpenGL.pro ├── Random.h ├── Scene0Framebuffer.h ├── Scene10ManyGeometriesMultiDrawIndirect.frag ├── Scene10ManyGeometriesMultiDrawIndirect.h ├── Scene10ManyGeometriesMultiDrawIndirect.vert ├── Scene11CADModel.frag ├── Scene11CADModel.h ├── Scene11CADModel.vert ├── Scene12CADModelFrustumCullingCPU.frag ├── Scene12CADModelFrustumCullingCPU.h ├── Scene12CADModelFrustumCullingCPU.vert ├── Scene13CADModelFrustumCullingGPU.comp ├── Scene13CADModelFrustumCullingGPU.frag ├── Scene13CADModelFrustumCullingGPU.h ├── Scene13CADModelFrustumCullingGPU.vert ├── Scene1CubeNoLighting.frag ├── Scene1CubeNoLighting.h ├── Scene1CubeNoLighting.vert ├── Scene2CubeVertexLighting.frag ├── Scene2CubeVertexLighting.h ├── Scene2CubeVertexLighting.vert ├── Scene3CubeFragLighting.frag ├── Scene3CubeFragLighting.h ├── Scene3CubeFragLighting.vert ├── Scene4CubeTexture.frag ├── Scene4CubeTexture.h ├── Scene4CubeTexture.vert ├── Scene5ManyCubesIndividual.frag ├── Scene5ManyCubesIndividual.h ├── Scene5ManyCubesIndividual.vert ├── Scene6ManyCubesInstancing.frag ├── Scene6ManyCubesInstancing.h ├── Scene6ManyCubesInstancing.vert ├── Scene6bManyCubesInstancing.frag ├── Scene6bManyCubesInstancing.h ├── Scene6bManyCubesInstancing.vert ├── Scene7ManyCubesIndividualTexture.frag ├── Scene7ManyCubesIndividualTexture.h ├── Scene7ManyCubesIndividualTexture.vert ├── Scene8ManyCubesInstancingTexture.frag ├── Scene8ManyCubesInstancingTexture.h ├── Scene8ManyCubesInstancingTexture.vert ├── Scene9ManyGeometriesIndividual.frag ├── Scene9ManyGeometriesIndividual.h ├── Scene9ManyGeometriesIndividual.vert ├── ShaderData.h ├── ShaderLoader.h ├── Timer.h ├── main.cpp └── tess │ ├── geometries.h │ ├── glutess │ ├── dict-list.h │ ├── dict.c │ ├── dict.h │ ├── geom.c │ ├── geom.h │ ├── glutess_facade.h │ ├── memalloc.c │ ├── memalloc.h │ ├── mesh.c │ ├── mesh.h │ ├── normal.c │ ├── normal.h │ ├── priorityq-heap.c │ ├── priorityq-heap.h │ ├── priorityq-sort.h │ ├── priorityq.c │ ├── priorityq.h │ ├── render.c │ ├── render.h │ ├── sweep.c │ ├── sweep.h │ ├── tess.c │ ├── tess.h │ ├── tessmono.c │ └── tessmono.h │ ├── mesh_builder.cpp │ ├── mesh_builder.h │ ├── mesh_optimizer.cpp │ ├── mesh_optimizer.h │ ├── polygon_tessellator.cpp │ ├── polygon_tessellator.h │ ├── tessellator.cpp │ ├── tessellator.h │ ├── triangle_mesh.cpp │ └── triangle_mesh.h └── teacher ├── AABB.h ├── BoxMesh.h ├── Camera.h ├── FPS.h ├── Framebuffer.h ├── FrustumCuller.cpp ├── FrustumCuller.h ├── Light.h ├── ModernOpenGL.pro ├── Random.h ├── Scene0Framebuffer.h ├── Scene10ManyGeometriesMultiDrawIndirect.frag ├── Scene10ManyGeometriesMultiDrawIndirect.h ├── Scene10ManyGeometriesMultiDrawIndirect.vert ├── Scene11CADModel.frag ├── Scene11CADModel.h ├── Scene11CADModel.vert ├── Scene12CADModelFrustumCullingCPU.frag ├── Scene12CADModelFrustumCullingCPU.h ├── Scene12CADModelFrustumCullingCPU.vert ├── Scene13CADModelFrustumCullingGPU.comp ├── Scene13CADModelFrustumCullingGPU.frag ├── Scene13CADModelFrustumCullingGPU.h ├── Scene13CADModelFrustumCullingGPU.vert ├── Scene1CubeNoLighting.frag ├── Scene1CubeNoLighting.h ├── Scene1CubeNoLighting.vert ├── Scene2CubeVertexLighting.frag ├── Scene2CubeVertexLighting.h ├── Scene2CubeVertexLighting.vert ├── Scene3CubeFragLighting.frag ├── Scene3CubeFragLighting.h ├── Scene3CubeFragLighting.vert ├── Scene4CubeTexture.frag ├── Scene4CubeTexture.h ├── Scene4CubeTexture.vert ├── Scene5ManyCubesIndividual.frag ├── Scene5ManyCubesIndividual.h ├── Scene5ManyCubesIndividual.vert ├── Scene6ManyCubesInstancing.frag ├── Scene6ManyCubesInstancing.h ├── Scene6ManyCubesInstancing.vert ├── Scene6bManyCubesInstancing.frag ├── Scene6bManyCubesInstancing.h ├── Scene6bManyCubesInstancing.vert ├── Scene7ManyCubesIndividualTexture.frag ├── Scene7ManyCubesIndividualTexture.h ├── Scene7ManyCubesIndividualTexture.vert ├── Scene8ManyCubesInstancingTexture.frag ├── Scene8ManyCubesInstancingTexture.h ├── Scene8ManyCubesInstancingTexture.vert ├── Scene9ManyGeometriesIndividual.frag ├── Scene9ManyGeometriesIndividual.h ├── Scene9ManyGeometriesIndividual.vert ├── ShaderData.h ├── ShaderLoader.h ├── Timer.h ├── main.cpp └── tess ├── geometries.h ├── glutess ├── dict-list.h ├── dict.c ├── dict.h ├── geom.c ├── geom.h ├── glutess_facade.h ├── memalloc.c ├── memalloc.h ├── mesh.c ├── mesh.h ├── normal.c ├── normal.h ├── priorityq-heap.c ├── priorityq-heap.h ├── priorityq-sort.h ├── priorityq.c ├── priorityq.h ├── render.c ├── render.h ├── sweep.c ├── sweep.h ├── tess.c ├── tess.h ├── tessmono.c └── tessmono.h ├── mesh_builder.cpp ├── mesh_builder.h ├── mesh_optimizer.cpp ├── mesh_optimizer.h ├── polygon_tessellator.cpp ├── polygon_tessellator.h ├── tessellator.cpp ├── tessellator.h ├── triangle_mesh.cpp └── triangle_mesh.h /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 potato3d 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # modern-opengl 2 | Modern OpenGL 4.5 rendering techniques 3 | 4 | Demonstrates several OpenGL concepts using modern API: direct state access (DSA), frame buffer objects (FBO), shader storage buffer objects (SSBO), texture sampler objects (TSO), uniform buffer objects (UBO), geometry instancing, indirect drawing, bindless textures, multidrawelementsindirect, compute shaders, CPU/GPU synchronization with fences, approaching zero driver overhead (AZDO), etc. 5 | 6 | The code was meant to be used as a hands-on training material. The teacher directory contains the full implementation, while the student directory has // TODO comments where new code must be inserted to complete each example scene. 7 | 8 | # Description 9 | 10 | * Scene 0: framebuffer and textures 11 | * Scene 1: vertex specification, vertex and fragment shaders, drawing commands 12 | * Scene 2: per-vertex lighting 13 | * Scene 3: per-fragment lighting 14 | * Scene 4: 2D texturing 15 | * Scene 5: individually draw many instances of same geometry 16 | * Scene 6: geometry instancing to improve performance when drawing many instances of same geometrry 17 | * Scene 6b: same as scene 6, but using a per-instance vertex attribute 18 | * Scene 7: individually draw many instances with texture 19 | * Scene 8: use bindless textures with geometry instances to improve performance 20 | * Scene 9: individually draw many instances of different geometries 21 | * Scene 10: multi draw indirect 22 | * Scene 11: multi draw indirect applied to a 3D CAD model 23 | * Scene 12: frustum culling on the CPU using explicit synchronization 24 | * Scene 13: frustum culling on the GPU using compute shaders 25 | -------------------------------------------------------------------------------- /dep/freeglut/inc/GL/freeglut.h: -------------------------------------------------------------------------------- 1 | #ifndef __FREEGLUT_H__ 2 | #define __FREEGLUT_H__ 3 | 4 | /* 5 | * freeglut.h 6 | * 7 | * The freeglut library include file 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 10 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 12 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | */ 16 | 17 | #include "freeglut_std.h" 18 | #include "freeglut_ext.h" 19 | 20 | /*** END OF FILE ***/ 21 | 22 | #endif /* __FREEGLUT_H__ */ 23 | -------------------------------------------------------------------------------- /dep/freeglut/inc/GL/glut.h: -------------------------------------------------------------------------------- 1 | #ifndef __GLUT_H__ 2 | #define __GLUT_H__ 3 | 4 | /* 5 | * glut.h 6 | * 7 | * The freeglut library include file 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 10 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 12 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | */ 16 | 17 | #include "freeglut_std.h" 18 | 19 | /*** END OF FILE ***/ 20 | 21 | #endif /* __GLUT_H__ */ 22 | -------------------------------------------------------------------------------- /dep/freeglut/lib/libfreeglut.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/potato3d/modern-opengl/3d3af217f9b81c4e6a157dc3be489cf639996a15/dep/freeglut/lib/libfreeglut.a -------------------------------------------------------------------------------- /dep/glew/lib/libglew.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/potato3d/modern-opengl/3d3af217f9b81c4e6a157dc3be489cf639996a15/dep/glew/lib/libglew.a -------------------------------------------------------------------------------- /dep/glm/inc/glm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(NAME glm_dummy) 2 | 3 | file(GLOB ROOT_SOURCE *.cpp) 4 | file(GLOB ROOT_INLINE *.inl) 5 | file(GLOB ROOT_HEADER *.hpp) 6 | file(GLOB ROOT_TEXT ../*.txt) 7 | file(GLOB ROOT_MD ../*.md) 8 | file(GLOB ROOT_NAT ../util/glm.natvis) 9 | 10 | file(GLOB_RECURSE CORE_SOURCE ./detail/*.cpp) 11 | file(GLOB_RECURSE CORE_INLINE ./detail/*.inl) 12 | file(GLOB_RECURSE CORE_HEADER ./detail/*.hpp) 13 | 14 | file(GLOB_RECURSE GTC_SOURCE ./gtc/*.cpp) 15 | file(GLOB_RECURSE GTC_INLINE ./gtc/*.inl) 16 | file(GLOB_RECURSE GTC_HEADER ./gtc/*.hpp) 17 | 18 | file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp) 19 | file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl) 20 | file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp) 21 | 22 | source_group("Text Files" FILES ${ROOT_TEXT} ${ROOT_MD}) 23 | source_group("Core Files" FILES ${CORE_SOURCE}) 24 | source_group("Core Files" FILES ${CORE_INLINE}) 25 | source_group("Core Files" FILES ${CORE_HEADER}) 26 | source_group("GTC Files" FILES ${GTC_SOURCE}) 27 | source_group("GTC Files" FILES ${GTC_INLINE}) 28 | source_group("GTC Files" FILES ${GTC_HEADER}) 29 | source_group("GTX Files" FILES ${GTX_SOURCE}) 30 | source_group("GTX Files" FILES ${GTX_INLINE}) 31 | source_group("GTX Files" FILES ${GTX_HEADER}) 32 | 33 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) 34 | 35 | if(GLM_TEST_ENABLE) 36 | add_executable(${NAME} ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT} 37 | ${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER} 38 | ${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER} 39 | ${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER} 40 | ${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}) 41 | endif(GLM_TEST_ENABLE) 42 | 43 | #add_library(glm STATIC glm.cpp) 44 | #add_library(glm_shared SHARED glm.cpp) 45 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/common.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/common.hpp 29 | /// @date 2013-12-24 / 2013-12-24 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | #pragma once 34 | 35 | #include "detail/func_common.hpp" 36 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/detail/_fixes.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/detail/_fixes.hpp 29 | /// @date 2011-02-21 / 2011-11-22 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | #include 34 | 35 | //! Workaround for compatibility with other libraries 36 | #ifdef max 37 | #undef max 38 | #endif 39 | 40 | //! Workaround for compatibility with other libraries 41 | #ifdef min 42 | #undef min 43 | #endif 44 | 45 | //! Workaround for Android 46 | #ifdef isnan 47 | #undef isnan 48 | #endif 49 | 50 | //! Workaround for Android 51 | #ifdef isinf 52 | #undef isinf 53 | #endif 54 | 55 | //! Workaround for Chrone Native Client 56 | #ifdef log2 57 | #undef log2 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/detail/intrinsic_exponential.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/detail/intrinsic_exponential.inl 25 | /// @date 2011-06-15 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/detail/intrinsic_integer.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/detail/intrinsic_integer.hpp 25 | /// @date 2009-05-11 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #pragma once 30 | 31 | #include "glm/glm.hpp" 32 | 33 | #if(!(GLM_ARCH & GLM_ARCH_SSE2)) 34 | # error "SSE2 instructions not supported or enabled" 35 | #else 36 | 37 | namespace glm{ 38 | namespace detail 39 | { 40 | __m128i _mm_bit_interleave_si128(__m128i x); 41 | __m128i _mm_bit_interleave_si128(__m128i x, __m128i y); 42 | 43 | }//namespace detail 44 | }//namespace glm 45 | 46 | #include "intrinsic_integer.inl" 47 | 48 | #endif//GLM_ARCH 49 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/detail/intrinsic_trigonometric.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/detail/intrinsic_trigonometric.hpp 25 | /// @date 2009-06-09 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #pragma once 30 | 31 | #include "setup.hpp" 32 | 33 | #if(!(GLM_ARCH & GLM_ARCH_SSE2)) 34 | # error "SSE2 instructions not supported or enabled" 35 | #else 36 | 37 | namespace glm{ 38 | namespace detail 39 | { 40 | 41 | }//namespace detail 42 | }//namespace glm 43 | 44 | #include "intrinsic_trigonometric.inl" 45 | 46 | #endif//GLM_ARCH 47 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/detail/intrinsic_trigonometric.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/detail/intrinsic_trigonometric.inl 25 | /// @date 2011-06-15 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/detail/intrinsic_vector_relational.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/detail/intrinsic_vector_relational.hpp 25 | /// @date 2009-06-09 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #pragma once 30 | 31 | #include "setup.hpp" 32 | 33 | #if(!(GLM_ARCH & GLM_ARCH_SSE2)) 34 | # error "SSE2 instructions not supported or enabled" 35 | #else 36 | 37 | namespace glm{ 38 | namespace detail 39 | { 40 | 41 | }//namespace detail 42 | }//namespace glm 43 | 44 | #include "intrinsic_vector_relational.inl" 45 | 46 | #endif//GLM_ARCH 47 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/detail/precision.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/detail/precision.hpp 29 | /// @date 2013-04-01 / 2013-04-01 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | #pragma once 34 | 35 | namespace glm 36 | { 37 | enum precision 38 | { 39 | highp, 40 | mediump, 41 | lowp, 42 | simd, 43 | defaultp = highp 44 | }; 45 | }//namespace glm 46 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/detail/type_half.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/detail/type_half.hpp 29 | /// @date 2008-08-17 / 2011-09-20 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | #pragma once 34 | 35 | #include "setup.hpp" 36 | 37 | namespace glm{ 38 | namespace detail 39 | { 40 | typedef short hdata; 41 | 42 | GLM_FUNC_DECL float toFloat32(hdata value); 43 | GLM_FUNC_DECL hdata toFloat16(float const & value); 44 | 45 | }//namespace detail 46 | }//namespace glm 47 | 48 | #include "type_half.inl" 49 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/detail/type_mat.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/detail/type_mat.inl 29 | /// @date 2011-06-15 / 2011-06-15 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/detail/type_vec.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/detail/type_vec.inl 29 | /// @date 2011-06-15 / 2011-06-15 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/detail/type_vec4_avx.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/detail/type_tvec4_avx.inl 29 | /// @date 2014-12-01 / 2014-12-01 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | namespace glm{ 34 | namespace detail 35 | { 36 | 37 | }//namespace detail 38 | 39 | 40 | 41 | }//namespace glm 42 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/detail/type_vec4_avx2.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/detail/type_tvec4_avx2.inl 29 | /// @date 2014-12-01 / 2014-12-01 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | namespace glm{ 34 | namespace detail 35 | { 36 | 37 | }//namespace detail 38 | 39 | 40 | 41 | }//namespace glm 42 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/exponential.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/exponential.hpp 29 | /// @date 2013-12-24 / 2013-12-24 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | #pragma once 34 | 35 | #include "detail/func_exponential.hpp" 36 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/geometric.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/geometric.hpp 29 | /// @date 2013-12-24 / 2013-12-24 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | #pragma once 34 | 35 | #include "detail/func_geometric.hpp" 36 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/gtc/type_precision.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtc_swizzle 28 | /// @file glm/gtc/swizzle.inl 29 | /// @date 2009-06-14 / 2011-06-15 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | namespace glm 34 | { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/gtc/vec1.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtc_vec1 28 | /// @file glm/gtc/vec1.inl 29 | /// @date 2013-03-16 / 2013-03-16 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/gtx/handed_coordinate_space.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtx_handed_coordinate_space 28 | /// @file glm/gtx/handed_coordinate_space.inl 29 | /// @date 2005-12-21 / 2009-02-19 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////////////////////// 32 | 33 | namespace glm 34 | { 35 | template 36 | GLM_FUNC_QUALIFIER bool rightHanded 37 | ( 38 | tvec3 const & tangent, 39 | tvec3 const & binormal, 40 | tvec3 const & normal 41 | ) 42 | { 43 | return dot(cross(normal, tangent), binormal) > T(0); 44 | } 45 | 46 | template 47 | GLM_FUNC_QUALIFIER bool leftHanded 48 | ( 49 | tvec3 const & tangent, 50 | tvec3 const & binormal, 51 | tvec3 const & normal 52 | ) 53 | { 54 | return dot(cross(normal, tangent), binormal) < T(0); 55 | } 56 | }//namespace glm 57 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/gtx/log_base.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtx_log_base 28 | /// @file glm/gtx/log_base.inl 29 | /// @date 2008-10-24 / 2014-11-25 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | namespace glm 34 | { 35 | template 36 | GLM_FUNC_QUALIFIER genType log(genType const & x, genType const & base) 37 | { 38 | assert(x != genType(0)); 39 | return glm::log(x) / glm::log(base); 40 | } 41 | 42 | template class vecType> 43 | GLM_FUNC_QUALIFIER vecType log(vecType const & x, vecType const & base) 44 | { 45 | return glm::log(x) / glm::log(base); 46 | } 47 | }//namespace glm 48 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/gtx/mixed_product.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtx_mixed_product 28 | /// @file glm/gtx/mixed_product.inl 29 | /// @date 2007-04-03 / 2008-09-17 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | namespace glm 34 | { 35 | template 36 | GLM_FUNC_QUALIFIER T mixedProduct 37 | ( 38 | tvec3 const & v1, 39 | tvec3 const & v2, 40 | tvec3 const & v3 41 | ) 42 | { 43 | return dot(cross(v1, v2), v3); 44 | } 45 | }//namespace glm 46 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/gtx/normal.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtx_normal 28 | /// @file glm/gtx/normal.inl 29 | /// @date 2005-12-21 / 2011-06-07 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | namespace glm 34 | { 35 | template 36 | GLM_FUNC_QUALIFIER tvec3 triangleNormal 37 | ( 38 | tvec3 const & p1, 39 | tvec3 const & p2, 40 | tvec3 const & p3 41 | ) 42 | { 43 | return normalize(cross(p1 - p2, p1 - p3)); 44 | } 45 | }//namespace glm 46 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/gtx/normalize_dot.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtx_normalize_dot 28 | /// @file glm/gtx/normalize_dot.inl 29 | /// @date 2007-09-28 / 2008-10-07 30 | /// @author Christophe Riccio 31 | ////////////////////////////////////////////////////////////////////////////////// 32 | 33 | namespace glm 34 | { 35 | template class vecType> 36 | GLM_FUNC_QUALIFIER T normalizeDot(vecType const & x, vecType const & y) 37 | { 38 | return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y)); 39 | } 40 | 41 | template class vecType> 42 | GLM_FUNC_QUALIFIER T fastNormalizeDot(vecType const & x, vecType const & y) 43 | { 44 | return glm::dot(x, y) * glm::fastInverseSqrt(glm::dot(x, x) * glm::dot(y, y)); 45 | } 46 | }//namespace glm 47 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/gtx/number_precision.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtx_number_precision 28 | /// @file glm/gtx/number_precision.inl 29 | /// @date 2007-05-10 / 2011-06-07 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | namespace glm 34 | { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/gtx/optimum_pow.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtx_optimum_pow 28 | /// @file glm/gtx/optimum_pow.inl 29 | /// @date 2005-12-21 / 2011-06-07 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | namespace glm 34 | { 35 | template 36 | GLM_FUNC_QUALIFIER genType pow2(genType const & x) 37 | { 38 | return x * x; 39 | } 40 | 41 | template 42 | GLM_FUNC_QUALIFIER genType pow3(genType const & x) 43 | { 44 | return x * x * x; 45 | } 46 | 47 | template 48 | GLM_FUNC_QUALIFIER genType pow4(genType const & x) 49 | { 50 | return (x * x) * (x * x); 51 | } 52 | }//namespace glm 53 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/gtx/perpendicular.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtx_perpendicular 28 | /// @file glm/gtx/perpendicular.inl 29 | /// @date 2005-12-21 / 2011-06-07 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | namespace glm 34 | { 35 | template 36 | GLM_FUNC_QUALIFIER vecType perp 37 | ( 38 | vecType const & x, 39 | vecType const & Normal 40 | ) 41 | { 42 | return x - proj(x, Normal); 43 | } 44 | }//namespace glm 45 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/gtx/projection.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtx_projection 28 | /// @file glm/gtx/projection.inl 29 | /// @date 2005-12-21 / 2011-06-07 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | namespace glm 34 | { 35 | template 36 | GLM_FUNC_QUALIFIER vecType proj(vecType const & x, vecType const & Normal) 37 | { 38 | return glm::dot(x, Normal) / glm::dot(Normal, Normal) * Normal; 39 | } 40 | }//namespace glm 41 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/gtx/raw_data.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtx_raw_data 28 | /// @file glm/gtx/raw_data.inl 29 | /// @date 2008-11-19 / 2011-06-07 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/gtx/std_based_type.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtx_std_based_type 28 | /// @file glm/gtx/std_based_type.inl 29 | /// @date 2008-06-08 / 2011-06-07 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | namespace glm 34 | { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/gtx/transform.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtx_transform 28 | /// @file glm/gtx/transform.inl 29 | /// @date 2005-12-21 / 2011-06-07 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | namespace glm 34 | { 35 | template 36 | GLM_FUNC_QUALIFIER tmat4x4 translate( 37 | tvec3 const & v) 38 | { 39 | return translate( 40 | tmat4x4(1.0f), v); 41 | } 42 | 43 | template 44 | GLM_FUNC_QUALIFIER tmat4x4 rotate( 45 | T angle, 46 | tvec3 const & v) 47 | { 48 | return rotate( 49 | tmat4x4(1), angle, v); 50 | } 51 | 52 | template 53 | GLM_FUNC_QUALIFIER tmat4x4 scale( 54 | tvec3 const & v) 55 | { 56 | return scale( 57 | tmat4x4(1.0f), v); 58 | } 59 | 60 | }//namespace glm 61 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/gtx/type_aligned.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtc_type_aligned 28 | /// @file glm/gtc/type_aligned.inl 29 | /// @date 2014-11-23 / 2014-11-23 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | namespace glm 34 | { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/integer.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/integer.hpp 29 | /// @date 2013-12-24 / 2013-12-24 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | #pragma once 34 | 35 | #include "detail/func_integer.hpp" 36 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/matrix.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/matrix.hpp 29 | /// @date 2013-12-24 / 2013-12-24 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | #pragma once 34 | 35 | #include "detail/func_matrix.hpp" 36 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/packing.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/packing.hpp 29 | /// @date 2013-12-24 / 2013-12-24 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | #pragma once 34 | 35 | #include "detail/func_packing.hpp" 36 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/trigonometric.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/trigonometric.hpp 29 | /// @date 2013-12-24 / 2013-12-24 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | #pragma once 34 | 35 | #include "detail/func_trigonometric.hpp" 36 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/vec2.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/vec2.hpp 29 | /// @date 2013-12-24 / 2013-12-24 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | #pragma once 34 | 35 | #include "detail/type_vec2.hpp" 36 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/vec3.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/vec3.hpp 29 | /// @date 2013-12-24 / 2013-12-24 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | #pragma once 34 | 35 | #include "detail/type_vec3.hpp" 36 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/vec4.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/vec4.hpp 29 | /// @date 2013-12-24 / 2013-12-24 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | #pragma once 34 | 35 | #include "detail/type_vec4.hpp" 36 | -------------------------------------------------------------------------------- /dep/glm/inc/glm/vector_relational.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/vector_relational.hpp 29 | /// @date 2013-12-24 / 2013-12-24 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | #pragma once 34 | 35 | #include "detail/func_vector_relational.hpp" 36 | -------------------------------------------------------------------------------- /student/AABB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | struct AABB 5 | { 6 | glm::vec3 min; 7 | glm::vec3 max; 8 | 9 | AABB() 10 | { 11 | min = glm::vec3( std::numeric_limits::max()); 12 | max = glm::vec3(-std::numeric_limits::max()); 13 | } 14 | 15 | void expand(const glm::vec3& point) 16 | { 17 | min = glm::min(min, point); 18 | max = glm::max(max, point); 19 | } 20 | 21 | bool valid() const 22 | { 23 | return min.x <= max.x && min.y <= max.y && min.z <= max.z; 24 | } 25 | 26 | const glm::vec3& operator[](unsigned int i) const 27 | { 28 | return *(&min + i); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /student/FPS.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class FPS 5 | { 6 | public: 7 | FPS() 8 | { 9 | _updateIntervalSec = 0.5f; 10 | _numFrames = 0; 11 | _prevMS = 0; 12 | } 13 | 14 | bool update(float& fps) 15 | { 16 | int currMS = glutGet(GLUT_ELAPSED_TIME); 17 | float elapsedSec = (currMS - _prevMS) * 1e-3f; 18 | ++_numFrames; 19 | 20 | if(elapsedSec < _updateIntervalSec) 21 | { 22 | return false; 23 | } 24 | else 25 | { 26 | fps = (float)_numFrames / elapsedSec; 27 | _numFrames = 0; 28 | _prevMS = currMS; 29 | return true; 30 | } 31 | } 32 | 33 | private: 34 | float _updateIntervalSec; 35 | unsigned int _numFrames; 36 | int _prevMS; 37 | }; 38 | -------------------------------------------------------------------------------- /student/Framebuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class Framebuffer 6 | { 7 | public: 8 | Framebuffer(int width, int height) 9 | { 10 | _width = width; 11 | _height = height; 12 | _fbo = 0; 13 | _colorTex = 0; 14 | _depthTex = 0; 15 | } 16 | 17 | int getWidth() const 18 | { 19 | return _width; 20 | } 21 | 22 | int getHeight() const 23 | { 24 | return _height; 25 | } 26 | 27 | bool initialize() 28 | { 29 | // ------------------------------------------------------------------------ 30 | // 1- Create textures to hold pixel data 31 | // ------------------------------------------------------------------------ 32 | 33 | //scene0: color texture 34 | 35 | //scene1: depth texture 36 | 37 | // ------------------------------------------------------------------------ 38 | // 2- Setup framebuffer object 39 | // ------------------------------------------------------------------------ 40 | 41 | //scene0: create fbo 42 | 43 | //scene0: setup color buffer 44 | 45 | //scene1: setup depth buffer 46 | 47 | //scene0: check fbo status 48 | 49 | return true; 50 | } 51 | 52 | void resize(int width, int height) 53 | { 54 | _width = width; 55 | _height = height; 56 | 57 | // resize framebuffer textures 58 | 59 | //scene0: color texture 60 | 61 | //scene1: depth texture 62 | } 63 | 64 | void clear() 65 | { 66 | // clear framebuffer 67 | 68 | //scene0: clear color 69 | 70 | //scene1: clear depth 71 | } 72 | 73 | void bindToDraw() 74 | { 75 | //scene0: set framebuffer output to correct color attachment 76 | 77 | //scene0: enable drawing to the framebuffer 78 | } 79 | 80 | void copyToDefault() 81 | { 82 | // to display the rendered image on screen, we will read from the framebuffer's output to the default framebuffer 83 | 84 | //scene0: set read buffer 85 | 86 | //scene0: set draw buffer 87 | 88 | //scene0: copy framebuffer contents to default framebuffer 89 | } 90 | 91 | private: 92 | GLsizei _width; 93 | GLsizei _height; 94 | GLuint _fbo; 95 | GLuint _colorTex; 96 | GLuint _depthTex; 97 | }; 98 | -------------------------------------------------------------------------------- /student/Light.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class Light 6 | { 7 | public: 8 | bool initialize() 9 | { 10 | LightData light; 11 | light.ambient = glm::vec4(0.2f, 0.2f, 0.2f, 1.0f); 12 | light.diffuse = glm::vec4(1.0f); 13 | light.specular = glm::vec4(0.5f); 14 | 15 | //scene2: create UBO to store light data inside GPU 16 | 17 | //scene2: associate light UBO to shader binding point 18 | 19 | return true; 20 | } 21 | 22 | private: 23 | LightData _data; 24 | }; 25 | -------------------------------------------------------------------------------- /student/ModernOpenGL.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | CONFIG += console 3 | CONFIG += c++14 4 | CONFIG -= qt 5 | 6 | HEADERS += $$files(*.h) 7 | SOURCES += $$files(*.cpp) 8 | OTHER_FILES += $$files(*.vert) 9 | OTHER_FILES += $$files(*.frag) 10 | OTHER_FILES += $$files(*.comp) 11 | 12 | HEADERS += $$files(rvm/*.h) 13 | SOURCES += $$files(rvm/*.cpp) 14 | 15 | HEADERS += $$files(tess/*.h) 16 | SOURCES += $$files(tess/*.cpp) 17 | SOURCES += $$files(tess/glutess/*.c) 18 | 19 | win32 { 20 | DEFINES += GLEW_STATIC 21 | DEFINES += FREEGLUT_STATIC 22 | INCLUDEPATH += ../dep/freeglut/inc 23 | INCLUDEPATH += ../dep/glew/inc 24 | INCLUDEPATH += ../dep/glm/inc 25 | LIBS += ../dep/glew/lib/libglew.a ../dep/freeglut/lib/libfreeglut.a -lopengl32 -lglu32 -lwinmm -lgdi32 -lpthread 26 | } 27 | unix { 28 | LIBS += -lGL -lGLU -lglut -lGLEW -lX11 -lpthread 29 | } 30 | -------------------------------------------------------------------------------- /student/Random.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | template 6 | std::function make_random(t_value min, t_value max, t_value seed = std::random_device()()) 7 | { 8 | typedef typename std::conditional::value, 9 | std::uniform_int_distribution, 10 | std::uniform_real_distribution>::type dist_type; 11 | 12 | if(!std::is_integral::value) 13 | { 14 | max = std::nextafter(max, std::numeric_limits::max()); 15 | } 16 | 17 | t_engine engine; 18 | engine.seed(seed); 19 | return std::bind(dist_type(min, max), engine); 20 | } 21 | 22 | template 23 | std::function make_random(t_value seed = std::random_device()()) 24 | { 25 | t_value min = 0.0; 26 | t_value max = 1.0; 27 | 28 | if(std::is_integral::value) 29 | { 30 | max = std::numeric_limits::max(); 31 | } 32 | 33 | return make_random(min, max, seed); 34 | } 35 | -------------------------------------------------------------------------------- /student/Scene0Framebuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class Scene 6 | { 7 | public: 8 | bool initialize() 9 | { 10 | return true; 11 | } 12 | 13 | const AABB& getBounds() 14 | { 15 | return _bounds; 16 | } 17 | 18 | void draw(const CameraData& /*cameraData*/) 19 | { 20 | // empty 21 | } 22 | 23 | private: 24 | AABB _bounds; 25 | }; 26 | -------------------------------------------------------------------------------- /student/Scene10ManyGeometriesMultiDrawIndirect.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data[]; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | in Instancing 22 | { 23 | flat int id; 24 | } in_Instancing; 25 | 26 | //------------------------------------------------------------------------------------------------- 27 | // OUTPUTS 28 | //------------------------------------------------------------------------------------------------- 29 | 30 | layout(location = OUT_COLOR) out vec4 out_Color; 31 | 32 | //------------------------------------------------------------------------------------------------- 33 | // MAIN 34 | //------------------------------------------------------------------------------------------------- 35 | 36 | // this code assumes light is at camera position (0,0,0 in eye space) 37 | void main() 38 | { 39 | vec3 diffuse = vec3(0.0f); 40 | vec3 specular = vec3(0.0f); 41 | 42 | const vec3 n = normalize(in_Lighting.eyeNormal); 43 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 44 | 45 | float diffuseIntensity = dot(n,l); 46 | 47 | if(diffuseIntensity > 0.0f) 48 | { 49 | const MaterialData m = sb_Material.data[in_Instancing.id]; 50 | 51 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 52 | 53 | const vec3 r = reflect(-l,n); 54 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 55 | const float specularIntensity = max(dot(r,e), 0.0f); 56 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 57 | } 58 | 59 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 60 | }; 61 | -------------------------------------------------------------------------------- /student/Scene10ManyGeometriesMultiDrawIndirect.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data[]; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | //scene10: draw id attrib 18 | 19 | //------------------------------------------------------------------------------------------------- 20 | // OUTPUTS 21 | //------------------------------------------------------------------------------------------------- 22 | 23 | out Lighting 24 | { 25 | vec3 eyePosition; 26 | vec3 eyeNormal; 27 | } out_Lighting; 28 | 29 | out Instancing 30 | { 31 | flat int id; 32 | } out_Instancing; 33 | 34 | //------------------------------------------------------------------------------------------------- 35 | // MAIN 36 | //------------------------------------------------------------------------------------------------- 37 | 38 | void main() 39 | { 40 | //scene10: get transform data using draw id attribute 41 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 42 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 43 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 44 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 45 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 46 | 47 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 48 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 49 | 50 | //scene10: output draw id to instancing 51 | } 52 | -------------------------------------------------------------------------------- /student/Scene11CADModel.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data[]; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | in Instancing 22 | { 23 | flat int id; 24 | } in_Instancing; 25 | 26 | //------------------------------------------------------------------------------------------------- 27 | // OUTPUTS 28 | //------------------------------------------------------------------------------------------------- 29 | 30 | layout(location = OUT_COLOR) out vec4 out_Color; 31 | 32 | //------------------------------------------------------------------------------------------------- 33 | // MAIN 34 | //------------------------------------------------------------------------------------------------- 35 | 36 | // this code assumes light is at camera position (0,0,0 in eye space) 37 | void main() 38 | { 39 | vec3 diffuse = vec3(0.0f); 40 | vec3 specular = vec3(0.0f); 41 | 42 | const vec3 n = normalize(in_Lighting.eyeNormal); 43 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 44 | 45 | float diffuseIntensity = dot(n,l); 46 | 47 | if(diffuseIntensity > 0.0f) 48 | { 49 | const MaterialData m = sb_Material.data[in_Instancing.id]; 50 | 51 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 52 | 53 | const vec3 r = reflect(-l,n); 54 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 55 | const float specularIntensity = max(dot(r,e), 0.0f); 56 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 57 | } 58 | 59 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 60 | }; 61 | -------------------------------------------------------------------------------- /student/Scene11CADModel.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data[]; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | layout(location = IN_DRAWID) in int in_DrawID; 18 | 19 | //------------------------------------------------------------------------------------------------- 20 | // OUTPUTS 21 | //------------------------------------------------------------------------------------------------- 22 | 23 | out Lighting 24 | { 25 | vec3 eyePosition; 26 | vec3 eyeNormal; 27 | } out_Lighting; 28 | 29 | out Instancing 30 | { 31 | flat int id; 32 | } out_Instancing; 33 | 34 | //------------------------------------------------------------------------------------------------- 35 | // MAIN 36 | //------------------------------------------------------------------------------------------------- 37 | 38 | void main() 39 | { 40 | const TransformData t = sb_Transform.data[in_DrawID]; 41 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 42 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 43 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 44 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 45 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 46 | 47 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 48 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 49 | 50 | out_Instancing.id = in_DrawID; 51 | } 52 | -------------------------------------------------------------------------------- /student/Scene12CADModelFrustumCullingCPU.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data[]; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | in Instancing 22 | { 23 | flat int id; 24 | } in_Instancing; 25 | 26 | //------------------------------------------------------------------------------------------------- 27 | // OUTPUTS 28 | //------------------------------------------------------------------------------------------------- 29 | 30 | layout(location = OUT_COLOR) out vec4 out_Color; 31 | 32 | //------------------------------------------------------------------------------------------------- 33 | // MAIN 34 | //------------------------------------------------------------------------------------------------- 35 | 36 | // this code assumes light is at camera position (0,0,0 in eye space) 37 | void main() 38 | { 39 | vec3 diffuse = vec3(0.0f); 40 | vec3 specular = vec3(0.0f); 41 | 42 | const vec3 n = normalize(in_Lighting.eyeNormal); 43 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 44 | 45 | float diffuseIntensity = dot(n,l); 46 | 47 | if(diffuseIntensity > 0.0f) 48 | { 49 | const MaterialData m = sb_Material.data[in_Instancing.id]; 50 | 51 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 52 | 53 | const vec3 r = reflect(-l,n); 54 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 55 | const float specularIntensity = max(dot(r,e), 0.0f); 56 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 57 | } 58 | 59 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 60 | }; 61 | -------------------------------------------------------------------------------- /student/Scene12CADModelFrustumCullingCPU.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data[]; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | layout(location = IN_DRAWID) in int in_DrawID; 18 | 19 | //------------------------------------------------------------------------------------------------- 20 | // OUTPUTS 21 | //------------------------------------------------------------------------------------------------- 22 | 23 | out Lighting 24 | { 25 | vec3 eyePosition; 26 | vec3 eyeNormal; 27 | } out_Lighting; 28 | 29 | out Instancing 30 | { 31 | flat int id; 32 | } out_Instancing; 33 | 34 | //------------------------------------------------------------------------------------------------- 35 | // MAIN 36 | //------------------------------------------------------------------------------------------------- 37 | 38 | void main() 39 | { 40 | const TransformData t = sb_Transform.data[in_DrawID]; 41 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 42 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 43 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 44 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 45 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 46 | 47 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 48 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 49 | 50 | out_Instancing.id = in_DrawID; 51 | } 52 | -------------------------------------------------------------------------------- /student/Scene13CADModelFrustumCullingGPU.comp: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------------------------- 2 | // GLOBAL 3 | // -------------------------------------------------------------------------------------------------------------- 4 | 5 | //scene13: declare block size 6 | 7 | // -------------------------------------------------------------------------------------------------------------- 8 | // INPUTS 9 | // -------------------------------------------------------------------------------------------------------------- 10 | 11 | //scene13: scene size uniform 12 | 13 | //scene13: frustum ssbo 14 | 15 | //scene13: input draw commands ssbo 16 | 17 | //scene13: drawable bounds 18 | 19 | // -------------------------------------------------------------------------------------------------------------- 20 | // OUTPUTS 21 | // -------------------------------------------------------------------------------------------------------------- 22 | 23 | //scene13: atomic counter 24 | 25 | //scene13: output visible draw commands ssbo 26 | 27 | //------------------------------------------------------------------------------------------------- 28 | // AUX FUNCTIONS 29 | //------------------------------------------------------------------------------------------------- 30 | 31 | bool isCulled(in const Plane p, in const BoundsData b) 32 | { 33 | return dot(vec3(p.nx, p.ny, p.nz), vec3(b.minmax[p.px].x, b.minmax[p.py].y, b.minmax[p.pz].z)) < -p.offset; 34 | } 35 | 36 | //------------------------------------------------------------------------------------------------- 37 | // MAIN 38 | //------------------------------------------------------------------------------------------------- 39 | 40 | void main() 41 | { 42 | uint drawID = gl_GlobalInvocationID.x; 43 | 44 | //scene13: 45 | // skip computation for extra invocations 46 | 47 | // determine if geometry should be drawn 48 | //scene13: get bounds using draw id 49 | 50 | // frustum culling 51 | //scene13: call isCulled for each plane 52 | 53 | // get draw command and write to correct location in output (no collision thanks to atomic counter) 54 | //scene13: increment atomic counter 55 | //scene13: store draw command in output 56 | } 57 | -------------------------------------------------------------------------------- /student/Scene13CADModelFrustumCullingGPU.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data[]; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | in Instancing 22 | { 23 | flat int id; 24 | } in_Instancing; 25 | 26 | //------------------------------------------------------------------------------------------------- 27 | // OUTPUTS 28 | //------------------------------------------------------------------------------------------------- 29 | 30 | layout(location = OUT_COLOR) out vec4 out_Color; 31 | 32 | //------------------------------------------------------------------------------------------------- 33 | // MAIN 34 | //------------------------------------------------------------------------------------------------- 35 | 36 | // this code assumes light is at camera position (0,0,0 in eye space) 37 | void main() 38 | { 39 | vec3 diffuse = vec3(0.0f); 40 | vec3 specular = vec3(0.0f); 41 | 42 | const vec3 n = normalize(in_Lighting.eyeNormal); 43 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 44 | 45 | float diffuseIntensity = dot(n,l); 46 | 47 | if(diffuseIntensity > 0.0f) 48 | { 49 | const MaterialData m = sb_Material.data[in_Instancing.id]; 50 | 51 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 52 | 53 | const vec3 r = reflect(-l,n); 54 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 55 | const float specularIntensity = max(dot(r,e), 0.0f); 56 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 57 | } 58 | 59 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 60 | }; 61 | -------------------------------------------------------------------------------- /student/Scene13CADModelFrustumCullingGPU.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data[]; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | layout(location = IN_DRAWID) in int in_DrawID; 18 | 19 | //------------------------------------------------------------------------------------------------- 20 | // OUTPUTS 21 | //------------------------------------------------------------------------------------------------- 22 | 23 | out Lighting 24 | { 25 | vec3 eyePosition; 26 | vec3 eyeNormal; 27 | } out_Lighting; 28 | 29 | out Instancing 30 | { 31 | flat int id; 32 | } out_Instancing; 33 | 34 | //------------------------------------------------------------------------------------------------- 35 | // MAIN 36 | //------------------------------------------------------------------------------------------------- 37 | 38 | void main() 39 | { 40 | const TransformData t = sb_Transform.data[in_DrawID]; 41 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 42 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 43 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 44 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 45 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 46 | 47 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 48 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 49 | 50 | out_Instancing.id = in_DrawID; 51 | } 52 | -------------------------------------------------------------------------------- /student/Scene1CubeNoLighting.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | //scene1: input lighting 6 | 7 | //------------------------------------------------------------------------------------------------- 8 | // OUTPUTS 9 | //------------------------------------------------------------------------------------------------- 10 | 11 | //scene1: color output 12 | 13 | //------------------------------------------------------------------------------------------------- 14 | // MAIN 15 | //------------------------------------------------------------------------------------------------- 16 | 17 | void main() 18 | { 19 | //scene1: output incoming color 20 | }; 21 | -------------------------------------------------------------------------------- /student/Scene1CubeNoLighting.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class Scene 9 | { 10 | public: 11 | bool initialize() 12 | { 13 | // ------------------------------------------------------------------------ 14 | // 1- Load scene data 15 | // ------------------------------------------------------------------------ 16 | 17 | std::vector vertices; 18 | std::vector elements; 19 | getBoxMesh(vertices, elements); 20 | 21 | _numElements = elements.size(); 22 | 23 | for(auto v : vertices) 24 | { 25 | _bounds.expand(v.position); 26 | } 27 | 28 | // ------------------------------------------------------------------------ 29 | // 2- Create buffers and transfer data to GPU 30 | // ------------------------------------------------------------------------ 31 | 32 | //scene1: create vbo 33 | 34 | //scene1: create ebo 35 | 36 | // ------------------------------------------------------------------------ 37 | // 3- Setup vertex array object 38 | // ------------------------------------------------------------------------ 39 | 40 | //scene1: create vao 41 | 42 | //scene1: bind vbo to vao 43 | 44 | //scene1: setup position attrib 45 | 46 | //scene1: setup color attrib 47 | 48 | //scene1: bind ebo 49 | 50 | // ------------------------------------------------------------------------ 51 | // 4- Create shader program 52 | // ------------------------------------------------------------------------ 53 | 54 | ShaderLoader loader; 55 | if(!loader.addFile(GL_VERTEX_SHADER, "../src/Scene1CubeNoLighting.vert", "../src/ShaderData.h")) 56 | { 57 | return false; 58 | } 59 | if(!loader.addFile(GL_FRAGMENT_SHADER, "../src/Scene1CubeNoLighting.frag", "../src/ShaderData.h")) 60 | { 61 | return false; 62 | } 63 | if(!loader.link(_program)) 64 | { 65 | return false; 66 | } 67 | 68 | return true; 69 | } 70 | 71 | const AABB& getBounds() 72 | { 73 | return _bounds; 74 | } 75 | 76 | void draw(const CameraData& /*cameraData*/) 77 | { 78 | //scene1: use program 79 | //scene1: bind vao 80 | //scene1: draw 81 | } 82 | 83 | private: 84 | AABB _bounds; 85 | unsigned int _numElements; 86 | GLuint _vao; 87 | GLuint _program; 88 | }; 89 | -------------------------------------------------------------------------------- /student/Scene1CubeNoLighting.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | //scene1: camera ubo 6 | 7 | //scene1: position attrib 8 | //scene1: color attrib 9 | 10 | //------------------------------------------------------------------------------------------------- 11 | // OUTPUTS 12 | //------------------------------------------------------------------------------------------------- 13 | 14 | //scene1: out lighting 15 | 16 | //------------------------------------------------------------------------------------------------- 17 | // MAIN 18 | //------------------------------------------------------------------------------------------------- 19 | 20 | void main() 21 | { 22 | //scene1: output position 23 | //scene1: output color 24 | } 25 | -------------------------------------------------------------------------------- /student/Scene2CubeVertexLighting.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | in Lighting 6 | { 7 | vec3 color; 8 | } in_Lighting; 9 | 10 | //------------------------------------------------------------------------------------------------- 11 | // OUTPUTS 12 | //------------------------------------------------------------------------------------------------- 13 | 14 | layout(location = OUT_COLOR) out vec4 out_Color; 15 | 16 | //------------------------------------------------------------------------------------------------- 17 | // MAIN 18 | //------------------------------------------------------------------------------------------------- 19 | 20 | void main() 21 | { 22 | out_Color = vec4(in_Lighting.color, 1.0f); 23 | }; 24 | -------------------------------------------------------------------------------- /student/Scene2CubeVertexLighting.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | //scene2: light ubo 11 | 12 | //scene2: material ssbo 13 | 14 | layout(location = IN_POSITION) in vec3 in_Position; 15 | //scene2: normal attrib 16 | 17 | //------------------------------------------------------------------------------------------------- 18 | // OUTPUTS 19 | //------------------------------------------------------------------------------------------------- 20 | 21 | out Lighting 22 | { 23 | vec3 color; 24 | } out_Lighting; 25 | 26 | //------------------------------------------------------------------------------------------------- 27 | // MAIN 28 | //------------------------------------------------------------------------------------------------- 29 | 30 | void main() 31 | { 32 | gl_Position = ub_Camera.data.viewProjMatrix * vec4(in_Position, 1.0f); 33 | 34 | //scene2: output lighting result 35 | } 36 | -------------------------------------------------------------------------------- /student/Scene3CubeFragLighting.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data; 13 | } sb_Material; 14 | 15 | //scene3: input lighting 16 | 17 | //------------------------------------------------------------------------------------------------- 18 | // OUTPUTS 19 | //------------------------------------------------------------------------------------------------- 20 | 21 | layout(location = OUT_COLOR) out vec4 out_Color; 22 | 23 | //------------------------------------------------------------------------------------------------- 24 | // MAIN 25 | //------------------------------------------------------------------------------------------------- 26 | 27 | // this code assumes light is at camera position (0,0,0 in eye space) 28 | void main() 29 | { 30 | vec3 diffuse = vec3(0.0f); 31 | vec3 specular = vec3(0.0f); 32 | 33 | //scene3: compute n from input normal 34 | //scene3: compute l from input position 35 | 36 | float diffuseIntensity = dot(n,l); 37 | 38 | if(diffuseIntensity > 0.0f) 39 | { 40 | const MaterialData m = sb_Material.data; 41 | 42 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 43 | 44 | const vec3 r = reflect(-l,n); 45 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 46 | const float specularIntensity = max(dot(r,e), 0.0f); 47 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 48 | } 49 | 50 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 51 | }; 52 | -------------------------------------------------------------------------------- /student/Scene3CubeFragLighting.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(location = IN_POSITION) in vec3 in_Position; 11 | layout(location = IN_NORMAL) in vec3 in_Normal; 12 | 13 | //------------------------------------------------------------------------------------------------- 14 | // OUTPUTS 15 | //------------------------------------------------------------------------------------------------- 16 | 17 | //scene3: lighting output 18 | 19 | //------------------------------------------------------------------------------------------------- 20 | // MAIN 21 | //------------------------------------------------------------------------------------------------- 22 | 23 | void main() 24 | { 25 | gl_Position = ub_Camera.data.viewProjMatrix * vec4(in_Position, 1.0f); 26 | 27 | //scene3: output normal and position in camera space 28 | } 29 | -------------------------------------------------------------------------------- /student/Scene4CubeTexture.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data; 13 | } sb_Material; 14 | 15 | //scene4: sampler 16 | 17 | in Lighting 18 | { 19 | vec3 eyePosition; 20 | vec3 eyeNormal; 21 | //scene4: texcoords 22 | } in_Lighting; 23 | 24 | //------------------------------------------------------------------------------------------------- 25 | // OUTPUTS 26 | //------------------------------------------------------------------------------------------------- 27 | 28 | layout(location = OUT_COLOR) out vec4 out_Color; 29 | 30 | //------------------------------------------------------------------------------------------------- 31 | // MAIN 32 | //------------------------------------------------------------------------------------------------- 33 | 34 | // this code assumes light is at camera position (0,0,0 in eye space) 35 | void main() 36 | { 37 | vec3 diffuse = vec3(0.0f); 38 | vec3 specular = vec3(0.0f); 39 | 40 | const vec3 n = normalize(in_Lighting.eyeNormal); 41 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 42 | 43 | float diffuseIntensity = dot(n,l); 44 | 45 | if(diffuseIntensity > 0.0f) 46 | { 47 | //scene4: get tex color 48 | 49 | const MaterialData m = sb_Material.data; 50 | 51 | //scene4: blend tex color with diffuse 52 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 53 | 54 | const vec3 r = reflect(-l,n); 55 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 56 | const float specularIntensity = max(dot(r,e), 0.0f); 57 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 58 | } 59 | 60 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 61 | }; 62 | -------------------------------------------------------------------------------- /student/Scene4CubeTexture.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(location = IN_POSITION) in vec3 in_Position; 11 | layout(location = IN_NORMAL) in vec3 in_Normal; 12 | //scene4: texcoord attrib 13 | 14 | //------------------------------------------------------------------------------------------------- 15 | // OUTPUTS 16 | //------------------------------------------------------------------------------------------------- 17 | 18 | out Lighting 19 | { 20 | vec3 eyePosition; 21 | vec3 eyeNormal; 22 | //scene4: texcoords 23 | } out_Lighting; 24 | 25 | //------------------------------------------------------------------------------------------------- 26 | // MAIN 27 | //------------------------------------------------------------------------------------------------- 28 | 29 | void main() 30 | { 31 | gl_Position = ub_Camera.data.viewProjMatrix * vec4(in_Position, 1.0f); 32 | 33 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * in_Normal; 34 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * vec4(in_Position, 1.0f)); 35 | //scene4: output texcoord 36 | } 37 | -------------------------------------------------------------------------------- /student/Scene5ManyCubesIndividual.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | //------------------------------------------------------------------------------------------------- 22 | // OUTPUTS 23 | //------------------------------------------------------------------------------------------------- 24 | 25 | layout(location = OUT_COLOR) out vec4 out_Color; 26 | 27 | //------------------------------------------------------------------------------------------------- 28 | // MAIN 29 | //------------------------------------------------------------------------------------------------- 30 | 31 | // this code assumes light is at camera position (0,0,0 in eye space) 32 | void main() 33 | { 34 | vec3 diffuse = vec3(0.0f); 35 | vec3 specular = vec3(0.0f); 36 | 37 | const vec3 n = normalize(in_Lighting.eyeNormal); 38 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 39 | 40 | float diffuseIntensity = dot(n,l); 41 | 42 | if(diffuseIntensity > 0.0f) 43 | { 44 | const MaterialData m = sb_Material.data; 45 | 46 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 47 | 48 | const vec3 r = reflect(-l,n); 49 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 50 | const float specularIntensity = max(dot(r,e), 0.0f); 51 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 52 | } 53 | 54 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 55 | }; 56 | -------------------------------------------------------------------------------- /student/Scene5ManyCubesIndividual.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | //scene5: transform ssbo 11 | 12 | layout(location = IN_POSITION) in vec3 in_Position; 13 | layout(location = IN_NORMAL) in vec3 in_Normal; 14 | 15 | //------------------------------------------------------------------------------------------------- 16 | // OUTPUTS 17 | //------------------------------------------------------------------------------------------------- 18 | 19 | out Lighting 20 | { 21 | vec3 eyePosition; 22 | vec3 eyeNormal; 23 | } out_Lighting; 24 | 25 | //------------------------------------------------------------------------------------------------- 26 | // MAIN 27 | //------------------------------------------------------------------------------------------------- 28 | 29 | void main() 30 | { 31 | //scene5: get transform from ssbo 32 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 33 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 34 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 35 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 36 | //scene5: output position 37 | //scene5: output normal in camera space 38 | //scene5: output position in camera space 39 | } 40 | -------------------------------------------------------------------------------- /student/Scene6ManyCubesInstancing.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | //scene6: material ssbo 11 | 12 | in Lighting 13 | { 14 | vec3 eyePosition; 15 | vec3 eyeNormal; 16 | } in_Lighting; 17 | 18 | //scene6: instancing id input 19 | 20 | //------------------------------------------------------------------------------------------------- 21 | // OUTPUTS 22 | //------------------------------------------------------------------------------------------------- 23 | 24 | layout(location = OUT_COLOR) out vec4 out_Color; 25 | 26 | //------------------------------------------------------------------------------------------------- 27 | // MAIN 28 | //------------------------------------------------------------------------------------------------- 29 | 30 | // this code assumes light is at camera position (0,0,0 in eye space) 31 | void main() 32 | { 33 | vec3 diffuse = vec3(0.0f); 34 | vec3 specular = vec3(0.0f); 35 | 36 | const vec3 n = normalize(in_Lighting.eyeNormal); 37 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 38 | 39 | float diffuseIntensity = dot(n,l); 40 | 41 | if(diffuseIntensity > 0.0f) 42 | { 43 | //scene6: get material using instancing id 44 | 45 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 46 | 47 | const vec3 r = reflect(-l,n); 48 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 49 | const float specularIntensity = max(dot(r,e), 0.0f); 50 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 51 | } 52 | 53 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 54 | }; 55 | -------------------------------------------------------------------------------- /student/Scene6ManyCubesInstancing.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | //scene6: transform ssbo 11 | 12 | layout(location = IN_POSITION) in vec3 in_Position; 13 | layout(location = IN_NORMAL) in vec3 in_Normal; 14 | 15 | //------------------------------------------------------------------------------------------------- 16 | // OUTPUTS 17 | //------------------------------------------------------------------------------------------------- 18 | 19 | out Lighting 20 | { 21 | vec3 eyePosition; 22 | vec3 eyeNormal; 23 | } out_Lighting; 24 | 25 | //scene6: instancing id output 26 | 27 | //------------------------------------------------------------------------------------------------- 28 | // MAIN 29 | //------------------------------------------------------------------------------------------------- 30 | 31 | void main() 32 | { 33 | //scene6: get transform data using instance id 34 | 35 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 36 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 37 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 38 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 39 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 40 | 41 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 42 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 43 | 44 | //scene6: output instancing id 45 | } 46 | -------------------------------------------------------------------------------- /student/Scene6bManyCubesInstancing.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data[]; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | in Instancing 22 | { 23 | flat int id; 24 | } in_Instancing; 25 | 26 | //------------------------------------------------------------------------------------------------- 27 | // OUTPUTS 28 | //------------------------------------------------------------------------------------------------- 29 | 30 | layout(location = OUT_COLOR) out vec4 out_Color; 31 | 32 | //------------------------------------------------------------------------------------------------- 33 | // MAIN 34 | //------------------------------------------------------------------------------------------------- 35 | 36 | // this code assumes light is at camera position (0,0,0 in eye space) 37 | void main() 38 | { 39 | vec3 diffuse = vec3(0.0f); 40 | vec3 specular = vec3(0.0f); 41 | 42 | const vec3 n = normalize(in_Lighting.eyeNormal); 43 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 44 | 45 | float diffuseIntensity = dot(n,l); 46 | 47 | if(diffuseIntensity > 0.0f) 48 | { 49 | const MaterialData m = sb_Material.data[in_Instancing.id]; 50 | 51 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 52 | 53 | const vec3 r = reflect(-l,n); 54 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 55 | const float specularIntensity = max(dot(r,e), 0.0f); 56 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 57 | } 58 | 59 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 60 | }; 61 | -------------------------------------------------------------------------------- /student/Scene6bManyCubesInstancing.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(location = IN_POSITION) in vec3 in_Position; 11 | layout(location = IN_NORMAL) in vec3 in_Normal; 12 | //scene6b: add transform vertex input 13 | 14 | //------------------------------------------------------------------------------------------------- 15 | // OUTPUTS 16 | //------------------------------------------------------------------------------------------------- 17 | 18 | out Lighting 19 | { 20 | vec3 eyePosition; 21 | vec3 eyeNormal; 22 | } out_Lighting; 23 | 24 | out Instancing 25 | { 26 | flat int id; 27 | } out_Instancing; 28 | 29 | //------------------------------------------------------------------------------------------------- 30 | // MAIN 31 | //------------------------------------------------------------------------------------------------- 32 | 33 | void main() 34 | { 35 | //scene6b: add transform to position attrib 36 | gl_Position = ub_Camera.data.viewProjMatrix * vec4(in_Position, 1.0f); 37 | 38 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * in_Normal; 39 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * vec4(in_Position, 1.0f)); 40 | 41 | out_Instancing.id = gl_InstanceID; 42 | } 43 | -------------------------------------------------------------------------------- /student/Scene7ManyCubesIndividualTexture.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data; 13 | } sb_Material; 14 | 15 | layout(binding = TEX_TEXTURE) uniform sampler2D tex_Texture; 16 | 17 | in Lighting 18 | { 19 | vec3 eyePosition; 20 | vec3 eyeNormal; 21 | vec2 texCoord; 22 | } in_Lighting; 23 | 24 | //------------------------------------------------------------------------------------------------- 25 | // OUTPUTS 26 | //------------------------------------------------------------------------------------------------- 27 | 28 | layout(location = OUT_COLOR) out vec4 out_Color; 29 | 30 | //------------------------------------------------------------------------------------------------- 31 | // MAIN 32 | //------------------------------------------------------------------------------------------------- 33 | 34 | // this code assumes light is at camera position (0,0,0 in eye space) 35 | void main() 36 | { 37 | vec3 diffuse = vec3(0.0f); 38 | vec3 specular = vec3(0.0f); 39 | 40 | const vec3 n = normalize(in_Lighting.eyeNormal); 41 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 42 | 43 | float diffuseIntensity = dot(n,l); 44 | 45 | if(diffuseIntensity > 0.0f) 46 | { 47 | vec3 texColor = texture(tex_Texture, in_Lighting.texCoord).rgb; 48 | 49 | const MaterialData m = sb_Material.data; 50 | 51 | diffuse = vec3(m.diffuse) * texColor * vec3(ub_Light.data.diffuse) * diffuseIntensity; 52 | 53 | const vec3 r = reflect(-l,n); 54 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 55 | const float specularIntensity = max(dot(r,e), 0.0f); 56 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 57 | } 58 | 59 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 60 | }; 61 | -------------------------------------------------------------------------------- /student/Scene7ManyCubesIndividualTexture.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | layout(location = IN_TEXCOORD) in vec2 in_TexCoord; 18 | 19 | //------------------------------------------------------------------------------------------------- 20 | // OUTPUTS 21 | //------------------------------------------------------------------------------------------------- 22 | 23 | out Lighting 24 | { 25 | vec3 eyePosition; 26 | vec3 eyeNormal; 27 | vec2 texCoord; 28 | } out_Lighting; 29 | 30 | //------------------------------------------------------------------------------------------------- 31 | // MAIN 32 | //------------------------------------------------------------------------------------------------- 33 | 34 | void main() 35 | { 36 | const TransformData t = sb_Transform.data; 37 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 38 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 39 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 40 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 41 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 42 | 43 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 44 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 45 | 46 | out_Lighting.texCoord = in_TexCoord; 47 | } 48 | -------------------------------------------------------------------------------- /student/Scene8ManyCubesInstancingTexture.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data[]; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | layout(location = IN_TEXCOORD) in vec2 in_TexCoord; 18 | 19 | //------------------------------------------------------------------------------------------------- 20 | // OUTPUTS 21 | //------------------------------------------------------------------------------------------------- 22 | 23 | out Lighting 24 | { 25 | vec3 eyePosition; 26 | vec3 eyeNormal; 27 | vec2 texCoord; 28 | } out_Lighting; 29 | 30 | out Instancing 31 | { 32 | flat int id; 33 | } out_Instancing; 34 | 35 | //------------------------------------------------------------------------------------------------- 36 | // MAIN 37 | //------------------------------------------------------------------------------------------------- 38 | 39 | void main() 40 | { 41 | const TransformData t = sb_Transform.data[gl_InstanceID]; 42 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 43 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 44 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 45 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 46 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 47 | 48 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 49 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 50 | 51 | out_Lighting.texCoord = in_TexCoord; 52 | 53 | out_Instancing.id = gl_InstanceID; 54 | } 55 | -------------------------------------------------------------------------------- /student/Scene9ManyGeometriesIndividual.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | //------------------------------------------------------------------------------------------------- 22 | // OUTPUTS 23 | //------------------------------------------------------------------------------------------------- 24 | 25 | layout(location = OUT_COLOR) out vec4 out_Color; 26 | 27 | //------------------------------------------------------------------------------------------------- 28 | // MAIN 29 | //------------------------------------------------------------------------------------------------- 30 | 31 | // this code assumes light is at camera position (0,0,0 in eye space) 32 | void main() 33 | { 34 | vec3 diffuse = vec3(0.0f); 35 | vec3 specular = vec3(0.0f); 36 | 37 | const vec3 n = normalize(in_Lighting.eyeNormal); 38 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 39 | 40 | float diffuseIntensity = dot(n,l); 41 | 42 | if(diffuseIntensity > 0.0f) 43 | { 44 | const MaterialData m = sb_Material.data; 45 | 46 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 47 | 48 | const vec3 r = reflect(-l,n); 49 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 50 | const float specularIntensity = max(dot(r,e), 0.0f); 51 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 52 | } 53 | 54 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 55 | }; 56 | -------------------------------------------------------------------------------- /student/Scene9ManyGeometriesIndividual.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | 18 | //------------------------------------------------------------------------------------------------- 19 | // OUTPUTS 20 | //------------------------------------------------------------------------------------------------- 21 | 22 | out Lighting 23 | { 24 | vec3 eyePosition; 25 | vec3 eyeNormal; 26 | } out_Lighting; 27 | 28 | //------------------------------------------------------------------------------------------------- 29 | // MAIN 30 | //------------------------------------------------------------------------------------------------- 31 | 32 | void main() 33 | { 34 | const TransformData t = sb_Transform.data; 35 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 36 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 37 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 38 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 39 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 40 | 41 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 42 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 43 | } 44 | -------------------------------------------------------------------------------- /student/ShaderData.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | #pragma once 3 | #include 4 | using namespace glm; 5 | #ifdef near 6 | #undef near 7 | #endif 8 | #ifdef far 9 | #undef far 10 | #endif 11 | #endif 12 | 13 | struct BoundsData 14 | { 15 | vec4 minmax[2]; 16 | }; 17 | 18 | struct Plane 19 | { 20 | float nx; 21 | float ny; 22 | float nz; 23 | float offset; 24 | int px; 25 | int py; 26 | int pz; 27 | }; 28 | 29 | struct FrustumData 30 | { 31 | Plane near; 32 | Plane left; 33 | Plane right; 34 | Plane bottom; 35 | Plane top; 36 | Plane far; 37 | }; 38 | 39 | struct CameraData 40 | { 41 | mat4 viewMatrix; 42 | mat4 viewProjMatrix; 43 | }; 44 | 45 | struct MaterialData 46 | { 47 | vec4 diffuse; 48 | vec4 specular; // w = shininess 49 | }; 50 | 51 | struct TransformData 52 | { 53 | vec4 row0; 54 | vec4 row1; 55 | vec4 row2; 56 | }; 57 | 58 | struct LightData 59 | { 60 | vec4 ambient; 61 | vec4 diffuse; 62 | vec4 specular; 63 | }; 64 | 65 | struct DrawCommand 66 | { 67 | uint elementCount; // count 68 | uint instanceCount; // instanceCount 69 | uint firstElement; // firstIndex 70 | uint baseVertex; // baseVertex 71 | uint baseInstance; // baseInstance 72 | }; 73 | 74 | // Uniform Buffers 75 | #define UB_CAMERA 0 76 | #define UB_LIGHT 1 77 | #define UB_TRANSFORM 2 78 | #define UB_MATERIAL 3 79 | 80 | // Storage Buffers 81 | #define SB_TRANSFORM 0 82 | #define SB_MATERIAL 1 83 | #define SB_TEXTURE 2 84 | #define SB_IN_DRAW_CMD 3 85 | #define SB_OUT_DRAW_CMD 4 86 | #define SB_BOUNDS 5 87 | #define SB_FRUSTUM 6 88 | 89 | // Vertex Attributes 90 | #define IN_POSITION 0 91 | #define IN_NORMAL 1 92 | #define IN_COLOR 2 93 | #define IN_TEXCOORD 3 94 | #define IN_DRAWID 4 95 | 96 | // Fragment Outputs 97 | #define OUT_COLOR 0 98 | #define NUM_FRAG_OUT 1 99 | 100 | // Texture Units 101 | #define TEX_TEXTURE 0 102 | 103 | // Compute Shader 104 | #define CS_BLOCK_SIZE_X 256 105 | 106 | // Uniform Variables 107 | #define U_SCENE_SIZE 0 108 | #define U_RAND_SEED 1 109 | 110 | // Atomic Counters 111 | #define AC_DRAW_COUNT 0 112 | -------------------------------------------------------------------------------- /student/Timer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class Timer 5 | { 6 | public: 7 | static int get_resolution(); 8 | Timer(); 9 | void restart(); 10 | double sec(); 11 | double msec(); 12 | double usec(); 13 | double nsec(); 14 | 15 | private: 16 | typedef typename std::conditional::type t_clock; 19 | t_clock::time_point _start; 20 | }; 21 | 22 | int Timer::get_resolution() 23 | { 24 | return t_clock::period::den; 25 | } 26 | 27 | Timer::Timer() 28 | { 29 | restart(); 30 | } 31 | 32 | void Timer::restart() 33 | { 34 | _start = t_clock::now(); 35 | } 36 | 37 | double Timer::sec() 38 | { 39 | return std::chrono::duration(t_clock::now() - _start).count(); 40 | } 41 | 42 | double Timer::msec() 43 | { 44 | return std::chrono::duration(t_clock::now() - _start).count(); 45 | } 46 | 47 | double Timer::usec() 48 | { 49 | return std::chrono::duration(t_clock::now() - _start).count(); 50 | } 51 | 52 | double Timer::nsec() 53 | { 54 | return std::chrono::duration(t_clock::now() - _start).count(); 55 | } 56 | -------------------------------------------------------------------------------- /student/tess/geometries.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace tess 5 | { 6 | struct box 7 | { 8 | vec3 extents = {0.0f, 0.0f, 0.0f}; 9 | }; 10 | 11 | struct circular_torus 12 | { 13 | float in_radius = 0.1f; 14 | float out_radius = 0.4f; 15 | float sweep_angle = math::half_pi(); 16 | }; 17 | 18 | struct cone 19 | { 20 | float top_radius = 0.25f; 21 | float bottom_radius = 0.5f; 22 | float height = 1.0f; 23 | }; 24 | 25 | struct cone_offset 26 | { 27 | float top_radius = 0.25f; 28 | float bottom_radius = 0.5f; 29 | float height = 1.0f; 30 | vec2 offset = {0.25f, 0.25f}; 31 | }; 32 | 33 | struct cylinder 34 | { 35 | float radius = 0.5f; 36 | float height = 1.0f; 37 | }; 38 | 39 | struct cylinder_offset 40 | { 41 | float radius = 0.5f; 42 | float height = 1.0f; 43 | vec2 offset = {0.25f, 0.25f}; 44 | }; 45 | 46 | struct dish 47 | { 48 | float radius = 0.5f; 49 | float height = 1.0f; 50 | }; 51 | 52 | struct pyramid 53 | { 54 | vec2 top_extents = {0.25f, 0.25f}; 55 | vec2 bottom_extents = {0.5f, 0.5f}; 56 | vec2 offset = {0.25f, 0.25f}; 57 | float height = 1.0f; 58 | }; 59 | 60 | struct rectangular_torus 61 | { 62 | float in_height = 1.0f; 63 | float in_radius = 0.1f; 64 | float out_radius = 0.4f; 65 | float sweep_angle = math::half_pi(); 66 | }; 67 | 68 | struct sphere 69 | { 70 | float radius = 0.5f; 71 | }; 72 | } // namespace tess 73 | -------------------------------------------------------------------------------- /student/tess/mesh_builder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace tess 5 | { 6 | class mesh_builder 7 | { 8 | public: 9 | mesh_builder(); 10 | 11 | void begin(); 12 | void set_primitive_mode(unsigned int mode); 13 | void add_element(element element); 14 | unsigned int add_vertex(const vertex& v); // return index of newly added vertex 15 | const vertex& get_vertex(unsigned int idx); 16 | triangle_mesh end(); 17 | 18 | private: 19 | void _add_triangle(element last_elem); 20 | 21 | void _add_triangle_fan(element last_elem); 22 | 23 | void _add_triangle_strip(element last_elem); 24 | 25 | private: 26 | std::vector _vertices; 27 | std::vector _elements; 28 | unsigned int _curr_prim_mode; 29 | element _curr_elements[2]; // keeps track of last two elements of current triangle 30 | unsigned int _num_curr_elements; 31 | bool _invert_winding; 32 | }; 33 | } // namespace tess 34 | -------------------------------------------------------------------------------- /student/tess/mesh_optimizer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace tess 5 | { 6 | class mesh_optimizer 7 | { 8 | public: 9 | typedef unsigned int flag; 10 | 11 | static const flag flag_check_results = 1; // check results for consistency and print any problems found: O(n^2) 12 | static const flag flag_all_optimizations = (~0U) << 1; // enable all optimizations: O(n) 13 | static const flag flag_remove_unused_vertices = 1 << 1; // remove vertices not referenced by any element: O(n) 14 | static const flag flag_weld_vertices_exact = 1 << 2; // merge vertices with exactly the same attributes: O(n) 15 | // todo: static const flag flag_weld_vertices_nearby = 1<<3; // merge nearby vertices using tolerance: O(n) 16 | 17 | void optimize(triangle_mesh& mesh, flag flags); 18 | 19 | private: 20 | std::vector _temp_vertices; 21 | std::vector _temp_elements; 22 | }; 23 | } // namespace tess 24 | -------------------------------------------------------------------------------- /student/tess/polygon_tessellator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace tess 5 | { 6 | class polygon_tessellator 7 | { 8 | public: 9 | polygon_tessellator(); 10 | ~polygon_tessellator(); 11 | 12 | void begin(); 13 | void add_polygon(const polygon& poly); 14 | triangle_mesh end(); 15 | 16 | private: 17 | polygon_tessellator(const polygon_tessellator&) = delete; 18 | polygon_tessellator& operator=(const polygon_tessellator&) = delete; 19 | 20 | class impl; 21 | impl* _d; 22 | }; 23 | } // namespace tess 24 | -------------------------------------------------------------------------------- /student/tess/triangle_mesh.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace tess 4 | { 5 | // --------------------------------------------------------------------------------------------------------------------------------------------------------- 6 | // vertex 7 | // --------------------------------------------------------------------------------------------------------------------------------------------------------- 8 | 9 | vertex::vertex() 10 | { 11 | } 12 | 13 | vertex::vertex(const vec3& _position, const vec3& _normal) 14 | : position(_position), normal(_normal) 15 | { 16 | } 17 | 18 | bool vertex::operator==(const vertex& other) const 19 | { 20 | return position == other.position && normal == other.normal; 21 | } 22 | 23 | // --------------------------------------------------------------------------------------------------------------------------------------------------------- 24 | // triangle_mesh 25 | // --------------------------------------------------------------------------------------------------------------------------------------------------------- 26 | 27 | bool triangle_mesh::is_valid() const 28 | { 29 | // Check if there are at least 3 vertices and 3 elements to define a triangle 30 | if(vertices.size() < 3 || elements.size() < 3) 31 | { 32 | return false; 33 | } 34 | 35 | // Check if mesh has at least one valid triangle 36 | for(unsigned int i = 0; i < elements.size() - 3; i += 3) 37 | { 38 | if(elements[i] != elements[i+1] && elements[i+1] != elements[i+2]) 39 | { 40 | if(elements[i] >= vertices.size() || elements[i+1] >= vertices.size() || elements[i+2] >= vertices.size()) 41 | { 42 | continue; 43 | } 44 | 45 | const auto& v1 = vertices[elements[i]].position; 46 | const auto& v2 = vertices[elements[i+1]].position; 47 | const auto& v3 = vertices[elements[i+2]].position; 48 | 49 | if(!std::isfinite(v1.x) || !std::isfinite(v1.y) || !std::isfinite(v1.z) || 50 | !std::isfinite(v2.x) || !std::isfinite(v2.y) || !std::isfinite(v2.z) || 51 | !std::isfinite(v3.x) || !std::isfinite(v3.y) || !std::isfinite(v3.z)) 52 | { 53 | continue; 54 | } 55 | 56 | if(v1 == v2 || v2 == v3 || v1 == v3) 57 | { 58 | continue; 59 | } 60 | 61 | return true; 62 | } 63 | } 64 | 65 | return false; 66 | } 67 | } // namespace tess 68 | -------------------------------------------------------------------------------- /student/tess/triangle_mesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace tess 9 | { 10 | using namespace glm; 11 | 12 | struct vertex 13 | { 14 | vertex(); 15 | vertex(const vec3& _position, const vec3& _normal); 16 | bool operator==(const vertex& other) const; 17 | 18 | vec3 position; 19 | vec3 normal; 20 | }; 21 | 22 | typedef unsigned int element; 23 | 24 | struct triangle_mesh 25 | { 26 | bool is_valid() const; 27 | void append(const triangle_mesh& other) 28 | { 29 | auto vertexStart = vertices.size(); 30 | auto elementStart = elements.size(); 31 | vertices.insert(vertices.end(), other.vertices.begin(), other.vertices.end()); 32 | elements.insert(elements.end(), other.elements.begin(), other.elements.end()); 33 | for(auto i = elementStart; i < elements.size(); ++i) 34 | { 35 | elements.at(i) += vertexStart; 36 | } 37 | } 38 | 39 | std::vector vertices; 40 | std::vector elements; 41 | }; 42 | } // namespace tess 43 | -------------------------------------------------------------------------------- /teacher/AABB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | struct AABB 5 | { 6 | glm::vec3 min; 7 | glm::vec3 max; 8 | 9 | AABB() 10 | { 11 | min = glm::vec3( std::numeric_limits::max()); 12 | max = glm::vec3(-std::numeric_limits::max()); 13 | } 14 | 15 | void expand(const glm::vec3& point) 16 | { 17 | min = glm::min(min, point); 18 | max = glm::max(max, point); 19 | } 20 | 21 | bool valid() const 22 | { 23 | return min.x <= max.x && min.y <= max.y && min.z <= max.z; 24 | } 25 | 26 | const glm::vec3& operator[](unsigned int i) const 27 | { 28 | return *(&min + i); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /teacher/FPS.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class FPS 5 | { 6 | public: 7 | FPS() 8 | { 9 | _updateIntervalSec = 0.5f; 10 | _numFrames = 0; 11 | _prevMS = 0; 12 | } 13 | 14 | bool update(float& fps) 15 | { 16 | int currMS = glutGet(GLUT_ELAPSED_TIME); 17 | float elapsedSec = (currMS - _prevMS) * 1e-3f; 18 | ++_numFrames; 19 | 20 | if(elapsedSec < _updateIntervalSec) 21 | { 22 | return false; 23 | } 24 | else 25 | { 26 | fps = (float)_numFrames / elapsedSec; 27 | _numFrames = 0; 28 | _prevMS = currMS; 29 | return true; 30 | } 31 | } 32 | 33 | private: 34 | float _updateIntervalSec; 35 | unsigned int _numFrames; 36 | int _prevMS; 37 | }; 38 | -------------------------------------------------------------------------------- /teacher/FrustumCuller.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void FrustumCuller::beginFrame(const glm::mat4& viewProj) 4 | { 5 | // NOTE: glm uses mat[col][row] 6 | _setPlane(_data.near, viewProj[0][3] + viewProj[0][2], viewProj[1][3] + viewProj[1][2], viewProj[2][3] + viewProj[2][2], viewProj[3][3] + viewProj[3][2]); // near 7 | _setPlane(_data.left, viewProj[0][3] + viewProj[0][0], viewProj[1][3] + viewProj[1][0], viewProj[2][3] + viewProj[2][0], viewProj[3][3] + viewProj[3][0]); // left 8 | _setPlane(_data.right, viewProj[0][3] - viewProj[0][0], viewProj[1][3] - viewProj[1][0], viewProj[2][3] - viewProj[2][0], viewProj[3][3] - viewProj[3][0]); // right 9 | _setPlane(_data.bottom, viewProj[0][3] + viewProj[0][1], viewProj[1][3] + viewProj[1][1], viewProj[2][3] + viewProj[2][1], viewProj[3][3] + viewProj[3][1]); // bottom 10 | _setPlane(_data.top, viewProj[0][3] - viewProj[0][1], viewProj[1][3] - viewProj[1][1], viewProj[2][3] - viewProj[2][1], viewProj[3][3] - viewProj[3][1]); // top 11 | _setPlane(_data.far, viewProj[0][3] - viewProj[0][2], viewProj[1][3] - viewProj[1][2], viewProj[2][3] - viewProj[2][2], viewProj[3][3] - viewProj[3][2]); // far 12 | } 13 | 14 | void FrustumCuller::_setPlane(Plane& p, float a, float b, float c, float d) 15 | { 16 | p.nx = a; 17 | p.ny = b; 18 | p.nz = c; 19 | p.offset = d; 20 | p.px = (p.nx > 0.0f) ? 1 : 0; 21 | p.py = (p.ny > 0.0f) ? 1 : 0; 22 | p.pz = (p.nz > 0.0f) ? 1 : 0; 23 | float invLen = 1.0f / glm::length(glm::vec3(p.nx, p.ny, p.nz)); 24 | p.nx *= invLen; 25 | p.ny *= invLen; 26 | p.nz *= invLen; 27 | p.offset *= invLen; 28 | } 29 | -------------------------------------------------------------------------------- /teacher/FrustumCuller.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class FrustumCuller 6 | { 7 | public: 8 | void beginFrame(const glm::mat4& viewProj); 9 | inline const FrustumData& getData() const; 10 | inline bool isCulled(const AABB& bounds) const; 11 | 12 | private: 13 | void _setPlane(Plane& p, float a, float b, float c, float d); 14 | inline bool _isCulled(const Plane& p, const AABB& bounds) const; 15 | 16 | private: 17 | FrustumData _data; 18 | }; 19 | 20 | inline const FrustumData& FrustumCuller::getData() const 21 | { 22 | return _data; 23 | } 24 | 25 | inline bool FrustumCuller::isCulled(const AABB& bounds) const 26 | { 27 | return _isCulled(_data.near, bounds) || 28 | _isCulled(_data.left, bounds) || 29 | _isCulled(_data.right, bounds) || 30 | _isCulled(_data.bottom, bounds) || 31 | _isCulled(_data.top, bounds) || 32 | _isCulled(_data.far, bounds); 33 | } 34 | 35 | inline bool FrustumCuller::_isCulled(const Plane& p, const AABB& bounds) const 36 | { 37 | return glm::dot(glm::vec3(p.nx, p.ny, p.nz), glm::vec3(bounds[p.px].x, bounds[p.py].y, bounds[p.pz].z)) < -p.offset; 38 | } 39 | -------------------------------------------------------------------------------- /teacher/Light.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class Light 6 | { 7 | public: 8 | bool initialize() 9 | { 10 | LightData light; 11 | light.ambient = glm::vec4(0.2f, 0.2f, 0.2f, 1.0f); 12 | light.diffuse = glm::vec4(1.0f); 13 | light.specular = glm::vec4(0.5f); 14 | 15 | // create UBO to store light data inside GPU 16 | GLuint lightUBO; 17 | glCreateBuffers(1, &lightUBO); 18 | glNamedBufferStorage(lightUBO, sizeof(LightData), &light, 0); // flags = 0 19 | 20 | // associate light UBO to shader binding point 21 | glBindBufferBase(GL_UNIFORM_BUFFER, UB_LIGHT, lightUBO); 22 | 23 | return true; 24 | } 25 | 26 | private: 27 | LightData _data; 28 | }; 29 | -------------------------------------------------------------------------------- /teacher/ModernOpenGL.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | CONFIG += console 3 | CONFIG += c++14 4 | CONFIG -= qt 5 | 6 | HEADERS += $$files(*.h) 7 | SOURCES += $$files(*.cpp) 8 | OTHER_FILES += $$files(*.vert) 9 | OTHER_FILES += $$files(*.frag) 10 | OTHER_FILES += $$files(*.comp) 11 | 12 | HEADERS += $$files(rvm/*.h) 13 | SOURCES += $$files(rvm/*.cpp) 14 | 15 | HEADERS += $$files(tess/*.h) 16 | SOURCES += $$files(tess/*.cpp) 17 | SOURCES += $$files(tess/glutess/*.c) 18 | 19 | win32 { 20 | DEFINES += GLEW_STATIC 21 | DEFINES += FREEGLUT_STATIC 22 | INCLUDEPATH += ../dep/freeglut/inc 23 | INCLUDEPATH += ../dep/glew/inc 24 | INCLUDEPATH += ../dep/glm/inc 25 | LIBS += ../dep/glew/lib/libglew.a ../dep/freeglut/lib/libfreeglut.a -lopengl32 -lglu32 -lwinmm -lgdi32 -lpthread 26 | } 27 | unix { 28 | LIBS += -lGL -lGLU -lglut -lGLEW -lX11 -lpthread 29 | } 30 | -------------------------------------------------------------------------------- /teacher/Random.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | template 6 | std::function make_random(t_value min, t_value max, t_value seed = std::random_device()()) 7 | { 8 | typedef typename std::conditional::value, 9 | std::uniform_int_distribution, 10 | std::uniform_real_distribution>::type dist_type; 11 | 12 | if(!std::is_integral::value) 13 | { 14 | max = std::nextafter(max, std::numeric_limits::max()); 15 | } 16 | 17 | t_engine engine; 18 | engine.seed(seed); 19 | return std::bind(dist_type(min, max), engine); 20 | } 21 | 22 | template 23 | std::function make_random(t_value seed = std::random_device()()) 24 | { 25 | t_value min = 0.0; 26 | t_value max = 1.0; 27 | 28 | if(std::is_integral::value) 29 | { 30 | max = std::numeric_limits::max(); 31 | } 32 | 33 | return make_random(min, max, seed); 34 | } 35 | -------------------------------------------------------------------------------- /teacher/Scene0Framebuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class Scene 6 | { 7 | public: 8 | bool initialize() 9 | { 10 | return true; 11 | } 12 | 13 | const AABB& getBounds() 14 | { 15 | return _bounds; 16 | } 17 | 18 | void draw(const CameraData& /*cameraData*/) 19 | { 20 | // empty 21 | } 22 | 23 | private: 24 | AABB _bounds; 25 | }; 26 | -------------------------------------------------------------------------------- /teacher/Scene10ManyGeometriesMultiDrawIndirect.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data[]; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | in Instancing 22 | { 23 | flat int id; 24 | } in_Instancing; 25 | 26 | //------------------------------------------------------------------------------------------------- 27 | // OUTPUTS 28 | //------------------------------------------------------------------------------------------------- 29 | 30 | layout(location = OUT_COLOR) out vec4 out_Color; 31 | 32 | //------------------------------------------------------------------------------------------------- 33 | // MAIN 34 | //------------------------------------------------------------------------------------------------- 35 | 36 | // this code assumes light is at camera position (0,0,0 in eye space) 37 | void main() 38 | { 39 | vec3 diffuse = vec3(0.0f); 40 | vec3 specular = vec3(0.0f); 41 | 42 | const vec3 n = normalize(in_Lighting.eyeNormal); 43 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 44 | 45 | float diffuseIntensity = dot(n,l); 46 | 47 | if(diffuseIntensity > 0.0f) 48 | { 49 | const MaterialData m = sb_Material.data[in_Instancing.id]; 50 | 51 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 52 | 53 | const vec3 r = reflect(-l,n); 54 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 55 | const float specularIntensity = max(dot(r,e), 0.0f); 56 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 57 | } 58 | 59 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 60 | }; 61 | -------------------------------------------------------------------------------- /teacher/Scene10ManyGeometriesMultiDrawIndirect.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data[]; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | layout(location = IN_DRAWID) in int in_DrawID; 18 | 19 | //------------------------------------------------------------------------------------------------- 20 | // OUTPUTS 21 | //------------------------------------------------------------------------------------------------- 22 | 23 | out Lighting 24 | { 25 | vec3 eyePosition; 26 | vec3 eyeNormal; 27 | } out_Lighting; 28 | 29 | out Instancing 30 | { 31 | flat int id; 32 | } out_Instancing; 33 | 34 | //------------------------------------------------------------------------------------------------- 35 | // MAIN 36 | //------------------------------------------------------------------------------------------------- 37 | 38 | void main() 39 | { 40 | const TransformData t = sb_Transform.data[in_DrawID]; 41 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 42 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 43 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 44 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 45 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 46 | 47 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 48 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 49 | 50 | out_Instancing.id = in_DrawID; 51 | } 52 | -------------------------------------------------------------------------------- /teacher/Scene11CADModel.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data[]; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | in Instancing 22 | { 23 | flat int id; 24 | } in_Instancing; 25 | 26 | //------------------------------------------------------------------------------------------------- 27 | // OUTPUTS 28 | //------------------------------------------------------------------------------------------------- 29 | 30 | layout(location = OUT_COLOR) out vec4 out_Color; 31 | 32 | //------------------------------------------------------------------------------------------------- 33 | // MAIN 34 | //------------------------------------------------------------------------------------------------- 35 | 36 | // this code assumes light is at camera position (0,0,0 in eye space) 37 | void main() 38 | { 39 | vec3 diffuse = vec3(0.0f); 40 | vec3 specular = vec3(0.0f); 41 | 42 | const vec3 n = normalize(in_Lighting.eyeNormal); 43 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 44 | 45 | float diffuseIntensity = dot(n,l); 46 | 47 | if(diffuseIntensity > 0.0f) 48 | { 49 | const MaterialData m = sb_Material.data[in_Instancing.id]; 50 | 51 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 52 | 53 | const vec3 r = reflect(-l,n); 54 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 55 | const float specularIntensity = max(dot(r,e), 0.0f); 56 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 57 | } 58 | 59 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 60 | }; 61 | -------------------------------------------------------------------------------- /teacher/Scene11CADModel.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data[]; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | layout(location = IN_DRAWID) in int in_DrawID; 18 | 19 | //------------------------------------------------------------------------------------------------- 20 | // OUTPUTS 21 | //------------------------------------------------------------------------------------------------- 22 | 23 | out Lighting 24 | { 25 | vec3 eyePosition; 26 | vec3 eyeNormal; 27 | } out_Lighting; 28 | 29 | out Instancing 30 | { 31 | flat int id; 32 | } out_Instancing; 33 | 34 | //------------------------------------------------------------------------------------------------- 35 | // MAIN 36 | //------------------------------------------------------------------------------------------------- 37 | 38 | void main() 39 | { 40 | const TransformData t = sb_Transform.data[in_DrawID]; 41 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 42 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 43 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 44 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 45 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 46 | 47 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 48 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 49 | 50 | out_Instancing.id = in_DrawID; 51 | } 52 | -------------------------------------------------------------------------------- /teacher/Scene12CADModelFrustumCullingCPU.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data[]; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | in Instancing 22 | { 23 | flat int id; 24 | } in_Instancing; 25 | 26 | //------------------------------------------------------------------------------------------------- 27 | // OUTPUTS 28 | //------------------------------------------------------------------------------------------------- 29 | 30 | layout(location = OUT_COLOR) out vec4 out_Color; 31 | 32 | //------------------------------------------------------------------------------------------------- 33 | // MAIN 34 | //------------------------------------------------------------------------------------------------- 35 | 36 | // this code assumes light is at camera position (0,0,0 in eye space) 37 | void main() 38 | { 39 | vec3 diffuse = vec3(0.0f); 40 | vec3 specular = vec3(0.0f); 41 | 42 | const vec3 n = normalize(in_Lighting.eyeNormal); 43 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 44 | 45 | float diffuseIntensity = dot(n,l); 46 | 47 | if(diffuseIntensity > 0.0f) 48 | { 49 | const MaterialData m = sb_Material.data[in_Instancing.id]; 50 | 51 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 52 | 53 | const vec3 r = reflect(-l,n); 54 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 55 | const float specularIntensity = max(dot(r,e), 0.0f); 56 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 57 | } 58 | 59 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 60 | }; 61 | -------------------------------------------------------------------------------- /teacher/Scene12CADModelFrustumCullingCPU.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data[]; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | layout(location = IN_DRAWID) in int in_DrawID; 18 | 19 | //------------------------------------------------------------------------------------------------- 20 | // OUTPUTS 21 | //------------------------------------------------------------------------------------------------- 22 | 23 | out Lighting 24 | { 25 | vec3 eyePosition; 26 | vec3 eyeNormal; 27 | } out_Lighting; 28 | 29 | out Instancing 30 | { 31 | flat int id; 32 | } out_Instancing; 33 | 34 | //------------------------------------------------------------------------------------------------- 35 | // MAIN 36 | //------------------------------------------------------------------------------------------------- 37 | 38 | void main() 39 | { 40 | const TransformData t = sb_Transform.data[in_DrawID]; 41 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 42 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 43 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 44 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 45 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 46 | 47 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 48 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 49 | 50 | out_Instancing.id = in_DrawID; 51 | } 52 | -------------------------------------------------------------------------------- /teacher/Scene13CADModelFrustumCullingGPU.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data[]; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | in Instancing 22 | { 23 | flat int id; 24 | } in_Instancing; 25 | 26 | //------------------------------------------------------------------------------------------------- 27 | // OUTPUTS 28 | //------------------------------------------------------------------------------------------------- 29 | 30 | layout(location = OUT_COLOR) out vec4 out_Color; 31 | 32 | //------------------------------------------------------------------------------------------------- 33 | // MAIN 34 | //------------------------------------------------------------------------------------------------- 35 | 36 | // this code assumes light is at camera position (0,0,0 in eye space) 37 | void main() 38 | { 39 | vec3 diffuse = vec3(0.0f); 40 | vec3 specular = vec3(0.0f); 41 | 42 | const vec3 n = normalize(in_Lighting.eyeNormal); 43 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 44 | 45 | float diffuseIntensity = dot(n,l); 46 | 47 | if(diffuseIntensity > 0.0f) 48 | { 49 | const MaterialData m = sb_Material.data[in_Instancing.id]; 50 | 51 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 52 | 53 | const vec3 r = reflect(-l,n); 54 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 55 | const float specularIntensity = max(dot(r,e), 0.0f); 56 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 57 | } 58 | 59 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 60 | }; 61 | -------------------------------------------------------------------------------- /teacher/Scene13CADModelFrustumCullingGPU.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data[]; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | layout(location = IN_DRAWID) in int in_DrawID; 18 | 19 | //------------------------------------------------------------------------------------------------- 20 | // OUTPUTS 21 | //------------------------------------------------------------------------------------------------- 22 | 23 | out Lighting 24 | { 25 | vec3 eyePosition; 26 | vec3 eyeNormal; 27 | } out_Lighting; 28 | 29 | out Instancing 30 | { 31 | flat int id; 32 | } out_Instancing; 33 | 34 | //------------------------------------------------------------------------------------------------- 35 | // MAIN 36 | //------------------------------------------------------------------------------------------------- 37 | 38 | void main() 39 | { 40 | const TransformData t = sb_Transform.data[in_DrawID]; 41 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 42 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 43 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 44 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 45 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 46 | 47 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 48 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 49 | 50 | out_Instancing.id = in_DrawID; 51 | } 52 | -------------------------------------------------------------------------------- /teacher/Scene1CubeNoLighting.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | in Lighting 6 | { 7 | vec3 color; 8 | } in_Lighting; 9 | 10 | //------------------------------------------------------------------------------------------------- 11 | // OUTPUTS 12 | //------------------------------------------------------------------------------------------------- 13 | 14 | layout(location = OUT_COLOR) out vec4 out_Color; 15 | 16 | //------------------------------------------------------------------------------------------------- 17 | // MAIN 18 | //------------------------------------------------------------------------------------------------- 19 | 20 | void main() 21 | { 22 | out_Color = vec4(in_Lighting.color, 1.0f); 23 | }; 24 | -------------------------------------------------------------------------------- /teacher/Scene1CubeNoLighting.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(location = IN_POSITION) in vec3 in_Position; 11 | layout(location = IN_COLOR) in vec3 in_Color; 12 | 13 | //------------------------------------------------------------------------------------------------- 14 | // OUTPUTS 15 | //------------------------------------------------------------------------------------------------- 16 | 17 | out Lighting 18 | { 19 | vec3 color; 20 | } out_Lighting; 21 | 22 | //------------------------------------------------------------------------------------------------- 23 | // MAIN 24 | //------------------------------------------------------------------------------------------------- 25 | 26 | void main() 27 | { 28 | gl_Position = ub_Camera.data.viewProjMatrix * vec4(in_Position, 1.0f); 29 | out_Lighting.color = in_Color; 30 | } 31 | -------------------------------------------------------------------------------- /teacher/Scene2CubeVertexLighting.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | in Lighting 6 | { 7 | vec3 color; 8 | } in_Lighting; 9 | 10 | //------------------------------------------------------------------------------------------------- 11 | // OUTPUTS 12 | //------------------------------------------------------------------------------------------------- 13 | 14 | layout(location = OUT_COLOR) out vec4 out_Color; 15 | 16 | //------------------------------------------------------------------------------------------------- 17 | // MAIN 18 | //------------------------------------------------------------------------------------------------- 19 | 20 | void main() 21 | { 22 | out_Color = vec4(in_Lighting.color, 1.0f); 23 | }; 24 | -------------------------------------------------------------------------------- /teacher/Scene2CubeVertexLighting.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std140, binding = UB_LIGHT) uniform Light 11 | { 12 | LightData data; 13 | } ub_Light; 14 | 15 | layout(std430, binding = SB_MATERIAL) buffer Material 16 | { 17 | readonly MaterialData data; 18 | } sb_Material; 19 | 20 | layout(location = IN_POSITION) in vec3 in_Position; 21 | layout(location = IN_NORMAL) in vec3 in_Normal; 22 | 23 | //------------------------------------------------------------------------------------------------- 24 | // OUTPUTS 25 | //------------------------------------------------------------------------------------------------- 26 | 27 | out Lighting 28 | { 29 | vec3 color; 30 | } out_Lighting; 31 | 32 | //------------------------------------------------------------------------------------------------- 33 | // MAIN 34 | //------------------------------------------------------------------------------------------------- 35 | 36 | void main() 37 | { 38 | gl_Position = ub_Camera.data.viewProjMatrix * vec4(in_Position, 1.0f); 39 | 40 | vec3 eyeNormal = mat3(ub_Camera.data.viewMatrix) * in_Normal; 41 | vec3 eyePosition = vec3(ub_Camera.data.viewMatrix * vec4(in_Position, 1.0f)); 42 | 43 | vec3 diffuse = vec3(0.0f); 44 | vec3 specular = vec3(0.0f); 45 | 46 | const vec3 n = normalize(eyeNormal); 47 | const vec3 l = normalize(-eyePosition); // light - vert = 0 - vert (eye space) 48 | 49 | float diffuseIntensity = dot(n,l); 50 | 51 | if(diffuseIntensity > 0.0f) 52 | { 53 | const MaterialData m = sb_Material.data; 54 | 55 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 56 | 57 | const vec3 r = reflect(-l,n); 58 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 59 | const float specularIntensity = max(dot(r,e), 0.0f); 60 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 61 | } 62 | 63 | out_Lighting.color = vec3(ub_Light.data.ambient) + diffuse + specular; 64 | } 65 | -------------------------------------------------------------------------------- /teacher/Scene3CubeFragLighting.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | //------------------------------------------------------------------------------------------------- 22 | // OUTPUTS 23 | //------------------------------------------------------------------------------------------------- 24 | 25 | layout(location = OUT_COLOR) out vec4 out_Color; 26 | 27 | //------------------------------------------------------------------------------------------------- 28 | // MAIN 29 | //------------------------------------------------------------------------------------------------- 30 | 31 | // this code assumes light is at camera position (0,0,0 in eye space) 32 | void main() 33 | { 34 | vec3 diffuse = vec3(0.0f); 35 | vec3 specular = vec3(0.0f); 36 | 37 | const vec3 n = normalize(in_Lighting.eyeNormal); 38 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 39 | 40 | float diffuseIntensity = dot(n,l); 41 | 42 | if(diffuseIntensity > 0.0f) 43 | { 44 | const MaterialData m = sb_Material.data; 45 | 46 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 47 | 48 | const vec3 r = reflect(-l,n); 49 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 50 | const float specularIntensity = max(dot(r,e), 0.0f); 51 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 52 | } 53 | 54 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 55 | }; 56 | -------------------------------------------------------------------------------- /teacher/Scene3CubeFragLighting.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(location = IN_POSITION) in vec3 in_Position; 11 | layout(location = IN_NORMAL) in vec3 in_Normal; 12 | 13 | //------------------------------------------------------------------------------------------------- 14 | // OUTPUTS 15 | //------------------------------------------------------------------------------------------------- 16 | 17 | out Lighting 18 | { 19 | vec3 eyePosition; 20 | vec3 eyeNormal; 21 | } out_Lighting; 22 | 23 | //------------------------------------------------------------------------------------------------- 24 | // MAIN 25 | //------------------------------------------------------------------------------------------------- 26 | 27 | void main() 28 | { 29 | gl_Position = ub_Camera.data.viewProjMatrix * vec4(in_Position, 1.0f); 30 | 31 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * in_Normal; 32 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * vec4(in_Position, 1.0f)); 33 | } 34 | -------------------------------------------------------------------------------- /teacher/Scene4CubeTexture.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data; 13 | } sb_Material; 14 | 15 | layout(binding = TEX_TEXTURE) uniform sampler2D tex_Texture; 16 | 17 | in Lighting 18 | { 19 | vec3 eyePosition; 20 | vec3 eyeNormal; 21 | vec2 texCoords; 22 | } in_Lighting; 23 | 24 | //------------------------------------------------------------------------------------------------- 25 | // OUTPUTS 26 | //------------------------------------------------------------------------------------------------- 27 | 28 | layout(location = OUT_COLOR) out vec4 out_Color; 29 | 30 | //------------------------------------------------------------------------------------------------- 31 | // MAIN 32 | //------------------------------------------------------------------------------------------------- 33 | 34 | // this code assumes light is at camera position (0,0,0 in eye space) 35 | void main() 36 | { 37 | vec3 diffuse = vec3(0.0f); 38 | vec3 specular = vec3(0.0f); 39 | 40 | const vec3 n = normalize(in_Lighting.eyeNormal); 41 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 42 | 43 | float diffuseIntensity = dot(n,l); 44 | 45 | if(diffuseIntensity > 0.0f) 46 | { 47 | vec3 texColor = texture(tex_Texture, in_Lighting.texCoords).rgb; 48 | 49 | const MaterialData m = sb_Material.data; 50 | 51 | diffuse = vec3(m.diffuse) * texColor * vec3(ub_Light.data.diffuse) * diffuseIntensity; 52 | 53 | const vec3 r = reflect(-l,n); 54 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 55 | const float specularIntensity = max(dot(r,e), 0.0f); 56 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 57 | } 58 | 59 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 60 | }; 61 | -------------------------------------------------------------------------------- /teacher/Scene4CubeTexture.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(location = IN_POSITION) in vec3 in_Position; 11 | layout(location = IN_NORMAL) in vec3 in_Normal; 12 | layout(location = IN_TEXCOORD) in vec2 in_TexCoord; 13 | 14 | //------------------------------------------------------------------------------------------------- 15 | // OUTPUTS 16 | //------------------------------------------------------------------------------------------------- 17 | 18 | out Lighting 19 | { 20 | vec3 eyePosition; 21 | vec3 eyeNormal; 22 | vec2 texCoords; 23 | } out_Lighting; 24 | 25 | //------------------------------------------------------------------------------------------------- 26 | // MAIN 27 | //------------------------------------------------------------------------------------------------- 28 | 29 | void main() 30 | { 31 | gl_Position = ub_Camera.data.viewProjMatrix * vec4(in_Position, 1.0f); 32 | 33 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * in_Normal; 34 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * vec4(in_Position, 1.0f)); 35 | out_Lighting.texCoords = in_TexCoord; 36 | } 37 | -------------------------------------------------------------------------------- /teacher/Scene5ManyCubesIndividual.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | //------------------------------------------------------------------------------------------------- 22 | // OUTPUTS 23 | //------------------------------------------------------------------------------------------------- 24 | 25 | layout(location = OUT_COLOR) out vec4 out_Color; 26 | 27 | //------------------------------------------------------------------------------------------------- 28 | // MAIN 29 | //------------------------------------------------------------------------------------------------- 30 | 31 | // this code assumes light is at camera position (0,0,0 in eye space) 32 | void main() 33 | { 34 | vec3 diffuse = vec3(0.0f); 35 | vec3 specular = vec3(0.0f); 36 | 37 | const vec3 n = normalize(in_Lighting.eyeNormal); 38 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 39 | 40 | float diffuseIntensity = dot(n,l); 41 | 42 | if(diffuseIntensity > 0.0f) 43 | { 44 | const MaterialData m = sb_Material.data; 45 | 46 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 47 | 48 | const vec3 r = reflect(-l,n); 49 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 50 | const float specularIntensity = max(dot(r,e), 0.0f); 51 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 52 | } 53 | 54 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 55 | }; 56 | -------------------------------------------------------------------------------- /teacher/Scene5ManyCubesIndividual.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | 18 | //------------------------------------------------------------------------------------------------- 19 | // OUTPUTS 20 | //------------------------------------------------------------------------------------------------- 21 | 22 | out Lighting 23 | { 24 | vec3 eyePosition; 25 | vec3 eyeNormal; 26 | } out_Lighting; 27 | 28 | //------------------------------------------------------------------------------------------------- 29 | // MAIN 30 | //------------------------------------------------------------------------------------------------- 31 | 32 | void main() 33 | { 34 | const TransformData t = sb_Transform.data; 35 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 36 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 37 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 38 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 39 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 40 | 41 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 42 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 43 | } 44 | -------------------------------------------------------------------------------- /teacher/Scene6ManyCubesInstancing.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data[]; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | in Instancing 22 | { 23 | flat int id; 24 | } in_Instancing; 25 | 26 | //------------------------------------------------------------------------------------------------- 27 | // OUTPUTS 28 | //------------------------------------------------------------------------------------------------- 29 | 30 | layout(location = OUT_COLOR) out vec4 out_Color; 31 | 32 | //------------------------------------------------------------------------------------------------- 33 | // MAIN 34 | //------------------------------------------------------------------------------------------------- 35 | 36 | // this code assumes light is at camera position (0,0,0 in eye space) 37 | void main() 38 | { 39 | vec3 diffuse = vec3(0.0f); 40 | vec3 specular = vec3(0.0f); 41 | 42 | const vec3 n = normalize(in_Lighting.eyeNormal); 43 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 44 | 45 | float diffuseIntensity = dot(n,l); 46 | 47 | if(diffuseIntensity > 0.0f) 48 | { 49 | const MaterialData m = sb_Material.data[in_Instancing.id]; 50 | 51 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 52 | 53 | const vec3 r = reflect(-l,n); 54 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 55 | const float specularIntensity = max(dot(r,e), 0.0f); 56 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 57 | } 58 | 59 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 60 | }; 61 | -------------------------------------------------------------------------------- /teacher/Scene6ManyCubesInstancing.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data[]; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | 18 | //------------------------------------------------------------------------------------------------- 19 | // OUTPUTS 20 | //------------------------------------------------------------------------------------------------- 21 | 22 | out Lighting 23 | { 24 | vec3 eyePosition; 25 | vec3 eyeNormal; 26 | } out_Lighting; 27 | 28 | out Instancing 29 | { 30 | flat int id; 31 | } out_Instancing; 32 | 33 | //------------------------------------------------------------------------------------------------- 34 | // MAIN 35 | //------------------------------------------------------------------------------------------------- 36 | 37 | void main() 38 | { 39 | const TransformData t = sb_Transform.data[gl_InstanceID]; 40 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 41 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 42 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 43 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 44 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 45 | 46 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 47 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 48 | 49 | out_Instancing.id = gl_InstanceID; 50 | } 51 | -------------------------------------------------------------------------------- /teacher/Scene6bManyCubesInstancing.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data[]; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | in Instancing 22 | { 23 | flat int id; 24 | } in_Instancing; 25 | 26 | //------------------------------------------------------------------------------------------------- 27 | // OUTPUTS 28 | //------------------------------------------------------------------------------------------------- 29 | 30 | layout(location = OUT_COLOR) out vec4 out_Color; 31 | 32 | //------------------------------------------------------------------------------------------------- 33 | // MAIN 34 | //------------------------------------------------------------------------------------------------- 35 | 36 | // this code assumes light is at camera position (0,0,0 in eye space) 37 | void main() 38 | { 39 | vec3 diffuse = vec3(0.0f); 40 | vec3 specular = vec3(0.0f); 41 | 42 | const vec3 n = normalize(in_Lighting.eyeNormal); 43 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 44 | 45 | float diffuseIntensity = dot(n,l); 46 | 47 | if(diffuseIntensity > 0.0f) 48 | { 49 | const MaterialData m = sb_Material.data[in_Instancing.id]; 50 | 51 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 52 | 53 | const vec3 r = reflect(-l,n); 54 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 55 | const float specularIntensity = max(dot(r,e), 0.0f); 56 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 57 | } 58 | 59 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 60 | }; 61 | -------------------------------------------------------------------------------- /teacher/Scene6bManyCubesInstancing.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(location = IN_POSITION) in vec3 in_Position; 11 | layout(location = IN_NORMAL) in vec3 in_Normal; 12 | layout(location = IN_TRANSFORM) in vec3 in_Transform; 13 | 14 | //------------------------------------------------------------------------------------------------- 15 | // OUTPUTS 16 | //------------------------------------------------------------------------------------------------- 17 | 18 | out Lighting 19 | { 20 | vec3 eyePosition; 21 | vec3 eyeNormal; 22 | } out_Lighting; 23 | 24 | out Instancing 25 | { 26 | flat int id; 27 | } out_Instancing; 28 | 29 | //------------------------------------------------------------------------------------------------- 30 | // MAIN 31 | //------------------------------------------------------------------------------------------------- 32 | 33 | void main() 34 | { 35 | gl_Position = ub_Camera.data.viewProjMatrix * vec4(in_Position + in_Transform, 1.0f); 36 | 37 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * in_Normal; 38 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * vec4(in_Position, 1.0f)); 39 | 40 | out_Instancing.id = gl_InstanceID; 41 | } 42 | -------------------------------------------------------------------------------- /teacher/Scene7ManyCubesIndividualTexture.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data; 13 | } sb_Material; 14 | 15 | layout(binding = TEX_TEXTURE) uniform sampler2D tex_Texture; 16 | 17 | in Lighting 18 | { 19 | vec3 eyePosition; 20 | vec3 eyeNormal; 21 | vec2 texCoord; 22 | } in_Lighting; 23 | 24 | //------------------------------------------------------------------------------------------------- 25 | // OUTPUTS 26 | //------------------------------------------------------------------------------------------------- 27 | 28 | layout(location = OUT_COLOR) out vec4 out_Color; 29 | 30 | //------------------------------------------------------------------------------------------------- 31 | // MAIN 32 | //------------------------------------------------------------------------------------------------- 33 | 34 | // this code assumes light is at camera position (0,0,0 in eye space) 35 | void main() 36 | { 37 | vec3 diffuse = vec3(0.0f); 38 | vec3 specular = vec3(0.0f); 39 | 40 | const vec3 n = normalize(in_Lighting.eyeNormal); 41 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 42 | 43 | float diffuseIntensity = dot(n,l); 44 | 45 | if(diffuseIntensity > 0.0f) 46 | { 47 | vec3 texColor = texture(tex_Texture, in_Lighting.texCoord).rgb; 48 | 49 | const MaterialData m = sb_Material.data; 50 | 51 | diffuse = vec3(m.diffuse) * texColor * vec3(ub_Light.data.diffuse) * diffuseIntensity; 52 | 53 | const vec3 r = reflect(-l,n); 54 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 55 | const float specularIntensity = max(dot(r,e), 0.0f); 56 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 57 | } 58 | 59 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 60 | }; 61 | -------------------------------------------------------------------------------- /teacher/Scene7ManyCubesIndividualTexture.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | layout(location = IN_TEXCOORD) in vec2 in_TexCoord; 18 | 19 | //------------------------------------------------------------------------------------------------- 20 | // OUTPUTS 21 | //------------------------------------------------------------------------------------------------- 22 | 23 | out Lighting 24 | { 25 | vec3 eyePosition; 26 | vec3 eyeNormal; 27 | vec2 texCoord; 28 | } out_Lighting; 29 | 30 | //------------------------------------------------------------------------------------------------- 31 | // MAIN 32 | //------------------------------------------------------------------------------------------------- 33 | 34 | void main() 35 | { 36 | const TransformData t = sb_Transform.data; 37 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 38 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 39 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 40 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 41 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 42 | 43 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 44 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 45 | 46 | out_Lighting.texCoord = in_TexCoord; 47 | } 48 | -------------------------------------------------------------------------------- /teacher/Scene8ManyCubesInstancingTexture.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data[]; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | layout(location = IN_TEXCOORD) in vec2 in_TexCoord; 18 | 19 | //------------------------------------------------------------------------------------------------- 20 | // OUTPUTS 21 | //------------------------------------------------------------------------------------------------- 22 | 23 | out Lighting 24 | { 25 | vec3 eyePosition; 26 | vec3 eyeNormal; 27 | vec2 texCoord; 28 | } out_Lighting; 29 | 30 | out Instancing 31 | { 32 | flat int id; 33 | } out_Instancing; 34 | 35 | //------------------------------------------------------------------------------------------------- 36 | // MAIN 37 | //------------------------------------------------------------------------------------------------- 38 | 39 | void main() 40 | { 41 | const TransformData t = sb_Transform.data[gl_InstanceID]; 42 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 43 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 44 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 45 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 46 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 47 | 48 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 49 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 50 | 51 | out_Lighting.texCoord = in_TexCoord; 52 | 53 | out_Instancing.id = gl_InstanceID; 54 | } 55 | -------------------------------------------------------------------------------- /teacher/Scene9ManyGeometriesIndividual.frag: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_LIGHT) uniform Light 6 | { 7 | LightData data; 8 | } ub_Light; 9 | 10 | layout(std430, binding = SB_MATERIAL) buffer Material 11 | { 12 | readonly MaterialData data; 13 | } sb_Material; 14 | 15 | in Lighting 16 | { 17 | vec3 eyePosition; 18 | vec3 eyeNormal; 19 | } in_Lighting; 20 | 21 | //------------------------------------------------------------------------------------------------- 22 | // OUTPUTS 23 | //------------------------------------------------------------------------------------------------- 24 | 25 | layout(location = OUT_COLOR) out vec4 out_Color; 26 | 27 | //------------------------------------------------------------------------------------------------- 28 | // MAIN 29 | //------------------------------------------------------------------------------------------------- 30 | 31 | // this code assumes light is at camera position (0,0,0 in eye space) 32 | void main() 33 | { 34 | vec3 diffuse = vec3(0.0f); 35 | vec3 specular = vec3(0.0f); 36 | 37 | const vec3 n = normalize(in_Lighting.eyeNormal); 38 | const vec3 l = normalize(-in_Lighting.eyePosition); // light - vert = 0 - vert (eye space) 39 | 40 | float diffuseIntensity = dot(n,l); 41 | 42 | if(diffuseIntensity > 0.0f) 43 | { 44 | const MaterialData m = sb_Material.data; 45 | 46 | diffuse = vec3(m.diffuse) * vec3(ub_Light.data.diffuse) * diffuseIntensity; 47 | 48 | const vec3 r = reflect(-l,n); 49 | const vec3 e = l; // cam - vert = 0 - vert (eye space) 50 | const float specularIntensity = max(dot(r,e), 0.0f); 51 | specular = vec3(m.specular) * vec3(ub_Light.data.specular) * pow(specularIntensity, m.specular.w); 52 | } 53 | 54 | out_Color = vec4(vec3(ub_Light.data.ambient) + diffuse + specular, 1.0f); 55 | }; 56 | -------------------------------------------------------------------------------- /teacher/Scene9ManyGeometriesIndividual.vert: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------- 2 | // INPUTS 3 | //------------------------------------------------------------------------------------------------- 4 | 5 | layout(std140, binding = UB_CAMERA) uniform Camera 6 | { 7 | CameraData data; 8 | } ub_Camera; 9 | 10 | layout(std430, binding = SB_TRANSFORM) buffer Transform 11 | { 12 | readonly TransformData data; 13 | } sb_Transform; 14 | 15 | layout(location = IN_POSITION) in vec3 in_Position; 16 | layout(location = IN_NORMAL) in vec3 in_Normal; 17 | 18 | //------------------------------------------------------------------------------------------------- 19 | // OUTPUTS 20 | //------------------------------------------------------------------------------------------------- 21 | 22 | out Lighting 23 | { 24 | vec3 eyePosition; 25 | vec3 eyeNormal; 26 | } out_Lighting; 27 | 28 | //------------------------------------------------------------------------------------------------- 29 | // MAIN 30 | //------------------------------------------------------------------------------------------------- 31 | 32 | void main() 33 | { 34 | const TransformData t = sb_Transform.data; 35 | mat4 modelMatrix = mat4(vec4(t.row0.x, t.row1.x, t.row2.x, 0.0f), // col 0 36 | vec4(t.row0.y, t.row1.y, t.row2.y, 0.0f), // col 1 37 | vec4(t.row0.z, t.row1.z, t.row2.z, 0.0f), // col 2 38 | vec4(t.row0.w, t.row1.w, t.row2.w, 1.0f)); // col 3 39 | gl_Position = ub_Camera.data.viewProjMatrix * modelMatrix * vec4(in_Position, 1.0f); 40 | 41 | out_Lighting.eyeNormal = mat3(ub_Camera.data.viewMatrix) * mat3(transpose(inverse(modelMatrix))) * in_Normal; 42 | out_Lighting.eyePosition = vec3(ub_Camera.data.viewMatrix * modelMatrix * vec4(in_Position, 1.0f)); 43 | } 44 | -------------------------------------------------------------------------------- /teacher/ShaderData.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | #pragma once 3 | #include 4 | using namespace glm; 5 | #ifdef near 6 | #undef near 7 | #endif 8 | #ifdef far 9 | #undef far 10 | #endif 11 | #endif 12 | 13 | struct BoundsData 14 | { 15 | vec4 minmax[2]; 16 | }; 17 | 18 | struct Plane 19 | { 20 | float nx; 21 | float ny; 22 | float nz; 23 | float offset; 24 | int px; 25 | int py; 26 | int pz; 27 | }; 28 | 29 | struct FrustumData 30 | { 31 | Plane near; 32 | Plane left; 33 | Plane right; 34 | Plane bottom; 35 | Plane top; 36 | Plane far; 37 | }; 38 | 39 | struct CameraData 40 | { 41 | mat4 viewMatrix; 42 | mat4 viewProjMatrix; 43 | }; 44 | 45 | struct MaterialData 46 | { 47 | vec4 diffuse; 48 | vec4 specular; // w = shininess 49 | }; 50 | 51 | struct TransformData 52 | { 53 | vec4 row0; 54 | vec4 row1; 55 | vec4 row2; 56 | }; 57 | 58 | struct LightData 59 | { 60 | vec4 ambient; 61 | vec4 diffuse; 62 | vec4 specular; 63 | }; 64 | 65 | struct DrawCommand 66 | { 67 | uint elementCount; // count 68 | uint instanceCount; // instanceCount 69 | uint firstElement; // firstIndex 70 | uint baseVertex; // baseVertex 71 | uint baseInstance; // baseInstance 72 | }; 73 | 74 | // Uniform Buffers 75 | #define UB_CAMERA 0 76 | #define UB_LIGHT 1 77 | #define UB_TRANSFORM 2 78 | #define UB_MATERIAL 3 79 | 80 | // Storage Buffers 81 | #define SB_TRANSFORM 0 82 | #define SB_MATERIAL 1 83 | #define SB_TEXTURE 2 84 | #define SB_IN_DRAW_CMD 3 85 | #define SB_OUT_DRAW_CMD 4 86 | #define SB_BOUNDS 5 87 | #define SB_FRUSTUM 6 88 | 89 | // Vertex Attributes 90 | #define IN_POSITION 0 91 | #define IN_NORMAL 1 92 | #define IN_COLOR 2 93 | #define IN_TEXCOORD 3 94 | #define IN_DRAWID 4 95 | #define IN_TRANSFORM 5 96 | 97 | // Fragment Outputs 98 | #define OUT_COLOR 0 99 | #define NUM_FRAG_OUT 1 100 | 101 | // Texture Units 102 | #define TEX_TEXTURE 0 103 | 104 | // Compute Shader 105 | #define CS_BLOCK_SIZE_X 256 106 | 107 | // Uniform Variables 108 | #define U_SCENE_SIZE 0 109 | #define U_RAND_SEED 1 110 | 111 | // Atomic Counters 112 | #define AC_DRAW_COUNT 0 113 | -------------------------------------------------------------------------------- /teacher/Timer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class Timer 5 | { 6 | public: 7 | static int get_resolution(); 8 | Timer(); 9 | void restart(); 10 | double sec(); 11 | double msec(); 12 | double usec(); 13 | double nsec(); 14 | 15 | private: 16 | typedef typename std::conditional::type t_clock; 19 | t_clock::time_point _start; 20 | }; 21 | 22 | int Timer::get_resolution() 23 | { 24 | return t_clock::period::den; 25 | } 26 | 27 | Timer::Timer() 28 | { 29 | restart(); 30 | } 31 | 32 | void Timer::restart() 33 | { 34 | _start = t_clock::now(); 35 | } 36 | 37 | double Timer::sec() 38 | { 39 | return std::chrono::duration(t_clock::now() - _start).count(); 40 | } 41 | 42 | double Timer::msec() 43 | { 44 | return std::chrono::duration(t_clock::now() - _start).count(); 45 | } 46 | 47 | double Timer::usec() 48 | { 49 | return std::chrono::duration(t_clock::now() - _start).count(); 50 | } 51 | 52 | double Timer::nsec() 53 | { 54 | return std::chrono::duration(t_clock::now() - _start).count(); 55 | } 56 | -------------------------------------------------------------------------------- /teacher/tess/geometries.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace tess 5 | { 6 | struct box 7 | { 8 | vec3 extents = {0.0f, 0.0f, 0.0f}; 9 | }; 10 | 11 | struct circular_torus 12 | { 13 | float in_radius = 0.1f; 14 | float out_radius = 0.4f; 15 | float sweep_angle = math::half_pi(); 16 | }; 17 | 18 | struct cone 19 | { 20 | float top_radius = 0.25f; 21 | float bottom_radius = 0.5f; 22 | float height = 1.0f; 23 | }; 24 | 25 | struct cone_offset 26 | { 27 | float top_radius = 0.25f; 28 | float bottom_radius = 0.5f; 29 | float height = 1.0f; 30 | vec2 offset = {0.25f, 0.25f}; 31 | }; 32 | 33 | struct cylinder 34 | { 35 | float radius = 0.5f; 36 | float height = 1.0f; 37 | }; 38 | 39 | struct cylinder_offset 40 | { 41 | float radius = 0.5f; 42 | float height = 1.0f; 43 | vec2 offset = {0.25f, 0.25f}; 44 | }; 45 | 46 | struct dish 47 | { 48 | float radius = 0.5f; 49 | float height = 1.0f; 50 | }; 51 | 52 | struct pyramid 53 | { 54 | vec2 top_extents = {0.25f, 0.25f}; 55 | vec2 bottom_extents = {0.5f, 0.5f}; 56 | vec2 offset = {0.25f, 0.25f}; 57 | float height = 1.0f; 58 | }; 59 | 60 | struct rectangular_torus 61 | { 62 | float in_height = 1.0f; 63 | float in_radius = 0.1f; 64 | float out_radius = 0.4f; 65 | float sweep_angle = math::half_pi(); 66 | }; 67 | 68 | struct sphere 69 | { 70 | float radius = 0.5f; 71 | }; 72 | } // namespace tess 73 | -------------------------------------------------------------------------------- /teacher/tess/mesh_builder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace tess 5 | { 6 | class mesh_builder 7 | { 8 | public: 9 | mesh_builder(); 10 | 11 | void begin(); 12 | void set_primitive_mode(unsigned int mode); 13 | void add_element(element element); 14 | unsigned int add_vertex(const vertex& v); // return index of newly added vertex 15 | const vertex& get_vertex(unsigned int idx); 16 | triangle_mesh end(); 17 | 18 | private: 19 | void _add_triangle(element last_elem); 20 | 21 | void _add_triangle_fan(element last_elem); 22 | 23 | void _add_triangle_strip(element last_elem); 24 | 25 | private: 26 | std::vector _vertices; 27 | std::vector _elements; 28 | unsigned int _curr_prim_mode; 29 | element _curr_elements[2]; // keeps track of last two elements of current triangle 30 | unsigned int _num_curr_elements; 31 | bool _invert_winding; 32 | }; 33 | } // namespace tess 34 | -------------------------------------------------------------------------------- /teacher/tess/mesh_optimizer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace tess 5 | { 6 | class mesh_optimizer 7 | { 8 | public: 9 | typedef unsigned int flag; 10 | 11 | static const flag flag_check_results = 1; // check results for consistency and print any problems found: O(n^2) 12 | static const flag flag_all_optimizations = (~0U) << 1; // enable all optimizations: O(n) 13 | static const flag flag_remove_unused_vertices = 1 << 1; // remove vertices not referenced by any element: O(n) 14 | static const flag flag_weld_vertices_exact = 1 << 2; // merge vertices with exactly the same attributes: O(n) 15 | // todo: static const flag flag_weld_vertices_nearby = 1<<3; // merge nearby vertices using tolerance: O(n) 16 | 17 | void optimize(triangle_mesh& mesh, flag flags); 18 | 19 | private: 20 | std::vector _temp_vertices; 21 | std::vector _temp_elements; 22 | }; 23 | } // namespace tess 24 | -------------------------------------------------------------------------------- /teacher/tess/polygon_tessellator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace tess 5 | { 6 | class polygon_tessellator 7 | { 8 | public: 9 | polygon_tessellator(); 10 | ~polygon_tessellator(); 11 | 12 | void begin(); 13 | void add_polygon(const polygon& poly); 14 | triangle_mesh end(); 15 | 16 | private: 17 | polygon_tessellator(const polygon_tessellator&) = delete; 18 | polygon_tessellator& operator=(const polygon_tessellator&) = delete; 19 | 20 | class impl; 21 | impl* _d; 22 | }; 23 | } // namespace tess 24 | -------------------------------------------------------------------------------- /teacher/tess/triangle_mesh.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace tess 4 | { 5 | // --------------------------------------------------------------------------------------------------------------------------------------------------------- 6 | // vertex 7 | // --------------------------------------------------------------------------------------------------------------------------------------------------------- 8 | 9 | vertex::vertex() 10 | { 11 | } 12 | 13 | vertex::vertex(const vec3& _position, const vec3& _normal) 14 | : position(_position), normal(_normal) 15 | { 16 | } 17 | 18 | bool vertex::operator==(const vertex& other) const 19 | { 20 | return position == other.position && normal == other.normal; 21 | } 22 | 23 | // --------------------------------------------------------------------------------------------------------------------------------------------------------- 24 | // triangle_mesh 25 | // --------------------------------------------------------------------------------------------------------------------------------------------------------- 26 | 27 | bool triangle_mesh::is_valid() const 28 | { 29 | // Check if there are at least 3 vertices and 3 elements to define a triangle 30 | if(vertices.size() < 3 || elements.size() < 3) 31 | { 32 | return false; 33 | } 34 | 35 | // Check if mesh has at least one valid triangle 36 | for(unsigned int i = 0; i < elements.size() - 3; i += 3) 37 | { 38 | if(elements[i] != elements[i+1] && elements[i+1] != elements[i+2]) 39 | { 40 | if(elements[i] >= vertices.size() || elements[i+1] >= vertices.size() || elements[i+2] >= vertices.size()) 41 | { 42 | continue; 43 | } 44 | 45 | const auto& v1 = vertices[elements[i]].position; 46 | const auto& v2 = vertices[elements[i+1]].position; 47 | const auto& v3 = vertices[elements[i+2]].position; 48 | 49 | if(!std::isfinite(v1.x) || !std::isfinite(v1.y) || !std::isfinite(v1.z) || 50 | !std::isfinite(v2.x) || !std::isfinite(v2.y) || !std::isfinite(v2.z) || 51 | !std::isfinite(v3.x) || !std::isfinite(v3.y) || !std::isfinite(v3.z)) 52 | { 53 | continue; 54 | } 55 | 56 | if(v1 == v2 || v2 == v3 || v1 == v3) 57 | { 58 | continue; 59 | } 60 | 61 | return true; 62 | } 63 | } 64 | 65 | return false; 66 | } 67 | } // namespace tess 68 | -------------------------------------------------------------------------------- /teacher/tess/triangle_mesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace tess 9 | { 10 | using namespace glm; 11 | 12 | struct vertex 13 | { 14 | vertex(); 15 | vertex(const vec3& _position, const vec3& _normal); 16 | bool operator==(const vertex& other) const; 17 | 18 | vec3 position; 19 | vec3 normal; 20 | }; 21 | 22 | typedef unsigned int element; 23 | 24 | struct triangle_mesh 25 | { 26 | bool is_valid() const; 27 | void append(const triangle_mesh& other) 28 | { 29 | auto vertexStart = vertices.size(); 30 | auto elementStart = elements.size(); 31 | vertices.insert(vertices.end(), other.vertices.begin(), other.vertices.end()); 32 | elements.insert(elements.end(), other.elements.begin(), other.elements.end()); 33 | for(auto i = elementStart; i < elements.size(); ++i) 34 | { 35 | elements.at(i) += vertexStart; 36 | } 37 | } 38 | 39 | std::vector vertices; 40 | std::vector elements; 41 | }; 42 | } // namespace tess 43 | --------------------------------------------------------------------------------