Commit 33efd59a authored by Byurrrer's avatar Byurrrer

добавил принудительный блум для самоосвещаемых материалов, оптимизировал...

добавил принудительный блум для самоосвещаемых материалов, оптимизировал использование рт у теней локальных источников света (временно), переместил рендер декалей, совместно поправили ошибки в рендере path_corner и мелкие внутренние ошибки реализации этого класса
parent 9b8eaadd
......@@ -2,6 +2,8 @@ echo "Executing editor config file"
cl_mode_editor 1
dbg_config_save 1
r_stats 1
hud_draw 0
......
......@@ -5,6 +5,7 @@ ppe_bloom_bp.ps
*/
#include <../struct.h>
#include <../mtrl.h>
//##########################################################################
......@@ -16,6 +17,7 @@ half3 g_vParam;
//##########################################################################
sampler2D g_sColor:register(s0);
sampler2D g_sNormals:register(s1);
//##########################################################################
......@@ -24,7 +26,10 @@ half4 main(VSO_PP IN) : COLOR0
half4 vColor = tex2D(g_sColor, IN.vTexUV);
vColor.rgb *= g_vParam.x;
vColor.a = 1.f;
[branch]if (vColor.r >= g_vParam.y && vColor.g >= g_vParam.y && vColor.b >= g_vParam.y)
half4 vNormals = tex2D(g_sNormals, IN.vTexUV);
half2 vLayerType = LayerDecode(vNormals.w);
[branch]if (vLayerType.y == MTLTYPE_UNLIT || vColor.r >= g_vParam.y || vColor.g >= g_vParam.y || vColor.b >= g_vParam.y)
{
vColor.rgb *= g_vParam.z;
return vColor;
......
......@@ -1032,7 +1032,7 @@ void CAIGrid::initGraphics()
m_pDXDevice->CreateVertexDeclaration(InstanceCAIquad, &m_pDecl);
m_idTex = SGCore_LoadTexAddName("decal_aigrid1.dds", LOAD_TEXTURE_TYPE_CONST);
m_idTex = SGCore_LoadTexAddName("decal_aigrid.dds", LOAD_TEXTURE_TYPE_CONST);
m_idVS = SGCore_ShaderLoad(SHADER_TYPE_VERTEX, "aigrid_quad.vs", "aigrid_quad.vs", SHADER_CHECKDOUBLE_PATH);
m_idPS = SGCore_ShaderLoad(SHADER_TYPE_PIXEL, "aigrid_quad.ps", "aigrid_quad.ps", SHADER_CHECKDOUBLE_PATH);
......
......@@ -22,6 +22,7 @@ See the license in LICENSE
#include "BaseWeapon.h"
#include "BaseAmmo.h"
#include "BaseMag.h"
#include "FuncTrain.h"
CPlayer * GameData::m_pPlayer;
CPointCamera * GameData::m_pActiveCamera;
......@@ -143,6 +144,28 @@ GameData::GameData(HWND hWnd, bool isGame):
Core_0RegisterConcmd("flashlight", ccmd_toggleflashlight);
Core_0RegisterConcmd("+use", ccmd_use_on);
Core_0RegisterConcmd("-use", ccmd_use_off);
Core_0RegisterConcmdArg("send_camera", [](int argc, const char ** argv){
if (argc < 2)
{
printf("cmd send_camera requires one argument");
return;
}
CBaseEntity *pEnt = m_pMgr->findEntityByName(argv[1]);
if (pEnt)
{
CFuncTrain *pTrain = (CFuncTrain*)pEnt->getParent();
if (pTrain)
{
m_pActiveCamera = (CPointCamera*)pEnt;
pTrain->start();
}
else
printf("cmd send_camera of found parent for camera '%s'", argv[1]);
}
else
printf("cmd send_camera not found '%s' camera", argv[1]);
});
Core_0RegisterConcmdArg("gui_load", [](int argc, const char ** argv){
if(argc != 3)
......
......@@ -92,6 +92,8 @@ protected:
static void ccmd_use_on();
static void ccmd_use_off();
static void ccmd_send_camera();
bool m_isGame;
};
......
......@@ -80,27 +80,32 @@ void CPathCorner::RecalcPath(float t)
}
pCur = m_pNextStop; // 1
pCur->m_fDelta = (float3)(-pCur->m_fLength / (2.0f * (m_fLength + pCur->m_fLength)));
pCur->m_fLambda = (float3)(1.5f * float3(pCur->m_fH - m_fH) / (m_fLength + pCur->m_fLength));
pCur = pCur->m_pNextStop; // 2
while(pCur->m_pNextStop)
if (pCur)
{
pNext = pCur->m_pNextStop;
pCur->m_fDelta = (float3)(-float3(pCur->m_fLength) / (float3(2.0f * pCur->m_pPrevStop->m_fLength + 2.0f * pCur->m_fLength) + pCur->m_pPrevStop->m_fLength * pCur->m_pPrevStop->m_fDelta));
pCur->m_fLambda = (float3)((3.0f * pCur->m_fH - 3.0f * pCur->m_pPrevStop->m_fH - pCur->m_pPrevStop->m_fLength * pCur->m_pPrevStop->m_fLambda) /
(float3(2.0f * pCur->m_pPrevStop->m_fLength + 2.0f * pCur->m_fLength) + pCur->m_pPrevStop->m_fLength * pCur->m_pPrevStop->m_fDelta));
pCur = pNext;
}
pCur->m_fDelta = (float3)(-pCur->m_fLength / (2.0f * (m_fLength + pCur->m_fLength)));
pCur->m_fLambda = (float3)(1.5f * float3(pCur->m_fH - m_fH) / (m_fLength + pCur->m_fLength));
pCur = pCur->m_pNextStop; // 2
while(pCur->m_pPrevStop)
{
pCur->m_pPrevStop->m_fCoeffsC = (float3)(pCur->m_fDelta * pCur->m_fCoeffsC + pCur->m_fLambda);
pCur = pCur->m_pPrevStop;
if (pCur)
{
while (pCur->m_pNextStop)
{
pNext = pCur->m_pNextStop;
pCur->m_fDelta = (float3)(-float3(pCur->m_fLength) / (float3(2.0f * pCur->m_pPrevStop->m_fLength + 2.0f * pCur->m_fLength) + pCur->m_pPrevStop->m_fLength * pCur->m_pPrevStop->m_fDelta));
pCur->m_fLambda = (float3)((3.0f * pCur->m_fH - 3.0f * pCur->m_pPrevStop->m_fH - pCur->m_pPrevStop->m_fLength * pCur->m_pPrevStop->m_fLambda) /
(float3(2.0f * pCur->m_pPrevStop->m_fLength + 2.0f * pCur->m_fLength) + pCur->m_pPrevStop->m_fLength * pCur->m_pPrevStop->m_fDelta));
pCur = pNext;
}
while (pCur->m_pPrevStop)
{
pCur->m_pPrevStop->m_fCoeffsC = (float3)(pCur->m_fDelta * pCur->m_fCoeffsC + pCur->m_fLambda);
pCur = pCur->m_pPrevStop;
}
}
}
/*pCur = pCur->m_pPrevStop;
......@@ -213,3 +218,10 @@ CPathCorner * CPathCorner::GetPrev()
{
return(m_pPrevStop);
}
void CPathCorner::setPos(const float3 & pos)
{
CBaseEntity::setPos(pos);
RecalcPath(0);
}
\ No newline at end of file
......@@ -45,6 +45,8 @@ public:
//! Получает предыдущую точку на пути
CPathCorner * GetPrev();
void setPos(const float3 & pos);
protected:
//! Пересчитывает путь
void RecalcPath(float t);
......
......@@ -233,7 +233,7 @@ SX_LIB_API void SGame_EditorRender(ID id, ID id_sel_tex, const float3 *pvRenderP
{
len += pCur->GetLength();
++count;
SGCore_GetDXDevice()->SetTransform(D3DTS_WORLD, (D3DMATRIX*)&SMMatrixTranslation(SMMatrixScaling(vBoxSize) * pCur->getPos()));
SGCore_GetDXDevice()->SetTransform(D3DTS_WORLD, (D3DMATRIX*)&(SMMatrixScaling(vBoxSize) * pEnt->getOrient().GetMatrix() * SMMatrixTranslation(pCur->getPos())));
if (id == pCur->getId())
SGCore_GetDXDevice()->SetTexture(0, SGCore_LoadTexGetTex(id_sel_tex));
......
......@@ -368,6 +368,10 @@ ID CLights::createPoint(ID id, const float3* center, float dist, const float3* c
tmplight->m_pShadowCube->setNearFar(&float2(LIGHTS_LOCAL_STD_NEAR, tmplight->m_fDist));
}
else
{
int qwerty = 0;
}
if (is_shadow)
tmplight->m_typeShadowed = LTYPE_SHADOW_DYNAMIC;
......@@ -1184,37 +1188,53 @@ void CLights::setLightTypeShadowed(ID id, LTYPE_SHADOW type)
m_aLights[id]->m_typeShadowed = type;
if (m_aLights[id]->m_typeLight == LTYPE_LIGHT_DIR)
if (type != LTYPE_SHADOW::LTYPE_SHADOW_NONE)
{
if (!m_aLights[id]->m_pShadowSM)
if (m_aLights[id]->m_typeLight == LTYPE_LIGHT_DIR)
{
m_aLights[id]->m_pShadowSM = new ShadowMapTech();
m_aLights[id]->m_pShadowSM->init();
m_aLights[id]->m_pShadowSM->setPosition(&float3(m_aLights[id]->m_vPosition.x, m_aLights[id]->m_vPosition.y, m_aLights[id]->m_vPosition.z));
m_aLights[id]->m_pShadowSM->setDirection(&(m_aLights[id]->m_qQuaternion * LIGHTS_DIR_BASE));
m_aLights[id]->m_pShadowSM->setAngleNearFar(&float3(m_aLights[id]->m_fAngle, 0.1, m_aLights[id]->m_fDist));
if (!m_aLights[id]->m_pShadowSM)
{
m_aLights[id]->m_pShadowSM = new ShadowMapTech();
m_aLights[id]->m_pShadowSM->init();
m_aLights[id]->m_pShadowSM->setPosition(&float3(m_aLights[id]->m_vPosition.x, m_aLights[id]->m_vPosition.y, m_aLights[id]->m_vPosition.z));
m_aLights[id]->m_pShadowSM->setDirection(&(m_aLights[id]->m_qQuaternion * LIGHTS_DIR_BASE));
m_aLights[id]->m_pShadowSM->setAngleNearFar(&float3(m_aLights[id]->m_fAngle, 0.1, m_aLights[id]->m_fDist));
}
}
}
else if (m_aLights[id]->m_typeLight == LTYPE_LIGHT_GLOBAL)
{
if (m_aLights[id]->m_isGlobal)
else if (m_aLights[id]->m_typeLight == LTYPE_LIGHT_GLOBAL)
{
if (!m_aLights[id]->m_pShadowPSSM)
if (m_aLights[id]->m_isGlobal)
{
m_aLights[id]->m_pShadowPSSM = new PSSM();
m_aLights[id]->m_pShadowPSSM->init();
m_aLights[id]->m_pShadowPSSM->setPosition(&float3(m_aLights[id]->m_vPosition.x, m_aLights[id]->m_vPosition.y, m_aLights[id]->m_vPosition.z));
if (!m_aLights[id]->m_pShadowPSSM)
{
m_aLights[id]->m_pShadowPSSM = new PSSM();
m_aLights[id]->m_pShadowPSSM->init();
m_aLights[id]->m_pShadowPSSM->setPosition(&float3(m_aLights[id]->m_vPosition.x, m_aLights[id]->m_vPosition.y, m_aLights[id]->m_vPosition.z));
}
}
}
else if (m_aLights[id]->m_typeLight == LTYPE_LIGHT_POINT)
{
if (!m_aLights[id]->m_pShadowCube)
{
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(LIGHTS_LOCAL_STD_NEAR, m_aLights[id]->m_fDist));
}
}
}
else if (m_aLights[id]->m_typeLight == LTYPE_LIGHT_POINT)
else
{
if (!m_aLights[id]->m_pShadowCube)
int qwerty = 0;
if (m_aLights[id]->m_pShadowSM)
{
mem_delete(m_aLights[id]->m_pShadowSM);
}
else if (m_aLights[id]->m_pShadowCube)
{
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(LIGHTS_LOCAL_STD_NEAR, m_aLights[id]->m_fDist));
mem_delete(m_aLights[id]->m_pShadowCube);
}
}
......
......@@ -107,11 +107,11 @@ 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) * fCoefSizeDepthMapForGlobal;
vSizeTexDepthGlobal.y = float(*r_win_height) * fCoefSizeDepthMapForGlobal;
vSizeTexDepthGlobal.x = float(*r_win_width) * light_data::fCoefSizeDepthMapForGlobal;
vSizeTexDepthGlobal.y = float(*r_win_height) * light_data::fCoefSizeDepthMapForGlobal;
vSizeTexDepthLocal.x = float(*r_win_width) * fCoefSizeDepthMapForLocal;
vSizeTexDepthLocal.y = float(*r_win_height) * fCoefSizeDepthMapForLocal;
vSizeTexDepthLocal.x = float(*r_win_width) * light_data::fCoefSizeDepthMapForLocal;
vSizeTexDepthLocal.y = float(*r_win_height) * light_data::fCoefSizeDepthMapForLocal;
}
void light_data::Init()
......
......@@ -858,7 +858,17 @@ void ShadowMapCubeTech::onLostDevice()
void ShadowMapCubeTech::onResetDevice()
{
D3DXCreateCubeTexture(light_data::pDXDevice, light_data::vSizeTexDepthLocal.x, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R32F, D3DPOOL_DEFAULT, &DepthMap);
HRESULT hr = D3DXCreateCubeTexture(light_data::pDXDevice, light_data::vSizeTexDepthLocal.x, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R32F, D3DPOOL_DEFAULT, &DepthMap);
if (hr == D3DERR_INVALIDCALL)
int qwert = 0;
else if (hr == D3DERR_NOTAVAILABLE)
int qwert = 0;
else if (hr == D3DERR_OUTOFVIDEOMEMORY)
int qwert = 0;
else if (hr == E_OUTOFMEMORY)
int qwert = 0;
light_data::pDXDevice->CreateDepthStencilSurface(light_data::vSizeTexDepthLocal.x, light_data::vSizeTexDepthLocal.x, D3DFMT_D24X8,D3DMULTISAMPLE_NONE, 0, TRUE, &DepthStencilSurface, NULL);
}
......@@ -997,7 +1007,17 @@ void ShadowMapCubeTech::init()
DepthSurface[4] = 0;
DepthSurface[5] = 0;
D3DXCreateCubeTexture(light_data::pDXDevice, light_data::vSizeTexDepthLocal.x, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R32F, D3DPOOL_DEFAULT, &DepthMap);
HRESULT hr = D3DXCreateCubeTexture(light_data::pDXDevice, light_data::vSizeTexDepthLocal.x, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R32F, D3DPOOL_DEFAULT, &DepthMap);
if (hr == D3DERR_INVALIDCALL)
int qwert = 0;
else if (hr == D3DERR_NOTAVAILABLE)
int qwert = 0;
else if (hr == D3DERR_OUTOFVIDEOMEMORY)
int qwert = 0;
else if (hr == E_OUTOFMEMORY)
int qwert = 0;
light_data::pDXDevice->CreateDepthStencilSurface(light_data::vSizeTexDepthLocal.x, light_data::vSizeTexDepthLocal.x, D3DFMT_D24X8,D3DMULTISAMPLE_NONE, 0, TRUE, &DepthStencilSurface, NULL);
}
......
......@@ -959,6 +959,7 @@ SX_LIB_API void SPP_RenderBloom(const float3_t *pParam)
SGCore_SetSamplerAddress(0, D3DTADDRESS_MIRROR);
pp_data::pDXDevice->SetTexture(0, SGCore_RTGetTexture(pp_data::rt_id::GetSendRT()));
pp_data::pDXDevice->SetTexture(1, SGCore_RTGetTexture(pp_data::rt_id::idNormal));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, pp_data::shaders_id::ps::idBloomBP, "g_vParam", (void*)pParam);
SGCore_ShaderBind(SHADER_TYPE_VERTEX, pp_data::shaders_id::vs::idScreenOut);
......@@ -971,9 +972,9 @@ SX_LIB_API void SPP_RenderBloom(const float3_t *pParam)
//pp_data::pDXDevice->SetRenderTarget(0, BackBuf);
mem_release(RenderSurf);
/*if (GetKeyState('N'))
/*if (GetAsyncKeyState('N'))
{
D3DXSaveTextureToFile("C:\\1\\sbp.png", D3DXIFF_PNG, SGCore_RTGetTexture(pp_data::rt_id::Bright), NULL);
D3DXSaveTextureToFile("C:\\1\\sbp.png", D3DXIFF_PNG, SGCore_RTGetTexture(pp_data::rt_id::idBright), NULL);
}*/
......
......@@ -687,6 +687,8 @@ void rfunc::BuildMRT(DWORD timeDelta, bool isRenderSimulation)
if (SGreen_GetCount() > 0)
SGreen_Render(timeDelta, &gdata::vConstCurrCamPos, GREEN_TYPE_ALL);
SXDecals_Render();
SGCore_ShaderUnBind();
}
......@@ -825,7 +827,7 @@ void rfunc::BuildMRT(DWORD timeDelta, bool isRenderSimulation)
gdata::pDXDevice->SetRenderState(D3DRS_ZWRITEENABLE, D3DZB_TRUE);
}
SXDecals_Render();
//SXDecals_Render();
}
else
{
......@@ -1454,7 +1456,7 @@ void rfunc::RenderMainPostProcess(DWORD timeDelta)
static const bool * pp_bloom = GET_PCVAR_BOOL("pp_bloom");
if (pp_bloom && (*pp_bloom))
SPP_RenderBloom(&float3_t(1, 0.7, 1.2));
SPP_RenderBloom(&float3_t(1, 0.85, 1.4));
//**********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment