diff --git a/Data/Scenes/IBLTest.scn b/Data/Scenes/IBLTest.scn
index 6edcbdb..c55ff06 100644
--- a/Data/Scenes/IBLTest.scn
+++ b/Data/Scenes/IBLTest.scn
@@ -21,6 +21,7 @@ ao false 1.00
// todo: directional light
// Light: [p]oint/[s]pot, color, shadowing? brightness, range/angle, pos(3), rot(X>Y>Z)
light s white false 1800 70 0 120 120 140 180 0
+skylight true
// objects
// =======
diff --git a/Data/Scenes/Room.scn b/Data/Scenes/Room.scn
index ef9a67e..560b27a 100644
--- a/Data/Scenes/Room.scn
+++ b/Data/Scenes/Room.scn
@@ -15,12 +15,13 @@
// Scene
// ---------------------------------------------------------------------------------------------------------------
+camera 0.1 1500 75 -70 25 50 112 11
camera 0.1 1500 75 0 50 -190 0 15
-camera 0.1 1500 75 0 50 120 180 0
-ao true 0.03
+ao true 0.23
+skylight true
-light s white true 2000 70 -90 65 0 180 0 65 0.8
-light s white true 7000 70 0 95 40 190 0 0 0.8
+light s white true 9000 80 -100 45 0 180 0 65 0.8
+light s white true 500 70 0 65 40 190 0 0 0.8
//light p orange false 1800 60 0 30 0 0.3
//light p cyan false 2400 84 60 25 -2 0.4
//light p red false 1500 60 -140 100 140 0.5
diff --git a/Data/Scenes/SSAOTest.scn b/Data/Scenes/SSAOTest.scn
index 6df9846..291cebb 100644
--- a/Data/Scenes/SSAOTest.scn
+++ b/Data/Scenes/SSAOTest.scn
@@ -17,6 +17,7 @@
// ---------------------------------------------------------------------------------------------------------------
camera 0.1 1500 75 0 30 -100 0 25
ao true 1
+skylight false
// objects
// =======
diff --git a/Data/Screenshots/IBL_la1.PNG b/Data/Screenshots/IBL_la1.PNG
deleted file mode 100644
index 78d8329..0000000
Binary files a/Data/Screenshots/IBL_la1.PNG and /dev/null differ
diff --git a/Data/Screenshots/archive.zip b/Data/Screenshots/archive.zip
index 444fab9..8e27755 100644
Binary files a/Data/Screenshots/archive.zip and b/Data/Screenshots/archive.zip differ
diff --git a/Data/Screenshots/blur.PNG b/Data/Screenshots/blur.PNG
deleted file mode 100644
index 83102cb..0000000
Binary files a/Data/Screenshots/blur.PNG and /dev/null differ
diff --git a/Data/Screenshots/brdf.PNG b/Data/Screenshots/brdf.PNG
deleted file mode 100644
index cb251e0..0000000
Binary files a/Data/Screenshots/brdf.PNG and /dev/null differ
diff --git a/Data/Screenshots/deferred.PNG b/Data/Screenshots/deferred.PNG
deleted file mode 100644
index 8a19366..0000000
Binary files a/Data/Screenshots/deferred.PNG and /dev/null differ
diff --git a/Data/Screenshots/gamma.PNG b/Data/Screenshots/gamma.PNG
deleted file mode 100644
index ec2b912..0000000
Binary files a/Data/Screenshots/gamma.PNG and /dev/null differ
diff --git a/Data/Screenshots/hdr_brdf_bloom.PNG b/Data/Screenshots/hdr_brdf_bloom.PNG
deleted file mode 100644
index a5067dc..0000000
Binary files a/Data/Screenshots/hdr_brdf_bloom.PNG and /dev/null differ
diff --git a/Data/Screenshots/room_skylight.PNG b/Data/Screenshots/room_skylight.PNG
new file mode 100644
index 0000000..4665300
Binary files /dev/null and b/Data/Screenshots/room_skylight.PNG differ
diff --git a/Data/Screenshots/space_gold.PNG b/Data/Screenshots/space_gold.PNG
new file mode 100644
index 0000000..9a9e4a8
Binary files /dev/null and b/Data/Screenshots/space_gold.PNG differ
diff --git a/Readme.md b/Readme.md
index 3621cc1..58b4562 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1,4 +1,4 @@
-# DX11Renderer - VDemo | DirectX11 & C++11 Real-Time Renderer
+# VDemo | DirectX11 & C++11 Real-Time Renderer
A DirectX 11 rendering framework for stuyding and practicing various rendering techniques and real-time algorithms.
@@ -10,8 +10,9 @@ A DirectX 11 rendering framework for stuyding and practicing various rendering t
BRDF, HDR, Tonemapping, Bloom, PCF Shadows
-![](Data/Screenshots/brdf.PNG)
+![](Data/Screenshots/space_gold.PNG)
+![](Data/Screenshots/room_skylight.PNG)
SSAO w/ Gaussian Blur
@@ -24,7 +25,30 @@ A DirectX 11 rendering framework for stuyding and practicing various rendering t
Note: if the linker throws the error `1>LINK : fatal error LNK1158: cannot run 'rc.exe'` do the following:
- Copy `rc.exe` and `rcdll.dll`
- from `C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64` to `C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin`
+ from `C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64` to `C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin` (or wherever you store Visual Studio)
+
+
+ ## Feature List / Version History
+
+ *v0.2.0 - Rendering Techniques & Multiple Scenes - November28-2017*
+ - Forward/Deferred Rendering
+ - PBR: GGX-Smith BRDF
+ - Environment Mapping (Image-Based Lighting)
+ - PCF Shadows
+ - Bloom
+ - SSAO w/ Gaussian Blur
+ - Scene files, Switchable/Reloadable scenes
+ - Improved build times
+
+*v0.1.0 - Simple Lighting, Texturing and Shader Reflection: July15-2017*
+ - Vertex-Geometry-Pixel Shader Pipeline
+ - Shader Reflection
+ - Phong Lighting
+ - Simple Shadow Maping Algorithm
+ - Normal Maps
+ - Diffuse Textures
+ - Procedural Geometry: Cube, Sphere, Cylinder, Grid
+
## Controls
@@ -40,7 +64,7 @@ A DirectX 11 rendering framework for stuyding and practicing various rendering t
Scenes:
- 0 - Room Scene
- 1 - SSAO Test Scene
- - 2 - IBL Test Scene
+ - 2 - IBL Test Scene (PageUp/Down to change EnvironmentMap)
| Engine Controls | |
@@ -57,42 +81,3 @@ Scenes:
| **;** | Toggle Ambient Occlusion |
| **Backspace** | Pause App |
| **ESC** | Exit App |
-
-
-
-## Milestones & Future
-
-Future Plans / In-Development: https://github.com/vilbeyli/DX11Renderer/issues
-
-See [active Milestones here](https://github.com/vilbeyli/DX11Renderer/milestones).
-
- ***Completed***
-
-*v0.1 : July15-2017*
- - Vertex-Geometry-Pixel Shader Pipeline
- - Shader Reflection
- - Phong Lighting
- - Simple Shadow Maps
- - Normal Maps
- - Diffuse Textures
- - Procedural Geometry: Cube, Sphere, Cylinder, Grid
-
- ***In Development***
-
- *v0.2* - Expected: Early December
- - PBR: GGX-Smith BRDF
- - Bloom
- - Cubemap Textures
- - Skybox
- - Environment Mapping (Image-Based Lighting)
- - Deferred Rendering
- - SSAO w/ Gaussian Blur
- - PCF Shadow Maps & Multiple dynamic spot-light
- - Anti-Aliasing
- - Z-PrePass
- - Scene files / Switchable scenes
-
- *v0.3 - Debug Features* - Expected: TBA
- - Debug drawing: Mesh, Bounding box, TBN vectors, etc.
- - Text drawing
- - ... TBA
diff --git a/Source/Engine/Settings.h b/Source/Engine/Settings.h
index 7281241..5bab057 100644
--- a/Source/Engine/Settings.h
+++ b/Source/Engine/Settings.h
@@ -20,14 +20,16 @@
namespace Settings
{
- struct Window {
+ struct Window
+ {
int width;
int height;
int fullscreen;
int vsync;
};
- struct Camera {
+ struct Camera
+ {
union
{
float fovH;
@@ -40,25 +42,30 @@ namespace Settings
float yaw, pitch;
};
- struct ShadowMap {
+ struct ShadowMap
+ {
size_t dimension;
};
- struct PostProcess {
- struct Bloom {
+ struct PostProcess
+ {
+ struct Bloom
+ {
float threshold_brdf;
float threshold_phong;
int blurPassCount;
} bloom;
- struct Tonemapping {
+ struct Tonemapping
+ {
float exposure;
} toneMapping;
bool HDREnabled = false;
};
- struct Rendering{
+ struct Rendering
+ {
ShadowMap shadowMap;
PostProcess postProcess;
bool bUseDeferredRendering;
@@ -67,14 +74,17 @@ namespace Settings
bool bEnableEnvironmentLighting;
};
- struct Engine {
+ struct Engine
+ {
Window window;
Rendering rendering;
int levelToLoad;
};
- struct SceneRender {
- bool bAmbientOcclusionEnabled; // screenspace ambient occlusion
+ struct SceneRender
+ {
+ bool bAmbientOcclusionEnabled; // screen-space ambient occlusion
float ambientFactor; // ambient lighting scalar
+ bool bSkylightEnabled; // ambient environment map lighting
};
};
\ No newline at end of file
diff --git a/Source/Engine/Source/Engine.cpp b/Source/Engine/Source/Engine.cpp
index 64103de..b0cb823 100644
--- a/Source/Engine/Source/Engine.cpp
+++ b/Source/Engine/Source/Engine.cpp
@@ -323,7 +323,7 @@ void Engine::PreRender()
mSceneView.sceneRenderSettings = scene->GetSceneRenderSettings();
mSceneView.bIsPBRLightingUsed = IsLightingModelPBR();
mSceneView.bIsDeferredRendering = mbUseDeferredRendering;
- mSceneView.bIsIBLEnabled = mSceneView.environmentMap.irradianceMap != -1;
+ mSceneView.bIsIBLEnabled = scene->mSceneRenderSettings.bSkylightEnabled && mSceneView.bIsPBRLightingUsed;
mSceneView.environmentMap = scene->GetEnvironmentMap();
@@ -498,8 +498,6 @@ void Engine::Render()
// LIGHT SOURCES
mpRenderer->BindDepthTarget(mWorldDepthTarget);
- RenderLights();
-
// SKYBOX
if (pScene->HasSkybox())
{
@@ -509,6 +507,9 @@ void Engine::Render()
mpRenderer->SetDepthStencilState(EDefaultDepthStencilState::DEPTH_STENCIL_WRITE);
mpRenderer->UnbindDepthTarget();
}
+
+ mpRenderer->SetDepthStencilState(EDefaultDepthStencilState::DEPTH_TEST_ONLY);
+ RenderLights();
}
@@ -540,6 +541,7 @@ void Engine::Render()
mpRenderer->BeginEvent("Z-PrePass");
mpRenderer->SetShader(EShaders::Z_PREPRASS);
+ mpRenderer->SetSamplerState("sNormalSampler", EDefaultSamplerState::LINEAR_FILTER_SAMPLER_WRAP_UVW);
mpRenderer->BindDepthTarget(mWorldDepthTarget);
mpRenderer->SetDepthStencilState(EDefaultDepthStencilState::DEPTH_STENCIL_WRITE);
mpRenderer->BindRenderTargets(normals, positions);
@@ -590,31 +592,29 @@ void Engine::Render()
mpRenderer->SetTexture("texAmbientOcclusion", tSSAO);
// todo: shader defines -> have a PBR shader with and without environment lighting through preprocessor
- if(mSelectedShader == EShaders::FORWARD_BRDF) mpRenderer->SetConstant1f("isEnvironmentLightingOn", mSceneView.bIsIBLEnabled ? 1.0f : 0.0f);
- if (mSceneView.bIsIBLEnabled && mSelectedShader == EShaders::FORWARD_BRDF)
+ if (mSceneView.bIsIBLEnabled)
{
mpRenderer->SetTexture("tIrradianceMap", texIrradianceMap);
mpRenderer->SetTexture("tPreFilteredEnvironmentMap", prefilteredEnvMap);
mpRenderer->SetTexture("tBRDFIntegrationLUT", tBRDFLUT);
mpRenderer->SetSamplerState("sEnvMapSampler", smpEnvMap);
}
- else
- {
- if (mSelectedShader == EShaders::FORWARD_BRDF) mpRenderer->SetSamplerState("sEnvMapSampler", EDefaultSamplerState::POINT_SAMPLER);
- }
if (mSelectedShader == EShaders::FORWARD_BRDF)
{
+ mpRenderer->SetConstant1f("isEnvironmentLightingOn", mSceneView.bIsIBLEnabled ? 1.0f : 0.0f);
mpRenderer->SetSamplerState("sWrapSampler", EDefaultSamplerState::WRAP_SAMPLER);
mpRenderer->SetSamplerState("sNearestSampler", EDefaultSamplerState::POINT_SAMPLER);
}
+ else
+ mpRenderer->SetSamplerState("sNormalSampler", EDefaultSamplerState::LINEAR_FILTER_SAMPLER_WRAP_UVW);
// todo: shader defines -> have a PBR shader with and without environment lighting through preprocessor
mpRenderer->SetConstant1f("ambientFactor", mSceneView.sceneRenderSettings.ambientFactor);
mpRenderer->SetConstant3f("cameraPos", mSceneView.cameraPosition);
mpRenderer->SetConstant2f("screenDimensions", mpRenderer->GetWindowDimensionsAsFloat2());
- mpRenderer->SetSamplerState("sLinearSampler", EDefaultSamplerState::LINEAR_FILTER_SAMPLER);
- //mpRenderer->SetSamplerState("sNormalSampler", mNormalSampler);
+ mpRenderer->SetSamplerState("sLinearSampler", EDefaultSamplerState::LINEAR_FILTER_SAMPLER_WRAP_UVW);
+
SendLightData();
}
diff --git a/Source/Engine/Source/GameObject.cpp b/Source/Engine/Source/GameObject.cpp
index 567840f..b570ae1 100644
--- a/Source/Engine/Source/GameObject.cpp
+++ b/Source/Engine/Source/GameObject.cpp
@@ -37,6 +37,7 @@ void GameObject::Render(Renderer* pRenderer, const SceneView& sceneView, bool Up
mat->SetMaterialConstants(pRenderer, shader, sceneView.bIsDeferredRendering);
}
+ // SET MATRICES
switch (shader)
{
case EShaders::TBN:
diff --git a/Source/Engine/Source/RenderPasses.cpp b/Source/Engine/Source/RenderPasses.cpp
index aa7483b..64d2570 100644
--- a/Source/Engine/Source/RenderPasses.cpp
+++ b/Source/Engine/Source/RenderPasses.cpp
@@ -443,7 +443,7 @@ void DeferredRenderingPasses::SetGeometryRenderingStates(Renderer* pRenderer) co
pRenderer->BindRenderTargets(_GBuffer._diffuseRoughnessRT, _GBuffer._specularMetallicRT, _GBuffer._normalRT, _GBuffer._positionRT);
pRenderer->BindDepthTarget(ENGINE->GetWorldDepthTarget());
pRenderer->SetDepthStencilState(_geometryStencilState);
- pRenderer->SetSamplerState("sNormalSampler", EDefaultSamplerState::LINEAR_FILTER_SAMPLER);
+ pRenderer->SetSamplerState("sNormalSampler", EDefaultSamplerState::LINEAR_FILTER_SAMPLER_WRAP_UVW);
pRenderer->Begin(clearCmd);
pRenderer->Apply();
}
@@ -478,8 +478,7 @@ void DeferredRenderingPasses::RenderLightingPass(
pRenderer->Apply();
// AMBIENT LIGHTING
- const bool bSkylight = texIrradianceMap != -1;
- //assert(bSkylight == sceneView.bIsIBLEnabled); // this fails from ibl->ssao test scene
+ const bool bSkylight = sceneView.bIsIBLEnabled;
if(bSkylight)
{
pRenderer->BeginEvent("Environment Map Lighting Pass");
diff --git a/Source/Renderer/Material.h b/Source/Renderer/Material.h
index f51886f..58d08b6 100644
--- a/Source/Renderer/Material.h
+++ b/Source/Renderer/Material.h
@@ -37,6 +37,7 @@ struct Material
float alpha;
vec3 specular;
+ vec2 tiling; // default=(1,1)
TextureID diffuseMap;
TextureID normalMap;
diff --git a/Source/Renderer/Model.h b/Source/Renderer/Model.h
index 2a89f33..c808ede 100644
--- a/Source/Renderer/Model.h
+++ b/Source/Renderer/Model.h
@@ -30,6 +30,7 @@ class Model
void SetDiffuseColor(const LinearColor & diffuseColor);
void SetNormalMap(const TextureID normalMap);
void SetDiffuseMap(const TextureID diffuseMap);
+ void SetTextureTiling(const vec2& tiling);
public:
InputBufferID mMesh;
diff --git a/Source/Renderer/Renderer.h b/Source/Renderer/Renderer.h
index 30a4a5e..f62f370 100644
--- a/Source/Renderer/Renderer.h
+++ b/Source/Renderer/Renderer.h
@@ -80,45 +80,6 @@ struct PipelineState
TextureID _depthBufferTexture; // ^
};
-enum ETextureUsage : unsigned
-{
- RESOURCE = D3D11_BIND_SHADER_RESOURCE,
- RENDER_TARGET = D3D11_BIND_RENDER_TARGET,
- RENDER_TARGET_RW = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET,
- DEPTH_TARGET = D3D11_BIND_DEPTH_STENCIL,
-
- TEXTURE_USAGE_COUNT
-};
-
-struct TextureDesc
-{
- int width;
- int height;
- EImageFormat format;
- ETextureUsage usage;
- std::string texFileName;
- void* data;
- int mipCount;
- int arraySize;
- bool bIsCubeMap;
- bool bGenerateMips;
-
- TextureDesc() :
- width(1),
- height(1),
- format(RGBA32F),
- usage(RESOURCE),
- texFileName(""),
- data(nullptr),
- mipCount(1),
- arraySize(1),
- bIsCubeMap(false),
- bGenerateMips(false)
- {}
-
- D3D11_TEXTURE2D_DESC dxDesc;
-};
-
class Renderer
{
friend class Engine;
diff --git a/Source/Renderer/RenderingEnums.h b/Source/Renderer/RenderingEnums.h
index a9f609d..18a7c8b 100644
--- a/Source/Renderer/RenderingEnums.h
+++ b/Source/Renderer/RenderingEnums.h
@@ -25,6 +25,7 @@
#include
+
enum class ERasterizerCullMode
{
FRONT = D3D11_CULL_FRONT,
@@ -97,6 +98,16 @@ enum ELayoutFormat
LAYOUT_FORMAT_COUNT
};
+enum ETextureUsage : unsigned
+{
+ RESOURCE = D3D11_BIND_SHADER_RESOURCE,
+ RENDER_TARGET = D3D11_BIND_RENDER_TARGET,
+ RENDER_TARGET_RW = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET,
+ DEPTH_TARGET = D3D11_BIND_DEPTH_STENCIL,
+
+ TEXTURE_USAGE_COUNT
+};
+
enum EImageFormat
{
// RGBA
diff --git a/Source/Renderer/Source/Material.cpp b/Source/Renderer/Source/Material.cpp
index 2cb496c..0c7e474 100644
--- a/Source/Renderer/Source/Material.cpp
+++ b/Source/Renderer/Source/Material.cpp
@@ -71,6 +71,7 @@ Material::Material()
diffuse(LinearColor::white),
alpha(1.0f),
specular(LinearColor::white.Value()),
+ tiling(1, 1),
diffuseMap(-1),
normalMap(-1)
{}
@@ -86,10 +87,13 @@ struct SurfaceMaterial
vec3 specular;
float roughness;
+ // todo: remove is*Map after shader permutation is implemented
float isDiffuseMap;
float isNormalMap;
+
float metalness;
float shininess;
+ vec2 tiling;
};
void Material::SetMaterialConstants(Renderer * renderer, EShaders shader, bool bIsDeferredRendering) const
@@ -98,6 +102,7 @@ void Material::SetMaterialConstants(Renderer * renderer, EShaders shader, bool b
{
case EShaders::NORMAL:
case EShaders::Z_PREPRASS:
+ renderer->SetConstant2f("uvScale", tiling);
renderer->SetConstant1f("isNormalMap", normalMap == -1 ? 0.0f : 1.0f);
if (normalMap != -1) renderer->SetTexture("texNormalMap", normalMap);
break;
@@ -142,6 +147,8 @@ void BRDF_Material::SetMaterialSpecificConstants(Renderer* renderer, EShaders sh
{
case EShaders::NORMAL:
case EShaders::Z_PREPRASS:
+ renderer->SetConstant2f("uvScale", tiling);
+ break;
case EShaders::UNLIT:
break;
default:
@@ -155,7 +162,8 @@ void BRDF_Material::SetMaterialSpecificConstants(Renderer* renderer, EShaders sh
diffuseMap == -1 ? 0.0f : 1.0f,
normalMap == -1 ? 0.0f : 1.0f,
metalness,
- 0.0f
+ 0.0f,
+ tiling
};
renderer->SetConstantStruct("surfaceMaterial", &mat);
@@ -194,7 +202,8 @@ void BlinnPhong_Material::SetMaterialSpecificConstants(Renderer* renderer, EShad
diffuseMap == -1 ? 0.0f : 1.0f,
normalMap == -1 ? 0.0f : 1.0f,
0.0f, // brdf metalness
- shininess
+ shininess,
+ tiling
};
renderer->SetConstantStruct("surfaceMaterial", &mat);
if (bIsDeferredRendering)
diff --git a/Source/Renderer/Source/Model.cpp b/Source/Renderer/Source/Model.cpp
index 96b4b66..436f2e3 100644
--- a/Source/Renderer/Source/Model.cpp
+++ b/Source/Renderer/Source/Model.cpp
@@ -37,3 +37,8 @@ void Model::SetDiffuseMap(const TextureID diffuseMap)
{
mBlinnPhong_Material.diffuseMap = mBRDF_Material.diffuseMap = diffuseMap;
}
+
+void Model::SetTextureTiling(const vec2 & tiling)
+{
+ mBlinnPhong_Material.tiling = mBRDF_Material.tiling = tiling;
+}
\ No newline at end of file
diff --git a/Source/Renderer/Source/Renderer.cpp b/Source/Renderer/Source/Renderer.cpp
index e636e63..23abfb1 100644
--- a/Source/Renderer/Source/Renderer.cpp
+++ b/Source/Renderer/Source/Renderer.cpp
@@ -716,6 +716,14 @@ TextureID Renderer::CreateTexture2D(const TextureDesc& texDesc)
tex._height = texDesc.height;
tex._name = texDesc.texFileName;
+
+ // check multi sampling quality level
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/bb173072(v=vs.85).aspx
+ //UINT maxMultiSamplingQualityLevel = 0;
+ //m_device->CheckMultisampleQualityLevels(, , &maxMultiSamplingQualityLevel);
+ //---
+
+
// Texture2D Resource
UINT miscFlags = 0;
miscFlags |= texDesc.bIsCubeMap ? D3D11_RESOURCE_MISC_TEXTURECUBE : 0;
diff --git a/Source/Renderer/Texture.h b/Source/Renderer/Texture.h
index e24768a..5923209 100644
--- a/Source/Renderer/Texture.h
+++ b/Source/Renderer/Texture.h
@@ -20,6 +20,7 @@
#include
#include
+#include "RenderingEnums.h"
using TextureID = int;
using SamplerID = int;
@@ -31,6 +32,36 @@ struct D3D11_TEXTURE2D_DESC;
struct ID3D11Texture3D;
struct ID3D11Texture2D;
+struct TextureDesc
+{
+ int width;
+ int height;
+ EImageFormat format;
+ ETextureUsage usage;
+ std::string texFileName;
+ void* data;
+ int mipCount;
+ int arraySize;
+ bool bIsCubeMap;
+ bool bGenerateMips;
+
+ TextureDesc() :
+ width(1),
+ height(1),
+ format(RGBA32F),
+ usage(RESOURCE),
+ texFileName(""),
+ data(nullptr),
+ mipCount(1),
+ arraySize(1),
+ bIsCubeMap(false),
+ bGenerateMips(false)
+ {}
+
+ D3D11_TEXTURE2D_DESC dxDesc;
+};
+
+
struct Texture
{
public:
diff --git a/Source/Scenes/RoomScene.cpp b/Source/Scenes/RoomScene.cpp
index 1a4f45f..9d4c966 100644
--- a/Source/Scenes/RoomScene.cpp
+++ b/Source/Scenes/RoomScene.cpp
@@ -91,7 +91,7 @@ void RoomScene::Load(SerializedScene& scene)
// offset to center the grid
const float offsetDim = -static_cast(gridDimension) * r / 2 + r / 2.0f;
- const vec3 offset = vec3(col * r, -1.0f, row * r) + vec3(offsetDim, 0.2f, offsetDim);
+ const vec3 offset = vec3(col * r, -1.0f, row * r) + vec3(offsetDim, 0.75f, offsetDim);
const vec3 pos = origin + offset;
@@ -102,13 +102,14 @@ void RoomScene::Load(SerializedScene& scene)
BRDF_Material& mat0 = sph.mModel.mBRDF_Material;
// col(-x->+x) -> metalness [0.0f, 1.0f]
- sph.mModel.SetDiffuseColor(LinearColor(vec3(LinearColor::red) / 1.5f));
+ sph.mModel.SetDiffuseColor(LinearColor(vec3(LinearColor::gold)));
//sph.mModel.SetDiffuseColor(LinearColor(vec3(LinearColor::white) * rowStep));
- mat0.metalness = colStep;
+ mat0.metalness = 1.0;
// row(-z->+z) -> roughness [roughnessLowClamp, 1.0f]
- const float roughnessLowClamp = 0.065f;
+ const float roughnessLowClamp = 0.07f;
mat0.roughness = rowStep < roughnessLowClamp ? roughnessLowClamp : rowStep;
+ mat0.roughness = (1.0f + roughnessLowClamp) - mat0.roughness;
BlinnPhong_Material& mat1 = sph.mModel.mBlinnPhong_Material;
const float shininessMax = 150.f;
@@ -126,7 +127,7 @@ void RoomScene::Load(SerializedScene& scene)
;// obj.mRenderSettings.bRenderTBN = true;
}
- mSkybox = Skybox::s_Presets[ECubeMapPresets::NIGHT_SKY];
+ mSkybox = Skybox::s_Presets[EEnvironmentMapPresets::MILKYWAY];
}
void RoomScene::Unload()
@@ -222,10 +223,10 @@ void RoomScene::ToggleFloorNormalMap()
void RoomScene::Room::Render(Renderer* pRenderer, const SceneView& sceneView, bool sendMaterialData) const
{
floor.Render(pRenderer, sceneView, sendMaterialData);
- wallL.Render(pRenderer, sceneView, sendMaterialData);
+ //wallL.Render(pRenderer, sceneView, sendMaterialData);
wallR.Render(pRenderer, sceneView, sendMaterialData);
- wallF.Render(pRenderer, sceneView, sendMaterialData);
- ceiling.Render(pRenderer, sceneView, sendMaterialData);
+ //wallF.Render(pRenderer, sceneView, sendMaterialData);
+ //ceiling.Render(pRenderer, sceneView, sendMaterialData);
}
void RoomScene::Room::Initialize(Renderer* pRenderer)
@@ -269,7 +270,7 @@ void RoomScene::Room::Initialize(Renderer* pRenderer)
floor.mModel.mBRDF_Material.metalness = 0.0f;
floor.mModel.SetDiffuseAlpha(LinearColor::gray, 1.0f);
floor.mModel.SetNormalMap(pRenderer->CreateTextureFromFile("openart/161_norm.JPG"));
-
+ floor.mModel.SetTextureTiling(vec2(10, 10));
//mat = Material::bronze;
//floor.m_model.SetDiffuseMap(pRenderer->CreateTextureFromFile("185.JPG"));
//floor.m_model.SetNormalMap(pRenderer->CreateTextureFromFile("185_norm.JPG"));
@@ -286,6 +287,9 @@ void RoomScene::Room::Initialize(Renderer* pRenderer)
ceiling.mModel.mBlinnPhong_Material.shininess = 20.0f;
}
+ const float ratio = floorWidth / wallHieght;
+ const vec2 wallTiling = vec2(ratio, 1.3f) * 1.7f;
+ const vec2 wallTilingInv = vec2(1.3f, ratio) * 1.7f;
// RIGHT WALL
{
Transform& tf = wallR.mTransform;
@@ -297,6 +301,7 @@ void RoomScene::Room::Initialize(Renderer* pRenderer)
wallR.mModel.SetDiffuseMap(pRenderer->CreateTextureFromFile("openart/190.JPG"));
wallR.mModel.SetNormalMap(pRenderer->CreateTextureFromFile("openart/190_norm.JPG"));
+ wallR.mModel.SetTextureTiling(wallTiling);
}
// LEFT WALL
@@ -311,6 +316,7 @@ void RoomScene::Room::Initialize(Renderer* pRenderer)
wallL.mModel.mBlinnPhong_Material.shininess = 60.0f;
wallL.mModel.SetDiffuseMap(pRenderer->CreateTextureFromFile("openart/190.JPG"));
wallL.mModel.SetNormalMap(pRenderer->CreateTextureFromFile("openart/190_norm.JPG"));
+ wallL.mModel.SetTextureTiling(wallTilingInv);
}
// WALL
{
@@ -322,6 +328,7 @@ void RoomScene::Room::Initialize(Renderer* pRenderer)
wallF.mModel.mBlinnPhong_Material.shininess = 90.0f;
wallF.mModel.SetDiffuseMap(pRenderer->CreateTextureFromFile("openart/190.JPG"));
wallF.mModel.SetNormalMap(pRenderer->CreateTextureFromFile("openart/190_norm.JPG"));
+ wallL.mModel.SetTextureTiling(vec2(1, 3));
}
wallL.mModel.mMesh = EGeometry::CUBE;
diff --git a/Source/Scenes/SSAOTestScene.cpp b/Source/Scenes/SSAOTestScene.cpp
index 5ceb6b9..306614e 100644
--- a/Source/Scenes/SSAOTestScene.cpp
+++ b/Source/Scenes/SSAOTestScene.cpp
@@ -78,6 +78,8 @@ void SSAOTestScene::Load(SerializedScene& scene)
obj.mModel.SetDiffuseMap(AmbientOcclusionPass::whiteTexture4x4);
}
+ mSkybox = Skybox::s_Presets[MILKYWAY];
+
}
void SSAOTestScene::Unload()
diff --git a/Source/Shaders/LightingCommon.hlsl b/Source/Shaders/LightingCommon.hlsl
index 743e636..be7d576 100644
--- a/Source/Shaders/LightingCommon.hlsl
+++ b/Source/Shaders/LightingCommon.hlsl
@@ -95,10 +95,13 @@ struct SurfaceMaterial
float3 specular;
float roughness;
+ // todo: remove is*Map after shader permutation is implemented
float isDiffuseMap;
float isNormalMap;
+
float metalness;
float shininess;
+ float2 uvScale;
};
struct BRDF_Surface
@@ -159,7 +162,7 @@ float ShadowTestPCF(float3 worldPos, float4 lightSpacePos, Texture2DArray shadow
projLSpaceCoords.z < 0.0f || projLSpaceCoords.z > 1.0f
)
{
- return 0.0f;
+ return 1.0f;
}
const float2 texelSize = 1.0f / (shadowMapDimensions);
diff --git a/Source/Shaders/ViewSpaceNormalsAndPositions_ps.hlsl b/Source/Shaders/ViewSpaceNormalsAndPositions_ps.hlsl
index b3bd4b3..87a759d 100644
--- a/Source/Shaders/ViewSpaceNormalsAndPositions_ps.hlsl
+++ b/Source/Shaders/ViewSpaceNormalsAndPositions_ps.hlsl
@@ -16,7 +16,7 @@
//
// Contact: volkanilbeyli@gmail.com
-#include "BRDF.hlsl"
+#include "ShadingMath.hlsl"
#define PI 3.14159265359f
#define EPSILON 0.000000000001f
@@ -42,6 +42,7 @@ struct PSOut
cbuffer cbSurfaceMaterial
{
float isNormalMap;
+ float2 uvScale;
};
Texture2D texNormalMap;
@@ -57,11 +58,12 @@ PSOut PSMain(PSIn In) : SV_TARGET
const float3 N = normalize(In.viewNormal);
const float3 T = normalize(In.viewTangent);
const float3 V = normalize(-P);
+ const float2 uv = In.uv * uvScale;
- BRDF_Surface s;
- s.N = (isNormalMap) * UnpackNormals(texNormalMap, sNormalSampler, In.uv, N, T) + (1.0f - isNormalMap) * N;
+
+ float3 surfaceN = (isNormalMap) * UnpackNormals(texNormalMap, sNormalSampler, uv, N, T) + (1.0f - isNormalMap) * N;
- GBuffer.normals = s.N;
+ GBuffer.normals = surfaceN;
GBuffer.position = P;
return GBuffer;
}
\ No newline at end of file
diff --git a/Source/Shaders/deferred_brdf_lighting_ps.hlsl b/Source/Shaders/deferred_brdf_lighting_ps.hlsl
index 59c0aec..ee83aab 100644
--- a/Source/Shaders/deferred_brdf_lighting_ps.hlsl
+++ b/Source/Shaders/deferred_brdf_lighting_ps.hlsl
@@ -87,7 +87,7 @@ float4 PSMain(PSIn In) : SV_TARGET
#if 1
float3 IdIs = float3(0.0f, 0.0f, 0.0f); // diffuse & specular
-
+
// POINT Lights
// brightness default: 300
//---------------------------------
@@ -140,7 +140,6 @@ float4 PSMain(PSIn In) : SV_TARGET
IdIs += BRDF(Wi, s, V, P) * radiance * shadowing * NdotL;
}
-
const float3 illumination = IdIs;
return float4(illumination, 1);
#endif
diff --git a/Source/Shaders/deferred_geometry_ps.hlsl b/Source/Shaders/deferred_geometry_ps.hlsl
index 09521c6..43dab28 100644
--- a/Source/Shaders/deferred_geometry_ps.hlsl
+++ b/Source/Shaders/deferred_geometry_ps.hlsl
@@ -62,10 +62,11 @@ PSOut PSMain(PSIn In) : SV_TARGET
const float3 N = normalize(In.viewNormal);
const float3 T = normalize(In.viewTangent);
const float3 V = normalize(-P);
+ float2 uv = In.uv * surfaceMaterial.uvScale;
BRDF_Surface s;
- s.N = (surfaceMaterial.isNormalMap) * UnpackNormals(texNormalMap, sNormalSampler, In.uv, N, T) + (1.0f - surfaceMaterial.isNormalMap) * N;
- s.diffuseColor = surfaceMaterial.diffuse * (surfaceMaterial.isDiffuseMap * texDiffuseMap.Sample(sNormalSampler, In.uv).xyz +
+ s.N = (surfaceMaterial.isNormalMap) * UnpackNormals(texNormalMap, sNormalSampler, uv, N, T) + (1.0f - surfaceMaterial.isNormalMap) * N;
+ s.diffuseColor = surfaceMaterial.diffuse * (surfaceMaterial.isDiffuseMap * texDiffuseMap.Sample(sNormalSampler, uv).xyz +
(1.0f - surfaceMaterial.isDiffuseMap) * surfaceMaterial.diffuse);
s.specularColor = surfaceMaterial.specular;
s.roughness = // use s.roughness for either roughness (PBR) or shininess (Phong)
diff --git a/Source/Shaders/forward_brdf_ps.hlsl b/Source/Shaders/forward_brdf_ps.hlsl
index 5663f53..9427934 100644
--- a/Source/Shaders/forward_brdf_ps.hlsl
+++ b/Source/Shaders/forward_brdf_ps.hlsl
@@ -76,6 +76,7 @@ float4 PSMain(PSIn In) : SV_TARGET
const int pointShadowsBaseIndex = 0; // omnidirectional cubemaps are sampled based on light dir, texture is its own array
const int spotShadowsBaseIndex = 0;
const int directionalShadowBaseIndex = spotShadowsBaseIndex + sceneLightData.numSpotCasters; // currently unused
+ const float2 uv = In.texCoord * surfaceMaterial.uvScale;
// lighting & surface parameters (World Space)
const float3 P = In.worldPos;
@@ -86,21 +87,23 @@ float4 PSMain(PSIn In) : SV_TARGET
const float2 screenSpaceUV = In.position.xy / screenDimensions;
BRDF_Surface s;
- s.N = (surfaceMaterial.isNormalMap) * UnpackNormals(texNormalMap, sLinearSampler, In.texCoord, N, T) + (1.0f - surfaceMaterial.isNormalMap) * N;
+ s.N = (surfaceMaterial.isNormalMap) * UnpackNormals(texNormalMap, sLinearSampler, uv, N, T) + (1.0f - surfaceMaterial.isNormalMap) * N;
// diffuse * diffuse here??
- s.diffuseColor = surfaceMaterial.diffuse * (surfaceMaterial.isDiffuseMap * texDiffuseMap.Sample(sLinearSampler, In.texCoord).xyz +
+ s.diffuseColor = surfaceMaterial.diffuse * (surfaceMaterial.isDiffuseMap * texDiffuseMap.Sample(sLinearSampler, uv).xyz +
(1.0f - surfaceMaterial.isDiffuseMap) * surfaceMaterial.diffuse);
s.specularColor = surfaceMaterial.specular;
s.roughness = surfaceMaterial.roughness;
s.metalness = surfaceMaterial.metalness;
- const float tAO = texAmbientOcclusion.Sample(sNearestSampler, screenSpaceUV).x;
+ const float texAO = texAmbientOcclusion.Sample(sNearestSampler, screenSpaceUV).x;
+ const float ao = texAO * ambientFactor;
// illumination
- const float3 Ia = s.diffuseColor * ambientFactor * tAO; // ambient
- float3 IdIs = float3(0.0f, 0.0f, 0.0f); // diffuse & specular
+ const float3 Ia = s.diffuseColor * ao; // ambient
+ float3 IdIs = float3(0.0f, 0.0f, 0.0f); // diffuse & specular
+ float3 IEnv = 0.0f.xxx; // environment lighting
// POINT Lights
// brightness default: 300
@@ -145,7 +148,6 @@ float4 PSMain(PSIn In) : SV_TARGET
// ENVIRONMENT Map
//---------------------------------
- float3 IEnv = 0.0f.xxx;
if(isEnvironmentLightingOn > 0.001f)
{
const float NdotV = max(0.0f, dot(N, V));
@@ -154,7 +156,8 @@ float4 PSMain(PSIn In) : SV_TARGET
const float3 environmentIrradience = tIrradianceMap.Sample(sWrapSampler, equirectangularUV).rgb;
const float3 environmentSpecular = tPreFilteredEnvironmentMap.SampleLevel(sEnvMapSampler, R, s.roughness * MAX_REFLECTION_LOD).rgb;
const float2 F0ScaleBias = tBRDFIntegrationLUT.Sample(sNearestSampler, float2(NdotV, 1.0f - s.roughness)).rg;
- IEnv = EnvironmentBRDF(s, V, tAO, environmentIrradience, environmentSpecular, F0ScaleBias);
+ IEnv = EnvironmentBRDF(s, V, ao, environmentIrradience, environmentSpecular, F0ScaleBias);
+ IEnv -= Ia; // cancel ambient lighting
}
const float3 illumination = Ia + IdIs + IEnv;
return float4(illumination, 1);
diff --git a/Source/Shaders/forward_phong_ps.hlsl b/Source/Shaders/forward_phong_ps.hlsl
index b82e9ff..ad49596 100644
--- a/Source/Shaders/forward_phong_ps.hlsl
+++ b/Source/Shaders/forward_phong_ps.hlsl
@@ -78,13 +78,14 @@ float4 PSMain(PSIn In) : SV_TARGET
const float3 Vw = normalize(cameraPos - In.worldPos);
const float2 screenSpaceUV = In.position.xy / screenDimensions;
const float3 Pw = In.worldPos;
+ const float2 uv = In.texCoord * surfaceMaterial.uvScale;
PHONG_Surface s;
- s.N = (surfaceMaterial.isNormalMap) * UnpackNormals(texNormalMap, sLinearSampler, In.texCoord, Nw, T) +
+ s.N = (surfaceMaterial.isNormalMap) * UnpackNormals(texNormalMap, sLinearSampler, uv, Nw, T) +
(1.0f - surfaceMaterial.isNormalMap) * Nw;
// diffuse * diffuse here??
- s.diffuseColor = surfaceMaterial.diffuse * (surfaceMaterial.isDiffuseMap * texDiffuseMap.Sample(sLinearSampler, In.texCoord).xyz +
+ s.diffuseColor = surfaceMaterial.diffuse * (surfaceMaterial.isDiffuseMap * texDiffuseMap.Sample(sLinearSampler, uv).xyz +
(1.0f - surfaceMaterial.isDiffuseMap) * surfaceMaterial.diffuse);
s.specularColor = surfaceMaterial.specular;
diff --git a/Source/Utilities/Color.h b/Source/Utilities/Color.h
index 6498518..b8e5248 100644
--- a/Source/Utilities/Color.h
+++ b/Source/Utilities/Color.h
@@ -69,7 +69,8 @@ struct LinearColor
//static std::string GetNameByColor(Color c);
public:
- static const LinearColor black, white, red, green, blue, magenta, yellow, cyan, gray, light_gray, orange, purple, gold;
+ static const LinearColor black, white, red, green, blue, magenta, yellow, cyan, gray, light_gray, orange, purple;
+ static const LinearColor gold, aluminum;
static const LinearColor bp_gold, bp_ruby, bp_jade, bp_bronze;
static const ColorPalette s_palette;
private:
diff --git a/Source/Utilities/Source/Color.cpp b/Source/Utilities/Source/Color.cpp
index 7958f92..5594ced 100644
--- a/Source/Utilities/Source/Color.cpp
+++ b/Source/Utilities/Source/Color.cpp
@@ -34,7 +34,11 @@ const LinearColor LinearColor::gray = vec3(0.2f, 0.2f, 0.2f);
const LinearColor LinearColor::light_gray = vec3(0.45f, 0.45f, 0.45f);
const LinearColor LinearColor::orange = vec3(1.0f, 0.5f, 0.0f);
const LinearColor LinearColor::purple = vec3(0.31f, 0.149f, 0.513f);
-const LinearColor LinearColor::gold = vec3(1.000f, 0.76f, 0.336f); // pbr?
+
+// PBR Metals
+const LinearColor LinearColor::gold = vec3(1.000f, 0.76f, 0.336f);
+const LinearColor LinearColor::aluminum = vec3(0.913f, 0.921f, 0.925f);
+//const LinearColor LinearColor::aluminum = vec3(0.263f, 0.421f, 0.925f);
// blinn phong values
const LinearColor LinearColor::bp_gold = vec3(0.75164f, 0.60648f, 0.22648f);
diff --git a/Source/Utilities/Source/CustomParser.cpp b/Source/Utilities/Source/CustomParser.cpp
index 30150a3..8d6deef 100644
--- a/Source/Utilities/Source/CustomParser.cpp
+++ b/Source/Utilities/Source/CustomParser.cpp
@@ -596,6 +596,10 @@ void Parser::ParseScene(Renderer* pRenderer, const std::vector& com
scene.settings.bAmbientOcclusionEnabled = sBoolTypeReflection.at(command[1]);
scene.settings.ambientFactor = stof(command[2]);
}
+ else if (cmd == "skylight")
+ {
+ scene.settings.bSkylightEnabled= sBoolTypeReflection.at(command[1]);
+ }
else
{
Log::Error("Parser: Unknown command \"%s\"", cmd.c_str());