├── .gitignore ├── BindlessDeferred ├── AppConfig.h ├── AppSettings.cpp ├── AppSettings.cs ├── AppSettings.h ├── AppSettings.hlsl ├── BindlessDeferred.cpp ├── BindlessDeferred.h ├── BindlessDeferred.sln ├── BindlessDeferred.vcxproj ├── BindlessDeferred.vcxproj.filters ├── BindlessDeferred_2019.sln ├── BindlessDeferred_2019.vcxproj ├── BindlessDeferred_2019.vcxproj.filters ├── BindlessDeferred_2022.sln ├── BindlessDeferred_2022.vcxproj ├── BindlessDeferred_2022.vcxproj.filters ├── ClusterVisualizer.hlsl ├── Clusters.hlsl ├── Deferred.hlsl ├── DepthOnly.hlsl ├── MSAAMask.hlsl ├── Manifest.txt ├── Mesh.hlsl ├── MeshRenderer.cpp ├── MeshRenderer.h ├── Picking.hlsl ├── PostProcessing.hlsl ├── PostProcessor.cpp ├── PostProcessor.h ├── Resolve.hlsl ├── Shading.hlsl ├── SharedTypes.h └── project.sublime-project ├── Content ├── .gitignore ├── Models │ └── Sponza │ │ ├── Background_Albedo.png │ │ ├── Background_Normal.png │ │ ├── Background_Roughness.png │ │ ├── ChainTexture_Albedo.png │ │ ├── ChainTexture_Metallic.png │ │ ├── ChainTexture_Normal.png │ │ ├── ChainTexture_Roughness.png │ │ ├── Dielectric_metallic.png │ │ ├── Lion_Albedo.png │ │ ├── Lion_Normal.png │ │ ├── Lion_Roughness.png │ │ ├── Metallic_metallic.png │ │ ├── Sponza.fbx │ │ ├── Sponza_Arch_diffuse.png │ │ ├── Sponza_Arch_normal.png │ │ ├── Sponza_Arch_roughness.png │ │ ├── Sponza_Bricks_a_Albedo.png │ │ ├── Sponza_Bricks_a_Normal.png │ │ ├── Sponza_Bricks_a_Roughness.png │ │ ├── Sponza_Ceiling_diffuse.png │ │ ├── Sponza_Ceiling_normal.png │ │ ├── Sponza_Ceiling_roughness.png │ │ ├── Sponza_Column_a_diffuse.png │ │ ├── Sponza_Column_a_normal.png │ │ ├── Sponza_Column_a_roughness.png │ │ ├── Sponza_Column_b_diffuse.png │ │ ├── Sponza_Column_b_normal.png │ │ ├── Sponza_Column_b_roughness.png │ │ ├── Sponza_Column_c_diffuse.png │ │ ├── Sponza_Column_c_normal.png │ │ ├── Sponza_Column_c_roughness.png │ │ ├── Sponza_Curtain_Blue_diffuse.png │ │ ├── Sponza_Curtain_Blue_normal.png │ │ ├── Sponza_Curtain_Green_diffuse.png │ │ ├── Sponza_Curtain_Green_normal.png │ │ ├── Sponza_Curtain_Red_diffuse.png │ │ ├── Sponza_Curtain_Red_normal.png │ │ ├── Sponza_Curtain_metallic.png │ │ ├── Sponza_Curtain_roughness.png │ │ ├── Sponza_Details_diffuse.png │ │ ├── Sponza_Details_metallic.png │ │ ├── Sponza_Details_normal.png │ │ ├── Sponza_Details_roughness.png │ │ ├── Sponza_Fabric_Blue_diffuse.png │ │ ├── Sponza_Fabric_Blue_normal.png │ │ ├── Sponza_Fabric_Green_diffuse.png │ │ ├── Sponza_Fabric_Green_normal.png │ │ ├── Sponza_Fabric_Red_diffuse.png │ │ ├── Sponza_Fabric_Red_normal.png │ │ ├── Sponza_Fabric_metallic.png │ │ ├── Sponza_Fabric_roughness.png │ │ ├── Sponza_FlagPole_diffuse.png │ │ ├── Sponza_FlagPole_normal.png │ │ ├── Sponza_FlagPole_roughness.png │ │ ├── Sponza_Floor_diffuse.png │ │ ├── Sponza_Floor_normal.png │ │ ├── Sponza_Floor_roughness.png │ │ ├── Sponza_Roof_diffuse.png │ │ ├── Sponza_Roof_normal.png │ │ ├── Sponza_Roof_roughness.png │ │ ├── Sponza_Thorn_diffuse.png │ │ ├── Sponza_Thorn_normal.png │ │ ├── Sponza_Thorn_roughness.png │ │ ├── VaseHanging_diffuse.png │ │ ├── VaseHanging_normal.png │ │ ├── VaseHanging_roughness.png │ │ ├── VasePlant_diffuse.png │ │ ├── VasePlant_normal.png │ │ ├── VasePlant_roughness.png │ │ ├── VaseRound_diffuse.png │ │ ├── VaseRound_normal.png │ │ ├── VaseRound_roughness.png │ │ ├── Vase_diffuse.png │ │ ├── Vase_normal.png │ │ ├── Vase_roughness.png │ │ └── gi_flag.png └── Textures │ ├── Decals │ ├── Decal_00_Albedo.tga │ ├── Decal_00_Normal.png │ ├── Decal_01_Albedo.tga │ ├── Decal_01_Normal.png │ ├── Decal_02_Albedo.tga │ ├── Decal_02_Normal.png │ ├── Decal_03_Albedo.tga │ ├── Decal_03_Normal.png │ ├── Decal_04_Albedo.tga │ ├── Decal_04_Normal.png │ ├── Decal_05_Albedo.tga │ ├── Decal_05_Normal.png │ ├── Decal_06_Albedo.tga │ ├── Decal_06_Normal.png │ ├── Decal_07_Albedo.tga │ └── Decal_07_Normal.png │ ├── Default.dds │ ├── DefaultBlack.dds │ ├── DefaultNormalMap.dds │ └── DefaultRoughness.dds ├── Externals ├── .gitignore ├── 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 ├── DXCompiler │ ├── Bin │ │ ├── dxcompiler.dll │ │ └── dxil.dll │ ├── Include │ │ ├── d3d12shader.h │ │ └── dxcapi.h │ └── Lib │ │ └── dxcompiler.lib ├── DirectXTex July 2017 │ ├── Include │ │ ├── DirectXTex.h │ │ └── DirectXTex.inl │ └── Lib 2017 │ │ ├── Debug │ │ ├── DirectXTex.lib │ │ └── DirectXTex.pdb │ │ └── Release │ │ ├── DirectXTex.lib │ │ └── DirectXTex.pdb ├── WinPixEventRuntime │ ├── Include │ │ └── WinPixEventRuntime │ │ │ ├── PIXEventsCommon.h │ │ │ ├── PIXEventsGenerated.h │ │ │ ├── pix3.h │ │ │ └── pix3_win.h │ └── bin │ │ ├── WinPixEventRuntime.dll │ │ └── WinPixEventRuntime.lib └── cxxopts │ ├── LICENSE │ └── include │ └── cxxopts.hpp ├── LICENSE ├── README.md └── SampleFramework12 ├── .gitignore └── v1.01 ├── .gitignore ├── App.cpp ├── App.h ├── Assert.cpp ├── Assert.h ├── Containers.h ├── EnkiTS ├── License.txt ├── LockLessMultiReadPipe.h ├── TaskScheduler.cpp ├── TaskScheduler.h ├── TaskScheduler_c.cpp └── TaskScheduler_c.h ├── Exceptions.h ├── FileIO.cpp ├── FileIO.h ├── Graphics ├── BRDF.h ├── Camera.cpp ├── Camera.h ├── DX12.cpp ├── DX12.h ├── DX12_Helpers.cpp ├── DX12_Helpers.h ├── DX12_Upload.cpp ├── DX12_Upload.h ├── DXErr.cpp ├── DXErr.h ├── Filtering.h ├── GraphicsTypes.cpp ├── GraphicsTypes.h ├── Model.cpp ├── Model.h ├── PostProcessHelper.cpp ├── PostProcessHelper.h ├── Profiler.cpp ├── Profiler.h ├── SH.cpp ├── SH.h ├── Sampling.cpp ├── Sampling.h ├── ShaderCompilation.cpp ├── ShaderCompilation.h ├── ShadowHelper.cpp ├── ShadowHelper.h ├── Skybox.cpp ├── Skybox.h ├── Spectrum.cpp ├── Spectrum.h ├── SpriteFont.cpp ├── SpriteFont.h ├── SpriteRenderer.cpp ├── SpriteRenderer.h ├── SwapChain.cpp ├── SwapChain.h ├── Textures.cpp └── Textures.h ├── HosekSky ├── ArHosekSkyModel.cpp ├── ArHosekSkyModel.h ├── ArHosekSkyModelData_CIEXYZ.h ├── ArHosekSkyModelData_RGB.h ├── ArHosekSkyModelData_Spectral.h └── README.txt ├── ImGui ├── LICENSE ├── imconfig.h ├── imgui.cpp ├── imgui.h ├── imgui_demo.cpp ├── imgui_draw.cpp ├── imgui_internal.h ├── stb_rect_pack.h ├── stb_textedit.h └── stb_truetype.h ├── ImGuiHelper.cpp ├── ImGuiHelper.h ├── Input.cpp ├── Input.h ├── InterfacePointers.h ├── Manifest.txt ├── MurmurHash.cpp ├── MurmurHash.h ├── PCH.cpp ├── PCH.h ├── SF12.props ├── SF12_Math.cpp ├── SF12_Math.h ├── Scripts ├── CopyDXC.bat ├── CopyDXCToOutputDir.bat └── SoftCopy.bat ├── Serialization.h ├── Settings.cpp ├── Settings.h ├── SettingsCompiler.exe ├── SettingsCompiler.sln ├── SettingsCompiler ├── App.config ├── Properties │ └── AssemblyInfo.cs ├── SettingTypes.cs ├── SettingsCompiler.cs └── SettingsCompiler.csproj ├── SettingsCompilerAttributes.dll ├── SettingsCompilerAttributes ├── Attributes.cs ├── Properties │ └── AssemblyInfo.cs └── SettingsCompilerAttributes.csproj ├── Shaders ├── BRDF.hlsl ├── Constants.hlsl ├── Conversion.hlsl ├── DecodeTextureCS.hlsl ├── DescriptorTables.hlsl ├── EVSM.hlsl ├── FullScreenTriangle.hlsl ├── ImGui.hlsl ├── MSM.hlsl ├── PPCommon.hlsl ├── Quaternion.hlsl ├── SH.hlsl ├── SMConvert.hlsl ├── Shadows.hlsl ├── Skybox.hlsl └── Sprite.hlsl ├── Timer.cpp ├── Timer.h ├── TinyEXR.cpp ├── TinyEXR.h ├── Tools ├── Packager.exe └── Packager │ ├── App.config │ ├── MainFrm.Designer.cs │ ├── MainFrm.cs │ ├── MainFrm.resx │ ├── Packager.csproj │ ├── Packager.sln │ ├── Program.cs │ └── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Utility.cpp ├── Utility.h ├── Window.cpp ├── Window.h └── sf12.natvis /.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 | *.VC.opendb 58 | *.VC.db 59 | 60 | # Visual Studio profiler 61 | *.psess 62 | *.vsp 63 | *.vspx 64 | 65 | # Guidance Automation Toolkit 66 | *.gpState 67 | 68 | # ReSharper is a .NET coding add-in 69 | _ReSharper*/ 70 | *.[Rr]e[Ss]harper 71 | 72 | # TeamCity is a build add-in 73 | _TeamCity* 74 | 75 | # DotCover is a Code Coverage Tool 76 | *.dotCover 77 | 78 | # NCrunch 79 | *.ncrunch* 80 | .*crunch*.local.xml 81 | 82 | # Installshield output folder 83 | [Ee]xpress/ 84 | 85 | # DocProject is a documentation generator add-in 86 | DocProject/buildhelp/ 87 | DocProject/Help/*.HxT 88 | DocProject/Help/*.HxC 89 | DocProject/Help/*.hhc 90 | DocProject/Help/*.hhk 91 | DocProject/Help/*.hhp 92 | DocProject/Help/Html2 93 | DocProject/Help/html 94 | 95 | # Click-Once directory 96 | publish/ 97 | 98 | # Publish Web Output 99 | *.Publish.xml 100 | *.pubxml 101 | 102 | # NuGet Packages Directory 103 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 104 | #packages/ 105 | 106 | # Windows Azure Build Output 107 | csx 108 | *.build.csdef 109 | 110 | # Windows Store app package directory 111 | AppPackages/ 112 | 113 | # Others 114 | sql/ 115 | *.Cache 116 | ClientBin/ 117 | [Ss]tyle[Cc]op.* 118 | ~$* 119 | *~ 120 | *.dbmdl 121 | *.[Pp]ublish.xml 122 | *.pfx 123 | *.publishsettings 124 | 125 | # RIA/Silverlight projects 126 | Generated_Code/ 127 | 128 | # Backup & report files from converting an old project file to a newer 129 | # Visual Studio version. Backup files are not needed, because we have git ;-) 130 | _UpgradeReport_Files/ 131 | Backup*/ 132 | UpgradeLog*.XML 133 | UpgradeLog*.htm 134 | 135 | # SQL Server files 136 | App_Data/*.mdf 137 | App_Data/*.ldf 138 | 139 | .vs/ 140 | 141 | ############# 142 | ## Windows detritus 143 | ############# 144 | 145 | # Windows image file caches 146 | Thumbs.db 147 | ehthumbs.db 148 | 149 | # Folder config file 150 | Desktop.ini 151 | 152 | # Recycle Bin used on file shares 153 | $RECYCLE.BIN/ 154 | 155 | # Mac crap 156 | .DS_Store 157 | 158 | #################### 159 | ## Sample framework 160 | #################### 161 | 162 | ShaderCache/ 163 | *.exe 164 | *.dll 165 | *.deps 166 | CorneaRefraction/CorneaRefractionMap.dds 167 | Temp_Lightmap.dds 168 | imgui.ini 169 | 170 | # Sublime 171 | *.sublime-workspace 172 | *.args.json -------------------------------------------------------------------------------- /BindlessDeferred/AppConfig.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Bindless Deferred Texturing Sample 4 | // by MJP 5 | // http://mynameismjp.wordpress.com/ 6 | // 7 | // All code and content licensed under the MIT license 8 | // 9 | //================================================================================================= 10 | 11 | #define EnableSkyModel_ (1) 12 | #define EnableEmbree_ (0) 13 | #define EnableShaderModel6_ (1) -------------------------------------------------------------------------------- /BindlessDeferred/AppSettings.hlsl: -------------------------------------------------------------------------------- 1 | struct AppSettings_Layout 2 | { 3 | bool EnableSun; 4 | bool SunAreaLightApproximation; 5 | float SunSize; 6 | float3 SunDirection; 7 | int MSAAMode; 8 | bool RenderLights; 9 | bool RenderDecals; 10 | int RenderMode; 11 | float Exposure; 12 | float BloomExposure; 13 | float BloomMagnitude; 14 | float BloomBlurSigma; 15 | bool EnableAlbedoMaps; 16 | bool EnableNormalMaps; 17 | bool EnableSpecular; 18 | bool ShowLightCounts; 19 | bool ShowDecalCounts; 20 | bool ShowMSAAMask; 21 | bool ShowUVGradients; 22 | bool AnimateLightIntensity; 23 | }; 24 | 25 | ConstantBuffer AppSettings : register(b12); 26 | 27 | static const int MSAAModes_MSAANone = 0; 28 | static const int MSAAModes_MSAA2x = 1; 29 | static const int MSAAModes_MSAA4x = 2; 30 | 31 | static const int Scenes_Sponza = 0; 32 | 33 | static const int RenderModes_ClusteredForward = 0; 34 | static const int RenderModes_DeferredTexturing = 1; 35 | 36 | static const int ClusterRasterizationModes_Normal = 0; 37 | static const int ClusterRasterizationModes_MSAA4x = 1; 38 | static const int ClusterRasterizationModes_MSAA8x = 2; 39 | static const int ClusterRasterizationModes_Conservative = 3; 40 | 41 | static const uint ClusterTileSize = 16; 42 | static const uint NumZTiles = 16; 43 | static const uint NumDecalTypes = 8; 44 | static const uint NumTexturesPerDecal = 2; 45 | static const uint NumDecalTextures = 16; 46 | static const uint MaxDecals = 64; 47 | static const uint DecalElementsPerCluster = 2; 48 | static const uint MaxSpotLights = 32; 49 | static const uint SpotLightElementsPerCluster = 1; 50 | static const float SpotLightRange = 7.5000f; 51 | static const float SpotShadowNearClip = 0.1000f; 52 | static const uint DeferredTileSize = 8; 53 | static const uint DeferredTileMaskSize = 2; 54 | static const float DeferredUVScale = 2.0000f; 55 | -------------------------------------------------------------------------------- /BindlessDeferred/BindlessDeferred.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26403.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BindlessDeferred", "BindlessDeferred.vcxproj", "{FA705507-9C58-4413-8878-8795F3B9897D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {FA705507-9C58-4413-8878-8795F3B9897D}.Debug|x64.ActiveCfg = Debug|x64 15 | {FA705507-9C58-4413-8878-8795F3B9897D}.Debug|x64.Build.0 = Debug|x64 16 | {FA705507-9C58-4413-8878-8795F3B9897D}.Release|x64.ActiveCfg = Release|x64 17 | {FA705507-9C58-4413-8878-8795F3B9897D}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /BindlessDeferred/BindlessDeferred_2019.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28922.388 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BindlessDeferred_2019", "BindlessDeferred_2019.vcxproj", "{FA705507-9C58-4413-8878-8795F3B9897D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {FA705507-9C58-4413-8878-8795F3B9897D}.Debug|x64.ActiveCfg = Debug|x64 15 | {FA705507-9C58-4413-8878-8795F3B9897D}.Debug|x64.Build.0 = Debug|x64 16 | {FA705507-9C58-4413-8878-8795F3B9897D}.Release|x64.ActiveCfg = Release|x64 17 | {FA705507-9C58-4413-8878-8795F3B9897D}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /BindlessDeferred/BindlessDeferred_2022.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.32014.148 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BindlessDeferred_2022", "BindlessDeferred_2022.vcxproj", "{FA705507-9C58-4413-8878-8795F3B9897D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {FA705507-9C58-4413-8878-8795F3B9897D}.Debug|x64.ActiveCfg = Debug|x64 15 | {FA705507-9C58-4413-8878-8795F3B9897D}.Debug|x64.Build.0 = Debug|x64 16 | {FA705507-9C58-4413-8878-8795F3B9897D}.Release|x64.ActiveCfg = Release|x64 17 | {FA705507-9C58-4413-8878-8795F3B9897D}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /BindlessDeferred/ClusterVisualizer.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Bindless Deferred Texturing 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 16 | #include "AppSettings.hlsl" 17 | 18 | //================================================================================================= 19 | // Resources 20 | //================================================================================================= 21 | struct ClusterVisConstants 22 | { 23 | row_major float4x4 Projection; 24 | float3 ViewMin; 25 | float NearClip; 26 | float3 ViewMax; 27 | float InvClipRange; 28 | float2 DisplaySize; 29 | uint NumXTiles; 30 | uint NumXYTiles; 31 | 32 | uint DecalClusterBufferIdx; 33 | uint SpotLightClusterBufferIdx; 34 | }; 35 | 36 | ConstantBuffer CBuffer : register(b0); 37 | 38 | // ================================================================================================ 39 | // Pixel shader for visualizing decal/light counts from an overhead view of the frustum 40 | // ================================================================================================ 41 | float4 ClusterVisualizerPS(in float4 PositionSS : SV_Position, in float2 TexCoord : TEXCOORD) : SV_Target0 42 | { 43 | ByteAddressBuffer decalClusterBuffer = RawBufferTable[CBuffer.DecalClusterBufferIdx]; 44 | ByteAddressBuffer spotLightClusterBuffer = RawBufferTable[CBuffer.SpotLightClusterBufferIdx]; 45 | 46 | float3 viewPos = lerp(CBuffer.ViewMin, CBuffer.ViewMax, float3(TexCoord.x, 0.5f, 1.0f - TexCoord.y)); 47 | float4 projectedPos = mul(float4(viewPos, 1.0f), CBuffer.Projection); 48 | projectedPos.xyz /= projectedPos.w; 49 | projectedPos.y *= -1.0f; 50 | projectedPos.xy = projectedPos.xy * 0.5f + 0.5f; 51 | 52 | float2 screenPos = projectedPos.xy * CBuffer.DisplaySize; 53 | float normalizedZPos = saturate((viewPos.z - CBuffer.NearClip) * CBuffer.InvClipRange); 54 | uint3 tileCoords = uint3(uint2(screenPos) / ClusterTileSize, normalizedZPos * NumZTiles); 55 | uint clusterIdx = (tileCoords.z * CBuffer.NumXYTiles) + (tileCoords.y * CBuffer.NumXTiles) + tileCoords.x; 56 | 57 | if(projectedPos.x < 0.0f || projectedPos.x > 1.0f || projectedPos.y < 0.0f || projectedPos.y > 1.0f) 58 | return 0.0f; 59 | 60 | float3 output = 0.05f; 61 | 62 | { 63 | uint numLights = 0; 64 | uint clusterOffset = clusterIdx * SpotLightElementsPerCluster; 65 | 66 | [unroll] 67 | for(uint elemIdx = 0; elemIdx < SpotLightElementsPerCluster; ++elemIdx) 68 | { 69 | uint clusterElemMask = spotLightClusterBuffer.Load((clusterOffset + elemIdx) * 4); 70 | numLights += countbits(clusterElemMask); 71 | } 72 | 73 | output.x += numLights / 10.0f; 74 | } 75 | 76 | { 77 | uint numDecals = 0; 78 | uint clusterOffset = clusterIdx * DecalElementsPerCluster; 79 | 80 | [unroll] 81 | for(uint elemIdx = 0; elemIdx < DecalElementsPerCluster; ++elemIdx) 82 | { 83 | uint clusterElemMask = decalClusterBuffer.Load((clusterOffset + elemIdx) * 4); 84 | numDecals += countbits(clusterElemMask); 85 | } 86 | 87 | output.y += numDecals / 10.0f; 88 | } 89 | 90 | return float4(output, 0.9f); 91 | } -------------------------------------------------------------------------------- /BindlessDeferred/DepthOnly.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Bindless Deferred Texturing 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 "SharedTypes.h" 14 | 15 | // ================================================================================================ 16 | // Constant buffers 17 | // ================================================================================================ 18 | struct VSConstants 19 | { 20 | row_major float4x4 World; 21 | row_major float4x4 View; 22 | row_major float4x4 WorldViewProjection; 23 | }; 24 | 25 | struct MatIndexConstants 26 | { 27 | uint MaterialTextureIndicesIdx; 28 | uint MatIndex; 29 | }; 30 | 31 | ConstantBuffer VSCBuffer : register(b0); 32 | ConstantBuffer MatIndexCBuffer : register(b1); 33 | 34 | //================================================================================================= 35 | // Resources 36 | //================================================================================================= 37 | StructuredBuffer MaterialIndicesBuffers[] : register(t0, space100); 38 | 39 | SamplerState AnisoSampler : register(s0); 40 | 41 | // ================================================================================================ 42 | // Input/Output structs 43 | // ================================================================================================ 44 | struct VSInput 45 | { 46 | float4 PositionOS : POSITION; 47 | float2 UV : UV; 48 | }; 49 | 50 | struct VSOutput 51 | { 52 | float4 PositionCS : SV_Position; 53 | float2 UV : UV; 54 | }; 55 | 56 | // ================================================================================================ 57 | // Vertex Shader 58 | // ================================================================================================ 59 | VSOutput VS(in VSInput input) 60 | { 61 | VSOutput output; 62 | 63 | // Calc the clip-space position 64 | output.PositionCS = mul(input.PositionOS, VSCBuffer.WorldViewProjection); 65 | output.UV = input.UV; 66 | 67 | return output; 68 | } 69 | 70 | // ================================================================================================ 71 | // Pixel Shader 72 | // ================================================================================================ 73 | void PS(in VSOutput input) 74 | { 75 | StructuredBuffer matIndicesBuffer = MaterialIndicesBuffers[MatIndexCBuffer.MaterialTextureIndicesIdx]; 76 | MaterialTextureIndices matIndices = matIndicesBuffer[MatIndexCBuffer.MatIndex]; 77 | Texture2D AlbedoMap = Tex2DTable[matIndices.Albedo]; 78 | const float alpha = AlbedoMap.Sample(AnisoSampler, input.UV).w; 79 | if(alpha < 0.5f) 80 | discard; 81 | } -------------------------------------------------------------------------------- /BindlessDeferred/MSAAMask.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Bindless Deferred Texturing 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 16 | #include "AppSettings.hlsl" 17 | 18 | struct TileMSAAMask 19 | { 20 | uint Masks[DeferredTileMaskSize]; 21 | }; 22 | 23 | //================================================================================================= 24 | // Constant buffers 25 | //================================================================================================= 26 | struct MSAAMaskConstants 27 | { 28 | uint NumXTiles; 29 | uint MaterialIDMapIdx; 30 | uint UVMapIdx; 31 | }; 32 | 33 | ConstantBuffer CBuffer : register(b0); 34 | 35 | //================================================================================================= 36 | // Resources 37 | //================================================================================================= 38 | Texture2DMS MaterialIDMaps[] : register(t0, space100); 39 | Texture2DMS UVMap : register(t1); 40 | 41 | AppendStructuredBuffer NonMSAATiles : register(u0); 42 | AppendStructuredBuffer MSAATiles : register(u1); 43 | RWStructuredBuffer MSAAMask : register(u2); 44 | 45 | groupshared TileMSAAMask GroupMask; 46 | 47 | //================================================================================================= 48 | // Pixel shader for generating a per-sample shading mask 49 | //================================================================================================= 50 | [numthreads(DeferredTileSize, DeferredTileSize, 1)] 51 | void MSAAMaskCS(in uint3 DispatchID : SV_DispatchThreadID, in uint GroupIndex : SV_GroupIndex, in uint3 GroupID : SV_GroupID) 52 | { 53 | uint2 pixelPos = DispatchID.xy; 54 | 55 | Texture2DMS uvMap = Tex2DMSTable[CBuffer.UVMapIdx]; 56 | Texture2DMS materialIDMap = MaterialIDMaps[CBuffer.UVMapIdx]; 57 | 58 | uint materialID = materialIDMap.Load(pixelPos, 0) & 0x7F; 59 | float2 zGradients = uvMap.Load(pixelPos, 0).zw; 60 | uint edge = 0; 61 | 62 | [unroll] 63 | for(uint i = 1; i < MSAASamples_; ++i) 64 | { 65 | edge += (materialIDMap.Load(pixelPos, i) & 0x7F) != materialID; 66 | #if UseZGradients_ 67 | edge += any(abs(UVMap.Load(pixelPos, i).zw - zGradients) > 0.0025f); 68 | #endif 69 | } 70 | 71 | const bool perSample = edge > 0; 72 | 73 | if(GroupIndex < DeferredTileMaskSize) 74 | GroupMask.Masks[GroupIndex] = 0; 75 | 76 | GroupMemoryBarrierWithGroupSync(); 77 | 78 | if(perSample) 79 | InterlockedOr(GroupMask.Masks[GroupIndex / 32], 1u << (GroupIndex % 32)); 80 | 81 | GroupMemoryBarrierWithGroupSync(); 82 | 83 | if(GroupIndex == 0) 84 | { 85 | uint packedTilePos = GroupID.x & 0xFFFF; 86 | packedTilePos |= (GroupID.y & 0xFFFF) << 16; 87 | 88 | uint groupEdge = 0; 89 | for(uint j = 0; j < DeferredTileMaskSize; ++j) 90 | groupEdge |= GroupMask.Masks[j]; 91 | 92 | if(groupEdge) 93 | MSAATiles.Append(packedTilePos); 94 | else 95 | NonMSAATiles.Append(packedTilePos); 96 | 97 | uint tileIdx = GroupID.y * CBuffer.NumXTiles + GroupID.x; 98 | MSAAMask[tileIdx] = GroupMask; 99 | } 100 | } -------------------------------------------------------------------------------- /BindlessDeferred/Manifest.txt: -------------------------------------------------------------------------------- 1 | [References] 2 | SampleFramework12\v1.01 3 | 4 | [Local] 5 | 6 | SharedTypes.h 7 | 8 | [Content] 9 | 10 | Models\Sponza\Sponza.fbx 11 | Models\Sponza\*.png 12 | Textures\Decals\*.tga 13 | Textures\Decals\*.png 14 | 15 | [Externals] 16 | 17 | -------------------------------------------------------------------------------- /BindlessDeferred/Picking.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Bindless Deferred Texturing 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 | 14 | struct PickingConstants 15 | { 16 | row_major float4x4 InverseViewProjection; 17 | uint2 PixelPos; 18 | float2 RTSize; 19 | uint TangentMapIdx; 20 | uint DepthMapIdx; 21 | }; 22 | 23 | ConstantBuffer CBuffer : register(b0); 24 | 25 | struct PickingData 26 | { 27 | float3 Position; 28 | float3 Normal; 29 | }; 30 | 31 | RWStructuredBuffer PickingBuffer : register(u0); 32 | 33 | [numthreads(1, 1, 1)] 34 | void PickingCS() 35 | { 36 | #if MSAA_ 37 | Texture2DMS tangentMap = Tex2DMSTable[CBuffer.TangentMapIdx]; 38 | Texture2DMS depthMap = Tex2DMSTable[CBuffer.DepthMapIdx]; 39 | 40 | float zw = depthMap.Load(CBuffer.PixelPos, 0).x; 41 | Quaternion tangentFrame = UnpackQuaternion(tangentMap.Load(CBuffer.PixelPos, 0)); 42 | #else 43 | Texture2D tangentMap = Tex2DTable[CBuffer.TangentMapIdx]; 44 | Texture2D depthMap = Tex2DTable[CBuffer.DepthMapIdx]; 45 | 46 | float zw = depthMap[CBuffer.PixelPos].x; 47 | Quaternion tangentFrame = UnpackQuaternion(tangentMap[CBuffer.PixelPos]); 48 | #endif 49 | 50 | float2 uv = (CBuffer.PixelPos + 0.5f) / CBuffer.RTSize; 51 | uv = uv * 2.0f - 1.0f; 52 | uv.y *= -1.0f; 53 | float4 positionWS = mul(float4(uv, zw, 1.0f), CBuffer.InverseViewProjection); 54 | 55 | float3 normal = normalize(QuatRotate(float3(0.0f, 0.0f, 1.0f), tangentFrame)); 56 | 57 | PickingData pickingData; 58 | pickingData.Position = positionWS.xyz / positionWS.w; 59 | pickingData.Normal = normal; 60 | PickingBuffer[0] = pickingData; 61 | } -------------------------------------------------------------------------------- /BindlessDeferred/PostProcessor.cpp: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Bindless Deferred Texturing 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 | 15 | #include "PostProcessor.h" 16 | 17 | void PostProcessor::Initialize() 18 | { 19 | helper.Initialize(); 20 | 21 | // Load the shaders 22 | toneMap = CompileFromFile(L"PostProcessing.hlsl", "ToneMap", ShaderType::Pixel); 23 | scale = CompileFromFile(L"PostProcessing.hlsl", "Scale", ShaderType::Pixel); 24 | blurH = CompileFromFile(L"PostProcessing.hlsl", "BlurH", ShaderType::Pixel); 25 | blurV = CompileFromFile(L"PostProcessing.hlsl", "BlurV", ShaderType::Pixel); 26 | bloom = CompileFromFile(L"PostProcessing.hlsl", "Bloom", ShaderType::Pixel); 27 | } 28 | 29 | void PostProcessor::Shutdown() 30 | { 31 | helper.Shutdown(); 32 | } 33 | 34 | void PostProcessor::CreatePSOs() 35 | { 36 | } 37 | 38 | void PostProcessor::DestroyPSOs() 39 | { 40 | helper.ClearCache(); 41 | } 42 | 43 | void PostProcessor::Render(ID3D12GraphicsCommandList* cmdList, const RenderTexture& input, const RenderTexture& output) 44 | { 45 | helper.Begin(cmdList); 46 | 47 | TempRenderTarget* bloomTarget = Bloom(cmdList, input); 48 | 49 | // Apply tone mapping 50 | uint32 inputs[2] = { input.SRV(), bloomTarget->RT.SRV() }; 51 | const RenderTexture* outputs[1] = { &output }; 52 | helper.PostProcess(toneMap, "Tone Mapping", inputs, ArraySize_(inputs), outputs, ArraySize_(outputs)); 53 | 54 | bloomTarget->InUse = false; 55 | 56 | helper.End(); 57 | } 58 | 59 | TempRenderTarget* PostProcessor::Bloom(ID3D12GraphicsCommandList* cmdList, const RenderTexture& input) 60 | { 61 | PIXMarker marker(cmdList, "Bloom"); 62 | 63 | const uint64 bloomWidth = input.Texture.Width / 2; 64 | const uint64 bloomHeight = input.Texture.Height / 2; 65 | 66 | TempRenderTarget* downscale1 = helper.GetTempRenderTarget(bloomWidth, bloomHeight, DXGI_FORMAT_R16G16B16A16_FLOAT); 67 | downscale1->RT.MakeWritable(cmdList); 68 | 69 | helper.PostProcess(bloom, "Bloom Initial Pass", input, downscale1); 70 | 71 | TempRenderTarget* blurTemp = helper.GetTempRenderTarget(bloomWidth, bloomHeight, DXGI_FORMAT_R16G16B16A16_FLOAT); 72 | downscale1->RT.MakeReadable(cmdList); 73 | 74 | // Blur it 75 | for(uint64 i = 0; i < 2; ++i) 76 | { 77 | blurTemp->RT.MakeWritable(cmdList); 78 | 79 | helper.PostProcess(blurH, "Horizontal Bloom Blur", downscale1, blurTemp); 80 | 81 | blurTemp->RT.MakeReadable(cmdList); 82 | downscale1->RT.MakeWritable(cmdList); 83 | 84 | helper.PostProcess(blurV, "Vertical Bloom Blur", blurTemp, downscale1); 85 | 86 | downscale1->RT.MakeReadable(cmdList); 87 | } 88 | 89 | blurTemp->InUse = false; 90 | 91 | return downscale1; 92 | } -------------------------------------------------------------------------------- /BindlessDeferred/PostProcessor.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Bindless Deferred Texturing 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 | 17 | #include "AppSettings.h" 18 | 19 | using namespace SampleFramework12; 20 | 21 | class PostProcessor 22 | { 23 | 24 | public: 25 | 26 | void Initialize(); 27 | void Shutdown(); 28 | 29 | void CreatePSOs(); 30 | void DestroyPSOs(); 31 | 32 | void Render(ID3D12GraphicsCommandList* cmdList, const RenderTexture& input, const RenderTexture& output); 33 | 34 | protected: 35 | 36 | TempRenderTarget* Bloom(ID3D12GraphicsCommandList* cmdList, const RenderTexture& input); 37 | 38 | PostProcessHelper helper; 39 | 40 | PixelShaderPtr toneMap; 41 | PixelShaderPtr scale; 42 | PixelShaderPtr bloom; 43 | PixelShaderPtr blurH; 44 | PixelShaderPtr blurV; 45 | }; -------------------------------------------------------------------------------- /BindlessDeferred/Resolve.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Bindless Deferred Texturing 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 16 | #include "AppSettings.hlsl" 17 | 18 | //================================================================================================= 19 | // Resources 20 | //================================================================================================= 21 | struct ResolveConstants 22 | { 23 | uint2 OutputSize; 24 | uint InputTextureIdx; 25 | }; 26 | 27 | ConstantBuffer CBuffer : register(b0); 28 | 29 | float Luminance(in float3 clr) 30 | { 31 | return dot(clr, float3(0.299f, 0.587f, 0.114f)); 32 | } 33 | 34 | float4 ResolvePS(in float4 Position : SV_Position) : SV_Target0 35 | { 36 | #if Deferred_ 37 | Texture2D inputTexture = Tex2DTable[CBuffer.InputTextureIdx]; 38 | #else 39 | Texture2DMS inputTexture = Tex2DMSTable[CBuffer.InputTextureIdx]; 40 | #endif 41 | 42 | uint2 pixelPos = uint2(Position.xy); 43 | 44 | #if Deferred_ 45 | if(inputTexture[pixelPos].w <= 1.0f) 46 | return float4(inputTexture[pixelPos].xyz, 1.0f); 47 | #endif 48 | 49 | const float ExposureFilterOffset = 2.0f; 50 | const float exposure = exp2(AppSettings.Exposure + ExposureFilterOffset) / FP16Scale; 51 | 52 | float3 sum = 0.0f; 53 | float totalWeight = 0.0f; 54 | 55 | [unroll] 56 | for(uint subSampleIdx = 0; subSampleIdx < MSAASamples_; ++subSampleIdx) 57 | { 58 | #if Deferred_ 59 | // For the deferred path, the output target is 2x the width/height since 60 | // D3D doesn't support writing to MSAA textures trough a UAV 61 | uint2 offset = uint2(subSampleIdx % 2, subSampleIdx / 2); 62 | offset *= CBuffer.OutputSize; 63 | float3 texSample = inputTexture[pixelPos + offset].xyz; 64 | #else 65 | float3 texSample = inputTexture.Load(pixelPos, subSampleIdx).xyz; 66 | #endif 67 | 68 | texSample = max(texSample, 0.0f); 69 | 70 | float sampleLum = Luminance(texSample); 71 | sampleLum *= exposure; 72 | float weight = 1.0f / (1.0f + sampleLum); 73 | 74 | sum += texSample * weight; 75 | totalWeight += weight; 76 | } 77 | 78 | float3 output = sum / max(totalWeight, 0.00001f); 79 | output = max(output, 0.0f); 80 | 81 | return float4(output, 1.0f); 82 | } -------------------------------------------------------------------------------- /BindlessDeferred/SharedTypes.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // Bindless Deferred Texturing 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 SampleFramework12::Float2 float2; 16 | typedef SampleFramework12::Float3 float3; 17 | typedef SampleFramework12::Float4 float4; 18 | 19 | typedef uint32 uint; 20 | typedef SampleFramework12::Uint2 uint2; 21 | typedef SampleFramework12::Uint3 uint3; 22 | typedef SampleFramework12::Uint4 uint4; 23 | 24 | typedef SampleFramework12::Int2 int2; 25 | typedef SampleFramework12::Int3 int3; 26 | typedef SampleFramework12::Int4 int4; 27 | 28 | #endif 29 | 30 | struct MaterialTextureIndices 31 | { 32 | uint Albedo; 33 | uint Normal; 34 | uint Roughness; 35 | uint Metallic; 36 | }; 37 | 38 | struct Decal 39 | { 40 | Quaternion Orientation; 41 | float3 Size; 42 | float3 Position; 43 | uint AlbedoTexIdx; 44 | uint NormalTexIdx; 45 | 46 | #if _WINDOWS 47 | Decal() : AlbedoTexIdx(uint32(-1)), NormalTexIdx(uint32(-1)) { } 48 | #endif 49 | }; 50 | 51 | struct SpotLight 52 | { 53 | float3 Position; 54 | float AngularAttenuationX; 55 | float3 Direction; 56 | float AngularAttenuationY; 57 | float3 Intensity; 58 | float Range; 59 | }; 60 | 61 | struct ClusterBounds 62 | { 63 | float3 Position; 64 | Quaternion Orientation; 65 | float3 Scale; 66 | uint2 ZBounds; 67 | }; 68 | -------------------------------------------------------------------------------- /BindlessDeferred/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", ".vs"] 9 | }, 10 | { 11 | "path": "../SampleFramework12/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", ".vs"] 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 | } -------------------------------------------------------------------------------- /Content/.gitignore: -------------------------------------------------------------------------------- 1 | ## Exclusions for content 2 | 3 | !*.obj 4 | *.swatch 5 | *.swatches -------------------------------------------------------------------------------- /Content/Models/Sponza/Background_Albedo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Background_Albedo.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Background_Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Background_Normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Background_Roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Background_Roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/ChainTexture_Albedo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/ChainTexture_Albedo.png -------------------------------------------------------------------------------- /Content/Models/Sponza/ChainTexture_Metallic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/ChainTexture_Metallic.png -------------------------------------------------------------------------------- /Content/Models/Sponza/ChainTexture_Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/ChainTexture_Normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/ChainTexture_Roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/ChainTexture_Roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Dielectric_metallic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Dielectric_metallic.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Lion_Albedo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Lion_Albedo.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Lion_Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Lion_Normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Lion_Roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Lion_Roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Metallic_metallic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Metallic_metallic.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza.fbx -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Arch_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Arch_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Arch_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Arch_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Arch_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Arch_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Bricks_a_Albedo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Bricks_a_Albedo.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Bricks_a_Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Bricks_a_Normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Bricks_a_Roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Bricks_a_Roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Ceiling_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Ceiling_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Ceiling_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Ceiling_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Ceiling_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Ceiling_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Column_a_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Column_a_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Column_a_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Column_a_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Column_a_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Column_a_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Column_b_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Column_b_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Column_b_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Column_b_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Column_b_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Column_b_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Column_c_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Column_c_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Column_c_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Column_c_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Column_c_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Column_c_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Curtain_Blue_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Curtain_Blue_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Curtain_Blue_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Curtain_Blue_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Curtain_Green_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Curtain_Green_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Curtain_Green_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Curtain_Green_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Curtain_Red_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Curtain_Red_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Curtain_Red_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Curtain_Red_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Curtain_metallic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Curtain_metallic.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Curtain_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Curtain_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Details_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Details_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Details_metallic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Details_metallic.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Details_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Details_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Details_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Details_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Fabric_Blue_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Fabric_Blue_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Fabric_Blue_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Fabric_Blue_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Fabric_Green_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Fabric_Green_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Fabric_Green_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Fabric_Green_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Fabric_Red_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Fabric_Red_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Fabric_Red_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Fabric_Red_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Fabric_metallic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Fabric_metallic.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Fabric_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Fabric_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_FlagPole_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_FlagPole_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_FlagPole_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_FlagPole_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_FlagPole_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_FlagPole_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Floor_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Floor_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Floor_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Floor_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Floor_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Floor_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Roof_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Roof_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Roof_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Roof_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Roof_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Roof_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Thorn_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Thorn_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Thorn_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Thorn_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Sponza_Thorn_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Sponza_Thorn_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/VaseHanging_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/VaseHanging_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/VaseHanging_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/VaseHanging_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/VaseHanging_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/VaseHanging_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/VasePlant_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/VasePlant_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/VasePlant_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/VasePlant_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/VasePlant_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/VasePlant_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/VaseRound_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/VaseRound_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/VaseRound_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/VaseRound_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/VaseRound_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/VaseRound_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Vase_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Vase_diffuse.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Vase_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Vase_normal.png -------------------------------------------------------------------------------- /Content/Models/Sponza/Vase_roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/Vase_roughness.png -------------------------------------------------------------------------------- /Content/Models/Sponza/gi_flag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Models/Sponza/gi_flag.png -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_00_Albedo.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_00_Albedo.tga -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_00_Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_00_Normal.png -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_01_Albedo.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_01_Albedo.tga -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_01_Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_01_Normal.png -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_02_Albedo.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_02_Albedo.tga -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_02_Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_02_Normal.png -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_03_Albedo.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_03_Albedo.tga -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_03_Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_03_Normal.png -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_04_Albedo.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_04_Albedo.tga -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_04_Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_04_Normal.png -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_05_Albedo.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_05_Albedo.tga -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_05_Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_05_Normal.png -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_06_Albedo.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_06_Albedo.tga -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_06_Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_06_Normal.png -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_07_Albedo.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_07_Albedo.tga -------------------------------------------------------------------------------- /Content/Textures/Decals/Decal_07_Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Decals/Decal_07_Normal.png -------------------------------------------------------------------------------- /Content/Textures/Default.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/Default.dds -------------------------------------------------------------------------------- /Content/Textures/DefaultBlack.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/DefaultBlack.dds -------------------------------------------------------------------------------- /Content/Textures/DefaultNormalMap.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/DefaultNormalMap.dds -------------------------------------------------------------------------------- /Content/Textures/DefaultRoughness.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Content/Textures/DefaultRoughness.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 | 24 | DXCompiler/bin/dxcompiler.pdb 25 | -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/bin/assimp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/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/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/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Externals/Assimp-3.1.1/include/defs.h -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/matrix3x3.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Externals/Assimp-3.1.1/include/matrix3x3.h -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/matrix3x3.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Externals/Assimp-3.1.1/include/matrix3x3.inl -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/matrix4x4.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Externals/Assimp-3.1.1/include/matrix4x4.h -------------------------------------------------------------------------------- /Externals/Assimp-3.1.1/include/matrix4x4.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Externals/Assimp-3.1.1/include/matrix4x4.inl -------------------------------------------------------------------------------- /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/lib/assimp.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Externals/Assimp-3.1.1/lib/assimp.lib -------------------------------------------------------------------------------- /Externals/DXCompiler/Bin/dxcompiler.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Externals/DXCompiler/Bin/dxcompiler.dll -------------------------------------------------------------------------------- /Externals/DXCompiler/Bin/dxil.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Externals/DXCompiler/Bin/dxil.dll -------------------------------------------------------------------------------- /Externals/DXCompiler/Lib/dxcompiler.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Externals/DXCompiler/Lib/dxcompiler.lib -------------------------------------------------------------------------------- /Externals/DirectXTex July 2017/Lib 2017/Debug/DirectXTex.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Externals/DirectXTex July 2017/Lib 2017/Debug/DirectXTex.lib -------------------------------------------------------------------------------- /Externals/DirectXTex July 2017/Lib 2017/Debug/DirectXTex.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Externals/DirectXTex July 2017/Lib 2017/Debug/DirectXTex.pdb -------------------------------------------------------------------------------- /Externals/DirectXTex July 2017/Lib 2017/Release/DirectXTex.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Externals/DirectXTex July 2017/Lib 2017/Release/DirectXTex.lib -------------------------------------------------------------------------------- /Externals/DirectXTex July 2017/Lib 2017/Release/DirectXTex.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Externals/DirectXTex July 2017/Lib 2017/Release/DirectXTex.pdb -------------------------------------------------------------------------------- /Externals/WinPixEventRuntime/Include/WinPixEventRuntime/pix3_win.h: -------------------------------------------------------------------------------- 1 | /*==========================================================================; 2 | * 3 | * Copyright (C) Microsoft Corporation. All Rights Reserved. 4 | * 5 | * File: PIX3_win.h 6 | * Content: PIX include file 7 | * Don't include this file directly - use pix3.h 8 | * 9 | ****************************************************************************/ 10 | 11 | #pragma once 12 | 13 | #ifndef _PIX3_H_ 14 | #error Don't include this file directly - use pix3.h 15 | #endif 16 | 17 | #ifndef _PIX3_WIN_H_ 18 | #define _PIX3_WIN_H_ 19 | 20 | struct PIXEventsBlockInfo 21 | { 22 | }; 23 | 24 | struct PIXEventsThreadInfo 25 | { 26 | PIXEventsBlockInfo* block; 27 | UINT64* biasedLimit; 28 | UINT64* destination; 29 | UINT64* limit; 30 | UINT64 id; 31 | }; 32 | 33 | extern "C" PIXEventsThreadInfo* PIXGetThreadInfo(); 34 | 35 | // The following defines denote the different metadata values that have been used 36 | // by tools to denote how to parse pix marker event data. The first two values 37 | // are legacy values. 38 | #define WINPIX_EVENT_UNICODE_VERSION 0 39 | #define WINPIX_EVENT_ANSI_VERSION 1 40 | #define WINPIX_EVENT_PIX3BLOB_VERSION 2 41 | 42 | #define D3D12_EVENT_METADATA WINPIX_EVENT_PIX3BLOB_VERSION 43 | 44 | __forceinline UINT64 PIXGetTimestampCounter() 45 | { 46 | LARGE_INTEGER time = {}; 47 | QueryPerformanceCounter(&time); 48 | return time.QuadPart; 49 | } 50 | 51 | #define PIXSetCPUMarkerOnContext(context, metadata, ...) MakeCPUSetMarkerForContext(metadata, context, __VA_ARGS__) 52 | #define PIXBeginCPUEventOnContext(context, metadata, ...) MakeCPUBeginEventForContext(metadata, context, __VA_ARGS__) 53 | #define PIXEndCPUEventOnContext(context) MakeCPUEndEventForContext(context) 54 | 55 | #endif //_PIX3_WIN_H_ 56 | -------------------------------------------------------------------------------- /Externals/WinPixEventRuntime/bin/WinPixEventRuntime.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Externals/WinPixEventRuntime/bin/WinPixEventRuntime.dll -------------------------------------------------------------------------------- /Externals/WinPixEventRuntime/bin/WinPixEventRuntime.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/Externals/WinPixEventRuntime/bin/WinPixEventRuntime.lib -------------------------------------------------------------------------------- /Externals/cxxopts/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Jarryd Beck 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bindless Deferred Texturing and Decals Sample 2 | 3 | This project is a D3D12 rendering sample that implements a deferred renderer using bindless deferred texturing. Deferred texturing is similar to normal deferred rendering, except that textures are not sampled in the geometry pass. Instead, the interpolated UV's are written into the G-Buffer so that the material textures can be sampled during the deferred pass. To enable sampling of textures from arbitrary materials, the demo makes use of dynamic indexing of texture descriptors. The demo also implements a deferred decal system using a clustering technique that's compatible with both deferred texturing as well as clustered forward rendering (which is also implemented in the demo as a baseline for comparison). 4 | 5 | See the full blog post for more info: [https://therealmjp.github.io/posts/bindless-texturing-for-deferred-rendering-and-decals/](https://therealmjp.github.io/posts/bindless-texturing-for-deferred-rendering-and-decals/) 6 | 7 | # Build Instructions 8 | 9 | The repository contains a Visual Studio 2015 project and solution file that's ready to build on Windows. All external dependencies are included in the repository, so there's no need to download additional libraries. Running the demo requires Windows 10, as well as a GPU that supports Feature Level 11_1. 10 | 11 | # Using The Demo App 12 | 13 | To move the camera, press the W/S/A/D/Q/E keys. The camera can also be rotated by right-clicking on the window and dragging the mouse. To place new decals, click the middle mouse button. Everything else is controlled through the in-app settings UI. 14 | 15 | # Using the new DirectX Shader Compiler 16 | 17 | This project supports using the new [open-source HLSL compiler](https://github.com/Microsoft/DirectXShaderCompiler) (also known as DXC), with support for Shader Model 6.0+. Usage of the new compiler is controlled by the "EnableShaderModel6_" macro that's defined in AppConfig.h. If you enable this flag, you'll want to make sure that you're on Windows 10 version 1803 or later to enable retail support for loading DXIL. If you're on an earlier Win10 version or an older driver, you may need to enable experimental feature support for D3D12ExperimentalShaderModels (see DX12.cpp for some code you can enable to do this). 18 | 19 | -------------------------------------------------------------------------------- /SampleFramework12/.gitignore: -------------------------------------------------------------------------------- 1 | ## Exclusions for SampleFramework12 2 | 3 | !SettingsCompiler.exe 4 | !SettingsCompilerAttributes.dll 5 | !Packager.exe -------------------------------------------------------------------------------- /SampleFramework12/v1.01/.gitignore: -------------------------------------------------------------------------------- 1 | !SettingsCompiler.exe 2 | !SettingsCompilerAttributes.dll -------------------------------------------------------------------------------- /SampleFramework12/v1.01/App.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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\\SwapChain.h" 16 | #include "Timer.h" 17 | #include "Graphics\\SpriteFont.h" 18 | #include "Graphics\\SpriteRenderer.h" 19 | 20 | namespace SampleFramework12 21 | { 22 | 23 | class App 24 | { 25 | 26 | public: 27 | 28 | App(const wchar* appName, const wchar* cmdLine); 29 | virtual ~App(); 30 | 31 | int32 Run(); 32 | 33 | protected: 34 | 35 | virtual void Initialize() = 0; 36 | virtual void Shutdown() = 0; 37 | 38 | virtual void Update(const Timer& timer) = 0; 39 | virtual void Render(const Timer& timer) = 0; 40 | 41 | virtual void BeforeReset() = 0; 42 | virtual void AfterReset() = 0; 43 | 44 | virtual void CreatePSOs() = 0; 45 | virtual void DestroyPSOs() = 0; 46 | 47 | virtual void BeforeFlush(); 48 | 49 | void Exit(); 50 | void ToggleFullScreen(bool fullScreen); 51 | void CalculateFPS(); 52 | 53 | static void OnWindowResized(void* context, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 54 | 55 | Window window; 56 | SwapChain swapChain; 57 | Timer appTimer; 58 | 59 | SpriteFont font; 60 | SpriteRenderer spriteRenderer; 61 | 62 | static const uint32 NumTimeDeltaSamples = 64; 63 | float timeDeltaBuffer[NumTimeDeltaSamples] = { }; 64 | uint32 currentTimeDeltaSample = 0; 65 | uint32 fps = 0; 66 | 67 | std::wstring applicationName; 68 | std::string globalHelpText = "MJPs sample framework for DX11"; 69 | 70 | bool showWindow = true; 71 | int32 returnCode = 0; 72 | D3D_FEATURE_LEVEL minFeatureLevel = D3D_FEATURE_LEVEL_11_0; 73 | uint32 adapterIdx = 0; 74 | 75 | Float4x4 appViewMatrix; 76 | 77 | static const uint64 MaxLogMessages = 1024; 78 | std::string logMessages[MaxLogMessages]; 79 | volatile int64 numLogMessages = 0; 80 | bool showLog = false; 81 | bool newLogMessage = false; 82 | 83 | private: 84 | 85 | void ParseCommandLine(const wchar* cmdLine); 86 | 87 | void Initialize_Internal(); 88 | void Shutdown_Internal(); 89 | 90 | void Update_Internal(); 91 | void Render_Internal(); 92 | 93 | void BeforeReset_Internal(); 94 | void AfterReset_Internal(); 95 | 96 | void CreatePSOs_Internal(); 97 | void DestroyPSOs_Internal(); 98 | 99 | void DrawLog(); 100 | 101 | public: 102 | 103 | // Accessors 104 | Window& Window() { return window; } 105 | SwapChain& SwapChain() { return swapChain; } 106 | SpriteFont& Font() { return font; } 107 | SpriteRenderer& SpriteRenderer() { return spriteRenderer; } 108 | 109 | void AddToLog(const char* msg); 110 | }; 111 | 112 | extern App* GlobalApp; 113 | 114 | } -------------------------------------------------------------------------------- /SampleFramework12/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 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/EnkiTS/License.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Doug Binks 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgement in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------------- /SampleFramework12/v1.01/EnkiTS/TaskScheduler_c.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Doug Binks 2 | // 3 | // This software is provided 'as-is', without any express or implied 4 | // warranty. In no event will the authors be held liable for any damages 5 | // arising from the use of this software. 6 | // 7 | // Permission is granted to anyone to use this software for any purpose, 8 | // including commercial applications, and to alter it and redistribute it 9 | // freely, subject to the following restrictions: 10 | // 11 | // 1. The origin of this software must not be misrepresented; you must not 12 | // claim that you wrote the original software. If you use this software 13 | // in a product, an acknowledgement in the product documentation would be 14 | // appreciated but is not required. 15 | // 2. Altered source versions must be plainly marked as such, and must not be 16 | // misrepresented as being the original software. 17 | // 3. This notice may not be removed or altered from any source distribution. 18 | 19 | #include "PCH.h" 20 | 21 | #include "TaskScheduler_c.h" 22 | #include "TaskScheduler.h" 23 | 24 | #include 25 | 26 | using namespace enki; 27 | 28 | struct enkiTaskScheduler : TaskScheduler 29 | { 30 | }; 31 | 32 | struct enkiTaskSet : ITaskSet 33 | { 34 | enkiTaskSet( enkiTaskExecuteRange taskFun_ ) : taskFun(taskFun_), pArgs(NULL) {} 35 | 36 | virtual void ExecuteRange( TaskSetPartition range, uint32_t threadnum ) 37 | { 38 | taskFun( range.start, range.end, threadnum, pArgs ); 39 | } 40 | 41 | enkiTaskExecuteRange taskFun; 42 | void* pArgs; 43 | }; 44 | 45 | enkiTaskScheduler* enkiCreateTaskScheduler() 46 | { 47 | enkiTaskScheduler* pETS = new enkiTaskScheduler(); 48 | pETS->Initialize(); 49 | return pETS; 50 | } 51 | 52 | enkiTaskScheduler* enkiCreateTaskSchedulerNumThreads( uint32_t numThreads_ ) 53 | { 54 | enkiTaskScheduler* pETS = new enkiTaskScheduler(); 55 | pETS->Initialize( numThreads_ ); 56 | return pETS; 57 | } 58 | 59 | void enkiDeleteTaskScheduler( enkiTaskScheduler* pETS_ ) 60 | { 61 | delete pETS_; 62 | } 63 | 64 | enkiTaskSet* enkiCreateTaskSet( enkiTaskScheduler* pETS_, enkiTaskExecuteRange taskFunc_ ) 65 | { 66 | return new enkiTaskSet( taskFunc_ ); 67 | } 68 | 69 | void enkiDeleteTaskSet( enkiTaskSet* pTaskSet_ ) 70 | { 71 | delete pTaskSet_; 72 | } 73 | 74 | void enkiAddTaskSetToPipe( enkiTaskScheduler* pETS_, enkiTaskSet* pTaskSet_, void* pArgs_, uint32_t setSize_ ) 75 | { 76 | assert( pTaskSet_ ); 77 | assert( pTaskSet_->taskFun ); 78 | 79 | pTaskSet_->m_SetSize = setSize_; 80 | pTaskSet_->pArgs = pArgs_; 81 | pETS_->AddTaskSetToPipe( pTaskSet_ ); 82 | } 83 | 84 | int enkiIsTaskSetComplete( enkiTaskScheduler* pETS_, enkiTaskSet* pTaskSet_ ) 85 | { 86 | assert( pTaskSet_ ); 87 | return ( pTaskSet_->GetIsComplete() ) ? 1 : 0; 88 | } 89 | 90 | void enkiWaitForTaskSet( enkiTaskScheduler* pETS_, enkiTaskSet* pTaskSet_ ) 91 | { 92 | pETS_->WaitforTaskSet( pTaskSet_ ); 93 | } 94 | 95 | void enkiWaitForAll( enkiTaskScheduler* pETS_ ) 96 | { 97 | pETS_->WaitforAll(); 98 | } 99 | 100 | 101 | uint32_t enkiGetNumTaskThreads( enkiTaskScheduler* pETS_ ) 102 | { 103 | return pETS_->GetNumTaskThreads(); 104 | } 105 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/EnkiTS/TaskScheduler_c.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Doug Binks 2 | // 3 | // This software is provided 'as-is', without any express or implied 4 | // warranty. In no event will the authors be held liable for any damages 5 | // arising from the use of this software. 6 | // 7 | // Permission is granted to anyone to use this software for any purpose, 8 | // including commercial applications, and to alter it and redistribute it 9 | // freely, subject to the following restrictions: 10 | // 11 | // 1. The origin of this software must not be misrepresented; you must not 12 | // claim that you wrote the original software. If you use this software 13 | // in a product, an acknowledgement in the product documentation would be 14 | // appreciated but is not required. 15 | // 2. Altered source versions must be plainly marked as such, and must not be 16 | // misrepresented as being the original software. 17 | // 3. This notice may not be removed or altered from any source distribution. 18 | 19 | #pragma once 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #include 26 | 27 | typedef struct enkiTaskScheduler enkiTaskScheduler; 28 | typedef struct enkiTaskSet enkiTaskSet; 29 | 30 | typedef void (* enkiTaskExecuteRange)( uint32_t start_, uint32_t end, uint32_t threadnum_, void* pArgs_ ); 31 | 32 | 33 | // Create a task scheduler - will create GetNumHardwareThreads()-1 threads, which is 34 | // sufficient to fill the system when including the main thread. 35 | // Initialize can be called multiple times - it will wait for completion 36 | // before re-initializing. 37 | enkiTaskScheduler* enkiCreateTaskScheduler(); 38 | 39 | // Create a task scheduler with numThreads_ (must be > 0) 40 | // will create numThreads_-1 threads, as thread 0 is 41 | // the thread on which the initialize was called. 42 | enkiTaskScheduler* enkiCreateTaskSchedulerNumThreads( uint32_t numThreads_ ); 43 | 44 | 45 | // Delete a task scheduler 46 | void enkiDeleteTaskScheduler( enkiTaskScheduler* pETS_ ); 47 | 48 | // Create a task set. 49 | enkiTaskSet* enkiCreateTaskSet( enkiTaskScheduler* pETS_, enkiTaskExecuteRange taskFunc_ ); 50 | 51 | // Delete a task set. 52 | void enkiDeleteTaskSet( enkiTaskSet* pTaskSet_ ); 53 | 54 | // schedule the task 55 | void enkiAddTaskSetToPipe( enkiTaskScheduler* pETS_, enkiTaskSet* pTaskSet_, void* pArgs_, uint32_t setSize_ ); 56 | 57 | // Check if TaskSet is complete. Doesn't wait. Returns 1 if complete, 0 if not. 58 | int enkiIsTaskSetComplete( enkiTaskScheduler* pETS_, enkiTaskSet* pTaskSet_ ); 59 | 60 | 61 | // Wait for a given task. 62 | // should only be called from thread which created the taskscheduler , or within a task 63 | // if called with 0 it will try to run tasks, and return if none available. 64 | void enkiWaitForTaskSet( enkiTaskScheduler* pETS_, enkiTaskSet* pTaskSet_ ); 65 | 66 | 67 | // Waits for all task sets to complete - not guaranteed to work unless we know we 68 | // are in a situation where tasks aren't being continuosly added. 69 | void enkiWaitForAll( enkiTaskScheduler* pETS_ ); 70 | 71 | 72 | // get number of threads 73 | uint32_t enkiGetNumTaskThreads( enkiTaskScheduler* pETS_ ); 74 | 75 | 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif -------------------------------------------------------------------------------- /SampleFramework12/v1.01/FileIO.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 SampleFramework12 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, FileOpenMode::Read); 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, FileOpenMode::Write); 94 | file.Write(val); 95 | } 96 | 97 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Graphics/BRDF.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 "..\\SF12_Math.h" 12 | 13 | namespace SampleFramework12 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 m2 = m * m; 55 | 56 | // Calculate the distribution term 57 | float d = m2 / (Pi * Square(nDotH * nDotH * (m2 - 1) + 1)); 58 | 59 | // Calculate the matching visibility term 60 | float v1i = GGX_V1(m2, nDotL); 61 | float v1o = GGX_V1(m2, nDotV); 62 | float vis = v1i * v1o; 63 | 64 | return d * vis; 65 | } 66 | // Computes the radiance reflected off a surface towards the eye given 67 | // the differential irradiance from a given direction 68 | inline Float3 CalcLighting(const Float3& normal, const Float3& lightIrradiance, 69 | const Float3& lightDir, const Float3& diffuseAlbedo, const Float3& position, 70 | const Float3& cameraPos, float roughness, bool includeSpecular, Float3 specAlbedo) 71 | { 72 | Float3 lighting = diffuseAlbedo * InvPi; 73 | 74 | if(includeSpecular && Float3::Dot(normal, lightDir) > 0.0f) 75 | { 76 | Float3 view = Float3::Normalize(cameraPos - position); 77 | const float nDotV = Saturate(Float3::Dot(normal, view)); 78 | Float3 h = Float3::Normalize(view + lightDir); 79 | 80 | Float3 fresnel = Fresnel(specAlbedo, h, lightDir); 81 | 82 | float specular = GGX_Specular(roughness, normal, h, view, lightDir); 83 | lighting += specular * fresnel; 84 | } 85 | 86 | return lighting * lightIrradiance; 87 | } 88 | 89 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Graphics/DX12.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 SampleFramework12 15 | { 16 | 17 | namespace DX12 18 | { 19 | 20 | // Constants 21 | const uint64 RenderLatency = 2; 22 | 23 | // Externals 24 | extern ID3D12Device2* Device; 25 | extern ID3D12GraphicsCommandList1* CmdList; 26 | extern ID3D12CommandQueue* GfxQueue; 27 | extern D3D_FEATURE_LEVEL FeatureLevel; 28 | extern IDXGIFactory4* Factory; 29 | extern IDXGIAdapter1* Adapter; 30 | 31 | extern uint64 CurrentCPUFrame; // Total number of CPU frames completed (completed means all command buffers submitted to the GPU) 32 | extern uint64 CurrentGPUFrame; // Total number of GPU frames completed (completed means that the GPU signals the fence) 33 | extern uint64 CurrFrameIdx; // CurrentCPUFrame % RenderLatency 34 | 35 | // Lifetime 36 | void Initialize(D3D_FEATURE_LEVEL minFeatureLevel, uint32 adapterIdx); 37 | void Shutdown(); 38 | 39 | // Frame submission synchronization 40 | void BeginFrame(); 41 | void EndFrame(IDXGISwapChain4* swapChain, uint32 syncIntervals); 42 | void FlushGPU(); 43 | 44 | void DeferredRelease_(IUnknown* resource); 45 | 46 | template void DeferredRelease(T*& resource) 47 | { 48 | IUnknown* base = resource; 49 | DeferredRelease_(base); 50 | resource = nullptr; 51 | } 52 | 53 | template void Release(T*& resource) 54 | { 55 | if(resource != nullptr) { 56 | resource->Release(); 57 | resource = nullptr; 58 | } 59 | } 60 | 61 | void DeferredCreateSRV(ID3D12Resource* resource, const D3D12_SHADER_RESOURCE_VIEW_DESC& desc, uint32 descriptorIdx); 62 | 63 | } // namespace DX12 64 | 65 | } // namespace SampleFramework12 66 | 67 | 68 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Graphics/DX12_Upload.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 SampleFramework12 15 | { 16 | 17 | struct MapResult 18 | { 19 | void* CPUAddress = nullptr; 20 | uint64 GPUAddress = 0; 21 | uint64 ResourceOffset = 0; 22 | ID3D12Resource* Resource = nullptr; 23 | }; 24 | 25 | struct UploadContext 26 | { 27 | ID3D12GraphicsCommandList* CmdList; 28 | void* CPUAddress = nullptr; 29 | uint64 ResourceOffset = 0; 30 | ID3D12Resource* Resource = nullptr; 31 | void* Submission = nullptr; 32 | }; 33 | 34 | struct ReadbackBuffer; 35 | struct Texture; 36 | 37 | namespace DX12 38 | { 39 | 40 | void Initialize_Upload(); 41 | void Shutdown_Upload(); 42 | 43 | void EndFrame_Upload(); 44 | 45 | // Resource upload/init 46 | UploadContext ResourceUploadBegin(uint64 size); 47 | void ResourceUploadEnd(UploadContext& context); 48 | 49 | // Temporary CPU-writable buffer memory 50 | MapResult AcquireTempBufferMem(uint64 size, uint64 alignment); 51 | 52 | void ConvertAndReadbackTexture(const Texture& texture, DXGI_FORMAT outputFormat, ReadbackBuffer& buffer); 53 | 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /SampleFramework12/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 -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Graphics/Filtering.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 "..\\SF12_Math.h" 12 | 13 | namespace SampleFramework12 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 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Graphics/PostProcessHelper.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 "..\\SF12_Math.h" 16 | #include "ShaderCompilation.h" 17 | #include "GraphicsTypes.h" 18 | 19 | namespace SampleFramework12 20 | { 21 | 22 | struct TempRenderTarget 23 | { 24 | RenderTexture RT; 25 | uint64 Width() const { return RT.Texture.Width; } 26 | uint64 Height() const { return RT.Texture.Height; } 27 | DXGI_FORMAT Format() const { return RT.Texture.Format; } 28 | bool32 InUse = false; 29 | }; 30 | 31 | class PostProcessHelper 32 | { 33 | 34 | public: 35 | 36 | PostProcessHelper(); 37 | ~PostProcessHelper(); 38 | 39 | void Initialize(); 40 | void Shutdown(); 41 | 42 | void ClearCache(); 43 | 44 | TempRenderTarget* GetTempRenderTarget(uint64 width, uint64 height, DXGI_FORMAT format, bool useAsUAV = false); 45 | 46 | void Begin(ID3D12GraphicsCommandList* cmdList); 47 | void End(); 48 | 49 | void PostProcess(CompiledShaderPtr pixelShader, const char* name, const RenderTexture& input, const RenderTexture& output); 50 | void PostProcess(CompiledShaderPtr pixelShader, const char* name, const RenderTexture& input, const TempRenderTarget* output); 51 | void PostProcess(CompiledShaderPtr pixelShader, const char* name, const TempRenderTarget* input, const RenderTexture& output); 52 | void PostProcess(CompiledShaderPtr pixelShader, const char* name, const TempRenderTarget* input, const TempRenderTarget* output); 53 | void PostProcess(CompiledShaderPtr pixelShader, const char* name, const uint32* inputs, uint64 numInputs, 54 | const RenderTexture*const* outputs, uint64 numOutputs); 55 | 56 | protected: 57 | 58 | 59 | struct CachedPSO 60 | { 61 | ID3D12PipelineState* PSO = nullptr; 62 | Hash Hash; 63 | }; 64 | 65 | GrowableList tempRenderTargets; 66 | GrowableList pipelineStates; 67 | ID3D12RootSignature* rootSignature = nullptr; 68 | 69 | VertexShaderPtr fullScreenTriVS; 70 | 71 | ID3D12GraphicsCommandList* cmdList = nullptr; 72 | }; 73 | 74 | } 75 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Graphics/Profiler.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 | #include "..\\Containers.h" 16 | #include "GraphicsTypes.h" 17 | 18 | namespace SampleFramework12 19 | { 20 | 21 | struct ProfileData; 22 | 23 | class Profiler 24 | { 25 | 26 | public: 27 | 28 | static Profiler GlobalProfiler; 29 | 30 | void Initialize(); 31 | void Shutdown(); 32 | 33 | uint64 StartProfile(ID3D12GraphicsCommandList* cmdList, const char* name); 34 | void EndProfile(ID3D12GraphicsCommandList* cmdList, uint64 idx); 35 | 36 | uint64 StartCPUProfile(const char* name); 37 | void EndCPUProfile(uint64 idx); 38 | 39 | void EndFrame(uint32 displayWidth, uint32 displayHeight); 40 | 41 | protected: 42 | 43 | Array profiles; 44 | Array cpuProfiles; 45 | uint64 numProfiles = 0; 46 | uint64 numCPUProfiles = 0; 47 | Timer timer; 48 | ID3D12QueryHeap* queryHeap = nullptr; 49 | ReadbackBuffer readbackBuffer; 50 | bool enableGPUProfiling = false; 51 | bool showUI = false; 52 | bool logToClipboard = false; 53 | }; 54 | 55 | class ProfileBlock 56 | { 57 | public: 58 | 59 | ProfileBlock(ID3D12GraphicsCommandList* cmdList, const char* name); 60 | ~ProfileBlock(); 61 | 62 | protected: 63 | 64 | ID3D12GraphicsCommandList* cmdList = nullptr; 65 | uint64 idx = uint64(-1); 66 | }; 67 | 68 | class CPUProfileBlock 69 | { 70 | public: 71 | 72 | CPUProfileBlock(const char* name); 73 | ~CPUProfileBlock(); 74 | 75 | protected: 76 | 77 | uint64 idx = uint64(-1); 78 | }; 79 | 80 | } 81 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Graphics/Sampling.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 "..\\SF12_Math.h" 12 | 13 | namespace SampleFramework12 14 | { 15 | 16 | // Shape sampling functions 17 | Float2 SquareToConcentricDiskMapping(float x, float y, float numSides, float polygonAmount); 18 | Float2 SquareToConcentricDiskMapping(float x, float y); 19 | Float3 SampleDirectionGGX(const Float3& v, const Float3& n, float roughness, const Float3x3& tangentToWorld, float u1, float u2); 20 | Float3 SampleSphere(float x1, float x2, float x3, float u1); 21 | Float3 SampleDirectionSphere(float u1, float u2); 22 | Float3 SampleDirectionHemisphere(float u1, float u2); 23 | Float3 SampleDirectionCosineHemisphere(float u1, float u2); 24 | Float3 SampleDirectionCone(float u1, float u2, float cosThetaMax); 25 | Float3 SampleDirectionRectangularLight(float u1, float u2, const Float3& sourcePos, 26 | const Float2& lightSize, const Float3& lightPos, 27 | const Quaternion lightOrientation, float& distanceToLight); 28 | 29 | // PDF functions 30 | float SampleDirectionGGX_PDF(const Float3& n, const Float3& h, const Float3& v, float roughness); 31 | float SampleDirectionSphere_PDF(); 32 | float SampleDirectionHemisphere_PDF(); 33 | float SampleDirectionCosineHemisphere_PDF(float cosTheta); 34 | float SampleDirectionCosineHemisphere_PDF(const Float3& normal, const Float3& sampleDir); 35 | float SampleDirectionCone_PDF(float cosThetaMax); 36 | float SampleDirectionRectangularLight_PDF(const Float2& lightSize, const Float3& sampleDir, 37 | const Quaternion lightOrientation, float distanceToLight); 38 | 39 | // Random sample generation 40 | Float2 Hammersley2D(uint64 sampleIdx, uint64 numSamples); 41 | Float2 SampleCMJ2D(int32 sampleIdx, int32 numSamplesX, int32 numSamplesY, int32 pattern); 42 | 43 | // Full random sample set generation 44 | void GenerateRandomSamples2D(Float2* samples, uint64 numSamples, Random& randomGenerator); 45 | void GenerateStratifiedSamples2D(Float2* samples, uint64 numSamplesX, uint64 numSamplesY, Random& randomGenerator); 46 | void GenerateGridSamples2D(Float2* samples, uint64 numSamplesX, uint64 numSamplesY); 47 | void GenerateHammersleySamples2D(Float2* samples, uint64 numSamples); 48 | void GenerateHammersleySamples2D(Float2* samples, uint64 numSamples, uint64 dimIdx); 49 | void GenerateLatinHypercubeSamples2D(Float2* samples, uint64 numSamples, Random& rng); 50 | void GenerateCMJSamples2D(Float2* samples, uint64 numSamplesX, uint64 numSamplesY, uint32 pattern); 51 | 52 | // Helpers 53 | float RadicalInverseBase2(uint32 bits); 54 | float RadicalInverseFast(uint64 baseIndex, uint64 index); 55 | 56 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Graphics/ShadowHelper.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 13 | #include "..\\SF12_Math.h" 14 | 15 | namespace SampleFramework12 16 | { 17 | 18 | class Camera; 19 | class OrthographicCamera; 20 | class PerspectiveCamera; 21 | struct ModelSpotLight; 22 | struct DepthBuffer; 23 | struct RenderTexture; 24 | 25 | const uint64 NumCascades = 4; 26 | const float MaxShadowFilterSize = 9.0f; 27 | 28 | struct SunShadowConstantsBase 29 | { 30 | Float4x4 ShadowMatrix; 31 | float CascadeSplits[NumCascades] = { }; 32 | Float4 CascadeOffsets[NumCascades]; 33 | Float4 CascadeScales[NumCascades]; 34 | }; 35 | 36 | struct EVSMConstants 37 | { 38 | float PositiveExponent = 0.0f; 39 | float NegativeExponent = 0.0f; 40 | float LightBleedingReduction = 0.25f; 41 | uint32 Padding = 0; 42 | }; 43 | 44 | struct MSMConstants 45 | { 46 | float DepthBias = 0.0f; 47 | float MomentBias = 0.0003f; 48 | float LightBleedingReduction = 0.25f; 49 | uint32 Padding = 0; 50 | }; 51 | 52 | struct SunShadowConstantsDepthMap 53 | { 54 | SunShadowConstantsBase Base; 55 | uint32 Dummy[4] = { }; 56 | }; 57 | 58 | struct SunShadowConstantsEVSM 59 | { 60 | SunShadowConstantsBase Base; 61 | EVSMConstants EVSM; 62 | }; 63 | 64 | struct SunShadowConstantsMSM 65 | { 66 | SunShadowConstantsBase Base; 67 | MSMConstants MSM; 68 | }; 69 | 70 | enum class ShadowMapMode : uint32 71 | { 72 | DepthMap, 73 | EVSM, 74 | MSM, 75 | 76 | NumValues, 77 | }; 78 | 79 | enum class ShadowMSAAMode : uint32 80 | { 81 | MSAA1x, 82 | MSAA2x, 83 | MSAA4x, 84 | 85 | NumValues, 86 | }; 87 | 88 | namespace ShadowHelper 89 | { 90 | 91 | extern Float4x4 ShadowScaleOffsetMatrix; 92 | 93 | void Initialize(ShadowMapMode smMode, ShadowMSAAMode msaaMode); 94 | void Shutdown(); 95 | 96 | void CreatePSOs(); 97 | void DestroyPSOs(); 98 | 99 | uint32 NumMSAASamples(); 100 | DXGI_FORMAT SMFormat(); 101 | 102 | void ConvertShadowMap(ID3D12GraphicsCommandList* cmdList, const DepthBuffer& depthMap, RenderTexture& smTarget, 103 | uint32 arraySlice, RenderTexture& tempTarget, float filterSizeU, float filterSizeV, 104 | bool32 linearizeDepth, float nearClip, float farClip, const Float4x4& projection, 105 | bool32 useCSConversion = false, bool32 use3x3Filter = true, float positiveExponent = 0.0f, float negativeExponent = 0.0f); 106 | 107 | extern Float4x4 ScaleOffsetMatrix; 108 | void PrepareCascades(const Float3& lightDir, uint64 shadowMapSize, bool stabilize, const Camera& camera, 109 | SunShadowConstantsBase& constants, OrthographicCamera* cascadeCameras); 110 | 111 | }; 112 | 113 | } 114 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Graphics/Skybox.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 "..\\SF12_Math.h" 16 | #include "ShaderCompilation.h" 17 | #include "GraphicsTypes.h" 18 | #include "SH.h" 19 | 20 | // HosekSky forward declares 21 | struct ArHosekSkyModelState; 22 | 23 | namespace SampleFramework12 24 | { 25 | 26 | #if EnableSkyModel_ 27 | 28 | // Cached data for the procedural sky model 29 | struct SkyCache 30 | { 31 | ArHosekSkyModelState* StateR = nullptr; 32 | ArHosekSkyModelState* StateG = nullptr; 33 | ArHosekSkyModelState* StateB = nullptr; 34 | Float3 SunDirection; 35 | Float3 SunRadiance; 36 | Float3 SunIrradiance; 37 | float SunSize = 0.0f; 38 | float Turbidity = 0.0f; 39 | Float3 Albedo; 40 | float Elevation = 0.0f; 41 | Texture CubeMap; 42 | SH9Color SH; 43 | 44 | void Init(const Float3& sunDirection, float sunSize, const Float3& groundAlbedo, float turbidity, bool createCubemap); 45 | void Shutdown(); 46 | ~SkyCache(); 47 | 48 | bool Initialized() const { return StateR != nullptr; } 49 | 50 | Float3 Sample(Float3 sampleDir) const; 51 | }; 52 | 53 | #endif // EnableSkyModel_ 54 | 55 | class Skybox 56 | { 57 | 58 | public: 59 | 60 | Skybox(); 61 | ~Skybox(); 62 | 63 | void Initialize(); 64 | void Shutdown(); 65 | 66 | void CreatePSOs(DXGI_FORMAT rtFormat, DXGI_FORMAT depthFormat, uint32 numMSAASamples); 67 | void DestroyPSOs(); 68 | 69 | void RenderEnvironmentMap(ID3D12GraphicsCommandList* cmdList, 70 | const Float4x4& view, 71 | const Float4x4& projection, 72 | const Texture* environmentMap, 73 | Float3 scale = Float3(1.0f, 1.0f, 1.0f)); 74 | 75 | #if EnableSkyModel_ 76 | 77 | void RenderSky(ID3D12GraphicsCommandList* cmdList, 78 | const Float4x4& view, 79 | const Float4x4& projection, 80 | const SkyCache& skyCache, 81 | bool enableSun = true, 82 | const Float3& scale = Float3(1.0f, 1.0f, 1.0f)); 83 | 84 | #endif // EnableSkyModel_ 85 | 86 | protected: 87 | 88 | void RenderCommon(ID3D12GraphicsCommandList* cmdList, 89 | const Texture* environmentMap, 90 | const Float4x4& view, 91 | const Float4x4& projection, 92 | Float3 scale); 93 | 94 | struct VSConstants 95 | { 96 | Float4x4 View; 97 | Float4x4 Projection; 98 | }; 99 | 100 | struct PSConstants 101 | { 102 | Float3 SunDirection = Float3(0.0f, 1.0f, 0.0f); 103 | float CosSunAngularRadius = 0.0f; 104 | Float3 SunColor = 1.0f; 105 | uint32 Padding = 0; 106 | Float3 Scale = 1.0f; 107 | uint32 EnvMapIdx = uint32(-1); 108 | }; 109 | 110 | CompiledShaderPtr vertexShader; 111 | CompiledShaderPtr pixelShader; 112 | StructuredBuffer vertexBuffer; 113 | FormattedBuffer indexBuffer; 114 | VSConstants vsConstants; 115 | PSConstants psConstants; 116 | ID3D12RootSignature* rootSignature; 117 | ID3D12PipelineState* pipelineState; 118 | }; 119 | 120 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Graphics/SpriteFont.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 "..\\SF12_Math.h" 16 | #include "GraphicsTypes.h" 17 | 18 | namespace SampleFramework12 19 | { 20 | 21 | class SpriteFont 22 | { 23 | 24 | public: 25 | 26 | enum FontStyle 27 | { 28 | Regular = 0, 29 | Bold = 1 << 0, 30 | Italic = 1 << 1, 31 | BoldItalic = Bold | Italic, 32 | Underline = 1 << 2, 33 | Strikeout = 1 << 3 34 | }; 35 | 36 | struct CharDesc 37 | { 38 | float X; 39 | float Y; 40 | float Width; 41 | float Height; 42 | }; 43 | 44 | static const wchar StartChar = '!'; 45 | static const wchar EndChar = 127; 46 | static const uint64 NumChars = EndChar - StartChar; 47 | static const uint32 TexWidth = 1024; 48 | 49 | SpriteFont(); 50 | ~SpriteFont(); 51 | 52 | // Lifetime 53 | void Initialize(const wchar* fontName, float fontSize, uint32 fontStyle, bool antiAliased); 54 | void Shutdown(); 55 | 56 | Float2 MeasureText(const wchar* text) const; 57 | 58 | // Accessors 59 | const CharDesc* CharDescriptors() const; 60 | const CharDesc& GetCharDescriptor(wchar character) const; 61 | float Size() const; 62 | const Texture* FontTexture() const; 63 | uint32 TextureWidth() const; 64 | uint32 TextureHeight() const; 65 | float SpaceWidth() const; 66 | float CharHeight() const; 67 | 68 | protected: 69 | 70 | Texture texture; 71 | CharDesc charDescs [NumChars]; 72 | float size = 0.0f; 73 | uint32 texHeight = 0; 74 | float spaceWidth = 0.0f; 75 | float charHeight = 0.0f; 76 | }; 77 | 78 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Graphics/SpriteRenderer.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 "..\\SF12_Math.h" 18 | #include "ShaderCompilation.h" 19 | #include "GraphicsTypes.h" 20 | 21 | namespace SampleFramework12 22 | { 23 | 24 | class SpriteFont; 25 | 26 | enum class SpriteFilterMode : uint64 27 | { 28 | Linear = 0, 29 | Point 30 | }; 31 | 32 | enum class SpriteBlendMode : uint64 33 | { 34 | AlphaBlend = 0, 35 | Opaque, 36 | 37 | NumValues 38 | }; 39 | 40 | struct SpriteTransform 41 | { 42 | Float2 Position; 43 | Float2 Scale = Float2(1.0f, 1.0f); 44 | Float2 SinCosRotation = Float2(0.0f, 1.0f); 45 | 46 | SpriteTransform() 47 | { 48 | } 49 | 50 | explicit SpriteTransform(Float2 position) : Position(position) 51 | { 52 | } 53 | 54 | explicit SpriteTransform(Float2 position, float rotation) : Position(position) 55 | { 56 | SinCosRotation = Float2(std::sin(rotation), std::cos(rotation)); 57 | } 58 | }; 59 | 60 | struct SpriteDrawData 61 | { 62 | SpriteTransform Transform; 63 | Float4 Color; 64 | Float4 DrawRect; 65 | }; 66 | 67 | class SpriteRenderer 68 | { 69 | 70 | public: 71 | 72 | static const uint64 MaxBatchSize = 1024; 73 | 74 | SpriteRenderer(); 75 | ~SpriteRenderer(); 76 | 77 | void Initialize(); 78 | void Shutdown(); 79 | 80 | void CreatePSOs(DXGI_FORMAT rtFormat); 81 | void DestroyPSOs(); 82 | 83 | void Begin(ID3D12GraphicsCommandList* cmdList, Float2 viewportSize, SpriteFilterMode filterMode = SpriteFilterMode::Linear, 84 | SpriteBlendMode = SpriteBlendMode::AlphaBlend); 85 | 86 | void Render(ID3D12GraphicsCommandList* cmdList, 87 | const Texture* texture, 88 | const SpriteTransform& transform, 89 | const Float4& color = Float4(1, 1, 1, 1), 90 | const Float4* drawRect = NULL); 91 | 92 | void RenderBatch(ID3D12GraphicsCommandList* cmdList, 93 | const Texture* texture, 94 | const SpriteDrawData* drawData, 95 | uint64 numSprites); 96 | 97 | void RenderText(ID3D12GraphicsCommandList* cmdList, 98 | const SpriteFont& font, 99 | const wchar* text, 100 | Float2 position, 101 | const Float4& color = Float4(1, 1, 1, 1)); 102 | 103 | void End(); 104 | 105 | protected: 106 | 107 | ShaderPtr vertexShader; 108 | ShaderPtr vertexShaderInstanced; 109 | ShaderPtr pixelShader; 110 | ShaderPtr pixelShaderOpaque; 111 | FormattedBuffer indexBuffer; 112 | StructuredBuffer instanceDataBuffer; 113 | SpriteDrawData textDrawData[MaxBatchSize]; 114 | ID3D12PipelineState* pipelineStates[uint64(SpriteBlendMode::NumValues)] = { }; 115 | ID3D12RootSignature* rootSignature = nullptr; 116 | Texture defaultTexture; 117 | 118 | struct PerBatchConstants 119 | { 120 | Float2 TextureSize; 121 | Float2 ViewportSize; 122 | bool32 LinearSampling = false; 123 | } perBatchData; 124 | }; 125 | 126 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Graphics/SwapChain.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 | #include "DX12.h" 17 | 18 | namespace SampleFramework12 19 | { 20 | 21 | class SwapChain 22 | { 23 | 24 | public: 25 | 26 | SwapChain(); 27 | ~SwapChain(); 28 | 29 | void Initialize(HWND outputWindow); 30 | void Shutdown(); 31 | void Reset(); 32 | void BeginFrame(); 33 | void EndFrame(); 34 | 35 | // Getters 36 | IDXGISwapChain4* D3DSwapChain() const { return swapChain; }; 37 | const RenderTexture& BackBuffer() const { return backBuffers[backBufferIdx]; }; 38 | 39 | DXGI_FORMAT Format() const { return format; }; 40 | uint32 Width() const { return width; }; 41 | uint32 Height() const { return height; }; 42 | bool FullScreen() const { return fullScreen; }; 43 | bool VSYNCEnabled() const { return vsync; }; 44 | uint32 NumVSYNCIntervals() const { return vsync ? numVSYNCIntervals : 0; }; 45 | HANDLE WaitableObject() const { return waitableObject; } 46 | 47 | // Setters 48 | void SetFormat(DXGI_FORMAT format_) { format = format_; }; 49 | void SetWidth(uint32 width_) { width = width_; }; 50 | void SetHeight(uint32 height_) { height = height_; }; 51 | void SetFullScreen(bool enabled) { fullScreen = enabled; }; 52 | void SetVSYNCEnabled(bool enabled) { vsync = enabled; }; 53 | void SetNumVSYNCIntervals(uint32 intervals) { numVSYNCIntervals = intervals; }; 54 | 55 | protected: 56 | 57 | void CheckForSuitableOutput(); 58 | void AfterReset(); 59 | void PrepareFullScreenSettings(); 60 | 61 | static const uint64 NumBackBuffers = 2; 62 | 63 | IDXGISwapChain4* swapChain = nullptr; 64 | uint32 backBufferIdx = 0; 65 | RenderTexture backBuffers[NumBackBuffers]; 66 | HANDLE waitableObject = INVALID_HANDLE_VALUE; 67 | 68 | IDXGIOutput* output = nullptr; 69 | 70 | DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM; 71 | DXGI_FORMAT noSRGBFormat = DXGI_FORMAT_R8G8B8A8_UNORM; 72 | uint32 width = 1280; 73 | uint32 height = 720; 74 | bool fullScreen = false; 75 | bool vsync = true; 76 | DXGI_RATIONAL refreshRate = { }; 77 | uint32 numVSYNCIntervals = 1; 78 | }; 79 | 80 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/HosekSky/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. -------------------------------------------------------------------------------- /SampleFramework12/v1.01/ImGui/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2015 Omar Cornut and ImGui contributors 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 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/ImGui/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // USER IMPLEMENTATION 3 | // This file contains compile-time options for ImGui. 4 | // Other options (memory allocation overrides, callbacks, etc.) can be set at runtime via the ImGuiIO structure - ImGui::GetIO(). 5 | //----------------------------------------------------------------------------- 6 | 7 | #pragma once 8 | 9 | //---- Define assertion handler. Defaults to calling assert(). 10 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 11 | 12 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows. 13 | //#define IMGUI_API __declspec( dllexport ) 14 | //#define IMGUI_API __declspec( dllimport ) 15 | 16 | //---- Include imgui_user.h at the end of imgui.h 17 | //#define IMGUI_INCLUDE_IMGUI_USER_H 18 | 19 | //---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions) 20 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS 21 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS 22 | 23 | //---- Don't implement help and test window functionality (ShowUserGuide()/ShowStyleEditor()/ShowTestWindow() methods will be empty) 24 | //#define IMGUI_DISABLE_TEST_WINDOWS 25 | 26 | //---- Don't define obsolete functions names 27 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 28 | 29 | //---- Pack colors to BGRA instead of RGBA (remove need to post process vertex buffer in back ends) 30 | //#define IMGUI_USE_BGRA_PACKED_COLOR 31 | 32 | //---- Implement STB libraries in a namespace to avoid conflicts 33 | //#define IMGUI_STB_NAMESPACE ImGuiStb 34 | 35 | //---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4. 36 | /* 37 | #define IM_VEC2_CLASS_EXTRA \ 38 | ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \ 39 | operator MyVec2() const { return MyVec2(x,y); } 40 | 41 | #define IM_VEC4_CLASS_EXTRA \ 42 | ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ 43 | operator MyVec4() const { return MyVec4(x,y,z,w); } 44 | */ 45 | 46 | //---- Use 32-bit vertex indices (instead of default: 16-bit) to allow meshes with more than 64K vertices 47 | //#define ImDrawIdx unsigned int 48 | 49 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. 50 | //---- e.g. create variants of the ImGui::Value() helper for your low-level math types, or your own widgets/helpers. 51 | /* 52 | namespace ImGui 53 | { 54 | void Value(const char* prefix, const MyMatrix44& v, const char* float_format = NULL); 55 | } 56 | */ 57 | 58 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/ImGuiHelper.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 "SF12_Math.h" 14 | #include "ImGui/imgui.h" 15 | 16 | namespace SampleFramework12 17 | { 18 | 19 | class Window; 20 | 21 | namespace ImGuiHelper 22 | { 23 | 24 | void Initialize(Window& window); 25 | void Shutdown(); 26 | 27 | void CreatePSOs(DXGI_FORMAT rtFormat); 28 | void DestroyPSOs(); 29 | 30 | void BeginFrame(uint32 displayWidth, uint32 displayHeight, float timeDelta); 31 | void EndFrame(ID3D12GraphicsCommandList* cmdList, D3D12_CPU_DESCRIPTOR_HANDLE rtv, 32 | uint32 displayWidth, uint32 displayHeight); 33 | 34 | } // namespace ImGuiHelper 35 | 36 | inline ImVec2 ToImVec2(Float2 v) 37 | { 38 | return ImVec2(v.x, v.y); 39 | } 40 | 41 | inline Float2 ToFloat2(ImVec2 v) 42 | { 43 | return Float2(v.x, v.y); 44 | } 45 | 46 | inline ImColor ToImColor(Float3 v) 47 | { 48 | return ImColor(v.x, v.y, v.z); 49 | } 50 | 51 | inline ImColor ToImColor(Float4 v) 52 | { 53 | return ImColor(v.x, v.y, v.z, v.w); 54 | } 55 | 56 | } // namespace SampleFramework12 57 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/InterfacePointers.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 SampleFramework12 15 | { 16 | 17 | // Common 18 | typedef Microsoft::WRL::ComPtr ID3DBlobPtr; 19 | 20 | // DXGI 21 | typedef Microsoft::WRL::ComPtr IDXGIAdapterPtr; 22 | typedef Microsoft::WRL::ComPtr IDXGIAdapter1Ptr; 23 | typedef Microsoft::WRL::ComPtr IDXGIDevicePtr; 24 | typedef Microsoft::WRL::ComPtr IDXGIDevice1Ptr; 25 | typedef Microsoft::WRL::ComPtr IDXGIDeviceSubObjectPtr; 26 | typedef Microsoft::WRL::ComPtr IDXGIFactoryPtr; 27 | typedef Microsoft::WRL::ComPtr IDXGIFactory1Ptr; 28 | typedef Microsoft::WRL::ComPtr IDXGIKeyedMutexPtr; 29 | typedef Microsoft::WRL::ComPtr IDXGIObjectPtr; 30 | typedef Microsoft::WRL::ComPtr IDXGIOutputPtr; 31 | typedef Microsoft::WRL::ComPtr IDXGIResourcePtr; 32 | typedef Microsoft::WRL::ComPtr IDXGISurface1Ptr; 33 | typedef Microsoft::WRL::ComPtr IDXGIFactory4Ptr; 34 | typedef Microsoft::WRL::ComPtr IDXGISwapChainPtr; 35 | typedef Microsoft::WRL::ComPtr IDXGISwapChain3Ptr; 36 | 37 | // D3D12 38 | typedef Microsoft::WRL::ComPtr ID3D12CommandAllocatorPtr; 39 | typedef Microsoft::WRL::ComPtr ID3D12CommandListPtr; 40 | typedef Microsoft::WRL::ComPtr ID3D12CommandQueuePtr; 41 | typedef Microsoft::WRL::ComPtr ID3D12CommandSignaturePtr; 42 | typedef Microsoft::WRL::ComPtr ID3D12DescriptorHeapPtr; 43 | typedef Microsoft::WRL::ComPtr ID3D12DevicePtr; 44 | typedef Microsoft::WRL::ComPtr ID3D12DeviceChildPtr; 45 | typedef Microsoft::WRL::ComPtr ID3D12FencePtr; 46 | typedef Microsoft::WRL::ComPtr ID3D12GraphicsCommandListPtr; 47 | typedef Microsoft::WRL::ComPtr ID3D12HeapPtr; 48 | typedef Microsoft::WRL::ComPtr ID3D12ObjectPtr; 49 | typedef Microsoft::WRL::ComPtr ID3D12PageablePtr; 50 | typedef Microsoft::WRL::ComPtr ID3D12PipelineStatePtr; 51 | typedef Microsoft::WRL::ComPtr ID3D12QueryHeapPtr; 52 | typedef Microsoft::WRL::ComPtr ID3D12ResourcePtr; 53 | typedef Microsoft::WRL::ComPtr ID3D12RootSignaturePtr; 54 | typedef Microsoft::WRL::ComPtr ID3D12RootSignatureDeserializerPtr; 55 | 56 | typedef Microsoft::WRL::ComPtr ID3D12FunctionParameterReflectionPtr; 57 | typedef Microsoft::WRL::ComPtr ID3D12FunctionReflectionPtr; 58 | typedef Microsoft::WRL::ComPtr ID3D12LibraryReflectionPtr; 59 | typedef Microsoft::WRL::ComPtr ID3D12ShaderReflectionPtr; 60 | typedef Microsoft::WRL::ComPtr ID3D12ShaderReflectionConstantBufferPtr; 61 | typedef Microsoft::WRL::ComPtr ID3D12ShaderReflectionTypePtr; 62 | typedef Microsoft::WRL::ComPtr ID3D12ShaderReflectionVariablePtr; 63 | 64 | typedef Microsoft::WRL::ComPtr ID3D12DebugPtr; 65 | typedef Microsoft::WRL::ComPtr ID3D12Debug1Ptr; 66 | typedef Microsoft::WRL::ComPtr ID3D12DebugDevicePtr; 67 | typedef Microsoft::WRL::ComPtr ID3D12DebugCommandListPtr; 68 | typedef Microsoft::WRL::ComPtr ID3D12DebugCommandQueuePtr; 69 | typedef Microsoft::WRL::ComPtr ID3D12InfoQueuePtr; 70 | 71 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Manifest.txt: -------------------------------------------------------------------------------- 1 | [Code] 2 | Graphics\ 3 | EnkiTS\ 4 | SettingsCompiler\ 5 | |SettingsCompiler\bin\ 6 | |SettingsCompiler\obj\ 7 | SettingsCompilerAttributes\ 8 | |SettingsCompilerAttributes\bin\ 9 | |SettingsCompilerAttributes\obj\ 10 | 11 | [Local] 12 | Shaders\ 13 | SettingsCompiler.exe 14 | SettingsCompilerAttributes.dll 15 | 16 | [Content] 17 | 18 | Textures\Default.dds 19 | Textures\DefaultNormalMap.dds 20 | Textures\DefaultRoughness.dds 21 | Textures\DefaultBlack.dds 22 | 23 | [Externals] 24 | 25 | imgui-1.46\ 26 | Assimp-3.1.1\ 27 | DirectXTex Aug 2015\ 28 | HosekSky\ 29 | WinPixEventRuntime\ 30 | cxxopts\ -------------------------------------------------------------------------------- /SampleFramework12/v1.01/MurmurHash.h: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 SampleFramework12 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, int32 len, uint32 seed = 0); 34 | Hash CombineHashes(Hash a, Hash b); 35 | 36 | } -------------------------------------------------------------------------------- /SampleFramework12/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 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/SF12.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | ..\SampleFramework12\v1.01\ 6 | 7 | 8 | $(ProjectDir);$(SampleFrameworkDir);$(IncludePath) 9 | 10 | 11 | 12 | %(PreprocessorDefinitions);SampleFrameworkDir_=L"..\\SampleFramework12\\v1.01\\" 13 | Create 14 | PCH.h 15 | true 16 | 17 | 18 | 19 | 20 | 21 | 22 | copy %(FullPath) $(OutDir)%(Filename)%(Extension) 23 | 24 | 25 | Copying external DLL 26 | 27 | 28 | $(OutDir)%(Filename)%(Extension) 29 | 30 | 31 | false 32 | 33 | 34 | 35 | 36 | $(SampleFrameworkDir) 37 | true 38 | 39 | 40 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Scripts/CopyDXC.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | set BUILD_TYPE=Release 6 | 7 | if "%1"=="-Debug" ( 8 | set BUILD_TYPE=Debug 9 | ) 10 | 11 | xcopy %HLSL_SRC_DIR%\Include\dxc\dxcapi.h %~dp0..\..\..\Externals\DXCompiler\Include\ /y 12 | xcopy %HLSL_BLD_DIR%\%BUILD_TYPE%\lib\dxcompiler.lib %~dp0..\..\..\Externals\DXCompiler\Lib\ /y 13 | xcopy %HLSL_BLD_DIR%\%BUILD_TYPE%\bin\dxcompiler.* %~dp0..\..\..\Externals\DXCompiler\Bin\ /y 14 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Scripts/CopyDXCToOutputDir.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | IF EXIST %1\..\Externals\DXCompiler\Bin\dxcompiler.dll ( 4 | copy %1\..\Externals\DXCompiler\Bin\dxcompiler.dll %2\dxcompiler.dll 5 | ) ELSE ( 6 | copy %3\dxcompiler.dll %2\dxcompiler.dll 7 | ) 8 | 9 | copy %3\dxil.dll %2\dxil.dll -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Scripts/SoftCopy.bat: -------------------------------------------------------------------------------- 1 | IF EXIST %1 (copy %1 %2) -------------------------------------------------------------------------------- /SampleFramework12/v1.01/SettingsCompiler.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/SampleFramework12/v1.01/SettingsCompiler.exe -------------------------------------------------------------------------------- /SampleFramework12/v1.01/SettingsCompiler.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingsCompiler", "SettingsCompiler\SettingsCompiler.csproj", "{A01DD775-61A4-42F1-9B2A-772E50456A68}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingsCompilerAttributes", "SettingsCompilerAttributes\SettingsCompilerAttributes.csproj", "{C61F717F-FF92-4D36-930E-1F49C198CBEE}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A01DD775-61A4-42F1-9B2A-772E50456A68}.Debug|x64.ActiveCfg = Debug|x64 17 | {A01DD775-61A4-42F1-9B2A-772E50456A68}.Debug|x64.Build.0 = Debug|x64 18 | {A01DD775-61A4-42F1-9B2A-772E50456A68}.Release|x64.ActiveCfg = Release|x64 19 | {A01DD775-61A4-42F1-9B2A-772E50456A68}.Release|x64.Build.0 = Release|x64 20 | {C61F717F-FF92-4D36-930E-1F49C198CBEE}.Debug|x64.ActiveCfg = Debug|x64 21 | {C61F717F-FF92-4D36-930E-1F49C198CBEE}.Debug|x64.Build.0 = Debug|x64 22 | {C61F717F-FF92-4D36-930E-1F49C198CBEE}.Release|x64.ActiveCfg = Release|x64 23 | {C61F717F-FF92-4D36-930E-1F49C198CBEE}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/SettingsCompiler/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /SampleFramework12/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 | -------------------------------------------------------------------------------- /SampleFramework12/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 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/SettingsCompilerAttributes.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/SampleFramework12/v1.01/SettingsCompilerAttributes.dll -------------------------------------------------------------------------------- /SampleFramework12/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 | -------------------------------------------------------------------------------- /SampleFramework12/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 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Shaders/Constants.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 | // Scale factor used for storing physical light units in fp16 floats (equal to 2^-10). 24 | static const float FP16Scale = 0.0009765625f; 25 | 26 | #endif // CONSTANTS_HLSL_ -------------------------------------------------------------------------------- /SampleFramework12/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 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Shaders/DecodeTextureCS.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #include 11 | 12 | //================================================================================================= 13 | // Resources 14 | //================================================================================================= 15 | 16 | // Inputs 17 | struct SRVIndicesLayout 18 | { 19 | uint InputTexture; 20 | }; 21 | 22 | ConstantBuffer SRVIndices : register(b0); 23 | 24 | 25 | // Outputs 26 | RWBuffer OutputBuffer : register(u0); 27 | 28 | //================================================================================================= 29 | // Entry points 30 | //================================================================================================= 31 | [numthreads(TGSize_, TGSize_, 1)] 32 | void DecodeTextureCS(in uint3 GroupID : SV_GroupID, in uint3 GroupThreadID : SV_GroupThreadID) 33 | { 34 | Texture2D inputTexture = Tex2DTable[SRVIndices.InputTexture]; 35 | 36 | uint2 textureSize = 0; 37 | inputTexture.GetDimensions(textureSize.x, textureSize.y); 38 | const uint2 texelIdx = GroupID.xy * uint2(TGSize_, TGSize_) + GroupThreadID.xy; 39 | const uint bufferIdx = texelIdx.y * textureSize.x + texelIdx.x; 40 | OutputBuffer[bufferIdx] = inputTexture[texelIdx]; 41 | } 42 | 43 | [numthreads(TGSize_, TGSize_, 1)] 44 | void DecodeTextureArrayCS(in uint3 GroupID : SV_GroupID, in uint3 GroupThreadID : SV_GroupThreadID) 45 | { 46 | Texture2DArray inputTexture = Tex2DArrayTable[SRVIndices.InputTexture]; 47 | 48 | uint2 textureSize = 0; 49 | uint numSlices = 0; 50 | inputTexture.GetDimensions(textureSize.x, textureSize.y, numSlices); 51 | const uint3 texelIdx = uint3(GroupID.xy * uint2(TGSize_, TGSize_) + GroupThreadID.xy, GroupID.z); 52 | const uint bufferIdx = texelIdx.z * (textureSize.x * textureSize.y) + (texelIdx.y * textureSize.x) + texelIdx.x; 53 | OutputBuffer[bufferIdx] = inputTexture[texelIdx]; 54 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Shaders/DescriptorTables.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | // This is the standard set of descriptor tables that shaders use for accessing the SRV's that they need. 11 | // These must match "NumStandardDescriptorRanges" and "StandardDescriptorRanges()" from DX12_Helpers.h 12 | Texture2D Tex2DTable[] : register(t0, space0); 13 | Texture2DArray Tex2DArrayTable[] : register(t0, space1); 14 | TextureCube TexCubeTable[] : register(t0, space2); 15 | Texture3D Tex3DTable[] : register(t0, space3); 16 | Texture2DMS Tex2DMSTable[] : register(t0, space4); 17 | ByteAddressBuffer RawBufferTable[] : register(t0, space5); 18 | Buffer BufferUintTable[] : register(t0, space6); -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Shaders/EVSM.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | float2 GetEVSMExponents(in float positiveExponent, in float negativeExponent, 11 | in float3 cascadeScale) 12 | { 13 | 14 | const float maxExponent = 42.0f; 15 | 16 | float2 lightSpaceExponents = float2(positiveExponent, negativeExponent); 17 | 18 | // Make sure exponents say consistent in light space regardless of partition 19 | // scaling. This prevents the exponentials from ever getting too rediculous 20 | // and maintains consistency across partitions. 21 | // Clamp to maximum range of fp32/fp16 to prevent overflow/underflow 22 | return min(lightSpaceExponents / cascadeScale.z, maxExponent); 23 | } 24 | 25 | // Input depth should be in [0, 1] 26 | float2 WarpDepth(float depth, float2 exponents) 27 | { 28 | // Rescale depth into [-1, 1] 29 | depth = 2.0f * depth - 1.0f; 30 | float pos = exp( exponents.x * depth); 31 | float neg = -exp(-exponents.y * depth); 32 | return float2(pos, neg); 33 | } 34 | 35 | //------------------------------------------------------------------------------------------------- 36 | // Reduces EVSM/MSM light bleeding by clipping and rescaling 37 | //------------------------------------------------------------------------------------------------- 38 | float ReduceLightBleeding(float shadowAmt, float clipAmt) 39 | { 40 | // Remove the [0, clipAmt] tail and linearly rescale (clipAmt, 1]. 41 | return saturate((shadowAmt - clipAmt) / (1.0f - clipAmt)); 42 | } 43 | 44 | float ChebyshevUpperBound(float2 moments, float mean, float minVariance, 45 | float lightBleedingReduction) 46 | { 47 | // Compute variance 48 | float variance = moments.y - (moments.x * moments.x); 49 | variance = max(variance, minVariance); 50 | 51 | // Compute probabilistic upper bound 52 | float d = mean - moments.x; 53 | float pMax = variance / (variance + (d * d)); 54 | 55 | pMax = ReduceLightBleeding(pMax, lightBleedingReduction); 56 | 57 | // One-tailed Chebyshev 58 | return (mean <= moments.x ? 1.0f : pMax); 59 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Shaders/FullScreenTriangle.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 | struct VSOutput 14 | { 15 | float4 Position : SV_Position; 16 | float2 TexCoord : TEXCOORD; 17 | }; 18 | 19 | //================================================================================================= 20 | // Vertex Shader 21 | //================================================================================================= 22 | VSOutput FullScreenTriangleVS(in uint VertexIdx : SV_VertexID) 23 | { 24 | VSOutput output; 25 | 26 | if(VertexIdx == 0) 27 | { 28 | output.Position = float4(-1.0f, 1.0f, 1.0f, 1.0f); 29 | output.TexCoord = float2(0.0f, 0.0f); 30 | } 31 | else if(VertexIdx == 1) 32 | { 33 | output.Position = float4(3.0f, 1.0f, 1.0f, 1.0f); 34 | output.TexCoord = float2(2.0f, 0.0f); 35 | } 36 | else 37 | { 38 | output.Position = float4(-1.0f, -3.0f, 1.0f, 1.0f); 39 | output.TexCoord = float2(0.0f, 2.0f); 40 | } 41 | 42 | return output; 43 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Shaders/ImGui.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #include 11 | 12 | struct VSInput 13 | { 14 | float2 Position : POSITION; 15 | float4 Color : COLOR; 16 | float2 UV : UV; 17 | }; 18 | 19 | struct VSOutput 20 | { 21 | float4 Position : SV_Position; 22 | float4 Color : COLOR; 23 | float2 UV : UV; 24 | }; 25 | 26 | struct ImGuiConstants 27 | { 28 | row_major float4x4 ProjectionMatrix; 29 | }; 30 | 31 | struct SRVIndicesLayout 32 | { 33 | uint TextureIdx; 34 | }; 35 | 36 | SamplerState LinearSampler : register(s0); 37 | ConstantBuffer ImGuiCB : register(b0); 38 | ConstantBuffer SRVIndices : register(b1); 39 | 40 | VSOutput ImGuiVS(in VSInput input) 41 | { 42 | VSOutput output; 43 | output.Position = mul(float4(input.Position, 0.0f, 1.0f), ImGuiCB.ProjectionMatrix); 44 | output.Color = input.Color; 45 | output.UV = input.UV; 46 | 47 | return output; 48 | } 49 | 50 | float4 ImGuiPS(in VSOutput input) : SV_Target0 51 | { 52 | Texture2D imGuiTexture = Tex2DTable[SRVIndices.TextureIdx]; 53 | return imGuiTexture.Sample(LinearSampler, input.UV) * input.Color; 54 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Shaders/PPCommon.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 | SamplerState PointSampler : register(s0); 11 | SamplerState LinearSampler : register(s1); 12 | SamplerState LinearWrapSampler : register(s2); 13 | SamplerState LinearBorderSampler : register(s3); 14 | 15 | struct SRVIndicesLayout 16 | { 17 | uint Idx0; 18 | uint Idx1; 19 | uint Idx2; 20 | uint Idx3; 21 | uint Idx4; 22 | uint Idx5; 23 | uint Idx6; 24 | uint Idx7; 25 | }; 26 | 27 | ConstantBuffer SRVIndices : register(b0); 28 | 29 | struct PSInput 30 | { 31 | float4 PositionSS : SV_Position; 32 | float2 TexCoord : TEXCOORD; 33 | }; -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Shaders/Skybox.hlsl: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 Sample Framework 4 | // http://mynameismjp.wordpress.com/ 5 | // 6 | // All code licensed under the MIT license 7 | // 8 | //================================================================================================= 9 | 10 | #include 11 | #include 12 | 13 | //================================================================================================= 14 | // Constant buffers 15 | //================================================================================================= 16 | struct VSConstants 17 | { 18 | row_major float4x4 View; 19 | row_major float4x4 Projection; 20 | float3 Bias; 21 | }; 22 | 23 | struct PSConstants 24 | { 25 | float3 SunDirection; 26 | float CosSunAngularRadius; 27 | float3 SunColor; 28 | float3 Scale; 29 | uint EnvMapIdx; 30 | }; 31 | 32 | ConstantBuffer VSCBuffer : register(b0); 33 | ConstantBuffer PSCBuffer : register(b0); 34 | 35 | //================================================================================================= 36 | // Samplers 37 | //================================================================================================= 38 | SamplerState LinearSampler : register(s0); 39 | 40 | //================================================================================================= 41 | // Input/Output structs 42 | //================================================================================================= 43 | 44 | struct VSInput 45 | { 46 | float3 PositionOS : POSITION; 47 | }; 48 | 49 | struct VSOutput 50 | { 51 | float4 PositionCS : SV_Position; 52 | float3 TexCoord : TEXCOORD; 53 | }; 54 | 55 | //================================================================================================= 56 | // Vertex Shader 57 | //================================================================================================= 58 | VSOutput SkyboxVS(in VSInput input) 59 | { 60 | VSOutput output; 61 | 62 | // Rotate into view-space, centered on the camera 63 | float3 positionVS = mul(float4(input.PositionOS, 0.0f), VSCBuffer.View).xyz; 64 | 65 | // Transform to clip-space 66 | output.PositionCS = mul(float4(positionVS, 1.0f), VSCBuffer.Projection); 67 | output.PositionCS.z = output.PositionCS.w; 68 | 69 | // Make a texture coordinate 70 | output.TexCoord = input.PositionOS; 71 | 72 | return output; 73 | } 74 | 75 | //================================================================================================= 76 | // Environment Map Pixel Shader 77 | //================================================================================================= 78 | float4 SkyboxPS(in VSOutput input) : SV_Target 79 | { 80 | // Sample the environment map 81 | TextureCube envMap = TexCubeTable[PSCBuffer.EnvMapIdx]; 82 | float3 color = envMap.Sample(LinearSampler, normalize(input.TexCoord)).xyz; 83 | 84 | // Draw a circle for the sun 85 | float3 dir = normalize(input.TexCoord); 86 | if(PSCBuffer.CosSunAngularRadius > 0.0f) 87 | { 88 | float cosSunAngle = dot(dir, PSCBuffer.SunDirection); 89 | if(cosSunAngle >= PSCBuffer.CosSunAngularRadius) 90 | color = PSCBuffer.SunColor; 91 | } 92 | 93 | color *= PSCBuffer.Scale; 94 | color = clamp(color, 0.0f, FP16Max); 95 | 96 | return float4(color, 1.0f); 97 | } 98 | -------------------------------------------------------------------------------- /SampleFramework12/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 SampleFramework12 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 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Tools/Packager.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheRealMJP/DeferredTexturing/20788a8f0f8a1406c01bbdb7ce18ef36bb5bf3b9/SampleFramework12/v1.01/Tools/Packager.exe -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Tools/Packager/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Tools/Packager/Packager.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {C90AF2A3-8AD5-4057-93E9-44810F6470B4} 8 | WinExe 9 | Properties 10 | Packager 11 | Packager 12 | v4.5 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Form 50 | 51 | 52 | MainFrm.cs 53 | 54 | 55 | 56 | 57 | MainFrm.cs 58 | 59 | 60 | ResXFileCodeGenerator 61 | Resources.Designer.cs 62 | Designer 63 | 64 | 65 | True 66 | Resources.resx 67 | 68 | 69 | SettingsSingleFileGenerator 70 | Settings.Designer.cs 71 | 72 | 73 | True 74 | Settings.settings 75 | True 76 | 77 | 78 | 79 | 80 | 81 | 82 | 89 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Tools/Packager/Packager.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("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Packager", "Packager.csproj", "{C90AF2A3-8AD5-4057-93E9-44810F6470B4}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {C90AF2A3-8AD5-4057-93E9-44810F6470B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {C90AF2A3-8AD5-4057-93E9-44810F6470B4}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {C90AF2A3-8AD5-4057-93E9-44810F6470B4}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {C90AF2A3-8AD5-4057-93E9-44810F6470B4}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Tools/Packager/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace Packager 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new MainFrm()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Tools/Packager/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("Packager")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Packager")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 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("19f9cd55-7425-4706-899d-ce34c4592123")] 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 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Tools/Packager/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18444 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Packager.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Packager.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Tools/Packager/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18444 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Packager.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.UserScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("")] 29 | public string CurrentProject { 30 | get { 31 | return ((string)(this["CurrentProject"])); 32 | } 33 | set { 34 | this["CurrentProject"] = value; 35 | } 36 | } 37 | 38 | [global::System.Configuration.UserScopedSettingAttribute()] 39 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 40 | [global::System.Configuration.DefaultSettingValueAttribute("")] 41 | public string CurrentOutput { 42 | get { 43 | return ((string)(this["CurrentOutput"])); 44 | } 45 | set { 46 | this["CurrentOutput"] = value; 47 | } 48 | } 49 | 50 | [global::System.Configuration.UserScopedSettingAttribute()] 51 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 52 | [global::System.Configuration.DefaultSettingValueAttribute("")] 53 | public string CurrentZIP { 54 | get { 55 | return ((string)(this["CurrentZIP"])); 56 | } 57 | set { 58 | this["CurrentZIP"] = value; 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Tools/Packager/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /SampleFramework12/v1.01/Utility.cpp: -------------------------------------------------------------------------------- 1 | //================================================================================================= 2 | // 3 | // MJP's DX12 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 "Utility.h" 13 | #include "Exceptions.h" 14 | #include "App.h" 15 | 16 | namespace SampleFramework12 17 | { 18 | 19 | void WriteLog(const wchar* format, ...) 20 | { 21 | wchar buffer[1024] = { 0 }; 22 | va_list args; 23 | va_start(args, format); 24 | vswprintf_s(buffer, ArraySize_(buffer), format, args); 25 | if(GlobalApp != nullptr) 26 | GlobalApp->AddToLog(WStringToAnsi(buffer).c_str()); 27 | 28 | OutputDebugStringW(buffer); 29 | OutputDebugStringW(L"\n"); 30 | } 31 | 32 | void WriteLog(const char* format, ...) 33 | { 34 | char buffer[1024] = { 0 }; 35 | va_list args; 36 | va_start(args, format); 37 | vsprintf_s(buffer, ArraySize_(buffer), format, args); 38 | if(GlobalApp != nullptr) 39 | GlobalApp->AddToLog(buffer); 40 | 41 | OutputDebugStringA(buffer); 42 | OutputDebugStringA("\n"); 43 | } 44 | 45 | std::wstring MakeString(const wchar* format, ...) 46 | { 47 | wchar buffer[1024] = { 0 }; 48 | va_list args; 49 | va_start(args, format); 50 | vswprintf_s(buffer, ArraySize_(buffer), format, args); 51 | return std::wstring(buffer); 52 | } 53 | 54 | std::string MakeString(const char* format, ...) 55 | { 56 | char buffer[1024] = { 0 }; 57 | va_list args; 58 | va_start(args, format); 59 | vsprintf_s(buffer, ArraySize_(buffer), format, args); 60 | return std::string(buffer); 61 | } 62 | 63 | std::wstring SampleFrameworkDir() 64 | { 65 | return std::wstring(SampleFrameworkDir_); 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /SampleFramework12/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 | #include "Containers.h" 16 | 17 | namespace SampleFramework12 18 | { 19 | 20 | class Window 21 | { 22 | 23 | // Public types 24 | public: 25 | 26 | typedef void (*MsgFunction)(void*, HWND, UINT, WPARAM, LPARAM); 27 | 28 | // Constructor and destructor 29 | public: 30 | 31 | Window(HINSTANCE hinstance, 32 | LPCWSTR name = L"SampleCommon Window", 33 | DWORD style = WS_CAPTION|WS_OVERLAPPED|WS_SYSMENU, 34 | DWORD exStyle = WS_EX_APPWINDOW, 35 | DWORD clientWidth = 1280, 36 | DWORD clientHeight = 720, 37 | LPCWSTR iconResource = NULL, 38 | LPCWSTR smallIconResource = NULL, 39 | LPCWSTR menuResource = NULL, 40 | LPCWSTR accelResource = NULL ); 41 | ~Window(); 42 | 43 | 44 | 45 | // Public methods 46 | public: 47 | 48 | HWND GetHwnd() const; 49 | HMENU GetMenu() const; 50 | HINSTANCE GetHinstance() const; 51 | void MessageLoop(); 52 | 53 | BOOL IsAlive() const; 54 | BOOL IsMinimized() const; 55 | BOOL HasFocus() const; 56 | LONG_PTR GetWindowStyle() const; 57 | LONG_PTR GetExtendedStyle() const; 58 | void SetWindowStyle(DWORD newStyle ); 59 | void SetExtendedStyle(DWORD newExStyle ); 60 | void Maximize(); 61 | void SetWindowPos(INT posX, INT posY); 62 | void GetWindowPos(INT& posX, INT& posY) const; 63 | void ShowWindow(bool show = true); 64 | void SetClientArea(INT clientX, INT clientY); 65 | void GetClientArea(INT& clientX, INT& clientY) const; 66 | void SetWindowTitle(LPCWSTR title); 67 | void SetScrollRanges(INT scrollRangeX, 68 | INT scrollRangeY, 69 | INT posX, 70 | INT posY); 71 | void Destroy(); 72 | 73 | INT CreateMessageBox(LPCWSTR message, LPCWSTR title = NULL, UINT type = MB_OK); 74 | 75 | void RegisterMessageCallback(MsgFunction msgFunction, void* context); 76 | 77 | operator HWND() { return hwnd; } //conversion operator 78 | 79 | // Private methods 80 | private: 81 | void MakeWindow(LPCWSTR iconResource, LPCWSTR smallIconResource, LPCWSTR menuResource); 82 | 83 | LRESULT MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 84 | static LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 85 | 86 | // Private members 87 | private: 88 | 89 | // Window properties 90 | HWND hwnd; // The window handle 91 | HINSTANCE hinstance; // The HINSTANCE of the application 92 | std::wstring appName; // The name of the application 93 | DWORD style; // The current window style 94 | DWORD exStyle; // The extended window style 95 | HACCEL accelTable; // Accelerator table handle 96 | 97 | struct Callback 98 | { 99 | MsgFunction Function; 100 | void* Context; 101 | }; 102 | 103 | GrowableList messageCallbacks; // Message callback list 104 | }; 105 | 106 | } -------------------------------------------------------------------------------- /SampleFramework12/v1.01/sf12.natvis: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | size 6 | 7 | size 8 | data 9 | 10 | 11 | 12 | 13 | 14 | 15 | count 16 | array 17 | 18 | count 19 | array.data 20 | 21 | 22 | 23 | 24 | 25 | {{x={x} y={y} z={z} w={w}}} 26 | 27 | 28 | 29 | {{x={x} y={y} z={z} w={w}}} 30 | 31 | 32 | 33 | {{x={x} y={y} z={z} w={w}}} 34 | 35 | 36 | --------------------------------------------------------------------------------