├── .gitignore ├── Content ├── .gitignore ├── Models │ └── Box │ │ ├── Blue.png │ │ ├── Blue_NRM.png │ │ ├── Box_Grill.fbx │ │ ├── Green.png │ │ ├── Green_NRM.png │ │ ├── Red.png │ │ ├── Red_NRM.png │ │ ├── White.png │ │ └── White_NRM.png └── Textures │ ├── Default.dds │ ├── DefaultNormalMap.dds │ └── Smoke.dds ├── Externals ├── .gitignore ├── AntTweakBar │ ├── bin │ │ └── AntTweakBar64.dll │ ├── include │ │ └── AntTweakBar.h │ └── lib │ │ └── AntTweakBar64.lib ├── Assimp-3.1.1 │ ├── bin │ │ └── assimp.dll │ ├── include │ │ ├── Compiler │ │ │ ├── poppack1.h │ │ │ ├── pstdint.h │ │ │ └── pushpack1.h │ │ ├── DefaultLogger.hpp │ │ ├── Exporter.hpp │ │ ├── IOStream.hpp │ │ ├── IOSystem.hpp │ │ ├── Importer.hpp │ │ ├── LogStream.hpp │ │ ├── Logger.hpp │ │ ├── NullLogger.hpp │ │ ├── ProgressHandler.hpp │ │ ├── ai_assert.h │ │ ├── anim.h │ │ ├── camera.h │ │ ├── cexport.h │ │ ├── cfileio.h │ │ ├── cimport.h │ │ ├── color4.h │ │ ├── color4.inl │ │ ├── config.h │ │ ├── defs.h │ │ ├── importerdesc.h │ │ ├── light.h │ │ ├── material.h │ │ ├── material.inl │ │ ├── matrix3x3.h │ │ ├── matrix3x3.inl │ │ ├── matrix4x4.h │ │ ├── matrix4x4.inl │ │ ├── mesh.h │ │ ├── metadata.h │ │ ├── postprocess.h │ │ ├── quaternion.h │ │ ├── quaternion.inl │ │ ├── scene.h │ │ ├── texture.h │ │ ├── types.h │ │ ├── vector2.h │ │ ├── vector2.inl │ │ ├── vector3.h │ │ ├── vector3.inl │ │ └── version.h │ └── lib │ │ └── assimp.lib ├── DirectXTex │ ├── Include │ │ ├── BC.h │ │ ├── BCDirectCompute.h │ │ ├── DDS.h │ │ ├── DirectXTex.h │ │ ├── DirectXTex.inl │ │ ├── DirectXTexP.h │ │ ├── Filters.h │ │ └── scoped.h │ ├── Lib 2012 │ │ ├── Debug │ │ │ ├── DirectXTex.lib │ │ │ └── directxtex.pdb │ │ └── Release │ │ │ ├── DirectXTex.lib │ │ │ └── directxtex.pdb │ └── Lib │ │ ├── Debug │ │ ├── DirectXTex.lib │ │ └── directxtex.pdb │ │ └── Release │ │ ├── DirectXTex.lib │ │ └── directxtex.pdb ├── HosekSky │ ├── Include │ │ ├── ArHosekSkyModel.c │ │ ├── ArHosekSkyModel.h │ │ ├── ArHosekSkyModelData_CIEXYZ.h │ │ ├── ArHosekSkyModelData_RGB.h │ │ ├── ArHosekSkyModelData_Spectral.h │ │ └── README.txt │ └── Lib 2013 │ │ ├── HosekSky.lib │ │ ├── HosekSky_Dbg.lib │ │ ├── hoseksky.pdb │ │ └── hoseksky_dbg.pdb └── d3dcompiler_47.dll ├── LICENSE ├── LowResRendering ├── AppPCH.h ├── AppSettings.cpp ├── AppSettings.cs ├── AppSettings.h ├── AppSettings.hlsl ├── BRDF.hlsl ├── DepthDownscale.hlsl ├── DepthOnly.hlsl ├── DepthReduction.hlsl ├── EVSM.hlsl ├── EVSMConvert.hlsl ├── Icon.ico ├── LowResComposite.hlsl ├── LowResRendering.cpp ├── LowResRendering.h ├── LowResRendering.rc ├── LowResRendering.sln ├── LowResRendering.vcxproj ├── LowResRendering.vcxproj.filters ├── Mesh.hlsl ├── MeshRenderer.cpp ├── MeshRenderer.h ├── Particles.hlsl ├── PostProcessing.hlsl ├── PostProcessor.cpp ├── PostProcessor.h ├── Resolve.hlsl ├── Shadows.hlsl ├── SharedConstants.h ├── project.sublime-project └── resource.h ├── README.md └── SampleFramework11 └── v1.01 ├── App.cpp ├── App.h ├── Assert.cpp ├── Assert.h ├── Exceptions.h ├── FileIO.cpp ├── FileIO.h ├── Graphics ├── BRDF.h ├── Camera.cpp ├── Camera.h ├── DDSTextureLoader.cpp ├── DDSTextureLoader.h ├── DXErr.cpp ├── DXErr.h ├── DeviceManager.cpp ├── DeviceManager.h ├── DeviceStates.cpp ├── DeviceStates.h ├── Filtering.h ├── GraphicsTypes.cpp ├── GraphicsTypes.h ├── Model.cpp ├── Model.h ├── PostProcessorBase.cpp ├── PostProcessorBase.h ├── Profiler.cpp ├── Profiler.h ├── SDKMesh.cpp ├── SDKMesh.h ├── SH.cpp ├── SH.h ├── Sampling.cpp ├── Sampling.h ├── ShaderCompilation.cpp ├── ShaderCompilation.h ├── Skybox.cpp ├── Skybox.h ├── Spectrum.cpp ├── Spectrum.h ├── SpriteFont.cpp ├── SpriteFont.h ├── SpriteRenderer.cpp ├── SpriteRenderer.h ├── Textures.cpp ├── Textures.h ├── WICTextureLoader.cpp └── WICTextureLoader.h ├── Input.cpp ├── Input.h ├── InterfacePointers.h ├── MurmurHash.cpp ├── MurmurHash.h ├── PCH.cpp ├── PCH.h ├── SF11_Math.cpp ├── SF11_Math.h ├── SampleFramework11.props ├── Serialization.h ├── Settings.cpp ├── Settings.h ├── SettingsCompiler ├── App.config ├── Properties │ └── AssemblyInfo.cs ├── SettingTypes.cs ├── SettingsCompiler.cs └── SettingsCompiler.csproj ├── SettingsCompilerAttributes ├── Attributes.cs ├── Properties │ └── AssemblyInfo.cs └── SettingsCompilerAttributes.csproj ├── Shaders ├── Constants.hlsl ├── Conversion.hlsl ├── D3DX_DXGIFormatConvert.inl ├── DecodeTextureCS.hlsl ├── PPIncludes.hlsl ├── Quad.hlsl ├── SH.hlsl ├── Skybox.hlsl └── Sprite.hlsl ├── Timer.cpp ├── Timer.h ├── TinyEXR.cpp ├── TinyEXR.h ├── TwHelper.cpp ├── TwHelper.h ├── Utility.cpp ├── Utility.h ├── Window.cpp └── Window.h /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Visual Studio 3 | ################# 4 | 5 | ## Ignore Visual Studio temporary files, build results, and 6 | ## files generated by popular Visual Studio add-ons. 7 | 8 | # User-specific files 9 | *.suo 10 | *.user 11 | *.sln.docstates 12 | 13 | # Build results 14 | 15 | [Dd]ebug/ 16 | [Rr]elease/ 17 | x64/ 18 | build/ 19 | [Bb]in/ 20 | [Oo]bj/ 21 | 22 | # MSTest test Results 23 | [Tt]est[Rr]esult*/ 24 | [Bb]uild[Ll]og.* 25 | 26 | *_i.c 27 | *_p.c 28 | *.ilk 29 | *.meta 30 | *.obj 31 | *.pch 32 | *.pdb 33 | *.pgc 34 | *.pgd 35 | *.rsp 36 | *.sbr 37 | *.tlb 38 | *.tli 39 | *.tlh 40 | *.tmp 41 | *.tmp_proj 42 | *.log 43 | *.vspscc 44 | *.vssscc 45 | .builds 46 | *.pidb 47 | *.log 48 | *.scc 49 | 50 | # Visual C++ cache files 51 | ipch/ 52 | *.aps 53 | *.ncb 54 | *.opensdf 55 | *.sdf 56 | *.cachefile 57 | 58 | # Visual Studio profiler 59 | *.psess 60 | *.vsp 61 | *.vspx 62 | 63 | # Guidance Automation Toolkit 64 | *.gpState 65 | 66 | # ReSharper is a .NET coding add-in 67 | _ReSharper*/ 68 | *.[Rr]e[Ss]harper 69 | 70 | # TeamCity is a build add-in 71 | _TeamCity* 72 | 73 | # DotCover is a Code Coverage Tool 74 | *.dotCover 75 | 76 | # NCrunch 77 | *.ncrunch* 78 | .*crunch*.local.xml 79 | 80 | # Installshield output folder 81 | [Ee]xpress/ 82 | 83 | # DocProject is a documentation generator add-in 84 | DocProject/buildhelp/ 85 | DocProject/Help/*.HxT 86 | DocProject/Help/*.HxC 87 | DocProject/Help/*.hhc 88 | DocProject/Help/*.hhk 89 | DocProject/Help/*.hhp 90 | DocProject/Help/Html2 91 | DocProject/Help/html 92 | 93 | # Click-Once directory 94 | publish/ 95 | 96 | # Publish Web Output 97 | *.Publish.xml 98 | *.pubxml 99 | 100 | # NuGet Packages Directory 101 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 102 | #packages/ 103 | 104 | # Windows Azure Build Output 105 | csx 106 | *.build.csdef 107 | 108 | # Windows Store app package directory 109 | AppPackages/ 110 | 111 | # Others 112 | sql/ 113 | *.Cache 114 | ClientBin/ 115 | [Ss]tyle[Cc]op.* 116 | ~$* 117 | *~ 118 | *.dbmdl 119 | *.[Pp]ublish.xml 120 | *.pfx 121 | *.publishsettings 122 | 123 | # RIA/Silverlight projects 124 | Generated_Code/ 125 | 126 | # Backup & report files from converting an old project file to a newer 127 | # Visual Studio version. Backup files are not needed, because we have git ;-) 128 | _UpgradeReport_Files/ 129 | Backup*/ 130 | UpgradeLog*.XML 131 | UpgradeLog*.htm 132 | 133 | # SQL Server files 134 | App_Data/*.mdf 135 | App_Data/*.ldf 136 | 137 | ############# 138 | ## Windows detritus 139 | ############# 140 | 141 | # Windows image file caches 142 | Thumbs.db 143 | ehthumbs.db 144 | 145 | # Folder config file 146 | Desktop.ini 147 | 148 | # Recycle Bin used on file shares 149 | $RECYCLE.BIN/ 150 | 151 | # Mac crap 152 | .DS_Store 153 | 154 | #################### 155 | ## Sample framework 156 | #################### 157 | 158 | ShaderCache/ 159 | *.exe 160 | *.dll 161 | *.deps 162 | CorneaRefraction/CorneaRefractionMap.dds 163 | Temp_Lightmap.dds 164 | 165 | # Sublime 166 | *.sublime-workspace -------------------------------------------------------------------------------- /Content/.gitignore: -------------------------------------------------------------------------------- 1 | ## Exclusions for content 2 | 3 | !*.obj 4 | *.swatch 5 | *.swatches -------------------------------------------------------------------------------- /Content/Models/Box/Blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Content/Models/Box/Blue.png -------------------------------------------------------------------------------- /Content/Models/Box/Blue_NRM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Content/Models/Box/Blue_NRM.png -------------------------------------------------------------------------------- /Content/Models/Box/Box_Grill.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Content/Models/Box/Box_Grill.fbx -------------------------------------------------------------------------------- /Content/Models/Box/Green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Content/Models/Box/Green.png -------------------------------------------------------------------------------- /Content/Models/Box/Green_NRM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Content/Models/Box/Green_NRM.png -------------------------------------------------------------------------------- /Content/Models/Box/Red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Content/Models/Box/Red.png -------------------------------------------------------------------------------- /Content/Models/Box/Red_NRM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Content/Models/Box/Red_NRM.png -------------------------------------------------------------------------------- /Content/Models/Box/White.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Content/Models/Box/White.png -------------------------------------------------------------------------------- /Content/Models/Box/White_NRM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Content/Models/Box/White_NRM.png -------------------------------------------------------------------------------- /Content/Textures/Default.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Content/Textures/Default.dds -------------------------------------------------------------------------------- /Content/Textures/DefaultNormalMap.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Content/Textures/DefaultNormalMap.dds -------------------------------------------------------------------------------- /Content/Textures/Smoke.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Content/Textures/Smoke.dds -------------------------------------------------------------------------------- /Externals/.gitignore: -------------------------------------------------------------------------------- 1 | ## Exclusions for externals 2 | 3 | ![Dd]ebug/ 4 | ![Rr]elease/ 5 | !x64/ 6 | !build/ 7 | 8 | ![Bb]in/ 9 | ![Oo]bj/ 10 | !*.exe 11 | !*.dll 12 | !*.pdb 13 | ![Ll]ib/ 14 | ![Ii]nclude/ 15 | 16 | boost157/ 17 | sun/source/x64/ 18 | 19 | *.sdf 20 | *.opensdf 21 | *.suo 22 | *.vcproj.user 23 | -------------------------------------------------------------------------------- /Externals/AntTweakBar/bin/AntTweakBar64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/AntTweakBar/bin/AntTweakBar64.dll -------------------------------------------------------------------------------- /Externals/AntTweakBar/lib/AntTweakBar64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/AntTweakBar/lib/AntTweakBar64.lib -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/bin/assimp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/Assimp-3.1.1/bin/assimp.dll -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/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 | -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/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__ ) 29 | # if defined(__clang__) 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 | 40 | // C4103: Packing was changed after the inclusion of the header, propably missing #pragma pop 41 | # pragma warning (disable : 4103) 42 | #endif 43 | 44 | #define AI_PUSHPACK_IS_DEFINED 45 | 46 | 47 | -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/LogStream.hpp: -------------------------------------------------------------------------------- 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 | /** @file LogStream.h 42 | * @brief Abstract base class 'LogStream', representing an output log stream. 43 | */ 44 | #ifndef INCLUDED_AI_LOGSTREAM_H 45 | #define INCLUDED_AI_LOGSTREAM_H 46 | #include "types.h" 47 | namespace Assimp { 48 | class IOSystem; 49 | 50 | // ------------------------------------------------------------------------------------ 51 | /** @brief CPP-API: Abstract interface for log stream implementations. 52 | * 53 | * Several default implementations are provided, see #aiDefaultLogStream for more 54 | * details. Writing your own implementation of LogStream is just necessary if these 55 | * are not enough for your purpose. */ 56 | class ASSIMP_API LogStream 57 | #ifndef SWIG 58 | : public Intern::AllocateFromAssimpHeap 59 | #endif 60 | { 61 | protected: 62 | /** @brief Default constructor */ 63 | LogStream() { 64 | } 65 | public: 66 | /** @brief Virtual destructor */ 67 | virtual ~LogStream() { 68 | } 69 | 70 | // ------------------------------------------------------------------- 71 | /** @brief Overwrite this for your own output methods 72 | * 73 | * Log messages *may* consist of multiple lines and you shouldn't 74 | * expect a consistent formatting. If you want custom formatting 75 | * (e.g. generate HTML), supply a custom instance of Logger to 76 | * #DefaultLogger:set(). Usually you can *expect* that a log message 77 | * is exactly one line and terminated with a single \n character. 78 | * @param message Message to be written */ 79 | virtual void write(const char* message) = 0; 80 | 81 | // ------------------------------------------------------------------- 82 | /** @brief Creates a default log stream 83 | * @param streams Type of the default stream 84 | * @param name For aiDefaultLogStream_FILE: name of the output file 85 | * @param io For aiDefaultLogStream_FILE: IOSystem to be used to open the output 86 | * file. Pass NULL for the default implementation. 87 | * @return New LogStream instance. */ 88 | static LogStream* createDefaultStream(aiDefaultLogStream stream, 89 | const char* name = "AssimpLog.txt", 90 | IOSystem* io = NULL); 91 | 92 | }; // !class LogStream 93 | // ------------------------------------------------------------------------------------ 94 | } // Namespace Assimp 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/NullLogger.hpp: -------------------------------------------------------------------------------- 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 | /** @file NullLogger.h 42 | * @brief Dummy logger 43 | */ 44 | 45 | #ifndef INCLUDED_AI_NULLLOGGER_H 46 | #define INCLUDED_AI_NULLLOGGER_H 47 | 48 | #include "Logger.hpp" 49 | namespace Assimp { 50 | // --------------------------------------------------------------------------- 51 | /** @brief CPP-API: Empty logging implementation. 52 | * 53 | * Does nothing! Used by default if the application hasn't requested a 54 | * custom logger via #DefaultLogger::set() or #DefaultLogger::create(); */ 55 | class ASSIMP_API NullLogger 56 | : public Logger { 57 | 58 | public: 59 | 60 | /** @brief Logs a debug message */ 61 | void OnDebug(const char* message) { 62 | (void)message; //this avoids compiler warnings 63 | } 64 | 65 | /** @brief Logs an info message */ 66 | void OnInfo(const char* message) { 67 | (void)message; //this avoids compiler warnings 68 | } 69 | 70 | /** @brief Logs a warning message */ 71 | void OnWarn(const char* message) { 72 | (void)message; //this avoids compiler warnings 73 | } 74 | 75 | /** @brief Logs an error message */ 76 | void OnError(const char* message) { 77 | (void)message; //this avoids compiler warnings 78 | } 79 | 80 | /** @brief Detach a still attached stream from logger */ 81 | bool attachStream(LogStream *pStream, unsigned int severity) { 82 | (void)pStream; (void)severity; //this avoids compiler warnings 83 | return false; 84 | } 85 | 86 | /** @brief Detach a still attached stream from logger */ 87 | bool detatchStream(LogStream *pStream, unsigned int severity) { 88 | (void)pStream; (void)severity; //this avoids compiler warnings 89 | return false; 90 | } 91 | 92 | private: 93 | }; 94 | } 95 | #endif // !! AI_NULLLOGGER_H_INCLUDED 96 | -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/ProgressHandler.hpp: -------------------------------------------------------------------------------- 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 | /** @file ProgressHandler.h 42 | * @brief Abstract base class 'ProgressHandler'. 43 | */ 44 | #ifndef INCLUDED_AI_PROGRESSHANDLER_H 45 | #define INCLUDED_AI_PROGRESSHANDLER_H 46 | #include "types.h" 47 | namespace Assimp { 48 | 49 | // ------------------------------------------------------------------------------------ 50 | /** @brief CPP-API: Abstract interface for custom progress report receivers. 51 | * 52 | * Each #Importer instance maintains its own #ProgressHandler. The default 53 | * implementation provided by Assimp doesn't do anything at all. */ 54 | class ASSIMP_API ProgressHandler 55 | #ifndef SWIG 56 | : public Intern::AllocateFromAssimpHeap 57 | #endif 58 | { 59 | protected: 60 | /** @brief Default constructor */ 61 | ProgressHandler () { 62 | } 63 | public: 64 | /** @brief Virtual destructor */ 65 | virtual ~ProgressHandler () { 66 | } 67 | 68 | // ------------------------------------------------------------------- 69 | /** @brief Progress callback. 70 | * @param percentage An estimate of the current loading progress, 71 | * in percent. Or -1.f if such an estimate is not available. 72 | * 73 | * There are restriction on what you may do from within your 74 | * implementation of this method: no exceptions may be thrown and no 75 | * non-const #Importer methods may be called. It is 76 | * not generally possible to predict the number of callbacks 77 | * fired during a single import. 78 | * 79 | * @return Return false to abort loading at the next possible 80 | * occasion (loaders and Assimp are generally allowed to perform 81 | * all needed cleanup tasks prior to returning control to the 82 | * caller). If the loading is aborted, #Importer::ReadFile() 83 | * returns always NULL. 84 | * 85 | * @note Currently, percentage is always -1.f because there is 86 | * no reliable way to compute it. 87 | * */ 88 | virtual bool Update(float percentage = -1.f) = 0; 89 | 90 | 91 | 92 | }; // !class ProgressHandler 93 | // ------------------------------------------------------------------------------------ 94 | } // Namespace Assimp 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/ai_assert.h: -------------------------------------------------------------------------------- 1 | /** @file assert.h 2 | */ 3 | #ifndef AI_DEBUG_H_INC 4 | #define AI_DEBUG_H_INC 5 | 6 | #ifdef ASSIMP_BUILD_DEBUG 7 | # include 8 | # define ai_assert(expression) assert(expression) 9 | #else 10 | # define ai_assert(expression) 11 | #endif 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/cfileio.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2012, 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 | /** @file aiFileIO.h 43 | * @brief Defines generic C routines to access memory-mapped files 44 | */ 45 | #ifndef AI_FILEIO_H_INC 46 | #define AI_FILEIO_H_INC 47 | 48 | #include "types.h" 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | struct aiFileIO; 53 | struct aiFile; 54 | 55 | // aiFile callbacks 56 | typedef size_t (*aiFileWriteProc) (C_STRUCT aiFile*, const char*, size_t, size_t); 57 | typedef size_t (*aiFileReadProc) (C_STRUCT aiFile*, char*, size_t,size_t); 58 | typedef size_t (*aiFileTellProc) (C_STRUCT aiFile*); 59 | typedef void (*aiFileFlushProc) (C_STRUCT aiFile*); 60 | typedef aiReturn (*aiFileSeek)(C_STRUCT aiFile*, size_t, aiOrigin); 61 | 62 | // aiFileIO callbacks 63 | typedef aiFile* (*aiFileOpenProc) (C_STRUCT aiFileIO*, const char*, const char*); 64 | typedef void (*aiFileCloseProc) (C_STRUCT aiFileIO*, C_STRUCT aiFile*); 65 | 66 | // Represents user-defined data 67 | typedef char* aiUserData; 68 | 69 | // ---------------------------------------------------------------------------------- 70 | /** @brief C-API: File system callbacks 71 | * 72 | * Provided are functions to open and close files. Supply a custom structure to 73 | * the import function. If you don't, a default implementation is used. Use custom 74 | * file systems to enable reading from other sources, such as ZIPs 75 | * or memory locations. */ 76 | struct aiFileIO 77 | { 78 | /** Function used to open a new file 79 | */ 80 | aiFileOpenProc OpenProc; 81 | 82 | /** Function used to close an existing file 83 | */ 84 | aiFileCloseProc CloseProc; 85 | 86 | /** User-defined, opaque data */ 87 | aiUserData UserData; 88 | }; 89 | 90 | // ---------------------------------------------------------------------------------- 91 | /** @brief C-API: File callbacks 92 | * 93 | * Actually, it's a data structure to wrap a set of fXXXX (e.g fopen) 94 | * replacement functions. 95 | * 96 | * The default implementation of the functions utilizes the fXXX functions from 97 | * the CRT. However, you can supply a custom implementation to Assimp by 98 | * delivering a custom aiFileIO. Use this to enable reading from other sources, 99 | * such as ZIP archives or memory locations. */ 100 | struct aiFile 101 | { 102 | /** Callback to read from a file */ 103 | aiFileReadProc ReadProc; 104 | 105 | /** Callback to write to a file */ 106 | aiFileWriteProc WriteProc; 107 | 108 | /** Callback to retrieve the current position of 109 | * the file cursor (ftell()) 110 | */ 111 | aiFileTellProc TellProc; 112 | 113 | /** Callback to retrieve the size of the file, 114 | * in bytes 115 | */ 116 | aiFileTellProc FileSizeProc; 117 | 118 | /** Callback to set the current position 119 | * of the file cursor (fseek()) 120 | */ 121 | aiFileSeek SeekProc; 122 | 123 | /** Callback to flush the file contents 124 | */ 125 | aiFileFlushProc FlushProc; 126 | 127 | /** User-defined, opaque data 128 | */ 129 | aiUserData UserData; 130 | }; 131 | 132 | #ifdef __cplusplus 133 | } 134 | #endif 135 | #endif // AI_FILEIO_H_INC 136 | -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/color4.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2012, 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 | /** @file aiColor4D.h 42 | * @brief RGBA color structure, including operators when compiling in C++ 43 | */ 44 | #ifndef AI_COLOR4D_H_INC 45 | #define AI_COLOR4D_H_INC 46 | 47 | #include "./Compiler/pushpack1.h" 48 | 49 | #ifdef __cplusplus 50 | 51 | // ---------------------------------------------------------------------------------- 52 | /** Represents a color in Red-Green-Blue space including an 53 | * alpha component. Color values range from 0 to 1. */ 54 | // ---------------------------------------------------------------------------------- 55 | template 56 | class aiColor4t 57 | { 58 | public: 59 | aiColor4t () : r(), g(), b(), a() {} 60 | aiColor4t (TReal _r, TReal _g, TReal _b, TReal _a) 61 | : r(_r), g(_g), b(_b), a(_a) {} 62 | aiColor4t (TReal _r) : r(_r), g(_r), b(_r), a(_r) {} 63 | aiColor4t (const aiColor4t& o) 64 | : r(o.r), g(o.g), b(o.b), a(o.a) {} 65 | 66 | public: 67 | // combined operators 68 | const aiColor4t& operator += (const aiColor4t& o); 69 | const aiColor4t& operator -= (const aiColor4t& o); 70 | const aiColor4t& operator *= (TReal f); 71 | const aiColor4t& operator /= (TReal f); 72 | 73 | public: 74 | // comparison 75 | bool operator == (const aiColor4t& other) const; 76 | bool operator != (const aiColor4t& other) const; 77 | bool operator < (const aiColor4t& other) const; 78 | 79 | // color tuple access, rgba order 80 | inline TReal operator[](unsigned int i) const; 81 | inline TReal& operator[](unsigned int i); 82 | 83 | /** check whether a color is (close to) black */ 84 | inline bool IsBlack() const; 85 | 86 | public: 87 | 88 | // Red, green, blue and alpha color values 89 | TReal r, g, b, a; 90 | } PACK_STRUCT; // !struct aiColor4D 91 | 92 | typedef aiColor4t aiColor4D; 93 | 94 | #else 95 | 96 | struct aiColor4D { 97 | float r, g, b, a; 98 | } PACK_STRUCT; 99 | 100 | #endif // __cplusplus 101 | 102 | #include "./Compiler/poppack1.h" 103 | 104 | #endif // AI_COLOR4D_H_INC 105 | -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/defs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/Assimp-3.1.1/include/defs.h -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/matrix3x3.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/Assimp-3.1.1/include/matrix3x3.h -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/matrix3x3.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/Assimp-3.1.1/include/matrix3x3.inl -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/matrix4x4.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/Assimp-3.1.1/include/matrix4x4.h -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/matrix4x4.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/Assimp-3.1.1/include/matrix4x4.inl -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/quaternion.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 | /** @file quaternion.h 42 | * @brief Quaternion structure, including operators when compiling in C++ 43 | */ 44 | #ifndef AI_QUATERNION_H_INC 45 | #define AI_QUATERNION_H_INC 46 | 47 | #ifdef __cplusplus 48 | 49 | template class aiVector3t; 50 | template class aiMatrix3x3t; 51 | 52 | // --------------------------------------------------------------------------- 53 | /** Represents a quaternion in a 4D vector. */ 54 | template 55 | class aiQuaterniont 56 | { 57 | public: 58 | aiQuaterniont() : w(1.0), x(), y(), z() {} 59 | aiQuaterniont(TReal pw, TReal px, TReal py, TReal pz) 60 | : w(pw), x(px), y(py), z(pz) {} 61 | 62 | /** Construct from rotation matrix. Result is undefined if the matrix is not orthonormal. */ 63 | aiQuaterniont( const aiMatrix3x3t& pRotMatrix); 64 | 65 | /** Construct from euler angles */ 66 | aiQuaterniont( TReal rotx, TReal roty, TReal rotz); 67 | 68 | /** Construct from an axis-angle pair */ 69 | aiQuaterniont( aiVector3t axis, TReal angle); 70 | 71 | /** Construct from a normalized quaternion stored in a vec3 */ 72 | aiQuaterniont( aiVector3t normalized); 73 | 74 | /** Returns a matrix representation of the quaternion */ 75 | aiMatrix3x3t GetMatrix() const; 76 | 77 | public: 78 | 79 | bool operator== (const aiQuaterniont& o) const; 80 | bool operator!= (const aiQuaterniont& o) const; 81 | 82 | bool Equal(const aiQuaterniont& o, TReal epsilon = 1e-6) const; 83 | 84 | public: 85 | 86 | /** Normalize the quaternion */ 87 | aiQuaterniont& Normalize(); 88 | 89 | /** Compute quaternion conjugate */ 90 | aiQuaterniont& Conjugate (); 91 | 92 | /** Rotate a point by this quaternion */ 93 | aiVector3t Rotate (const aiVector3t& in); 94 | 95 | /** Multiply two quaternions */ 96 | aiQuaterniont operator* (const aiQuaterniont& two) const; 97 | 98 | public: 99 | 100 | /** Performs a spherical interpolation between two quaternions and writes the result into the third. 101 | * @param pOut Target object to received the interpolated rotation. 102 | * @param pStart Start rotation of the interpolation at factor == 0. 103 | * @param pEnd End rotation, factor == 1. 104 | * @param pFactor Interpolation factor between 0 and 1. Values outside of this range yield undefined results. 105 | */ 106 | static void Interpolate( aiQuaterniont& pOut, const aiQuaterniont& pStart, 107 | const aiQuaterniont& pEnd, TReal pFactor); 108 | 109 | public: 110 | 111 | //! w,x,y,z components of the quaternion 112 | TReal w, x, y, z; 113 | } ; 114 | 115 | typedef aiQuaterniont aiQuaternion; 116 | 117 | #else 118 | 119 | struct aiQuaternion { 120 | float w, x, y, z; 121 | }; 122 | 123 | #endif 124 | 125 | 126 | #endif // AI_QUATERNION_H_INC 127 | -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/vector2.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2012, 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 | /** @file aiVector2t.h 42 | * @brief 2D vector structure, including operators when compiling in C++ 43 | */ 44 | #ifndef AI_VECTOR2D_H_INC 45 | #define AI_VECTOR2D_H_INC 46 | 47 | #ifdef __cplusplus 48 | # include 49 | #else 50 | # include 51 | #endif 52 | 53 | #include "./Compiler/pushpack1.h" 54 | 55 | // ---------------------------------------------------------------------------------- 56 | /** Represents a two-dimensional vector. 57 | */ 58 | 59 | #ifdef __cplusplus 60 | template 61 | class aiVector2t 62 | { 63 | public: 64 | 65 | aiVector2t () : x(), y() {} 66 | aiVector2t (TReal _x, TReal _y) : x(_x), y(_y) {} 67 | explicit aiVector2t (TReal _xyz) : x(_xyz), y(_xyz) {} 68 | aiVector2t (const aiVector2t& o) : x(o.x), y(o.y) {} 69 | 70 | public: 71 | 72 | void Set( TReal pX, TReal pY); 73 | TReal SquareLength() const ; 74 | TReal Length() const ; 75 | aiVector2t& Normalize(); 76 | 77 | public: 78 | 79 | const aiVector2t& operator += (const aiVector2t& o); 80 | const aiVector2t& operator -= (const aiVector2t& o); 81 | const aiVector2t& operator *= (TReal f); 82 | const aiVector2t& operator /= (TReal f); 83 | 84 | TReal operator[](unsigned int i) const; 85 | TReal& operator[](unsigned int i); 86 | 87 | bool operator== (const aiVector2t& other) const; 88 | bool operator!= (const aiVector2t& other) const; 89 | 90 | bool Equal(const aiVector2t& other, TReal epsilon = 1e-6) const; 91 | 92 | aiVector2t& operator= (TReal f); 93 | const aiVector2t SymMul(const aiVector2t& o); 94 | 95 | template 96 | operator aiVector2t () const; 97 | 98 | TReal x, y; 99 | } PACK_STRUCT; 100 | 101 | typedef aiVector2t aiVector2D; 102 | 103 | #else 104 | 105 | struct aiVector2D { 106 | float x,y; 107 | }; 108 | 109 | #endif // __cplusplus 110 | 111 | #include "./Compiler/poppack1.h" 112 | 113 | #endif // AI_VECTOR2D_H_INC 114 | -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/vector3.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2012, 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 | /** @file aiVector3D.h 42 | * @brief 3D vector structure, including operators when compiling in C++ 43 | */ 44 | #ifndef AI_VECTOR3D_H_INC 45 | #define AI_VECTOR3D_H_INC 46 | 47 | #ifdef __cplusplus 48 | # include 49 | #else 50 | # include 51 | #endif 52 | 53 | #include "./Compiler/pushpack1.h" 54 | 55 | #ifdef __cplusplus 56 | 57 | template class aiMatrix3x3t; 58 | template class aiMatrix4x4t; 59 | 60 | // --------------------------------------------------------------------------- 61 | /** Represents a three-dimensional vector. */ 62 | template 63 | class aiVector3t 64 | { 65 | public: 66 | 67 | aiVector3t () : x(), y(), z() {} 68 | aiVector3t (TReal _x, TReal _y, TReal _z) : x(_x), y(_y), z(_z) {} 69 | explicit aiVector3t (TReal _xyz) : x(_xyz), y(_xyz), z(_xyz) {} 70 | aiVector3t (const aiVector3t& o) : x(o.x), y(o.y), z(o.z) {} 71 | 72 | public: 73 | 74 | // combined operators 75 | const aiVector3t& operator += (const aiVector3t& o); 76 | const aiVector3t& operator -= (const aiVector3t& o); 77 | const aiVector3t& operator *= (TReal f); 78 | const aiVector3t& operator /= (TReal f); 79 | 80 | // transform vector by matrix 81 | aiVector3t& operator *= (const aiMatrix3x3t& mat); 82 | aiVector3t& operator *= (const aiMatrix4x4t& mat); 83 | 84 | // access a single element 85 | TReal operator[](unsigned int i) const; 86 | TReal& operator[](unsigned int i); 87 | 88 | // comparison 89 | bool operator== (const aiVector3t& other) const; 90 | bool operator!= (const aiVector3t& other) const; 91 | bool operator < (const aiVector3t& other) const; 92 | 93 | bool Equal(const aiVector3t& other, TReal epsilon = 1e-6) const; 94 | 95 | template 96 | operator aiVector3t () const; 97 | 98 | public: 99 | 100 | /** @brief Set the components of a vector 101 | * @param pX X component 102 | * @param pY Y component 103 | * @param pZ Z component */ 104 | void Set( TReal pX, TReal pY, TReal pZ); 105 | 106 | /** @brief Get the squared length of the vector 107 | * @return Square length */ 108 | TReal SquareLength() const; 109 | 110 | 111 | /** @brief Get the length of the vector 112 | * @return length */ 113 | TReal Length() const; 114 | 115 | 116 | /** @brief Normalize the vector */ 117 | aiVector3t& Normalize(); 118 | 119 | 120 | /** @brief Componentwise multiplication of two vectors 121 | * 122 | * Note that vec*vec yields the dot product. 123 | * @param o Second factor */ 124 | const aiVector3t SymMul(const aiVector3t& o); 125 | 126 | TReal x, y, z; 127 | } PACK_STRUCT; 128 | 129 | 130 | typedef aiVector3t aiVector3D; 131 | 132 | #else 133 | 134 | struct aiVector3D { 135 | 136 | float x,y,z; 137 | } PACK_STRUCT; 138 | 139 | #endif // __cplusplus 140 | 141 | #include "./Compiler/poppack1.h" 142 | 143 | #ifdef __cplusplus 144 | 145 | 146 | 147 | #endif // __cplusplus 148 | 149 | #endif // AI_VECTOR3D_H_INC 150 | -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2012, 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 | /** @file aiVersion.h 43 | * @brief Functions to query the version of the Assimp runtime, check 44 | * compile flags, ... 45 | */ 46 | #ifndef INCLUDED_AI_VERSION_H 47 | #define INCLUDED_AI_VERSION_H 48 | 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | // --------------------------------------------------------------------------- 54 | /** @brief Returns a string with legal copyright and licensing information 55 | * about Assimp. The string may include multiple lines. 56 | * @return Pointer to static string. 57 | */ 58 | ASSIMP_API const char* aiGetLegalString (void); 59 | 60 | // --------------------------------------------------------------------------- 61 | /** @brief Returns the current minor version number of Assimp. 62 | * @return Minor version of the Assimp runtime the application was 63 | * linked/built against 64 | */ 65 | ASSIMP_API unsigned int aiGetVersionMinor (void); 66 | 67 | // --------------------------------------------------------------------------- 68 | /** @brief Returns the current major version number of Assimp. 69 | * @return Major version of the Assimp runtime the application was 70 | * linked/built against 71 | */ 72 | ASSIMP_API unsigned int aiGetVersionMajor (void); 73 | 74 | // --------------------------------------------------------------------------- 75 | /** @brief Returns the repository revision of the Assimp runtime. 76 | * @return SVN Repository revision number of the Assimp runtime the 77 | * application was linked/built against. 78 | */ 79 | ASSIMP_API unsigned int aiGetVersionRevision (void); 80 | 81 | //! Assimp was compiled as a shared object (Windows: DLL) 82 | #define ASSIMP_CFLAGS_SHARED 0x1 83 | //! Assimp was compiled against STLport 84 | #define ASSIMP_CFLAGS_STLPORT 0x2 85 | //! Assimp was compiled as a debug build 86 | #define ASSIMP_CFLAGS_DEBUG 0x4 87 | 88 | //! Assimp was compiled with ASSIMP_BUILD_BOOST_WORKAROUND defined 89 | #define ASSIMP_CFLAGS_NOBOOST 0x8 90 | //! Assimp was compiled with ASSIMP_BUILD_SINGLETHREADED defined 91 | #define ASSIMP_CFLAGS_SINGLETHREADED 0x10 92 | 93 | // --------------------------------------------------------------------------- 94 | /** @brief Returns assimp's compile flags 95 | * @return Any bitwise combination of the ASSIMP_CFLAGS_xxx constants. 96 | */ 97 | ASSIMP_API unsigned int aiGetCompileFlags (void); 98 | 99 | #ifdef __cplusplus 100 | } // end extern "C" 101 | #endif 102 | 103 | #endif // !! #ifndef INCLUDED_AI_VERSION_H 104 | -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/lib/assimp.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/Assimp-3.1.1/lib/assimp.lib -------------------------------------------------------------------------------- /Externals/DirectXTex/Include/BCDirectCompute.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------- 2 | // BCDirectCompute.h 3 | // 4 | // Direct3D 11 Compute Shader BC Compressor 5 | // 6 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 7 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 8 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 9 | // PARTICULAR PURPOSE. 10 | // 11 | // Copyright (c) Microsoft Corporation. All rights reserved. 12 | //------------------------------------------------------------------------------------- 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER > 1000) 15 | #pragma once 16 | #endif 17 | 18 | namespace DirectX 19 | { 20 | 21 | class GPUCompressBC 22 | { 23 | public: 24 | GPUCompressBC(); 25 | 26 | HRESULT Initialize( _In_ ID3D11Device* pDevice ); 27 | 28 | HRESULT Prepare( _In_ size_t width, _In_ size_t height, _In_ DXGI_FORMAT format, _In_ float alphaWeight = 1.f ); 29 | 30 | HRESULT Compress( _In_ const Image& srcImage, _In_ const Image& destImage ); 31 | 32 | DXGI_FORMAT GetSourceFormat() const { return m_srcformat; } 33 | 34 | private: 35 | DXGI_FORMAT m_bcformat; 36 | DXGI_FORMAT m_srcformat; 37 | float m_alphaWeight; 38 | size_t m_width; 39 | size_t m_height; 40 | 41 | Microsoft::WRL::ComPtr m_device; 42 | Microsoft::WRL::ComPtr m_context; 43 | 44 | Microsoft::WRL::ComPtr m_err1; 45 | Microsoft::WRL::ComPtr m_err1UAV; 46 | Microsoft::WRL::ComPtr m_err1SRV; 47 | 48 | Microsoft::WRL::ComPtr m_err2; 49 | Microsoft::WRL::ComPtr m_err2UAV; 50 | Microsoft::WRL::ComPtr m_err2SRV; 51 | 52 | Microsoft::WRL::ComPtr m_output; 53 | Microsoft::WRL::ComPtr m_outputCPU; 54 | Microsoft::WRL::ComPtr m_outputUAV; 55 | Microsoft::WRL::ComPtr m_constBuffer; 56 | 57 | // Compute shader library 58 | Microsoft::WRL::ComPtr m_BC6H_tryModeG10CS; 59 | Microsoft::WRL::ComPtr m_BC6H_tryModeLE10CS; 60 | Microsoft::WRL::ComPtr m_BC6H_encodeBlockCS; 61 | 62 | Microsoft::WRL::ComPtr m_BC7_tryMode456CS; 63 | Microsoft::WRL::ComPtr m_BC7_tryMode137CS; 64 | Microsoft::WRL::ComPtr m_BC7_tryMode02CS; 65 | Microsoft::WRL::ComPtr m_BC7_encodeBlockCS; 66 | }; 67 | 68 | }; // namespace -------------------------------------------------------------------------------- /Externals/DirectXTex/Include/scoped.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------- 2 | // scoped.h 3 | // 4 | // Utility header with helper classes for exception-safe handling of resources 5 | // 6 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 7 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 8 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 9 | // PARTICULAR PURPOSE. 10 | // 11 | // Copyright (c) Microsoft Corporation. All rights reserved. 12 | //------------------------------------------------------------------------------------- 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER > 1000) 15 | #pragma once 16 | #endif 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | //--------------------------------------------------------------------------------- 23 | struct aligned_deleter { void operator()(void* p) { _aligned_free(p); } }; 24 | 25 | typedef std::unique_ptr ScopedAlignedArrayFloat; 26 | 27 | typedef std::unique_ptr ScopedAlignedArrayXMVECTOR; 28 | 29 | //--------------------------------------------------------------------------------- 30 | struct handle_closer { void operator()(HANDLE h) { assert(h != INVALID_HANDLE_VALUE); if (h) CloseHandle(h); } }; 31 | 32 | typedef public std::unique_ptr ScopedHandle; 33 | 34 | inline HANDLE safe_handle( HANDLE h ) { return (h == INVALID_HANDLE_VALUE) ? 0 : h; } 35 | -------------------------------------------------------------------------------- /Externals/DirectXTex/Lib 2012/Debug/DirectXTex.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/DirectXTex/Lib 2012/Debug/DirectXTex.lib -------------------------------------------------------------------------------- /Externals/DirectXTex/Lib 2012/Debug/directxtex.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/DirectXTex/Lib 2012/Debug/directxtex.pdb -------------------------------------------------------------------------------- /Externals/DirectXTex/Lib 2012/Release/DirectXTex.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/DirectXTex/Lib 2012/Release/DirectXTex.lib -------------------------------------------------------------------------------- /Externals/DirectXTex/Lib 2012/Release/directxtex.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/DirectXTex/Lib 2012/Release/directxtex.pdb -------------------------------------------------------------------------------- /Externals/DirectXTex/Lib/Debug/DirectXTex.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/DirectXTex/Lib/Debug/DirectXTex.lib -------------------------------------------------------------------------------- /Externals/DirectXTex/Lib/Debug/directxtex.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/DirectXTex/Lib/Debug/directxtex.pdb -------------------------------------------------------------------------------- /Externals/DirectXTex/Lib/Release/DirectXTex.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/DirectXTex/Lib/Release/DirectXTex.lib -------------------------------------------------------------------------------- /Externals/DirectXTex/Lib/Release/directxtex.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/DirectXTex/Lib/Release/directxtex.pdb -------------------------------------------------------------------------------- /Externals/HosekSky/Include/README.txt: -------------------------------------------------------------------------------- 1 | This file is part of a sample implementation of the analytical skylight and 2 | solar radiance models presented in the SIGGRAPH 2012 paper 3 | 4 | 5 | "An Analytic Model for Full Spectral Sky-Dome Radiance" 6 | 7 | and the 2013 IEEE CG&A paper 8 | 9 | "Adding a Solar Radiance Function to the Hosek Skylight Model" 10 | 11 | both by 12 | 13 | Lukas Hosek and Alexander Wilkie 14 | Charles University in Prague, Czech Republic 15 | 16 | 17 | Version: 1.4a, February 22nd, 2013 18 | 19 | Version history: 20 | 21 | 1.4a February 22nd, 2013 22 | Removed unnecessary and counter-intuitive solar radius parameters 23 | from the interface of the colourspace sky dome initialisation functions. 24 | 25 | 1.4 February 11th, 2013 26 | Fixed a bug which caused the relative brightness of the solar disc 27 | and the sky dome to be off by a factor of about 6. The sun was too 28 | bright: this affected both normal and alien sun scenarios. The 29 | coefficients of the solar radiance function were changed to fix this. 30 | 31 | 1.3 January 21st, 2013 (not released to the public) 32 | Added support for solar discs that are not exactly the same size as 33 | the terrestrial sun. Also added support for suns with a different 34 | emission spectrum ("Alien World" functionality). 35 | 36 | 1.2a December 18th, 2012 37 | Fixed a mistake and some inaccuracies in the solar radiance function 38 | explanations found in ArHosekSkyModel.h. The actual source code is 39 | unchanged compared to version 1.2. 40 | 41 | 1.2 December 17th, 2012 42 | Native RGB data and a solar radiance function that matches the turbidity 43 | conditions were added. 44 | 45 | 1.1 September 2012 46 | The coefficients of the spectral model are now scaled so that the output 47 | is given in physical units: W / (m^-2 * sr * nm). Also, the output of the 48 | XYZ model is now no longer scaled to the range [0...1]. Instead, it is 49 | the result of a simple conversion from spectral data via the CIE 2 degree 50 | standard observer matching functions. Therefore, after multiplication 51 | with 683 lm / W, the Y channel now corresponds to luminance in lm. 52 | 53 | 1.0 May 11th, 2012 54 | Initial release. 55 | 56 | 57 | Please visit http://cgg.mff.cuni.cz/projects/SkylightModelling/ to check if 58 | an updated version of this code has been published! 59 | 60 | This archive contains the following files: 61 | 62 | README.txt This file. 63 | 64 | ArHosekSkyModel.h Header file for the reference functions. Their 65 | usage is explained there, and sample code for 66 | calling them is given. 67 | 68 | ArHosekSkyModel.c Implementation of the functions. 69 | 70 | ArHosekSkyModelData_Spectral.h Spectral coefficient data. 71 | ArHosekSkyModelData_CIEXYZ.h CIE XYZ coefficient data. 72 | ArHosekSkyModelData_RGB.h RGB coefficient data. 73 | 74 | Please note that the source files are in C99, and you have to set appropriate 75 | compiler flags for them to work. For example, when compiling this code with 76 | gcc, you have to add the "-std=c99" or "-std=gnu99" flags. -------------------------------------------------------------------------------- /Externals/HosekSky/Lib 2013/HosekSky.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/HosekSky/Lib 2013/HosekSky.lib -------------------------------------------------------------------------------- /Externals/HosekSky/Lib 2013/HosekSky_Dbg.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/HosekSky/Lib 2013/HosekSky_Dbg.lib -------------------------------------------------------------------------------- /Externals/HosekSky/Lib 2013/hoseksky.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/HosekSky/Lib 2013/hoseksky.pdb -------------------------------------------------------------------------------- /Externals/HosekSky/Lib 2013/hoseksky_dbg.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/HosekSky/Lib 2013/hoseksky_dbg.pdb -------------------------------------------------------------------------------- /Externals/d3dcompiler_47.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/Externals/d3dcompiler_47.dll -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 MJP 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /LowResRendering/AppPCH.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Low-Resolution Rendering Sample 4 | // by MJP 5 | // http://mynameismjp.wordpress.com/ 6 | // 7 | // All code and content licensed under the MIT license 8 | // 9 | //================================================================================================= -------------------------------------------------------------------------------- /LowResRendering/AppSettings.hlsl: -------------------------------------------------------------------------------- 1 | cbuffer AppSettings : register(b7) 2 | { 3 | bool EnableSun; 4 | bool SunAreaLightApproximation; 5 | float3 SunTintColor; 6 | float SunIntensityScale; 7 | float SunSize; 8 | int SunDirType; 9 | float3 SunDirection; 10 | float SunAzimuth; 11 | float SunElevation; 12 | int MSAAMode; 13 | float FilterSize; 14 | bool EnableAlbedoMaps; 15 | bool EnableNormalMaps; 16 | float NormalMapIntensity; 17 | float DiffuseIntensity; 18 | float Roughness; 19 | float SpecularIntensity; 20 | int NumParticles; 21 | float EmitRadius; 22 | float EmitCenterX; 23 | float EmitCenterY; 24 | float EmitCenterZ; 25 | float AbsorptionScale; 26 | bool EnableParticleAlbedoMap; 27 | bool BillboardParticles; 28 | bool RenderLowRes; 29 | int LowResRenderMode; 30 | float ResolveSubPixelThreshold; 31 | float CompositeSubPixelThreshold; 32 | float NearestDepthThreshold; 33 | float BloomExposure; 34 | float BloomMagnitude; 35 | float BloomBlurSigma; 36 | bool ShowMSAAEdges; 37 | } 38 | 39 | static const int SunDirectionTypes_UnitVector = 0; 40 | static const int SunDirectionTypes_HorizontalCoordSystem = 1; 41 | 42 | static const int MSAAModes_MSAANone = 0; 43 | static const int MSAAModes_MSAA2x = 1; 44 | 45 | static const int LowResRenderModes_MSAA = 0; 46 | static const int LowResRenderModes_NearestDepth = 1; 47 | 48 | static const float ExposureRangeScale = 0.0010f; 49 | static const float BaseSunSize = 0.2700f; 50 | static const int MaxParticles = 32768; 51 | -------------------------------------------------------------------------------- /LowResRendering/DepthDownscale.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Low-Resolution Rendering Sample 4 | // by MJP 5 | // http://mynameismjp.wordpress.com/ 6 | // 7 | // All code and content licensed under the MIT license 8 | // 9 | //================================================================================================= 10 | 11 | //================================================================================================= 12 | // Includes 13 | //================================================================================================= 14 | #include 15 | #include "AppSettings.hlsl" 16 | 17 | //================================================================================================= 18 | // Constants 19 | //================================================================================================= 20 | #ifndef MSAASamples_ 21 | #define MSAASamples_ 1 22 | #endif 23 | 24 | #define MSAA_ (MSAASamples_ > 1) 25 | 26 | //================================================================================================= 27 | // Resources 28 | //================================================================================================= 29 | #if MSAA_ 30 | Texture2DMS FullResDepth : register(t0); 31 | #else 32 | Texture2D FullResDepth : register(t0); 33 | #endif 34 | 35 | // Downscales the high-resolution depth buffer to a half-resolution MSAA depth buffer. When 36 | // we do this we're not *really* downsampling, we're just stuffing the depth values into corresponding 37 | // depth subsamples. This effectively lets us perform the depth test at full resolution, while shading 38 | // at half resolution. If we were on a platform where it were possible to alias a depth buffer as a 39 | // lower-resolution MSAA depth buffer, then we wouldn't need this step. 40 | float DepthDownscaleMSAA(in float4 Position : SV_Position, in uint SampleIdx : SV_SampleIndex) : SV_Depth 41 | { 42 | float output = 1.0f; 43 | 44 | #if MSAASamples_ == 1 45 | const uint NumOutputSamples = 4; 46 | const float2 LoadOffsets[NumOutputSamples] = 47 | { 48 | float2(-0.5f, -0.5f), 49 | float2( 0.5f, -0.5f), 50 | float2(-0.5f, 0.5f), 51 | float2( 0.5f, 0.5f), 52 | }; 53 | 54 | float2 loadPos = Position.xy * 2.0f + LoadOffsets[min(SampleIdx, NumOutputSamples - 1)]; 55 | output = FullResDepth[uint2(loadPos)]; 56 | #elif MSAASamples_ == 2 57 | const uint NumOutputSamples = 8; 58 | 59 | const float2 LoadOffsets[NumOutputSamples] = 60 | { 61 | float2(-0.5f, -0.5f), 62 | float2(-0.5f, -0.5f), 63 | 64 | float2( 0.5f, -0.5f), 65 | float2( 0.5f, -0.5f), 66 | 67 | float2(-0.5f, 0.5f), 68 | float2(-0.5f, 0.5f), 69 | 70 | float2( 0.5f, 0.5f), 71 | float2( 0.5f, 0.5f), 72 | }; 73 | 74 | float2 loadPos = Position.xy * 2.0f + LoadOffsets[min(SampleIdx, NumOutputSamples - 1)]; 75 | output = FullResDepth.Load(uint2(loadPos), SampleIdx % 2); 76 | #else 77 | #error "Not implemented" 78 | #endif 79 | 80 | return output; 81 | } 82 | 83 | // Downscales the depth buffer to half resolution using point sampling. Used for "Nearest-Depth" 84 | // low-res rendering mode. 85 | float DepthDownscale(in float4 Position : SV_Position) : SV_Depth 86 | { 87 | #if MSAA_ 88 | return FullResDepth.Load(uint2(Position.xy) * 2, 0); 89 | #else 90 | return FullResDepth[uint2(Position.xy * 2)]; 91 | #endif 92 | } -------------------------------------------------------------------------------- /LowResRendering/DepthOnly.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Low-Resolution Rendering Sample 4 | // by MJP 5 | // http://mynameismjp.wordpress.com/ 6 | // 7 | // All code and content licensed under the MIT license 8 | // 9 | //================================================================================================= 10 | 11 | // ================================================================================================ 12 | // Constant buffers 13 | // ================================================================================================ 14 | cbuffer VSConstants : register(b0) 15 | { 16 | float4x4 World; 17 | float4x4 View; 18 | float4x4 WorldViewProjection; 19 | } 20 | 21 | // ================================================================================================ 22 | // Input/Output structs 23 | // ================================================================================================ 24 | struct VSInput 25 | { 26 | float4 PositionOS : POSITION; 27 | }; 28 | 29 | struct VSOutput 30 | { 31 | float4 PositionCS : SV_Position; 32 | }; 33 | 34 | // ================================================================================================ 35 | // Vertex Shader 36 | // ================================================================================================ 37 | VSOutput VS(in VSInput input) 38 | { 39 | VSOutput output; 40 | 41 | // Calc the clip-space position 42 | output.PositionCS = mul(input.PositionOS, WorldViewProjection); 43 | 44 | return output; 45 | } 46 | 47 | // ================================================================================================ 48 | // Pixel Shader 49 | // ================================================================================================ 50 | float4 PS() : SV_Target 51 | { 52 | return float4(0.0f, 0.0f, 0.0f, 1.0f); 53 | } -------------------------------------------------------------------------------- /LowResRendering/EVSM.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Low-Resolution Rendering Sample 4 | // by MJP 5 | // http://mynameismjp.wordpress.com/ 6 | // 7 | // All code and content licensed under the MIT license 8 | // 9 | //================================================================================================= 10 | 11 | float2 GetEVSMExponents(in float positiveExponent, in float negativeExponent, 12 | in float3 cascadeScale) 13 | { 14 | 15 | const float maxExponent = 42.0f; 16 | 17 | float2 lightSpaceExponents = float2(positiveExponent, negativeExponent); 18 | 19 | // Make sure exponents say consistent in light space regardless of partition 20 | // scaling. This prevents the exponentials from ever getting too rediculous 21 | // and maintains consistency across partitions. 22 | // Clamp to maximum range of fp32/fp16 to prevent overflow/underflow 23 | return min(lightSpaceExponents / cascadeScale.z, maxExponent); 24 | } 25 | 26 | // Input depth should be in [0, 1] 27 | float2 WarpDepth(float depth, float2 exponents) 28 | { 29 | // Rescale depth into [-1, 1] 30 | depth = 2.0f * depth - 1.0f; 31 | float pos = exp( exponents.x * depth); 32 | float neg = -exp(-exponents.y * depth); 33 | return float2(pos, neg); 34 | } 35 | 36 | float Linstep(float a, float b, float v) 37 | { 38 | return saturate((v - a) / (b - a)); 39 | } 40 | 41 | float ReduceLightBleeding(float pMax, float amount) 42 | { 43 | // Remove the [0, amount] tail and linearly rescale (amount, 1]. 44 | return Linstep(amount, 1.0f, pMax); 45 | } 46 | 47 | float ChebyshevUpperBound(float2 moments, float mean, float minVariance, 48 | float lightBleedingReduction) 49 | { 50 | // Compute variance 51 | float variance = moments.y - (moments.x * moments.x); 52 | variance = max(variance, minVariance); 53 | 54 | // Compute probabilistic upper bound 55 | float d = mean - moments.x; 56 | float pMax = variance / (variance + (d * d)); 57 | 58 | pMax = ReduceLightBleeding(pMax, lightBleedingReduction); 59 | 60 | // One-tailed Chebyshev 61 | return (mean <= moments.x ? 1.0f : pMax); 62 | } -------------------------------------------------------------------------------- /LowResRendering/EVSMConvert.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Low-Resolution Rendering Sample 4 | // by MJP 5 | // http://mynameismjp.wordpress.com/ 6 | // 7 | // All code and content licensed under the MIT license 8 | // 9 | //================================================================================================= 10 | 11 | //================================================================================================= 12 | // Includes 13 | //================================================================================================= 14 | #include "EVSM.hlsl" 15 | 16 | //================================================================================================= 17 | // Constants 18 | //================================================================================================= 19 | #ifndef MSAASamples_ 20 | #define MSAASamples_ 1 21 | #endif 22 | 23 | #ifndef SampleRadius_ 24 | #define SampleRadius_ 0 25 | #endif 26 | 27 | //================================================================================================= 28 | // Resources 29 | //================================================================================================= 30 | #if MSAASamples_ > 1 31 | Texture2DMS ShadowMap : register(t0); 32 | #else 33 | Texture2D ShadowMap : register(t0); 34 | #endif 35 | 36 | #if Vertical_ 37 | Texture2D EVSMMap : register(t0); 38 | #else 39 | Texture2DArray EVSMMap : register(t0); 40 | #endif 41 | 42 | cbuffer EVSMConstants : register(b0) 43 | { 44 | float3 CascadeScale; 45 | float PositiveExponent; 46 | float NegativeExponent; 47 | float FilterSize; 48 | float2 ShadowMapSize; 49 | } 50 | 51 | struct VSOutput 52 | { 53 | float4 Position : SV_Position; 54 | float2 TexCoord : TEXCOORD; 55 | }; 56 | 57 | VSOutput FullScreenVS(in uint VertexID : SV_VertexID) 58 | { 59 | VSOutput output; 60 | 61 | if(VertexID == 0) 62 | { 63 | output.Position = float4(-1.0f, 1.0f, 1.0f, 1.0f); 64 | output.TexCoord = float2(0.0f, 0.0f); 65 | } 66 | else if(VertexID == 1) 67 | { 68 | output.Position = float4(3.0f, 1.0f, 1.0f, 1.0f); 69 | output.TexCoord = float2(2.0f, 0.0f); 70 | } 71 | else 72 | { 73 | output.Position = float4(-1.0f, -3.0f, 1.0f, 1.0f); 74 | output.TexCoord = float2(0.0f, 2.0f); 75 | } 76 | 77 | return output; 78 | } 79 | 80 | float4 ConvertToEVSM(in VSOutput input) : SV_Target0 81 | { 82 | float sampleWeight = 1.0f / float(MSAASamples_); 83 | uint2 coords = uint2(input.Position.xy); 84 | 85 | float2 exponents = GetEVSMExponents(PositiveExponent, NegativeExponent, CascadeScale); 86 | 87 | float4 average = float4(0.0f, 0.0f, 0.0f, 0.0f); 88 | 89 | // Sample indices to Load() must be literal, so force unroll 90 | [unroll] 91 | for(uint i = 0; i < MSAASamples_; ++i) 92 | { 93 | // Convert to EVSM representation 94 | #if MSAASamples_ > 1 95 | float depth = ShadowMap.Load(coords, i); 96 | #else 97 | float depth = ShadowMap[coords]; 98 | #endif 99 | 100 | float2 warpedDepth = WarpDepth(depth, exponents); 101 | average += sampleWeight * float4(warpedDepth.xy, warpedDepth.xy * warpedDepth.xy); 102 | } 103 | 104 | return average; 105 | } 106 | 107 | float4 BlurSample(in float2 screenPos, in float offset, in float2 mapSize) 108 | { 109 | #if Vertical_ 110 | float2 samplePos = screenPos; 111 | samplePos.y = clamp(screenPos.y + offset, 0, mapSize.y); 112 | return EVSMMap[uint2(samplePos)]; 113 | #else 114 | float2 samplePos = screenPos; 115 | samplePos.x = clamp(screenPos.x + offset, 0, mapSize.x); 116 | return EVSMMap[uint3(samplePos, 0)]; 117 | #endif 118 | } 119 | 120 | float4 BlurEVSM(in VSOutput input) : SV_Target0 121 | { 122 | const float Radius = FilterSize / 2.0f; 123 | 124 | float4 sum = 0.0f; 125 | 126 | [unroll] 127 | for(int i = -SampleRadius_; i <= SampleRadius_; ++i) 128 | { 129 | float4 sample = BlurSample(input.Position.xy, i, ShadowMapSize); 130 | 131 | sample *= saturate((Radius + 0.5f) - abs(i)); 132 | 133 | sum += sample; 134 | } 135 | 136 | return sum / FilterSize; 137 | } -------------------------------------------------------------------------------- /LowResRendering/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/LowResRendering/Icon.ico -------------------------------------------------------------------------------- /LowResRendering/LowResRendering.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Low-Resolution Rendering Sample 4 | // by MJP 5 | // http://mynameismjp.wordpress.com/ 6 | // 7 | // All code and content licensed under the MIT license 8 | // 9 | //================================================================================================= 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "PostProcessor.h" 26 | #include "MeshRenderer.h" 27 | 28 | using namespace SampleFramework11; 29 | 30 | struct ParticleData; 31 | 32 | class LowResRendering : public App 33 | { 34 | 35 | protected: 36 | 37 | FirstPersonCamera camera; 38 | 39 | SpriteFont font; 40 | SampleFramework11::SpriteRenderer spriteRenderer; 41 | Skybox skybox; 42 | 43 | PostProcessor postProcessor; 44 | DepthStencilBuffer depthBuffer; 45 | RenderTarget2D colorTargetMSAA; 46 | RenderTarget2D colorResolveTarget; 47 | RenderTarget2D lowResTargetMSAA; 48 | RenderTarget2D lowResTarget; 49 | DepthStencilBuffer lowResDepthMSAA; 50 | DepthStencilBuffer lowResDepth; 51 | 52 | // Model 53 | Model sceneModels[1]; 54 | MeshRenderer meshRenderer; 55 | 56 | ID3D11RasterizerStatePtr msaaLowResRS[uint64(MSAAModes::NumValues)]; 57 | PixelShaderPtr depthDownscalePS[uint64(MSAAModes::NumValues)]; 58 | PixelShaderPtr msaaDepthDownscalePS[uint64(MSAAModes::NumValues)]; 59 | PixelShaderPtr msaaLowResCompositePS[uint64(MSAAModes::NumValues)]; 60 | PixelShaderPtr msaaLowResResolvePS[uint64(MSAAModes::NumValues)]; 61 | PixelShaderPtr nearestDepthCompositePS[uint64(MSAAModes::NumValues)]; 62 | 63 | VertexShaderPtr particlesVS; 64 | PixelShaderPtr particlesPS; 65 | std::vector particleData; 66 | uint64 numParticles = 0; 67 | float rotationAmount = 0.0f; 68 | ID3D11BufferPtr particleBuffer; 69 | ID3D11ShaderResourceViewPtr particleBufferSRV; 70 | ID3D11BufferPtr particleIB; 71 | ID3D11ShaderResourceViewPtr smokeTexture; 72 | Random randomGenerator; 73 | ID3D11BlendStatePtr particleBlendState; 74 | ID3D11BlendStatePtr compositeBlendState; 75 | 76 | VertexShaderPtr fullScreenTriVS; 77 | PixelShaderPtr resolvePS[uint64(MSAAModes::NumValues)]; 78 | 79 | struct ParticleConstants 80 | { 81 | Float4x4 ViewProjection; 82 | Float3 CameraRight; 83 | Float4Align Float3 CameraUp; 84 | float Time; 85 | Float4Align Float3 SunDirectionWS; 86 | Float4Align Float3 SunIlluminance; 87 | Float4Align Float3 CameraPosWS; 88 | }; 89 | 90 | ConstantBuffer particleConstants; 91 | 92 | struct CompositeConstants 93 | { 94 | Float4x4 Projection; 95 | Float2 LowResSize; 96 | }; 97 | 98 | ConstantBuffer compositeConstants; 99 | 100 | struct ResolveConstants 101 | { 102 | uint32 SampleRadius; 103 | Float2 TextureSize; 104 | }; 105 | 106 | ConstantBuffer resolveConstants; 107 | 108 | virtual void Initialize() override; 109 | virtual void Render(const Timer& timer) override; 110 | virtual void Update(const Timer& timer) override; 111 | virtual void BeforeReset() override; 112 | virtual void AfterReset() override; 113 | 114 | void CreateRenderTargets(); 115 | void InitializeNVAPI(); 116 | void InitializeParticles(); 117 | 118 | void UpdateParticles(const Timer& timer); 119 | 120 | void RenderMainPass(); 121 | void RenderParticles(const Timer& timer); 122 | void RenderAA(); 123 | void RenderHUD(const Timer& timer); 124 | 125 | public: 126 | 127 | LowResRendering(); 128 | }; 129 | -------------------------------------------------------------------------------- /LowResRendering/LowResRendering.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/LowResRendering/LowResRendering.rc -------------------------------------------------------------------------------- /LowResRendering/LowResRendering.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LowResRendering", "LowResRendering.vcxproj", "{1D9C887B-E727-438B-8977-A0E7363B1FC6}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {A01DD775-61A4-42F1-9B2A-772E50456A68} = {A01DD775-61A4-42F1-9B2A-772E50456A68} 9 | {C61F717F-FF92-4D36-930E-1F49C198CBEE} = {C61F717F-FF92-4D36-930E-1F49C198CBEE} 10 | EndProjectSection 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingsCompiler", "..\SampleFramework11\v1.01\SettingsCompiler\SettingsCompiler.csproj", "{A01DD775-61A4-42F1-9B2A-772E50456A68}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingsCompilerAttributes", "..\SampleFramework11\v1.01\SettingsCompilerAttributes\SettingsCompilerAttributes.csproj", "{C61F717F-FF92-4D36-930E-1F49C198CBEE}" 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|x64 = Debug|x64 19 | Release|x64 = Release|x64 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {1D9C887B-E727-438B-8977-A0E7363B1FC6}.Debug|x64.ActiveCfg = Debug|x64 23 | {1D9C887B-E727-438B-8977-A0E7363B1FC6}.Debug|x64.Build.0 = Debug|x64 24 | {1D9C887B-E727-438B-8977-A0E7363B1FC6}.Release|x64.ActiveCfg = Release|x64 25 | {1D9C887B-E727-438B-8977-A0E7363B1FC6}.Release|x64.Build.0 = Release|x64 26 | {A01DD775-61A4-42F1-9B2A-772E50456A68}.Debug|x64.ActiveCfg = Debug|x64 27 | {A01DD775-61A4-42F1-9B2A-772E50456A68}.Debug|x64.Build.0 = Debug|x64 28 | {A01DD775-61A4-42F1-9B2A-772E50456A68}.Release|x64.ActiveCfg = Release|x64 29 | {A01DD775-61A4-42F1-9B2A-772E50456A68}.Release|x64.Build.0 = Release|x64 30 | {C61F717F-FF92-4D36-930E-1F49C198CBEE}.Debug|x64.ActiveCfg = Debug|x64 31 | {C61F717F-FF92-4D36-930E-1F49C198CBEE}.Debug|x64.Build.0 = Debug|x64 32 | {C61F717F-FF92-4D36-930E-1F49C198CBEE}.Release|x64.ActiveCfg = Release|x64 33 | {C61F717F-FF92-4D36-930E-1F49C198CBEE}.Release|x64.Build.0 = Release|x64 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | EndGlobal 39 | -------------------------------------------------------------------------------- /LowResRendering/MeshRenderer.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Low-Resolution Rendering Sample 4 | // by MJP 5 | // http://mynameismjp.wordpress.com/ 6 | // 7 | // All code and content licensed under the MIT license 8 | // 9 | //================================================================================================= 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "AppSettings.h" 23 | 24 | using namespace SampleFramework11; 25 | 26 | class MeshRenderer 27 | { 28 | 29 | protected: 30 | 31 | // Constants 32 | static const uint32 NumCascades = 4; 33 | static const uint32 ReadbackLatency = 1; 34 | 35 | public: 36 | 37 | MeshRenderer(); 38 | 39 | void Initialize(ID3D11Device* device, ID3D11DeviceContext* context, const Model* sceneModel); 40 | void SetModel(const Model* model); 41 | 42 | void RenderDepth(ID3D11DeviceContext* context, const Camera& camera, bool noZClip, bool flippedZRange); 43 | void RenderMainPass(ID3D11DeviceContext* context, const Camera& camera); 44 | 45 | void Update(const Camera& camera); 46 | 47 | void OnResize(uint32 width, uint32 height); 48 | 49 | void ReduceDepth(ID3D11DeviceContext* context, DepthStencilBuffer& depthTarget, 50 | const Camera& camera); 51 | 52 | void RenderSunShadowMap(ID3D11DeviceContext* context, const Camera& camera); 53 | 54 | 55 | protected: 56 | 57 | void LoadShaders(); 58 | void CreateShadowMaps(); 59 | void ConvertToEVSM(ID3D11DeviceContext* context, uint32 cascadeIdx, Float3 cascadeScale); 60 | 61 | ID3D11DevicePtr device; 62 | 63 | BlendStates blendStates; 64 | RasterizerStates rasterizerStates; 65 | DepthStencilStates depthStencilStates; 66 | SamplerStates samplerStates; 67 | 68 | const Model* sceneModel; 69 | 70 | DepthStencilBuffer sunShadowDepthMap; 71 | RenderTarget2D tempVSM; 72 | 73 | ID3D11RasterizerStatePtr noZClipRSState; 74 | ID3D11SamplerStatePtr evsmSampler; 75 | 76 | std::vector meshInputLayouts; 77 | VertexShaderPtr meshVS; 78 | PixelShaderPtr meshPS; 79 | 80 | std::vector meshDepthInputLayouts; 81 | VertexShaderPtr meshDepthVS; 82 | 83 | VertexShaderPtr fullScreenVS; 84 | PixelShaderPtr evsmConvertPS; 85 | PixelShaderPtr evsmBlurH; 86 | PixelShaderPtr evsmBlurV; 87 | 88 | ComputeShaderPtr depthReductionInitialCS[2]; 89 | ComputeShaderPtr depthReductionCS; 90 | std::vector depthReductionTargets; 91 | StagingTexture2D reductionStagingTextures[ReadbackLatency]; 92 | uint32 currFrame; 93 | 94 | Float2 reductionDepth; 95 | 96 | // Constant buffers 97 | struct MeshVSConstants 98 | { 99 | Float4Align Float4x4 World; 100 | Float4Align Float4x4 View; 101 | Float4Align Float4x4 WorldViewProjection; 102 | }; 103 | 104 | struct MeshPSConstants 105 | { 106 | Float4Align Float3 SunDirectionWS; 107 | float CosSunAngularRadius; 108 | Float4Align Float3 SunIlluminance; 109 | float SinSunAngularRadius; 110 | Float4Align Float3 CameraPosWS; 111 | }; 112 | 113 | struct EVSMConstants 114 | { 115 | Float3 CascadeScale; 116 | float PositiveExponent; 117 | float NegativeExponent; 118 | float FilterSize; 119 | Float2 ShadowMapSize; 120 | }; 121 | 122 | struct ReductionConstants 123 | { 124 | Float4x4 Projection; 125 | float NearClip; 126 | float FarClip; 127 | Uint2 TextureSize; 128 | uint32 NumSamples; 129 | }; 130 | 131 | ConstantBuffer meshVSConstants; 132 | ConstantBuffer meshPSConstants; 133 | ConstantBuffer evsmConstants; 134 | ConstantBuffer reductionConstants; 135 | 136 | public: 137 | 138 | struct ShadowConstants 139 | { 140 | Float4Align Float4x4 ShadowMatrix; 141 | Float4Align float CascadeSplits[NumCascades]; 142 | 143 | Float4Align Float4 CascadeOffsets[NumCascades]; 144 | Float4Align Float4 CascadeScales[NumCascades]; 145 | 146 | float PositiveExponent; 147 | float NegativeExponent; 148 | float LightBleedingReduction; 149 | }; 150 | 151 | ConstantBuffer shadowConstants; 152 | RenderTarget2D sunVSM; 153 | }; -------------------------------------------------------------------------------- /LowResRendering/PostProcessing.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Low-Resolution Rendering Sample 4 | // by MJP 5 | // http://mynameismjp.wordpress.com/ 6 | // 7 | // All code and content licensed under the MIT license 8 | // 9 | //================================================================================================= 10 | 11 | #include 12 | #include 13 | #include "AppSettings.hlsl" 14 | 15 | //================================================================================================= 16 | // Helper Functions 17 | //================================================================================================= 18 | 19 | // Calculates the gaussian blur weight for a given distance and sigmas 20 | float CalcGaussianWeight(int sampleDist, float sigma) 21 | { 22 | float g = 1.0f / sqrt(2.0f * 3.14159 * sigma * sigma); 23 | return (g * exp(-(sampleDist * sampleDist) / (2 * sigma * sigma))); 24 | } 25 | 26 | // Performs a gaussian blur in one direction 27 | float4 Blur(in PSInput input, float2 texScale, float sigma, bool nrmlize) 28 | { 29 | float4 color = 0; 30 | float weightSum = 0.0f; 31 | for(int i = -7; i < 7; i++) 32 | { 33 | float weight = CalcGaussianWeight(i, sigma); 34 | weightSum += weight; 35 | float2 texCoord = input.TexCoord; 36 | texCoord += (i / InputSize0) * texScale; 37 | float4 sample = InputTexture0.Sample(PointSampler, texCoord); 38 | color += sample * weight; 39 | } 40 | 41 | if(nrmlize) 42 | color /= weightSum; 43 | 44 | return color; 45 | } 46 | 47 | // Applies the approximated version of HP Duiker's film stock curve 48 | float3 ToneMapFilmicALU(in float3 color) 49 | { 50 | color = max(0, color - 0.004f); 51 | color = (color * (6.2f * color + 0.5f)) / (color * (6.2f * color + 1.7f)+ 0.06f); 52 | return color; 53 | } 54 | 55 | // ================================================================================================ 56 | // Shader Entry Points 57 | // ================================================================================================ 58 | 59 | Texture2D BloomInput : register(t0); 60 | 61 | // Initial pass for bloom 62 | float4 Bloom(in PSInput input) : SV_Target 63 | { 64 | float4 reds = BloomInput.GatherRed(LinearSampler, input.TexCoord); 65 | float4 greens = BloomInput.GatherGreen(LinearSampler, input.TexCoord); 66 | float4 blues = BloomInput.GatherBlue(LinearSampler, input.TexCoord); 67 | 68 | float3 result = 0.0f; 69 | 70 | [unroll] 71 | for(uint i = 0; i < 4; ++i) 72 | { 73 | float3 color = float3(reds[i], greens[i], blues[i]); 74 | 75 | result += color; 76 | } 77 | 78 | result /= 4.0f; 79 | 80 | return float4(result, 1.0f); 81 | } 82 | 83 | // Uses hw bilinear filtering for upscaling or downscaling 84 | float4 Scale(in PSInput input) : SV_Target 85 | { 86 | return InputTexture0.Sample(PointSampler, input.TexCoord); 87 | } 88 | 89 | // Horizontal gaussian blur 90 | float4 BlurH(in PSInput input) : SV_Target 91 | { 92 | return Blur(input, float2(1, 0), BloomBlurSigma, false); 93 | } 94 | 95 | // Vertical gaussian blur 96 | float4 BlurV(in PSInput input) : SV_Target 97 | { 98 | return Blur(input, float2(0, 1), BloomBlurSigma, false); 99 | } 100 | 101 | // Applies exposure and tone mapping to the input 102 | float4 ToneMap(in PSInput input) : SV_Target0 103 | { 104 | // Tone map the primary input 105 | float3 color = InputTexture0.Sample(PointSampler, input.TexCoord).rgb; 106 | if(ShowMSAAEdges == false) 107 | color += InputTexture1.Sample(LinearSampler, input.TexCoord).xyz * BloomMagnitude * exp2(BloomExposure); 108 | 109 | color *= exp2(-16.0f) / ExposureRangeScale; 110 | color = ToneMapFilmicALU(color); 111 | 112 | return float4(color, 1.0f); 113 | } -------------------------------------------------------------------------------- /LowResRendering/PostProcessor.cpp: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Low-Resolution Rendering Sample 4 | // by MJP 5 | // http://mynameismjp.wordpress.com/ 6 | // 7 | // All code and content licensed under the MIT license 8 | // 9 | //================================================================================================= 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "PostProcessor.h" 19 | #include "SharedConstants.h" 20 | 21 | // Constants 22 | static const uint32 TGSize = 16; 23 | static const uint32 LumMapSize = 1024; 24 | 25 | void PostProcessor::Initialize(ID3D11Device* device) 26 | { 27 | PostProcessorBase::Initialize(device); 28 | 29 | // Load the shaders 30 | toneMap = CompilePSFromFile(device, L"PostProcessing.hlsl", "ToneMap"); 31 | scale = CompilePSFromFile(device, L"PostProcessing.hlsl", "Scale"); 32 | blurH = CompilePSFromFile(device, L"PostProcessing.hlsl", "BlurH"); 33 | blurV = CompilePSFromFile(device, L"PostProcessing.hlsl", "BlurV"); 34 | bloom = CompilePSFromFile(device, L"PostProcessing.hlsl", "Bloom"); 35 | } 36 | 37 | void PostProcessor::AfterReset(uint32 width, uint32 height) 38 | { 39 | PostProcessorBase::AfterReset(width, height); 40 | } 41 | 42 | void PostProcessor::Render(ID3D11DeviceContext* deviceContext, ID3D11ShaderResourceView* input, 43 | ID3D11ShaderResourceView* depthBuffer, const Camera& camera, 44 | ID3D11RenderTargetView* output, float deltaSeconds) 45 | { 46 | PostProcessorBase::Render(deviceContext, input, output); 47 | 48 | TempRenderTarget* bloom = Bloom(input); 49 | 50 | // Apply tone mapping 51 | ToneMap(input, bloom->SRView, output); 52 | 53 | bloom->InUse = false; 54 | 55 | // Check for leaked temp render targets 56 | for(uint64 i = 0; i < tempRenderTargets.size(); ++i) 57 | Assert_(tempRenderTargets[i]->InUse == false); 58 | } 59 | 60 | TempRenderTarget* PostProcessor::Bloom(ID3D11ShaderResourceView* input) 61 | { 62 | PIXEvent pixEvent(L"Bloom"); 63 | 64 | TempRenderTarget* downscale1 = GetTempRenderTarget(inputWidth / 2, inputHeight / 2, DXGI_FORMAT_R16G16B16A16_FLOAT); 65 | inputs.push_back(input); 66 | outputs.push_back(downscale1->RTView); 67 | PostProcess(bloom, L"Bloom Initial Pass"); 68 | 69 | // Blur it 70 | for(uint64 i = 0; i < 2; ++i) 71 | { 72 | TempRenderTarget* blurTemp = GetTempRenderTarget(inputWidth / 2, inputHeight / 2, DXGI_FORMAT_R16G16B16A16_FLOAT); 73 | PostProcess(downscale1->SRView, blurTemp->RTView, blurH, L"Horizontal Bloom Blur"); 74 | 75 | PostProcess(blurTemp->SRView, downscale1->RTView, blurV, L"Vertical Bloom Blur"); 76 | blurTemp->InUse = false; 77 | } 78 | 79 | return downscale1; 80 | } 81 | 82 | void PostProcessor::ToneMap(ID3D11ShaderResourceView* input, 83 | ID3D11ShaderResourceView* bloom, 84 | ID3D11RenderTargetView* output) 85 | { 86 | // Use an intermediate render target so that we can render do sRGB conversion ourselves in the shader 87 | TempRenderTarget* tmOutput = GetTempRenderTarget(inputWidth, inputHeight, DXGI_FORMAT_R8G8B8A8_UNORM); 88 | 89 | inputs.push_back(input); 90 | inputs.push_back(bloom); 91 | outputs.push_back(tmOutput->RTView); 92 | 93 | PostProcess(toneMap, L"Tone Mapping"); 94 | 95 | ID3D11ResourcePtr outputResource; 96 | output->GetResource(&outputResource); 97 | 98 | context->CopyResource(outputResource, tmOutput->Texture); 99 | 100 | tmOutput->InUse = false; 101 | } -------------------------------------------------------------------------------- /LowResRendering/PostProcessor.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Low-Resolution Rendering Sample 4 | // by MJP 5 | // http://mynameismjp.wordpress.com/ 6 | // 7 | // All code and content licensed under the MIT license 8 | // 9 | //================================================================================================= 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "AppSettings.h" 19 | 20 | using namespace SampleFramework11; 21 | 22 | namespace SampleFramework11 23 | { 24 | class Camera; 25 | } 26 | 27 | class PostProcessor : public PostProcessorBase 28 | { 29 | 30 | public: 31 | 32 | void Initialize(ID3D11Device* device); 33 | 34 | void Render(ID3D11DeviceContext* deviceContext, ID3D11ShaderResourceView* input, 35 | ID3D11ShaderResourceView* depthBuffer, const Camera& camera, 36 | ID3D11RenderTargetView* output, float deltaSeconds); 37 | void AfterReset(UINT width, UINT height); 38 | 39 | protected: 40 | 41 | void CalcAvgLuminance(ID3D11ShaderResourceView* input); 42 | TempRenderTarget* Bloom(ID3D11ShaderResourceView* input); 43 | void ToneMap(ID3D11ShaderResourceView* input, 44 | ID3D11ShaderResourceView* bloom, 45 | ID3D11RenderTargetView* output); 46 | 47 | PixelShaderPtr toneMap; 48 | PixelShaderPtr scale; 49 | PixelShaderPtr bloom; 50 | PixelShaderPtr blurH; 51 | PixelShaderPtr blurV; 52 | }; -------------------------------------------------------------------------------- /LowResRendering/Shadows.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Low-Resolution Rendering Sample 4 | // by MJP 5 | // http://mynameismjp.wordpress.com/ 6 | // 7 | // All code and content licensed under the MIT license 8 | // 9 | //================================================================================================= 10 | 11 | #include "EVSM.hlsl" 12 | 13 | //================================================================================================= 14 | // Constants 15 | //================================================================================================= 16 | static const uint NumCascades = 4; 17 | 18 | cbuffer ShadowConstants : register(b1) 19 | { 20 | float4x4 ShadowMatrix; 21 | float4 CascadeSplits; 22 | float4 CascadeOffsets[NumCascades]; 23 | float4 CascadeScales[NumCascades]; 24 | float PositiveExponent; 25 | float NegativeExponent; 26 | float LightBleedingReduction; 27 | } 28 | 29 | //------------------------------------------------------------------------------------------------- 30 | // Samples the EVSM shadow map 31 | //------------------------------------------------------------------------------------------------- 32 | float SampleShadowMapEVSM(in float3 shadowPos, in float3 shadowPosDX, 33 | in float3 shadowPosDY, in uint cascadeIdx, 34 | in Texture2DArray sunShadowMap, in SamplerState evsmSampler) 35 | { 36 | float2 exponents = GetEVSMExponents(PositiveExponent, NegativeExponent, 37 | CascadeScales[cascadeIdx].xyz); 38 | float2 warpedDepth = WarpDepth(shadowPos.z, exponents); 39 | 40 | float4 occluder = sunShadowMap.SampleGrad(evsmSampler, float3(shadowPos.xy, cascadeIdx), 41 | shadowPosDX.xy, shadowPosDY.xy); 42 | 43 | // Derivative of warping at depth 44 | float2 depthScale = 0.0001f * exponents * warpedDepth; 45 | float2 minVariance = depthScale * depthScale; 46 | 47 | float posContrib = ChebyshevUpperBound(occluder.xz, warpedDepth.x, minVariance.x, LightBleedingReduction); 48 | float negContrib = ChebyshevUpperBound(occluder.yw, warpedDepth.y, minVariance.y, LightBleedingReduction); 49 | float shadowContrib = posContrib; 50 | shadowContrib = min(shadowContrib, negContrib); 51 | 52 | return shadowContrib; 53 | } 54 | 55 | //------------------------------------------------------------------------------------------------- 56 | // Samples the appropriate shadow map cascade 57 | //------------------------------------------------------------------------------------------------- 58 | float3 SampleShadowCascade(in float3 shadowPosition, in float3 shadowPosDX, 59 | in float3 shadowPosDY, in uint cascadeIdx, 60 | in Texture2DArray sunShadowMap, in SamplerState evsmSampler) 61 | { 62 | shadowPosition += CascadeOffsets[cascadeIdx].xyz; 63 | shadowPosition *= CascadeScales[cascadeIdx].xyz; 64 | 65 | shadowPosDX *= CascadeScales[cascadeIdx].xyz; 66 | shadowPosDY *= CascadeScales[cascadeIdx].xyz; 67 | 68 | float3 cascadeColor = 1.0f; 69 | 70 | float shadow = SampleShadowMapEVSM(shadowPosition, shadowPosDX, shadowPosDY, cascadeIdx, sunShadowMap, evsmSampler); 71 | 72 | return shadow * cascadeColor; 73 | } 74 | 75 | //-------------------------------------------------------------------------------------- 76 | // Computes the sun visibility term by performing the shadow test 77 | //-------------------------------------------------------------------------------------- 78 | float3 SunShadowVisibility(in float3 positionWS, in float depthVS, 79 | in Texture2DArray sunShadowMap, in SamplerState evsmSampler) 80 | { 81 | float3 shadowVisibility = 1.0f; 82 | uint cascadeIdx = 0; 83 | 84 | // Project into shadow space 85 | float3 samplePos = positionWS; 86 | float3 shadowPosition = mul(float4(samplePos, 1.0f), ShadowMatrix).xyz; 87 | float3 shadowPosDX = ddx(shadowPosition); 88 | float3 shadowPosDY = ddy(shadowPosition); 89 | 90 | // Figure out which cascade to sample from 91 | [unroll] 92 | for(uint i = 0; i < NumCascades - 1; ++i) 93 | { 94 | [flatten] 95 | if(depthVS > CascadeSplits[i]) 96 | cascadeIdx = i + 1; 97 | } 98 | 99 | shadowVisibility = SampleShadowCascade(shadowPosition, shadowPosDX, shadowPosDY, 100 | cascadeIdx, sunShadowMap, evsmSampler); 101 | 102 | return shadowVisibility; 103 | } -------------------------------------------------------------------------------- /LowResRendering/SharedConstants.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Low-Resolution Rendering Sample 4 | // by MJP 5 | // http://mynameismjp.wordpress.com/ 6 | // 7 | // All code and content licensed under the MIT license 8 | // 9 | //================================================================================================= 10 | 11 | #if _WINDOWS 12 | 13 | #pragma once 14 | 15 | typedef SampleFramework11::Float2 float2; 16 | typedef SampleFramework11::Float3 float3; 17 | typedef SampleFramework11::Float4 float4; 18 | 19 | typedef uint32 uint; 20 | typedef SampleFramework11::Uint2 uint2; 21 | typedef SampleFramework11::Uint3 uint3; 22 | typedef SampleFramework11::Uint4 uint4; 23 | 24 | #endif 25 | 26 | static const uint ReductionTGSize = 16; 27 | 28 | struct ParticleData 29 | { 30 | float3 Position; 31 | float Size; 32 | float Opacity; 33 | float Lifetime; 34 | }; -------------------------------------------------------------------------------- /LowResRendering/project.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "folders": 3 | [ 4 | { 5 | "path": "/", 6 | "name": "Local", 7 | "file_exclude_patterns": ["*.sln", "*.vcxproj", "*.filters", "*.rc", "*.props", "*.user", "*.opensdf", "*.ico"], 8 | "folder_exclude_patterns": ["Debug", "Release", "bin", "obj", "Properties", "ipch", "x64", "ShaderCache"] 9 | }, 10 | { 11 | "path": "../SampleFramework11/v1.01/", 12 | "name": "SampleFramework", 13 | "file_exclude_patterns": ["*.sln", "*.vcxproj", "*.filters", "*.rc", "*.props", "*.user", "*.opensdf", "*.ico"], 14 | "folder_exclude_patterns": ["Debug", "Release", "bin", "obj", "Properties", "ipch", "x64"] 15 | }, 16 | { 17 | "path": "../Externals/", 18 | "name": "Externals", 19 | "file_exclude_patterns": ["*.sln", "*.vcxproj", "*.filters", "*.rc", "*.props", "*.user", "*.opensdf", "*.ico", "*.lib", "*.dll", "*.pdb"], 20 | "folder_exclude_patterns": ["Debug", "Release", "x64", "obj", "Properties", "ipch", "x64", "Lib*", "bin"] 21 | } 22 | ], 23 | "settings": 24 | { 25 | "tab_size": 4, 26 | "translate_tabs_to_spaces": true, 27 | "trim_trailing_white_space_on_save": true 28 | } 29 | } -------------------------------------------------------------------------------- /LowResRendering/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by SampleTest.rc 4 | // 5 | #define IDD_DIALOG1 101 6 | #define IDI_ICON 102 7 | #define IDI_DEFAULT 102 8 | 9 | // Next default values for new objects 10 | // 11 | #ifdef APSTUDIO_INVOKED 12 | #ifndef APSTUDIO_READONLY_SYMBOLS 13 | #define _APS_NEXT_RESOURCE_VALUE 103 14 | #define _APS_NEXT_COMMAND_VALUE 40001 15 | #define _APS_NEXT_CONTROL_VALUE 1001 16 | #define _APS_NEXT_SYMED_VALUE 101 17 | #endif 18 | #endif 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Low-Resolution Rendering Sample 2 | 3 | This is a D3D11 sample project that demonstrates a technique for using MSAA to render transparents at half resolution. Using MSAA effectively allows shading at a low resolution, while still rasterizing and depth testing at full resolution. This helps reduce haloing and other artifacts commonly associated with low-resolution transparents. The sample also implements nearest-depth upsampling as well as full-resolution rendering for comparison. 4 | 5 | To make sure that the low-resolution MSAA sample points line up with the sample points from the full-resolution render target, the sample makes use of the programmable sample point functionality found in Nvidia's second generation Maxwell GPU's. This is done by using the D3D11 driver extensions exposed through Nvidia's properietary NVAPI. If you don't have an Nvidia GPU, or you have an Nvidia GPU that doesn't support programmable sample points, the sample will automatically disable the functionality and remove the corresponding UI. 6 | 7 | This code sample was done as part of an article for my blog, which you can find here: [http://mynameismjp.wordpress.com/2015/09/13/programmable-sample-points/](http://mynameismjp.wordpress.com/2015/09/13/programmable-sample-points/) 8 | 9 | # Build Instructions 10 | 11 | The repository contains a Visual Studio 2013 project and solution file that's ready to build on Windows. All external dependencies are included in the repository, with the exception of NVAPI, which is excluded due to its licensing terms. This means that if you clone the repo and build the project as-is, you'll get the following error: 12 | 13 | `Cannot open include file: '../Externals/NVAPI-352/nvapi.h': No such file or directory` 14 | 15 | To build with NVAPI, you'll need to download it from [Nvidia's developer website](https://developer.nvidia.com/nvapi), and unzip the file into Externals\NVAPI-352. If you already have it somewhere else, you can change the path to the include and the lib at the top of LowResRendering.cpp. Alternatively, you can also disable NVAPI entirely by defining "UseNVAPI_" to 0 at the top of LowResRendering.cpp. 16 | 17 | -------------------------------------------------------------------------------- /SampleFramework11/v1.01/App.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #pragma once 11 | 12 | #include "PCH.h" 13 | 14 | #include "Window.h" 15 | #include "Graphics\\DeviceManager.h" 16 | #include "Graphics\\DeviceStates.h" 17 | #include "Timer.h" 18 | #include "Graphics\\SpriteFont.h" 19 | #include "Graphics\\SpriteRenderer.h" 20 | 21 | namespace SampleFramework11 22 | { 23 | 24 | class App 25 | { 26 | 27 | public: 28 | 29 | App(const wchar* appName, const wchar* iconResource = NULL); 30 | virtual ~App(); 31 | 32 | int32 Run(); 33 | 34 | void RenderText(const std::wstring& text, Float2 pos); 35 | void RenderCenteredText(const std::wstring& text); 36 | 37 | protected: 38 | 39 | virtual void Initialize(); 40 | virtual void Update(const Timer& timer) = 0; 41 | virtual void Render(const Timer& timer) = 0; 42 | 43 | virtual void BeforeReset(); 44 | virtual void AfterReset(); 45 | 46 | void Exit(); 47 | void ToggleFullScreen(bool fullScreen); 48 | void CalculateFPS(); 49 | 50 | static LRESULT OnWindowResized(void* context, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 51 | 52 | Window window; 53 | DeviceManager deviceManager; 54 | Timer timer; 55 | 56 | BlendStates blendStates; 57 | RasterizerStates rasterizerStates; 58 | DepthStencilStates depthStencilStates; 59 | SamplerStates samplerStates; 60 | 61 | SpriteFont font; 62 | SpriteRenderer spriteRenderer; 63 | 64 | static const uint32 NumTimeDeltaSamples = 64; 65 | float timeDeltaBuffer[NumTimeDeltaSamples]; 66 | uint32 currentTimeDeltaSample; 67 | uint32 fps; 68 | 69 | TwBar* tweakBar; 70 | 71 | std::wstring applicationName; 72 | std::string globalHelpText = "MJPs sample framework for DX11"; 73 | 74 | bool createConsole; 75 | bool showWindow; 76 | int32 returnCode; 77 | 78 | public: 79 | 80 | // Accessors 81 | Window& Window() { return window; } 82 | DeviceManager& DeviceManager() { return deviceManager; } 83 | SpriteFont& Font() { return font; } 84 | SpriteRenderer& SpriteRenderer() { return spriteRenderer; } 85 | TwBar* TweakBar() { return tweakBar; } 86 | }; 87 | 88 | extern App* GlobalApp; 89 | 90 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Assert.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, Power of Two Games LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Power of Two Games LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY POWER OF TWO GAMES LLC ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL POWER OF TWO GAMES LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "PCH.h" 29 | 30 | #include "Assert.h" 31 | 32 | namespace pow2 33 | { 34 | 35 | namespace 36 | { 37 | 38 | Assert::FailBehavior DefaultHandler(const char* condition, 39 | const char* msg, 40 | const char* file, 41 | const int line) 42 | { 43 | const uint64 BufferSize = 2048; 44 | char buffer[BufferSize]; 45 | sprintf_s(buffer, BufferSize, "%s(%d): Assert Failure: ", file, line); 46 | 47 | if(condition != NULL) 48 | sprintf_s(buffer, BufferSize, "%s'%s' ", buffer, condition); 49 | 50 | if(msg != NULL) 51 | sprintf_s(buffer, BufferSize, "%s%s", buffer, msg); 52 | 53 | sprintf_s(buffer, BufferSize, "%s\n", buffer); 54 | 55 | OutputDebugStringA(buffer); 56 | 57 | return Assert::Halt; 58 | } 59 | 60 | Assert::Handler& GetAssertHandlerInstance() 61 | { 62 | static Assert::Handler s_handler = &DefaultHandler; 63 | return s_handler; 64 | } 65 | 66 | } 67 | 68 | Assert::Handler Assert::GetHandler() 69 | { 70 | return GetAssertHandlerInstance(); 71 | } 72 | 73 | void Assert::SetHandler(Assert::Handler newHandler) 74 | { 75 | GetAssertHandlerInstance() = newHandler; 76 | } 77 | 78 | Assert::FailBehavior Assert::ReportFailure(const char* condition, 79 | const char* file, 80 | const int line, 81 | const char* msg, ...) 82 | { 83 | const char* message = NULL; 84 | if (msg != NULL) 85 | { 86 | char messageBuffer[1024]; 87 | { 88 | va_list args; 89 | va_start(args, msg); 90 | vsnprintf_s(messageBuffer, 1024, 1024, msg, args); 91 | va_end(args); 92 | } 93 | 94 | message = messageBuffer; 95 | } 96 | 97 | return GetAssertHandlerInstance()(condition, message, file, line); 98 | } 99 | 100 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, Power of Two Games LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Power of Two Games LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY POWER OF TWO GAMES LLC ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL POWER OF TWO GAMES LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #pragma once 29 | 30 | #define POW2_ASSERTS_ENABLED 31 | 32 | namespace pow2 { namespace Assert 33 | { 34 | enum FailBehavior 35 | { 36 | Halt, 37 | Continue, 38 | }; 39 | 40 | typedef FailBehavior (*Handler)(const char* condition, 41 | const char* msg, 42 | const char* file, 43 | int line); 44 | 45 | Handler GetHandler(); 46 | void SetHandler(Handler newHandler); 47 | 48 | FailBehavior ReportFailure(const char* condition, 49 | const char* file, 50 | int line, 51 | const char* msg, ...); 52 | }} 53 | 54 | #define POW2_HALT() __debugbreak() 55 | #define POW2_UNUSED(x) do { (void)sizeof(x); } while(0) 56 | 57 | #ifdef POW2_ASSERTS_ENABLED 58 | #define POW2_ASSERT(cond) \ 59 | do \ 60 | { \ 61 | if (!(cond)) \ 62 | { \ 63 | if (pow2::Assert::ReportFailure(#cond, __FILE__, __LINE__, 0) == \ 64 | pow2::Assert::Halt) \ 65 | POW2_HALT(); \ 66 | } \ 67 | } while(0) 68 | 69 | #define POW2_ASSERT_MSG(cond, msg, ...) \ 70 | do \ 71 | { \ 72 | if (!(cond)) \ 73 | { \ 74 | if (pow2::Assert::ReportFailure(#cond, __FILE__, __LINE__, (msg), __VA_ARGS__) == \ 75 | pow2::Assert::Halt) \ 76 | POW2_HALT(); \ 77 | } \ 78 | } while(0) 79 | 80 | #define POW2_ASSERT_FAIL(msg, ...) \ 81 | do \ 82 | { \ 83 | if (pow2::Assert::ReportFailure(0, __FILE__, __LINE__, (msg), __VA_ARGS__) == \ 84 | pow2::Assert::Halt) \ 85 | POW2_HALT(); \ 86 | } while(0) 87 | 88 | #define POW2_VERIFY(cond) POW2_ASSERT(cond) 89 | #define POW2_VERIFY_MSG(cond, msg, ...) POW2_ASSERT_MSG(cond, msg, ##__VA_ARGS__) 90 | #else 91 | #define POW2_ASSERT(condition) \ 92 | do { POW2_UNUSED(condition); } while(0) 93 | #define POW2_ASSERT_MSG(condition, msg, ...) \ 94 | do { POW2_UNUSED(condition); POW2_UNUSED(msg); } while(0) 95 | #define POW2_ASSERT_FAIL(msg, ...) \ 96 | do { POW2_UNUSED(msg); } while(0) 97 | #define POW2_VERIFY(cond) (void)(cond) 98 | #define POW2_VERIFY_MSG(cond, msg, ...) \ 99 | do { (void)(cond); POW2_UNUSED(msg); } while(0) 100 | #endif 101 | 102 | // SampleFramework11 Asserts 103 | #ifdef _DEBUG 104 | #define UseAsserts_ 1 105 | #else 106 | #define UseAsserts_ 0 107 | #endif 108 | 109 | #if UseAsserts_ 110 | #define Assert_(x) POW2_ASSERT(x) 111 | #define AssertMsg_(x, msg, ...) POW2_ASSERT_MSG(x, msg, __VA_ARGS__) 112 | #define AssertFail_(msg, ...) POW2_ASSERT_FAIL(msg, __VA_ARGS__) 113 | #else 114 | #define Assert_(x) 115 | #define AssertMsg_(x, msg, ...) 116 | #define AssertFail_(msg, ...) 117 | #endif 118 | 119 | #define UseStaticAsserts_ 1 120 | 121 | #if UseStaticAsserts_ 122 | #define StaticAssert_(x) static_assert(x, #x); 123 | #define StaticAssertMsg_(x, msg) static_assert(x, #x ", " msg); 124 | #else 125 | #define StaticAssert_(x) 126 | #define StaticAssertMsg_(x, msg) 127 | #endif 128 | -------------------------------------------------------------------------------- /SampleFramework11/v1.01/FileIO.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #pragma once 11 | 12 | #include "PCH.h" 13 | 14 | #include "Exceptions.h" 15 | #include "Utility.h" 16 | 17 | namespace SampleFramework11 18 | { 19 | 20 | // Utility functions 21 | bool FileExists(const wchar* filePath); 22 | bool DirectoryExists(const wchar* dirPath); 23 | std::wstring GetDirectoryFromFilePath(const wchar* filePath); 24 | std::wstring GetFileName(const wchar* filePath); 25 | std::wstring GetFileNameWithoutExtension(const wchar* filePath); 26 | std::wstring GetFilePathWithoutExtension(const wchar* filePath); 27 | std::wstring GetFileExtension(const wchar* filePath); 28 | uint64 GetFileTimestamp(const wchar* filePath); 29 | 30 | std::string ReadFileAsString(const wchar* filePath); 31 | void WriteStringAsFile(const wchar* filePath, const std::string& data); 32 | 33 | enum class FileOpenMode 34 | { 35 | Read = 0, 36 | Write = 1, 37 | }; 38 | 39 | class File 40 | { 41 | 42 | private: 43 | 44 | HANDLE fileHandle; 45 | FileOpenMode openMode; 46 | 47 | public: 48 | 49 | // Lifetime 50 | File(); 51 | File(const wchar* filePath, FileOpenMode openMode); 52 | ~File(); 53 | 54 | // Explicit Open and close 55 | void Open(const wchar* filePath, FileOpenMode openMode); 56 | void Close(); 57 | 58 | // I/O 59 | void Read(uint64 size, void* data) const; 60 | void Write(uint64 size, const void* data) const; 61 | 62 | template void Read(T& data) const; 63 | template void Write(const T& data) const; 64 | 65 | // Accessors 66 | uint64 Size() const; 67 | }; 68 | 69 | // == File ======================================================================================== 70 | 71 | template void File::Read(T& data) const 72 | { 73 | Read(sizeof(T), &data); 74 | } 75 | 76 | template void File::Write(const T& data) const 77 | { 78 | Write(sizeof(T), &data); 79 | } 80 | 81 | // Templated helper functions 82 | 83 | // Reads a POD type from a file 84 | template void ReadFromFile(const wchar* fileName, T& val) 85 | { 86 | File file(fileName, File::OpenRead); 87 | file.Read(val); 88 | } 89 | 90 | // Writes a POD type to a file 91 | template void WriteToFile(const wchar* fileName, const T& val) 92 | { 93 | File file(fileName, File::OpenWrite); 94 | file.Write(val); 95 | } 96 | 97 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Graphics/BRDF.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #include "..\\PCH.h" 11 | #include "..\\SF11_Math.h" 12 | 13 | namespace SampleFramework11 14 | { 15 | 16 | // Calculates the Fresnel factor using Schlick's approximation 17 | inline Float3 Fresnel(Float3 specAlbedo, Float3 h, Float3 l) 18 | { 19 | Float3 fresnel = specAlbedo + (Float3(1.0f) - specAlbedo) * std::pow((1.0f - Saturate(Float3::Dot(l, h))), 5.0f); 20 | 21 | // Fade out spec entirely when lower than 0.1% albedo 22 | fresnel *= Saturate(Float3::Dot(specAlbedo, 333.0f)); 23 | 24 | return fresnel; 25 | } 26 | 27 | // Calculates the Fresnel factor using Schlick's approximation 28 | inline Float3 Fresnel(Float3 specAlbedo, Float3 fresnelAlbedo, Float3 h, Float3 l) 29 | { 30 | Float3 fresnel = specAlbedo + (fresnelAlbedo - specAlbedo) * std::pow((1.0f - Saturate(Float3::Dot(l, h))), 5.0f); 31 | 32 | // Fade out spec entirely when lower than 0.1% albedo 33 | fresnel *= Saturate(Float3::Dot(specAlbedo, 333.0f)); 34 | 35 | return fresnel; 36 | } 37 | 38 | // Helper for computing the GGX visibility term 39 | inline float GGX_V1(float m2, float nDotX) 40 | { 41 | return 1.0f / (nDotX + sqrt(m2 + (1 - m2) * nDotX * nDotX)); 42 | } 43 | 44 | // Computes the specular term using a GGX microfacet distribution, with a matching 45 | // geometry factor and visibility term. Based on "Microfacet Models for Refraction Through 46 | // Rough Surfaces" [Walter 07]. m is roughness, n is the surface normal, h is the half vector, 47 | // l is the direction to the light source, and specAlbedo is the RGB specular albedo 48 | inline float GGX_Specular(float m, const Float3& n, const Float3& h, const Float3& v, const Float3& l) 49 | { 50 | float nDotH = Saturate(Float3::Dot(n, h)); 51 | float nDotL = Saturate(Float3::Dot(n, l)); 52 | float nDotV = Saturate(Float3::Dot(n, v)); 53 | 54 | float nDotH2 = nDotH * nDotH; 55 | float m2 = m * m; 56 | 57 | // Calculate the distribution term 58 | float d = m2 / (Pi * Square(nDotH * nDotH * (m2 - 1) + 1)); 59 | 60 | // Calculate the matching visibility term 61 | float v1i = GGX_V1(m2, nDotL); 62 | float v1o = GGX_V1(m2, nDotV); 63 | float vis = v1i * v1o; 64 | 65 | return d * vis; 66 | } 67 | // Computes the radiance reflected off a surface towards the eye given 68 | // the differential irradiance from a given direction 69 | inline Float3 CalcLighting(const Float3& normal, const Float3& lightIrradiance, 70 | const Float3& lightDir, const Float3& diffuseAlbedo, const Float3& position, 71 | const Float3& cameraPos, float roughness, bool includeSpecular, Float3 specAlbedo) 72 | { 73 | Float3 lighting = diffuseAlbedo * InvPi; 74 | 75 | if(includeSpecular && Float3::Dot(normal, lightDir) > 0.0f) 76 | { 77 | Float3 view = Float3::Normalize(cameraPos - position); 78 | const float nDotV = Saturate(Float3::Dot(normal, view)); 79 | Float3 h = Float3::Normalize(view + lightDir); 80 | 81 | Float3 fresnel = Fresnel(specAlbedo, h, lightDir); 82 | 83 | float specular = GGX_Specular(roughness, normal, h, view, lightDir); 84 | lighting += specular * fresnel; 85 | } 86 | 87 | return lighting * lightIrradiance; 88 | } 89 | 90 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Graphics/Camera.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #pragma once 11 | 12 | #include "..\\PCH.h" 13 | #include "..\\SF11_Math.h" 14 | 15 | namespace SampleFramework11 16 | { 17 | 18 | // Abstract base class for camera types 19 | class Camera 20 | { 21 | 22 | protected: 23 | 24 | Float4x4 view; 25 | Float4x4 projection; 26 | Float4x4 viewProjection; 27 | 28 | Float4x4 world; 29 | Float3 position; 30 | Quaternion orientation; 31 | 32 | float nearZ; 33 | float farZ; 34 | 35 | virtual void CreateProjection() = 0; 36 | void WorldMatrixChanged(); 37 | 38 | public: 39 | 40 | Camera(float nearZ, float farZ); 41 | ~Camera(); 42 | 43 | const Float4x4& ViewMatrix() const { return view; }; 44 | const Float4x4& ProjectionMatrix() const { return projection; }; 45 | const Float4x4& ViewProjectionMatrix() const { return viewProjection; }; 46 | const Float4x4& WorldMatrix() const { return world; }; 47 | const Float3& Position() const { return position; }; 48 | const Quaternion& Orientation() const { return orientation; }; 49 | const float& NearClip() const { return nearZ; }; 50 | const float& FarClip() const { return farZ; }; 51 | 52 | Float3 Forward() const; 53 | Float3 Back() const; 54 | Float3 Up() const; 55 | Float3 Down() const; 56 | Float3 Right() const; 57 | Float3 Left() const; 58 | 59 | void SetLookAt(const Float3& eye, const Float3& lookAt, const Float3& up); 60 | void SetWorldMatrix(const Float4x4& newWorld); 61 | void SetPosition(const Float3& newPosition); 62 | void SetOrientation(const Quaternion& newOrientation); 63 | void SetNearClip(float newNearClip); 64 | void SetFarClip(float newFarClip); 65 | void SetProjection(const Float4x4& newProjection); 66 | }; 67 | 68 | // Camera with an orthographic projection 69 | class OrthographicCamera : public Camera 70 | { 71 | 72 | protected: 73 | 74 | float xMin; 75 | float xMax; 76 | float yMin; 77 | float yMax; 78 | 79 | virtual void CreateProjection() override; 80 | 81 | public: 82 | 83 | OrthographicCamera(float minX, float minY, float maxX, float maxY, float nearClip, float farClip); 84 | ~OrthographicCamera(); 85 | 86 | float MinX() const { return xMin; }; 87 | float MinY() const { return yMin; }; 88 | float MaxX() const { return xMax; }; 89 | float MaxY() const { return yMax; }; 90 | 91 | void SetMinX(float minX); 92 | void SetMinY(float minY); 93 | void SetMaxX(float maxX); 94 | void SetMaxY(float maxY); 95 | }; 96 | 97 | // Camera with a perspective projection 98 | class PerspectiveCamera : public Camera 99 | { 100 | 101 | protected: 102 | 103 | float aspect; 104 | float fov; 105 | 106 | virtual void CreateProjection() override; 107 | 108 | public: 109 | 110 | PerspectiveCamera(float aspectRatio, float fieldOfView, float nearClip, float farClip); 111 | ~PerspectiveCamera(); 112 | 113 | float AspectRatio() const { return aspect; }; 114 | float FieldOfView() const { return fov; }; 115 | 116 | void SetAspectRatio(float aspectRatio); 117 | void SetFieldOfView(float fieldOfView); 118 | }; 119 | 120 | // Perspective camera that rotates about Z and Y axes 121 | class FirstPersonCamera : public PerspectiveCamera 122 | { 123 | 124 | protected: 125 | 126 | float xRot; 127 | float yRot; 128 | 129 | public: 130 | 131 | FirstPersonCamera(float aspectRatio = 16.0f / 9.0f, float fieldOfView = Pi_4, float nearClip = 0.01f, float farClip = 100.0f); 132 | ~FirstPersonCamera(); 133 | 134 | float XRotation() const { return xRot; }; 135 | float YRotation() const { return yRot; }; 136 | 137 | void SetXRotation(float xRotation); 138 | void SetYRotation(float yRotation); 139 | }; 140 | 141 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Graphics/DXErr.h: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // File: DXErr.h 3 | // 4 | // DirectX Error Library 5 | // 6 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 7 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 8 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 9 | // PARTICULAR PURPOSE. 10 | // 11 | // Copyright (c) Microsoft Corporation. All rights reserved. 12 | //-------------------------------------------------------------------------------------- 13 | 14 | // This version only supports UNICODE. 15 | 16 | #pragma once 17 | 18 | #include "..\\PCH.h" 19 | 20 | //-------------------------------------------------------------------------------------- 21 | // DXGetErrorString 22 | //-------------------------------------------------------------------------------------- 23 | const wchar* WINAPI DXGetErrorStringW( _In_ HRESULT hr ); 24 | 25 | #define DXGetErrorString DXGetErrorStringW 26 | 27 | //-------------------------------------------------------------------------------------- 28 | // DXGetErrorDescription has to be modified to return a copy in a buffer rather than 29 | // the original static string. 30 | //-------------------------------------------------------------------------------------- 31 | void WINAPI DXGetErrorDescriptionW( _In_ HRESULT hr, _Out_cap_(count) wchar* desc, _In_ size_t count ); 32 | 33 | #define DXGetErrorDescription DXGetErrorDescriptionW 34 | 35 | //-------------------------------------------------------------------------------------- 36 | // DXTrace 37 | // 38 | // Desc: Outputs a formatted error message to the debug stream 39 | // 40 | // Args: wchar* strFile The current file, typically passed in using the 41 | // __FILEW__ macro. 42 | // DWORD dwLine The current line number, typically passed in using the 43 | // __LINE__ macro. 44 | // HRESULT hr An HRESULT that will be traced to the debug stream. 45 | // CHAR* strMsg A string that will be traced to the debug stream (may be NULL) 46 | // BOOL bPopMsgBox If true, then a message box will popup also containing the passed info. 47 | // 48 | // Return: The hr that was passed in. 49 | //-------------------------------------------------------------------------------------- 50 | HRESULT WINAPI DXTraceW( _In_z_ const wchar* strFile, _In_ DWORD dwLine, _In_ HRESULT hr, _In_opt_ const wchar* strMsg, _In_ bool bPopMsgBox ); 51 | 52 | #define DXTrace DXTraceW 53 | 54 | //-------------------------------------------------------------------------------------- 55 | // 56 | // Helper macros 57 | // 58 | //-------------------------------------------------------------------------------------- 59 | #if defined(DEBUG) || defined(_DEBUG) 60 | #define DXTRACE_MSG(str) DXTrace( __FILEW__, (DWORD)__LINE__, 0, str, false ) 61 | #define DXTRACE_ERR(str,hr) DXTrace( __FILEW__, (DWORD)__LINE__, hr, str, false ) 62 | #define DXTRACE_ERR_MSGBOX(str,hr) DXTrace( __FILEW__, (DWORD)__LINE__, hr, str, true ) 63 | #else 64 | #define DXTRACE_MSG(str) (0L) 65 | #define DXTRACE_ERR(str,hr) (hr) 66 | #define DXTRACE_ERR_MSGBOX(str,hr) (hr) 67 | #endif -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Graphics/DeviceManager.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #pragma once 11 | 12 | #include "..\\PCH.h" 13 | 14 | #include "..\\InterfacePointers.h" 15 | #include "GraphicsTypes.h" 16 | 17 | namespace SampleFramework11 18 | { 19 | 20 | class DeviceManager 21 | { 22 | 23 | public: 24 | 25 | DeviceManager(); 26 | ~DeviceManager(); 27 | 28 | void Initialize(HWND outputWindow); 29 | void Reset(); 30 | void Present(); 31 | 32 | // Getters 33 | ID3D11Device* Device() const { return device.GetInterfacePtr(); }; 34 | ID3D11DeviceContext* ImmediateContext() const { return immediateContext.GetInterfacePtr(); }; 35 | IDXGISwapChain* SwapChain() const { return swapChain.GetInterfacePtr(); }; 36 | ID3D11RenderTargetView* BackBuffer() const { return bbRTView.GetInterfacePtr(); }; 37 | ID3D11Texture2D* BackBufferTexture() const { return bbTexture; }; 38 | D3D_FEATURE_LEVEL FeatureLevel() const { return featureLevel; }; 39 | D3D_FEATURE_LEVEL MinFeatureLevel() const { return minFeatureLevel; }; 40 | 41 | DXGI_FORMAT BackBufferFormat() const { return backBufferFormat; }; 42 | uint32 BackBufferWidth() const { return backBufferWidth; }; 43 | uint32 BackBufferHeight() const { return backBufferHeight; }; 44 | uint32 BackBufferMSCount() const { return msCount; }; 45 | uint32 BackBufferMSQuality() const { return msQuality; }; 46 | bool FullScreen() const { return fullScreen; }; 47 | bool VSYNCEnabled() const { return vsync; }; 48 | uint32 NumVSYNCIntervals() const { return numVSYNCIntervals; }; 49 | 50 | 51 | // Setters 52 | void SetBackBufferFormat(DXGI_FORMAT format) { backBufferFormat = format; }; 53 | void SetBackBufferWidth(uint32 width) { backBufferWidth = width; }; 54 | void SetBackBufferHeight(uint32 height) { backBufferHeight = height; }; 55 | void SetBackBufferMSCount(uint32 count) { msCount = count; }; 56 | void SetBackBufferMSQuality(uint32 quality) { msQuality = quality; }; 57 | void SetFullScreen(bool enabled) { fullScreen = enabled; }; 58 | void SetVSYNCEnabled(bool enabled) { vsync = enabled; }; 59 | void SetMinFeatureLevel(D3D_FEATURE_LEVEL level) { minFeatureLevel = level; }; 60 | void SetNumVSYNCIntervals(uint32 intervals) { numVSYNCIntervals = intervals; }; 61 | 62 | protected: 63 | 64 | void CheckForSuitableOutput(); 65 | void AfterReset(); 66 | void PrepareFullScreenSettings(); 67 | 68 | IDXGIFactory1Ptr factory; 69 | IDXGIAdapter1Ptr adapter; 70 | IDXGIOutputPtr output; 71 | 72 | ID3D11DevicePtr device; 73 | ID3D11DeviceContextPtr immediateContext; 74 | IDXGISwapChainPtr swapChain; 75 | ID3D11Texture2DPtr bbTexture; 76 | ID3D11RenderTargetViewPtr bbRTView; 77 | 78 | DXGI_FORMAT backBufferFormat; 79 | uint32 backBufferWidth; 80 | uint32 backBufferHeight; 81 | uint32 msCount; 82 | uint32 msQuality; 83 | bool fullScreen; 84 | bool vsync; 85 | DXGI_RATIONAL refreshRate; 86 | uint32 numVSYNCIntervals; 87 | 88 | D3D_FEATURE_LEVEL featureLevel; 89 | D3D_FEATURE_LEVEL minFeatureLevel; 90 | }; 91 | 92 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Graphics/Filtering.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #include "..\\PCH.h" 11 | #include "..\\SF11_Math.h" 12 | 13 | namespace SampleFramework11 14 | { 15 | 16 | inline float FilterBox1D(float x) 17 | { 18 | x = std::abs(x); 19 | return x <= 1.0f ? 1.0f : 0.0f; 20 | } 21 | 22 | inline float FilterBox2D(Float2 xy) 23 | { 24 | return FilterBox1D(xy.x) * FilterBox1D(xy.y); 25 | } 26 | 27 | inline float FilterCircle2D(Float2 xy) 28 | { 29 | return FilterBox1D(Float2::Length(xy)); 30 | } 31 | 32 | inline float FilterTriangle1D(float x) 33 | { 34 | x = std::abs(x); 35 | return Saturate(1.0f - std::abs(x)); 36 | } 37 | 38 | inline float FilterTriangle2D(Float2 xy) 39 | { 40 | return FilterTriangle1D(xy.x) * FilterTriangle1D(xy.y); 41 | } 42 | 43 | inline float FilterCone2D(Float2 xy) 44 | { 45 | return FilterTriangle1D(Float2::Length(xy)); 46 | } 47 | 48 | inline float FilterGaussian1D(float x, float sigma) 49 | { 50 | x = std::abs(x); 51 | const float g = 1.0f / std::sqrt(2.0f * 3.14159f * sigma * sigma); 52 | return (g * std::exp(-(x * x) / (2 * sigma * sigma))); 53 | } 54 | 55 | inline float FilterGaussian2D(Float2 xy, float sigma) 56 | { 57 | return FilterGaussian1D(xy.x, sigma) * FilterGaussian1D(xy.y, sigma); 58 | } 59 | 60 | inline float FilterCubic1D(float x, float B, float C) 61 | { 62 | // Rescale from [-1, 1] range to [-2, 2] 63 | x = std::abs(x) * 2.0f; 64 | 65 | float y = 0.0f; 66 | float x2 = x * x; 67 | float x3 = x * x * x; 68 | if(x < 1) 69 | y = (12 - 9 * B - 6 * C) * x3 + (-18 + 12 * B + 6 * C) * x2 + (6 - 2 * B); 70 | else if(x <= 2) 71 | y = (-B - 6 * C) * x3 + (6 * B + 30 * C) * x2 + (-12 * B - 48 * C) * x + (8 * B + 24 * C); 72 | 73 | return y / 6.0f; 74 | } 75 | 76 | inline float FilterCubic2D(Float2 xy, float B, float C) 77 | { 78 | return FilterCubic1D(xy.x, B, C) * FilterCubic1D(xy.y, B, C); 79 | } 80 | 81 | inline float FilterBSpline1D(float x) 82 | { 83 | return FilterCubic1D(x, 1.0f, 0.0f); 84 | } 85 | 86 | inline float FilterBSpline2D(Float2 xy) 87 | { 88 | return FilterBSpline1D(xy.x) * FilterBSpline1D(xy.y); 89 | } 90 | 91 | inline float FilterCatmullRom1D(float x) 92 | { 93 | return FilterCubic1D(x, 0.0f, 0.5f); 94 | } 95 | 96 | inline float FilterCatmullRom2D(Float2 xy) 97 | { 98 | return FilterCatmullRom1D(xy.x) * FilterCatmullRom1D(xy.y); 99 | } 100 | 101 | inline float FilterMitchell1D(float x) 102 | { 103 | return FilterCubic1D(x, 1 / 3.0f, 1 / 3.0f); 104 | } 105 | 106 | inline float FilterMitchell2D(Float2 xy) 107 | { 108 | return FilterMitchell1D(xy.x) * FilterMitchell1D(xy.y); 109 | } 110 | 111 | inline float FilterSinc1D(float x) 112 | { 113 | x = std::abs(x); 114 | 115 | float s; 116 | if(x < 0.001f) 117 | s = 1.0f; 118 | else 119 | s = std::sin(x * Pi) / (x * Pi); 120 | 121 | return s; 122 | } 123 | 124 | inline float BlackmanHarris(float x) 125 | { 126 | const float a0 = 0.35875f; 127 | const float a1 = 0.48829f; 128 | const float a2 = 0.14128f; 129 | const float a3 = 0.01168f; 130 | return a0 - a1 * std::cos(Pi * x) + a2 * std::cos(2 * Pi * x) - a3 * std::cos(3 * Pi * x); 131 | } 132 | 133 | inline float FilterBlackmanHarris1D(float x) 134 | { 135 | float t = 1.0f - std::abs(x); 136 | return Saturate(BlackmanHarris(t)); 137 | } 138 | 139 | inline float FilterSmoothstep1D(float x) 140 | { 141 | x = std::abs(x); 142 | return 1.0f - Smoothstep(0.0f, 1.0f, x); 143 | } 144 | 145 | inline float FilterSmoothstep2D(Float2 xy) 146 | { 147 | return FilterSmoothstep1D(Float2::Length(xy)); 148 | } 149 | 150 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Graphics/PostProcessorBase.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #pragma once 11 | 12 | #include "..\\PCH.h" 13 | 14 | #include "..\\InterfacePointers.h" 15 | #include "ShaderCompilation.h" 16 | 17 | namespace SampleFramework11 18 | { 19 | 20 | struct TempRenderTarget 21 | { 22 | ID3D11Texture2D* Texture; 23 | ID3D11ShaderResourceView* SRView; 24 | ID3D11RenderTargetView* RTView; 25 | ID3D11UnorderedAccessView* UAView; 26 | UINT Width; 27 | UINT Height; 28 | DXGI_FORMAT Format; 29 | UINT MSCount; 30 | UINT MSQuality; 31 | bool InUse; 32 | }; 33 | 34 | class PostProcessorBase 35 | { 36 | 37 | public: 38 | 39 | PostProcessorBase(); 40 | ~PostProcessorBase(); 41 | 42 | virtual void Initialize(ID3D11Device* device); 43 | 44 | virtual void Render(ID3D11DeviceContext* deviceContext, ID3D11ShaderResourceView* input, ID3D11RenderTargetView* output); 45 | 46 | virtual void AfterReset(UINT width, UINT height); 47 | 48 | protected: 49 | 50 | static const UINT_PTR MaxInputs = 8; 51 | 52 | struct PSConstants 53 | { 54 | XMFLOAT2 InputSize[MaxInputs]; 55 | XMFLOAT2 OutputSize; 56 | }; 57 | 58 | struct QuadVertex 59 | { 60 | XMFLOAT4 Position; 61 | XMFLOAT2 TexCoord; 62 | }; 63 | 64 | TempRenderTarget* GetTempRenderTarget(uint32 width, uint32 height, DXGI_FORMAT format, uint32 msCount = 1, 65 | uint32 msQuality = 0, uint32 mipLevels = 1, bool generateMipMaps = false, 66 | bool useAsUAV = false); 67 | void ClearTempRenderTargetCache(); 68 | 69 | void PostProcess(ID3D11ShaderResourceView* input, ID3D11RenderTargetView* output, ID3D11PixelShader* pixelShader, const wchar* name); 70 | virtual void PostProcess(ID3D11PixelShader* pixelShader, const wchar* name); 71 | 72 | std::vector tempRenderTargets; 73 | ID3D11Device* device; 74 | ID3D11DeviceContext* context; 75 | 76 | // Full screen quad 77 | ID3D11BufferPtr quadVB; 78 | ID3D11BufferPtr quadIB; 79 | VertexShaderPtr quadVS; 80 | ID3D11InputLayoutPtr quadInputLayout; 81 | 82 | // Sampler states 83 | ID3D11SamplerStatePtr pointSamplerState; 84 | ID3D11SamplerStatePtr linearSamplerState; 85 | ID3D11SamplerStatePtr linearWrapSamplerState; 86 | ID3D11SamplerStatePtr linearBorderSamplerState; 87 | ID3D11SamplerStatePtr pointBorderSamplerState; 88 | 89 | // Device states 90 | ID3D11DepthStencilStatePtr dsState; 91 | ID3D11BlendStatePtr blendState; 92 | ID3D11RasterizerStatePtr rastState; 93 | 94 | // Inputs and outputs 95 | std::vector inputs; 96 | std::vector outputs; 97 | std::vector uaViews; 98 | 99 | // Constant buffer 100 | ID3D11BufferPtr psConstants; 101 | 102 | uint32 inputWidth; 103 | uint32 inputHeight; 104 | }; 105 | 106 | } 107 | -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Graphics/Profiler.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #pragma once 11 | 12 | #include "..\\PCH.h" 13 | #include "..\\InterfacePointers.h" 14 | #include "..\\Timer.h" 15 | 16 | namespace SampleFramework11 17 | { 18 | 19 | class SpriteRenderer; 20 | class SpriteFont; 21 | 22 | class Profiler 23 | { 24 | 25 | public: 26 | 27 | static Profiler GlobalProfiler; 28 | 29 | void Initialize(ID3D11Device* device, ID3D11DeviceContext* immContext); 30 | 31 | void StartProfile(const std::wstring& name); 32 | void EndProfile(const std::wstring& name); 33 | 34 | void StartCPUProfile(const std::wstring& name); 35 | void EndCPUProfile(const std::wstring& name); 36 | 37 | void EndFrame(SpriteRenderer& spriteRenderer, SpriteFont& spriteFont); 38 | 39 | protected: 40 | 41 | // Constants 42 | static const uint64 QueryLatency = 5; 43 | 44 | struct ProfileData 45 | { 46 | ID3D11QueryPtr DisjointQuery[QueryLatency]; 47 | ID3D11QueryPtr TimestampStartQuery[QueryLatency]; 48 | ID3D11QueryPtr TimestampEndQuery[QueryLatency]; 49 | bool QueryStarted; 50 | bool QueryFinished; 51 | bool Active; 52 | 53 | bool CPUProfile; 54 | int64 StartTime; 55 | int64 EndTime; 56 | 57 | static const uint32 FilterSize = 64; 58 | double TimeSamples[FilterSize]; 59 | uint32 CurrSample; 60 | 61 | ProfileData() : QueryStarted(false), QueryFinished(false), Active(false), 62 | CPUProfile(false), StartTime(0), EndTime(0), CurrSample(0) 63 | { 64 | for(uint32 i = 0; i < FilterSize; ++i) 65 | TimeSamples[i] = 0.0; 66 | } 67 | }; 68 | 69 | typedef std::map ProfileMap; 70 | 71 | ProfileMap profiles; 72 | uint64 currFrame; 73 | 74 | ID3D11DevicePtr device; 75 | ID3D11DeviceContextPtr context; 76 | 77 | Timer timer; 78 | }; 79 | 80 | class ProfileBlock 81 | { 82 | public: 83 | 84 | ProfileBlock(const std::wstring& name); 85 | ~ProfileBlock(); 86 | 87 | protected: 88 | 89 | std::wstring name; 90 | }; 91 | 92 | class CPUProfileBlock 93 | { 94 | public: 95 | 96 | CPUProfileBlock(const std::wstring& name); 97 | ~CPUProfileBlock(); 98 | 99 | protected: 100 | 101 | std::wstring name; 102 | }; 103 | 104 | } 105 | -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Graphics/SH.cpp: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #include "PCH.h" 11 | #include "SH.h" 12 | #include "..\\Utility.h" 13 | #include "ShaderCompilation.h" 14 | #include "Textures.h" 15 | 16 | namespace SampleFramework11 17 | { 18 | 19 | SH9 ProjectOntoSH9(const Float3& dir) 20 | { 21 | SH9 sh; 22 | 23 | // Band 0 24 | sh.Coefficients[0] = 0.282095f; 25 | 26 | // Band 1 27 | sh.Coefficients[1] = 0.488603f * dir.y; 28 | sh.Coefficients[2] = 0.488603f * dir.z; 29 | sh.Coefficients[3] = 0.488603f * dir.x; 30 | 31 | // Band 2 32 | sh.Coefficients[4] = 1.092548f * dir.x * dir.y; 33 | sh.Coefficients[5] = 1.092548f * dir.y * dir.z; 34 | sh.Coefficients[6] = 0.315392f * (3.0f * dir.z * dir.z - 1.0f); 35 | sh.Coefficients[7] = 1.092548f * dir.x * dir.z; 36 | sh.Coefficients[8] = 0.546274f * (dir.x * dir.x - dir.y * dir.y); 37 | 38 | return sh; 39 | } 40 | 41 | SH9Color ProjectOntoSH9Color(const Float3& dir, const Float3& color) 42 | { 43 | SH9 sh = ProjectOntoSH9(dir); 44 | SH9Color shColor; 45 | for(uint64 i = 0; i < 9; ++i) 46 | shColor.Coefficients[i] = color * sh.Coefficients[i]; 47 | return shColor; 48 | } 49 | 50 | Float3 EvalSH9Cosine(const Float3& dir, const SH9Color& sh) 51 | { 52 | SH9 dirSH = ProjectOntoSH9(dir); 53 | dirSH.Coefficients[0] *= CosineA0; 54 | dirSH.Coefficients[1] *= CosineA1; 55 | dirSH.Coefficients[2] *= CosineA1; 56 | dirSH.Coefficients[3] *= CosineA1; 57 | dirSH.Coefficients[4] *= CosineA2; 58 | dirSH.Coefficients[5] *= CosineA2; 59 | dirSH.Coefficients[6] *= CosineA2; 60 | dirSH.Coefficients[7] *= CosineA2; 61 | dirSH.Coefficients[8] *= CosineA2; 62 | 63 | Float3 result; 64 | for(uint64 i = 0; i < 9; ++i) 65 | result += dirSH.Coefficients[i] * sh.Coefficients[i]; 66 | 67 | return result; 68 | } 69 | 70 | H4 ProjectOntoH4(const Float3& dir) 71 | { 72 | H4 result; 73 | 74 | result[0] = (1.0f / std::sqrt(2.0f * 3.14159f)); 75 | 76 | // Band 1 77 | result[1] = std::sqrt(1.5f / 3.14159f) * dir.y; 78 | result[2] = std::sqrt(1.5f / 3.14159f) * (2 * dir.z - 1.0f); 79 | result[3] = std::sqrt(1.5f / 3.14159f) * dir.x; 80 | 81 | return result; 82 | } 83 | 84 | float EvalH4(const H4& h, const Float3& dir) 85 | { 86 | H4 b = ProjectOntoH4(dir); 87 | return H4::Dot(h, b); 88 | } 89 | 90 | H4 ConvertToH4(const SH9& sh) 91 | { 92 | const float rt2 = sqrt(2.0f); 93 | const float rt32 = sqrt(3.0f / 2.0f); 94 | const float rt52 = sqrt(5.0f / 2.0f); 95 | const float rt152 = sqrt(15.0f / 2.0f); 96 | const float convMatrix[4][9] = 97 | { 98 | { 1.0f / rt2, 0, 0.5f * rt32, 0, 0, 0, 0, 0, 0 }, 99 | { 0, 1.0f / rt2, 0, 0, 0, (3.0f / 8.0f) * rt52, 0, 0, 0 }, 100 | { 0, 0, 1.0f / (2.0f * rt2), 0, 0, 0, 0.25f * rt152, 0, 0 }, 101 | { 0, 0, 0, 1.0f / rt2, 0, 0, 0, (3.0f / 8.0f) * rt52, 0 } 102 | }; 103 | 104 | H4 hBasis; 105 | 106 | for(uint64 row = 0; row < 4; ++row) 107 | { 108 | hBasis.Coefficients[row] = 0.0f; 109 | 110 | for(uint64 col = 0; col < 9; ++col) 111 | hBasis.Coefficients[row] += convMatrix[row][col] * sh.Coefficients[col]; 112 | } 113 | 114 | return hBasis; 115 | } 116 | 117 | 118 | SH9Color ProjectCubemapToSH(ID3D11Device* device, ID3D11ShaderResourceView* cubeMap) 119 | { 120 | TextureData textureData; 121 | GetTextureData(device, cubeMap, textureData); 122 | Assert_(textureData.NumSlices == 6); 123 | const uint32 width = textureData.Width; 124 | const uint32 height = textureData.Height; 125 | 126 | SH9Color result; 127 | float weightSum = 0.0f; 128 | for(uint32 face = 0; face < 6; ++face) 129 | { 130 | for(uint32 y = 0; y < height; ++y) 131 | { 132 | for(uint32 x = 0; x < width; ++x) 133 | { 134 | const uint32 idx = face * (width * height) + y * (width) + x; 135 | Float3 sample = textureData.Texels[idx].To3D(); 136 | 137 | float u = (x + 0.5f) / width; 138 | float v = (y + 0.5f) / height; 139 | 140 | // Account for cubemap texel distribution 141 | u = u * 2.0f - 1.0f; 142 | v = v * 2.0f - 1.0f; 143 | const float temp = 1.0f + u * u + v * v; 144 | const float weight = 4.0f / (sqrt(temp) * temp); 145 | 146 | Float3 dir = MapXYSToDirection(x, y, face, width, height); 147 | result += ProjectOntoSH9Color(dir, sample) * weight; 148 | weightSum += weight; 149 | } 150 | } 151 | } 152 | 153 | result *= (4.0f * 3.14159f) / weightSum; 154 | return result; 155 | } 156 | 157 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Graphics/Sampling.cpp: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #include "PCH.h" 11 | #include "Sampling.h" 12 | 13 | namespace SampleFramework11 14 | { 15 | 16 | #define RadicalInverse_(base) \ 17 | { \ 18 | const float radical = 1.0f / float(base); \ 19 | uint64 value = 0; \ 20 | float factor = 1.0f; \ 21 | while(sampleIdx) { \ 22 | uint64 next = sampleIdx / base; \ 23 | uint64 digit = sampleIdx - next * base; \ 24 | value = value * base + digit; \ 25 | factor *= radical; \ 26 | sampleIdx = next; \ 27 | } \ 28 | inverse = float(value) * factor; \ 29 | } 30 | 31 | float RadicalInverseFast(uint64 baseIdx, uint64 sampleIdx) 32 | { 33 | Assert_(baseIdx < 64); 34 | 35 | float inverse = 0.0f; 36 | 37 | switch (baseIdx) 38 | { 39 | case 0: RadicalInverse_(2); break; 40 | case 1: RadicalInverse_(3); break; 41 | case 2: RadicalInverse_(5); break; 42 | case 3: RadicalInverse_(7); break; 43 | case 4: RadicalInverse_(11); break; 44 | case 5: RadicalInverse_(13); break; 45 | case 6: RadicalInverse_(17); break; 46 | case 7: RadicalInverse_(19); break; 47 | case 8: RadicalInverse_(23); break; 48 | case 9: RadicalInverse_(29); break; 49 | case 10: RadicalInverse_(31); break; 50 | case 11: RadicalInverse_(37); break; 51 | case 12: RadicalInverse_(41); break; 52 | case 13: RadicalInverse_(43); break; 53 | case 14: RadicalInverse_(47); break; 54 | case 15: RadicalInverse_(53); break; 55 | case 16: RadicalInverse_(59); break; 56 | case 17: RadicalInverse_(61); break; 57 | case 18: RadicalInverse_(67); break; 58 | case 19: RadicalInverse_(71); break; 59 | case 20: RadicalInverse_(73); break; 60 | case 21: RadicalInverse_(79); break; 61 | case 22: RadicalInverse_(83); break; 62 | case 23: RadicalInverse_(89); break; 63 | case 24: RadicalInverse_(97); break; 64 | case 25: RadicalInverse_(101); break; 65 | case 26: RadicalInverse_(103); break; 66 | case 27: RadicalInverse_(107); break; 67 | case 28: RadicalInverse_(109); break; 68 | case 29: RadicalInverse_(113); break; 69 | case 30: RadicalInverse_(127); break; 70 | case 31: RadicalInverse_(131); break; 71 | case 32: RadicalInverse_(137); break; 72 | case 33: RadicalInverse_(139); break; 73 | case 34: RadicalInverse_(149); break; 74 | case 35: RadicalInverse_(151); break; 75 | case 36: RadicalInverse_(157); break; 76 | case 37: RadicalInverse_(163); break; 77 | case 38: RadicalInverse_(167); break; 78 | case 39: RadicalInverse_(173); break; 79 | case 40: RadicalInverse_(179); break; 80 | case 41: RadicalInverse_(181); break; 81 | case 42: RadicalInverse_(191); break; 82 | case 43: RadicalInverse_(193); break; 83 | case 44: RadicalInverse_(197); break; 84 | case 45: RadicalInverse_(199); break; 85 | case 46: RadicalInverse_(211); break; 86 | case 47: RadicalInverse_(223); break; 87 | case 48: RadicalInverse_(227); break; 88 | case 49: RadicalInverse_(229); break; 89 | case 50: RadicalInverse_(233); break; 90 | case 51: RadicalInverse_(239); break; 91 | case 52: RadicalInverse_(241); break; 92 | case 53: RadicalInverse_(251); break; 93 | case 54: RadicalInverse_(257); break; 94 | case 55: RadicalInverse_(263); break; 95 | case 56: RadicalInverse_(269); break; 96 | case 57: RadicalInverse_(271); break; 97 | case 58: RadicalInverse_(277); break; 98 | case 59: RadicalInverse_(281); break; 99 | case 60: RadicalInverse_(283); break; 100 | case 61: RadicalInverse_(293); break; 101 | case 62: RadicalInverse_(307); break; 102 | case 63: RadicalInverse_(311); break; 103 | } 104 | return std::min(inverse, OneMinusEpsilon); 105 | } 106 | 107 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Graphics/Sampling.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/LowResRendering/2f5742f04ab869fef5783a7c6837c38aefe008c3/SampleFramework11/v1.01/Graphics/Sampling.h -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Graphics/Skybox.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #pragma once 11 | 12 | #include "..\\PCH.h" 13 | 14 | #include "..\\InterfacePointers.h" 15 | #include "..\\SF11_Math.h" 16 | #include "ShaderCompilation.h" 17 | #include "GraphicsTypes.h" 18 | 19 | // HosekSky forward declares 20 | struct ArHosekSkyModelState; 21 | 22 | namespace SampleFramework11 23 | { 24 | 25 | // Cached data for the procedural sky model 26 | struct SkyCache 27 | { 28 | ArHosekSkyModelState* StateR = nullptr; 29 | ArHosekSkyModelState* StateG = nullptr; 30 | ArHosekSkyModelState* StateB = nullptr; 31 | Float3 SunDirection; 32 | float Turbidity = 0.0f; 33 | Float3 Albedo; 34 | float Elevation = 0.0f; 35 | ID3D11ShaderResourceViewPtr CubeMap; 36 | 37 | void Init(Float3 sunDirection, Float3 groundAlbedo, float turbidity); 38 | void Shutdown(); 39 | ~SkyCache(); 40 | }; 41 | 42 | class Skybox 43 | { 44 | 45 | public: 46 | 47 | Skybox(); 48 | ~Skybox(); 49 | 50 | void Initialize(ID3D11Device* device); 51 | 52 | void RenderEnvironmentMap(ID3D11DeviceContext* context, 53 | ID3D11ShaderResourceView* environmentMap, 54 | const Float4x4& view, 55 | const Float4x4& projection, 56 | Float3 scale = Float3(1.0f, 1.0f, 1.0f)); 57 | 58 | void RenderSky(ID3D11DeviceContext* context, 59 | Float3 sunDirection, 60 | Float3 groundAlbedo, 61 | Float3 sunColor, 62 | float sunSize, 63 | float turbidity, 64 | const Float4x4& view, 65 | const Float4x4& projection, 66 | Float3 scale = Float3(1.0f, 1.0f, 1.0f)); 67 | 68 | void RenderSimpleSky(ID3D11DeviceContext* context, 69 | Float3 skyColor, 70 | Float3 sunDirection, 71 | Float3 sunColor, 72 | float sunSize, 73 | const Float4x4& view, 74 | const Float4x4& projection, 75 | Float3 scake = Float3(1.0f, 1.0f, 1.0f)); 76 | 77 | static void Save2DSkyAsEXR(ID3D11Device* device, const SkyCache& skyCache, 78 | uint32 width, uint32 height, Float3 sunColor, 79 | float sunSize, bool32 includeSun, bool32 normalizeIntensity, 80 | const wchar* filePath); 81 | 82 | static Float3 SampleSky(const SkyCache& cache, Float3 sampleDir); 83 | 84 | protected: 85 | 86 | void RenderCommon(ID3D11DeviceContext* context, 87 | ID3D11ShaderResourceView* environmentMap, 88 | ID3D11PixelShader* ps, 89 | const Float4x4& view, 90 | const Float4x4& projection, 91 | Float3 scale); 92 | 93 | static const uint64 NumIndices = 36; 94 | static const uint64 NumVertices = 8; 95 | 96 | struct VSConstants 97 | { 98 | Float4x4 View; 99 | Float4x4 Projection; 100 | }; 101 | 102 | struct PSConstants 103 | { 104 | Float3 SunDirection = Float3(0.0f, 1.0f, 0.0f); 105 | bool32 EnableSun = false; 106 | Float3 SkyColor = 1.0f; 107 | Float4Align Float3 SunColor = 1.0f; 108 | float CosSunAngularRadius = 0.0f; 109 | Float3 Scale = 1.0f; 110 | }; 111 | 112 | ID3D11DevicePtr device; 113 | VertexShaderPtr vertexShader; 114 | PixelShaderPtr emPixelShader; 115 | PixelShaderPtr simpleSkyPS; 116 | ID3D11InputLayoutPtr inputLayout; 117 | ID3D11BufferPtr vertexBuffer; 118 | ID3D11BufferPtr indexBuffer; 119 | ConstantBuffer vsConstantBuffer; 120 | ConstantBuffer psConstantBuffer; 121 | ID3D11DepthStencilStatePtr dsState; 122 | ID3D11BlendStatePtr blendState; 123 | ID3D11RasterizerStatePtr rastState; 124 | ID3D11SamplerStatePtr samplerState; 125 | 126 | SkyCache skyCache; 127 | }; 128 | 129 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Graphics/SpriteFont.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #pragma once 11 | 12 | #include "..\\PCH.h" 13 | 14 | #include "..\\InterfacePointers.h" 15 | #include "..\\SF11_Math.h" 16 | 17 | namespace SampleFramework11 18 | { 19 | 20 | class SpriteFont 21 | { 22 | 23 | public: 24 | 25 | enum FontStyle 26 | { 27 | Regular = 0, 28 | Bold = 1 << 0, 29 | Italic = 1 << 1, 30 | BoldItalic = Bold | Italic, 31 | Underline = 1 << 2, 32 | Strikeout = 1 << 3 33 | }; 34 | 35 | struct CharDesc 36 | { 37 | float X; 38 | float Y; 39 | float Width; 40 | float Height; 41 | }; 42 | 43 | static const wchar StartChar = '!'; 44 | static const wchar EndChar = 127; 45 | static const uint64 NumChars = EndChar - StartChar; 46 | static const UINT TexWidth = 1024; 47 | 48 | // Lifetime 49 | SpriteFont(); 50 | ~SpriteFont(); 51 | 52 | void Initialize(LPCWSTR fontName, float fontSize, UINT fontStyle, bool antiAliased, ID3D11Device* device); 53 | 54 | Float2 MeasureText(const wchar* text) const; 55 | 56 | // Accessors 57 | ID3D11ShaderResourceView* SRView() const; 58 | const CharDesc* CharDescriptors() const; 59 | const CharDesc& GetCharDescriptor(wchar character) const; 60 | float Size() const; 61 | ID3D11Texture2D* Texture() const; 62 | UINT TextureWidth() const; 63 | UINT TextureHeight() const; 64 | float SpaceWidth() const; 65 | float CharHeight() const; 66 | 67 | protected: 68 | 69 | ID3D11Texture2DPtr texture; 70 | ID3D11ShaderResourceViewPtr srView; 71 | CharDesc charDescs [NumChars]; 72 | float size; 73 | UINT texHeight; 74 | float spaceWidth; 75 | float charHeight; 76 | }; 77 | 78 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Graphics/SpriteRenderer.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #pragma once 11 | 12 | #include "..\\PCH.h" 13 | 14 | #include "..\\Exceptions.h" 15 | #include "..\\Utility.h" 16 | #include "..\\InterfacePointers.h" 17 | #include "..\\SF11_Math.h" 18 | #include "ShaderCompilation.h" 19 | 20 | namespace SampleFramework11 21 | { 22 | 23 | class SpriteFont; 24 | 25 | class SpriteRenderer 26 | { 27 | 28 | public: 29 | 30 | enum FilterMode 31 | { 32 | DontSet = 0, 33 | Linear = 1, 34 | Point = 2 35 | }; 36 | 37 | enum BlendMode 38 | { 39 | AlphaBlend = 0, 40 | OpaqueBlend = 1, 41 | }; 42 | 43 | static const uint64 MaxBatchSize = 1000; 44 | 45 | struct SpriteDrawData 46 | { 47 | Float4x4 Transform; 48 | Float4 Color; 49 | Float4 DrawRect; 50 | }; 51 | 52 | SpriteRenderer(); 53 | ~SpriteRenderer(); 54 | 55 | void Initialize(ID3D11Device* device); 56 | 57 | void Begin(ID3D11DeviceContext* deviceContext, FilterMode filterMode = DontSet, BlendMode = AlphaBlend); 58 | 59 | void Render(ID3D11ShaderResourceView* texture, 60 | const Float4x4& transform, 61 | const Float4& color = Float4(1, 1, 1, 1), 62 | const Float4* drawRect = NULL); 63 | 64 | void RenderBatch(ID3D11ShaderResourceView* texture, 65 | const SpriteDrawData* drawData, 66 | uint64 numSprites); 67 | 68 | void RenderText(const SpriteFont& font, 69 | const wchar* text, 70 | const Float4x4& transform, 71 | const Float4& color = Float4(1, 1, 1, 1)); 72 | 73 | void End(); 74 | 75 | protected: 76 | 77 | D3D11_TEXTURE2D_DESC SetPerBatchData(ID3D11ShaderResourceView* texture); 78 | 79 | ID3D11DevicePtr device; 80 | VertexShaderPtr vertexShader; 81 | VertexShaderPtr vertexShaderInstanced; 82 | PixelShaderPtr pixelShader; 83 | PixelShaderPtr pixelShaderOpaque; 84 | ID3D11BufferPtr vertexBuffer; 85 | ID3D11BufferPtr indexBuffer; 86 | ID3D11BufferPtr vsPerBatchCB; 87 | ID3D11BufferPtr vsPerInstanceCB; 88 | ID3D11BufferPtr instanceDataBuffer; 89 | ID3D11InputLayoutPtr inputLayout; 90 | ID3D11InputLayoutPtr inputLayoutInstanced; 91 | ID3D11DeviceContextPtr context; 92 | 93 | ID3D11RasterizerStatePtr rastState; 94 | ID3D11DepthStencilStatePtr dsState; 95 | ID3D11BlendStatePtr alphaBlendState; 96 | ID3D11BlendStatePtr opaqueBlendState; 97 | ID3D11SamplerStatePtr linearSamplerState; 98 | ID3D11SamplerStatePtr pointSamplerState; 99 | 100 | bool initialized; 101 | 102 | SpriteDrawData textDrawData [MaxBatchSize]; 103 | 104 | struct SpriteVertex 105 | { 106 | Float2 Position; 107 | Float2 TexCoord; 108 | }; 109 | 110 | struct VSPerBatchCB 111 | { 112 | Float2 TextureSize; 113 | Float2 ViewportSize; 114 | }; 115 | }; 116 | 117 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Input.cpp: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #include "PCH.h" 11 | 12 | #include "Input.h" 13 | #include "Exceptions.h" 14 | 15 | namespace SampleFramework11 16 | { 17 | 18 | MouseState MouseState::prevState; 19 | KeyboardState KeyboardState::prevState; 20 | BYTE KeyboardState::currState[256]; 21 | 22 | MouseState::MouseState() : X (0), 23 | Y (0), 24 | DX (0), 25 | DY (0), 26 | IsOverWindow (false) 27 | { 28 | 29 | } 30 | 31 | MouseState MouseState::GetMouseState(HWND hwnd) 32 | { 33 | POINT pos; 34 | if (!GetCursorPos(&pos)) 35 | throw Win32Exception(GetLastError()); 36 | 37 | if (hwnd != NULL) 38 | if(!ScreenToClient(hwnd, &pos)) 39 | throw Win32Exception(GetLastError()); 40 | 41 | MouseState newState; 42 | newState.X = pos.x; 43 | newState.Y = pos.y; 44 | newState.DX = pos.x - prevState.X; 45 | newState.DY = pos.y - prevState.Y; 46 | 47 | newState.LButton.Pressed = (GetKeyState(VK_LBUTTON) & 0x8000) > 0; 48 | newState.LButton.RisingEdge = newState.LButton.Pressed && !prevState.LButton.Pressed; 49 | newState.LButton.RisingEdge = !newState.LButton.Pressed && prevState.LButton.Pressed; 50 | 51 | newState.MButton.Pressed = (GetKeyState(VK_MBUTTON) & 0x8000) > 0; 52 | newState.MButton.RisingEdge = newState.MButton.Pressed && !prevState.MButton.Pressed; 53 | newState.MButton.RisingEdge = !newState.MButton.Pressed && prevState.MButton.Pressed; 54 | 55 | newState.RButton.Pressed = (GetKeyState(VK_RBUTTON) & 0x8000) > 0; 56 | newState.RButton.RisingEdge = newState.RButton.Pressed && !prevState.RButton.Pressed; 57 | newState.RButton.RisingEdge = !newState.RButton.Pressed && prevState.RButton.Pressed; 58 | 59 | if (hwnd != NULL) 60 | { 61 | RECT clientRect; 62 | if (!::GetClientRect(hwnd, &clientRect)) 63 | throw Win32Exception(GetLastError()); 64 | newState.IsOverWindow = (pos.x >= 0 && pos.x < clientRect.right 65 | && pos.y >= 0 && pos.y < clientRect.bottom); 66 | } 67 | else 68 | newState.IsOverWindow = false; 69 | 70 | prevState = newState; 71 | return prevState; 72 | } 73 | 74 | void MouseState::SetCursorPos(int x, int y, HWND hwnd) 75 | { 76 | POINT pos; 77 | pos.x = x; 78 | pos.y = y; 79 | 80 | if (hwnd != NULL) 81 | if (!ClientToScreen(hwnd, &pos)) 82 | throw Win32Exception(GetLastError()); 83 | 84 | if (!::SetCursorPos(pos.x, pos.y)) 85 | throw Win32Exception(GetLastError()); 86 | } 87 | 88 | KeyState KeyboardState::GetKeyState(Keys key) const 89 | { 90 | return keyStates[key]; 91 | } 92 | 93 | bool KeyboardState::IsKeyDown(Keys key) const 94 | { 95 | return keyStates[key].Pressed; 96 | } 97 | 98 | bool KeyboardState::RisingEdge(Keys key) const 99 | { 100 | return keyStates[key].RisingEdge; 101 | } 102 | 103 | KeyboardState KeyboardState::GetKeyboardState(HWND hwnd) 104 | { 105 | if(GetForegroundWindow() != hwnd) 106 | return prevState; 107 | 108 | ::GetKeyboardState(currState); 109 | 110 | KeyState state; 111 | for (UINT i = 0; i < 256; ++i) 112 | { 113 | state.Pressed = KeyPressed(currState[i]); 114 | state.RisingEdge = state.Pressed && !prevState.keyStates[i].Pressed; 115 | state.FallingEdge = !state.Pressed && prevState.keyStates[i].Pressed; 116 | prevState.keyStates[i] = state; 117 | } 118 | 119 | return prevState; 120 | } 121 | 122 | KeyState::KeyState() : Pressed(false), 123 | RisingEdge(false), 124 | FallingEdge(false) 125 | { 126 | } 127 | 128 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/InterfacePointers.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #pragma once 11 | 12 | #include "PCH.h" 13 | 14 | namespace SampleFramework11 15 | { 16 | 17 | // Device 18 | _COM_SMARTPTR_TYPEDEF(ID3D11Device, __uuidof(ID3D11Device)); 19 | _COM_SMARTPTR_TYPEDEF(ID3D11DeviceContext, __uuidof(ID3D11DeviceContext)); 20 | _COM_SMARTPTR_TYPEDEF(ID3D11DeviceChild, __uuidof(ID3D11DeviceChild)); 21 | _COM_SMARTPTR_TYPEDEF(ID3D11Query, __uuidof(ID3D11Query)); 22 | _COM_SMARTPTR_TYPEDEF(ID3D11CommandList, __uuidof(ID3D11CommandList)); 23 | _COM_SMARTPTR_TYPEDEF(ID3D11Counter, __uuidof(ID3D11Counter)); 24 | _COM_SMARTPTR_TYPEDEF(ID3D11InputLayout, __uuidof(ID3D11InputLayout)); 25 | _COM_SMARTPTR_TYPEDEF(ID3D11Predicate, __uuidof(ID3D11Predicate)); 26 | _COM_SMARTPTR_TYPEDEF(ID3D11Asynchronous, __uuidof(ID3D11Asynchronous)); 27 | _COM_SMARTPTR_TYPEDEF(ID3D11InfoQueue, __uuidof(ID3D11InfoQueue)); 28 | _COM_SMARTPTR_TYPEDEF(ID3D11Debug, __uuidof(ID3D11Debug)); 29 | 30 | // States 31 | _COM_SMARTPTR_TYPEDEF(ID3D11BlendState, __uuidof(ID3D11BlendState)); 32 | _COM_SMARTPTR_TYPEDEF(ID3D11DepthStencilState, __uuidof(ID3D11DepthStencilState)); 33 | _COM_SMARTPTR_TYPEDEF(ID3D11RasterizerState, __uuidof(ID3D11RasterizerState)); 34 | _COM_SMARTPTR_TYPEDEF(ID3D11SamplerState, __uuidof(ID3D11SamplerState)); 35 | 36 | // Resources 37 | _COM_SMARTPTR_TYPEDEF(ID3D11Resource, __uuidof(ID3D11Resource)); 38 | _COM_SMARTPTR_TYPEDEF(ID3D11Texture1D, __uuidof(ID3D11Texture1D)); 39 | _COM_SMARTPTR_TYPEDEF(ID3D11Texture2D, __uuidof(ID3D11Texture2D)); 40 | _COM_SMARTPTR_TYPEDEF(ID3D11Texture3D, __uuidof(ID3D11Texture3D)); 41 | _COM_SMARTPTR_TYPEDEF(ID3D11Buffer, __uuidof(ID3D11Buffer)); 42 | 43 | // Views 44 | _COM_SMARTPTR_TYPEDEF(ID3D11View, __uuidof(ID3D11View)); 45 | _COM_SMARTPTR_TYPEDEF(ID3D11RenderTargetView, __uuidof(ID3D11RenderTargetView)); 46 | _COM_SMARTPTR_TYPEDEF(ID3D11ShaderResourceView, __uuidof(ID3D11ShaderResourceView)); 47 | _COM_SMARTPTR_TYPEDEF(ID3D11DepthStencilView, __uuidof(ID3D11DepthStencilView)); 48 | _COM_SMARTPTR_TYPEDEF(ID3D11UnorderedAccessView, __uuidof(ID3D11UnorderedAccessView)); 49 | 50 | // Shaders 51 | _COM_SMARTPTR_TYPEDEF(ID3D11ComputeShader, __uuidof(ID3D11ComputeShader)); 52 | _COM_SMARTPTR_TYPEDEF(ID3D11DomainShader, __uuidof(ID3D11DomainShader)); 53 | _COM_SMARTPTR_TYPEDEF(ID3D11GeometryShader, __uuidof(ID3D11GeometryShader)); 54 | _COM_SMARTPTR_TYPEDEF(ID3D11HullShader, __uuidof(ID3D11HullShader)); 55 | _COM_SMARTPTR_TYPEDEF(ID3D11PixelShader, __uuidof(ID3D11PixelShader)); 56 | _COM_SMARTPTR_TYPEDEF(ID3D11VertexShader, __uuidof(ID3D11VertexShader)); 57 | _COM_SMARTPTR_TYPEDEF(ID3D11ClassInstance, __uuidof(ID3D11ClassInstance)); 58 | _COM_SMARTPTR_TYPEDEF(ID3D11ClassLinkage, __uuidof(ID3D11ClassLinkage)); 59 | _COM_SMARTPTR_TYPEDEF(ID3D11ShaderReflection, IID_ID3D11ShaderReflection); 60 | _COM_SMARTPTR_TYPEDEF(ID3D11ShaderReflectionConstantBuffer, IID_ID3D11ShaderReflectionConstantBuffer); 61 | _COM_SMARTPTR_TYPEDEF(ID3D11ShaderReflectionType, IID_ID3D11ShaderReflectionType); 62 | _COM_SMARTPTR_TYPEDEF(ID3D11ShaderReflectionVariable, IID_ID3D11ShaderReflectionVariable); 63 | 64 | // D3D10 65 | _COM_SMARTPTR_TYPEDEF(ID3D10Blob, IID_ID3D10Blob); 66 | typedef ID3D10BlobPtr ID3DBlobPtr; 67 | 68 | // DXGI 69 | _COM_SMARTPTR_TYPEDEF(IDXGISwapChain, __uuidof(IDXGISwapChain)); 70 | _COM_SMARTPTR_TYPEDEF(IDXGIAdapter, __uuidof(IDXGIAdapter)); 71 | _COM_SMARTPTR_TYPEDEF(IDXGIAdapter1, __uuidof(IDXGIAdapter1)); 72 | _COM_SMARTPTR_TYPEDEF(IDXGIDevice, __uuidof(IDXGIDevice)); 73 | _COM_SMARTPTR_TYPEDEF(IDXGIDevice1, __uuidof(IDXGIDevice1)); 74 | _COM_SMARTPTR_TYPEDEF(IDXGIDeviceSubObject, __uuidof(IDXGIDeviceSubObject)); 75 | _COM_SMARTPTR_TYPEDEF(IDXGIFactory, __uuidof(IDXGIFactory)); 76 | _COM_SMARTPTR_TYPEDEF(IDXGIFactory1, __uuidof(IDXGIFactory1)); 77 | _COM_SMARTPTR_TYPEDEF(IDXGIKeyedMutex, __uuidof(IDXGIKeyedMutex)); 78 | _COM_SMARTPTR_TYPEDEF(IDXGIObject, __uuidof(IDXGIObject)); 79 | _COM_SMARTPTR_TYPEDEF(IDXGIOutput, __uuidof(IDXGIOutput)); 80 | _COM_SMARTPTR_TYPEDEF(IDXGIResource, __uuidof(IDXGIResource)); 81 | _COM_SMARTPTR_TYPEDEF(IDXGISurface1, __uuidof(IDXGISurface1)); 82 | 83 | } 84 | -------------------------------------------------------------------------------- /SampleFramework11/v1.01/MurmurHash.cpp: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #include "PCH.h" 11 | #include "MurmurHash.h" 12 | #include "Utility.h" 13 | 14 | namespace SampleFramework11 15 | { 16 | 17 | std::wstring Hash::ToString() const 18 | { 19 | return SampleFramework11::ToString(A) + L"_" + SampleFramework11::ToString(B); 20 | } 21 | 22 | // Platform-specific functions and macros 23 | #define FORCE_INLINE __forceinline 24 | 25 | #include 26 | 27 | #define ROTL32(x,y) _rotl(x,y) 28 | #define ROTL64(x,y) _rotl64(x,y) 29 | 30 | #define BIG_CONSTANT(x) (x) 31 | 32 | //----------------------------------------------------------------------------- 33 | // Block read - if your platform needs to do endian-swapping or can only 34 | // handle aligned reads, do the conversion here 35 | 36 | FORCE_INLINE uint32_t getblock ( const uint32_t * p, int i ) 37 | { 38 | return p[i]; 39 | } 40 | 41 | FORCE_INLINE uint64_t getblock ( const uint64_t * p, int i ) 42 | { 43 | return p[i]; 44 | } 45 | 46 | //----------------------------------------------------------------------------- 47 | // Finalization mix - force all bits of a hash block to avalanche 48 | 49 | FORCE_INLINE uint32_t fmix ( uint32_t h ) 50 | { 51 | h ^= h >> 16; 52 | h *= 0x85ebca6b; 53 | h ^= h >> 13; 54 | h *= 0xc2b2ae35; 55 | h ^= h >> 16; 56 | 57 | return h; 58 | } 59 | 60 | //---------- 61 | 62 | FORCE_INLINE uint64_t fmix ( uint64_t k ) 63 | { 64 | k ^= k >> 33; 65 | k *= BIG_CONSTANT(0xff51afd7ed558ccd); 66 | k ^= k >> 33; 67 | k *= BIG_CONSTANT(0xc4ceb9fe1a85ec53); 68 | k ^= k >> 33; 69 | 70 | return k; 71 | } 72 | 73 | 74 | //----------------------------------------------------------------------------- 75 | 76 | Hash GenerateHash(const void* key, const int len, const uint32_t seed) 77 | { 78 | const uint8_t * data = (const uint8_t*)key; 79 | const int nblocks = len / 16; 80 | 81 | uint64_t h1 = seed; 82 | uint64_t h2 = seed; 83 | 84 | const uint64_t c1 = BIG_CONSTANT(0x87c37b91114253d5); 85 | const uint64_t c2 = BIG_CONSTANT(0x4cf5ad432745937f); 86 | 87 | //---------- 88 | // body 89 | 90 | const uint64_t * blocks = (const uint64_t *)(data); 91 | 92 | for(int i = 0; i < nblocks; i++) 93 | { 94 | uint64_t k1 = getblock(blocks,i*2+0); 95 | uint64_t k2 = getblock(blocks,i*2+1); 96 | 97 | k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1; 98 | 99 | h1 = ROTL64(h1,27); h1 += h2; h1 = h1*5+0x52dce729; 100 | 101 | k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2; 102 | 103 | h2 = ROTL64(h2,31); h2 += h1; h2 = h2*5+0x38495ab5; 104 | } 105 | 106 | //---------- 107 | // tail 108 | 109 | const uint8_t * tail = (const uint8_t*)(data + nblocks*16); 110 | 111 | uint64_t k1 = 0; 112 | uint64_t k2 = 0; 113 | 114 | switch(len & 15) 115 | { 116 | case 15: k2 ^= uint64_t(tail[14]) << 48; 117 | case 14: k2 ^= uint64_t(tail[13]) << 40; 118 | case 13: k2 ^= uint64_t(tail[12]) << 32; 119 | case 12: k2 ^= uint64_t(tail[11]) << 24; 120 | case 11: k2 ^= uint64_t(tail[10]) << 16; 121 | case 10: k2 ^= uint64_t(tail[ 9]) << 8; 122 | case 9: k2 ^= uint64_t(tail[ 8]) << 0; 123 | k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2; 124 | 125 | case 8: k1 ^= uint64_t(tail[ 7]) << 56; 126 | case 7: k1 ^= uint64_t(tail[ 6]) << 48; 127 | case 6: k1 ^= uint64_t(tail[ 5]) << 40; 128 | case 5: k1 ^= uint64_t(tail[ 4]) << 32; 129 | case 4: k1 ^= uint64_t(tail[ 3]) << 24; 130 | case 3: k1 ^= uint64_t(tail[ 2]) << 16; 131 | case 2: k1 ^= uint64_t(tail[ 1]) << 8; 132 | case 1: k1 ^= uint64_t(tail[ 0]) << 0; 133 | k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1; 134 | }; 135 | 136 | //---------- 137 | // finalization 138 | 139 | h1 ^= len; h2 ^= len; 140 | 141 | h1 += h2; 142 | h2 += h1; 143 | 144 | h1 = fmix(h1); 145 | h2 = fmix(h2); 146 | 147 | h1 += h2; 148 | h2 += h1; 149 | 150 | return Hash(h1, h2); 151 | } 152 | 153 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/MurmurHash.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #pragma once 11 | 12 | #include "PCH.h" 13 | 14 | namespace SampleFramework11 15 | { 16 | 17 | struct Hash 18 | { 19 | uint64 A; 20 | uint64 B; 21 | 22 | Hash() : A(0), B(0) {} 23 | Hash(uint64 a, uint64 b) : A(a), B(b) {} 24 | 25 | std::wstring ToString() const; 26 | 27 | bool operator==(const Hash& other) 28 | { 29 | return A == other.A && B == other.B; 30 | } 31 | }; 32 | 33 | Hash GenerateHash(const void* key, int len, uint32 seed = 0); 34 | 35 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/PCH.cpp: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #include "PCH.h" 11 | 12 | -------------------------------------------------------------------------------- /SampleFramework11/v1.01/SampleFramework11.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | ../SampleFramework11/v1.01/ 6 | 7 | 8 | $(ProjectDir)..\Externals\sun\lib;$(ProjectDir)..\Externals\HosekSky\Lib 2013;$(ProjectDir)..\Externals\DirectXTex\Lib\$(Configuration);$(ProjectDir)..\Externals\Assimp-3.1.1\lib;$(ProjectDir)..\Externals\AntTweakBar\lib;$(Configuration);$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64) 9 | $(VC_IncludePath);$(WindowsSDK_IncludePath);$(ProjectDir)$(SampleFrameworkDir);$(ProjectDir) 10 | 11 | 12 | 13 | %(PreprocessorDefinitions);SampleFrameworkDir_=L"$(SampleFrameworkDir)" 14 | Create 15 | PCH.h 16 | true 17 | Level3 18 | true 19 | 20 | 21 | 22 | 23 | 24 | 25 | copy %(FullPath) $(SolutionDir)%(Filename)%(Extension) 26 | 27 | 28 | Copying external DLL 29 | 30 | 31 | $(ProjectDir)%(Filename)%(Extension) 32 | 33 | 34 | false 35 | 36 | 37 | 38 | 39 | $(SampleFrameworkDir) 40 | true 41 | 42 | 43 | -------------------------------------------------------------------------------- /SampleFramework11/v1.01/SettingsCompiler/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /SampleFramework11/v1.01/SettingsCompiler/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SettingsCompiler")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SettingsCompiler")] 13 | [assembly: AssemblyCopyright("Copyright © 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("82e71a1c-e522-48b7-80f5-8b6d46fa51fb")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /SampleFramework11/v1.01/SettingsCompiler/SettingsCompiler.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {A01DD775-61A4-42F1-9B2A-772E50456A68} 8 | Exe 9 | Properties 10 | SettingsCompiler 11 | SettingsCompiler 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | bin\x64\Debug\ 18 | DEBUG;TRACE 19 | full 20 | x64 21 | prompt 22 | MinimumRecommendedRules.ruleset 23 | true 24 | false 25 | 26 | 27 | bin\x64\Release\ 28 | TRACE 29 | true 30 | pdbonly 31 | x64 32 | prompt 33 | MinimumRecommendedRules.ruleset 34 | true 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | {c61f717f-ff92-4d36-930e-1f49c198cbee} 56 | SettingsCompilerAttributes 57 | 58 | 59 | 60 | 61 | copy $(TargetPath) $(SolutionDir)$(TargetFileName) 62 | 63 | 70 | -------------------------------------------------------------------------------- /SampleFramework11/v1.01/SettingsCompilerAttributes/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SettingsCompilerAttributes")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SettingsCompilerAttributes")] 13 | [assembly: AssemblyCopyright("Copyright © 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a4917329-37f4-41b3-bedd-b7a7ce76bf2d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /SampleFramework11/v1.01/SettingsCompilerAttributes/SettingsCompilerAttributes.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {C61F717F-FF92-4D36-930E-1F49C198CBEE} 8 | Library 9 | Properties 10 | SettingsCompilerAttributes 11 | SettingsCompilerAttributes 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | bin\x64\Debug\ 18 | DEBUG;TRACE 19 | full 20 | x64 21 | prompt 22 | MinimumRecommendedRules.ruleset 23 | false 24 | 25 | 26 | bin\x64\Release\ 27 | TRACE 28 | true 29 | pdbonly 30 | x64 31 | prompt 32 | MinimumRecommendedRules.ruleset 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | copy $(TargetPath) $(SolutionDir)$(TargetFileName) 50 | 51 | 58 | -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Shaders/Constants.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #ifndef CONSTANTS_HLSL_ 11 | #define CONSTANTS_HLSL_ 12 | 13 | static const float Pi = 3.141592654f; 14 | static const float Pi2 = 6.283185307f; 15 | static const float Pi_2 = 1.570796327f; 16 | static const float Pi_4 = 0.7853981635f; 17 | static const float InvPi = 0.318309886f; 18 | static const float InvPi2 = 0.159154943f; 19 | 20 | // Max value that we can store in an fp16 buffer (actually a little less so that we have room for error, real max is 65504) 21 | static const float FP16Max = 65000.0f; 22 | 23 | #endif // CONSTANTS_HLSL_ -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Shaders/Conversion.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | //================================================================================================= 11 | // Float/half conversion functions 12 | //================================================================================================= 13 | uint2 Float4ToHalf(in float4 val) 14 | { 15 | uint2 result = 0; 16 | result.x = f32tof16(val.x); 17 | result.x |= f32tof16(val.y) << 16; 18 | result.y = f32tof16(val.z); 19 | result.y |= f32tof16(val.w) << 16; 20 | 21 | return result; 22 | } 23 | 24 | uint2 Float3ToHalf(in float3 val) 25 | { 26 | uint2 result = 0; 27 | result.x = f32tof16(val.x); 28 | result.x |= f32tof16(val.y) << 16; 29 | result.y = f32tof16(val.z); 30 | 31 | return result; 32 | } 33 | 34 | uint Float2ToHalf(in float2 val) 35 | { 36 | uint result = 0; 37 | result = f32tof16(val.x); 38 | result |= f32tof16(val.y) << 16; 39 | 40 | return result; 41 | } 42 | 43 | float4 HalfToFloat4(in uint2 val) 44 | { 45 | float4 result; 46 | result.x = f16tof32(val.x); 47 | result.y = f16tof32(val.x >> 16); 48 | result.z = f16tof32(val.y); 49 | result.w = f16tof32(val.y >> 16); 50 | 51 | return result; 52 | } 53 | 54 | float3 HalfToFloat3(in uint2 val) 55 | { 56 | float3 result; 57 | result.x = f16tof32(val.x); 58 | result.y = f16tof32(val.x >> 16); 59 | result.z = f16tof32(val.y); 60 | 61 | return result; 62 | } 63 | 64 | float2 HalfToFloat2(in uint val) 65 | { 66 | float2 result; 67 | result.x = f16tof32(val); 68 | result.y = f16tof32(val >> 16); 69 | 70 | return result; 71 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Shaders/DecodeTextureCS.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | //================================================================================================= 11 | // Resources 12 | //================================================================================================= 13 | 14 | // Inputs 15 | Texture2D InputTexture : register(t0); 16 | Texture2DArray InputTextureArray : register(t0); 17 | 18 | // Outputs 19 | RWTexture2D OutputTexture : register(u0); 20 | RWTexture2DArray OutputTextureArray : register(u0); 21 | 22 | //================================================================================================= 23 | // Entry points 24 | //================================================================================================= 25 | [numthreads(TGSize_, TGSize_, 1)] 26 | void DecodeTextureCS(in uint3 GroupID : SV_GroupID, in uint3 GroupThreadID : SV_GroupThreadID) 27 | { 28 | const uint2 texelIdx = GroupID.xy * uint2(TGSize_, TGSize_) + GroupThreadID.xy; 29 | OutputTexture[texelIdx] = InputTexture[texelIdx]; 30 | } 31 | 32 | [numthreads(TGSize_, TGSize_, 1)] 33 | void DecodeTextureArrayCS(in uint3 GroupID : SV_GroupID, in uint3 GroupThreadID : SV_GroupThreadID) 34 | { 35 | const uint3 texelIdx = uint3(GroupID.xy * uint2(TGSize_, TGSize_) + GroupThreadID.xy, GroupID.z); 36 | OutputTextureArray[texelIdx] = InputTextureArray[texelIdx]; 37 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Shaders/PPIncludes.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | cbuffer PSConstants : register(b0) 11 | { 12 | float2 InputSize0; 13 | float2 InputSize1; 14 | float2 InputSize2; 15 | float2 InputSize3; 16 | float2 InputSize4; 17 | float2 InputSize5; 18 | float2 InputSize6; 19 | float2 InputSize7; 20 | float2 OutputSize; 21 | } 22 | 23 | SamplerState PointSampler : register(s0); 24 | SamplerState LinearSampler : register(s1); 25 | SamplerState LinearWrapSampler : register(s2); 26 | SamplerState LinearBorderSampler : register(s3); 27 | SamplerState PointBorderSampler : register(s4); 28 | 29 | Texture2D InputTexture0 : register(t0); 30 | Texture2D InputTexture1 : register(t1); 31 | Texture2D InputTexture2 : register(t2); 32 | Texture2D InputTexture3 : register(t3); 33 | Texture2D InputTexture4 : register(t4); 34 | Texture2D InputTexture5 : register(t5); 35 | Texture2D InputTexture6 : register(t6); 36 | Texture2D InputTexture7 : register(t7); 37 | 38 | struct PSInput 39 | { 40 | float4 PositionSS : SV_Position; 41 | float2 TexCoord : TEXCOORD; 42 | }; -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Shaders/Quad.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | //================================================================================================= 11 | // Input/Output structs 12 | //================================================================================================= 13 | 14 | struct VSInput 15 | { 16 | float4 PositionCS : POSITION; 17 | float2 TexCoord : TEXCOORD; 18 | }; 19 | 20 | struct VSOutput 21 | { 22 | float4 PositionCS : SV_Position; 23 | float2 TexCoord : TEXCOORD; 24 | }; 25 | 26 | //================================================================================================= 27 | // Vertex Shader 28 | //================================================================================================= 29 | VSOutput QuadVS(in VSInput input) 30 | { 31 | VSOutput output; 32 | 33 | // Just pass it along 34 | output.PositionCS = input.PositionCS; 35 | output.TexCoord = input.TexCoord; 36 | 37 | return output; 38 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Shaders/Skybox.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #include 11 | 12 | //================================================================================================= 13 | // Constant buffers 14 | //================================================================================================= 15 | 16 | cbuffer VSConstants : register (b0) 17 | { 18 | float4x4 View; 19 | float4x4 Projection; 20 | float3 Bias; 21 | } 22 | 23 | 24 | cbuffer PSConstants : register (b0) 25 | { 26 | float3 SunDirection; 27 | bool EnableSun; 28 | float3 SkyColor; 29 | float3 SunColor; 30 | float CosSunAngularRadius; 31 | float Scale; 32 | } 33 | 34 | //================================================================================================= 35 | // Samplers 36 | //================================================================================================= 37 | 38 | TextureCube EnvironmentMap : register(t0); 39 | SamplerState LinearSampler : register(s0); 40 | 41 | 42 | //================================================================================================= 43 | // Input/Output structs 44 | //================================================================================================= 45 | 46 | struct VSInput 47 | { 48 | float3 PositionOS : POSITION; 49 | }; 50 | 51 | struct VSOutput 52 | { 53 | float4 PositionCS : SV_Position; 54 | float3 TexCoord : TEXCOORD; 55 | }; 56 | 57 | 58 | //================================================================================================= 59 | // Vertex Shader 60 | //================================================================================================= 61 | VSOutput SkyboxVS(in VSInput input) 62 | { 63 | VSOutput output; 64 | 65 | // Rotate into view-space, centered on the camera 66 | float3 positionVS = mul(input.PositionOS.xyz, (float3x3)View); 67 | 68 | // Transform to clip-space 69 | output.PositionCS = mul(float4(positionVS, 1.0f), Projection); 70 | 71 | // Make a texture coordinate 72 | output.TexCoord = input.PositionOS; 73 | 74 | return output; 75 | } 76 | 77 | //------------------------------------------------------------------------------------------------- 78 | // Common pixel shader functionality 79 | //------------------------------------------------------------------------------------------------- 80 | float4 PSCommon(in VSOutput input, in float3 baseColor) : SV_Target 81 | { 82 | float3 color = baseColor; 83 | 84 | // Draw a circle for the sun 85 | float3 dir = normalize(input.TexCoord); 86 | if(EnableSun) 87 | { 88 | float cosSunAngle = dot(dir, SunDirection); 89 | if(cosSunAngle >= CosSunAngularRadius) 90 | color = SunColor; 91 | } 92 | 93 | color *= Scale; 94 | color = clamp(color, 0.0f, FP16Max); 95 | 96 | return float4(color, 1.0f); 97 | } 98 | 99 | //================================================================================================= 100 | // Environment Map Pixel Shader 101 | //================================================================================================= 102 | float4 SkyboxPS(in VSOutput input) : SV_Target 103 | { 104 | // Sample the environment map 105 | float3 envMapClr = EnvironmentMap.Sample(LinearSampler, normalize(input.TexCoord)).rgb; 106 | return PSCommon(input, envMapClr); 107 | } 108 | 109 | //================================================================================================= 110 | // Simple Sky Pixel Shader 111 | //================================================================================================= 112 | float4 SimpleSkyPS(in VSOutput input) : SV_Target 113 | { 114 | return PSCommon(input, SkyColor); 115 | } 116 | -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Timer.cpp: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #include "PCH.h" 11 | 12 | #include "Timer.h" 13 | 14 | #include "Utility.h" 15 | 16 | namespace SampleFramework11 17 | { 18 | 19 | Timer::Timer() 20 | { 21 | // Query for the performance counter frequency 22 | LARGE_INTEGER largeInt; 23 | Win32Call(QueryPerformanceFrequency(&largeInt)); 24 | frequency = largeInt.QuadPart; 25 | frequencyD = static_cast(frequency); 26 | 27 | // Init the elapsed time 28 | Win32Call(QueryPerformanceCounter(&largeInt)); 29 | startTime = largeInt.QuadPart; 30 | elapsed = largeInt.QuadPart - startTime; 31 | elapsedF = static_cast(elapsed); 32 | elapsedSeconds = elapsed / frequency; 33 | elapsedSecondsD = elapsed / frequencyD; 34 | elapsedSecondsF = static_cast(elapsedSecondsD); 35 | elapsedMilliseconds = static_cast(elapsedSecondsD * 1000); 36 | elapsedMillisecondsD = elapsedSecondsD * 1000; 37 | elapsedMillisecondsF = static_cast(elapsedMillisecondsD); 38 | elapsedMicroseconds = static_cast(elapsedMillisecondsD * 1000); 39 | elapsedMicrosecondsD = elapsedMillisecondsD * 1000; 40 | elapsedMicrosecondsF = static_cast(elapsedMillisecondsD); 41 | 42 | delta = 0; 43 | deltaF = 0; 44 | deltaMilliseconds = 0; 45 | deltaMillisecondsF = 0; 46 | deltaMicroseconds = 0; 47 | deltaMicrosecondsF = 0; 48 | } 49 | 50 | Timer::~Timer() 51 | { 52 | } 53 | 54 | void Timer::Update() 55 | { 56 | LARGE_INTEGER largeInt; 57 | Win32Call(QueryPerformanceCounter(&largeInt)); 58 | int64 currentTime = largeInt.QuadPart - startTime; 59 | delta = currentTime - elapsed; 60 | deltaF = static_cast(deltaF); 61 | deltaSeconds = delta / frequency; 62 | deltaSecondsD = delta / frequencyD; 63 | deltaSecondsF = static_cast(deltaSecondsD); 64 | deltaMillisecondsD = deltaSecondsD * 1000; 65 | deltaMilliseconds = static_cast(deltaMillisecondsD); 66 | deltaMillisecondsF = static_cast(deltaMillisecondsD); 67 | deltaMicrosecondsD = deltaMillisecondsD * 1000; 68 | deltaMicroseconds = static_cast(deltaMicrosecondsD); 69 | deltaMicrosecondsF = static_cast(deltaMicrosecondsD); 70 | 71 | elapsed = currentTime; 72 | elapsedF = static_cast(elapsed); 73 | elapsedSeconds = elapsed / frequency; 74 | elapsedSecondsD = elapsed / frequencyD; 75 | elapsedSecondsF = static_cast(elapsedSecondsD); 76 | elapsedMilliseconds = static_cast(elapsedSecondsD * 1000); 77 | elapsedMillisecondsD = elapsedSecondsD * 1000; 78 | elapsedMillisecondsF = static_cast(elapsedMillisecondsD); 79 | elapsedMicroseconds = static_cast(elapsedMillisecondsD * 1000); 80 | elapsedMicrosecondsD = elapsedMillisecondsD * 1000; 81 | elapsedMicrosecondsF = static_cast(elapsedMillisecondsD); 82 | } 83 | 84 | int64 Timer::ElapsedSeconds() const 85 | { 86 | return elapsedSeconds; 87 | } 88 | 89 | float Timer::ElapsedSecondsF() const 90 | { 91 | return elapsedSecondsF; 92 | } 93 | 94 | double Timer::ElapsedSecondsD() const 95 | { 96 | return elapsedSecondsD; 97 | } 98 | 99 | int64 Timer::DeltaSeconds() const 100 | { 101 | return deltaSeconds; 102 | } 103 | 104 | float Timer::DeltaSecondsF() const 105 | { 106 | return deltaSecondsF; 107 | } 108 | 109 | double Timer::DeltaSecondsD() const 110 | { 111 | return deltaSecondsD; 112 | } 113 | 114 | int64 Timer::ElapsedMilliseconds() const 115 | { 116 | return elapsedMilliseconds; 117 | } 118 | 119 | float Timer::ElapsedMillisecondsF() const 120 | { 121 | return elapsedMillisecondsF; 122 | } 123 | 124 | double Timer::ElapsedMillisecondsD() const 125 | { 126 | return elapsedMillisecondsD; 127 | } 128 | 129 | int64 Timer::DeltaMilliseconds() const 130 | { 131 | return deltaMilliseconds; 132 | } 133 | 134 | float Timer::DeltaMillisecondsF() const 135 | { 136 | return deltaMillisecondsF; 137 | } 138 | 139 | double Timer::DeltaMillisecondsD() const 140 | { 141 | return deltaMillisecondsD; 142 | } 143 | 144 | int64 Timer::ElapsedMicroseconds() const 145 | { 146 | return elapsedMicroseconds; 147 | } 148 | 149 | float Timer::ElapsedMicrosecondsF() const 150 | { 151 | return elapsedMicrosecondsF; 152 | } 153 | 154 | double Timer::ElapsedMicrosecondsD() const 155 | { 156 | return elapsedMicrosecondsD; 157 | } 158 | 159 | int64 Timer::DeltaMicroseconds() const 160 | { 161 | return deltaMicroseconds; 162 | } 163 | 164 | float Timer::DeltaMicrosecondsF() const 165 | { 166 | return deltaMicrosecondsF; 167 | } 168 | 169 | double Timer::DeltaMicrosecondsD() const 170 | { 171 | return deltaMicrosecondsD; 172 | } 173 | 174 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Timer.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #pragma once 11 | 12 | #include "PCH.h" 13 | 14 | namespace SampleFramework11 15 | { 16 | 17 | class Timer 18 | { 19 | 20 | public: 21 | 22 | Timer(); 23 | ~Timer(); 24 | 25 | void Update(); 26 | 27 | int64 ElapsedSeconds() const; 28 | float ElapsedSecondsF() const; 29 | double ElapsedSecondsD() const; 30 | int64 DeltaSeconds() const; 31 | float DeltaSecondsF() const; 32 | double DeltaSecondsD() const; 33 | 34 | int64 ElapsedMilliseconds() const; 35 | float ElapsedMillisecondsF() const; 36 | double ElapsedMillisecondsD() const; 37 | int64 DeltaMilliseconds() const; 38 | float DeltaMillisecondsF() const; 39 | double DeltaMillisecondsD() const; 40 | 41 | int64 ElapsedMicroseconds() const; 42 | float ElapsedMicrosecondsF() const; 43 | double ElapsedMicrosecondsD() const; 44 | int64 DeltaMicroseconds() const; 45 | float DeltaMicrosecondsF() const; 46 | double DeltaMicrosecondsD() const; 47 | 48 | protected: 49 | 50 | int64 startTime; 51 | 52 | int64 frequency; 53 | double frequencyD; 54 | 55 | int64 elapsed; 56 | int64 delta; 57 | 58 | float elapsedF; 59 | float deltaF; 60 | 61 | double elapsedD; 62 | double deltaD; 63 | 64 | int64 elapsedSeconds; 65 | int64 deltaSeconds; 66 | 67 | float elapsedSecondsF; 68 | float deltaSecondsF; 69 | 70 | double elapsedSecondsD; 71 | double deltaSecondsD; 72 | 73 | int64 elapsedMilliseconds; 74 | int64 deltaMilliseconds; 75 | 76 | float elapsedMillisecondsF; 77 | float deltaMillisecondsF; 78 | 79 | double elapsedMillisecondsD; 80 | double deltaMillisecondsD; 81 | 82 | int64 elapsedMicroseconds; 83 | int64 deltaMicroseconds; 84 | 85 | float elapsedMicrosecondsF; 86 | float deltaMicrosecondsF; 87 | 88 | double elapsedMicrosecondsD; 89 | double deltaMicrosecondsD; 90 | }; 91 | 92 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/TinyEXR.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Syoyo Fujita 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef __TINYEXR_H__ 28 | #define __TINYEXR_H__ 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | typedef struct { 35 | int num_channels; 36 | const char **channel_names; 37 | float **images; // image[channels][pixels] 38 | int width; 39 | int height; 40 | } EXRImage; 41 | 42 | typedef struct { 43 | int num_channels; 44 | const char **channel_names; 45 | float ***image; // image[channels][scanlines][samples] 46 | int **offset_table; // offset_table[scanline][offsets] 47 | int width; 48 | int height; 49 | } DeepImage; 50 | 51 | // Loads single-frame OpenEXR image. Assume EXR image contains RGB(A) channels. 52 | // Application must free image data as returned by `out_rgba` 53 | // Result image format is: float x RGBA x width x hight 54 | // Return 0 if success 55 | // Returns error string in `err` when there's an error 56 | extern int LoadEXR(float **out_rgba, int *width, int *height, 57 | const char *filename, const char **err); 58 | 59 | // Loads multi-channel, single-frame OpenEXR image. 60 | // Application must free EXRImage 61 | // Return 0 if success 62 | // Returns error string in `err` when there's an error 63 | extern int LoadMultiChannelEXR(EXRImage *image, const char *filename, 64 | const char **err); 65 | 66 | // Saves floating point RGBA image as OpenEXR. 67 | // Image is compressed with ZIP. 68 | // Return 0 if success 69 | // Returns error string in `err` when there's an error 70 | //extern int SaveEXR(const float *in_rgba, int width, int height, 71 | // const char *filename, const char **err); 72 | 73 | // Saves multi-channel, single-frame OpenEXR image. 74 | // Application must free EXRImage 75 | // Return 0 if success 76 | // Returns error string in `err` when there's an error 77 | extern int SaveMultiChannelEXR(const EXRImage *image, const char *filename, 78 | const char **err); 79 | 80 | // Loads single-frame OpenEXR deep image. 81 | // Application must free memory of variables in DeepImage(image, offset_table) 82 | // Return 0 if success 83 | // Returns error string in `err` when there's an error 84 | extern int LoadDeepEXR(DeepImage *out_image, const char *filename, 85 | const char **err); 86 | 87 | // NOT YET IMPLEMENTED: 88 | // Saves single-frame OpenEXR deep image. 89 | // Return 0 if success 90 | // Returns error string in `err` when there's an error 91 | // extern int SaveDeepEXR(const DeepImage *in_image, const char *filename, 92 | // const char **err); 93 | 94 | // NOT YET IMPLEMENTED: 95 | // Loads multi-part OpenEXR deep image. 96 | // Application must free memory of variables in DeepImage(image, offset_table) 97 | // extern int LoadMultiPartDeepEXR(DeepImage **out_image, int num_parts, const 98 | // char *filename, 99 | // const char **err); 100 | 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | 105 | #endif // __TINYEXR_H__ 106 | -------------------------------------------------------------------------------- /SampleFramework11/v1.01/TwHelper.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #pragma once 11 | 12 | #include "PCH.h" 13 | #include "Exceptions.h" 14 | #include "SF11_Math.h" 15 | 16 | namespace SampleFramework11 17 | { 18 | 19 | namespace TwHelper 20 | { 21 | 22 | enum class ColorOrder 23 | { 24 | RGBA, 25 | ARGB, 26 | }; 27 | 28 | enum class ColorMode 29 | { 30 | RGB, 31 | HLS, 32 | }; 33 | 34 | enum class Axis 35 | { 36 | PositiveX, 37 | NegativeX, 38 | PositiveY, 39 | NegativeY, 40 | PositiveZ, 41 | NegativeZ, 42 | }; 43 | 44 | enum class TextMode 45 | { 46 | Light, 47 | Dark, 48 | }; 49 | 50 | enum class IconPosition 51 | { 52 | TopLeft, 53 | TopRight, 54 | BottomLeft, 55 | BottomRight, 56 | }; 57 | 58 | enum class IconAlignment 59 | { 60 | Vertical, 61 | Horizontal, 62 | }; 63 | 64 | enum class FontSize 65 | { 66 | Small = 0, 67 | Medium = 1, 68 | Large = 2, 69 | }; 70 | 71 | enum class FontStyle 72 | { 73 | Default, 74 | Fixed, 75 | }; 76 | 77 | enum class ButtonAlignment 78 | { 79 | Left, 80 | Center, 81 | Right, 82 | }; 83 | 84 | // Helper functions for AntTweakBar 85 | 86 | // Variable parameters 87 | void SetLabel(TwBar* bar, const char* varName, const char* label); 88 | void SetHelpText(TwBar* bar, const char* varName, const char* helpText); 89 | void SetGroup(TwBar* bar, const char* varName, const char* group); 90 | void SetVisible(TwBar* bar, const char* varName, bool32 visible); 91 | void SetReadOnly(TwBar* bar, const char* varName, bool32 readOnly); 92 | void SetMinMax(TwBar* bar, const char* varName, float min, float max); 93 | void SetMinMax(TwBar* bar, const char* varName, int32 min, int32 max); 94 | void SetStep(TwBar* bar, const char* varName, float step); 95 | void SetPrecision(TwBar* bar, const char* varName, int32 precision); 96 | void SetHexidecimal(TwBar* bar, const char* varName, bool32 hex); 97 | void SetShortcutKey(TwBar* bar, const char* varName, const char* shortcutKey); 98 | void SetShortcutKeyIncrement(TwBar* bar, const char* varName, const char* shortcutKey); 99 | void SetShortcutKeyDecrement(TwBar* bar, const char* varName, const char* shortcutKey); 100 | void SetBoolLabels(TwBar* bar, const char* varName, const char* falseLabel, const char* trueLabel); 101 | void SetUseAlphaChannel(TwBar* bar, const char* varName, bool32 useAlpha); 102 | void SetColorOrder(TwBar* bar, const char* varName, ColorOrder order); 103 | void SetColorMode(TwBar* bar, const char* varName, ColorMode mode); 104 | void SetUseArrowMode(TwBar* bar, const char* varName, bool32 useArrowMode, Float3 initialDirection); 105 | void SetArrowColor(TwBar* bar, const char* varName, Float3 color); 106 | void SetAxisMapping(TwBar* bar, const char* varName, Axis xAxis, Axis yAxis, Axis zAxis); 107 | void SetShowNumericalValue(TwBar* bar, const char* varName, bool32 showValue); 108 | 109 | // TweakBar parameters 110 | void SetLabel(TwBar* bar, const char* label); 111 | void SetHelpText(TwBar* bar, const char* helpText); 112 | void SetColor(TwBar* bar, Float3 color); 113 | void SetAlpha(TwBar* bar, float alpha); 114 | void SetTextMode(TwBar* bar, TextMode textMode); 115 | void SetPosition(TwBar* bar, int32 posX, int32 posY); 116 | void SetSize(TwBar* bar, int32 sizeX, int32 sizeY); 117 | void SetValuesWidth(TwBar* bar, int32 width, bool32 fit); 118 | void SetRefreshRate(TwBar* bar, float rate); 119 | void SetVisible(TwBar* bar, bool32 visible); 120 | void SetIconified(TwBar* bar, bool32 iconified); 121 | void SetIconifiable(TwBar* bar, bool32 iconifiable); 122 | void SetMovable(TwBar* bar, bool32 movable); 123 | void SetResizable(TwBar* bar, bool32 resizable); 124 | void SetAlwaysOnTop(TwBar* bar, bool32 alwaysOnTop); 125 | void SetAlwaysOnBottom(TwBar* bar, bool32 alwaysOnBottom); 126 | void SetContained(TwBar* bar, bool32 contained); 127 | void SetButtonAlignment(TwBar* bar, ButtonAlignment alignment); 128 | 129 | // Group parameters 130 | void SetOpened(TwBar* bar, const char* groupName, bool32 opened); 131 | 132 | // Global parameters 133 | void SetGlobalHelpText(const char* helpText); 134 | void SetIconPosition(IconPosition position); 135 | void SetIconAlignment(IconAlignment alignment); 136 | void SetIconMargin(int32 marginX, int32 marginY); 137 | void SetFontSize(FontSize size); 138 | void SetFontStyle(FontStyle style); 139 | void SetFontResizable(bool32 resizable); 140 | void SetFontScaling(float scale); 141 | void SetDrawOverlappedBars(bool32 drawOverlapped); 142 | void SetButtonAlignment(ButtonAlignment alignment); 143 | 144 | } 145 | 146 | } -------------------------------------------------------------------------------- /SampleFramework11/v1.01/Window.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX11 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #pragma once 11 | 12 | #include "PCH.h" 13 | 14 | #include "Exceptions.h" 15 | 16 | namespace SampleFramework11 17 | { 18 | 19 | class Window 20 | { 21 | 22 | // Public types 23 | public: 24 | 25 | typedef LRESULT (*MsgFunction)(void*, HWND, UINT, WPARAM, LPARAM); 26 | 27 | // Constructor and destructor 28 | public: 29 | 30 | Window(HINSTANCE hinstance, 31 | LPCWSTR name = L"SampleCommon Window", 32 | DWORD style = WS_CAPTION|WS_OVERLAPPED|WS_SYSMENU, 33 | DWORD exStyle = WS_EX_APPWINDOW, 34 | DWORD clientWidth = 1280, 35 | DWORD clientHeight = 720, 36 | LPCWSTR iconResource = NULL, 37 | LPCWSTR smallIconResource = NULL, 38 | LPCWSTR menuResource = NULL, 39 | LPCWSTR accelResource = NULL ); 40 | ~Window(); 41 | 42 | 43 | 44 | // Public methods 45 | public: 46 | 47 | HWND GetHwnd() const; 48 | HMENU GetMenu() const; 49 | HINSTANCE GetHinstance() const; 50 | void MessageLoop(); 51 | 52 | BOOL IsAlive() const; 53 | BOOL IsMinimized() const; 54 | LONG_PTR GetWindowStyle() const; 55 | LONG_PTR GetExtendedStyle() const; 56 | void SetWindowStyle(DWORD newStyle ); 57 | void SetExtendedStyle(DWORD newExStyle ); 58 | void Maximize(); 59 | void SetWindowPos(INT posX, INT posY); 60 | void GetWindowPos(INT& posX, INT& posY) const; 61 | void ShowWindow(bool show = true); 62 | void SetClientArea(INT clientX, INT clientY); 63 | void GetClientArea(INT& clientX, INT& clientY) const; 64 | void SetWindowTitle(LPCWSTR title); 65 | void SetScrollRanges(INT scrollRangeX, 66 | INT scrollRangeY, 67 | INT posX, 68 | INT posY); 69 | void Destroy(); 70 | 71 | INT CreateMessageBox(LPCWSTR message, LPCWSTR title = NULL, UINT type = MB_OK); 72 | 73 | void RegisterMessageCallback(UINT message, MsgFunction msgFunction, void* context); 74 | 75 | operator HWND() { return hwnd; } //conversion operator 76 | 77 | // Private methods 78 | private: 79 | void MakeWindow(LPCWSTR iconResource, LPCWSTR smallIconResource, LPCWSTR menuResource); 80 | 81 | LRESULT MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 82 | static LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 83 | 84 | // Private members 85 | private: 86 | 87 | // Window properties 88 | HWND hwnd; // The window handle 89 | HINSTANCE hinstance; // The HINSTANCE of the application 90 | std::wstring appName; // The name of the application 91 | DWORD style; // The current window style 92 | DWORD exStyle; // The extended window style 93 | HACCEL accelTable; // Accelerator table handle 94 | 95 | struct Callback 96 | { 97 | MsgFunction Function; 98 | void* Context; 99 | }; 100 | 101 | std::map messageCallbacks; // Message callback map 102 | }; 103 | 104 | } --------------------------------------------------------------------------------