Skip to content

Commit 187502d

Browse files
committed
GITechDemo:
*switched default BRDF to Cook-Torrance with GGX normal distribution and geometric shadowing terms *added new BRDFs: Ashikhmin-Shirley and Ward *added PBR material samples throughout the Sponza model *added a script which builds PBR sample model and textures *added an option to tonemap and saturate colors in the color copy shader in order to fix issues with SSR (specular highlights with very high intensity would ruin the mip chain of the light accumulation buffer and cause very bright reflections on rougher surfaces) *updated some artist parameters (mainly lighting parameters and some post-processing parameters to compensate for the latter) *refactored and fixed various issues with Cook-Torrance shader code *moved cubemap reflections code from DirectionalLight.hlsl to ScreenSpaceReflection.hlsl so as to properly blend it with the SSR result, where applicable *updated .gitignore for VS2017
1 parent bebb6ce commit 187502d

File tree

107 files changed

+6636
-104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+6636
-104
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*.user
77
*.sln.docstates
88
*.VC.opendb
9+
.vs/
910

1011
# Build results
1112
[Dd]ebug/

GITechDemo/Build/build_data_win.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def Run():
5353
# List of scripts to run for building data
5454
dataBuildScript = [
5555
"compile_sponza_model.py",
56+
"compile_pbr_materials.py",
5657
"compile_utility_textures.py"
5758
]
5859

GITechDemo/Code/AppMain/GITechDemo.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ xcopy /y /d "$(SolutionDir)..\External\Synesthesia3D\External\DX9\utils\$(Platfo
348348
<ClInclude Include="Framework\Windows\FrameworkWin.h" />
349349
<ClInclude Include="GITechDemo\RenderScheme\DirectionalLightVolumePass.h" />
350350
<ClInclude Include="GITechDemo\RenderScheme\HDRDownsampleForBloomPass.h" />
351+
<ClInclude Include="GITechDemo\RenderScheme\PBRMaterialTestPass.h" />
351352
<ClInclude Include="GITechDemo\RenderScheme\ScreenSpaceReflectionPass.h" />
352353
<ClInclude Include="GITechDemo\RenderScheme\SSAOPass.h" />
353354
<ClInclude Include="GITechDemo\RenderScheme\BloomPass.h" />
@@ -384,6 +385,7 @@ xcopy /y /d "$(SolutionDir)..\External\Synesthesia3D\External\DX9\utils\$(Platfo
384385
<ClCompile Include="Framework\Windows\FrameworkWin.cpp" />
385386
<ClCompile Include="GITechDemo\RenderScheme\DirectionalLightVolumePass.cpp" />
386387
<ClCompile Include="GITechDemo\RenderScheme\HDRDownsampleForBloomPass.cpp" />
388+
<ClCompile Include="GITechDemo\RenderScheme\PBRMaterialTestPass.cpp" />
387389
<ClCompile Include="GITechDemo\RenderScheme\ScreenSpaceReflectionPass.cpp" />
388390
<ClCompile Include="GITechDemo\RenderScheme\SSAOPass.cpp" />
389391
<ClCompile Include="GITechDemo\RenderScheme\BloomPass.cpp" />

GITechDemo/Code/AppMain/GITechDemo.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@
145145
<ClInclude Include="GITechDemo\RenderScheme\ScreenSpaceReflectionPass.h">
146146
<Filter>App\Render Schemes</Filter>
147147
</ClInclude>
148+
<ClInclude Include="GITechDemo\RenderScheme\PBRMaterialTestPass.h">
149+
<Filter>App\Render Schemes</Filter>
150+
</ClInclude>
148151
</ItemGroup>
149152
<ItemGroup>
150153
<ClCompile Include="Framework\main.cpp">
@@ -246,6 +249,9 @@
246249
<ClCompile Include="GITechDemo\RenderScheme\ScreenSpaceReflectionPass.cpp">
247250
<Filter>App\Render Schemes</Filter>
248251
</ClCompile>
252+
<ClCompile Include="GITechDemo\RenderScheme\PBRMaterialTestPass.cpp">
253+
<Filter>App\Render Schemes</Filter>
254+
</ClCompile>
249255
</ItemGroup>
250256
<ItemGroup>
251257
<Image Include="Framework\Windows\Framework.ico">

GITechDemo/Code/AppMain/GITechDemo/GITechDemo.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,34 @@ void GITechDemo::Update(const float fDeltaTime)
670670
}
671671
gmtl::normalize((Vec3f&)f3LightDir);
672672

673+
#if 0
674+
// NaN at this position!
675+
f3LightDir.GetCurrentValue()[0] = 9.41706021e-05;
676+
f3LightDir.GetCurrentValue()[1] = -1.00000000;
677+
f3LightDir.GetCurrentValue()[2] = -0.000278121064;
678+
679+
m_tCamera.vPos[0] = 545.252686;
680+
m_tCamera.vPos[1] = -1660.33801;
681+
m_tCamera.vPos[2] = -81.6245651;
682+
683+
m_tCamera.mRot.mData[0] = -0.0230895355;
684+
m_tCamera.mRot.mData[1] = 0.260565788;
685+
m_tCamera.mRot.mData[2] = 0.965138495;
686+
m_tCamera.mRot.mData[3] = 0.000000000;
687+
m_tCamera.mRot.mData[4] = 0.0582327023;
688+
m_tCamera.mRot.mData[5] = 0.964119077;
689+
m_tCamera.mRot.mData[6] = -0.258897275;
690+
m_tCamera.mRot.mData[7] = 0.000000000;
691+
m_tCamera.mRot.mData[8] = -0.998014688;
692+
m_tCamera.mRot.mData[9] = 0.0502296351;
693+
m_tCamera.mRot.mData[10] = -0.0374352485;
694+
m_tCamera.mRot.mData[11] = 0.000000000;
695+
m_tCamera.mRot.mData[12] = 0.000000000;
696+
m_tCamera.mRot.mData[13] = 0.000000000;
697+
m_tCamera.mRot.mData[14] = 0.000000000;
698+
m_tCamera.mRot.mData[15] = 1.00000000;
699+
#endif
700+
673701
// Precalculate some parts of the equation for reconstructing
674702
// linear depth from hyperbolic depth
675703
f2LinearDepthEquation = Vec2f(fZNear * fZFar / (fZNear - fZFar), fZFar / (fZFar - fZNear));

