Skip to content

Commit b88c5df

Browse files
committed
GITechDemo changes:
*Some RSM optimizations in the form of a quarter-resolution indirect light accumulation buffer, which gets additively color blended over the full-res light accumulation buffer using edge-aware bilateral upscaling *Added a new PCF filter type with a 4x4 Poisson Disk kernel rotated 0, 90, 180 and 270 degrees around its center (although more bandwidth intensive, it further improved the shadow's jagged edges) *Created a script for automating the build process LibRenderer changes: *Small bug fixes
1 parent 5bf7b77 commit b88c5df

File tree

13 files changed

+300
-101
lines changed

13 files changed

+300
-101
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
[Dd]ebugPublic/
1212
[Rr]elease/
1313
## x64/
14-
build/
14+
#build/
15+
!/*/[Bb]uild/**
16+
/*/[Bb]uild/**/
1517
bld/
1618
/*/[Bb]in/
1719
[Oo]bj/

GITechDemo/Build/build_win.py

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
import os
2+
import shutil
3+
import fnmatch
4+
import errno
5+
import sys
6+
7+
PROJECT_NAME = "GITechDemo"
8+
DEFAULT_VSCOMNTOOLS = "VS120COMNTOOLS"
9+
FORCE_REBUILD = False
10+
11+
def copyfiles(srcdir, dstdir, filepattern):
12+
def failed(exc):
13+
raise exc
14+
15+
for dirpath, dirs, files in os.walk(srcdir, topdown=True, onerror=failed):
16+
for file in fnmatch.filter(files, filepattern):
17+
shutil.copy2(os.path.join(dirpath, file), dstdir)
18+
break # no recursion
19+
20+
def makedir(path):
21+
try:
22+
os.makedirs(path)
23+
except OSError as exception:
24+
if exception.errno != errno.EEXIST:
25+
raise
26+
27+
def copytree(src, dst, symlinks = False, ignore = None):
28+
if not os.path.exists(dst):
29+
os.makedirs(dst)
30+
shutil.copystat(src, dst)
31+
lst = os.listdir(src)
32+
if ignore:
33+
excl = ignore(src, lst)
34+
lst = [x for x in lst if x not in excl]
35+
for item in lst:
36+
s = os.path.join(src, item)
37+
d = os.path.join(dst, item)
38+
if symlinks and os.path.islink(s):
39+
if os.path.lexists(d):
40+
os.remove(d)
41+
os.symlink(os.readlink(s), d)
42+
try:
43+
st = os.lstat(s)
44+
mode = stat.S_IMODE(st.st_mode)
45+
os.lchmod(d, mode)
46+
except:
47+
pass # lchmod not available
48+
elif os.path.isdir(s):
49+
copytree(s, d, symlinks, ignore)
50+
else:
51+
shutil.copy2(s, d)
52+
53+
def buildsln(pathToTools, platform):
54+
cmd = "\"" + pathToTools + "VsDevCmd.bat\" && "
55+
cmd += "MSBuild.exe /maxcpucount /p:Configuration=Release /p:Platform=" + platform
56+
if(FORCE_REBUILD):
57+
cmd += " /t:rebuild "
58+
else:
59+
cmd += " "
60+
cmd += os.getcwd() + "/../Code/Solutions/"
61+
cmd += PROJECT_NAME + ".sln"
62+
#print(cmd)
63+
os.system(cmd)
64+
65+
#os.system('reg query "HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7"')
66+
#os.system('reg delete "HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v "12.0"')
67+
#os.system("reg add \"HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7\" /v \"12.0\" /t REG_SZ /d \"C:\Program Files (x86)\Microsoft Visual Studio 12.0\\\\\"")
68+
69+
if(len(sys.argv) > 1 and sys.argv[1] == "rebuild"):
70+
FORCE_REBUILD = True;
71+
72+
print("\nStarting build process...\n")
73+
74+
if(os.getenv(DEFAULT_VSCOMNTOOLS)):
75+
pathToTools = os.getenv(DEFAULT_VSCOMNTOOLS)
76+
elif(os.getenv("VS140COMNTOOLS")): # Visual Studio 2015
77+
pathToTools = os.getenv("VS140COMNTOOLS")
78+
elif(os.getenv("VS120COMNTOOLS")): # Visual Studio 2013
79+
pathToTools = os.getenv("VS120COMNTOOLS")
80+
#elif(os.getenv("VS110COMNTOOLS")): # Visual Studio 2012
81+
# pathToTools = os.getenv("VS110COMNTOOLS")
82+
#elif(os.getenv("VS100COMNTOOLS")): # Visual Studio 2010
83+
# pathToTools = os.getenv("VS100COMNTOOLS")
84+
#elif(os.getenv("VS90COMNTOOLS")): # Visual Studio 2008
85+
# pathToTools = os.getenv("VS90COMNTOOLS")
86+
#elif(os.getenv("VS80COMNTOOLS")): # Visual Studio 2005
87+
# pathToTools = os.getenv("VS80COMNTOOLS")
88+
else:
89+
print("No compatible version of Visual Studio found!\n")
90+
91+
if(pathToTools):
92+
buildsln(pathToTools, "x86")
93+
buildsln(pathToTools, "x64")
94+
95+
print("\nConfiguring build...\n");
96+
97+
# Create directory structure
98+
makedir("Windows")
99+
makedir("Windows/bin")
100+
makedir("Windows/bin/x64")
101+
makedir("Windows/bin/x86")
102+
makedir("Windows/data")
103+
104+
# Copy 64bit binaries
105+
copyfiles("../Bin/x64/Release/" + PROJECT_NAME + "/", "./Windows/bin/x64", "*.exe")
106+
copyfiles("../Bin/x64/Release/" + PROJECT_NAME + "/", "./Windows/bin/x64", "*.dll")
107+
108+
# Copy 32bit binaries
109+
copyfiles("../Bin/Win32/Release/" + PROJECT_NAME + "/", "./Windows/bin/x86", "*.exe")
110+
copyfiles("../Bin/Win32/Release/" + PROJECT_NAME + "/", "./Windows/bin/x86", "*.dll")
111+
112+
# Copy data
113+
copytree("../Data/", "./Windows/data")
114+
115+
# Create x64 batch files
116+
x64bat = open("./Windows/run_x64.bat", "w")
117+
x64bat.write("\
118+
@echo off\n\
119+
:A\n\
120+
cls\n\
121+
cd %~dp0/data\n\
122+
start %1../bin/x64/" + PROJECT_NAME + ".exe\n\
123+
exit")
124+
x64bat.close()
125+
126+
# Create x86 batch files
127+
x86bat = open("./Windows/run_x86.bat", "w")
128+
x86bat.write("\
129+
@echo off\n\
130+
:A\n\
131+
cls\n\
132+
cd %~dp0/data\n\
133+
start %1../bin/x86/" + PROJECT_NAME + ".exe\n\
134+
exit")
135+
x86bat.close()
136+
137+
print("DONE!");

GITechDemo/Code/AppMain/GITechDemo/GITechDemo.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ const unsigned int RSM_SIZE = 512;
7474
const unsigned int RSM_NUM_PASSES = 8;
7575
const unsigned int RSM_SAMPLES_PER_PASS = 16;
7676
const unsigned int RSM_NUM_SAMPLES = RSM_NUM_PASSES * RSM_SAMPLES_PER_PASS;
77-
const float RSM_INTENSITY = 150.f;
77+
const float RSM_INTENSITY = 200.f;
7878
const float RSM_KERNEL_SCALE = 0.02f;
79-
const bool USE_HALF_RES_INDIRECT_LIGHT_ACCUMULATION_BUFFER = false;
79+
const bool USE_QUARTER_RES_INDIRECT_LIGHT_ACCUMULATION_BUFFER = true;
8080

8181
const bool DEBUG_CSM_CAMERA = false;
8282
const bool DEBUG_RSM_CAMERA = false;
@@ -267,7 +267,7 @@ RenderTarget* ShadowMapDir = nullptr;
267267
RenderTarget* LightAccumulationBuffer = nullptr;
268268
// The RSM render target
269269
RenderTarget* RSMBuffer = nullptr;
270-
// The indirect light accumulation buffer (half resolution)
270+
// The indirect light accumulation buffer (quarter resolution)
271271
RenderTarget* IndirectLightAccumulationBuffer = nullptr;
272272

273273
// A model consisting of several meshes and material information
@@ -733,6 +733,7 @@ void AllocateRenderResources()
733733

734734
// Load the sky cube map texture
735735
skyTexIdx = ResourceMgr->CreateTexture("models/sponza/textures/sky.lrt");
736+
ResourceMgr->GetTexture(skyTexIdx)->SetFilter(SF_MIN_MAG_LINEAR_MIP_LINEAR);
736737
PopLoadThreadEvent(); // textures
737738

738739
// Load shaders
@@ -932,7 +933,7 @@ void AllocateRenderResources()
932933
ResourceMgr->GetTexture(RSMBuffer->GetDepthBuffer())->SetAddressingMode(SAM_BORDER);
933934
ResourceMgr->GetTexture(RSMBuffer->GetDepthBuffer())->SetBorderColor(Vec4f(0.f, 0.f, 0.f, 0.f));
934935

935-
// Indirect lighting accumulation buffer (half resolution)
936+
// Indirect lighting accumulation buffer (quarter resolution)
936937
rtIdx = ResourceMgr->CreateRenderTarget(1, PF_A8R8G8B8, 0.5f, 0.5f, false, false, PF_NONE);
937938
IndirectLightAccumulationBuffer = ResourceMgr->GetRenderTarget(rtIdx);
938939
ResourceMgr->GetTexture(IndirectLightAccumulationBuffer->GetColorBuffer(0))->SetFilter(SF_MIN_MAG_LINEAR_MIP_NONE);
@@ -1794,7 +1795,7 @@ void AccumulateIndirectLight()
17941795
PUSH_PROFILE_MARKER("AccumulateIndirectLight()");
17951796

17961797
RenderTarget* const rtBkp = RenderTarget::GetActiveRenderTarget();
1797-
if (USE_HALF_RES_INDIRECT_LIGHT_ACCUMULATION_BUFFER)
1798+
if (USE_QUARTER_RES_INDIRECT_LIGHT_ACCUMULATION_BUFFER)
17981799
{
17991800
rtBkp->Disable();
18001801
IndirectLightAccumulationBuffer->Enable();
@@ -1806,6 +1807,9 @@ void AccumulateIndirectLight()
18061807
if (ShdInputLUT[RSMApplyVS][f2HalfTexelOffset] != ~0)
18071808
RSMApplyVInput->SetFloat2(ShdInputLUT[RSMApplyVS][f2HalfTexelOffset], Vec2f(0.5f / GBuffer->GetWidth(), 0.5f / GBuffer->GetHeight()));
18081809

1810+
if (ShdInputLUT[RSMApplyPS][f2HalfTexelOffset] != ~0)
1811+
RSMApplyFInput->SetFloat2(ShdInputLUT[RSMApplyPS][f2HalfTexelOffset], Vec2f(0.5f / GBuffer->GetWidth(), 0.5f / GBuffer->GetHeight()));
1812+
18091813
if (ShdInputLUT[RSMApplyPS][texRSMFluxBuffer] != ~0)
18101814
RSMApplyFInput->SetTexture(ShdInputLUT[RSMApplyPS][texRSMFluxBuffer], RSMBuffer->GetColorBuffer(0));
18111815

@@ -1866,15 +1870,18 @@ void AccumulateIndirectLight()
18661870
}
18671871
POP_PROFILE_MARKER();
18681872

1869-
if (USE_HALF_RES_INDIRECT_LIGHT_ACCUMULATION_BUFFER)
1873+
if (USE_QUARTER_RES_INDIRECT_LIGHT_ACCUMULATION_BUFFER)
18701874
{
18711875
IndirectLightAccumulationBuffer->Disable();
18721876
rtBkp->Enable();
18731877

18741878
PUSH_PROFILE_MARKER("RSMApply.hlsl (upsample)");
18751879

1876-
if (ShdInputLUT[RSMApplyVS][f2HalfTexelOffset] != ~0)
1877-
RSMApplyVInput->SetFloat2(ShdInputLUT[RSMApplyVS][f2HalfTexelOffset], Vec2f(0.5f / IndirectLightAccumulationBuffer->GetWidth(), 0.5f / IndirectLightAccumulationBuffer->GetHeight()));
1880+
//if (ShdInputLUT[RSMApplyVS][f2HalfTexelOffset] != ~0)
1881+
// RSMApplyVInput->SetFloat2(ShdInputLUT[RSMApplyVS][f2HalfTexelOffset], Vec2f(0.5f / IndirectLightAccumulationBuffer->GetWidth(), 0.5f / IndirectLightAccumulationBuffer->GetHeight()));
1882+
1883+
if (ShdInputLUT[RSMApplyPS][f3RSMKernel] != ~0)
1884+
RSMApplyFInput->SetFloatArray(ShdInputLUT[RSMApplyPS][f3RSMKernel], RSMKernel);
18781885

18791886
if (ShdInputLUT[RSMApplyPS][bIsUpsamplePass] != ~0)
18801887
RSMApplyFInput->SetBool(ShdInputLUT[RSMApplyPS][bIsUpsamplePass], true);

GITechDemo/Code/AppMain/GITechDemo/GITechDemo.vcxproj

Lines changed: 18 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -98,37 +98,31 @@
9898
<LinkIncremental>true</LinkIncremental>
9999
<OutDir>$(SolutionDir)..\..\Bin\$(Platform)\$(Configuration)\$(SolutionName)\</OutDir>
100100
<IntDir>$(SolutionDir)..\..\BinTemp\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
101-
<CustomBuildAfterTargets>Clean</CustomBuildAfterTargets>
102101
</PropertyGroup>
103102
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
104103
<LinkIncremental>true</LinkIncremental>
105104
<OutDir>$(SolutionDir)..\..\Bin\$(Platform)\$(Configuration)\$(SolutionName)\</OutDir>
106105
<IntDir>$(SolutionDir)..\..\BinTemp\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
107-
<CustomBuildAfterTargets>Clean</CustomBuildAfterTargets>
108106
</PropertyGroup>
109107
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
110108
<LinkIncremental>false</LinkIncremental>
111109
<OutDir>$(SolutionDir)..\..\Bin\$(Platform)\$(Configuration)\$(SolutionName)\</OutDir>
112110
<IntDir>$(SolutionDir)..\..\BinTemp\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
113-
<CustomBuildAfterTargets>Clean</CustomBuildAfterTargets>
114111
</PropertyGroup>
115112
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
116113
<LinkIncremental>false</LinkIncremental>
117114
<OutDir>$(SolutionDir)..\..\Bin\$(Platform)\$(Configuration)\$(SolutionName)\</OutDir>
118115
<IntDir>$(SolutionDir)..\..\BinTemp\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
119-
<CustomBuildAfterTargets>Clean</CustomBuildAfterTargets>
120116
</PropertyGroup>
121117
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">
122118
<LinkIncremental>false</LinkIncremental>
123119
<OutDir>$(SolutionDir)..\..\Bin\$(Platform)\$(Configuration)\$(SolutionName)\</OutDir>
124120
<IntDir>$(SolutionDir)..\..\BinTemp\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
125-
<CustomBuildAfterTargets>Clean</CustomBuildAfterTargets>
126121
</PropertyGroup>
127122
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">
128123
<LinkIncremental>false</LinkIncremental>
129124
<OutDir>$(SolutionDir)..\..\Bin\$(Platform)\$(Configuration)\$(SolutionName)\</OutDir>
130125
<IntDir>$(SolutionDir)..\..\BinTemp\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
131-
<CustomBuildAfterTargets>Clean</CustomBuildAfterTargets>
132126
</PropertyGroup>
133127
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
134128
<ClCompile>
@@ -146,15 +140,9 @@
146140
<AdditionalLibraryDirectories>
147141
</AdditionalLibraryDirectories>
148142
</Link>
149-
<CustomBuildStep>
150-
<Command>DEL /F /Q "$(OutDir)"</Command>
151-
</CustomBuildStep>
152-
<CustomBuildStep>
153-
<Message>Deleting DLL dependencies</Message>
154-
</CustomBuildStep>
155-
<CustomBuildStep>
156-
<Outputs>dummy</Outputs>
157-
</CustomBuildStep>
143+
<CustomBuildStep />
144+
<CustomBuildStep />
145+
<CustomBuildStep />
158146
</ItemDefinitionGroup>
159147
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
160148
<ClCompile>
@@ -172,15 +160,9 @@
172160
<AdditionalLibraryDirectories>
173161
</AdditionalLibraryDirectories>
174162
</Link>
175-
<CustomBuildStep>
176-
<Command>DEL /F /Q "$(OutDir)"</Command>
177-
</CustomBuildStep>
178-
<CustomBuildStep>
179-
<Message>Deleting DLL dependencies</Message>
180-
</CustomBuildStep>
181-
<CustomBuildStep>
182-
<Outputs>dummy</Outputs>
183-
</CustomBuildStep>
163+
<CustomBuildStep />
164+
<CustomBuildStep />
165+
<CustomBuildStep />
184166
</ItemDefinitionGroup>
185167
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
186168
<ClCompile>
@@ -200,15 +182,9 @@
200182
<AdditionalLibraryDirectories>
201183
</AdditionalLibraryDirectories>
202184
</Link>
203-
<CustomBuildStep>
204-
<Command>DEL /F /Q "$(OutDir)"</Command>
205-
</CustomBuildStep>
206-
<CustomBuildStep>
207-
<Message>Deleting DLL dependencies</Message>
208-
</CustomBuildStep>
209-
<CustomBuildStep>
210-
<Outputs>dummy</Outputs>
211-
</CustomBuildStep>
185+
<CustomBuildStep />
186+
<CustomBuildStep />
187+
<CustomBuildStep />
212188
</ItemDefinitionGroup>
213189
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
214190
<ClCompile>
@@ -228,15 +204,9 @@
228204
<AdditionalLibraryDirectories>
229205
</AdditionalLibraryDirectories>
230206
</Link>
231-
<CustomBuildStep>
232-
<Command>DEL /F /Q "$(OutDir)"</Command>
233-
</CustomBuildStep>
234-
<CustomBuildStep>
235-
<Message>Deleting DLL dependencies</Message>
236-
</CustomBuildStep>
237-
<CustomBuildStep>
238-
<Outputs>dummy</Outputs>
239-
</CustomBuildStep>
207+
<CustomBuildStep />
208+
<CustomBuildStep />
209+
<CustomBuildStep />
240210
</ItemDefinitionGroup>
241211
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">
242212
<ClCompile>
@@ -256,15 +226,9 @@
256226
<AdditionalLibraryDirectories>
257227
</AdditionalLibraryDirectories>
258228
</Link>
259-
<CustomBuildStep>
260-
<Command>DEL /F /Q "$(OutDir)"</Command>
261-
</CustomBuildStep>
262-
<CustomBuildStep>
263-
<Message>Deleting DLL dependencies</Message>
264-
</CustomBuildStep>
265-
<CustomBuildStep>
266-
<Outputs>dummy</Outputs>
267-
</CustomBuildStep>
229+
<CustomBuildStep />
230+
<CustomBuildStep />
231+
<CustomBuildStep />
268232
</ItemDefinitionGroup>
269233
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">
270234
<ClCompile>
@@ -284,15 +248,9 @@
284248
<AdditionalLibraryDirectories>
285249
</AdditionalLibraryDirectories>
286250
</Link>
287-
<CustomBuildStep>
288-
<Command>DEL /F /Q "$(OutDir)"</Command>
289-
</CustomBuildStep>
290-
<CustomBuildStep>
291-
<Message>Deleting DLL dependencies</Message>
292-
</CustomBuildStep>
293-
<CustomBuildStep>
294-
<Outputs>dummy</Outputs>
295-
</CustomBuildStep>
251+
<CustomBuildStep />
252+
<CustomBuildStep />
253+
<CustomBuildStep />
296254
</ItemDefinitionGroup>
297255
<ItemGroup>
298256
<Text Include="ReadMe.txt" />

GITechDemo/Code/Libraries/LibRenderer/Common/Texture.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ void Texture::ComputeTextureProperties(const Vec3i dimensions)
146146
if ((dimensions[0] <= 0 || dimensions[1] <= 0) && (IsRenderTarget() || IsDepthStencil()))
147147
m_bIsDynamicRT = true;
148148

149-
unsigned int width = !m_bIsDynamicRT ? dimensions[0] : Renderer::GetInstance()->GetBackBufferSize()[0] * m_fWidthRatio;
150-
unsigned int height = !m_bIsDynamicRT ? dimensions[1] : Renderer::GetInstance()->GetBackBufferSize()[1] * m_fHeightRatio;
151-
unsigned int depth = !m_bIsDynamicRT ? dimensions[2] : 1;
149+
unsigned int width = !m_bIsDynamicRT ? dimensions[0] : (unsigned int)((float)Renderer::GetInstance()->GetBackBufferSize()[0] * m_fWidthRatio);
150+
unsigned int height = !m_bIsDynamicRT ? dimensions[1] : (unsigned int)((float)Renderer::GetInstance()->GetBackBufferSize()[1] * m_fHeightRatio);
151+
unsigned int depth = !m_bIsDynamicRT ? dimensions[2] : 1u;
152152
if (IsCompressed())
153153
{
154154
// Calculate the smallest number divisible by 4 which is >= width/height

0 commit comments

Comments
 (0)