light update fix
This commit is contained in:
+10
-14
@@ -3901,15 +3901,13 @@ void Light::UpdateLight()
|
||||
else if (type == Light::SPOT) {
|
||||
if (shadow)
|
||||
{
|
||||
if (!shadowCam_spotLight.empty())
|
||||
{
|
||||
shadowCam_spotLight[0].Update(XMLoadFloat4x4(&world));
|
||||
shadowCam_spotLight[0].Create_Perspective(XM_PIDIV2);
|
||||
}
|
||||
else
|
||||
if (shadowCam_spotLight.empty())
|
||||
{
|
||||
shadowCam_spotLight.push_back(SHCAM(XMFLOAT4(0, 0, 0, 1), 0.1f, 1000.0f, enerDis.z));
|
||||
}
|
||||
shadowCam_spotLight[0].Update(XMLoadFloat4x4(&world));
|
||||
shadowCam_spotLight[0].farplane = enerDis.y;
|
||||
shadowCam_spotLight[0].Create_Perspective(enerDis.z);
|
||||
}
|
||||
|
||||
bounds.createFromHalfWidth(translation, XMFLOAT3(enerDis.y, enerDis.y, enerDis.y));
|
||||
@@ -3917,14 +3915,7 @@ void Light::UpdateLight()
|
||||
else if (type == Light::POINT) {
|
||||
if (shadow)
|
||||
{
|
||||
if (!shadowCam_pointLight.empty())
|
||||
{
|
||||
for (unsigned int i = 0; i < shadowCam_pointLight.size(); ++i) {
|
||||
shadowCam_pointLight[i].Update(XMLoadFloat3(&translation));
|
||||
shadowCam_pointLight[i].Create_Perspective(XM_PIDIV2);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (shadowCam_pointLight.empty())
|
||||
{
|
||||
shadowCam_pointLight.push_back(SHCAM(XMFLOAT4(0.5f, -0.5f, -0.5f, -0.5f), 0.1f, 1000.0f, XM_PIDIV2)); //+x
|
||||
shadowCam_pointLight.push_back(SHCAM(XMFLOAT4(0.5f, 0.5f, 0.5f, -0.5f), 0.1f, 1000.0f, XM_PIDIV2)); //-x
|
||||
@@ -3935,6 +3926,11 @@ void Light::UpdateLight()
|
||||
shadowCam_pointLight.push_back(SHCAM(XMFLOAT4(0.707f, 0, 0, -0.707f), 0.1f, 1000.0f, XM_PIDIV2)); //+z
|
||||
shadowCam_pointLight.push_back(SHCAM(XMFLOAT4(0, 0.707f, 0.707f, 0), 0.1f, 1000.0f, XM_PIDIV2)); //-z
|
||||
}
|
||||
for (unsigned int i = 0; i < shadowCam_pointLight.size(); ++i) {
|
||||
shadowCam_pointLight[i].Update(XMLoadFloat3(&translation));
|
||||
shadowCam_spotLight[i].farplane = enerDis.y;
|
||||
shadowCam_pointLight[i].Create_Perspective(XM_PIDIV2);
|
||||
}
|
||||
}
|
||||
|
||||
bounds.createFromHalfWidth(translation, XMFLOAT3(enerDis.y, enerDis.y, enerDis.y));
|
||||
|
||||
@@ -2331,13 +2331,16 @@ void wiRenderer::DrawForShadowMap(GRAPHICSTHREAD threadID)
|
||||
switch (l->type)
|
||||
{
|
||||
case Light::SPOT:
|
||||
orderedSpotLights.insert(l);
|
||||
if(!l->shadowCam_spotLight.empty())
|
||||
orderedSpotLights.insert(l);
|
||||
break;
|
||||
case Light::POINT:
|
||||
orderedPointLights.insert(l);
|
||||
if (!l->shadowCam_pointLight.empty())
|
||||
orderedPointLights.insert(l);
|
||||
break;
|
||||
default:
|
||||
dirLights.insert(l);
|
||||
if (!l->shadowCam_dirLight.empty())
|
||||
dirLights.insert(l);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2460,14 +2463,10 @@ void wiRenderer::DrawForShadowMap(GRAPHICSTHREAD threadID)
|
||||
|
||||
Light::shadowMaps_spotLight[i].Set(threadID);
|
||||
Frustum frustum;
|
||||
XMFLOAT4X4 proj, view;
|
||||
XMStoreFloat4x4(&proj, XMLoadFloat4x4(&l->shadowCam_spotLight[0].Projection));
|
||||
XMStoreFloat4x4(&view, XMLoadFloat4x4(&l->shadowCam_spotLight[0].View));
|
||||
frustum.ConstructFrustum(wiRenderer::getCamera()->zFarP, proj, view);
|
||||
frustum.ConstructFrustum(wiRenderer::getCamera()->zFarP, l->shadowCam_spotLight[0].Projection, l->shadowCam_spotLight[0].View);
|
||||
if (spTree)
|
||||
wiSPTree::getVisible(spTree->root, frustum, culledObjects);
|
||||
|
||||
int index = 0;
|
||||
#pragma region BLOAT
|
||||
{
|
||||
if (!culledObjects.empty()) {
|
||||
@@ -2489,7 +2488,7 @@ void wiRenderer::DrawForShadowMap(GRAPHICSTHREAD threadID)
|
||||
|
||||
//MAPPED_SUBRESOURCE mappedResource;
|
||||
ShadowCB cb;
|
||||
cb.mVP = l->shadowCam_spotLight[index].getVP();
|
||||
cb.mVP = l->shadowCam_spotLight[0].getVP();
|
||||
GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_SHADOW], &cb, threadID);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user