Skip to content

Commit

Permalink
closing milestone 2: adding texture tiling
Browse files Browse the repository at this point in the history
fixes #48
  • Loading branch information
vilbeyli committed Dec 1, 2017
1 parent 33117f7 commit 581d5df
Show file tree
Hide file tree
Showing 36 changed files with 193 additions and 141 deletions.
1 change: 1 addition & 0 deletions Data/Scenes/IBLTest.scn
Original file line number Diff line number Diff line change
Expand Up @@ -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
// =======
Expand Down
9 changes: 5 additions & 4 deletions Data/Scenes/Room.scn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Data/Scenes/SSAOTest.scn
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// ---------------------------------------------------------------------------------------------------------------
camera 0.1 1500 75 0 30 -100 0 25
ao true 1
skylight false

// objects
// =======
Expand Down
Binary file removed Data/Screenshots/IBL_la1.PNG
Binary file not shown.
Binary file modified Data/Screenshots/archive.zip
Binary file not shown.
Binary file removed Data/Screenshots/blur.PNG
Binary file not shown.
Binary file removed Data/Screenshots/brdf.PNG
Binary file not shown.
Binary file removed Data/Screenshots/deferred.PNG
Binary file not shown.
Binary file removed Data/Screenshots/gamma.PNG
Binary file not shown.
Binary file removed Data/Screenshots/hdr_brdf_bloom.PNG
Binary file not shown.
Binary file added Data/Screenshots/room_skylight.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/Screenshots/space_gold.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 28 additions & 43 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -10,8 +10,9 @@ A DirectX 11 rendering framework for stuyding and practicing various rendering t

<center><i>BRDF, HDR, Tonemapping, Bloom, PCF Shadows</i></center>

![](Data/Screenshots/brdf.PNG)
![](Data/Screenshots/space_gold.PNG)

![](Data/Screenshots/room_skylight.PNG)

<center><i>SSAO w/ Gaussian Blur</i></center>

Expand All @@ -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

Expand All @@ -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 | |
Expand All @@ -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
30 changes: 20 additions & 10 deletions Source/Engine/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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
};
};
22 changes: 11 additions & 11 deletions Source/Engine/Source/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -498,8 +498,6 @@ void Engine::Render()

// LIGHT SOURCES
mpRenderer->BindDepthTarget(mWorldDepthTarget);
RenderLights();

// SKYBOX
if (pScene->HasSkybox())
{
Expand All @@ -509,6 +507,9 @@ void Engine::Render()
mpRenderer->SetDepthStencilState(EDefaultDepthStencilState::DEPTH_STENCIL_WRITE);
mpRenderer->UnbindDepthTarget();
}

mpRenderer->SetDepthStencilState(EDefaultDepthStencilState::DEPTH_TEST_ONLY);
RenderLights();
}


Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}

Expand Down
1 change: 1 addition & 0 deletions Source/Engine/Source/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions Source/Engine/Source/RenderPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions Source/Renderer/Material.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct Material
float alpha;
vec3 specular;

vec2 tiling; // default=(1,1)
TextureID diffuseMap;
TextureID normalMap;

Expand Down
1 change: 1 addition & 0 deletions Source/Renderer/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
39 changes: 0 additions & 39 deletions Source/Renderer/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions Source/Renderer/RenderingEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <d3d11.h>


enum class ERasterizerCullMode
{
FRONT = D3D11_CULL_FRONT,
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 581d5df

Please sign in to comment.