Proper Lighting, supports Multiple Lights
This commit is contained in:
parent
fb51881fab
commit
718b1ade2b
|
@ -204,4 +204,14 @@ Core::Buffer::operator ID3D11Buffer *()
|
||||||
Core::Buffer::operator const ID3D11Buffer *() const
|
Core::Buffer::operator const ID3D11Buffer *() const
|
||||||
{
|
{
|
||||||
return this->mBuffer;
|
return this->mBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 Core::Buffer::GetElementCount()
|
||||||
|
{
|
||||||
|
return this->mElementCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 Core::Buffer::GetVertexSize()
|
||||||
|
{
|
||||||
|
return this->mElementSize;
|
||||||
}
|
}
|
|
@ -20,7 +20,12 @@ ID3D11RenderTargetView* Core::backBufferRTV = NULL;
|
||||||
ID3D11UnorderedAccessView* Core::backBufferUAV = NULL;
|
ID3D11UnorderedAccessView* Core::backBufferUAV = NULL;
|
||||||
|
|
||||||
ID3D11DepthStencilView* Core::depthStencil = NULL;
|
ID3D11DepthStencilView* Core::depthStencil = NULL;
|
||||||
|
ID3D11ShaderResourceView* Core::depthStencilUAV = NULL;
|
||||||
|
|
||||||
D3D11_VIEWPORT* Core::viewPort = NULL;
|
D3D11_VIEWPORT* Core::viewPort = NULL;
|
||||||
|
|
||||||
Oyster::Math::Float2 Core::resolution = Oyster::Math::Float2::null;
|
Oyster::Math::Float2 Core::resolution = Oyster::Math::Float2::null;
|
||||||
|
|
||||||
|
ID3D11ShaderResourceView* Core::srvNULL[16] = {0};
|
||||||
|
ID3D11RenderTargetView* Core::rtvNULL[8] = {0};
|
||||||
|
ID3D11UnorderedAccessView* Core::uavNULL[8] = {0};
|
|
@ -30,82 +30,87 @@ namespace Oyster
|
||||||
static ID3D11UnorderedAccessView* backBufferUAV;
|
static ID3D11UnorderedAccessView* backBufferUAV;
|
||||||
//DepthStencil
|
//DepthStencil
|
||||||
static ID3D11DepthStencilView* depthStencil;
|
static ID3D11DepthStencilView* depthStencil;
|
||||||
|
static ID3D11ShaderResourceView* depthStencilUAV;
|
||||||
//ViewPort
|
//ViewPort
|
||||||
static D3D11_VIEWPORT* viewPort;
|
static D3D11_VIEWPORT* viewPort;
|
||||||
|
|
||||||
static Oyster::Math::Float2 resolution;
|
static Oyster::Math::Float2 resolution;
|
||||||
|
|
||||||
|
static ID3D11ShaderResourceView* srvNULL[16];
|
||||||
|
static ID3D11RenderTargetView* rtvNULL[8];
|
||||||
|
static ID3D11UnorderedAccessView* uavNULL[8];
|
||||||
|
|
||||||
class Buffer
|
class Buffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum BUFFER_TYPE
|
enum BUFFER_TYPE
|
||||||
{
|
|
||||||
VERTEX_BUFFER,
|
|
||||||
INDEX_BUFFER,
|
|
||||||
CONSTANT_BUFFER_VS,
|
|
||||||
CONSTANT_BUFFER_GS,
|
|
||||||
CONSTANT_BUFFER_PS,
|
|
||||||
CONSTANT_BUFFER_CS,
|
|
||||||
STRUCTURED_BUFFER,
|
|
||||||
BUFFER_TYPE_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
enum BUFFER_USAGE
|
|
||||||
{
|
|
||||||
BUFFER_DEFAULT,
|
|
||||||
BUFFER_STREAM_OUT_TARGET,
|
|
||||||
BUFFER_CPU_WRITE,
|
|
||||||
BUFFER_CPU_WRITE_DISCARD,
|
|
||||||
BUFFER_CPU_READ,
|
|
||||||
BUFFER_USAGE_COUNT,
|
|
||||||
BUFFER_USAGE_IMMUTABLE
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BUFFER_INIT_DESC
|
|
||||||
{
|
|
||||||
BUFFER_TYPE Type;
|
|
||||||
UINT32 NumElements;
|
|
||||||
UINT32 ElementSize;
|
|
||||||
BUFFER_USAGE Usage;
|
|
||||||
void* InitData;
|
|
||||||
|
|
||||||
BUFFER_INIT_DESC()
|
|
||||||
{
|
{
|
||||||
InitData = NULL;
|
VERTEX_BUFFER,
|
||||||
Usage = BUFFER_DEFAULT;
|
INDEX_BUFFER,
|
||||||
}
|
CONSTANT_BUFFER_VS,
|
||||||
};
|
CONSTANT_BUFFER_GS,
|
||||||
protected:
|
CONSTANT_BUFFER_PS,
|
||||||
ID3D11Buffer* mBuffer;
|
CONSTANT_BUFFER_CS,
|
||||||
BUFFER_TYPE mType;
|
STRUCTURED_BUFFER,
|
||||||
BUFFER_USAGE mUsage;
|
BUFFER_TYPE_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
UINT32 mElementSize;
|
enum BUFFER_USAGE
|
||||||
UINT32 mElementCount;
|
{
|
||||||
public:
|
BUFFER_DEFAULT,
|
||||||
Buffer();
|
BUFFER_STREAM_OUT_TARGET,
|
||||||
virtual ~Buffer();
|
BUFFER_CPU_WRITE,
|
||||||
|
BUFFER_CPU_WRITE_DISCARD,
|
||||||
|
BUFFER_CPU_READ,
|
||||||
|
BUFFER_USAGE_COUNT,
|
||||||
|
BUFFER_USAGE_IMMUTABLE
|
||||||
|
};
|
||||||
|
|
||||||
HRESULT Init(const BUFFER_INIT_DESC& initDesc);
|
struct BUFFER_INIT_DESC
|
||||||
|
{
|
||||||
|
BUFFER_TYPE Type;
|
||||||
|
UINT32 NumElements;
|
||||||
|
UINT32 ElementSize;
|
||||||
|
BUFFER_USAGE Usage;
|
||||||
|
void* InitData;
|
||||||
|
|
||||||
void* Map();
|
BUFFER_INIT_DESC()
|
||||||
void Unmap();
|
{
|
||||||
|
InitData = NULL;
|
||||||
|
Usage = BUFFER_DEFAULT;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
protected:
|
||||||
|
ID3D11Buffer* mBuffer;
|
||||||
|
BUFFER_TYPE mType;
|
||||||
|
BUFFER_USAGE mUsage;
|
||||||
|
|
||||||
operator ID3D11Buffer*();
|
UINT32 mElementSize;
|
||||||
operator const ID3D11Buffer*() const;
|
UINT32 mElementCount;
|
||||||
|
public:
|
||||||
|
Buffer();
|
||||||
|
virtual ~Buffer();
|
||||||
|
|
||||||
HRESULT Apply(UINT32 misc = 0) const;
|
HRESULT Init(const BUFFER_INIT_DESC& initDesc);
|
||||||
|
|
||||||
ID3D11Buffer* GetBufferPointer();
|
void* Map();
|
||||||
UINT32 GetVertexSize();
|
void Unmap();
|
||||||
UINT32 GetElementCount();
|
|
||||||
|
operator ID3D11Buffer*();
|
||||||
|
operator const ID3D11Buffer*() const;
|
||||||
|
|
||||||
|
HRESULT Apply(UINT32 misc = 0) const;
|
||||||
|
|
||||||
|
ID3D11Buffer* GetBufferPointer();
|
||||||
|
UINT32 GetVertexSize();
|
||||||
|
UINT32 GetElementCount();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ShaderManager
|
class PipelineManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct ShaderEffect
|
struct RenderPass
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -125,16 +130,36 @@ namespace Oyster
|
||||||
ID3D11SamplerState **SampleState;
|
ID3D11SamplerState **SampleState;
|
||||||
int SampleCount;
|
int SampleCount;
|
||||||
ID3D11BlendState *BlendState;
|
ID3D11BlendState *BlendState;
|
||||||
|
|
||||||
}RenderStates;
|
}RenderStates;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
std::vector<Buffer*> Vertex;
|
std::vector<ID3D11Buffer*> Vertex;
|
||||||
std::vector<Buffer*> Geometry;
|
std::vector<ID3D11Buffer*> Geometry;
|
||||||
std::vector<Buffer*> Pixel;
|
std::vector<ID3D11Buffer*> Pixel;
|
||||||
|
std::vector<ID3D11Buffer*> Compute;
|
||||||
}CBuffers;
|
}CBuffers;
|
||||||
|
|
||||||
ShaderEffect()
|
struct
|
||||||
|
{
|
||||||
|
std::vector<ID3D11ShaderResourceView*> Vertex;
|
||||||
|
std::vector<ID3D11ShaderResourceView*> Geometry;
|
||||||
|
std::vector<ID3D11ShaderResourceView*> Pixel;
|
||||||
|
std::vector<ID3D11ShaderResourceView*> Compute;
|
||||||
|
}SRV;
|
||||||
|
|
||||||
|
std::vector<ID3D11RenderTargetView*> RTV;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
std::vector<ID3D11UnorderedAccessView*> Pixel;
|
||||||
|
std::vector<ID3D11UnorderedAccessView*> Compute;
|
||||||
|
}UAV;
|
||||||
|
|
||||||
|
ID3D11DepthStencilView* depth;
|
||||||
|
|
||||||
|
RenderPass()
|
||||||
{
|
{
|
||||||
RenderStates.BlendState=NULL;
|
RenderStates.BlendState=NULL;
|
||||||
RenderStates.DepthStencil=NULL;
|
RenderStates.DepthStencil=NULL;
|
||||||
|
@ -164,7 +189,7 @@ namespace Oyster
|
||||||
char* data;
|
char* data;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void SetShaderEffect(ShaderEffect);
|
static void SetRenderPass(RenderPass);
|
||||||
|
|
||||||
static void CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout);
|
static void CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout);
|
||||||
|
|
||||||
|
@ -192,6 +217,7 @@ namespace Oyster
|
||||||
};
|
};
|
||||||
|
|
||||||
static void Clean();
|
static void Clean();
|
||||||
|
static void CleanPipeline();
|
||||||
};
|
};
|
||||||
|
|
||||||
//Set resulotion Before Calling Full Init
|
//Set resulotion Before Calling Full Init
|
||||||
|
@ -200,7 +226,7 @@ namespace Oyster
|
||||||
public:
|
public:
|
||||||
enum State
|
enum State
|
||||||
{
|
{
|
||||||
Sucsess,
|
Success,
|
||||||
Fail
|
Fail
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -217,6 +243,12 @@ namespace Oyster
|
||||||
static State FullInit(HWND Window, bool MSAA_Quality, bool Fullscreen);
|
static State FullInit(HWND Window, bool MSAA_Quality, bool Fullscreen);
|
||||||
|
|
||||||
static State ReInitialize(HWND Window, bool MSAA_Quality, bool Fullscreen);
|
static State ReInitialize(HWND Window, bool MSAA_Quality, bool Fullscreen);
|
||||||
|
|
||||||
|
static State CreateLinkedShaderResourceFromTexture(ID3D11RenderTargetView** rtv, ID3D11ShaderResourceView** srv, ID3D11UnorderedAccessView** uav);
|
||||||
|
|
||||||
|
static State CreateLinkedShaderResourceFromStructuredBuffer(Buffer** Structured, ID3D11ShaderResourceView** srv, ID3D11UnorderedAccessView** uav);
|
||||||
|
static State CreateLinkedShaderResourceFromStructuredBuffer(void* InitData, int numElem, int ElemSize, Buffer** Structured, ID3D11ShaderResourceView** srv, ID3D11UnorderedAccessView** uav);
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace Oyster
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(Core::device)
|
if(Core::device)
|
||||||
return Init::Sucsess;
|
return Init::Success;
|
||||||
|
|
||||||
return Init::Fail;
|
return Init::Fail;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ namespace Oyster
|
||||||
|
|
||||||
dxgiFactory->Release();
|
dxgiFactory->Release();
|
||||||
|
|
||||||
return Init::Sucsess;
|
return Init::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Init::State Core::Init::CreateDepthStencil(bool MSAA_Quality, Oyster::Math::Float2 Size)
|
Core::Init::State Core::Init::CreateDepthStencil(bool MSAA_Quality, Oyster::Math::Float2 Size)
|
||||||
|
@ -176,9 +176,9 @@ namespace Oyster
|
||||||
D3D11_TEXTURE2D_DESC desc;
|
D3D11_TEXTURE2D_DESC desc;
|
||||||
desc.MipLevels=1;
|
desc.MipLevels=1;
|
||||||
desc.ArraySize=1;
|
desc.ArraySize=1;
|
||||||
desc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
|
desc.Format = DXGI_FORMAT_R32_TYPELESS;
|
||||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||||
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
|
||||||
desc.CPUAccessFlags=0;
|
desc.CPUAccessFlags=0;
|
||||||
desc.MiscFlags=0;
|
desc.MiscFlags=0;
|
||||||
desc.Height = (UINT)Size.y;
|
desc.Height = (UINT)Size.y;
|
||||||
|
@ -211,15 +211,32 @@ namespace Oyster
|
||||||
ID3D11Texture2D* depthstencil;
|
ID3D11Texture2D* depthstencil;
|
||||||
|
|
||||||
if(FAILED(Core::device->CreateTexture2D(&desc,0,&depthstencil)))
|
if(FAILED(Core::device->CreateTexture2D(&desc,0,&depthstencil)))
|
||||||
|
{
|
||||||
return Init::Fail;
|
return Init::Fail;
|
||||||
if(FAILED(Core::device->CreateDepthStencilView(depthstencil,0,&Core::depthStencil)))
|
}
|
||||||
|
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
|
||||||
|
dsvDesc.Format = DXGI_FORMAT_D32_FLOAT;
|
||||||
|
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
|
||||||
|
dsvDesc.Flags = 0;
|
||||||
|
dsvDesc.Texture2D.MipSlice = 0;
|
||||||
|
if(Core::device->CreateDepthStencilView(depthstencil,&dsvDesc,&Core::depthStencil) != S_OK)
|
||||||
{
|
{
|
||||||
depthstencil->Release();
|
depthstencil->Release();
|
||||||
return Init::Fail;
|
return Init::Fail;
|
||||||
}
|
}
|
||||||
|
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
|
||||||
|
srvDesc.Format = DXGI_FORMAT_R32_FLOAT;
|
||||||
|
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||||
|
srvDesc.Texture2D.MipLevels = 1;
|
||||||
|
srvDesc.Texture2D.MostDetailedMip = 0;
|
||||||
|
if(FAILED(Core::device->CreateShaderResourceView(depthstencil,&srvDesc,&Core::depthStencilUAV)))
|
||||||
|
{
|
||||||
|
depthStencil->Release();
|
||||||
|
return Init::Fail;
|
||||||
|
}
|
||||||
depthstencil->Release();
|
depthstencil->Release();
|
||||||
|
|
||||||
return Init::Sucsess;
|
return Init::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Init::State Core::Init::CreateBackBufferViews()
|
Core::Init::State Core::Init::CreateBackBufferViews()
|
||||||
|
@ -261,7 +278,7 @@ namespace Oyster
|
||||||
|
|
||||||
backBuffer->Release();
|
backBuffer->Release();
|
||||||
|
|
||||||
return Init::Sucsess;
|
return Init::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Init::State Core::Init::CreateViewPort(Oyster::Math::Float2 Origin, Oyster::Math::Float2 Size)
|
Core::Init::State Core::Init::CreateViewPort(Oyster::Math::Float2 Origin, Oyster::Math::Float2 Size)
|
||||||
|
@ -277,7 +294,7 @@ namespace Oyster
|
||||||
Core::viewPort->MinDepth = 0.0f;
|
Core::viewPort->MinDepth = 0.0f;
|
||||||
Core::viewPort->MaxDepth = 1.0f;
|
Core::viewPort->MaxDepth = 1.0f;
|
||||||
|
|
||||||
return Init::Sucsess;
|
return Init::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Init::State Core::Init::FullInit(HWND Window, bool MSAA_Quality, bool Fullscreen)
|
Core::Init::State Core::Init::FullInit(HWND Window, bool MSAA_Quality, bool Fullscreen)
|
||||||
|
@ -307,7 +324,7 @@ namespace Oyster
|
||||||
return Init::Fail;
|
return Init::Fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Init::Sucsess;
|
return Init::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Init::State Core::Init::ReInitialize(HWND Window, bool MSAA_Quality, bool Fullscreen)
|
Core::Init::State Core::Init::ReInitialize(HWND Window, bool MSAA_Quality, bool Fullscreen)
|
||||||
|
@ -332,7 +349,88 @@ namespace Oyster
|
||||||
return Init::Fail;
|
return Init::Fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Init::Sucsess;
|
return Init::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::CreateLinkedShaderResourceFromTexture(ID3D11RenderTargetView** rtv, ID3D11ShaderResourceView** srv, ID3D11UnorderedAccessView** uav)
|
||||||
|
{
|
||||||
|
ID3D11Texture2D* tex;
|
||||||
|
D3D11_TEXTURE2D_DESC texDesc;
|
||||||
|
texDesc.Width = Core::resolution.x;
|
||||||
|
texDesc.Height = Core::resolution.y;
|
||||||
|
texDesc.MipLevels = 1;
|
||||||
|
texDesc.ArraySize = 1;
|
||||||
|
texDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||||
|
texDesc.SampleDesc.Count = 1;
|
||||||
|
texDesc.SampleDesc.Quality = 0;
|
||||||
|
texDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||||
|
texDesc.CPUAccessFlags = 0;
|
||||||
|
texDesc.MiscFlags = 0;
|
||||||
|
texDesc.BindFlags = 0;
|
||||||
|
if(rtv)
|
||||||
|
{
|
||||||
|
texDesc.BindFlags |= D3D11_BIND_RENDER_TARGET;
|
||||||
|
}
|
||||||
|
if(srv)
|
||||||
|
{
|
||||||
|
texDesc.BindFlags |= D3D11_BIND_SHADER_RESOURCE;
|
||||||
|
}
|
||||||
|
if(uav)
|
||||||
|
{
|
||||||
|
texDesc.BindFlags |= D3D11_BIND_UNORDERED_ACCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(FAILED(Core::device->CreateTexture2D(&texDesc,NULL,&tex)))
|
||||||
|
return State::Fail;
|
||||||
|
if(rtv)
|
||||||
|
{
|
||||||
|
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
|
||||||
|
rtvDesc.Format = texDesc.Format;
|
||||||
|
rtvDesc.Texture2D.MipSlice = 0;
|
||||||
|
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||||
|
|
||||||
|
Core::device->CreateRenderTargetView(tex, &rtvDesc, rtv);
|
||||||
|
}
|
||||||
|
if(srv)
|
||||||
|
{
|
||||||
|
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
|
||||||
|
srvDesc.Texture2D.MipLevels = 1;
|
||||||
|
srvDesc.Texture2D.MostDetailedMip = 0;
|
||||||
|
srvDesc.Format = texDesc.Format;
|
||||||
|
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||||
|
|
||||||
|
Core::device->CreateShaderResourceView(tex,&srvDesc,srv);
|
||||||
|
}
|
||||||
|
if(uav)
|
||||||
|
{
|
||||||
|
D3D11_UNORDERED_ACCESS_VIEW_DESC uavDesc;
|
||||||
|
uavDesc.Texture2D.MipSlice = 0;
|
||||||
|
uavDesc.Format = texDesc.Format;
|
||||||
|
uavDesc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D;
|
||||||
|
|
||||||
|
Core::device->CreateUnorderedAccessView(tex,&uavDesc,uav);
|
||||||
|
}
|
||||||
|
|
||||||
|
SAFE_RELEASE(tex);
|
||||||
|
|
||||||
|
|
||||||
|
return State::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Core::Init::CreateLinkedShaderResourceFromStructuredBuffer(Buffer** Structured, ID3D11ShaderResourceView** srv, ID3D11UnorderedAccessView** uav)
|
||||||
|
{
|
||||||
|
D3D11_SHADER_RESOURCE_VIEW_DESC desc;
|
||||||
|
desc.Buffer.FirstElement=0;
|
||||||
|
desc.Buffer.ElementWidth = (*Structured)->GetElementCount();
|
||||||
|
desc.Format = DXGI_FORMAT_UNKNOWN;
|
||||||
|
desc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
|
||||||
|
|
||||||
|
if(Core::device->CreateShaderResourceView(**(Structured),&desc, srv)==S_OK)
|
||||||
|
{
|
||||||
|
return State::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
return State::Fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,12 +28,14 @@ namespace Oyster
|
||||||
std::map<std::wstring,int> HSMap;
|
std::map<std::wstring,int> HSMap;
|
||||||
|
|
||||||
std::vector<ID3D11VertexShader*> VS;
|
std::vector<ID3D11VertexShader*> VS;
|
||||||
std::vector<Core::ShaderManager::ShaderData> VData;
|
std::vector<Core::PipelineManager::ShaderData> VData;
|
||||||
std::map<std::wstring,int> VSMap;
|
std::map<std::wstring,int> VSMap;
|
||||||
|
|
||||||
|
Core::PipelineManager::RenderPass Current;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma region Init
|
#pragma region Init
|
||||||
bool Core::ShaderManager::Init(std::wstring filename, ShaderType type, std::wstring name)
|
bool Core::PipelineManager::Init(std::wstring filename, ShaderType type, std::wstring name)
|
||||||
{
|
{
|
||||||
void* data;
|
void* data;
|
||||||
bool ForceReload;
|
bool ForceReload;
|
||||||
|
@ -44,7 +46,7 @@ namespace Oyster
|
||||||
#endif
|
#endif
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case Oyster::Graphics::Core::ShaderManager::Vertex:
|
case Oyster::Graphics::Core::PipelineManager::Vertex:
|
||||||
if(!VSMap.count(name) || ForceReload)
|
if(!VSMap.count(name) || ForceReload)
|
||||||
{
|
{
|
||||||
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderV, -1, ForceReload);
|
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderV, -1, ForceReload);
|
||||||
|
@ -55,7 +57,7 @@ namespace Oyster
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Oyster::Graphics::Core::ShaderManager::Hull:
|
case Oyster::Graphics::Core::PipelineManager::Hull:
|
||||||
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderH, -1, ForceReload);
|
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderH, -1, ForceReload);
|
||||||
if(!HSMap.count(name) || ForceReload)
|
if(!HSMap.count(name) || ForceReload)
|
||||||
{
|
{
|
||||||
|
@ -66,7 +68,7 @@ namespace Oyster
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Oyster::Graphics::Core::ShaderManager::Domain:
|
case Oyster::Graphics::Core::PipelineManager::Domain:
|
||||||
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderD, -1, ForceReload);
|
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderD, -1, ForceReload);
|
||||||
if(!DSMap.count(name) || ForceReload)
|
if(!DSMap.count(name) || ForceReload)
|
||||||
{
|
{
|
||||||
|
@ -77,7 +79,7 @@ namespace Oyster
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Oyster::Graphics::Core::ShaderManager::Geometry:
|
case Oyster::Graphics::Core::PipelineManager::Geometry:
|
||||||
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderG, -1, ForceReload);
|
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderG, -1, ForceReload);
|
||||||
if(!GSMap.count(name) || ForceReload)
|
if(!GSMap.count(name) || ForceReload)
|
||||||
{
|
{
|
||||||
|
@ -88,7 +90,7 @@ namespace Oyster
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Oyster::Graphics::Core::ShaderManager::Pixel:
|
case Oyster::Graphics::Core::PipelineManager::Pixel:
|
||||||
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderP, -1, ForceReload);
|
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderP, -1, ForceReload);
|
||||||
if(!PSMap.count(name) || ForceReload)
|
if(!PSMap.count(name) || ForceReload)
|
||||||
{
|
{
|
||||||
|
@ -99,7 +101,7 @@ namespace Oyster
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Oyster::Graphics::Core::ShaderManager::Compute:
|
case Oyster::Graphics::Core::PipelineManager::Compute:
|
||||||
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderC, -1, ForceReload);
|
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderC, -1, ForceReload);
|
||||||
if(!CSMap.count(name) || ForceReload)
|
if(!CSMap.count(name) || ForceReload)
|
||||||
{
|
{
|
||||||
|
@ -116,44 +118,44 @@ namespace Oyster
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Core::ShaderManager::CreateShader(Core::ShaderManager::ShaderData data, Core::ShaderManager::ShaderType type)
|
void* Core::PipelineManager::CreateShader(Core::PipelineManager::ShaderData data, Core::PipelineManager::ShaderType type)
|
||||||
{
|
{
|
||||||
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case Oyster::Graphics::Core::ShaderManager::Vertex:
|
case Oyster::Graphics::Core::PipelineManager::Vertex:
|
||||||
ID3D11VertexShader* vs;
|
ID3D11VertexShader* vs;
|
||||||
hr = Core::device->CreateVertexShader(data.data,data.size,NULL,&vs);
|
hr = Core::device->CreateVertexShader(data.data,data.size,NULL,&vs);
|
||||||
if(hr == S_OK)
|
if(hr == S_OK)
|
||||||
VData.push_back(data);
|
VData.push_back(data);
|
||||||
return vs;
|
return vs;
|
||||||
break;
|
break;
|
||||||
case Oyster::Graphics::Core::ShaderManager::Hull:
|
case Oyster::Graphics::Core::PipelineManager::Hull:
|
||||||
ID3D11HullShader* hs;
|
ID3D11HullShader* hs;
|
||||||
Core::device->CreateHullShader(data.data,data.size,NULL,&hs);
|
Core::device->CreateHullShader(data.data,data.size,NULL,&hs);
|
||||||
delete[] data.data;
|
delete[] data.data;
|
||||||
return hs;
|
return hs;
|
||||||
break;
|
break;
|
||||||
case Oyster::Graphics::Core::ShaderManager::Domain:
|
case Oyster::Graphics::Core::PipelineManager::Domain:
|
||||||
ID3D11DomainShader* ds;
|
ID3D11DomainShader* ds;
|
||||||
Core::device->CreateDomainShader(data.data,data.size,NULL,&ds);
|
Core::device->CreateDomainShader(data.data,data.size,NULL,&ds);
|
||||||
delete[] data.data;
|
delete[] data.data;
|
||||||
return ds;
|
return ds;
|
||||||
break;
|
break;
|
||||||
case Oyster::Graphics::Core::ShaderManager::Geometry:
|
case Oyster::Graphics::Core::PipelineManager::Geometry:
|
||||||
ID3D11GeometryShader* gs;
|
ID3D11GeometryShader* gs;
|
||||||
Core::device->CreateGeometryShader(data.data,data.size,NULL,&gs);
|
Core::device->CreateGeometryShader(data.data,data.size,NULL,&gs);
|
||||||
delete[] data.data;
|
delete[] data.data;
|
||||||
return gs;
|
return gs;
|
||||||
break;
|
break;
|
||||||
case Oyster::Graphics::Core::ShaderManager::Pixel:
|
case Oyster::Graphics::Core::PipelineManager::Pixel:
|
||||||
ID3D11PixelShader* ps;
|
ID3D11PixelShader* ps;
|
||||||
Core::device->CreatePixelShader(data.data,data.size,NULL,&ps);
|
Core::device->CreatePixelShader(data.data,data.size,NULL,&ps);
|
||||||
delete[] data.data;
|
delete[] data.data;
|
||||||
return ps;
|
return ps;
|
||||||
break;
|
break;
|
||||||
case Oyster::Graphics::Core::ShaderManager::Compute:
|
case Oyster::Graphics::Core::PipelineManager::Compute:
|
||||||
ID3D11ComputeShader* cs;
|
ID3D11ComputeShader* cs;
|
||||||
Core::device->CreateComputeShader(data.data,data.size,NULL,&cs);
|
Core::device->CreateComputeShader(data.data,data.size,NULL,&cs);
|
||||||
delete[] data.data;
|
delete[] data.data;
|
||||||
|
@ -164,7 +166,7 @@ namespace Oyster
|
||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
void Core::ShaderManager::CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout)
|
void Core::PipelineManager::CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *desc, int ElementCount,int VertexIndex,ID3D11InputLayout *&Layout)
|
||||||
{
|
{
|
||||||
if(VertexIndex==-1)
|
if(VertexIndex==-1)
|
||||||
{
|
{
|
||||||
|
@ -175,79 +177,113 @@ namespace Oyster
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma region Get
|
#pragma region Get
|
||||||
int Core::ShaderManager::Get::Pixel(std::wstring Name)
|
int Core::PipelineManager::Get::Pixel(std::wstring Name)
|
||||||
{
|
{
|
||||||
if(PSMap.count(Name))
|
if(PSMap.count(Name))
|
||||||
return PSMap[Name];
|
return PSMap[Name];
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Core::ShaderManager::Get::Vertex(std::wstring Name)
|
int Core::PipelineManager::Get::Vertex(std::wstring Name)
|
||||||
{
|
{
|
||||||
if(VSMap.count(Name))
|
if(VSMap.count(Name))
|
||||||
return VSMap[Name];
|
return VSMap[Name];
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int Core::ShaderManager::Get::Geometry(std::wstring Name)
|
int Core::PipelineManager::Get::Geometry(std::wstring Name)
|
||||||
{
|
{
|
||||||
if(GSMap.count(Name))
|
if(GSMap.count(Name))
|
||||||
return GSMap[Name];
|
return GSMap[Name];
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Core::ShaderManager::Get::Compute(std::wstring Name)
|
int Core::PipelineManager::Get::Compute(std::wstring Name)
|
||||||
{
|
{
|
||||||
if(CSMap.count(Name))
|
if(CSMap.count(Name))
|
||||||
return CSMap[Name];
|
return CSMap[Name];
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int Core::ShaderManager::Get::Hull(std::wstring Name)
|
int Core::PipelineManager::Get::Hull(std::wstring Name)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int Core::ShaderManager::Get::Domain(std::wstring Name)
|
int Core::PipelineManager::Get::Domain(std::wstring Name)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region Set
|
#pragma region Set
|
||||||
/// \todo smart set
|
void Core::PipelineManager::Set::Pixel(int Index)
|
||||||
void Core::ShaderManager::Set::Pixel(int Index)
|
|
||||||
{
|
{
|
||||||
if(Index==-1)
|
if(Current.Shaders.Pixel != Index)
|
||||||
Core::deviceContext->PSSetShader( NULL,NULL,0);
|
{
|
||||||
else
|
if(Index==-1)
|
||||||
Core::deviceContext->PSSetShader( PS[Index],NULL,0);
|
{
|
||||||
|
Core::deviceContext->PSSetShader( NULL,NULL,0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Core::deviceContext->PSSetShader( PS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
Current.Shaders.Pixel=Index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void Core::ShaderManager::Set::Vertex(int Index)
|
|
||||||
|
void Core::PipelineManager::Set::Vertex(int Index)
|
||||||
{
|
{
|
||||||
if(Index==-1)
|
if(Current.Shaders.Vertex != Index)
|
||||||
Core::deviceContext->VSSetShader( NULL,NULL,0);
|
{
|
||||||
else
|
if(Index==-1)
|
||||||
Core::deviceContext->VSSetShader( VS[Index],NULL,0);
|
{
|
||||||
|
Core::deviceContext->VSSetShader( NULL,NULL,0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Core::deviceContext->VSSetShader( VS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
Current.Shaders.Vertex = Index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void Core::ShaderManager::Set::Geometry(int Index)
|
|
||||||
|
void Core::PipelineManager::Set::Geometry(int Index)
|
||||||
{
|
{
|
||||||
if(Index==-1)
|
if(Current.Shaders.Geometry != Index)
|
||||||
Core::deviceContext->GSSetShader( NULL,NULL,0);
|
{
|
||||||
else
|
if(Index==-1)
|
||||||
Core::deviceContext->GSSetShader( GS[Index],NULL,0);
|
{
|
||||||
|
Core::deviceContext->GSSetShader( NULL,NULL,0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Core::deviceContext->GSSetShader( GS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
Current.Shaders.Geometry = Index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void Core::ShaderManager::Set::Compute(int Index)
|
|
||||||
|
void Core::PipelineManager::Set::Compute(int Index)
|
||||||
{
|
{
|
||||||
if(Index==-1)
|
if(Current.Shaders.Compute != Index)
|
||||||
Core::deviceContext->CSSetShader( NULL,NULL,0);
|
{
|
||||||
else
|
if(Index==-1)
|
||||||
Core::deviceContext->CSSetShader( CS[Index],NULL,0);
|
{
|
||||||
|
Core::deviceContext->CSSetShader( NULL,NULL,0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Core::deviceContext->CSSetShader( CS[Index],NULL,0);
|
||||||
|
}
|
||||||
|
Current.Shaders.Compute = Index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// \todo set Hull
|
/// \todo set Hull
|
||||||
void Core::ShaderManager::Set::Hull(int Index)
|
void Core::PipelineManager::Set::Hull(int Index)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/// \todo set Domain
|
/// \todo set Domain
|
||||||
void Core::ShaderManager::Set::Domain(int Index)
|
void Core::PipelineManager::Set::Domain(int Index)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -256,33 +292,95 @@ namespace Oyster
|
||||||
/// \todo smart Set ie. not resetting the shader
|
/// \todo smart Set ie. not resetting the shader
|
||||||
/// \todo research states
|
/// \todo research states
|
||||||
/// \todo smart buffer set
|
/// \todo smart buffer set
|
||||||
void Core::ShaderManager::SetShaderEffect(ShaderEffect se)
|
void Core::PipelineManager::SetRenderPass(RenderPass se)
|
||||||
{
|
{
|
||||||
|
CleanPipeline();
|
||||||
Set::Pixel(se.Shaders.Pixel);
|
Set::Pixel(se.Shaders.Pixel);
|
||||||
Set::Vertex(se.Shaders.Vertex);
|
Set::Vertex(se.Shaders.Vertex);
|
||||||
Set::Geometry(se.Shaders.Geometry);
|
Set::Geometry(se.Shaders.Geometry);
|
||||||
Set::Compute(se.Shaders.Compute);
|
Set::Compute(se.Shaders.Compute);
|
||||||
Core::deviceContext->IASetInputLayout(se.IAStage.Layout);
|
Core::deviceContext->IASetInputLayout(se.IAStage.Layout);
|
||||||
Core::deviceContext->IASetPrimitiveTopology(se.IAStage.Topology);
|
Core::deviceContext->IASetPrimitiveTopology(se.IAStage.Topology);
|
||||||
for(unsigned int i=0;i<se.CBuffers.Vertex.size();++i)
|
if(se.CBuffers.Vertex.size())
|
||||||
se.CBuffers.Vertex[i]->Apply(i);
|
{
|
||||||
for(unsigned int i=0;i<se.CBuffers.Geometry.size();++i)
|
deviceContext->VSSetConstantBuffers(0,se.CBuffers.Vertex.size(),&se.CBuffers.Vertex[0]);
|
||||||
se.CBuffers.Geometry[i]->Apply(i);
|
}
|
||||||
for(unsigned int i=0;i<se.CBuffers.Pixel.size();++i)
|
if(se.CBuffers.Pixel.size())
|
||||||
se.CBuffers.Pixel[i]->Apply(i);
|
{
|
||||||
|
deviceContext->PSSetConstantBuffers(0,se.CBuffers.Pixel.size(),&se.CBuffers.Pixel[0]);
|
||||||
|
}
|
||||||
|
if(se.CBuffers.Geometry.size())
|
||||||
|
{
|
||||||
|
deviceContext->GSSetConstantBuffers(0,se.CBuffers.Geometry.size(),&se.CBuffers.Geometry[0]);
|
||||||
|
}
|
||||||
|
if(se.CBuffers.Compute.size())
|
||||||
|
{
|
||||||
|
deviceContext->CSSetConstantBuffers(0,se.CBuffers.Compute.size(),&se.CBuffers.Compute[0]);
|
||||||
|
}
|
||||||
Core::deviceContext->RSSetState(se.RenderStates.Rasterizer);
|
Core::deviceContext->RSSetState(se.RenderStates.Rasterizer);
|
||||||
Core::deviceContext->PSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState);
|
Core::deviceContext->PSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState);
|
||||||
Core::deviceContext->OMSetDepthStencilState(se.RenderStates.DepthStencil,0);
|
Core::deviceContext->OMSetDepthStencilState(se.RenderStates.DepthStencil,0);
|
||||||
float test[4] = {0};
|
float test[4] = {0};
|
||||||
Core::deviceContext->OMSetBlendState(se.RenderStates.BlendState,test,-1);
|
Core::deviceContext->OMSetBlendState(se.RenderStates.BlendState,test,-1);
|
||||||
|
|
||||||
|
if(se.SRV.Vertex.size())
|
||||||
|
{
|
||||||
|
Core::deviceContext->VSSetShaderResources(0,se.SRV.Vertex.size(),&se.SRV.Vertex[0]);
|
||||||
|
}
|
||||||
|
if(se.SRV.Geometry.size())
|
||||||
|
{
|
||||||
|
Core::deviceContext->GSSetShaderResources(0,se.SRV.Geometry.size(),&se.SRV.Geometry[0]);
|
||||||
|
}
|
||||||
|
if(se.SRV.Pixel.size())
|
||||||
|
{
|
||||||
|
Core::deviceContext->PSSetShaderResources(0,se.SRV.Pixel.size(),&se.SRV.Pixel[0]);
|
||||||
|
}
|
||||||
|
if(se.SRV.Compute.size())
|
||||||
|
{
|
||||||
|
Core::deviceContext->CSSetShaderResources(0,se.SRV.Compute.size(),&se.SRV.Compute[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(se.RTV.size())
|
||||||
|
{
|
||||||
|
if(se.UAV.Pixel.size())
|
||||||
|
{
|
||||||
|
deviceContext->OMSetRenderTargetsAndUnorderedAccessViews(se.RTV.size(),&se.RTV[0],se.depth,se.RTV.size(),se.UAV.Pixel.size(),&se.UAV.Pixel[0],0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
deviceContext->OMSetRenderTargets(se.RTV.size(),&se.RTV[0],se.depth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(se.UAV.Pixel.size())
|
||||||
|
{
|
||||||
|
deviceContext->OMSetRenderTargetsAndUnorderedAccessViews(0,NULL,se.depth,0,se.UAV.Pixel.size(),&se.UAV.Pixel[0],0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(se.UAV.Compute.size())
|
||||||
|
{
|
||||||
|
deviceContext->CSSetUnorderedAccessViews(0,se.UAV.Compute.size(),&se.UAV.Compute[0],0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::ShaderManager::Clean()
|
void Core::PipelineManager::Clean()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < (int)VData.size(); ++i)
|
for(int i = 0; i < (int)VData.size(); ++i)
|
||||||
{
|
{
|
||||||
delete[] VData[i].data;
|
delete[] VData[i].data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::PipelineManager::CleanPipeline()
|
||||||
|
{
|
||||||
|
deviceContext->VSSetShaderResources(0,16,Core::srvNULL);
|
||||||
|
deviceContext->GSSetShaderResources(0,16,Core::srvNULL);
|
||||||
|
deviceContext->PSSetShaderResources(0,16,Core::srvNULL);
|
||||||
|
deviceContext->CSSetShaderResources(0,16,Core::srvNULL);
|
||||||
|
deviceContext->CSSetUnorderedAccessViews(0,8,Core::uavNULL,NULL);
|
||||||
|
deviceContext->OMSetRenderTargets(8,Core::rtvNULL, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
#include "..\OysterGraphics\Core\Dx11Includes.h"
|
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
|
#pragma once
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
@ -31,6 +31,22 @@ namespace Oyster
|
||||||
Oyster::Math::Float4 boneWeights;
|
Oyster::Math::Float4 boneWeights;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct LightConstants
|
||||||
|
{
|
||||||
|
Math::Float4x4 InvProj;
|
||||||
|
Math::Float2 Pixels;
|
||||||
|
int Lights;
|
||||||
|
float Pad;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Pointlight
|
||||||
|
{
|
||||||
|
Math::Float3 Pos;
|
||||||
|
float Radius;
|
||||||
|
Math::Float3 Color;
|
||||||
|
float Bright;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
#include "GFXAPI.h"
|
#include "GFXAPI.h"
|
||||||
#include "../Core/Core.h"
|
#include "../Core/Core.h"
|
||||||
#include "../Render/Resources/Resources.h"
|
#include "../Render/Resources/Debug.h"
|
||||||
|
#include "../Render/Resources/Deffered.h"
|
||||||
#include "../Render/Rendering/Render.h"
|
#include "../Render/Rendering/Render.h"
|
||||||
#include "../FileLoader/ObjReader.h"
|
#include "../FileLoader/ObjReader.h"
|
||||||
#include "../../Misc/Resource/OysterResource.h"
|
#include "../../Misc/Resource/OysterResource.h"
|
||||||
|
@ -14,6 +15,7 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
Math::Float4x4 View;
|
Math::Float4x4 View;
|
||||||
Math::Float4x4 Projection;
|
Math::Float4x4 Projection;
|
||||||
|
std::vector<Definitions::Pointlight> Lights;
|
||||||
}
|
}
|
||||||
|
|
||||||
API::State API::Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Math::Float2 resulotion)
|
API::State API::Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Math::Float2 resulotion)
|
||||||
|
@ -24,10 +26,13 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
return API::Fail;
|
return API::Fail;
|
||||||
}
|
}
|
||||||
if(Render::Resources::Init() == Core::Init::Fail)
|
#ifdef _DEBUG
|
||||||
|
if(Render::Resources::Debug::Init() == Core::Init::Fail)
|
||||||
{
|
{
|
||||||
return API::Fail;
|
return API::Fail;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
Render::Resources::Deffered::Init();
|
||||||
|
|
||||||
Render::Preparations::Basic::SetViewPort();
|
Render::Preparations::Basic::SetViewPort();
|
||||||
return API::Sucsess;
|
return API::Sucsess;
|
||||||
|
@ -45,7 +50,14 @@ namespace Oyster
|
||||||
|
|
||||||
void API::NewFrame()
|
void API::NewFrame()
|
||||||
{
|
{
|
||||||
Render::Rendering::Basic::NewFrame(View, Projection);
|
if(Lights.size())
|
||||||
|
{
|
||||||
|
Render::Rendering::Basic::NewFrame(View, Projection, &Lights[0], Lights.size());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Render::Rendering::Basic::NewFrame(View, Projection, NULL, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void API::RenderScene(Model::Model models[], int count)
|
void API::RenderScene(Model::Model models[], int count)
|
||||||
|
@ -90,10 +102,15 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
SAFE_DELETE(Core::viewPort);
|
SAFE_DELETE(Core::viewPort);
|
||||||
Oyster::Resource::OysterResource::Clean();
|
Oyster::Resource::OysterResource::Clean();
|
||||||
Oyster::Graphics::Core::ShaderManager::Clean();
|
Oyster::Graphics::Core::PipelineManager::Clean();
|
||||||
Oyster::Graphics::Render::Resources::Clean();
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
Oyster::Graphics::Render::Resources::Debug::Clean();
|
||||||
|
#endif
|
||||||
|
Oyster::Graphics::Render::Resources::Deffered::Clean();
|
||||||
|
|
||||||
SAFE_RELEASE(Core::depthStencil);
|
SAFE_RELEASE(Core::depthStencil);
|
||||||
|
SAFE_RELEASE(Core::depthStencilUAV);
|
||||||
SAFE_RELEASE(Core::backBufferRTV);
|
SAFE_RELEASE(Core::backBufferRTV);
|
||||||
SAFE_RELEASE(Core::backBufferUAV);
|
SAFE_RELEASE(Core::backBufferUAV);
|
||||||
|
|
||||||
|
@ -101,5 +118,15 @@ namespace Oyster
|
||||||
SAFE_RELEASE(Core::deviceContext);
|
SAFE_RELEASE(Core::deviceContext);
|
||||||
SAFE_RELEASE(Core::device);
|
SAFE_RELEASE(Core::device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void API::AddLight(Definitions::Pointlight light)
|
||||||
|
{
|
||||||
|
Lights.push_back(light);
|
||||||
|
}
|
||||||
|
|
||||||
|
void API::ClearLights()
|
||||||
|
{
|
||||||
|
Lights.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "../Definitions/GraphicalDefinition.h"
|
||||||
#include "..\Model\Model.h"
|
#include "..\Model\Model.h"
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
//#include <vld.h>
|
||||||
|
|
||||||
#ifdef GFX_DLL_EXPORT
|
#ifdef GFX_DLL_EXPORT
|
||||||
#define GFX_DLL_USAGE __declspec(dllexport)
|
#define GFX_DLL_USAGE __declspec(dllexport)
|
||||||
|
@ -41,6 +43,9 @@ namespace Oyster
|
||||||
static Oyster::Graphics::Model::Model* CreateModel(std::wstring filename);
|
static Oyster::Graphics::Model::Model* CreateModel(std::wstring filename);
|
||||||
static void DeleteModel(Oyster::Graphics::Model::Model* model);
|
static void DeleteModel(Oyster::Graphics::Model::Model* model);
|
||||||
|
|
||||||
|
static void AddLight(Definitions::Pointlight light);
|
||||||
|
static void ClearLights();
|
||||||
|
|
||||||
static State SetOptions(Option);
|
static State SetOptions(Option);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace Oyster
|
||||||
|
|
||||||
void LoadShaderP(const wchar_t filename[], Oyster::Resource::CustomData& out)
|
void LoadShaderP(const wchar_t filename[], Oyster::Resource::CustomData& out)
|
||||||
{
|
{
|
||||||
LoadShader(filename,out,Core::ShaderManager::Pixel);
|
LoadShader(filename,out,Core::PipelineManager::Pixel);
|
||||||
if(out.loadedData==NULL)
|
if(out.loadedData==NULL)
|
||||||
{
|
{
|
||||||
memset(&out,0,sizeof(out));
|
memset(&out,0,sizeof(out));
|
||||||
|
@ -62,7 +62,7 @@ namespace Oyster
|
||||||
void LoadShaderG(const wchar_t filename[], Oyster::Resource::CustomData& out)
|
void LoadShaderG(const wchar_t filename[], Oyster::Resource::CustomData& out)
|
||||||
{
|
{
|
||||||
|
|
||||||
LoadShader(filename,out,Core::ShaderManager::Geometry);
|
LoadShader(filename,out,Core::PipelineManager::Geometry);
|
||||||
if(out.loadedData==NULL)
|
if(out.loadedData==NULL)
|
||||||
{
|
{
|
||||||
memset(&out,0,sizeof(out));
|
memset(&out,0,sizeof(out));
|
||||||
|
@ -74,7 +74,7 @@ namespace Oyster
|
||||||
void LoadShaderC(const wchar_t filename[], Oyster::Resource::CustomData& out)
|
void LoadShaderC(const wchar_t filename[], Oyster::Resource::CustomData& out)
|
||||||
{
|
{
|
||||||
|
|
||||||
LoadShader(filename,out,Core::ShaderManager::Compute);
|
LoadShader(filename,out,Core::PipelineManager::Compute);
|
||||||
if(out.loadedData==NULL)
|
if(out.loadedData==NULL)
|
||||||
{
|
{
|
||||||
memset(&out,0,sizeof(out));
|
memset(&out,0,sizeof(out));
|
||||||
|
@ -86,7 +86,7 @@ namespace Oyster
|
||||||
void LoadShaderH(const wchar_t filename[], Oyster::Resource::CustomData& out)
|
void LoadShaderH(const wchar_t filename[], Oyster::Resource::CustomData& out)
|
||||||
{
|
{
|
||||||
|
|
||||||
LoadShader(filename,out,Core::ShaderManager::Hull);
|
LoadShader(filename,out,Core::PipelineManager::Hull);
|
||||||
if(out.loadedData==NULL)
|
if(out.loadedData==NULL)
|
||||||
{
|
{
|
||||||
memset(&out,0,sizeof(out));
|
memset(&out,0,sizeof(out));
|
||||||
|
@ -98,7 +98,7 @@ namespace Oyster
|
||||||
void LoadShaderD(const wchar_t filename[], Oyster::Resource::CustomData& out)
|
void LoadShaderD(const wchar_t filename[], Oyster::Resource::CustomData& out)
|
||||||
{
|
{
|
||||||
|
|
||||||
LoadShader(filename,out,Core::ShaderManager::Domain);
|
LoadShader(filename,out,Core::PipelineManager::Domain);
|
||||||
if(out.loadedData==NULL)
|
if(out.loadedData==NULL)
|
||||||
{
|
{
|
||||||
memset(&out,0,sizeof(out));
|
memset(&out,0,sizeof(out));
|
||||||
|
@ -110,7 +110,7 @@ namespace Oyster
|
||||||
void LoadShaderV(const wchar_t filename[], Oyster::Resource::CustomData& out)
|
void LoadShaderV(const wchar_t filename[], Oyster::Resource::CustomData& out)
|
||||||
{
|
{
|
||||||
|
|
||||||
LoadShader(filename,out,Core::ShaderManager::Vertex);
|
LoadShader(filename,out,Core::PipelineManager::Vertex);
|
||||||
if(out.loadedData==NULL)
|
if(out.loadedData==NULL)
|
||||||
{
|
{
|
||||||
memset(&out,0,sizeof(out));
|
memset(&out,0,sizeof(out));
|
||||||
|
@ -121,28 +121,28 @@ namespace Oyster
|
||||||
|
|
||||||
void LoadShader(const wchar_t filename[], Oyster::Resource::CustomData& out, int type)
|
void LoadShader(const wchar_t filename[], Oyster::Resource::CustomData& out, int type)
|
||||||
{
|
{
|
||||||
Core::ShaderManager::ShaderData data;
|
Core::PipelineManager::ShaderData data;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
ID3DBlob *Shader=NULL, *Error=NULL;
|
ID3DBlob *Shader=NULL, *Error=NULL;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
switch (Core::ShaderManager::ShaderType(type))
|
switch (Core::PipelineManager::ShaderType(type))
|
||||||
{
|
{
|
||||||
case Oyster::Graphics::Core::ShaderManager::Vertex:
|
case Oyster::Graphics::Core::PipelineManager::Vertex:
|
||||||
hr = D3DCompileFromFile(filename,NULL,D3D_COMPILE_STANDARD_FILE_INCLUDE,"main","vs_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error);
|
hr = D3DCompileFromFile(filename,NULL,D3D_COMPILE_STANDARD_FILE_INCLUDE,"main","vs_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error);
|
||||||
break;
|
break;
|
||||||
case Oyster::Graphics::Core::ShaderManager::Hull:
|
case Oyster::Graphics::Core::PipelineManager::Hull:
|
||||||
hr = D3DCompileFromFile(filename,NULL,D3D_COMPILE_STANDARD_FILE_INCLUDE,"main","hs_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error);
|
hr = D3DCompileFromFile(filename,NULL,D3D_COMPILE_STANDARD_FILE_INCLUDE,"main","hs_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error);
|
||||||
break;
|
break;
|
||||||
case Oyster::Graphics::Core::ShaderManager::Domain:
|
case Oyster::Graphics::Core::PipelineManager::Domain:
|
||||||
hr = D3DCompileFromFile(filename,NULL,D3D_COMPILE_STANDARD_FILE_INCLUDE,"main","ds_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error);
|
hr = D3DCompileFromFile(filename,NULL,D3D_COMPILE_STANDARD_FILE_INCLUDE,"main","ds_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error);
|
||||||
break;
|
break;
|
||||||
case Oyster::Graphics::Core::ShaderManager::Geometry:
|
case Oyster::Graphics::Core::PipelineManager::Geometry:
|
||||||
hr = D3DCompileFromFile(filename,NULL,D3D_COMPILE_STANDARD_FILE_INCLUDE,"main","gs_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error);
|
hr = D3DCompileFromFile(filename,NULL,D3D_COMPILE_STANDARD_FILE_INCLUDE,"main","gs_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error);
|
||||||
break;
|
break;
|
||||||
case Oyster::Graphics::Core::ShaderManager::Pixel:
|
case Oyster::Graphics::Core::PipelineManager::Pixel:
|
||||||
hr = D3DCompileFromFile(filename,NULL,D3D_COMPILE_STANDARD_FILE_INCLUDE,"main","ps_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error);
|
hr = D3DCompileFromFile(filename,NULL,D3D_COMPILE_STANDARD_FILE_INCLUDE,"main","ps_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error);
|
||||||
break;
|
break;
|
||||||
case Oyster::Graphics::Core::ShaderManager::Compute:
|
case Oyster::Graphics::Core::PipelineManager::Compute:
|
||||||
hr = D3DCompileFromFile(filename,NULL,D3D_COMPILE_STANDARD_FILE_INCLUDE,"main","cs_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error);
|
hr = D3DCompileFromFile(filename,NULL,D3D_COMPILE_STANDARD_FILE_INCLUDE,"main","cs_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -185,7 +185,7 @@ namespace Oyster
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
out.loadedData = Core::ShaderManager::CreateShader(data, Core::ShaderManager::ShaderType(type));
|
out.loadedData = Core::PipelineManager::CreateShader(data, Core::PipelineManager::ShaderType(type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,14 +174,15 @@
|
||||||
<ClCompile Include="Core\Buffer.cpp" />
|
<ClCompile Include="Core\Buffer.cpp" />
|
||||||
<ClCompile Include="Core\Core.cpp" />
|
<ClCompile Include="Core\Core.cpp" />
|
||||||
<ClCompile Include="Core\Init.cpp" />
|
<ClCompile Include="Core\Init.cpp" />
|
||||||
<ClCompile Include="Core\ShaderManager.cpp" />
|
<ClCompile Include="Core\PipelineManager.cpp" />
|
||||||
<ClCompile Include="DllInterfaces\GFXAPI.cpp" />
|
<ClCompile Include="DllInterfaces\GFXAPI.cpp" />
|
||||||
<ClCompile Include="FileLoader\ObjReader.cpp" />
|
<ClCompile Include="FileLoader\ObjReader.cpp" />
|
||||||
<ClCompile Include="FileLoader\ShaderLoader.cpp" />
|
<ClCompile Include="FileLoader\ShaderLoader.cpp" />
|
||||||
<ClCompile Include="FileLoader\ModelLoader.cpp" />
|
<ClCompile Include="FileLoader\ModelLoader.cpp" />
|
||||||
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
|
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
|
||||||
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
|
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
|
||||||
<ClCompile Include="Render\Resources\Resources.cpp" />
|
<ClCompile Include="Render\Resources\Deffered.cpp" />
|
||||||
|
<ClCompile Include="Render\Resources\Debug.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Core\Core.h" />
|
<ClInclude Include="Core\Core.h" />
|
||||||
|
@ -194,7 +195,8 @@
|
||||||
<ClInclude Include="Render\Preparations\Preparations.h" />
|
<ClInclude Include="Render\Preparations\Preparations.h" />
|
||||||
<ClInclude Include="Render\Rendering\Render.h" />
|
<ClInclude Include="Render\Rendering\Render.h" />
|
||||||
<ClInclude Include="Definitions\GraphicalDefinition.h" />
|
<ClInclude Include="Definitions\GraphicalDefinition.h" />
|
||||||
<ClInclude Include="Render\Resources\Resources.h" />
|
<ClInclude Include="Render\Resources\Deffered.h" />
|
||||||
|
<ClInclude Include="Render\Resources\Debug.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
||||||
|
@ -205,29 +207,23 @@
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<FxCompile Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\PixelGatherData.hlsl">
|
<FxCompile Include="Shader\HLSL\Deffered Shaders\LightPass.hlsl">
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
|
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
|
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
|
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
|
||||||
</FxCompile>
|
|
||||||
<FxCompile Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\VertexGatherData.hlsl">
|
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
|
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
|
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
|
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
|
||||||
</FxCompile>
|
|
||||||
<FxCompile Include="Shader\HLSL\Deffered Shaders\Render\LightPass.hlsl">
|
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0</ShaderModel>
|
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compute</ShaderType>
|
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0</ShaderModel>
|
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compute</ShaderType>
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compute</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compute</ShaderType>
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0</ShaderModel>
|
</FxCompile>
|
||||||
|
<FxCompile Include="Shader\HLSL\Deffered Shaders\PixelGatherData.hlsl">
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
|
||||||
|
</FxCompile>
|
||||||
|
<FxCompile Include="Shader\HLSL\Deffered Shaders\VertexGatherData.hlsl">
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl">
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl">
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
||||||
|
@ -268,10 +264,10 @@
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\GBufferHeader.hlsli" />
|
<None Include="Shader\HLSL\Deffered Shaders\Defines.hlsli" />
|
||||||
<None Include="Shader\HLSL\Deffered Shaders\Render\Defines.hlsli" />
|
<None Include="Shader\HLSL\Deffered Shaders\GBufferHeader.hlsli" />
|
||||||
<None Include="Shader\HLSL\Deffered Shaders\Render\LightCalc.hlsli" />
|
<None Include="Shader\HLSL\Deffered Shaders\LightCalc.hlsli" />
|
||||||
<None Include="Shader\HLSL\Deffered Shaders\Render\PosManipulation.hlsli" />
|
<None Include="Shader\HLSL\Deffered Shaders\PosManipulation.hlsli" />
|
||||||
<None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" />
|
<None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|
|
@ -21,9 +21,6 @@
|
||||||
<ClCompile Include="Core\Core.cpp">
|
<ClCompile Include="Core\Core.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Core\ShaderManager.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Core\Init.cpp">
|
<ClCompile Include="Core\Init.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -33,21 +30,27 @@
|
||||||
<ClCompile Include="Render\Preparations\BasicPreparations.cpp">
|
<ClCompile Include="Render\Preparations\BasicPreparations.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Render\Resources\Resources.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="FileLoader\ObjReader.cpp">
|
<ClCompile Include="FileLoader\ObjReader.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="FileLoader\TextureLoader.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="DllInterfaces\GFXAPI.cpp">
|
<ClCompile Include="DllInterfaces\GFXAPI.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="FileLoader\ShaderLoader.cpp">
|
<ClCompile Include="FileLoader\ShaderLoader.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="FileLoader\ModelLoader.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Render\Resources\Deffered.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Render\Resources\Debug.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Core\PipelineManager.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Core\Core.h">
|
<ClInclude Include="Core\Core.h">
|
||||||
|
@ -65,9 +68,6 @@
|
||||||
<ClInclude Include="Model\Model.h">
|
<ClInclude Include="Model\Model.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Render\Resources\Resources.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Definitions\GraphicalDefinition.h">
|
<ClInclude Include="Definitions\GraphicalDefinition.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -83,19 +83,27 @@
|
||||||
<ClInclude Include="FileLoader\GeneralLoader.h">
|
<ClInclude Include="FileLoader\GeneralLoader.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Render\Resources\Deffered.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Render\Resources\Debug.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugVertex.hlsl" />
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugVertex.hlsl" />
|
||||||
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl" />
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl" />
|
||||||
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl" />
|
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl" />
|
||||||
<FxCompile Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\PixelGatherData.hlsl" />
|
|
||||||
<FxCompile Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\VertexGatherData.hlsl" />
|
|
||||||
<FxCompile Include="Shader\HLSL\SimpleDebug\TextureDebug.hlsl" />
|
<FxCompile Include="Shader\HLSL\SimpleDebug\TextureDebug.hlsl" />
|
||||||
<FxCompile Include="Shader\HLSL\Deffered Shaders\Render\LightPass.hlsl" />
|
<FxCompile Include="Shader\HLSL\Deffered Shaders\LightPass.hlsl" />
|
||||||
|
<FxCompile Include="Shader\HLSL\Deffered Shaders\PixelGatherData.hlsl" />
|
||||||
|
<FxCompile Include="Shader\HLSL\Deffered Shaders\VertexGatherData.hlsl" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Shader\HLSL\Deffered Shaders\GatherGBuffer\GBufferHeader.hlsli" />
|
|
||||||
<None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" />
|
<None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" />
|
||||||
<None Include="Shader\HLSL\Deffered Shaders\Render\Defines.hlsli" />
|
<None Include="Shader\HLSL\Deffered Shaders\Defines.hlsli" />
|
||||||
|
<None Include="Shader\HLSL\Deffered Shaders\GBufferHeader.hlsli" />
|
||||||
|
<None Include="Shader\HLSL\Deffered Shaders\LightCalc.hlsli" />
|
||||||
|
<None Include="Shader\HLSL\Deffered Shaders\PosManipulation.hlsli" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -1,5 +1,5 @@
|
||||||
#include "Render.h"
|
#include "Render.h"
|
||||||
#include "../Resources/Resources.h"
|
#include "../Resources/Deffered.h"
|
||||||
#include "../../Definitions/GraphicalDefinition.h"
|
#include "../../Definitions/GraphicalDefinition.h"
|
||||||
#include "../../Model/ModelInfo.h"
|
#include "../../Model/ModelInfo.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -13,22 +13,34 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
namespace Rendering
|
namespace Rendering
|
||||||
{
|
{
|
||||||
|
Definitions::Pointlight pl;
|
||||||
|
|
||||||
void Basic::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection)
|
void Basic::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights)
|
||||||
{
|
{
|
||||||
Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(1,0,0,1));
|
Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(1,0,0,1));
|
||||||
Core::ShaderManager::SetShaderEffect(Graphics::Render::Resources::obj);
|
Preparations::Basic::ClearRTV(Resources::Deffered::GBufferRTV,Resources::Deffered::GBufferSize,Math::Float4(1,0,0,1));
|
||||||
Preparations::Basic::BindBackBufferRTV();
|
Core::PipelineManager::SetRenderPass(Graphics::Render::Resources::Deffered::GeometryPass);
|
||||||
|
|
||||||
Definitions::VP vp;
|
Definitions::VP vp;
|
||||||
vp.V = View;
|
vp.V = View;
|
||||||
vp.P = Projection;
|
vp.P = Projection;
|
||||||
|
|
||||||
void* data = Resources::VPData.Map();
|
void* data = Resources::Deffered::VPData.Map();
|
||||||
memcpy(data, &vp, sizeof(Definitions::VP));
|
memcpy(data, &vp, sizeof(Definitions::VP));
|
||||||
Resources::VPData.Unmap();
|
Resources::Deffered::VPData.Unmap();
|
||||||
|
|
||||||
Resources::VPData.Apply();
|
Definitions::LightConstants lc;
|
||||||
|
lc.InvProj = Projection.GetInverse();
|
||||||
|
lc.Pixels = Core::resolution;
|
||||||
|
lc.Lights = numLights;
|
||||||
|
|
||||||
|
data = Resources::Deffered::LightConstantsData.Map();
|
||||||
|
memcpy(data, &lc, sizeof(Definitions::LightConstants));
|
||||||
|
Resources::Deffered::LightConstantsData.Unmap();
|
||||||
|
|
||||||
|
data = Resources::Deffered::PointLightsData.Map();
|
||||||
|
memcpy(data, Lights, sizeof(Definitions::Pointlight) * numLights);
|
||||||
|
Resources::Deffered::PointLightsData.Unmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Basic::RenderScene(Model::Model* models, int count)
|
void Basic::RenderScene(Model::Model* models, int count)
|
||||||
|
@ -37,14 +49,17 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
if(models[i].Visible)
|
if(models[i].Visible)
|
||||||
{
|
{
|
||||||
void* data = Resources::ModelData.Map();
|
void* data = Resources::Deffered::ModelData.Map();
|
||||||
memcpy(data,&(models[i].WorldMatrix),sizeof(Math::Float4x4));
|
memcpy(data,&(models[i].WorldMatrix),sizeof(Math::Float4x4));
|
||||||
Resources::ModelData.Unmap();
|
Resources::Deffered::ModelData.Unmap();
|
||||||
|
|
||||||
|
|
||||||
Model::ModelInfo* info = (Model::ModelInfo*)models[i].info;
|
Model::ModelInfo* info = (Model::ModelInfo*)models[i].info;
|
||||||
|
|
||||||
Core::deviceContext->PSSetShaderResources(0,info->Material.size(),&(info->Material[0]));
|
if(info->Material.size())
|
||||||
|
{
|
||||||
|
Core::deviceContext->PSSetShaderResources(0,info->Material.size(),&(info->Material[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
info->Vertices->Apply();
|
info->Vertices->Apply();
|
||||||
|
@ -62,8 +77,11 @@ namespace Oyster
|
||||||
}
|
}
|
||||||
void Basic::EndFrame()
|
void Basic::EndFrame()
|
||||||
{
|
{
|
||||||
IDXGISwapChain* chain = Core::swapChain;
|
Core::PipelineManager::SetRenderPass(Resources::Deffered::LightPass);
|
||||||
chain->Present(0,0);
|
|
||||||
|
Core::deviceContext->Dispatch((Core::resolution.x + 15U) / 16U,(Core::resolution.y + 15U) / 16U,1);
|
||||||
|
|
||||||
|
Core::swapChain->Present(0,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "..\..\Definitions\GraphicalDefinition.h"
|
||||||
#include "..\..\Core\Core.h"
|
#include "..\..\Core\Core.h"
|
||||||
#include "..\Preparations\Preparations.h"
|
#include "..\Preparations\Preparations.h"
|
||||||
#include "..\..\Model\Model.h"
|
#include "..\..\Model\Model.h"
|
||||||
|
@ -16,7 +16,7 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection);
|
static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights);
|
||||||
static void RenderScene(Model::Model* models, int count);
|
static void RenderScene(Model::Model* models, int count);
|
||||||
static void EndFrame();
|
static void EndFrame();
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
#include "Debug.h"
|
||||||
|
#include "..\OysterGraphics\Definitions\GraphicalDefinition.h"
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
// /Bin/Executable/Tester ->
|
||||||
|
// /Code/OysterGraphics/Shader/HLSL
|
||||||
|
const std::wstring PathFromExeToCso = L"..\\Content\\Shaders\\";
|
||||||
|
const std::wstring PathFromExeToHlsl = L"..\\..\\Code\\OysterGraphics\\Shader\\HLSL\\";
|
||||||
|
const std::wstring VertexTransformDebug = L"TransformDebugVertex";
|
||||||
|
const std::wstring VertexDebug = L"DebugVertex";
|
||||||
|
const std::wstring PixelRed = L"DebugPixel";
|
||||||
|
const std::wstring PixelTexture = L"Texture";
|
||||||
|
const std::wstring ComputeDebug = L"Debug";
|
||||||
|
|
||||||
|
typedef Oyster::Graphics::Core::PipelineManager::ShaderType ShaderType;
|
||||||
|
typedef Oyster::Graphics::Core::PipelineManager::Get GetShader;
|
||||||
|
typedef Oyster::Graphics::Core::PipelineManager Shader;
|
||||||
|
typedef Oyster::Graphics::Core::Buffer Buffer;
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
//Shader::RenderPass Resources::Debug::obj;
|
||||||
|
Shader::RenderPass Resources::Debug::debugCompute;// = Shader::ShaderEffect();;
|
||||||
|
//Buffer Resources::Debug::ModelData = Buffer();
|
||||||
|
//Buffer Resources::Debug::VPData = Buffer();
|
||||||
|
|
||||||
|
//ID3D11ShaderResourceView* Resources::Debug::srv = NULL;
|
||||||
|
//ID3D11RenderTargetView* Resources::Debug::rtv = NULL;
|
||||||
|
|
||||||
|
Core::Init::State Resources::Debug::Init()
|
||||||
|
{
|
||||||
|
|
||||||
|
#pragma region LoadShaders
|
||||||
|
/** Load Compute Shaders for d3dcompile */
|
||||||
|
Core::PipelineManager::Init(PathFromExeToHlsl + L"ComputeDebug\\" + L"DebugCompute.hlsl", ShaderType::Compute, ComputeDebug);
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
return Core::Init::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Resources::Debug::Clean()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,39 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef Reources_h
|
||||||
|
#define Reources_h
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
|
||||||
|
#include "../OysterGraphics/Core/Core.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
namespace Resources
|
||||||
|
{
|
||||||
|
class Debug
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//static Core::PipelineManager::RenderPass obj;
|
||||||
|
static Core::PipelineManager::RenderPass debugCompute;
|
||||||
|
//static Core::Buffer ModelData;
|
||||||
|
//static Core::Buffer VPData;
|
||||||
|
|
||||||
|
//static ID3D11ShaderResourceView* srv;
|
||||||
|
//static ID3D11RenderTargetView* rtv;
|
||||||
|
|
||||||
|
static Core::Init::State Init();
|
||||||
|
static void Clean();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,227 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Deffered.h"
|
||||||
|
#include "..\..\Definitions\GraphicalDefinition.h"
|
||||||
|
|
||||||
|
typedef Oyster::Graphics::Core::PipelineManager::ShaderType ShaderType;
|
||||||
|
typedef Oyster::Graphics::Core::PipelineManager::Get GetShader;
|
||||||
|
typedef Oyster::Graphics::Core::PipelineManager Shader;
|
||||||
|
typedef Oyster::Graphics::Core::Buffer Buffer;
|
||||||
|
|
||||||
|
const std::wstring PathToHLSL = L"..\\..\\Code\\OysterGraphics\\Shader\\HLSL\\Deffered Shaders\\";
|
||||||
|
const std::wstring PathToCSO = L"..\\Content\\Shaders\\";
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
namespace Resources
|
||||||
|
{
|
||||||
|
|
||||||
|
ID3D11RenderTargetView* Deffered::GBufferRTV[2] = {0};
|
||||||
|
ID3D11ShaderResourceView* Deffered::GBufferSRV[2] = {0};
|
||||||
|
|
||||||
|
|
||||||
|
Shader::RenderPass Deffered::GeometryPass;
|
||||||
|
Shader::RenderPass Deffered::LightPass;
|
||||||
|
|
||||||
|
Buffer Deffered::ModelData = Buffer();
|
||||||
|
Buffer Deffered::VPData = Buffer();
|
||||||
|
Buffer Deffered::LightConstantsData = Buffer();
|
||||||
|
|
||||||
|
Buffer Deffered::PointLightsData = Buffer();
|
||||||
|
ID3D11ShaderResourceView* Deffered::PointLightView = NULL;
|
||||||
|
|
||||||
|
Core::Init::State Deffered::Init()
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
std::wstring path = PathToHLSL;
|
||||||
|
std::wstring end = L".hlsl";
|
||||||
|
#else
|
||||||
|
std::wstring path = PathToCSO;
|
||||||
|
std::wstring end = L".cso";
|
||||||
|
#endif
|
||||||
|
//Load Shaders
|
||||||
|
Core::PipelineManager::Init(path + L"PixelGatherData" + end, ShaderType::Pixel, L"Geometry");
|
||||||
|
Core::PipelineManager::Init(path + L"VertexGatherData" + end, ShaderType::Vertex, L"Geometry");
|
||||||
|
Core::PipelineManager::Init(path + L"LightPass" + end, ShaderType::Compute, L"LightPass");
|
||||||
|
|
||||||
|
//Create Buffers
|
||||||
|
Buffer::BUFFER_INIT_DESC desc;
|
||||||
|
desc.ElementSize = sizeof(Oyster::Math::Matrix);
|
||||||
|
desc.NumElements = 1;
|
||||||
|
desc.InitData = NULL;
|
||||||
|
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_VS;
|
||||||
|
desc.Usage = Buffer::BUFFER_USAGE::BUFFER_CPU_WRITE_DISCARD;
|
||||||
|
|
||||||
|
ModelData.Init(desc);
|
||||||
|
|
||||||
|
desc.NumElements = 2;
|
||||||
|
VPData.Init(desc);
|
||||||
|
|
||||||
|
desc.ElementSize = sizeof(Definitions::LightConstants);
|
||||||
|
desc.NumElements = 1;
|
||||||
|
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_CS;
|
||||||
|
|
||||||
|
LightConstantsData.Init(desc);
|
||||||
|
|
||||||
|
desc.ElementSize = sizeof(Definitions::Pointlight);
|
||||||
|
desc.NumElements = MaxLightSize;
|
||||||
|
desc.Type = Buffer::STRUCTURED_BUFFER;
|
||||||
|
PointLightsData.Init(desc);
|
||||||
|
|
||||||
|
//Create States
|
||||||
|
D3D11_RASTERIZER_DESC rdesc;
|
||||||
|
rdesc.CullMode = D3D11_CULL_BACK;
|
||||||
|
rdesc.FillMode = D3D11_FILL_SOLID;
|
||||||
|
rdesc.FrontCounterClockwise = true;
|
||||||
|
rdesc.DepthBias = 0;
|
||||||
|
rdesc.DepthBiasClamp = 0;
|
||||||
|
rdesc.DepthClipEnable = true;
|
||||||
|
rdesc.SlopeScaledDepthBias = 0;
|
||||||
|
rdesc.ScissorEnable = false;
|
||||||
|
rdesc.MultisampleEnable = false;
|
||||||
|
rdesc.AntialiasedLineEnable = false;
|
||||||
|
|
||||||
|
ID3D11RasterizerState* rs = NULL;
|
||||||
|
Oyster::Graphics::Core::device->CreateRasterizerState(&rdesc,&rs);
|
||||||
|
|
||||||
|
D3D11_SAMPLER_DESC sdesc;
|
||||||
|
sdesc.Filter = D3D11_FILTER_ANISOTROPIC;
|
||||||
|
sdesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||||
|
sdesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||||
|
sdesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||||
|
sdesc.MipLODBias = 0;
|
||||||
|
sdesc.MaxAnisotropy =4;
|
||||||
|
sdesc.ComparisonFunc = D3D11_COMPARISON_LESS_EQUAL;
|
||||||
|
*sdesc.BorderColor = *Oyster::Math::Float4(1,1,1,1).element;
|
||||||
|
sdesc.MinLOD = 0;
|
||||||
|
sdesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||||
|
|
||||||
|
ID3D11SamplerState** ss = new ID3D11SamplerState*[1];
|
||||||
|
Oyster::Graphics::Core::device->CreateSamplerState(&sdesc,ss);
|
||||||
|
|
||||||
|
D3D11_DEPTH_STENCIL_DESC ddesc;
|
||||||
|
ddesc.DepthEnable = true;
|
||||||
|
ddesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
||||||
|
ddesc.DepthFunc = D3D11_COMPARISON_LESS;
|
||||||
|
|
||||||
|
ddesc.StencilEnable = true;
|
||||||
|
ddesc.StencilReadMask = 0xFF;
|
||||||
|
ddesc.StencilWriteMask = 0xFF;
|
||||||
|
|
||||||
|
ddesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
||||||
|
ddesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
|
||||||
|
ddesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
||||||
|
ddesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
||||||
|
|
||||||
|
ddesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
||||||
|
ddesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
|
||||||
|
ddesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
||||||
|
ddesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
||||||
|
|
||||||
|
ID3D11DepthStencilState* dsState;
|
||||||
|
Core::device->CreateDepthStencilState(&ddesc,&dsState);
|
||||||
|
|
||||||
|
//Create Views
|
||||||
|
for(int i = 0; i< Resources::Deffered::GBufferSize; ++i)
|
||||||
|
{
|
||||||
|
Core::Init::CreateLinkedShaderResourceFromTexture(&GBufferRTV[i],&GBufferSRV[i],NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
Buffer* b = &PointLightsData;
|
||||||
|
|
||||||
|
Core::Init::CreateLinkedShaderResourceFromStructuredBuffer(&b,&PointLightView,NULL);
|
||||||
|
|
||||||
|
//Create ShaderEffects
|
||||||
|
GeometryPass.Shaders.Pixel = GetShader::Pixel(L"Geometry");
|
||||||
|
GeometryPass.Shaders.Vertex = GetShader::Vertex(L"Geometry");
|
||||||
|
|
||||||
|
D3D11_INPUT_ELEMENT_DESC indesc[] =
|
||||||
|
{
|
||||||
|
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
|
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
|
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
Shader::CreateInputLayout(indesc,3,GetShader::Vertex(L"Geometry"),GeometryPass.IAStage.Layout);
|
||||||
|
GeometryPass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
||||||
|
GeometryPass.CBuffers.Vertex.push_back(VPData);
|
||||||
|
GeometryPass.CBuffers.Vertex.push_back(ModelData);
|
||||||
|
GeometryPass.RenderStates.Rasterizer = rs;
|
||||||
|
GeometryPass.RenderStates.SampleCount = 1;
|
||||||
|
GeometryPass.RenderStates.SampleState = ss;
|
||||||
|
GeometryPass.RenderStates.DepthStencil = dsState;
|
||||||
|
for(int i = 0; i<Deffered::GBufferSize;++i)
|
||||||
|
{
|
||||||
|
GeometryPass.RTV.push_back(GBufferRTV[i]);
|
||||||
|
}
|
||||||
|
GeometryPass.depth = Core::depthStencil;
|
||||||
|
|
||||||
|
LightPass.Shaders.Compute = GetShader::Compute(L"LightPass");
|
||||||
|
LightPass.UAV.Compute.push_back(Core::backBufferUAV);
|
||||||
|
for(int i = 0; i<Deffered::GBufferSize;++i)
|
||||||
|
{
|
||||||
|
LightPass.SRV.Compute.push_back(GBufferSRV[i]);
|
||||||
|
}
|
||||||
|
LightPass.SRV.Compute.push_back(Core::depthStencilUAV);
|
||||||
|
LightPass.CBuffers.Compute.push_back(LightConstantsData);
|
||||||
|
LightPass.SRV.Compute.push_back(PointLightView);
|
||||||
|
|
||||||
|
|
||||||
|
return Core::Init::State::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Deffered::Clean()
|
||||||
|
{
|
||||||
|
Resources::Deffered::ModelData.~Buffer();
|
||||||
|
Resources::Deffered::VPData.~Buffer();
|
||||||
|
Resources::Deffered::LightConstantsData.~Buffer();
|
||||||
|
Resources::Deffered::PointLightsData.~Buffer();
|
||||||
|
|
||||||
|
for(int i = 0; i< GBufferSize; ++i)
|
||||||
|
{
|
||||||
|
SAFE_RELEASE(GBufferRTV[i]);
|
||||||
|
SAFE_RELEASE(GBufferSRV[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for(int i = 0; i < (int)GeometryPass.CBuffers.Vertex.size(); ++i)
|
||||||
|
{
|
||||||
|
SAFE_RELEASE(GeometryPass.CBuffers.Vertex[i]);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < (int)GeometryPass.CBuffers.Pixel.size(); ++i)
|
||||||
|
{
|
||||||
|
SAFE_RELEASE(GeometryPass.CBuffers.Pixel[i]);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < (int)GeometryPass.CBuffers.Geometry.size(); ++i)
|
||||||
|
{
|
||||||
|
SAFE_RELEASE(GeometryPass.CBuffers.Geometry[i]);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < (int)GeometryPass.CBuffers.Compute.size(); ++i)
|
||||||
|
{
|
||||||
|
SAFE_RELEASE(GeometryPass.CBuffers.Compute[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
SAFE_RELEASE(GeometryPass.IAStage.Layout);
|
||||||
|
|
||||||
|
SAFE_RELEASE(GeometryPass.RenderStates.BlendState);
|
||||||
|
|
||||||
|
SAFE_RELEASE(GeometryPass.RenderStates.DepthStencil);
|
||||||
|
|
||||||
|
SAFE_RELEASE(GeometryPass.RenderStates.Rasterizer);
|
||||||
|
|
||||||
|
for(int i = 0; i < GeometryPass.RenderStates.SampleCount; ++i)
|
||||||
|
{
|
||||||
|
SAFE_RELEASE(GeometryPass.RenderStates.SampleState[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
SAFE_DELETE_ARRAY(GeometryPass.RenderStates.SampleState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../../Core/Core.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Graphics
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
namespace Resources
|
||||||
|
{
|
||||||
|
class Deffered
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
static const int GBufferSize = 2;
|
||||||
|
static const int MaxLightSize = 100;
|
||||||
|
//! GBuffers
|
||||||
|
//! 0 = Diffuse + SpecKoeff
|
||||||
|
//! 1 = Normal + Glow
|
||||||
|
static ID3D11RenderTargetView* GBufferRTV[GBufferSize];
|
||||||
|
static ID3D11ShaderResourceView* GBufferSRV[GBufferSize];
|
||||||
|
|
||||||
|
static Core::PipelineManager::RenderPass GeometryPass;
|
||||||
|
static Core::PipelineManager::RenderPass LightPass;
|
||||||
|
|
||||||
|
static Core::Buffer ModelData;
|
||||||
|
static Core::Buffer VPData;
|
||||||
|
|
||||||
|
static Core::Buffer LightConstantsData;
|
||||||
|
|
||||||
|
static Core::Buffer PointLightsData;
|
||||||
|
static ID3D11ShaderResourceView* PointLightView;
|
||||||
|
|
||||||
|
static Core::Init::State Init();
|
||||||
|
static void Clean();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,192 +0,0 @@
|
||||||
#include "Resources.h"
|
|
||||||
#include "..\OysterGraphics\Definitions\GraphicalDefinition.h"
|
|
||||||
|
|
||||||
// /Bin/Executable/Tester ->
|
|
||||||
// /Code/OysterGraphics/Shader/HLSL
|
|
||||||
const std::wstring PathFromExeToCso = L"..\\Content\\Shaders\\";
|
|
||||||
const std::wstring PathFromExeToHlsl = L"..\\..\\Code\\OysterGraphics\\Shader\\HLSL\\";
|
|
||||||
const std::wstring VertexTransformDebug = L"TransformDebugVertex";
|
|
||||||
const std::wstring VertexDebug = L"DebugVertex";
|
|
||||||
const std::wstring PixelRed = L"DebugPixel";
|
|
||||||
const std::wstring PixelTexture = L"Texture";
|
|
||||||
|
|
||||||
typedef Oyster::Graphics::Core::ShaderManager::ShaderType ShaderType;
|
|
||||||
typedef Oyster::Graphics::Core::ShaderManager::Get GetShader;
|
|
||||||
typedef Oyster::Graphics::Core::ShaderManager Shader;
|
|
||||||
typedef Oyster::Graphics::Core::Buffer Buffer;
|
|
||||||
|
|
||||||
namespace Oyster
|
|
||||||
{
|
|
||||||
namespace Graphics
|
|
||||||
{
|
|
||||||
namespace Render
|
|
||||||
{
|
|
||||||
Shader::ShaderEffect Resources::obj;// = Shader::ShaderEffect();;
|
|
||||||
Buffer Resources::ModelData = Buffer();
|
|
||||||
Buffer Resources::VPData = Buffer();
|
|
||||||
|
|
||||||
Core::Init::State Resources::Init()
|
|
||||||
{
|
|
||||||
|
|
||||||
#pragma region LoadShaders
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
|
|
||||||
/** Load Vertex Shader for d3dcompile*/
|
|
||||||
Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" +L"DebugCameraVertex.hlsl",ShaderType::Vertex, VertexTransformDebug);
|
|
||||||
Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" +L"DebugVertex.hlsl",ShaderType::Vertex, VertexDebug);
|
|
||||||
|
|
||||||
/** Load Pixel Shader for d3dcompile */
|
|
||||||
Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" + L"DebugPixel.hlsl", ShaderType::Pixel, PixelRed);
|
|
||||||
Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" + L"TextureDebug.hlsl", ShaderType::Pixel, PixelTexture);
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
/** Load Vertex Shader with Precompiled */
|
|
||||||
Core::ShaderManager::Init(PathFromExeToCso + L"DebugCameraVertex.cso",ShaderType::Vertex, VertexTransformDebug);
|
|
||||||
Core::ShaderManager::Init(PathFromExeToCso + L"DebugVertex.cso",ShaderType::Vertex, VertexDebug);
|
|
||||||
|
|
||||||
/** Load Pixel Shader with Precompiled */
|
|
||||||
Core::ShaderManager::Init(PathFromExeToCso + L"DebugPixel.cso",ShaderType::Pixel, PixelRed);
|
|
||||||
Core::ShaderManager::Init(PathFromExeToCso + L"TextureDebug.cso",ShaderType::Pixel, PixelTexture);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
#pragma region CreateBuffers
|
|
||||||
Buffer::BUFFER_INIT_DESC desc;
|
|
||||||
desc.ElementSize = sizeof(Oyster::Math::Matrix);
|
|
||||||
desc.NumElements = 1;
|
|
||||||
desc.InitData = NULL;
|
|
||||||
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_VS;
|
|
||||||
desc.Usage = Buffer::BUFFER_USAGE::BUFFER_CPU_WRITE_DISCARD;
|
|
||||||
|
|
||||||
ModelData.Init(desc);
|
|
||||||
|
|
||||||
desc.NumElements = 2;
|
|
||||||
VPData.Init(desc);
|
|
||||||
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
#pragma region Setup Render States
|
|
||||||
/** @todo Create DX States */
|
|
||||||
|
|
||||||
D3D11_RASTERIZER_DESC rdesc;
|
|
||||||
rdesc.CullMode = D3D11_CULL_BACK;
|
|
||||||
rdesc.FillMode = D3D11_FILL_SOLID;
|
|
||||||
rdesc.FrontCounterClockwise = true;
|
|
||||||
rdesc.DepthBias = 0;
|
|
||||||
rdesc.DepthBiasClamp = 0;
|
|
||||||
rdesc.DepthClipEnable = true;
|
|
||||||
rdesc.SlopeScaledDepthBias = 0;
|
|
||||||
rdesc.ScissorEnable = false;
|
|
||||||
rdesc.MultisampleEnable = false;
|
|
||||||
rdesc.AntialiasedLineEnable = false;
|
|
||||||
|
|
||||||
ID3D11RasterizerState* rs = NULL;
|
|
||||||
Oyster::Graphics::Core::device->CreateRasterizerState(&rdesc,&rs);
|
|
||||||
|
|
||||||
D3D11_SAMPLER_DESC sdesc;
|
|
||||||
sdesc.Filter = D3D11_FILTER_ANISOTROPIC;
|
|
||||||
/// @todo parata med fredrik om wraping
|
|
||||||
sdesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
|
||||||
sdesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
|
||||||
sdesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
|
||||||
sdesc.MipLODBias = 0;
|
|
||||||
sdesc.MaxAnisotropy =4;
|
|
||||||
sdesc.ComparisonFunc = D3D11_COMPARISON_LESS_EQUAL;
|
|
||||||
*sdesc.BorderColor = *Oyster::Math::Float4(1,1,1,1).element;
|
|
||||||
sdesc.MinLOD = 0;
|
|
||||||
sdesc.MaxLOD = D3D11_FLOAT32_MAX;
|
|
||||||
|
|
||||||
ID3D11SamplerState** ss = new ID3D11SamplerState*[1];
|
|
||||||
Oyster::Graphics::Core::device->CreateSamplerState(&sdesc,ss);
|
|
||||||
|
|
||||||
D3D11_DEPTH_STENCIL_DESC ddesc;
|
|
||||||
ddesc.DepthEnable = true;
|
|
||||||
ddesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
|
||||||
ddesc.DepthFunc = D3D11_COMPARISON_LESS;
|
|
||||||
|
|
||||||
ddesc.StencilEnable = true;
|
|
||||||
ddesc.StencilReadMask = 0xFF;
|
|
||||||
ddesc.StencilWriteMask = 0xFF;
|
|
||||||
|
|
||||||
ddesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
|
||||||
ddesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
|
|
||||||
ddesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
|
||||||
ddesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
|
||||||
|
|
||||||
ddesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
|
||||||
ddesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
|
|
||||||
ddesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
|
||||||
ddesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
|
||||||
|
|
||||||
ID3D11DepthStencilState* dsState;
|
|
||||||
Core::device->CreateDepthStencilState(&ddesc,&dsState);
|
|
||||||
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
#pragma region Setup Views
|
|
||||||
/** @todo Create Views */
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
#pragma region Create Shader Effects
|
|
||||||
/** @todo Create ShaderEffects */
|
|
||||||
obj.Shaders.Pixel = GetShader::Pixel(PixelTexture);
|
|
||||||
obj.Shaders.Vertex = GetShader::Vertex(VertexTransformDebug);
|
|
||||||
|
|
||||||
D3D11_INPUT_ELEMENT_DESC indesc[] =
|
|
||||||
{
|
|
||||||
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
|
||||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
|
||||||
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 }
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
Shader::CreateInputLayout(indesc,3,GetShader::Vertex(VertexTransformDebug),obj.IAStage.Layout);
|
|
||||||
obj.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
|
||||||
obj.CBuffers.Vertex.push_back(&VPData);
|
|
||||||
obj.RenderStates.Rasterizer = rs;
|
|
||||||
obj.RenderStates.SampleCount = 1;
|
|
||||||
obj.RenderStates.SampleState = ss;
|
|
||||||
obj.RenderStates.DepthStencil = dsState;
|
|
||||||
|
|
||||||
ModelData.Apply(1);
|
|
||||||
#pragma endregion
|
|
||||||
return Core::Init::Sucsess;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Resources::Clean()
|
|
||||||
{
|
|
||||||
Resources::ModelData.~Buffer();
|
|
||||||
for(int i = 0; i < obj.CBuffers.Vertex.size(); ++i)
|
|
||||||
{
|
|
||||||
obj.CBuffers.Vertex[i]->~Buffer();
|
|
||||||
}
|
|
||||||
for(int i = 0; i < obj.CBuffers.Pixel.size(); ++i)
|
|
||||||
{
|
|
||||||
SAFE_DELETE(obj.CBuffers.Pixel[i]);
|
|
||||||
}
|
|
||||||
for(int i = 0; i < obj.CBuffers.Geometry.size(); ++i)
|
|
||||||
{
|
|
||||||
SAFE_DELETE(obj.CBuffers.Geometry[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
SAFE_RELEASE(obj.IAStage.Layout);
|
|
||||||
|
|
||||||
SAFE_RELEASE(obj.RenderStates.BlendState);
|
|
||||||
|
|
||||||
SAFE_RELEASE(obj.RenderStates.DepthStencil);
|
|
||||||
|
|
||||||
SAFE_RELEASE(obj.RenderStates.Rasterizer);
|
|
||||||
|
|
||||||
for(int i = 0; i < obj.RenderStates.SampleCount; ++i)
|
|
||||||
{
|
|
||||||
SAFE_RELEASE(obj.RenderStates.SampleState[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
SAFE_DELETE_ARRAY(obj.RenderStates.SampleState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifndef Reources_h
|
|
||||||
#define Reources_h
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include "../OysterGraphics/Core/Core.h"
|
|
||||||
|
|
||||||
namespace Oyster
|
|
||||||
{
|
|
||||||
namespace Graphics
|
|
||||||
{
|
|
||||||
namespace Render
|
|
||||||
{
|
|
||||||
class Resources
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Core::ShaderManager::ShaderEffect obj;
|
|
||||||
static Core::Buffer ModelData;
|
|
||||||
static Core::Buffer VPData;
|
|
||||||
|
|
||||||
static Core::Init::State Init();
|
|
||||||
static void Clean();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -3,8 +3,10 @@
|
||||||
|
|
||||||
struct PointLight
|
struct PointLight
|
||||||
{
|
{
|
||||||
float4 PosRadius;
|
float3 Pos;
|
||||||
float4 ColorBright;
|
float Radius;
|
||||||
|
float3 Color;
|
||||||
|
float Bright;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DiffSpec
|
struct DiffSpec
|
||||||
|
@ -13,19 +15,21 @@ struct DiffSpec
|
||||||
float3 Specular;
|
float3 Specular;
|
||||||
};
|
};
|
||||||
|
|
||||||
cbuffer PointLights : register(b0)
|
cbuffer LightConstants : register(b0)
|
||||||
{
|
|
||||||
PointLight pl;
|
|
||||||
}
|
|
||||||
|
|
||||||
cbuffer LightConstants : register(b1)
|
|
||||||
{
|
{
|
||||||
float4x4 InvProj;
|
float4x4 InvProj;
|
||||||
int2 Pixels;
|
float2 Pixels;
|
||||||
|
int Lights;
|
||||||
|
float Pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D DiffuseGlow : register(t0);
|
Texture2D DiffuseGlow : register(t0);
|
||||||
Texture2D NormalSpec : register(t1);
|
Texture2D NormalSpec : register(t1);
|
||||||
Texture2D DepthTexture : register(t2);
|
Texture2D DepthTexture : register(t2);
|
||||||
|
|
||||||
|
|
||||||
|
StructuredBuffer<PointLight> Points : register(t3);
|
||||||
|
|
||||||
|
RWTexture2D<float4> Output : register(u0);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -3,10 +3,10 @@ struct VertexIn
|
||||||
float3 pos : POSITION;
|
float3 pos : POSITION;
|
||||||
float2 UV : TEXCOORD;
|
float2 UV : TEXCOORD;
|
||||||
float3 normal : NORMAL;
|
float3 normal : NORMAL;
|
||||||
float3 tangent : TANGENT;
|
//float3 tangent : TANGENT;
|
||||||
float3 biTangent : BITANGENT;
|
//float3 biTangent : BITANGENT;
|
||||||
float4 boneIndex : BONEINDEX;
|
//float4 boneIndex : BONEINDEX;
|
||||||
float4 boneWeight : BONEWEIGHT;
|
//float4 boneWeight : BONEWEIGHT;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VertexOut
|
struct VertexOut
|
||||||
|
@ -15,8 +15,8 @@ struct VertexOut
|
||||||
float4 ViewPos : POSITION;
|
float4 ViewPos : POSITION;
|
||||||
float2 UV : TEXCOORD;
|
float2 UV : TEXCOORD;
|
||||||
float3 normal : NORMAL;
|
float3 normal : NORMAL;
|
||||||
float3 tangent : TANGENT;
|
//float3 tangent : TANGENT;
|
||||||
float3 biTangent : BITANGENT;
|
//float3 biTangent : BITANGENT;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PixelOut
|
struct PixelOut
|
||||||
|
@ -26,7 +26,9 @@ struct PixelOut
|
||||||
};
|
};
|
||||||
|
|
||||||
Texture2D Diffuse : register(t0);
|
Texture2D Diffuse : register(t0);
|
||||||
Texture2D Specular : register(t1);
|
Texture2D Normal : register(t1);
|
||||||
|
|
||||||
|
SamplerState S1 : register(s0);
|
||||||
|
|
||||||
cbuffer PerFrame : register(b0)
|
cbuffer PerFrame : register(b0)
|
||||||
{
|
{
|
|
@ -1,9 +0,0 @@
|
||||||
#include "GBufferHeader.hlsli"
|
|
||||||
|
|
||||||
PixelOut main(VertexOut input)
|
|
||||||
{
|
|
||||||
PixelOut output;
|
|
||||||
output.DiffuseGlow = float4(1.0f, 0.0f, 0.0f, 1.0f);
|
|
||||||
output.NormalSpec = float4(input.normal, 1.0f);
|
|
||||||
return output;
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
#include "GBufferHeader.hlsli"
|
|
||||||
|
|
||||||
VertexOut main( VertexIn input )
|
|
||||||
{
|
|
||||||
VertexOut output;
|
|
||||||
matrix WV = mul(View, World);
|
|
||||||
output.ViewPos = mul(WV, float4(input.pos,1));
|
|
||||||
output.pos = mul(Projection, output.ViewPos);
|
|
||||||
output.UV = input.UV;
|
|
||||||
output.normal = float4(input.normal, 0);
|
|
||||||
return output;
|
|
||||||
}
|
|
|
@ -4,7 +4,7 @@ DiffSpec LightCalc(PointLight pl, float3 pos, int2 texCoord)
|
||||||
{
|
{
|
||||||
DiffSpec output;
|
DiffSpec output;
|
||||||
float4 normalSpec = NormalSpec[texCoord];
|
float4 normalSpec = NormalSpec[texCoord];
|
||||||
float3 lightVec = pl.PosRadius.xyz - pos.xyz;
|
float3 lightVec = pl.Pos - pos.xyz;
|
||||||
float d = length(lightVec);
|
float d = length(lightVec);
|
||||||
lightVec = lightVec/d;
|
lightVec = lightVec/d;
|
||||||
|
|
||||||
|
@ -12,12 +12,17 @@ DiffSpec LightCalc(PointLight pl, float3 pos, int2 texCoord)
|
||||||
float3 v = reflect(-lightVec, normalSpec.xyz);
|
float3 v = reflect(-lightVec, normalSpec.xyz);
|
||||||
float specFactor = pow(max(dot(v,normalize(-pos)), 0.0f),normalSpec.w);
|
float specFactor = pow(max(dot(v,normalize(-pos)), 0.0f),normalSpec.w);
|
||||||
//Check att later
|
//Check att later
|
||||||
float att = (max(d-pl.PosRadius.w,0)/pow(pl.PosRadius.w,2));
|
float att = max( 0, 1 - (d / pl.Radius));
|
||||||
|
//att = 1;
|
||||||
//fix Ilum calcs instead of PhongBlinn
|
//fix Ilum calcs instead of PhongBlinn
|
||||||
output.Diffuse = pl.ColorBright.w * att * diffFactor * pl.ColorBright.xyz;
|
output.Diffuse = pl.Bright * att * diffFactor * pl.Color;
|
||||||
output.Specular = pl.ColorBright.w * att * specFactor * pl.ColorBright.xyz;
|
output.Specular = pl.Bright * att * specFactor * pl.Color;
|
||||||
if(diffFactor == 0)
|
if(diffFactor == 0)
|
||||||
output.Specular * 0;
|
output.Specular * 0;
|
||||||
|
if(d > pl.Radius)
|
||||||
|
{
|
||||||
|
output.Diffuse = float4(0,0,0,1);
|
||||||
|
output.Specular = float4(0,0,0,1);
|
||||||
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
#include "Defines.hlsli"
|
||||||
|
#include "LightCalc.hlsli"
|
||||||
|
#include "PosManipulation.hlsli"
|
||||||
|
//todo
|
||||||
|
//LightCulling
|
||||||
|
//Calc Diff + Spec
|
||||||
|
//Calc Ambience
|
||||||
|
//Write Glow
|
||||||
|
|
||||||
|
|
||||||
|
[numthreads(16, 16, 1)]
|
||||||
|
void main( uint3 DTid : SV_DispatchThreadID )
|
||||||
|
{
|
||||||
|
float3 ViewPos = ToVpos(DTid.xy);
|
||||||
|
DiffSpec Shaded;
|
||||||
|
Shaded.Diffuse = float4(0,0,0,0);
|
||||||
|
Shaded.Specular = float4(0,0,0,0);
|
||||||
|
for(int i = 0; i < Lights; ++i)
|
||||||
|
{
|
||||||
|
DiffSpec light = LightCalc(Points[i], ViewPos, DTid.xy);
|
||||||
|
Shaded.Diffuse = light.Diffuse;
|
||||||
|
Shaded.Specular = light.Specular;
|
||||||
|
}
|
||||||
|
//Output[DTid.xy] = float4(ViewPos,1);
|
||||||
|
//Output[DTid.xy] = DepthTexture[DTid.xy].x;
|
||||||
|
//Output[DTid.xy] = float4(DTid.xy/ Pixels,1,1);
|
||||||
|
//Output[DTid.xy] = NormalSpec[DTid.xy];
|
||||||
|
//Output[DTid.xy] = float4(light.Diffuse, 1);
|
||||||
|
//Output[DTid.xy] = float4(light.Specular, 1);
|
||||||
|
Output[DTid.xy] = float4( Shaded.Diffuse * DiffuseGlow[DTid.xy].xyz + Shaded.Specular + DiffuseGlow[DTid.xy].xyz * 0.2f, 1);
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
#include "GBufferHeader.hlsli"
|
||||||
|
|
||||||
|
PixelOut main(VertexOut input)
|
||||||
|
{
|
||||||
|
PixelOut output;
|
||||||
|
output.DiffuseGlow = Diffuse.Sample(S1, input.UV);
|
||||||
|
output.NormalSpec = float4(normalize(input.normal), 1.0f);
|
||||||
|
return output;
|
||||||
|
}
|
|
@ -4,18 +4,19 @@
|
||||||
float3 ToVpos(float2 texCoord)
|
float3 ToVpos(float2 texCoord)
|
||||||
{
|
{
|
||||||
//Get proper UV
|
//Get proper UV
|
||||||
float2 UV = float2(texCoord) / float2(Pixels);
|
float2 UV = texCoord / Pixels;
|
||||||
|
|
||||||
float4 ViewPos;
|
float4 ViewPos = float4(0,0,0,0);
|
||||||
// Get the depth value for this pixel
|
// Get the depth value for this pixel
|
||||||
ViewPos.z= DepthTexture[texCoord].x;
|
ViewPos.z= DepthTexture[texCoord].x;
|
||||||
//Get X/w
|
//Get X/w
|
||||||
ViewPos.x = UV.x * 2 - 1;
|
ViewPos.x = UV.x * 2 - 1;
|
||||||
//Get Y/w
|
//Get Y/w
|
||||||
|
//ViewPos.y = -(UV.y * 2) + 1;
|
||||||
ViewPos.y = 1 - 2 * UV.y;
|
ViewPos.y = 1 - 2 * UV.y;
|
||||||
ViewPos.w = 1;
|
ViewPos.w = 1;
|
||||||
|
|
||||||
//Un project
|
//Un project
|
||||||
ViewPos = mul(ViewPos, InvProj);
|
ViewPos = mul(InvProj, ViewPos);
|
||||||
return ViewPos.xyz / ViewPos.w;
|
return ViewPos.xyz / ViewPos.w;
|
||||||
}
|
}
|
|
@ -1,16 +0,0 @@
|
||||||
#include "Defines.hlsli"
|
|
||||||
#include "LightCalc.hlsli"
|
|
||||||
#include "PosManipulation.hlsli"
|
|
||||||
//todo
|
|
||||||
//LightCulling
|
|
||||||
//Calc Diff + Spec
|
|
||||||
//Calc Ambience
|
|
||||||
//Write Glow
|
|
||||||
|
|
||||||
|
|
||||||
[numthreads(1, 1, 1)]
|
|
||||||
void main( uint3 DTid : SV_DispatchThreadID )
|
|
||||||
{
|
|
||||||
float3 ViewPos = ToVpos(DTid.xy);
|
|
||||||
//DiffSpec LightCalc(pl, float3 pos)
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#include "GBufferHeader.hlsli"
|
||||||
|
|
||||||
|
VertexOut main( VertexIn input )
|
||||||
|
{
|
||||||
|
VertexOut output;
|
||||||
|
float4 WorldPos = mul(World, float4(input.pos,1));
|
||||||
|
float4 ViewPos = mul(View, WorldPos);
|
||||||
|
output.pos = mul(Projection, ViewPos);
|
||||||
|
float4 WorldNor = mul(World, float4(input.normal,0));
|
||||||
|
float4 ViewNor = mul(View, WorldNor);
|
||||||
|
output.normal = ViewNor;
|
||||||
|
//output.normal.z *= -1;
|
||||||
|
|
||||||
|
output.UV = input.UV;
|
||||||
|
//output.normal = ViewNor;
|
||||||
|
return output;
|
||||||
|
}
|
|
@ -19,6 +19,7 @@ HINSTANCE g_hInst = NULL;
|
||||||
HWND g_hWnd = NULL;
|
HWND g_hWnd = NULL;
|
||||||
Oyster::Graphics::Model::Model* m = NULL;
|
Oyster::Graphics::Model::Model* m = NULL;
|
||||||
Oyster::Graphics::Model::Model* m2 = NULL;
|
Oyster::Graphics::Model::Model* m2 = NULL;
|
||||||
|
Oyster::Graphics::Model::Model* m3 = NULL;
|
||||||
Oyster::Math::Float4x4 V;
|
Oyster::Math::Float4x4 V;
|
||||||
Oyster::Math::Float4x4 P;
|
Oyster::Math::Float4x4 P;
|
||||||
|
|
||||||
|
@ -188,9 +189,11 @@ HRESULT InitDirect3D()
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region Obj
|
#pragma region Obj
|
||||||
m = Oyster::Graphics::API::CreateModel(L"crate");
|
m = Oyster::Graphics::API::CreateModel(L"orca_dummy");
|
||||||
m2 = Oyster::Graphics::API::CreateModel(L"crate");
|
m2 = Oyster::Graphics::API::CreateModel(L"worldDummy");
|
||||||
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null);
|
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null);
|
||||||
|
m3 = Oyster::Graphics::API::CreateModel(L"worldDummy");
|
||||||
|
m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null);
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
|
@ -199,7 +202,18 @@ HRESULT InitDirect3D()
|
||||||
P.Invert();
|
P.Invert();
|
||||||
|
|
||||||
V = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),Oyster::Math::Float3(0,0,5.4f));
|
V = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),Oyster::Math::Float3(0,0,5.4f));
|
||||||
V = Oyster::Math3D::InverseOrientationMatrix(V);
|
//V = Oyster::Math3D::OrientationMatrix_LookAtPos(Oyster::Math::Float3(0,0,0), Oyster::Math::Float3(0,1,0), Oyster::Math::Float3(0,0,-5.4f));
|
||||||
|
//V.v[3][2] *= -1;
|
||||||
|
V = V.GetInverse();
|
||||||
|
|
||||||
|
|
||||||
|
Oyster::Graphics::Definitions::Pointlight pl;
|
||||||
|
pl.Color = Oyster::Math::Float3(1,1,1);
|
||||||
|
pl.Bright = 1;
|
||||||
|
pl.Pos = (V * Oyster::Math::Float4(Oyster::Math::Float3(0,0,5.4f), 1)).xyz;
|
||||||
|
pl.Radius = 15;
|
||||||
|
|
||||||
|
Oyster::Graphics::API::AddLight(pl);
|
||||||
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -207,9 +221,11 @@ HRESULT InitDirect3D()
|
||||||
float angle = 0;
|
float angle = 0;
|
||||||
HRESULT Update(float deltaTime)
|
HRESULT Update(float deltaTime)
|
||||||
{
|
{
|
||||||
angle += Oyster::Math::pi/30000;
|
|
||||||
|
angle += Oyster::Math::pi/10000;
|
||||||
m->WorldMatrix = Oyster::Math3D::RotationMatrix_AxisY(angle);
|
m->WorldMatrix = Oyster::Math3D::RotationMatrix_AxisY(angle);
|
||||||
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,0,1)*-angle,Oyster::Math::Float3(0,4,0),Oyster::Math::Float3::null);
|
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(1,0,0)*-angle,Oyster::Math::Float3(0,-4,0),Oyster::Math::Float3::null);
|
||||||
|
m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(1,0,0)*-0,Oyster::Math::Float3(3,4,-1*angle),Oyster::Math::Float3::null);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,6 +236,7 @@ HRESULT Render(float deltaTime)
|
||||||
|
|
||||||
Oyster::Graphics::API::RenderModel(*m);
|
Oyster::Graphics::API::RenderModel(*m);
|
||||||
Oyster::Graphics::API::RenderModel(*m2);
|
Oyster::Graphics::API::RenderModel(*m2);
|
||||||
|
Oyster::Graphics::API::RenderModel(*m3);
|
||||||
|
|
||||||
Oyster::Graphics::API::EndFrame();
|
Oyster::Graphics::API::EndFrame();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue