Commit e869636c authored by D-AIRY's avatar D-AIRY

Some cleanup

parent 8e9ebaf4
......@@ -178,9 +178,6 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\source\common\file_utils.cpp" />
<ClCompile Include="..\..\..\source\common\string.cpp" />
<ClCompile Include="..\..\..\source\common\string_utils.cpp" />
<ClCompile Include="..\..\..\source\light\light.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
......@@ -195,12 +192,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\source\light\plugin_main.cpp" />
<ClCompile Include="..\..\..\source\light\shadow.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\source\light\sxlight.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
......@@ -210,15 +201,11 @@
<ClCompile Include="..\..\..\source\light\sxlight_dll.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\source\common\file_utils.h" />
<ClInclude Include="..\..\..\source\common\string.h" />
<ClInclude Include="..\..\..\source\common\string_utils.h" />
<ClInclude Include="..\..\..\source\light\LightSystem.h" />
<ClInclude Include="..\..\..\source\light\IXLight.h" />
<ClInclude Include="..\..\..\source\light\IXLightSystem.h" />
<ClInclude Include="..\..\..\source\light\light.h" />
<ClInclude Include="..\..\..\source\light\ml_data.h" />
<ClInclude Include="..\..\..\source\light\shadow.h" />
<ClInclude Include="..\..\..\source\light\sxlight.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
......
......@@ -4,24 +4,12 @@
<ClCompile Include="..\..\..\source\light\ml_data.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\light\shadow.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\light\sxlight.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\light\light.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\common\string.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\common\file_utils.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\common\string_utils.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\light\sxlight_dll.cpp">
<Filter>Source</Filter>
</ClCompile>
......@@ -41,9 +29,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\source\light\shadow.h">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\light\sxlight.h">
<Filter>Headers</Filter>
</ClInclude>
......@@ -53,15 +38,6 @@
<ClInclude Include="..\..\..\source\light\ml_data.h">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\common\string.h">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\common\file_utils.h">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\common\string_utils.h">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\light\IXLight.h">
<Filter>Headers</Filter>
</ClInclude>
......
......@@ -53,13 +53,6 @@ void CLevel::clear()
}
mem_release(m_pSun);
#if 0
if(!m_isServerMode)
{
SLight_ClearIDArr();
}
#endif
//SGame_UnloadObjLevel();
// Core_0ConsoleExecCmd("ent_unload_level");
// SPhysics_UnloadGeom();
......
This diff is collapsed.
......@@ -12,255 +12,12 @@ See the license in LICENSE
//#define SM_D3D_CONVERSIONS
#include <common/Math.h>
#include <common/Array.h>
#include <common/String.h>
#include <graphix/graphix.h>
#include <xcommon/IXMutationObserver.h>
#include "sxlight.h"
#include "ml_data.h"
#define LIGHTS_PRE_COND_ID(id,stdval) \
if (!(id >= 0 && id < (ID)m_aLights.size()))\
{LibReport(REPORT_MSG_LEVEL_ERROR, "%s - light: unresolved index of access '%d'", GEN_MSG_LOCATION, id); return stdval; }\
else if (!m_aLights[id]) \
{LibReport(REPORT_MSG_LEVEL_ERROR, "%s - light: light is deleted '%d'", GEN_MSG_LOCATION, id); return stdval; }
#define LIGHTS_PRE_COND_KEY_DEL(key,stdval) \
if (!(key >= 0 && key < (ID)m_aDelLights.size()))\
{LibReport(REPORT_MSG_LEVEL_ERROR, "%s - light: unresolved key of access '%d'", GEN_MSG_LOCATION, key); return stdval; }
#include "shadow.h"
class CLights
{
public:
CLights();
~CLights();
ID createCopy(ID id);
IXLight *getIXLight(ID id);
#if 0
void onLostDevice();
void onResetDevice();
#endif
int getCountLights() const;
void clear();
void resetUpdate4Local();
//очистка массивов идентификацторов (просчетов видимости)
void clearIDArr();
bool getExists(ID id) const;
ID createPoint(ID id, const float3 *pCenter, float fDist, const float3 *pColor, bool isGlobal, bool isShadow);
ID createDirection(ID id, const float3 *pPos, float fDist, const float3 *pColor, const SMQuaternion *pOrient, float fTopRadius, float fAngle, bool isShadow);
void deleteLight(ID id);
void render(ID id, DWORD timeDelta);
ID getLightGlobal() const;
bool getCastGlobalShadow() const;
void setCastGlobalShadow(bool isShadowed);
//-----------------------------------------------------------------------------
char* getLightName(ID id);
void setLightName(ID id, const char *szName);
void getLightColor(ID id, float3 *pVec) const;
void setLightColor(ID id, const float3 *pVec);
void getLightPos(ID id, float3 *pVec, bool isGreal = false) const;
void setLightPos(ID id, const float3 *pVec, bool isGreal = false);
float getLightPower(ID id) const;
float getLightDist(ID id) const;
void setLightDist(ID id, float fRadiusHeight, bool isCreate);
void setLightShadowIntensity(ID id, float fShadowCoef);
float getLightShadowIntensity(ID id);
//-----------------------------------------------------------------------------
void getLightOrient(ID id, SMQuaternion *pQ) const;
void setLightOrient(ID id, const SMQuaternion *pQ);
float getLightTopRadius(ID id) const;
void setLightTopRadius(ID id, float fTopRadius);
float getLightAngle(ID id) const;
void setLightAngle(ID id, float fAngle, bool isCreate);
void setLightCubeEdgeEnable(ID id, int iEdge, bool isEnable);
bool getLightCubeEdgeEnable(ID id, int iEdge) const;
//-----------------------------------------------------------------------------
void setShadowBias(ID id, float fVal);
float getShadowBias(ID id) const;
void setShadowBlurPixel(ID id, float fBlurPixel);
float getShadowBlurPixel(ID id) const;
void setShadowLocalNear(ID id, float fSlnear);
float getShadowLocalNear(ID id) const;
void setShadowLocalFar(ID id, float fSlfar);
float getShadowLocalFar(ID id) const;
//-----------------------------------------------------------------------------
bool comVisibleForFrustum(ID id, const IFrustum *pFrustum);
bool getVisibleForFrustum(ID id);
float comDistFor(ID id, const float3 *pVec);
float getDistFor(ID id);
void comVisibleFrustumDistFor(const IFrustum *pFrustum, const float3 *pVec);
//-----------------------------------------------------------------------------
#if 0
bool getLightEnable(ID id) const;
void setLightEnable(ID id, bool val);
bool getLightShadowed(ID id) const;
LTYPE_LIGHT getLightType(ID id) const;
void setLightTypeShadowed(ID id, LTYPE_SHADOW typeShadow);
LTYPE_SHADOW getLightTypeShadowed(ID id) const;
#endif
//-----------------------------------------------------------------------------
IGXTexture2D* getShadow2();
void shadowRenderBegin(ID id);
void shadowRenderEnd(ID id);
void shadowRenderPre(ID id, int iCube);
void shadowRenderPost(ID id, int iCube);
//-----------------------------------------------------------------------------
void initShaderOfTypeMaterial(ID id, int iTypeMat, const float4x4 *pWorldMat);
//-----------------------------------------------------------------------------
IFrustum* getLightFrustum(ID id, int iHow) const;
IFrustum* getLightFrustumG(ID id, int iSplit) const;
void updateLightGFrustums(ID id, int iSplit, const float3 *pPos, const float3 *pDir);
//-----------------------------------------------------------------------------
ID getLightIDArr(ID id, ID inid, int iHow);
void setLightIDArr(ID id, ID inid, int iHow, ID idArr);
//-----------------------------------------------------------------------------
bool lightCountUpdateUpdate(ID id, const float3 *pViewPos, int iGhow = -1);
bool lightCountUpdateAllowed(ID id, int iGhow = -1) const;
void lightCountUpdateNull(ID id);
//-----------------------------------------------------------------------------
void toneMappingCom(DWORD timeDelta, float fFactorAdapted = 10);
//-----------------------------------------------------------------------------
void set4Or3Splits(ID id, bool is4);
bool get4Or3Splits(ID id);
//-----------------------------------------------------------------------------
void shadowGen(ID id);
void shadowNull();
void shadowGen2(ID id);
void shadowSoft(bool useRandomSam, float fSize, bool isFirst = false);
//-----------------------------------------------------------------------------
int delGetCount();
LTYPE_LIGHT delGetType(ID idKey);
void delDel(ID idKey);
ID delGetIDArr(ID idKey, ID inid, int iHow);
//-----------------------------------------------------------------------------
struct CLight
{
CLight();
~CLight();
SX_ALIGNED_OP_MEM;
ID m_id;
IXLight *m_pIXLight = NULL;
LTYPE_LIGHT m_typeLight;
char m_szName[OBJECT_NAME_MAX_LEN];
bool m_isVisible;
bool m_isEnable;
bool m_isGlobal;
LTYPE_SHADOW m_typeShadowed;
int m_iCountUpdate;
IMesh *m_pMesh;
float3 m_vPosition;
float m_fPower;
float m_fDist;
float m_fGAngleX, m_fGAngleY; //sun pos
SMQuaternion m_qQuaternion;
float3 m_vColor;
float2_t m_vTopBottomRadius;
float m_fAngle;
float m_fShadowIntensity;
void *m_pBoundVolume;
float4x4 m_mWorldMat;
bool m_isVSDataDirty = false;
IGXConstantBuffer *m_pVSData = NULL;
bool m_isVisibleFor;
float m_fDistFor;
//PSSM *m_pShadowPSSM;
//ShadowMapTech *m_pShadowSM;
//ShadowMapCubeTech *m_pShadowCube;
};
protected:
ID addLight(CLight *pObj);
//! массив всех элементов, основанный на id
Array<CLight*> m_aLights;
//! массив света который надо удалить
Array<CLight*> m_aDelLights;
//!
Array<ID> m_aFreeIDs;
ID m_idShadowMap;
ID m_idShadowMap2;
int m_iHowShadow;
ID m_idGlobalLight;
bool m_isCastGlobalShadow;
};
class CLightSystem;
class CXLight: public virtual IXLight
{
......
......@@ -10,34 +10,8 @@ namespace light_data
{
void Init();
void ReCalcSize();
IGXDevice *pDXDevice = 0;
//размер текстуры глубины дл¤ локальных источников света
float2_t vSizeTexDepthGlobal = float2_t(1024, 768);
//размер текстуры глубины дл¤ локальных источников света
float2_t vSizeTexDepthLocal = float2_t(1024, 768);
//дистанции дл¤ 4 сплитов дл¤ глоальных теней PSSM
float4_t vDistForPSSM = float4_t(10.f, 40.f, 100.f, 200.f);
//коэфициент размера текстур дл¤ карт глубин локальных источников света
float fCoefSizeDepthMapForLocal = 2;
//коэфициент размера текстур дл¤ карт глубин глобального источника света
float fCoefSizeDepthMapForGlobal = 1;
bool isHalfGenPCFShadowLocal = false;
//ориентаци¤ и верхний вектор дл¤ рендера в кубическую текстуру
float3 vOrientedCube[6] = { float3(1, 0, 0), float3(-1, 0, 0), float3(0, 1, 0), float3(0, -1, 0), float3(0, 0, 1), float3(0, 0, -1) };
float3 vUpVectorsCube[6] = { float3(0, 1, 0), float3(0, 1, 0), float3(0, 0, -1), float3(0, 0, 1), float3(0, 1, 0), float3(0, 1, 0) };
float4x4 mRefProjPlane;
float4x4 mRefProjCube;
IGXSamplerState *pSamplerPointClamp;
IGXSamplerState *pSamplerLinearClamp;
IGXSamplerState *pSamplerPointWrap;
......@@ -125,25 +99,8 @@ namespace light_data
ID idLightBound;
};
};
namespace texture_id
{
ID idNoiseTex;
};
};
void light_data::ReCalcSize()
{
static const int *r_win_width = GET_PCVAR_INT("r_win_width");
static const int *r_win_height = GET_PCVAR_INT("r_win_height");
vSizeTexDepthGlobal.x = float(*r_win_width) * light_data::fCoefSizeDepthMapForGlobal;
vSizeTexDepthGlobal.y = float(*r_win_height) * light_data::fCoefSizeDepthMapForGlobal;
vSizeTexDepthLocal.x = float(*r_win_width) * light_data::fCoefSizeDepthMapForLocal;
vSizeTexDepthLocal.y = float(*r_win_height) * light_data::fCoefSizeDepthMapForLocal;
}
void light_data::Init()
{
light_data::pDXDevice = SGCore_GetDXDevice();
......
......@@ -21,36 +21,8 @@ namespace light_data
{
void Init();
void ReCalcSize();
extern IGXDevice *pDXDevice;
//размер текстуры глубины дл¤ локальных источников света
extern float2_t vSizeTexDepthGlobal;
//размер текстуры глубины дл¤ локальных источников света
extern float2_t vSizeTexDepthLocal;
//дистанции дл¤ 4 сплитов дл¤ глоальных теней PSSM
extern float4_t vDistForPSSM;
//коэфициент размера текстур дл¤ карт глубин локальных источников света
extern float fCoefSizeDepthMapForLocal;
//коэфициент размера текстур дл¤ карт глубин глобального источника света
extern float fCoefSizeDepthMapForGlobal;
extern float2_t vSizeTexReflection;
extern bool isHalfGenPCFShadowLocal;
//ориентаци¤ и верхний вектор дл¤ рендера в кубическую текстуру
extern float3 vOrientedCube[6];
extern float3 vUpVectorsCube[6];
extern float4x4 mRefProjPlane;
extern float4x4 mRefProjCube;
extern IGXSamplerState *pSamplerPointClamp;
extern IGXSamplerState *pSamplerLinearClamp;
extern IGXSamplerState *pSamplerPointWrap;
......@@ -138,11 +110,6 @@ namespace light_data
extern ID idLightBound;
};
};
namespace texture_id
{
extern ID idNoiseTex;
};
};
#endif
\ No newline at end of file
This diff is collapsed.
/***********************************************************
Copyright © Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
See the license in LICENSE
***********************************************************/
#ifndef __SHADOW_H
#define __SHADOW_H
#include <gdefines.h>
//#define SM_D3D_CONVERSIONS
#include <common/Math.h>
#include <common/Array.h>
#include <graphix/graphix.h>
#include <gcore/sxgcore.h>
#include "sxlight.h"
#include "ml_data.h"
class PSSM
{
public:
PSSM();
~PSSM();
void onLostDevice();
void onResetDevice();
SX_ALIGNED_OP_MEM
void init();
void updateFrustums(int iSplit, const float3 *pPosCam, const float3 *pDirCam);
void preRender(int iSplit);
void begin();
void end();
void genShadow(IGXTexture2D *pShadowMap);
void genShadowAll(IGXTexture2D *pShadowMap);
void setPosition(const float3 *pPos);
void getPosition(float3 *pPos);
void setBlurPixel(float fBlurPixel);
bool getBlurPixel();
void set4Or3Splits(bool is4);
bool get4Or3Splits();
void setIDArr(ID id, int iSplit, ID idArr);
long getCountIDArrs();
ID getIDArr(ID id, int iSplit);
IFrustum *m_aFrustums[5];
int m_aIsUpdate[5];
float2 m_aNearFar[5];
IGXTexture2D *m_aDepthMaps[5];
protected:
Array<ID*> IDArr;
float3 Position;
void flickering(float4x4 *matLVP,float size_x,float size_y);
float BlurPixel;
float2 FovRatio;
//генерация теней для 4 сплитов, иначе для 3
bool Generating4Slits;
IGXSurface* DepthSurfaces[5];
IGXDepthStencilSurface* DepthStencilSurface;
float4x4 Views[5];
float4x4 Projs[5];
float4x4 ViewProj[5];
float4x4 OldView,OldProj,OldViewProj;
float4x4 ScaleBiasMat;
IGXDepthStencilSurface* OldDepthStencilSurface;
IGXSurface* OldColorSurface;
};
//##########################################################################
class ShadowMapTech
{
public:
ShadowMapTech();
~ShadowMapTech();
void onLostDevice();
void onResetDevice();
SX_ALIGNED_OP_MEM
void init();
void setBias(float bias);
float getBias();
void setBlurPixel(float blur_pixel);
float getBlurPixel();
void begin();
void end();
void genShadow(IGXTexture2D* shadowmap);
void setPosition(const float3* pos);
void getPosition(float3* pos);
void setDirection(const float3* dir);
void getDirection(float3* dir);
void setAngleNearFar(const float3* anf);
void getAngleNearFar(float3* anf);
void setFar(float sfar);
float getFar();
void setNear(float snear);
float getNear();
void setAngle(float sangle);
float getAngle();
void setIDArr(long id, long idarr);
long getCountIDArrs();
long getIDArr(long id);
IFrustum* Frustum;
float4x4 View;
float4x4 Proj;
private:
Array<long> IDArr;
float Bias;
float BlurPixel;
float3 Position;
float3 Direction;
float3 AngleNearFar;
IGXTexture2D* DepthMap;
IGXSurface* DepthSurface;
IGXDepthStencilSurface *DepthStencilSurface;
float4x4 OldView,OldProj,OldViewProj;
float4x4 ScaleBiasMat;
IGXDepthStencilSurface* OldDepthStencilSurface;
IGXSurface* OldColorSurface;
};
//##########################################################################
class ShadowMapCubeTech
{
public:
ShadowMapCubeTech();
~ShadowMapCubeTech();
void onLostDevice();
void onResetDevice();
SX_ALIGNED_OP_MEM
void setEnableCubeEdge(int edge,bool enable);
bool getEnableCubeEdge(int edge);
void setBias(float bias);
float getBias();
void setBlurPixel(float blur_pixel);
bool getBlurPixel();