GITechDemo/Code/AppMain/GITechDemo/RenderScheme/BloomPass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void BloomPass::Update(const float fDeltaTime)
7070
bSingleChannelCopy = false;
7171
f4CustomColorModulator = Vec4f(1.f, 1.f, 1.f, 1.f);
7272
bDepthDownsample = false;
73+
bApplyTonemap = false;
7374
}
7475

7576
// Apply a brightness filter to the downsampled HDR scene color buffer

GITechDemo/Code/AppMain/GITechDemo/RenderScheme/DepthOfFieldPass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ void DepthOfFieldPass::Update(const float fDeltaTime)
8787

8888
bSingleChannelCopy = false;
8989
f4CustomColorModulator = Vec4f(1.f, 1.f, 1.f, 1.f);
90+
bApplyTonemap = false;
9091
}
9192

9293
void DepthOfFieldPass::AutofocusPass()

GITechDemo/Code/AppMain/GITechDemo/RenderScheme/DirectionalLightVolumePass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ void DirectionalLightVolumePass::Update(const float fDeltaTime)
8787
texNoise = NoiseTexture.GetTextureIndex();
8888
fElapsedTime += fDeltaTime;
8989
f3FogBox = Vec3f(CASCADE_MAX_VIEW_DEPTH, CASCADE_MAX_VIEW_DEPTH, CASCADE_MAX_VIEW_DEPTH);
90+
bApplyTonemap = false;
9091
}
9192

9293
void DirectionalLightVolumePass::CalculateLightVolume()

GITechDemo/Code/AppMain/GITechDemo/RenderScheme/GBufferPass.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ void GBufferPass::Update(const float fDeltaTime)
6767
ResourceMgr->GetTexture(GBuffer.GetRenderTarget()->GetColorBuffer(3))->SetAddressingMode(SAM_CLAMP);
6868
ResourceMgr->GetTexture(GBuffer.GetRenderTarget()->GetDepthBuffer())->SetAddressingMode(SAM_CLAMP);
6969

70+
// Update matrices
71+
f44WorldMat = makeTrans(Vec3f(0, 0, 0), Type2Type<Matrix44f>());
7072
f44WorldViewMat = f44ViewMat * f44WorldMat;
7173
f44WorldViewProjMat = f44ProjMat * f44WorldViewMat;
7274

@@ -169,13 +171,13 @@ void GBufferPass::Draw()
169171
bHasNormalMap = (texNormal != -1) && GBUFFER_USE_NORMAL_MAPS;
170172

171173
// For Blinn-Phong BRDF
172-
texSpec = (nBRDFModel == BLINN_PHONG ? specTexIdx : ~0u);
174+
texSpec = specTexIdx;
173175
bHasSpecMap = (texSpec != -1);
174176
fSpecIntensity = SponzaScene.GetModel()->arrMaterial[SponzaScene.GetModel()->arrMesh[mesh]->nMaterialIdx]->fShininessStrength;
175177

176178
// For Cook-Torrance BRDF
177-
texMatType = (nBRDFModel == COOK_TORRANCE_GGX || nBRDFModel == COOK_TORRANCE_BECKMANN ? matTexIdx : ~0u);
178-
texRoughness = (nBRDFModel == COOK_TORRANCE_GGX || nBRDFModel == COOK_TORRANCE_BECKMANN ? roughnessTexIdx : ~0u);
179+
texMatType = matTexIdx;
180+
texRoughness = roughnessTexIdx;
179181

180182
GBufferGenerationShader.Enable();
181183
RenderContext->DrawVertexBuffer(SponzaScene.GetModel()->arrMesh[mesh]->pVertexBuffer);
@@ -194,6 +196,9 @@ void GBufferPass::Draw()
194196

195197
GBuffer.Disable();
196198

199+
// Draw child render passes (in this case, the PBR material test spheres)
200+
DrawChildren();
201+
197202
// Generate linear depth buffer and quarter-resolution versions of the hyperbolic and linear depth buffers
198203
const bool blendEnable = RenderContext->GetRenderStateManager()->GetColorBlendEnabled();
199204
RenderContext->GetRenderStateManager()->SetColorBlendEnabled(false);

GITechDemo/Code/AppMain/GITechDemo/RenderScheme/MotionBlurPass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ void MotionBlurPass::Update(const float fDeltaTime)
5050
{
5151
bSingleChannelCopy = false;
5252
f4CustomColorModulator = Vec4f(1.f, 1.f, 1.f, 1.f);
53+
bApplyTonemap = false;
5354
}
5455

5556
void MotionBlurPass::Draw()

0 commit comments

Comments
 (0)