tiled lighting shadow update part1
This commit is contained in:
@@ -6,23 +6,17 @@ using namespace wiGraphicsTypes;
|
||||
wiDepthTarget::wiDepthTarget()
|
||||
{
|
||||
texture = nullptr;
|
||||
textureCube = nullptr;
|
||||
isCube = false;
|
||||
}
|
||||
|
||||
|
||||
wiDepthTarget::~wiDepthTarget()
|
||||
{
|
||||
SAFE_DELETE(texture);
|
||||
SAFE_DELETE(textureCube);
|
||||
}
|
||||
|
||||
void wiDepthTarget::Initialize(int width, int height, UINT MSAAC)
|
||||
{
|
||||
SAFE_DELETE(texture);
|
||||
SAFE_DELETE(textureCube);
|
||||
|
||||
isCube = false;
|
||||
|
||||
Texture2DDesc depthGPUBufferDesc;
|
||||
ZeroMemory(&depthGPUBufferDesc, sizeof(depthGPUBufferDesc));
|
||||
@@ -42,12 +36,9 @@ void wiDepthTarget::Initialize(int width, int height, UINT MSAAC)
|
||||
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&depthGPUBufferDesc, nullptr, &texture);
|
||||
}
|
||||
void wiDepthTarget::InitializeCube(int size)
|
||||
void wiDepthTarget::InitializeCube(int size, bool independentFaces)
|
||||
{
|
||||
SAFE_DELETE(texture);
|
||||
SAFE_DELETE(textureCube);
|
||||
|
||||
isCube = true;
|
||||
|
||||
Texture2DDesc depthGPUBufferDesc;
|
||||
ZeroMemory(&depthGPUBufferDesc, sizeof(depthGPUBufferDesc));
|
||||
@@ -65,7 +56,9 @@ void wiDepthTarget::InitializeCube(int size)
|
||||
depthGPUBufferDesc.CPUAccessFlags = 0;
|
||||
depthGPUBufferDesc.MiscFlags = RESOURCE_MISC_TEXTURECUBE;
|
||||
|
||||
wiRenderer::GetDevice()->CreateTextureCube(&depthGPUBufferDesc, nullptr, &textureCube);
|
||||
texture = new Texture2D;
|
||||
texture->RequestIndepententRenderTargetCubemapFaces(independentFaces);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&depthGPUBufferDesc, nullptr, &texture);
|
||||
}
|
||||
|
||||
void wiDepthTarget::Clear(GRAPHICSTHREAD threadID)
|
||||
|
||||
@@ -6,25 +6,17 @@ class wiDepthTarget
|
||||
{
|
||||
private:
|
||||
wiGraphicsTypes::Texture2D* texture;
|
||||
wiGraphicsTypes::TextureCube* textureCube;
|
||||
bool isCube;
|
||||
public:
|
||||
//Texture2D texture2D;
|
||||
//DepthStencilView depthTarget;
|
||||
//Texture2D* shaderResource;
|
||||
|
||||
//ShaderResourceViewDesc shaderResourceViewDesc;
|
||||
|
||||
|
||||
wiDepthTarget();
|
||||
~wiDepthTarget();
|
||||
|
||||
void Initialize(int width, int height, UINT MSAAC);
|
||||
void InitializeCube(int size);
|
||||
void InitializeCube(int size, bool independentFaces = false);
|
||||
void Clear(GRAPHICSTHREAD threadID);
|
||||
void CopyFrom(const wiDepthTarget&, GRAPHICSTHREAD threadID);
|
||||
|
||||
wiGraphicsTypes::Texture2D* GetTexture() const { return(isCube ? textureCube : texture); }
|
||||
wiGraphicsTypes::Texture2D* GetTexture() const { return texture; }
|
||||
wiGraphicsTypes::Texture2DDesc GetDesc() const { return GetTexture()->GetDesc(); }
|
||||
};
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace wiGraphicsTypes
|
||||
virtual HRESULT CreateTexture1D() = 0;
|
||||
virtual HRESULT CreateTexture2D(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, Texture2D **ppTexture2D) = 0;
|
||||
virtual HRESULT CreateTexture3D() = 0;
|
||||
virtual HRESULT CreateTextureCube(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, TextureCube **ppTextureCube) = 0;
|
||||
virtual HRESULT CreateShaderResourceView(Texture2D* pTexture) = 0;
|
||||
virtual HRESULT CreateRenderTargetView(Texture2D* pTexture) = 0;
|
||||
virtual HRESULT CreateDepthStencilView(Texture2D* pTexture) = 0;
|
||||
@@ -76,9 +75,9 @@ namespace wiGraphicsTypes
|
||||
///////////////Thread-sensitive////////////////////////
|
||||
|
||||
virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargetViews, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void ClearRenderTarget(Texture2D* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargetViews, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, UINT arrayIndex = 0) = 0;
|
||||
virtual void ClearRenderTarget(Texture2D* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, UINT arrayIndex = 0) = 0;
|
||||
virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, UINT arrayIndex = 0) = 0;
|
||||
virtual void BindResourcePS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindResourceVS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindResourceGS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
|
||||
@@ -1609,25 +1609,27 @@ HRESULT GraphicsDevice_DX11::CreateTexture1D()
|
||||
}
|
||||
HRESULT GraphicsDevice_DX11::CreateTexture2D(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, Texture2D **ppTexture2D)
|
||||
{
|
||||
D3D11_TEXTURE2D_DESC desc = _ConvertTexture2DDesc(pDesc);
|
||||
if ((*ppTexture2D) == nullptr)
|
||||
{
|
||||
(*ppTexture2D) = new Texture2D;
|
||||
}
|
||||
(*ppTexture2D)->desc = *pDesc;
|
||||
|
||||
if (desc.SampleDesc.Count > 1)
|
||||
if ((*ppTexture2D)->desc.SampleDesc.Count > 1)
|
||||
{
|
||||
UINT quality;
|
||||
device->CheckMultisampleQualityLevels(desc.Format, desc.SampleDesc.Count, &quality);
|
||||
desc.SampleDesc.Quality = quality - 1;
|
||||
device->CheckMultisampleQualityLevels(_ConvertFormat((*ppTexture2D)->desc.Format), (*ppTexture2D)->desc.SampleDesc.Count, &quality);
|
||||
(*ppTexture2D)->desc.SampleDesc.Quality = quality - 1;
|
||||
if (quality == 0)
|
||||
{
|
||||
assert(0 && "MSAA Samplecount not supported!");
|
||||
desc.SampleDesc.Count = 1;
|
||||
(*ppTexture2D)->desc.SampleDesc.Count = 1;
|
||||
}
|
||||
}
|
||||
|
||||
D3D11_TEXTURE2D_DESC desc = _ConvertTexture2DDesc(&(*ppTexture2D)->desc);
|
||||
D3D11_SUBRESOURCE_DATA* data = _ConvertSubresourceData(pInitialData);
|
||||
|
||||
(*ppTexture2D) = new Texture2D;
|
||||
(*ppTexture2D)->desc = *pDesc;
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
hr = device->CreateTexture2D(&desc, data, &((*ppTexture2D)->texture2D_DX11));
|
||||
@@ -1661,64 +1663,60 @@ HRESULT GraphicsDevice_DX11::CreateTexture3D()
|
||||
// TODO
|
||||
return E_FAIL;
|
||||
}
|
||||
HRESULT GraphicsDevice_DX11::CreateTextureCube(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, TextureCube **ppTextureCube)
|
||||
{
|
||||
D3D11_TEXTURE2D_DESC desc = _ConvertTexture2DDesc(pDesc);
|
||||
|
||||
D3D11_SUBRESOURCE_DATA* data = _ConvertSubresourceData(pInitialData);
|
||||
|
||||
(*ppTextureCube) = new TextureCube;
|
||||
(*ppTextureCube)->desc = *pDesc;
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if (!(desc.MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE))
|
||||
{
|
||||
desc.MiscFlags |= D3D11_RESOURCE_MISC_TEXTURECUBE;
|
||||
}
|
||||
|
||||
hr = device->CreateTexture2D(&desc, data, &((*ppTextureCube)->texture2D_DX11));
|
||||
assert(SUCCEEDED(hr) && "TextureCube creation failed!");
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
CreateRenderTargetView(*ppTextureCube);
|
||||
CreateShaderResourceView(*ppTextureCube);
|
||||
CreateDepthStencilView(*ppTextureCube);
|
||||
|
||||
return hr;
|
||||
}
|
||||
HRESULT GraphicsDevice_DX11::CreateShaderResourceView(Texture2D* pTexture)
|
||||
{
|
||||
HRESULT hr = E_FAIL;
|
||||
if (pTexture->desc.BindFlags & D3D11_BIND_SHADER_RESOURCE)
|
||||
{
|
||||
UINT arraySize = pTexture->desc.ArraySize;
|
||||
UINT sampleCount = pTexture->desc.SampleDesc.Count;
|
||||
bool multisampled = sampleCount > 1;
|
||||
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc;
|
||||
if (pTexture->desc.MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE)
|
||||
ZeroMemory(&shaderResourceViewDesc, sizeof(shaderResourceViewDesc));
|
||||
// Try to resolve shader resource format:
|
||||
switch (pTexture->desc.Format)
|
||||
{
|
||||
case FORMAT_R32_TYPELESS:
|
||||
shaderResourceViewDesc.Format = DXGI_FORMAT_R32_FLOAT;
|
||||
break;
|
||||
case FORMAT_R24G8_TYPELESS:
|
||||
shaderResourceViewDesc.Format = DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
|
||||
break;
|
||||
default:
|
||||
shaderResourceViewDesc.Format = _ConvertFormat(pTexture->desc.Format);
|
||||
if (pTexture->desc.BindFlags & D3D11_BIND_DEPTH_STENCIL)
|
||||
break;
|
||||
}
|
||||
|
||||
if (arraySize > 1)
|
||||
{
|
||||
if (pTexture->desc.MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE)
|
||||
{
|
||||
shaderResourceViewDesc.Format = DXGI_FORMAT_R32_FLOAT;
|
||||
shaderResourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
|
||||
shaderResourceViewDesc.TextureCube.MostDetailedMip = 0; //from most detailed...
|
||||
shaderResourceViewDesc.TextureCube.MipLevels = -1; //...to least detailed
|
||||
}
|
||||
else
|
||||
{
|
||||
shaderResourceViewDesc.ViewDimension = (multisampled ? D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY : D3D11_SRV_DIMENSION_TEXTURE2DARRAY);
|
||||
shaderResourceViewDesc.Texture2DArray.FirstArraySlice = 0;
|
||||
shaderResourceViewDesc.Texture2DArray.ArraySize = arraySize;
|
||||
shaderResourceViewDesc.Texture2DArray.MostDetailedMip = 0; //from most detailed...
|
||||
shaderResourceViewDesc.Texture2DArray.MipLevels = -1; //...to least detailed
|
||||
}
|
||||
shaderResourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
|
||||
shaderResourceViewDesc.TextureCube.MostDetailedMip = 0; //from most detailed...
|
||||
shaderResourceViewDesc.TextureCube.MipLevels = -1; //...to least detailed
|
||||
}
|
||||
else
|
||||
{
|
||||
shaderResourceViewDesc.Format = _ConvertFormat(pTexture->desc.Format);
|
||||
if (pTexture->desc.BindFlags & D3D11_BIND_DEPTH_STENCIL)
|
||||
{
|
||||
shaderResourceViewDesc.Format = DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
|
||||
}
|
||||
shaderResourceViewDesc.ViewDimension = (pTexture->desc.SampleDesc.Count == 1 ? D3D11_SRV_DIMENSION_TEXTURE2D : D3D11_SRV_DIMENSION_TEXTURE2DMS);
|
||||
shaderResourceViewDesc.ViewDimension = (multisampled ? D3D11_SRV_DIMENSION_TEXTURE2DMS : D3D11_SRV_DIMENSION_TEXTURE2D);
|
||||
shaderResourceViewDesc.Texture2D.MostDetailedMip = 0; //from most detailed...
|
||||
shaderResourceViewDesc.Texture2D.MipLevels = -1; //...to least detailed
|
||||
}
|
||||
|
||||
hr = device->CreateShaderResourceView(pTexture->texture2D_DX11, &shaderResourceViewDesc, &pTexture->shaderResourceView_DX11);
|
||||
|
||||
assert(SUCCEEDED(hr) && "ShaderResourceView Creation failed!");
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
HRESULT GraphicsDevice_DX11::CreateRenderTargetView(Texture2D* pTexture)
|
||||
@@ -1726,24 +1724,101 @@ HRESULT GraphicsDevice_DX11::CreateRenderTargetView(Texture2D* pTexture)
|
||||
HRESULT hr = E_FAIL;
|
||||
if (pTexture->desc.BindFlags & D3D11_BIND_RENDER_TARGET)
|
||||
{
|
||||
UINT arraySize = pTexture->desc.ArraySize;
|
||||
UINT sampleCount = pTexture->desc.SampleDesc.Count;
|
||||
bool multisampled = sampleCount > 1;
|
||||
|
||||
D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
|
||||
if (pTexture->desc.MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE)
|
||||
ZeroMemory(&renderTargetViewDesc, sizeof(renderTargetViewDesc));
|
||||
renderTargetViewDesc.Format = _ConvertFormat(pTexture->desc.Format);
|
||||
renderTargetViewDesc.Texture2DArray.MipSlice = 0;
|
||||
|
||||
if (pTexture->desc.MiscFlags & RESOURCE_MISC_TEXTURECUBE)
|
||||
{
|
||||
renderTargetViewDesc.Format = _ConvertFormat(pTexture->desc.Format);
|
||||
// TextureCube, TextureCubeArray...
|
||||
const UINT faces = 6;
|
||||
UINT slices = arraySize / faces;
|
||||
|
||||
renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
|
||||
renderTargetViewDesc.Texture2DArray.FirstArraySlice = 0;
|
||||
renderTargetViewDesc.Texture2DArray.ArraySize = 6;
|
||||
renderTargetViewDesc.Texture2DArray.MipSlice = 0;
|
||||
|
||||
if (pTexture->independentRTVCubemapFaces)
|
||||
{
|
||||
// independent faces
|
||||
for (UINT i = 0; i < arraySize; ++i)
|
||||
{
|
||||
renderTargetViewDesc.Texture2DArray.FirstArraySlice = i;
|
||||
renderTargetViewDesc.Texture2DArray.ArraySize = 1;
|
||||
|
||||
pTexture->renderTargetViews_DX11.push_back(nullptr);
|
||||
hr = device->CreateRenderTargetView(pTexture->texture2D_DX11, &renderTargetViewDesc, &pTexture->renderTargetViews_DX11[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (pTexture->independentRTVArraySlices)
|
||||
{
|
||||
// independent slices
|
||||
for (UINT i = 0; i < slices; ++i)
|
||||
{
|
||||
renderTargetViewDesc.Texture2DArray.FirstArraySlice = i * faces;
|
||||
renderTargetViewDesc.Texture2DArray.ArraySize = faces;
|
||||
|
||||
pTexture->renderTargetViews_DX11.push_back(nullptr);
|
||||
hr = device->CreateRenderTargetView(pTexture->texture2D_DX11, &renderTargetViewDesc, &pTexture->renderTargetViews_DX11[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// everything in one
|
||||
renderTargetViewDesc.Texture2DArray.FirstArraySlice = 0;
|
||||
renderTargetViewDesc.Texture2DArray.ArraySize = arraySize;
|
||||
|
||||
pTexture->renderTargetViews_DX11.push_back(nullptr);
|
||||
hr = device->CreateRenderTargetView(pTexture->texture2D_DX11, &renderTargetViewDesc, &pTexture->renderTargetViews_DX11[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
renderTargetViewDesc.Format = _ConvertFormat(pTexture->desc.Format);
|
||||
renderTargetViewDesc.ViewDimension = (pTexture->desc.SampleDesc.Count == 1 ? D3D11_RTV_DIMENSION_TEXTURE2D : D3D11_RTV_DIMENSION_TEXTURE2DMS);
|
||||
renderTargetViewDesc.Texture2D.MipSlice = 0;
|
||||
}
|
||||
// Texture2D, Texture2DArray...
|
||||
if (arraySize > 1 && pTexture->independentRTVArraySlices)
|
||||
{
|
||||
for (UINT i = 0; i < arraySize; ++i)
|
||||
{
|
||||
renderTargetViewDesc.ViewDimension = (multisampled ? D3D11_RTV_DIMENSION_TEXTURE2DMS : D3D11_RTV_DIMENSION_TEXTURE2D);
|
||||
renderTargetViewDesc.Texture2DArray.FirstArraySlice = i;
|
||||
renderTargetViewDesc.Texture2DArray.ArraySize = 1;
|
||||
renderTargetViewDesc.Texture2DArray.MipSlice = 0;
|
||||
|
||||
hr = device->CreateRenderTargetView(pTexture->texture2D_DX11, &renderTargetViewDesc, &pTexture->renderTargetView_DX11);
|
||||
pTexture->renderTargetViews_DX11.push_back(nullptr);
|
||||
hr = device->CreateRenderTargetView(pTexture->texture2D_DX11, &renderTargetViewDesc, &pTexture->renderTargetViews_DX11[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (arraySize > 1)
|
||||
{
|
||||
renderTargetViewDesc.ViewDimension = (multisampled ? D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY : D3D11_RTV_DIMENSION_TEXTURE2DARRAY);
|
||||
renderTargetViewDesc.Texture2DArray.FirstArraySlice = 0;
|
||||
renderTargetViewDesc.Texture2DArray.ArraySize = arraySize;
|
||||
renderTargetViewDesc.Texture2DArray.MipSlice = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
renderTargetViewDesc.ViewDimension = (multisampled ? D3D11_RTV_DIMENSION_TEXTURE2DMS : D3D11_RTV_DIMENSION_TEXTURE2D);
|
||||
renderTargetViewDesc.Texture2D.MipSlice = 0;
|
||||
}
|
||||
|
||||
pTexture->renderTargetViews_DX11.push_back(nullptr);
|
||||
hr = device->CreateRenderTargetView(pTexture->texture2D_DX11, &renderTargetViewDesc, &pTexture->renderTargetViews_DX11[0]);
|
||||
}
|
||||
}
|
||||
|
||||
assert(SUCCEEDED(hr) && "RenderTargetView Creation failed!");
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
HRESULT GraphicsDevice_DX11::CreateDepthStencilView(Texture2D* pTexture)
|
||||
@@ -1751,28 +1826,132 @@ HRESULT GraphicsDevice_DX11::CreateDepthStencilView(Texture2D* pTexture)
|
||||
HRESULT hr = E_FAIL;
|
||||
if (pTexture->desc.BindFlags & D3D11_BIND_DEPTH_STENCIL)
|
||||
{
|
||||
UINT arraySize = pTexture->desc.ArraySize;
|
||||
UINT sampleCount = pTexture->desc.SampleDesc.Count;
|
||||
bool multisampled = sampleCount > 1;
|
||||
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc;
|
||||
if (pTexture->desc.MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE)
|
||||
ZeroMemory(&depthStencilViewDesc, sizeof(depthStencilViewDesc));
|
||||
depthStencilViewDesc.Texture2DArray.MipSlice = 0;
|
||||
depthStencilViewDesc.Flags = 0;
|
||||
|
||||
// Try to resolve depth stencil format:
|
||||
switch (pTexture->desc.Format)
|
||||
{
|
||||
ZeroMemory(&depthStencilViewDesc, sizeof(depthStencilViewDesc));
|
||||
case FORMAT_R32_TYPELESS:
|
||||
depthStencilViewDesc.Format = DXGI_FORMAT_D32_FLOAT;
|
||||
break;
|
||||
case FORMAT_R24G8_TYPELESS:
|
||||
depthStencilViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
|
||||
break;
|
||||
default:
|
||||
depthStencilViewDesc.Format = _ConvertFormat(pTexture->desc.Format);
|
||||
break;
|
||||
}
|
||||
|
||||
//if (pTexture->desc.MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE)
|
||||
//{
|
||||
// ZeroMemory(&depthStencilViewDesc, sizeof(depthStencilViewDesc));
|
||||
// depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
|
||||
// depthStencilViewDesc.Texture2DArray.FirstArraySlice = 0;
|
||||
// depthStencilViewDesc.Texture2DArray.ArraySize = 6;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// ZeroMemory(&depthStencilViewDesc, sizeof(depthStencilViewDesc));
|
||||
// depthStencilViewDesc.ViewDimension = (pTexture->desc.SampleDesc.Count == 1 ? D3D11_DSV_DIMENSION_TEXTURE2D : D3D11_DSV_DIMENSION_TEXTURE2DMS);
|
||||
// depthStencilViewDesc.Texture2D.MipSlice = 0;
|
||||
// depthStencilViewDesc.Flags = 0;
|
||||
//}
|
||||
|
||||
//hr = device->CreateDepthStencilView(pTexture->texture2D_DX11, &depthStencilViewDesc, &pTexture->depthStencilView_DX11);
|
||||
|
||||
if (pTexture->desc.MiscFlags & RESOURCE_MISC_TEXTURECUBE)
|
||||
{
|
||||
// TextureCube, TextureCubeArray...
|
||||
const UINT faces = 6;
|
||||
UINT slices = arraySize / faces;
|
||||
|
||||
depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
|
||||
depthStencilViewDesc.Texture2DArray.FirstArraySlice = 0;
|
||||
depthStencilViewDesc.Texture2DArray.ArraySize = 6;
|
||||
depthStencilViewDesc.Texture2DArray.MipSlice = 0;
|
||||
depthStencilViewDesc.Flags = 0;
|
||||
|
||||
if (pTexture->independentRTVCubemapFaces)
|
||||
{
|
||||
// independent faces
|
||||
for (UINT i = 0; i < arraySize; ++i)
|
||||
{
|
||||
depthStencilViewDesc.Texture2DArray.FirstArraySlice = i;
|
||||
depthStencilViewDesc.Texture2DArray.ArraySize = 1;
|
||||
|
||||
pTexture->depthStencilViews_DX11.push_back(nullptr);
|
||||
hr = device->CreateDepthStencilView(pTexture->texture2D_DX11, &depthStencilViewDesc, &pTexture->depthStencilViews_DX11[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (pTexture->independentRTVArraySlices)
|
||||
{
|
||||
// independent slices
|
||||
for (UINT i = 0; i < slices; ++i)
|
||||
{
|
||||
depthStencilViewDesc.Texture2DArray.FirstArraySlice = i * faces;
|
||||
depthStencilViewDesc.Texture2DArray.ArraySize = faces;
|
||||
|
||||
pTexture->depthStencilViews_DX11.push_back(nullptr);
|
||||
hr = device->CreateDepthStencilView(pTexture->texture2D_DX11, &depthStencilViewDesc, &pTexture->depthStencilViews_DX11[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// everything in one
|
||||
depthStencilViewDesc.Texture2DArray.FirstArraySlice = 0;
|
||||
depthStencilViewDesc.Texture2DArray.ArraySize = arraySize;
|
||||
|
||||
pTexture->depthStencilViews_DX11.push_back(nullptr);
|
||||
hr = device->CreateDepthStencilView(pTexture->texture2D_DX11, &depthStencilViewDesc, &pTexture->depthStencilViews_DX11[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ZeroMemory(&depthStencilViewDesc, sizeof(depthStencilViewDesc));
|
||||
depthStencilViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
|
||||
depthStencilViewDesc.ViewDimension = (pTexture->desc.SampleDesc.Count == 1 ? D3D11_DSV_DIMENSION_TEXTURE2D : D3D11_DSV_DIMENSION_TEXTURE2DMS);
|
||||
depthStencilViewDesc.Texture2D.MipSlice = 0;
|
||||
depthStencilViewDesc.Flags = 0;
|
||||
// Texture2D, Texture2DArray...
|
||||
if (arraySize > 1 && pTexture->independentRTVArraySlices)
|
||||
{
|
||||
for (UINT i = 0; i < arraySize; ++i)
|
||||
{
|
||||
depthStencilViewDesc.ViewDimension = (multisampled ? D3D11_DSV_DIMENSION_TEXTURE2DMS : D3D11_DSV_DIMENSION_TEXTURE2D);
|
||||
depthStencilViewDesc.Texture2DArray.FirstArraySlice = i;
|
||||
depthStencilViewDesc.Texture2DArray.ArraySize = 1;
|
||||
depthStencilViewDesc.Texture2DArray.MipSlice = 0;
|
||||
|
||||
pTexture->depthStencilViews_DX11.push_back(nullptr);
|
||||
hr = device->CreateDepthStencilView(pTexture->texture2D_DX11, &depthStencilViewDesc, &pTexture->depthStencilViews_DX11[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (arraySize > 1)
|
||||
{
|
||||
depthStencilViewDesc.ViewDimension = (multisampled ? D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY : D3D11_DSV_DIMENSION_TEXTURE2DARRAY);
|
||||
depthStencilViewDesc.Texture2DArray.FirstArraySlice = 0;
|
||||
depthStencilViewDesc.Texture2DArray.ArraySize = arraySize;
|
||||
depthStencilViewDesc.Texture2DArray.MipSlice = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
depthStencilViewDesc.ViewDimension = (multisampled ? D3D11_DSV_DIMENSION_TEXTURE2DMS : D3D11_DSV_DIMENSION_TEXTURE2D);
|
||||
depthStencilViewDesc.Texture2D.MipSlice = 0;
|
||||
}
|
||||
|
||||
pTexture->depthStencilViews_DX11.push_back(nullptr);
|
||||
hr = device->CreateDepthStencilView(pTexture->texture2D_DX11, &depthStencilViewDesc, &pTexture->depthStencilViews_DX11[0]);
|
||||
}
|
||||
}
|
||||
|
||||
hr = device->CreateDepthStencilView(pTexture->texture2D_DX11, &depthStencilViewDesc, &pTexture->depthStencilView_DX11);
|
||||
assert(SUCCEEDED(hr) && "DepthStencilView Creation failed!");
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
HRESULT GraphicsDevice_DX11::CreateInputLayout(const VertexLayoutDesc *pInputElementDescs, UINT NumElements,
|
||||
@@ -1986,28 +2165,31 @@ void GraphicsDevice_DX11::BindViewports(UINT NumViewports, const ViewPort *pView
|
||||
deviceContexts[threadID]->RSSetViewports(NumViewports, pd3dViewPorts);
|
||||
SAFE_DELETE_ARRAY(pd3dViewPorts);
|
||||
}
|
||||
void GraphicsDevice_DX11::BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargetViews, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID)
|
||||
void GraphicsDevice_DX11::BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargetViews, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID, UINT arrayIndex)
|
||||
{
|
||||
ID3D11RenderTargetView* renderTargetViews[8];
|
||||
for (UINT i = 0; i < min(NumViews, 8); ++i)
|
||||
{
|
||||
renderTargetViews[i] = ppRenderTargetViews[i]->renderTargetView_DX11;
|
||||
assert(ppRenderTargetViews[i]->renderTargetViews_DX11.size() > arrayIndex && "Invalid rendertarget arrayIndex!");
|
||||
renderTargetViews[i] = ppRenderTargetViews[i]->renderTargetViews_DX11[arrayIndex];
|
||||
}
|
||||
deviceContexts[threadID]->OMSetRenderTargets(NumViews, renderTargetViews,
|
||||
(depthStencilTexture == nullptr ? nullptr : depthStencilTexture->depthStencilView_DX11));
|
||||
deviceContexts[threadID]->OMSetRenderTargets(NumViews, NumViews > 0 ? renderTargetViews : nullptr,
|
||||
(depthStencilTexture == nullptr ? nullptr : depthStencilTexture->depthStencilViews_DX11[arrayIndex]));
|
||||
}
|
||||
void GraphicsDevice_DX11::ClearRenderTarget(Texture2D* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID)
|
||||
void GraphicsDevice_DX11::ClearRenderTarget(Texture2D* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID, UINT arrayIndex)
|
||||
{
|
||||
deviceContexts[threadID]->ClearRenderTargetView(pTexture->renderTargetView_DX11, ColorRGBA);
|
||||
assert(pTexture->renderTargetViews_DX11.size() > arrayIndex && "Invalid rendertarget arrayIndex!");
|
||||
deviceContexts[threadID]->ClearRenderTargetView(pTexture->renderTargetViews_DX11[arrayIndex], ColorRGBA);
|
||||
}
|
||||
void GraphicsDevice_DX11::ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID)
|
||||
void GraphicsDevice_DX11::ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID, UINT arrayIndex)
|
||||
{
|
||||
assert(pTexture->depthStencilViews_DX11.size() > arrayIndex && "Invalid depthstencil arrayIndex!");
|
||||
UINT _flags = 0;
|
||||
if (ClearFlags & CLEAR_DEPTH)
|
||||
_flags |= D3D11_CLEAR_DEPTH;
|
||||
if (ClearFlags & CLEAR_STENCIL)
|
||||
_flags |= D3D11_CLEAR_STENCIL;
|
||||
deviceContexts[threadID]->ClearDepthStencilView(pTexture->depthStencilView_DX11, _flags, Depth, Stencil);
|
||||
deviceContexts[threadID]->ClearDepthStencilView(pTexture->depthStencilViews_DX11[arrayIndex], _flags, Depth, Stencil);
|
||||
}
|
||||
void GraphicsDevice_DX11::BindResourcePS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,6 @@ namespace wiGraphicsTypes
|
||||
virtual HRESULT CreateTexture1D() override;
|
||||
virtual HRESULT CreateTexture2D(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, Texture2D **ppTexture2D) override;
|
||||
virtual HRESULT CreateTexture3D() override;
|
||||
virtual HRESULT CreateTextureCube(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, TextureCube **ppTextureCube) override;
|
||||
virtual HRESULT CreateShaderResourceView(Texture2D* pTexture) override;
|
||||
virtual HRESULT CreateRenderTargetView(Texture2D* pTexture) override;
|
||||
virtual HRESULT CreateDepthStencilView(Texture2D* pTexture) override;
|
||||
@@ -80,9 +79,9 @@ namespace wiGraphicsTypes
|
||||
///////////////Thread-sensitive////////////////////////
|
||||
|
||||
virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
|
||||
virtual void BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargetViews, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
|
||||
virtual void ClearRenderTarget(Texture2D* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
|
||||
virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
|
||||
virtual void BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargetViews, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, UINT arrayIndex = 0) override;
|
||||
virtual void ClearRenderTarget(Texture2D* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, UINT arrayIndex = 0) override;
|
||||
virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, UINT arrayIndex = 0) override;
|
||||
virtual void BindResourcePS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
|
||||
virtual void BindResourceVS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
|
||||
virtual void BindResourceGS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
|
||||
|
||||
@@ -151,15 +151,35 @@ namespace wiGraphicsTypes
|
||||
SAFE_DELETE(vertexLayout);
|
||||
}
|
||||
|
||||
Texture::Texture() : GPUResource(), GPUUnorderedResource()
|
||||
Texture::Texture() : GPUResource(), GPUUnorderedResource(), independentRTVArraySlices(false), independentRTVCubemapFaces(false)
|
||||
{
|
||||
SAFE_INIT(renderTargetView_DX11);
|
||||
SAFE_INIT(depthStencilView_DX11);
|
||||
}
|
||||
Texture::~Texture()
|
||||
{
|
||||
SAFE_RELEASE(renderTargetView_DX11);
|
||||
SAFE_RELEASE(depthStencilView_DX11);
|
||||
for (auto& x : renderTargetViews_DX11)
|
||||
{
|
||||
SAFE_RELEASE(x);
|
||||
}
|
||||
for (auto& x : depthStencilViews_DX11)
|
||||
{
|
||||
SAFE_RELEASE(x);
|
||||
}
|
||||
}
|
||||
void Texture::RequestIndepententRenderTargetArraySlices(bool value)
|
||||
{
|
||||
independentRTVArraySlices = value;
|
||||
}
|
||||
bool Texture::IsIndepententRenderTargetArraySlices()
|
||||
{
|
||||
return independentRTVArraySlices;
|
||||
}
|
||||
void Texture::RequestIndepententRenderTargetCubemapFaces(bool value)
|
||||
{
|
||||
independentRTVCubemapFaces = value;
|
||||
}
|
||||
bool Texture::IsIndepententRenderTargetCubemapFaces()
|
||||
{
|
||||
return independentRTVCubemapFaces;
|
||||
}
|
||||
|
||||
Texture2D::Texture2D() :Texture()
|
||||
@@ -170,13 +190,4 @@ namespace wiGraphicsTypes
|
||||
{
|
||||
SAFE_RELEASE(texture2D_DX11);
|
||||
}
|
||||
|
||||
TextureCube::TextureCube() :Texture2D()
|
||||
{
|
||||
|
||||
}
|
||||
TextureCube::~TextureCube()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace wiGraphicsTypes
|
||||
{
|
||||
friend class GraphicsDevice_DX11;
|
||||
private:
|
||||
ID3D11Buffer* resource_DX11;
|
||||
ID3D11Buffer* resource_DX11;
|
||||
GPUBufferDesc desc;
|
||||
public:
|
||||
GPUBuffer();
|
||||
@@ -227,13 +227,22 @@ namespace wiGraphicsTypes
|
||||
{
|
||||
friend class GraphicsDevice_DX11;
|
||||
private:
|
||||
ID3D11RenderTargetView* renderTargetView_DX11;
|
||||
ID3D11DepthStencilView* depthStencilView_DX11;
|
||||
vector<ID3D11RenderTargetView*> renderTargetViews_DX11;
|
||||
vector<ID3D11DepthStencilView*> depthStencilViews_DX11;
|
||||
bool independentRTVArraySlices;
|
||||
bool independentRTVCubemapFaces;
|
||||
public:
|
||||
|
||||
Texture();
|
||||
virtual ~Texture();
|
||||
// if true, then each array slice will get a unique rendertarget
|
||||
void RequestIndepententRenderTargetArraySlices(bool value);
|
||||
bool IsIndepententRenderTargetArraySlices();
|
||||
// if true, then each face of the cubemap will get a unique rendertarget
|
||||
void RequestIndepententRenderTargetCubemapFaces(bool value);
|
||||
bool IsIndepententRenderTargetCubemapFaces();
|
||||
};
|
||||
|
||||
class Texture2D : public Texture
|
||||
{
|
||||
friend class GraphicsDevice_DX11;
|
||||
@@ -246,13 +255,6 @@ namespace wiGraphicsTypes
|
||||
|
||||
Texture2DDesc GetDesc() { return desc; }
|
||||
};
|
||||
class TextureCube : public Texture2D
|
||||
{
|
||||
friend class GraphicsDevice_DX11;
|
||||
public:
|
||||
TextureCube();
|
||||
virtual ~TextureCube();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _GRAPHICSRESOURCE_H_
|
||||
|
||||
@@ -840,7 +840,7 @@ void LoadWiLights(const string& directory, const string& name, const string& ide
|
||||
lights.back()->type=Light::DIRECTIONAL;
|
||||
file>>lights.back()->name;
|
||||
lights.back()->shadow = true;
|
||||
lights.back()->shadowMaps_dirLight.resize(3);
|
||||
//lights.back()->shadowMaps_dirLight.resize(3);
|
||||
lights.back()->shadowBias = 9.99995464e-005f;
|
||||
//for (int i = 0; i < 3; ++i)
|
||||
//{
|
||||
@@ -4031,13 +4031,13 @@ void Object::Serialize(wiArchive& archive)
|
||||
#pragma endregion
|
||||
|
||||
#pragma region LIGHT
|
||||
vector<wiRenderTarget> Light::shadowMaps_pointLight;
|
||||
vector<wiRenderTarget> Light::shadowMaps_spotLight;
|
||||
Texture2D* Light::dirLightShadowMapArray = nullptr;
|
||||
Texture2D* Light::spotLightShadowMapArray = nullptr;
|
||||
Texture2D* Light::pointLightShadowMapArray = nullptr;
|
||||
Light::Light():Transform() {
|
||||
color = XMFLOAT4(0, 0, 0, 0);
|
||||
enerDis = XMFLOAT4(0, 0, 0, 0);
|
||||
type = LightType::POINT;
|
||||
//shadowMap.resize(0);
|
||||
shadow = false;
|
||||
noHalo = false;
|
||||
lensFlareRimTextures.resize(0);
|
||||
@@ -4169,10 +4169,10 @@ void Light::Serialize(wiArchive& archive)
|
||||
int temp;
|
||||
archive >> temp;
|
||||
type = (LightType)temp;
|
||||
if (type == DIRECTIONAL)
|
||||
{
|
||||
shadowMaps_dirLight.resize(3);
|
||||
}
|
||||
//if (type == DIRECTIONAL)
|
||||
//{
|
||||
// shadowMaps_dirLight.resize(3);
|
||||
//}
|
||||
size_t lensFlareCount;
|
||||
archive >> lensFlareCount;
|
||||
string rim;
|
||||
|
||||
@@ -775,10 +775,12 @@ struct Light : public Cullable , public Transform
|
||||
vector<wiGraphicsTypes::Texture2D*> lensFlareRimTextures;
|
||||
vector<string> lensFlareNames;
|
||||
|
||||
//vector<wiRenderTarget> shadowMap;
|
||||
static vector<wiRenderTarget> shadowMaps_pointLight;
|
||||
static vector<wiRenderTarget> shadowMaps_spotLight;
|
||||
vector<wiRenderTarget> shadowMaps_dirLight;
|
||||
//static vector<wiRenderTarget> shadowMaps_pointLight;
|
||||
//static vector<wiRenderTarget> shadowMaps_spotLight;
|
||||
//vector<wiRenderTarget> shadowMaps_dirLight;
|
||||
static wiGraphicsTypes::Texture2D* dirLightShadowMapArray;
|
||||
static wiGraphicsTypes::Texture2D* spotLightShadowMapArray;
|
||||
static wiGraphicsTypes::Texture2D* pointLightShadowMapArray;
|
||||
int shadowMap_index;
|
||||
|
||||
vector<SHCAM> shadowCam_pointLight;
|
||||
|
||||
@@ -9,40 +9,32 @@ wiRenderTarget::wiRenderTarget()
|
||||
{
|
||||
numViews = 0;
|
||||
depth = nullptr;
|
||||
isCube = false;
|
||||
}
|
||||
wiRenderTarget::wiRenderTarget(UINT width, UINT height, bool hasDepth, FORMAT format, UINT mipMapLevelCount, UINT MSAAC, bool depthOnly)
|
||||
{
|
||||
numViews = 0;
|
||||
depth = nullptr;
|
||||
isCube = false;
|
||||
Initialize(width, height, hasDepth, format, mipMapLevelCount, MSAAC);
|
||||
}
|
||||
|
||||
|
||||
wiRenderTarget::~wiRenderTarget()
|
||||
{
|
||||
clear();
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
void wiRenderTarget::clear() {
|
||||
void wiRenderTarget::CleanUp() {
|
||||
for (unsigned int i = 0; i < renderTargets.size(); ++i)
|
||||
{
|
||||
SAFE_DELETE(renderTargets[i]);
|
||||
}
|
||||
for (unsigned int i = 0; i < renderTargets_Cube.size(); ++i)
|
||||
{
|
||||
SAFE_DELETE(renderTargets_Cube[i]);
|
||||
}
|
||||
SAFE_DELETE(depth);
|
||||
}
|
||||
|
||||
void wiRenderTarget::Initialize(UINT width, UINT height, bool hasDepth
|
||||
, FORMAT format, UINT mipMapLevelCount, UINT MSAAC, bool depthOnly)
|
||||
{
|
||||
clear();
|
||||
|
||||
isCube = false;
|
||||
CleanUp();
|
||||
|
||||
if (!depthOnly)
|
||||
{
|
||||
@@ -54,7 +46,7 @@ void wiRenderTarget::Initialize(UINT width, UINT height, bool hasDepth
|
||||
textureDesc.ArraySize = 1;
|
||||
textureDesc.Format = format;
|
||||
textureDesc.SampleDesc.Count = MSAAC;
|
||||
//textureDesc.SampleDesc.Quality = 0; // auto-fill in device
|
||||
//textureDesc.SampleDesc.Quality = 0; // auto-fill in device to maximum
|
||||
textureDesc.Usage = USAGE_DEFAULT;
|
||||
textureDesc.BindFlags = BIND_RENDER_TARGET | BIND_SHADER_RESOURCE;
|
||||
textureDesc.CPUAccessFlags = 0;
|
||||
@@ -83,10 +75,7 @@ void wiRenderTarget::Initialize(UINT width, UINT height, bool hasDepth
|
||||
}
|
||||
void wiRenderTarget::InitializeCube(UINT size, bool hasDepth, FORMAT format, UINT mipMapLevelCount, bool depthOnly)
|
||||
{
|
||||
clear();
|
||||
|
||||
isCube = true;
|
||||
|
||||
CleanUp();
|
||||
|
||||
if (!depthOnly)
|
||||
{
|
||||
@@ -98,7 +87,7 @@ void wiRenderTarget::InitializeCube(UINT size, bool hasDepth, FORMAT format, UIN
|
||||
textureDesc.ArraySize = 6;
|
||||
textureDesc.Format = format;
|
||||
textureDesc.SampleDesc.Count = 1;
|
||||
//textureDesc.SampleDesc.Quality = 0; // auto-fill in device
|
||||
textureDesc.SampleDesc.Quality = 0;
|
||||
textureDesc.Usage = USAGE_DEFAULT;
|
||||
textureDesc.BindFlags = BIND_RENDER_TARGET | BIND_SHADER_RESOURCE;
|
||||
textureDesc.CPUAccessFlags = 0;
|
||||
@@ -109,8 +98,8 @@ void wiRenderTarget::InitializeCube(UINT size, bool hasDepth, FORMAT format, UIN
|
||||
}
|
||||
|
||||
numViews = 1;
|
||||
renderTargets_Cube.push_back(nullptr);
|
||||
wiRenderer::GetDevice()->CreateTextureCube(&textureDesc, nullptr, &renderTargets_Cube[0]);
|
||||
renderTargets.push_back(nullptr);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&textureDesc, nullptr, &renderTargets[0]);
|
||||
}
|
||||
|
||||
viewPort.Width = (FLOAT)size;
|
||||
@@ -136,12 +125,6 @@ void wiRenderTarget::Add(FORMAT format)
|
||||
renderTargets.push_back(nullptr);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&desc, nullptr, &renderTargets.back());
|
||||
}
|
||||
else if (!renderTargets_Cube.empty())
|
||||
{
|
||||
numViews++;
|
||||
renderTargets_Cube.push_back(nullptr);
|
||||
wiRenderer::GetDevice()->CreateTextureCube(&desc, nullptr, &renderTargets_Cube.back());
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0 && "Rendertarget Add failed because it is not properly initilaized!");
|
||||
@@ -179,12 +162,12 @@ void wiRenderTarget::Deactivate(GRAPHICSTHREAD threadID)
|
||||
void wiRenderTarget::Set(GRAPHICSTHREAD threadID, bool disableColor)
|
||||
{
|
||||
wiRenderer::GetDevice()->BindViewports(1, &viewPort, threadID);
|
||||
wiRenderer::GetDevice()->BindRenderTargets(disableColor ? 0 : numViews, disableColor ? nullptr : (isCube ? (Texture2D**)renderTargets_Cube.data() : renderTargets.data()), (depth ? depth->GetTexture() : nullptr), threadID);
|
||||
wiRenderer::GetDevice()->BindRenderTargets(disableColor ? 0 : numViews, disableColor ? nullptr : renderTargets.data(), (depth ? depth->GetTexture() : nullptr), threadID);
|
||||
}
|
||||
void wiRenderTarget::Set(GRAPHICSTHREAD threadID, wiDepthTarget* getDepth, bool disableColor)
|
||||
{
|
||||
wiRenderer::GetDevice()->BindViewports(1, &viewPort, threadID);
|
||||
wiRenderer::GetDevice()->BindRenderTargets(disableColor ? 0 : numViews, disableColor ? nullptr : (isCube ? (Texture2D**)renderTargets_Cube.data() : renderTargets.data()), (getDepth ? getDepth->GetTexture() : nullptr), threadID);
|
||||
wiRenderer::GetDevice()->BindRenderTargets(disableColor ? 0 : numViews, disableColor ? nullptr : renderTargets.data(), (getDepth ? getDepth->GetTexture() : nullptr), threadID);
|
||||
}
|
||||
|
||||
UINT wiRenderTarget::GetMipCount()
|
||||
|
||||
@@ -9,10 +9,7 @@ class wiRenderTarget
|
||||
{
|
||||
private:
|
||||
int numViews;
|
||||
void clear();
|
||||
vector<wiGraphicsTypes::Texture2D*> renderTargets;
|
||||
vector<wiGraphicsTypes::TextureCube*> renderTargets_Cube;
|
||||
bool isCube;
|
||||
public:
|
||||
wiGraphicsTypes::ViewPort viewPort;
|
||||
wiDepthTarget* depth;
|
||||
@@ -20,6 +17,7 @@ public:
|
||||
wiRenderTarget();
|
||||
wiRenderTarget(UINT width, UINT height, bool hasDepth = false, wiGraphicsTypes::FORMAT format = wiGraphicsTypes::FORMAT_R8G8B8A8_UNORM, UINT mipMapLevelCount = 1, UINT MSAAC = 1, bool depthOnly = false);
|
||||
~wiRenderTarget();
|
||||
void CleanUp();
|
||||
|
||||
void Initialize(UINT width, UINT height, bool hasDepth = false, wiGraphicsTypes::FORMAT format = wiGraphicsTypes::FORMAT_R8G8B8A8_UNORM, UINT mipMapLevelCount = 1, UINT MSAAC = 1, bool depthOnly = false);
|
||||
void InitializeCube(UINT size, bool hasDepth, wiGraphicsTypes::FORMAT format = wiGraphicsTypes::FORMAT_R8G8B8A8_UNORM, UINT mipMapLevelCount = 1, bool depthOnly = false);
|
||||
@@ -32,7 +30,7 @@ public:
|
||||
void Set(GRAPHICSTHREAD threadID, bool disableColor = false);
|
||||
void Set(GRAPHICSTHREAD threadID, wiDepthTarget*, bool disableColor = false);
|
||||
|
||||
wiGraphicsTypes::Texture2D* GetTexture(int viewID = 0) const{ return (isCube ? renderTargets_Cube[viewID] : renderTargets[viewID]); }
|
||||
wiGraphicsTypes::Texture2D* GetTexture(int viewID = 0) const{ return renderTargets[viewID]; }
|
||||
wiGraphicsTypes::Texture2DDesc GetDesc(int viewID = 0) const { assert(viewID < numViews); return GetTexture(viewID)->GetDesc(); }
|
||||
UINT GetMipCount();
|
||||
bool IsInitialized() const { return (numViews > 0 || depth != nullptr); }
|
||||
|
||||
+152
-53
@@ -2216,11 +2216,11 @@ void wiRenderer::DrawLights(Camera* camera, GRAPHICSTHREAD threadID)
|
||||
);
|
||||
lcb.col=XMFLOAT4(l->color.x*l->enerDis.x,l->color.y*l->enerDis.x,l->color.z*l->enerDis.x,1);
|
||||
lcb.mBiasResSoftshadow=XMFLOAT4(l->shadowBias,(float)SHADOWMAPRES,(float)SOFTSHADOW,0);
|
||||
for (unsigned int shmap = 0; shmap < l->shadowMaps_dirLight.size(); ++shmap){
|
||||
lcb.mShM[shmap]=l->shadowCam_dirLight[shmap].getVP();
|
||||
if(l->shadowMaps_dirLight[shmap].depth)
|
||||
GetDevice()->BindResourcePS(l->shadowMaps_dirLight[shmap].depth->GetTexture(),TEXSLOT_SHADOW0+shmap,threadID);
|
||||
}
|
||||
//for (unsigned int shmap = 0; shmap < l->shadowMaps_dirLight.size(); ++shmap){
|
||||
// lcb.mShM[shmap]=l->shadowCam_dirLight[shmap].getVP();
|
||||
// if(l->shadowMaps_dirLight[shmap].depth)
|
||||
// GetDevice()->BindResourcePS(l->shadowMaps_dirLight[shmap].depth->GetTexture(),TEXSLOT_SHADOW0+shmap,threadID);
|
||||
//}
|
||||
GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_DIRLIGHT],&lcb,threadID);
|
||||
|
||||
GetDevice()->Draw(3, threadID);
|
||||
@@ -2233,12 +2233,12 @@ void wiRenderer::DrawLights(Camera* camera, GRAPHICSTHREAD threadID)
|
||||
lcb.enerdis=l->enerDis;
|
||||
lcb.enerdis.w = 0.f;
|
||||
|
||||
if (l->shadow && l->shadowMap_index>=0)
|
||||
{
|
||||
lcb.enerdis.w = 1.f;
|
||||
if(Light::shadowMaps_pointLight[l->shadowMap_index].depth)
|
||||
GetDevice()->BindResourcePS(Light::shadowMaps_pointLight[l->shadowMap_index].depth->GetTexture(), TEXSLOT_SHADOW_CUBE, threadID);
|
||||
}
|
||||
//if (l->shadow && l->shadowMap_index>=0)
|
||||
//{
|
||||
// lcb.enerdis.w = 1.f;
|
||||
// if(Light::shadowMaps_pointLight[l->shadowMap_index].depth)
|
||||
// GetDevice()->BindResourcePS(Light::shadowMaps_pointLight[l->shadowMap_index].depth->GetTexture(), TEXSLOT_SHADOW_CUBE, threadID);
|
||||
//}
|
||||
GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_POINTLIGHT], &lcb, threadID);
|
||||
|
||||
GetDevice()->Draw(240, threadID);
|
||||
@@ -2264,12 +2264,12 @@ void wiRenderer::DrawLights(Camera* camera, GRAPHICSTHREAD threadID)
|
||||
lcb.enerdis=l->enerDis;
|
||||
lcb.enerdis.z=(float)cos(l->enerDis.z/2.0);
|
||||
|
||||
if (l->shadow && l->shadowMap_index>=0)
|
||||
{
|
||||
lcb.mShM = l->shadowCam_spotLight[0].getVP();
|
||||
if(Light::shadowMaps_spotLight[l->shadowMap_index].depth)
|
||||
GetDevice()->BindResourcePS(Light::shadowMaps_spotLight[l->shadowMap_index].depth->GetTexture(), TEXSLOT_SHADOW0, threadID);
|
||||
}
|
||||
//if (l->shadow && l->shadowMap_index>=0)
|
||||
//{
|
||||
// lcb.mShM = l->shadowCam_spotLight[0].getVP();
|
||||
// if(Light::shadowMaps_spotLight[l->shadowMap_index].depth)
|
||||
// GetDevice()->BindResourcePS(Light::shadowMaps_spotLight[l->shadowMap_index].depth->GetTexture(), TEXSLOT_SHADOW0, threadID);
|
||||
//}
|
||||
GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_SPOTLIGHT], &lcb, threadID);
|
||||
|
||||
GetDevice()->Draw(192, threadID);
|
||||
@@ -2405,11 +2405,24 @@ void wiRenderer::ClearShadowMaps(GRAPHICSTHREAD threadID){
|
||||
{
|
||||
GetDevice()->UnBindResources(TEXSLOT_SHADOW0, 1 + TEXSLOT_SHADOW_CUBE - TEXSLOT_SHADOW0, threadID);
|
||||
|
||||
for (unsigned int index = 0; index < Light::shadowMaps_pointLight.size(); ++index) {
|
||||
Light::shadowMaps_pointLight[index].Activate(threadID);
|
||||
//for (unsigned int index = 0; index < Light::shadowMaps_pointLight.size(); ++index) {
|
||||
// Light::shadowMaps_pointLight[index].Activate(threadID);
|
||||
//}
|
||||
//for (unsigned int index = 0; index < Light::shadowMaps_spotLight.size(); ++index) {
|
||||
// Light::shadowMaps_spotLight[index].Activate(threadID);
|
||||
//}
|
||||
|
||||
for (UINT i = 0; i < Light::dirLightShadowMapArray->GetDesc().ArraySize; ++i)
|
||||
{
|
||||
GetDevice()->ClearDepthStencil(Light::dirLightShadowMapArray, CLEAR_DEPTH, 1.0f, 0, threadID, i);
|
||||
}
|
||||
for (unsigned int index = 0; index < Light::shadowMaps_spotLight.size(); ++index) {
|
||||
Light::shadowMaps_spotLight[index].Activate(threadID);
|
||||
for (UINT i = 0; i < Light::spotLightShadowMapArray->GetDesc().ArraySize; ++i)
|
||||
{
|
||||
GetDevice()->ClearDepthStencil(Light::spotLightShadowMapArray, CLEAR_DEPTH, 1.0f, 0, threadID, i);
|
||||
}
|
||||
for (UINT i = 0; i < Light::pointLightShadowMapArray->GetDesc().ArraySize / 6; ++i)
|
||||
{
|
||||
GetDevice()->ClearDepthStencil(Light::pointLightShadowMapArray, CLEAR_DEPTH, 1.0f, 0, threadID, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2422,6 +2435,8 @@ void wiRenderer::DrawForShadowMap(GRAPHICSTHREAD threadID)
|
||||
const FrameCulling& culling = frameCullings[getCamera()];
|
||||
const CulledList& culledLights = culling.culledLights;
|
||||
|
||||
ViewPort vp;
|
||||
|
||||
if (culledLights.size() > 0)
|
||||
{
|
||||
|
||||
@@ -2475,13 +2490,22 @@ void wiRenderer::DrawForShadowMap(GRAPHICSTHREAD threadID)
|
||||
CulledList culledObjects;
|
||||
CulledCollection culledRenderer;
|
||||
|
||||
if (!l->shadowMaps_dirLight[index].IsInitialized() || l->shadowMaps_dirLight[index].depth->GetDesc().Height != SHADOWMAPRES)
|
||||
{
|
||||
// Create the shadow map
|
||||
l->shadowMaps_dirLight[index].Initialize(SHADOWMAPRES, SHADOWMAPRES, true, FORMAT_R32_FLOAT, 1, 1, true);
|
||||
}
|
||||
//if (!l->shadowMaps_dirLight[index].IsInitialized() || l->shadowMaps_dirLight[index].depth->GetDesc().Height != SHADOWMAPRES)
|
||||
//{
|
||||
// // Create the shadow map
|
||||
// l->shadowMaps_dirLight[index].Initialize(SHADOWMAPRES, SHADOWMAPRES, true, FORMAT_R32_FLOAT, 1, 1, true);
|
||||
//}
|
||||
|
||||
l->shadowMaps_dirLight[index].Activate(threadID);
|
||||
//l->shadowMaps_dirLight[index].Activate(threadID);
|
||||
|
||||
vp.TopLeftX = 0;
|
||||
vp.TopLeftY = 0;
|
||||
vp.Width = (float)SHADOWMAPRES;
|
||||
vp.Height = (float)SHADOWMAPRES;
|
||||
vp.MinDepth = 0.0f;
|
||||
vp.MaxDepth = 1.0f;
|
||||
GetDevice()->BindViewports(1, &vp, threadID);
|
||||
GetDevice()->BindRenderTargets(0, nullptr, Light::dirLightShadowMapArray, threadID, /*l->shadowMap_index * 3 + */index);
|
||||
|
||||
const float siz = l->shadowCam_dirLight[index].size * 0.5f;
|
||||
const float f = l->shadowCam_dirLight[index].farplane;
|
||||
@@ -2580,7 +2604,16 @@ void wiRenderer::DrawForShadowMap(GRAPHICSTHREAD threadID)
|
||||
CulledList culledObjects;
|
||||
CulledCollection culledRenderer;
|
||||
|
||||
Light::shadowMaps_spotLight[i].Set(threadID);
|
||||
//Light::shadowMaps_spotLight[i].Set(threadID);
|
||||
vp.TopLeftX = 0;
|
||||
vp.TopLeftY = 0;
|
||||
vp.Width = (float)SPOTLIGHTSHADOWRES;
|
||||
vp.Height = (float)SPOTLIGHTSHADOWRES;
|
||||
vp.MinDepth = 0.0f;
|
||||
vp.MaxDepth = 1.0f;
|
||||
GetDevice()->BindViewports(1, &vp, threadID);
|
||||
GetDevice()->BindRenderTargets(0, nullptr, Light::spotLightShadowMapArray, threadID, l->shadowMap_index);
|
||||
|
||||
Frustum frustum;
|
||||
frustum.ConstructFrustum(wiRenderer::getCamera()->zFarP, l->shadowCam_spotLight[0].Projection, l->shadowCam_spotLight[0].View);
|
||||
if (spTree)
|
||||
@@ -2679,7 +2712,15 @@ void wiRenderer::DrawForShadowMap(GRAPHICSTHREAD threadID)
|
||||
|
||||
l->shadowMap_index = i;
|
||||
|
||||
Light::shadowMaps_pointLight[i].Set(threadID);
|
||||
//Light::shadowMaps_pointLight[i].Set(threadID);
|
||||
vp.TopLeftX = 0;
|
||||
vp.TopLeftY = 0;
|
||||
vp.Width = (float)POINTLIGHTSHADOWRES;
|
||||
vp.Height = (float)POINTLIGHTSHADOWRES;
|
||||
vp.MinDepth = 0.0f;
|
||||
vp.MaxDepth = 1.0f;
|
||||
GetDevice()->BindViewports(1, &vp, threadID);
|
||||
GetDevice()->BindRenderTargets(0, nullptr, Light::pointLightShadowMapArray, threadID, l->shadowMap_index);
|
||||
|
||||
//MAPPED_SUBRESOURCE mappedResource;
|
||||
PointLightCB lcb;
|
||||
@@ -2776,28 +2817,86 @@ void wiRenderer::SetDirectionalLightShadowProps(int resolution, int softShadowQu
|
||||
{
|
||||
SHADOWMAPRES = resolution;
|
||||
SOFTSHADOW = softShadowQuality;
|
||||
|
||||
SAFE_DELETE(Light::dirLightShadowMapArray);
|
||||
Light::dirLightShadowMapArray = new Texture2D;
|
||||
Light::dirLightShadowMapArray->RequestIndepententRenderTargetArraySlices(true);
|
||||
|
||||
Texture2DDesc desc;
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
desc.Width = SHADOWMAPRES;
|
||||
desc.Height = SHADOWMAPRES;
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 3;
|
||||
desc.Format = FORMAT_R32_TYPELESS;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.SampleDesc.Quality = 0;
|
||||
desc.Usage = USAGE_DEFAULT;
|
||||
desc.BindFlags = BIND_DEPTH_STENCIL | BIND_SHADER_RESOURCE;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = 0;
|
||||
GetDevice()->CreateTexture2D(&desc, nullptr, &Light::dirLightShadowMapArray);
|
||||
}
|
||||
void wiRenderer::SetPointLightShadowProps(int shadowMapCount, int resolution)
|
||||
{
|
||||
POINTLIGHTSHADOW = shadowMapCount;
|
||||
POINTLIGHTSHADOWRES = resolution;
|
||||
Light::shadowMaps_pointLight.clear();
|
||||
Light::shadowMaps_pointLight.resize(shadowMapCount);
|
||||
for (int i = 0; i < shadowMapCount; ++i)
|
||||
{
|
||||
Light::shadowMaps_pointLight[i].InitializeCube(POINTLIGHTSHADOWRES, true, FORMAT_R32_FLOAT, 1, true);
|
||||
}
|
||||
//Light::shadowMaps_pointLight.clear();
|
||||
//Light::shadowMaps_pointLight.resize(shadowMapCount);
|
||||
//for (int i = 0; i < shadowMapCount; ++i)
|
||||
//{
|
||||
// Light::shadowMaps_pointLight[i].InitializeCube(POINTLIGHTSHADOWRES, true, FORMAT_R32_FLOAT, 1, true);
|
||||
//}
|
||||
|
||||
SAFE_DELETE(Light::pointLightShadowMapArray);
|
||||
Light::pointLightShadowMapArray = new Texture2D;
|
||||
Light::pointLightShadowMapArray->RequestIndepententRenderTargetArraySlices(true);
|
||||
Light::pointLightShadowMapArray->RequestIndepententRenderTargetCubemapFaces(false);
|
||||
|
||||
Texture2DDesc desc;
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
desc.Width = POINTLIGHTSHADOWRES;
|
||||
desc.Height = POINTLIGHTSHADOWRES;
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 6 * POINTLIGHTSHADOW;
|
||||
desc.Format = FORMAT_R32_TYPELESS;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.SampleDesc.Quality = 0;
|
||||
desc.Usage = USAGE_DEFAULT;
|
||||
desc.BindFlags = BIND_DEPTH_STENCIL | BIND_SHADER_RESOURCE;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = RESOURCE_MISC_TEXTURECUBE;
|
||||
GetDevice()->CreateTexture2D(&desc, nullptr, &Light::pointLightShadowMapArray);
|
||||
}
|
||||
void wiRenderer::SetSpotLightShadowProps(int shadowMapCount, int resolution)
|
||||
{
|
||||
SPOTLIGHTSHADOW = shadowMapCount;
|
||||
SPOTLIGHTSHADOWRES = resolution;
|
||||
Light::shadowMaps_spotLight.clear();
|
||||
Light::shadowMaps_spotLight.resize(shadowMapCount);
|
||||
for (int i = 0; i < shadowMapCount; ++i)
|
||||
{
|
||||
Light::shadowMaps_spotLight[i].Initialize(SPOTLIGHTSHADOWRES, SPOTLIGHTSHADOWRES, true, FORMAT_R32_FLOAT, 1, 1, true);
|
||||
}
|
||||
//Light::shadowMaps_spotLight.clear();
|
||||
//Light::shadowMaps_spotLight.resize(shadowMapCount);
|
||||
//for (int i = 0; i < shadowMapCount; ++i)
|
||||
//{
|
||||
// Light::shadowMaps_spotLight[i].Initialize(SPOTLIGHTSHADOWRES, SPOTLIGHTSHADOWRES, true, FORMAT_R32_FLOAT, 1, 1, true);
|
||||
//}
|
||||
|
||||
SAFE_DELETE(Light::spotLightShadowMapArray);
|
||||
Light::spotLightShadowMapArray = new Texture2D;
|
||||
Light::spotLightShadowMapArray->RequestIndepententRenderTargetArraySlices(true);
|
||||
|
||||
Texture2DDesc desc;
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
desc.Width = SPOTLIGHTSHADOWRES;
|
||||
desc.Height = SPOTLIGHTSHADOWRES;
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = SPOTLIGHTSHADOW;
|
||||
desc.Format = FORMAT_R32_TYPELESS;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.SampleDesc.Quality = 0;
|
||||
desc.Usage = USAGE_DEFAULT;
|
||||
desc.BindFlags = BIND_DEPTH_STENCIL | BIND_SHADER_RESOURCE;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = 0;
|
||||
GetDevice()->CreateTexture2D(&desc, nullptr, &Light::spotLightShadowMapArray);
|
||||
}
|
||||
|
||||
PSTYPES GetPSTYPE(SHADERTYPE shaderType, const Material* const material)
|
||||
@@ -3787,18 +3886,18 @@ void wiRenderer::EnableForwardShadowmaps(GRAPHICSTHREAD threadID)
|
||||
{
|
||||
case Light::DIRECTIONAL:
|
||||
{
|
||||
DirectionalLightCB lcb;
|
||||
lcb.direction = XMVector3Normalize(
|
||||
-XMVector3Transform(XMVectorSet(0, -1, 0, 1), XMMatrixRotationQuaternion(XMLoadFloat4(&l->rotation)))
|
||||
);
|
||||
lcb.col = XMFLOAT4(l->color.x*l->enerDis.x, l->color.y*l->enerDis.x, l->color.z*l->enerDis.x, 1);
|
||||
lcb.mBiasResSoftshadow = XMFLOAT4(l->shadowBias, (float)SHADOWMAPRES, (float)SOFTSHADOW, 0);
|
||||
for (unsigned int shmap = 0; shmap < l->shadowMaps_dirLight.size(); ++shmap) {
|
||||
lcb.mShM[shmap] = l->shadowCam_dirLight[shmap].getVP();
|
||||
if (l->shadowMaps_dirLight[shmap].depth)
|
||||
GetDevice()->BindResourcePS(l->shadowMaps_dirLight[shmap].depth->GetTexture(), TEXSLOT_SHADOW0 + shmap, threadID);
|
||||
}
|
||||
GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_DIRLIGHT], &lcb, threadID);
|
||||
//DirectionalLightCB lcb;
|
||||
//lcb.direction = XMVector3Normalize(
|
||||
// -XMVector3Transform(XMVectorSet(0, -1, 0, 1), XMMatrixRotationQuaternion(XMLoadFloat4(&l->rotation)))
|
||||
//);
|
||||
//lcb.col = XMFLOAT4(l->color.x*l->enerDis.x, l->color.y*l->enerDis.x, l->color.z*l->enerDis.x, 1);
|
||||
//lcb.mBiasResSoftshadow = XMFLOAT4(l->shadowBias, (float)SHADOWMAPRES, (float)SOFTSHADOW, 0);
|
||||
//for (unsigned int shmap = 0; shmap < l->shadowMaps_dirLight.size(); ++shmap) {
|
||||
// lcb.mShM[shmap] = l->shadowCam_dirLight[shmap].getVP();
|
||||
// if (l->shadowMaps_dirLight[shmap].depth)
|
||||
// GetDevice()->BindResourcePS(l->shadowMaps_dirLight[shmap].depth->GetTexture(), TEXSLOT_SHADOW0 + shmap, threadID);
|
||||
//}
|
||||
//GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_DIRLIGHT], &lcb, threadID);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -130,7 +130,7 @@ Texture2D* wiTextureHelper::wiTextureHelperInstance::getColor(const wiColor& col
|
||||
data[i + 3] = color.a;
|
||||
}
|
||||
|
||||
Texture2D* texture;
|
||||
Texture2D* texture = nullptr;
|
||||
if (FAILED(CreateTexture(texture, data, 1, 1, 4)))
|
||||
{
|
||||
delete[] data;
|
||||
|
||||
Reference in New Issue
Block a user