Commit 4c62a310 authored by Byurrrer's avatar Byurrrer

добавил коэффициент освещенности тени для локальных источников света, поправил...

добавил коэффициент освещенности тени для локальных источников света, поправил ошибки в sxgeom (трассировка, рендер), исправил ошибку когда очищался уровень и удалялись дефолтные для рендера объекты расчетов видимости из растительности, прибирался в редакторе уровней, много прибрал но работа еще есть, доабвил растительности чекбокс при генерации (генерация на основании усредненного rgb или по альфаканалу, добавил для создания статических моделей чекбокс segmentatiion, теперь статику можно копировать и перемещать мышкой, игровые объекты можно перемещать мышкой, статику и игровые объекты можно создавать по клику мыши, поправил баги  #221, #223, добавил спец-имена для соединений
parent a7a8ec8b
......@@ -34,7 +34,7 @@ half4 main(VSO_PP IN):COLOR0
/* расчет фонового цвета
1) интерполяция от чернобелого до цветного, на основании затенения, то есть чем больше тень тем меньше там фонового цвета
*/
half3 vAmbientColor = lerp((vAmbient.x + vAmbient.y + vAmbient.z)/3.0, vAmbient.xyz, vAmbient.w*2);
half3 vAmbientColor = lerp((vAmbient.x + vAmbient.y + vAmbient.z)/3.0, vAmbient.xyz, saturate(vAmbient.w+0.5));
/* 2) интерполяция приема цвета материалом, чем больше отражательная способность (f0) тем меньше примет цвета материал*/
vAmbientColor = lerp(vAmbientColor.xyz, 1.0, clamp(vParameters.y, F0_MIN_4_DEST_AMBIENT, vParameters.y));
......
......@@ -10,7 +10,7 @@ lighting_blend.ps
//##########################################################################
half4 g_vLightPos;
half2 g_vLightPowerDist;
half3 g_vLightPowerDistShadow;
half4 g_vViewPos;
half4 g_vLightColor;
......@@ -84,7 +84,7 @@ PSO_Lbuffer main(VSO_ResPos IN)
half4 vPosition = half4(g_vViewPos.xyz + IN.vWorldRay * fDepth, 1.0);
half fDistance = distance(vPosition.xyz, g_vLightPos.xyz);
half fInvDistance = 1.f - (fDistance/g_vLightPowerDist.y);
half fInvDistance = 1.f - (fDistance/g_vLightPowerDistShadow.y);
[branch]if(fInvDistance < 0.0)
fInvDistance = 0.0;
......@@ -128,10 +128,12 @@ PSO_Lbuffer main(VSO_ResPos IN)
fDiffuse *= max(fShadow, lerp(0.01, 0.09, g_vLightColor.w));
#endif
OUT.vAmdient.xyz = g_vLightColor.xyz * g_vLightColor.xyz * g_vLightPowerDist.x * fAttenuation;
OUT.vAmdient.w = fDiffuse * fMdiffuse * vParam.w * g_vLightPowerDist.x * 2.0 * fAttenuation;
fDiffuse = lerp(fDiffuse, 1.0, g_vLightPowerDistShadow.z);
OUT.vSpecular = fSpecular * fAbsDiffuse * fAttenuation * g_vLightPowerDist.x;
OUT.vAmdient.xyz = g_vLightColor.xyz * g_vLightColor.xyz * g_vLightPowerDistShadow.x * fAttenuation;
OUT.vAmdient.w = fDiffuse * fMdiffuse * vParam.w * g_vLightPowerDistShadow.x * 2.0 * fAttenuation;
OUT.vSpecular = fSpecular * fAbsDiffuse * fAttenuation * g_vLightPowerDistShadow.x;
return OUT;
}
\ No newline at end of file
......@@ -27,7 +27,7 @@ samplerCUBE g_sDepthShadow:register(s1);
half4 main(VSO_ResPos IN):COLOR0
{
half fShadow = 0.0;
//g_vSizeMapBias.y = -0.05;
half fDepth = tex2Dlod2(g_sDepthView, IN.vTexUV, 0).r;
half4 vPosition = half4(g_vPosCam + IN.vWorldRay * fDepth, 1.0);
......@@ -36,6 +36,7 @@ half4 main(VSO_ResPos IN):COLOR0
half fDistance = length(vDir);
half fDivDist = 1.0/fDistance;
//vDir = normalize(vDir);
half3 vTexUV = vDir.xyz;
//fShadow = (texCUBE(g_sDepthShadow , -(vTexUV) * fDivDist ).x + g_vSizeMapBias.y) > fDistance ? 1 : 0;
......
......@@ -12,6 +12,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\source\common\string.cpp" />
<ClCompile Include="..\..\..\source\common\string_utils.cpp" />
<ClCompile Include="..\..\..\source\geom\models.cpp" />
<ClCompile Include="..\..\..\source\geom\sxgeom.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
......@@ -21,6 +22,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\source\common\string.h" />
<ClInclude Include="..\..\..\source\common\string_utils.h" />
<ClInclude Include="..\..\..\source\geom\models.h" />
<ClInclude Include="..\..\..\source\geom\sxgeom.h" />
</ItemGroup>
......
......@@ -11,6 +11,9 @@
<ClCompile Include="..\..\..\source\geom\models.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\common\string_utils.cpp">
<Filter>Source</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="Source">
......@@ -30,5 +33,8 @@
<ClInclude Include="..\..\..\source\geom\models.h">
<Filter>Header</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\common\string_utils.h">
<Filter>Header</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
common @ fa73c511
Subproject commit 8bbd70ed5082cda282e26075004b685becee85f1
Subproject commit fa73c511af2276d218e37cd70c262102ad2bd7ee
......@@ -19,6 +19,8 @@ BEGIN_PROPTABLE(CLightDirectional)
DEFINE_FIELD_FLOAT(m_fDist, 0, "dist", "Distance", EDITOR_TEXTFIELD)
//! Дальность дальняя
DEFINE_FIELD_FLOAT(m_fShadowDist, 0, "shadow_dist", "Shadow distance", EDITOR_TEXTFIELD)
//! Коэффициент теней - на сколько тень черная
DEFINE_FIELD_FLOAT(m_fShadowCoef, 0, "shadow_coef", "Shadow coefficient", EDITOR_TEXTFIELD)
//! Тип тени
DEFINE_FIELD_INT(m_iShadowType, 0, "shadow_type", "Shadow type", EDITOR_COMBOBOX)
......@@ -44,6 +46,7 @@ BaseClass(pMgr)
m_fDist = 10;
m_fShadowDist = m_fDist;
m_iShadowType = 1;
m_fShadowCoef = 0;
m_fAngle = SM_PI * 0.4f;
m_fRadiusTop = 0.01f;
m_idLight = SLight_CreateDirection(&float3(0, 0, 0), m_fDist, &(float3)m_vColor, &SMQuaternion(-SM_PI, 'z'), m_fRadiusTop, m_fAngle, true);
......@@ -93,6 +96,7 @@ void CLightDirectional::onSync()
if (SLight_GetTypeShadowed(m_idLight) != m_iShadowType)
SLight_SetTypeShadowed(m_idLight, (LTYPE_SHADOW)m_iShadowType);
SLight_SetShadowCoef(m_idLight, m_fShadowCoef);
static SMQuaternion curr_rot;
SLight_GetOrient(m_idLight, &curr_rot);
......
......@@ -39,6 +39,9 @@ public:
void setShadowType(int iShadowType) { m_iShadowType = iShadowType; };
int getShadowType() const { return m_iShadowType; };
void setShadowCoef(float fShadowCoef) { m_fShadowCoef = fShadowCoef; };
float getShadowCoef() const { return m_fShadowCoef; };
void setEnable(bool isEnable) { m_isEnable = isEnable; };
bool getEnable() const { return m_isEnable; };
......@@ -58,6 +61,7 @@ protected:
float m_fDist;
float m_fShadowDist;
int m_iShadowType;
float m_fShadowCoef;
bool m_isEnable;
......
......@@ -19,6 +19,8 @@ BEGIN_PROPTABLE(CLightPoint)
DEFINE_FIELD_FLOAT(m_fDist, 0, "dist", "Distance", EDITOR_TEXTFIELD)
//! Дальность дальняя
DEFINE_FIELD_FLOAT(m_fShadowDist, 0, "light_far", "Shadow far plane", EDITOR_TEXTFIELD)
//! Коэффициент теней - на сколько тень черная
DEFINE_FIELD_FLOAT(m_fShadowCoef, 0, "shadow_coef", "Shadow coefficient", EDITOR_TEXTFIELD)
//! Тип тени
DEFINE_FIELD_INT(m_iShadowType, 0, "type_shadow", "Type shadow", EDITOR_COMBOBOX)
......@@ -50,6 +52,7 @@ BaseClass(pMgr)
m_fDist = 10;
m_fShadowDist = m_fDist;
m_iShadowType = 1;
m_fShadowCoef = 0;
m_idLight = SLight_CreatePoint(&float3(0, 0, 0), m_fDist, &(float3)m_vColor, false, true);
}
......@@ -85,6 +88,8 @@ void CLightPoint::onSync()
m_fShadowDist = m_fDist;
}
SLight_SetShadowCoef(m_idLight, m_fShadowCoef);
if (SLight_GetShadowLocalFar(m_idLight) != m_fShadowDist)
SLight_SetShadowLocalFar(m_idLight, m_fShadowDist);
......
......@@ -38,6 +38,9 @@ public:
void setShadowDist(float fShadowDist) { m_fShadowDist = fShadowDist; };
float getShadowDist() const { return m_fShadowDist; };
void setShadowCoef(float fShadowCoef) { m_fShadowCoef = fShadowCoef; };
float getShadowCoef() const { return m_fShadowCoef; };
void setShadowType(int iShadowType) { m_iShadowType = iShadowType; };
int getShadowType() const { return m_iShadowType; };
......@@ -54,6 +57,7 @@ protected:
float m_fShadowDist;
int m_iShadowType;
bool m_isEnable;
float m_fShadowCoef;
void onSync();
......
......@@ -657,6 +657,11 @@ void CBound::calcBound(IDirect3DVertexBuffer9 *pVertexBuffer, int iCountVertex,
m_vMaxOrigin = vPos;
m_vMinOrigin = vPos;
vPos = SMVector3Transform(vPos, m_mWorld);
m_vMaxTransform = vPos;
m_vMinTransform = vPos;
for (int i = 0; i<iCountVertex; ++i)
{
vPos = *(float3_t*)((char*)(pVertex)+iBytePerVertex * i);
......
......@@ -776,7 +776,7 @@ SX_LIB_API IDirect3DVertexDeclaration9* SGCore_StaticModelGetDecl();
@{*/
/*! Простой объект трансформаций с минимальным описанием.
\note Для корректного использования необходимо сначала установить позицию/поворот/масштаб после чего CalculateWorld
\note Для корректного использования необходимо сначала установить позицию/поворот/масштаб после чего calcWorld
*/
struct ITransObject : public IBaseObject
{
......
......@@ -1276,13 +1276,12 @@ ID CModels::addModel(const char *szPath, const char *szName, const char *szLod,
pModel->m_pModel->m_uiSubsetCount = iCountSubsetNew;
pModel->m_pModel->m_uiAllVertexCount = iCountVertexNew;
pModel->m_pModel->m_uiAllIndexCount = iCountIndexNew;
if (iCountSubsetNew > 0)
pModel->m_pBoundVolume->calcBound(pModel->m_pModel->m_pVertexBuffer, pModel->m_pModel->m_uiAllVertexCount, sizeof(vertex_static_ex));
//}
}
if (iCountSubsetNew > 0)
pModel->m_pBoundVolume->calcBound(pModel->m_pModel->m_pVertexBuffer, pModel->m_pModel->m_uiAllVertexCount, sizeof(vertex_static_ex));
// ,
if (pModel->m_pModel->m_uiSubsetCount > 0 && needSegmentation)
{
......@@ -1395,9 +1394,22 @@ ID CModels::copy(ID idModel)
CModel *pModel = m_aModels[idModel];
CModel *pCopy = new CModel();
pCopy->m_sName = pModel->m_sName + "-copy";
pCopy->m_sPath = pModel->m_sPath;
int iPos = StrFindI(pModel->m_sName.c_str(), GEOM_COPY_POSTFIX);
if (iPos >= 0)
{
if (pModel->m_sName.length() == iPos + strlen(GEOM_COPY_POSTFIX))
pCopy->m_sName = pModel->m_sName + "1";
else
{
String sName = StrSubstr(pModel->m_sName.c_str(), 0, iPos + strlen(GEOM_COPY_POSTFIX));
String sNum = StrSubstr(pModel->m_sName.c_str(), iPos + strlen(GEOM_COPY_POSTFIX));
pCopy->m_sName = sName + (sNum.toInt() + 1);
}
}
else
pCopy->m_sName = pModel->m_sName + GEOM_COPY_POSTFIX;
pCopy->m_sPath = pModel->m_sPath;
pCopy->m_pModel = pModel->m_pModel->getCopy();
......@@ -2748,22 +2760,22 @@ void CModels::comVisibleTransparency(const IFrustum *pFrustum, const float3 *pVi
//##########################################################################
void CModels::renderSingly(DWORD timeDelta, ID idModel, ID idMtrl)
void CModels::renderSingly(DWORD timeDelta, ID idModel, ID idMtrl, const float3 *pPos)
{
STATIC_PRECOND_MODEL_ID(idModel, _VOID);
CModel *pModel = m_aModels[idModel];
if (pModel->m_isRenderLod && pModel->m_pLod)
renderLod(timeDelta, idModel, idMtrl);
renderLod(timeDelta, idModel, idMtrl, pPos);
else
{
if (pModel->m_pModel->m_uiSubsetCount == 0)
renderObject(timeDelta, idModel, idMtrl);
if (pModel->m_pModel->m_uiSubsetCount > 0)
renderObject(timeDelta, idModel, idMtrl, pPos);
}
}
void CModels::render(DWORD timeDelta, GEOM_RENDER_TYPE type, ID idTex, ID idVisCalcObj)
void CModels::render(DWORD timeDelta, GEOM_RENDER_TYPE type, ID idVisCalcObj)
{
STATIC_PRECOND_VISCALCOBJ_ID(idVisCalcObj, _VOID);
......@@ -2775,7 +2787,7 @@ void CModels::render(DWORD timeDelta, GEOM_RENDER_TYPE type, ID idTex, ID idVisC
{
if (m_aModels[i]->m_isRenderLod && m_aModels[i]->m_pLod)
{
renderLod(timeDelta, i, idTex);
renderLod(timeDelta, i);
}
else
{
......@@ -2783,9 +2795,9 @@ void CModels::render(DWORD timeDelta, GEOM_RENDER_TYPE type, ID idTex, ID idVisC
continue;
if (m_aModels[i]->m_pArrSplits)
renderSegmets(timeDelta, i, idTex, idVisCalcObj);
renderSegmets(timeDelta, i, -1, idVisCalcObj);
else
renderObject(timeDelta, i, idTex);
renderObject(timeDelta, i);
}
}
}
......@@ -2813,7 +2825,7 @@ void CModels::render(DWORD timeDelta, GEOM_RENDER_TYPE type, ID idTex, ID idVisC
}
}
void CModels::renderLod(DWORD timeDelta, ID idModel, ID idTex)
void CModels::renderLod(DWORD timeDelta, ID idModel, ID idTex, const float3 *pPos)
{
STATIC_PRECOND_MODEL_ID(idModel, _VOID);
......@@ -2824,9 +2836,20 @@ void CModels::renderLod(DWORD timeDelta, ID idModel, ID idTex)
int iCountIndex = 0;
float4x4 mWorld;
if (pPos)
{
const float3 *pScale = m_aModels[idModel]->m_pBoundVolume->getScale();
const float3 *pRot = m_aModels[idModel]->m_pBoundVolume->getRotation();
mWorld = SMMatrixScaling(*pScale) * SMMatrixRotationX(pRot->x) * SMMatrixRotationY(pRot->y) * SMMatrixRotationZ(pRot->z) * SMMatrixTranslation(*pPos);
}
else
mWorld = *(m_aModels[idModel]->m_pBoundVolume->calcWorld());
for (int g = 0; g < m_aModels[idModel]->m_pLod->m_pModel->m_uiSubsetCount; g++)
{
SGCore_MtlSet((idTex > 0 ? idTex : m_aModels[idModel]->m_pLod->m_aIDsTextures[g]), (float4x4*)m_aModels[idModel]->m_pBoundVolume->calcWorld());
SGCore_MtlSet((idTex > 0 ? idTex : m_aModels[idModel]->m_pLod->m_aIDsTextures[g]), &mWorld);
SGCore_DIP(D3DPT_TRIANGLELIST, 0, 0, m_aModels[idModel]->m_pLod->m_pModel->m_pVertexCount[g], iCountIndex, m_aModels[idModel]->m_pLod->m_pModel->m_pIndexCount[g] / 3);
Core_RIntSet(G_RI_INT_COUNT_POLY, Core_RIntGet(G_RI_INT_COUNT_POLY) + ((m_aModels[idModel]->m_pLod->m_pModel->m_pIndexCount[g] / 3)));
......@@ -2834,7 +2857,7 @@ void CModels::renderLod(DWORD timeDelta, ID idModel, ID idTex)
}
}
void CModels::renderObject(DWORD timeDelta, ID idModel, ID idTex)
void CModels::renderObject(DWORD timeDelta, ID idModel, ID idTex, const float3 *pPos)
{
STATIC_PRECOND_MODEL_ID(idModel, _VOID);
......@@ -2849,9 +2872,20 @@ void CModels::renderObject(DWORD timeDelta, ID idModel, ID idTex)
int iCountIndex = 0;
float4x4 mWorld;
if (pPos)
{
const float3 *pScale = m_aModels[idModel]->m_pBoundVolume->getScale();
const float3 *pRot = m_aModels[idModel]->m_pBoundVolume->getRotation();
mWorld = SMMatrixScaling(*pScale) * SMMatrixRotationX(pRot->x) * SMMatrixRotationY(pRot->y) * SMMatrixRotationZ(pRot->z) * SMMatrixTranslation(*pPos);
}
else
mWorld = *(m_aModels[idModel]->m_pBoundVolume->calcWorld());
for (int g = 0; g < m_aModels[idModel]->m_pModel->m_uiSubsetCount; g++)
{
SGCore_MtlSet((idTex > 0 ? idTex : m_aModels[idModel]->m_aIDsTextures[g]), (float4x4*)m_aModels[idModel]->m_pBoundVolume->calcWorld());
SGCore_MtlSet((idTex >= 0 ? idTex : m_aModels[idModel]->m_aIDsTextures[g]), &mWorld);
SGCore_DIP(D3DPT_TRIANGLELIST, 0, 0, m_aModels[idModel]->m_pModel->m_pVertexCount[g], iCountIndex, m_aModels[idModel]->m_pModel->m_pIndexCount[g] / 3);
Core_RIntSet(G_RI_INT_COUNT_POLY, Core_RIntGet(G_RI_INT_COUNT_POLY) + ((m_aModels[idModel]->m_pModel->m_pIndexCount[g] / 3)));
......@@ -3407,6 +3441,13 @@ void CModels::modelGetGroupCenter(ID idModel, ID idGroup, float3_t *pCenter)
}
}
bool CModels::modelGerSegmentation(ID idModel)
{
STATIC_PRECOND_MODEL_ID(idModel, false);
return (m_aModels[idModel]->m_pArrSplits != NULL);
}
//##########################################################################
void CModels::getArrBuffsGeom(float3_t ***pppArrVertex, int32_t **ppArrCountVertex, uint32_t ***pppArrIndex, ID ***pppArrMtl, int32_t **ppArrCountIndex, int32_t *pCountModels)
......@@ -3605,9 +3646,17 @@ bool CModels::traceBeam(const float3 *pStart, const float3 *pDir, float3 *pResul
il = (*pDir) * 10000.0f;
bool isFound = false;
float3 vMin, vMax;
for (int id = 0; id < m_aModels.size(); ++id)
{
CModel *pModel = m_aModels[id];
pModel->m_pBoundVolume->getMinMax(&vMin, &vMax);
if (!SMBoxRayIntersection(vMin, vMax, *pStart, *pDir))
continue;
float4x4 mWorld = *(pModel->m_pBoundVolume->calcWorld());
if (pModel->m_pArrSplits)
{
getPartBeam(id, SX_GEOM_TRACEBEAM_VISCALCOBJ, pStart, pDir);
......@@ -3626,9 +3675,9 @@ bool CModels::traceBeam(const float3 *pStart, const float3 *pDir, float3 *pResul
for (int p = 0; p<m_aVisInfo[1]->m_aVisible4Model[id]->m_ppSegments[k]->m_pCountPoly[g] * 3; p += 3)
{
oTriangle.m_vA = pVertex[m_aVisInfo[1]->m_aVisible4Model[id]->m_ppSegments[k]->m_ppArrPoly[g][p]].Pos;
oTriangle.m_vB = pVertex[m_aVisInfo[1]->m_aVisible4Model[id]->m_ppSegments[k]->m_ppArrPoly[g][p + 1]].Pos;
oTriangle.m_vC = pVertex[m_aVisInfo[1]->m_aVisible4Model[id]->m_ppSegments[k]->m_ppArrPoly[g][p + 2]].Pos;
oTriangle.m_vA = SMVector3Transform(pVertex[m_aVisInfo[1]->m_aVisible4Model[id]->m_ppSegments[k]->m_ppArrPoly[g][p]].Pos, mWorld);
oTriangle.m_vB = SMVector3Transform(pVertex[m_aVisInfo[1]->m_aVisible4Model[id]->m_ppSegments[k]->m_ppArrPoly[g][p + 1]].Pos, mWorld);
oTriangle.m_vC = SMVector3Transform(pVertex[m_aVisInfo[1]->m_aVisible4Model[id]->m_ppSegments[k]->m_ppArrPoly[g][p + 2]].Pos, mWorld);
if (oTriangle.IntersectLine((*pStart), il, &ip))
{
......@@ -3654,18 +3703,18 @@ bool CModels::traceBeam(const float3 *pStart, const float3 *pDir, float3 *pResul
else
{
vertex_static_ex* pVertex;
pModel->m_pModel->m_pVertexBuffer->Lock(0, 0, (void**)&pVertex, 0);
pModel->m_pModel->m_pVertexBuffer->Lock(0, 0, (void**)&pVertex, D3DLOCK_READONLY);
UINT *pIndex;
pModel->m_pModel->m_pIndexBuffer->Lock(0, 0, (void**)&pIndex, 0);
pModel->m_pModel->m_pIndexBuffer->Lock(0, 0, (void**)&pIndex, D3DLOCK_READONLY);
for (int g = 0; g < pModel->m_pModel->m_uiSubsetCount; ++g)
{
for (int k = 0; k<pModel->m_pModel->m_pIndexCount[g]/3; k+=3)
for (int k = 0; k<pModel->m_pModel->m_pIndexCount[g]; k+=3)
{
oTriangle.m_vA = pVertex[pIndex[pModel->m_pModel->m_pStartIndex[g] + k]].Pos;
oTriangle.m_vB = pVertex[pIndex[pModel->m_pModel->m_pStartIndex[g] + k + 1]].Pos;
oTriangle.m_vC = pVertex[pIndex[pModel->m_pModel->m_pStartIndex[g] + k + 2]].Pos;
oTriangle.m_vA = SMVector3Transform(pVertex[pIndex[pModel->m_pModel->m_pStartIndex[g] + k]].Pos, mWorld);
oTriangle.m_vB = SMVector3Transform(pVertex[pIndex[pModel->m_pModel->m_pStartIndex[g] + k + 1]].Pos, mWorld);
oTriangle.m_vC = SMVector3Transform(pVertex[pIndex[pModel->m_pModel->m_pStartIndex[g] + k + 2]].Pos, mWorld);
if (oTriangle.IntersectLine((*pStart), il, &ip))
{
......@@ -3698,7 +3747,7 @@ bool CModels::traceBeam(const float3 *pStart, const float3 *pDir, float3 *pResul
pTransparencyModel->m_pVertexBuffer->Lock(0, 0, (void**)&pVertex, 0);
pTransparencyModel->m_pIndexBuffer->Lock(0, 0, (void**)&pIndex, 0);
for (int k = 0; k<pTransparencyModel->m_iCountIndex / 3; k += 3)
for (int k = 0; k<pTransparencyModel->m_iCountIndex; k += 3)
{
oTriangle.m_vA = pVertex[pIndex[k]].Pos;
oTriangle.m_vB = pVertex[pIndex[k + 1]].Pos;
......
......@@ -28,6 +28,8 @@ See the license in LICENSE
//!@}
#define GEOM_COPY_POSTFIX "-copy"
extern IDirect3DDevice9 *g_pDXDevice;
//##########################################################################
......@@ -439,6 +441,9 @@ public:
//!
void modelGetGroupCenter(ID idModel, ID idGroup, float3_t *pCenter);
//!
bool modelGerSegmentation(ID idModel);
//**********************************************************************
//!
......@@ -447,10 +452,10 @@ public:
//**********************************************************************
//!
void renderSingly(DWORD timeDelta, ID idModel, ID idMtrl = -1);
void renderSingly(DWORD timeDelta, ID idModel, ID idMtrl = -1, const float3 *pPos = 0);
//!
void render(DWORD timeDelta, GEOM_RENDER_TYPE type, ID idTex = -1, ID idVisCalcObj = SX_GEOM_DEFAULT_VISCALCOBJ);
void render(DWORD timeDelta, GEOM_RENDER_TYPE type, ID idVisCalcObj = SX_GEOM_DEFAULT_VISCALCOBJ);
//**********************************************************************
......@@ -567,10 +572,10 @@ protected:
//**********************************************************************
//!
void renderLod(DWORD timeDelta, ID idModel, ID idTex = -1);
void renderLod(DWORD timeDelta, ID idModel, ID idTex = -1, const float3 *pPos = 0);
//!
void renderObject(DWORD timeDelta, ID idModel, ID idTex = -1);
void renderObject(DWORD timeDelta, ID idModel, ID idTex = -1, const float3 *pPos = 0);
//!
void renderSegmets(DWORD timeDelta, ID idModel, ID idTex = -1, ID idVisCalcObj = SX_GEOM_DEFAULT_VISCALCOBJ);
......
......@@ -105,11 +105,11 @@ SX_LIB_API bool SGeom_TransparencyExistsForRender(ID idVisCalcObj)
return g_pModels->existsTransparency4Render(idVisCalcObj);
}
SX_LIB_API void SGeom_RenderSingly(DWORD timeDelta, ID idModel, ID idMtrl)
SX_LIB_API void SGeom_RenderSingly(DWORD timeDelta, ID idModel, ID idMtrl, const float3 *pPos)
{
GEOM_PRECOND(_VOID);
g_pModels->renderSingly(timeDelta, idModel, idMtrl);
g_pModels->renderSingly(timeDelta, idModel, idMtrl, pPos);
}
SX_LIB_API void SGeom_Render(DWORD timeDelta, GEOM_RENDER_TYPE type, ID idVisCalcObj, ID idExcludeModel, ID idExcludeGroup)
......@@ -289,6 +289,12 @@ SX_LIB_API void SGeom_ModelGetGroupMinMax(ID idModel, ID idGroup, float3_t *pMin
g_pModels->modelGetGroupMinMax(idModel, idGroup, pMin, pMax);
}
SX_LIB_API bool SGeom_ModelGetSegmentation(ID idModel)
{
GEOM_PRECOND(false);
return g_pModels->modelGerSegmentation(idModel);
}
//**************************************************************************
SX_LIB_API void SGeom_SortTransparent(const float3 *pViewPos)
......
......@@ -168,7 +168,7 @@ SX_LIB_API void SGeom_ComVisible(
SX_LIB_API bool SGeom_TransparencyExistsForRender(ID idVisCalcObj = SX_GEOM_DEFAULT_VISCALCOBJ);
//! рендер одной модели
SX_LIB_API void SGeom_RenderSingly(DWORD timeDelta, ID idModel, ID idMtrl = -1);
SX_LIB_API void SGeom_RenderSingly(DWORD timeDelta, ID idModel, ID idMtrl = -1, const float3 *pPos = 0);
//! отрисовка всех моделей, на основе информации о видимости из массива видимости idVisCalcObj
SX_LIB_API void SGeom_Render(
......@@ -302,6 +302,9 @@ SX_LIB_API void SGeom_ModelGetGroupPlane(ID idModel, ID idGroup, D3DXPLANE *pPla
//! записывает максимум и минимум подгруппы idGroup
SX_LIB_API void SGeom_ModelGetGroupMinMax(ID idModel, ID idGroup, float3_t *pMin, float3_t *pMax);
//! сегментирована ли модель
SX_LIB_API bool SGeom_ModelGetSegmentation(ID idModel);
//!@}
//**************************************************************************
......
......@@ -99,7 +99,7 @@ ID CLights::createCopy(ID id)
tmplight2->m_pShadowCube = new ShadowMapCubeTech();
tmplight2->m_pShadowCube->init();
tmplight2->m_pShadowCube->setPosition(&float3(tmplight->m_vPosition.x, tmplight->m_vPosition.y, tmplight->m_vPosition.z));
tmplight2->m_pShadowCube->setNearFar(&float2(0.1f, tmplight->m_fDist));
tmplight2->m_pShadowCube->setNearFar(&float2(LIGHTS_LOCAL_STD_NEAR, tmplight->m_fDist));
tmplight2->m_pShadowCube->setNear(tmplight2->m_pShadowCube->getNear());
tmplight2->m_pShadowCube->setFar(tmplight2->m_pShadowCube->getFar());
tmplight2->m_pShadowCube->setBias(tmplight->m_pShadowCube->getBias());
......@@ -123,6 +123,8 @@ CLights::CLight::CLight()
m_typeLight = LTYPE_LIGHT_NONE;
m_szName[0] = 0;
m_fShadowCoef = 0.01;
m_id = -1;
m_typeShadowed = LTYPE_SHADOW_STATIC;
......@@ -552,7 +554,7 @@ void CLights::setLightDist(ID id, float radius_height, bool is_create)
}
if (m_aLights[id]->m_pShadowCube)
m_aLights[id]->m_pShadowCube->setNearFar(&float2(0.1, m_aLights[id]->m_fDist));
m_aLights[id]->m_pShadowCube->setNearFar(&float2(LIGHTS_LOCAL_STD_NEAR, m_aLights[id]->m_fDist));
if (m_aLights[id]->m_pMesh)
{
......@@ -565,6 +567,17 @@ void CLights::setLightDist(ID id, float radius_height, bool is_create)
lightCountUpdateNull(id);
}
void CLights::setLightShadowCoef(ID id, float fShadowCoef)
{
LIGHTS_PRE_COND_ID(id, _VOID);
m_aLights[id]->m_fShadowCoef = fShadowCoef;
}
float CLights::getLightShadowCoef(ID id)
{
return m_aLights[id]->m_fShadowCoef;
}
void CLights::setLightPos(ID id, const float3* vec, bool greal)
{
LIGHTS_PRE_COND_ID(id, _VOID);
......@@ -1180,7 +1193,7 @@ void CLights::setLightTypeShadowed(ID id, LTYPE_SHADOW type)
m_aLights[id]->m_pShadowCube = new ShadowMapCubeTech();
m_aLights[id]->m_pShadowCube->init();
m_aLights[id]->m_pShadowCube->setPosition(&float3(m_aLights[id]->m_vPosition.x, m_aLights[id]->m_vPosition.y, m_aLights[id]->m_vPosition.z));
m_aLights[id]->m_pShadowCube->setNearFar(&float2(0.1f, m_aLights[id]->m_fDist));
m_aLights[id]->m_pShadowCube->setNearFar(&float2(LIGHTS_LOCAL_STD_NEAR, m_aLights[id]->m_fDist));
}
}
......
......@@ -79,6 +79,9 @@ public:
float getLightDist(ID id) const;
void setLightDist(ID id, float fRadiusHeight, bool isCreate);
void setLightShadowCoef(ID id, float fShadowCoef);
float getLightShadowCoef(ID id);
//-----------------------------------------------------------------------------
void getLightOrient(ID id, SMQuaternion *pQ) const;
......@@ -211,6 +214,8 @@ public:
float2_t m_vTopBottomRadius;
float m_fAngle;
float m_fShadowCoef;
ISXBound *m_pBoundVolume;
float4x4 m_mWorldMat;
......
......@@ -179,8 +179,8 @@ void light_data::Init()
D3DXMACRO Defines_GSD_9[] = { { "GSD_9", "" }, { 0, 0 } };
light_data::shader_id::ps::idGenShadowDirect9 = SGCore_ShaderLoad(SHADER_TYPE_PIXEL, "ppgensm_direct.ps", "ppgensm_direct_9.ps", SHADER_CHECKDOUBLE_NAME, Defines_GSD_9);
light_data::shader_id::ps::idGenShadowCube1 = SGCore_ShaderLoad(SHADER_TYPE_PIXEL, "ppgensm_point.ps", "ppgensm_point.ps", SHADER_CHECKDOUBLE_NAME);
D3DXMACRO Defines_GSC_9[] = { { "GSC_9", "" }, { 0, 0 } };
light_data::shader_id::ps::idGenShadowCube6 = SGCore_ShaderLoad(SHADER_TYPE_PIXEL, "ppgensm_point.ps", "ppgensm_point_9.ps", SHADER_CHECKDOUBLE_NAME, Defines_GSC_9);
D3DXMACRO Defines_GSC_6[] = { { "GSC_6", "" }, { 0, 0 } };
light_data::shader_id::ps::idGenShadowCube6 = SGCore_ShaderLoad(SHADER_TYPE_PIXEL, "ppgensm_point.ps", "ppgensm_point_6.ps", SHADER_CHECKDOUBLE_NAME, Defines_GSC_6);
light_data::shader_id::ps::idPPBlurDepthBased = SGCore_ShaderLoad(SHADER_TYPE_PIXEL, "pp_blur_depth_based.ps", "pp_blur_depth_based.ps", SHADER_CHECKDOUBLE_PATH);
light_data::shader_id::ps::idPPBlurDepthBasedNoise = SGCore_ShaderLoad(SHADER_TYPE_PIXEL, "pp_blur_depth_based_noise.ps", "pp_blur_depth_based_noise.ps", SHADER_CHECKDOUBLE_PATH);
......
......@@ -894,7 +894,7 @@ ShadowMapCubeTech::ShadowMapCubeTech()
EnableEdge[0] = EnableEdge[1] = EnableEdge[2] = EnableEdge[3] = EnableEdge[4] = EnableEdge[5] = true;
EnableEdgeNulled[0] = EnableEdgeNulled[1] = EnableEdgeNulled[2] = EnableEdgeNulled[3] = EnableEdgeNulled[4] = EnableEdgeNulled[5] = false;
Bias = 0.1f;
Bias = 0.001f;
BlurPixel = 16.0f;
DepthMap = 0;
......@@ -1141,7 +1141,7 @@ void ShadowMapCubeTech::genShadow(IDirect3DTexture9* shadowmap)
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, light_data::shader_id::ps::idGenShadowCube1, "g_vPosCam", &observerpos);
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, light_data::shader_id::ps::idGenShadowCube1, "g_vLightPos", &Position);
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, light_data::shader_id::ps::idGenShadowCube1, "g_vSizeMapBias", &float2(light_data::vSizeTexDepthLocal.x, Bias));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, light_data::shader_id::ps::idGenShadowCube1, "g_fPixelSize", &pixel_size);
//SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, light_data::shader_id::ps::idGenShadowCube1, "g_fPixelSize", &pixel_size);
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, light_data::shader_id::ps::idGenShadowCube1, "g_vLightPos", &Position);
}
else
......
......@@ -184,6 +184,18 @@ SX_LIB_API void SLight_SetCastGlobalShadow(bool isShadowed)
return ArrLights->setCastGlobalShadow(isShadowed);
}
SX_LIB_API void SLight_SetShadowCoef(ID id, float m_fShadowCoef)
{
ML_PRECOND(_VOID);
ArrLights->setLightShadowCoef(id, m_fShadowCoef);
}
SX_LIB_API float SLight_GetShadowCoef(ID id)
{
ML_PRECOND(0);
return ArrLights->getLightShadowCoef(id);
}
SX_LIB_API void SLight_GetColor(ID id, float3 *pColor)
{
ML_PRECOND(_VOID);
......
......@@ -103,7 +103,7 @@ Cчитается: LIGHTS_UPDATE_PSSM_SPLIT*number_split
#define LIGHTS_LOCAL_STD_TOP_RADIUS 0.1
/*! стандартное значение ближней плоскости отсечения для теней локального света */
#define LIGHTS_LOCAL_STD_NEAR 0.1