├── .gitignore ├── CMakeLists.txt ├── CMakePresets.json ├── README.md ├── cmake └── FindGLM.cmake ├── ext ├── glm │ ├── CMakeLists.txt │ ├── common.hpp │ ├── detail │ │ ├── _features.hpp │ │ ├── _fixes.hpp │ │ ├── _noise.hpp │ │ ├── _swizzle.hpp │ │ ├── _swizzle_func.hpp │ │ ├── _vectorize.hpp │ │ ├── compute_common.hpp │ │ ├── compute_vector_relational.hpp │ │ ├── func_common.inl │ │ ├── func_common_simd.inl │ │ ├── func_exponential.inl │ │ ├── func_exponential_simd.inl │ │ ├── func_geometric.inl │ │ ├── func_geometric_simd.inl │ │ ├── func_integer.inl │ │ ├── func_integer_simd.inl │ │ ├── func_matrix.inl │ │ ├── func_matrix_simd.inl │ │ ├── func_packing.inl │ │ ├── func_packing_simd.inl │ │ ├── func_trigonometric.inl │ │ ├── func_trigonometric_simd.inl │ │ ├── func_vector_relational.inl │ │ ├── func_vector_relational_simd.inl │ │ ├── glm.cpp │ │ ├── qualifier.hpp │ │ ├── setup.hpp │ │ ├── type_float.hpp │ │ ├── type_half.hpp │ │ ├── type_half.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_mat4x4_simd.inl │ │ ├── type_quat.hpp │ │ ├── type_quat.inl │ │ ├── type_quat_simd.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_simd.inl │ ├── exponential.hpp │ ├── ext.hpp │ ├── ext │ │ ├── matrix_clip_space.hpp │ │ ├── matrix_clip_space.inl │ │ ├── matrix_common.hpp │ │ ├── matrix_common.inl │ │ ├── matrix_double2x2.hpp │ │ ├── matrix_double2x2_precision.hpp │ │ ├── matrix_double2x3.hpp │ │ ├── matrix_double2x3_precision.hpp │ │ ├── matrix_double2x4.hpp │ │ ├── matrix_double2x4_precision.hpp │ │ ├── matrix_double3x2.hpp │ │ ├── matrix_double3x2_precision.hpp │ │ ├── matrix_double3x3.hpp │ │ ├── matrix_double3x3_precision.hpp │ │ ├── matrix_double3x4.hpp │ │ ├── matrix_double3x4_precision.hpp │ │ ├── matrix_double4x2.hpp │ │ ├── matrix_double4x2_precision.hpp │ │ ├── matrix_double4x3.hpp │ │ ├── matrix_double4x3_precision.hpp │ │ ├── matrix_double4x4.hpp │ │ ├── matrix_double4x4_precision.hpp │ │ ├── matrix_float2x2.hpp │ │ ├── matrix_float2x2_precision.hpp │ │ ├── matrix_float2x3.hpp │ │ ├── matrix_float2x3_precision.hpp │ │ ├── matrix_float2x4.hpp │ │ ├── matrix_float2x4_precision.hpp │ │ ├── matrix_float3x2.hpp │ │ ├── matrix_float3x2_precision.hpp │ │ ├── matrix_float3x3.hpp │ │ ├── matrix_float3x3_precision.hpp │ │ ├── matrix_float3x4.hpp │ │ ├── matrix_float3x4_precision.hpp │ │ ├── matrix_float4x2.hpp │ │ ├── matrix_float4x2_precision.hpp │ │ ├── matrix_float4x3.hpp │ │ ├── matrix_float4x3_precision.hpp │ │ ├── matrix_float4x4.hpp │ │ ├── matrix_float4x4_precision.hpp │ │ ├── matrix_projection.hpp │ │ ├── matrix_projection.inl │ │ ├── matrix_relational.hpp │ │ ├── matrix_relational.inl │ │ ├── matrix_transform.hpp │ │ ├── matrix_transform.inl │ │ ├── quaternion_common.hpp │ │ ├── quaternion_common.inl │ │ ├── quaternion_common_simd.inl │ │ ├── quaternion_double.hpp │ │ ├── quaternion_double_precision.hpp │ │ ├── quaternion_exponential.hpp │ │ ├── quaternion_exponential.inl │ │ ├── quaternion_float.hpp │ │ ├── quaternion_float_precision.hpp │ │ ├── quaternion_geometric.hpp │ │ ├── quaternion_geometric.inl │ │ ├── quaternion_relational.hpp │ │ ├── quaternion_relational.inl │ │ ├── quaternion_transform.hpp │ │ ├── quaternion_transform.inl │ │ ├── quaternion_trigonometric.hpp │ │ ├── quaternion_trigonometric.inl │ │ ├── scalar_common.hpp │ │ ├── scalar_common.inl │ │ ├── scalar_constants.hpp │ │ ├── scalar_constants.inl │ │ ├── scalar_int_sized.hpp │ │ ├── scalar_integer.hpp │ │ ├── scalar_integer.inl │ │ ├── scalar_packing.hpp │ │ ├── scalar_packing.inl │ │ ├── scalar_relational.hpp │ │ ├── scalar_relational.inl │ │ ├── scalar_uint_sized.hpp │ │ ├── scalar_ulp.hpp │ │ ├── scalar_ulp.inl │ │ ├── vector_bool1.hpp │ │ ├── vector_bool1_precision.hpp │ │ ├── vector_bool2.hpp │ │ ├── vector_bool2_precision.hpp │ │ ├── vector_bool3.hpp │ │ ├── vector_bool3_precision.hpp │ │ ├── vector_bool4.hpp │ │ ├── vector_bool4_precision.hpp │ │ ├── vector_common.hpp │ │ ├── vector_common.inl │ │ ├── vector_double1.hpp │ │ ├── vector_double1_precision.hpp │ │ ├── vector_double2.hpp │ │ ├── vector_double2_precision.hpp │ │ ├── vector_double3.hpp │ │ ├── vector_double3_precision.hpp │ │ ├── vector_double4.hpp │ │ ├── vector_double4_precision.hpp │ │ ├── vector_float1.hpp │ │ ├── vector_float1_precision.hpp │ │ ├── vector_float2.hpp │ │ ├── vector_float2_precision.hpp │ │ ├── vector_float3.hpp │ │ ├── vector_float3_precision.hpp │ │ ├── vector_float4.hpp │ │ ├── vector_float4_precision.hpp │ │ ├── vector_int1.hpp │ │ ├── vector_int1_precision.hpp │ │ ├── vector_int1_sized.hpp │ │ ├── vector_int2.hpp │ │ ├── vector_int2_precision.hpp │ │ ├── vector_int2_sized.hpp │ │ ├── vector_int3.hpp │ │ ├── vector_int3_precision.hpp │ │ ├── vector_int3_sized.hpp │ │ ├── vector_int4.hpp │ │ ├── vector_int4_precision.hpp │ │ ├── vector_int4_sized.hpp │ │ ├── vector_integer.hpp │ │ ├── vector_integer.inl │ │ ├── vector_packing.hpp │ │ ├── vector_packing.inl │ │ ├── vector_relational.hpp │ │ ├── vector_relational.inl │ │ ├── vector_uint1.hpp │ │ ├── vector_uint1_precision.hpp │ │ ├── vector_uint1_sized.hpp │ │ ├── vector_uint2.hpp │ │ ├── vector_uint2_precision.hpp │ │ ├── vector_uint2_sized.hpp │ │ ├── vector_uint3.hpp │ │ ├── vector_uint3_precision.hpp │ │ ├── vector_uint3_sized.hpp │ │ ├── vector_uint4.hpp │ │ ├── vector_uint4_precision.hpp │ │ ├── vector_uint4_sized.hpp │ │ ├── vector_ulp.hpp │ │ └── vector_ulp.inl │ ├── 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 │ │ ├── quaternion_simd.inl │ │ ├── random.hpp │ │ ├── random.inl │ │ ├── reciprocal.hpp │ │ ├── reciprocal.inl │ │ ├── round.hpp │ │ ├── round.inl │ │ ├── type_aligned.hpp │ │ ├── type_precision.hpp │ │ ├── type_precision.inl │ │ ├── type_ptr.hpp │ │ ├── type_ptr.inl │ │ ├── ulp.hpp │ │ ├── ulp.inl │ │ └── vec1.hpp │ ├── gtx │ │ ├── associated_min_max.hpp │ │ ├── associated_min_max.inl │ │ ├── bit.hpp │ │ ├── bit.inl │ │ ├── closest_point.hpp │ │ ├── closest_point.inl │ │ ├── color_encoding.hpp │ │ ├── color_encoding.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 │ │ ├── easing.hpp │ │ ├── easing.inl │ │ ├── euler_angles.hpp │ │ ├── euler_angles.inl │ │ ├── extend.hpp │ │ ├── extend.inl │ │ ├── extended_min_max.hpp │ │ ├── extended_min_max.inl │ │ ├── exterior_product.hpp │ │ ├── exterior_product.inl │ │ ├── fast_exponential.hpp │ │ ├── fast_exponential.inl │ │ ├── fast_square_root.hpp │ │ ├── fast_square_root.inl │ │ ├── fast_trigonometry.hpp │ │ ├── fast_trigonometry.inl │ │ ├── float_notmalize.inl │ │ ├── functions.hpp │ │ ├── functions.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_factorisation.hpp │ │ ├── matrix_factorisation.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 │ │ ├── spline.hpp │ │ ├── spline.inl │ │ ├── std_based_type.hpp │ │ ├── std_based_type.inl │ │ ├── string_cast.hpp │ │ ├── string_cast.inl │ │ ├── texture.hpp │ │ ├── texture.inl │ │ ├── transform.hpp │ │ ├── transform.inl │ │ ├── transform2.hpp │ │ ├── transform2.inl │ │ ├── type_aligned.hpp │ │ ├── type_aligned.inl │ │ ├── type_trait.hpp │ │ ├── type_trait.inl │ │ ├── vec_swizzle.hpp │ │ ├── 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 │ │ ├── common.h │ │ ├── exponential.h │ │ ├── geometric.h │ │ ├── integer.h │ │ ├── matrix.h │ │ ├── neon.h │ │ ├── packing.h │ │ ├── platform.h │ │ ├── trigonometric.h │ │ └── vector_relational.h │ ├── trigonometric.hpp │ ├── vec2.hpp │ ├── vec3.hpp │ ├── vec4.hpp │ └── vector_relational.hpp ├── stb_image │ ├── stb_image.cpp │ ├── stb_image.h │ └── stb_image_write.h ├── tiny_obj_loader.cpp └── tiny_obj_loader.h ├── img ├── fireplace.jpg ├── fireplace2.jpg ├── fireplace_weight.jpg ├── mis_weight_s.jpg └── penn.png ├── include ├── Core │ ├── AABB.h │ ├── BSDF.h │ ├── BVH.h │ ├── Camera.h │ ├── Color.h │ ├── Environment.h │ ├── Hittable.h │ ├── Integrator.h │ ├── Light.h │ ├── Math.h │ ├── Microfacet.h │ ├── Object.h │ ├── PhaseFunction.h │ ├── PiecewiseDistrib.h │ ├── Ray.h │ ├── Sampler.h │ ├── Scene.h │ ├── Shape.h │ ├── Spectrum.h │ ├── SurfaceInfo.h │ ├── SurfaceIntr.h │ ├── Texture.h │ ├── ToneMapping.h │ └── Transform.h ├── SceneLoader.h ├── Utils │ ├── Buffer.h │ ├── Buffer2D.h │ ├── EnumBitField.h │ ├── Error.h │ ├── File.h │ ├── FrameBufferDouble.h │ ├── ImageSave.h │ ├── NamespaceDecl.h │ ├── ObjReader.h │ ├── RandomGenerator.h │ ├── SobolMatrices1024x52.h │ ├── TempAssignment.h │ └── Timer.h ├── Zillum.h ├── glmIncluder.h └── stbIncluder.h └── src ├── Accelerator ├── AABB.cpp └── BVH.cpp ├── Integrator ├── AmbientOcclusion.cpp ├── BDPT.cpp ├── Integrator.cpp ├── LightPath.cpp ├── Path.cpp └── TriplePath.cpp ├── Math ├── Math.cpp ├── PiecewiseDistrib.cpp ├── ToneMapping.cpp └── Transform.cpp ├── Medium └── PhaseFunction.cpp ├── Sampler ├── Independent.cpp └── Sobol.cpp ├── Scene ├── Camera │ ├── Camera.cpp │ ├── Panorama.cpp │ └── ThinLens.cpp ├── Environment │ ├── MonoColor.cpp │ └── SphereMapHDR.cpp ├── Light.cpp ├── Scene.cpp └── Shape │ ├── MeshTriangle.cpp │ ├── Quad.cpp │ ├── Sphere.cpp │ └── Triangle.cpp ├── SceneLoader.cpp ├── Surface ├── BSDF │ ├── ClearCoat.cpp │ ├── Dielectric.cpp │ ├── Disney.cpp │ ├── Lambert.cpp │ ├── Layered.cpp │ ├── Metal.cpp │ ├── MetallicWorkflow.cpp │ ├── Mirror.cpp │ └── ThinDielectric.cpp └── Microfacet │ ├── GTR1.cpp │ ├── GTR2.cpp │ └── Microfacet.cpp ├── Zillum.cpp └── main.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | /version/ 2 | /.vscode 3 | /res 4 | /screenshot 5 | /out 6 | /build 7 | .vs/ 8 | *.exe 9 | *.o 10 | *.ps1 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zillum 2 | 3 | CPU Physically Based Renderer 4 | 5 | - [*ZillumGL - OpenGL version*](https://github.com/HummaWhite/ZillumGL) 6 | - [*Blogs*](https://hummawhite.github.io/posts) 7 | 8 | ![](./img/fireplace.jpg) 9 | 10 | ![](https://hummawhite.github.io/img/pt_bdpt_lpt.png) 11 | 12 | ![](./img/fireplace2.jpg) 13 | 14 | #### Implemented light transport methods 15 | 16 | - Path Tracing 17 | - Adjoint Particle Tracing (Light Tracing) 18 | - Bidirectional Path Tracing 19 | 20 | #### Other features 21 | 22 | - Microfacet BSDF 23 | - Environment light importance sampling 24 | - MTBVH 25 | - Sobol sampler 26 | 27 | #### Currently or potentially working on 28 | 29 | - Photon Mapping family (PM, PPM, SPPM) 30 | - Metropolis Light Transport 31 | - BSSRDF 32 | - Participating Media 33 | - **VERTEX CONNECTION AND MERGING** 34 | - ... 35 | 36 | ### Bidirectional Path Tracing 37 | 38 | Visualization of different connection strategies and their MIS weights 39 | 40 | ![](./img/mis_weight_s.jpg) 41 | 42 |
Unweighted, MIS weight, weighted
43 | 44 | ![](./img/fireplace_weight.jpg) 45 | -------------------------------------------------------------------------------- /cmake/FindGLM.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Find GLM 3 | # 4 | # Try to find GLM : OpenGL Mathematics. 5 | # This module defines 6 | # - GLM_INCLUDE_DIRS 7 | # - GLM_FOUND 8 | # 9 | # The following variables can be set as arguments for the module. 10 | # - GLM_ROOT_DIR : Root library directory of GLM 11 | # 12 | # References: 13 | # - https://github.com/Groovounet/glm/blob/master/util/FindGLM.cmake 14 | # - https://bitbucket.org/alfonse/gltut/src/28636298c1c0/glm-0.9.0.7/FindGLM.cmake 15 | # 16 | 17 | # Additional modules 18 | include(FindPackageHandleStandardArgs) 19 | 20 | if (WIN32) 21 | # Find include files 22 | find_path( 23 | GLM_INCLUDE_DIR 24 | NAMES glm/glm.hpp 25 | PATHS 26 | $ENV{PROGRAMFILES}/include 27 | ${GLM_ROOT_DIR} 28 | DOC "The directory where glm/glm.hpp resides") 29 | else() 30 | # Find include files 31 | find_path( 32 | GLM_INCLUDE_DIR 33 | NAMES glm/glm.hpp 34 | PATHS 35 | /usr/include 36 | /usr/local/include 37 | /sw/include 38 | /opt/local/include 39 | ${GLM_ROOT_DIR} 40 | DOC "The directory where glm/glm.hpp resides") 41 | endif() 42 | 43 | # Handle REQUIRD argument, define *_FOUND variable 44 | find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIR) 45 | 46 | # Define GLM_INCLUDE_DIRS 47 | if (GLM_FOUND) 48 | set(GLM_INCLUDE_DIRS ${GLM_INCLUDE_DIR}) 49 | endif() 50 | 51 | # Hide some variables 52 | mark_as_advanced(GLM_INCLUDE_DIR) 53 | -------------------------------------------------------------------------------- /ext/glm/detail/_fixes.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //! Workaround for compatibility with other libraries 4 | #ifdef max 5 | #undef max 6 | #endif 7 | 8 | //! Workaround for compatibility with other libraries 9 | #ifdef min 10 | #undef min 11 | #endif 12 | 13 | //! Workaround for Android 14 | #ifdef isnan 15 | #undef isnan 16 | #endif 17 | 18 | //! Workaround for Android 19 | #ifdef isinf 20 | #undef isinf 21 | #endif 22 | 23 | //! Workaround for Chrone Native Client 24 | #ifdef log2 25 | #undef log2 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /ext/glm/detail/compute_common.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "setup.hpp" 4 | #include 5 | 6 | namespace glm{ 7 | namespace detail 8 | { 9 | template 10 | struct compute_abs 11 | {}; 12 | 13 | template 14 | struct compute_abs 15 | { 16 | GLM_FUNC_QUALIFIER GLM_CONSTEXPR static genFIType call(genFIType x) 17 | { 18 | GLM_STATIC_ASSERT( 19 | std::numeric_limits::is_iec559 || std::numeric_limits::is_signed, 20 | "'abs' only accept floating-point and integer scalar or vector inputs"); 21 | 22 | return x >= genFIType(0) ? x : -x; 23 | // TODO, perf comp with: *(((int *) &x) + 1) &= 0x7fffffff; 24 | } 25 | }; 26 | 27 | #if GLM_COMPILER & GLM_COMPILER_CUDA 28 | template<> 29 | struct compute_abs 30 | { 31 | GLM_FUNC_QUALIFIER GLM_CONSTEXPR static float call(float x) 32 | { 33 | return fabsf(x); 34 | } 35 | }; 36 | #endif 37 | 38 | template 39 | struct compute_abs 40 | { 41 | GLM_FUNC_QUALIFIER GLM_CONSTEXPR static genFIType call(genFIType x) 42 | { 43 | GLM_STATIC_ASSERT( 44 | (!std::numeric_limits::is_signed && std::numeric_limits::is_integer), 45 | "'abs' only accept floating-point and integer scalar or vector inputs"); 46 | return x; 47 | } 48 | }; 49 | }//namespace detail 50 | }//namespace glm 51 | -------------------------------------------------------------------------------- /ext/glm/detail/compute_vector_relational.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //#include "compute_common.hpp" 4 | #include "setup.hpp" 5 | #include 6 | 7 | namespace glm{ 8 | namespace detail 9 | { 10 | template 11 | struct compute_equal 12 | { 13 | GLM_FUNC_QUALIFIER GLM_CONSTEXPR static bool call(T a, T b) 14 | { 15 | return a == b; 16 | } 17 | }; 18 | /* 19 | template 20 | struct compute_equal 21 | { 22 | GLM_FUNC_QUALIFIER GLM_CONSTEXPR static bool call(T a, T b) 23 | { 24 | return detail::compute_abs::is_signed>::call(b - a) <= static_cast(0); 25 | //return std::memcmp(&a, &b, sizeof(T)) == 0; 26 | } 27 | }; 28 | */ 29 | }//namespace detail 30 | }//namespace glm 31 | -------------------------------------------------------------------------------- /ext/glm/detail/func_exponential_simd.inl: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/detail/func_exponential_simd.inl 3 | 4 | #include "../simd/exponential.h" 5 | 6 | #if GLM_ARCH & GLM_ARCH_SSE2_BIT 7 | 8 | namespace glm{ 9 | namespace detail 10 | { 11 | template 12 | struct compute_sqrt<4, float, Q, true> 13 | { 14 | GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& v) 15 | { 16 | vec<4, float, Q> Result; 17 | Result.data = _mm_sqrt_ps(v.data); 18 | return Result; 19 | } 20 | }; 21 | 22 | # if GLM_CONFIG_ALIGNED_GENTYPES == GLM_ENABLE 23 | template<> 24 | struct compute_sqrt<4, float, aligned_lowp, true> 25 | { 26 | GLM_FUNC_QUALIFIER static vec<4, float, aligned_lowp> call(vec<4, float, aligned_lowp> const& v) 27 | { 28 | vec<4, float, aligned_lowp> Result; 29 | Result.data = glm_vec4_sqrt_lowp(v.data); 30 | return Result; 31 | } 32 | }; 33 | # endif 34 | }//namespace detail 35 | }//namespace glm 36 | 37 | #endif//GLM_ARCH & GLM_ARCH_SSE2_BIT 38 | -------------------------------------------------------------------------------- /ext/glm/detail/func_packing_simd.inl: -------------------------------------------------------------------------------- 1 | namespace glm{ 2 | namespace detail 3 | { 4 | 5 | }//namespace detail 6 | }//namespace glm 7 | -------------------------------------------------------------------------------- /ext/glm/detail/func_trigonometric_simd.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HummaWhite/Zillum/f5cbec605e7c24ee4dd0f29917ce102ee310ef4f/ext/glm/detail/func_trigonometric_simd.inl -------------------------------------------------------------------------------- /ext/glm/detail/func_vector_relational_simd.inl: -------------------------------------------------------------------------------- 1 | namespace glm{ 2 | namespace detail 3 | { 4 | 5 | }//namespace detail 6 | }//namespace glm 7 | -------------------------------------------------------------------------------- /ext/glm/detail/type_half.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "setup.hpp" 4 | 5 | namespace glm{ 6 | namespace detail 7 | { 8 | typedef short hdata; 9 | 10 | GLM_FUNC_DECL float toFloat32(hdata value); 11 | GLM_FUNC_DECL hdata toFloat16(float const& value); 12 | 13 | }//namespace detail 14 | }//namespace glm 15 | 16 | #include "type_half.inl" 17 | -------------------------------------------------------------------------------- /ext/glm/detail/type_mat4x4_simd.inl: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | 3 | namespace glm 4 | { 5 | 6 | }//namespace glm 7 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_common.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_matrix_common 2 | /// @file glm/ext/matrix_common.hpp 3 | /// 4 | /// @defgroup ext_matrix_common GLM_EXT_matrix_common 5 | /// @ingroup ext 6 | /// 7 | /// Defines functions for common matrix operations. 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// @see ext_matrix_common 12 | 13 | #pragma once 14 | 15 | #include "../detail/qualifier.hpp" 16 | #include "../detail/_fixes.hpp" 17 | 18 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 19 | # pragma message("GLM: GLM_EXT_matrix_transform extension included") 20 | #endif 21 | 22 | namespace glm 23 | { 24 | /// @addtogroup ext_matrix_common 25 | /// @{ 26 | 27 | template 28 | GLM_FUNC_DECL mat mix(mat const& x, mat const& y, mat const& a); 29 | 30 | template 31 | GLM_FUNC_DECL mat mix(mat const& x, mat const& y, U a); 32 | 33 | /// @} 34 | }//namespace glm 35 | 36 | #include "matrix_common.inl" 37 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_common.inl: -------------------------------------------------------------------------------- 1 | #include "../matrix.hpp" 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER mat mix(mat const& x, mat const& y, U a) 7 | { 8 | return mat(x) * (static_cast(1) - a) + mat(y) * a; 9 | } 10 | 11 | template 12 | GLM_FUNC_QUALIFIER mat mix(mat const& x, mat const& y, mat const& a) 13 | { 14 | return matrixCompMult(mat(x), static_cast(1) - a) + matrixCompMult(mat(y), a); 15 | } 16 | }//namespace glm 17 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_double2x2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_double2x2.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat2x2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 2 columns of 2 components matrix of double-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<2, 2, double, defaultp> dmat2x2; 16 | 17 | /// 2 columns of 2 components matrix of double-precision floating-point numbers. 18 | /// 19 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 20 | typedef mat<2, 2, double, defaultp> dmat2; 21 | 22 | /// @} 23 | }//namespace glm 24 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_double2x3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_double2x3.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat2x3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 2 columns of 3 components matrix of double-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<2, 3, double, defaultp> dmat2x3; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_double2x3_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_double2x3_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat2x3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix_precision 10 | /// @{ 11 | 12 | /// 2 columns of 3 components matrix of double-precision floating-point numbers using low precision arithmetic in term of ULPs. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef mat<2, 3, double, lowp> lowp_dmat2x3; 17 | 18 | /// 2 columns of 3 components matrix of double-precision floating-point numbers using medium precision arithmetic in term of ULPs. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef mat<2, 3, double, mediump> mediump_dmat2x3; 23 | 24 | /// 2 columns of 3 components matrix of double-precision floating-point numbers using medium precision arithmetic in term of ULPs. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef mat<2, 3, double, highp> highp_dmat2x3; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_double2x4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_double2x4.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat2x4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 2 columns of 4 components matrix of double-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<2, 4, double, defaultp> dmat2x4; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_double2x4_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_double2x4_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat2x4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix_precision 10 | /// @{ 11 | 12 | /// 2 columns of 4 components matrix of double-precision floating-point numbers using low precision arithmetic in term of ULPs. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef mat<2, 4, double, lowp> lowp_dmat2x4; 17 | 18 | /// 2 columns of 4 components matrix of double-precision floating-point numbers using medium precision arithmetic in term of ULPs. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef mat<2, 4, double, mediump> mediump_dmat2x4; 23 | 24 | /// 2 columns of 4 components matrix of double-precision floating-point numbers using medium precision arithmetic in term of ULPs. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef mat<2, 4, double, highp> highp_dmat2x4; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_double3x2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_double3x2.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat3x2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 3 columns of 2 components matrix of double-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<3, 2, double, defaultp> dmat3x2; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_double3x2_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_double3x2_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat3x2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix_precision 10 | /// @{ 11 | 12 | /// 3 columns of 2 components matrix of double-precision floating-point numbers using low precision arithmetic in term of ULPs. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef mat<3, 2, double, lowp> lowp_dmat3x2; 17 | 18 | /// 3 columns of 2 components matrix of double-precision floating-point numbers using medium precision arithmetic in term of ULPs. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef mat<3, 2, double, mediump> mediump_dmat3x2; 23 | 24 | /// 3 columns of 2 components matrix of double-precision floating-point numbers using medium precision arithmetic in term of ULPs. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef mat<3, 2, double, highp> highp_dmat3x2; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_double3x3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_double3x3.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat3x3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 3 columns of 3 components matrix of double-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<3, 3, double, defaultp> dmat3x3; 16 | 17 | /// 3 columns of 3 components matrix of double-precision floating-point numbers. 18 | /// 19 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 20 | typedef mat<3, 3, double, defaultp> dmat3; 21 | 22 | /// @} 23 | }//namespace glm 24 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_double3x4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_double3x4.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat3x4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 3 columns of 4 components matrix of double-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<3, 4, double, defaultp> dmat3x4; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_double4x2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_double4x2.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat4x2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 4 columns of 2 components matrix of double-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<4, 2, double, defaultp> dmat4x2; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_double4x3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_double4x3.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat4x3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 4 columns of 3 components matrix of double-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<4, 3, double, defaultp> dmat4x3; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_double4x4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_double4x4.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat4x4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 4 columns of 4 components matrix of double-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<4, 4, double, defaultp> dmat4x4; 16 | 17 | /// 4 columns of 4 components matrix of double-precision floating-point numbers. 18 | /// 19 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 20 | typedef mat<4, 4, double, defaultp> dmat4; 21 | 22 | /// @} 23 | }//namespace glm 24 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_float2x2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_float2x2.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat2x2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 2 columns of 2 components matrix of single-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<2, 2, float, defaultp> mat2x2; 16 | 17 | /// 2 columns of 2 components matrix of single-precision floating-point numbers. 18 | /// 19 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 20 | typedef mat<2, 2, float, defaultp> mat2; 21 | 22 | /// @} 23 | }//namespace glm 24 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_float2x3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_float2x3.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat2x3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 2 columns of 3 components matrix of single-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<2, 3, float, defaultp> mat2x3; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_float2x3_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_float2x3_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat2x3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix_precision 10 | /// @{ 11 | 12 | /// 2 columns of 3 components matrix of single-precision floating-point numbers using low precision arithmetic in term of ULPs. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef mat<2, 3, float, lowp> lowp_mat2x3; 17 | 18 | /// 2 columns of 3 components matrix of single-precision floating-point numbers using medium precision arithmetic in term of ULPs. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef mat<2, 3, float, mediump> mediump_mat2x3; 23 | 24 | /// 2 columns of 3 components matrix of single-precision floating-point numbers using high precision arithmetic in term of ULPs. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef mat<2, 3, float, highp> highp_mat2x3; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_float2x4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_float2x4.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat2x4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 2 columns of 4 components matrix of single-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<2, 4, float, defaultp> mat2x4; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_float2x4_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_float2x4_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat2x4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix_precision 10 | /// @{ 11 | 12 | /// 2 columns of 4 components matrix of single-precision floating-point numbers using low precision arithmetic in term of ULPs. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef mat<2, 4, float, lowp> lowp_mat2x4; 17 | 18 | /// 2 columns of 4 components matrix of single-precision floating-point numbers using medium precision arithmetic in term of ULPs. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef mat<2, 4, float, mediump> mediump_mat2x4; 23 | 24 | /// 2 columns of 4 components matrix of single-precision floating-point numbers using high precision arithmetic in term of ULPs. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef mat<2, 4, float, highp> highp_mat2x4; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_float3x2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_float3x2.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat3x2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core 10 | /// @{ 11 | 12 | /// 3 columns of 2 components matrix of single-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<3, 2, float, defaultp> mat3x2; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_float3x2_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_float3x2_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat3x2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix_precision 10 | /// @{ 11 | 12 | /// 3 columns of 2 components matrix of single-precision floating-point numbers using low precision arithmetic in term of ULPs. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef mat<3, 2, float, lowp> lowp_mat3x2; 17 | 18 | /// 3 columns of 2 components matrix of single-precision floating-point numbers using medium precision arithmetic in term of ULPs. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef mat<3, 2, float, mediump> mediump_mat3x2; 23 | 24 | /// 3 columns of 2 components matrix of single-precision floating-point numbers using high precision arithmetic in term of ULPs. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef mat<3, 2, float, highp> highp_mat3x2; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_float3x3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_float3x3.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat3x3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 3 columns of 3 components matrix of single-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<3, 3, float, defaultp> mat3x3; 16 | 17 | /// 3 columns of 3 components matrix of single-precision floating-point numbers. 18 | /// 19 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 20 | typedef mat<3, 3, float, defaultp> mat3; 21 | 22 | /// @} 23 | }//namespace glm 24 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_float3x4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_float3x4.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat3x4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 3 columns of 4 components matrix of single-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<3, 4, float, defaultp> mat3x4; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_float3x4_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_float3x4_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat3x4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix_precision 10 | /// @{ 11 | 12 | /// 3 columns of 4 components matrix of single-precision floating-point numbers using low precision arithmetic in term of ULPs. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef mat<3, 4, float, lowp> lowp_mat3x4; 17 | 18 | /// 3 columns of 4 components matrix of single-precision floating-point numbers using medium precision arithmetic in term of ULPs. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef mat<3, 4, float, mediump> mediump_mat3x4; 23 | 24 | /// 3 columns of 4 components matrix of single-precision floating-point numbers using high precision arithmetic in term of ULPs. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef mat<3, 4, float, highp> highp_mat3x4; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_float4x2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_float4x2.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat4x2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 4 columns of 2 components matrix of single-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<4, 2, float, defaultp> mat4x2; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_float4x2_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_float2x2_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat2x2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix_precision 10 | /// @{ 11 | 12 | /// 4 columns of 2 components matrix of single-precision floating-point numbers using low precision arithmetic in term of ULPs. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef mat<4, 2, float, lowp> lowp_mat4x2; 17 | 18 | /// 4 columns of 2 components matrix of single-precision floating-point numbers using medium precision arithmetic in term of ULPs. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef mat<4, 2, float, mediump> mediump_mat4x2; 23 | 24 | /// 4 columns of 2 components matrix of single-precision floating-point numbers using high precision arithmetic in term of ULPs. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef mat<4, 2, float, highp> highp_mat4x2; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_float4x3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_float4x3.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat4x3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix 10 | /// @{ 11 | 12 | /// 4 columns of 3 components matrix of single-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<4, 3, float, defaultp> mat4x3; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_float4x3_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_float4x3_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat4x3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_matrix_precision 10 | /// @{ 11 | 12 | /// 4 columns of 3 components matrix of single-precision floating-point numbers using low precision arithmetic in term of ULPs. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef mat<4, 3, float, lowp> lowp_mat4x3; 17 | 18 | /// 4 columns of 3 components matrix of single-precision floating-point numbers using medium precision arithmetic in term of ULPs. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef mat<4, 3, float, mediump> mediump_mat4x3; 23 | 24 | /// 4 columns of 3 components matrix of single-precision floating-point numbers using high precision arithmetic in term of ULPs. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef mat<4, 3, float, highp> highp_mat4x3; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/matrix_float4x4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/matrix_float4x4.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_mat4x4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @ingroup core_matrix 10 | /// @{ 11 | 12 | /// 4 columns of 4 components matrix of single-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 15 | typedef mat<4, 4, float, defaultp> mat4x4; 16 | 17 | /// 4 columns of 4 components matrix of single-precision floating-point numbers. 18 | /// 19 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 20 | typedef mat<4, 4, float, defaultp> mat4; 21 | 22 | /// @} 23 | }//namespace glm 24 | -------------------------------------------------------------------------------- /ext/glm/ext/quaternion_common_simd.inl: -------------------------------------------------------------------------------- 1 | #if GLM_ARCH & GLM_ARCH_SSE2_BIT 2 | 3 | namespace glm{ 4 | namespace detail 5 | { 6 | template 7 | struct compute_dot, float, true> 8 | { 9 | static GLM_FUNC_QUALIFIER float call(qua const& x, qua const& y) 10 | { 11 | return _mm_cvtss_f32(glm_vec1_dot(x.data, y.data)); 12 | } 13 | }; 14 | }//namespace detail 15 | }//namespace glm 16 | 17 | #endif//GLM_ARCH & GLM_ARCH_SSE2_BIT 18 | 19 | -------------------------------------------------------------------------------- /ext/glm/ext/quaternion_double.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_quaternion_double 2 | /// @file glm/ext/quaternion_double.hpp 3 | /// 4 | /// @defgroup ext_quaternion_double GLM_EXT_quaternion_double 5 | /// @ingroup ext 6 | /// 7 | /// Exposes double-precision floating point quaternion type. 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// @see ext_quaternion_float 12 | /// @see ext_quaternion_double_precision 13 | /// @see ext_quaternion_common 14 | /// @see ext_quaternion_exponential 15 | /// @see ext_quaternion_geometric 16 | /// @see ext_quaternion_relational 17 | /// @see ext_quaternion_transform 18 | /// @see ext_quaternion_trigonometric 19 | 20 | #pragma once 21 | 22 | // Dependency: 23 | #include "../detail/type_quat.hpp" 24 | 25 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 26 | # pragma message("GLM: GLM_EXT_quaternion_double extension included") 27 | #endif 28 | 29 | namespace glm 30 | { 31 | /// @addtogroup ext_quaternion_double 32 | /// @{ 33 | 34 | /// Quaternion of double-precision floating-point numbers. 35 | typedef qua dquat; 36 | 37 | /// @} 38 | } //namespace glm 39 | 40 | -------------------------------------------------------------------------------- /ext/glm/ext/quaternion_double_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_quaternion_double_precision 2 | /// @file glm/ext/quaternion_double_precision.hpp 3 | /// 4 | /// @defgroup ext_quaternion_double_precision GLM_EXT_quaternion_double_precision 5 | /// @ingroup ext 6 | /// 7 | /// Exposes double-precision floating point quaternion type with various precision in term of ULPs. 8 | /// 9 | /// Include to use the features of this extension. 10 | 11 | #pragma once 12 | 13 | // Dependency: 14 | #include "../detail/type_quat.hpp" 15 | 16 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 17 | # pragma message("GLM: GLM_EXT_quaternion_double_precision extension included") 18 | #endif 19 | 20 | namespace glm 21 | { 22 | /// @addtogroup ext_quaternion_double_precision 23 | /// @{ 24 | 25 | /// Quaternion of double-precision floating-point numbers using high precision arithmetic in term of ULPs. 26 | /// 27 | /// @see ext_quaternion_double_precision 28 | typedef qua lowp_dquat; 29 | 30 | /// Quaternion of medium double-qualifier floating-point numbers using high precision arithmetic in term of ULPs. 31 | /// 32 | /// @see ext_quaternion_double_precision 33 | typedef qua mediump_dquat; 34 | 35 | /// Quaternion of high double-qualifier floating-point numbers using high precision arithmetic in term of ULPs. 36 | /// 37 | /// @see ext_quaternion_double_precision 38 | typedef qua highp_dquat; 39 | 40 | /// @} 41 | } //namespace glm 42 | 43 | -------------------------------------------------------------------------------- /ext/glm/ext/quaternion_float.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_quaternion_float 2 | /// @file glm/ext/quaternion_float.hpp 3 | /// 4 | /// @defgroup ext_quaternion_float GLM_EXT_quaternion_float 5 | /// @ingroup ext 6 | /// 7 | /// Exposes single-precision floating point quaternion type. 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// @see ext_quaternion_double 12 | /// @see ext_quaternion_float_precision 13 | /// @see ext_quaternion_common 14 | /// @see ext_quaternion_exponential 15 | /// @see ext_quaternion_geometric 16 | /// @see ext_quaternion_relational 17 | /// @see ext_quaternion_transform 18 | /// @see ext_quaternion_trigonometric 19 | 20 | #pragma once 21 | 22 | // Dependency: 23 | #include "../detail/type_quat.hpp" 24 | 25 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 26 | # pragma message("GLM: GLM_EXT_quaternion_float extension included") 27 | #endif 28 | 29 | namespace glm 30 | { 31 | /// @addtogroup ext_quaternion_float 32 | /// @{ 33 | 34 | /// Quaternion of single-precision floating-point numbers. 35 | typedef qua quat; 36 | 37 | /// @} 38 | } //namespace glm 39 | 40 | -------------------------------------------------------------------------------- /ext/glm/ext/quaternion_float_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_quaternion_float_precision 2 | /// @file glm/ext/quaternion_float_precision.hpp 3 | /// 4 | /// @defgroup ext_quaternion_float_precision GLM_EXT_quaternion_float_precision 5 | /// @ingroup ext 6 | /// 7 | /// Exposes single-precision floating point quaternion type with various precision in term of ULPs. 8 | /// 9 | /// Include to use the features of this extension. 10 | 11 | #pragma once 12 | 13 | // Dependency: 14 | #include "../detail/type_quat.hpp" 15 | 16 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 17 | # pragma message("GLM: GLM_EXT_quaternion_float_precision extension included") 18 | #endif 19 | 20 | namespace glm 21 | { 22 | /// @addtogroup ext_quaternion_float_precision 23 | /// @{ 24 | 25 | /// Quaternion of single-precision floating-point numbers using high precision arithmetic in term of ULPs. 26 | typedef qua lowp_quat; 27 | 28 | /// Quaternion of single-precision floating-point numbers using high precision arithmetic in term of ULPs. 29 | typedef qua mediump_quat; 30 | 31 | /// Quaternion of single-precision floating-point numbers using high precision arithmetic in term of ULPs. 32 | typedef qua highp_quat; 33 | 34 | /// @} 35 | } //namespace glm 36 | 37 | -------------------------------------------------------------------------------- /ext/glm/ext/quaternion_geometric.inl: -------------------------------------------------------------------------------- 1 | namespace glm 2 | { 3 | template 4 | GLM_FUNC_QUALIFIER T dot(qua const& x, qua const& y) 5 | { 6 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'dot' accepts only floating-point inputs"); 7 | return detail::compute_dot, T, detail::is_aligned::value>::call(x, y); 8 | } 9 | 10 | template 11 | GLM_FUNC_QUALIFIER T length(qua const& q) 12 | { 13 | return glm::sqrt(dot(q, q)); 14 | } 15 | 16 | template 17 | GLM_FUNC_QUALIFIER qua normalize(qua const& q) 18 | { 19 | T len = length(q); 20 | if(len <= static_cast(0)) // Problem 21 | return qua(static_cast(1), static_cast(0), static_cast(0), static_cast(0)); 22 | T oneOverLen = static_cast(1) / len; 23 | return qua(q.w * oneOverLen, q.x * oneOverLen, q.y * oneOverLen, q.z * oneOverLen); 24 | } 25 | 26 | template 27 | GLM_FUNC_QUALIFIER qua cross(qua const& q1, qua const& q2) 28 | { 29 | return qua( 30 | q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z, 31 | q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y, 32 | q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z, 33 | q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x); 34 | } 35 | }//namespace glm 36 | 37 | -------------------------------------------------------------------------------- /ext/glm/ext/quaternion_relational.inl: -------------------------------------------------------------------------------- 1 | namespace glm 2 | { 3 | template 4 | GLM_FUNC_QUALIFIER vec<4, bool, Q> equal(qua const& x, qua const& y) 5 | { 6 | vec<4, bool, Q> Result; 7 | for(length_t i = 0; i < x.length(); ++i) 8 | Result[i] = x[i] == y[i]; 9 | return Result; 10 | } 11 | 12 | template 13 | GLM_FUNC_QUALIFIER vec<4, bool, Q> equal(qua const& x, qua const& y, T epsilon) 14 | { 15 | vec<4, T, Q> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w); 16 | return lessThan(abs(v), vec<4, T, Q>(epsilon)); 17 | } 18 | 19 | template 20 | GLM_FUNC_QUALIFIER vec<4, bool, Q> notEqual(qua const& x, qua const& y) 21 | { 22 | vec<4, bool, Q> Result; 23 | for(length_t i = 0; i < x.length(); ++i) 24 | Result[i] = x[i] != y[i]; 25 | return Result; 26 | } 27 | 28 | template 29 | GLM_FUNC_QUALIFIER vec<4, bool, Q> notEqual(qua const& x, qua const& y, T epsilon) 30 | { 31 | vec<4, T, Q> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w); 32 | return greaterThanEqual(abs(v), vec<4, T, Q>(epsilon)); 33 | } 34 | }//namespace glm 35 | 36 | -------------------------------------------------------------------------------- /ext/glm/ext/quaternion_transform.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_quaternion_transform 2 | /// @file glm/ext/quaternion_transform.hpp 3 | /// 4 | /// @defgroup ext_quaternion_transform GLM_EXT_quaternion_transform 5 | /// @ingroup ext 6 | /// 7 | /// Provides transformation functions for quaternion types 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// @see ext_quaternion_float 12 | /// @see ext_quaternion_double 13 | /// @see ext_quaternion_exponential 14 | /// @see ext_quaternion_geometric 15 | /// @see ext_quaternion_relational 16 | /// @see ext_quaternion_trigonometric 17 | 18 | #pragma once 19 | 20 | // Dependency: 21 | #include "../common.hpp" 22 | #include "../trigonometric.hpp" 23 | #include "../geometric.hpp" 24 | 25 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 26 | # pragma message("GLM: GLM_EXT_quaternion_transform extension included") 27 | #endif 28 | 29 | namespace glm 30 | { 31 | /// @addtogroup ext_quaternion_transform 32 | /// @{ 33 | 34 | /// Rotates a quaternion from a vector of 3 components axis and an angle. 35 | /// 36 | /// @param q Source orientation 37 | /// @param angle Angle expressed in radians. 38 | /// @param axis Axis of the rotation 39 | /// 40 | /// @tparam T Floating-point scalar types 41 | /// @tparam Q Value from qualifier enum 42 | template 43 | GLM_FUNC_DECL qua rotate(qua const& q, T const& angle, vec<3, T, Q> const& axis); 44 | /// @} 45 | } //namespace glm 46 | 47 | #include "quaternion_transform.inl" 48 | -------------------------------------------------------------------------------- /ext/glm/ext/quaternion_transform.inl: -------------------------------------------------------------------------------- 1 | namespace glm 2 | { 3 | template 4 | GLM_FUNC_QUALIFIER qua rotate(qua const& q, T const& angle, vec<3, T, Q> const& v) 5 | { 6 | vec<3, T, Q> Tmp = v; 7 | 8 | // Axis of rotation must be normalised 9 | T len = glm::length(Tmp); 10 | if(abs(len - static_cast(1)) > static_cast(0.001)) 11 | { 12 | T oneOverLen = static_cast(1) / len; 13 | Tmp.x *= oneOverLen; 14 | Tmp.y *= oneOverLen; 15 | Tmp.z *= oneOverLen; 16 | } 17 | 18 | T const AngleRad(angle); 19 | T const Sin = sin(AngleRad * static_cast(0.5)); 20 | 21 | return q * qua(cos(AngleRad * static_cast(0.5)), Tmp.x * Sin, Tmp.y * Sin, Tmp.z * Sin); 22 | } 23 | }//namespace glm 24 | 25 | -------------------------------------------------------------------------------- /ext/glm/ext/quaternion_trigonometric.inl: -------------------------------------------------------------------------------- 1 | #include "scalar_constants.hpp" 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER T angle(qua const& x) 7 | { 8 | if (abs(x.w) > cos_one_over_two()) 9 | { 10 | return asin(sqrt(x.x * x.x + x.y * x.y + x.z * x.z)) * static_cast(2); 11 | } 12 | 13 | return acos(x.w) * static_cast(2); 14 | } 15 | 16 | template 17 | GLM_FUNC_QUALIFIER vec<3, T, Q> axis(qua const& x) 18 | { 19 | T const tmp1 = static_cast(1) - x.w * x.w; 20 | if(tmp1 <= static_cast(0)) 21 | return vec<3, T, Q>(0, 0, 1); 22 | T const tmp2 = static_cast(1) / sqrt(tmp1); 23 | return vec<3, T, Q>(x.x * tmp2, x.y * tmp2, x.z * tmp2); 24 | } 25 | 26 | template 27 | GLM_FUNC_QUALIFIER qua angleAxis(T const& angle, vec<3, T, Q> const& v) 28 | { 29 | T const a(angle); 30 | T const s = glm::sin(a * static_cast(0.5)); 31 | 32 | return qua(glm::cos(a * static_cast(0.5)), v * s); 33 | } 34 | }//namespace glm 35 | -------------------------------------------------------------------------------- /ext/glm/ext/scalar_constants.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_scalar_constants 2 | /// @file glm/ext/scalar_constants.hpp 3 | /// 4 | /// @defgroup ext_scalar_constants GLM_EXT_scalar_constants 5 | /// @ingroup ext 6 | /// 7 | /// Provides a list of constants and precomputed useful values. 8 | /// 9 | /// Include to use the features of this extension. 10 | 11 | #pragma once 12 | 13 | // Dependencies 14 | #include "../detail/setup.hpp" 15 | 16 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 17 | # pragma message("GLM: GLM_EXT_scalar_constants extension included") 18 | #endif 19 | 20 | namespace glm 21 | { 22 | /// @addtogroup ext_scalar_constants 23 | /// @{ 24 | 25 | /// Return the epsilon constant for floating point types. 26 | template 27 | GLM_FUNC_DECL GLM_CONSTEXPR genType epsilon(); 28 | 29 | /// Return the pi constant for floating point types. 30 | template 31 | GLM_FUNC_DECL GLM_CONSTEXPR genType pi(); 32 | 33 | /// Return the value of cos(1 / 2) for floating point types. 34 | template 35 | GLM_FUNC_DECL GLM_CONSTEXPR genType cos_one_over_two(); 36 | 37 | /// @} 38 | } //namespace glm 39 | 40 | #include "scalar_constants.inl" 41 | -------------------------------------------------------------------------------- /ext/glm/ext/scalar_constants.inl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType epsilon() 7 | { 8 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'epsilon' only accepts floating-point inputs"); 9 | return std::numeric_limits::epsilon(); 10 | } 11 | 12 | template 13 | GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType pi() 14 | { 15 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'pi' only accepts floating-point inputs"); 16 | return static_cast(3.14159265358979323846264338327950288); 17 | } 18 | 19 | template 20 | GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType cos_one_over_two() 21 | { 22 | return genType(0.877582561890372716130286068203503191); 23 | } 24 | } //namespace glm 25 | -------------------------------------------------------------------------------- /ext/glm/ext/scalar_int_sized.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_scalar_int_sized 2 | /// @file glm/ext/scalar_int_sized.hpp 3 | /// 4 | /// @defgroup ext_scalar_int_sized GLM_EXT_scalar_int_sized 5 | /// @ingroup ext 6 | /// 7 | /// Exposes sized signed integer scalar types. 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// @see ext_scalar_uint_sized 12 | 13 | #pragma once 14 | 15 | #include "../detail/setup.hpp" 16 | 17 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 18 | # pragma message("GLM: GLM_EXT_scalar_int_sized extension included") 19 | #endif 20 | 21 | namespace glm{ 22 | namespace detail 23 | { 24 | # if GLM_HAS_EXTENDED_INTEGER_TYPE 25 | typedef std::int8_t int8; 26 | typedef std::int16_t int16; 27 | typedef std::int32_t int32; 28 | # else 29 | typedef signed char int8; 30 | typedef signed short int16; 31 | typedef signed int int32; 32 | #endif// 33 | 34 | template<> 35 | struct is_int 36 | { 37 | enum test {value = ~0}; 38 | }; 39 | 40 | template<> 41 | struct is_int 42 | { 43 | enum test {value = ~0}; 44 | }; 45 | 46 | template<> 47 | struct is_int 48 | { 49 | enum test {value = ~0}; 50 | }; 51 | }//namespace detail 52 | 53 | 54 | /// @addtogroup ext_scalar_int_sized 55 | /// @{ 56 | 57 | /// 8 bit signed integer type. 58 | typedef detail::int8 int8; 59 | 60 | /// 16 bit signed integer type. 61 | typedef detail::int16 int16; 62 | 63 | /// 32 bit signed integer type. 64 | typedef detail::int32 int32; 65 | 66 | /// 64 bit signed integer type. 67 | typedef detail::int64 int64; 68 | 69 | /// @} 70 | }//namespace glm 71 | -------------------------------------------------------------------------------- /ext/glm/ext/scalar_packing.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HummaWhite/Zillum/f5cbec605e7c24ee4dd0f29917ce102ee310ef4f/ext/glm/ext/scalar_packing.hpp -------------------------------------------------------------------------------- /ext/glm/ext/scalar_packing.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HummaWhite/Zillum/f5cbec605e7c24ee4dd0f29917ce102ee310ef4f/ext/glm/ext/scalar_packing.inl -------------------------------------------------------------------------------- /ext/glm/ext/scalar_relational.inl: -------------------------------------------------------------------------------- 1 | #include "../common.hpp" 2 | #include "../ext/scalar_int_sized.hpp" 3 | #include "../ext/scalar_uint_sized.hpp" 4 | #include "../detail/type_float.hpp" 5 | 6 | namespace glm 7 | { 8 | template 9 | GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool equal(genType const& x, genType const& y, genType const& epsilon) 10 | { 11 | return abs(x - y) <= epsilon; 12 | } 13 | 14 | template 15 | GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool notEqual(genType const& x, genType const& y, genType const& epsilon) 16 | { 17 | return abs(x - y) > epsilon; 18 | } 19 | 20 | template 21 | GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool equal(genType const& x, genType const& y, int MaxULPs) 22 | { 23 | detail::float_t const a(x); 24 | detail::float_t const b(y); 25 | 26 | // Different signs means they do not match. 27 | if(a.negative() != b.negative()) 28 | return false; 29 | 30 | // Find the difference in ULPs. 31 | typename detail::float_t::int_type const DiffULPs = abs(a.i - b.i); 32 | return DiffULPs <= MaxULPs; 33 | } 34 | 35 | template 36 | GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool notEqual(genType const& x, genType const& y, int ULPs) 37 | { 38 | return !equal(x, y, ULPs); 39 | } 40 | }//namespace glm 41 | -------------------------------------------------------------------------------- /ext/glm/ext/scalar_uint_sized.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_scalar_uint_sized 2 | /// @file glm/ext/scalar_uint_sized.hpp 3 | /// 4 | /// @defgroup ext_scalar_uint_sized GLM_EXT_scalar_uint_sized 5 | /// @ingroup ext 6 | /// 7 | /// Exposes sized unsigned integer scalar types. 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// @see ext_scalar_int_sized 12 | 13 | #pragma once 14 | 15 | #include "../detail/setup.hpp" 16 | 17 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 18 | # pragma message("GLM: GLM_EXT_scalar_uint_sized extension included") 19 | #endif 20 | 21 | namespace glm{ 22 | namespace detail 23 | { 24 | # if GLM_HAS_EXTENDED_INTEGER_TYPE 25 | typedef std::uint8_t uint8; 26 | typedef std::uint16_t uint16; 27 | typedef std::uint32_t uint32; 28 | # else 29 | typedef unsigned char uint8; 30 | typedef unsigned short uint16; 31 | typedef unsigned int uint32; 32 | #endif 33 | 34 | template<> 35 | struct is_int 36 | { 37 | enum test {value = ~0}; 38 | }; 39 | 40 | template<> 41 | struct is_int 42 | { 43 | enum test {value = ~0}; 44 | }; 45 | 46 | template<> 47 | struct is_int 48 | { 49 | enum test {value = ~0}; 50 | }; 51 | }//namespace detail 52 | 53 | 54 | /// @addtogroup ext_scalar_uint_sized 55 | /// @{ 56 | 57 | /// 8 bit unsigned integer type. 58 | typedef detail::uint8 uint8; 59 | 60 | /// 16 bit unsigned integer type. 61 | typedef detail::uint16 uint16; 62 | 63 | /// 32 bit unsigned integer type. 64 | typedef detail::uint32 uint32; 65 | 66 | /// 64 bit unsigned integer type. 67 | typedef detail::uint64 uint64; 68 | 69 | /// @} 70 | }//namespace glm 71 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_bool1.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_vector_bool1 2 | /// @file glm/ext/vector_bool1.hpp 3 | /// 4 | /// @defgroup ext_vector_bool1 GLM_EXT_vector_bool1 5 | /// @ingroup ext 6 | /// 7 | /// Exposes bvec1 vector type. 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// @see ext_vector_bool1_precision extension. 12 | 13 | #pragma once 14 | 15 | #include "../detail/type_vec1.hpp" 16 | 17 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 18 | # pragma message("GLM: GLM_EXT_vector_bool1 extension included") 19 | #endif 20 | 21 | namespace glm 22 | { 23 | /// @addtogroup ext_vector_bool1 24 | /// @{ 25 | 26 | /// 1 components vector of boolean. 27 | typedef vec<1, bool, defaultp> bvec1; 28 | 29 | /// @} 30 | }//namespace glm 31 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_bool1_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_vector_bool1_precision 2 | /// @file glm/ext/vector_bool1_precision.hpp 3 | /// 4 | /// @defgroup ext_vector_bool1_precision GLM_EXT_vector_bool1_precision 5 | /// @ingroup ext 6 | /// 7 | /// Exposes highp_bvec1, mediump_bvec1 and lowp_bvec1 types. 8 | /// 9 | /// Include to use the features of this extension. 10 | 11 | #pragma once 12 | 13 | #include "../detail/type_vec1.hpp" 14 | 15 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 16 | # pragma message("GLM: GLM_EXT_vector_bool1_precision extension included") 17 | #endif 18 | 19 | namespace glm 20 | { 21 | /// @addtogroup ext_vector_bool1_precision 22 | /// @{ 23 | 24 | /// 1 component vector of bool values. 25 | typedef vec<1, bool, highp> highp_bvec1; 26 | 27 | /// 1 component vector of bool values. 28 | typedef vec<1, bool, mediump> mediump_bvec1; 29 | 30 | /// 1 component vector of bool values. 31 | typedef vec<1, bool, lowp> lowp_bvec1; 32 | 33 | /// @} 34 | }//namespace glm 35 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_bool2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_bool2.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector 10 | /// @{ 11 | 12 | /// 2 components vector of boolean. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | typedef vec<2, bool, defaultp> bvec2; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_bool2_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_bool2_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector_precision 10 | /// @{ 11 | 12 | /// 2 components vector of high qualifier bool numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef vec<2, bool, highp> highp_bvec2; 17 | 18 | /// 2 components vector of medium qualifier bool numbers. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef vec<2, bool, mediump> mediump_bvec2; 23 | 24 | /// 2 components vector of low qualifier bool numbers. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef vec<2, bool, lowp> lowp_bvec2; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_bool3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_bool3.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector 10 | /// @{ 11 | 12 | /// 3 components vector of boolean. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | typedef vec<3, bool, defaultp> bvec3; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_bool3_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_bool3_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector_precision 10 | /// @{ 11 | 12 | /// 3 components vector of high qualifier bool numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef vec<3, bool, highp> highp_bvec3; 17 | 18 | /// 3 components vector of medium qualifier bool numbers. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef vec<3, bool, mediump> mediump_bvec3; 23 | 24 | /// 3 components vector of low qualifier bool numbers. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef vec<3, bool, lowp> lowp_bvec3; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_bool4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_bool4.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector 10 | /// @{ 11 | 12 | /// 4 components vector of boolean. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | typedef vec<4, bool, defaultp> bvec4; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_bool4_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_bool4_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector_precision 10 | /// @{ 11 | 12 | /// 4 components vector of high qualifier bool numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef vec<4, bool, highp> highp_bvec4; 17 | 18 | /// 4 components vector of medium qualifier bool numbers. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef vec<4, bool, mediump> mediump_bvec4; 23 | 24 | /// 4 components vector of low qualifier bool numbers. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef vec<4, bool, lowp> lowp_bvec4; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_double1.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_vector_double1 2 | /// @file glm/ext/vector_double1.hpp 3 | /// 4 | /// @defgroup ext_vector_double1 GLM_EXT_vector_double1 5 | /// @ingroup ext 6 | /// 7 | /// Exposes double-precision floating point vector type with one component. 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// @see ext_vector_double1_precision extension. 12 | /// @see ext_vector_float1 extension. 13 | 14 | #pragma once 15 | 16 | #include "../detail/type_vec1.hpp" 17 | 18 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 19 | # pragma message("GLM: GLM_EXT_vector_double1 extension included") 20 | #endif 21 | 22 | namespace glm 23 | { 24 | /// @addtogroup ext_vector_double1 25 | /// @{ 26 | 27 | /// 1 components vector of double-precision floating-point numbers. 28 | typedef vec<1, double, defaultp> dvec1; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_double1_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_vector_double1_precision 2 | /// @file glm/ext/vector_double1_precision.hpp 3 | /// 4 | /// @defgroup ext_vector_double1_precision GLM_EXT_vector_double1_precision 5 | /// @ingroup ext 6 | /// 7 | /// Exposes highp_dvec1, mediump_dvec1 and lowp_dvec1 types. 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// @see ext_vector_double1 12 | 13 | #pragma once 14 | 15 | #include "../detail/type_vec1.hpp" 16 | 17 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 18 | # pragma message("GLM: GLM_EXT_vector_double1_precision extension included") 19 | #endif 20 | 21 | namespace glm 22 | { 23 | /// @addtogroup ext_vector_double1_precision 24 | /// @{ 25 | 26 | /// 1 component vector of double-precision floating-point numbers using high precision arithmetic in term of ULPs. 27 | typedef vec<1, double, highp> highp_dvec1; 28 | 29 | /// 1 component vector of double-precision floating-point numbers using medium precision arithmetic in term of ULPs. 30 | typedef vec<1, double, mediump> mediump_dvec1; 31 | 32 | /// 1 component vector of double-precision floating-point numbers using low precision arithmetic in term of ULPs. 33 | typedef vec<1, double, lowp> lowp_dvec1; 34 | 35 | /// @} 36 | }//namespace glm 37 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_double2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_double2.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector 10 | /// @{ 11 | 12 | /// 2 components vector of double-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | typedef vec<2, double, defaultp> dvec2; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_double2_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_double2_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector_precision 10 | /// @{ 11 | 12 | /// 2 components vector of high double-qualifier floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef vec<2, double, highp> highp_dvec2; 17 | 18 | /// 2 components vector of medium double-qualifier floating-point numbers. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef vec<2, double, mediump> mediump_dvec2; 23 | 24 | /// 2 components vector of low double-qualifier floating-point numbers. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef vec<2, double, lowp> lowp_dvec2; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_double3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_double3.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector 10 | /// @{ 11 | 12 | /// 3 components vector of double-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | typedef vec<3, double, defaultp> dvec3; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_double3_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_double3_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector_precision 10 | /// @{ 11 | 12 | /// 3 components vector of high double-qualifier floating-point numbers. 13 | /// There is no guarantee on the actual qualifier. 14 | /// 15 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 16 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 17 | typedef vec<3, double, highp> highp_dvec3; 18 | 19 | /// 3 components vector of medium double-qualifier floating-point numbers. 20 | /// There is no guarantee on the actual qualifier. 21 | /// 22 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 23 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 24 | typedef vec<3, double, mediump> mediump_dvec3; 25 | 26 | /// 3 components vector of low double-qualifier floating-point numbers. 27 | /// There is no guarantee on the actual qualifier. 28 | /// 29 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 30 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 31 | typedef vec<3, double, lowp> lowp_dvec3; 32 | 33 | /// @} 34 | }//namespace glm 35 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_double4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_double4.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector 10 | /// @{ 11 | 12 | /// 4 components vector of double-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | typedef vec<4, double, defaultp> dvec4; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_float1.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_vector_float1 2 | /// @file glm/ext/vector_float1.hpp 3 | /// 4 | /// @defgroup ext_vector_float1 GLM_EXT_vector_float1 5 | /// @ingroup ext 6 | /// 7 | /// Exposes single-precision floating point vector type with one component. 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// @see ext_vector_float1_precision extension. 12 | /// @see ext_vector_double1 extension. 13 | 14 | #pragma once 15 | 16 | #include "../detail/type_vec1.hpp" 17 | 18 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 19 | # pragma message("GLM: GLM_EXT_vector_float1 extension included") 20 | #endif 21 | 22 | namespace glm 23 | { 24 | /// @addtogroup ext_vector_float1 25 | /// @{ 26 | 27 | /// 1 components vector of single-precision floating-point numbers. 28 | typedef vec<1, float, defaultp> vec1; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_float1_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_vector_float1_precision 2 | /// @file glm/ext/vector_float1_precision.hpp 3 | /// 4 | /// @defgroup ext_vector_float1_precision GLM_EXT_vector_float1_precision 5 | /// @ingroup ext 6 | /// 7 | /// Exposes highp_vec1, mediump_vec1 and lowp_vec1 types. 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// @see ext_vector_float1 extension. 12 | 13 | #pragma once 14 | 15 | #include "../detail/type_vec1.hpp" 16 | 17 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 18 | # pragma message("GLM: GLM_EXT_vector_float1_precision extension included") 19 | #endif 20 | 21 | namespace glm 22 | { 23 | /// @addtogroup ext_vector_float1_precision 24 | /// @{ 25 | 26 | /// 1 component vector of single-precision floating-point numbers using high precision arithmetic in term of ULPs. 27 | typedef vec<1, float, highp> highp_vec1; 28 | 29 | /// 1 component vector of single-precision floating-point numbers using medium precision arithmetic in term of ULPs. 30 | typedef vec<1, float, mediump> mediump_vec1; 31 | 32 | /// 1 component vector of single-precision floating-point numbers using low precision arithmetic in term of ULPs. 33 | typedef vec<1, float, lowp> lowp_vec1; 34 | 35 | /// @} 36 | }//namespace glm 37 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_float2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_float2.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector 10 | /// @{ 11 | 12 | /// 2 components vector of single-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | typedef vec<2, float, defaultp> vec2; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_float2_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_float2_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector_precision 10 | /// @{ 11 | 12 | /// 2 components vector of high single-qualifier floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef vec<2, float, highp> highp_vec2; 17 | 18 | /// 2 components vector of medium single-qualifier floating-point numbers. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef vec<2, float, mediump> mediump_vec2; 23 | 24 | /// 2 components vector of low single-qualifier floating-point numbers. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef vec<2, float, lowp> lowp_vec2; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_float3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_float3.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector 10 | /// @{ 11 | 12 | /// 3 components vector of single-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | typedef vec<3, float, defaultp> vec3; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_float3_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_float3_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector_precision 10 | /// @{ 11 | 12 | /// 3 components vector of high single-qualifier floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef vec<3, float, highp> highp_vec3; 17 | 18 | /// 3 components vector of medium single-qualifier floating-point numbers. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef vec<3, float, mediump> mediump_vec3; 23 | 24 | /// 3 components vector of low single-qualifier floating-point numbers. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef vec<3, float, lowp> lowp_vec3; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_float4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_float4.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector 10 | /// @{ 11 | 12 | /// 4 components vector of single-precision floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | typedef vec<4, float, defaultp> vec4; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_float4_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_float4_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector_precision 10 | /// @{ 11 | 12 | /// 4 components vector of high single-qualifier floating-point numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef vec<4, float, highp> highp_vec4; 17 | 18 | /// 4 components vector of medium single-qualifier floating-point numbers. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef vec<4, float, mediump> mediump_vec4; 23 | 24 | /// 4 components vector of low single-qualifier floating-point numbers. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef vec<4, float, lowp> lowp_vec4; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_int1.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_vector_int1 2 | /// @file glm/ext/vector_int1.hpp 3 | /// 4 | /// @defgroup ext_vector_int1 GLM_EXT_vector_int1 5 | /// @ingroup ext 6 | /// 7 | /// Exposes ivec1 vector type. 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// @see ext_vector_uint1 extension. 12 | /// @see ext_vector_int1_precision extension. 13 | 14 | #pragma once 15 | 16 | #include "../detail/type_vec1.hpp" 17 | 18 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 19 | # pragma message("GLM: GLM_EXT_vector_int1 extension included") 20 | #endif 21 | 22 | namespace glm 23 | { 24 | /// @addtogroup ext_vector_int1 25 | /// @{ 26 | 27 | /// 1 component vector of signed integer numbers. 28 | typedef vec<1, int, defaultp> ivec1; 29 | 30 | /// @} 31 | }//namespace glm 32 | 33 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_int1_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_vector_int1_precision 2 | /// @file glm/ext/vector_int1_precision.hpp 3 | /// 4 | /// @defgroup ext_vector_int1_precision GLM_EXT_vector_int1_precision 5 | /// @ingroup ext 6 | /// 7 | /// Exposes highp_ivec1, mediump_ivec1 and lowp_ivec1 types. 8 | /// 9 | /// Include to use the features of this extension. 10 | 11 | #pragma once 12 | 13 | #include "../detail/type_vec1.hpp" 14 | 15 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 16 | # pragma message("GLM: GLM_EXT_vector_int1_precision extension included") 17 | #endif 18 | 19 | namespace glm 20 | { 21 | /// @addtogroup ext_vector_int1_precision 22 | /// @{ 23 | 24 | /// 1 component vector of signed integer values. 25 | typedef vec<1, int, highp> highp_ivec1; 26 | 27 | /// 1 component vector of signed integer values. 28 | typedef vec<1, int, mediump> mediump_ivec1; 29 | 30 | /// 1 component vector of signed integer values. 31 | typedef vec<1, int, lowp> lowp_ivec1; 32 | 33 | /// @} 34 | }//namespace glm 35 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_int2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_int2.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector 10 | /// @{ 11 | 12 | /// 2 components vector of signed integer numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | typedef vec<2, int, defaultp> ivec2; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_int2_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_int2_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector_precision 10 | /// @{ 11 | 12 | /// 2 components vector of high qualifier signed integer numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef vec<2, int, highp> highp_ivec2; 17 | 18 | /// 2 components vector of medium qualifier signed integer numbers. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef vec<2, int, mediump> mediump_ivec2; 23 | 24 | /// 2 components vector of low qualifier signed integer numbers. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef vec<2, int, lowp> lowp_ivec2; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_int3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_int3.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector 10 | /// @{ 11 | 12 | /// 3 components vector of signed integer numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | typedef vec<3, int, defaultp> ivec3; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_int3_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_int3_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector_precision 10 | /// @{ 11 | 12 | /// 3 components vector of high qualifier signed integer numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef vec<3, int, highp> highp_ivec3; 17 | 18 | /// 3 components vector of medium qualifier signed integer numbers. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef vec<3, int, mediump> mediump_ivec3; 23 | 24 | /// 3 components vector of low qualifier signed integer numbers. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef vec<3, int, lowp> lowp_ivec3; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_int4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_int4.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector 10 | /// @{ 11 | 12 | /// 4 components vector of signed integer numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | typedef vec<4, int, defaultp> ivec4; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_int4_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_int4_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector_precision 10 | /// @{ 11 | 12 | /// 4 components vector of high qualifier signed integer numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef vec<4, int, highp> highp_ivec4; 17 | 18 | /// 4 components vector of medium qualifier signed integer numbers. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef vec<4, int, mediump> mediump_ivec4; 23 | 24 | /// 4 components vector of low qualifier signed integer numbers. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef vec<4, int, lowp> lowp_ivec4; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_packing.hpp: -------------------------------------------------------------------------------- 1 | /// @ref vector_packing 2 | /// @file glm/ext/vector_packing.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup ext_vector_packing GLM_EXT_vector_packing 7 | /// @ingroup ext 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// This extension provides a set of function to convert vertors to packed 12 | /// formats. 13 | 14 | #pragma once 15 | 16 | // Dependency: 17 | #include "../detail/qualifier.hpp" 18 | 19 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 20 | # pragma message("GLM: GLM_EXT_vector_packing extension included") 21 | #endif 22 | 23 | namespace glm 24 | { 25 | /// @addtogroup ext_vector_packing 26 | /// @{ 27 | 28 | 29 | /// @} 30 | }// namespace glm 31 | 32 | #include "vector_packing.inl" 33 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_packing.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HummaWhite/Zillum/f5cbec605e7c24ee4dd0f29917ce102ee310ef4f/ext/glm/ext/vector_packing.inl -------------------------------------------------------------------------------- /ext/glm/ext/vector_uint1.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_vector_uint1 2 | /// @file glm/ext/vector_uint1.hpp 3 | /// 4 | /// @defgroup ext_vector_uint1 GLM_EXT_vector_uint1 5 | /// @ingroup ext 6 | /// 7 | /// Exposes uvec1 vector type. 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// @see ext_vector_int1 extension. 12 | /// @see ext_vector_uint1_precision extension. 13 | 14 | #pragma once 15 | 16 | #include "../detail/type_vec1.hpp" 17 | 18 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 19 | # pragma message("GLM: GLM_EXT_vector_uint1 extension included") 20 | #endif 21 | 22 | namespace glm 23 | { 24 | /// @addtogroup ext_vector_uint1 25 | /// @{ 26 | 27 | /// 1 component vector of unsigned integer numbers. 28 | typedef vec<1, unsigned int, defaultp> uvec1; 29 | 30 | /// @} 31 | }//namespace glm 32 | 33 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_uint1_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref ext_vector_uint1_precision 2 | /// @file glm/ext/vector_uint1_precision.hpp 3 | /// 4 | /// @defgroup ext_vector_uint1_precision GLM_EXT_vector_uint1_precision 5 | /// @ingroup ext 6 | /// 7 | /// Exposes highp_uvec1, mediump_uvec1 and lowp_uvec1 types. 8 | /// 9 | /// Include to use the features of this extension. 10 | 11 | #pragma once 12 | 13 | #include "../detail/type_vec1.hpp" 14 | 15 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 16 | # pragma message("GLM: GLM_EXT_vector_uint1_precision extension included") 17 | #endif 18 | 19 | namespace glm 20 | { 21 | /// @addtogroup ext_vector_uint1_precision 22 | /// @{ 23 | 24 | /// 1 component vector of unsigned integer values. 25 | /// 26 | /// @see ext_vector_uint1_precision 27 | typedef vec<1, unsigned int, highp> highp_uvec1; 28 | 29 | /// 1 component vector of unsigned integer values. 30 | /// 31 | /// @see ext_vector_uint1_precision 32 | typedef vec<1, unsigned int, mediump> mediump_uvec1; 33 | 34 | /// 1 component vector of unsigned integer values. 35 | /// 36 | /// @see ext_vector_uint1_precision 37 | typedef vec<1, unsigned int, lowp> lowp_uvec1; 38 | 39 | /// @} 40 | }//namespace glm 41 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_uint2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_uint2.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector 10 | /// @{ 11 | 12 | /// 2 components vector of unsigned integer numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | typedef vec<2, unsigned int, defaultp> uvec2; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_uint2_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_uint2_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec2.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector_precision 10 | /// @{ 11 | 12 | /// 2 components vector of high qualifier unsigned integer numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef vec<2, unsigned int, highp> highp_uvec2; 17 | 18 | /// 2 components vector of medium qualifier unsigned integer numbers. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef vec<2, unsigned int, mediump> mediump_uvec2; 23 | 24 | /// 2 components vector of low qualifier unsigned integer numbers. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef vec<2, unsigned int, lowp> lowp_uvec2; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_uint3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_uint3.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector 10 | /// @{ 11 | 12 | /// 3 components vector of unsigned integer numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | typedef vec<3, unsigned int, defaultp> uvec3; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_uint3_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_uint3_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec3.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector_precision 10 | /// @{ 11 | 12 | /// 3 components vector of high qualifier unsigned integer numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef vec<3, unsigned int, highp> highp_uvec3; 17 | 18 | /// 3 components vector of medium qualifier unsigned integer numbers. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef vec<3, unsigned int, mediump> mediump_uvec3; 23 | 24 | /// 3 components vector of low qualifier unsigned integer numbers. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef vec<3, unsigned int, lowp> lowp_uvec3; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_uint4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_uint4.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector 10 | /// @{ 11 | 12 | /// 4 components vector of unsigned integer numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | typedef vec<4, unsigned int, defaultp> uvec4; 16 | 17 | /// @} 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /ext/glm/ext/vector_uint4_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/ext/vector_uint4_precision.hpp 3 | 4 | #pragma once 5 | #include "../detail/type_vec4.hpp" 6 | 7 | namespace glm 8 | { 9 | /// @addtogroup core_vector_precision 10 | /// @{ 11 | 12 | /// 4 components vector of high qualifier unsigned integer numbers. 13 | /// 14 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 15 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 16 | typedef vec<4, unsigned int, highp> highp_uvec4; 17 | 18 | /// 4 components vector of medium qualifier unsigned integer numbers. 19 | /// 20 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 21 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 22 | typedef vec<4, unsigned int, mediump> mediump_uvec4; 23 | 24 | /// 4 components vector of low qualifier unsigned integer numbers. 25 | /// 26 | /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors 27 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 28 | typedef vec<4, unsigned int, lowp> lowp_uvec4; 29 | 30 | /// @} 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /ext/glm/gtc/matrix_access.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtc_matrix_access 2 | /// @file glm/gtc/matrix_access.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtc_matrix_access GLM_GTC_matrix_access 7 | /// @ingroup gtc 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// Defines functions to access rows or columns of a matrix easily. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../detail/setup.hpp" 17 | 18 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 19 | # pragma message("GLM: GLM_GTC_matrix_access extension included") 20 | #endif 21 | 22 | namespace glm 23 | { 24 | /// @addtogroup gtc_matrix_access 25 | /// @{ 26 | 27 | /// Get a specific row of a matrix. 28 | /// @see gtc_matrix_access 29 | template 30 | GLM_FUNC_DECL typename genType::row_type row( 31 | genType const& m, 32 | length_t index); 33 | 34 | /// Set a specific row to a matrix. 35 | /// @see gtc_matrix_access 36 | template 37 | GLM_FUNC_DECL genType row( 38 | genType const& m, 39 | length_t index, 40 | typename genType::row_type const& x); 41 | 42 | /// Get a specific column of a matrix. 43 | /// @see gtc_matrix_access 44 | template 45 | GLM_FUNC_DECL typename genType::col_type column( 46 | genType const& m, 47 | length_t index); 48 | 49 | /// Set a specific column to a matrix. 50 | /// @see gtc_matrix_access 51 | template 52 | GLM_FUNC_DECL genType column( 53 | genType const& m, 54 | length_t index, 55 | typename genType::col_type const& x); 56 | 57 | /// @} 58 | }//namespace glm 59 | 60 | #include "matrix_access.inl" 61 | -------------------------------------------------------------------------------- /ext/glm/gtc/matrix_access.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtc_matrix_access 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER genType row 7 | ( 8 | genType const& m, 9 | length_t index, 10 | typename genType::row_type const& x 11 | ) 12 | { 13 | assert(index >= 0 && index < m[0].length()); 14 | 15 | genType Result = m; 16 | for(length_t i = 0; i < m.length(); ++i) 17 | Result[i][index] = x[i]; 18 | return Result; 19 | } 20 | 21 | template 22 | GLM_FUNC_QUALIFIER typename genType::row_type row 23 | ( 24 | genType const& m, 25 | length_t index 26 | ) 27 | { 28 | assert(index >= 0 && index < m[0].length()); 29 | 30 | typename genType::row_type Result(0); 31 | for(length_t i = 0; i < m.length(); ++i) 32 | Result[i] = m[i][index]; 33 | return Result; 34 | } 35 | 36 | template 37 | GLM_FUNC_QUALIFIER genType column 38 | ( 39 | genType const& m, 40 | length_t index, 41 | typename genType::col_type const& x 42 | ) 43 | { 44 | assert(index >= 0 && index < m.length()); 45 | 46 | genType Result = m; 47 | Result[index] = x; 48 | return Result; 49 | } 50 | 51 | template 52 | GLM_FUNC_QUALIFIER typename genType::col_type column 53 | ( 54 | genType const& m, 55 | length_t index 56 | ) 57 | { 58 | assert(index >= 0 && index < m.length()); 59 | 60 | return m[index]; 61 | } 62 | }//namespace glm 63 | -------------------------------------------------------------------------------- /ext/glm/gtc/matrix_inverse.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtc_matrix_inverse 2 | /// @file glm/gtc/matrix_inverse.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtc_matrix_inverse GLM_GTC_matrix_inverse 7 | /// @ingroup gtc 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// Defines additional matrix inverting functions. 12 | 13 | #pragma once 14 | 15 | // Dependencies 16 | #include "../detail/setup.hpp" 17 | #include "../matrix.hpp" 18 | #include "../mat2x2.hpp" 19 | #include "../mat3x3.hpp" 20 | #include "../mat4x4.hpp" 21 | 22 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 23 | # pragma message("GLM: GLM_GTC_matrix_inverse extension included") 24 | #endif 25 | 26 | namespace glm 27 | { 28 | /// @addtogroup gtc_matrix_inverse 29 | /// @{ 30 | 31 | /// Fast matrix inverse for affine matrix. 32 | /// 33 | /// @param m Input matrix to invert. 34 | /// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-qualifier floating point value is highly innacurate. 35 | /// @see gtc_matrix_inverse 36 | template 37 | GLM_FUNC_DECL genType affineInverse(genType const& m); 38 | 39 | /// Compute the inverse transpose of a matrix. 40 | /// 41 | /// @param m Input matrix to invert transpose. 42 | /// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-qualifier floating point value is highly innacurate. 43 | /// @see gtc_matrix_inverse 44 | template 45 | GLM_FUNC_DECL genType inverseTranspose(genType const& m); 46 | 47 | /// @} 48 | }//namespace glm 49 | 50 | #include "matrix_inverse.inl" 51 | -------------------------------------------------------------------------------- /ext/glm/gtc/matrix_transform.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtc_matrix_transform 2 | /// @file glm/gtc/matrix_transform.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtx_transform 6 | /// @see gtx_transform2 7 | /// 8 | /// @defgroup gtc_matrix_transform GLM_GTC_matrix_transform 9 | /// @ingroup gtc 10 | /// 11 | /// Include to use the features of this extension. 12 | /// 13 | /// Defines functions that generate common transformation matrices. 14 | /// 15 | /// The matrices generated by this extension use standard OpenGL fixed-function 16 | /// conventions. For example, the lookAt function generates a transform from world 17 | /// space into the specific eye space that the projective matrix functions 18 | /// (perspective, ortho, etc) are designed to expect. The OpenGL compatibility 19 | /// specifications defines the particular layout of this eye space. 20 | 21 | #pragma once 22 | 23 | // Dependencies 24 | #include "../mat4x4.hpp" 25 | #include "../vec2.hpp" 26 | #include "../vec3.hpp" 27 | #include "../vec4.hpp" 28 | #include "../ext/matrix_projection.hpp" 29 | #include "../ext/matrix_clip_space.hpp" 30 | #include "../ext/matrix_transform.hpp" 31 | 32 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 33 | # pragma message("GLM: GLM_GTC_matrix_transform extension included") 34 | #endif 35 | 36 | #include "matrix_transform.inl" 37 | -------------------------------------------------------------------------------- /ext/glm/gtc/matrix_transform.inl: -------------------------------------------------------------------------------- 1 | #include "../geometric.hpp" 2 | #include "../trigonometric.hpp" 3 | #include "../matrix.hpp" 4 | -------------------------------------------------------------------------------- /ext/glm/gtc/quaternion_simd.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HummaWhite/Zillum/f5cbec605e7c24ee4dd0f29917ce102ee310ef4f/ext/glm/gtc/quaternion_simd.inl -------------------------------------------------------------------------------- /ext/glm/gtc/type_precision.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtc_precision 2 | 3 | namespace glm 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /ext/glm/gtc/vec1.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtc_vec1 2 | /// @file glm/gtc/vec1.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtc_vec1 GLM_GTC_vec1 7 | /// @ingroup gtc 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// Add vec1, ivec1, uvec1 and bvec1 types. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../ext/vector_bool1.hpp" 17 | #include "../ext/vector_bool1_precision.hpp" 18 | #include "../ext/vector_float1.hpp" 19 | #include "../ext/vector_float1_precision.hpp" 20 | #include "../ext/vector_double1.hpp" 21 | #include "../ext/vector_double1_precision.hpp" 22 | #include "../ext/vector_int1.hpp" 23 | #include "../ext/vector_int1_precision.hpp" 24 | #include "../ext/vector_uint1.hpp" 25 | #include "../ext/vector_uint1_precision.hpp" 26 | 27 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 28 | # pragma message("GLM: GLM_GTC_vec1 extension included") 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /ext/glm/gtx/closest_point.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_closest_point 2 | /// @file glm/gtx/closest_point.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_closest_point GLM_GTX_closest_point 7 | /// @ingroup gtx 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// Find the point on a straight line which is the closet of a point. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 19 | # ifndef GLM_ENABLE_EXPERIMENTAL 20 | # pragma message("GLM: GLM_GTX_closest_point is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 21 | # else 22 | # pragma message("GLM: GLM_GTX_closest_point extension included") 23 | # endif 24 | #endif 25 | 26 | namespace glm 27 | { 28 | /// @addtogroup gtx_closest_point 29 | /// @{ 30 | 31 | /// Find the point on a straight line which is the closet of a point. 32 | /// @see gtx_closest_point 33 | template 34 | GLM_FUNC_DECL vec<3, T, Q> closestPointOnLine( 35 | vec<3, T, Q> const& point, 36 | vec<3, T, Q> const& a, 37 | vec<3, T, Q> const& b); 38 | 39 | /// 2d lines work as well 40 | template 41 | GLM_FUNC_DECL vec<2, T, Q> closestPointOnLine( 42 | vec<2, T, Q> const& point, 43 | vec<2, T, Q> const& a, 44 | vec<2, T, Q> const& b); 45 | 46 | /// @} 47 | }// namespace glm 48 | 49 | #include "closest_point.inl" 50 | -------------------------------------------------------------------------------- /ext/glm/gtx/closest_point.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_closest_point 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER vec<3, T, Q> closestPointOnLine 7 | ( 8 | vec<3, T, Q> const& point, 9 | vec<3, T, Q> const& a, 10 | vec<3, T, Q> const& b 11 | ) 12 | { 13 | T LineLength = distance(a, b); 14 | vec<3, T, Q> Vector = point - a; 15 | vec<3, T, Q> LineDirection = (b - a) / LineLength; 16 | 17 | // Project Vector to LineDirection to get the distance of point from a 18 | T Distance = dot(Vector, LineDirection); 19 | 20 | if(Distance <= T(0)) return a; 21 | if(Distance >= LineLength) return b; 22 | return a + LineDirection * Distance; 23 | } 24 | 25 | template 26 | GLM_FUNC_QUALIFIER vec<2, T, Q> closestPointOnLine 27 | ( 28 | vec<2, T, Q> const& point, 29 | vec<2, T, Q> const& a, 30 | vec<2, T, Q> const& b 31 | ) 32 | { 33 | T LineLength = distance(a, b); 34 | vec<2, T, Q> Vector = point - a; 35 | vec<2, T, Q> LineDirection = (b - a) / LineLength; 36 | 37 | // Project Vector to LineDirection to get the distance of point from a 38 | T Distance = dot(Vector, LineDirection); 39 | 40 | if(Distance <= T(0)) return a; 41 | if(Distance >= LineLength) return b; 42 | return a + LineDirection * Distance; 43 | } 44 | 45 | }//namespace glm 46 | -------------------------------------------------------------------------------- /ext/glm/gtx/extend.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_extend 2 | /// @file glm/gtx/extend.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_extend GLM_GTX_extend 7 | /// @ingroup gtx 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// Extend a position from a source to a position at a defined length. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 19 | # ifndef GLM_ENABLE_EXPERIMENTAL 20 | # pragma message("GLM: GLM_GTX_extend is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 21 | # else 22 | # pragma message("GLM: GLM_GTX_extend extension included") 23 | # endif 24 | #endif 25 | 26 | namespace glm 27 | { 28 | /// @addtogroup gtx_extend 29 | /// @{ 30 | 31 | /// Extends of Length the Origin position using the (Source - Origin) direction. 32 | /// @see gtx_extend 33 | template 34 | GLM_FUNC_DECL genType extend( 35 | genType const& Origin, 36 | genType const& Source, 37 | typename genType::value_type const Length); 38 | 39 | /// @} 40 | }//namespace glm 41 | 42 | #include "extend.inl" 43 | -------------------------------------------------------------------------------- /ext/glm/gtx/extend.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_extend 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER genType extend 7 | ( 8 | genType const& Origin, 9 | genType const& Source, 10 | genType const& Distance 11 | ) 12 | { 13 | return Origin + (Source - Origin) * Distance; 14 | } 15 | 16 | template 17 | GLM_FUNC_QUALIFIER vec<2, T, Q> extend 18 | ( 19 | vec<2, T, Q> const& Origin, 20 | vec<2, T, Q> const& Source, 21 | T const& Distance 22 | ) 23 | { 24 | return Origin + (Source - Origin) * Distance; 25 | } 26 | 27 | template 28 | GLM_FUNC_QUALIFIER vec<3, T, Q> extend 29 | ( 30 | vec<3, T, Q> const& Origin, 31 | vec<3, T, Q> const& Source, 32 | T const& Distance 33 | ) 34 | { 35 | return Origin + (Source - Origin) * Distance; 36 | } 37 | 38 | template 39 | GLM_FUNC_QUALIFIER vec<4, T, Q> extend 40 | ( 41 | vec<4, T, Q> const& Origin, 42 | vec<4, T, Q> const& Source, 43 | T const& Distance 44 | ) 45 | { 46 | return Origin + (Source - Origin) * Distance; 47 | } 48 | }//namespace glm 49 | -------------------------------------------------------------------------------- /ext/glm/gtx/exterior_product.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_exterior_product 2 | /// @file glm/gtx/exterior_product.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtx_exterior_product (dependence) 6 | /// 7 | /// @defgroup gtx_exterior_product GLM_GTX_exterior_product 8 | /// @ingroup gtx 9 | /// 10 | /// Include to use the features of this extension. 11 | /// 12 | /// @brief Allow to perform bit operations on integer values 13 | 14 | #pragma once 15 | 16 | // Dependencies 17 | #include "../detail/setup.hpp" 18 | #include "../detail/qualifier.hpp" 19 | 20 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 21 | # ifndef GLM_ENABLE_EXPERIMENTAL 22 | # pragma message("GLM: GLM_GTX_exterior_product is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 23 | # else 24 | # pragma message("GLM: GLM_GTX_exterior_product extension included") 25 | # endif 26 | #endif 27 | 28 | namespace glm 29 | { 30 | /// @addtogroup gtx_exterior_product 31 | /// @{ 32 | 33 | /// Returns the cross product of x and y. 34 | /// 35 | /// @tparam T Floating-point scalar types 36 | /// @tparam Q Value from qualifier enum 37 | /// 38 | /// @see Exterior product 39 | template 40 | GLM_FUNC_DECL T cross(vec<2, T, Q> const& v, vec<2, T, Q> const& u); 41 | 42 | /// @} 43 | } //namespace glm 44 | 45 | #include "exterior_product.inl" 46 | -------------------------------------------------------------------------------- /ext/glm/gtx/exterior_product.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_exterior_product 2 | 3 | #include 4 | 5 | namespace glm { 6 | namespace detail 7 | { 8 | template 9 | struct compute_cross_vec2 10 | { 11 | GLM_FUNC_QUALIFIER static T call(vec<2, T, Q> const& v, vec<2, T, Q> const& u) 12 | { 13 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'cross' accepts only floating-point inputs"); 14 | 15 | return v.x * u.y - u.x * v.y; 16 | } 17 | }; 18 | }//namespace detail 19 | 20 | template 21 | GLM_FUNC_QUALIFIER T cross(vec<2, T, Q> const& x, vec<2, T, Q> const& y) 22 | { 23 | return detail::compute_cross_vec2::value>::call(x, y); 24 | } 25 | }//namespace glm 26 | 27 | -------------------------------------------------------------------------------- /ext/glm/gtx/float_notmalize.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_float_normalize 2 | 3 | #include 4 | 5 | namespace glm 6 | { 7 | template 8 | GLM_FUNC_QUALIFIER vec floatNormalize(vec const& v) 9 | { 10 | return vec(v) / static_cast(std::numeric_limits::max()); 11 | } 12 | 13 | }//namespace glm 14 | -------------------------------------------------------------------------------- /ext/glm/gtx/functions.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_functions 2 | /// @file glm/gtx/functions.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtc_quaternion (dependence) 6 | /// 7 | /// @defgroup gtx_functions GLM_GTX_functions 8 | /// @ingroup gtx 9 | /// 10 | /// Include to use the features of this extension. 11 | /// 12 | /// List of useful common functions. 13 | 14 | #pragma once 15 | 16 | // Dependencies 17 | #include "../detail/setup.hpp" 18 | #include "../detail/qualifier.hpp" 19 | #include "../detail/type_vec2.hpp" 20 | 21 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 22 | # ifndef GLM_ENABLE_EXPERIMENTAL 23 | # pragma message("GLM: GLM_GTX_functions is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 24 | # else 25 | # pragma message("GLM: GLM_GTX_functions extension included") 26 | # endif 27 | #endif 28 | 29 | namespace glm 30 | { 31 | /// @addtogroup gtx_functions 32 | /// @{ 33 | 34 | /// 1D gauss function 35 | /// 36 | /// @see gtc_epsilon 37 | template 38 | GLM_FUNC_DECL T gauss( 39 | T x, 40 | T ExpectedValue, 41 | T StandardDeviation); 42 | 43 | /// 2D gauss function 44 | /// 45 | /// @see gtc_epsilon 46 | template 47 | GLM_FUNC_DECL T gauss( 48 | vec<2, T, Q> const& Coord, 49 | vec<2, T, Q> const& ExpectedValue, 50 | vec<2, T, Q> const& StandardDeviation); 51 | 52 | /// @} 53 | }//namespace glm 54 | 55 | #include "functions.inl" 56 | 57 | -------------------------------------------------------------------------------- /ext/glm/gtx/functions.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_functions 2 | 3 | #include "../exponential.hpp" 4 | 5 | namespace glm 6 | { 7 | template 8 | GLM_FUNC_QUALIFIER T gauss 9 | ( 10 | T x, 11 | T ExpectedValue, 12 | T StandardDeviation 13 | ) 14 | { 15 | return exp(-((x - ExpectedValue) * (x - ExpectedValue)) / (static_cast(2) * StandardDeviation * StandardDeviation)) / (StandardDeviation * sqrt(static_cast(6.28318530717958647692528676655900576))); 16 | } 17 | 18 | template 19 | GLM_FUNC_QUALIFIER T gauss 20 | ( 21 | vec<2, T, Q> const& Coord, 22 | vec<2, T, Q> const& ExpectedValue, 23 | vec<2, T, Q> const& StandardDeviation 24 | ) 25 | { 26 | vec<2, T, Q> const Squared = ((Coord - ExpectedValue) * (Coord - ExpectedValue)) / (static_cast(2) * StandardDeviation * StandardDeviation); 27 | return exp(-(Squared.x + Squared.y)); 28 | } 29 | }//namespace glm 30 | 31 | -------------------------------------------------------------------------------- /ext/glm/gtx/gradient_paint.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_gradient_paint 2 | /// @file glm/gtx/gradient_paint.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtx_optimum_pow (dependence) 6 | /// 7 | /// @defgroup gtx_gradient_paint GLM_GTX_gradient_paint 8 | /// @ingroup gtx 9 | /// 10 | /// Include to use the features of this extension. 11 | /// 12 | /// Functions that return the color of procedural gradient for specific coordinates. 13 | 14 | #pragma once 15 | 16 | // Dependency: 17 | #include "../glm.hpp" 18 | #include "../gtx/optimum_pow.hpp" 19 | 20 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 21 | # ifndef GLM_ENABLE_EXPERIMENTAL 22 | # pragma message("GLM: GLM_GTX_gradient_paint is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 23 | # else 24 | # pragma message("GLM: GLM_GTX_gradient_paint extension included") 25 | # endif 26 | #endif 27 | 28 | namespace glm 29 | { 30 | /// @addtogroup gtx_gradient_paint 31 | /// @{ 32 | 33 | /// Return a color from a radial gradient. 34 | /// @see - gtx_gradient_paint 35 | template 36 | GLM_FUNC_DECL T radialGradient( 37 | vec<2, T, Q> const& Center, 38 | T const& Radius, 39 | vec<2, T, Q> const& Focal, 40 | vec<2, T, Q> const& Position); 41 | 42 | /// Return a color from a linear gradient. 43 | /// @see - gtx_gradient_paint 44 | template 45 | GLM_FUNC_DECL T linearGradient( 46 | vec<2, T, Q> const& Point0, 47 | vec<2, T, Q> const& Point1, 48 | vec<2, T, Q> const& Position); 49 | 50 | /// @} 51 | }// namespace glm 52 | 53 | #include "gradient_paint.inl" 54 | -------------------------------------------------------------------------------- /ext/glm/gtx/gradient_paint.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_gradient_paint 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER T radialGradient 7 | ( 8 | vec<2, T, Q> const& Center, 9 | T const& Radius, 10 | vec<2, T, Q> const& Focal, 11 | vec<2, T, Q> const& Position 12 | ) 13 | { 14 | vec<2, T, Q> F = Focal - Center; 15 | vec<2, T, Q> D = Position - Focal; 16 | T Radius2 = pow2(Radius); 17 | T Fx2 = pow2(F.x); 18 | T Fy2 = pow2(F.y); 19 | 20 | T Numerator = (D.x * F.x + D.y * F.y) + sqrt(Radius2 * (pow2(D.x) + pow2(D.y)) - pow2(D.x * F.y - D.y * F.x)); 21 | T Denominator = Radius2 - (Fx2 + Fy2); 22 | return Numerator / Denominator; 23 | } 24 | 25 | template 26 | GLM_FUNC_QUALIFIER T linearGradient 27 | ( 28 | vec<2, T, Q> const& Point0, 29 | vec<2, T, Q> const& Point1, 30 | vec<2, T, Q> const& Position 31 | ) 32 | { 33 | vec<2, T, Q> Dist = Point1 - Point0; 34 | return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist); 35 | } 36 | }//namespace glm 37 | -------------------------------------------------------------------------------- /ext/glm/gtx/handed_coordinate_space.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_handed_coordinate_space 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER bool rightHanded 7 | ( 8 | vec<3, T, Q> const& tangent, 9 | vec<3, T, Q> const& binormal, 10 | vec<3, T, Q> const& normal 11 | ) 12 | { 13 | return dot(cross(normal, tangent), binormal) > T(0); 14 | } 15 | 16 | template 17 | GLM_FUNC_QUALIFIER bool leftHanded 18 | ( 19 | vec<3, T, Q> const& tangent, 20 | vec<3, T, Q> const& binormal, 21 | vec<3, T, Q> const& normal 22 | ) 23 | { 24 | return dot(cross(normal, tangent), binormal) < T(0); 25 | } 26 | }//namespace glm 27 | -------------------------------------------------------------------------------- /ext/glm/gtx/log_base.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_log_base 2 | /// @file glm/gtx/log_base.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_log_base GLM_GTX_log_base 7 | /// @ingroup gtx 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// Logarithm for any base. base can be a vector or a scalar. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 19 | # ifndef GLM_ENABLE_EXPERIMENTAL 20 | # pragma message("GLM: GLM_GTX_log_base is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 21 | # else 22 | # pragma message("GLM: GLM_GTX_log_base extension included") 23 | # endif 24 | #endif 25 | 26 | namespace glm 27 | { 28 | /// @addtogroup gtx_log_base 29 | /// @{ 30 | 31 | /// Logarithm for any base. 32 | /// From GLM_GTX_log_base. 33 | template 34 | GLM_FUNC_DECL genType log( 35 | genType const& x, 36 | genType const& base); 37 | 38 | /// Logarithm for any base. 39 | /// From GLM_GTX_log_base. 40 | template 41 | GLM_FUNC_DECL vec sign( 42 | vec const& x, 43 | vec const& base); 44 | 45 | /// @} 46 | }//namespace glm 47 | 48 | #include "log_base.inl" 49 | -------------------------------------------------------------------------------- /ext/glm/gtx/log_base.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_log_base 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER genType log(genType const& x, genType const& base) 7 | { 8 | return glm::log(x) / glm::log(base); 9 | } 10 | 11 | template 12 | GLM_FUNC_QUALIFIER vec log(vec const& x, vec const& base) 13 | { 14 | return glm::log(x) / glm::log(base); 15 | } 16 | }//namespace glm 17 | -------------------------------------------------------------------------------- /ext/glm/gtx/matrix_cross_product.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_matrix_cross_product 2 | /// @file glm/gtx/matrix_cross_product.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtx_extented_min_max (dependence) 6 | /// 7 | /// @defgroup gtx_matrix_cross_product GLM_GTX_matrix_cross_product 8 | /// @ingroup gtx 9 | /// 10 | /// Include to use the features of this extension. 11 | /// 12 | /// Build cross product matrices 13 | 14 | #pragma once 15 | 16 | // Dependency: 17 | #include "../glm.hpp" 18 | 19 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 20 | # ifndef GLM_ENABLE_EXPERIMENTAL 21 | # pragma message("GLM: GLM_GTX_matrix_cross_product is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 22 | # else 23 | # pragma message("GLM: GLM_GTX_matrix_cross_product extension included") 24 | # endif 25 | #endif 26 | 27 | namespace glm 28 | { 29 | /// @addtogroup gtx_matrix_cross_product 30 | /// @{ 31 | 32 | //! Build a cross product matrix. 33 | //! From GLM_GTX_matrix_cross_product extension. 34 | template 35 | GLM_FUNC_DECL mat<3, 3, T, Q> matrixCross3( 36 | vec<3, T, Q> const& x); 37 | 38 | //! Build a cross product matrix. 39 | //! From GLM_GTX_matrix_cross_product extension. 40 | template 41 | GLM_FUNC_DECL mat<4, 4, T, Q> matrixCross4( 42 | vec<3, T, Q> const& x); 43 | 44 | /// @} 45 | }//namespace glm 46 | 47 | #include "matrix_cross_product.inl" 48 | -------------------------------------------------------------------------------- /ext/glm/gtx/matrix_cross_product.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_matrix_cross_product 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER mat<3, 3, T, Q> matrixCross3 7 | ( 8 | vec<3, T, Q> const& x 9 | ) 10 | { 11 | mat<3, 3, T, Q> Result(T(0)); 12 | Result[0][1] = x.z; 13 | Result[1][0] = -x.z; 14 | Result[0][2] = -x.y; 15 | Result[2][0] = x.y; 16 | Result[1][2] = x.x; 17 | Result[2][1] = -x.x; 18 | return Result; 19 | } 20 | 21 | template 22 | GLM_FUNC_QUALIFIER mat<4, 4, T, Q> matrixCross4 23 | ( 24 | vec<3, T, Q> const& x 25 | ) 26 | { 27 | mat<4, 4, T, Q> Result(T(0)); 28 | Result[0][1] = x.z; 29 | Result[1][0] = -x.z; 30 | Result[0][2] = -x.y; 31 | Result[2][0] = x.y; 32 | Result[1][2] = x.x; 33 | Result[2][1] = -x.x; 34 | return Result; 35 | } 36 | 37 | }//namespace glm 38 | -------------------------------------------------------------------------------- /ext/glm/gtx/matrix_decompose.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_matrix_decompose 2 | /// @file glm/gtx/matrix_decompose.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_matrix_decompose GLM_GTX_matrix_decompose 7 | /// @ingroup gtx 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// Decomposes a model matrix to translations, rotation and scale components 12 | 13 | #pragma once 14 | 15 | // Dependencies 16 | #include "../mat4x4.hpp" 17 | #include "../vec3.hpp" 18 | #include "../vec4.hpp" 19 | #include "../geometric.hpp" 20 | #include "../gtc/quaternion.hpp" 21 | #include "../gtc/matrix_transform.hpp" 22 | 23 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 24 | # ifndef GLM_ENABLE_EXPERIMENTAL 25 | # pragma message("GLM: GLM_GTX_matrix_decompose is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 26 | # else 27 | # pragma message("GLM: GLM_GTX_matrix_decompose extension included") 28 | # endif 29 | #endif 30 | 31 | namespace glm 32 | { 33 | /// @addtogroup gtx_matrix_decompose 34 | /// @{ 35 | 36 | /// Decomposes a model matrix to translations, rotation and scale components 37 | /// @see gtx_matrix_decompose 38 | template 39 | GLM_FUNC_DECL bool decompose( 40 | mat<4, 4, T, Q> const& modelMatrix, 41 | vec<3, T, Q> & scale, qua & orientation, vec<3, T, Q> & translation, vec<3, T, Q> & skew, vec<4, T, Q> & perspective); 42 | 43 | /// @} 44 | }//namespace glm 45 | 46 | #include "matrix_decompose.inl" 47 | -------------------------------------------------------------------------------- /ext/glm/gtx/matrix_factorisation.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HummaWhite/Zillum/f5cbec605e7c24ee4dd0f29917ce102ee310ef4f/ext/glm/gtx/matrix_factorisation.inl -------------------------------------------------------------------------------- /ext/glm/gtx/matrix_transform_2d.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_matrix_transform_2d 2 | /// @author Miguel Ángel Pérez Martínez 3 | 4 | #include "../trigonometric.hpp" 5 | 6 | namespace glm 7 | { 8 | 9 | template 10 | GLM_FUNC_QUALIFIER mat<3, 3, T, Q> translate( 11 | mat<3, 3, T, Q> const& m, 12 | vec<2, T, Q> const& v) 13 | { 14 | mat<3, 3, T, Q> Result(m); 15 | Result[2] = m[0] * v[0] + m[1] * v[1] + m[2]; 16 | return Result; 17 | } 18 | 19 | 20 | template 21 | GLM_FUNC_QUALIFIER mat<3, 3, T, Q> rotate( 22 | mat<3, 3, T, Q> const& m, 23 | T angle) 24 | { 25 | T const a = angle; 26 | T const c = cos(a); 27 | T const s = sin(a); 28 | 29 | mat<3, 3, T, Q> Result; 30 | Result[0] = m[0] * c + m[1] * s; 31 | Result[1] = m[0] * -s + m[1] * c; 32 | Result[2] = m[2]; 33 | return Result; 34 | } 35 | 36 | template 37 | GLM_FUNC_QUALIFIER mat<3, 3, T, Q> scale( 38 | mat<3, 3, T, Q> const& m, 39 | vec<2, T, Q> const& v) 40 | { 41 | mat<3, 3, T, Q> Result; 42 | Result[0] = m[0] * v[0]; 43 | Result[1] = m[1] * v[1]; 44 | Result[2] = m[2]; 45 | return Result; 46 | } 47 | 48 | template 49 | GLM_FUNC_QUALIFIER mat<3, 3, T, Q> shearX( 50 | mat<3, 3, T, Q> const& m, 51 | T y) 52 | { 53 | mat<3, 3, T, Q> Result(1); 54 | Result[0][1] = y; 55 | return m * Result; 56 | } 57 | 58 | template 59 | GLM_FUNC_QUALIFIER mat<3, 3, T, Q> shearY( 60 | mat<3, 3, T, Q> const& m, 61 | T x) 62 | { 63 | mat<3, 3, T, Q> Result(1); 64 | Result[1][0] = x; 65 | return m * Result; 66 | } 67 | 68 | }//namespace glm 69 | -------------------------------------------------------------------------------- /ext/glm/gtx/mixed_product.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_mixed_product 2 | /// @file glm/gtx/mixed_product.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_mixed_product GLM_GTX_mixed_producte 7 | /// @ingroup gtx 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// Mixed product of 3 vectors. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 19 | # ifndef GLM_ENABLE_EXPERIMENTAL 20 | # pragma message("GLM: GLM_GTX_mixed_product is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 21 | # else 22 | # pragma message("GLM: GLM_GTX_mixed_product extension included") 23 | # endif 24 | #endif 25 | 26 | namespace glm 27 | { 28 | /// @addtogroup gtx_mixed_product 29 | /// @{ 30 | 31 | /// @brief Mixed product of 3 vectors (from GLM_GTX_mixed_product extension) 32 | template 33 | GLM_FUNC_DECL T mixedProduct( 34 | vec<3, T, Q> const& v1, 35 | vec<3, T, Q> const& v2, 36 | vec<3, T, Q> const& v3); 37 | 38 | /// @} 39 | }// namespace glm 40 | 41 | #include "mixed_product.inl" 42 | -------------------------------------------------------------------------------- /ext/glm/gtx/mixed_product.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_mixed_product 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER T mixedProduct 7 | ( 8 | vec<3, T, Q> const& v1, 9 | vec<3, T, Q> const& v2, 10 | vec<3, T, Q> const& v3 11 | ) 12 | { 13 | return dot(cross(v1, v2), v3); 14 | } 15 | }//namespace glm 16 | -------------------------------------------------------------------------------- /ext/glm/gtx/normal.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_normal 2 | /// @file glm/gtx/normal.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtx_extented_min_max (dependence) 6 | /// 7 | /// @defgroup gtx_normal GLM_GTX_normal 8 | /// @ingroup gtx 9 | /// 10 | /// Include to use the features of this extension. 11 | /// 12 | /// Compute the normal of a triangle. 13 | 14 | #pragma once 15 | 16 | // Dependency: 17 | #include "../glm.hpp" 18 | 19 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 20 | # ifndef GLM_ENABLE_EXPERIMENTAL 21 | # pragma message("GLM: GLM_GTX_normal is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 22 | # else 23 | # pragma message("GLM: GLM_GTX_normal extension included") 24 | # endif 25 | #endif 26 | 27 | namespace glm 28 | { 29 | /// @addtogroup gtx_normal 30 | /// @{ 31 | 32 | /// Computes triangle normal from triangle points. 33 | /// 34 | /// @see gtx_normal 35 | template 36 | GLM_FUNC_DECL vec<3, T, Q> triangleNormal(vec<3, T, Q> const& p1, vec<3, T, Q> const& p2, vec<3, T, Q> const& p3); 37 | 38 | /// @} 39 | }//namespace glm 40 | 41 | #include "normal.inl" 42 | -------------------------------------------------------------------------------- /ext/glm/gtx/normal.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_normal 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER vec<3, T, Q> triangleNormal 7 | ( 8 | vec<3, T, Q> const& p1, 9 | vec<3, T, Q> const& p2, 10 | vec<3, T, Q> const& p3 11 | ) 12 | { 13 | return normalize(cross(p1 - p2, p1 - p3)); 14 | } 15 | }//namespace glm 16 | -------------------------------------------------------------------------------- /ext/glm/gtx/normalize_dot.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_normalize_dot 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER T normalizeDot(vec const& x, vec const& y) 7 | { 8 | return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y)); 9 | } 10 | 11 | template 12 | GLM_FUNC_QUALIFIER T fastNormalizeDot(vec const& x, vec const& y) 13 | { 14 | return glm::dot(x, y) * glm::fastInverseSqrt(glm::dot(x, x) * glm::dot(y, y)); 15 | } 16 | }//namespace glm 17 | -------------------------------------------------------------------------------- /ext/glm/gtx/number_precision.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_number_precision 2 | 3 | namespace glm 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /ext/glm/gtx/optimum_pow.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_optimum_pow 2 | /// @file glm/gtx/optimum_pow.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_optimum_pow GLM_GTX_optimum_pow 7 | /// @ingroup gtx 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// Integer exponentiation of power functions. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 19 | # ifndef GLM_ENABLE_EXPERIMENTAL 20 | # pragma message("GLM: GLM_GTX_optimum_pow is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 21 | # else 22 | # pragma message("GLM: GLM_GTX_optimum_pow extension included") 23 | # endif 24 | #endif 25 | 26 | namespace glm{ 27 | namespace gtx 28 | { 29 | /// @addtogroup gtx_optimum_pow 30 | /// @{ 31 | 32 | /// Returns x raised to the power of 2. 33 | /// 34 | /// @see gtx_optimum_pow 35 | template 36 | GLM_FUNC_DECL genType pow2(genType const& x); 37 | 38 | /// Returns x raised to the power of 3. 39 | /// 40 | /// @see gtx_optimum_pow 41 | template 42 | GLM_FUNC_DECL genType pow3(genType const& x); 43 | 44 | /// Returns x raised to the power of 4. 45 | /// 46 | /// @see gtx_optimum_pow 47 | template 48 | GLM_FUNC_DECL genType pow4(genType const& x); 49 | 50 | /// @} 51 | }//namespace gtx 52 | }//namespace glm 53 | 54 | #include "optimum_pow.inl" 55 | -------------------------------------------------------------------------------- /ext/glm/gtx/optimum_pow.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_optimum_pow 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER genType pow2(genType const& x) 7 | { 8 | return x * x; 9 | } 10 | 11 | template 12 | GLM_FUNC_QUALIFIER genType pow3(genType const& x) 13 | { 14 | return x * x * x; 15 | } 16 | 17 | template 18 | GLM_FUNC_QUALIFIER genType pow4(genType const& x) 19 | { 20 | return (x * x) * (x * x); 21 | } 22 | }//namespace glm 23 | -------------------------------------------------------------------------------- /ext/glm/gtx/orthonormalize.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_orthonormalize 2 | /// @file glm/gtx/orthonormalize.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtx_extented_min_max (dependence) 6 | /// 7 | /// @defgroup gtx_orthonormalize GLM_GTX_orthonormalize 8 | /// @ingroup gtx 9 | /// 10 | /// Include to use the features of this extension. 11 | /// 12 | /// Orthonormalize matrices. 13 | 14 | #pragma once 15 | 16 | // Dependency: 17 | #include "../vec3.hpp" 18 | #include "../mat3x3.hpp" 19 | #include "../geometric.hpp" 20 | 21 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 22 | # ifndef GLM_ENABLE_EXPERIMENTAL 23 | # pragma message("GLM: GLM_GTX_orthonormalize is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 24 | # else 25 | # pragma message("GLM: GLM_GTX_orthonormalize extension included") 26 | # endif 27 | #endif 28 | 29 | namespace glm 30 | { 31 | /// @addtogroup gtx_orthonormalize 32 | /// @{ 33 | 34 | /// Returns the orthonormalized matrix of m. 35 | /// 36 | /// @see gtx_orthonormalize 37 | template 38 | GLM_FUNC_DECL mat<3, 3, T, Q> orthonormalize(mat<3, 3, T, Q> const& m); 39 | 40 | /// Orthonormalizes x according y. 41 | /// 42 | /// @see gtx_orthonormalize 43 | template 44 | GLM_FUNC_DECL vec<3, T, Q> orthonormalize(vec<3, T, Q> const& x, vec<3, T, Q> const& y); 45 | 46 | /// @} 47 | }//namespace glm 48 | 49 | #include "orthonormalize.inl" 50 | -------------------------------------------------------------------------------- /ext/glm/gtx/orthonormalize.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_orthonormalize 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER mat<3, 3, T, Q> orthonormalize(mat<3, 3, T, Q> const& m) 7 | { 8 | mat<3, 3, T, Q> r = m; 9 | 10 | r[0] = normalize(r[0]); 11 | 12 | T d0 = dot(r[0], r[1]); 13 | r[1] -= r[0] * d0; 14 | r[1] = normalize(r[1]); 15 | 16 | T d1 = dot(r[1], r[2]); 17 | d0 = dot(r[0], r[2]); 18 | r[2] -= r[0] * d0 + r[1] * d1; 19 | r[2] = normalize(r[2]); 20 | 21 | return r; 22 | } 23 | 24 | template 25 | GLM_FUNC_QUALIFIER vec<3, T, Q> orthonormalize(vec<3, T, Q> const& x, vec<3, T, Q> const& y) 26 | { 27 | return normalize(x - y * dot(y, x)); 28 | } 29 | }//namespace glm 30 | -------------------------------------------------------------------------------- /ext/glm/gtx/perpendicular.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_perpendicular 2 | /// @file glm/gtx/perpendicular.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtx_projection (dependence) 6 | /// 7 | /// @defgroup gtx_perpendicular GLM_GTX_perpendicular 8 | /// @ingroup gtx 9 | /// 10 | /// Include to use the features of this extension. 11 | /// 12 | /// Perpendicular of a vector from other one 13 | 14 | #pragma once 15 | 16 | // Dependency: 17 | #include "../glm.hpp" 18 | #include "../gtx/projection.hpp" 19 | 20 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 21 | # ifndef GLM_ENABLE_EXPERIMENTAL 22 | # pragma message("GLM: GLM_GTX_perpendicular is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 23 | # else 24 | # pragma message("GLM: GLM_GTX_perpendicular extension included") 25 | # endif 26 | #endif 27 | 28 | namespace glm 29 | { 30 | /// @addtogroup gtx_perpendicular 31 | /// @{ 32 | 33 | //! Projects x a perpendicular axis of Normal. 34 | //! From GLM_GTX_perpendicular extension. 35 | template 36 | GLM_FUNC_DECL genType perp(genType const& x, genType const& Normal); 37 | 38 | /// @} 39 | }//namespace glm 40 | 41 | #include "perpendicular.inl" 42 | -------------------------------------------------------------------------------- /ext/glm/gtx/perpendicular.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_perpendicular 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER genType perp(genType const& x, genType const& Normal) 7 | { 8 | return x - proj(x, Normal); 9 | } 10 | }//namespace glm 11 | -------------------------------------------------------------------------------- /ext/glm/gtx/polar_coordinates.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_polar_coordinates 2 | /// @file glm/gtx/polar_coordinates.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_polar_coordinates GLM_GTX_polar_coordinates 7 | /// @ingroup gtx 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// Conversion from Euclidean space to polar space and revert. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 19 | # ifndef GLM_ENABLE_EXPERIMENTAL 20 | # pragma message("GLM: GLM_GTX_polar_coordinates is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 21 | # else 22 | # pragma message("GLM: GLM_GTX_polar_coordinates extension included") 23 | # endif 24 | #endif 25 | 26 | namespace glm 27 | { 28 | /// @addtogroup gtx_polar_coordinates 29 | /// @{ 30 | 31 | /// Convert Euclidean to Polar coordinates, x is the latitude, y the longitude and z the xz distance. 32 | /// 33 | /// @see gtx_polar_coordinates 34 | template 35 | GLM_FUNC_DECL vec<3, T, Q> polar( 36 | vec<3, T, Q> const& euclidean); 37 | 38 | /// Convert Polar to Euclidean coordinates. 39 | /// 40 | /// @see gtx_polar_coordinates 41 | template 42 | GLM_FUNC_DECL vec<3, T, Q> euclidean( 43 | vec<2, T, Q> const& polar); 44 | 45 | /// @} 46 | }//namespace glm 47 | 48 | #include "polar_coordinates.inl" 49 | -------------------------------------------------------------------------------- /ext/glm/gtx/polar_coordinates.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_polar_coordinates 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER vec<3, T, Q> polar 7 | ( 8 | vec<3, T, Q> const& euclidean 9 | ) 10 | { 11 | T const Length(length(euclidean)); 12 | vec<3, T, Q> const tmp(euclidean / Length); 13 | T const xz_dist(sqrt(tmp.x * tmp.x + tmp.z * tmp.z)); 14 | 15 | return vec<3, T, Q>( 16 | asin(tmp.y), // latitude 17 | atan(tmp.x, tmp.z), // longitude 18 | xz_dist); // xz distance 19 | } 20 | 21 | template 22 | GLM_FUNC_QUALIFIER vec<3, T, Q> euclidean 23 | ( 24 | vec<2, T, Q> const& polar 25 | ) 26 | { 27 | T const latitude(polar.x); 28 | T const longitude(polar.y); 29 | 30 | return vec<3, T, Q>( 31 | cos(latitude) * sin(longitude), 32 | sin(latitude), 33 | cos(latitude) * cos(longitude)); 34 | } 35 | 36 | }//namespace glm 37 | -------------------------------------------------------------------------------- /ext/glm/gtx/projection.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_projection 2 | /// @file glm/gtx/projection.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_projection GLM_GTX_projection 7 | /// @ingroup gtx 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// Projection of a vector to other one 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../geometric.hpp" 17 | 18 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 19 | # ifndef GLM_ENABLE_EXPERIMENTAL 20 | # pragma message("GLM: GLM_GTX_projection is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 21 | # else 22 | # pragma message("GLM: GLM_GTX_projection extension included") 23 | # endif 24 | #endif 25 | 26 | namespace glm 27 | { 28 | /// @addtogroup gtx_projection 29 | /// @{ 30 | 31 | /// Projects x on Normal. 32 | /// 33 | /// @param[in] x A vector to project 34 | /// @param[in] Normal A normal that doesn't need to be of unit length. 35 | /// 36 | /// @see gtx_projection 37 | template 38 | GLM_FUNC_DECL genType proj(genType const& x, genType const& Normal); 39 | 40 | /// @} 41 | }//namespace glm 42 | 43 | #include "projection.inl" 44 | -------------------------------------------------------------------------------- /ext/glm/gtx/projection.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_projection 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER genType proj(genType const& x, genType const& Normal) 7 | { 8 | return glm::dot(x, Normal) / glm::dot(Normal, Normal) * Normal; 9 | } 10 | }//namespace glm 11 | -------------------------------------------------------------------------------- /ext/glm/gtx/raw_data.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_raw_data 2 | /// @file glm/gtx/raw_data.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_raw_data GLM_GTX_raw_data 7 | /// @ingroup gtx 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// Projection of a vector to other one 12 | 13 | #pragma once 14 | 15 | // Dependencies 16 | #include "../ext/scalar_uint_sized.hpp" 17 | #include "../detail/setup.hpp" 18 | 19 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 20 | # ifndef GLM_ENABLE_EXPERIMENTAL 21 | # pragma message("GLM: GLM_GTX_raw_data is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 22 | # else 23 | # pragma message("GLM: GLM_GTX_raw_data extension included") 24 | # endif 25 | #endif 26 | 27 | namespace glm 28 | { 29 | /// @addtogroup gtx_raw_data 30 | /// @{ 31 | 32 | //! Type for byte numbers. 33 | //! From GLM_GTX_raw_data extension. 34 | typedef detail::uint8 byte; 35 | 36 | //! Type for word numbers. 37 | //! From GLM_GTX_raw_data extension. 38 | typedef detail::uint16 word; 39 | 40 | //! Type for dword numbers. 41 | //! From GLM_GTX_raw_data extension. 42 | typedef detail::uint32 dword; 43 | 44 | //! Type for qword numbers. 45 | //! From GLM_GTX_raw_data extension. 46 | typedef detail::uint64 qword; 47 | 48 | /// @} 49 | }// namespace glm 50 | 51 | #include "raw_data.inl" 52 | -------------------------------------------------------------------------------- /ext/glm/gtx/raw_data.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_raw_data 2 | 3 | -------------------------------------------------------------------------------- /ext/glm/gtx/scalar_relational.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_scalar_relational 2 | /// @file glm/gtx/scalar_relational.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_scalar_relational GLM_GTX_scalar_relational 7 | /// @ingroup gtx 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// Extend a position from a source to a position at a defined length. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 19 | # ifndef GLM_ENABLE_EXPERIMENTAL 20 | # pragma message("GLM: GLM_GTX_extend is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 21 | # else 22 | # pragma message("GLM: GLM_GTX_extend extension included") 23 | # endif 24 | #endif 25 | 26 | namespace glm 27 | { 28 | /// @addtogroup gtx_scalar_relational 29 | /// @{ 30 | 31 | 32 | 33 | /// @} 34 | }//namespace glm 35 | 36 | #include "scalar_relational.inl" 37 | -------------------------------------------------------------------------------- /ext/glm/gtx/scalar_relational.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_scalar_relational 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER bool lessThan 7 | ( 8 | T const& x, 9 | T const& y 10 | ) 11 | { 12 | return x < y; 13 | } 14 | 15 | template 16 | GLM_FUNC_QUALIFIER bool lessThanEqual 17 | ( 18 | T const& x, 19 | T const& y 20 | ) 21 | { 22 | return x <= y; 23 | } 24 | 25 | template 26 | GLM_FUNC_QUALIFIER bool greaterThan 27 | ( 28 | T const& x, 29 | T const& y 30 | ) 31 | { 32 | return x > y; 33 | } 34 | 35 | template 36 | GLM_FUNC_QUALIFIER bool greaterThanEqual 37 | ( 38 | T const& x, 39 | T const& y 40 | ) 41 | { 42 | return x >= y; 43 | } 44 | 45 | template 46 | GLM_FUNC_QUALIFIER bool equal 47 | ( 48 | T const& x, 49 | T const& y 50 | ) 51 | { 52 | return detail::compute_equal::is_iec559>::call(x, y); 53 | } 54 | 55 | template 56 | GLM_FUNC_QUALIFIER bool notEqual 57 | ( 58 | T const& x, 59 | T const& y 60 | ) 61 | { 62 | return !detail::compute_equal::is_iec559>::call(x, y); 63 | } 64 | 65 | GLM_FUNC_QUALIFIER bool any 66 | ( 67 | bool const& x 68 | ) 69 | { 70 | return x; 71 | } 72 | 73 | GLM_FUNC_QUALIFIER bool all 74 | ( 75 | bool const& x 76 | ) 77 | { 78 | return x; 79 | } 80 | 81 | GLM_FUNC_QUALIFIER bool not_ 82 | ( 83 | bool const& x 84 | ) 85 | { 86 | return !x; 87 | } 88 | }//namespace glm 89 | -------------------------------------------------------------------------------- /ext/glm/gtx/std_based_type.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_std_based_type 2 | 3 | namespace glm 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /ext/glm/gtx/string_cast.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_string_cast 2 | /// @file glm/gtx/string_cast.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtx_integer (dependence) 6 | /// @see gtx_quaternion (dependence) 7 | /// 8 | /// @defgroup gtx_string_cast GLM_GTX_string_cast 9 | /// @ingroup gtx 10 | /// 11 | /// Include to use the features of this extension. 12 | /// 13 | /// Setup strings for GLM type values 14 | /// 15 | /// This extension is not supported with CUDA 16 | 17 | #pragma once 18 | 19 | // Dependency: 20 | #include "../glm.hpp" 21 | #include "../gtc/type_precision.hpp" 22 | #include "../gtc/quaternion.hpp" 23 | #include "../gtx/dual_quaternion.hpp" 24 | #include 25 | #include 26 | 27 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 28 | # ifndef GLM_ENABLE_EXPERIMENTAL 29 | # pragma message("GLM: GLM_GTX_string_cast is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 30 | # else 31 | # pragma message("GLM: GLM_GTX_string_cast extension included") 32 | # endif 33 | #endif 34 | 35 | #if(GLM_COMPILER & GLM_COMPILER_CUDA) 36 | # error "GLM_GTX_string_cast is not supported on CUDA compiler" 37 | #endif 38 | 39 | namespace glm 40 | { 41 | /// @addtogroup gtx_string_cast 42 | /// @{ 43 | 44 | /// Create a string from a GLM vector or matrix typed variable. 45 | /// @see gtx_string_cast extension. 46 | template 47 | GLM_FUNC_DECL std::string to_string(genType const& x); 48 | 49 | /// @} 50 | }//namespace glm 51 | 52 | #include "string_cast.inl" 53 | -------------------------------------------------------------------------------- /ext/glm/gtx/texture.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_texture 2 | /// @file glm/gtx/texture.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_texture GLM_GTX_texture 7 | /// @ingroup gtx 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// Wrapping mode of texture coordinates. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | #include "../gtc/integer.hpp" 18 | #include "../gtx/component_wise.hpp" 19 | 20 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 21 | # ifndef GLM_ENABLE_EXPERIMENTAL 22 | # pragma message("GLM: GLM_GTX_texture is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 23 | # else 24 | # pragma message("GLM: GLM_GTX_texture extension included") 25 | # endif 26 | #endif 27 | 28 | namespace glm 29 | { 30 | /// @addtogroup gtx_texture 31 | /// @{ 32 | 33 | /// Compute the number of mipmaps levels necessary to create a mipmap complete texture 34 | /// 35 | /// @param Extent Extent of the texture base level mipmap 36 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector 37 | /// @tparam T Floating-point or signed integer scalar types 38 | /// @tparam Q Value from qualifier enum 39 | template 40 | T levels(vec const& Extent); 41 | 42 | /// @} 43 | }// namespace glm 44 | 45 | #include "texture.inl" 46 | 47 | -------------------------------------------------------------------------------- /ext/glm/gtx/texture.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_texture 2 | 3 | namespace glm 4 | { 5 | template 6 | inline T levels(vec const& Extent) 7 | { 8 | return glm::log2(compMax(Extent)) + static_cast(1); 9 | } 10 | 11 | template 12 | inline T levels(T Extent) 13 | { 14 | return vec<1, T, defaultp>(Extent).x; 15 | } 16 | }//namespace glm 17 | 18 | -------------------------------------------------------------------------------- /ext/glm/gtx/transform.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_transform 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER mat<4, 4, T, Q> translate(vec<3, T, Q> const& v) 7 | { 8 | return translate(mat<4, 4, T, Q>(static_cast(1)), v); 9 | } 10 | 11 | template 12 | GLM_FUNC_QUALIFIER mat<4, 4, T, Q> rotate(T angle, vec<3, T, Q> const& v) 13 | { 14 | return rotate(mat<4, 4, T, Q>(static_cast(1)), angle, v); 15 | } 16 | 17 | template 18 | GLM_FUNC_QUALIFIER mat<4, 4, T, Q> scale(vec<3, T, Q> const& v) 19 | { 20 | return scale(mat<4, 4, T, Q>(static_cast(1)), v); 21 | } 22 | 23 | }//namespace glm 24 | -------------------------------------------------------------------------------- /ext/glm/gtx/type_aligned.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtc_type_aligned 2 | 3 | namespace glm 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /ext/glm/gtx/vector_angle.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_vector_angle 2 | 3 | namespace glm 4 | { 5 | template 6 | GLM_FUNC_QUALIFIER genType angle 7 | ( 8 | genType const& x, 9 | genType const& y 10 | ) 11 | { 12 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'angle' only accept floating-point inputs"); 13 | return acos(clamp(dot(x, y), genType(-1), genType(1))); 14 | } 15 | 16 | template 17 | GLM_FUNC_QUALIFIER T angle(vec const& x, vec const& y) 18 | { 19 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'angle' only accept floating-point inputs"); 20 | return acos(clamp(dot(x, y), T(-1), T(1))); 21 | } 22 | 23 | //! \todo epsilon is hard coded to 0.01 24 | template 25 | GLM_FUNC_QUALIFIER T orientedAngle(vec<2, T, Q> const& x, vec<2, T, Q> const& y) 26 | { 27 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'orientedAngle' only accept floating-point inputs"); 28 | T const Angle(acos(clamp(dot(x, y), T(-1), T(1)))); 29 | 30 | if(all(epsilonEqual(y, glm::rotate(x, Angle), T(0.0001)))) 31 | return Angle; 32 | else 33 | return -Angle; 34 | } 35 | 36 | template 37 | GLM_FUNC_QUALIFIER T orientedAngle(vec<3, T, Q> const& x, vec<3, T, Q> const& y, vec<3, T, Q> const& ref) 38 | { 39 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'orientedAngle' only accept floating-point inputs"); 40 | 41 | T const Angle(acos(clamp(dot(x, y), T(-1), T(1)))); 42 | return mix(Angle, -Angle, dot(ref, cross(x, y)) < T(0)); 43 | } 44 | }//namespace glm 45 | -------------------------------------------------------------------------------- /ext/glm/gtx/wrap.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_wrap 2 | /// @file glm/gtx/wrap.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_wrap GLM_GTX_wrap 7 | /// @ingroup gtx 8 | /// 9 | /// Include to use the features of this extension. 10 | /// 11 | /// Wrapping mode of texture coordinates. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | #include "../gtc/vec1.hpp" 18 | 19 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) 20 | # ifndef GLM_ENABLE_EXPERIMENTAL 21 | # pragma message("GLM: GLM_GTX_wrap is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.") 22 | # else 23 | # pragma message("GLM: GLM_GTX_wrap extension included") 24 | # endif 25 | #endif 26 | 27 | namespace glm 28 | { 29 | /// @addtogroup gtx_wrap 30 | /// @{ 31 | 32 | /// Simulate GL_CLAMP OpenGL wrap mode 33 | /// @see gtx_wrap extension. 34 | template 35 | GLM_FUNC_DECL genType clamp(genType const& Texcoord); 36 | 37 | /// Simulate GL_REPEAT OpenGL wrap mode 38 | /// @see gtx_wrap extension. 39 | template 40 | GLM_FUNC_DECL genType repeat(genType const& Texcoord); 41 | 42 | /// Simulate GL_MIRRORED_REPEAT OpenGL wrap mode 43 | /// @see gtx_wrap extension. 44 | template 45 | GLM_FUNC_DECL genType mirrorClamp(genType const& Texcoord); 46 | 47 | /// Simulate GL_MIRROR_REPEAT OpenGL wrap mode 48 | /// @see gtx_wrap extension. 49 | template 50 | GLM_FUNC_DECL genType mirrorRepeat(genType const& Texcoord); 51 | 52 | /// @} 53 | }// namespace glm 54 | 55 | #include "wrap.inl" 56 | -------------------------------------------------------------------------------- /ext/glm/mat2x2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/mat2x2.hpp 3 | 4 | #pragma once 5 | #include "./ext/matrix_double2x2.hpp" 6 | #include "./ext/matrix_double2x2_precision.hpp" 7 | #include "./ext/matrix_float2x2.hpp" 8 | #include "./ext/matrix_float2x2_precision.hpp" 9 | 10 | -------------------------------------------------------------------------------- /ext/glm/mat2x3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/mat2x3.hpp 3 | 4 | #pragma once 5 | #include "./ext/matrix_double2x3.hpp" 6 | #include "./ext/matrix_double2x3_precision.hpp" 7 | #include "./ext/matrix_float2x3.hpp" 8 | #include "./ext/matrix_float2x3_precision.hpp" 9 | 10 | -------------------------------------------------------------------------------- /ext/glm/mat2x4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/mat2x4.hpp 3 | 4 | #pragma once 5 | #include "./ext/matrix_double2x4.hpp" 6 | #include "./ext/matrix_double2x4_precision.hpp" 7 | #include "./ext/matrix_float2x4.hpp" 8 | #include "./ext/matrix_float2x4_precision.hpp" 9 | 10 | -------------------------------------------------------------------------------- /ext/glm/mat3x2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/mat3x2.hpp 3 | 4 | #pragma once 5 | #include "./ext/matrix_double3x2.hpp" 6 | #include "./ext/matrix_double3x2_precision.hpp" 7 | #include "./ext/matrix_float3x2.hpp" 8 | #include "./ext/matrix_float3x2_precision.hpp" 9 | 10 | -------------------------------------------------------------------------------- /ext/glm/mat3x3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/mat3x3.hpp 3 | 4 | #pragma once 5 | #include "./ext/matrix_double3x3.hpp" 6 | #include "./ext/matrix_double3x3_precision.hpp" 7 | #include "./ext/matrix_float3x3.hpp" 8 | #include "./ext/matrix_float3x3_precision.hpp" 9 | -------------------------------------------------------------------------------- /ext/glm/mat3x4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/mat3x4.hpp 3 | 4 | #pragma once 5 | #include "./ext/matrix_double3x4.hpp" 6 | #include "./ext/matrix_double3x4_precision.hpp" 7 | #include "./ext/matrix_float3x4.hpp" 8 | #include "./ext/matrix_float3x4_precision.hpp" 9 | -------------------------------------------------------------------------------- /ext/glm/mat4x2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/mat4x2.hpp 3 | 4 | #pragma once 5 | #include "./ext/matrix_double4x2.hpp" 6 | #include "./ext/matrix_double4x2_precision.hpp" 7 | #include "./ext/matrix_float4x2.hpp" 8 | #include "./ext/matrix_float4x2_precision.hpp" 9 | 10 | -------------------------------------------------------------------------------- /ext/glm/mat4x3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/mat4x3.hpp 3 | 4 | #pragma once 5 | #include "./ext/matrix_double4x3.hpp" 6 | #include "./ext/matrix_double4x3_precision.hpp" 7 | #include "./ext/matrix_float4x3.hpp" 8 | #include "./ext/matrix_float4x3_precision.hpp" 9 | -------------------------------------------------------------------------------- /ext/glm/mat4x4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/mat4x4.hpp 3 | 4 | #pragma once 5 | #include "./ext/matrix_double4x4.hpp" 6 | #include "./ext/matrix_double4x4_precision.hpp" 7 | #include "./ext/matrix_float4x4.hpp" 8 | #include "./ext/matrix_float4x4_precision.hpp" 9 | 10 | -------------------------------------------------------------------------------- /ext/glm/simd/exponential.h: -------------------------------------------------------------------------------- 1 | /// @ref simd 2 | /// @file glm/simd/experimental.h 3 | 4 | #pragma once 5 | 6 | #include "platform.h" 7 | 8 | #if GLM_ARCH & GLM_ARCH_SSE2_BIT 9 | 10 | GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec1_sqrt_lowp(glm_f32vec4 x) 11 | { 12 | return _mm_mul_ss(_mm_rsqrt_ss(x), x); 13 | } 14 | 15 | GLM_FUNC_QUALIFIER glm_f32vec4 glm_vec4_sqrt_lowp(glm_f32vec4 x) 16 | { 17 | return _mm_mul_ps(_mm_rsqrt_ps(x), x); 18 | } 19 | 20 | #endif//GLM_ARCH & GLM_ARCH_SSE2_BIT 21 | -------------------------------------------------------------------------------- /ext/glm/simd/packing.h: -------------------------------------------------------------------------------- 1 | /// @ref simd 2 | /// @file glm/simd/packing.h 3 | 4 | #pragma once 5 | 6 | #if GLM_ARCH & GLM_ARCH_SSE2_BIT 7 | 8 | #endif//GLM_ARCH & GLM_ARCH_SSE2_BIT 9 | -------------------------------------------------------------------------------- /ext/glm/simd/trigonometric.h: -------------------------------------------------------------------------------- 1 | /// @ref simd 2 | /// @file glm/simd/trigonometric.h 3 | 4 | #pragma once 5 | 6 | #if GLM_ARCH & GLM_ARCH_SSE2_BIT 7 | 8 | #endif//GLM_ARCH & GLM_ARCH_SSE2_BIT 9 | 10 | -------------------------------------------------------------------------------- /ext/glm/simd/vector_relational.h: -------------------------------------------------------------------------------- 1 | /// @ref simd 2 | /// @file glm/simd/vector_relational.h 3 | 4 | #pragma once 5 | 6 | #if GLM_ARCH & GLM_ARCH_SSE2_BIT 7 | 8 | #endif//GLM_ARCH & GLM_ARCH_SSE2_BIT 9 | -------------------------------------------------------------------------------- /ext/glm/vec2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/vec2.hpp 3 | 4 | #pragma once 5 | #include "./ext/vector_bool2.hpp" 6 | #include "./ext/vector_bool2_precision.hpp" 7 | #include "./ext/vector_float2.hpp" 8 | #include "./ext/vector_float2_precision.hpp" 9 | #include "./ext/vector_double2.hpp" 10 | #include "./ext/vector_double2_precision.hpp" 11 | #include "./ext/vector_int2.hpp" 12 | #include "./ext/vector_int2_precision.hpp" 13 | #include "./ext/vector_uint2.hpp" 14 | #include "./ext/vector_uint2_precision.hpp" 15 | -------------------------------------------------------------------------------- /ext/glm/vec3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/vec3.hpp 3 | 4 | #pragma once 5 | #include "./ext/vector_bool3.hpp" 6 | #include "./ext/vector_bool3_precision.hpp" 7 | #include "./ext/vector_float3.hpp" 8 | #include "./ext/vector_float3_precision.hpp" 9 | #include "./ext/vector_double3.hpp" 10 | #include "./ext/vector_double3_precision.hpp" 11 | #include "./ext/vector_int3.hpp" 12 | #include "./ext/vector_int3_precision.hpp" 13 | #include "./ext/vector_uint3.hpp" 14 | #include "./ext/vector_uint3_precision.hpp" 15 | -------------------------------------------------------------------------------- /ext/glm/vec4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/vec4.hpp 3 | 4 | #pragma once 5 | #include "./ext/vector_bool4.hpp" 6 | #include "./ext/vector_bool4_precision.hpp" 7 | #include "./ext/vector_float4.hpp" 8 | #include "./ext/vector_float4_precision.hpp" 9 | #include "./ext/vector_double4.hpp" 10 | #include "./ext/vector_double4_precision.hpp" 11 | #include "./ext/vector_int4.hpp" 12 | #include "./ext/vector_int4_precision.hpp" 13 | #include "./ext/vector_uint4.hpp" 14 | #include "./ext/vector_uint4_precision.hpp" 15 | 16 | -------------------------------------------------------------------------------- /ext/stb_image/stb_image.cpp: -------------------------------------------------------------------------------- 1 | #define STB_IMAGE_IMPLEMENTATION 2 | #define STB_IMAGE_WRITE_IMPLEMENTATION 3 | #include "stb_image.h" 4 | #include "stb_image_write.h" 5 | -------------------------------------------------------------------------------- /ext/tiny_obj_loader.cpp: -------------------------------------------------------------------------------- 1 | #define TINYOBJLOADER_IMPLEMENTATION 2 | #include "tiny_obj_loader.h" -------------------------------------------------------------------------------- /img/fireplace.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HummaWhite/Zillum/f5cbec605e7c24ee4dd0f29917ce102ee310ef4f/img/fireplace.jpg -------------------------------------------------------------------------------- /img/fireplace2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HummaWhite/Zillum/f5cbec605e7c24ee4dd0f29917ce102ee310ef4f/img/fireplace2.jpg -------------------------------------------------------------------------------- /img/fireplace_weight.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HummaWhite/Zillum/f5cbec605e7c24ee4dd0f29917ce102ee310ef4f/img/fireplace_weight.jpg -------------------------------------------------------------------------------- /img/mis_weight_s.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HummaWhite/Zillum/f5cbec605e7c24ee4dd0f29917ce102ee310ef4f/img/mis_weight_s.jpg -------------------------------------------------------------------------------- /img/penn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HummaWhite/Zillum/f5cbec605e7c24ee4dd0f29917ce102ee310ef4f/img/penn.png -------------------------------------------------------------------------------- /include/Core/AABB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "glmIncluder.h" 7 | #include "Math.h" 8 | #include "Ray.h" 9 | 10 | struct BoxHit 11 | { 12 | bool hit; 13 | float tMin, tMax; 14 | }; 15 | 16 | struct AABB 17 | { 18 | AABB() : pMin(1e30f), pMax(-1e30f) {} 19 | AABB(const Vec3f &p) : pMin(p), pMax(p) {} 20 | AABB(const Vec3f &pMin, const Vec3f &pMax): 21 | pMin(pMin), pMax(pMax) {} 22 | AABB(const Vec3f ¢er, float radius): 23 | pMin(center - Vec3f(radius)), pMax(center + Vec3f(radius)) {} 24 | 25 | AABB(const Vec3f &va, const Vec3f &vb, const Vec3f &vc); 26 | AABB(const AABB &boundA, const AABB &boundB); 27 | 28 | void expand(const AABB& rhs); 29 | BoxHit hit(const Ray &ray); 30 | float volume() const; 31 | Vec3f centroid() const; 32 | float surfaceArea() const; 33 | int maxExtent() const; 34 | 35 | std::string toString(); 36 | 37 | Vec3f pMin; 38 | Vec3f pMax; 39 | }; 40 | -------------------------------------------------------------------------------- /include/Core/BVH.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "Hittable.h" 9 | #include "AABB.h" 10 | 11 | enum class BVHSplitMethod { SAH, Middle, EqualCounts, HLBVH }; 12 | 13 | const int BVHLeafMark = 0x80000000; 14 | 15 | struct BVHNode 16 | { 17 | AABB bound; 18 | HittablePtr hittable; 19 | int size; 20 | }; 21 | 22 | struct BVHTableElement 23 | { 24 | int misNext; 25 | int nodeIndex; 26 | }; 27 | 28 | struct HittableInfo 29 | { 30 | AABB bound; 31 | Vec3f centroid; 32 | HittablePtr hittable; 33 | }; 34 | 35 | class BVH 36 | { 37 | public: 38 | BVH() = default; 39 | BVH(const std::vector &hittables, BVHSplitMethod method = BVHSplitMethod::SAH); 40 | 41 | bool testIntersec(const Ray &ray, float dist); 42 | std::pair closestHit(const Ray &ray); 43 | 44 | int size() const { return mTreeSize; } 45 | int depth() const { return mDepth; } 46 | AABB box() const { return mTree[0].bound; } 47 | 48 | private: 49 | void quickBuild(std::vector &primInfo, const AABB &rootExtent); 50 | void standardBuild(std::vector &primInfo, const AABB &rootExtent); 51 | void buildHitTable(); 52 | 53 | private: 54 | int mTreeSize = 0; 55 | int mDepth = 0; 56 | BVHSplitMethod mSplitMethod; 57 | 58 | std::vector mTree; 59 | std::vector mHitTables[6]; 60 | }; -------------------------------------------------------------------------------- /include/Core/Color.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "glmIncluder.h" 8 | 9 | struct RGB24 { 10 | RGB24() = default; 11 | 12 | RGB24(uint8_t _r, uint8_t _g, uint8_t _b) : 13 | r(glm::clamp(_r, 0, 255u)), 14 | g(glm::clamp(_g, 0, 255u)), 15 | b(glm::clamp(_b, 0, 255u)) {} 16 | 17 | RGB24(Vec3f color) { 18 | Vec3f c = glm::clamp(color, Vec3f(0.0f), Vec3f(1.0f)); 19 | c *= 255; 20 | *this = RGB24(c.x, c.y, c.z); 21 | } 22 | 23 | Vec3f toVec3() { return Vec3f(r, g, b) / 255.0f; } 24 | Vec4f toVec4() { return Vec4f(Vec3f(r, g, b) / 255.0f, 1.0f); } 25 | 26 | static RGB24 swapRB(RGB24 c) { 27 | std::swap(c.r, c.b); 28 | return c; 29 | } 30 | 31 | static Vec3f halfWheel(float x) { 32 | const float Div = 1.0f / 3.0f; 33 | if (x < Div) 34 | return Vec3f(0.0f, 1.0f, 1.0f - x / Div); 35 | else if (x < Div * 2) 36 | return Vec3f(x / Div - 1.0f, 1.0f, 0.0f); 37 | else 38 | return Vec3f(1.0f, 3.0f - x / Div, 0.0f); 39 | } 40 | 41 | static Vec3f threeFourthWheel(float x) { 42 | const float Div = 1.0f / 4.0f; 43 | if (x < Div) 44 | return Vec3f(0.0f, x / Div, 1.0f); 45 | else if (x < Div * 2) 46 | return Vec3f(0.0f, 1.0f, 2.0f - x / Div); 47 | else if (x < Div * 3) 48 | return Vec3f(x / Div - 2.0f, 1.0f, 0.0f); 49 | else 50 | return Vec3f(1.0f, 4.0f - x / Div, 0.0f); 51 | } 52 | 53 | uint8_t r, g, b; 54 | }; 55 | 56 | struct RGBA32 { 57 | uint8_t r, g, b, a; 58 | }; -------------------------------------------------------------------------------- /include/Core/Environment.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "glmIncluder.h" 8 | #include "Utils/RandomGenerator.h" 9 | #include "Light.h" 10 | #include "Ray.h" 11 | #include "Transform.h" 12 | #include "Texture.h" 13 | #include "PiecewiseDistrib.h" 14 | 15 | struct EnvLiSample { 16 | Vec3f wi; 17 | Spectrum Li; 18 | float pdf; 19 | }; 20 | 21 | class Environment { 22 | public: 23 | virtual Spectrum radiance(const Vec3f &dir) = 0; 24 | virtual EnvLiSample sampleLi(const Vec2f &u1, const Vec2f &u2) = 0; 25 | virtual float pdfLi(const Vec3f &wi) = 0; 26 | virtual float power() = 0; 27 | }; 28 | 29 | using EnvPtr = std::shared_ptr; 30 | 31 | class EnvSingleColor : public Environment { 32 | public: 33 | EnvSingleColor(const Spectrum &color) : mRadiance(color) {} 34 | 35 | Spectrum radiance(const Vec3f &dir) { return mRadiance; } 36 | EnvLiSample sampleLi(const Vec2f &u1, const Vec2f &u2); 37 | float pdfLi(const Vec3f &wi); 38 | float power() { return Math::luminance(mRadiance) * 2.0f * Math::square(Math::Pi); } 39 | 40 | private: 41 | Spectrum mRadiance; 42 | }; 43 | 44 | class EnvSphereMapHDR : public Environment { 45 | public: 46 | EnvSphereMapHDR(const char *filePath); 47 | 48 | Spectrum radiance(const Vec3f &dir) { return mSphereMap->getSpherical(dir); } 49 | EnvLiSample sampleLi(const Vec2f &u1, const Vec2f &u2); 50 | float pdfLi(const Vec3f &wi); 51 | float power() { return mDistrib.sum(); } 52 | 53 | private: 54 | float getPortion(const Vec3f &wi); 55 | 56 | private: 57 | Texture3fPtr mSphereMap; 58 | int mWidth, mHeight; 59 | PiecewiseIndependent2D mDistrib; 60 | }; -------------------------------------------------------------------------------- /include/Core/Hittable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "Ray.h" 8 | #include "AABB.h" 9 | #include "Transform.h" 10 | 11 | enum class HittableType { 12 | Object, Light, Shape 13 | }; 14 | 15 | class Hittable { 16 | public: 17 | Hittable(HittableType type) : mType(type) {} 18 | 19 | virtual std::optional closestHit(const Ray &ray) = 0; 20 | virtual Vec3f uniformSample(const Vec2f &u) = 0; 21 | virtual Vec3f normalGeom(const Vec3f &p) = 0; 22 | virtual Vec3f normalShading(const Vec3f &p) { return normalGeom(p); } 23 | virtual float surfaceArea() = 0; 24 | virtual Vec2f surfaceUV(const Vec3f &p) = 0; 25 | virtual AABB bound() = 0; 26 | 27 | HittableType type() const { return mType; } 28 | 29 | virtual void setTransform(const Transform& trans) { mTransform = trans; } 30 | virtual void setTransform(const glm::mat4 &trans) { mTransform.set(trans); } 31 | Transform& getTransform() { return mTransform; } 32 | 33 | protected: 34 | Transform mTransform; 35 | HittableType mType; 36 | }; 37 | 38 | using HittablePtr = std::shared_ptr; -------------------------------------------------------------------------------- /include/Core/Light.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "Shape.h" 9 | 10 | struct LightLiSample { 11 | Vec3f wi; 12 | Spectrum Li; 13 | float dist; 14 | float pdf; 15 | }; 16 | 17 | struct LightLeSample { 18 | Ray ray; 19 | Spectrum Le; 20 | float pdfPos; 21 | float pdfDir; 22 | }; 23 | 24 | struct LightPdf { 25 | float pdfPos; 26 | float pdfDir; 27 | }; 28 | 29 | class Light : public Hittable { 30 | public: 31 | Light(HittablePtr shape, const Spectrum &power, bool delta): 32 | shape(shape), mPower(power), Hittable(HittableType::Light) {} 33 | 34 | std::optional closestHit(const Ray &ray) { return shape->closestHit(ray); } 35 | 36 | Vec3f uniformSample(const Vec2f &u) { return shape->uniformSample(u); } 37 | Vec3f normalGeom(const Vec3f &p) { return shape->normalGeom(p); } 38 | float surfaceArea() { return shape->surfaceArea(); } 39 | Vec2f surfaceUV(const Vec3f &p) { return shape->surfaceUV(p); } 40 | AABB bound() { return shape->bound(); } 41 | 42 | void setTransform(const Transform& trans) override { 43 | mTransform = trans; 44 | shape->setTransform(trans); 45 | } 46 | 47 | Spectrum getPower(){ return mPower; } 48 | float luminance() { return Math::luminance(mPower); } 49 | 50 | std::optional sampleLi(Vec3f refPoint, Vec2f u); 51 | float pdfLi(const Vec3f &ref, const Vec3f &y); 52 | Spectrum Le(Ray ray); 53 | LightLeSample sampleLe(const std::array &u); 54 | LightPdf pdfLe(const Ray &ray); 55 | 56 | protected: 57 | HittablePtr shape; 58 | Vec3f mPower; 59 | }; 60 | 61 | using LightPtr = std::shared_ptr; -------------------------------------------------------------------------------- /include/Core/Microfacet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Transform.h" 4 | #include "Math.h" 5 | 6 | class NormalDistrib { 7 | public: 8 | virtual float d(const Vec3f &m) const = 0; 9 | virtual float pdf(const Vec3f &m, const Vec3f &wo) const = 0; 10 | virtual Vec3f sampleWm(const Vec3f &wo, const Vec2f &u) const = 0; 11 | }; 12 | 13 | class GTR2Distrib: public NormalDistrib { 14 | public: 15 | GTR2Distrib(float roughness, bool sampleVisible, float aniso = 0.0f); 16 | 17 | float d(const Vec3f &m) const; 18 | float pdf(const Vec3f &m, const Vec3f &wo) const; 19 | Vec3f sampleWm(const Vec3f &wo, const Vec2f &u) const; 20 | float g(const Vec3f &wo, const Vec3f &wi) const; 21 | 22 | private: 23 | bool visible; 24 | float alpha; 25 | }; 26 | 27 | class GTR1Distrib: public NormalDistrib { 28 | public: 29 | GTR1Distrib(float roughness) : alpha(roughness * roughness) {} 30 | 31 | float d(const Vec3f &m) const; 32 | float pdf(const Vec3f &m, const Vec3f &wo) const; 33 | Vec3f sampleWm(const Vec3f &wo, const Vec2f &u) const; 34 | 35 | private: 36 | float alpha; 37 | }; 38 | 39 | float schlickG(float cosTheta, float alpha); 40 | float smithG(float cosThetaO, float cosThetaI, float alpha); 41 | float smithG(const Vec3f &wo, const Vec3f &wi, float alpha); 42 | 43 | float ggx(float cosTheta, float alpha); 44 | float ggx(float cosTheta, float sinPhi, const glm::vec2 &alph); 45 | float gtr1(float cosTheta, float alpha); 46 | 47 | float schlickW(float cosTheta); 48 | float schlickF(float cosTheta); 49 | Vec3f SchlickF(float cosTheta, const Vec3f &f0); 50 | Vec3f SchlickF(float cosTheta, const Vec3f &f0, float roughness); -------------------------------------------------------------------------------- /include/Core/Object.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "SurfaceInfo.h" 7 | #include "Shape.h" 8 | #include "BSDF.h" 9 | 10 | class Object: public Hittable { 11 | public: 12 | Object(HittablePtr shape, BSDFPtr material): 13 | shape(shape), material(material), Hittable(HittableType::Object) {} 14 | 15 | SurfaceInfo surfaceInfo(const Vec3f &x) { 16 | Vec2f uv = shape->surfaceUV(x); 17 | return SurfaceInfo({ uv.x, 1.0f - uv.y }, shape->normalShading(x), shape->normalGeom(x), material); 18 | } 19 | 20 | std::optional closestHit(const Ray &r) { 21 | return shape->closestHit(r); 22 | } 23 | 24 | Vec3f uniformSample(const Vec2f &u) { 25 | return shape->uniformSample(u); 26 | } 27 | 28 | Vec3f normalGeom(const Vec3f &p) { 29 | return shape->normalGeom(p); 30 | } 31 | 32 | Vec3f normalShading(const Vec3f &p) override { 33 | return shape->normalShading(p); 34 | } 35 | 36 | float surfaceArea() { 37 | return shape->surfaceArea(); 38 | } 39 | 40 | Vec2f surfaceUV(const Vec3f &p) { 41 | return shape->surfaceUV(p); 42 | } 43 | 44 | void setTransform(const Transform& trans) override { 45 | mTransform = trans; 46 | shape->setTransform(trans); 47 | } 48 | 49 | AABB bound() { 50 | return shape->bound(); 51 | } 52 | 53 | protected: 54 | HittablePtr shape; 55 | BSDFPtr material; 56 | }; 57 | 58 | using ObjectPtr = std::shared_ptr; -------------------------------------------------------------------------------- /include/Core/PhaseFunction.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Core/Math.h" 4 | #include "Core/Transform.h" 5 | 6 | struct PhaseSample { 7 | PhaseSample(Vec3f w, float pdf) : w(w), pdf(pdf), p(pdf) {} 8 | float p; 9 | Vec3f w; 10 | float pdf; 11 | }; 12 | 13 | float HGPhaseFunction(float cosTheta, float g); 14 | float HGPhasePDF(Vec3f wo, Vec3f wi, float g); 15 | PhaseSample HGPhaseSample(Vec3f wo, float g, Vec2f u); -------------------------------------------------------------------------------- /include/Core/PiecewiseDistrib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Math.h" 4 | 5 | #include 6 | #include 7 | 8 | class Piecewise1D { 9 | public: 10 | Piecewise1D() = default; 11 | Piecewise1D(const std::vector &distrib); 12 | 13 | int sample(const Vec2f &u) const; 14 | float sum() const { return sumDistrib; } 15 | std::vector> getTable() const { return table; } 16 | 17 | private: 18 | typedef std::pair Element; 19 | 20 | private: 21 | std::vector table; 22 | float sumDistrib; 23 | }; 24 | 25 | class PiecewiseIndependent2D { 26 | public: 27 | PiecewiseIndependent2D() = default; 28 | PiecewiseIndependent2D(float *pdf, int width, int height); 29 | 30 | std::pair sample(const Vec2f &u1, const Vec2f &u2) const; 31 | float sum() const { return colTable.sum(); } 32 | 33 | private: 34 | std::vector rowTables; 35 | Piecewise1D colTable; 36 | }; -------------------------------------------------------------------------------- /include/Core/Ray.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "glmIncluder.h" 7 | 8 | const float RayOffset = 1e-4f; 9 | 10 | struct Ray { 11 | Ray() = default; 12 | 13 | Ray(const Vec3f &_ori, const Vec3f &_dir): 14 | ori(_ori), dir(glm::normalize(_dir)){} 15 | 16 | Ray offset() const { return Ray(ori + dir * RayOffset, dir); } 17 | 18 | Vec3f get(float t) const { return ori + dir * t; } 19 | 20 | Vec3f ori; 21 | Vec3f dir; 22 | }; 23 | -------------------------------------------------------------------------------- /include/Core/Spectrum.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Color.h" 4 | using Spectrum = Vec3f; -------------------------------------------------------------------------------- /include/Core/SurfaceInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "Core/BSDF.h" 7 | 8 | struct SurfaceInfo { 9 | SurfaceInfo() = default; 10 | 11 | SurfaceInfo(const Vec2f& uv, const Vec3f& ns, BSDFPtr bsdf) : 12 | uv(uv), ns(ns), bsdf(bsdf) {} 13 | 14 | SurfaceInfo(const Vec2f& uv, const Vec3f& ns, const Vec3f& ng, BSDFPtr bsdf) : 15 | uv(uv), ns(ns), ng(ng), bsdf(bsdf) { 16 | if (glm::dot(ng, ns) < 0) { 17 | this->ng = -ng; 18 | } 19 | } 20 | 21 | void flipNormal() { 22 | ns = -ns; 23 | ng = -ng; 24 | } 25 | 26 | Spectrum f(Vec3f n, Vec3f wo, Vec3f wi, Sampler* sampler, TransportMode mode = TransportMode::Radiance) { 27 | wo = Transform::worldToLocal(n, wo); 28 | wi = Transform::worldToLocal(n, wi); 29 | return bsdf->bsdf(wo, wi, uv, mode, sampler); 30 | } 31 | 32 | float pdf(Vec3f n, Vec3f wo, Vec3f wi, Sampler* sampler, TransportMode mode = TransportMode::Radiance) { 33 | wo = Transform::worldToLocal(n, wo); 34 | wi = Transform::worldToLocal(n, wi); 35 | return bsdf->pdf(wo, wi, uv, mode, sampler); 36 | } 37 | 38 | std::optional sample(Vec3f n, Vec3f wo, Sampler* sampler, TransportMode mode = TransportMode::Radiance) { 39 | wo = Transform::worldToLocal(n, wo); 40 | auto sample = bsdf->sample(wo, uv, mode, sampler); 41 | if (!sample) { 42 | return std::nullopt; 43 | } 44 | else { 45 | sample->w = Transform::localToWorld(n, sample->w); 46 | return sample; 47 | } 48 | } 49 | 50 | Vec2f uv; 51 | Vec3f ns; 52 | Vec3f ng; 53 | BSDFPtr bsdf; 54 | }; -------------------------------------------------------------------------------- /include/Core/SurfaceIntr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "glmIncluder.h" 7 | #include "Core/Sampler.h" 8 | 9 | class BSDF; 10 | using BSDFPtr = std::shared_ptr; 11 | 12 | struct SurfaceIntr { 13 | SurfaceIntr() : wo(0.f), uv(0.f), wi(0.f), sampler(nullptr) {} 14 | 15 | SurfaceIntr(const Vec3f& wGiven) : 16 | wo(wGiven), sampler(nullptr), wi(0.f), uv(0.f) {} 17 | 18 | SurfaceIntr(const Vec3f& wo, const Vec3f& wi) : 19 | wo(wo), wi(wi), sampler(nullptr), uv(0.f) {} 20 | 21 | SurfaceIntr(const Vec3f &wo, const Vec2f &uv, Sampler* sampler = nullptr) : 22 | wo(wo), uv(uv), wi(0.f), sampler(sampler) {} 23 | 24 | SurfaceIntr(const Vec3f &wo, const Vec3f &wi, const Vec2f &uv, Sampler* sampler = nullptr) : 25 | wo(wo), wi(wi), uv(uv), sampler(sampler) {} 26 | 27 | SurfaceIntr swapInOut() const { 28 | return { wi, wo, uv, sampler }; 29 | } 30 | 31 | Vec3f wo; 32 | Vec3f wi; 33 | Vec2f uv; 34 | Sampler* sampler; 35 | }; -------------------------------------------------------------------------------- /include/Core/ToneMapping.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "glmIncluder.h" 7 | #include "Utils/NamespaceDecl.h" 8 | #include "Spectrum.h" 9 | 10 | NAMESPACE_BEGIN(ToneMapping) 11 | 12 | Vec3f reinhard(const Vec3f &color); 13 | Vec3f CE(const Vec3f &color); 14 | Vec3f filmic(const Vec3f &color); 15 | Vec3f ACES(const Vec3f &color); 16 | 17 | NAMESPACE_END(ToneMapping) -------------------------------------------------------------------------------- /include/Core/Transform.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Math.h" 6 | #include "AABB.h" 7 | 8 | class Transform { 9 | public: 10 | Transform(): matrix(1.0f), matInv(1.0f), matInvT(1.0f) {} 11 | Transform(const Mat4f &transform) : matrix(transform), matInv(glm::inverse(transform)), 12 | matInvT(glm::transpose(matInv)) {} 13 | 14 | void set(const Mat4f &transform) { *this = Transform(transform); } 15 | Vec3f get(const Vec3f &v) const { return Vec3f(matrix * glm::vec4(v, 1.0f)); } 16 | Vec3f getInversed(const Vec3f &v) const { return Vec3f(matInv * glm::vec4(v, 1.0f)); } 17 | Vec3f getInversedNormal(const Vec3f &N) const { return glm::normalize(matInvT * N); } 18 | 19 | AABB getTransformedBox(const AABB &box) const; 20 | 21 | static Vec2f sphereToPlane(const Vec3f &uv); 22 | static Vec3f planeToSphere(const Vec2f &uv); 23 | static Vec2f toConcentricDisk(const Vec2f &uv); 24 | static Vec3f localToWorld(const Vec3f &N, const Vec3f &dir); 25 | static Vec3f worldToLocal(const Vec3f& n, const Vec3f& dir); 26 | 27 | public: 28 | Mat4f matrix; 29 | Mat4f matInv; 30 | Mat3f matInvT; 31 | }; 32 | 33 | namespace Math { 34 | std::pair sampleHemisphereCosine(const Vec3f &N, const Vec2f &u); 35 | Vec3f sampleHemisphereCosine(const Vec2f& u); 36 | } -------------------------------------------------------------------------------- /include/SceneLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Core/Scene.h" 4 | 5 | ScenePtr setupScene(int windowWidth, int windowHeight); -------------------------------------------------------------------------------- /include/Utils/Buffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | template 10 | struct Buffer { 11 | Buffer(): data(nullptr) {} 12 | 13 | Buffer(int count) { 14 | init(count); 15 | } 16 | 17 | ~Buffer() { 18 | //release(); 19 | } 20 | 21 | virtual void init(int count) { 22 | if (data != nullptr) return; 23 | data = new T[count]; 24 | this->count = count; 25 | } 26 | 27 | virtual void release() { 28 | if (data == nullptr) return; 29 | delete[] data; 30 | data = nullptr; 31 | count = 0; 32 | } 33 | 34 | virtual void resize(int count) { 35 | release(); 36 | init(count); 37 | } 38 | 39 | void fill(T val) { 40 | std::fill(data, data + count, val); 41 | } 42 | 43 | void load(const void *src, size_t byteSize, int offset = 0) { 44 | if (data == nullptr) { 45 | std::cout << "Buffer::Error: buffer not initialized" << std::endl; 46 | exit(-1); 47 | } 48 | memcpy(data + offset, src, byteSize); 49 | } 50 | 51 | void copy(Buffer& buffer) { 52 | init(buffer.count); 53 | memcpy(data, buffer.ptr(), count * sizeof(T)); 54 | } 55 | 56 | T& operator [] (int index) { 57 | return data[index]; 58 | } 59 | 60 | const T& operator [] (int index) const { 61 | return data[index]; 62 | } 63 | 64 | void* bufPtr() { 65 | return (void*)data; 66 | } 67 | 68 | T* ptr() { 69 | return data; 70 | } 71 | 72 | T *data = nullptr; 73 | int count = 0; 74 | }; -------------------------------------------------------------------------------- /include/Utils/Buffer2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Buffer.h" 4 | 5 | template 6 | struct Buffer2D : Buffer { 7 | Buffer2D() = default; 8 | 9 | Buffer2D(int w, int h) { 10 | init(w, h); 11 | } 12 | 13 | ~Buffer2D() = default; 14 | 15 | void init(int w, int h) { 16 | Buffer::init(w * h); 17 | width = w, height = h; 18 | } 19 | 20 | void release() { 21 | Buffer::release(); 22 | width = height = 0; 23 | } 24 | 25 | void resize(int w, int h) { 26 | Buffer::resize(w * h); 27 | init(w, h); 28 | } 29 | 30 | T& operator () (int i, int j) { 31 | return this->data[j * width + i]; 32 | } 33 | 34 | const T& operator () (int i, int j) const { 35 | return this->data[j * width + i]; 36 | } 37 | 38 | T& operator () (float u, float v) { 39 | int iu = std::min(static_cast(u * width), width - 1); 40 | int iv = std::min(static_cast(v * height), height - 1); 41 | return this->data[iv * width + iu]; 42 | } 43 | 44 | const T& operator () (float u, float v) const { 45 | int iu = std::min(static_cast(u * width), width - 1); 46 | int iv = std::min(static_cast(v * height), height - 1); 47 | return this->data[iv * width + iu]; 48 | } 49 | 50 | std::tuple convertUV(float u, float v) { 51 | return { u * width, v * height }; 52 | } 53 | 54 | int width = 0; 55 | int height = 0; 56 | }; 57 | -------------------------------------------------------------------------------- /include/Utils/EnumBitField.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | template 6 | struct EnableEnumBitMask { 7 | static constexpr bool enable = false; 8 | }; 9 | 10 | template 11 | typename std::enable_if::enable, E>::type operator | (E lhs, E rhs) { 12 | typedef typename std::underlying_type::type underlying; 13 | return static_cast(static_cast(lhs) | static_cast(rhs)); 14 | } 15 | 16 | template 17 | typename std::enable_if::enable, E>::type operator & (E lhs, E rhs) { 18 | typedef typename std::underlying_type::type underlying; 19 | return static_cast(static_cast(lhs) & static_cast(rhs)); 20 | } -------------------------------------------------------------------------------- /include/Utils/Error.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "NamespaceDecl.h" 8 | 9 | static std::mutex DebugPrintMutex; 10 | #define DEBUG_PRINT_BEGIN DebugPrintMutex.lock(); 11 | #define DEBUG_PRINT_END DebugPrintMutex.unlock(); 12 | #define DEBUG_PRINT(msg) { DebugPrintMutex.lock(); std::cout << msg; DebugPrintMutex.unlock(); } 13 | #define DEBUG_LOG(msg) DEBUG_PRINT(msg << "\n") 14 | #define REPORT_IF(cond, msg) if (cond) DEBUG_LOG(msg) 15 | #define REPORT_RETURN_IF(cond, ret, msg) if (cond) { DEBUG_LOG(msg) return ret; } 16 | 17 | NAMESPACE_BEGIN(Error) 18 | 19 | template 20 | void bracketLine(const std::string& msg) { 21 | static_assert(NTabs >= 0); 22 | for (int i = 0; i < NTabs; i++) 23 | std::cerr << "\t"; 24 | std::cerr << "[" << msg << "]" << std::endl; 25 | } 26 | 27 | static void line(const std::string& msg) { 28 | std::cerr << msg << std::endl; 29 | } 30 | 31 | static void exit(const std::string& msg = "") { 32 | std::cerr << "[Error exit " << msg << "]" << std::endl; 33 | std::abort(); 34 | } 35 | 36 | static void impossiblePath() { 37 | exit("[Impossible path: this path is impossible to be reached, check the program]"); 38 | } 39 | 40 | static void check(bool cond, const std::string& errMsg = "") { 41 | if (!cond) { 42 | std::cerr << "[Check failed " << errMsg << "]" << std::endl; 43 | std::abort(); 44 | } 45 | } 46 | 47 | NAMESPACE_END(Error) -------------------------------------------------------------------------------- /include/Utils/File.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace File = std::filesystem; -------------------------------------------------------------------------------- /include/Utils/FrameBufferDouble.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Buffer2D.h" 4 | 5 | template 6 | class FrameBufferDouble { 7 | public: 8 | FrameBufferDouble() {} 9 | 10 | FrameBufferDouble(int w, int h) { 11 | buf[0].init(w, h); 12 | buf[1].init(w, h); 13 | } 14 | 15 | void init(int w, int h) { 16 | buf[0].init(w, h); 17 | buf[1].init(w, h); 18 | } 19 | 20 | void release() { 21 | buf[0].release(); 22 | buf[1].release(); 23 | } 24 | 25 | void resize(int w, int h) { 26 | buf[0].resize(w, h); 27 | buf[1].resize(w, h); 28 | } 29 | 30 | void fill(T val) { 31 | buf[index].fill(val); 32 | } 33 | 34 | int width() { return buf[0].width; } 35 | int height() { return buf[0].height; } 36 | 37 | T& operator () (int i, int j) { return buf[index](i, j); } 38 | T& operator [] (int i) { return buf[index][i]; } 39 | 40 | Buffer2D& getCurrentBuffer() { return buf[index]; } 41 | 42 | void swap() { index ^= 1; } 43 | 44 | private: 45 | Buffer2D buf[2]; 46 | int index = 0; 47 | }; 48 | -------------------------------------------------------------------------------- /include/Utils/ImageSave.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Buffer2D.h" 6 | #include "Core/Color.h" 7 | #include "stbIncluder.h" 8 | 9 | template 10 | void saveImage(const std::string &name, Buffer2D &buffer, std::function transformFunc) { 11 | int w = buffer.width; 12 | int h = buffer.height; 13 | int size = w * h; 14 | RGB24 *data = new RGB24[size]; 15 | for (int i = 0; i < size; i++) 16 | data[i] = RGB24::swapRB(transformFunc(buffer[i])); 17 | stbi_write_png(name.c_str(), w, h, 3, data, w * 3); 18 | delete[] data; 19 | } 20 | 21 | template 22 | void saveImage(const std::string &name, T *buffer, int w, int h, std::function transformFunc) { 23 | int size = w * h; 24 | RGB24 *data = new RGB24[size]; 25 | for (int i = 0; i < size; i++) 26 | data[i] = RGB24::swapRB(transformFunc(buffer[i])); 27 | stbi_write_png(name.c_str(), w, h, 3, data, w * 3); 28 | delete[] data; 29 | } -------------------------------------------------------------------------------- /include/Utils/NamespaceDecl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define NAMESPACE_BEGIN(x) namespace x { 4 | #define NAMESPACE_END(x) } -------------------------------------------------------------------------------- /include/Utils/ObjReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "glmIncluder.h" 11 | #include "tiny_obj_loader.h" 12 | 13 | namespace ObjReader { 14 | struct VertexInfo { 15 | std::vector vertices; 16 | std::vector texcoords; 17 | std::vector normals; 18 | }; 19 | 20 | static VertexInfo readFile(const char* filePath) { 21 | VertexInfo data; 22 | std::cout << "Loading Obj: " << filePath << std::endl; 23 | 24 | tinyobj::attrib_t attrib; 25 | std::vector shapes; 26 | std::vector materials; 27 | std::string errStr; 28 | tinyobj::LoadObj(&attrib, &shapes, &materials, &errStr, filePath); 29 | 30 | bool hasTexcoord = attrib.texcoords.size() != 0; 31 | 32 | for (const auto &shape : shapes) { 33 | for (auto idx : shape.mesh.indices) { 34 | data.vertices.push_back(*reinterpret_cast(attrib.vertices.data() + idx.vertex_index * 3)); 35 | data.normals.push_back(*reinterpret_cast(attrib.normals.data() + idx.normal_index * 3)); 36 | if (!hasTexcoord) { 37 | continue; 38 | } 39 | data.texcoords.push_back(*reinterpret_cast(attrib.texcoords.data() + idx.texcoord_index * 2)); 40 | } 41 | } 42 | return data; 43 | } 44 | }; 45 | -------------------------------------------------------------------------------- /include/Utils/RandomGenerator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | typedef std::uniform_real_distribution UniformDouble; 8 | typedef std::uniform_real_distribution UniformFloat; 9 | typedef std::uniform_int_distribution UniformUint; 10 | typedef std::uniform_int_distribution UniformInt; 11 | typedef std::uniform_int_distribution UniformUint16; 12 | typedef std::uniform_int_distribution UniformInt16; 13 | 14 | static std::default_random_engine globalRandomEngine(time(0)); 15 | 16 | static float uniformFloat() { 17 | return UniformFloat(0.0f, 1.0f)(globalRandomEngine); 18 | } 19 | 20 | static float uniformFloat(float tMin, float tMax) { 21 | return UniformFloat(tMin, tMax)(globalRandomEngine); 22 | } 23 | 24 | template 25 | T uniformInt(T tMin, T tMax) { 26 | return std::uniform_int_distribution(tMin, tMax)(globalRandomEngine); 27 | } 28 | -------------------------------------------------------------------------------- /include/Utils/TempAssignment.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | class TempAssignment { 5 | public: 6 | TempAssignment(T *reference = nullptr, const T &newValue = T()) { 7 | assign(reference, newValue); 8 | } 9 | 10 | TempAssignment(T &reference, const T &newValue) { 11 | assign(&reference, newValue); 12 | } 13 | 14 | ~TempAssignment() { 15 | if (mReference) 16 | *mReference = mBackup; 17 | } 18 | 19 | TempAssignment& operator = (TempAssignment &&rhs) { 20 | mReference = rhs.mReference; 21 | mBackup = rhs.mBackup; 22 | rhs.mReference = nullptr; 23 | return *this; 24 | } 25 | 26 | void assign(T *reference, const T &newValue) { 27 | if (reference) { 28 | mBackup = *reference; 29 | *reference = newValue; 30 | } 31 | mReference = reference; 32 | } 33 | 34 | private: 35 | T *mReference; 36 | T mBackup; 37 | }; -------------------------------------------------------------------------------- /include/Utils/Timer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | const auto InitTime = std::chrono::high_resolution_clock::now(); 8 | 9 | static int64_t getTime() { 10 | return std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - InitTime).count(); 11 | } 12 | 13 | class Timer { 14 | public: 15 | Timer() : mStartTime(getTime()) {} 16 | 17 | double get() const { 18 | return (getTime() - mStartTime) * 1e-9; 19 | } 20 | 21 | void reset() { 22 | mStartTime = getTime(); 23 | } 24 | 25 | private: 26 | int64_t mStartTime; 27 | }; -------------------------------------------------------------------------------- /include/Zillum.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define NOMINMAX 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "Core/Texture.h" 13 | #include "Core/Integrator.h" 14 | #include "Utils/FrameBufferDouble.h" 15 | #include "Utils/ImageSave.h" 16 | #include "SceneLoader.h" 17 | #include "glm/glm.hpp" 18 | 19 | class Zillum { 20 | public: 21 | void init(const std::string& name, HINSTANCE instance, const char *cmdParam); 22 | LRESULT process(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 23 | bool render(); 24 | 25 | private: 26 | void initScene(); 27 | void writeBuffer(); 28 | void flushScreen(); 29 | void processKey(); 30 | void saveImage(); 31 | 32 | private: 33 | std::string mName; 34 | int mWindowWidth; 35 | int mWindowHeight; 36 | 37 | HINSTANCE mInstance; 38 | HWND mWindow; 39 | HDC mMemdc; 40 | HBITMAP mBitmap; 41 | 42 | bool mKeyPressing[256]; 43 | bool mF1Pressed = false; 44 | bool mCursorDisabled = true; 45 | int mLastCursorX; 46 | int mLastCursorY; 47 | bool mFirstCursorMove = true; 48 | 49 | int mToneMapping = 1; 50 | bool mCorrectGamma = true; 51 | 52 | bool mAutoSaveImage = true; 53 | 54 | FrameBufferDouble mColorBuffer; 55 | IntegratorPtr mIntegrator; 56 | ScenePtr mScene; 57 | 58 | Timer mTimer; 59 | }; 60 | -------------------------------------------------------------------------------- /include/stbIncluder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "stb_image/stb_image.h" 4 | #include "stb_image/stb_image_write.h" -------------------------------------------------------------------------------- /src/Math/ToneMapping.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/ToneMapping.h" 2 | 3 | NAMESPACE_BEGIN(ToneMapping) 4 | 5 | Vec3f reinhard(const Vec3f &color) { 6 | return color / (color + Vec3f(1.0f)); 7 | } 8 | 9 | Vec3f CE(const Vec3f &color) { 10 | return Vec3f(1.0f) - glm::exp(-color); 11 | } 12 | 13 | Vec3f filmic(const Vec3f &color) { 14 | auto calc = [](const Vec3f &x) { 15 | const float A = 0.22f, B = 0.3f, C = 0.1f, D = 0.2f, E = 0.01f, F = 0.3f; 16 | return ((x * (x * A + Vec3f(B * C)) + Vec3f(D * E)) / (x * (x * A + Vec3f(B)) + Vec3f(D * F)) - Vec3f(E / F)); 17 | }; 18 | const float WHITE = 11.2f; 19 | 20 | return calc(color * 1.6f) / calc(Vec3f(WHITE)); 21 | } 22 | 23 | Vec3f ACES(const Vec3f &color) { 24 | return (color * (color * 2.51f + Vec3f(0.03f))) / (color * (color * 2.43f + Vec3f(0.59f)) + Vec3f(0.14f)); 25 | } 26 | 27 | NAMESPACE_END(ToneMapping) -------------------------------------------------------------------------------- /src/Medium/PhaseFunction.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/PhaseFunction.h" 2 | 3 | float HGPhaseFunction(float cosTheta, float g) { 4 | float denom = 1.f + g * (g + 2 * cosTheta); 5 | return .25f * Math::PiInv * (1 - g * g) / (denom * Math::sqrtc(denom)); 6 | } 7 | 8 | float HGPhasePDF(Vec3f wo, Vec3f wi, float g) { 9 | return HGPhaseFunction(glm::dot(wo, wi), g); 10 | } 11 | 12 | PhaseSample HGPhaseSample(Vec3f wo, float g, Vec2f u) { 13 | float g2 = g * g; 14 | float cosTheta = (glm::abs(g) < 1e-3f) ? 15 | 1.f - 2.f * u.x : 16 | -(1 + g2 - Math::square((1 - g2) / (1 + g - 2 * g * u.x)) / (2.f * g)); 17 | 18 | float sinTheta = Math::sqrtc(1.f - cosTheta * cosTheta); 19 | float phi = Math::Pi * 2.f * u.y; 20 | Vec3f wiLocal(std::cos(phi) * sinTheta, std::sin(phi) * sinTheta, cosTheta); 21 | 22 | return PhaseSample(Transform::localToWorld(wo, wiLocal), HGPhaseFunction(cosTheta, g)); 23 | } -------------------------------------------------------------------------------- /src/Sampler/Independent.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Sampler.h" 2 | 3 | IndependentSampler::IndependentSampler() : 4 | Sampler(SamplerType::Independent) { 5 | rng.seed(globalRandomEngine()); 6 | } 7 | 8 | float IndependentSampler::get1() { 9 | return std::uniform_real_distribution(0.0f, Math::OneMinusEpsilon)(rng); 10 | } 11 | 12 | SamplerPtr IndependentSampler::copy() { 13 | IndependentSampler *sampler = new IndependentSampler(*this); 14 | return SamplerPtr(sampler); 15 | } -------------------------------------------------------------------------------- /src/Sampler/Sobol.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Sampler.h" 2 | #include "Utils/SobolMatrices1024x52.h" 3 | 4 | uint32_t sobolSample(uint64_t index, int dim, uint32_t scramble = 0) { 5 | uint32_t r = scramble; 6 | for (int i = dim * SobolMatricesSize; index; index >>= 1, i++) { 7 | if (index & 1) { 8 | r ^= SobolMatrices[i]; 9 | } 10 | } 11 | return r; 12 | } 13 | 14 | float SobolSampler::get1() { 15 | float r = static_cast(sobolSample(index, dim++, scramble)) * 0x1p-32f; 16 | if (randomScrambling) { 17 | scramble = rng(); 18 | } 19 | return std::min(r, Math::OneMinusEpsilon); 20 | } 21 | 22 | void SobolSampler::setPixel(int x, int y) { 23 | dim = 0; 24 | rng.seed(y << 16 | x); 25 | scramble = rng(); 26 | } 27 | 28 | void SobolSampler::nextSample() { 29 | index++; 30 | dim = 0; 31 | } 32 | 33 | void SobolSampler::nextSamples(size_t samples) { 34 | index += samples; 35 | dim = 0; 36 | } 37 | 38 | SamplerPtr SobolSampler::copy() { 39 | SobolSampler *sampler = new SobolSampler(*this); 40 | return SamplerPtr(sampler); 41 | } -------------------------------------------------------------------------------- /src/Scene/Camera/Panorama.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Camera.h" 2 | 3 | Vec2f PanoramaCamera::rasterPos(Ray ray) { 4 | return {}; 5 | } 6 | 7 | Ray PanoramaCamera::generateRay(SamplerPtr sampler) { 8 | return generateRay(sampler->get2(), sampler); 9 | } 10 | 11 | Ray PanoramaCamera::generateRay(Vec2f uv, SamplerPtr sampler) { 12 | auto dir = Transform::planeToSphere((uv + Vec2f(0.5f, 1.0f)) * 0.5f); 13 | dir.x = -dir.x; 14 | dir.z = -dir.z; 15 | return { mPos, dir }; 16 | } 17 | 18 | std::optional PanoramaCamera::sampleIi(Vec3f ref, Vec2f u) { 19 | return std::nullopt; 20 | } 21 | 22 | CameraPdf PanoramaCamera::pdfIe(Ray ray) { 23 | return {}; 24 | } 25 | 26 | Spectrum PanoramaCamera::Ie(Ray ray) { 27 | return {}; 28 | } -------------------------------------------------------------------------------- /src/Scene/Environment/MonoColor.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Environment.h" 2 | 3 | EnvLiSample EnvSingleColor::sampleLi(const Vec2f &u1, const Vec2f &u2) { 4 | auto wi = Transform::planeToSphere(u1); 5 | return { wi, mRadiance, Math::PiInv * 0.25f }; 6 | } 7 | 8 | float EnvSingleColor::pdfLi(const Vec3f &wi) { 9 | return Math::PiInv * 0.25f; 10 | } -------------------------------------------------------------------------------- /src/Scene/Light.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Light.h" 2 | 3 | std::optional Light::sampleLi(Vec3f ref, Vec2f u) { 4 | Vec3f y = uniformSample(u); 5 | Vec3f Wi = glm::normalize(y - ref); 6 | Vec3f N = normalGeom(y); 7 | float cosTheta = glm::dot(N, -Wi); 8 | 9 | if (cosTheta <= 1e-6f) { 10 | return std::nullopt; 11 | } 12 | 13 | float dist = glm::distance(ref, y); 14 | float pdf = dist * dist / (surfaceArea() * cosTheta); 15 | return LightLiSample{Wi, Le({ y, -Wi }), dist, pdf}; 16 | } 17 | 18 | float Light::pdfLi(const Vec3f &ref, const Vec3f &y) { 19 | auto N = normalGeom(y); 20 | auto Wi = glm::normalize(y - ref); 21 | float cosTheta = Math::satDot(N, -Wi); 22 | if (cosTheta < 1e-8f) { 23 | return 0.0f; 24 | } 25 | return Math::distSquare(ref, y) / (surfaceArea() * cosTheta); 26 | } 27 | 28 | Spectrum Light::Le(Ray ray) { 29 | if (glm::dot(normalGeom(ray.ori), ray.dir) <= 0.0f) { 30 | return Spectrum(0.0f); 31 | } 32 | return mPower / (2.0f * Math::Pi * surfaceArea()); 33 | } 34 | 35 | LightLeSample Light::sampleLe(const std::array &u) { 36 | auto ori = uniformSample({ u[0], u[1] }); 37 | float pdfPos = 1.0f / surfaceArea(); 38 | 39 | auto N = normalGeom(ori); 40 | auto [We, pdfDir] = Math::sampleHemisphereCosine(N, { u[2], u[3] }); 41 | Ray ray(ori, We); 42 | return { ray, Le(ray), pdfPos, pdfDir }; 43 | } 44 | 45 | LightPdf Light::pdfLe(const Ray &ray) { 46 | float pdfPos = 1.0f / surfaceArea(); 47 | float pdfDir = (glm::dot(normalGeom(ray.ori), ray.dir) <= 0) ? 0 : 0.5f * Math::PiInv; 48 | return { pdfPos, pdfDir }; 49 | } -------------------------------------------------------------------------------- /src/Scene/Shape/MeshTriangle.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Shape.h" 2 | 3 | Vec3f MeshTriangle::normalShading(const Vec3f &p) { 4 | auto [va, vb, vc] = triangle.vertices(); 5 | Vec3f oriP = triangle.getTransform().getInversed(p); 6 | 7 | float areaInv = 1.0f / glm::length(glm::cross(vb - va, vc - va)); 8 | float la = glm::length(glm::cross(vb - oriP, vc - oriP)) * areaInv; 9 | float lb = glm::length(glm::cross(vc - oriP, va - oriP)) * areaInv; 10 | float lc = glm::length(glm::cross(va - oriP, vb - oriP)) * areaInv; 11 | 12 | return glm::normalize(triangle.getTransform().getInversedNormal(na * la + nb * lb + nc * lc)); 13 | } 14 | 15 | Vec2f MeshTriangle::surfaceUV(const Vec3f &p) { 16 | auto [va, vb, vc] = triangle.vertices(); 17 | Vec3f oriP = triangle.getTransform().getInversed(p); 18 | 19 | float areaInv = 1.0f / glm::length(glm::cross(vb - va, vc - va)); 20 | float la = glm::length(glm::cross(vb - oriP, vc - oriP)) * areaInv; 21 | float lb = glm::length(glm::cross(vc - oriP, va - oriP)) * areaInv; 22 | float lc = glm::length(glm::cross(va - oriP, vb - oriP)) * areaInv; 23 | 24 | return ta * la + tb * lb + tc * lc; 25 | } 26 | 27 | void MeshTriangle::setTransform(const Transform& trans) { 28 | mTransform = trans; 29 | triangle.setTransform(trans); 30 | } -------------------------------------------------------------------------------- /src/Scene/Shape/Quad.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Shape.h" 2 | 3 | std::optional Quad::closestHit(const Ray &ray) { 4 | Vec3f o = mTransform.getInversed(ray.ori); 5 | Vec3f d = mTransform.getInversed(ray.ori + ray.dir) - o; 6 | 7 | Ray inversedRay = {o, d}; 8 | Vec3f vd = vb + vc - va; 9 | 10 | auto ha = Triangle(va, vb, vc).closestHit(inversedRay); 11 | auto hb = Triangle(vc, vb, vd).closestHit(inversedRay); 12 | 13 | if (ha.has_value()) { 14 | return ha; 15 | } 16 | if (hb.has_value()) { 17 | return hb; 18 | } 19 | 20 | return std::nullopt; 21 | } 22 | 23 | Vec3f Quad::uniformSample(const Vec2f &u) { 24 | return mTransform.get((vb - va) * u.x + (vc - va) * u.y + va); 25 | } 26 | 27 | Vec3f Quad::normalGeom(const Vec3f &p) { 28 | Vec3f N = glm::normalize(glm::cross(vb - va, vc - va)); 29 | return glm::normalize(mTransform.getInversedNormal(N)); 30 | } 31 | 32 | float Quad::surfaceArea() { 33 | return glm::length(glm::cross(vc - va, vb - va)); 34 | } 35 | 36 | AABB Quad::bound() { 37 | Vec3f pa = mTransform.get(va); 38 | Vec3f pb = mTransform.get(vb); 39 | Vec3f pc = mTransform.get(vc); 40 | Vec3f pd = pb + pc - pa; 41 | return AABB(AABB(pa, pb, pc), AABB(pb, pc, pd)); 42 | } -------------------------------------------------------------------------------- /src/Scene/Shape/Sphere.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Shape.h" 2 | 3 | std::optional Sphere::closestHit(const Ray &ray) { 4 | Vec3f o = mTransform.getInversed(ray.ori); 5 | Vec3f d = mTransform.getInversed(ray.ori + ray.dir) - o; 6 | Vec3f c = center; 7 | 8 | float t = dot(d, c - o) / dot(d, d); 9 | float r = radius; 10 | 11 | float e = glm::length(o + d * t - c); 12 | if (e > r) { 13 | return std::nullopt; 14 | } 15 | 16 | float q = sqrt(glm::max(r * r - e * e, 0.0f)); 17 | // 想不到吧,r * r - e * e还是可能小于0 18 | if (glm::length(o - c) < r) { 19 | if (!intersectFromInside) 20 | return std::nullopt; 21 | float res = t + q; 22 | return res >= 0 ? res : std::optional(); 23 | } 24 | float res = t - q; 25 | return res >= 0 ? res : std::optional(); 26 | } 27 | 28 | Vec3f Sphere::uniformSample(const Vec2f &u) { 29 | float t = Math::Pi * 2.0f * u.x; 30 | float p = Math::Pi * u.y; 31 | 32 | return Vec3f(cos(t) * sin(p), sin(t) * sin(p), cos(p)) * radius + center; 33 | } 34 | 35 | Vec3f Sphere::normalGeom(const Vec3f &p) { 36 | return mTransform.getInversedNormal(glm::normalize(p - center)); 37 | } 38 | 39 | float Sphere::surfaceArea() { 40 | return 4.0f * Math::Pi * radius * radius; 41 | } 42 | 43 | Vec2f Sphere::surfaceUV(const Vec3f &p) { 44 | auto oriP = mTransform.getInversed(p); 45 | return Transform::sphereToPlane(glm::normalize(oriP - center)); 46 | } -------------------------------------------------------------------------------- /src/Surface/BSDF/ClearCoat.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/BSDF.h" 2 | 3 | Spectrum ClearcoatBSDF::bsdf(Vec3f wo, Vec3f wi, Vec2f uv, TransportMode mode, Params params) const 4 | { 5 | auto wh = glm::normalize(wo + wi); 6 | 7 | float cosWo = Math::saturate(wo.z); 8 | float cosWi = Math::saturate(wi.z); 9 | 10 | float d = distrib.d(wh); 11 | auto f = SchlickF(Math::absDot(wh, wo), Vec3f(0.04f)); 12 | float g = smithG(wo, wi, 0.25f); 13 | 14 | float denom = 4.0f * cosWo * cosWi; 15 | if (denom < 1e-7f) 16 | return Spectrum(0.0f); 17 | 18 | return f * d * g * weight / denom; 19 | } 20 | 21 | float ClearcoatBSDF::pdf(Vec3f wo, Vec3f wi, Vec2f uv, TransportMode mode, Params params) const 22 | { 23 | auto wh = glm::normalize(wo + wi); 24 | return distrib.pdf(wh, wo) / (4.0f * glm::dot(wh, wo)); 25 | } 26 | 27 | std::optional ClearcoatBSDF::sample(Vec3f wo, Vec2f uv, TransportMode mode, Sampler* sampler, BSDFType component) const 28 | { 29 | auto wh = distrib.sampleWm(wo, sampler->get2()); 30 | auto wi = glm::reflect(-wo, wh); 31 | 32 | if (wi.z < 0.0f) 33 | return std::nullopt; 34 | return BSDFSample(wi, bsdf(wo, wi, uv, mode), pdf(wo, wi, uv, mode), BSDFType::Glossy | BSDFType::Reflection); 35 | } -------------------------------------------------------------------------------- /src/Surface/BSDF/Lambert.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/BSDF.h" 2 | 3 | Spectrum LambertBSDF::bsdf(Vec3f wo, Vec3f wi, Vec2f uv, TransportMode mode, Params params) const { 4 | return albedo.get(uv) * Math::PiInv; 5 | } 6 | 7 | float LambertBSDF::pdf(Vec3f wo, Vec3f wi, Vec2f uv, TransportMode mode, Params params) const { 8 | return wi.z * Math::PiInv; 9 | } 10 | 11 | std::optional LambertBSDF::sample(Vec3f wo, Vec2f uv, TransportMode mode, Sampler* sampler, BSDFType component) const { 12 | Vec3f wi = Math::sampleHemisphereCosine(sampler->get2()); 13 | return BSDFSample(wi, albedo.get(uv) * Math::PiInv, wi.z * Math::PiInv, BSDFType::Diffuse | BSDFType::Reflection); 14 | } -------------------------------------------------------------------------------- /src/Surface/BSDF/Mirror.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/BSDF.h" 2 | 3 | Spectrum MirrorBSDF::bsdf(Vec3f wo, Vec3f wi, Vec2f uv, TransportMode mode, Params params) const { 4 | return Spectrum(0.0f); 5 | } 6 | 7 | float MirrorBSDF::pdf(Vec3f wo, Vec3f wi, Vec2f uv, TransportMode mode, Params params) const { 8 | return 0.0f; 9 | } 10 | 11 | std::optional MirrorBSDF::sample(Vec3f wo, Vec2f uv, TransportMode mode, Sampler* sampler, BSDFType component) const { 12 | Vec3f wi = { -wo.x, -wo.y, wo.z }; 13 | return BSDFSample(wi, baseColor.get(uv), 1.0f, BSDFType::Delta | BSDFType::Reflection); 14 | } -------------------------------------------------------------------------------- /src/Surface/BSDF/ThinDielectric.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/BSDF.h" 2 | 3 | Spectrum ThinDielectricBSDF::bsdf(Vec3f wo, Vec3f wi, Vec2f uv, TransportMode mode, Params params) const { 4 | return Spectrum(0.0f); 5 | } 6 | 7 | std::optional ThinDielectricBSDF::sample(Vec3f wo, Vec2f uv, TransportMode mode, Sampler* sampler, BSDFType component) const { 8 | float refl = FresnelDielectric(wo.z, ior); 9 | float trans = 1.0f - refl; 10 | if (refl < 1.0f) { 11 | refl += trans * trans * refl / (1.0f - refl * refl); 12 | trans = 1.0f - refl; 13 | } 14 | return (sampler->get1() < refl) ? 15 | BSDFSample({ -wo.x, -wo.y, wo.z }, baseColor, 1.0f, BSDFType::Delta | BSDFType::Reflection) : 16 | BSDFSample(-wo, baseColor, 1.0f, BSDFType::Delta | BSDFType::Transmission); 17 | } -------------------------------------------------------------------------------- /src/Surface/Microfacet/GTR1.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Microfacet.h" 2 | 3 | float GTR1Distrib::d(const Vec3f &m) const 4 | { 5 | return gtr1(glm::abs(m.z), alpha); 6 | } 7 | 8 | float GTR1Distrib::pdf(const Vec3f &m, const Vec3f &wo) const 9 | { 10 | return d(m) * glm::abs(m.z); 11 | } 12 | 13 | Vec3f GTR1Distrib::sampleWm(const Vec3f &wo, const Vec2f &u) const 14 | { 15 | float cosTheta = glm::sqrt(glm::max(0.0f, (1.0f - glm::pow(alpha, 1.0f - u.x)) / (1.0f - alpha))); 16 | float sinTheta = glm::sqrt(glm::max(0.0f, 1.0f - cosTheta * cosTheta)); 17 | float phi = 2.0f * u.y * Math::Pi; 18 | 19 | Vec3f m = glm::normalize(Vec3f(glm::cos(phi) * sinTheta, glm::sin(phi) * sinTheta, cosTheta)); 20 | if (!Math::sameHemisphere(wo, m)) 21 | m = -m; 22 | return m; 23 | } -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Zillum.h" 4 | 5 | Zillum app; 6 | 7 | LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { 8 | return app.process(hWnd, message, wParam, lParam); 9 | } 10 | 11 | int main(int argc, char* argv[]) { 12 | const char* name = "Zillum"; 13 | 14 | MSG msg; 15 | WNDCLASSA wndClass; 16 | HINSTANCE instance = GetModuleHandle(nullptr); 17 | 18 | wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS; 19 | wndClass.lpfnWndProc = WndProc; 20 | wndClass.cbClsExtra = 0; 21 | wndClass.cbWndExtra = 0; 22 | wndClass.hInstance = instance; 23 | wndClass.hIcon = LoadIcon(nullptr, IDI_APPLICATION); 24 | wndClass.hCursor = LoadCursor(nullptr, IDC_ARROW); 25 | wndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); 26 | wndClass.lpszMenuName = nullptr; 27 | wndClass.lpszClassName = name; 28 | 29 | if (!RegisterClassA(&wndClass)) { 30 | MessageBoxA(nullptr, "This program requires Windows NT!", name, MB_ICONERROR); 31 | return 0; 32 | } 33 | 34 | std::string cmdLine; 35 | for (int i = 1; i < argc; i++) { 36 | cmdLine += argv[i] + ' '; 37 | } 38 | 39 | app.init(std::string(name), instance, cmdLine.c_str()); 40 | 41 | while (true) { 42 | if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { 43 | if (msg.message == WM_QUIT) { 44 | break; 45 | } 46 | else { 47 | TranslateMessage(&msg); 48 | DispatchMessage(&msg); 49 | } 50 | } 51 | else { 52 | if (!app.render()) { 53 | break; 54 | } 55 | } 56 | } 57 | return msg.wParam; 58 | } --------------------------------------------------------------------------------