Skip to content

Commit

Permalink
GITechDemo changes:
Browse files Browse the repository at this point in the history
*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
  • Loading branch information
iftodebogdan committed May 29, 2015
1 parent 5bf7b77 commit b88c5df
Show file tree
Hide file tree
Showing 13 changed files with 300 additions and 101 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
[Dd]ebugPublic/
[Rr]elease/
## x64/
build/
#build/
!/*/[Bb]uild/**
/*/[Bb]uild/**/
bld/
/*/[Bb]in/
[Oo]bj/
Expand Down
137 changes: 137 additions & 0 deletions GITechDemo/Build/build_win.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import os
import shutil
import fnmatch
import errno
import sys

PROJECT_NAME = "GITechDemo"
DEFAULT_VSCOMNTOOLS = "VS120COMNTOOLS"
FORCE_REBUILD = False

def copyfiles(srcdir, dstdir, filepattern):
def failed(exc):
raise exc

for dirpath, dirs, files in os.walk(srcdir, topdown=True, onerror=failed):
for file in fnmatch.filter(files, filepattern):
shutil.copy2(os.path.join(dirpath, file), dstdir)
break # no recursion

def makedir(path):
try:
os.makedirs(path)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise

def copytree(src, dst, symlinks = False, ignore = None):
if not os.path.exists(dst):
os.makedirs(dst)
shutil.copystat(src, dst)
lst = os.listdir(src)
if ignore:
excl = ignore(src, lst)
lst = [x for x in lst if x not in excl]
for item in lst:
s = os.path.join(src, item)
d = os.path.join(dst, item)
if symlinks and os.path.islink(s):
if os.path.lexists(d):
os.remove(d)
os.symlink(os.readlink(s), d)
try:
st = os.lstat(s)
mode = stat.S_IMODE(st.st_mode)
os.lchmod(d, mode)
except:
pass # lchmod not available
elif os.path.isdir(s):
copytree(s, d, symlinks, ignore)
else:
shutil.copy2(s, d)

def buildsln(pathToTools, platform):
cmd = "\"" + pathToTools + "VsDevCmd.bat\" && "
cmd += "MSBuild.exe /maxcpucount /p:Configuration=Release /p:Platform=" + platform
if(FORCE_REBUILD):
cmd += " /t:rebuild "
else:
cmd += " "
cmd += os.getcwd() + "/../Code/Solutions/"
cmd += PROJECT_NAME + ".sln"
#print(cmd)
os.system(cmd)

#os.system('reg query "HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7"')
#os.system('reg delete "HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v "12.0"')
#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\\\\\"")

if(len(sys.argv) > 1 and sys.argv[1] == "rebuild"):
FORCE_REBUILD = True;

print("\nStarting build process...\n")

if(os.getenv(DEFAULT_VSCOMNTOOLS)):
pathToTools = os.getenv(DEFAULT_VSCOMNTOOLS)
elif(os.getenv("VS140COMNTOOLS")): # Visual Studio 2015
pathToTools = os.getenv("VS140COMNTOOLS")
elif(os.getenv("VS120COMNTOOLS")): # Visual Studio 2013
pathToTools = os.getenv("VS120COMNTOOLS")
#elif(os.getenv("VS110COMNTOOLS")): # Visual Studio 2012
# pathToTools = os.getenv("VS110COMNTOOLS")
#elif(os.getenv("VS100COMNTOOLS")): # Visual Studio 2010
# pathToTools = os.getenv("VS100COMNTOOLS")
#elif(os.getenv("VS90COMNTOOLS")): # Visual Studio 2008
# pathToTools = os.getenv("VS90COMNTOOLS")
#elif(os.getenv("VS80COMNTOOLS")): # Visual Studio 2005
# pathToTools = os.getenv("VS80COMNTOOLS")
else:
print("No compatible version of Visual Studio found!\n")

if(pathToTools):
buildsln(pathToTools, "x86")
buildsln(pathToTools, "x64")

print("\nConfiguring build...\n");

# Create directory structure
makedir("Windows")
makedir("Windows/bin")
makedir("Windows/bin/x64")
makedir("Windows/bin/x86")
makedir("Windows/data")

# Copy 64bit binaries
copyfiles("../Bin/x64/Release/" + PROJECT_NAME + "/", "./Windows/bin/x64", "*.exe")
copyfiles("../Bin/x64/Release/" + PROJECT_NAME + "/", "./Windows/bin/x64", "*.dll")

# Copy 32bit binaries
copyfiles("../Bin/Win32/Release/" + PROJECT_NAME + "/", "./Windows/bin/x86", "*.exe")
copyfiles("../Bin/Win32/Release/" + PROJECT_NAME + "/", "./Windows/bin/x86", "*.dll")

# Copy data
copytree("../Data/", "./Windows/data")

# Create x64 batch files
x64bat = open("./Windows/run_x64.bat", "w")
x64bat.write("\
@echo off\n\
:A\n\
cls\n\
cd %~dp0/data\n\
start %1../bin/x64/" + PROJECT_NAME + ".exe\n\
exit")
x64bat.close()

# Create x86 batch files
x86bat = open("./Windows/run_x86.bat", "w")
x86bat.write("\
@echo off\n\
:A\n\
cls\n\
cd %~dp0/data\n\
start %1../bin/x86/" + PROJECT_NAME + ".exe\n\
exit")
x86bat.close()

print("DONE!");
23 changes: 15 additions & 8 deletions GITechDemo/Code/AppMain/GITechDemo/GITechDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ const unsigned int RSM_SIZE = 512;
const unsigned int RSM_NUM_PASSES = 8;
const unsigned int RSM_SAMPLES_PER_PASS = 16;
const unsigned int RSM_NUM_SAMPLES = RSM_NUM_PASSES * RSM_SAMPLES_PER_PASS;
const float RSM_INTENSITY = 150.f;
const float RSM_INTENSITY = 200.f;
const float RSM_KERNEL_SCALE = 0.02f;
const bool USE_HALF_RES_INDIRECT_LIGHT_ACCUMULATION_BUFFER = false;
const bool USE_QUARTER_RES_INDIRECT_LIGHT_ACCUMULATION_BUFFER = true;

const bool DEBUG_CSM_CAMERA = false;
const bool DEBUG_RSM_CAMERA = false;
Expand Down Expand Up @@ -267,7 +267,7 @@ RenderTarget* ShadowMapDir = nullptr;
RenderTarget* LightAccumulationBuffer = nullptr;
// The RSM render target
RenderTarget* RSMBuffer = nullptr;
// The indirect light accumulation buffer (half resolution)
// The indirect light accumulation buffer (quarter resolution)
RenderTarget* IndirectLightAccumulationBuffer = nullptr;

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

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

// Load shaders
Expand Down Expand Up @@ -932,7 +933,7 @@ void AllocateRenderResources()
ResourceMgr->GetTexture(RSMBuffer->GetDepthBuffer())->SetAddressingMode(SAM_BORDER);
ResourceMgr->GetTexture(RSMBuffer->GetDepthBuffer())->SetBorderColor(Vec4f(0.f, 0.f, 0.f, 0.f));

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

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

if (ShdInputLUT[RSMApplyPS][f2HalfTexelOffset] != ~0)
RSMApplyFInput->SetFloat2(ShdInputLUT[RSMApplyPS][f2HalfTexelOffset], Vec2f(0.5f / GBuffer->GetWidth(), 0.5f / GBuffer->GetHeight()));

if (ShdInputLUT[RSMApplyPS][texRSMFluxBuffer] != ~0)
RSMApplyFInput->SetTexture(ShdInputLUT[RSMApplyPS][texRSMFluxBuffer], RSMBuffer->GetColorBuffer(0));

Expand Down Expand Up @@ -1866,15 +1870,18 @@ void AccumulateIndirectLight()
}
POP_PROFILE_MARKER();

if (USE_HALF_RES_INDIRECT_LIGHT_ACCUMULATION_BUFFER)
if (USE_QUARTER_RES_INDIRECT_LIGHT_ACCUMULATION_BUFFER)
{
IndirectLightAccumulationBuffer->Disable();
rtBkp->Enable();

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

if (ShdInputLUT[RSMApplyVS][f2HalfTexelOffset] != ~0)
RSMApplyVInput->SetFloat2(ShdInputLUT[RSMApplyVS][f2HalfTexelOffset], Vec2f(0.5f / IndirectLightAccumulationBuffer->GetWidth(), 0.5f / IndirectLightAccumulationBuffer->GetHeight()));
//if (ShdInputLUT[RSMApplyVS][f2HalfTexelOffset] != ~0)
// RSMApplyVInput->SetFloat2(ShdInputLUT[RSMApplyVS][f2HalfTexelOffset], Vec2f(0.5f / IndirectLightAccumulationBuffer->GetWidth(), 0.5f / IndirectLightAccumulationBuffer->GetHeight()));

if (ShdInputLUT[RSMApplyPS][f3RSMKernel] != ~0)
RSMApplyFInput->SetFloatArray(ShdInputLUT[RSMApplyPS][f3RSMKernel], RSMKernel);

if (ShdInputLUT[RSMApplyPS][bIsUpsamplePass] != ~0)
RSMApplyFInput->SetBool(ShdInputLUT[RSMApplyPS][bIsUpsamplePass], true);
Expand Down
78 changes: 18 additions & 60 deletions GITechDemo/Code/AppMain/GITechDemo/GITechDemo.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,37 +98,31 @@
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)..\..\Bin\$(Platform)\$(Configuration)\$(SolutionName)\</OutDir>
<IntDir>$(SolutionDir)..\..\BinTemp\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
<CustomBuildAfterTargets>Clean</CustomBuildAfterTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)..\..\Bin\$(Platform)\$(Configuration)\$(SolutionName)\</OutDir>
<IntDir>$(SolutionDir)..\..\BinTemp\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
<CustomBuildAfterTargets>Clean</CustomBuildAfterTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)..\..\Bin\$(Platform)\$(Configuration)\$(SolutionName)\</OutDir>
<IntDir>$(SolutionDir)..\..\BinTemp\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
<CustomBuildAfterTargets>Clean</CustomBuildAfterTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)..\..\Bin\$(Platform)\$(Configuration)\$(SolutionName)\</OutDir>
<IntDir>$(SolutionDir)..\..\BinTemp\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
<CustomBuildAfterTargets>Clean</CustomBuildAfterTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)..\..\Bin\$(Platform)\$(Configuration)\$(SolutionName)\</OutDir>
<IntDir>$(SolutionDir)..\..\BinTemp\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
<CustomBuildAfterTargets>Clean</CustomBuildAfterTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)..\..\Bin\$(Platform)\$(Configuration)\$(SolutionName)\</OutDir>
<IntDir>$(SolutionDir)..\..\BinTemp\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
<CustomBuildAfterTargets>Clean</CustomBuildAfterTargets>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand All @@ -146,15 +140,9 @@
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
<Command>DEL /F /Q "$(OutDir)"</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>Deleting DLL dependencies</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>dummy</Outputs>
</CustomBuildStep>
<CustomBuildStep />
<CustomBuildStep />
<CustomBuildStep />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
Expand All @@ -172,15 +160,9 @@
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
<Command>DEL /F /Q "$(OutDir)"</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>Deleting DLL dependencies</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>dummy</Outputs>
</CustomBuildStep>
<CustomBuildStep />
<CustomBuildStep />
<CustomBuildStep />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
Expand All @@ -200,15 +182,9 @@
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
<Command>DEL /F /Q "$(OutDir)"</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>Deleting DLL dependencies</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>dummy</Outputs>
</CustomBuildStep>
<CustomBuildStep />
<CustomBuildStep />
<CustomBuildStep />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
Expand All @@ -228,15 +204,9 @@
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
<Command>DEL /F /Q "$(OutDir)"</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>Deleting DLL dependencies</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>dummy</Outputs>
</CustomBuildStep>
<CustomBuildStep />
<CustomBuildStep />
<CustomBuildStep />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">
<ClCompile>
Expand All @@ -256,15 +226,9 @@
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
<Command>DEL /F /Q "$(OutDir)"</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>Deleting DLL dependencies</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>dummy</Outputs>
</CustomBuildStep>
<CustomBuildStep />
<CustomBuildStep />
<CustomBuildStep />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">
<ClCompile>
Expand All @@ -284,15 +248,9 @@
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
<Command>DEL /F /Q "$(OutDir)"</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>Deleting DLL dependencies</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>dummy</Outputs>
</CustomBuildStep>
<CustomBuildStep />
<CustomBuildStep />
<CustomBuildStep />
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
Expand Down
6 changes: 3 additions & 3 deletions GITechDemo/Code/Libraries/LibRenderer/Common/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ void Texture::ComputeTextureProperties(const Vec3i dimensions)
if ((dimensions[0] <= 0 || dimensions[1] <= 0) && (IsRenderTarget() || IsDepthStencil()))
m_bIsDynamicRT = true;

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

0 comments on commit b88c5df

Please sign in to comment.