├── .gitignore ├── .release ├── .workonrc.products ├── LICENSE ├── LICENSE-BINARY ├── Makefile ├── README ├── README-DISNEY ├── README-WIN32 ├── brdf.spec.in ├── config.pri ├── main.pro ├── make_win32_dist.sh └── src ├── brdf ├── .gitignore ├── BRDFAnalytic.cpp ├── BRDFAnalytic.h ├── BRDFBase.cpp ├── BRDFBase.h ├── BRDFImageSlice.cpp ├── BRDFImageSlice.h ├── BRDFMeasuredAniso.cpp ├── BRDFMeasuredAniso.h ├── BRDFMeasuredMERL.cpp ├── BRDFMeasuredMERL.h ├── ColorVarWidget.cpp ├── ColorVarWidget.h ├── DGLFrameBuffer.cpp ├── DGLFrameBuffer.h ├── DGLShader.cpp ├── DGLShader.h ├── FloatVarWidget.cpp ├── FloatVarWidget.h ├── IBLWidget.cpp ├── IBLWidget.h ├── IBLWindow.cpp ├── IBLWindow.h ├── ImageSliceWidget.cpp ├── ImageSliceWidget.h ├── ImageSliceWindow.cpp ├── ImageSliceWindow.h ├── LitSphereWidget.cpp ├── LitSphereWidget.h ├── LitSphereWindow.cpp ├── LitSphereWindow.h ├── MainWindow.cpp ├── MainWindow.h ├── ParameterGroupWidget.cpp ├── ParameterGroupWidget.h ├── ParameterWindow.cpp ├── ParameterWindow.h ├── Paths.cpp ├── Paths.h ├── Plot3DWidget.cpp ├── Plot3DWidget.h ├── PlotCartesianWidget.cpp ├── PlotCartesianWidget.h ├── PlotCartesianWindow.cpp ├── PlotCartesianWindow.h ├── PlotPolarWidget.cpp ├── PlotPolarWidget.h ├── Quad.cpp ├── Quad.h ├── SharedContextGLWidget.cpp ├── SharedContextGLWidget.h ├── ShowingBase.h ├── ShowingDockWidget.cpp ├── ShowingDockWidget.h ├── SimpleModel.cpp ├── SimpleModel.h ├── Sphere.cpp ├── Sphere.h ├── ViewerWindow.cpp ├── ViewerWindow.h ├── bitmapContainer.h ├── brdf.pc ├── brdf.pro ├── geodesicHemisphere.h ├── glerror.cpp ├── glerror.h ├── glm │ ├── CMakeLists.txt │ ├── common.hpp │ ├── detail │ │ ├── _features.hpp │ │ ├── _fixes.hpp │ │ ├── _noise.hpp │ │ ├── _swizzle.hpp │ │ ├── _swizzle_func.hpp │ │ ├── _vectorize.hpp │ │ ├── dummy.cpp │ │ ├── func_common.hpp │ │ ├── func_common.inl │ │ ├── func_common_simd.inl │ │ ├── func_exponential.hpp │ │ ├── func_exponential.inl │ │ ├── func_exponential_simd.inl │ │ ├── func_geometric.hpp │ │ ├── func_geometric.inl │ │ ├── func_geometric_simd.inl │ │ ├── func_integer.hpp │ │ ├── func_integer.inl │ │ ├── func_integer_simd.inl │ │ ├── func_matrix.hpp │ │ ├── func_matrix.inl │ │ ├── func_matrix_simd.inl │ │ ├── func_packing.hpp │ │ ├── func_packing.inl │ │ ├── func_packing_simd.inl │ │ ├── func_trigonometric.hpp │ │ ├── func_trigonometric.inl │ │ ├── func_trigonometric_simd.inl │ │ ├── func_vector_relational.hpp │ │ ├── func_vector_relational.inl │ │ ├── func_vector_relational_simd.inl │ │ ├── glm.cpp │ │ ├── precision.hpp │ │ ├── setup.hpp │ │ ├── type_float.hpp │ │ ├── type_gentype.hpp │ │ ├── type_gentype.inl │ │ ├── type_half.hpp │ │ ├── type_half.inl │ │ ├── type_int.hpp │ │ ├── type_mat.hpp │ │ ├── type_mat.inl │ │ ├── type_mat2x2.hpp │ │ ├── type_mat2x2.inl │ │ ├── type_mat2x3.hpp │ │ ├── type_mat2x3.inl │ │ ├── type_mat2x4.hpp │ │ ├── type_mat2x4.inl │ │ ├── type_mat3x2.hpp │ │ ├── type_mat3x2.inl │ │ ├── type_mat3x3.hpp │ │ ├── type_mat3x3.inl │ │ ├── type_mat3x4.hpp │ │ ├── type_mat3x4.inl │ │ ├── type_mat4x2.hpp │ │ ├── type_mat4x2.inl │ │ ├── type_mat4x3.hpp │ │ ├── type_mat4x3.inl │ │ ├── type_mat4x4.hpp │ │ ├── type_mat4x4.inl │ │ ├── type_mat4x4_simd.inl │ │ ├── type_vec.hpp │ │ ├── type_vec.inl │ │ ├── type_vec1.hpp │ │ ├── type_vec1.inl │ │ ├── type_vec2.hpp │ │ ├── type_vec2.inl │ │ ├── type_vec3.hpp │ │ ├── type_vec3.inl │ │ ├── type_vec4.hpp │ │ ├── type_vec4.inl │ │ └── type_vec4_simd.inl │ ├── exponential.hpp │ ├── ext.hpp │ ├── fwd.hpp │ ├── geometric.hpp │ ├── glm.hpp │ ├── gtc │ │ ├── bitfield.hpp │ │ ├── bitfield.inl │ │ ├── color_space.hpp │ │ ├── color_space.inl │ │ ├── constants.hpp │ │ ├── constants.inl │ │ ├── epsilon.hpp │ │ ├── epsilon.inl │ │ ├── functions.hpp │ │ ├── functions.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 │ │ └── vec1.inl │ ├── 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 │ │ ├── euler_angles.hpp │ │ ├── euler_angles.inl │ │ ├── extend.hpp │ │ ├── extend.inl │ │ ├── extended_min_max.hpp │ │ ├── extended_min_max.inl │ │ ├── fast_exponential.hpp │ │ ├── fast_exponential.inl │ │ ├── fast_square_root.hpp │ │ ├── fast_square_root.inl │ │ ├── fast_trigonometry.hpp │ │ ├── fast_trigonometry.inl │ │ ├── float_notmalize.inl │ │ ├── gradient_paint.hpp │ │ ├── gradient_paint.inl │ │ ├── handed_coordinate_space.hpp │ │ ├── handed_coordinate_space.inl │ │ ├── hash.hpp │ │ ├── hash.inl │ │ ├── integer.hpp │ │ ├── integer.inl │ │ ├── intersect.hpp │ │ ├── intersect.inl │ │ ├── io.hpp │ │ ├── io.inl │ │ ├── log_base.hpp │ │ ├── log_base.inl │ │ ├── matrix_cross_product.hpp │ │ ├── matrix_cross_product.inl │ │ ├── matrix_decompose.hpp │ │ ├── matrix_decompose.inl │ │ ├── matrix_interpolation.hpp │ │ ├── matrix_interpolation.inl │ │ ├── matrix_major_storage.hpp │ │ ├── matrix_major_storage.inl │ │ ├── matrix_operation.hpp │ │ ├── matrix_operation.inl │ │ ├── matrix_query.hpp │ │ ├── matrix_query.inl │ │ ├── matrix_transform_2d.hpp │ │ ├── matrix_transform_2d.inl │ │ ├── mixed_product.hpp │ │ ├── mixed_product.inl │ │ ├── norm.hpp │ │ ├── norm.inl │ │ ├── normal.hpp │ │ ├── normal.inl │ │ ├── normalize_dot.hpp │ │ ├── normalize_dot.inl │ │ ├── number_precision.hpp │ │ ├── number_precision.inl │ │ ├── optimum_pow.hpp │ │ ├── optimum_pow.inl │ │ ├── orthonormalize.hpp │ │ ├── orthonormalize.inl │ │ ├── perpendicular.hpp │ │ ├── perpendicular.inl │ │ ├── polar_coordinates.hpp │ │ ├── polar_coordinates.inl │ │ ├── projection.hpp │ │ ├── projection.inl │ │ ├── quaternion.hpp │ │ ├── quaternion.inl │ │ ├── range.hpp │ │ ├── raw_data.hpp │ │ ├── raw_data.inl │ │ ├── rotate_normalized_axis.hpp │ │ ├── rotate_normalized_axis.inl │ │ ├── rotate_vector.hpp │ │ ├── rotate_vector.inl │ │ ├── scalar_multiplication.hpp │ │ ├── scalar_relational.hpp │ │ ├── scalar_relational.inl │ │ ├── spline.hpp │ │ ├── spline.inl │ │ ├── std_based_type.hpp │ │ ├── std_based_type.inl │ │ ├── string_cast.hpp │ │ ├── string_cast.inl │ │ ├── transform.hpp │ │ ├── transform.inl │ │ ├── transform2.hpp │ │ ├── transform2.inl │ │ ├── type_aligned.hpp │ │ ├── type_aligned.inl │ │ ├── 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 │ │ ├── packing.h │ │ ├── platform.h │ │ ├── trigonometric.h │ │ └── vector_relational.h │ ├── trigonometric.hpp │ ├── vec2.hpp │ ├── vec3.hpp │ ├── vec4.hpp │ └── vector_relational.hpp ├── main.cpp ├── ptex │ ├── PtexCache.cpp │ ├── PtexCache.h │ ├── PtexDict.h │ ├── PtexHalf.cpp │ ├── PtexHalf.h │ ├── PtexHashMap.h │ ├── PtexIO.h │ ├── PtexInt.h │ ├── PtexMutex.h │ ├── PtexPlatform.h │ ├── PtexReader.cpp │ ├── PtexReader.h │ ├── PtexUtils.cpp │ ├── PtexUtils.h │ └── Ptexture.h └── trim.h ├── brdfs ├── ashikhman_shirley.brdf ├── blinn.brdf ├── blinnphong.brdf ├── compare.brdf ├── cooktorrance.brdf ├── dAniso.brdf ├── d_beckmann.brdf ├── d_blinnphong.brdf ├── d_exponential.brdf ├── d_gaussian.brdf ├── d_ggx.brdf ├── d_nishino.brdf ├── d_phong.brdf ├── d_trowbridge_reitz.brdf ├── disney.brdf ├── edwards06.brdf ├── f_cooktorrance.brdf ├── f_schlick.brdf ├── f_schlick_f0.brdf ├── g_ap07.brdf ├── g_as00.brdf ├── g_cooktorrance.brdf ├── g_duer.brdf ├── g_kelemen.brdf ├── g_kurt10.brdf ├── g_neumann.brdf ├── g_schlick.brdf ├── g_walter07.brdf ├── g_ward.brdf ├── lambert.brdf ├── minnaert.brdf ├── modifiedphong.brdf ├── orennayar.brdf ├── phong.brdf ├── schlick.brdf ├── showAngles.brdf ├── showVectors.brdf ├── stretchedphong.brdf ├── walter.brdf └── ward.brdf ├── data ├── sphere.obj └── teapot.obj ├── images ├── closeSmall.png ├── folderSmall.png ├── imageSmall.png ├── modelSmall.png ├── reloadSmall.png ├── resetSmall.png ├── soloColorsSmall.png ├── soloSmall.png └── verasansmono.png ├── probes ├── beach.penv ├── furnace.penv └── spot.penv └── shaderTemplates ├── IBLComp.frag ├── IBLResult.frag ├── Plane.frag ├── Plane.vert ├── Plots.frag ├── Plots.geom ├── Plots.vert ├── Plots3D.geom ├── Plots3D.vert ├── Quad.vert ├── Text.frag ├── Text.geom ├── Text.vert ├── brdfIBL.frag ├── brdfIBL.vert ├── brdftemplate2D.frag ├── brdftemplate2D.vert ├── brdftemplate3D.frag ├── brdftemplate3D.vert ├── brdftemplateAnglePlot.frag ├── brdftemplateAnglePlot.vert ├── brdftemplateAnglePlotAlbedo.frag ├── brdftemplateAnglePlotAlbedo.geom ├── brdftemplateAnglePlotAlbedo.vert ├── brdftemplateAnglePlotThetaD.frag ├── brdftemplateAnglePlotThetaD.vert ├── brdftemplateAnglePlotThetaH.frag ├── brdftemplateAnglePlotThetaH.vert ├── brdftemplateImageSlice.frag ├── brdftemplateImageSlice.vert ├── brdftemplatePlot.geom ├── brdftemplatesphere.frag ├── brdftemplatesphere.vert ├── imageSlice.func ├── measured.func └── measuredAniso.func /.gitignore: -------------------------------------------------------------------------------- 1 | /Linux-* 2 | *.o 3 | moc_* 4 | *.dll 5 | *.exe 6 | *.filters 7 | *.ipch 8 | *.opensdf 9 | *.pdb 10 | *.sdf 11 | *.sln 12 | *.suo 13 | *.user 14 | *.vcxproj 15 | src/brdf/release 16 | src/brdf/debug 17 | /Makefile.main.pro 18 | /src/**/Makefile 19 | /.qmake.stash 20 | -------------------------------------------------------------------------------- /.release: -------------------------------------------------------------------------------- 1 | bin 2 | share 3 | -------------------------------------------------------------------------------- /.workonrc.products: -------------------------------------------------------------------------------- 1 | brdf 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BRDF Explorer 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | This license governs use of the accompanying software. If you use the software, you 5 | accept this license. If you do not accept the license, do not use the software. 6 | 7 | 1. Definitions 8 | The terms "reproduce," "reproduction," "derivative works," and "distribution" have 9 | the same meaning here as under U.S. copyright law. A "contribution" is the original 10 | software, or any additions or changes to the software. A "contributor" is any person 11 | that distributes its contribution under this license. "Licensed patents" are a 12 | contributor's patent claims that read directly on its contribution. 13 | 14 | 2. Grant of Rights 15 | (A) Copyright Grant- Subject to the terms of this license, including the license 16 | conditions and limitations in section 3, each contributor grants you a non-exclusive, 17 | worldwide, royalty-free copyright license to reproduce its contribution, prepare 18 | derivative works of its contribution, and distribute its contribution or any derivative 19 | works that you create. 20 | (B) Patent Grant- Subject to the terms of this license, including the license 21 | conditions and limitations in section 3, each contributor grants you a non-exclusive, 22 | worldwide, royalty-free license under its licensed patents to make, have made, 23 | use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the 24 | software or derivative works of the contribution in the software. 25 | 26 | 3. Conditions and Limitations 27 | (A) No Trademark License- This license does not grant you rights to use any 28 | contributors' name, logo, or trademarks. 29 | (B) If you bring a patent claim against any contributor over patents that you claim 30 | are infringed by the software, your patent license from such contributor to the 31 | software ends automatically. 32 | (C) If you distribute any portion of the software, you must retain all copyright, 33 | patent, trademark, and attribution notices that are present in the software. 34 | (D) If you distribute any portion of the software in source code form, you may do 35 | so only under this license by including a complete copy of this license with your 36 | distribution. If you distribute any portion of the software in compiled or object code 37 | form, you may only do so under a license that complies with this license. 38 | (E) The software is licensed "as-is." You bear the risk of using it. The contributors 39 | give no express warranties, guarantees or conditions. You may have additional 40 | consumer rights under your local laws which this license cannot change. 41 | To the extent permitted under your local laws, the contributors exclude the 42 | implied warranties of merchantability, fitness for a particular purpose and non- 43 | infringement. 44 | -------------------------------------------------------------------------------- /LICENSE-BINARY: -------------------------------------------------------------------------------- 1 | BRDF Explorer 2 | Copyright Disney Enterprises, Inc. All rights reserved. 3 | 4 | See LICENSE for the specific application components license. 5 | Source code is available at http://disneyanimation.com/ 6 | http://www.disneyanimation.com/technology/brdf.html 7 | 8 | Developed with Nokia Qt4. Qt4 libraries are unmodified and 9 | dynamically linked LGPL versions. Binaries and source are available at 10 | http://qt.nokia.com/products. 11 | 12 | Windows binary is cross compiled using ming32. 13 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | MYOS = $(shell uname -s) 2 | MYREL = $(shell uname -r | cut -f1 -d-) 3 | MYARCH = $(shell uname -p) 4 | 5 | prefix ?= $(CURDIR)/$(MYOS)-$(MYREL)-$(MYARCH) 6 | 7 | ifdef DESTDIR 8 | export INSTALL_ROOT := $(DESTDIR) 9 | endif 10 | 11 | export QMAKEFEATURES := $(PWD)/features 12 | PROJECT_FILE = main.pro 13 | REAL_MAKEFILE = Makefile.$(PROJECT_FILE) 14 | 15 | 16 | ifeq ($(MYOS), Darwin) 17 | QMAKE = qmake -spec macx-g++ 18 | else 19 | QMAKE = qmake 20 | endif 21 | 22 | default: $(REAL_MAKEFILE) 23 | $(MAKE) -f $(REAL_MAKEFILE) all 24 | 25 | 26 | install: $(REAL_MAKEFILE) 27 | $(MAKE) -f $(REAL_MAKEFILE) install 28 | 29 | %: $(REAL_MAKEFILE) 30 | $(MAKE) -f $(REAL_MAKEFILE) $@ 31 | 32 | 33 | $(REAL_MAKEFILE): $(PROJECT_FILE) 34 | $(QMAKE) prefix=$(prefix) -o $(REAL_MAKEFILE) $(PROJECT_FILE) 35 | 36 | $(PROJECT_FILE): ; 37 | -------------------------------------------------------------------------------- /README-DISNEY: -------------------------------------------------------------------------------- 1 | To produce a Disney-friendly, attach-able product: 2 | qmake 3 | make install 4 | 5 | NOTE: if building against the system, use 'qmake-qt4' instead of just 'qmake', 6 | or else you might end up using the qt3.3 qmake. 7 | 8 | -------------------------------------------------------------------------------- /README-WIN32: -------------------------------------------------------------------------------- 1 | How to compile BRDF Explorer for Windows 2 | ======================================== 3 | 4 | The following external dependencies are required (versions are ones that I used, other might also work): 5 | - Qt 4.8.1 6 | - GLEW 1.9.0 7 | - ZLib 1.2.5 8 | - GLUT 3.7 9 | 10 | Make sure that qmake is in your PATH. Also put GLEW, ZLib and GLUT include and library directories somewhere VC can find them. 11 | 12 | Open Visual Studio 2010 command prompt and navigate to brdf project root directory. 13 | Run "qmake -r -tp vc prefix=foo", this will generate the vcxproj and sln files. 14 | -------------------------------------------------------------------------------- /brdf.spec.in: -------------------------------------------------------------------------------- 1 | # RPMs can be built using 'git make-rpm' 2 | Name: brdf 3 | Version: __VERSION__ 4 | Release: __RELEASE__%{?dist} 5 | Summary: BRDF Explorer 6 | 7 | Group: Applications/Multimedia 8 | License: Disney 9 | URL: http://gitweb/projects/%{name} 10 | Source0: http://gitweb/projects/%{name}-%{version}.tar.gz 11 | 12 | BuildRequires: gcc 13 | BuildRequires: gcc-c++ 14 | BuildRequires: glew 15 | BuildRequires: glew-devel 16 | BuildRequires: qt 17 | BuildRequires: qt-devel 18 | BuildRequires: pkgconfig-disney 19 | 20 | Requires: glew 21 | Requires: qt 22 | 23 | prefix: %{_prefix} 24 | BuildRoot: %{_topdir}/BUILDROOT/%{name}-%{version} 25 | 26 | %description 27 | The BRDF Explorer is the best way to quickly get a feel for 28 | how shader controls work and quickly dial in material settings 29 | 30 | %prep 31 | %setup -q 32 | 33 | %build 34 | 35 | %install 36 | qmake-qt4 prefix=%{_prefix} 37 | make INSTALL_ROOT=%{buildroot} install 38 | 39 | %clean 40 | rm -rf %{buildroot} 41 | 42 | %post 43 | 44 | %postun 45 | 46 | %files 47 | %defattr(-,root,root,-) 48 | %{_bindir}/brdf 49 | %{_datadir}/brdf 50 | -------------------------------------------------------------------------------- /config.pri: -------------------------------------------------------------------------------- 1 | # PATH_TO_ZLIB_SOURCE 2 | ZLIB_INCLUDE_DIR = 3 | 4 | # PATH TO zlibwapi.lib (zlib 1.2.11 version) 5 | ZLIB_LIB = 6 | 7 | # PATH TO zlibwapi.dll (zlib 1.2.11 version) 8 | ZLIB_DLL = 9 | 10 | QMAKE_MAC_SDK = macosx10.9 11 | QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9 12 | -------------------------------------------------------------------------------- /main.pro: -------------------------------------------------------------------------------- 1 | include(config.pri) 2 | 3 | TEMPLATE = subdirs 4 | CONFIG += ordered 5 | SUBDIRS += src/brdf 6 | -------------------------------------------------------------------------------- /make_win32_dist.sh: -------------------------------------------------------------------------------- 1 | 2 | VERSION=1.0.0 3 | 4 | make clean 5 | qmake-qt4 -spec linux-mingw32-custom 6 | make -j 8 7 | 8 | DIR=brdf-$VERSION-win32 9 | rm -rf $DIR 10 | mkdir $DIR 11 | pushd $DIR 12 | cp -a ../src/{data,probes,images,brdfs,shaderTemplates} ./ 13 | cp /jobs2/soft/users/aselle/windows-build/QtSDK/Desktop/Qt/4.6.4/bin/{QtGui4.dll,QtCore4.dll,QtOpenGL4.dll,libgcc_s_dw2-1.dll,mingwm10.dll} ./ 14 | cp ../src/brdf/release/brdf.exe ./ 15 | cp ../{LICENSE,LICENSE-BINARY,README} ./ 16 | popd 17 | zip -r brdf-$VERSION-win32.zip brdf-$VERSION-win32 -------------------------------------------------------------------------------- /src/brdf/.gitignore: -------------------------------------------------------------------------------- 1 | /brdf 2 | /brdf.app 3 | *.o 4 | *.swp 5 | -------------------------------------------------------------------------------- /src/brdf/Quad.h: -------------------------------------------------------------------------------- 1 | #ifndef _QUAD_H_ 2 | #define _QUAD_H_ 3 | 4 | #include "BRDFBase.h" 5 | #include "DGLShader.h" 6 | 7 | class Quad : GLContext 8 | { 9 | public: 10 | Quad(); 11 | Quad(float x1, float y1, float x2, float y2); 12 | Quad(float x1, float y1, float x2, float y2, float u1, float v1, float u2, float v2); 13 | ~Quad(); 14 | 15 | void init(); 16 | 17 | void setTexCoord(unsigned int id, float x, float y); 18 | void setPos(unsigned int id, float x, float y); 19 | 20 | void draw(const DGLShader* shader); 21 | 22 | private: 23 | float _texCoord[8]; 24 | float _pos[8]; 25 | unsigned int _indices[6]; 26 | 27 | bool _ready; 28 | 29 | GLuint _vao; 30 | GLuint _bufs[3]; 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/brdf/Sphere.h: -------------------------------------------------------------------------------- 1 | #ifndef _SPHERE_H 2 | #define _SPHERE_H 3 | 4 | #if defined(_MSC_VER) 5 | #define _USE_MATH_DEFINES 6 | #include 7 | #include 8 | #else 9 | #include 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include "DGLShader.h" 16 | 17 | class Sphere : GLContext 18 | { 19 | 20 | public: 21 | Sphere(float radius=1.f, int nU=100, int nV=100); 22 | ~Sphere(); 23 | void init(); 24 | void draw(const DGLShader *shader); 25 | float radius() const { return _radius; } 26 | int lats() const { return _nU; } 27 | int longs() const { return _nV; } 28 | 29 | private : 30 | GLuint _vao; 31 | GLuint _bufs[6]; 32 | 33 | std::vector _indices; /* vertex indices */ 34 | std::vector _vertices; /* 3D positions */ 35 | std::vector _colors; /* colors */ 36 | std::vector _normals; /* 3D normals */ 37 | std::vector _tangents; /* 3D tangent to surface */ 38 | std::vector _texCoords; /* 2D texture coordinates */ 39 | 40 | float _radius; 41 | int _nU, _nV; 42 | bool _ready; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/brdf/ViewerWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "ViewerWindow.h" 2 | #include 3 | #include "SharedContextGLWidget.h" 4 | 5 | ViewerWindow::ViewerWindow(GLWindow *widget) 6 | { 7 | glWidget = widget; 8 | QVBoxLayout *mainLayout = new QVBoxLayout; 9 | mainLayout->addWidget(QWidget::createWindowContainer(glWidget)); 10 | setLayout(mainLayout); 11 | } 12 | 13 | void ViewerWindow::resizeEvent(QResizeEvent * event) 14 | { 15 | Q_UNUSED(event) 16 | glWidget->updateGL(); 17 | } 18 | 19 | void ViewerWindow::setShowing( bool s ) 20 | { 21 | if( glWidget ){ 22 | glWidget->setShowing( s ); 23 | if(s) 24 | glWidget->updateGL(); 25 | } 26 | } 27 | 28 | GLWindow* ViewerWindow::getWidget() 29 | { 30 | return glWidget; 31 | } 32 | -------------------------------------------------------------------------------- /src/brdf/ViewerWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef VIEWERWINDOW_H 2 | #define VIEWERWINDOW_H 3 | 4 | #include 5 | #include "ShowingBase.h" 6 | 7 | class GLWindow; 8 | 9 | class ViewerWindow : public QWidget, public ShowingBase 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | ViewerWindow(GLWindow* widget); 15 | GLWindow* getWidget() ; 16 | 17 | protected: 18 | void setShowing( bool s ); 19 | void resizeEvent(QResizeEvent * event); 20 | 21 | protected: 22 | GLWindow* glWidget; 23 | }; 24 | 25 | #endif // VIEWERWINDOW_H 26 | -------------------------------------------------------------------------------- /src/brdf/brdf.pc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/brdf/brdf.pc -------------------------------------------------------------------------------- /src/brdf/brdf.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | CONFIG += qt5 #debug 3 | 4 | isEmpty(prefix) { 5 | prefix = $$system(pf-makevar --absolute root 2>/dev/null) 6 | } 7 | isEmpty(prefix) { 8 | error("$prefix is undefined. Please pass prefix= to qmake") 9 | } 10 | 11 | DEST = $$prefix 12 | isEmpty(LIBDIR) { 13 | LIBDIR = $$system(pf-makevar lib 2>/dev/null) 14 | } 15 | isEmpty(LIBDIR) { 16 | LIBDIR = lib 17 | } 18 | 19 | TARGET = brdf 20 | target.path = $$DEST/bin 21 | 22 | HEADERS = *.h 23 | SOURCES = \ 24 | Quad.cpp \ 25 | Sphere.cpp \ 26 | BRDFAnalytic.cpp \ 27 | BRDFBase.cpp \ 28 | BRDFImageSlice.cpp \ 29 | BRDFMeasuredAniso.cpp \ 30 | BRDFMeasuredMERL.cpp \ 31 | ColorVarWidget.cpp \ 32 | FloatVarWidget.cpp \ 33 | DGLFrameBuffer.cpp \ 34 | DGLShader.cpp \ 35 | IBLWidget.cpp \ 36 | IBLWindow.cpp \ 37 | ImageSliceWidget.cpp \ 38 | ImageSliceWindow.cpp \ 39 | LitSphereWindow.cpp \ 40 | main.cpp \ 41 | glerror.cpp \ 42 | MainWindow.cpp \ 43 | ViewerWindow.cpp \ 44 | ParameterGroupWidget.cpp \ 45 | ParameterWindow.cpp \ 46 | SharedContextGLWidget.cpp \ 47 | ShowingDockWidget.cpp \ 48 | PlotCartesianWindow.cpp \ 49 | PlotCartesianWidget.cpp \ 50 | PlotPolarWidget.cpp \ 51 | Plot3DWidget.cpp \ 52 | LitSphereWidget.cpp \ 53 | SimpleModel.cpp \ 54 | Paths.cpp \ 55 | ptex/PtexReader.cpp \ 56 | ptex/PtexUtils.cpp \ 57 | ptex/PtexCache.cpp \ 58 | ptex/PtexHalf.cpp 59 | 60 | 61 | QT += widgets opengl 62 | DEFINES += PTEX_STATIC NOMINMAX 63 | 64 | macx { 65 | CONFIG -= app_bundle 66 | } 67 | 68 | brdfs.path = $$DEST/share/brdf/brdfs 69 | brdfs.files = ../brdfs/* 70 | 71 | data.path = $$DEST/share/brdf/data 72 | data.files = ../data/* 73 | 74 | images.path = $$DEST/share/brdf/images 75 | images.files = ../images/* 76 | 77 | probes.path = $$DEST/share/brdf/probes 78 | probes.files = ../probes/* 79 | 80 | shaderTemplates.path = $$DEST/share/brdf/shaderTemplates 81 | shaderTemplates.files = ../shaderTemplates/* 82 | 83 | pkgconfig.path = $$DEST/$$LIBDIR/pkgconfig 84 | pkgconfig.files = brdf.pc 85 | 86 | INSTALLS = target brdfs data images probes shaderTemplates pkgconfig 87 | 88 | win32-msvc*{ 89 | INCLUDEPATH += ZLIB_DIR 90 | DEFINES += ZLIB_WINAPI 91 | LIBS += ZLIB_LIB 92 | } 93 | 94 | win32-g++*{ 95 | LIBS += -lz 96 | } 97 | 98 | unix*{ 99 | LIBS += -lz 100 | } 101 | 102 | # Windows cross compile at disney 103 | linux-mingw32-custom{ 104 | WINDOWS_BUILD=/jobs2/soft/users/aselle/windows-build 105 | LIBS += -static-libgcc 106 | } 107 | -------------------------------------------------------------------------------- /src/brdf/glerror.cpp: -------------------------------------------------------------------------------- 1 | #include "glerror.h" 2 | #include 3 | #include 4 | #include 5 | 6 | #include "SharedContextGLWidget.h" 7 | 8 | static const struct { 9 | GLenum code; 10 | const char *string; 11 | } errors[]= { 12 | {GL_NO_ERROR, "no error"}, 13 | {GL_INVALID_ENUM, "invalid enumerant"}, 14 | {GL_INVALID_VALUE, "invalid value"}, 15 | {GL_INVALID_OPERATION, "invalid operation"}, 16 | {GL_OUT_OF_MEMORY, "out of memory"}, 17 | {GL_INVALID_FRAMEBUFFER_OPERATION, "Invalid framebuffer operation"}, 18 | {0, "(unrecognized error code)" } 19 | }; 20 | 21 | const char* GLErrorString(GLenum errorCode) 22 | { 23 | for(int i=0; errors[i].string; i++) 24 | { 25 | if (errors[i].code == errorCode) 26 | { 27 | return errors[i].string; 28 | } 29 | } 30 | 31 | return NULL; 32 | } 33 | 34 | bool QueryExtension(const char *extName) 35 | { 36 | /* 37 | ** Search for extName in the extensions string. Use of strstr() 38 | ** is not sufficient because extension names can be prefixes of 39 | ** other extension names. Could use strtok() but the constant 40 | ** string returned by glGetString might be in read-only memory. 41 | */ 42 | char *p; 43 | char *end; 44 | int extNameLen; 45 | 46 | extNameLen = strlen(extName); 47 | 48 | p = (char *)GLContext::glFuncs()->glGetString(GL_EXTENSIONS); 49 | if (NULL == p) { 50 | return false; 51 | } 52 | 53 | end = p + strlen(p); 54 | 55 | while (p < end) { 56 | int n = strcspn(p, " "); 57 | if ((extNameLen == n) && (strncmp(extName, p, n) == 0)) { 58 | return true; 59 | } 60 | p += (n + 1); 61 | } 62 | return false; 63 | } 64 | 65 | int PrintOpenGLError(const char *file, int line, const char *msg) 66 | { 67 | // Returns 1 if an OpenGL error occurred, 0 otherwise. 68 | int retCode = 0; 69 | GLenum glErr = GLContext::glFuncs()->glGetError(); 70 | while (glErr != GL_NO_ERROR) 71 | { 72 | const char *errDescr = (const char *)GLErrorString(glErr); 73 | if (! errDescr) { 74 | if (glErr == GL_INVALID_FRAMEBUFFER_OPERATION) 75 | errDescr = "Invalid framebuffer operation (ext)"; 76 | else 77 | errDescr = "(unrecognized error code)"; 78 | } 79 | 80 | char output[1000]; 81 | sprintf(output, "OpenGL Error %s (%d) in file %s:%d%s%s%s", 82 | errDescr, glErr, file, line, 83 | msg ? " (" : "", 84 | msg ? msg : "", 85 | msg ? ")" : ""); 86 | 87 | std::cout << output << std::endl; 88 | 89 | retCode = 1; 90 | 91 | glErr = GLContext::glFuncs()->glGetError(); 92 | } 93 | return retCode; 94 | } 95 | -------------------------------------------------------------------------------- /src/brdf/glerror.h: -------------------------------------------------------------------------------- 1 | #ifndef GLERROR_H 2 | #define GLERROR_H 3 | 4 | bool QueryExtension(const char *extName); 5 | int PrintOpenGLError(const char *file, int line, const char *msg = 0); 6 | 7 | #define CKGL() PrintOpenGLError(__FILE__, __LINE__) 8 | 9 | #endif // GLERROR_H 10 | -------------------------------------------------------------------------------- /src/brdf/glm/common.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/common.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/func_common.hpp" 7 | -------------------------------------------------------------------------------- /src/brdf/glm/detail/_fixes.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/detail/_fixes.hpp 3 | 4 | #include 5 | 6 | //! Workaround for compatibility with other libraries 7 | #ifdef max 8 | #undef max 9 | #endif 10 | 11 | //! Workaround for compatibility with other libraries 12 | #ifdef min 13 | #undef min 14 | #endif 15 | 16 | //! Workaround for Android 17 | #ifdef isnan 18 | #undef isnan 19 | #endif 20 | 21 | //! Workaround for Android 22 | #ifdef isinf 23 | #undef isinf 24 | #endif 25 | 26 | //! Workaround for Chrone Native Client 27 | #ifdef log2 28 | #undef log2 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /src/brdf/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, P, true> 13 | { 14 | GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const & v) 15 | { 16 | vec<4, float, P> result(uninitialize); 17 | result.data = _mm_sqrt_ps(v.data); 18 | return result; 19 | } 20 | }; 21 | 22 | template<> 23 | struct compute_sqrt<4, float, aligned_lowp, true> 24 | { 25 | GLM_FUNC_QUALIFIER static vec<4, float, aligned_lowp> call(vec<4, float, aligned_lowp> const & v) 26 | { 27 | vec<4, float, aligned_lowp> result(uninitialize); 28 | result.data = glm_vec4_sqrt_lowp(v.data); 29 | return result; 30 | } 31 | }; 32 | }//namespace detail 33 | }//namespace glm 34 | 35 | #endif//GLM_ARCH & GLM_ARCH_SSE2_BIT 36 | -------------------------------------------------------------------------------- /src/brdf/glm/detail/func_integer_simd.inl: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/detail/func_integer_simd.inl 3 | 4 | #include "../simd/integer.h" 5 | 6 | #if GLM_ARCH & GLM_ARCH_SSE2_BIT 7 | 8 | namespace glm{ 9 | namespace detail 10 | { 11 | template 12 | struct compute_bitfieldReverseStep<4, uint32, P, vec, true, true> 13 | { 14 | GLM_FUNC_QUALIFIER static vec<4, uint32, P> call(vec<4, uint32, P> const & v, uint32 Mask, uint32 Shift) 15 | { 16 | __m128i const set0 = v.data; 17 | 18 | __m128i const set1 = _mm_set1_epi32(Mask); 19 | __m128i const and1 = _mm_and_si128(set0, set1); 20 | __m128i const sft1 = _mm_slli_epi32(and1, Shift); 21 | 22 | __m128i const set2 = _mm_andnot_si128(set0, _mm_set1_epi32(-1)); 23 | __m128i const and2 = _mm_and_si128(set0, set2); 24 | __m128i const sft2 = _mm_srai_epi32(and2, Shift); 25 | 26 | __m128i const or0 = _mm_or_si128(sft1, sft2); 27 | 28 | return or0; 29 | } 30 | }; 31 | 32 | template 33 | struct compute_bitfieldBitCountStep<4, uint32, P, vec, true, true> 34 | { 35 | GLM_FUNC_QUALIFIER static vec<4, uint32, P> call(vec<4, uint32, P> const & v, uint32 Mask, uint32 Shift) 36 | { 37 | __m128i const set0 = v.data; 38 | 39 | __m128i const set1 = _mm_set1_epi32(Mask); 40 | __m128i const and0 = _mm_and_si128(set0, set1); 41 | __m128i const sft0 = _mm_slli_epi32(set0, Shift); 42 | __m128i const and1 = _mm_and_si128(sft0, set1); 43 | __m128i const add0 = _mm_add_epi32(and0, and1); 44 | 45 | return add0; 46 | } 47 | }; 48 | }//namespace detail 49 | 50 | # if GLM_ARCH & GLM_ARCH_AVX_BIT 51 | template<> 52 | GLM_FUNC_QUALIFIER int bitCount(uint32 x) 53 | { 54 | return _mm_popcnt_u32(x); 55 | } 56 | 57 | # if(GLM_MODEL == GLM_MODEL_64) 58 | template<> 59 | GLM_FUNC_QUALIFIER int bitCount(uint64 x) 60 | { 61 | return static_cast(_mm_popcnt_u64(x)); 62 | } 63 | # endif//GLM_MODEL 64 | # endif//GLM_ARCH 65 | 66 | }//namespace glm 67 | 68 | #endif//GLM_ARCH & GLM_ARCH_SSE2_BIT 69 | -------------------------------------------------------------------------------- /src/brdf/glm/detail/func_packing_simd.inl: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/detail/func_packing_simd.inl 3 | 4 | namespace glm{ 5 | namespace detail 6 | { 7 | 8 | }//namespace detail 9 | }//namespace glm 10 | -------------------------------------------------------------------------------- /src/brdf/glm/detail/func_trigonometric_simd.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/brdf/glm/detail/func_trigonometric_simd.inl -------------------------------------------------------------------------------- /src/brdf/glm/detail/func_vector_relational_simd.inl: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/detail/func_vector_relational_simd.inl 3 | 4 | namespace glm{ 5 | namespace detail 6 | { 7 | 8 | }//namespace detail 9 | }//namespace glm 10 | -------------------------------------------------------------------------------- /src/brdf/glm/detail/precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/detail/precision.hpp 3 | 4 | #pragma once 5 | 6 | #include "setup.hpp" 7 | 8 | namespace glm 9 | { 10 | enum precision 11 | { 12 | packed_highp, 13 | packed_mediump, 14 | packed_lowp, 15 | 16 | # if GLM_HAS_ALIGNED_TYPE 17 | aligned_highp, 18 | aligned_mediump, 19 | aligned_lowp, 20 | aligned = aligned_highp, 21 | # endif 22 | 23 | highp = packed_highp, 24 | mediump = packed_mediump, 25 | lowp = packed_lowp, 26 | packed = packed_highp, 27 | 28 | # if GLM_HAS_ALIGNED_TYPE && defined(GLM_FORCE_ALIGNED) 29 | defaultp = aligned_highp 30 | # else 31 | defaultp = highp 32 | # endif 33 | }; 34 | 35 | template struct vec; 36 | template struct mat; 37 | 38 | namespace detail 39 | { 40 | template 41 | struct is_aligned 42 | { 43 | static const bool value = false; 44 | }; 45 | 46 | # if GLM_HAS_ALIGNED_TYPE 47 | template<> 48 | struct is_aligned 49 | { 50 | static const bool value = true; 51 | }; 52 | 53 | template<> 54 | struct is_aligned 55 | { 56 | static const bool value = true; 57 | }; 58 | 59 | template<> 60 | struct is_aligned 61 | { 62 | static const bool value = true; 63 | }; 64 | # endif 65 | }//namespace detail 66 | }//namespace glm 67 | -------------------------------------------------------------------------------- /src/brdf/glm/detail/type_half.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/detail/type_half.hpp 3 | 4 | #pragma once 5 | 6 | #include "setup.hpp" 7 | 8 | namespace glm{ 9 | namespace detail 10 | { 11 | typedef short hdata; 12 | 13 | GLM_FUNC_DECL float toFloat32(hdata value); 14 | GLM_FUNC_DECL hdata toFloat16(float const & value); 15 | 16 | }//namespace detail 17 | }//namespace glm 18 | 19 | #include "type_half.inl" 20 | -------------------------------------------------------------------------------- /src/brdf/glm/detail/type_mat.inl: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/detail/type_mat.inl 3 | 4 | -------------------------------------------------------------------------------- /src/brdf/glm/detail/type_mat4x4_simd.inl: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/detail/type_mat4x4_sse2.inl 3 | 4 | namespace glm 5 | { 6 | 7 | }//namespace glm 8 | -------------------------------------------------------------------------------- /src/brdf/glm/detail/type_vec.inl: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/detail/type_vec.inl 3 | -------------------------------------------------------------------------------- /src/brdf/glm/exponential.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/exponential.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/func_exponential.hpp" 7 | -------------------------------------------------------------------------------- /src/brdf/glm/geometric.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/geometric.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/func_geometric.hpp" 7 | -------------------------------------------------------------------------------- /src/brdf/glm/gtc/color_space.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtc_color_space 2 | /// @file glm/gtc/color_space.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtc_color_space (dependence) 6 | /// 7 | /// @defgroup gtc_color_space GLM_GTC_color_space 8 | /// @ingroup gtc 9 | /// 10 | /// @brief Allow to perform bit operations on integer values 11 | /// 12 | /// need to be included to use these functionalities. 13 | 14 | #pragma once 15 | 16 | // Dependencies 17 | #include "../detail/setup.hpp" 18 | #include "../detail/precision.hpp" 19 | #include "../exponential.hpp" 20 | #include "../vec3.hpp" 21 | #include "../vec4.hpp" 22 | #include 23 | 24 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 25 | # pragma message("GLM: GLM_GTC_color_space extension included") 26 | #endif 27 | 28 | namespace glm 29 | { 30 | /// @addtogroup gtc_color_space 31 | /// @{ 32 | 33 | /// Convert a linear color to sRGB color using a standard gamma correction. 34 | /// IEC 61966-2-1:1999 / Rec. 709 specification https://www.w3.org/Graphics/Color/srgb 35 | template class vecType> 36 | GLM_FUNC_DECL vecType convertLinearToSRGB(vecType const & ColorLinear); 37 | 38 | /// Convert a linear color to sRGB color using a custom gamma correction. 39 | /// IEC 61966-2-1:1999 / Rec. 709 specification https://www.w3.org/Graphics/Color/srgb 40 | template class vecType> 41 | GLM_FUNC_DECL vecType convertLinearToSRGB(vecType const & ColorLinear, T Gamma); 42 | 43 | /// Convert a sRGB color to linear color using a standard gamma correction. 44 | /// IEC 61966-2-1:1999 / Rec. 709 specification https://www.w3.org/Graphics/Color/srgb 45 | template class vecType> 46 | GLM_FUNC_DECL vecType convertSRGBToLinear(vecType const & ColorSRGB); 47 | 48 | /// Convert a sRGB color to linear color using a custom gamma correction. 49 | // IEC 61966-2-1:1999 / Rec. 709 specification https://www.w3.org/Graphics/Color/srgb 50 | template class vecType> 51 | GLM_FUNC_DECL vecType convertSRGBToLinear(vecType const & ColorSRGB, T Gamma); 52 | 53 | /// @} 54 | } //namespace glm 55 | 56 | #include "color_space.inl" 57 | -------------------------------------------------------------------------------- /src/brdf/glm/gtc/epsilon.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtc_epsilon 2 | /// @file glm/gtc/epsilon.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtc_quaternion (dependence) 6 | /// 7 | /// @defgroup gtc_epsilon GLM_GTC_epsilon 8 | /// @ingroup gtc 9 | /// 10 | /// @brief Comparison functions for a user defined epsilon values. 11 | /// 12 | /// need to be included to use these functionalities. 13 | 14 | #pragma once 15 | 16 | // Dependencies 17 | #include "../detail/setup.hpp" 18 | #include "../detail/precision.hpp" 19 | 20 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 21 | # pragma message("GLM: GLM_GTC_epsilon extension included") 22 | #endif 23 | 24 | namespace glm 25 | { 26 | /// @addtogroup gtc_epsilon 27 | /// @{ 28 | 29 | /// Returns the component-wise comparison of |x - y| < epsilon. 30 | /// True if this expression is satisfied. 31 | /// 32 | /// @see gtc_epsilon 33 | template class vecType> 34 | GLM_FUNC_DECL vecType epsilonEqual( 35 | vecType const& x, 36 | vecType const& y, 37 | T const & epsilon); 38 | 39 | /// Returns the component-wise comparison of |x - y| < epsilon. 40 | /// True if this expression is satisfied. 41 | /// 42 | /// @see gtc_epsilon 43 | template 44 | GLM_FUNC_DECL bool epsilonEqual( 45 | genType const & x, 46 | genType const & y, 47 | genType const & epsilon); 48 | 49 | /// Returns the component-wise comparison of |x - y| < epsilon. 50 | /// True if this expression is not satisfied. 51 | /// 52 | /// @see gtc_epsilon 53 | template 54 | GLM_FUNC_DECL typename genType::boolType epsilonNotEqual( 55 | genType const & x, 56 | genType const & y, 57 | typename genType::value_type const & epsilon); 58 | 59 | /// Returns the component-wise comparison of |x - y| >= epsilon. 60 | /// True if this expression is not satisfied. 61 | /// 62 | /// @see gtc_epsilon 63 | template 64 | GLM_FUNC_DECL bool epsilonNotEqual( 65 | genType const & x, 66 | genType const & y, 67 | genType const & epsilon); 68 | 69 | /// @} 70 | }//namespace glm 71 | 72 | #include "epsilon.inl" 73 | -------------------------------------------------------------------------------- /src/brdf/glm/gtc/functions.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtc_functions 2 | /// @file glm/gtc/functions.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtc_quaternion (dependence) 6 | /// 7 | /// @defgroup gtc_functions GLM_GTC_functions 8 | /// @ingroup gtc 9 | /// 10 | /// @brief List of useful common functions. 11 | /// 12 | /// need to be included to use these functionalities. 13 | 14 | #pragma once 15 | 16 | // Dependencies 17 | #include "../detail/setup.hpp" 18 | #include "../detail/precision.hpp" 19 | #include "../detail/type_vec2.hpp" 20 | 21 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 22 | # pragma message("GLM: GLM_GTC_functions extension included") 23 | #endif 24 | 25 | namespace glm 26 | { 27 | /// @addtogroup gtc_functions 28 | /// @{ 29 | 30 | /// 1D gauss function 31 | /// 32 | /// @see gtc_epsilon 33 | template 34 | GLM_FUNC_DECL T gauss( 35 | T x, 36 | T ExpectedValue, 37 | T StandardDeviation); 38 | 39 | /// 2D gauss function 40 | /// 41 | /// @see gtc_epsilon 42 | template 43 | GLM_FUNC_DECL T gauss( 44 | vec<2, T, P> const& Coord, 45 | vec<2, T, P> const& ExpectedValue, 46 | vec<2, T, P> const& StandardDeviation); 47 | 48 | /// @} 49 | }//namespace glm 50 | 51 | #include "functions.inl" 52 | 53 | -------------------------------------------------------------------------------- /src/brdf/glm/gtc/functions.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtc_functions 2 | /// @file glm/gtc/functions.inl 3 | 4 | #include "../detail/func_exponential.hpp" 5 | 6 | namespace glm 7 | { 8 | template 9 | GLM_FUNC_QUALIFIER T gauss 10 | ( 11 | T x, 12 | T ExpectedValue, 13 | T StandardDeviation 14 | ) 15 | { 16 | return exp(-((x - ExpectedValue) * (x - ExpectedValue)) / (static_cast(2) * StandardDeviation * StandardDeviation)) / (StandardDeviation * sqrt(static_cast(6.28318530717958647692528676655900576))); 17 | } 18 | 19 | template 20 | GLM_FUNC_QUALIFIER T gauss 21 | ( 22 | vec<2, T, P> const& Coord, 23 | vec<2, T, P> const& ExpectedValue, 24 | vec<2, T, P> const& StandardDeviation 25 | ) 26 | { 27 | vec<2, T, P> const Squared = ((Coord - ExpectedValue) * (Coord - ExpectedValue)) / (static_cast(2) * StandardDeviation * StandardDeviation); 28 | return exp(-(Squared.x + Squared.y)); 29 | } 30 | }//namespace glm 31 | 32 | -------------------------------------------------------------------------------- /src/brdf/glm/gtc/integer.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtc_integer 2 | /// @file glm/gtc/integer.inl 3 | 4 | namespace glm{ 5 | namespace detail 6 | { 7 | template class vecType, bool Aligned> 8 | struct compute_log2 9 | { 10 | GLM_FUNC_QUALIFIER static vecType call(vecType const& v) 11 | { 12 | //Equivalent to return findMSB(vec); but save one function call in ASM with VC 13 | //return findMSB(vec); 14 | return vecType(detail::compute_findMSB_vec::call(v)); 15 | } 16 | }; 17 | 18 | # if GLM_HAS_BITSCAN_WINDOWS 19 | template 20 | struct compute_log2<4, int, P, vec, false, Aligned> 21 | { 22 | GLM_FUNC_QUALIFIER static vec<4, int, P> call(vec<4, int, P> const& v) 23 | { 24 | vec<4, int, P> Result(glm::uninitialize); 25 | 26 | _BitScanReverse(reinterpret_cast(&Result.x), v.x); 27 | _BitScanReverse(reinterpret_cast(&Result.y), v.y); 28 | _BitScanReverse(reinterpret_cast(&Result.z), v.z); 29 | _BitScanReverse(reinterpret_cast(&Result.w), v.w); 30 | 31 | return Result; 32 | } 33 | }; 34 | # endif//GLM_HAS_BITSCAN_WINDOWS 35 | }//namespace detail 36 | template 37 | GLM_FUNC_QUALIFIER int iround(genType x) 38 | { 39 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'iround' only accept floating-point inputs"); 40 | assert(static_cast(0.0) <= x); 41 | 42 | return static_cast(x + static_cast(0.5)); 43 | } 44 | 45 | template class vecType> 46 | GLM_FUNC_QUALIFIER vecType iround(vecType const& x) 47 | { 48 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'iround' only accept floating-point inputs"); 49 | assert(all(lessThanEqual(vecType(0), x))); 50 | 51 | return vecType(x + static_cast(0.5)); 52 | } 53 | 54 | template 55 | GLM_FUNC_QUALIFIER uint uround(genType x) 56 | { 57 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'uround' only accept floating-point inputs"); 58 | assert(static_cast(0.0) <= x); 59 | 60 | return static_cast(x + static_cast(0.5)); 61 | } 62 | 63 | template class vecType> 64 | GLM_FUNC_QUALIFIER vecType uround(vecType const& x) 65 | { 66 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'uround' only accept floating-point inputs"); 67 | assert(all(lessThanEqual(vecType(0), x))); 68 | 69 | return vecType(x + static_cast(0.5)); 70 | } 71 | }//namespace glm 72 | -------------------------------------------------------------------------------- /src/brdf/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 | /// Defines functions to access rows or columns of a matrix easily. 10 | /// need to be included to use these functionalities. 11 | 12 | #pragma once 13 | 14 | // Dependency: 15 | #include "../detail/setup.hpp" 16 | 17 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 18 | # pragma message("GLM: GLM_GTC_matrix_access extension included") 19 | #endif 20 | 21 | namespace glm 22 | { 23 | /// @addtogroup gtc_matrix_access 24 | /// @{ 25 | 26 | /// Get a specific row of a matrix. 27 | /// @see gtc_matrix_access 28 | template 29 | GLM_FUNC_DECL typename genType::row_type row( 30 | genType const & m, 31 | length_t index); 32 | 33 | /// Set a specific row to a matrix. 34 | /// @see gtc_matrix_access 35 | template 36 | GLM_FUNC_DECL genType row( 37 | genType const & m, 38 | length_t index, 39 | typename genType::row_type const & x); 40 | 41 | /// Get a specific column of a matrix. 42 | /// @see gtc_matrix_access 43 | template 44 | GLM_FUNC_DECL typename genType::col_type column( 45 | genType const & m, 46 | length_t index); 47 | 48 | /// Set a specific column to a matrix. 49 | /// @see gtc_matrix_access 50 | template 51 | GLM_FUNC_DECL genType column( 52 | genType const & m, 53 | length_t index, 54 | typename genType::col_type const & x); 55 | 56 | /// @} 57 | }//namespace glm 58 | 59 | #include "matrix_access.inl" 60 | -------------------------------------------------------------------------------- /src/brdf/glm/gtc/matrix_access.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtc_matrix_access 2 | /// @file glm/gtc/matrix_access.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER genType row 8 | ( 9 | genType const & m, 10 | length_t index, 11 | typename genType::row_type const & x 12 | ) 13 | { 14 | assert(index >= 0 && index < m[0].length()); 15 | 16 | genType Result = m; 17 | for(length_t i = 0; i < m.length(); ++i) 18 | Result[i][index] = x[i]; 19 | return Result; 20 | } 21 | 22 | template 23 | GLM_FUNC_QUALIFIER typename genType::row_type row 24 | ( 25 | genType const & m, 26 | length_t index 27 | ) 28 | { 29 | assert(index >= 0 && index < m[0].length()); 30 | 31 | typename genType::row_type Result; 32 | for(length_t i = 0; i < m.length(); ++i) 33 | Result[i] = m[i][index]; 34 | return Result; 35 | } 36 | 37 | template 38 | GLM_FUNC_QUALIFIER genType column 39 | ( 40 | genType const & m, 41 | length_t index, 42 | typename genType::col_type const & x 43 | ) 44 | { 45 | assert(index >= 0 && index < m.length()); 46 | 47 | genType Result = m; 48 | Result[index] = x; 49 | return Result; 50 | } 51 | 52 | template 53 | GLM_FUNC_QUALIFIER typename genType::col_type column 54 | ( 55 | genType const & m, 56 | length_t index 57 | ) 58 | { 59 | assert(index >= 0 && index < m.length()); 60 | 61 | return m[index]; 62 | } 63 | }//namespace glm 64 | -------------------------------------------------------------------------------- /src/brdf/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 | /// Defines additional matrix inverting functions. 10 | /// need to be included to use these functionalities. 11 | 12 | #pragma once 13 | 14 | // Dependencies 15 | #include "../detail/setup.hpp" 16 | #include "../matrix.hpp" 17 | #include "../mat2x2.hpp" 18 | #include "../mat3x3.hpp" 19 | #include "../mat4x4.hpp" 20 | 21 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 22 | # pragma message("GLM: GLM_GTC_matrix_inverse extension included") 23 | #endif 24 | 25 | namespace glm 26 | { 27 | /// @addtogroup gtc_matrix_inverse 28 | /// @{ 29 | 30 | /// Fast matrix inverse for affine matrix. 31 | /// 32 | /// @param m Input matrix to invert. 33 | /// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-precision floating point value is highly innacurate. 34 | /// @see gtc_matrix_inverse 35 | template 36 | GLM_FUNC_DECL genType affineInverse(genType const & m); 37 | 38 | /// Compute the inverse transpose of a matrix. 39 | /// 40 | /// @param m Input matrix to invert transpose. 41 | /// @tparam genType Squared floating-point matrix: half, float or double. Inverse of matrix based of half-precision floating point value is highly innacurate. 42 | /// @see gtc_matrix_inverse 43 | template 44 | GLM_FUNC_DECL genType inverseTranspose(genType const & m); 45 | 46 | /// @} 47 | }//namespace glm 48 | 49 | #include "matrix_inverse.inl" 50 | -------------------------------------------------------------------------------- /src/brdf/glm/gtc/noise.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtc_noise 2 | /// @file glm/gtc/noise.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtc_noise GLM_GTC_noise 7 | /// @ingroup gtc 8 | /// 9 | /// Defines 2D, 3D and 4D procedural noise functions 10 | /// Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise": 11 | /// https://github.com/ashima/webgl-noise 12 | /// Following Stefan Gustavson's paper "Simplex noise demystified": 13 | /// http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf 14 | /// need to be included to use these functionalities. 15 | 16 | #pragma once 17 | 18 | // Dependencies 19 | #include "../detail/setup.hpp" 20 | #include "../detail/precision.hpp" 21 | #include "../detail/_noise.hpp" 22 | #include "../geometric.hpp" 23 | #include "../common.hpp" 24 | #include "../vector_relational.hpp" 25 | #include "../vec2.hpp" 26 | #include "../vec3.hpp" 27 | #include "../vec4.hpp" 28 | 29 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 30 | # pragma message("GLM: GLM_GTC_noise extension included") 31 | #endif 32 | 33 | namespace glm 34 | { 35 | /// @addtogroup gtc_noise 36 | /// @{ 37 | 38 | /// Classic perlin noise. 39 | /// @see gtc_noise 40 | template class vecType> 41 | GLM_FUNC_DECL T perlin( 42 | vecType const& p); 43 | 44 | /// Periodic perlin noise. 45 | /// @see gtc_noise 46 | template class vecType> 47 | GLM_FUNC_DECL T perlin( 48 | vecType const& p, 49 | vecType const& rep); 50 | 51 | /// Simplex noise. 52 | /// @see gtc_noise 53 | template class vecType> 54 | GLM_FUNC_DECL T simplex( 55 | vecType const& p); 56 | 57 | /// @} 58 | }//namespace glm 59 | 60 | #include "noise.inl" 61 | -------------------------------------------------------------------------------- /src/brdf/glm/gtc/type_precision.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtc_swizzle 2 | /// @file glm/gtc/swizzle.inl 3 | 4 | namespace glm 5 | { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/brdf/glm/gtc/ulp.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtc_ulp 2 | /// @file glm/gtc/ulp.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtc_ulp GLM_GTC_ulp 7 | /// @ingroup gtc 8 | /// 9 | /// @brief Allow the measurement of the accuracy of a function against a reference 10 | /// implementation. This extension works on floating-point data and provide results 11 | /// in ULP. 12 | /// need to be included to use these features. 13 | 14 | #pragma once 15 | 16 | // Dependencies 17 | #include "../detail/setup.hpp" 18 | #include "../detail/precision.hpp" 19 | #include "../detail/type_int.hpp" 20 | 21 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 22 | # pragma message("GLM: GLM_GTC_ulp extension included") 23 | #endif 24 | 25 | namespace glm 26 | { 27 | /// @addtogroup gtc_ulp 28 | /// @{ 29 | 30 | /// Return the next ULP value(s) after the input value(s). 31 | /// @see gtc_ulp 32 | template 33 | GLM_FUNC_DECL genType next_float(genType const & x); 34 | 35 | /// Return the previous ULP value(s) before the input value(s). 36 | /// @see gtc_ulp 37 | template 38 | GLM_FUNC_DECL genType prev_float(genType const & x); 39 | 40 | /// Return the value(s) ULP distance after the input value(s). 41 | /// @see gtc_ulp 42 | template 43 | GLM_FUNC_DECL genType next_float(genType const & x, uint const & Distance); 44 | 45 | /// Return the value(s) ULP distance before the input value(s). 46 | /// @see gtc_ulp 47 | template 48 | GLM_FUNC_DECL genType prev_float(genType const & x, uint const & Distance); 49 | 50 | /// Return the distance in the number of ULP between 2 scalars. 51 | /// @see gtc_ulp 52 | template 53 | GLM_FUNC_DECL uint float_distance(T const & x, T const & y); 54 | 55 | /// Return the distance in the number of ULP between 2 vectors. 56 | /// @see gtc_ulp 57 | template class vecType> 58 | GLM_FUNC_DECL vecType<2, uint> float_distance(vecType<2, T> const & x, vecType<2, T> const & y); 59 | 60 | /// @} 61 | }// namespace glm 62 | 63 | #include "ulp.inl" 64 | -------------------------------------------------------------------------------- /src/brdf/glm/gtc/vec1.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtc_vec1 2 | /// @file glm/gtc/vec1.inl 3 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Find the point on a straight line which is the closet of a point. 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #ifndef GLM_ENABLE_EXPERIMENTAL 19 | # error "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." 20 | #endif 21 | 22 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 23 | # pragma message("GLM: GLM_GTX_closest_point extension included") 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, P> closestPointOnLine( 35 | vec<3, T, P> const & point, 36 | vec<3, T, P> const & a, 37 | vec<3, T, P> const & b); 38 | 39 | /// 2d lines work as well 40 | template 41 | GLM_FUNC_DECL vec<2, T, P> closestPointOnLine( 42 | vec<2, T, P> const & point, 43 | vec<2, T, P> const & a, 44 | vec<2, T, P> const & b); 45 | 46 | /// @} 47 | }// namespace glm 48 | 49 | #include "closest_point.inl" 50 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/closest_point.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_closest_point 2 | /// @file glm/gtx/closest_point.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER vec<3, T, P> closestPointOnLine 8 | ( 9 | vec<3, T, P> const & point, 10 | vec<3, T, P> const & a, 11 | vec<3, T, P> const & b 12 | ) 13 | { 14 | T LineLength = distance(a, b); 15 | vec<3, T, P> Vector = point - a; 16 | vec<3, T, P> LineDirection = (b - a) / LineLength; 17 | 18 | // Project Vector to LineDirection to get the distance of point from a 19 | T Distance = dot(Vector, LineDirection); 20 | 21 | if(Distance <= T(0)) return a; 22 | if(Distance >= LineLength) return b; 23 | return a + LineDirection * Distance; 24 | } 25 | 26 | template 27 | GLM_FUNC_QUALIFIER vec<2, T, P> closestPointOnLine 28 | ( 29 | vec<2, T, P> const & point, 30 | vec<2, T, P> const & a, 31 | vec<2, T, P> const & b 32 | ) 33 | { 34 | T LineLength = distance(a, b); 35 | vec<2, T, P> Vector = point - a; 36 | vec<2, T, P> LineDirection = (b - a) / LineLength; 37 | 38 | // Project Vector to LineDirection to get the distance of point from a 39 | T Distance = dot(Vector, LineDirection); 40 | 41 | if(Distance <= T(0)) return a; 42 | if(Distance >= LineLength) return b; 43 | return a + LineDirection * Distance; 44 | } 45 | 46 | }//namespace glm 47 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/color_encoding.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_color_encoding 2 | /// @file glm/gtx/color_encoding.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtx_color_encoding (dependence) 6 | /// 7 | /// @defgroup gtx_color_encoding GLM_GTX_color_encoding 8 | /// @ingroup gtx 9 | /// 10 | /// @brief Allow to perform bit operations on integer values 11 | /// 12 | /// need to be included to use these functionalities. 13 | 14 | #pragma once 15 | 16 | // Dependencies 17 | #include "../detail/setup.hpp" 18 | #include "../detail/precision.hpp" 19 | #include "../vec3.hpp" 20 | #include 21 | 22 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 23 | # pragma message("GLM: GLM_GTC_color_encoding extension included") 24 | #endif 25 | 26 | namespace glm 27 | { 28 | /// @addtogroup gtx_color_encoding 29 | /// @{ 30 | 31 | /// Convert a linear sRGB color to D65 YUV. 32 | template 33 | GLM_FUNC_DECL vec<3, T, P> convertLinearSRGBToD65XYZ(vec<3, T, P> const& ColorLinearSRGB); 34 | 35 | /// Convert a linear sRGB color to D50 YUV. 36 | template 37 | GLM_FUNC_DECL vec<3, T, P> convertLinearSRGBToD50XYZ(vec<3, T, P> const& ColorLinearSRGB); 38 | 39 | /// Convert a D65 YUV color to linear sRGB. 40 | template 41 | GLM_FUNC_DECL vec<3, T, P> convertD65XYZToLinearSRGB(vec<3, T, P> const& ColorD65XYZ); 42 | 43 | /// Convert a D65 YUV color to D50 YUV. 44 | template 45 | GLM_FUNC_DECL vec<3, T, P> convertD65XYZToD50XYZ(vec<3, T, P> const& ColorD65XYZ); 46 | 47 | /// @} 48 | } //namespace glm 49 | 50 | #include "color_encoding.inl" 51 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/color_encoding.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_color_encoding 2 | /// @file glm/gtx/color_encoding.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER vec<3, T, P> convertLinearSRGBToD65XYZ(vec<3, T, P> const& ColorLinearSRGB) 8 | { 9 | vec<3, T, P> const M(0.490f, 0.17697f, 0.2f); 10 | vec<3, T, P> const N(0.31f, 0.8124f, 0.01063f); 11 | vec<3, T, P> const O(0.490f, 0.01f, 0.99f); 12 | 13 | return (M * ColorLinearSRGB + N * ColorLinearSRGB + O * ColorLinearSRGB) * static_cast(5.650675255693055f); 14 | } 15 | 16 | template 17 | GLM_FUNC_QUALIFIER vec<3, T, P> convertLinearSRGBToD50XYZ(vec<3, T, P> const& ColorLinearSRGB) 18 | { 19 | vec<3, T, P> const M(0.436030342570117f, 0.222438466210245f, 0.013897440074263f); 20 | vec<3, T, P> const N(0.385101860087134f, 0.716942745571917f, 0.097076381494207f); 21 | vec<3, T, P> const O(0.143067806654203f, 0.060618777416563f, 0.713926257896652f); 22 | 23 | return M * ColorLinearSRGB + N * ColorLinearSRGB + O * ColorLinearSRGB; 24 | } 25 | 26 | template 27 | GLM_FUNC_QUALIFIER vec<3, T, P> convertD65XYZToLinearSRGB(vec<3, T, P> const& ColorD65XYZ) 28 | { 29 | vec<3, T, P> const M(0.41847f, -0.091169f, 0.0009209f); 30 | vec<3, T, P> const N(-0.15866f, 0.25243f, 0.015708f); 31 | vec<3, T, P> const O(0.0009209f, -0.0025498f, 0.1786f); 32 | 33 | return M * ColorD65XYZ + N * ColorD65XYZ + O * ColorD65XYZ; 34 | } 35 | 36 | template 37 | GLM_FUNC_QUALIFIER vec<3, T, P> convertD65XYZToD50XYZ(vec<3, T, P> const& ColorD65XYZ) 38 | { 39 | vec<3, T, P> const M(+1.047844353856414f, +0.029549007606644f, -0.009250984365223f); 40 | vec<3, T, P> const N(+0.022898981050086f, +0.990508028941971f, +0.015072338237051f); 41 | vec<3, T, P> const O(-0.050206647741605f, -0.017074711360960f, +0.751717835079977f); 42 | 43 | return M * ColorD65XYZ + N * ColorD65XYZ + O * ColorD65XYZ; 44 | } 45 | 46 | }//namespace glm 47 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/color_space.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_color_space 2 | /// @file glm/gtx/color_space.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_color_space GLM_GTX_color_space 7 | /// @ingroup gtx 8 | /// 9 | /// @brief Related to RGB to HSV conversions and operations. 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #ifndef GLM_ENABLE_EXPERIMENTAL 19 | # error "GLM: GLM_GTX_color_space 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." 20 | #endif 21 | 22 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 23 | # pragma message("GLM: GLM_GTX_color_space extension included") 24 | #endif 25 | 26 | namespace glm 27 | { 28 | /// @addtogroup gtx_color_space 29 | /// @{ 30 | 31 | /// Converts a color from HSV color space to its color in RGB color space. 32 | /// @see gtx_color_space 33 | template 34 | GLM_FUNC_DECL vec<3, T, P> rgbColor( 35 | vec<3, T, P> const & hsvValue); 36 | 37 | /// Converts a color from RGB color space to its color in HSV color space. 38 | /// @see gtx_color_space 39 | template 40 | GLM_FUNC_DECL vec<3, T, P> hsvColor( 41 | vec<3, T, P> const & rgbValue); 42 | 43 | /// Build a saturation matrix. 44 | /// @see gtx_color_space 45 | template 46 | GLM_FUNC_DECL mat<4, 4, T, defaultp> saturation( 47 | T const s); 48 | 49 | /// Modify the saturation of a color. 50 | /// @see gtx_color_space 51 | template 52 | GLM_FUNC_DECL vec<3, T, P> saturation( 53 | T const s, 54 | vec<3, T, P> const & color); 55 | 56 | /// Modify the saturation of a color. 57 | /// @see gtx_color_space 58 | template 59 | GLM_FUNC_DECL vec<4, T, P> saturation( 60 | T const s, 61 | vec<4, T, P> const & color); 62 | 63 | /// Compute color luminosity associating ratios (0.33, 0.59, 0.11) to RGB canals. 64 | /// @see gtx_color_space 65 | template 66 | GLM_FUNC_DECL T luminosity( 67 | vec<3, T, P> const & color); 68 | 69 | /// @} 70 | }//namespace glm 71 | 72 | #include "color_space.inl" 73 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/color_space_YCoCg.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_color_space_YCoCg 2 | /// @file glm/gtx/color_space_YCoCg.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_color_space_YCoCg GLM_GTX_color_space_YCoCg 7 | /// @ingroup gtx 8 | /// 9 | /// @brief RGB to YCoCg conversions and operations 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #ifndef GLM_ENABLE_EXPERIMENTAL 19 | # error "GLM: GLM_GTX_color_space_YCoCg 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." 20 | #endif 21 | 22 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 23 | # pragma message("GLM: GLM_GTX_color_space_YCoCg extension included") 24 | #endif 25 | 26 | namespace glm 27 | { 28 | /// @addtogroup gtx_color_space_YCoCg 29 | /// @{ 30 | 31 | /// Convert a color from RGB color space to YCoCg color space. 32 | /// @see gtx_color_space_YCoCg 33 | template 34 | GLM_FUNC_DECL vec<3, T, P> rgb2YCoCg( 35 | vec<3, T, P> const & rgbColor); 36 | 37 | /// Convert a color from YCoCg color space to RGB color space. 38 | /// @see gtx_color_space_YCoCg 39 | template 40 | GLM_FUNC_DECL vec<3, T, P> YCoCg2rgb( 41 | vec<3, T, P> const & YCoCgColor); 42 | 43 | /// Convert a color from RGB color space to YCoCgR color space. 44 | /// @see "YCoCg-R: A Color Space with RGB Reversibility and Low Dynamic Range" 45 | /// @see gtx_color_space_YCoCg 46 | template 47 | GLM_FUNC_DECL vec<3, T, P> rgb2YCoCgR( 48 | vec<3, T, P> const & rgbColor); 49 | 50 | /// Convert a color from YCoCgR color space to RGB color space. 51 | /// @see "YCoCg-R: A Color Space with RGB Reversibility and Low Dynamic Range" 52 | /// @see gtx_color_space_YCoCg 53 | template 54 | GLM_FUNC_DECL vec<3, T, P> YCoCgR2rgb( 55 | vec<3, T, P> const & YCoCgColor); 56 | 57 | /// @} 58 | }//namespace glm 59 | 60 | #include "color_space_YCoCg.inl" 61 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/common.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_common 2 | /// @file glm/gtx/common.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_common GLM_GTX_common 7 | /// @ingroup gtx 8 | /// 9 | /// @brief Provide functions to increase the compatibility with Cg and HLSL languages 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependencies: 16 | #include "../vec2.hpp" 17 | #include "../vec3.hpp" 18 | #include "../vec4.hpp" 19 | #include "../gtc/vec1.hpp" 20 | 21 | #ifndef GLM_ENABLE_EXPERIMENTAL 22 | # error "GLM: GLM_GTX_common 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 | #endif 24 | 25 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 26 | # pragma message("GLM: GLM_GTX_common extension included") 27 | #endif 28 | 29 | namespace glm 30 | { 31 | /// @addtogroup gtx_common 32 | /// @{ 33 | 34 | /// Returns true if x is a denormalized number 35 | /// Numbers whose absolute value is too small to be represented in the normal format are represented in an alternate, denormalized format. 36 | /// This format is less precise but can represent values closer to zero. 37 | /// 38 | /// @tparam genType Floating-point scalar or vector types. 39 | /// 40 | /// @see GLSL isnan man page 41 | /// @see GLSL 4.20.8 specification, section 8.3 Common Functions 42 | template 43 | GLM_FUNC_DECL typename genType::bool_type isdenormal(genType const & x); 44 | 45 | /// Similar to 'mod' but with a different rounding and integer support. 46 | /// Returns 'x - y * trunc(x/y)' instead of 'x - y * floor(x/y)' 47 | /// 48 | /// @see GLSL mod vs HLSL fmod 49 | /// @see GLSL mod man page 50 | template class vecType> 51 | GLM_FUNC_DECL vecType fmod(vecType const & v); 52 | 53 | /// @} 54 | }//namespace glm 55 | 56 | #include "common.inl" 57 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/compatibility.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_compatibility 2 | /// @file glm/gtx/compatibility.inl 3 | 4 | #include 5 | 6 | namespace glm 7 | { 8 | // isfinite 9 | template 10 | GLM_FUNC_QUALIFIER bool isfinite( 11 | genType const & x) 12 | { 13 | # if GLM_HAS_CXX11_STL 14 | return std::isfinite(x) != 0; 15 | # elif GLM_COMPILER & GLM_COMPILER_VC 16 | return _finite(x); 17 | # elif GLM_COMPILER & GLM_COMPILER_GCC && GLM_PLATFORM & GLM_PLATFORM_ANDROID 18 | return _isfinite(x) != 0; 19 | # else 20 | if (std::numeric_limits::is_integer || std::denorm_absent == std::numeric_limits::has_denorm) 21 | return std::numeric_limits::min() <= x && std::numeric_limits::max() >= x; 22 | else 23 | return -std::numeric_limits::max() <= x && std::numeric_limits::max() >= x; 24 | # endif 25 | } 26 | 27 | template 28 | GLM_FUNC_QUALIFIER vec<1, bool, P> isfinite( 29 | vec<1, T, P> const & x) 30 | { 31 | return vec<1, bool, P>( 32 | isfinite(x.x)); 33 | } 34 | 35 | template 36 | GLM_FUNC_QUALIFIER vec<2, bool, P> isfinite( 37 | vec<2, T, P> const & x) 38 | { 39 | return vec<2, bool, P>( 40 | isfinite(x.x), 41 | isfinite(x.y)); 42 | } 43 | 44 | template 45 | GLM_FUNC_QUALIFIER vec<3, bool, P> isfinite( 46 | vec<3, T, P> const & x) 47 | { 48 | return vec<3, bool, P>( 49 | isfinite(x.x), 50 | isfinite(x.y), 51 | isfinite(x.z)); 52 | } 53 | 54 | template 55 | GLM_FUNC_QUALIFIER vec<4, bool, P> isfinite( 56 | vec<4, T, P> const & x) 57 | { 58 | return vec<4, bool, P>( 59 | isfinite(x.x), 60 | isfinite(x.y), 61 | isfinite(x.z), 62 | isfinite(x.w)); 63 | } 64 | 65 | }//namespace glm 66 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/component_wise.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_component_wise 2 | /// @file glm/gtx/component_wise.hpp 3 | /// @date 2007-05-21 / 2011-06-07 4 | /// @author Christophe Riccio 5 | /// 6 | /// @see core (dependence) 7 | /// 8 | /// @defgroup gtx_component_wise GLM_GTX_component_wise 9 | /// @ingroup gtx 10 | /// 11 | /// @brief Operations between components of a type 12 | /// 13 | /// need to be included to use these functionalities. 14 | 15 | #pragma once 16 | 17 | // Dependencies 18 | #include "../detail/setup.hpp" 19 | #include "../detail/precision.hpp" 20 | 21 | #ifndef GLM_ENABLE_EXPERIMENTAL 22 | # error "GLM: GLM_GTX_component_wise 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 | #endif 24 | 25 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 26 | # pragma message("GLM: GLM_GTX_component_wise extension included") 27 | #endif 28 | 29 | namespace glm 30 | { 31 | /// @addtogroup gtx_component_wise 32 | /// @{ 33 | 34 | /// Convert an integer vector to a normalized float vector. 35 | /// If the parameter value type is already a floating precision type, the value is passed through. 36 | /// @see gtx_component_wise 37 | template class vecType> 38 | GLM_FUNC_DECL vecType compNormalize(vecType const & v); 39 | 40 | /// Convert a normalized float vector to an integer vector. 41 | /// If the parameter value type is already a floating precision type, the value is passed through. 42 | /// @see gtx_component_wise 43 | template class vecType> 44 | GLM_FUNC_DECL vecType compScale(vecType const & v); 45 | 46 | /// Add all vector components together. 47 | /// @see gtx_component_wise 48 | template 49 | GLM_FUNC_DECL typename genType::value_type compAdd(genType const & v); 50 | 51 | /// Multiply all vector components together. 52 | /// @see gtx_component_wise 53 | template 54 | GLM_FUNC_DECL typename genType::value_type compMul(genType const & v); 55 | 56 | /// Find the minimum value between single vector components. 57 | /// @see gtx_component_wise 58 | template 59 | GLM_FUNC_DECL typename genType::value_type compMin(genType const & v); 60 | 61 | /// Find the maximum value between single vector components. 62 | /// @see gtx_component_wise 63 | template 64 | GLM_FUNC_DECL typename genType::value_type compMax(genType const & v); 65 | 66 | /// @} 67 | }//namespace glm 68 | 69 | #include "component_wise.inl" 70 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Extend a position from a source to a position at a defined length. 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #ifndef GLM_ENABLE_EXPERIMENTAL 19 | # error "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." 20 | #endif 21 | 22 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 23 | # pragma message("GLM: GLM_GTX_extend extension included") 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 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/extend.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_extend 2 | /// @file glm/gtx/extend.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER genType extend 8 | ( 9 | genType const & Origin, 10 | genType const & Source, 11 | genType const & Distance 12 | ) 13 | { 14 | return Origin + (Source - Origin) * Distance; 15 | } 16 | 17 | template 18 | GLM_FUNC_QUALIFIER vec<2, T, P> extend 19 | ( 20 | vec<2, T, P> const & Origin, 21 | vec<2, T, P> const & Source, 22 | T const & Distance 23 | ) 24 | { 25 | return Origin + (Source - Origin) * Distance; 26 | } 27 | 28 | template 29 | GLM_FUNC_QUALIFIER vec<3, T, P> extend 30 | ( 31 | vec<3, T, P> const & Origin, 32 | vec<3, T, P> const & Source, 33 | T const & Distance 34 | ) 35 | { 36 | return Origin + (Source - Origin) * Distance; 37 | } 38 | 39 | template 40 | GLM_FUNC_QUALIFIER vec<4, T, P> extend 41 | ( 42 | vec<4, T, P> const & Origin, 43 | vec<4, T, P> const & Source, 44 | T const & Distance 45 | ) 46 | { 47 | return Origin + (Source - Origin) * Distance; 48 | } 49 | }//namespace glm 50 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/fast_trigonometry.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_fast_trigonometry 2 | /// @file glm/gtx/fast_trigonometry.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_fast_trigonometry GLM_GTX_fast_trigonometry 7 | /// @ingroup gtx 8 | /// 9 | /// @brief Fast but less accurate implementations of trigonometric functions. 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../gtc/constants.hpp" 17 | 18 | #ifndef GLM_ENABLE_EXPERIMENTAL 19 | # error "GLM: GLM_GTX_fast_trigonometry 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." 20 | #endif 21 | 22 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 23 | # pragma message("GLM: GLM_GTX_fast_trigonometry extension included") 24 | #endif 25 | 26 | namespace glm 27 | { 28 | /// @addtogroup gtx_fast_trigonometry 29 | /// @{ 30 | 31 | /// Wrap an angle to [0 2pi[ 32 | /// From GLM_GTX_fast_trigonometry extension. 33 | template 34 | GLM_FUNC_DECL T wrapAngle(T angle); 35 | 36 | /// Faster than the common sin function but less accurate. 37 | /// From GLM_GTX_fast_trigonometry extension. 38 | template 39 | GLM_FUNC_DECL T fastSin(T angle); 40 | 41 | /// Faster than the common cos function but less accurate. 42 | /// From GLM_GTX_fast_trigonometry extension. 43 | template 44 | GLM_FUNC_DECL T fastCos(T angle); 45 | 46 | /// Faster than the common tan function but less accurate. 47 | /// Defined between -2pi and 2pi. 48 | /// From GLM_GTX_fast_trigonometry extension. 49 | template 50 | GLM_FUNC_DECL T fastTan(T angle); 51 | 52 | /// Faster than the common asin function but less accurate. 53 | /// Defined between -2pi and 2pi. 54 | /// From GLM_GTX_fast_trigonometry extension. 55 | template 56 | GLM_FUNC_DECL T fastAsin(T angle); 57 | 58 | /// Faster than the common acos function but less accurate. 59 | /// Defined between -2pi and 2pi. 60 | /// From GLM_GTX_fast_trigonometry extension. 61 | template 62 | GLM_FUNC_DECL T fastAcos(T angle); 63 | 64 | /// Faster than the common atan function but less accurate. 65 | /// Defined between -2pi and 2pi. 66 | /// From GLM_GTX_fast_trigonometry extension. 67 | template 68 | GLM_FUNC_DECL T fastAtan(T y, T x); 69 | 70 | /// Faster than the common atan function but less accurate. 71 | /// Defined between -2pi and 2pi. 72 | /// From GLM_GTX_fast_trigonometry extension. 73 | template 74 | GLM_FUNC_DECL T fastAtan(T angle); 75 | 76 | /// @} 77 | }//namespace glm 78 | 79 | #include "fast_trigonometry.inl" 80 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/float_notmalize.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_float_normalize 2 | /// @file glm/gtx/float_normalize.inl 3 | 4 | #include 5 | 6 | namespace glm 7 | { 8 | template class vecType> 9 | GLM_FUNC_QUALIFIER vecType floatNormalize(vecType const & v) 10 | { 11 | return vecType(v) / static_cast(std::numeric_limits::max()); 12 | } 13 | 14 | }//namespace glm 15 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Functions that return the color of procedural gradient for specific coordinates. 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | #include "../gtx/optimum_pow.hpp" 18 | 19 | #ifndef GLM_ENABLE_EXPERIMENTAL 20 | # error "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." 21 | #endif 22 | 23 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 24 | # pragma message("GLM: GLM_GTX_gradient_paint extension included") 25 | #endif 26 | 27 | namespace glm 28 | { 29 | /// @addtogroup gtx_gradient_paint 30 | /// @{ 31 | 32 | /// Return a color from a radial gradient. 33 | /// @see - gtx_gradient_paint 34 | template 35 | GLM_FUNC_DECL T radialGradient( 36 | vec<2, T, P> const & Center, 37 | T const & Radius, 38 | vec<2, T, P> const & Focal, 39 | vec<2, T, P> const & Position); 40 | 41 | /// Return a color from a linear gradient. 42 | /// @see - gtx_gradient_paint 43 | template 44 | GLM_FUNC_DECL T linearGradient( 45 | vec<2, T, P> const & Point0, 46 | vec<2, T, P> const & Point1, 47 | vec<2, T, P> const & Position); 48 | 49 | /// @} 50 | }// namespace glm 51 | 52 | #include "gradient_paint.inl" 53 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/gradient_paint.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_gradient_paint 2 | /// @file glm/gtx/gradient_paint.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER T radialGradient 8 | ( 9 | vec<2, T, P> const & Center, 10 | T const & Radius, 11 | vec<2, T, P> const & Focal, 12 | vec<2, T, P> const & Position 13 | ) 14 | { 15 | vec<2, T, P> F = Focal - Center; 16 | vec<2, T, P> D = Position - Focal; 17 | T Radius2 = pow2(Radius); 18 | T Fx2 = pow2(F.x); 19 | T Fy2 = pow2(F.y); 20 | 21 | 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)); 22 | T Denominator = Radius2 - (Fx2 + Fy2); 23 | return Numerator / Denominator; 24 | } 25 | 26 | template 27 | GLM_FUNC_QUALIFIER T linearGradient 28 | ( 29 | vec<2, T, P> const & Point0, 30 | vec<2, T, P> const & Point1, 31 | vec<2, T, P> const & Position 32 | ) 33 | { 34 | vec<2, T, P> Dist = Point1 - Point0; 35 | return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist); 36 | } 37 | }//namespace glm 38 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/handed_coordinate_space.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_handed_coordinate_space 2 | /// @file glm/gtx/handed_coordinate_space.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_handed_coordinate_space GLM_GTX_handed_coordinate_space 7 | /// @ingroup gtx 8 | /// 9 | /// @brief To know if a set of three basis vectors defines a right or left-handed coordinate system. 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #ifndef GLM_ENABLE_EXPERIMENTAL 19 | # error "GLM: GLM_GTX_handed_coordinate_space 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." 20 | #endif 21 | 22 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 23 | # pragma message("GLM: GLM_GTX_handed_coordinate_space extension included") 24 | #endif 25 | 26 | namespace glm 27 | { 28 | /// @addtogroup gtx_handed_coordinate_space 29 | /// @{ 30 | 31 | //! Return if a trihedron right handed or not. 32 | //! From GLM_GTX_handed_coordinate_space extension. 33 | template 34 | GLM_FUNC_DECL bool rightHanded( 35 | vec<3, T, P> const & tangent, 36 | vec<3, T, P> const & binormal, 37 | vec<3, T, P> const & normal); 38 | 39 | //! Return if a trihedron left handed or not. 40 | //! From GLM_GTX_handed_coordinate_space extension. 41 | template 42 | GLM_FUNC_DECL bool leftHanded( 43 | vec<3, T, P> const & tangent, 44 | vec<3, T, P> const & binormal, 45 | vec<3, T, P> const & normal); 46 | 47 | /// @} 48 | }// namespace glm 49 | 50 | #include "handed_coordinate_space.inl" 51 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/handed_coordinate_space.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_handed_coordinate_space 2 | /// @file glm/gtx/handed_coordinate_space.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER bool rightHanded 8 | ( 9 | vec<3, T, P> const & tangent, 10 | vec<3, T, P> const & binormal, 11 | vec<3, T, P> const & normal 12 | ) 13 | { 14 | return dot(cross(normal, tangent), binormal) > T(0); 15 | } 16 | 17 | template 18 | GLM_FUNC_QUALIFIER bool leftHanded 19 | ( 20 | vec<3, T, P> const & tangent, 21 | vec<3, T, P> const & binormal, 22 | vec<3, T, P> const & normal 23 | ) 24 | { 25 | return dot(cross(normal, tangent), binormal) < T(0); 26 | } 27 | }//namespace glm 28 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/integer.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_integer 2 | /// @file glm/gtx/integer.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_integer GLM_GTX_integer 7 | /// @ingroup gtx 8 | /// 9 | /// @brief Add support for integer for core functions 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | #include "../gtc/integer.hpp" 18 | 19 | #ifndef GLM_ENABLE_EXPERIMENTAL 20 | # error "GLM: GLM_GTX_integer 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 | #endif 22 | 23 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 24 | # pragma message("GLM: GLM_GTX_integer extension included") 25 | #endif 26 | 27 | namespace glm 28 | { 29 | /// @addtogroup gtx_integer 30 | /// @{ 31 | 32 | //! Returns x raised to the y power. 33 | //! From GLM_GTX_integer extension. 34 | GLM_FUNC_DECL int pow(int x, int y); 35 | 36 | //! Returns the positive square root of x. 37 | //! From GLM_GTX_integer extension. 38 | GLM_FUNC_DECL int sqrt(int x); 39 | 40 | //! Returns the floor log2 of x. 41 | //! From GLM_GTX_integer extension. 42 | GLM_FUNC_DECL unsigned int floor_log2(unsigned int x); 43 | 44 | //! Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. 45 | //! From GLM_GTX_integer extension. 46 | GLM_FUNC_DECL int mod(int x, int y); 47 | 48 | //! Return the factorial value of a number (!12 max, integer only) 49 | //! From GLM_GTX_integer extension. 50 | template 51 | GLM_FUNC_DECL genType factorial(genType const & x); 52 | 53 | //! 32bit signed integer. 54 | //! From GLM_GTX_integer extension. 55 | typedef signed int sint; 56 | 57 | //! Returns x raised to the y power. 58 | //! From GLM_GTX_integer extension. 59 | GLM_FUNC_DECL uint pow(uint x, uint y); 60 | 61 | //! Returns the positive square root of x. 62 | //! From GLM_GTX_integer extension. 63 | GLM_FUNC_DECL uint sqrt(uint x); 64 | 65 | //! Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. 66 | //! From GLM_GTX_integer extension. 67 | GLM_FUNC_DECL uint mod(uint x, uint y); 68 | 69 | //! Returns the number of leading zeros. 70 | //! From GLM_GTX_integer extension. 71 | GLM_FUNC_DECL uint nlz(uint x); 72 | 73 | /// @} 74 | }//namespace glm 75 | 76 | #include "integer.inl" 77 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/intersect.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/brdf/glm/gtx/intersect.hpp -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Logarithm for any base. base can be a vector or a scalar. 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #ifndef GLM_ENABLE_EXPERIMENTAL 19 | # error "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." 20 | #endif 21 | 22 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 23 | # pragma message("GLM: GLM_GTX_log_base extension included") 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 class vecType> 41 | GLM_FUNC_DECL vecType sign( 42 | vecType const& x, 43 | vecType const& base); 44 | 45 | /// @} 46 | }//namespace glm 47 | 48 | #include "log_base.inl" 49 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/log_base.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_log_base 2 | /// @file glm/gtx/log_base.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER genType log(genType const & x, genType const & base) 8 | { 9 | assert(x != genType(0)); 10 | return glm::log(x) / glm::log(base); 11 | } 12 | 13 | template class vecType> 14 | GLM_FUNC_QUALIFIER vecType log(vecType const & x, vecType const & base) 15 | { 16 | return glm::log(x) / glm::log(base); 17 | } 18 | }//namespace glm 19 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Build cross product matrices 11 | /// 12 | /// need to be included to use these functionalities. 13 | 14 | #pragma once 15 | 16 | // Dependency: 17 | #include "../glm.hpp" 18 | 19 | #ifndef GLM_ENABLE_EXPERIMENTAL 20 | # error "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." 21 | #endif 22 | 23 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 24 | # pragma message("GLM: GLM_GTX_matrix_cross_product extension included") 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, P> matrixCross3( 36 | vec<3, T, P> 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, P> matrixCross4( 42 | vec<3, T, P> const & x); 43 | 44 | /// @} 45 | }//namespace glm 46 | 47 | #include "matrix_cross_product.inl" 48 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/matrix_cross_product.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_matrix_cross_product 2 | /// @file glm/gtx/matrix_cross_product.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER mat<3, 3, T, P> matrixCross3 8 | ( 9 | vec<3, T, P> const & x 10 | ) 11 | { 12 | mat<3, 3, T, P> Result(T(0)); 13 | Result[0][1] = x.z; 14 | Result[1][0] = -x.z; 15 | Result[0][2] = -x.y; 16 | Result[2][0] = x.y; 17 | Result[1][2] = x.x; 18 | Result[2][1] = -x.x; 19 | return Result; 20 | } 21 | 22 | template 23 | GLM_FUNC_QUALIFIER mat<4, 4, T, P> matrixCross4 24 | ( 25 | vec<3, T, P> const & x 26 | ) 27 | { 28 | mat<4, 4, T, P> Result(T(0)); 29 | Result[0][1] = x.z; 30 | Result[1][0] = -x.z; 31 | Result[0][2] = -x.y; 32 | Result[2][0] = x.y; 33 | Result[1][2] = x.x; 34 | Result[2][1] = -x.x; 35 | return Result; 36 | } 37 | 38 | }//namespace glm 39 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Decomposes a model matrix to translations, rotation and scale components 10 | /// 11 | /// need to be included to use these functionalities. 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 | #ifndef GLM_ENABLE_EXPERIMENTAL 24 | # error "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." 25 | #endif 26 | 27 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 28 | # pragma message("GLM: GLM_GTX_matrix_decompose extension included") 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, P> const& modelMatrix, 41 | vec<3, T, P> & scale, tquat & orientation, vec<3, T, P> & translation, vec<3, T, P> & skew, vec<4, T, P> & perspective); 42 | 43 | /// @} 44 | }//namespace glm 45 | 46 | #include "matrix_decompose.inl" 47 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/matrix_interpolation.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_matrix_interpolation 2 | /// @file glm/gtx/matrix_interpolation.hpp 3 | /// @author Ghenadii Ursachi (the.asteroth@gmail.com) 4 | /// 5 | /// @see core (dependence) 6 | /// 7 | /// @defgroup gtx_matrix_interpolation GLM_GTX_matrix_interpolation 8 | /// @ingroup gtx 9 | /// 10 | /// @brief Allows to directly interpolate two exiciting matrices. 11 | /// 12 | /// need to be included to use these functionalities. 13 | 14 | #pragma once 15 | 16 | // Dependency: 17 | #include "../glm.hpp" 18 | 19 | #ifndef GLM_ENABLE_EXPERIMENTAL 20 | # error "GLM: GLM_GTX_matrix_interpolation 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 | #endif 22 | 23 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 24 | # pragma message("GLM: GLM_GTX_matrix_interpolation extension included") 25 | #endif 26 | 27 | namespace glm 28 | { 29 | /// @addtogroup gtx_matrix_interpolation 30 | /// @{ 31 | 32 | /// Get the axis and angle of the rotation from a matrix. 33 | /// From GLM_GTX_matrix_interpolation extension. 34 | template 35 | GLM_FUNC_DECL void axisAngle( 36 | mat<4, 4, T, P> const& mat, 37 | vec<3, T, P> & axis, 38 | T & angle); 39 | 40 | /// Build a matrix from axis and angle. 41 | /// From GLM_GTX_matrix_interpolation extension. 42 | template 43 | GLM_FUNC_DECL mat<4, 4, T, P> axisAngleMatrix( 44 | vec<3, T, P> const & axis, 45 | T const angle); 46 | 47 | /// Extracts the rotation part of a matrix. 48 | /// From GLM_GTX_matrix_interpolation extension. 49 | template 50 | GLM_FUNC_DECL mat<4, 4, T, P> extractMatrixRotation( 51 | mat<4, 4, T, P> const& mat); 52 | 53 | /// Build a interpolation of 4 * 4 matrixes. 54 | /// From GLM_GTX_matrix_interpolation extension. 55 | /// Warning! works only with rotation and/or translation matrixes, scale will generate unexpected results. 56 | template 57 | GLM_FUNC_DECL mat<4, 4, T, P> interpolate( 58 | mat<4, 4, T, P> const& m1, 59 | mat<4, 4, T, P> const& m2, 60 | T const delta); 61 | 62 | /// @} 63 | }//namespace glm 64 | 65 | #include "matrix_interpolation.inl" 66 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/matrix_transform_2d.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_matrix_transform_2d 2 | /// @file glm/gtc/matrix_transform_2d.inl 3 | /// @author Miguel Ángel Pérez Martínez 4 | 5 | #include "../trigonometric.hpp" 6 | 7 | namespace glm 8 | { 9 | 10 | template 11 | GLM_FUNC_QUALIFIER mat<3, 3, T, P> translate( 12 | mat<3, 3, T, P> const& m, 13 | vec<2, T, P> const & v) 14 | { 15 | mat<3, 3, T, P> Result(m); 16 | Result[2] = m[0] * v[0] + m[1] * v[1] + m[2]; 17 | return Result; 18 | } 19 | 20 | 21 | template 22 | GLM_FUNC_QUALIFIER mat<3, 3, T, P> rotate( 23 | mat<3, 3, T, P> const& m, 24 | T angle) 25 | { 26 | T const a = angle; 27 | T const c = cos(a); 28 | T const s = sin(a); 29 | 30 | mat<3, 3, T, P> Result(uninitialize); 31 | Result[0] = m[0] * c + m[1] * s; 32 | Result[1] = m[0] * -s + m[1] * c; 33 | Result[2] = m[2]; 34 | return Result; 35 | } 36 | 37 | template 38 | GLM_FUNC_QUALIFIER mat<3, 3, T, P> scale( 39 | mat<3, 3, T, P> const& m, 40 | vec<2, T, P> const & v) 41 | { 42 | mat<3, 3, T, P> Result(uninitialize); 43 | Result[0] = m[0] * v[0]; 44 | Result[1] = m[1] * v[1]; 45 | Result[2] = m[2]; 46 | return Result; 47 | } 48 | 49 | template 50 | GLM_FUNC_QUALIFIER mat<3, 3, T, P> shearX( 51 | mat<3, 3, T, P> const& m, 52 | T y) 53 | { 54 | mat<3, 3, T, P> Result(1); 55 | Result[0][1] = y; 56 | return m * Result; 57 | } 58 | 59 | template 60 | GLM_FUNC_QUALIFIER mat<3, 3, T, P> shearY( 61 | mat<3, 3, T, P> const& m, 62 | T x) 63 | { 64 | mat<3, 3, T, P> Result(1); 65 | Result[1][0] = x; 66 | return m * Result; 67 | } 68 | 69 | }//namespace glm 70 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Mixed product of 3 vectors. 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #ifndef GLM_ENABLE_EXPERIMENTAL 19 | # error "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." 20 | #endif 21 | 22 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 23 | # pragma message("GLM: GLM_GTX_mixed_product extension included") 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, P> const & v1, 35 | vec<3, T, P> const & v2, 36 | vec<3, T, P> const & v3); 37 | 38 | /// @} 39 | }// namespace glm 40 | 41 | #include "mixed_product.inl" 42 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/mixed_product.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_mixed_product 2 | /// @file glm/gtx/mixed_product.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER T mixedProduct 8 | ( 9 | vec<3, T, P> const & v1, 10 | vec<3, T, P> const & v2, 11 | vec<3, T, P> const & v3 12 | ) 13 | { 14 | return dot(cross(v1, v2), v3); 15 | } 16 | }//namespace glm 17 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/norm.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_norm 2 | /// @file glm/gtx/norm.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtx_quaternion (dependence) 6 | /// 7 | /// @defgroup gtx_norm GLM_GTX_norm 8 | /// @ingroup gtx 9 | /// 10 | /// @brief Various ways to compute vector norms. 11 | /// 12 | /// need to be included to use these functionalities. 13 | 14 | #pragma once 15 | 16 | // Dependency: 17 | #include "../detail/func_geometric.hpp" 18 | #include "../gtx/quaternion.hpp" 19 | 20 | #ifndef GLM_ENABLE_EXPERIMENTAL 21 | # error "GLM: GLM_GTX_norm 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 | #endif 23 | 24 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 25 | # pragma message("GLM: GLM_GTX_norm extension included") 26 | #endif 27 | 28 | namespace glm 29 | { 30 | /// @addtogroup gtx_norm 31 | /// @{ 32 | 33 | /// Returns the squared length of x. 34 | /// From GLM_GTX_norm extension. 35 | template class vecType> 36 | GLM_FUNC_DECL T length2( 37 | vecType const& x); 38 | 39 | /// Returns the squared distance between p0 and p1, i.e., length2(p0 - p1). 40 | /// From GLM_GTX_norm extension. 41 | template class vecType> 42 | GLM_FUNC_DECL T distance2( 43 | vecType const& p0, 44 | vecType const& p1); 45 | 46 | //! Returns the L1 norm between x and y. 47 | //! From GLM_GTX_norm extension. 48 | template 49 | GLM_FUNC_DECL T l1Norm( 50 | vec<3, T, P> const & x, 51 | vec<3, T, P> const & y); 52 | 53 | //! Returns the L1 norm of v. 54 | //! From GLM_GTX_norm extension. 55 | template 56 | GLM_FUNC_DECL T l1Norm( 57 | vec<3, T, P> const & v); 58 | 59 | //! Returns the L2 norm between x and y. 60 | //! From GLM_GTX_norm extension. 61 | template 62 | GLM_FUNC_DECL T l2Norm( 63 | vec<3, T, P> const & x, 64 | vec<3, T, P> const & y); 65 | 66 | //! Returns the L2 norm of v. 67 | //! From GLM_GTX_norm extension. 68 | template 69 | GLM_FUNC_DECL T l2Norm( 70 | vec<3, T, P> const & x); 71 | 72 | //! Returns the L norm between x and y. 73 | //! From GLM_GTX_norm extension. 74 | template 75 | GLM_FUNC_DECL T lxNorm( 76 | vec<3, T, P> const & x, 77 | vec<3, T, P> const & y, 78 | unsigned int Depth); 79 | 80 | //! Returns the L norm of v. 81 | //! From GLM_GTX_norm extension. 82 | template 83 | GLM_FUNC_DECL T lxNorm( 84 | vec<3, T, P> const & x, 85 | unsigned int Depth); 86 | 87 | /// @} 88 | }//namespace glm 89 | 90 | #include "norm.inl" 91 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Compute the normal of a triangle. 11 | /// 12 | /// need to be included to use these functionalities. 13 | 14 | #pragma once 15 | 16 | // Dependency: 17 | #include "../glm.hpp" 18 | 19 | #ifndef GLM_ENABLE_EXPERIMENTAL 20 | # error "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." 21 | #endif 22 | 23 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 24 | # pragma message("GLM: GLM_GTX_normal extension included") 25 | #endif 26 | 27 | namespace glm 28 | { 29 | /// @addtogroup gtx_normal 30 | /// @{ 31 | 32 | //! Computes triangle normal from triangle points. 33 | //! From GLM_GTX_normal extension. 34 | template 35 | GLM_FUNC_DECL vec<3, T, P> triangleNormal( 36 | vec<3, T, P> const & p1, 37 | vec<3, T, P> const & p2, 38 | vec<3, T, P> const & p3); 39 | 40 | /// @} 41 | }//namespace glm 42 | 43 | #include "normal.inl" 44 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/normal.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_normal 2 | /// @file glm/gtx/normal.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER vec<3, T, P> triangleNormal 8 | ( 9 | vec<3, T, P> const & p1, 10 | vec<3, T, P> const & p2, 11 | vec<3, T, P> const & p3 12 | ) 13 | { 14 | return normalize(cross(p1 - p2, p1 - p3)); 15 | } 16 | }//namespace glm 17 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/normalize_dot.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_normalize_dot 2 | /// @file glm/gtx/normalize_dot.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtx_fast_square_root (dependence) 6 | /// 7 | /// @defgroup gtx_normalize_dot GLM_GTX_normalize_dot 8 | /// @ingroup gtx 9 | /// 10 | /// @brief Dot product of vectors that need to be normalize with a single square root. 11 | /// 12 | /// need to be included to use these functionalities. 13 | 14 | #pragma once 15 | 16 | // Dependency: 17 | #include "../gtx/fast_square_root.hpp" 18 | 19 | #ifndef GLM_ENABLE_EXPERIMENTAL 20 | # error "GLM: GLM_GTX_normalize_dot 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 | #endif 22 | 23 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 24 | # pragma message("GLM: GLM_GTX_normalize_dot extension included") 25 | #endif 26 | 27 | namespace glm 28 | { 29 | /// @addtogroup gtx_normalize_dot 30 | /// @{ 31 | 32 | /// Normalize parameters and returns the dot product of x and y. 33 | /// It's faster that dot(normalize(x), normalize(y)). 34 | /// 35 | /// @see gtx_normalize_dot extension. 36 | template class vecType> 37 | GLM_FUNC_DECL T normalizeDot(vecType const & x, vecType const & y); 38 | 39 | /// Normalize parameters and returns the dot product of x and y. 40 | /// Faster that dot(fastNormalize(x), fastNormalize(y)). 41 | /// 42 | /// @see gtx_normalize_dot extension. 43 | template class vecType> 44 | GLM_FUNC_DECL T fastNormalizeDot(vecType const & x, vecType const & y); 45 | 46 | /// @} 47 | }//namespace glm 48 | 49 | #include "normalize_dot.inl" 50 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/normalize_dot.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_normalize_dot 2 | /// @file glm/gtx/normalize_dot.inl 3 | 4 | namespace glm 5 | { 6 | template class vecType> 7 | GLM_FUNC_QUALIFIER T normalizeDot(vecType const & x, vecType const & y) 8 | { 9 | return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y)); 10 | } 11 | 12 | template class vecType> 13 | GLM_FUNC_QUALIFIER T fastNormalizeDot(vecType const & x, vecType const & y) 14 | { 15 | return glm::dot(x, y) * glm::fastInverseSqrt(glm::dot(x, x) * glm::dot(y, y)); 16 | } 17 | }//namespace glm 18 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/number_precision.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_number_precision 2 | /// @file glm/gtx/number_precision.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtc_type_precision (dependence) 6 | /// @see gtc_quaternion (dependence) 7 | /// 8 | /// @defgroup gtx_number_precision GLM_GTX_number_precision 9 | /// @ingroup gtx 10 | /// 11 | /// @brief Defined size types. 12 | /// 13 | /// need to be included to use these functionalities. 14 | 15 | #pragma once 16 | 17 | // Dependency: 18 | #include "../glm.hpp" 19 | #include "../gtc/type_precision.hpp" 20 | 21 | #ifndef GLM_ENABLE_EXPERIMENTAL 22 | # error "GLM: GLM_GTX_number_precision 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 | #endif 24 | 25 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 26 | # pragma message("GLM: GLM_GTX_number_precision extension included") 27 | #endif 28 | 29 | namespace glm{ 30 | namespace gtx 31 | { 32 | ///////////////////////////// 33 | // Unsigned int vector types 34 | 35 | /// @addtogroup gtx_number_precision 36 | /// @{ 37 | 38 | typedef u8 u8vec1; //!< \brief 8bit unsigned integer scalar. (from GLM_GTX_number_precision extension) 39 | typedef u16 u16vec1; //!< \brief 16bit unsigned integer scalar. (from GLM_GTX_number_precision extension) 40 | typedef u32 u32vec1; //!< \brief 32bit unsigned integer scalar. (from GLM_GTX_number_precision extension) 41 | typedef u64 u64vec1; //!< \brief 64bit unsigned integer scalar. (from GLM_GTX_number_precision extension) 42 | 43 | ////////////////////// 44 | // Float vector types 45 | 46 | typedef f32 f32vec1; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_number_precision extension) 47 | typedef f64 f64vec1; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_number_precision extension) 48 | 49 | ////////////////////// 50 | // Float matrix types 51 | 52 | typedef f32 f32mat1; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_number_precision extension) 53 | typedef f32 f32mat1x1; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_number_precision extension) 54 | typedef f64 f64mat1; //!< \brief Double-precision floating-point scalar. (from GLM_GTX_number_precision extension) 55 | typedef f64 f64mat1x1; //!< \brief Double-precision floating-point scalar. (from GLM_GTX_number_precision extension) 56 | 57 | /// @} 58 | }//namespace gtx 59 | }//namespace glm 60 | 61 | #include "number_precision.inl" 62 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/number_precision.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_number_precision 2 | /// @file glm/gtx/number_precision.inl 3 | 4 | namespace glm 5 | { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Integer exponentiation of power functions. 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #ifndef GLM_ENABLE_EXPERIMENTAL 19 | # error "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." 20 | #endif 21 | 22 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 23 | # pragma message("GLM: GLM_GTX_optimum_pow extension included") 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 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/optimum_pow.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_optimum_pow 2 | /// @file glm/gtx/optimum_pow.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER genType pow2(genType const & x) 8 | { 9 | return x * x; 10 | } 11 | 12 | template 13 | GLM_FUNC_QUALIFIER genType pow3(genType const & x) 14 | { 15 | return x * x * x; 16 | } 17 | 18 | template 19 | GLM_FUNC_QUALIFIER genType pow4(genType const & x) 20 | { 21 | return (x * x) * (x * x); 22 | } 23 | }//namespace glm 24 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Orthonormalize matrices. 11 | /// 12 | /// need to be included to use these functionalities. 13 | 14 | #pragma once 15 | 16 | // Dependency: 17 | #include "../vec3.hpp" 18 | #include "../mat3x3.hpp" 19 | #include "../geometric.hpp" 20 | 21 | #ifndef GLM_ENABLE_EXPERIMENTAL 22 | # error "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." 23 | #endif 24 | 25 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 26 | # pragma message("GLM: GLM_GTX_orthonormalize extension included") 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, P> orthonormalize(mat<3, 3, T, P> const & m); 39 | 40 | /// Orthonormalizes x according y. 41 | /// 42 | /// @see gtx_orthonormalize 43 | template 44 | GLM_FUNC_DECL vec<3, T, P> orthonormalize(vec<3, T, P> const & x, vec<3, T, P> const & y); 45 | 46 | /// @} 47 | }//namespace glm 48 | 49 | #include "orthonormalize.inl" 50 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/orthonormalize.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_orthonormalize 2 | /// @file glm/gtx/orthonormalize.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER mat<3, 3, T, P> orthonormalize(mat<3, 3, T, P> const & m) 8 | { 9 | mat<3, 3, T, P> r = m; 10 | 11 | r[0] = normalize(r[0]); 12 | 13 | T d0 = dot(r[0], r[1]); 14 | r[1] -= r[0] * d0; 15 | r[1] = normalize(r[1]); 16 | 17 | T d1 = dot(r[1], r[2]); 18 | d0 = dot(r[0], r[2]); 19 | r[2] -= r[0] * d0 + r[1] * d1; 20 | r[2] = normalize(r[2]); 21 | 22 | return r; 23 | } 24 | 25 | template 26 | GLM_FUNC_QUALIFIER vec<3, T, P> orthonormalize(vec<3, T, P> const & x, vec<3, T, P> const & y) 27 | { 28 | return normalize(x - y * dot(y, x)); 29 | } 30 | }//namespace glm 31 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Perpendicular of a vector from other one 11 | /// 12 | /// need to be included to use these functionalities. 13 | 14 | #pragma once 15 | 16 | // Dependency: 17 | #include "../glm.hpp" 18 | #include "../gtx/projection.hpp" 19 | 20 | #ifndef GLM_ENABLE_EXPERIMENTAL 21 | # error "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." 22 | #endif 23 | 24 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 25 | # pragma message("GLM: GLM_GTX_perpendicular extension included") 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 vecType perp( 37 | vecType const & x, 38 | vecType const & Normal); 39 | 40 | /// @} 41 | }//namespace glm 42 | 43 | #include "perpendicular.inl" 44 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/perpendicular.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_perpendicular 2 | /// @file glm/gtx/perpendicular.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER vecType perp 8 | ( 9 | vecType const & x, 10 | vecType const & Normal 11 | ) 12 | { 13 | return x - proj(x, Normal); 14 | } 15 | }//namespace glm 16 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Conversion from Euclidean space to polar space and revert. 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #ifndef GLM_ENABLE_EXPERIMENTAL 19 | # error "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." 20 | #endif 21 | 22 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 23 | # pragma message("GLM: GLM_GTX_polar_coordinates extension included") 24 | #endif 25 | 26 | namespace glm 27 | { 28 | /// @addtogroup gtx_polar_coordinates 29 | /// @{ 30 | 31 | /// Convert Euclidean to Polar coordinates, x is the xz distance, y, the latitude and z the longitude. 32 | /// 33 | /// @see gtx_polar_coordinates 34 | template 35 | GLM_FUNC_DECL vec<3, T, P> polar( 36 | vec<3, T, P> const & euclidean); 37 | 38 | /// Convert Polar to Euclidean coordinates. 39 | /// 40 | /// @see gtx_polar_coordinates 41 | template 42 | GLM_FUNC_DECL vec<3, T, P> euclidean( 43 | vec<2, T, P> const & polar); 44 | 45 | /// @} 46 | }//namespace glm 47 | 48 | #include "polar_coordinates.inl" 49 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/polar_coordinates.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_polar_coordinates 2 | /// @file glm/gtx/polar_coordinates.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER vec<3, T, P> polar 8 | ( 9 | vec<3, T, P> const & euclidean 10 | ) 11 | { 12 | T const Length(length(euclidean)); 13 | vec<3, T, P> const tmp(euclidean / Length); 14 | T const xz_dist(sqrt(tmp.x * tmp.x + tmp.z * tmp.z)); 15 | 16 | return vec<3, T, P>( 17 | asin(tmp.y), // latitude 18 | atan(tmp.x, tmp.z), // longitude 19 | xz_dist); // xz distance 20 | } 21 | 22 | template 23 | GLM_FUNC_QUALIFIER vec<3, T, P> euclidean 24 | ( 25 | vec<2, T, P> const & polar 26 | ) 27 | { 28 | T const latitude(polar.x); 29 | T const longitude(polar.y); 30 | 31 | return vec<3, T, P>( 32 | cos(latitude) * sin(longitude), 33 | sin(latitude), 34 | cos(latitude) * cos(longitude)); 35 | } 36 | 37 | }//namespace glm 38 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Projection of a vector to other one 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../geometric.hpp" 17 | 18 | #ifndef GLM_ENABLE_EXPERIMENTAL 19 | # error "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." 20 | #endif 21 | 22 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 23 | # pragma message("GLM: GLM_GTX_projection extension included") 24 | #endif 25 | 26 | namespace glm 27 | { 28 | /// @addtogroup gtx_projection 29 | /// @{ 30 | 31 | /// Projects x on Normal. 32 | /// 33 | /// @see gtx_projection 34 | template 35 | GLM_FUNC_DECL vecType proj(vecType const & x, vecType const & Normal); 36 | 37 | /// @} 38 | }//namespace glm 39 | 40 | #include "projection.inl" 41 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/projection.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_projection 2 | /// @file glm/gtx/projection.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER vecType proj(vecType const & x, vecType const & Normal) 8 | { 9 | return glm::dot(x, Normal) / glm::dot(Normal, Normal) * Normal; 10 | } 11 | }//namespace glm 12 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/range.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_range 2 | /// @file glm/gtx/range.hpp 3 | /// @author Joshua Moerman 4 | /// 5 | /// @defgroup gtx_range GLM_GTX_range 6 | /// @ingroup gtx 7 | /// 8 | /// @brief Defines begin and end for vectors and matrices. Useful for range-based for loop. 9 | /// The range is defined over the elements, not over columns or rows (e.g. mat4 has 16 elements). 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependencies 16 | #include "../detail/setup.hpp" 17 | 18 | #ifndef GLM_ENABLE_EXPERIMENTAL 19 | # error "GLM: GLM_GTX_range 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." 20 | #endif 21 | 22 | #if !GLM_HAS_RANGE_FOR 23 | # error "GLM_GTX_range requires C++11 suppport or 'range for'" 24 | #endif 25 | 26 | #include "../gtc/type_ptr.hpp" 27 | #include "../gtc/vec1.hpp" 28 | 29 | namespace glm 30 | { 31 | /// @addtogroup gtx_range 32 | /// @{ 33 | 34 | template 35 | inline length_t components(vec<1, T, P> const & v) 36 | { 37 | return v.length(); 38 | } 39 | 40 | template 41 | inline length_t components(vec<2, T, P> const & v) 42 | { 43 | return v.length(); 44 | } 45 | 46 | template 47 | inline length_t components(vec<3, T, P> const & v) 48 | { 49 | return v.length(); 50 | } 51 | 52 | template 53 | inline length_t components(vec<4, T, P> const & v) 54 | { 55 | return v.length(); 56 | } 57 | 58 | template 59 | inline length_t components(genType const & m) 60 | { 61 | return m.length() * m[0].length(); 62 | } 63 | 64 | template 65 | inline typename genType::value_type const * begin(genType const & v) 66 | { 67 | return value_ptr(v); 68 | } 69 | 70 | template 71 | inline typename genType::value_type const * end(genType const & v) 72 | { 73 | return begin(v) + components(v); 74 | } 75 | 76 | template 77 | inline typename genType::value_type * begin(genType& v) 78 | { 79 | return value_ptr(v); 80 | } 81 | 82 | template 83 | inline typename genType::value_type * end(genType& v) 84 | { 85 | return begin(v) + components(v); 86 | } 87 | 88 | /// @} 89 | }//namespace glm 90 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Projection of a vector to other one 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependencies 16 | #include "../detail/setup.hpp" 17 | #include "../detail/type_int.hpp" 18 | 19 | #ifndef GLM_ENABLE_EXPERIMENTAL 20 | # error "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." 21 | #endif 22 | 23 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 24 | # pragma message("GLM: GLM_GTX_raw_data extension included") 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 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/raw_data.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_raw_data 2 | /// @file glm/gtx/raw_data.inl 3 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/rotate_normalized_axis.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_rotate_normalized_axis 2 | /// @file glm/gtx/rotate_normalized_axis.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtc_matrix_transform 6 | /// @see gtc_quaternion 7 | /// 8 | /// @defgroup gtx_rotate_normalized_axis GLM_GTX_rotate_normalized_axis 9 | /// @ingroup gtx 10 | /// 11 | /// @brief Quaternions and matrices rotations around normalized axis. 12 | /// 13 | /// need to be included to use these functionalities. 14 | 15 | #pragma once 16 | 17 | // Dependency: 18 | #include "../glm.hpp" 19 | #include "../gtc/epsilon.hpp" 20 | #include "../gtc/quaternion.hpp" 21 | 22 | #ifndef GLM_ENABLE_EXPERIMENTAL 23 | # error "GLM: GLM_GTX_rotate_normalized_axis 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 | #endif 25 | 26 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 27 | # pragma message("GLM: GLM_GTX_rotate_normalized_axis extension included") 28 | #endif 29 | 30 | namespace glm 31 | { 32 | /// @addtogroup gtx_rotate_normalized_axis 33 | /// @{ 34 | 35 | /// Builds a rotation 4 * 4 matrix created from a normalized axis and an angle. 36 | /// 37 | /// @param m Input matrix multiplied by this rotation matrix. 38 | /// @param angle Rotation angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise. 39 | /// @param axis Rotation axis, must be normalized. 40 | /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. 41 | /// 42 | /// @see gtx_rotate_normalized_axis 43 | /// @see - rotate(T angle, T x, T y, T z) 44 | /// @see - rotate(mat<4, 4, T, P> const & m, T angle, T x, T y, T z) 45 | /// @see - rotate(T angle, vec<3, T, P> const & v) 46 | template 47 | GLM_FUNC_DECL mat<4, 4, T, P> rotateNormalizedAxis( 48 | mat<4, 4, T, P> const& m, 49 | T const & angle, 50 | vec<3, T, P> const & axis); 51 | 52 | /// Rotates a quaternion from a vector of 3 components normalized axis and an angle. 53 | /// 54 | /// @param q Source orientation 55 | /// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise. 56 | /// @param axis Normalized axis of the rotation, must be normalized. 57 | /// 58 | /// @see gtx_rotate_normalized_axis 59 | template 60 | GLM_FUNC_DECL tquat rotateNormalizedAxis( 61 | tquat const & q, 62 | T const & angle, 63 | vec<3, T, P> const & axis); 64 | 65 | /// @} 66 | }//namespace glm 67 | 68 | #include "rotate_normalized_axis.inl" 69 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/rotate_normalized_axis.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_rotate_normalized_axis 2 | /// @file glm/gtx/rotate_normalized_axis.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER mat<4, 4, T, P> rotateNormalizedAxis 8 | ( 9 | mat<4, 4, T, P> const& m, 10 | T const & angle, 11 | vec<3, T, P> const & v 12 | ) 13 | { 14 | T const a = angle; 15 | T const c = cos(a); 16 | T const s = sin(a); 17 | 18 | vec<3, T, P> const axis(v); 19 | 20 | vec<3, T, P> const temp((static_cast(1) - c) * axis); 21 | 22 | mat<4, 4, T, P> Rotate(uninitialize); 23 | Rotate[0][0] = c + temp[0] * axis[0]; 24 | Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2]; 25 | Rotate[0][2] = 0 + temp[0] * axis[2] - s * axis[1]; 26 | 27 | Rotate[1][0] = 0 + temp[1] * axis[0] - s * axis[2]; 28 | Rotate[1][1] = c + temp[1] * axis[1]; 29 | Rotate[1][2] = 0 + temp[1] * axis[2] + s * axis[0]; 30 | 31 | Rotate[2][0] = 0 + temp[2] * axis[0] + s * axis[1]; 32 | Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0]; 33 | Rotate[2][2] = c + temp[2] * axis[2]; 34 | 35 | mat<4, 4, T, P> Result(uninitialize); 36 | Result[0] = m[0] * Rotate[0][0] + m[1] * Rotate[0][1] + m[2] * Rotate[0][2]; 37 | Result[1] = m[0] * Rotate[1][0] + m[1] * Rotate[1][1] + m[2] * Rotate[1][2]; 38 | Result[2] = m[0] * Rotate[2][0] + m[1] * Rotate[2][1] + m[2] * Rotate[2][2]; 39 | Result[3] = m[3]; 40 | return Result; 41 | } 42 | 43 | template 44 | GLM_FUNC_QUALIFIER tquat rotateNormalizedAxis 45 | ( 46 | tquat const & q, 47 | T const & angle, 48 | vec<3, T, P> const & v 49 | ) 50 | { 51 | vec<3, T, P> const Tmp(v); 52 | 53 | T const AngleRad(angle); 54 | T const Sin = sin(AngleRad * T(0.5)); 55 | 56 | return q * tquat(cos(AngleRad * static_cast(0.5)), Tmp.x * Sin, Tmp.y * Sin, Tmp.z * Sin); 57 | //return gtc::quaternion::cross(q, tquat(cos(AngleRad * T(0.5)), Tmp.x * fSin, Tmp.y * fSin, Tmp.z * fSin)); 58 | } 59 | }//namespace glm 60 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/scalar_multiplication.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx 2 | /// @file glm/gtx/scalar_multiplication.hpp 3 | /// @author Joshua Moerman 4 | /// 5 | /// @brief Enables scalar multiplication for all types 6 | /// 7 | /// Since GLSL is very strict about types, the following (often used) combinations do not work: 8 | /// double * vec4 9 | /// int * vec4 10 | /// vec4 / int 11 | /// So we'll fix that! Of course "float * vec4" should remain the same (hence the enable_if magic) 12 | 13 | #pragma once 14 | 15 | #include "../detail/setup.hpp" 16 | 17 | #ifndef GLM_ENABLE_EXPERIMENTAL 18 | # error "GLM: GLM_GTX_scalar_multiplication 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." 19 | #endif 20 | 21 | #if !GLM_HAS_TEMPLATE_ALIASES && !(GLM_COMPILER & GLM_COMPILER_GCC) 22 | # error "GLM_GTX_scalar_multiplication requires C++11 support or alias templates and if not support for GCC" 23 | #endif 24 | 25 | #include "../vec2.hpp" 26 | #include "../vec3.hpp" 27 | #include "../vec4.hpp" 28 | #include "../mat2x2.hpp" 29 | #include 30 | 31 | namespace glm 32 | { 33 | template 34 | using return_type_scalar_multiplication = typename std::enable_if< 35 | !std::is_same::value // T may not be a float 36 | && std::is_arithmetic::value, Vec // But it may be an int or double (no vec3 or mat3, ...) 37 | >::type; 38 | 39 | #define GLM_IMPLEMENT_SCAL_MULT(Vec) \ 40 | template \ 41 | return_type_scalar_multiplication \ 42 | operator*(T const & s, Vec rh){ \ 43 | return rh *= static_cast(s); \ 44 | } \ 45 | \ 46 | template \ 47 | return_type_scalar_multiplication \ 48 | operator*(Vec lh, T const & s){ \ 49 | return lh *= static_cast(s); \ 50 | } \ 51 | \ 52 | template \ 53 | return_type_scalar_multiplication \ 54 | operator/(Vec lh, T const & s){ \ 55 | return lh *= 1.0f / s; \ 56 | } 57 | 58 | GLM_IMPLEMENT_SCAL_MULT(vec2) 59 | GLM_IMPLEMENT_SCAL_MULT(vec3) 60 | GLM_IMPLEMENT_SCAL_MULT(vec4) 61 | 62 | GLM_IMPLEMENT_SCAL_MULT(mat2) 63 | GLM_IMPLEMENT_SCAL_MULT(mat2x3) 64 | GLM_IMPLEMENT_SCAL_MULT(mat2x4) 65 | GLM_IMPLEMENT_SCAL_MULT(mat3x2) 66 | GLM_IMPLEMENT_SCAL_MULT(mat3) 67 | GLM_IMPLEMENT_SCAL_MULT(mat3x4) 68 | GLM_IMPLEMENT_SCAL_MULT(mat4x2) 69 | GLM_IMPLEMENT_SCAL_MULT(mat4x3) 70 | GLM_IMPLEMENT_SCAL_MULT(mat4) 71 | 72 | #undef GLM_IMPLEMENT_SCAL_MULT 73 | } // namespace glm 74 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Extend a position from a source to a position at a defined length. 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | 18 | #ifndef GLM_ENABLE_EXPERIMENTAL 19 | # error "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." 20 | #endif 21 | 22 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 23 | # pragma message("GLM: GLM_GTX_extend extension included") 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 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/scalar_relational.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_scalar_relational 2 | /// @file glm/gtx/scalar_relational.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER bool lessThan 8 | ( 9 | T const & x, 10 | T const & y 11 | ) 12 | { 13 | return x < y; 14 | } 15 | 16 | template 17 | GLM_FUNC_QUALIFIER bool lessThanEqual 18 | ( 19 | T const & x, 20 | T const & y 21 | ) 22 | { 23 | return x <= y; 24 | } 25 | 26 | template 27 | GLM_FUNC_QUALIFIER bool greaterThan 28 | ( 29 | T const & x, 30 | T const & y 31 | ) 32 | { 33 | return x > y; 34 | } 35 | 36 | template 37 | GLM_FUNC_QUALIFIER bool greaterThanEqual 38 | ( 39 | T const & x, 40 | T const & y 41 | ) 42 | { 43 | return x >= y; 44 | } 45 | 46 | template 47 | GLM_FUNC_QUALIFIER bool equal 48 | ( 49 | T const & x, 50 | T const & y 51 | ) 52 | { 53 | return x == y; 54 | } 55 | 56 | template 57 | GLM_FUNC_QUALIFIER bool notEqual 58 | ( 59 | T const & x, 60 | T const & y 61 | ) 62 | { 63 | return x != y; 64 | } 65 | 66 | GLM_FUNC_QUALIFIER bool any 67 | ( 68 | bool const & x 69 | ) 70 | { 71 | return x; 72 | } 73 | 74 | GLM_FUNC_QUALIFIER bool all 75 | ( 76 | bool const & x 77 | ) 78 | { 79 | return x; 80 | } 81 | 82 | GLM_FUNC_QUALIFIER bool not_ 83 | ( 84 | bool const & x 85 | ) 86 | { 87 | return !x; 88 | } 89 | }//namespace glm 90 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/spline.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_spline 2 | /// @file glm/gtx/spline.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_spline GLM_GTX_spline 7 | /// @ingroup gtx 8 | /// 9 | /// @brief Spline functions 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | #include "../gtx/optimum_pow.hpp" 18 | 19 | #ifndef GLM_ENABLE_EXPERIMENTAL 20 | # error "GLM: GLM_GTX_spline 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 | #endif 22 | 23 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 24 | # pragma message("GLM: GLM_GTX_spline extension included") 25 | #endif 26 | 27 | namespace glm 28 | { 29 | /// @addtogroup gtx_spline 30 | /// @{ 31 | 32 | /// Return a point from a catmull rom curve. 33 | /// @see gtx_spline extension. 34 | template 35 | GLM_FUNC_DECL genType catmullRom( 36 | genType const & v1, 37 | genType const & v2, 38 | genType const & v3, 39 | genType const & v4, 40 | typename genType::value_type const & s); 41 | 42 | /// Return a point from a hermite curve. 43 | /// @see gtx_spline extension. 44 | template 45 | GLM_FUNC_DECL genType hermite( 46 | genType const & v1, 47 | genType const & t1, 48 | genType const & v2, 49 | genType const & t2, 50 | typename genType::value_type const & s); 51 | 52 | /// Return a point from a cubic curve. 53 | /// @see gtx_spline extension. 54 | template 55 | GLM_FUNC_DECL genType cubic( 56 | genType const & v1, 57 | genType const & v2, 58 | genType const & v3, 59 | genType const & v4, 60 | typename genType::value_type const & s); 61 | 62 | /// @} 63 | }//namespace glm 64 | 65 | #include "spline.inl" 66 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/spline.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_spline 2 | /// @file glm/gtx/spline.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER genType catmullRom 8 | ( 9 | genType const & v1, 10 | genType const & v2, 11 | genType const & v3, 12 | genType const & v4, 13 | typename genType::value_type const & s 14 | ) 15 | { 16 | typename genType::value_type s1 = s; 17 | typename genType::value_type s2 = pow2(s); 18 | typename genType::value_type s3 = pow3(s); 19 | 20 | typename genType::value_type f1 = -s3 + typename genType::value_type(2) * s2 - s; 21 | typename genType::value_type f2 = typename genType::value_type(3) * s3 - typename genType::value_type(5) * s2 + typename genType::value_type(2); 22 | typename genType::value_type f3 = typename genType::value_type(-3) * s3 + typename genType::value_type(4) * s2 + s; 23 | typename genType::value_type f4 = s3 - s2; 24 | 25 | return (f1 * v1 + f2 * v2 + f3 * v3 + f4 * v4) / typename genType::value_type(2); 26 | 27 | } 28 | 29 | template 30 | GLM_FUNC_QUALIFIER genType hermite 31 | ( 32 | genType const & v1, 33 | genType const & t1, 34 | genType const & v2, 35 | genType const & t2, 36 | typename genType::value_type const & s 37 | ) 38 | { 39 | typename genType::value_type s1 = s; 40 | typename genType::value_type s2 = pow2(s); 41 | typename genType::value_type s3 = pow3(s); 42 | 43 | typename genType::value_type f1 = typename genType::value_type(2) * s3 - typename genType::value_type(3) * s2 + typename genType::value_type(1); 44 | typename genType::value_type f2 = typename genType::value_type(-2) * s3 + typename genType::value_type(3) * s2; 45 | typename genType::value_type f3 = s3 - typename genType::value_type(2) * s2 + s; 46 | typename genType::value_type f4 = s3 - s2; 47 | 48 | return f1 * v1 + f2 * v2 + f3 * t1 + f4 * t2; 49 | } 50 | 51 | template 52 | GLM_FUNC_QUALIFIER genType cubic 53 | ( 54 | genType const & v1, 55 | genType const & v2, 56 | genType const & v3, 57 | genType const & v4, 58 | typename genType::value_type const & s 59 | ) 60 | { 61 | return ((v1 * s + v2) * s + v3) * s + v4; 62 | } 63 | }//namespace glm 64 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/std_based_type.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_std_based_type 2 | /// @file glm/gtx/std_based_type.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtx_extented_min_max (dependence) 6 | /// 7 | /// @defgroup gtx_std_based_type GLM_GTX_std_based_type 8 | /// @ingroup gtx 9 | /// 10 | /// @brief Adds vector types based on STL value types. 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | #include 18 | 19 | #ifndef GLM_ENABLE_EXPERIMENTAL 20 | # error "GLM: GLM_GTX_std_based_type 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 | #endif 22 | 23 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 24 | # pragma message("GLM: GLM_GTX_std_based_type extension included") 25 | #endif 26 | 27 | namespace glm 28 | { 29 | /// @addtogroup gtx_std_based_type 30 | /// @{ 31 | 32 | /// Vector type based of one std::size_t component. 33 | /// @see GLM_GTX_std_based_type 34 | typedef vec<1, std::size_t, defaultp> size1; 35 | 36 | /// Vector type based of two std::size_t components. 37 | /// @see GLM_GTX_std_based_type 38 | typedef vec<2, std::size_t, defaultp> size2; 39 | 40 | /// Vector type based of three std::size_t components. 41 | /// @see GLM_GTX_std_based_type 42 | typedef vec<3, std::size_t, defaultp> size3; 43 | 44 | /// Vector type based of four std::size_t components. 45 | /// @see GLM_GTX_std_based_type 46 | typedef vec<4, std::size_t, defaultp> size4; 47 | 48 | /// Vector type based of one std::size_t component. 49 | /// @see GLM_GTX_std_based_type 50 | typedef vec<1, std::size_t, defaultp> size1_t; 51 | 52 | /// Vector type based of two std::size_t components. 53 | /// @see GLM_GTX_std_based_type 54 | typedef vec<2, std::size_t, defaultp> size2_t; 55 | 56 | /// Vector type based of three std::size_t components. 57 | /// @see GLM_GTX_std_based_type 58 | typedef vec<3, std::size_t, defaultp> size3_t; 59 | 60 | /// Vector type based of four std::size_t components. 61 | /// @see GLM_GTX_std_based_type 62 | typedef vec<4, std::size_t, defaultp> size4_t; 63 | 64 | /// @} 65 | }//namespace glm 66 | 67 | #include "std_based_type.inl" 68 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/std_based_type.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_std_based_type 2 | /// @file glm/gtx/std_based_type.inl 3 | 4 | namespace glm 5 | { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Setup strings for GLM type values 12 | /// 13 | /// need to be included to use these functionalities. 14 | /// This extension is not supported with CUDA 15 | 16 | #pragma once 17 | 18 | // Dependency: 19 | #include "../glm.hpp" 20 | #include "../gtc/type_precision.hpp" 21 | #include "../gtc/quaternion.hpp" 22 | #include "../gtx/dual_quaternion.hpp" 23 | #include 24 | #include 25 | 26 | #ifndef GLM_ENABLE_EXPERIMENTAL 27 | # error "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." 28 | #endif 29 | 30 | #if(GLM_COMPILER & GLM_COMPILER_CUDA) 31 | # error "GLM_GTX_string_cast is not supported on CUDA compiler" 32 | #endif 33 | 34 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 35 | # pragma message("GLM: GLM_GTX_string_cast extension included") 36 | #endif 37 | 38 | namespace glm 39 | { 40 | /// @addtogroup gtx_string_cast 41 | /// @{ 42 | 43 | /// Create a string from a GLM vector or matrix typed variable. 44 | /// @see gtx_string_cast extension. 45 | template 46 | GLM_FUNC_DECL std::string to_string(genType const& x); 47 | 48 | /// @} 49 | }//namespace glm 50 | 51 | #include "string_cast.inl" 52 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/transform.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_transform 2 | /// @file glm/gtx/transform.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtc_matrix_transform (dependence) 6 | /// @see gtx_transform 7 | /// @see gtx_transform2 8 | /// 9 | /// @defgroup gtx_transform GLM_GTX_transform 10 | /// @ingroup gtx 11 | /// 12 | /// @brief Add transformation matrices 13 | /// 14 | /// need to be included to use these functionalities. 15 | 16 | #pragma once 17 | 18 | // Dependency: 19 | #include "../glm.hpp" 20 | #include "../gtc/matrix_transform.hpp" 21 | 22 | #ifndef GLM_ENABLE_EXPERIMENTAL 23 | # error "GLM: GLM_GTX_transform 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 | #endif 25 | 26 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 27 | # pragma message("GLM: GLM_GTX_transform extension included") 28 | #endif 29 | 30 | namespace glm 31 | { 32 | /// @addtogroup gtx_transform 33 | /// @{ 34 | 35 | /// Transforms a matrix with a translation 4 * 4 matrix created from 3 scalars. 36 | /// @see gtc_matrix_transform 37 | /// @see gtx_transform 38 | template 39 | GLM_FUNC_DECL mat<4, 4, T, P> translate( 40 | vec<3, T, P> const & v); 41 | 42 | /// Builds a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in radians. 43 | /// @see gtc_matrix_transform 44 | /// @see gtx_transform 45 | template 46 | GLM_FUNC_DECL mat<4, 4, T, P> rotate( 47 | T angle, 48 | vec<3, T, P> const & v); 49 | 50 | /// Transforms a matrix with a scale 4 * 4 matrix created from a vector of 3 components. 51 | /// @see gtc_matrix_transform 52 | /// @see gtx_transform 53 | template 54 | GLM_FUNC_DECL mat<4, 4, T, P> scale( 55 | vec<3, T, P> const & v); 56 | 57 | /// @} 58 | }// namespace glm 59 | 60 | #include "transform.inl" 61 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/transform.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_transform 2 | /// @file glm/gtx/transform.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER mat<4, 4, T, P> translate(vec<3, T, P> const & v) 8 | { 9 | return translate(mat<4, 4, T, P>(static_cast(1)), v); 10 | } 11 | 12 | template 13 | GLM_FUNC_QUALIFIER mat<4, 4, T, P> rotate(T angle, vec<3, T, P> const & v) 14 | { 15 | return rotate(mat<4, 4, T, P>(static_cast(1)), angle, v); 16 | } 17 | 18 | template 19 | GLM_FUNC_QUALIFIER mat<4, 4, T, P> scale(vec<3, T, P> const & v) 20 | { 21 | return scale(mat<4, 4, T, P>(static_cast(1)), v); 22 | } 23 | 24 | }//namespace glm 25 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/type_aligned.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtc_type_aligned 2 | /// @file glm/gtc/type_aligned.inl 3 | 4 | namespace glm 5 | { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/type_trait.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/brdf/glm/gtx/type_trait.inl -------------------------------------------------------------------------------- /src/brdf/glm/gtx/vector_angle.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_vector_angle 2 | /// @file glm/gtx/vector_angle.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// @see gtx_quaternion (dependence) 6 | /// @see gtx_epsilon (dependence) 7 | /// 8 | /// @defgroup gtx_vector_angle GLM_GTX_vector_angle 9 | /// @ingroup gtx 10 | /// 11 | /// @brief Compute angle between vectors 12 | /// 13 | /// need to be included to use these functionalities. 14 | 15 | #pragma once 16 | 17 | // Dependency: 18 | #include "../glm.hpp" 19 | #include "../gtc/epsilon.hpp" 20 | #include "../gtx/quaternion.hpp" 21 | #include "../gtx/rotate_vector.hpp" 22 | 23 | #ifndef GLM_ENABLE_EXPERIMENTAL 24 | # error "GLM: GLM_GTX_vector_angle 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." 25 | #endif 26 | 27 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 28 | # pragma message("GLM: GLM_GTX_vector_angle extension included") 29 | #endif 30 | 31 | namespace glm 32 | { 33 | /// @addtogroup gtx_vector_angle 34 | /// @{ 35 | 36 | //! Returns the absolute angle between two vectors. 37 | //! Parameters need to be normalized. 38 | /// @see gtx_vector_angle extension. 39 | template 40 | GLM_FUNC_DECL typename vecType::value_type angle( 41 | vecType const & x, 42 | vecType const & y); 43 | 44 | //! Returns the oriented angle between two 2d vectors. 45 | //! Parameters need to be normalized. 46 | /// @see gtx_vector_angle extension. 47 | template 48 | GLM_FUNC_DECL T orientedAngle( 49 | vec<2, T, P> const & x, 50 | vec<2, T, P> const & y); 51 | 52 | //! Returns the oriented angle between two 3d vectors based from a reference axis. 53 | //! Parameters need to be normalized. 54 | /// @see gtx_vector_angle extension. 55 | template 56 | GLM_FUNC_DECL T orientedAngle( 57 | vec<3, T, P> const & x, 58 | vec<3, T, P> const & y, 59 | vec<3, T, P> const & ref); 60 | 61 | /// @} 62 | }// namespace glm 63 | 64 | #include "vector_angle.inl" 65 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/vector_angle.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_vector_angle 2 | /// @file glm/gtx/vector_angle.inl 3 | 4 | namespace glm 5 | { 6 | template 7 | GLM_FUNC_QUALIFIER genType angle 8 | ( 9 | genType const & x, 10 | genType const & y 11 | ) 12 | { 13 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'angle' only accept floating-point inputs"); 14 | return acos(clamp(dot(x, y), genType(-1), genType(1))); 15 | } 16 | 17 | template class vecType> 18 | GLM_FUNC_QUALIFIER T angle 19 | ( 20 | vecType const& x, 21 | vecType const& y 22 | ) 23 | { 24 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'angle' only accept floating-point inputs"); 25 | return acos(clamp(dot(x, y), T(-1), T(1))); 26 | } 27 | 28 | //! \todo epsilon is hard coded to 0.01 29 | template 30 | GLM_FUNC_QUALIFIER T orientedAngle 31 | ( 32 | vec<2, T, P> const & x, 33 | vec<2, T, P> const & y 34 | ) 35 | { 36 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'orientedAngle' only accept floating-point inputs"); 37 | T const Angle(acos(clamp(dot(x, y), T(-1), T(1)))); 38 | 39 | if(all(epsilonEqual(y, glm::rotate(x, Angle), T(0.0001)))) 40 | return Angle; 41 | else 42 | return -Angle; 43 | } 44 | 45 | template 46 | GLM_FUNC_QUALIFIER T orientedAngle 47 | ( 48 | vec<3, T, P> const & x, 49 | vec<3, T, P> const & y, 50 | vec<3, T, P> const & ref 51 | ) 52 | { 53 | GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'orientedAngle' only accept floating-point inputs"); 54 | 55 | T const Angle(acos(clamp(dot(x, y), T(-1), T(1)))); 56 | return mix(Angle, -Angle, dot(ref, cross(x, y)) < T(0)); 57 | } 58 | }//namespace glm 59 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/vector_query.hpp: -------------------------------------------------------------------------------- 1 | /// @ref gtx_vector_query 2 | /// @file glm/gtx/vector_query.hpp 3 | /// 4 | /// @see core (dependence) 5 | /// 6 | /// @defgroup gtx_vector_query GLM_GTX_vector_query 7 | /// @ingroup gtx 8 | /// 9 | /// @brief Query informations of vector types 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | #include 18 | #include 19 | 20 | #ifndef GLM_ENABLE_EXPERIMENTAL 21 | # error "GLM: GLM_GTX_vector_query 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 | #endif 23 | 24 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 25 | # pragma message("GLM: GLM_GTX_vector_query extension included") 26 | #endif 27 | 28 | namespace glm 29 | { 30 | /// @addtogroup gtx_vector_query 31 | /// @{ 32 | 33 | //! Check whether two vectors are collinears. 34 | /// @see gtx_vector_query extensions. 35 | template class vecType> 36 | GLM_FUNC_DECL bool areCollinear(vecType const & v0, vecType const & v1, T const & epsilon); 37 | 38 | //! Check whether two vectors are orthogonals. 39 | /// @see gtx_vector_query extensions. 40 | template class vecType> 41 | GLM_FUNC_DECL bool areOrthogonal(vecType const & v0, vecType const & v1, T const & epsilon); 42 | 43 | //! Check whether a vector is normalized. 44 | /// @see gtx_vector_query extensions. 45 | template class vecType> 46 | GLM_FUNC_DECL bool isNormalized(vecType const & v, T const & epsilon); 47 | 48 | //! Check whether a vector is null. 49 | /// @see gtx_vector_query extensions. 50 | template class vecType> 51 | GLM_FUNC_DECL bool isNull(vecType const & v, T const & epsilon); 52 | 53 | //! Check whether a each component of a vector is null. 54 | /// @see gtx_vector_query extensions. 55 | template class vecType> 56 | GLM_FUNC_DECL vecType isCompNull(vecType const & v, T const & epsilon); 57 | 58 | //! Check whether two vectors are orthonormal. 59 | /// @see gtx_vector_query extensions. 60 | template class vecType> 61 | GLM_FUNC_DECL bool areOrthonormal(vecType const & v0, vecType const & v1, T const & epsilon); 62 | 63 | /// @} 64 | }// namespace glm 65 | 66 | #include "vector_query.inl" 67 | -------------------------------------------------------------------------------- /src/brdf/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 | /// @brief Wrapping mode of texture coordinates. 10 | /// 11 | /// need to be included to use these functionalities. 12 | 13 | #pragma once 14 | 15 | // Dependency: 16 | #include "../glm.hpp" 17 | #include "../gtc/vec1.hpp" 18 | 19 | #ifndef GLM_ENABLE_EXPERIMENTAL 20 | # error "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." 21 | #endif 22 | 23 | #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) 24 | # pragma message("GLM: GLM_GTX_wrap extension included") 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 | -------------------------------------------------------------------------------- /src/brdf/glm/gtx/wrap.inl: -------------------------------------------------------------------------------- 1 | /// @ref gtx_wrap 2 | /// @file glm/gtx/wrap.inl 3 | 4 | namespace glm 5 | { 6 | template class vecType> 7 | GLM_FUNC_QUALIFIER vecType clamp(vecType const& Texcoord) 8 | { 9 | return glm::clamp(Texcoord, vecType(0), vecType(1)); 10 | } 11 | 12 | template 13 | GLM_FUNC_QUALIFIER genType clamp(genType const & Texcoord) 14 | { 15 | return clamp(vec<1, genType, defaultp>(Texcoord)).x; 16 | } 17 | 18 | template class vecType> 19 | GLM_FUNC_QUALIFIER vecType repeat(vecType const& Texcoord) 20 | { 21 | return glm::fract(Texcoord); 22 | } 23 | 24 | template 25 | GLM_FUNC_QUALIFIER genType repeat(genType const & Texcoord) 26 | { 27 | return repeat(vec<1, genType, defaultp>(Texcoord)).x; 28 | } 29 | 30 | template class vecType> 31 | GLM_FUNC_QUALIFIER vecType mirrorClamp(vecType const& Texcoord) 32 | { 33 | return glm::fract(glm::abs(Texcoord)); 34 | } 35 | 36 | template 37 | GLM_FUNC_QUALIFIER genType mirrorClamp(genType const & Texcoord) 38 | { 39 | return mirrorClamp(vec<1, genType, defaultp>(Texcoord)).x; 40 | } 41 | 42 | template class vecType> 43 | GLM_FUNC_QUALIFIER vecType mirrorRepeat(vecType const& Texcoord) 44 | { 45 | vecType const Abs = glm::abs(Texcoord); 46 | vecType const Clamp = glm::mod(glm::floor(Abs), vecType(2)); 47 | vecType const Floor = glm::floor(Abs); 48 | vecType const Rest = Abs - Floor; 49 | vecType const Mirror = Clamp + Rest; 50 | return mix(Rest, vecType(1) - Rest, glm::greaterThanEqual(Mirror, vecType(1))); 51 | } 52 | 53 | template 54 | GLM_FUNC_QUALIFIER genType mirrorRepeat(genType const& Texcoord) 55 | { 56 | return mirrorRepeat(vec<1, genType, defaultp>(Texcoord)).x; 57 | } 58 | }//namespace glm 59 | -------------------------------------------------------------------------------- /src/brdf/glm/integer.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/integer.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/func_integer.hpp" 7 | -------------------------------------------------------------------------------- /src/brdf/glm/mat2x3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/mat2x3.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/type_mat2x3.hpp" 7 | 8 | namespace glm 9 | { 10 | /// 2 columns of 3 components matrix of low precision floating-point numbers. 11 | /// There is no guarantee on the actual precision. 12 | /// 13 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 14 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 15 | typedef mat<2, 3, float, lowp> lowp_mat2x3; 16 | 17 | /// 2 columns of 3 components matrix of medium precision floating-point numbers. 18 | /// There is no guarantee on the actual precision. 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 high precision floating-point numbers. 25 | /// There is no guarantee on the actual precision. 26 | /// 27 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 28 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 29 | typedef mat<2, 3, float, highp> highp_mat2x3; 30 | 31 | }//namespace glm 32 | 33 | -------------------------------------------------------------------------------- /src/brdf/glm/mat2x4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/mat2x4.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/type_mat2x4.hpp" 7 | 8 | namespace glm 9 | { 10 | /// 2 columns of 4 components matrix of low precision floating-point numbers. 11 | /// There is no guarantee on the actual precision. 12 | /// 13 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 14 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 15 | typedef mat<2, 4, float, lowp> lowp_mat2x4; 16 | 17 | /// 2 columns of 4 components matrix of medium precision floating-point numbers. 18 | /// There is no guarantee on the actual precision. 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 high precision floating-point numbers. 25 | /// There is no guarantee on the actual precision. 26 | /// 27 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 28 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 29 | typedef mat<2, 4, float, highp> highp_mat2x4; 30 | 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /src/brdf/glm/mat3x2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/mat3x2.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/type_mat3x2.hpp" 7 | 8 | namespace glm 9 | { 10 | /// 3 columns of 2 components matrix of low precision floating-point numbers. 11 | /// There is no guarantee on the actual precision. 12 | /// 13 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 14 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 15 | typedef mat<3, 2, float, lowp> lowp_mat3x2; 16 | 17 | /// 3 columns of 2 components matrix of medium precision floating-point numbers. 18 | /// There is no guarantee on the actual precision. 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 high precision floating-point numbers. 25 | /// There is no guarantee on the actual precision. 26 | /// 27 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 28 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 29 | typedef mat<3, 2, float, highp> highp_mat3x2; 30 | 31 | }//namespace 32 | -------------------------------------------------------------------------------- /src/brdf/glm/mat3x4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/mat3x4.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/type_mat3x4.hpp" 7 | 8 | namespace glm 9 | { 10 | /// 3 columns of 4 components matrix of low precision floating-point numbers. 11 | /// There is no guarantee on the actual precision. 12 | /// 13 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 14 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 15 | typedef mat<3, 4, float, lowp> lowp_mat3x4; 16 | 17 | /// 3 columns of 4 components matrix of medium precision floating-point numbers. 18 | /// There is no guarantee on the actual precision. 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 high precision floating-point numbers. 25 | /// There is no guarantee on the actual precision. 26 | /// 27 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 28 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 29 | typedef mat<3, 4, float, highp> highp_mat3x4; 30 | 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /src/brdf/glm/mat4x2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/mat4x2.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/type_mat4x2.hpp" 7 | 8 | namespace glm 9 | { 10 | /// 4 columns of 2 components matrix of low precision floating-point numbers. 11 | /// There is no guarantee on the actual precision. 12 | /// 13 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 14 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 15 | typedef mat<4, 2, float, lowp> lowp_mat4x2; 16 | 17 | /// 4 columns of 2 components matrix of medium precision floating-point numbers. 18 | /// There is no guarantee on the actual precision. 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 high precision floating-point numbers. 25 | /// There is no guarantee on the actual precision. 26 | /// 27 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 28 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 29 | typedef mat<4, 2, float, highp> highp_mat4x2; 30 | 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /src/brdf/glm/mat4x3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/mat4x3.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/type_mat4x3.hpp" 7 | 8 | namespace glm 9 | { 10 | /// 4 columns of 3 components matrix of low precision floating-point numbers. 11 | /// There is no guarantee on the actual precision. 12 | /// 13 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 14 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 15 | typedef mat<4, 3, float, lowp> lowp_mat4x3; 16 | 17 | /// 4 columns of 3 components matrix of medium precision floating-point numbers. 18 | /// There is no guarantee on the actual precision. 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 high precision floating-point numbers. 25 | /// There is no guarantee on the actual precision. 26 | /// 27 | /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices 28 | /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier 29 | typedef mat<4, 3, float, highp> highp_mat4x3; 30 | 31 | }//namespace glm 32 | -------------------------------------------------------------------------------- /src/brdf/glm/matrix.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/matrix.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/func_matrix.hpp" 7 | -------------------------------------------------------------------------------- /src/brdf/glm/packing.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/packing.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/func_packing.hpp" 7 | -------------------------------------------------------------------------------- /src/brdf/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_vec4 glm_vec1_sqrt_lowp(glm_vec4 x) 11 | { 12 | return _mm_mul_ss(_mm_rsqrt_ss(x), x); 13 | } 14 | 15 | GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_sqrt_lowp(glm_vec4 x) 16 | { 17 | return _mm_mul_ps(_mm_rsqrt_ps(x), x); 18 | } 19 | 20 | #endif//GLM_ARCH & GLM_ARCH_SSE2_BIT 21 | -------------------------------------------------------------------------------- /src/brdf/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 | -------------------------------------------------------------------------------- /src/brdf/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 | -------------------------------------------------------------------------------- /src/brdf/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 | -------------------------------------------------------------------------------- /src/brdf/glm/trigonometric.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/trigonometric.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/func_trigonometric.hpp" 7 | -------------------------------------------------------------------------------- /src/brdf/glm/vec2.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/vec2.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/type_vec2.hpp" 7 | -------------------------------------------------------------------------------- /src/brdf/glm/vec3.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/vec3.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/type_vec3.hpp" 7 | -------------------------------------------------------------------------------- /src/brdf/glm/vec4.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/vec4.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/type_vec4.hpp" 7 | -------------------------------------------------------------------------------- /src/brdf/glm/vector_relational.hpp: -------------------------------------------------------------------------------- 1 | /// @ref core 2 | /// @file glm/vector_relational.hpp 3 | 4 | #pragma once 5 | 6 | #include "detail/func_vector_relational.hpp" 7 | -------------------------------------------------------------------------------- /src/brdf/ptex/PtexInt.h: -------------------------------------------------------------------------------- 1 | #ifndef PtexInt_h 2 | #define PtexInt_h 3 | 4 | /* 5 | PTEX SOFTWARE 6 | Copyright 2009 Disney Enterprises, Inc. All rights reserved 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | * Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in 17 | the documentation and/or other materials provided with the 18 | distribution. 19 | 20 | * The names "Disney", "Walt Disney Pictures", "Walt Disney Animation 21 | Studios" or the names of its contributors may NOT be used to 22 | endorse or promote products derived from this software without 23 | specific prior written permission from Walt Disney Pictures. 24 | 25 | Disclaimer: THIS SOFTWARE IS PROVIDED BY WALT DISNEY PICTURES AND 26 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 27 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 28 | FOR A PARTICULAR PURPOSE, NONINFRINGEMENT AND TITLE ARE DISCLAIMED. 29 | IN NO EVENT SHALL WALT DISNEY PICTURES, THE COPYRIGHT HOLDER OR 30 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 31 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 32 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 33 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND BASED ON ANY 34 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 37 | */ 38 | 39 | /** 40 | @file PtexInt.h 41 | @brief Portable fixed-width integer types 42 | */ 43 | 44 | #if defined(_MSC_VER) && _MSC_VER < 1600 45 | typedef __int8 int8_t; 46 | typedef __int16 int16_t; 47 | typedef __int32 int32_t; 48 | typedef __int64 int64_t; 49 | typedef unsigned __int8 uint8_t; 50 | typedef unsigned __int16 uint16_t; 51 | typedef unsigned __int32 uint32_t; 52 | typedef unsigned __int64 uint64_t; 53 | #else 54 | #include 55 | #endif 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/brdfs/ashikhman_shirley.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Ashikhmin Shirley 2000 - Anisotropic phong reflectance model 4 | 5 | # variables go here... 6 | # only floats supported right now. 7 | # [type] [name] [min val] [max val] [default val] 8 | 9 | ::begin parameters 10 | float Rs 0 1 .1 11 | float Rd 0 1 1 12 | float nu 1 1000 100 13 | float nv 1 1000 100 14 | bool isotropic 1 15 | bool coupled_diffuse 1 16 | ::end parameters 17 | 18 | 19 | # Then comes the shader. This should be GLSL code 20 | # that defines a function called BRDF (although you can 21 | # add whatever else you want too, like sqr() below). 22 | 23 | ::begin shader 24 | 25 | float sqr( float x ) 26 | { 27 | return x*x; 28 | } 29 | 30 | float Fresnel(float f0, float u) 31 | { 32 | // from Schlick 33 | return f0 + (1-f0) * pow(1-u, 5); 34 | } 35 | 36 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 37 | { 38 | float PI = 3.14159265358979323846; 39 | vec3 H = normalize(L+V); 40 | float HdotV = dot(H,V); 41 | float HdotX = dot(H,X); 42 | float HdotY = dot(H,Y); 43 | float NdotH = dot(N,H); 44 | float NdotV = dot(N,V); 45 | float NdotL = dot(N,L); 46 | 47 | float F = Fresnel(Rs, HdotV); 48 | float norm_s = sqrt((nu+1)*((isotropic?nu:nv)+1))/(8*PI); 49 | float n = isotropic ? nu :(nu*sqr(HdotX) + nv*sqr(HdotY))/(1-sqr(NdotH)); 50 | float rho_s = norm_s * F * pow(max(NdotH,0), n) / (HdotV * max(NdotV, NdotL)); 51 | 52 | float rho_d = 28/(23*PI) * Rd * (1-pow(1-NdotV/2, 5)) * (1-pow(1-NdotL/2, 5)); 53 | if (coupled_diffuse) rho_d *= (1-Rs); 54 | 55 | return vec3(rho_s + rho_d); 56 | } 57 | 58 | ::end shader 59 | -------------------------------------------------------------------------------- /src/brdfs/blinn.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Blinn implementation of Torrance-Sparrow 4 | 5 | # variables go here... 6 | # only floats supported right now. 7 | # [type] [name] [min val] [max val] [default val] 8 | 9 | ::begin parameters 10 | float n 1 100 10 11 | float ior 1 2.5 1.5 12 | bool include_Fresnel 0 13 | bool divide_by_NdotL 1 14 | ::end parameters 15 | 16 | 17 | # Then comes the shader. This should be GLSL code 18 | # that defines a function called BRDF (although you can 19 | # add whatever else you want too, like sqr() below). 20 | 21 | ::begin shader 22 | 23 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 24 | { 25 | vec3 H = normalize(L+V); 26 | 27 | float NdotH = dot(N, H); 28 | float VdotH = dot(V, H); 29 | float NdotL = dot(N, L); 30 | float NdotV = dot(N, V); 31 | 32 | float x = acos(NdotH) * n; 33 | float D = exp( -x*x); 34 | float G = (NdotV < NdotL) ? 35 | ((2*NdotV*NdotH < VdotH) ? 36 | 2*NdotH / VdotH : 37 | 1.0 / NdotV) 38 | : 39 | ((2*NdotL*NdotH < VdotH) ? 40 | 2*NdotH*NdotL / (VdotH*NdotV) : 41 | 1.0 / NdotV); 42 | 43 | // fresnel 44 | float c = VdotH; 45 | float g = sqrt(ior*ior + c*c - 1); 46 | float F = 0.5 * pow(g-c,2) / pow(g+c,2) * (1 + pow(c*(g+c)-1,2) / pow(c*(g-c)+1,2)); 47 | 48 | float val = NdotH < 0 ? 0.0 : D * G * (include_Fresnel ? F : 1.0); 49 | 50 | if (divide_by_NdotL) 51 | val = val / dot(N,L); 52 | return vec3(val); 53 | } 54 | 55 | ::end shader 56 | -------------------------------------------------------------------------------- /src/brdfs/blinnphong.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Blinn Phong based on halfway-vector 4 | 5 | # variables go here... 6 | # only floats supported right now. 7 | # [type] [name] [min val] [max val] [default val] 8 | 9 | ::begin parameters 10 | float n 1 1000 100 11 | bool divide_by_NdotL 1 12 | ::end parameters 13 | 14 | 15 | # Then comes the shader. This should be GLSL code 16 | # that defines a function called BRDF (although you can 17 | # add whatever else you want too, like sqr() below). 18 | 19 | ::begin shader 20 | 21 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 22 | { 23 | vec3 H = normalize(L+V); 24 | 25 | float val = pow(max(0,dot(N,H)),n); 26 | if (divide_by_NdotL) 27 | val = val / dot(N,L); 28 | return vec3(val); 29 | } 30 | 31 | ::end shader 32 | -------------------------------------------------------------------------------- /src/brdfs/cooktorrance.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # variables go here... 4 | # only floats supported right now. 5 | # [type] [name] [min val] [max val] [default val] 6 | 7 | ::begin parameters 8 | float m 0.001 .3 .1 9 | float f0 0 1 .1 10 | bool include_F 1 11 | bool include_G 1 12 | ::end parameters 13 | 14 | 15 | # Then comes the shader. This should be GLSL code 16 | # that defines a function called BRDF (although you can 17 | # add whatever else you want too, like sqr() below). 18 | 19 | ::begin shader 20 | 21 | float sqr(float x) { return x*x; } 22 | 23 | float Beckmann(float m, float t) 24 | { 25 | float M = m*m; 26 | float T = t*t; 27 | return exp((T-1)/(M*T)) / (M*T*T); 28 | } 29 | 30 | float Fresnel(float f0, float u) 31 | { 32 | // from Schlick 33 | return f0 + (1-f0) * pow(1-u, 5); 34 | } 35 | 36 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 37 | { 38 | // compute the half vec3 39 | vec3 H = normalize( L + V ); 40 | 41 | float NdotH = dot(N, H); 42 | float VdotH = dot(V, H); 43 | float NdotL = dot(N, L); 44 | float NdotV = dot(N, V); 45 | float oneOverNdotV = 1.0 / NdotV; 46 | 47 | float D = Beckmann(m, NdotH); 48 | float F = Fresnel(f0, VdotH); 49 | 50 | NdotH = NdotH + NdotH; 51 | float G = (NdotV < NdotL) ? 52 | ((NdotV*NdotH < VdotH) ? 53 | NdotH / VdotH : 54 | oneOverNdotV) 55 | : 56 | ((NdotL*NdotH < VdotH) ? 57 | NdotH*NdotL / (VdotH*NdotV) : 58 | oneOverNdotV); 59 | 60 | if (include_G) G = oneOverNdotV; 61 | float val = NdotH < 0 ? 0.0 : D * G ; 62 | 63 | if (include_F) val *= F; 64 | 65 | val = val / NdotL; 66 | return vec3(val); 67 | } 68 | 69 | ::end shader 70 | -------------------------------------------------------------------------------- /src/brdfs/dAniso.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | ::begin parameters 4 | float roughness 0.0001 .1 0.01 5 | bool clampLights 0 6 | float falloff 0 .25 0.1 7 | bool orient 0 8 | bool kajiya 0 9 | ::end parameters 10 | 11 | 12 | ::begin shader 13 | 14 | // Disney anisoSpecular - based on Kajiya-Kay 1989 15 | 16 | float smoothstep(float a, float b, float x) 17 | { 18 | if ( a < b ) { 19 | if ( x < a ) return 0.0; 20 | if ( x >= b ) return 1.0; 21 | x = (x - a)/(b - a); 22 | } else if (a > b) { 23 | if ( x <= b ) return 1.0; 24 | if ( x > a ) return 0.0; 25 | x = 1 - (x - b)/(a - b); 26 | } 27 | else return x < a ? 0.0 : 1.0; 28 | return x*x * (3 - 2*x); 29 | } 30 | 31 | 32 | vec3 reflect(vec3 I, vec3 N) 33 | { 34 | return 2*dot(I,N)*N - I; 35 | } 36 | 37 | 38 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 39 | { 40 | float PI = 3.14159265358979323846; 41 | vec3 T = orient ? X : Y; 42 | float glossiness = roughness != 0 ? (1/roughness) : 999999.0; 43 | float LdotN = dot(L,N); 44 | float lightAngle = acos(LdotN); 45 | float cosAngleLT = dot(L,T); 46 | float sinAngleLT = sqrt(1 - (cosAngleLT * cosAngleLT)); 47 | float cosAngleVT = dot(V,T); 48 | float spec = pow(((sinAngleLT * sqrt(1 - (cosAngleVT * cosAngleVT))) 49 | - (cosAngleLT * cosAngleVT)), 50 | glossiness); 51 | 52 | if (kajiya) { 53 | vec3 R = reflect(L,N); 54 | float t = acos(dot(L,T)) - acos(dot(R,T)); 55 | spec = pow(cos(t), glossiness); 56 | } 57 | 58 | if (clampLights) { 59 | spec *= smoothstep(0.0, falloff*0.5*PI, 0.5*PI-lightAngle); 60 | } 61 | return vec3(spec); 62 | } 63 | 64 | ::end shader 65 | -------------------------------------------------------------------------------- /src/brdfs/d_beckmann.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Beckmann distribution, from Cook-Torrance 4 | # with added 1/PI normalization factor 5 | 6 | # variables go here... 7 | # only floats supported right now. 8 | # [type] [name] [min val] [max val] [default val] 9 | 10 | ::begin parameters 11 | float m 0.001 .7 .1 12 | ::end parameters 13 | 14 | 15 | # Then comes the shader. This should be GLSL code 16 | # that defines a function called BRDF (although you can 17 | # add whatever else you want too, like sqr() below). 18 | 19 | ::begin shader 20 | 21 | const float PI = 3.14159265358979323846; 22 | 23 | float Beckmann(float m, float t) 24 | { 25 | float M = m*m; 26 | float T = t*t; 27 | return exp((T-1)/(M*T)) / (PI*M*T*T); 28 | } 29 | 30 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 31 | { 32 | // compute the half vec3 33 | vec3 H = normalize( L + V ); 34 | float NdotH = dot(N, H); 35 | 36 | float D = Beckmann(m, NdotH); 37 | return vec3(D); 38 | } 39 | 40 | ::end shader 41 | -------------------------------------------------------------------------------- /src/brdfs/d_blinnphong.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Blinn's 1977 phong variant 4 | 5 | # normalization constant: 6 | # 1/Integrate[Cos[x]^n Cos[x] Sin[x], {x, 0, Pi/2}, {phi, 0, 2 Pi} , Assumptions -> n > 0] 7 | # == (2 + n)/(2 Pi) 8 | 9 | 10 | # variables go here... 11 | # only floats supported right now. 12 | # [type] [name] [min val] [max val] [default val] 13 | 14 | ::begin parameters 15 | float n 1 1000 100 16 | bool normalized 1 17 | ::end parameters 18 | 19 | # Then comes the shader. This should be GLSL code 20 | # that defines a function called BRDF (although you can 21 | # add whatever else you want too, like sqr() below). 22 | 23 | ::begin shader 24 | 25 | const float PI = 3.14159265358979323846; 26 | 27 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 28 | { 29 | vec3 H = normalize(L+V); 30 | float D = pow(max(0, dot(N,H)),n); 31 | if (normalized) 32 | D *= (2+n) / (2*PI); 33 | return vec3(D); 34 | } 35 | 36 | ::end shader 37 | -------------------------------------------------------------------------------- /src/brdfs/d_exponential.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Exponential distribution 4 | 5 | # normalization constant 6 | # 1/Integrate[Exp[-(x/c)] Cos[x] Sin[x], {x, 0, Pi/2}, {phi, 0, 2 Pi} , Assumptions -> c > 0] 7 | # == (1 + 4 c^2)/(2 c^2 (1 + Exp[-(Pi/(2 c))]) Pi) 8 | 9 | # variables go here... 10 | # only floats supported right now. 11 | # [type] [name] [min val] [max val] [default val] 12 | 13 | ::begin parameters 14 | float c 0.001 1 .1 15 | bool normalized 1 16 | ::end parameters 17 | 18 | 19 | # Then comes the shader. This should be GLSL code 20 | # that defines a function called BRDF (although you can 21 | # add whatever else you want too, like sqr() below). 22 | 23 | ::begin shader 24 | 25 | float Exponential(float c, float t) 26 | { 27 | return exp(-t/c); 28 | } 29 | 30 | const float PI = 3.14159265358979323846; 31 | 32 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 33 | { 34 | // compute the half vec3 35 | vec3 H = normalize( L + V ); 36 | float NdotH = dot(N, H); 37 | 38 | float D = Exponential(c, acos(NdotH)); 39 | if (normalized) 40 | D *= (1 + 4*c*c)/(2*c*c*(1 + exp(-(PI/(2*c))))*PI); 41 | return vec3(D); 42 | } 43 | 44 | ::end shader 45 | -------------------------------------------------------------------------------- /src/brdfs/d_gaussian.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # variables go here... 4 | # only floats supported right now. 5 | # [type] [name] [min val] [max val] [default val] 6 | 7 | ::begin parameters 8 | float c 0.001 1 .1 9 | ::end parameters 10 | 11 | 12 | # Then comes the shader. This should be GLSL code 13 | # that defines a function called BRDF (although you can 14 | # add whatever else you want too, like sqr() below). 15 | 16 | ::begin shader 17 | 18 | float Gaussian(float c, float thetaH) 19 | { 20 | return exp(-thetaH*thetaH/(c*c)); 21 | } 22 | 23 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 24 | { 25 | // compute the half vec3 26 | vec3 H = normalize( L + V ); 27 | float NdotH = dot(N, H); 28 | 29 | float D = Gaussian(c, acos(NdotH)); 30 | return vec3(D); 31 | } 32 | 33 | ::end shader 34 | -------------------------------------------------------------------------------- /src/brdfs/d_ggx.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # ggx from Walter 07 4 | 5 | # variables go here... 6 | # only floats supported right now. 7 | # [type] [name] [min val] [max val] [default val] 8 | 9 | ::begin parameters 10 | float alpha 0.001 1 .1 11 | ::end parameters 12 | 13 | 14 | # Then comes the shader. This should be GLSL code 15 | # that defines a function called BRDF (although you can 16 | # add whatever else you want too, like sqr() below). 17 | 18 | ::begin shader 19 | const float PI = 3.14159265358979323846; 20 | 21 | float sqr(float x) { return x*x; } 22 | 23 | float GGX(float alpha, float cosThetaM) 24 | { 25 | float CosSquared = cosThetaM*cosThetaM; 26 | float TanSquared = (1-CosSquared)/CosSquared; 27 | return (1.0/PI) * sqr(alpha/(CosSquared * (alpha*alpha + TanSquared))); 28 | } 29 | 30 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 31 | { 32 | vec3 H = normalize( L + V ); 33 | float D = GGX(alpha, dot(N,H)); 34 | return vec3(D); 35 | } 36 | 37 | ::end shader 38 | -------------------------------------------------------------------------------- /src/brdfs/d_nishino.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Nishino 2009, "Directional Statistic BRDF Model" 4 | # (Hemi-EPD = hemispherical exponential power distribution) 5 | 6 | ::begin parameters 7 | float n 1 1000 100 8 | float k .1 10 1 9 | ::end parameters 10 | ::begin shader 11 | 12 | vec3 reflect(vec3 I, vec3 N) 13 | { 14 | return 2*dot(I,N)*N - I; 15 | } 16 | 17 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 18 | { 19 | float PI = 3.14159265358979323846 ; 20 | vec3 H = normalize(L+V); 21 | float NdotH = max(0,dot(N,H)); 22 | // note: k in Nishino is assumed negative - negate as used instead 23 | float epd = 1-exp(-k * pow(NdotH,n)); 24 | // the normalization constant includes gamma functions which are unavailable in glsl 25 | // float Cn = pow(n*k,1/n) / (gamma(1/n) - igamma(1/n, k) - pow(n*k, 1/n)) 26 | // some approximation is needed 27 | float Cn = 1; 28 | 29 | return vec3(Cn*epd); 30 | } 31 | 32 | ::end shader 33 | -------------------------------------------------------------------------------- /src/brdfs/d_phong.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Phong 4 | # normalization constant: 5 | # 1/Integrate[Cos[x]^n Cos[x] Sin[x], {x, 0, Pi/2}, {phi, 0, 2 Pi} , Assumptions -> n > 0] 6 | # == (2 + n)/(2 Pi) 7 | 8 | # variables go here... 9 | # only floats supported right now. 10 | # [type] [name] [min val] [max val] [default val] 11 | 12 | ::begin parameters 13 | float n 1 1000 100 14 | bool normalized 1 15 | ::end parameters 16 | 17 | # Then comes the shader. This should be GLSL code 18 | # that defines a function called BRDF (although you can 19 | # add whatever else you want too, like sqr() below). 20 | 21 | ::begin shader 22 | 23 | vec3 reflect(vec3 I, vec3 N) 24 | { 25 | return 2*dot(I,N)*N - I; 26 | } 27 | 28 | const float PI = 3.14159265358979323846; 29 | 30 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 31 | { 32 | vec3 R = reflect(L,N); 33 | float D = pow(max(0, dot(R,V)),n); 34 | if (normalized) 35 | D *= (2+n) / (2*PI); 36 | return vec3(D); 37 | } 38 | 39 | ::end shader 40 | -------------------------------------------------------------------------------- /src/brdfs/d_trowbridge_reitz.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # TrowbridgeReitz (from Blinn 77) 4 | 5 | # normalization constant added: 6 | # 1/Integrate[(c^2 / (Cos[x]^2 (c^2 - 1) + 1))^2 Cos[x] Sin[x], {x, 0, Pi/2}, {phi, 0, 2 Pi}] 7 | # == 1/(c^2 Pi) 8 | 9 | # variables go here... 10 | # only floats supported right now. 11 | # [type] [name] [min val] [max val] [default val] 12 | 13 | ::begin parameters 14 | float c 0.001 1 .1 15 | bool normalized 1 16 | ::end parameters 17 | 18 | 19 | # Then comes the shader. This should be GLSL code 20 | # that defines a function called BRDF (although you can 21 | # add whatever else you want too, like sqr() below). 22 | 23 | ::begin shader 24 | const float PI = 3.14159265358979323846; 25 | 26 | float sqr(float x) { return x*x; } 27 | 28 | float TrowbridgeReitz(float c, float cosAlpha) 29 | { 30 | float cSquared = c*c; 31 | return sqr(cSquared / (cosAlpha*cosAlpha*(cSquared-1)+1)); 32 | } 33 | 34 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 35 | { 36 | // compute the half vec3 37 | vec3 H = normalize( L + V ); 38 | float D = TrowbridgeReitz(c, dot(N,H)); 39 | if (normalized) { 40 | D *= 1/(c*c*PI); 41 | } 42 | return vec3(D); 43 | } 44 | 45 | ::end shader 46 | -------------------------------------------------------------------------------- /src/brdfs/edwards06.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Edwards halfway-vector disk 2006 4 | 5 | 6 | ::begin parameters 7 | float n 0 100 10 8 | float R 0 1 1 9 | ::end parameters 10 | 11 | 12 | ::begin shader 13 | 14 | const float PI = 3.14159265358979323846; 15 | 16 | float lump(vec3 h, float R, float n) 17 | { 18 | return (n+1)/(PI*R*R) * pow(1-dot(h,h)/(R*R), n); 19 | } 20 | 21 | 22 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 23 | { 24 | float NdotV = dot(N,V); 25 | float NdotL = dot(N,L); 26 | 27 | if (NdotL < 0 || NdotV < 0) return vec3(0); 28 | 29 | vec3 H = normalize(L+V); 30 | float NdotH = dot(N,H); 31 | float LdotH = dot(L,H); 32 | 33 | // scaling projection 34 | vec3 uH = L+V; // unnormalized H 35 | vec3 h = NdotV / dot(N,uH) * uH; 36 | vec3 huv = h - NdotV * N; 37 | 38 | // specular term (D and G) 39 | float p = lump(huv, R, n); 40 | return vec3(p * pow(NdotV, 2) / (4 * NdotL * LdotH * pow(NdotH, 3))); 41 | } 42 | 43 | ::end shader 44 | -------------------------------------------------------------------------------- /src/brdfs/f_cooktorrance.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # variables go here... 4 | # only floats supported right now. 5 | # [type] [name] [min val] [max val] [default val] 6 | 7 | ::begin parameters 8 | float ior 1 3 1.2 9 | ::end parameters 10 | 11 | 12 | # Then comes the shader. This should be GLSL code 13 | # that defines a function called BRDF (although you can 14 | # add whatever other functions you want too). 15 | 16 | ::begin shader 17 | 18 | float Fresnel(float c, float ior) 19 | { 20 | float g = sqrt(ior*ior + c*c - 1); 21 | return 0.5 * pow(g-c,2) / pow(g+c,2) * (1 + pow(c*(g+c)-1,2) / pow(c*(g-c)+1,2)); 22 | } 23 | 24 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 25 | { 26 | vec3 H = normalize(L+V); 27 | float F = Fresnel(dot(L,H), ior); 28 | return vec3(F); 29 | } 30 | 31 | ::end shader 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/brdfs/f_schlick.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # variables go here... 4 | # only floats supported right now. 5 | # [type] [name] [min val] [max val] [default val] 6 | 7 | ::begin parameters 8 | float ior 1 3 1.2 9 | ::end parameters 10 | 11 | 12 | # Then comes the shader. This should be GLSL code 13 | # that defines a function called BRDF (although you can 14 | # add whatever other functions you want too). 15 | 16 | ::begin shader 17 | 18 | float Fresnel(float f0, float u) 19 | { 20 | return f0 + (1-f0) * pow(1-u, 5); 21 | } 22 | 23 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 24 | { 25 | vec3 H = normalize(L+V); 26 | float f0 = pow((ior-1)/(ior+1), 2); 27 | float F = Fresnel(f0, dot(L,H)); 28 | return vec3(F); 29 | } 30 | 31 | ::end shader 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/brdfs/f_schlick_f0.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # variables go here... 4 | # only floats supported right now. 5 | # [type] [name] [min val] [max val] [default val] 6 | 7 | ::begin parameters 8 | float f0 0 1 0.1 9 | ::end parameters 10 | 11 | 12 | # Then comes the shader. This should be GLSL code 13 | # that defines a function called BRDF (although you can 14 | # add whatever other functions you want too). 15 | 16 | ::begin shader 17 | 18 | float Fresnel(float f0, float u) 19 | { 20 | return f0 + (1-f0) * pow(1-u, 5); 21 | } 22 | 23 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 24 | { 25 | vec3 H = normalize(L+V); 26 | float F = Fresnel(f0, dot(L,H)); 27 | return vec3(F); 28 | } 29 | 30 | ::end shader 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/brdfs/g_ap07.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Ashikhmin Premoze 2007, Distribution-based BRDFs 4 | # Note: This model didn't have an explicit G; the G is implied by factoring 5 | # out the 1/(N.L * N.V) term. 6 | 7 | # variables go here... 8 | # only floats supported right now. 9 | # [type] [name] [min val] [max val] [default val] 10 | 11 | ::begin parameters 12 | bool includeInvNdotLNdotV 0 13 | ::end parameters 14 | 15 | # Then comes the shader. This should be GLSL code 16 | # that defines a function called BRDF (although you can 17 | # add whatever else you want too, like sqr() below). 18 | 19 | ::begin shader 20 | 21 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 22 | { 23 | float NdotL = dot(N,L); 24 | float NdotV = dot(N,V); 25 | 26 | float G = NdotL*NdotV/(NdotL+NdotV - NdotL*NdotV); 27 | if (includeInvNdotLNdotV) G *= 1/(NdotL*NdotV); 28 | return vec3(G); 29 | } 30 | 31 | ::end shader 32 | -------------------------------------------------------------------------------- /src/brdfs/g_as00.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Ashikhmin Shirley 2000, An Isotropic BRDF Model 4 | # Note: This model didn't have an explicit G; the G is implied by factoring 5 | # out the 1/(N.L * N.V) term. 6 | 7 | # variables go here... 8 | # only floats supported right now. 9 | # [type] [name] [min val] [max val] [default val] 10 | 11 | ::begin parameters 12 | bool includeInvNdotLNdotV 0 13 | ::end parameters 14 | 15 | # Then comes the shader. This should be GLSL code 16 | # that defines a function called BRDF (although you can 17 | # add whatever else you want too, like sqr() below). 18 | 19 | ::begin shader 20 | 21 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 22 | { 23 | float NdotL = dot(N, L); 24 | float NdotV = dot(N, V); 25 | if (NdotL < 0 || NdotV < 0) return vec3(0); 26 | 27 | vec3 H = normalize(L+V); 28 | float HdotL = dot(H,L); 29 | 30 | float G = NdotL*NdotV/(HdotL*max(NdotL,NdotV)); 31 | if (includeInvNdotLNdotV) G *= 1/(NdotL*NdotV); 32 | return vec3(G); 33 | } 34 | 35 | ::end shader 36 | -------------------------------------------------------------------------------- /src/brdfs/g_cooktorrance.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Torrance-Sparrow G term (from Cook-Torrance) 4 | 5 | # variables go here... 6 | # only floats supported right now. 7 | # [type] [name] [min val] [max val] [default val] 8 | 9 | ::begin parameters 10 | bool includeInvNdotLNdotV 0 11 | ::end parameters 12 | 13 | # Then comes the shader. This should be GLSL code 14 | # that defines a function called BRDF (although you can 15 | # add whatever else you want too, like sqr() below). 16 | 17 | ::begin shader 18 | 19 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 20 | { 21 | vec3 H = normalize(L+V); 22 | 23 | float NdotH = dot(N, H); 24 | float VdotH = dot(V, H); 25 | float NdotL = dot(N, L); 26 | float NdotV = dot(N, V); 27 | 28 | float G = min(1.0, min(2*NdotH*NdotV / VdotH, 2*NdotH*NdotL / VdotH)); 29 | if (includeInvNdotLNdotV) G *= 1/(NdotL*NdotV); 30 | return vec3(G); 31 | } 32 | 33 | ::end shader 34 | -------------------------------------------------------------------------------- /src/brdfs/g_duer.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Duer 2010 Bounding the Albedo of the Ward Reflectance Model 4 | 5 | # Note: This model didn't have an explicit G; the G is implied by factoring 6 | # out the 1/(N.L * N.V) term. 7 | 8 | # variables go here... 9 | # only floats supported right now. 10 | # [type] [name] [min val] [max val] [default val] 11 | 12 | ::begin parameters 13 | bool includeInvNdotLNdotV 0 14 | ::end parameters 15 | 16 | 17 | # Then comes the shader. This should be GLSL code 18 | # that defines a function called BRDF (although you can 19 | # add whatever else you want too, like sqr() below). 20 | 21 | ::begin shader 22 | 23 | 24 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 25 | { 26 | float NdotL = dot(N,L); 27 | float NdotV = dot(N,V); 28 | vec3 LplusV = L + V; 29 | 30 | float G = dot(LplusV,LplusV) * pow(dot(LplusV,N),-4); 31 | if (includeInvNdotLNdotV) G *= NdotL*NdotV; 32 | return vec3(G); 33 | } 34 | 35 | ::end shader 36 | -------------------------------------------------------------------------------- /src/brdfs/g_kelemen.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Kelemen01 "A Microfacet Based Coupled Specular-Matte BRDF Model with Importance Sampling" 4 | # Note: This model didn't have an explicit G; the G is implied by factoring 5 | # out the 1/(N.L * N.V) term. 6 | 7 | # variables go here... 8 | # only floats supported right now. 9 | # [type] [name] [min val] [max val] [default val] 10 | 11 | ::begin parameters 12 | bool includeInvNdotLNdotV 0 13 | ::end parameters 14 | 15 | # Then comes the shader. This should be GLSL code 16 | # that defines a function called BRDF (although you can 17 | # add whatever else you want too, like sqr() below). 18 | 19 | ::begin shader 20 | 21 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 22 | { 23 | float NdotL = dot(N, L); 24 | float NdotV = dot(N, V); 25 | 26 | float G = NdotL*NdotV * 2/(1+dot(L,V)); 27 | if (includeInvNdotLNdotV) G *= 1/(NdotL*NdotV); 28 | return vec3(G); 29 | } 30 | 31 | ::end shader 32 | -------------------------------------------------------------------------------- /src/brdfs/g_kurt10.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Kurt10, An Anisotropic BRDF Model for Fitting and Monte Carlo Rendering 4 | # Note: This model didn't have an explicit G; the G is implied by factoring 5 | # out the 1/(N.L * N.V) term. 6 | 7 | # variables go here... 8 | # only floats supported right now. 9 | # [type] [name] [min val] [max val] [default val] 10 | 11 | ::begin parameters 12 | float alpha 0 .5 0.5 13 | bool includeInvNdotLNdotV 0 14 | ::end parameters 15 | 16 | # Then comes the shader. This should be GLSL code 17 | # that defines a function called BRDF (although you can 18 | # add whatever else you want too, like sqr() below). 19 | 20 | ::begin shader 21 | 22 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 23 | { 24 | vec3 H = normalize(L+V); 25 | float NdotL = dot(N, L); 26 | float NdotV = dot(N, V); 27 | float G = NdotL*NdotV/(dot(V,H)*pow(NdotL*NdotV, alpha)); 28 | 29 | if (includeInvNdotLNdotV) G *= 1/(NdotL*NdotV); 30 | return vec3(G); 31 | } 32 | 33 | ::end shader 34 | -------------------------------------------------------------------------------- /src/brdfs/g_neumann.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Neumann99, Compact Metallic Reflectance Models 4 | # Note: This model didn't have an explicit G; the G is implied by factoring 5 | # out the 1/(N.L * N.V) term. 6 | 7 | # variables go here... 8 | # only floats supported right now. 9 | # [type] [name] [min val] [max val] [default val] 10 | 11 | ::begin parameters 12 | bool includeInvNdotLNdotV 0 13 | ::end parameters 14 | 15 | # Then comes the shader. This should be GLSL code 16 | # that defines a function called BRDF (although you can 17 | # add whatever else you want too, like sqr() below). 18 | 19 | ::begin shader 20 | 21 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 22 | { 23 | float NdotL = dot(N, L); 24 | float NdotV = dot(N, V); 25 | float G = NdotL*NdotV/max(NdotL, NdotV); 26 | if (includeInvNdotLNdotV) G *= 1/(NdotL*NdotV); 27 | return vec3(G); 28 | } 29 | 30 | ::end shader 31 | -------------------------------------------------------------------------------- /src/brdfs/g_schlick.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Schlick94 G term 4 | 5 | # variables go here... 6 | # only floats supported right now. 7 | # [type] [name] [min val] [max val] [default val] 8 | 9 | ::begin parameters 10 | float m 0 1 .5 11 | bool includeInvNdotLNdotV 0 12 | ::end parameters 13 | 14 | # Then comes the shader. This should be GLSL code 15 | # that defines a function called BRDF (although you can 16 | # add whatever else you want too, like sqr() below). 17 | 18 | ::begin shader 19 | float PI = 3.14159265358979323846; 20 | 21 | float G(float v, float m) 22 | { 23 | float k = sqrt(2*m*m/PI); 24 | return v > 0 ? v/(v-k*v + k) : 0.0; 25 | } 26 | 27 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 28 | { 29 | float NdotL = dot(N, L); 30 | float NdotV = dot(N, V); 31 | 32 | float G = G(NdotL, m) * G(NdotV, m); 33 | if (includeInvNdotLNdotV) G *= 1/(NdotL*NdotV); 34 | return vec3(G); 35 | } 36 | 37 | ::end shader 38 | -------------------------------------------------------------------------------- /src/brdfs/g_walter07.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Walter07 G term (from GGX distribution) 4 | 5 | # variables go here... 6 | # only floats supported right now. 7 | # [type] [name] [min val] [max val] [default val] 8 | 9 | ::begin parameters 10 | float alphaG 0.001 1 .1 11 | bool includeInvNdotLNdotV 0 12 | ::end parameters 13 | 14 | # Then comes the shader. This should be GLSL code 15 | # that defines a function called BRDF (although you can 16 | # add whatever else you want too, like sqr() below). 17 | 18 | ::begin shader 19 | 20 | float G1_GGX(float Ndotv, float alphaG) 21 | { 22 | return 2/(1 + sqrt(1 + alphaG*alphaG * (1-Ndotv*Ndotv)/(Ndotv*Ndotv))); 23 | } 24 | 25 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 26 | { 27 | float NdotL = dot(N, L); 28 | float NdotV = dot(N, V); 29 | float G = G1_GGX(NdotL, alphaG) * G1_GGX(NdotV, alphaG); 30 | if (includeInvNdotLNdotV) G *= 1/(NdotL*NdotV); 31 | return vec3(G); 32 | } 33 | 34 | ::end shader 35 | -------------------------------------------------------------------------------- /src/brdfs/g_ward.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Ward 92 4 | # Note: This model didn't have an explicit G; the G is implied by factoring 5 | # out the 1/(N.L * N.V) term. 6 | 7 | # variables go here... 8 | # only floats supported right now. 9 | # [type] [name] [min val] [max val] [default val] 10 | 11 | ::begin parameters 12 | bool includeInvNdotLNdotV 0 13 | ::end parameters 14 | 15 | 16 | # Then comes the shader. This should be GLSL code 17 | # that defines a function called BRDF (although you can 18 | # add whatever else you want too, like sqr() below). 19 | 20 | ::begin shader 21 | 22 | 23 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 24 | { 25 | float G = pow( dot(N,L) * dot(N,V), 26 | includeInvNdotLNdotV ? -0.5 : 0.5 ); 27 | return vec3(G); 28 | } 29 | 30 | ::end shader 31 | -------------------------------------------------------------------------------- /src/brdfs/lambert.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # variables go here... 4 | # only floats supported right now. 5 | # [type] [name] [min val] [max val] [default val] 6 | 7 | ::begin parameters 8 | float reflectance 0.0 1.0 1.0 9 | ::end parameters 10 | 11 | 12 | # Then comes the shader. This should be GLSL code 13 | # that defines a function called BRDF (although you can 14 | # add whatever other functions you want too). 15 | 16 | ::begin shader 17 | 18 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 19 | { 20 | return vec3(reflectance / 3.14159265); 21 | } 22 | 23 | ::end shader 24 | -------------------------------------------------------------------------------- /src/brdfs/minnaert.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # variables go here... 4 | # only floats supported right now. 5 | # [type] [name] [min val] [max val] [default val] 6 | 7 | ::begin parameters 8 | float k 0.5 1 1 9 | ::end parameters 10 | 11 | 12 | # Then comes the shader. This should be GLSL code 13 | # that defines a function called BRDF (although you can 14 | # add whatever other functions you want too). 15 | 16 | ::begin shader 17 | 18 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 19 | { 20 | vec3 H = normalize(L+V); 21 | return vec3((k+1) * pow(dot(N,L)*dot(N,V), k-1) / (2*3.14159265)); 22 | } 23 | 24 | ::end shader 25 | -------------------------------------------------------------------------------- /src/brdfs/modifiedphong.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # variables go here... 4 | # only floats supported right now. 5 | # [type] [name] [min val] [max val] [default val] 6 | 7 | ::begin parameters 8 | float n 1 1000 1 9 | ::end parameters 10 | 11 | 12 | # Then comes the shader. This should be GLSL code 13 | # that defines a function called BRDF (although you can 14 | # add whatever else you want too, like sqr() below). 15 | 16 | ::begin shader 17 | 18 | vec3 reflect(vec3 I, vec3 N) 19 | { 20 | return 2*dot(I,N)*N - I; 21 | } 22 | 23 | float sqr( float x ) 24 | { 25 | return x*x; 26 | } 27 | 28 | 29 | // Phong BRDF 30 | 31 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 32 | { 33 | vec3 R = reflect(L,N); 34 | 35 | // specular 36 | float norm = (n+2)/(2*3.14159265358979323846); 37 | float val = norm * pow(max(0, dot(R,V)),n); 38 | return vec3(val); 39 | } 40 | 41 | ::end shader 42 | -------------------------------------------------------------------------------- /src/brdfs/orennayar.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # variables go here... 4 | # only floats supported right now. 5 | # [type] [name] [min val] [max val] [default val] 6 | 7 | ::begin parameters 8 | float rho 0 1 .9 9 | float sigma 0.0 90 30 10 | ::end parameters 11 | 12 | # Then comes the shader. This should be GLSL code 13 | # that defines a function called BRDF (although you can 14 | # add whatever other functions you want too). 15 | 16 | ::begin shader 17 | 18 | const float PI = 3.14159265358979323846; 19 | 20 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 21 | { 22 | float VdotN = dot(V,N); 23 | float LdotN = dot(L,N); 24 | float theta_r = acos (VdotN); 25 | float sigma2 = pow(sigma*PI/180,2); 26 | 27 | float cos_phi_diff = dot( normalize(V-N*(VdotN)), normalize(L - N*(LdotN)) ); 28 | float theta_i = acos (LdotN); 29 | float alpha = max (theta_i, theta_r); 30 | float beta = min (theta_i, theta_r); 31 | if (alpha > PI/2) return vec3(0); 32 | 33 | float C1 = 1 - 0.5 * sigma2 / (sigma2 + 0.33); 34 | float C2 = 0.45 * sigma2 / (sigma2 + 0.09); 35 | if (cos_phi_diff >= 0) C2 *= sin(alpha); 36 | else C2 *= (sin(alpha) - pow(2*beta/PI,3)); 37 | float C3 = 0.125 * sigma2 / (sigma2+0.09) * pow ((4*alpha*beta)/(PI*PI),2); 38 | float L1 = rho/PI * (C1 + cos_phi_diff * C2 * tan(beta) + (1 - abs(cos_phi_diff)) * C3 * tan((alpha+beta)/2)); 39 | float L2 = 0.17 * rho*rho / PI * sigma2/(sigma2+0.13) * (1 - cos_phi_diff*(4*beta*beta)/(PI*PI)); 40 | return vec3(L1 + L2); 41 | } 42 | 43 | ::end shader 44 | -------------------------------------------------------------------------------- /src/brdfs/phong.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # variables go here... 4 | # only floats supported right now. 5 | # [type] [name] [min val] [max val] [default val] 6 | 7 | ::begin parameters 8 | float n 1 1000 100 9 | bool divide_by_NdotL 1 10 | ::end parameters 11 | 12 | 13 | # Then comes the shader. This should be GLSL code 14 | # that defines a function called BRDF (although you can 15 | # add whatever else you want too, like sqr() below). 16 | 17 | ::begin shader 18 | 19 | vec3 reflect(vec3 I, vec3 N) 20 | { 21 | return 2*dot(I,N)*N - I; 22 | } 23 | 24 | float sqr( float x ) 25 | { 26 | return x*x; 27 | } 28 | 29 | 30 | // Phong BRDF 31 | 32 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 33 | { 34 | vec3 R = reflect(L,N); 35 | 36 | // specular 37 | float val = pow(max(0, dot(R,V)),n); 38 | if (divide_by_NdotL) 39 | val = val / dot(N,L); 40 | return vec3(val); 41 | } 42 | 43 | ::end shader 44 | -------------------------------------------------------------------------------- /src/brdfs/schlick.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Schlicks 1994 "New BRDF Model" 4 | 5 | ::begin parameters 6 | float f0 0 1 1 7 | ::end parameters 8 | 9 | 10 | ::begin shader 11 | 12 | float Fresnel(float f0, float u) 13 | { 14 | return f0 + (1-f0) * pow(1-u, 5); 15 | } 16 | 17 | 18 | 19 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 20 | { 21 | vec3 H = normalize(L+V); 22 | float val = Fresnel(f0, dot(H,L)); 23 | return vec3(val); 24 | } 25 | 26 | ::end shader 27 | -------------------------------------------------------------------------------- /src/brdfs/showAngles.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # variables go here... 4 | # only floats supported right now. 5 | # [type] [name] [min val] [max val] [default val] 6 | 7 | ::begin parameters 8 | bool show_thetaH 0 9 | bool show_thetaD 0 10 | bool show_thetaL 0 11 | bool show_thetaV 0 12 | bool show_phiH 0 13 | bool show_phiD 0 14 | bool show_phiL 0 15 | bool show_phiV 0 16 | ::end parameters 17 | 18 | 19 | # Then comes the shader. This should be GLSL code 20 | # that defines a function called BRDF (although you can 21 | # add whatever other functions you want too). 22 | 23 | ::begin shader 24 | 25 | const float PI = 3.14159265358979323846; 26 | 27 | float theta(vec3 v, vec3 N) 28 | { 29 | return acos(dot(v,N)) / (0.5*PI); 30 | } 31 | 32 | float phi(vec3 v, vec3 N, vec3 X) 33 | { 34 | vec3 Y = normalize(cross(N,X)); 35 | float costheta = clamp(dot(v,N),-1,1); 36 | float sintheta = sqrt(1-costheta*costheta); 37 | float cosphi = dot(v,X) / sintheta; 38 | float sinphi = dot(v,Y) / sintheta; 39 | float phi = acos(cosphi) / (2*PI); 40 | return sinphi < 0 ? 1-phi : phi; 41 | } 42 | 43 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 44 | { 45 | vec3 H = normalize(L+V); 46 | return vec3( 47 | show_thetaH ? theta(H,N) : 48 | show_thetaD ? theta(L,H) : 49 | show_thetaL ? theta(L,N) : 50 | show_thetaV ? theta(V,N) : 51 | show_phiH ? phi(H,N,X) : 52 | show_phiD ? phi(L,H,normalize(cross(H,cross(H,N)))) : 53 | show_phiL ? phi(L,N,X) : 54 | show_phiV ? phi(V,N,X) : .5 55 | ); 56 | } 57 | 58 | ::end shader 59 | -------------------------------------------------------------------------------- /src/brdfs/showVectors.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # variables go here... 4 | # only floats supported right now. 5 | # [type] [name] [min val] [max val] [default val] 6 | 7 | ::begin parameters 8 | bool show_X 0 9 | bool show_Y 0 10 | bool show_N 0 11 | bool show_L 0 12 | bool show_V 0 13 | bool show_H 0 14 | bool _x 0 15 | bool _y 0 16 | bool _z 0 17 | bool zeroToOne 0 18 | ::end parameters 19 | 20 | 21 | # Then comes the shader. This should be GLSL code 22 | # that defines a function called BRDF (although you can 23 | # add whatever other functions you want too). 24 | 25 | ::begin shader 26 | 27 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 28 | { 29 | vec3 H = normalize(L+V); 30 | vec3 v = 31 | show_X ? X : 32 | show_Y ? Y : 33 | show_N ? N : 34 | show_L ? L : 35 | show_V ? V : 36 | show_H ? H : 37 | vec3(0); 38 | if (zeroToOne) v = v/2 + .5; 39 | return (_x ? vec3(v[0]) : 40 | _y ? vec3(v[1]) : 41 | _z ? vec3(v[2]) : 42 | v); 43 | } 44 | 45 | ::end shader 46 | -------------------------------------------------------------------------------- /src/brdfs/stretchedphong.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | # "Stretched Phong" BRDF from "Compact Metallic Reflectance Models", Neumann et al. 1999 3 | 4 | # variables go here... 5 | # only floats supported right now. 6 | # [type] [name] [min val] [max val] [default val] 7 | 8 | ::begin parameters 9 | float Ks 0 1 1 10 | float n 1 1000 1 11 | float p 0 1 1 12 | ::end parameters 13 | 14 | 15 | # Then comes the shader. This should be GLSL code 16 | # that defines a function called BRDF (although you can 17 | # add whatever else you want too, like sqr() below). 18 | 19 | ::begin shader 20 | 21 | vec3 reflect(vec3 I, vec3 N) 22 | { 23 | return 2*dot(I,N)*N - I; 24 | } 25 | 26 | float sqr( float x ) 27 | { 28 | return x*x; 29 | } 30 | 31 | 32 | 33 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 34 | { 35 | float norm = (n+2)/(2*3.14159265358979323846); 36 | float NdotL = dot(N,L); 37 | float NdotV = dot(N,V); 38 | float LdotV = dot(L,V); 39 | 40 | float val = norm * pow(max(0, 2 * NdotL * NdotV - LdotV), n) / pow(max(NdotL, NdotV), p); 41 | return vec3(vec3(Ks * val)); 42 | } 43 | 44 | ::end shader 45 | -------------------------------------------------------------------------------- /src/brdfs/walter.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # Walter07, w/ GGX 4 | 5 | # variables go here... 6 | # only floats supported right now. 7 | # [type] [name] [min val] [max val] [default val] 8 | 9 | ::begin parameters 10 | float Kd 0 1 0 11 | float Ks 0 1 .1 12 | float alphaG 0.001 1 .1 13 | float ior 1.3 3 2 14 | bool useFresnel 0 15 | ::end parameters 16 | 17 | ::begin shader 18 | 19 | const float PI = 3.14159265358979323846; 20 | 21 | float sqr(float x) { return x*x; } 22 | 23 | float GGX(float NdotH, float alphaG) 24 | { 25 | return alphaG*alphaG / (PI * sqr(NdotH*NdotH*(alphaG*alphaG-1) + 1)); 26 | } 27 | 28 | float smithG_GGX(float Ndotv, float alphaG) 29 | { 30 | return 2/(1 + sqrt(1 + alphaG*alphaG * (1-Ndotv*Ndotv)/(Ndotv*Ndotv))); 31 | } 32 | 33 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 34 | { 35 | float NdotL = dot(N, L); 36 | float NdotV = dot(N, V); 37 | if (NdotL < 0 || NdotV < 0) return vec3(0); 38 | 39 | vec3 H = normalize(L+V); 40 | float NdotH = dot(N, H); 41 | float VdotH = dot(V, H); 42 | 43 | float D = GGX(NdotH, alphaG); 44 | float G = smithG_GGX(NdotL, alphaG) * smithG_GGX(NdotV, alphaG); 45 | 46 | // fresnel 47 | float c = VdotH; 48 | float g = sqrt(ior*ior + c*c - 1); 49 | float F = useFresnel ? 0.5 * pow(g-c,2) / pow(g+c,2) * (1 + pow(c*(g+c)-1,2) / pow(c*(g-c)+1,2)) : 1.0; 50 | 51 | float val = Kd/PI + Ks * D * G * F / (4 * NdotL * NdotV); 52 | return vec3(val); 53 | } 54 | 55 | ::end shader 56 | -------------------------------------------------------------------------------- /src/brdfs/ward.brdf: -------------------------------------------------------------------------------- 1 | analytic 2 | 3 | # variables go here... 4 | # only floats supported right now. 5 | # [type] [name] [min val] [max val] [default val] 6 | 7 | ::begin parameters 8 | float alpha_x 0 1.0 0.15 9 | float alpha_y 0 1.0 0.15 10 | color Cs 1 1 1 11 | color Cd 1 1 1 12 | bool isotropic 0 13 | ::end parameters 14 | 15 | 16 | # Then comes the shader. This should be GLSL code 17 | # that defines a function called BRDF (although you can 18 | # add whatever else you want too, like sqr() below). 19 | 20 | ::begin shader 21 | 22 | float sqr( float x ) 23 | { 24 | return x*x; 25 | } 26 | 27 | 28 | // Ward BRDF 29 | // this is the formulation specified in "Notes on the Ward BRDF" - Bruce Walter, 2005 30 | 31 | vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y ) 32 | { 33 | vec3 H = normalize(L + V); 34 | 35 | // specular 36 | float ax = alpha_x; 37 | float ay = isotropic ? alpha_x : alpha_y; 38 | float exponent = -( 39 | sqr( dot(H,X) / ax ) + 40 | sqr( dot(H,Y) / ay) 41 | ) / sqr( dot( H, N ) ); 42 | 43 | float spec = 1.0 / (4.0 * 3.14159265 * ax * ay * sqrt( dot(L,N) * dot(V, N) )); 44 | spec *= exp( exponent ); 45 | 46 | return Cd / 3.14159265 + Cs * spec; 47 | } 48 | 49 | ::end shader 50 | -------------------------------------------------------------------------------- /src/images/closeSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/images/closeSmall.png -------------------------------------------------------------------------------- /src/images/folderSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/images/folderSmall.png -------------------------------------------------------------------------------- /src/images/imageSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/images/imageSmall.png -------------------------------------------------------------------------------- /src/images/modelSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/images/modelSmall.png -------------------------------------------------------------------------------- /src/images/reloadSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/images/reloadSmall.png -------------------------------------------------------------------------------- /src/images/resetSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/images/resetSmall.png -------------------------------------------------------------------------------- /src/images/soloColorsSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/images/soloColorsSmall.png -------------------------------------------------------------------------------- /src/images/soloSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/images/soloSmall.png -------------------------------------------------------------------------------- /src/images/verasansmono.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/images/verasansmono.png -------------------------------------------------------------------------------- /src/probes/beach.penv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/probes/beach.penv -------------------------------------------------------------------------------- /src/probes/furnace.penv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/probes/furnace.penv -------------------------------------------------------------------------------- /src/probes/spot.penv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wdas/brdf/f39eb38620072814b9fbd5743e1d9b7b9a0ca18a/src/probes/spot.penv -------------------------------------------------------------------------------- /src/shaderTemplates/Plane.frag: -------------------------------------------------------------------------------- 1 | #version 410 2 | 3 | uniform vec3 drawColor; 4 | 5 | in vec3 normal; 6 | 7 | out vec4 fragColor; 8 | 9 | void main(void) 10 | { 11 | 12 | fragColor = vec4(drawColor,1); 13 | } 14 | -------------------------------------------------------------------------------- /src/shaderTemplates/Plane.vert: -------------------------------------------------------------------------------- 1 | #version 410 2 | 3 | uniform mat4 projectionMatrix; 4 | uniform mat4 modelViewMatrix; 5 | 6 | in vec3 vtx_position; 7 | in vec3 vtx_normal; 8 | 9 | out vec3 normal; 10 | 11 | void main(void) 12 | { 13 | normal = vtx_normal; 14 | gl_Position = projectionMatrix * modelViewMatrix * vec4(vtx_position,1); 15 | } 16 | -------------------------------------------------------------------------------- /src/shaderTemplates/Plots.frag: -------------------------------------------------------------------------------- 1 | #version 410 2 | 3 | uniform float thickness; 4 | const float antialias = 5.0; 5 | 6 | in vec3 v_color; 7 | in vec2 v_texCoord; 8 | 9 | out vec4 fragColor; 10 | 11 | void main(void) 12 | { 13 | float distance = v_texCoord.y; 14 | float d = abs(distance) - thickness + antialias; 15 | float alpha = 1.0; 16 | if( d > 0.0 ) 17 | { 18 | alpha = d/(antialias); 19 | alpha = exp(-alpha*alpha); 20 | } 21 | fragColor = vec4(v_color,alpha); 22 | } 23 | -------------------------------------------------------------------------------- /src/shaderTemplates/Plots.geom: -------------------------------------------------------------------------------- 1 | #version 410 2 | 3 | layout(lines) in; 4 | layout(triangle_strip, max_vertices = 6) out; 5 | 6 | uniform vec2 viewport_size; 7 | uniform float thickness; 8 | 9 | in vec3 vs_color[]; 10 | 11 | out vec3 v_color; 12 | out vec2 v_texCoord; 13 | 14 | 15 | void main(void) 16 | { 17 | vec2 start = (gl_in[0].gl_Position.xy / gl_in[0].gl_Position.w) * viewport_size; 18 | vec2 end = (gl_in[1].gl_Position.xy / gl_in[1].gl_Position.w) * viewport_size; 19 | 20 | vec2 axis = end - start; 21 | float l = length(axis); 22 | axis = normalize(axis); 23 | vec2 side = vec2(-axis.y,axis.x); 24 | 25 | vec2 a = (start + side*thickness); 26 | vec2 b = (end + side*thickness); 27 | vec2 c = (end - side*thickness); 28 | vec2 d = (start - side*thickness); 29 | 30 | gl_Position = vec4(a / viewport_size,0,1); 31 | v_color = vs_color[0]; 32 | v_texCoord = vec2(0,thickness); 33 | EmitVertex(); 34 | 35 | gl_Position = vec4(d / viewport_size,0,1); 36 | v_color = vs_color[0]; 37 | v_texCoord = vec2(0,-thickness); 38 | EmitVertex(); 39 | 40 | gl_Position = vec4(b / viewport_size,0,1); 41 | v_color = vs_color[1]; 42 | v_texCoord = vec2(l,thickness); 43 | EmitVertex(); 44 | 45 | gl_Position = vec4(c / viewport_size,0,1); 46 | v_color = vs_color[1]; 47 | v_texCoord = vec2(l,-thickness); 48 | EmitVertex(); 49 | 50 | EndPrimitive(); 51 | } 52 | -------------------------------------------------------------------------------- /src/shaderTemplates/Plots.vert: -------------------------------------------------------------------------------- 1 | #version 410 2 | 3 | uniform mat4 projectionMatrix; 4 | uniform mat4 modelViewMatrix; 5 | 6 | in vec3 vtx_position; 7 | in vec3 vtx_color; 8 | 9 | out vec3 vs_color; 10 | 11 | void main(void) 12 | { 13 | vs_color = vtx_color; 14 | gl_Position = projectionMatrix * modelViewMatrix * vec4(vtx_position,1); 15 | } 16 | -------------------------------------------------------------------------------- /src/shaderTemplates/Plots3D.vert: -------------------------------------------------------------------------------- 1 | #version 410 2 | 3 | uniform mat4 projectionMatrix; 4 | uniform mat4 modelViewMatrix; 5 | 6 | in vec3 vtx_position; 7 | in vec3 vtx_color; 8 | 9 | out vec3 vs_pos; 10 | out vec3 vs_color; 11 | 12 | void main(void) 13 | { 14 | vs_color = vtx_color; 15 | vec4 view_pos = modelViewMatrix * vec4(vtx_position,1); 16 | vs_pos = view_pos.xyz; 17 | gl_Position = projectionMatrix * view_pos; 18 | } 19 | -------------------------------------------------------------------------------- /src/shaderTemplates/Quad.vert: -------------------------------------------------------------------------------- 1 | #version 410 2 | 3 | uniform mat4 projectionMatrix; 4 | uniform mat4 modelViewMatrix; 5 | 6 | in vec2 vtx_position; 7 | in vec2 vtx_texCoord; 8 | 9 | out vec2 texCoord; 10 | 11 | void main(void) 12 | { 13 | texCoord = vtx_texCoord; 14 | gl_Position = projectionMatrix * modelViewMatrix * vec4(vtx_position,0,1); 15 | } 16 | -------------------------------------------------------------------------------- /src/shaderTemplates/Text.frag: -------------------------------------------------------------------------------- 1 | // from http://github.prideout.net/strings-inside-vertex-buffers/ 2 | 3 | #version 410 4 | 5 | uniform sampler2D Sampler; 6 | uniform vec3 TextColor; 7 | 8 | in vec2 gTexCoord; 9 | out vec4 fragColor; 10 | 11 | void main() 12 | { 13 | float A = texture(Sampler, gTexCoord).r; 14 | fragColor = vec4(TextColor, A); 15 | } 16 | -------------------------------------------------------------------------------- /src/shaderTemplates/Text.geom: -------------------------------------------------------------------------------- 1 | // from http://github.prideout.net/strings-inside-vertex-buffers/ 2 | 3 | #version 410 4 | 5 | layout(points) in; 6 | layout(triangle_strip, max_vertices = 4) out; 7 | 8 | in int vCharacter[1]; 9 | in int vPosition[1]; 10 | out vec2 gTexCoord; 11 | uniform sampler2D Sampler; 12 | 13 | uniform vec2 CellSize; 14 | uniform vec2 CellOffset; 15 | uniform vec2 RenderSize; 16 | uniform vec2 RenderOrigin; 17 | 18 | uniform mat4 projectionMatrix; 19 | uniform mat4 modelViewMatrix; 20 | 21 | void main() 22 | { 23 | // Determine the final quad's position and size: 24 | vec4 transformedOrigin = projectionMatrix * modelViewMatrix * vec4(RenderOrigin,0,1); 25 | float x = transformedOrigin.x + float(vPosition[0]) * RenderSize.x * 2; 26 | float y = transformedOrigin.y; 27 | vec4 P = vec4(x, y, 0, 1); 28 | vec4 U = vec4(1, 0, 0, 0) * RenderSize.x; 29 | vec4 V = vec4(0, 1, 0, 0) * RenderSize.y; 30 | 31 | // Determine the texture coordinates: 32 | int letter = vCharacter[0]; 33 | letter = clamp(letter - 32, 0, 96); 34 | int row = letter / 16 + 1; 35 | int col = letter % 16; 36 | float S0 = CellOffset.x + CellSize.x * col; 37 | float T0 = CellOffset.y + 1 - CellSize.y * row; 38 | float S1 = S0 + CellSize.x - CellOffset.x; 39 | float T1 = T0 + CellSize.y; 40 | 41 | // Output the quad's vertices: 42 | gTexCoord = vec2(S0, T1); gl_Position = P - U - V; EmitVertex(); 43 | gTexCoord = vec2(S1, T1); gl_Position = P + U - V; EmitVertex(); 44 | gTexCoord = vec2(S0, T0); gl_Position = P - U + V; EmitVertex(); 45 | gTexCoord = vec2(S1, T0); gl_Position = P + U + V; EmitVertex(); 46 | EndPrimitive(); 47 | } 48 | -------------------------------------------------------------------------------- /src/shaderTemplates/Text.vert: -------------------------------------------------------------------------------- 1 | // from http://github.prideout.net/strings-inside-vertex-buffers/ 2 | 3 | #version 410 4 | 5 | in int Character; 6 | out int vCharacter; 7 | out int vPosition; 8 | 9 | void main() 10 | { 11 | vCharacter = Character; 12 | vPosition = gl_VertexID; 13 | gl_Position = vec4(0, 0, 0, 1); 14 | } 15 | -------------------------------------------------------------------------------- /src/shaderTemplates/brdftemplateAnglePlotAlbedo.geom: -------------------------------------------------------------------------------- 1 | #version 410 2 | 3 | layout(lines_adjacency) in; 4 | layout(triangle_strip, max_vertices = 6) out; 5 | 6 | uniform vec2 viewport_size; 7 | uniform float thickness; 8 | 9 | in vec4 v_albedoData[]; 10 | 11 | out vec2 v_texCoord; 12 | out vec4 albedoData; 13 | 14 | void main(void) 15 | { 16 | vec2 prev = (gl_in[0].gl_Position.xy/gl_in[0].gl_Position.w) * viewport_size; 17 | vec2 start = (gl_in[1].gl_Position.xy/gl_in[1].gl_Position.w) * viewport_size; 18 | vec2 end = (gl_in[2].gl_Position.xy/gl_in[2].gl_Position.w) * viewport_size; 19 | vec2 next = (gl_in[3].gl_Position.xy/gl_in[3].gl_Position.w) * viewport_size; 20 | 21 | // determine the tangent of each of the 3 segments (previous, current, next) 22 | vec2 v0 = normalize(start-prev); 23 | vec2 v1 = normalize(end-start); 24 | vec2 v2 = normalize(next-end); 25 | 26 | // determine the normal of each of the 3 segments 27 | vec2 n0 = vec2(-v0.y, v0.x); 28 | vec2 n1 = vec2(-v1.y, v1.x); 29 | vec2 n2 = vec2(-v2.y, v2.x); 30 | 31 | // mittering 32 | vec2 miter_a = normalize(n0 + n1); // miter at start of current segment 33 | vec2 miter_b = normalize(n1 + n2); // miter at end of current segment 34 | 35 | // determine the length of the miter by projecting it onto normal and then inverse it 36 | float length_a = thickness / dot(miter_a, n1); 37 | float length_b = thickness / dot(miter_b, n1); 38 | 39 | vec2 a = (start - length_a * miter_a); 40 | vec2 b = (end - length_b * miter_b); 41 | vec2 c = (end + length_b * miter_b); 42 | vec2 d = (start + length_a * miter_a); 43 | 44 | float l = length(end - start); 45 | 46 | if( prev == start ) 47 | gl_Position = vec4((start - n1*thickness) / viewport_size,0,1); 48 | else 49 | gl_Position = vec4((a / viewport_size),0,1); 50 | v_texCoord = vec2(0,thickness); 51 | albedoData = v_albedoData[1]; 52 | EmitVertex(); 53 | 54 | if( prev == start ) 55 | gl_Position = vec4((start + n1*thickness) / viewport_size,0,1); 56 | else 57 | gl_Position = vec4((d / viewport_size),0,1); 58 | v_texCoord = vec2(0,-thickness); 59 | albedoData = v_albedoData[1]; 60 | EmitVertex(); 61 | 62 | if( end == next ) 63 | gl_Position = vec4((end - n1*thickness) / viewport_size,0,1); 64 | else 65 | gl_Position = vec4((b / viewport_size),0,1); 66 | v_texCoord = vec2(l,-thickness); 67 | albedoData = v_albedoData[2]; 68 | EmitVertex(); 69 | 70 | if( end == next ) 71 | gl_Position = vec4((end + n1*thickness) / viewport_size,0,1); 72 | else 73 | gl_Position = vec4((c / viewport_size),0,1); 74 | v_texCoord = vec2(l,thickness); 75 | albedoData = v_albedoData[2]; 76 | EmitVertex(); 77 | 78 | EndPrimitive(); 79 | } 80 | --------------------------------------------------------------------------------