├── .gitignore ├── LICENSE ├── README.md └── Shadows ├── Core ├── jName.cpp └── jName.h ├── External ├── AntTweakBar │ ├── include │ │ └── AntTweakBar.h │ └── lib │ │ ├── AntTweakBar.dll │ │ ├── AntTweakBar.lib │ │ ├── AntTweakBar64.dll │ │ ├── AntTweakBar64.lib │ │ └── Readme.txt ├── SOIL_STBI │ └── stbi_DDS_aug_c.h ├── assimp │ ├── include │ │ └── assimp │ │ │ ├── .editorconfig │ │ │ ├── BaseImporter.h │ │ │ ├── Bitmap.h │ │ │ ├── BlobIOSystem.h │ │ │ ├── ByteSwapper.h │ │ │ ├── Compiler │ │ │ ├── poppack1.h │ │ │ ├── pstdint.h │ │ │ └── pushpack1.h │ │ │ ├── CreateAnimMesh.h │ │ │ ├── DefaultIOStream.h │ │ │ ├── DefaultIOSystem.h │ │ │ ├── DefaultLogger.hpp │ │ │ ├── Defines.h │ │ │ ├── Exceptional.h │ │ │ ├── Exporter.hpp │ │ │ ├── GenericProperty.h │ │ │ ├── Hash.h │ │ │ ├── IOStream.hpp │ │ │ ├── IOStreamBuffer.h │ │ │ ├── IOSystem.hpp │ │ │ ├── Importer.hpp │ │ │ ├── LineSplitter.h │ │ │ ├── LogAux.h │ │ │ ├── LogStream.hpp │ │ │ ├── Logger.hpp │ │ │ ├── Macros.h │ │ │ ├── MathFunctions.h │ │ │ ├── MemoryIOWrapper.h │ │ │ ├── NullLogger.hpp │ │ │ ├── ParsingUtils.h │ │ │ ├── Profiler.h │ │ │ ├── ProgressHandler.hpp │ │ │ ├── RemoveComments.h │ │ │ ├── SGSpatialSort.h │ │ │ ├── SceneCombiner.h │ │ │ ├── SkeletonMeshBuilder.h │ │ │ ├── SmoothingGroups.h │ │ │ ├── SmoothingGroups.inl │ │ │ ├── SpatialSort.h │ │ │ ├── StandardShapes.h │ │ │ ├── StreamReader.h │ │ │ ├── StreamWriter.h │ │ │ ├── StringComparison.h │ │ │ ├── StringUtils.h │ │ │ ├── Subdivision.h │ │ │ ├── TinyFormatter.h │ │ │ ├── Vertex.h │ │ │ ├── XMLTools.h │ │ │ ├── ZipArchiveIOSystem.h │ │ │ ├── aabb.h │ │ │ ├── ai_assert.h │ │ │ ├── anim.h │ │ │ ├── camera.h │ │ │ ├── cexport.h │ │ │ ├── cfileio.h │ │ │ ├── cimport.h │ │ │ ├── color4.h │ │ │ ├── color4.inl │ │ │ ├── config.h │ │ │ ├── config.h.in │ │ │ ├── defs.h │ │ │ ├── fast_atof.h │ │ │ ├── importerdesc.h │ │ │ ├── irrXMLWrapper.h │ │ │ ├── light.h │ │ │ ├── material.h │ │ │ ├── material.inl │ │ │ ├── matrix3x3.h │ │ │ ├── matrix3x3.inl │ │ │ ├── matrix4x4.h │ │ │ ├── matrix4x4.inl │ │ │ ├── mesh.h │ │ │ ├── metadata.h │ │ │ ├── pbrmaterial.h │ │ │ ├── port │ │ │ └── AndroidJNI │ │ │ │ └── AndroidJNIIOSystem.h │ │ │ ├── postprocess.h │ │ │ ├── qnan.h │ │ │ ├── quaternion.h │ │ │ ├── quaternion.inl │ │ │ ├── scene.h │ │ │ ├── texture.h │ │ │ ├── types.h │ │ │ ├── vector2.h │ │ │ ├── vector2.inl │ │ │ ├── vector3.h │ │ │ ├── vector3.inl │ │ │ └── version.h │ └── lib │ │ ├── assimp-vc142-mt.dll │ │ ├── assimp-vc142-mt.exp │ │ ├── assimp-vc142-mt.lib │ │ ├── assimp-vc142-mtd.dll │ │ ├── assimp-vc142-mtd.exp │ │ └── assimp-vc142-mtd.lib ├── cityhash │ ├── city.cc │ ├── city.h │ └── citycrc.h └── cyHair │ └── cyHairFile.h ├── GLFW ├── glfw3.h └── glfw3native.h ├── Generic └── TemplateUtility.h ├── IMGUI ├── imconfig.h ├── imgui.cpp ├── imgui.h ├── imgui_demo.cpp ├── imgui_draw.cpp ├── imgui_impl_glfw.cpp ├── imgui_impl_glfw.h ├── imgui_impl_opengl3.cpp ├── imgui_impl_opengl3.h ├── imgui_internal.h ├── imgui_widgets.cpp ├── imstb_rectpack.h ├── imstb_textedit.h └── imstb_truetype.h ├── Image ├── bulb.png ├── eye.png ├── grace_probe.hdr ├── head.png ├── spot.png └── sun.png ├── Main.cpp ├── Math ├── MathUtility.h ├── Matrix.cpp ├── Matrix.h ├── Plane.cpp ├── Plane.h ├── Vector.cpp └── Vector.h ├── Shaders ├── color_only_fs.glsl ├── color_only_vs.glsl ├── common.glsl ├── compute │ ├── compute_example.glsl │ ├── compute_link_linkedlist.glsl │ └── compute_sort_linkedlist.glsl ├── fs_boundvolume.glsl ├── fs_cascade.glsl ├── fs_graph.glsl ├── fs_red.glsl ├── fs_shadowMap.glsl ├── fs_test.glsl ├── fullscreen │ ├── fs_adaptiveLuminance.glsl │ ├── fs_bloom_threshold.glsl │ ├── fs_blur.glsl │ ├── fs_blur_gaussian_horizontal.glsl │ ├── fs_blur_gaussian_vertical.glsl │ ├── fs_deepshadow.glsl │ ├── fs_deepshadow_aa.glsl │ ├── fs_expdeepshadow.glsl │ ├── fs_luminanceMap.glsl │ ├── fs_omniDirectionalShadowMap.glsl │ ├── fs_omnidirectional_blur.glsl │ ├── fs_scale.glsl │ ├── fs_tonemap.glsl │ └── vs_fullscreen_common.glsl ├── shadow.glsl ├── shadowmap │ ├── fs.glsl │ ├── fs_EVSM.glsl │ ├── fs_deepShadowMap.glsl │ ├── fs_deferred.glsl │ ├── fs_expDeepShadowMap.glsl │ ├── fs_expDeferred.glsl │ ├── fs_exponentialShadowMap.glsl │ ├── fs_hair.glsl │ ├── fs_omniDirectionalEVSM.glsl │ ├── fs_omniDirectionalExponentialShadowMap.glsl │ ├── fs_omniDirectionalShadowMap.glsl │ ├── fs_shadowMap.glsl │ ├── fs_varianceShadowMap.glsl │ ├── gs_cascadeShadowMap.glsl │ ├── gs_omniDirectionalShadowMap.glsl │ ├── vs.glsl │ ├── vs_EVSM.glsl │ ├── vs_deferred.glsl │ ├── vs_expDeepShadowMap.glsl │ ├── vs_hair.glsl │ ├── vs_omniDirectionalShadowMap.glsl │ ├── vs_shadowMap.glsl │ └── vs_varianceShadowMap.glsl ├── shadowvolume │ ├── fs.glsl │ ├── fs_ambientonly.glsl │ ├── fs_shadowvolume_cpu.glsl │ ├── fs_shadowvolume_gpu.glsl │ ├── gs_shadowvolume_gpu.glsl │ ├── vs.glsl │ ├── vs_shadowvolume_cpu.glsl │ └── vs_shadowvolume_gpu.glsl ├── tex_fs.glsl ├── tex_ui_fs.glsl ├── tex_ui_vs.glsl ├── tex_vs.glsl ├── vs_boundvolume.glsl ├── vs_cascade.glsl ├── vs_graph.glsl ├── vs_red.glsl ├── vs_shadowMap.glsl └── vs_test.glsl ├── Shadows.sln ├── Shadows.vcxproj ├── Shadows.vcxproj.filters ├── TGALoader.cpp ├── TGALoader.h ├── TinyXml2 ├── tinyxml2.cpp └── tinyxml2.h ├── glad.c ├── glad └── include │ ├── KHR │ └── khrplatform.h │ └── glad │ └── glad.h ├── glfw3.dll ├── glfw3.lib ├── glfw3dll.lib ├── jAppSettings.cpp ├── jAppSettings.h ├── jBoundPrimitiveType.h ├── jCamera.cpp ├── jCamera.h ├── jCollision.cpp ├── jCollision.h ├── jDeferredRenderer.cpp ├── jDeferredRenderer.h ├── jEngine.cpp ├── jEngine.h ├── jFile.cpp ├── jFile.h ├── jForwardRenderer.cpp ├── jForwardRenderer.h ├── jGBuffer.cpp ├── jGBuffer.h ├── jGame.cpp ├── jGame.h ├── jHairModelLoader.cpp ├── jHairModelLoader.h ├── jImageFileLoader.cpp ├── jImageFileLoader.h ├── jImageLoader.cpp ├── jImageLoader.h ├── jInputEvent.cpp ├── jInputEvent.h ├── jLight.cpp ├── jLight.h ├── jMaterial.cpp ├── jMaterial.h ├── jMeshObject.cpp ├── jMeshObject.h ├── jModelLoader.cpp ├── jModelLoader.h ├── jObject.cpp ├── jObject.h ├── jPerformanceProfile.cpp ├── jPerformanceProfile.h ├── jPipeline.cpp ├── jPipeline.h ├── jPostProcess.cpp ├── jPostProcess.h ├── jPrimitiveUtil.cpp ├── jPrimitiveUtil.h ├── jRHI.cpp ├── jRHI.h ├── jRHIType.h ├── jRHI_DirectX11.cpp ├── jRHI_DirectX11.h ├── jRHI_OpenGL.cpp ├── jRHI_OpenGL.h ├── jRHI_Vulkan.cpp ├── jRHI_Vulkan.h ├── jRenderObject.cpp ├── jRenderObject.h ├── jRenderTargetPool.cpp ├── jRenderTargetPool.h ├── jRenderer.cpp ├── jRenderer.h ├── jRendererTemplate.h ├── jSamplerStatePool.cpp ├── jSamplerStatePool.h ├── jShader.cpp ├── jShader.h ├── jShadowAppProperties.cpp ├── jShadowAppProperties.h ├── jShadowTypes.h ├── jShadowUtil.cpp ├── jShadowVolume.cpp ├── jShadowVolume.h ├── jShadowVolumeTypes.h ├── jUtil.cpp ├── jUtil.h ├── jVertexAdjacency.cpp ├── jVertexAdjacency.h ├── loadpng.cpp ├── lodepng.h ├── model ├── straight.hair └── woman.x ├── pch.cpp ├── pch.h └── stb_image.h /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Choi Jae Ho 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Shadows/Core/jName.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jName.h" 3 | 4 | std::unordered_map> jName::s_NameTable; 5 | const jName jName::Invalid; -------------------------------------------------------------------------------- /Shadows/Core/jName.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct jName 4 | { 5 | private: 6 | static std::unordered_map> s_NameTable; 7 | 8 | public: 9 | const static jName Invalid; 10 | 11 | FORCEINLINE static uint32 GenerateNameHash(const char* pName, size_t size) 12 | { 13 | return CityHash32(pName, size); 14 | } 15 | 16 | jName() = default; 17 | 18 | FORCEINLINE explicit jName(uint32 InNameHash) 19 | { 20 | NameHash = InNameHash; 21 | NameString = nullptr; 22 | NameStringLength = 0; 23 | } 24 | 25 | FORCEINLINE explicit jName(const char* pName) 26 | { 27 | Set(pName, strlen(pName)); 28 | } 29 | 30 | FORCEINLINE explicit jName(const char* pName, size_t size) 31 | { 32 | Set(pName, size); 33 | } 34 | 35 | FORCEINLINE explicit jName(const std::string& name) 36 | { 37 | Set(name.c_str(), name.length()); 38 | } 39 | 40 | FORCEINLINE jName(const jName& name) 41 | { 42 | *this = name; 43 | } 44 | 45 | FORCEINLINE void Set(const char* pName, size_t size) 46 | { 47 | check(pName); 48 | const uint32 NewNameHash = GenerateNameHash(pName, size); 49 | 50 | const auto find_it = s_NameTable.find(NewNameHash); 51 | if (s_NameTable.end() != find_it) 52 | { 53 | NameHash = NewNameHash; 54 | NameString = find_it->second->c_str(); 55 | NameStringLength = find_it->second->size(); 56 | return; 57 | } 58 | 59 | const auto it_ret = s_NameTable.emplace(NewNameHash, CreateNewName_Internal(pName, NewNameHash)); 60 | if (it_ret.second) 61 | { 62 | NameHash = NewNameHash; 63 | NameString = it_ret.first->second->c_str(); 64 | NameStringLength = it_ret.first->second->size(); 65 | return; 66 | } 67 | 68 | check(0); 69 | } 70 | 71 | FORCEINLINE operator uint32() const 72 | { 73 | check(NameHash != -1); 74 | return NameHash; 75 | } 76 | 77 | FORCEINLINE jName& operator = (const jName& In) 78 | { 79 | NameHash = In.NameHash; 80 | NameString = In.NameString; 81 | NameStringLength = In.NameStringLength; 82 | return *this; 83 | } 84 | 85 | FORCEINLINE bool operator == (const jName& rhs) const 86 | { 87 | return GetNameHash() == rhs.GetNameHash(); 88 | } 89 | 90 | FORCEINLINE bool IsValid() const { return NameHash != -1; } 91 | FORCEINLINE const char* ToStr() const 92 | { 93 | if (!IsValid()) 94 | return nullptr; 95 | 96 | if (NameString) 97 | return NameString; 98 | 99 | const auto it_find = s_NameTable.find(NameHash); 100 | if (it_find == s_NameTable.end()) 101 | return nullptr; 102 | 103 | NameString = it_find->second->c_str(); 104 | NameStringLength = it_find->second->size(); 105 | 106 | return it_find->second->c_str(); 107 | } 108 | FORCEINLINE uint32 GetNameHash() const { return NameHash; } 109 | 110 | private: 111 | FORCEINLINE static std::shared_ptr CreateNewName_Internal(const char* pName, uint32 NameHash) 112 | { 113 | check(pName); 114 | 115 | return std::shared_ptr(new std::string(pName)); 116 | } 117 | 118 | uint32 NameHash = -1; 119 | mutable const char* NameString = nullptr; 120 | mutable size_t NameStringLength = 0; 121 | }; 122 | 123 | struct jNameHashFunc 124 | { 125 | std::size_t operator()(const jName& name) const 126 | { 127 | return static_cast(name.GetNameHash()); 128 | } 129 | }; -------------------------------------------------------------------------------- /Shadows/External/AntTweakBar/lib/AntTweakBar.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/External/AntTweakBar/lib/AntTweakBar.dll -------------------------------------------------------------------------------- /Shadows/External/AntTweakBar/lib/AntTweakBar.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/External/AntTweakBar/lib/AntTweakBar.lib -------------------------------------------------------------------------------- /Shadows/External/AntTweakBar/lib/AntTweakBar64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/External/AntTweakBar/lib/AntTweakBar64.dll -------------------------------------------------------------------------------- /Shadows/External/AntTweakBar/lib/AntTweakBar64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/External/AntTweakBar/lib/AntTweakBar64.lib -------------------------------------------------------------------------------- /Shadows/External/AntTweakBar/lib/Readme.txt: -------------------------------------------------------------------------------- 1 | These files are part of the AntTweakBar library. 2 | http://anttweakbar.sourceforge.net/doc 3 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/.editorconfig: -------------------------------------------------------------------------------- 1 | # See for details 2 | 3 | [*.{h,hpp,inl}] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | trim_trailing_whitespace = true 7 | indent_size = 4 8 | indent_style = space 9 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/Compiler/poppack1.h: -------------------------------------------------------------------------------- 1 | 2 | // =============================================================================== 3 | // May be included multiple times - resets structure packing to the defaults 4 | // for all supported compilers. Reverts the changes made by #include 5 | // 6 | // Currently this works on the following compilers: 7 | // MSVC 7,8,9 8 | // GCC 9 | // BORLAND (complains about 'pack state changed but not reverted', but works) 10 | // =============================================================================== 11 | 12 | #ifndef AI_PUSHPACK_IS_DEFINED 13 | # error pushpack1.h must be included after poppack1.h 14 | #endif 15 | 16 | // reset packing to the original value 17 | #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) 18 | # pragma pack( pop ) 19 | #endif 20 | #undef PACK_STRUCT 21 | 22 | #undef AI_PUSHPACK_IS_DEFINED 23 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/Compiler/pushpack1.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | // =============================================================================== 4 | // May be included multiple times - sets structure packing to 1 5 | // for all supported compilers. #include reverts the changes. 6 | // 7 | // Currently this works on the following compilers: 8 | // MSVC 7,8,9 9 | // GCC 10 | // BORLAND (complains about 'pack state changed but not reverted', but works) 11 | // Clang 12 | // 13 | // 14 | // USAGE: 15 | // 16 | // struct StructToBePacked { 17 | // } PACK_STRUCT; 18 | // 19 | // =============================================================================== 20 | 21 | #ifdef AI_PUSHPACK_IS_DEFINED 22 | # error poppack1.h must be included after pushpack1.h 23 | #endif 24 | 25 | #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) 26 | # pragma pack(push,1) 27 | # define PACK_STRUCT 28 | #elif defined( __GNUC__ ) || defined(__clang__) 29 | # if !defined(HOST_MINGW) 30 | # define PACK_STRUCT __attribute__((__packed__)) 31 | # else 32 | # define PACK_STRUCT __attribute__((gcc_struct, __packed__)) 33 | # endif 34 | #else 35 | # error Compiler not supported 36 | #endif 37 | 38 | #if defined(_MSC_VER) 39 | // C4103: Packing was changed after the inclusion of the header, probably missing #pragma pop 40 | # pragma warning (disable : 4103) 41 | #endif 42 | 43 | #define AI_PUSHPACK_IS_DEFINED 44 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/CreateAnimMesh.h: -------------------------------------------------------------------------------- 1 | /* 2 | Open Asset Import Library (assimp) 3 | ---------------------------------------------------------------------- 4 | 5 | Copyright (c) 2006-2019, assimp team 6 | 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use of this software in source and binary forms, 11 | with or without modification, are permitted provided that the 12 | following conditions are met: 13 | 14 | * Redistributions of source code must retain the above 15 | copyright notice, this list of conditions and the 16 | following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above 19 | copyright notice, this list of conditions and the 20 | following disclaimer in the documentation and/or other 21 | materials provided with the distribution. 22 | 23 | * Neither the name of the assimp team, nor the names of its 24 | contributors may be used to endorse or promote products 25 | derived from this software without specific prior 26 | written permission of the assimp team. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | 40 | ---------------------------------------------------------------------- 41 | */ 42 | 43 | /** @file CreateAnimMesh.h 44 | * Create AnimMesh from Mesh 45 | */ 46 | #ifndef INCLUDED_AI_CREATE_ANIM_MESH_H 47 | #define INCLUDED_AI_CREATE_ANIM_MESH_H 48 | 49 | #include 50 | 51 | namespace Assimp { 52 | 53 | /** Create aiAnimMesh from aiMesh. */ 54 | ASSIMP_API aiAnimMesh *aiCreateAnimMesh(const aiMesh *mesh); 55 | 56 | } // end of namespace Assimp 57 | #endif // INCLUDED_AI_CREATE_ANIM_MESH_H 58 | 59 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/DefaultIOSystem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Open Asset Import Library (assimp) 3 | ---------------------------------------------------------------------- 4 | 5 | Copyright (c) 2006-2019, assimp team 6 | 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use of this software in source and binary forms, 11 | with or without modification, are permitted provided that the 12 | following conditions are met: 13 | 14 | * Redistributions of source code must retain the above 15 | copyright notice, this list of conditions and the 16 | following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above 19 | copyright notice, this list of conditions and the 20 | following disclaimer in the documentation and/or other 21 | materials provided with the distribution. 22 | 23 | * Neither the name of the assimp team, nor the names of its 24 | contributors may be used to endorse or promote products 25 | derived from this software without specific prior 26 | written permission of the assimp team. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | 40 | ---------------------------------------------------------------------- 41 | */ 42 | 43 | /** @file Default implementation of IOSystem using the standard C file functions */ 44 | #ifndef AI_DEFAULTIOSYSTEM_H_INC 45 | #define AI_DEFAULTIOSYSTEM_H_INC 46 | 47 | #include 48 | 49 | namespace Assimp { 50 | 51 | // --------------------------------------------------------------------------- 52 | /** Default implementation of IOSystem using the standard C file functions */ 53 | class ASSIMP_API DefaultIOSystem : public IOSystem { 54 | public: 55 | // ------------------------------------------------------------------- 56 | /** Tests for the existence of a file at the given path. */ 57 | bool Exists( const char* pFile) const; 58 | 59 | // ------------------------------------------------------------------- 60 | /** Returns the directory separator. */ 61 | char getOsSeparator() const; 62 | 63 | // ------------------------------------------------------------------- 64 | /** Open a new file with a given path. */ 65 | IOStream* Open( const char* pFile, const char* pMode = "rb"); 66 | 67 | // ------------------------------------------------------------------- 68 | /** Closes the given file and releases all resources associated with it. */ 69 | void Close( IOStream* pFile); 70 | 71 | // ------------------------------------------------------------------- 72 | /** Compare two paths */ 73 | bool ComparePaths (const char* one, const char* second) const; 74 | 75 | /** @brief get the file name of a full filepath 76 | * example: /tmp/archive.tar.gz -> archive.tar.gz 77 | */ 78 | static std::string fileName( const std::string &path ); 79 | 80 | /** @brief get the complete base name of a full filepath 81 | * example: /tmp/archive.tar.gz -> archive.tar 82 | */ 83 | static std::string completeBaseName( const std::string &path); 84 | 85 | /** @brief get the path of a full filepath 86 | * example: /tmp/archive.tar.gz -> /tmp/ 87 | */ 88 | static std::string absolutePath( const std::string &path); 89 | }; 90 | 91 | } //!ns Assimp 92 | 93 | #endif //AI_DEFAULTIOSYSTEM_H_INC 94 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/Defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | Open Asset Import Library (assimp) 3 | ---------------------------------------------------------------------- 4 | 5 | Copyright (c) 2006-2012, assimp team 6 | All rights reserved. 7 | 8 | Redistribution and use of this software in source and binary forms, 9 | with or without modification, are permitted provided that the 10 | following conditions are met: 11 | 12 | * Redistributions of source code must retain the above 13 | copyright notice, this list of conditions and the 14 | following disclaimer. 15 | 16 | * Redistributions in binary form must reproduce the above 17 | copyright notice, this list of conditions and the 18 | following disclaimer in the documentation and/or other 19 | materials provided with the distribution. 20 | 21 | * Neither the name of the assimp team, nor the names of its 22 | contributors may be used to endorse or promote products 23 | derived from this software without specific prior 24 | written permission of the assimp team. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 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 DAMAGE. 37 | 38 | ---------------------------------------------------------------------- 39 | */ 40 | 41 | // We need those constants, workaround for any platforms where nobody defined them yet 42 | #if (!defined SIZE_MAX) 43 | # define SIZE_MAX (~((size_t)0)) 44 | #endif 45 | 46 | #if (!defined UINT_MAX) 47 | # define UINT_MAX (~((unsigned int)0)) 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/Exceptional.h: -------------------------------------------------------------------------------- 1 | /* 2 | Open Asset Import Library (assimp) 3 | ---------------------------------------------------------------------- 4 | 5 | Copyright (c) 2006-2008, assimp team 6 | All rights reserved. 7 | 8 | Redistribution and use of this software in source and binary forms, 9 | with or without modification, are permitted provided that the 10 | following conditions are met: 11 | 12 | * Redistributions of source code must retain the above 13 | copyright notice, this list of conditions and the 14 | following disclaimer. 15 | 16 | * Redistributions in binary form must reproduce the above 17 | copyright notice, this list of conditions and the 18 | following disclaimer in the documentation and/or other 19 | materials provided with the distribution. 20 | 21 | * Neither the name of the assimp team, nor the names of its 22 | contributors may be used to endorse or promote products 23 | derived from this software without specific prior 24 | written permission of the assimp team. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 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 DAMAGE. 37 | 38 | ---------------------------------------------------------------------- 39 | */ 40 | 41 | #ifndef INCLUDED_EXCEPTIONAL_H 42 | #define INCLUDED_EXCEPTIONAL_H 43 | 44 | #include 45 | #include 46 | using std::runtime_error; 47 | 48 | #ifdef _MSC_VER 49 | # pragma warning(disable : 4275) 50 | #endif 51 | 52 | // --------------------------------------------------------------------------- 53 | /** FOR IMPORTER PLUGINS ONLY: Simple exception class to be thrown if an 54 | * unrecoverable error occurs while importing. Loading APIs return 55 | * NULL instead of a valid aiScene then. */ 56 | class DeadlyImportError 57 | : public runtime_error 58 | { 59 | public: 60 | /** Constructor with arguments */ 61 | explicit DeadlyImportError( const std::string& errorText) 62 | : runtime_error(errorText) 63 | { 64 | } 65 | 66 | private: 67 | }; 68 | 69 | typedef DeadlyImportError DeadlyExportError; 70 | 71 | #ifdef _MSC_VER 72 | # pragma warning(default : 4275) 73 | #endif 74 | 75 | // --------------------------------------------------------------------------- 76 | template 77 | struct ExceptionSwallower { 78 | T operator ()() const { 79 | return T(); 80 | } 81 | }; 82 | 83 | // --------------------------------------------------------------------------- 84 | template 85 | struct ExceptionSwallower { 86 | T* operator ()() const { 87 | return NULL; 88 | } 89 | }; 90 | 91 | // --------------------------------------------------------------------------- 92 | template <> 93 | struct ExceptionSwallower { 94 | aiReturn operator ()() const { 95 | try { 96 | throw; 97 | } 98 | catch (std::bad_alloc&) { 99 | return aiReturn_OUTOFMEMORY; 100 | } 101 | catch (...) { 102 | return aiReturn_FAILURE; 103 | } 104 | } 105 | }; 106 | 107 | // --------------------------------------------------------------------------- 108 | template <> 109 | struct ExceptionSwallower { 110 | void operator ()() const { 111 | return; 112 | } 113 | }; 114 | 115 | #define ASSIMP_BEGIN_EXCEPTION_REGION()\ 116 | {\ 117 | try { 118 | 119 | #define ASSIMP_END_EXCEPTION_REGION(type)\ 120 | } catch(...) {\ 121 | return ExceptionSwallower()();\ 122 | }\ 123 | } 124 | 125 | #endif // INCLUDED_EXCEPTIONAL_H 126 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/Macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2019, assimp team 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use of this software in source and binary forms, 11 | with or without modification, are permitted provided that the following 12 | conditions are met: 13 | 14 | * Redistributions of source code must retain the above 15 | copyright notice, this list of conditions and the 16 | following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above 19 | copyright notice, this list of conditions and the 20 | following disclaimer in the documentation and/or other 21 | materials provided with the distribution. 22 | 23 | * Neither the name of the assimp team, nor the names of its 24 | contributors may be used to endorse or promote products 25 | derived from this software without specific prior 26 | written permission of the assimp team. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | --------------------------------------------------------------------------- 40 | */ 41 | 42 | /* Helper macro to set a pointer to NULL in debug builds 43 | */ 44 | #if (defined ASSIMP_BUILD_DEBUG) 45 | # define AI_DEBUG_INVALIDATE_PTR(x) x = NULL; 46 | #else 47 | # define AI_DEBUG_INVALIDATE_PTR(x) 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/MathFunctions.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2016, assimp team 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use of this software in source and binary forms, 11 | with or without modification, are permitted provided that the following 12 | conditions are met: 13 | 14 | * Redistributions of source code must retain the above 15 | copyright notice, this list of conditions and the 16 | following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above 19 | copyright notice, this list of conditions and the 20 | following disclaimer in the documentation and/or other 21 | materials provided with the distribution. 22 | 23 | * Neither the name of the assimp team, nor the names of its 24 | contributors may be used to endorse or promote products 25 | derived from this software without specific prior 26 | written permission of the assimp team. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | --------------------------------------------------------------------------- 40 | */ 41 | 42 | #pragma once 43 | 44 | /** @file MathFunctions.h 45 | * @brief Implementation of math utility functions. 46 | * 47 | */ 48 | 49 | #include 50 | 51 | namespace Assimp { 52 | namespace Math { 53 | 54 | // TODO: use binary GCD for unsigned integers .... 55 | template < typename IntegerType > 56 | inline 57 | IntegerType gcd( IntegerType a, IntegerType b ) { 58 | const IntegerType zero = (IntegerType)0; 59 | while ( true ) { 60 | if ( a == zero ) 61 | return b; 62 | b %= a; 63 | 64 | if ( b == zero ) 65 | return a; 66 | a %= b; 67 | } 68 | } 69 | 70 | template < typename IntegerType > 71 | inline 72 | IntegerType lcm( IntegerType a, IntegerType b ) { 73 | const IntegerType t = gcd (a,b); 74 | if (!t) 75 | return t; 76 | return a / t * b; 77 | } 78 | 79 | template 80 | inline 81 | T getEpsilon() { 82 | return std::numeric_limits::epsilon(); 83 | } 84 | 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/NullLogger.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Open Asset Import Library (assimp) 3 | ---------------------------------------------------------------------- 4 | 5 | Copyright (c) 2006-2019, assimp team 6 | 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use of this software in source and binary forms, 11 | with or without modification, are permitted provided that the 12 | following conditions are met: 13 | 14 | * Redistributions of source code must retain the above 15 | copyright notice, this list of conditions and the 16 | following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above 19 | copyright notice, this list of conditions and the 20 | following disclaimer in the documentation and/or other 21 | materials provided with the distribution. 22 | 23 | * Neither the name of the assimp team, nor the names of its 24 | contributors may be used to endorse or promote products 25 | derived from this software without specific prior 26 | written permission of the assimp team. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | 40 | ---------------------------------------------------------------------- 41 | */ 42 | 43 | /** @file NullLogger.hpp 44 | * @brief Dummy logger 45 | */ 46 | 47 | #ifndef INCLUDED_AI_NULLLOGGER_H 48 | #define INCLUDED_AI_NULLLOGGER_H 49 | 50 | #include "Logger.hpp" 51 | 52 | namespace Assimp { 53 | 54 | // --------------------------------------------------------------------------- 55 | /** @brief CPP-API: Empty logging implementation. 56 | * 57 | * Does nothing! Used by default if the application hasn't requested a 58 | * custom logger via #DefaultLogger::set() or #DefaultLogger::create(); */ 59 | class ASSIMP_API NullLogger 60 | : public Logger { 61 | 62 | public: 63 | 64 | /** @brief Logs a debug message */ 65 | void OnDebug(const char* message) { 66 | (void)message; //this avoids compiler warnings 67 | } 68 | 69 | /** @brief Logs an info message */ 70 | void OnInfo(const char* message) { 71 | (void)message; //this avoids compiler warnings 72 | } 73 | 74 | /** @brief Logs a warning message */ 75 | void OnWarn(const char* message) { 76 | (void)message; //this avoids compiler warnings 77 | } 78 | 79 | /** @brief Logs an error message */ 80 | void OnError(const char* message) { 81 | (void)message; //this avoids compiler warnings 82 | } 83 | 84 | /** @brief Detach a still attached stream from logger */ 85 | bool attachStream(LogStream *pStream, unsigned int severity) { 86 | (void)pStream; (void)severity; //this avoids compiler warnings 87 | return false; 88 | } 89 | 90 | /** @brief Detach a still attached stream from logger */ 91 | bool detatchStream(LogStream *pStream, unsigned int severity) { 92 | (void)pStream; (void)severity; //this avoids compiler warnings 93 | return false; 94 | } 95 | 96 | private: 97 | }; 98 | } 99 | #endif // !! AI_NULLLOGGER_H_INCLUDED 100 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/Profiler.h: -------------------------------------------------------------------------------- 1 | /* 2 | Open Asset Import Library (assimp) 3 | ---------------------------------------------------------------------- 4 | 5 | Copyright (c) 2006-2019, assimp team 6 | 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use of this software in source and binary forms, 11 | with or without modification, are permitted provided that the 12 | following conditions are met: 13 | 14 | * Redistributions of source code must retain the above 15 | copyright notice, this list of conditions and the 16 | following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above 19 | copyright notice, this list of conditions and the 20 | following disclaimer in the documentation and/or other 21 | materials provided with the distribution. 22 | 23 | * Neither the name of the assimp team, nor the names of its 24 | contributors may be used to endorse or promote products 25 | derived from this software without specific prior 26 | written permission of the assimp team. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | 40 | ---------------------------------------------------------------------- 41 | */ 42 | 43 | /** @file Profiler.h 44 | * @brief Utility to measure the respective runtime of each import step 45 | */ 46 | #ifndef INCLUDED_PROFILER_H 47 | #define INCLUDED_PROFILER_H 48 | 49 | #include 50 | #include 51 | #include "TinyFormatter.h" 52 | 53 | #include 54 | 55 | namespace Assimp { 56 | namespace Profiling { 57 | 58 | using namespace Formatter; 59 | 60 | // ------------------------------------------------------------------------------------------------ 61 | /** Simple wrapper around boost::timer to simplify reporting. Timings are automatically 62 | * dumped to the log file. 63 | */ 64 | class Profiler { 65 | public: 66 | Profiler() { 67 | // empty 68 | } 69 | 70 | public: 71 | 72 | /** Start a named timer */ 73 | void BeginRegion(const std::string& region) { 74 | regions[region] = std::chrono::system_clock::now(); 75 | ASSIMP_LOG_DEBUG((format("START `"),region,"`")); 76 | } 77 | 78 | 79 | /** End a specific named timer and write its end time to the log */ 80 | void EndRegion(const std::string& region) { 81 | RegionMap::const_iterator it = regions.find(region); 82 | if (it == regions.end()) { 83 | return; 84 | } 85 | 86 | std::chrono::duration elapsedSeconds = std::chrono::system_clock::now() - regions[region]; 87 | ASSIMP_LOG_DEBUG((format("END `"),region,"`, dt= ", elapsedSeconds.count()," s")); 88 | } 89 | 90 | private: 91 | typedef std::map> RegionMap; 92 | RegionMap regions; 93 | }; 94 | 95 | } 96 | } 97 | 98 | #endif 99 | 100 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/RemoveComments.h: -------------------------------------------------------------------------------- 1 | /* 2 | Open Asset Import Library (assimp) 3 | ---------------------------------------------------------------------- 4 | 5 | Copyright (c) 2006-2019, assimp team 6 | 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use of this software in source and binary forms, 11 | with or without modification, are permitted provided that the 12 | following conditions are met: 13 | 14 | * Redistributions of source code must retain the above 15 | copyright notice, this list of conditions and the 16 | following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above 19 | copyright notice, this list of conditions and the 20 | following disclaimer in the documentation and/or other 21 | materials provided with the distribution. 22 | 23 | * Neither the name of the assimp team, nor the names of its 24 | contributors may be used to endorse or promote products 25 | derived from this software without specific prior 26 | written permission of the assimp team. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | 40 | ---------------------------------------------------------------------- 41 | */ 42 | 43 | /** @file Declares a helper class, "CommentRemover", which can be 44 | * used to remove comments (single and multi line) from a text file. 45 | */ 46 | #ifndef AI_REMOVE_COMMENTS_H_INC 47 | #define AI_REMOVE_COMMENTS_H_INC 48 | 49 | 50 | #include 51 | 52 | namespace Assimp { 53 | 54 | // --------------------------------------------------------------------------- 55 | /** \brief Helper class to remove single and multi line comments from a file 56 | * 57 | * Some mesh formats like MD5 have comments that are quite similar 58 | * to those in C or C++ so this code has been moved to a separate 59 | * module. 60 | */ 61 | class ASSIMP_API CommentRemover 62 | { 63 | // class cannot be instanced 64 | CommentRemover() {} 65 | 66 | public: 67 | 68 | //! Remove single-line comments. The end of a line is 69 | //! expected to be either NL or CR or NLCR. 70 | //! \param szComment The start sequence of the comment, e.g. "//" 71 | //! \param szBuffer Buffer to work with 72 | //! \param chReplacement Character to be used as replacement 73 | //! for commented lines. By default this is ' ' 74 | static void RemoveLineComments(const char* szComment, 75 | char* szBuffer, char chReplacement = ' '); 76 | 77 | //! Remove multi-line comments. The end of a line is 78 | //! expected to be either NL or CR or NLCR. Multi-line comments 79 | //! may not be nested (as in C). 80 | //! \param szCommentStart The start sequence of the comment, e.g. "/*" 81 | //! \param szCommentEnd The end sequence of the comment, e.g. "*/" 82 | //! \param szBuffer Buffer to work with 83 | //! \param chReplacement Character to be used as replacement 84 | //! for commented lines. By default this is ' ' 85 | static void RemoveMultiLineComments(const char* szCommentStart, 86 | const char* szCommentEnd,char* szBuffer, 87 | char chReplacement = ' '); 88 | }; 89 | } // ! Assimp 90 | 91 | #endif // !! AI_REMOVE_COMMENTS_H_INC 92 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/SmoothingGroups.h: -------------------------------------------------------------------------------- 1 | /* 2 | Open Asset Import Library (assimp) 3 | ---------------------------------------------------------------------- 4 | 5 | Copyright (c) 2006-2019, assimp team 6 | 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use of this software in source and binary forms, 11 | with or without modification, are permitted provided that the 12 | following conditions are met: 13 | 14 | * Redistributions of source code must retain the above 15 | copyright notice, this list of conditions and the 16 | following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above 19 | copyright notice, this list of conditions and the 20 | following disclaimer in the documentation and/or other 21 | materials provided with the distribution. 22 | 23 | * Neither the name of the assimp team, nor the names of its 24 | contributors may be used to endorse or promote products 25 | derived from this software without specific prior 26 | written permission of the assimp team. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | 40 | ---------------------------------------------------------------------- 41 | */ 42 | 43 | /** @file Defines the helper data structures for importing 3DS files. 44 | http://www.jalix.org/ressources/graphics/3DS/_unofficials/3ds-unofficial.txt */ 45 | 46 | #ifndef AI_SMOOTHINGGROUPS_H_INC 47 | #define AI_SMOOTHINGGROUPS_H_INC 48 | 49 | #include 50 | #include 51 | #include 52 | 53 | // --------------------------------------------------------------------------- 54 | /** Helper structure representing a face with smoothing groups assigned */ 55 | struct FaceWithSmoothingGroup { 56 | FaceWithSmoothingGroup() AI_NO_EXCEPT 57 | : mIndices() 58 | , iSmoothGroup(0) { 59 | // in debug builds set all indices to a common magic value 60 | #ifdef ASSIMP_BUILD_DEBUG 61 | this->mIndices[0] = 0xffffffff; 62 | this->mIndices[1] = 0xffffffff; 63 | this->mIndices[2] = 0xffffffff; 64 | #endif 65 | } 66 | 67 | 68 | //! Indices. .3ds is using uint16. However, after 69 | //! an unique vertex set has been generated, 70 | //! individual index values might exceed 2^16 71 | uint32_t mIndices[3]; 72 | 73 | //! specifies to which smoothing group the face belongs to 74 | uint32_t iSmoothGroup; 75 | }; 76 | 77 | // --------------------------------------------------------------------------- 78 | /** Helper structure representing a mesh whose faces have smoothing 79 | groups assigned. This allows us to reuse the code for normal computations 80 | from smoothings groups for several loaders (3DS, ASE). All of them 81 | use face structures which inherit from #FaceWithSmoothingGroup, 82 | but as they add extra members and need to be copied by value we 83 | need to use a template here. 84 | */ 85 | template 86 | struct MeshWithSmoothingGroups 87 | { 88 | //! Vertex positions 89 | std::vector mPositions; 90 | 91 | //! Face lists 92 | std::vector mFaces; 93 | 94 | //! List of normal vectors 95 | std::vector mNormals; 96 | }; 97 | 98 | // --------------------------------------------------------------------------- 99 | /** Computes normal vectors for the mesh 100 | */ 101 | template 102 | void ComputeNormalsWithSmoothingsGroups(MeshWithSmoothingGroups& sMesh); 103 | 104 | 105 | // include implementations 106 | #include "SmoothingGroups.inl" 107 | 108 | #endif // !! AI_SMOOTHINGGROUPS_H_INC 109 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/XMLTools.h: -------------------------------------------------------------------------------- 1 | /* 2 | Open Asset Import Library (assimp) 3 | ---------------------------------------------------------------------- 4 | 5 | Copyright (c) 2006-2019, assimp team 6 | 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use of this software in source and binary forms, 11 | with or without modification, are permitted provided that the 12 | following conditions are met: 13 | 14 | * Redistributions of source code must retain the above 15 | copyright notice, this list of conditions and the 16 | following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above 19 | copyright notice, this list of conditions and the 20 | following disclaimer in the documentation and/or other 21 | materials provided with the distribution. 22 | 23 | * Neither the name of the assimp team, nor the names of its 24 | contributors may be used to endorse or promote products 25 | derived from this software without specific prior 26 | written permission of the assimp team. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | 40 | ---------------------------------------------------------------------- 41 | */ 42 | 43 | #ifndef INCLUDED_ASSIMP_XML_TOOLS_H 44 | #define INCLUDED_ASSIMP_XML_TOOLS_H 45 | 46 | #include 47 | 48 | namespace Assimp { 49 | // XML escape the 5 XML special characters (",',<,> and &) in |data| 50 | // Based on http://stackoverflow.com/questions/5665231 51 | std::string XMLEscape(const std::string& data) { 52 | std::string buffer; 53 | 54 | const size_t size = data.size(); 55 | buffer.reserve(size + size / 8); 56 | for(size_t i = 0; i < size; ++i) { 57 | const char c = data[i]; 58 | switch(c) { 59 | case '&' : 60 | buffer.append("&"); 61 | break; 62 | case '\"': 63 | buffer.append("""); 64 | break; 65 | case '\'': 66 | buffer.append("'"); 67 | break; 68 | case '<' : 69 | buffer.append("<"); 70 | break; 71 | case '>' : 72 | buffer.append(">"); 73 | break; 74 | default: 75 | buffer.append(&c, 1); 76 | break; 77 | } 78 | } 79 | return buffer; 80 | } 81 | } 82 | 83 | #endif // INCLUDED_ASSIMP_XML_TOOLS_H 84 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/ZipArchiveIOSystem.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2019, assimp team 7 | 8 | 9 | 10 | All rights reserved. 11 | 12 | Redistribution and use of this software in source and binary forms, 13 | with or without modification, are permitted provided that the following 14 | conditions are met: 15 | 16 | * Redistributions of source code must retain the above 17 | copyright notice, this list of conditions and the 18 | following disclaimer. 19 | 20 | * Redistributions in binary form must reproduce the above 21 | copyright notice, this list of conditions and the 22 | following disclaimer in the documentation and/or other 23 | materials provided with the distribution. 24 | 25 | * Neither the name of the assimp team, nor the names of its 26 | contributors may be used to endorse or promote products 27 | derived from this software without specific prior 28 | written permission of the assimp team. 29 | 30 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 31 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 32 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 33 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 34 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 36 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 37 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 38 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 40 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | --------------------------------------------------------------------------- 42 | */ 43 | 44 | /** @file ZipArchiveIOSystem.h 45 | * @brief Implementation of IOSystem to read a ZIP file from another IOSystem 46 | */ 47 | 48 | #ifndef AI_ZIPARCHIVEIOSYSTEM_H_INC 49 | #define AI_ZIPARCHIVEIOSYSTEM_H_INC 50 | 51 | #include 52 | #include 53 | 54 | namespace Assimp { 55 | class ZipArchiveIOSystem : public IOSystem { 56 | public: 57 | //! Open a Zip using the proffered IOSystem 58 | ZipArchiveIOSystem(IOSystem* pIOHandler, const char *pFilename, const char* pMode = "r"); 59 | ZipArchiveIOSystem(IOSystem* pIOHandler, const std::string& rFilename, const char* pMode = "r"); 60 | virtual ~ZipArchiveIOSystem(); 61 | bool Exists(const char* pFilename) const override; 62 | char getOsSeparator() const override; 63 | IOStream* Open(const char* pFilename, const char* pMode = "rb") override; 64 | void Close(IOStream* pFile) override; 65 | 66 | // Specific to ZIP 67 | //! The file was opened and is a ZIP 68 | bool isOpen() const; 69 | 70 | //! Get the list of all files with their simplified paths 71 | //! Intended for use within Assimp library boundaries 72 | void getFileList(std::vector& rFileList) const; 73 | 74 | //! Get the list of all files with extension (must be lowercase) 75 | //! Intended for use within Assimp library boundaries 76 | void getFileListExtension(std::vector& rFileList, const std::string& extension) const; 77 | 78 | static bool isZipArchive(IOSystem* pIOHandler, const char *pFilename); 79 | static bool isZipArchive(IOSystem* pIOHandler, const std::string& rFilename); 80 | 81 | private: 82 | class Implement; 83 | Implement *pImpl = nullptr; 84 | }; 85 | } // Namespace Assimp 86 | 87 | #endif // AI_ZIPARCHIVEIOSYSTEM_H_INC 88 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/aabb.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2019, assimp team 7 | 8 | 9 | 10 | All rights reserved. 11 | 12 | Redistribution and use of this software in source and binary forms, 13 | with or without modification, are permitted provided that the following 14 | conditions are met: 15 | 16 | * Redistributions of source code must retain the above 17 | copyright notice, this list of conditions and the 18 | following disclaimer. 19 | 20 | * Redistributions in binary form must reproduce the above 21 | copyright notice, this list of conditions and the 22 | following disclaimer in the documentation and/or other 23 | materials provided with the distribution. 24 | 25 | * Neither the name of the assimp team, nor the names of its 26 | contributors may be used to endorse or promote products 27 | derived from this software without specific prior 28 | written permission of the assimp team. 29 | 30 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 31 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 32 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 33 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 34 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 36 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 37 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 38 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 40 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | --------------------------------------------------------------------------- 42 | */ 43 | 44 | #pragma once 45 | #ifndef AI_AABB_H_INC 46 | #define AI_AABB_H_INC 47 | 48 | #include 49 | 50 | struct aiAABB { 51 | C_STRUCT aiVector3D mMin; 52 | C_STRUCT aiVector3D mMax; 53 | 54 | #ifdef __cplusplus 55 | 56 | aiAABB() 57 | : mMin() 58 | , mMax() { 59 | // empty 60 | } 61 | 62 | aiAABB(const aiVector3D &min, const aiVector3D &max ) 63 | : mMin(min) 64 | , mMax(max) { 65 | // empty 66 | } 67 | 68 | ~aiAABB() { 69 | // empty 70 | } 71 | 72 | #endif 73 | }; 74 | 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/ai_assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2019, assimp team 7 | 8 | 9 | 10 | All rights reserved. 11 | 12 | Redistribution and use of this software in source and binary forms, 13 | with or without modification, are permitted provided that the following 14 | conditions are met: 15 | 16 | * Redistributions of source code must retain the above 17 | copyright notice, this list of conditions and the 18 | following disclaimer. 19 | 20 | * Redistributions in binary form must reproduce the above 21 | copyright notice, this list of conditions and the 22 | following disclaimer in the documentation and/or other 23 | materials provided with the distribution. 24 | 25 | * Neither the name of the assimp team, nor the names of its 26 | contributors may be used to endorse or promote products 27 | derived from this software without specific prior 28 | written permission of the assimp team. 29 | 30 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 31 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 32 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 33 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 34 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 36 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 37 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 38 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 40 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | --------------------------------------------------------------------------- 42 | */ 43 | #pragma once 44 | #ifndef AI_ASSERT_H_INC 45 | #define AI_ASSERT_H_INC 46 | 47 | #ifdef ASSIMP_BUILD_DEBUG 48 | # include 49 | # define ai_assert(expression) assert( expression ) 50 | # define ai_assert_entry() assert( false ) 51 | #else 52 | # define ai_assert(expression) 53 | # define ai_assert_entry() 54 | #endif // ASSIMP_BUILD_DEBUG 55 | 56 | #endif // AI_ASSERT_H_INC 57 | 58 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/color4.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2019, assimp team 7 | 8 | 9 | 10 | All rights reserved. 11 | 12 | Redistribution and use of this software in source and binary forms, 13 | with or without modification, are permitted provided that the following 14 | conditions are met: 15 | 16 | * Redistributions of source code must retain the above 17 | copyright notice, this list of conditions and the 18 | following disclaimer. 19 | 20 | * Redistributions in binary form must reproduce the above 21 | copyright notice, this list of conditions and the 22 | following disclaimer in the documentation and/or other 23 | materials provided with the distribution. 24 | 25 | * Neither the name of the assimp team, nor the names of its 26 | contributors may be used to endorse or promote products 27 | derived from this software without specific prior 28 | written permission of the assimp team. 29 | 30 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 31 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 32 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 33 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 34 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 36 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 37 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 38 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 40 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | --------------------------------------------------------------------------- 42 | */ 43 | /** @file color4.h 44 | * @brief RGBA color structure, including operators when compiling in C++ 45 | */ 46 | #pragma once 47 | #ifndef AI_COLOR4D_H_INC 48 | #define AI_COLOR4D_H_INC 49 | 50 | #include "defs.h" 51 | 52 | #ifdef __cplusplus 53 | 54 | // ---------------------------------------------------------------------------------- 55 | /** Represents a color in Red-Green-Blue space including an 56 | * alpha component. Color values range from 0 to 1. */ 57 | // ---------------------------------------------------------------------------------- 58 | template 59 | class aiColor4t 60 | { 61 | public: 62 | aiColor4t() AI_NO_EXCEPT : r(), g(), b(), a() {} 63 | aiColor4t (TReal _r, TReal _g, TReal _b, TReal _a) 64 | : r(_r), g(_g), b(_b), a(_a) {} 65 | explicit aiColor4t (TReal _r) : r(_r), g(_r), b(_r), a(_r) {} 66 | aiColor4t (const aiColor4t& o) = default; 67 | 68 | public: 69 | // combined operators 70 | const aiColor4t& operator += (const aiColor4t& o); 71 | const aiColor4t& operator -= (const aiColor4t& o); 72 | const aiColor4t& operator *= (TReal f); 73 | const aiColor4t& operator /= (TReal f); 74 | 75 | public: 76 | // comparison 77 | bool operator == (const aiColor4t& other) const; 78 | bool operator != (const aiColor4t& other) const; 79 | bool operator < (const aiColor4t& other) const; 80 | 81 | // color tuple access, rgba order 82 | inline TReal operator[](unsigned int i) const; 83 | inline TReal& operator[](unsigned int i); 84 | 85 | /** check whether a color is (close to) black */ 86 | inline bool IsBlack() const; 87 | 88 | public: 89 | 90 | // Red, green, blue and alpha color values 91 | TReal r, g, b, a; 92 | }; // !struct aiColor4D 93 | 94 | typedef aiColor4t aiColor4D; 95 | 96 | #else 97 | 98 | struct aiColor4D { 99 | ai_real r, g, b, a; 100 | }; 101 | 102 | #endif // __cplusplus 103 | 104 | #endif // AI_COLOR4D_H_INC 105 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/pbrmaterial.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2019, assimp team 7 | 8 | 9 | 10 | All rights reserved. 11 | 12 | Redistribution and use of this software in source and binary forms, 13 | with or without modification, are permitted provided that the following 14 | conditions are met: 15 | 16 | * Redistributions of source code must retain the above 17 | copyright notice, this list of conditions and the 18 | following disclaimer. 19 | 20 | * Redistributions in binary form must reproduce the above 21 | copyright notice, this list of conditions and the 22 | following disclaimer in the documentation and/or other 23 | materials provided with the distribution. 24 | 25 | * Neither the name of the assimp team, nor the names of its 26 | contributors may be used to endorse or promote products 27 | derived from this software without specific prior 28 | written permission of the assimp team. 29 | 30 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 31 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 32 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 33 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 34 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 36 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 37 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 38 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 40 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | --------------------------------------------------------------------------- 42 | */ 43 | 44 | /** @file pbrmaterial.h 45 | * @brief Defines the material system of the library 46 | */ 47 | #ifndef AI_PBRMATERIAL_H_INC 48 | #define AI_PBRMATERIAL_H_INC 49 | 50 | #define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_FACTOR "$mat.gltf.pbrMetallicRoughness.baseColorFactor", 0, 0 51 | #define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLIC_FACTOR "$mat.gltf.pbrMetallicRoughness.metallicFactor", 0, 0 52 | #define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_ROUGHNESS_FACTOR "$mat.gltf.pbrMetallicRoughness.roughnessFactor", 0, 0 53 | #define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_TEXTURE aiTextureType_DIFFUSE, 1 54 | #define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLICROUGHNESS_TEXTURE aiTextureType_UNKNOWN, 0 55 | #define AI_MATKEY_GLTF_ALPHAMODE "$mat.gltf.alphaMode", 0, 0 56 | #define AI_MATKEY_GLTF_ALPHACUTOFF "$mat.gltf.alphaCutoff", 0, 0 57 | #define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS "$mat.gltf.pbrSpecularGlossiness", 0, 0 58 | #define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS_GLOSSINESS_FACTOR "$mat.gltf.pbrMetallicRoughness.glossinessFactor", 0, 0 59 | #define AI_MATKEY_GLTF_UNLIT "$mat.gltf.unlit", 0, 0 60 | 61 | #define _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE "$tex.file.texCoord" 62 | #define _AI_MATKEY_GLTF_MAPPINGNAME_BASE "$tex.mappingname" 63 | #define _AI_MATKEY_GLTF_MAPPINGID_BASE "$tex.mappingid" 64 | #define _AI_MATKEY_GLTF_MAPPINGFILTER_MAG_BASE "$tex.mappingfiltermag" 65 | #define _AI_MATKEY_GLTF_MAPPINGFILTER_MIN_BASE "$tex.mappingfiltermin" 66 | #define _AI_MATKEY_GLTF_SCALE_BASE "$tex.scale" 67 | #define _AI_MATKEY_GLTF_STRENGTH_BASE "$tex.strength" 68 | 69 | #define AI_MATKEY_GLTF_TEXTURE_TEXCOORD(type, N) _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE, type, N 70 | #define AI_MATKEY_GLTF_MAPPINGNAME(type, N) _AI_MATKEY_GLTF_MAPPINGNAME_BASE, type, N 71 | #define AI_MATKEY_GLTF_MAPPINGID(type, N) _AI_MATKEY_GLTF_MAPPINGID_BASE, type, N 72 | #define AI_MATKEY_GLTF_MAPPINGFILTER_MAG(type, N) _AI_MATKEY_GLTF_MAPPINGFILTER_MAG_BASE, type, N 73 | #define AI_MATKEY_GLTF_MAPPINGFILTER_MIN(type, N) _AI_MATKEY_GLTF_MAPPINGFILTER_MIN_BASE, type, N 74 | #define AI_MATKEY_GLTF_TEXTURE_SCALE(type, N) _AI_MATKEY_GLTF_SCALE_BASE, type, N 75 | #define AI_MATKEY_GLTF_TEXTURE_STRENGTH(type, N) _AI_MATKEY_GLTF_STRENGTH_BASE, type, N 76 | 77 | #endif //!!AI_PBRMATERIAL_H_INC 78 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/port/AndroidJNI/AndroidJNIIOSystem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Open Asset Import Library (assimp) 3 | ---------------------------------------------------------------------- 4 | 5 | Copyright (c) 2006-2016, assimp team 6 | All rights reserved. 7 | 8 | Redistribution and use of this software in source and binary forms, 9 | with or without modification, are permitted provided that the 10 | following conditions are met: 11 | 12 | * Redistributions of source code must retain the above 13 | copyright notice, this list of conditions and the 14 | following disclaimer. 15 | 16 | * Redistributions in binary form must reproduce the above 17 | copyright notice, this list of conditions and the 18 | following disclaimer in the documentation and/or other 19 | materials provided with the distribution. 20 | 21 | * Neither the name of the assimp team, nor the names of its 22 | contributors may be used to endorse or promote products 23 | derived from this software without specific prior 24 | written permission of the assimp team. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 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 DAMAGE. 37 | 38 | ---------------------------------------------------------------------- 39 | */ 40 | 41 | /** @file Android implementation of IOSystem using the standard C file functions. 42 | * Aimed to ease the access to android assets */ 43 | 44 | #if __ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT) 45 | #ifndef AI_ANDROIDJNIIOSYSTEM_H_INC 46 | #define AI_ANDROIDJNIIOSYSTEM_H_INC 47 | 48 | #include 49 | #include 50 | #include 51 | #include 52 | 53 | namespace Assimp { 54 | 55 | // --------------------------------------------------------------------------- 56 | /** Android extension to DefaultIOSystem using the standard C file functions */ 57 | class ASSIMP_API AndroidJNIIOSystem : public DefaultIOSystem 58 | { 59 | public: 60 | 61 | /** Initialize android activity data */ 62 | std::string mApkWorkspacePath; 63 | AAssetManager* mApkAssetManager; 64 | 65 | /** Constructor. */ 66 | AndroidJNIIOSystem(ANativeActivity* activity); 67 | 68 | /** Destructor. */ 69 | ~AndroidJNIIOSystem(); 70 | 71 | // ------------------------------------------------------------------- 72 | /** Tests for the existence of a file at the given path. */ 73 | bool Exists( const char* pFile) const; 74 | 75 | // ------------------------------------------------------------------- 76 | /** Opens a file at the given path, with given mode */ 77 | IOStream* Open( const char* strFile, const char* strMode); 78 | 79 | // ------------------------------------------------------------------------------------------------ 80 | // Inits Android extractor 81 | void AndroidActivityInit(ANativeActivity* activity); 82 | 83 | // ------------------------------------------------------------------------------------------------ 84 | // Extracts android asset 85 | bool AndroidExtractAsset(std::string name); 86 | 87 | }; 88 | 89 | } //!ns Assimp 90 | 91 | #endif //AI_ANDROIDJNIIOSYSTEM_H_INC 92 | #endif //__ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT) 93 | -------------------------------------------------------------------------------- /Shadows/External/assimp/include/assimp/vector2.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2019, assimp team 7 | 8 | 9 | 10 | All rights reserved. 11 | 12 | Redistribution and use of this software in source and binary forms, 13 | with or without modification, are permitted provided that the following 14 | conditions are met: 15 | 16 | * Redistributions of source code must retain the above 17 | copyright notice, this list of conditions and the 18 | following disclaimer. 19 | 20 | * Redistributions in binary form must reproduce the above 21 | copyright notice, this list of conditions and the 22 | following disclaimer in the documentation and/or other 23 | materials provided with the distribution. 24 | 25 | * Neither the name of the assimp team, nor the names of its 26 | contributors may be used to endorse or promote products 27 | derived from this software without specific prior 28 | written permission of the assimp team. 29 | 30 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 31 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 32 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 33 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 34 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 36 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 37 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 38 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 40 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | --------------------------------------------------------------------------- 42 | */ 43 | /** @file vector2.h 44 | * @brief 2D vector structure, including operators when compiling in C++ 45 | */ 46 | #pragma once 47 | #ifndef AI_VECTOR2D_H_INC 48 | #define AI_VECTOR2D_H_INC 49 | 50 | #ifdef __cplusplus 51 | # include 52 | #else 53 | # include 54 | #endif 55 | 56 | #include "defs.h" 57 | 58 | // ---------------------------------------------------------------------------------- 59 | /** Represents a two-dimensional vector. 60 | */ 61 | 62 | #ifdef __cplusplus 63 | template 64 | class aiVector2t { 65 | public: 66 | aiVector2t () : x(), y() {} 67 | aiVector2t (TReal _x, TReal _y) : x(_x), y(_y) {} 68 | explicit aiVector2t (TReal _xyz) : x(_xyz), y(_xyz) {} 69 | aiVector2t (const aiVector2t& o) = default; 70 | 71 | void Set( TReal pX, TReal pY); 72 | TReal SquareLength() const ; 73 | TReal Length() const ; 74 | aiVector2t& Normalize(); 75 | 76 | const aiVector2t& operator += (const aiVector2t& o); 77 | const aiVector2t& operator -= (const aiVector2t& o); 78 | const aiVector2t& operator *= (TReal f); 79 | const aiVector2t& operator /= (TReal f); 80 | 81 | TReal operator[](unsigned int i) const; 82 | 83 | bool operator== (const aiVector2t& other) const; 84 | bool operator!= (const aiVector2t& other) const; 85 | 86 | bool Equal(const aiVector2t& other, TReal epsilon = 1e-6) const; 87 | 88 | aiVector2t& operator= (TReal f); 89 | const aiVector2t SymMul(const aiVector2t& o); 90 | 91 | template 92 | operator aiVector2t () const; 93 | 94 | TReal x, y; 95 | }; 96 | 97 | typedef aiVector2t aiVector2D; 98 | 99 | #else 100 | 101 | struct aiVector2D { 102 | ai_real x, y; 103 | }; 104 | 105 | #endif // __cplusplus 106 | 107 | #endif // AI_VECTOR2D_H_INC 108 | -------------------------------------------------------------------------------- /Shadows/External/assimp/lib/assimp-vc142-mt.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/External/assimp/lib/assimp-vc142-mt.dll -------------------------------------------------------------------------------- /Shadows/External/assimp/lib/assimp-vc142-mt.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/External/assimp/lib/assimp-vc142-mt.exp -------------------------------------------------------------------------------- /Shadows/External/assimp/lib/assimp-vc142-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/External/assimp/lib/assimp-vc142-mt.lib -------------------------------------------------------------------------------- /Shadows/External/assimp/lib/assimp-vc142-mtd.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/External/assimp/lib/assimp-vc142-mtd.dll -------------------------------------------------------------------------------- /Shadows/External/assimp/lib/assimp-vc142-mtd.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/External/assimp/lib/assimp-vc142-mtd.exp -------------------------------------------------------------------------------- /Shadows/External/assimp/lib/assimp-vc142-mtd.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/External/assimp/lib/assimp-vc142-mtd.lib -------------------------------------------------------------------------------- /Shadows/External/cityhash/citycrc.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 Google, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | // CityHash, by Geoff Pike and Jyrki Alakuijala 22 | // 23 | // This file declares the subset of the CityHash functions that require 24 | // _mm_crc32_u64(). See the CityHash README for details. 25 | // 26 | // Functions in the CityHash family are not suitable for cryptography. 27 | 28 | #ifndef CITY_HASH_CRC_H_ 29 | #define CITY_HASH_CRC_H_ 30 | 31 | #include 32 | 33 | // Hash function for a byte array. 34 | uint128 CityHashCrc128(const char *s, size_t len); 35 | 36 | // Hash function for a byte array. For convenience, a 128-bit seed is also 37 | // hashed into the result. 38 | uint128 CityHashCrc128WithSeed(const char *s, size_t len, uint128 seed); 39 | 40 | // Hash function for a byte array. Sets result[0] ... result[3]. 41 | void CityHashCrc256(const char *s, size_t len, uint64 *result); 42 | 43 | #endif // CITY_HASH_CRC_H_ 44 | -------------------------------------------------------------------------------- /Shadows/Generic/TemplateUtility.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | struct Int2Type 5 | { 6 | enum { value = T }; 7 | }; 8 | 9 | using true_type = Int2Type<1>; 10 | using false_type = Int2Type<0>; 11 | 12 | using identity_type = true_type; 13 | #define IdentityType identity_type() 14 | 15 | using zero_type = false_type; 16 | #define ZeroType zero_type() 17 | 18 | template 19 | FORCEINLINE T Aligned(T A, T Align) 20 | { 21 | return (A + (Align - 1)) & ~(Align - 1); 22 | } -------------------------------------------------------------------------------- /Shadows/IMGUI/imgui_impl_glfw.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Binding for GLFW 2 | // This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..) 3 | // (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) 4 | 5 | // Implemented features: 6 | // [X] Platform: Clipboard support. 7 | // [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 8 | // [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: 3 cursors types are missing from GLFW. 9 | // [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE). 10 | 11 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 12 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. 13 | // https://github.com/ocornut/imgui 14 | 15 | // About GLSL version: 16 | // The 'glsl_version' initialization parameter defaults to "#version 150" if NULL. 17 | // Only override if your GL version doesn't handle this GLSL version. Keep NULL if unsure! 18 | 19 | #pragma once 20 | 21 | struct GLFWwindow; 22 | 23 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks); 24 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks); 25 | IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown(); 26 | IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame(); 27 | 28 | // InitXXX function with 'install_callbacks=true': install GLFW callbacks. They will call user's previously installed callbacks, if any. 29 | // InitXXX function with 'install_callbacks=false': do not install GLFW callbacks. You will need to call them yourself from your own GLFW callbacks. 30 | IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods); 31 | IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset); 32 | IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); 33 | IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c); 34 | -------------------------------------------------------------------------------- /Shadows/IMGUI/imgui_impl_opengl3.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline 2 | // - Desktop GL: 3.x 4.x 3 | // - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0) 4 | // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) 5 | 6 | // Implemented features: 7 | // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. 8 | // [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bits indices. 9 | 10 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 11 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. 12 | // https://github.com/ocornut/imgui 13 | 14 | // About Desktop OpenGL function loaders: 15 | // Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers. 16 | // Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad). 17 | // You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own. 18 | 19 | // About GLSL version: 20 | // The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string. 21 | // On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es" 22 | // Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp. 23 | 24 | #pragma once 25 | 26 | // Specific OpenGL versions 27 | //#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten 28 | //#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android 29 | 30 | // Set default OpenGL3 loader to be gl3w 31 | #if !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \ 32 | && !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \ 33 | && !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \ 34 | && !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM) 35 | #define IMGUI_IMPL_OPENGL_LOADER_GL3W 36 | #endif 37 | 38 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL); 39 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown(); 40 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame(); 41 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data); 42 | 43 | // Called by Init/NewFrame/Shutdown 44 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture(); 45 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture(); 46 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects(); 47 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(); 48 | -------------------------------------------------------------------------------- /Shadows/Image/bulb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/Image/bulb.png -------------------------------------------------------------------------------- /Shadows/Image/eye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/Image/eye.png -------------------------------------------------------------------------------- /Shadows/Image/grace_probe.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/Image/grace_probe.hdr -------------------------------------------------------------------------------- /Shadows/Image/head.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/Image/head.png -------------------------------------------------------------------------------- /Shadows/Image/spot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/Image/spot.png -------------------------------------------------------------------------------- /Shadows/Image/sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/Image/sun.png -------------------------------------------------------------------------------- /Shadows/Math/MathUtility.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | static constexpr float FLOAT_TOLERANCE = 0.00001f; 4 | static constexpr float PI = 3.141592653f; 5 | 6 | template 7 | FORCEINLINE void Swap(T& A, T& B) 8 | { 9 | T t = A; 10 | A = B; 11 | B = t; 12 | } 13 | 14 | FORCEINLINE bool IsNearlyEqual(float fA, float fB, float fTolerance = FLOAT_TOLERANCE) 15 | { 16 | return fabs(fA - fB) <= fTolerance; 17 | } 18 | 19 | FORCEINLINE bool IsNearlyZero(float fValue, float fTolerance = FLOAT_TOLERANCE) 20 | { 21 | return fabs(fValue) < FLOAT_TOLERANCE; 22 | } 23 | 24 | FORCEINLINE constexpr float RadianToDegree(float fRadian) 25 | { 26 | constexpr float ToDegree = 180.0f / PI; 27 | return fRadian * ToDegree; 28 | } 29 | 30 | FORCEINLINE constexpr float DegreeToRadian(float fDegree) 31 | { 32 | constexpr float ToRadian = PI / 180.0f; 33 | return fDegree * ToRadian; 34 | } 35 | 36 | template 37 | FORCEINLINE constexpr T Clamp(T const& A, T const& Min, T const& Max) 38 | { 39 | JASSERT(Max >= Min); 40 | 41 | if (Max <= A) 42 | return Max; 43 | 44 | if (Min >= A) 45 | return Min; 46 | 47 | return A; 48 | } 49 | 50 | template 51 | FORCEINLINE constexpr T Saturate(T const& A) 52 | { 53 | return Clamp(A, T(0.0f), T(1.0f)); 54 | } 55 | 56 | template 57 | FORCEINLINE constexpr T Lerp(const T& A, const T& B, float t) 58 | { 59 | return (A + (B - A) * t); 60 | } 61 | 62 | template 63 | FORCEINLINE constexpr T Max(T const& A, T const& B) 64 | { 65 | return (A > B) ? A : B; 66 | } 67 | 68 | template 69 | FORCEINLINE constexpr T Min(T const& A, T const& B) 70 | { 71 | return (A < B) ? A : B; 72 | } -------------------------------------------------------------------------------- /Shadows/Math/Matrix.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Matrix.h" 3 | -------------------------------------------------------------------------------- /Shadows/Math/Plane.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Plane.h" 3 | -------------------------------------------------------------------------------- /Shadows/Math/Plane.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Vector.h" 4 | 5 | struct jPlane 6 | { 7 | jPlane() = default; 8 | 9 | jPlane(float nx, float ny, float nz, float distance) 10 | : n(nx, ny, nz), d(distance) 11 | {} 12 | 13 | jPlane(Vector normal, float distance) 14 | : n(normal), d(distance) 15 | {} 16 | 17 | static jPlane CreateFrustumFromThreePoints(const Vector& p0, const Vector& p1, const Vector& p2) 18 | { 19 | const auto direction0 = p1 - p0; 20 | const auto direction1 = p2 - p0; 21 | const auto normal = direction0.CrossProduct(direction1).GetNormalize(); 22 | const auto distance = p2.DotProduct(normal); 23 | return jPlane(normal, distance); 24 | } 25 | 26 | float DotProductWithNormal(const Vector& direction) 27 | { 28 | return n.DotProduct(direction); 29 | } 30 | 31 | float DotProductWithPosition(const Vector& position) 32 | { 33 | return (n.x * position.x + n.y * position.y + n.z * position.z + d); 34 | } 35 | 36 | Vector n; 37 | float d; 38 | }; 39 | -------------------------------------------------------------------------------- /Shadows/Math/Vector.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Vector.h" 3 | #include "Matrix.h" 4 | 5 | const Vector Vector::OneVector = Vector(1.0f); 6 | const Vector Vector::ZeroVector = Vector(ZeroType); 7 | const Vector Vector::FowardVector = Vector(0.0f, 0.0f, 1.0f); 8 | const Vector Vector::RightVector = Vector(1.0f, 0.0f, 0.0f); 9 | const Vector Vector::UpVector = Vector(0.0f, 1.0f, 0.0f); 10 | 11 | Vector Vector::GetEulerAngleFrom() const 12 | { 13 | // Vector::UpVector 이 기반 회전 벡터 방향으로 가정함. 14 | return Vector(acosf(y), atan2f(x, z), 0.0f); 15 | } 16 | 17 | Vector Vector::GetDirectionFromEulerAngle() const 18 | { 19 | return Matrix::MakeRotate(x, y, z).TransformDirection(Vector::UpVector); 20 | } 21 | 22 | // Vector 23 | void Vector::operator=(struct Vector2 const& vector) 24 | { 25 | x = vector.x; 26 | y = vector.y; 27 | z = 0.0f; 28 | } 29 | 30 | void Vector::operator=(struct Vector4 const& vector) 31 | { 32 | x = vector.x; 33 | y = vector.y; 34 | z = vector.y; 35 | } 36 | 37 | ////////////////////////////////////////////////////////////////////////// 38 | 39 | // Vector4 40 | const Vector4 Vector4::OneVector = Vector4(1.0f); 41 | const Vector4 Vector4::ZeroVector = Vector4(ZeroType); 42 | const Vector4 Vector4::FowardVector = Vector4(0.0f, 0.0f, 1.0f, 0.0f); 43 | const Vector4 Vector4::RightVector = Vector4(1.0f, 0.0f, 0.0f, 0.0f); 44 | const Vector4 Vector4::UpVector = Vector4(0.0f, 1.0f, 0.0f, 0.0f); 45 | const Vector4 Vector4::ColorRed = Vector4(1.0f, 0.0f, 0.0f, 1.0f); 46 | const Vector4 Vector4::ColorWhite = Vector4(1.0f, 1.0f, 1.0f, 1.0f); 47 | 48 | void Vector4::operator=(struct Vector2 const& vector) 49 | { 50 | x = vector.x; 51 | y = vector.y; 52 | z = 0.0f; 53 | w = 0.0f; 54 | } 55 | 56 | void Vector4::operator=(struct Vector const& vector) 57 | { 58 | x = vector.x; 59 | y = vector.y; 60 | z = vector.z; 61 | w = 0.0f; 62 | } 63 | 64 | ////////////////////////////////////////////////////////////////////////// 65 | 66 | 67 | // Vector2 68 | void Vector2::operator=(struct Vector const& vector) 69 | { 70 | x = vector.x; 71 | y = vector.y; 72 | } 73 | 74 | void Vector2::operator=(struct Vector4 const& vector) 75 | { 76 | x = vector.x; 77 | y = vector.y; 78 | } 79 | ////////////////////////////////////////////////////////////////////////// 80 | -------------------------------------------------------------------------------- /Shadows/Shaders/color_only_fs.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | precision mediump float; 4 | 5 | in vec4 Color_; 6 | 7 | out vec4 color; 8 | 9 | void main() 10 | { 11 | color = vec4(Color_); 12 | } -------------------------------------------------------------------------------- /Shadows/Shaders/color_only_vs.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | precision mediump float; 4 | 5 | layout(location = 0) in vec3 Pos; 6 | layout(location = 1) in vec4 Color; 7 | 8 | uniform mat4 MVP; 9 | 10 | out vec4 Color_; 11 | 12 | void main() 13 | { 14 | Color_ = Color; 15 | gl_Position = MVP * vec4(Pos, 1.0); 16 | } -------------------------------------------------------------------------------- /Shadows/Shaders/compute/compute_example.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | layout (local_size_x = 32, local_size_y = 32) in; 4 | 5 | layout (binding=0, rgba8) readonly uniform image2D img_input; 6 | layout (binding=1, rgba8) writeonly uniform image2D img_output; 7 | 8 | layout (std430, binding=2) buffer shader_data 9 | { 10 | vec4 camera_position; 11 | vec4 light_position; 12 | vec4 light_diffuse; 13 | }; 14 | 15 | layout (std430) buffer StartElementBufEntry 16 | { 17 | uint start[]; 18 | }; 19 | 20 | struct NodeData 21 | { 22 | float depth; 23 | float alpha; 24 | int next; 25 | int prev; 26 | }; 27 | 28 | layout (std430) buffer LinkedListEntryDepthAlphaNext 29 | { 30 | NodeData LinkedListData[]; 31 | }; 32 | 33 | layout (binding = 3, offset = 0) uniform atomic_uint LinkedListCounter; 34 | 35 | void AddNewLinkedList() 36 | { 37 | uint counter = atomicCounterIncrement(LinkedListCounter); 38 | LinkedListData[counter].depth = float(counter); 39 | 40 | uint originalValue = atomicExchange(start[0], counter); 41 | LinkedListData[counter].next = int(originalValue); 42 | } 43 | 44 | void main(void) 45 | { 46 | vec4 texel; 47 | ivec2 p = ivec2(gl_GlobalInvocationID.xy); 48 | 49 | //if (p.x == 1 && p.y == 1) 50 | AddNewLinkedList(); 51 | 52 | camera_position = vec4(100, 200, 300, 400); 53 | light_position = vec4(101, 201, 301, 401); 54 | light_diffuse = vec4(102, 202, 302, 402); 55 | 56 | texel = imageLoad(img_input, p); 57 | texel = vec4(1.0) - texel; 58 | imageStore(img_output, p, texel); 59 | } 60 | -------------------------------------------------------------------------------- /Shadows/Shaders/compute/compute_link_linkedlist.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | layout (local_size_x = 16, local_size_y = 8) in; 4 | 5 | #define DS_LINKED_LIST_DEPTH 50 6 | 7 | layout (std430) buffer StartElementBufEntry 8 | { 9 | int start[]; 10 | }; 11 | 12 | struct NodeData 13 | { 14 | float depth; 15 | float alpha; 16 | int next; 17 | int prev; 18 | }; 19 | 20 | layout (std430) buffer LinkedListEntryDepthAlphaNext 21 | { 22 | NodeData LinkedListData[]; 23 | }; 24 | 25 | struct NeighborData 26 | { 27 | int right; 28 | int top; 29 | }; 30 | 31 | layout (std430) buffer LinkedListEntryNeighbors 32 | { 33 | NeighborData NeighborListData[]; 34 | }; 35 | 36 | struct LocalListEntry 37 | { 38 | float depth; 39 | float alpha; 40 | }; 41 | 42 | uniform int ShadowMapWidth; 43 | uniform int ShadowMapHeight; 44 | 45 | void main(void) 46 | { 47 | ivec2 uv = ivec2(gl_GlobalInvocationID.xy); 48 | 49 | if(uv.y > (ShadowMapHeight - 1) || uv.x > (ShadowMapWidth - 1)) 50 | return; 51 | 52 | int centerStartIndex = int(start[uv.y * ShadowMapWidth + uv.x]); 53 | if (-1 == centerStartIndex) 54 | return; 55 | 56 | int rightStartIndex; 57 | int topStartIndex; 58 | 59 | if (uv.x != ShadowMapWidth - 1) 60 | rightStartIndex = int(start[uv.y * ShadowMapWidth + uv.x + 1]); 61 | else 62 | rightStartIndex = -1; 63 | 64 | if (uv.y != ShadowMapHeight - 1) 65 | topStartIndex = int(start[(uv.y + 1) * ShadowMapWidth + uv.x]); 66 | else 67 | topStartIndex = -1; 68 | 69 | NodeData currentEntryRight; 70 | NodeData currentEntryTop; 71 | if (rightStartIndex != -1) 72 | currentEntryRight = LinkedListData[rightStartIndex]; 73 | if (topStartIndex != -1) 74 | currentEntryTop = LinkedListData[topStartIndex]; 75 | 76 | NodeData temp; 77 | float depth; 78 | for(int i=0;i temp.depth) 88 | break; 89 | rightStartIndex = currentEntryRight.next; 90 | currentEntryRight = temp; 91 | } 92 | NeighborListData[centerStartIndex].right = rightStartIndex; 93 | 94 | for(int k = 0; k < DS_LINKED_LIST_DEPTH; ++k) 95 | { 96 | if(topStartIndex == -1 || currentEntryTop.next == -1) 97 | break; 98 | temp = LinkedListData[currentEntryTop.next]; 99 | if(depth > temp.depth) 100 | break; 101 | topStartIndex = currentEntryTop.next; 102 | currentEntryTop = temp; 103 | } 104 | NeighborListData[centerStartIndex].top = topStartIndex; 105 | 106 | centerStartIndex = LinkedListData[centerStartIndex].next; 107 | if(centerStartIndex == -1) 108 | break; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Shadows/Shaders/compute/compute_sort_linkedlist.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | layout (local_size_x = 16, local_size_y = 8) in; 4 | 5 | #define DS_LINKED_LIST_DEPTH 50 6 | 7 | layout (std430) buffer StartElementBufEntry 8 | { 9 | int start[]; 10 | }; 11 | 12 | struct NodeData 13 | { 14 | float depth; 15 | float alpha; 16 | int next; 17 | int prev; 18 | }; 19 | 20 | layout (std430) buffer LinkedListEntryDepthAlphaNext 21 | { 22 | NodeData LinkedListData[]; 23 | }; 24 | 25 | struct LocalListEntry 26 | { 27 | float depth; 28 | float alpha; 29 | }; 30 | 31 | uniform int ShadowMapWidth; 32 | uniform int ShadowMapHeight; 33 | 34 | void main(void) 35 | { 36 | ivec2 uv = ivec2(gl_GlobalInvocationID.xy); 37 | 38 | if(uv.y > (ShadowMapHeight - 1) || uv.x > (ShadowMapWidth - 1)) 39 | return; 40 | 41 | int startIndex = int(start[uv.y * ShadowMapWidth + uv.x]); 42 | if (-1 == startIndex) 43 | return; 44 | 45 | LocalListEntry tempList[DS_LINKED_LIST_DEPTH]; 46 | int curIndex = startIndex; 47 | int numOfList = 0; 48 | for(int i=0;i= 0) && (temp.depth < tempList[j].depth);--j) 64 | tempList[j + 1] = tempList[j]; 65 | tempList[j + 1] = temp; 66 | } 67 | 68 | float shadingBefore = 1.0; 69 | int prevIndex = -1; 70 | curIndex = startIndex; 71 | for(int i=0;i 0.0) 45 | { 46 | index = i; 47 | break; 48 | } 49 | } 50 | 51 | vec3 pos = Pos_.xyz / Pos_.w; 52 | 53 | vec3 ProjCoords = LightSpacePos[0].xyz / LightSpacePos[0].w; 54 | vec3 ProjCoords2 = LightSpacePos[1].xyz / LightSpacePos[1].w; 55 | vec3 ProjCoords3 = LightSpacePos[2].xyz / LightSpacePos[2].w; 56 | //ProjCoords = ProjCoords * 0.5 + 0.5; 57 | 58 | //if (-1.0 == index) 59 | // color = vec4(1.0, 0.0, pos.z, 1.0); 60 | //else if (0 == index) 61 | //if (ProjCoords.z < -0.01) 62 | color = vec4(Pos_.x, Pos_.y, Pos_.z, 1.0); 63 | //else 64 | // color = vec4(0.0, 0.0, 0.0, 1.0); 65 | //else if (1 == index) 66 | // color = vec4(0.0, 1.0, pos.z, 1.0); 67 | //else if (2 == index) 68 | // color = vec4(1.0, 0.0, pos.z, 1.0); 69 | } -------------------------------------------------------------------------------- /Shadows/Shaders/fs_shadowMap.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | precision mediump float; 4 | 5 | void main() 6 | { 7 | gl_FragData[0].xyz = gl_FragCoord.zzz; 8 | gl_FragData[0].w = 1.0; 9 | } -------------------------------------------------------------------------------- /Shadows/Shaders/fs_test.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | precision highp float; 4 | 5 | out vec4 color; 6 | 7 | #define NUM_CASCADES 3 8 | in vec4 LightSpacePos[NUM_CASCADES]; 9 | in vec4 Pos_; 10 | in vec4 Color_; 11 | 12 | uniform float cascadeEndsW[NUM_CASCADES]; 13 | uniform sampler2D cascade_shadow_sampler[NUM_CASCADES]; 14 | 15 | #define SHADOW_BIAS_DIRECTIONAL 0.01 16 | 17 | bool IsInRange01(vec3 pos) 18 | { 19 | return (pos.x >= 0.0 && pos.x <= 1.0 && pos.y >= 0.0 && pos.y <= 1.0 && pos.z >= 0.0 && pos.z <= 1.0); 20 | } 21 | 22 | int GetCascadeIndex(float viewSpaceZ) 23 | { 24 | for (int i = 0; i < NUM_CASCADES; ++i) 25 | { 26 | if (-viewSpaceZ < cascadeEndsW[i]) 27 | return i; 28 | } 29 | return -1; 30 | } 31 | 32 | void main() 33 | { 34 | vec4 lightClipSpacePos[NUM_CASCADES]; 35 | for (int i = 0; i < NUM_CASCADES; ++i) 36 | lightClipSpacePos[i] = (LightSpacePos[i] / LightSpacePos[i].w) * 0.5 + vec4(0.5); 37 | 38 | //float z = (Pos_.z / Pos_.w) * 0.5 + 0.5; 39 | 40 | color = vec4(0.0, 0.0, 0.0, 1.0); 41 | 42 | //int tempIndex = GetCascadeIndex(Pos_.z); 43 | //switch (tempIndex) 44 | //{ 45 | //case 0: 46 | // color = vec4(1.0, 0.0, 0.0, 0.0); 47 | // break; 48 | //case 1: 49 | // color = vec4(0.0, 1.0, 0.0, 0.0); 50 | // break; 51 | //case 2: 52 | // color = vec4(0.0, 0.0, 1.0, 0.0); 53 | // break; 54 | //} 55 | 56 | //if (IsInRange01(lightClipSpacePos[2].xyz)) 57 | //{ 58 | // color += vec4(1.0, 0.0, 0.0, 0.0); 59 | //} 60 | //else if (IsInRange01(lightClipSpacePos[1].xyz)) 61 | //{ 62 | // color += vec4(0.0, 0.0, 1.0, 0.0); 63 | //} 64 | //else if (IsInRange01(lightClipSpacePos[0].xyz)) 65 | //{ 66 | // color += vec4(0.0, 1.0, 0.0, 0.0); 67 | //} 68 | 69 | //float z = texture(cascade_shadow_sampler[0], lightClipSpacePos[0].xy).x; 70 | //color = vec4(gl_FragCoord.z, gl_FragCoord.z, gl_FragCoord.z, 1.0); 71 | //return; 72 | 73 | //for (int i = NUM_CASCADES - 1; i >= 0; --i) 74 | 75 | for (int i = 0; i < NUM_CASCADES; ++i) 76 | { 77 | if (!IsInRange01(lightClipSpacePos[i].xyz)) 78 | continue; 79 | 80 | if (lightClipSpacePos[i].z >= texture(cascade_shadow_sampler[i], lightClipSpacePos[i].xy).x + 0.01) 81 | { 82 | return; 83 | } 84 | } 85 | 86 | color = Color_; 87 | 88 | return; 89 | } -------------------------------------------------------------------------------- /Shadows/Shaders/fullscreen/fs_adaptiveLuminance.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | precision mediump float; 3 | 4 | uniform sampler2D tex_object; 5 | uniform sampler2D tex_object2; 6 | uniform vec2 PixelSize; 7 | 8 | uniform float TimeDeltaSecond; 9 | uniform float AdaptationRate; 10 | 11 | in vec2 TexCoord_; 12 | out vec4 FragColor; 13 | 14 | void main() 15 | { 16 | float currentLuminance = exp(textureLod(tex_object, vec2(0.5, 0.5), 10.0).x); 17 | float lastLuminance = texelFetch(tex_object2, ivec2(0, 0), 0).x; 18 | 19 | // Adapt the luminance using Pattanaik's technique 20 | float adaptedLuminance = lastLuminance + (currentLuminance - lastLuminance) * (1.0 - exp(-TimeDeltaSecond * AdaptationRate)); 21 | 22 | FragColor = vec4(adaptedLuminance, 0.0, 0.0, 1.0); 23 | } -------------------------------------------------------------------------------- /Shadows/Shaders/fullscreen/fs_bloom_threshold.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | precision mediump float; 3 | 4 | uniform sampler2D tex_object; 5 | uniform sampler2D tex_object2; 6 | 7 | uniform float BloomThreshold; 8 | uniform float AutoExposureKeyValue; 9 | 10 | in vec2 TexCoord_; 11 | out vec4 FragColor; 12 | 13 | // Retrieves the log-average luminance from the texture 14 | float GetAvgLuminance(sampler2D lumTex) 15 | { 16 | return texelFetch(lumTex, ivec2(0, 0), 0).x; 17 | } 18 | 19 | // Approximates luminance from an RGB value 20 | float GetLuminance(vec3 color) 21 | { 22 | return max(dot(color, vec3(0.299f, 0.587f, 0.114f)), 0.0001f); 23 | } 24 | 25 | // Determines the color based on exposure settings 26 | vec3 CalcExposedColor(vec3 color, float avgLuminance, float threshold, out float exposure) 27 | { 28 | // Use geometric mean 29 | avgLuminance = max(avgLuminance, 0.001); 30 | float keyValue = AutoExposureKeyValue; 31 | float linearExposure = (keyValue / avgLuminance); 32 | exposure = log2(max(linearExposure, 0.0001)); 33 | exposure -= threshold; 34 | return exp2(exposure) * color; 35 | } 36 | 37 | void main() 38 | { 39 | vec3 color = texture(tex_object, TexCoord_).xyz; 40 | 41 | float avgLuminance = GetAvgLuminance(tex_object2); 42 | float exposure = 0.0; 43 | float pixelLuminance = GetLuminance(color); 44 | color = CalcExposedColor(color, avgLuminance, BloomThreshold, exposure); 45 | 46 | if (dot(color, vec3(0.333)) <= 0.001) 47 | color = vec3(0.0); 48 | 49 | FragColor = vec4(color, 1.0); 50 | } 51 | -------------------------------------------------------------------------------- /Shadows/Shaders/fullscreen/fs_blur.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | precision mediump float; 3 | 4 | uniform sampler2D tex_object; 5 | uniform vec2 PixelSize; 6 | uniform float IsVertical; 7 | uniform float MaxDist; 8 | 9 | #define FILTER_STEP_COUNT 5.0 10 | #define FilterSize vec2(FILTER_STEP_COUNT, FILTER_STEP_COUNT) 11 | #define COUNT (FILTER_STEP_COUNT * 2.0 + 1.0) 12 | 13 | in vec2 TexCoord_; 14 | out vec4 FragColor; 15 | 16 | void main() 17 | { 18 | vec2 radiusUV = (FilterSize * PixelSize) / FILTER_STEP_COUNT; 19 | 20 | if (IsVertical > 0.0) 21 | { 22 | radiusUV = vec2(0.0, radiusUV.y); 23 | } 24 | else 25 | { 26 | radiusUV = vec2(radiusUV.x, 0.0); 27 | } 28 | 29 | vec4 color = vec4(0); 30 | for (float x = -FILTER_STEP_COUNT; x <= FILTER_STEP_COUNT; ++x) 31 | { 32 | vec2 offset = vec2(x, x) * radiusUV; 33 | vec2 tex = TexCoord_ + offset; 34 | 35 | if (tex.x < 0.0 || tex.x > 1.0 || tex.y < 0.0 || tex.y > 1.0) 36 | { 37 | color.x += exp(MaxDist); 38 | color.y += exp(MaxDist * MaxDist); 39 | color.w += 1.0; 40 | } 41 | else 42 | { 43 | color += texture(tex_object, tex); 44 | } 45 | } 46 | 47 | FragColor = color / COUNT; 48 | } -------------------------------------------------------------------------------- /Shadows/Shaders/fullscreen/fs_blur_gaussian_horizontal.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | precision mediump float; 3 | 4 | uniform sampler2D tex_object; 5 | uniform vec2 RenderTargetSize; 6 | uniform float BloomBlurSigma; 7 | 8 | in vec2 TexCoord_; 9 | out vec4 FragColor; 10 | 11 | // Calculates the gaussian blur weight for a given distance and sigmas 12 | float CalcGaussianWeight(int sampleDist, float sigma) 13 | { 14 | float g = 1.0f / sqrt(2.0 * 3.14159 * sigma * sigma); 15 | return (g * exp(-(sampleDist * sampleDist) / (2 * sigma * sigma))); 16 | } 17 | 18 | // Performs a gaussian blur in one direction 19 | vec4 Blur(sampler2D texObject, vec2 texCoord, vec2 texScale, float sigma) 20 | { 21 | vec4 color = vec4(0.0); 22 | for (int i = -6; i < 6; i++) 23 | { 24 | float weight = CalcGaussianWeight(i, sigma); 25 | vec2 newTexCoord = texCoord; 26 | newTexCoord += (i / RenderTargetSize) * texScale; 27 | color += texture(texObject, newTexCoord) * weight; 28 | } 29 | 30 | return color; 31 | } 32 | 33 | void main() 34 | { 35 | FragColor = Blur(tex_object, TexCoord_, vec2(1.0, 0.0), BloomBlurSigma); 36 | } 37 | -------------------------------------------------------------------------------- /Shadows/Shaders/fullscreen/fs_blur_gaussian_vertical.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | precision mediump float; 3 | 4 | uniform sampler2D tex_object; 5 | uniform vec2 RenderTargetSize; 6 | uniform float BloomBlurSigma; 7 | 8 | in vec2 TexCoord_; 9 | out vec4 FragColor; 10 | 11 | // Calculates the gaussian blur weight for a given distance and sigmas 12 | float CalcGaussianWeight(int sampleDist, float sigma) 13 | { 14 | float g = 1.0f / sqrt(2.0 * 3.14159 * sigma * sigma); 15 | return (g * exp(-(sampleDist * sampleDist) / (2 * sigma * sigma))); 16 | } 17 | 18 | // Performs a gaussian blur in one direction 19 | vec4 Blur(sampler2D texObject, vec2 texCoord, vec2 texScale, float sigma) 20 | { 21 | vec4 color = vec4(0.0); 22 | for (int i = -6; i < 6; i++) 23 | { 24 | float weight = CalcGaussianWeight(i, sigma); 25 | vec2 newTexCoord = texCoord; 26 | newTexCoord += (i / RenderTargetSize) * texScale; 27 | color += texture(texObject, newTexCoord) * weight; 28 | } 29 | 30 | return color; 31 | } 32 | 33 | void main() 34 | { 35 | FragColor = Blur(tex_object, TexCoord_, vec2(0.0, 1.0), BloomBlurSigma); 36 | } 37 | -------------------------------------------------------------------------------- /Shadows/Shaders/fullscreen/fs_deepshadow_aa.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | precision mediump float; 3 | 4 | uniform sampler2D tex_object; 5 | uniform vec2 PixelSize; 6 | 7 | in vec2 TexCoord_; 8 | out vec4 FragColor; 9 | 10 | #define AA_WEIGHT 0.5f 11 | 12 | void main() 13 | { 14 | const vec2 delta[8] = 15 | { 16 | vec2(-1, 1), vec2(1, -1), vec2(-1, 1), vec2(1, 1), 17 | vec2(-1, 0), vec2(1, 0), vec2(0, -1), vec2(0, 1) 18 | }; 19 | 20 | vec4 color = vec4(0.0,0.0,0.0,0.0); 21 | for(int i = 0 ; i < 8 ; i++) 22 | color += texture(tex_object, TexCoord_ + delta[i] * PixelSize * AA_WEIGHT); 23 | 24 | color += 2.0f * texture(tex_object, TexCoord_); 25 | FragColor = color * 1.0f / 10.0f; 26 | } 27 | -------------------------------------------------------------------------------- /Shadows/Shaders/fullscreen/fs_luminanceMap.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | precision mediump float; 3 | 4 | uniform sampler2D tex_object; 5 | uniform vec2 PixelSize; 6 | 7 | in vec2 TexCoord_; 8 | out vec4 FragColor; 9 | 10 | // Approximates luminance from an RGB value 11 | float GetLuminance(vec3 color) 12 | { 13 | return max(dot(color, vec3(0.299f, 0.587f, 0.114f)), 0.0001f); 14 | } 15 | 16 | void main() 17 | { 18 | vec4 color = texture(tex_object, TexCoord_); 19 | float luminance = log(max(GetLuminance(color.xyz), 0.00001f)); 20 | FragColor = vec4(luminance, 0.0, 0.0, 1.0); 21 | } -------------------------------------------------------------------------------- /Shadows/Shaders/fullscreen/fs_omniDirectionalShadowMap.glsl: -------------------------------------------------------------------------------- 1 | #include "common.glsl" 2 | 3 | precision mediump float; 4 | 5 | #define MAX_NUM_OF_POINT_LIGHT 3 6 | #define MAX_NUM_OF_SPOT_LIGHT 3 7 | 8 | uniform int NumOfPointLight; 9 | uniform int NumOfSpotLight; 10 | 11 | uniform jPointLight PointLight[MAX_NUM_OF_POINT_LIGHT]; 12 | uniform jSpotLight SpotLight[MAX_NUM_OF_SPOT_LIGHT]; 13 | 14 | varying vec3 Pos_; 15 | 16 | void main() 17 | { 18 | if (NumOfPointLight > 0) 19 | { 20 | vec3 lightDir = Pos_ - PointLight[0].LightPos; 21 | 22 | float dist = dot(lightDir.xyz, lightDir.xyz); 23 | gl_FragData[0].x = dist; 24 | gl_FragData[0].y = sqrt(dist); 25 | gl_FragData[0].w = 1.0; 26 | } 27 | else if (NumOfSpotLight > 0) 28 | { 29 | vec3 lightDir = Pos_ - SpotLight[0].LightPos; 30 | 31 | float dist = dot(lightDir.xyz, lightDir.xyz); 32 | gl_FragData[0].x = dist; 33 | gl_FragData[0].y = sqrt(dist); 34 | gl_FragData[0].w = 1.0; 35 | } 36 | } -------------------------------------------------------------------------------- /Shadows/Shaders/fullscreen/fs_omnidirectional_blur.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | uniform sampler2D tex_object; 8 | uniform vec2 PixelSize; 9 | uniform float IsVertical; 10 | uniform float MaxDist; 11 | 12 | #define FILTER_STEP_COUNT 5.0 13 | #define FILTER_SIZE vec2(FILTER_STEP_COUNT, FILTER_STEP_COUNT) 14 | #define COUNT (FILTER_STEP_COUNT * 2.0 + 1.0) 15 | 16 | in vec2 TexCoord_; 17 | in int Layer; 18 | 19 | out vec4 color; 20 | 21 | void main() 22 | { 23 | const float invCount = 1.0 / COUNT; 24 | const float inv6 = 1.0 / 6.0; 25 | 26 | vec2 radiusUV = (FILTER_SIZE * PixelSize) / FILTER_STEP_COUNT; 27 | radiusUV.y *= inv6; 28 | if (IsVertical > 0.0) 29 | radiusUV = vec2(0.0, radiusUV.y); 30 | else 31 | radiusUV = vec2(radiusUV.x, 0.0); 32 | 33 | vec4 colorTemp = vec4(0); 34 | for (float x = -FILTER_STEP_COUNT; x <= FILTER_STEP_COUNT; ++x) 35 | { 36 | int index = int(TexCoord_.y / inv6); 37 | vec2 tex = TexCoord_ + vec2(x, x) * radiusUV; 38 | TexArrayUV uv; 39 | uv.u = tex.x; 40 | uv.v = (tex.y - (inv6 * index)) * 6.0; 41 | uv.index = index; 42 | uv = MakeTexArrayUV(uv); 43 | tex = Convert_TexArrayUV_To_Tex2dUV(uv); 44 | colorTemp += texture(tex_object, tex) * invCount; 45 | } 46 | color = colorTemp; 47 | } -------------------------------------------------------------------------------- /Shadows/Shaders/fullscreen/fs_scale.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | precision mediump float; 3 | 4 | uniform sampler2D tex_object; 5 | 6 | in vec2 TexCoord_; 7 | out vec4 FragColor; 8 | 9 | void main() 10 | { 11 | FragColor = texture(tex_object, TexCoord_); 12 | } 13 | -------------------------------------------------------------------------------- /Shadows/Shaders/fullscreen/fs_tonemap.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | precision mediump float; 3 | 4 | uniform sampler2D tex_object; 5 | uniform sampler2D tex_object2; 6 | uniform sampler2D tex_object3; 7 | uniform vec2 PixelSize; 8 | uniform int UseTonemap; 9 | uniform float AutoExposureKeyValue; 10 | uniform float BloomMagnitude; 11 | 12 | in vec2 TexCoord_; 13 | out vec4 FragColor; 14 | 15 | // http://filmicworlds.com/blog/filmic-tonemapping-operators/ 16 | vec3 Uncharted2Tonemap(vec3 x) 17 | { 18 | float A = 0.15; // Shoulder Strength 19 | float B = 0.50; // Linear Strength 20 | float C = 0.10; // Linear Angle 21 | float D = 0.20; // Toe Strength 22 | float E = 0.02; // Toe Numerator 23 | float F = 0.30; // Toe Denominator 24 | float W = 11.2; // Linear White Point Value 25 | 26 | return ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F; 27 | } 28 | 29 | // https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/ 30 | vec3 ACESFilmTonemap(vec3 x) 31 | { 32 | float a = 2.51f; 33 | float b = 0.03f; 34 | float c = 2.43f; 35 | float d = 0.59f; 36 | float e = 0.14f; 37 | return clamp((x * (a * x + b)) / (x * (c * x + d) + e), vec3(0.0), vec3(1.0)); 38 | } 39 | 40 | // http://filmicworlds.com/blog/filmic-tonemapping-with-piecewise-power-curves/ // wait for implementation 41 | 42 | // Applies the filmic curve from John Hable's presentation 43 | vec3 FilmicToneMapALU(vec3 linearColor) 44 | { 45 | vec3 color = max(vec3(0.0), linearColor - vec3(0.004)); 46 | color = (color * (6.2 * color + 0.5)) / (color * (6.2 * color + 1.7) + 0.06); 47 | 48 | // result has 1/2.2 baked in 49 | return pow(color, vec3(2.2)); 50 | } 51 | 52 | // Retrieves the log-average luminance from the texture 53 | float GetAvgLuminance(sampler2D lumTex) 54 | { 55 | return texelFetch(lumTex, ivec2(0, 0), 0).x; 56 | } 57 | 58 | // Determines the color based on exposure settings 59 | vec3 CalcExposedColor(vec3 color, float avgLuminance, float threshold, out float exposure) 60 | { 61 | // Use geometric mean 62 | avgLuminance = max(avgLuminance, 0.001); 63 | float keyValue = AutoExposureKeyValue; 64 | float linearExposure = (keyValue / avgLuminance); 65 | exposure = log2(max(linearExposure, 0.0001)); 66 | exposure -= threshold; 67 | return exp2(exposure) * color; 68 | } 69 | 70 | void main() 71 | { 72 | vec4 color = texture(tex_object, TexCoord_); 73 | if (UseTonemap > 0) 74 | { 75 | float avgLuminance = GetAvgLuminance(tex_object2); 76 | float exposure = 0.0; 77 | color.xyz = CalcExposedColor(color.xyz, avgLuminance, 0.0, exposure); 78 | 79 | // Filmic Tonemap 80 | //color.xyz = FilmicToneMapALU(color.xyz); 81 | 82 | // Uncharted2Tonemap 83 | vec3 cur = Uncharted2Tonemap(color.xyz); 84 | float W = 11.2; // Linear White Point Value 85 | vec3 whiteScale = 1.0 / Uncharted2Tonemap(vec3(W)); 86 | color.xyz = cur * whiteScale; 87 | 88 | // ACES Filmic Tonemap 89 | //color.xyz = ACESFilmTonemap(color.xyz); 90 | } 91 | 92 | vec3 bloom = texture(tex_object3, TexCoord_).xyz; 93 | bloom *= BloomMagnitude; 94 | color.xyz += bloom.xyz; 95 | 96 | color.xyz = pow(color.xyz, vec3(1.0 / 2.2)); // from Linear color to sRGB 97 | 98 | FragColor = vec4(color.xyz, 1.0); 99 | } -------------------------------------------------------------------------------- /Shadows/Shaders/fullscreen/vs_fullscreen_common.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | precision mediump float; 3 | 4 | layout(location = 0) in float VertID; 5 | 6 | out vec2 TexCoord_; 7 | 8 | void main() 9 | { 10 | int vert = int(VertID); 11 | 12 | TexCoord_ = vec2((vert << 1) & 2, vert & 2); 13 | gl_Position = vec4(TexCoord_ * vec2(2.0, 2.0) - vec2(1.0, 1.0), 0.5, 1.0); 14 | } 15 | -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/fs.glsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/Shaders/shadowmap/fs.glsl -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/fs_EVSM.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | varying vec3 Pos_; 8 | uniform float ESM_C; 9 | 10 | layout (std140) uniform DirectionalLightShadowMapBlock 11 | { 12 | mat4 ShadowVP; 13 | mat4 ShadowV; 14 | vec3 LightPos; // Directional Light Pos 임시 15 | float LightZNear; 16 | float LightZFar; 17 | }; 18 | 19 | void main() 20 | { 21 | vec3 lightDir = Pos_ - LightPos; 22 | float distSquared = dot(lightDir.xyz, lightDir.xyz); 23 | float distFromLight = (sqrt(distSquared) - LightZNear) / (LightZFar - LightZNear); 24 | float ez = exp(distFromLight * ESM_C); 25 | 26 | gl_FragData[0].x = ez; 27 | gl_FragData[0].y = ez * ez; 28 | gl_FragData[0].w = 1.0; 29 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/fs_deepShadowMap.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | precision mediump float; 4 | 5 | layout (std430) buffer StartElementBufEntry 6 | { 7 | int start[]; 8 | }; 9 | 10 | struct NodeData 11 | { 12 | float depth; 13 | float alpha; 14 | int next; 15 | int prev; 16 | }; 17 | 18 | layout (std430) buffer LinkedListEntryDepthAlphaNext 19 | { 20 | NodeData LinkedListData[]; 21 | }; 22 | 23 | uniform float DeepShadowAlpha; 24 | uniform int ShadowMapWidth; 25 | 26 | #define DEEP_SHADOW_MAP_BIAS 0.005 27 | 28 | layout (binding = 3, offset = 0) uniform atomic_uint LinkedListCounter; 29 | //layout (binding = 4, offset = 0) uniform atomic_uint LinkedListCounterTester; 30 | 31 | out vec4 color; 32 | 33 | void main() 34 | { 35 | uint counter = atomicCounterIncrement(LinkedListCounter); 36 | LinkedListData[counter].depth = gl_FragCoord.z + DEEP_SHADOW_MAP_BIAS; 37 | LinkedListData[counter].alpha = DeepShadowAlpha; 38 | 39 | vec2 uv = gl_FragCoord.xy; 40 | 41 | int index = int(uint(uv.y) * ShadowMapWidth + uint(uv.x)); 42 | 43 | uint originalVal = atomicExchange(start[index], int(counter)); 44 | LinkedListData[counter].next = int(originalVal); 45 | 46 | color = vec4(1.0, 0.0, 0.0, 1.0); 47 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/fs_deferred.glsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/Shaders/shadowmap/fs_deferred.glsl -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/fs_expDeepShadowMap.glsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/Shaders/shadowmap/fs_expDeepShadowMap.glsl -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/fs_expDeferred.glsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/Shaders/shadowmap/fs_expDeferred.glsl -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/fs_exponentialShadowMap.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | in vec3 Pos_; 8 | 9 | uniform float ESM_C; 10 | 11 | layout (std140) uniform DirectionalLightShadowMapBlock 12 | { 13 | mat4 ShadowVP; 14 | mat4 ShadowV; 15 | vec3 LightPos; // Directional Light Pos 임시 16 | float LightZNear; 17 | float LightZFar; 18 | }; 19 | 20 | void main() 21 | { 22 | vec3 lightDir = Pos_ - LightPos; 23 | float distSquared = dot(lightDir.xyz, lightDir.xyz); 24 | float distFromLight = (sqrt(distSquared) - LightZNear) / (LightZFar - LightZNear); 25 | 26 | gl_FragData[0].x = exp(distFromLight * ESM_C); 27 | gl_FragData[0].w = 1.0; 28 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/fs_omniDirectionalEVSM.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | #define MAX_NUM_OF_POINT_LIGHT 1 8 | #define MAX_NUM_OF_SPOT_LIGHT 1 9 | 10 | uniform int NumOfPointLight; 11 | uniform int NumOfSpotLight; 12 | 13 | layout (std140) uniform PointLightBlock 14 | { 15 | jPointLight PointLight[MAX_NUM_OF_POINT_LIGHT]; 16 | }; 17 | 18 | layout (std140) uniform SpotLightBlock 19 | { 20 | jSpotLight SpotLight[MAX_NUM_OF_SPOT_LIGHT]; 21 | }; 22 | 23 | layout (std140) uniform PointLightShadowMapBlock 24 | { 25 | float PointLightZNear; 26 | float PointLightZFar; 27 | }; 28 | 29 | layout (std140) uniform SpotLightShadowMapBlock 30 | { 31 | float SpotLightZNear; 32 | float SpotLightZFar; 33 | }; 34 | 35 | uniform float PointLightESM_C; 36 | uniform float SpotLightESM_C; 37 | 38 | in vec4 fragPos_; 39 | 40 | void main() 41 | { 42 | if (NumOfPointLight > 0) 43 | { 44 | vec3 lightDir = fragPos_.xyz - PointLight[0].LightPos; 45 | float distSquared = dot(lightDir.xyz, lightDir.xyz); 46 | float distFromLight = (sqrt(distSquared) - PointLightZNear) / (PointLightZFar - PointLightZNear); 47 | float ez = exp(distFromLight * PointLightESM_C); 48 | 49 | gl_FragData[0].x = ez * ez; 50 | gl_FragData[0].y = ez; 51 | gl_FragData[0].w = 1.0; 52 | } 53 | else if (NumOfSpotLight > 0) 54 | { 55 | vec3 lightDir = fragPos_.xyz - SpotLight[0].LightPos; 56 | float distSquared = dot(lightDir.xyz, lightDir.xyz); 57 | float distFromLight = (sqrt(distSquared) - SpotLightZNear) / (SpotLightZFar - SpotLightZNear); 58 | float ez = exp(distFromLight * PointLightESM_C); 59 | 60 | gl_FragData[0].x = ez * ez; 61 | gl_FragData[0].y = ez; 62 | gl_FragData[0].w = 1.0; 63 | } 64 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/fs_omniDirectionalExponentialShadowMap.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | #define MAX_NUM_OF_POINT_LIGHT 1 8 | #define MAX_NUM_OF_SPOT_LIGHT 1 9 | 10 | uniform int NumOfPointLight; 11 | uniform int NumOfSpotLight; 12 | 13 | layout (std140) uniform PointLightBlock 14 | { 15 | jPointLight PointLight[MAX_NUM_OF_POINT_LIGHT]; 16 | }; 17 | 18 | layout (std140) uniform SpotLightBlock 19 | { 20 | jSpotLight SpotLight[MAX_NUM_OF_SPOT_LIGHT]; 21 | }; 22 | 23 | layout (std140) uniform PointLightShadowMapBlock 24 | { 25 | float PointLightZNear; 26 | float PointLightZFar; 27 | }; 28 | 29 | layout (std140) uniform SpotLightShadowMapBlock 30 | { 31 | float SpotLightZNear; 32 | float SpotLightZFar; 33 | }; 34 | 35 | uniform float PointLightESM_C; 36 | uniform float SpotLightESM_C; 37 | 38 | in vec4 fragPos_; 39 | 40 | void main() 41 | { 42 | if (NumOfPointLight > 0) 43 | { 44 | vec3 lightDir = fragPos_.xyz - PointLight[0].LightPos; 45 | float distSquared = dot(lightDir.xyz, lightDir.xyz); 46 | float distFromLight = (sqrt(distSquared) - PointLightZNear) / (PointLightZFar - PointLightZNear); 47 | 48 | gl_FragData[0].x = exp(distFromLight * PointLightESM_C); 49 | gl_FragData[0].w = 1.0; 50 | } 51 | else if (NumOfSpotLight > 0) 52 | { 53 | vec3 lightDir = fragPos_.xyz - SpotLight[0].LightPos; 54 | float distSquared = dot(lightDir.xyz, lightDir.xyz); 55 | float distFromLight = (sqrt(distSquared) - SpotLightZNear) / (SpotLightZFar - SpotLightZNear); 56 | 57 | gl_FragData[0].x = exp(distFromLight * SpotLightESM_C); 58 | gl_FragData[0].w = 1.0; 59 | } 60 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/fs_omniDirectionalShadowMap.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | #define MAX_NUM_OF_POINT_LIGHT 1 8 | #define MAX_NUM_OF_SPOT_LIGHT 1 9 | 10 | uniform int NumOfPointLight; 11 | uniform int NumOfSpotLight; 12 | 13 | layout (std140) uniform PointLightBlock 14 | { 15 | jPointLight PointLight[MAX_NUM_OF_POINT_LIGHT]; 16 | }; 17 | 18 | layout (std140) uniform SpotLightBlock 19 | { 20 | jSpotLight SpotLight[MAX_NUM_OF_SPOT_LIGHT]; 21 | }; 22 | 23 | in vec4 fragPos_; 24 | out vec4 color; 25 | 26 | void main() 27 | { 28 | if (NumOfPointLight > 0) 29 | { 30 | vec3 lightDir = fragPos_.xyz - PointLight[0].LightPos; 31 | 32 | float dist = dot(lightDir.xyz, lightDir.xyz); 33 | color.x = dist; 34 | color.y = sqrt(dist); 35 | color.w = 1.0; 36 | gl_FragDepth = color.y / PointLight[0].MaxDistance; 37 | } 38 | else if (NumOfSpotLight > 0) 39 | { 40 | vec3 lightDir = fragPos_.xyz - SpotLight[0].LightPos; 41 | 42 | float dist = dot(lightDir.xyz, lightDir.xyz); 43 | color.x = dist; 44 | color.y = sqrt(dist); 45 | color.w = 1.0; 46 | gl_FragDepth = color.y / SpotLight[0].MaxDistance; 47 | } 48 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/fs_shadowMap.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | void main() 8 | { 9 | gl_FragData[0].x = gl_FragCoord.z; 10 | gl_FragData[0].w = 1.0; 11 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/fs_varianceShadowMap.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | in vec3 Pos_; 8 | 9 | layout (std140) uniform DirectionalLightShadowMapBlock 10 | { 11 | mat4 ShadowVP; 12 | mat4 ShadowV; 13 | vec3 LightPos; // Directional Light Pos 임시 14 | float LightZNear; 15 | float LightZFar; 16 | }; 17 | 18 | void main() 19 | { 20 | vec3 lightDir = Pos_ - LightPos; 21 | float distSquared = dot(lightDir.xyz, lightDir.xyz); 22 | 23 | gl_FragData[0].x = sqrt(distSquared); 24 | gl_FragData[0].y = distSquared; 25 | 26 | // float z = gl_FragCoord.z; 27 | // gl_FragData[0].x = z; 28 | // gl_FragData[0].y = z; 29 | // gl_FragData[0].w = 1.0; 30 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/gs_cascadeShadowMap.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | #preprocessor 4 | 5 | precision mediump float; 6 | 7 | #define NUM_CASCADES 3 8 | #define NUM_VERTICES 9 9 | 10 | layout (triangles) in; 11 | layout (triangle_strip, max_vertices=NUM_VERTICES) out; 12 | 13 | uniform mat4 CascadeLightVP[NUM_CASCADES]; 14 | 15 | out vec4 fragPos_; 16 | out int Layer; 17 | 18 | void main() 19 | { 20 | for(int cascadeIndex=0; cascadeIndex < NUM_CASCADES;++cascadeIndex) 21 | { 22 | Layer = cascadeIndex; 23 | gl_ViewportIndex = cascadeIndex; 24 | for(int i=0;i<3;++i) 25 | { 26 | fragPos_ = gl_in[i].gl_Position; 27 | gl_Position = CascadeLightVP[cascadeIndex] * fragPos_; 28 | EmitVertex(); 29 | } 30 | EndPrimitive(); 31 | } 32 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/gs_omniDirectionalShadowMap.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | #preprocessor 4 | 5 | precision mediump float; 6 | 7 | layout (triangles) in; 8 | layout (triangle_strip, max_vertices=18) out; 9 | 10 | uniform mat4 OmniShadowMapVP[6]; 11 | 12 | out vec4 fragPos_; 13 | out int Layer; 14 | 15 | void main() 16 | { 17 | for(int face=0;face<6;++face) 18 | { 19 | Layer = face; 20 | gl_ViewportIndex = face; 21 | for(int i=0;i<3;++i) 22 | { 23 | fragPos_ = gl_in[i].gl_Position; 24 | gl_Position = OmniShadowMapVP[face] * fragPos_; 25 | EmitVertex(); 26 | } 27 | EndPrimitive(); 28 | } 29 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/vs.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #preprocessor 4 | 5 | #include "common.glsl" 6 | 7 | precision mediump float; 8 | 9 | layout(location = 0) in vec3 Pos; 10 | layout(location = 1) in vec4 Color; 11 | layout(location = 2) in vec3 Normal; 12 | 13 | #if defined(USE_TEXTURE) 14 | layout(location = 3) in vec2 TexCoord; 15 | #endif // USE_TEXTURE 16 | 17 | uniform mat4 MVP; 18 | uniform mat4 MV; 19 | uniform mat4 M; 20 | 21 | // out vec3 ShadowPos_; 22 | // out vec3 ShadowCameraPos_; 23 | out vec3 Pos_; 24 | out vec4 Color_; 25 | out vec3 Normal_; 26 | 27 | #if defined(USE_TEXTURE) 28 | out vec2 TexCoord_; 29 | #endif // USE_TEXTURE 30 | 31 | #if defined(USE_CSM) 32 | #define NUM_CASCADES 3 33 | uniform mat4 CascadeLightVP[NUM_CASCADES]; 34 | out vec3 PosV_; 35 | out vec4 LightSpacePos[NUM_CASCADES]; 36 | #endif // USE_CSM 37 | 38 | void main() 39 | { 40 | gl_Position = MVP * vec4(Pos, 1.0); 41 | 42 | #if defined(USE_CSM) 43 | for (int i = 0; i < NUM_CASCADES; i++) 44 | LightSpacePos[i] = CascadeLightVP[i] * M * vec4(Pos, 1.0); 45 | PosV_ = TransformPos(MV, Pos); 46 | #endif // USE_CSM 47 | 48 | #if defined(USE_TEXTURE) 49 | TexCoord_ = TexCoord; 50 | #endif // USE_TEXTURE 51 | 52 | Color_ = Color; 53 | Normal_ = TransformNormal(M, Normal); 54 | Pos_ = TransformPos(M, Pos); 55 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/vs_EVSM.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | layout(location = 0) in vec3 Pos; 8 | 9 | uniform mat4 MVP; 10 | uniform mat4 M; 11 | 12 | out vec3 Pos_; 13 | 14 | void main() 15 | { 16 | gl_Position = MVP * vec4(Pos, 1.0); 17 | Pos_ = TransformPos(M, Pos); 18 | } 19 | -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/vs_deferred.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #preprocessor 4 | 5 | #include "common.glsl" 6 | 7 | precision mediump float; 8 | 9 | layout(location = 0) in vec3 Pos; 10 | layout(location = 1) in vec4 Color; 11 | layout(location = 2) in vec3 Normal; 12 | 13 | #if defined(USE_TEXTURE) 14 | layout(location = 3) in vec2 TexCoord; 15 | #endif // USE_TEXTURE 16 | 17 | uniform mat4 MVP; 18 | uniform mat4 MV; 19 | uniform mat4 M; 20 | 21 | // out vec3 ShadowPos_; 22 | // out vec3 ShadowCameraPos_; 23 | out vec3 Pos_; 24 | out vec4 Color_; 25 | out vec3 Normal_; 26 | 27 | #if defined(USE_TEXTURE) 28 | out vec2 TexCoord_; 29 | #endif // USE_TEXTURE 30 | 31 | void main() 32 | { 33 | #if defined(USE_TEXTURE) 34 | TexCoord_ = TexCoord; 35 | #endif // USE_TEXTURE 36 | 37 | Color_ = Color; 38 | Normal_ = TransformNormal(M, Normal); 39 | Pos_ = TransformPos(M, Pos); 40 | 41 | gl_Position = MVP * vec4(Pos, 1.0); 42 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/vs_expDeepShadowMap.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | layout(location = 0) in vec3 Pos; 8 | 9 | uniform mat4 MVP; 10 | uniform mat4 M; 11 | 12 | out vec3 Pos_; 13 | 14 | void main() 15 | { 16 | gl_Position = MVP * vec4(Pos, 1.0); 17 | Pos_ = TransformPos(M, Pos); 18 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/vs_hair.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #preprocessor 4 | 5 | #include "common.glsl" 6 | 7 | precision mediump float; 8 | 9 | layout(location = 0) in vec3 Pos; 10 | layout(location = 1) in vec4 Color; 11 | layout(location = 2) in vec3 Normal; 12 | 13 | #if defined(USE_TEXTURE) 14 | layout(location = 3) in vec2 TexCoord; 15 | #endif // USE_TEXTURE 16 | 17 | uniform mat4 MVP; 18 | uniform mat4 MV; 19 | uniform mat4 M; 20 | 21 | // out vec3 ShadowPos_; 22 | // out vec3 ShadowCameraPos_; 23 | out vec3 Pos_; 24 | out vec4 Color_; 25 | out vec3 Normal_; 26 | 27 | #if defined(USE_TEXTURE) 28 | out vec2 TexCoord_; 29 | #endif // USE_TEXTURE 30 | 31 | void main() 32 | { 33 | #if defined(USE_TEXTURE) 34 | TexCoord_ = TexCoord; 35 | #endif // USE_TEXTURE 36 | 37 | Color_ = Color; 38 | Normal_ = TransformNormal(M, Normal); 39 | Pos_ = TransformPos(M, Pos); 40 | 41 | gl_Position = MVP * vec4(Pos, 1.0); 42 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/vs_omniDirectionalShadowMap.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | layout(location = 0) in vec3 Pos; 8 | 9 | //uniform mat4 MVP; 10 | uniform mat4 M; 11 | 12 | //out vec3 Pos_; 13 | 14 | void main() 15 | { 16 | gl_Position = M * vec4(Pos, 1.0); 17 | //Pos_ = TransformPos(M, Pos); 18 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/vs_shadowMap.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | layout(location = 0) in vec3 Pos; 8 | uniform mat4 MVP; 9 | 10 | void main() 11 | { 12 | gl_Position = MVP * vec4(Pos, 1.0); 13 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowmap/vs_varianceShadowMap.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | layout(location = 0) in vec3 Pos; 8 | 9 | uniform mat4 MVP; 10 | uniform mat4 M; 11 | 12 | out vec3 Pos_; 13 | 14 | void main() 15 | { 16 | gl_Position = MVP * vec4(Pos, 1.0); 17 | Pos_ = TransformPos(M, Pos); 18 | } 19 | -------------------------------------------------------------------------------- /Shadows/Shaders/shadowvolume/fs.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #preprocessor 4 | 5 | #include "common.glsl" 6 | 7 | precision mediump float; 8 | 9 | #define MAX_NUM_OF_DIRECTIONAL_LIGHT 1 10 | #define MAX_NUM_OF_POINT_LIGHT 1 11 | #define MAX_NUM_OF_SPOT_LIGHT 1 12 | 13 | uniform int NumOfDirectionalLight; 14 | uniform int NumOfPointLight; 15 | uniform int NumOfSpotLight; 16 | 17 | layout (std140) uniform DirectionalLightBlock 18 | { 19 | jDirectionalLight DirectionalLight[MAX_NUM_OF_DIRECTIONAL_LIGHT]; 20 | }; 21 | 22 | layout (std140) uniform PointLightBlock 23 | { 24 | jPointLight PointLight[MAX_NUM_OF_POINT_LIGHT]; 25 | }; 26 | 27 | layout (std140) uniform SpotLightBlock 28 | { 29 | jSpotLight SpotLight[MAX_NUM_OF_SPOT_LIGHT]; 30 | }; 31 | 32 | uniform vec3 Eye; 33 | uniform int Collided; 34 | 35 | #if defined(USE_MATERIAL) 36 | uniform jMaterial Material; 37 | #endif // USE_MATERIAL 38 | 39 | #if defined(USE_TEXTURE) 40 | uniform sampler2D tex_object2; 41 | uniform int TextureSRGB[1]; 42 | #endif // USE_TEXTURE 43 | 44 | in vec3 Pos_; 45 | in vec4 Color_; 46 | in vec3 Normal_; 47 | 48 | #if defined(USE_TEXTURE) 49 | in vec2 TexCoord_; 50 | #endif // USE_TEXTURE 51 | 52 | out vec4 color; 53 | 54 | void main() 55 | { 56 | vec3 normal = normalize(Normal_); 57 | vec3 viewDir = normalize(Eye - Pos_); 58 | 59 | vec4 diffuse = Color_; 60 | if (Collided != 0) 61 | diffuse = vec4(1.0, 1.0, 1.0, 1.0); 62 | 63 | #if defined(USE_TEXTURE) 64 | if (TextureSRGB[0] > 0) 65 | { 66 | // from sRGB to Linear color 67 | vec4 tempColor = texture(tex_object2, TexCoord_); 68 | diffuse.xyz *= pow(tempColor.xyz, vec3(2.2)); 69 | diffuse.w *= tempColor.w; 70 | } 71 | else 72 | { 73 | diffuse *= texture(tex_object2, TexCoord_); 74 | } 75 | #endif // USE_TEXTURE 76 | 77 | #if defined(USE_MATERIAL) 78 | diffuse.xyz *= Material.Diffuse; 79 | diffuse.xyz += Material.Emissive; 80 | #endif // USE_MATERIAL 81 | 82 | vec3 directColor = vec3(0.0, 0.0, 0.0); 83 | 84 | for(int i=0;i= NumOfDirectionalLight) 87 | break; 88 | 89 | jDirectionalLight light = DirectionalLight[i]; 90 | #if defined(USE_MATERIAL) 91 | light.SpecularLightIntensity = Material.Specular; 92 | light.SpecularPow = Material.Shininess; 93 | #endif // USE_MATERIAL 94 | 95 | directColor += GetDirectionalLight(light, normal, viewDir); 96 | } 97 | 98 | for(int i=0;i= NumOfPointLight) 101 | break; 102 | 103 | jPointLight light = PointLight[i]; 104 | #if defined(USE_MATERIAL) 105 | light.SpecularLightIntensity = Material.Specular; 106 | light.SpecularPow = Material.Shininess; 107 | #endif // USE_MATERIAL 108 | 109 | directColor += GetPointLight(light, normal, Pos_, viewDir); 110 | } 111 | 112 | for(int i=0;i= NumOfSpotLight) 115 | break; 116 | 117 | jSpotLight light = SpotLight[i]; 118 | #if defined(USE_MATERIAL) 119 | light.SpecularLightIntensity = Material.Specular; 120 | light.SpecularPow = Material.Shininess; 121 | #endif // USE_MATERIAL 122 | 123 | directColor += GetSpotLight(light, normal, Pos_, viewDir); 124 | } 125 | 126 | color = vec4(directColor * (1.0 / 3.14) * diffuse.xyz, diffuse.w); 127 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowvolume/fs_ambientonly.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #preprocessor 4 | 5 | #include "common.glsl" 6 | 7 | precision mediump float; 8 | 9 | uniform vec3 Eye; 10 | 11 | uniform jAmbientLight AmbientLight; 12 | 13 | uniform int Collided; 14 | 15 | #if defined(USE_TEXTURE) 16 | uniform sampler2D tex_object2; 17 | uniform int TextureSRGB[1]; 18 | #endif // USE_TEXTURE 19 | 20 | #if defined(USE_MATERIAL) 21 | uniform jMaterial Material; 22 | #endif // USE_MATERIAL 23 | 24 | 25 | in vec3 Pos_; 26 | in vec4 Color_; 27 | in vec3 Normal_; 28 | 29 | out vec4 color; 30 | 31 | void main() 32 | { 33 | vec4 diffuse = Color_; 34 | if (Collided != 0) 35 | diffuse = vec4(1.0, 1.0, 1.0, 1.0); 36 | 37 | #if defined(USE_TEXTURE) 38 | if (TextureSRGB[0] > 0) 39 | { 40 | // from sRGB to Linear color 41 | vec4 tempColor = texture(tex_object2, TexCoord_); 42 | diffuse.xyz *= pow(tempColor.xyz, vec3(2.2)); 43 | diffuse.w *= tempColor.w; 44 | } 45 | else 46 | { 47 | diffuse *= texture(tex_object2, TexCoord_); 48 | } 49 | #endif // USE_TEXTURE 50 | 51 | #if defined(USE_MATERIAL) 52 | diffuse.xyz *= Material.Diffuse; 53 | diffuse.xyz += Material.Emissive; 54 | #endif // USE_MATERIAL 55 | 56 | color = vec4(GetAmbientLight(AmbientLight) * diffuse.xyz, diffuse.w); 57 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowvolume/fs_shadowvolume_cpu.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | in vec4 Color_; 8 | 9 | out vec4 color; 10 | 11 | void main() 12 | { 13 | color = vec4(Color_); 14 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowvolume/fs_shadowvolume_gpu.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | in vec4 Color_; 8 | 9 | out vec4 color; 10 | 11 | void main() 12 | { 13 | color = vec4(Color_); 14 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowvolume/gs_shadowvolume_gpu.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | #preprocessor 4 | 5 | precision mediump float; 6 | 7 | layout(triangles_adjacency) in; 8 | layout(triangle_strip, max_vertices = 24) out; 9 | 10 | uniform mat4 VP; 11 | uniform mat4 MVP; 12 | uniform mat4 M; 13 | uniform int IsTwoSided; 14 | 15 | in vec3 LightDirWS_[]; 16 | 17 | void EmitTriangle(int v0Index, int v1Index, int v2Index) 18 | { 19 | // Frontface 20 | { 21 | gl_Position = VP * gl_in[v0Index].gl_Position; 22 | EmitVertex(); 23 | gl_Position = VP * gl_in[v1Index].gl_Position; 24 | EmitVertex(); 25 | gl_Position = VP * gl_in[v2Index].gl_Position; 26 | EmitVertex(); 27 | EndPrimitive(); 28 | } 29 | 30 | // Backface 31 | { 32 | gl_Position = VP * vec4(LightDirWS_[v1Index], 0.0); 33 | EmitVertex(); 34 | gl_Position = VP * vec4(LightDirWS_[v0Index], 0.0); 35 | EmitVertex(); 36 | gl_Position = VP * vec4(LightDirWS_[v2Index], 0.0); 37 | EmitVertex(); 38 | EndPrimitive(); 39 | } 40 | } 41 | 42 | void EmitEdgeSilhouette(bool isFrontFace, int v0Index, int v1Index, int adjcency_vertIndex) 43 | { 44 | vec3 m0 = gl_in[v0Index].gl_Position.xyz; 45 | vec3 m1 = gl_in[v1Index].gl_Position.xyz; 46 | 47 | vec3 l0 = LightDirWS_[v0Index]; 48 | vec3 l1 = LightDirWS_[v1Index]; 49 | 50 | vec3 adj_vert = gl_in[adjcency_vertIndex].gl_Position.xyz; 51 | 52 | vec3 c = cross(m1 - adj_vert, m0 - adj_vert); 53 | bool face = dot(c, (l0 + l1)) > 0; 54 | if (face != isFrontFace) 55 | { 56 | vec4 a0; 57 | vec4 a1; 58 | vec4 a2; 59 | vec4 a3; 60 | if (face) 61 | { 62 | a0 = VP * vec4(m0, 1.0); 63 | a1 = VP * vec4(m1, 1.0); 64 | a2 = VP * vec4(l0, 0.0); 65 | a3 = VP * vec4(l1, 0.0); 66 | } 67 | else 68 | { 69 | a0 = VP * vec4(m1, 1.0); 70 | a1 = VP * vec4(m0, 1.0); 71 | a2 = VP * vec4(l1, 0.0); 72 | a3 = VP * vec4(l0, 0.0); 73 | } 74 | 75 | gl_Position = a0; 76 | EmitVertex(); 77 | gl_Position = a1; 78 | EmitVertex(); 79 | gl_Position = a2; 80 | EmitVertex(); 81 | EndPrimitive(); 82 | gl_Position = a2; 83 | EmitVertex(); 84 | gl_Position = a1; 85 | EmitVertex(); 86 | gl_Position = a3; 87 | EmitVertex(); 88 | EndPrimitive(); 89 | } 90 | } 91 | 92 | void main() 93 | { 94 | vec3 m0 = gl_in[0].gl_Position.xyz; 95 | vec3 m1 = gl_in[2].gl_Position.xyz; 96 | vec3 m2 = gl_in[4].gl_Position.xyz; 97 | 98 | vec3 ma0 = gl_in[1].gl_Position.xyz; 99 | vec3 ma1 = gl_in[3].gl_Position.xyz; 100 | vec3 ma2 = gl_in[5].gl_Position.xyz; 101 | 102 | vec3 r = cross(m1 - m0, m2 - m0); 103 | bool isFrontFace = dot(LightDirWS_[0], r) > 0; 104 | 105 | vec4 v0; 106 | vec4 v1; 107 | vec4 v2; 108 | if (IsTwoSided > 0) 109 | { 110 | if (isFrontFace) 111 | EmitTriangle(0, 2, 4); 112 | else 113 | EmitTriangle(2, 0, 4); 114 | 115 | // Two sided objects has just either face front or back face. so it should be draw no matter what faces does it. 116 | EmitEdgeSilhouette(isFrontFace, 0, 2, 1); 117 | EmitEdgeSilhouette(isFrontFace, 2, 4, 3); 118 | EmitEdgeSilhouette(isFrontFace, 4, 0, 5); 119 | } 120 | else 121 | { 122 | if (isFrontFace) 123 | { 124 | v0 = VP * gl_in[0].gl_Position; 125 | v1 = VP * gl_in[2].gl_Position; 126 | v2 = VP * gl_in[4].gl_Position; 127 | 128 | gl_Position = v0; 129 | EmitVertex(); 130 | gl_Position = v1; 131 | EmitVertex(); 132 | gl_Position = v2; 133 | EmitVertex(); 134 | EndPrimitive(); 135 | } 136 | else 137 | { 138 | v0 = VP * vec4(LightDirWS_[0], 0.0); 139 | v1 = VP * vec4(LightDirWS_[2], 0.0); 140 | v2 = VP * vec4(LightDirWS_[4], 0.0); 141 | 142 | gl_Position = v0; 143 | EmitVertex(); 144 | gl_Position = v1; 145 | EmitVertex(); 146 | gl_Position = v2; 147 | EmitVertex(); 148 | EndPrimitive(); 149 | } 150 | 151 | if (isFrontFace) 152 | { 153 | EmitEdgeSilhouette(isFrontFace, 0, 2, 1); 154 | EmitEdgeSilhouette(isFrontFace, 2, 4, 3); 155 | EmitEdgeSilhouette(isFrontFace, 4, 0, 5); 156 | } 157 | } 158 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowvolume/vs.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #preprocessor 4 | 5 | #include "common.glsl" 6 | 7 | precision mediump float; 8 | 9 | layout(location = 0) in vec3 Pos; 10 | layout(location = 1) in vec4 Color; 11 | layout(location = 2) in vec3 Normal; 12 | 13 | #if defined(USE_TEXTURE) 14 | layout(location = 3) in vec2 TexCoord; 15 | #endif // USE_TEXTURE 16 | 17 | uniform mat4 MVP; 18 | uniform mat4 MV; 19 | uniform mat4 M; 20 | 21 | out vec3 Pos_; 22 | out vec4 Color_; 23 | out vec3 Normal_; 24 | 25 | #if defined(USE_TEXTURE) 26 | out vec2 TexCoord_; 27 | #endif // USE_TEXTURE 28 | 29 | void main() 30 | { 31 | #if defined(USE_TEXTURE) 32 | TexCoord_ = TexCoord; 33 | #endif // USE_TEXTURE 34 | Color_ = Color; 35 | Normal_ = TransformNormal(M, Normal); 36 | Pos_ = TransformPos(M, Pos); 37 | gl_Position = MVP * vec4(Pos, 1.0); 38 | } -------------------------------------------------------------------------------- /Shadows/Shaders/shadowvolume/vs_shadowvolume_cpu.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | layout(location = 0) in vec4 Pos; 8 | layout(location = 1) in vec4 Color; 9 | 10 | uniform mat4 M; 11 | uniform mat4 VP; 12 | uniform mat4 MVP; 13 | 14 | #define MAX_NUM_OF_DIRECTIONAL_LIGHT 1 15 | #define MAX_NUM_OF_POINT_LIGHT 1 16 | #define MAX_NUM_OF_SPOT_LIGHT 1 17 | 18 | uniform int NumOfDirectionalLight; 19 | uniform int NumOfPointLight; 20 | uniform int NumOfSpotLight; 21 | 22 | layout (std140) uniform DirectionalLightBlock 23 | { 24 | jDirectionalLight DirectionalLight[MAX_NUM_OF_DIRECTIONAL_LIGHT]; 25 | }; 26 | 27 | layout (std140) uniform PointLightBlock 28 | { 29 | jPointLight PointLight[MAX_NUM_OF_POINT_LIGHT]; 30 | }; 31 | 32 | layout (std140) uniform SpotLightBlock 33 | { 34 | jSpotLight SpotLight[MAX_NUM_OF_SPOT_LIGHT]; 35 | }; 36 | 37 | out vec4 Color_; 38 | 39 | void main() 40 | { 41 | Color_ = Color; 42 | 43 | if (Pos.w == 0.0) 44 | { 45 | vec4 PosTemp = M * vec4(Pos.xyz, 1.0); 46 | PosTemp.xyz /= PosTemp.w; 47 | 48 | vec3 lightPos; 49 | vec3 lightDir; 50 | if (NumOfPointLight > 0) 51 | { 52 | lightPos = PointLight[0].LightPos; 53 | lightDir = normalize(PosTemp.xyz - lightPos); 54 | } 55 | else if (NumOfSpotLight > 0) 56 | { 57 | lightPos = SpotLight[0].LightPos; 58 | lightDir = normalize(PosTemp.xyz - lightPos); 59 | } 60 | else if (NumOfDirectionalLight > 0) 61 | { 62 | lightDir = DirectionalLight[0].LightDirection; 63 | } 64 | gl_Position = VP * vec4(lightDir, 0.0); 65 | } 66 | else 67 | { 68 | gl_Position = MVP * Pos; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Shadows/Shaders/shadowvolume/vs_shadowvolume_gpu.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | #include "common.glsl" 4 | 5 | precision mediump float; 6 | 7 | layout(location = 0) in vec4 Pos; 8 | layout(location = 1) in vec4 Color; 9 | 10 | #define MAX_NUM_OF_DIRECTIONAL_LIGHT 1 11 | #define MAX_NUM_OF_POINT_LIGHT 1 12 | #define MAX_NUM_OF_SPOT_LIGHT 1 13 | 14 | uniform int NumOfDirectionalLight; 15 | uniform int NumOfPointLight; 16 | uniform int NumOfSpotLight; 17 | 18 | layout (std140) uniform DirectionalLightBlock 19 | { 20 | jDirectionalLight DirectionalLight[MAX_NUM_OF_DIRECTIONAL_LIGHT]; 21 | }; 22 | 23 | layout (std140) uniform PointLightBlock 24 | { 25 | jPointLight PointLight[MAX_NUM_OF_POINT_LIGHT]; 26 | }; 27 | 28 | layout (std140) uniform SpotLightBlock 29 | { 30 | jSpotLight SpotLight[MAX_NUM_OF_SPOT_LIGHT]; 31 | }; 32 | 33 | uniform mat4 M; 34 | uniform mat4 VP; 35 | uniform mat4 MVP; 36 | 37 | out vec4 Color_; 38 | out vec3 LightDirWS_; 39 | 40 | void main() 41 | { 42 | Color_ = Color; 43 | 44 | vec4 PosTemp = M * vec4(Pos.xyz, 1.0); 45 | PosTemp.xyz /= PosTemp.w; 46 | 47 | vec3 lightPos; 48 | if (NumOfPointLight > 0) 49 | { 50 | lightPos = PointLight[0].LightPos; 51 | LightDirWS_ = normalize(PosTemp.xyz - lightPos); 52 | } 53 | else if (NumOfSpotLight > 0) 54 | { 55 | lightPos = SpotLight[0].LightPos; 56 | LightDirWS_ = normalize(PosTemp.xyz - lightPos); 57 | } 58 | else if (NumOfDirectionalLight > 0) 59 | { 60 | LightDirWS_ = DirectionalLight[0].LightDirection; 61 | } 62 | 63 | { 64 | gl_Position = PosTemp; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Shadows/Shaders/tex_fs.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | precision mediump float; 4 | 5 | uniform sampler2D tex_object2; 6 | uniform int TextureSRGB[1]; 7 | uniform int UseTexture; 8 | 9 | in vec2 TexCoord_; 10 | in vec4 Color_; 11 | 12 | out vec4 color; 13 | 14 | void main() 15 | { 16 | if (UseTexture > 0) 17 | { 18 | color = texture2D(tex_object2, TexCoord_); 19 | if (TextureSRGB[0] > 0) 20 | color.xyz = pow(color.xyz, vec3(2.2)); 21 | } 22 | else 23 | { 24 | color = Color_; 25 | } 26 | } -------------------------------------------------------------------------------- /Shadows/Shaders/tex_ui_fs.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | precision mediump float; 4 | 5 | uniform sampler2D tex_object; 6 | uniform int TextureSRGB[1]; 7 | in vec2 TexCoord_; 8 | 9 | out vec4 color; 10 | 11 | void main() 12 | { 13 | color = texture2D(tex_object, TexCoord_); 14 | if (TextureSRGB[0] > 0) 15 | color.xyz = pow(color.xyz, vec3(2.2)); 16 | } -------------------------------------------------------------------------------- /Shadows/Shaders/tex_ui_vs.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | precision mediump float; 4 | 5 | layout(location = 0) in vec2 VertPos; // [0, 1] 6 | 7 | uniform vec2 PixelSize; 8 | uniform vec2 Pos; 9 | uniform vec2 Size; 10 | 11 | out vec2 TexCoord_; 12 | 13 | void main() 14 | { 15 | TexCoord_ = VertPos; 16 | 17 | gl_Position.x = (VertPos.x * Size.x + Pos.x) * PixelSize.x; 18 | gl_Position.y = (VertPos.y * Size.y + Pos.y) * PixelSize.y; 19 | 20 | gl_Position.xy = gl_Position.xy * 2.0 - 1.0; // [0, 1] -> [-1, -1] 21 | gl_Position.z = 0.5; 22 | gl_Position.w = 1.0; 23 | } 24 | -------------------------------------------------------------------------------- /Shadows/Shaders/tex_vs.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | precision mediump float; 4 | 5 | layout(location = 0) in vec3 Pos; 6 | layout(location = 1) in vec4 Color; 7 | 8 | uniform mat4 MVP; 9 | 10 | out vec2 TexCoord_; 11 | out vec4 Color_; 12 | 13 | void main() 14 | { 15 | TexCoord_ = (Pos.xz + 0.5); 16 | Color_ = Color; 17 | gl_Position = MVP * vec4(Pos, 1.0); 18 | } 19 | -------------------------------------------------------------------------------- /Shadows/Shaders/vs_boundvolume.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | precision mediump float; 4 | 5 | layout(location = 0) in vec3 Pos; 6 | 7 | uniform mat4 MVP; 8 | 9 | void main() 10 | { 11 | gl_Position = MVP * vec4(Pos, 1.0); 12 | } -------------------------------------------------------------------------------- /Shadows/Shaders/vs_cascade.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | precision mediump float; 4 | 5 | layout(location = 0) in vec3 Pos; 6 | 7 | uniform mat4 MVP; 8 | uniform mat4 lightMVP[3]; 9 | 10 | out vec4 lightPos[3]; 11 | out float ClipSpaceZ; 12 | 13 | void main() 14 | { 15 | for(int i=0;i<3;++i) 16 | { 17 | lightPos[i] = lightMVP[i] * vec4(Pos, 1.0); 18 | } 19 | gl_Position = MVP * vec4(Pos, 1.0); 20 | ClipSpaceZ = gl_Position.z; 21 | } -------------------------------------------------------------------------------- /Shadows/Shaders/vs_graph.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | precision mediump float; 4 | 5 | layout(location = 0) in vec2 Pos; 6 | layout(location = 1) in mat4 Transform; 7 | 8 | uniform vec2 InvViewportSize; 9 | 10 | flat out int InstanceId; 11 | 12 | void main() 13 | { 14 | vec4 Pos_ = Transform * vec4(Pos, 0.0f, 1.0f); 15 | 16 | Pos_.xy *= InvViewportSize; 17 | Pos_ = Pos_ * 2.0f - 1.0f; 18 | Pos_.y = -Pos_.y; 19 | 20 | Pos_.z = 0.5f; 21 | Pos_.w = 1.0f; 22 | gl_Position = Pos_; 23 | InstanceId = gl_InstanceID; 24 | } -------------------------------------------------------------------------------- /Shadows/Shaders/vs_red.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | precision mediump float; 4 | 5 | layout(location = 0) in vec3 Pos; 6 | 7 | #define NUM_CASCADES 3 8 | 9 | uniform mat4 MVP; 10 | uniform mat4 gLightWVP[NUM_CASCADES]; 11 | 12 | out vec4 LightSpacePos[NUM_CASCADES]; 13 | out vec4 Pos_; 14 | 15 | void main() 16 | { 17 | for (int i = 0; i < NUM_CASCADES; i++) { 18 | LightSpacePos[i] = gLightWVP[i] * vec4(Pos, 1.0); 19 | } 20 | 21 | Pos_ = gLightWVP[0] * vec4(Pos, 1.0); 22 | 23 | gl_Position = MVP * vec4(Pos, 1.0); 24 | } -------------------------------------------------------------------------------- /Shadows/Shaders/vs_shadowMap.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | precision mediump float; 4 | 5 | layout(location = 0) in vec3 Pos; 6 | uniform mat4 MVP; 7 | 8 | void main() 9 | { 10 | gl_Position = MVP * vec4(Pos, 1.0); 11 | } -------------------------------------------------------------------------------- /Shadows/Shaders/vs_test.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | precision mediump float; 4 | 5 | layout(location = 0) in vec3 Pos; 6 | layout(location = 1) in vec4 Color; 7 | 8 | #define NUM_CASCADES 3 9 | 10 | uniform mat4 MVP; 11 | uniform mat4 M; 12 | uniform mat4 VP; 13 | uniform mat4 MV; 14 | uniform mat4 CascadeLightVP[NUM_CASCADES]; 15 | 16 | out vec4 LightSpacePos[NUM_CASCADES]; 17 | out vec4 Pos_; 18 | out vec4 Color_; 19 | 20 | void main() 21 | { 22 | for (int i = 0; i < NUM_CASCADES; i++) 23 | LightSpacePos[i] = CascadeLightVP[i] * M * vec4(Pos, 1.0); 24 | 25 | gl_Position = MVP * vec4(Pos, 1.0); 26 | Pos_ = M * vec4(Pos, 1.0); 27 | Color_ = Color; 28 | } -------------------------------------------------------------------------------- /Shadows/Shadows.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28917.181 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Shadows", "Shadows.vcxproj", "{35A5F1CE-9058-4D97-A4D2-E66DCB2BAE54}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {35A5F1CE-9058-4D97-A4D2-E66DCB2BAE54}.Debug|x64.ActiveCfg = Debug|x64 17 | {35A5F1CE-9058-4D97-A4D2-E66DCB2BAE54}.Debug|x64.Build.0 = Debug|x64 18 | {35A5F1CE-9058-4D97-A4D2-E66DCB2BAE54}.Debug|x86.ActiveCfg = Debug|Win32 19 | {35A5F1CE-9058-4D97-A4D2-E66DCB2BAE54}.Debug|x86.Build.0 = Debug|Win32 20 | {35A5F1CE-9058-4D97-A4D2-E66DCB2BAE54}.Release|x64.ActiveCfg = Release|x64 21 | {35A5F1CE-9058-4D97-A4D2-E66DCB2BAE54}.Release|x64.Build.0 = Release|x64 22 | {35A5F1CE-9058-4D97-A4D2-E66DCB2BAE54}.Release|x86.ActiveCfg = Release|Win32 23 | {35A5F1CE-9058-4D97-A4D2-E66DCB2BAE54}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {B5466674-E43B-458E-BCC4-37E6346690AA} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Shadows/TGALoader.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "TGALoader.h" 3 | 4 | 5 | TGALoader::TGALoader() 6 | { 7 | } 8 | 9 | 10 | TGALoader::~TGALoader() 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /Shadows/TGALoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class TGALoader 3 | { 4 | public: 5 | TGALoader(); 6 | ~TGALoader(); 7 | }; 8 | 9 | -------------------------------------------------------------------------------- /Shadows/glfw3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/glfw3.dll -------------------------------------------------------------------------------- /Shadows/glfw3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/glfw3.lib -------------------------------------------------------------------------------- /Shadows/glfw3dll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/glfw3dll.lib -------------------------------------------------------------------------------- /Shadows/jAppSettings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "jAppSettings.h" 3 | 4 | jAppSettings* jAppSettings::_instance = nullptr; 5 | 6 | ////////////////////////////////////////////////////////////////////////// 7 | void jAppSettings::Init(int32 width, int32 height) 8 | { 9 | // todo it's depend on rhi type 10 | TwInit(TW_OPENGL_CORE, nullptr); 11 | TwWindowSize(width, height); 12 | 13 | auto mainPannel = jAppSettings::GetInstance().AddTwBar("MainPannel"); // Default Pannel 14 | mainPannel->SetSizeBar(250, 600); 15 | mainPannel->SetValueSizeFit(); 16 | } 17 | 18 | jAppSettingBase* jAppSettings::AddTwBar(const char* barName) 19 | { 20 | auto it_find = BarMap.find(barName); 21 | if (it_find != BarMap.end()) 22 | delete it_find->second; 23 | 24 | auto appSettings = new jAppSettingBase(TwNewBar(barName)); 25 | BarMap[barName] = appSettings; 26 | return appSettings; 27 | } 28 | 29 | void jAppSettings::DeleteTwBar(const char* barName) 30 | { 31 | auto it_find = BarMap.find(barName); 32 | if (it_find != BarMap.end()) 33 | { 34 | delete it_find->second; 35 | BarMap.erase(it_find); 36 | } 37 | } 38 | 39 | ////////////////////////////////////////////////////////////////////////// 40 | 41 | void jAppSettingBase::SetSizeBar(int sizeX, int sizeY) 42 | { 43 | char szTemp[256] = { 0, }; 44 | sprintf_s(szTemp, sizeof(szTemp) - 1, "%s size='%d %d'", TwGetBarName(Bar), sizeX, sizeY); 45 | TwDefine(szTemp); 46 | } 47 | 48 | void jAppSettingBase::SetPositionBar(int ix, int iy) 49 | { 50 | char szTemp[256] = { 0, }; 51 | sprintf_s(szTemp, sizeof(szTemp) - 1, "%s position='%d %d'", TwGetBarName(Bar), ix, iy); 52 | TwDefine(szTemp); 53 | } 54 | 55 | void jAppSettingBase::SetValueSizeFit() 56 | { 57 | char szTemp[256] = { 0, }; 58 | sprintf_s(szTemp, sizeof(szTemp) - 1, "%s valueswidth=fit", TwGetBarName(Bar)); 59 | TwDefine(szTemp); 60 | } 61 | -------------------------------------------------------------------------------- /Shadows/jBoundPrimitiveType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Math/Vector.h" 3 | 4 | struct jBoundBox 5 | { 6 | static jBoundBox GenerateBoundBox(const std::vector& vertices) 7 | { 8 | auto min = Vector(FLT_MAX); 9 | auto max = Vector(FLT_MIN); 10 | for (size_t i = 0; i < vertices.size() / 3; ++i) 11 | { 12 | auto curIndex = i * 3; 13 | auto x = vertices[curIndex]; 14 | auto y = vertices[curIndex + 1]; 15 | auto z = vertices[curIndex + 2]; 16 | if (max.x < x) 17 | max.x = x; 18 | if (max.y < y) 19 | max.y = y; 20 | if (max.z < z) 21 | max.z = z; 22 | 23 | if (min.x > x) 24 | min.x = x; 25 | if (min.y > y) 26 | min.y = y; 27 | if (min.z > z) 28 | min.z = z; 29 | } 30 | 31 | return { min, max }; 32 | } 33 | 34 | FORCEINLINE void CreateBoundBox(const std::vector& vertices) { *this = jBoundBox::GenerateBoundBox(vertices); } 35 | FORCEINLINE Vector GetExtent() const { return (Max - Min); } 36 | FORCEINLINE Vector GetHalfExtent() const { return GetExtent() / 0.5f; } 37 | 38 | Vector Min; 39 | Vector Max; 40 | }; 41 | 42 | struct jBoundSphere 43 | { 44 | float Radius = 0.0f; 45 | 46 | static jBoundSphere GenerateBoundSphere(const std::vector& vertices) 47 | { 48 | auto maxDist = FLT_MIN; 49 | for (size_t i = 0; i < vertices.size() / 3; ++i) 50 | { 51 | auto curIndex = i * 3; 52 | auto x = vertices[curIndex]; 53 | auto y = vertices[curIndex + 1]; 54 | auto z = vertices[curIndex + 2]; 55 | 56 | auto currentPos = Vector(x, y, z); 57 | const auto dist = currentPos.Length(); 58 | if (maxDist < dist) 59 | maxDist = dist; 60 | } 61 | return { maxDist }; 62 | } 63 | 64 | FORCEINLINE void CreateBoundSphere(const std::vector& vertices) { *this = jBoundSphere::GenerateBoundSphere(vertices); } 65 | }; 66 | -------------------------------------------------------------------------------- /Shadows/jCollision.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jCollision.h" 3 | 4 | 5 | jCollision::jCollision() 6 | { 7 | } 8 | 9 | 10 | jCollision::~jCollision() 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /Shadows/jCollision.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class jCollision 3 | { 4 | public: 5 | jCollision(); 6 | ~jCollision(); 7 | }; 8 | 9 | -------------------------------------------------------------------------------- /Shadows/jDeferredRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "jRHI.h" 3 | #include "jRenderer.h" 4 | #include "jGBuffer.h" 5 | #include "jPipeline.h" 6 | 7 | class jCamera; 8 | 9 | class jDeferredRenderer : public jRenderer 10 | { 11 | public: 12 | jDeferredRenderer(const jRenderTargetInfo& geometryBufferInfo); 13 | virtual ~jDeferredRenderer(); 14 | 15 | typedef void (*RenderPassFunc)(jCamera*); 16 | 17 | virtual void Setup(); 18 | virtual void Teardown(); 19 | 20 | virtual void ShadowPrePass(const jCamera* camera) override; 21 | virtual void RenderPass(const jCamera* camera) override; 22 | virtual void DebugRenderPass(const jCamera* camera) override; 23 | virtual void BoundVolumeRenderPass(const jCamera* camera) override; 24 | virtual void PostProcessPass(const jCamera* camera) override; 25 | virtual void PostRenderPass(const jCamera* camera) override; 26 | 27 | virtual void UpdateSettings() {} 28 | 29 | private: 30 | jGBuffer GBuffer; 31 | jRenderTargetInfo GeometryBufferInfo; 32 | jPipelineSet* DeferredDeepShadowMapPipelineSet = nullptr; 33 | std::shared_ptr LuminanceRenderTarget; 34 | std::shared_ptr OutRenderTarget; 35 | std::shared_ptr PostPrceoss_AA_DeepShadowAddition; 36 | std::shared_ptr PostProcessOutput; 37 | std::shared_ptr PostProcessOutput2; 38 | std::shared_ptr PostProcessLuminanceOutput; 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /Shadows/jEngine.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jEngine.h" 3 | #include "jAppSettings.h" 4 | #include "jShadowAppProperties.h" 5 | #include "jPipeline.h" 6 | #include "jShader.h" 7 | #include "jPerformanceProfile.h" 8 | #include "jSamplerStatePool.h" 9 | 10 | jEngine::jEngine() 11 | { 12 | } 13 | 14 | 15 | jEngine::~jEngine() 16 | { 17 | Game.Teardown(); 18 | 19 | jShadowAppSettingProperties::GetInstance().Teardown(jAppSettings::GetInstance().Get("MainPannel")); 20 | } 21 | 22 | void jEngine::Init() 23 | { 24 | jSamplerStatePool::CreateDefaultSamplerState(); 25 | jShaderInfo::CreateShaders(); 26 | IPipeline::SetupPipelines(); 27 | 28 | g_rhi->EnableSRGB(false); 29 | 30 | Game.Setup(); 31 | 32 | jShadowAppSettingProperties::GetInstance().Setup(jAppSettings::GetInstance().Get("MainPannel")); 33 | } 34 | 35 | void jEngine::ProcessInput() 36 | { 37 | Game.ProcessInput(); 38 | } 39 | 40 | void jEngine::Update(float deltaTime) 41 | { 42 | SCOPE_PROFILE(Engine_Update); 43 | SCOPE_GPU_PROFILE(Engine_Update); 44 | 45 | g_timeDeltaSecond = deltaTime; 46 | Game.Update(deltaTime); 47 | 48 | jShader::UpdateShaders(); 49 | } 50 | 51 | void jEngine::Resize(int width, int height) 52 | { 53 | glViewport(0, 0, width, height); 54 | } 55 | 56 | void jEngine::OnMouseButton() 57 | { 58 | Game.OnMouseButton(); 59 | } 60 | 61 | void jEngine::OnMouseMove(int32 xOffset, int32 yOffset) 62 | { 63 | Game.OnMouseMove(xOffset, yOffset); 64 | } 65 | -------------------------------------------------------------------------------- /Shadows/jEngine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "jGame.h" 4 | 5 | class jEngine 6 | { 7 | public: 8 | jEngine(); 9 | ~jEngine(); 10 | 11 | void Init(); 12 | void ProcessInput(); 13 | void Update(float deltaTime); 14 | void Resize(int width, int height); 15 | void OnMouseButton(); 16 | void OnMouseMove(int32 xOffset, int32 yOffset); 17 | 18 | jGame Game; 19 | 20 | class jAppSettingProperties* AppSettingProperties = nullptr; 21 | }; 22 | 23 | -------------------------------------------------------------------------------- /Shadows/jFile.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "jFile.h" 3 | 4 | uint64 jFile::GetFileTimeStamp(const char* filename) 5 | { 6 | JASSERT(filename); 7 | 8 | WIN32_FILE_ATTRIBUTE_DATA attributes; 9 | GetFileAttributesExA(filename, GetFileExInfoStandard, &attributes); 10 | return attributes.ftLastWriteTime.dwLowDateTime | static_cast(attributes.ftLastWriteTime.dwHighDateTime) << 32; 11 | } 12 | 13 | jFile::~jFile() 14 | { 15 | CloseFile(); 16 | } 17 | 18 | bool jFile::OpenFile(const char* szFileName, FileType::Enum fileType /*= FileType::BINARY*/, ReadWriteType::Enum readWriteType /*= ReadWriteType::READ*/) 19 | { 20 | std::string option; 21 | switch (readWriteType) 22 | { 23 | case ReadWriteType::READ: 24 | option += "r"; 25 | break; 26 | case ReadWriteType::WRITE: 27 | option += "w"; 28 | break; 29 | case ReadWriteType::APPEND: 30 | option += "a"; 31 | break; 32 | case ReadWriteType::READ_UPDATE: 33 | option += "r+"; 34 | break; 35 | case ReadWriteType::WRITE_UPDATE: 36 | option += "w+"; 37 | break; 38 | case ReadWriteType::APPEND_UPDATE: 39 | option += "a+"; 40 | break; 41 | } 42 | 43 | switch(fileType) 44 | { 45 | case FileType::BINARY: 46 | option += "b"; 47 | break; 48 | case FileType::TEXT: 49 | option += "t"; 50 | break; 51 | } 52 | 53 | CloseFile(); 54 | 55 | fopen_s(&m_fp, szFileName, option.c_str()); 56 | 57 | return (nullptr != m_fp); 58 | } 59 | 60 | size_t jFile::ReadFileToBuffer(bool appendToEndofBuffer/* = true*/, unsigned int index/* = 0*/, unsigned int count/* = 0*/) 61 | { 62 | size_t readSize = 0; 63 | if (m_fp) 64 | { 65 | unsigned int writeStartIndex = 0; 66 | if (0 < count) 67 | { 68 | if (appendToEndofBuffer) 69 | { 70 | writeStartIndex = static_cast(m_buffer.size() - 1); 71 | m_buffer.resize(m_buffer.size() + count + 1); 72 | } 73 | else 74 | { 75 | m_buffer.resize(count + 1); 76 | } 77 | } 78 | else 79 | { 80 | fseek(m_fp, 0, SEEK_END); // non-portable 81 | count = ftell(m_fp); 82 | 83 | m_buffer.clear(); 84 | m_buffer.resize(count + 1); 85 | } 86 | fseek(m_fp, index, SEEK_SET); 87 | 88 | readSize += fread(&m_buffer[writeStartIndex], sizeof(ELEMENT_TYPE), count, m_fp); 89 | m_buffer.resize(readSize + 1); 90 | m_buffer[readSize] = 0; 91 | } 92 | 93 | return readSize; 94 | } 95 | 96 | void jFile::CloseFile() 97 | { 98 | if (m_fp) 99 | { 100 | fclose(m_fp); 101 | m_fp = NULL; 102 | } 103 | } 104 | 105 | const char* jFile::GetBuffer(unsigned int index /*= 0*/, unsigned int count /*= 0*/) const 106 | { 107 | if (m_buffer.empty()) 108 | { 109 | return nullptr; 110 | } 111 | 112 | return &m_buffer[0]; 113 | } 114 | 115 | bool jFile::GetBuffer(FILE_BUFFER& outBuffer, const char* startToken, const char* endToken) 116 | { 117 | if (m_buffer.empty()) 118 | { 119 | return false; 120 | } 121 | 122 | char* startPos = strstr(&m_buffer[0], startToken); 123 | 124 | if (startPos) 125 | { 126 | size_t startTokenLength = strlen(startToken); 127 | startPos += startTokenLength; 128 | 129 | char* endPos = strstr(&m_buffer[0], endToken); 130 | size_t count = 0; 131 | if (endPos) 132 | { 133 | count = endPos - startPos; 134 | } 135 | else 136 | { 137 | count = &m_buffer[m_buffer.size() - 1] - startPos; 138 | } 139 | 140 | if (0 < count) 141 | { 142 | outBuffer.resize(count + 1); 143 | memcpy(&outBuffer[0], startPos, count * sizeof(ELEMENT_TYPE)); 144 | outBuffer[count] = 0; 145 | 146 | return true; 147 | } 148 | } 149 | 150 | return false; 151 | } 152 | -------------------------------------------------------------------------------- /Shadows/jFile.h: -------------------------------------------------------------------------------- 1 | #ifndef __FILE_H__ 2 | #define __FILE_H__ 3 | 4 | struct FileType 5 | { 6 | enum Enum 7 | { 8 | BINARY = 0, 9 | TEXT, 10 | }; 11 | }; 12 | 13 | struct ReadWriteType 14 | { 15 | enum Enum 16 | { 17 | READ = 0, // READ ONLY, MUST EXIST FILE 18 | WRITE, // WRITE ONLY, IF THE FILE EXIST, DELETE ALL CONTENTS, IF THE FILE NOT EXIST CREATE FILE. 19 | APPEND, // WRITE ONLY END OF THE FILE, IF THE FILE NOT EXIST CREATE FILE. 20 | READ_UPDATE, // READ / WRITE, IF THE FILE NOT EXIST, NULL WILL RETURN 21 | WRITE_UPDATE, // READ / WRITE, IF THE FILE EXIST, DELETE ALL CONTENTS, IF THE FILE NOT EXIST, FILE WILL CREATE. 22 | APPEND_UPDATE, // READ / WRITE, WRITE END OF THE FILE, READ CAN ANY WHERE. IF THE FILE NOT EXIST, FILE WILL CREATE 23 | }; 24 | }; 25 | 26 | class jFile 27 | { 28 | public: 29 | typedef char ELEMENT_TYPE; 30 | typedef std::vector FILE_BUFFER; 31 | 32 | static uint64 GetFileTimeStamp(const char* filename); 33 | 34 | jFile() : m_fp(nullptr) {} 35 | ~jFile(); 36 | 37 | bool OpenFile(const char* szFileName, FileType::Enum fileType = FileType::BINARY, ReadWriteType::Enum readWriteType = ReadWriteType::READ); 38 | size_t ReadFileToBuffer(bool appendToEndofBuffer = true, unsigned int index = 0, unsigned int count = 0); 39 | void CloseFile(); 40 | const char* GetBuffer(unsigned int index = 0, unsigned int count = 0) const; 41 | bool GetBuffer(FILE_BUFFER& outBuffer, const char* startToken, const char* endToken); 42 | bool IsBufferEmpty() const { return m_buffer.empty(); } 43 | 44 | private: 45 | FILE* m_fp; 46 | std::vector m_buffer; 47 | }; 48 | 49 | #endif // __FILE_H__ 50 | 51 | -------------------------------------------------------------------------------- /Shadows/jForwardRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "jRHI.h" 3 | #include "jRenderer.h" 4 | #include "jGBuffer.h" 5 | #include "jPipeline.h" 6 | 7 | class jCamera; 8 | 9 | class jForwardRenderer : public jRenderer 10 | { 11 | public: 12 | using jRenderer::jRenderer; 13 | virtual ~jForwardRenderer(); 14 | 15 | typedef void (*RenderPassFunc)(jCamera*); 16 | 17 | virtual void Setup(); 18 | virtual void Teardown(); 19 | 20 | virtual void ShadowPrePass(const jCamera* camera) override; 21 | virtual void RenderPass(const jCamera* camera) override; 22 | virtual void DebugRenderPass(const jCamera* camera) override; 23 | virtual void BoundVolumeRenderPass(const jCamera* camera) override; 24 | virtual void PostProcessPass(const jCamera* camera) override; 25 | virtual void PostRenderPass(const jCamera* camera) override; 26 | virtual void DebugUIPass(const jCamera* camera) override; 27 | 28 | virtual void UpdateSettings() {} 29 | 30 | std::shared_ptr RenderTarget; 31 | std::shared_ptr RenderTarget2; 32 | std::shared_ptr LuminanceRenderTarget; 33 | std::shared_ptr AvgLuminanceRenderTarget; 34 | std::shared_ptr PostProcessInput; 35 | }; 36 | 37 | -------------------------------------------------------------------------------- /Shadows/jGBuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jGBuffer.h" 3 | #include "jRHI.h" 4 | 5 | jGBuffer::~jGBuffer() 6 | { 7 | GeometryBuffer; 8 | } 9 | 10 | bool jGBuffer::Begin(int index /*= 0*/, bool mrt /*= false*/) const 11 | { 12 | return GeometryBuffer && GeometryBuffer->Begin(index, mrt); 13 | } 14 | 15 | void jGBuffer::End() const 16 | { 17 | GeometryBuffer->End(); 18 | } 19 | 20 | void jGBuffer::BindGeometryBuffer(const jShader* shader) const 21 | { 22 | jMaterialData materialData; 23 | { 24 | static auto name = jName("ColorSampler"); 25 | materialData.AddMaterialParam(name, GeometryBuffer->Textures[0].get()); 26 | } 27 | 28 | { 29 | static auto name = jName("NormalSampler"); 30 | materialData.AddMaterialParam(name, GeometryBuffer->Textures[1].get()); 31 | } 32 | 33 | { 34 | static auto name = jName("PosInWorldSampler"); 35 | materialData.AddMaterialParam(name, GeometryBuffer->Textures[2].get()); 36 | } 37 | 38 | { 39 | static auto name = jName("PosInLightSampler"); 40 | materialData.AddMaterialParam(name, GeometryBuffer->Textures[3].get()); 41 | } 42 | 43 | g_rhi->SetMatetrial(&materialData, shader, 20); 44 | } -------------------------------------------------------------------------------- /Shadows/jGBuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct jRenderTarget; 4 | struct jShader; 5 | 6 | class jGBuffer 7 | { 8 | public: 9 | ~jGBuffer(); 10 | 11 | bool Begin(int index = 0, bool mrt = false) const; 12 | void End() const; 13 | void BindGeometryBuffer(const jShader* shader) const; 14 | void BindGeometryBuffer(const jShader* shader, const jTexture* resolvedColor) const; 15 | 16 | std::shared_ptr GeometryBuffer; 17 | }; -------------------------------------------------------------------------------- /Shadows/jGame.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "jShadowTypes.h" 3 | #include "jPostProcess.h" 4 | 5 | class jRHI; 6 | extern jRHI* g_rhi; 7 | 8 | class jDirectionalLight; 9 | class jLight; 10 | class jCamera; 11 | struct jShader; 12 | class jPointLight; 13 | class jSpotLight; 14 | class jRenderer; 15 | struct jRenderTarget; 16 | struct IShaderStorageBufferObject; 17 | struct IAtomicCounterBuffer; 18 | struct jTexture; 19 | struct jRenderTarget; 20 | class jObject; 21 | class jPipelineSet; 22 | class jCascadeDirectionalLight; 23 | class jUIQuadPrimitive; 24 | 25 | class jGame 26 | { 27 | public: 28 | jGame(); 29 | ~jGame(); 30 | 31 | void ProcessInput(); 32 | void Setup(); 33 | 34 | enum class ESpawnedType 35 | { 36 | None = 0, 37 | Hair, 38 | TestPrimitive, 39 | CubePrimitive 40 | }; 41 | 42 | void SpawnObjects(ESpawnedType spawnType); 43 | 44 | void RemoveSpawnedObjects(); 45 | void SpawnHairObjects(); 46 | void SpawnTestPrimitives(); 47 | void SapwnCubePrimitives(); 48 | 49 | void SpawnGraphTestFunc(); // Test 50 | 51 | ESpawnedType SpawnedType = ESpawnedType::None; 52 | 53 | void Update(float deltaTime); 54 | 55 | void UpdateAppSetting(); 56 | 57 | void OnMouseButton(); 58 | void OnMouseMove(int32 xOffset, int32 yOffset); 59 | void Teardown(); 60 | 61 | jDirectionalLight* DirectionalLight = nullptr; 62 | jDirectionalLight* NormalDirectionalLight = nullptr; 63 | jCascadeDirectionalLight* CascadeDirectionalLight = nullptr; 64 | jPointLight* PointLight = nullptr; 65 | jSpotLight* SpotLight = nullptr; 66 | jLight* AmbientLight = nullptr; 67 | jCamera* MainCamera = nullptr; 68 | 69 | jObject* Sphere = nullptr; 70 | 71 | jRenderer* Renderer = nullptr; 72 | 73 | std::map ShadowRendererMap; 74 | EShadowType ShadowType = EShadowType::MAX; 75 | 76 | jRenderer* DeferredRenderer = nullptr; 77 | jRenderer* ForwardRenderer = nullptr; 78 | 79 | jPipelineSet* ShadowVolumePipelineSet = nullptr; 80 | std::map ShadowPipelineSetMap; 81 | std::map ShadowPoissonSamplePipelineSetMap; 82 | 83 | EShadowMapType CurrentShadowMapType = EShadowMapType::SSM; 84 | bool UsePoissonSample = false; 85 | EShadowType CurrentShadowType = EShadowType::MAX; 86 | 87 | jObject* DirectionalLightInfo = nullptr; 88 | jObject* PointLightInfo = nullptr; 89 | jObject* SpotLightInfo = nullptr; 90 | jUIQuadPrimitive* DirectionalLightShadowMapUIDebug = nullptr; 91 | 92 | std::vector SpawnedObjects; 93 | }; 94 | 95 | -------------------------------------------------------------------------------- /Shadows/jHairModelLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class jHairObject; 4 | 5 | class jHairModelLoader 6 | { 7 | public: 8 | ~jHairModelLoader(); 9 | 10 | static jHairModelLoader& GetInstance() 11 | { 12 | if (!_instance) 13 | _instance = new jHairModelLoader(); 14 | return *_instance; 15 | } 16 | 17 | jHairObject* CreateHairObject(const char* filename); 18 | 19 | private: 20 | jHairModelLoader(); 21 | static jHairModelLoader* _instance; 22 | }; 23 | 24 | -------------------------------------------------------------------------------- /Shadows/jImageFileLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct jImageData 4 | { 5 | bool sRGB = false; 6 | int32 Width = 0; 7 | int32 Height = 0; 8 | jName Filename; 9 | std::vector ImageData; 10 | ETextureFormat Format = ETextureFormat::RGBA; 11 | EFormatType FormatType = EFormatType::UNSIGNED_BYTE; 12 | }; 13 | 14 | class jImageFileLoader 15 | { 16 | public: 17 | ~jImageFileLoader(); 18 | 19 | static jImageFileLoader& GetInstance() 20 | { 21 | if (!_instance) 22 | _instance = new jImageFileLoader(); 23 | return *_instance; 24 | } 25 | 26 | std::weak_ptr LoadImageDataFromFile(const jName& filename, bool sRGB = false); 27 | std::weak_ptr LoadTextureFromFile(const jName& filename, bool sRGB = false); 28 | 29 | private: 30 | std::map > CachedImageDataMap; 31 | std::map > CachedTextureMap; 32 | 33 | private: 34 | jImageFileLoader(); 35 | 36 | static jImageFileLoader* _instance; 37 | }; 38 | 39 | -------------------------------------------------------------------------------- /Shadows/jImageLoader.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jImageLoader.h" 3 | 4 | 5 | jImageLoader::jImageLoader() 6 | { 7 | } 8 | 9 | 10 | jImageLoader::~jImageLoader() 11 | { 12 | } 13 | 14 | void jImageLoader::LoadJpg(std::vector& out, const char* filename) 15 | { 16 | 17 | } 18 | 19 | void jImageLoader::LoadPng(std::vector& out, const char* filename) 20 | { 21 | 22 | } 23 | 24 | void jImageLoader::Load(std::vector& out, const char* filename) 25 | { 26 | const auto length = strlen(filename); 27 | if (length <= 4) 28 | return; 29 | 30 | if (strstr(&filename[length - 4], ".jpg")) 31 | { 32 | LoadJpg(out, filename); 33 | } 34 | else if (strstr(&filename[length - 4], ".png")) 35 | { 36 | LoadPng(out, filename); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Shadows/jImageLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class jImageLoader 3 | { 4 | public: 5 | jImageLoader(); 6 | ~jImageLoader(); 7 | 8 | void LoadJpg(std::vector& out, const char* filename); 9 | void LoadPng(std::vector& out, const char* filename); 10 | void Load(std::vector& out, const char* filename); 11 | }; 12 | 13 | -------------------------------------------------------------------------------- /Shadows/jInputEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jInputEvent.h" 3 | 4 | 5 | jInputEvent::jInputEvent() 6 | { 7 | } 8 | 9 | 10 | jInputEvent::~jInputEvent() 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /Shadows/jInputEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class jInputEvent 3 | { 4 | public: 5 | jInputEvent(); 6 | ~jInputEvent(); 7 | }; 8 | 9 | -------------------------------------------------------------------------------- /Shadows/jMaterial.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jMaterial.h" 3 | -------------------------------------------------------------------------------- /Shadows/jMaterial.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | -------------------------------------------------------------------------------- /Shadows/jMeshObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "jObject.h" 3 | #include "Math\Vector.h" 4 | 5 | struct jTexture; 6 | 7 | struct jMeshMaterial 8 | { 9 | enum class EMaterialTextureType : int8 10 | { 11 | DiffuseSampler = 0, 12 | SpecularSampler, 13 | AmbientSampler, 14 | EmissiveSampler, 15 | HeightSampler, // Height or Bump map 16 | NormalSampler, 17 | ShininessSampler, 18 | OpacitySampler, 19 | DisplacementSampler, 20 | LightmapSampler, 21 | ReflectionSampler, 22 | Max 23 | }; 24 | 25 | static jName MaterialTextureTypeString[(int32)EMaterialTextureType::Max + 1]; 26 | 27 | struct Material 28 | { 29 | Vector4 Ambient = Vector4::OneVector; 30 | Vector4 Diffuse = Vector4::OneVector; 31 | Vector4 Specular = Vector4::OneVector; 32 | Vector4 Emissive = Vector4::OneVector; 33 | float SpecularShiness = 0.0f; 34 | float Opacity = 1.0f; 35 | float Reflectivity = 0.0f; 36 | float IndexOfRefraction = 1.0f; // 1.0 means lights will not refract 37 | 38 | void BindMaterialData(const jShader* shader) const; 39 | }; 40 | 41 | struct TextureData 42 | { 43 | std::weak_ptr TextureWeakPtr; 44 | ETextureAddressMode TextureAddressModeU = ETextureAddressMode::REPEAT; 45 | ETextureAddressMode TextureAddressModeV = ETextureAddressMode::REPEAT; 46 | std::string TextureName; 47 | 48 | const jTexture* GetTexture() const 49 | { 50 | if (TextureWeakPtr.expired()) 51 | return nullptr; 52 | return TextureWeakPtr.lock().get(); 53 | } 54 | }; 55 | 56 | Material Data; 57 | TextureData TexData[static_cast(EMaterialTextureType::Max)]; 58 | }; 59 | struct jMeshData 60 | { 61 | std::vector Vertices; 62 | std::vector Normals; 63 | std::vector Tangents; 64 | std::vector Bitangents; 65 | std::vector TexCoord; 66 | std::map Materials; 67 | std::vector Faces; 68 | }; 69 | 70 | struct jSubMesh 71 | { 72 | int32 StartVertex = -1; 73 | int32 EndVertex = -1; 74 | int32 StartFace = -1; 75 | int32 EndFace = -1; 76 | int32 MaterialIndex = -1; 77 | 78 | jMaterialData MaterialData; 79 | std::string Name; 80 | }; 81 | 82 | struct jMeshNode 83 | { 84 | int32 SubMeshIndex = -1; 85 | jMeshNode* Parent = nullptr; 86 | 87 | std::vector MeshIndex; 88 | std::vector childNode; 89 | }; 90 | 91 | class jMeshObject : public jObject 92 | { 93 | public: 94 | static jMeshMaterial NullMeshMateral; 95 | 96 | jMeshObject(); 97 | 98 | jMeshData* MeshData = nullptr; 99 | mutable std::vector SubMeshes; 100 | jMeshNode* RootNode = nullptr; 101 | 102 | virtual void Draw(const jCamera* camera, const jShader* shader, const std::list& lights, int32 instanceCount = 0 ) const override; 103 | 104 | void SetMaterialUniform(const jShader* shader, const jMeshMaterial* material) const; 105 | 106 | void DrawNode(const jMeshNode* node, const jCamera* camera, const jShader* shader, const std::list& lights) const; 107 | void DrawSubMesh(int32 meshIndex, const jCamera* camera, const jShader* shader, const std::list& lights) const; 108 | }; 109 | 110 | class jHairObject : public jObject 111 | { 112 | public: 113 | 114 | }; 115 | -------------------------------------------------------------------------------- /Shadows/jModelLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class jMeshObject; 4 | 5 | class jModelLoader 6 | { 7 | public: 8 | ~jModelLoader(); 9 | 10 | static jModelLoader& GetInstance() 11 | { 12 | if (!_instance) 13 | _instance = new jModelLoader(); 14 | return *_instance; 15 | } 16 | 17 | //bool ConvertToFBX(const char* destFilename, const char* filename) const; 18 | 19 | jMeshObject* LoadFromFile(const char* filename); 20 | jMeshObject* LoadFromFile(const char* filename, const char* materialRootDir); 21 | 22 | private: 23 | jModelLoader(); 24 | 25 | static jModelLoader* _instance; 26 | }; 27 | 28 | -------------------------------------------------------------------------------- /Shadows/jObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "jBoundPrimitiveType.h" 3 | 4 | class jRenderObject; 5 | class jCamera; 6 | struct jShader; 7 | class jLight; 8 | class jVertexAdjacency; 9 | class IShadowVolume; 10 | 11 | class jObject 12 | { 13 | public: 14 | jObject(); 15 | virtual ~jObject(); 16 | 17 | ////////////////////////////////////////////////////////////////////////// 18 | static void AddObject(jObject* object); 19 | static void RemoveObject(jObject* object); 20 | static void FlushDirtyState(); 21 | 22 | static const std::list& GetShadowCasterObject() { return s_ShadowCasterObject; } 23 | static const std::list& GetStaticObject() { return s_StaticObjects; } 24 | static const std::list& GetBoundBoxObject() { return s_BoundBoxObjects; } 25 | static const std::list& GetBoundSphereObject() { return s_BoundSphereObjects; } 26 | static const std::list& GetDebugObject() { return s_DebugObjects; } 27 | static const std::list& GetUIObject() { return s_UIObjects; } 28 | static const std::list& GetUIDebugObject() { return s_UIDebugObjects; } 29 | 30 | static void AddBoundBoxObject(jObject* object); 31 | static void RemoveBoundBoxObject(jObject* object); 32 | 33 | static void AddBoundSphereObject(jObject* object); 34 | static void RemoveBoundSphereObject(jObject* object); 35 | 36 | static void AddDebugObject(jObject* object); 37 | static void RemoveDebugObject(jObject* object); 38 | 39 | static void AddUIObject(jObject* object); 40 | static void RemoveUIObject(jObject* object); 41 | 42 | static void AddUIDebugObject(jObject* object); 43 | static void RemoveUIDebugObject(jObject* object); 44 | ////////////////////////////////////////////////////////////////////////// 45 | 46 | virtual void Update(float deltaTime); 47 | //virtual void Draw(const jCamera* camera, const jShader* shader); 48 | virtual void Draw(const jCamera* camera, const jShader* shader, const std::list& lights, int32 instanceCount = 0) const; 49 | 50 | void SetDirtyState() { DirtyObjectState = true; s_DirtyStateObjects.insert(this); } 51 | 52 | void SetSkipShadowMapGen(bool skipShadowMapGen) { SkipShadowMapGen = skipShadowMapGen; SetDirtyState(); } 53 | void SetSkipUpdateShadowVolume(bool skipUpdateShadowVolume) { SkipUpdateShadowVolume = skipUpdateShadowVolume; SetDirtyState(); } 54 | void SetVisible(bool visible) { Visible = visible; SetDirtyState(); } 55 | 56 | void CreateBoundBox(bool isShow = true); 57 | void ShowBoundBox(bool isShow); 58 | 59 | jRenderObject* RenderObject = nullptr; 60 | jVertexAdjacency* VertexAdjacency = nullptr; 61 | IShadowVolume* ShadowVolumeGPU = nullptr; 62 | IShadowVolume* ShadowVolumeCPU = nullptr; 63 | 64 | bool SkipShadowMapGen = false; 65 | bool SkipUpdateShadowVolume = false; 66 | bool Visible = true; 67 | bool DirtyObjectState = false; 68 | 69 | bool IsPostUpdate = true; 70 | std::function PostUpdateFunc; 71 | 72 | // todo 현재는 보유만 하고있음. 73 | jObject* BoundBoxObject = nullptr; 74 | jObject* BoundSphereObject = nullptr; 75 | 76 | jBoundBox BoundBox; 77 | jBoundSphere BoundSphere; 78 | 79 | private: 80 | static std::list s_ShadowCasterObject; 81 | static std::list s_StaticObjects; 82 | static std::list s_BoundBoxObjects; 83 | static std::list s_BoundSphereObjects; 84 | static std::list s_DebugObjects; 85 | static std::list s_UIObjects; 86 | static std::list s_UIDebugObjects; 87 | static std::set s_DirtyStateObjects; 88 | }; 89 | 90 | -------------------------------------------------------------------------------- /Shadows/jPerformanceProfile.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jPerformanceProfile.h" 3 | 4 | jPerformanceProfile* jPerformanceProfile::_instance = nullptr; 5 | 6 | std::unordered_map ScopedProfileCPUMap[MaxProfileFrame]; 7 | std::unordered_map ScopedProfileGPUMap[MaxProfileFrame]; 8 | static int32 PerformanceFrame = 0; 9 | 10 | std::unordered_set jQueryTimePool::s_running; 11 | std::unordered_set jQueryTimePool::s_resting; 12 | 13 | std::list jProfile_GPU::WatingResultList[2]; 14 | int32 jProfile_GPU::CurrentWatingResultListIndex = 0; 15 | 16 | int32 NextFrame() 17 | { 18 | PerformanceFrame = (PerformanceFrame + 1) % MaxProfileFrame; 19 | return PerformanceFrame; 20 | } 21 | 22 | void ClearScopedProfileCPU() 23 | { 24 | for (int32 i = 0; i < MaxProfileFrame; ++i) 25 | ScopedProfileCPUMap[i].clear(); 26 | } 27 | 28 | void AddScopedProfileCPU(const jName& name, uint64 elapsedTick) 29 | { 30 | ScopedProfileCPUMap[PerformanceFrame][name] = elapsedTick; 31 | } 32 | 33 | void ClearScopedProfileGPU() 34 | { 35 | for (int32 i = 0; i < MaxProfileFrame; ++i) 36 | ScopedProfileGPUMap[i].clear(); 37 | } 38 | 39 | void AddScopedProfileGPU(const jName& name, uint64 elapsedTick) 40 | { 41 | ScopedProfileGPUMap[PerformanceFrame][name] = elapsedTick; 42 | } 43 | 44 | void jPerformanceProfile::Update(float deltaTime) 45 | { 46 | jProfile_GPU::ProcessWaitings(); 47 | 48 | CalcAvg(); 49 | NextFrame(); 50 | 51 | if (TRUE_PER_MS(1000)) 52 | PrintOutputDebugString(); 53 | } 54 | 55 | void jPerformanceProfile::CalcAvg() 56 | { 57 | { 58 | AvgProfileMap.clear(); 59 | 60 | for (int32 i = 0; i < MaxProfileFrame; ++i) 61 | { 62 | const auto& scopedProfileMap = ScopedProfileCPUMap[i]; 63 | for (auto& iter : scopedProfileMap) 64 | { 65 | auto& avgProfile = AvgProfileMap[iter.first]; 66 | avgProfile.TotalElapsedTick += iter.second; 67 | ++avgProfile.TotalSampleCount; 68 | } 69 | } 70 | 71 | for (auto& iter : AvgProfileMap) 72 | { 73 | JASSERT(iter.second.TotalSampleCount > 0); 74 | iter.second.AvgElapsedMS = iter.second.TotalElapsedTick / static_cast(iter.second.TotalSampleCount); // ms 75 | } 76 | } 77 | 78 | { 79 | GPUAvgProfileMap.clear(); 80 | 81 | for (int32 i = 0; i < MaxProfileFrame; ++i) 82 | { 83 | const auto& scopedProfileMap = ScopedProfileGPUMap[i]; 84 | for (auto& iter : scopedProfileMap) 85 | { 86 | auto& avgProfile = GPUAvgProfileMap[iter.first]; 87 | avgProfile.TotalElapsedTick += iter.second; 88 | ++avgProfile.TotalSampleCount; 89 | } 90 | } 91 | 92 | for (auto& iter : GPUAvgProfileMap) 93 | { 94 | JASSERT(iter.second.TotalSampleCount > 0); 95 | iter.second.AvgElapsedMS = (iter.second.TotalElapsedTick / static_cast(iter.second.TotalSampleCount)) * 0.000001; // ns -> ms 96 | } 97 | } 98 | } 99 | 100 | void jPerformanceProfile::PrintOutputDebugString() 101 | { 102 | std::string result; 103 | char szTemp[128] = { 0, }; 104 | if (!AvgProfileMap.empty()) 105 | { 106 | result += "-----CPU---PerformanceProfile----------\n"; 107 | for (auto& iter : AvgProfileMap) 108 | { 109 | sprintf_s(szTemp, sizeof(szTemp), "%s : \t\t\t\t%lf ms", iter.first.ToStr(), iter.second.AvgElapsedMS); 110 | result += szTemp; 111 | result += "\n"; 112 | } 113 | } 114 | 115 | if (!GPUAvgProfileMap.empty()) 116 | { 117 | result += "-----GPU---PerformanceProfile----------\n"; 118 | for (auto& iter : GPUAvgProfileMap) 119 | { 120 | sprintf_s(szTemp, sizeof(szTemp), "%s : \t\t\t\t%lf ms", iter.first.ToStr(), iter.second.AvgElapsedMS); 121 | result += szTemp; 122 | result += "\n"; 123 | } 124 | } 125 | OutputDebugStringA(result.c_str()); 126 | } 127 | -------------------------------------------------------------------------------- /Shadows/jRHI.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jRHI.h" 3 | #include "jShader.h" 4 | 5 | 6 | ////////////////////////////////////////////////////////////////////////// 7 | void IUniformBuffer::Bind(const jShader* shader) const 8 | { 9 | SetUniformbuffer(shader); 10 | } 11 | 12 | ////////////////////////////////////////////////////////////////////////// 13 | 14 | jRHI::jRHI() 15 | { 16 | } 17 | 18 | void jRHI::MapBufferdata(IBuffer* buffer) const 19 | { 20 | 21 | } 22 | 23 | void jQueryPrimitiveGenerated::Begin() const 24 | { 25 | g_rhi->BeginQueryPrimitiveGenerated(this); 26 | } 27 | 28 | void jQueryPrimitiveGenerated::End() const 29 | { 30 | g_rhi->EndQueryPrimitiveGenerated(); 31 | } 32 | 33 | uint64 jQueryPrimitiveGenerated::GetResult() 34 | { 35 | g_rhi->GetQueryPrimitiveGeneratedResult(this); 36 | return NumOfGeneratedPrimitives; 37 | } 38 | 39 | void jMaterialData::AddMaterialParam(const jName& name, const jTexture* texture, const jSamplerState* samplerState) 40 | { 41 | Params.emplace_back(jMaterialParam(name, texture, samplerState)); 42 | } 43 | 44 | void jMaterialData::SetMaterialParam(int32 index, const jName& name, const jTexture* texture, const jSamplerState* samplerState /*= nullptr*/) 45 | { 46 | if (Params.size() <= index) 47 | { 48 | Params.resize(index + 1); 49 | OutputDebugStringA("Resized Params in SetMaterialParam\n"); 50 | } 51 | 52 | Params[index].Name = name; 53 | Params[index].Texture = texture; 54 | Params[index].SamplerState = samplerState; 55 | } 56 | 57 | void jMaterialData::SetMaterialParam(int32 index, const jName& name) 58 | { 59 | if (Params.size() <= index) 60 | return; 61 | 62 | Params[index].Name = name; 63 | } 64 | 65 | void jMaterialData::SetMaterialParam(int32 index, const jTexture* texture) 66 | { 67 | if (Params.size() <= index) 68 | return; 69 | 70 | Params[index].Texture = texture; 71 | } 72 | 73 | void jMaterialData::SetMaterialParam(int32 index, const jSamplerState* samplerState) 74 | { 75 | if (Params.size() <= index) 76 | return; 77 | 78 | Params[index].SamplerState = samplerState; 79 | } 80 | 81 | jName GetCommonTextureName(int32 index) 82 | { 83 | static std::vector s_tex_name; 84 | 85 | if ((s_tex_name.size() > index) && s_tex_name[index].IsValid()) 86 | { 87 | return s_tex_name[index]; 88 | } 89 | 90 | if (s_tex_name.size() < (index + 1)) 91 | s_tex_name.resize(index + 1); 92 | 93 | char szTemp[128] = { 0, }; 94 | if (index > 0) 95 | sprintf_s(szTemp, sizeof(szTemp), "tex_object%d", index + 1); 96 | else 97 | sprintf_s(szTemp, sizeof(szTemp), "tex_object"); 98 | 99 | s_tex_name[index] = jName(szTemp); 100 | return s_tex_name[index]; 101 | } 102 | 103 | jName GetCommonTextureSRGBName(int32 index) 104 | { 105 | static std::vector s_tex_srgb_name; 106 | 107 | if ((s_tex_srgb_name.size() > index) && s_tex_srgb_name[index].IsValid()) 108 | { 109 | return s_tex_srgb_name[index]; 110 | } 111 | 112 | if (s_tex_srgb_name.size() < (index + 1)) 113 | s_tex_srgb_name.resize(index + 1); 114 | 115 | char szTemp[128] = { 0, }; 116 | sprintf_s(szTemp, sizeof(szTemp), "TextureSRGB[%d]", index); 117 | 118 | s_tex_srgb_name[index] = jName(szTemp); 119 | return s_tex_srgb_name[index]; 120 | } 121 | -------------------------------------------------------------------------------- /Shadows/jRHI_DirectX11.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jRHI_DirectX11.h" 3 | 4 | 5 | jRHI_DirectX11::jRHI_DirectX11() 6 | { 7 | } 8 | 9 | 10 | jRHI_DirectX11::~jRHI_DirectX11() 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /Shadows/jRHI_DirectX11.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "jRHI.h" 4 | 5 | // todo 6 | class jRHI_DirectX11 : public jRHI 7 | { 8 | public: 9 | jRHI_DirectX11(); 10 | ~jRHI_DirectX11(); 11 | }; 12 | 13 | -------------------------------------------------------------------------------- /Shadows/jRHI_Vulkan.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jRHI_Vulkan.h" 3 | 4 | 5 | jRHI_Vulkan::jRHI_Vulkan() 6 | { 7 | } 8 | 9 | 10 | jRHI_Vulkan::~jRHI_Vulkan() 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /Shadows/jRHI_Vulkan.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "jRHI.h" 4 | 5 | // todo 6 | class jRHI_Vulkan : public jRHI 7 | { 8 | public: 9 | jRHI_Vulkan(); 10 | ~jRHI_Vulkan(); 11 | }; 12 | 13 | -------------------------------------------------------------------------------- /Shadows/jRenderTargetPool.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jRenderTargetPool.h" 3 | #include "jRHI.h" 4 | 5 | std::map > jRenderTargetPool::RenderTargetResourceMap; 6 | std::map jRenderTargetPool::RenderTargetHashVariableMap; 7 | 8 | struct jTexture* jRenderTargetPool::GetNullTexture(ETextureType type) 9 | { 10 | switch (type) 11 | { 12 | case ETextureType::TEXTURE_2D: 13 | case ETextureType::TEXTURE_2D_ARRAY_OMNISHADOW: 14 | { 15 | static auto temp = jRenderTargetPool::GetRenderTarget({ ETextureType::TEXTURE_2D, ETextureFormat::RGBA, ETextureFormat::RGBA, EFormatType::BYTE, EDepthBufferType::NONE, 2, 2, 1 }); 16 | return temp->GetTexture(); 17 | } 18 | case ETextureType::TEXTURE_2D_ARRAY: 19 | { 20 | static auto temp = jRenderTargetPool::GetRenderTarget({ ETextureType::TEXTURE_2D_ARRAY, ETextureFormat::RGBA, ETextureFormat::RGBA, EFormatType::BYTE, EDepthBufferType::NONE, 2, 2, 1 }); 21 | return temp->GetTexture(); 22 | } 23 | case ETextureType::TEXTURE_2D_MULTISAMPLE: 24 | case ETextureType::TEXTURE_2D_ARRAY_OMNISHADOW_MULTISAMPLE: 25 | { 26 | static auto temp = jRenderTargetPool::GetRenderTarget(jRenderTargetInfo(ETextureType::TEXTURE_2D_MULTISAMPLE, ETextureFormat::RGBA, ETextureFormat::RGBA 27 | , EFormatType::BYTE, EDepthBufferType::NONE, 2, 2, 1, ETextureFilter::LINEAR, ETextureFilter::LINEAR, false, false, 4)); 28 | return temp->GetTexture(); 29 | } 30 | case ETextureType::TEXTURE_2D_ARRAY_MULTISAMPLE: 31 | { 32 | static auto temp = jRenderTargetPool::GetRenderTarget(jRenderTargetInfo(ETextureType::TEXTURE_2D_ARRAY_MULTISAMPLE, ETextureFormat::RGBA, ETextureFormat::RGBA 33 | , EFormatType::BYTE, EDepthBufferType::NONE, 2, 2, 1, ETextureFilter::LINEAR, ETextureFilter::LINEAR, false, false, 4)); 34 | return temp->GetTexture(); 35 | } 36 | case ETextureType::TEXTURE_CUBE: 37 | { 38 | static auto temp = jRenderTargetPool::GetRenderTarget({ ETextureType::TEXTURE_CUBE, ETextureFormat::RGBA, ETextureFormat::RGBA, EFormatType::BYTE, EDepthBufferType::NONE, 2, 2, 1 }); 39 | return temp->GetTexture(); 40 | } 41 | default: 42 | JASSERT(0); 43 | break; 44 | } 45 | 46 | return nullptr; 47 | } 48 | 49 | jRenderTargetPool::jRenderTargetPool() 50 | { 51 | } 52 | 53 | 54 | jRenderTargetPool::~jRenderTargetPool() 55 | { 56 | } 57 | 58 | std::shared_ptr jRenderTargetPool::GetRenderTarget(const jRenderTargetInfo& info) 59 | { 60 | auto hash = info.GetHash(); 61 | 62 | auto it_find = RenderTargetResourceMap.find(hash); 63 | if (RenderTargetResourceMap.end() != it_find) 64 | { 65 | auto& renderTargets = it_find->second; 66 | for (auto& iter : renderTargets) 67 | { 68 | if (!iter.IsUsing) 69 | { 70 | iter.IsUsing = true; 71 | return iter.RenderTargetPtr; 72 | } 73 | } 74 | } 75 | 76 | auto renderTargetPtr = std::shared_ptr(g_rhi->CreateRenderTarget(info)); 77 | if (renderTargetPtr) 78 | { 79 | RenderTargetResourceMap[hash].push_back({ true, renderTargetPtr }); 80 | RenderTargetHashVariableMap[renderTargetPtr.get()] = hash; 81 | } 82 | 83 | return renderTargetPtr; 84 | } 85 | 86 | void jRenderTargetPool::ReturnRenderTarget(jRenderTarget* renderTarget) 87 | { 88 | auto it_find = RenderTargetHashVariableMap.find(renderTarget); 89 | if (RenderTargetHashVariableMap.end() == it_find) 90 | return; 91 | 92 | const size_t hash = it_find->second; 93 | for (auto& iter : RenderTargetResourceMap[hash]) 94 | { 95 | if (renderTarget == iter.RenderTargetPtr.get()) 96 | { 97 | iter.IsUsing = false; 98 | break; 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Shadows/jRenderTargetPool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "jRHIType.h" 3 | #include "jRHI.h" 4 | 5 | class jRenderTargetPool 6 | { 7 | public: 8 | jRenderTargetPool(); 9 | ~jRenderTargetPool(); 10 | 11 | static std::shared_ptr GetRenderTarget(const jRenderTargetInfo& info); 12 | static void ReturnRenderTarget(jRenderTarget* renderTarget); 13 | 14 | struct jRenderTargetPoolResource 15 | { 16 | bool IsUsing = false; 17 | std::shared_ptr RenderTargetPtr; 18 | }; 19 | static std::map > RenderTargetResourceMap; 20 | static std::map RenderTargetHashVariableMap; 21 | 22 | static struct jTexture* GetNullTexture(ETextureType type); 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /Shadows/jRenderer.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jRenderer.h" 3 | #include "jObject.h" 4 | #include "jShadowAppProperties.h" 5 | #include "jShader.h" 6 | #include "jPipeline.h" 7 | 8 | void jRenderer::Render(const jCamera* camera) 9 | { 10 | ShadowPrePass(camera); 11 | DebugShadowPrePass(camera); 12 | 13 | RenderPass(camera); 14 | PostRenderPass(camera); 15 | DebugRenderPass(camera); 16 | BoundVolumeRenderPass(camera); 17 | 18 | PostProcessPass(camera); 19 | 20 | UIPass(camera); 21 | DebugUIPass(camera); 22 | } 23 | 24 | void jRenderer::SetChangePipelineSet(jPipelineSet* newPipelineSet) 25 | { 26 | if (!newPipelineSet) 27 | return; 28 | 29 | PipelineSet = newPipelineSet; 30 | } -------------------------------------------------------------------------------- /Shadows/jRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "jRHI.h" 3 | #include "jPostProcess.h" 4 | 5 | class jCamera; 6 | class jPipelineSet; 7 | 8 | class jRenderer 9 | { 10 | public: 11 | jRenderer() {} 12 | jRenderer(jPipelineSet* pipelineSet) 13 | : PipelineSet(pipelineSet) 14 | {} 15 | virtual ~jRenderer() {} 16 | 17 | typedef void (*RenderPassFunc)(jCamera*); 18 | 19 | virtual void Setup() {} 20 | virtual void Teardown() {} 21 | virtual void Reset() {} 22 | 23 | virtual void ShadowPrePass(const jCamera* camera) {} 24 | virtual void DebugShadowPrePass(const jCamera* camera) {} 25 | 26 | virtual void RenderPass(const jCamera* camera) {} 27 | virtual void PostRenderPass(const jCamera* camera) {} 28 | virtual void DebugRenderPass(const jCamera* camera) {} 29 | virtual void BoundVolumeRenderPass(const jCamera* camera) {} 30 | 31 | virtual void PostProcessPass(const jCamera* camera) {} 32 | virtual void DebugPostProcessPass(const jCamera* camera) {} 33 | 34 | virtual void UIPass(const jCamera* camera) {} 35 | virtual void DebugUIPass(const jCamera* camera) {} 36 | 37 | virtual void Render(const jCamera* camera); 38 | virtual void UpdateSettings() {} 39 | 40 | virtual void SetChangePipelineSet(jPipelineSet* newPipelineSet); 41 | 42 | jPipelineSet* PipelineSet = nullptr; 43 | jPostprocessChain PostProcessChain; 44 | }; 45 | 46 | -------------------------------------------------------------------------------- /Shadows/jRendererTemplate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | -------------------------------------------------------------------------------- /Shadows/jSamplerStatePool.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jSamplerStatePool.h" 3 | 4 | std::map > jSamplerStatePool::SamplerStateMap; 5 | std::map jSamplerStatePool::SamplerStateNameVariableMap; 6 | 7 | std::shared_ptr jSamplerStatePool::CreateSamplerState(const jName& name, const jSamplerStateInfo& info) 8 | { 9 | auto it_find = SamplerStateMap.find(name); 10 | if (SamplerStateMap.end() != it_find) 11 | return it_find->second; 12 | 13 | auto samplerState = std::shared_ptr(g_rhi->CreateSamplerState(info)); 14 | JASSERT(samplerState.get()); 15 | SamplerStateMap.insert(std::make_pair(name, samplerState)); 16 | SamplerStateNameVariableMap.insert(std::make_pair(samplerState.get(), name)); 17 | return samplerState; 18 | } 19 | 20 | std::shared_ptr jSamplerStatePool::GetSamplerState(const jName& name) 21 | { 22 | auto it_find = SamplerStateMap.find(name); 23 | return (SamplerStateMap.end() != it_find) ? it_find->second : nullptr; 24 | } 25 | 26 | void jSamplerStatePool::CreateDefaultSamplerState() 27 | { 28 | { 29 | jSamplerStateInfo info; 30 | info.Minification = ETextureFilter::LINEAR; 31 | info.Magnification = ETextureFilter::LINEAR; 32 | info.AddressU = ETextureAddressMode::REPEAT; 33 | info.AddressV = ETextureAddressMode::REPEAT; 34 | info.AddressW = ETextureAddressMode::REPEAT; 35 | CreateSamplerState(jName("LinearWrap"), info); 36 | 37 | info.Minification = ETextureFilter::LINEAR_MIPMAP_LINEAR; 38 | CreateSamplerState(jName("LinearWrapMipmap"), info); 39 | } 40 | { 41 | jSamplerStateInfo info; 42 | info.Minification = ETextureFilter::LINEAR; 43 | info.Magnification = ETextureFilter::LINEAR; 44 | info.AddressU = ETextureAddressMode::CLAMP_TO_EDGE; 45 | info.AddressV = ETextureAddressMode::CLAMP_TO_EDGE; 46 | info.AddressW = ETextureAddressMode::CLAMP_TO_EDGE; 47 | CreateSamplerState(jName("LinearClamp"), info); 48 | 49 | info.Minification = ETextureFilter::LINEAR_MIPMAP_LINEAR; 50 | CreateSamplerState(jName("LinearClampMipmap"), info); 51 | } 52 | { 53 | jSamplerStateInfo info; 54 | info.Minification = ETextureFilter::LINEAR; 55 | info.Magnification = ETextureFilter::LINEAR; 56 | info.AddressU = ETextureAddressMode::CLAMP_TO_EDGE; 57 | info.AddressV = ETextureAddressMode::CLAMP_TO_EDGE; 58 | info.AddressW = ETextureAddressMode::CLAMP_TO_EDGE; 59 | info.TextureComparisonMode = ETextureComparisonMode::COMPARE_REF_TO_TEXTURE; 60 | info.ComparisonFunc = EComparisonFunc::LESS; 61 | CreateSamplerState(jName("LinearClampShadow"), info); 62 | } 63 | { 64 | jSamplerStateInfo info; 65 | info.Minification = ETextureFilter::LINEAR; 66 | info.Magnification = ETextureFilter::LINEAR; 67 | info.AddressU = ETextureAddressMode::CLAMP_TO_BORDER; 68 | info.AddressV = ETextureAddressMode::CLAMP_TO_BORDER; 69 | info.AddressW = ETextureAddressMode::CLAMP_TO_BORDER; 70 | CreateSamplerState(jName("LinearBorder"), info); 71 | 72 | info.Minification = ETextureFilter::LINEAR_MIPMAP_LINEAR; 73 | CreateSamplerState(jName("LinearBorderMipmap"), info); 74 | } 75 | { 76 | jSamplerStateInfo info; 77 | info.Minification = ETextureFilter::NEAREST; 78 | info.Magnification = ETextureFilter::NEAREST; 79 | info.AddressU = ETextureAddressMode::CLAMP_TO_EDGE; 80 | info.AddressV = ETextureAddressMode::CLAMP_TO_EDGE; 81 | info.AddressW = ETextureAddressMode::CLAMP_TO_EDGE; 82 | CreateSamplerState(jName("Point"), info); 83 | 84 | info.Minification = ETextureFilter::NEAREST_MIPMAP_NEAREST; 85 | CreateSamplerState(jName("PointMipmap"), info); 86 | } 87 | { 88 | jSamplerStateInfo info; 89 | info.Minification = ETextureFilter::NEAREST; 90 | info.Magnification = ETextureFilter::NEAREST; 91 | info.AddressU = ETextureAddressMode::REPEAT; 92 | info.AddressV = ETextureAddressMode::REPEAT; 93 | info.AddressW = ETextureAddressMode::REPEAT; 94 | CreateSamplerState(jName("PointWrap"), info); 95 | 96 | info.Minification = ETextureFilter::NEAREST_MIPMAP_NEAREST; 97 | CreateSamplerState(jName("PointWrapMipmap"), info); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Shadows/jSamplerStatePool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct jSamplerState; 4 | 5 | class jSamplerStatePool 6 | { 7 | public: 8 | static std::shared_ptr CreateSamplerState(const jName& name, const jSamplerStateInfo& info); 9 | static std::shared_ptr GetSamplerState(const jName& name); 10 | 11 | static void CreateDefaultSamplerState(); 12 | 13 | private: 14 | static std::map > SamplerStateMap; 15 | static std::map SamplerStateNameVariableMap; 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /Shadows/jShader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct jShaderInfo 4 | { 5 | static std::map s_ShaderInfoMap; 6 | static void AddShaderInfo(const jShaderInfo& shaderInfo); 7 | static void CreateShaders(); 8 | 9 | size_t CreateShaderHash() const 10 | { 11 | return std::hash{}(vs+vsPreProcessor+gs+gsPreProcessor+fs+fsPreProcessor+cs+csPreProcessor); 12 | } 13 | std::string name; 14 | std::string vs; 15 | std::string gs; 16 | std::string fs; 17 | std::string cs; 18 | std::string vsPreProcessor; 19 | std::string gsPreProcessor; 20 | std::string fsPreProcessor; 21 | std::string csPreProcessor; 22 | }; 23 | 24 | #define DECLARE_SHADER_VS_FS_WITH_OPTION_MORE(Name, VS, FS, IsUseTexture, IsUseMaterial, MoreOption) \ 25 | { \ 26 | jShaderInfo info; \ 27 | info.name = Name; \ 28 | info.vs = VS; \ 29 | info.fs = FS; \ 30 | info.vsPreProcessor += IsUseTexture ? "#define USE_TEXTURE 1" : "";\ 31 | info.vsPreProcessor += IsUseMaterial ? "\r\n#define USE_MATERIAL 1" : "";\ 32 | info.vsPreProcessor += "\r\n"MoreOption;\ 33 | info.fsPreProcessor += IsUseTexture ? "#define USE_TEXTURE 1" : "";\ 34 | info.fsPreProcessor += IsUseMaterial ? "\r\n#define USE_MATERIAL 1" : "";\ 35 | info.fsPreProcessor += "\r\n"MoreOption;\ 36 | jShaderInfo::AddShaderInfo(info); \ 37 | } 38 | 39 | #define DECLARE_SHADER_VS_FS_WITH_OPTION(Name, VS, FS, IsUseTexture, IsUseMaterial) \ 40 | { \ 41 | jShaderInfo info; \ 42 | info.name = Name; \ 43 | info.vs = VS; \ 44 | info.fs = FS; \ 45 | info.vsPreProcessor += IsUseTexture ? "#define USE_TEXTURE 1" : "";\ 46 | info.vsPreProcessor += IsUseMaterial ? "\r\n#define USE_MATERIAL 1" : "";\ 47 | info.fsPreProcessor += IsUseTexture ? "#define USE_TEXTURE 1" : "";\ 48 | info.fsPreProcessor += IsUseMaterial ? "\r\n#define USE_MATERIAL 1" : "";\ 49 | jShaderInfo::AddShaderInfo(info); \ 50 | } 51 | 52 | #define DECLARE_SHADER_VS_FS_WITH_DEFINE(Name, VS, FS, AdditionalDifine) \ 53 | { \ 54 | jShaderInfo info; \ 55 | info.name = Name; \ 56 | info.vs = VS; \ 57 | info.fs = FS; \ 58 | info.vsPreProcessor += "\r\n"AdditionalDifine;\ 59 | info.fsPreProcessor += "\r\n"AdditionalDifine;\ 60 | jShaderInfo::AddShaderInfo(info); \ 61 | } 62 | 63 | #define DECLARE_SHADER_VS_FS(Name, VS, FS) DECLARE_SHADER_VS_FS_WITH_OPTION(Name, VS, FS, false, false) 64 | 65 | #define DECLARE_SHADER_VS_GS_FS_WITH_OPTION(Name, VS, GS, FS, IsUseTexture, IsUseMaterial) \ 66 | { \ 67 | jShaderInfo info; \ 68 | info.name = Name; \ 69 | info.vs = VS; \ 70 | info.gs = GS; \ 71 | info.fs = FS; \ 72 | info.vsPreProcessor += IsUseTexture ? "#define USE_TEXTURE 1" : "";\ 73 | info.vsPreProcessor += IsUseMaterial ? "\r\n#define USE_MATERIAL 1" : "";\ 74 | info.gsPreProcessor += IsUseTexture ? "#define USE_TEXTURE 1" : ""; \ 75 | info.gsPreProcessor += IsUseMaterial ? "\r\n#define USE_MATERIAL 1" : ""; \ 76 | info.fsPreProcessor += IsUseTexture ? "#define USE_TEXTURE 1" : "";\ 77 | info.fsPreProcessor += IsUseMaterial ? "\r\n#define USE_MATERIAL 1" : "";\ 78 | jShaderInfo::AddShaderInfo(info); \ 79 | } 80 | 81 | #define DECLARE_SHADER_VS_GS_FS(Name, VS, GS, FS) DECLARE_SHADER_VS_GS_FS_WITH_OPTION(Name, VS, GS, FS, false, false) 82 | 83 | #define DECLARE_SHADER_CS_WITH_OPTION(Name, CS, IsUseTexture, IsUseMaterial) \ 84 | { \ 85 | jShaderInfo info; \ 86 | info.name = Name; \ 87 | info.cs = CS; \ 88 | info.csPreProcessor += IsUseTexture ? "#define USE_TEXTURE 1" : "";\ 89 | info.csPreProcessor += IsUseMaterial ? "\r\n#define USE_MATERIAL 1" : "";\ 90 | jShaderInfo::AddShaderInfo(info); \ 91 | } 92 | #define DECLARE_SHADER_CS(Name, CS) DECLARE_SHADER_CS_WITH_OPTION(Name, CS, false, false); 93 | 94 | 95 | struct jShader : public std::enable_shared_from_this 96 | { 97 | static std::unordered_map > ShaderMap; 98 | static std::vector > ShaderVector; 99 | static std::unordered_map > ShaderNameMap; 100 | static jShader* GetShader(size_t hashCode); 101 | static jShader* GetShader(const std::string& name); 102 | static jShader* CreateShader(const jShaderInfo& shaderInfo); 103 | static std::shared_ptr GetShaderPtr(size_t hashCode); 104 | static std::shared_ptr GetShaderPtr(const std::string& name); 105 | static std::shared_ptr CreateShaderPtr(const jShaderInfo& shaderInfo); 106 | static void UpdateShaders(); 107 | 108 | uint64 TimeStamp = 0; 109 | jShaderInfo ShaderInfo; 110 | 111 | void UpdateShader(); 112 | }; -------------------------------------------------------------------------------- /Shadows/jShadowAppProperties.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "jAppSettings.h" 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | class jShadowAppSettingProperties : public jAppSettingProperties 6 | { 7 | public: 8 | static jShadowAppSettingProperties& GetInstance() 9 | { 10 | if (!_instance) 11 | _instance = new jShadowAppSettingProperties(); 12 | return *_instance; 13 | } 14 | 15 | bool ShadowOn = true; 16 | EShadowType ShadowType = EShadowType::ShadowMap; 17 | bool ShowSilhouette_DirectionalLight = false; 18 | bool ShowSilhouette_PointLight = false; 19 | bool ShowSilhouette_SpotLight = false; 20 | bool IsGPUShadowVolume = true; 21 | EShadowMapType ShadowMapType = EShadowMapType::SSM; 22 | bool UsePoissonSample = true; 23 | bool ShowDirectionalLightMap = false; 24 | bool UseTonemap = true; 25 | float AutoExposureKeyValue = 0.5f; 26 | bool DirectionalLightOn = true; 27 | bool PointLightOn = true; 28 | bool SpotLightOn = true; 29 | bool ShowDirectionalLightInfo = true; 30 | bool ShowPointLightInfo = false; 31 | bool ShowSpotLightInfo = false; 32 | bool ShowBoundBox = false; 33 | bool ShowBoundSphere = false; 34 | Vector DirecionalLightDirection = Vector(-0.56f, -0.83f, 0.01f).GetNormalize(); 35 | Vector PointLightPosition = Vector(10.0f, 100.0f, 10.0f); 36 | Vector SpotLightPosition = Vector(0.0f, 60.0f, 5.0f); 37 | Vector SpotLightDirection = Vector(-1.0f, -1.0f, -0.4f).GetNormalize(); 38 | float DeepShadowAlpha = 0.3f; 39 | bool ExponentDeepShadowOn = false; 40 | bool CSMDebugOn = false; 41 | float AdaptationRate = 1.0f; 42 | float BloomThreshold = 3.0f; 43 | float BloomBlurSigma = 0.8f; 44 | float BloomMagnitude = 0.75f; 45 | 46 | virtual void Setup(jAppSettingBase* appSetting) override; 47 | virtual void Teardown(jAppSettingBase* appSetting) override; 48 | 49 | void SwitchShadowType(jAppSettingBase* appSetting); 50 | void SwitchShadowMapType(jAppSettingBase* appSetting); 51 | 52 | private: 53 | jShadowAppSettingProperties() {} 54 | 55 | static jShadowAppSettingProperties* _instance; 56 | }; 57 | 58 | -------------------------------------------------------------------------------- /Shadows/jShadowTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum class EShadowType 4 | { 5 | ShadowVolume = 0, 6 | ShadowMap, 7 | MAX, 8 | }; 9 | 10 | static const char* EShadowTypeString[] = { 11 | "ShadowVolume", 12 | "ShadowMap", 13 | }; 14 | 15 | enum class EShadowVolumeSilhouette 16 | { 17 | DirectionalLight = 0, 18 | PointLight, 19 | SpotLight, 20 | MAX, 21 | }; 22 | 23 | static const char* EShadowVolumeSilhouetteString[] = { 24 | "DirectionalLight", 25 | "PointLight", 26 | "SpotLight", 27 | }; 28 | 29 | 30 | enum class EShadowMapType 31 | { 32 | SSM = 0, 33 | PCF, 34 | PCSS, 35 | VSM, 36 | ESM, 37 | EVSM, 38 | DeepShadowMap_DirectionalLight, 39 | CSM_SSM, 40 | MAX 41 | }; 42 | 43 | static const char* EShadowMapTypeString[] = { 44 | "SSM", 45 | "PCF", 46 | "PCSS", 47 | "VSM", 48 | "ESM", 49 | "EVSM", 50 | "DeepShadowMap_DirectionalLight", 51 | "CSM_SSM", 52 | }; -------------------------------------------------------------------------------- /Shadows/jShadowVolume.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Math/Vector.h" 3 | #include "jPipeline.h" 4 | 5 | class jVertexAdjacency; 6 | class jObject; 7 | struct jVertexStreamData; 8 | 9 | ////////////////////////////////////////////////////////////////////////// 10 | // IShadowVolume 11 | class IShadowVolume 12 | { 13 | public: 14 | IShadowVolume() = default; 15 | IShadowVolume(jVertexAdjacency* vertexAdjacency) : VertexAdjacency(vertexAdjacency) {} 16 | 17 | virtual void Update(const Vector& lightPosOrDirection, bool isOmniDirectional, jObject* ownerObject) {} 18 | virtual void UpdateShadowVolumeObject() {} 19 | 20 | virtual void CreateShadowVolumeObject() = 0; 21 | virtual void Draw(const jPipelineContext& pipelineContext, const jShader* shader) const = 0; 22 | 23 | protected: 24 | jVertexAdjacency* VertexAdjacency = nullptr; 25 | }; 26 | 27 | ////////////////////////////////////////////////////////////////////////// 28 | // jShadowVolumeCPU 29 | class jShadowVolumeCPU : public IShadowVolume 30 | { 31 | public: 32 | jShadowVolumeCPU() = default; 33 | using IShadowVolume::IShadowVolume; 34 | 35 | virtual void Update(const Vector& lightPosOrDirection, bool isOmniDirectional, jObject* ownerObject) override; 36 | virtual void Draw(const jPipelineContext& pipelineContext, const jShader* shader) const override; 37 | 38 | jObject* EdgeObject = nullptr; 39 | jObject* QuadObject = nullptr; 40 | 41 | private: 42 | void UpdateEdge(size_t edgeKey); // to do the edge detection 43 | virtual void CreateShadowVolumeObject() override; 44 | virtual void UpdateShadowVolumeObject() override; 45 | 46 | private: 47 | bool IsInitialized = false; 48 | bool CreateEdgeObject = false; 49 | bool CreateQuadObject = true; 50 | std::set Edges; 51 | std::vector EdgeVertices; 52 | std::vector QuadVertices; 53 | 54 | std::shared_ptr EdgeVertexStreamData; 55 | std::shared_ptr QuadVertexStreamData; 56 | }; 57 | 58 | ////////////////////////////////////////////////////////////////////////// 59 | // jShadowVolumeGPU 60 | class jShadowVolumeGPU : public IShadowVolume 61 | { 62 | public: 63 | jShadowVolumeGPU() = default; 64 | using IShadowVolume::IShadowVolume; 65 | 66 | virtual void CreateShadowVolumeObject() override; 67 | virtual void Update(const Vector& lightPosOrDirection, bool isOmniDirectional, jObject* ownerObject) override; 68 | virtual void Draw(const jPipelineContext& pipelineContext, const jShader* shader) const override; 69 | 70 | jObject* ShadowVolumeObject = nullptr; 71 | }; -------------------------------------------------------------------------------- /Shadows/jShadowVolumeTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /Shadows/jUtil.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jUtil.h" 3 | 4 | 5 | jUtil::jUtil() 6 | { 7 | } 8 | 9 | 10 | jUtil::~jUtil() 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /Shadows/jUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class jUtil 3 | { 4 | public: 5 | jUtil(); 6 | ~jUtil(); 7 | }; 8 | 9 | -------------------------------------------------------------------------------- /Shadows/jVertexAdjacency.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Math/Vector.h" 3 | #include "Math/Matrix.h" 4 | 5 | class jObject; 6 | 7 | struct jTriangle 8 | { 9 | int32 TriangleIndex = 0; 10 | int32 VertexIndex0 = 0; 11 | int32 VertexIndex1 = 0; 12 | int32 VertexIndex2 = 0; 13 | Vector Normal; 14 | Vector CenterPos; 15 | size_t EdgeKey0 = 0; 16 | size_t EdgeKey1 = 0; 17 | size_t EdgeKey2 = 0; 18 | 19 | Vector TransformedNormal; 20 | Vector TransformedCenterPos; 21 | }; 22 | 23 | struct jEdge 24 | { 25 | int32 VertexIndex0 = 0; 26 | int32 VertexIndex1 = 0; 27 | int32 TriangleIndex = 0; 28 | int32 TriangleIndex2 = 0; 29 | int32 IndexInTriangle = 0; 30 | 31 | FORCEINLINE bool ContainVertexIndex(int32 vertexIndex) const 32 | { 33 | return (VertexIndex0 == vertexIndex) || (VertexIndex1 == vertexIndex); 34 | } 35 | }; 36 | 37 | class jVertexAdjacency 38 | { 39 | public: 40 | static jVertexAdjacency* GenerateVertexAdjacencyInfo(const std::vector& vertices, const std::vector& faces); 41 | void Update(jObject* ownerObject); 42 | 43 | FORCEINLINE const std::vector& GetTriangleAdjacencyIndices() const { return TriangleAdjacencyIndces; } 44 | void CreateTriangleAdjacencyIndices(std::vector& OutResult) const; 45 | 46 | FORCEINLINE const std::vector& GetTriangleAdjacencyVertices() const { return Vertices; } 47 | 48 | std::vector TriangleAdjacencyIndces; 49 | 50 | private: 51 | friend class jShadowVolumeCPU; 52 | 53 | size_t MakeEdgeKey(int32 vertexIndex0, int32 vertexIndex1); 54 | jEdge* FindEdge(int32 vertexIndex0, int32 vertexIndex1); 55 | jEdge* AddEdge(int32 vertexIndex0, int32 vertexIndex1, int32 triangleIndex, int32 indexInTriangle); 56 | void CreateAdjacencyEdgeInfo(const std::vector& vertices, int32 triangleIndex, int32 vertexIndex0, int32 vertexIndex1, int32 vertexIndex2); 57 | int32 AddVertex(const std::vector& vertices, int32 vertexIndex); 58 | void UpdatedTransformedAdjacencyInfo(const Matrix& world, bool generateTransformedInfo = false); 59 | 60 | bool isInitialized = false; 61 | std::map Triangles; 62 | std::map Edges; 63 | std::vector Vertices; 64 | std::vector ResultVertices; 65 | }; 66 | -------------------------------------------------------------------------------- /Shadows/model/straight.hair: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scahp/Shadows/87853997029283edfbbb60eaad03cf163c95f26c/Shadows/model/straight.hair -------------------------------------------------------------------------------- /Shadows/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "jRHI.h" 3 | 4 | std::map g_KeyState; 5 | std::map g_MouseState; 6 | float g_timeDeltaSecond = 0.0f; 7 | -------------------------------------------------------------------------------- /Shadows/pch.h: -------------------------------------------------------------------------------- 1 | #ifndef PCH_H 2 | #define PCH_H 3 | 4 | #define NOMINMAX 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "External/cityhash/city.h" 31 | 32 | #define JASSERT(x) assert(x) 33 | #define JMESSAGE(x) MessageBoxA(0, x, "", MB_OK) 34 | 35 | #define ensure(x) (JASSERT(x), (x)) 36 | #define check(x) JASSERT(x) 37 | 38 | using int8 = char; 39 | using uint8 = unsigned char; 40 | using int16 = short; 41 | using uint16 = unsigned short; 42 | using int32 = int; 43 | using uint32 = unsigned int; 44 | using int64 = __int64; 45 | using uint64 = unsigned __int64; 46 | 47 | using tchar = wchar_t; 48 | 49 | // settings 50 | const unsigned int SCR_WIDTH = 1280; 51 | const unsigned int SCR_HEIGHT = 720; 52 | 53 | const unsigned int SM_WIDTH = 1024; 54 | const unsigned int SM_HEIGHT = 1024; 55 | 56 | const unsigned int SM_ARRAY_WIDTH = 512; 57 | const unsigned int SM_ARRAY_HEIGHT = 512; 58 | 59 | const unsigned int SM_LINKED_LIST_WIDTH = SM_WIDTH; 60 | const unsigned int SM_LINKED_LIST_HEIGHT = SM_HEIGHT; 61 | 62 | const unsigned int LUMINANCE_WIDTH = 512; 63 | const unsigned int LUMINANCE_HEIGHT = 512; 64 | 65 | constexpr int NUM_CASCADES = 3; 66 | constexpr int NUM_FRUSTUM_CORNERS = 8; 67 | 68 | #define FORCEINLINE __forceinline 69 | 70 | enum class EMouseButtonType 71 | { 72 | LEFT = 0, 73 | MIDDLE, 74 | RIGHT, 75 | MAX 76 | }; 77 | 78 | extern std::map g_KeyState; 79 | extern std::map g_MouseState; 80 | extern float g_timeDeltaSecond; 81 | 82 | ////////////////////////////////////////////////////////////////////////// 83 | // https://stackoverflow.com/questions/2590677/how-do-i-combine-hash-values-in-c0x 84 | template 85 | inline void hash_combine(std::size_t& seed, const T& v) 86 | { 87 | std::hash hasher; 88 | seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); 89 | } 90 | 91 | #include "jRHIType.h" 92 | #include "jPerformanceProfile.h" 93 | 94 | #define TRUE_PER_MS(WaitMS)\ 95 | [waitMS = WaitMS]() -> bool\ 96 | {\ 97 | static int64 lastTick = GetTickCount64();\ 98 | int64 currentTick = GetTickCount64();\ 99 | if (currentTick - lastTick >= waitMS)\ 100 | {\ 101 | lastTick = currentTick;\ 102 | return true;\ 103 | }\ 104 | return false;\ 105 | }() 106 | 107 | // imgui 108 | #include "IMGUI/imgui.h" 109 | #include "IMGUI/imgui_impl_glfw.h" 110 | #include "IMGUI/imgui_impl_opengl3.h" 111 | 112 | 113 | #include "jShadowAppProperties.h" 114 | 115 | #define DEBUG_OUTPUT_ON 0 116 | //#define DEBUG_OUTPUT_LEVEL 0 // show all 117 | //#define DEBUG_OUTPUT_LEVEL 1 // show mid priority 118 | #define DEBUG_OUTPUT_LEVEL 2 // show high priority 119 | 120 | #include "Core/jName.h" 121 | 122 | #endif //PCH_H 123 | --------------------------------------------------------------------------------