Commit a63ead4a authored by Byurrrer's avatar Byurrrer

снес регистры дубликаты кваров

parent aa27b08e
......@@ -7,12 +7,13 @@ ppe_fog_linear.ps
#include <../struct.h>
half3 FogColor;
half4 Param;
half FogDenisty;
/*half4 Param;
//x - интенсивность тумана
//y - на сколько небо в тумане
//z - минимальное значение тумана
//w - максимальное значение тумана
*/
sampler2D DepthMap:register(s0);
......@@ -21,10 +22,10 @@ half4 main(vs_out_pp IN) : COLOR0
half Depth = tex2D(DepthMap, IN.TexUV).r;
[branch]if(Depth >= 1.f)
Depth = Param.y;
clip(-1);
half tmp_alpha = clamp((Param.x * Depth),Param.z,Param.w);
half4 cc = half4(FogColor,tmp_alpha);
/*half tmp_alpha = clamp((Param.x * Depth),Param.z,Param.w);
half4 cc = half4(FogColor,tmp_alpha);*/
return cc;
return half4(FogColor,FogDenisty * Depth);
}
\ No newline at end of file
......@@ -22,6 +22,8 @@ bind f9 shader_reload
cl_mode_editor 1
r_default_fov 1.046
pp_ssao 1
pp_bloom true
pp_lensflare true
......
......@@ -101,6 +101,7 @@
<ItemGroup>
<ClInclude Include="..\..\..\source\common\string.h" />
<ClInclude Include="..\..\..\source\gdefines.h" />
<ClInclude Include="..\..\..\source\GRegisterIndex.h" />
<ClInclude Include="..\..\..\source\SkyXEngine.h" />
<ClInclude Include="..\..\..\source\SkyXEngine_Build\resource.h" />
</ItemGroup>
......
......@@ -35,6 +35,9 @@
<ClInclude Include="..\..\..\source\common\string.h">
<Filter>Header</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\GRegisterIndex.h">
<Filter>Header</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\source\SkyXEngine_Build\SkyXEngine.rc">
......
......@@ -32,7 +32,7 @@ See the license in LICENSE
@{*/
#define G_RI_BOOL_CLIPPLANE0 0 /*!< использовать ли плоскость отсечения */
#define G_RI_BOOL_RENDER_WINDOWED 1 /*!< оконный рендер - true, полноэкранный - false */
//#define G_RI_BOOL_RENDER_WINDOWED 1 /*!< оконный рендер - true, полноэкранный - false */
//!@}
......@@ -41,11 +41,11 @@ See the license in LICENSE
/*! \name float register
@{*/
#define G_RI_FLOAT_OBSERVER_NEAR 0 /*!< ближняя плоскость отсечения наблюдателя */
#define G_RI_FLOAT_OBSERVER_FAR 1 /*!< дальняя плоскость отсечения наблюдателя или дальность видимости */
#define G_RI_FLOAT_OBSERVER_FOV 2 /*!< fov наблюдателя */
#define G_RI_FLOAT_WINSIZE_WIDTH 3 /*!< ширина окна рендера */
#define G_RI_FLOAT_WINSIZE_HEIGHT 4 /*!< высота окна рендера */
//#define G_RI_FLOAT_OBSERVER_NEAR 0 /*!< ближняя плоскость отсечения наблюдателя */
//#define G_RI_FLOAT_OBSERVER_FAR 1 /*!< дальняя плоскость отсечения наблюдателя или дальность видимости */
//#define G_RI_FLOAT_OBSERVER_FOV 2 /*!< fov наблюдателя */
//#define G_RI_FLOAT_WINSIZE_WIDTH 3 /*!< ширина окна рендера */
//#define G_RI_FLOAT_WINSIZE_HEIGHT 4 /*!< высота окна рендера */
//!@}
......
......@@ -46,7 +46,7 @@ GameData::GameData()
Core_0RegisterConcmd("spawn", ccmd_spawn);
Core_0RegisterConcmd("observe", ccmd_observe);
Core_0RegisterCVarFloat("r_default_fov", 45.0f, "Default FOV value");
//Core_0RegisterCVarFloat("r_default_fov", 45.0f, "Default FOV value");
Core_0RegisterCVarBool("cl_mode_editor", false, "Editor control mode");
Core_0RegisterCVarBool("cl_grab_cursor", true, "Grab cursor on move");
......
......@@ -62,9 +62,13 @@ void Crosshair::Update()
return;
}
}
static const int *winr_width = GET_PCVAR_INT("winr_width");
static const int *winr_height = GET_PCVAR_INT("winr_height");
//build new buffer
float fScreenWidth = Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH);
float fScreenHeight = Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT);
float fScreenWidth = *winr_width;
float fScreenHeight = *winr_height;
float fTexWidth = m_f2TexSize.x;
float fTexHeight = m_f2TexSize.y;
float fXradius = fTexWidth / fScreenWidth * 0.5f;
......
......@@ -175,9 +175,9 @@ void GCoreInit(HWND hwnd, int width, int heigth, bool windowed, DWORD create_dev
//
Core_RFloatSet(G_RI_FLOAT_WINSIZE_WIDTH, (float)width);
/*Core_RFloatSet(G_RI_FLOAT_WINSIZE_WIDTH, (float)width);
Core_RFloatSet(G_RI_FLOAT_WINSIZE_HEIGHT, (float)heigth);
Core_RBoolSet(G_RI_BOOL_RENDER_WINDOWED, windowed);
Core_RBoolSet(G_RI_BOOL_RENDER_WINDOWED, windowed);*/
MShaders = new ShaderManager();
MRenderTargets = new CreatorTextures();
......@@ -320,9 +320,9 @@ SX_LIB_API bool SGCore_OnDeviceReset(int width, int heigth, bool windowed)
D3DAPP.BackBufferHeight = heigth;
D3DAPP.Windowed = windowed;
Core_RFloatSet(G_RI_FLOAT_WINSIZE_WIDTH, (float)width);
/*Core_RFloatSet(G_RI_FLOAT_WINSIZE_WIDTH, (float)width);
Core_RFloatSet(G_RI_FLOAT_WINSIZE_HEIGHT, (float)heigth);
Core_RBoolSet(G_RI_BOOL_RENDER_WINDOWED, windowed);
Core_RBoolSet(G_RI_BOOL_RENDER_WINDOWED, windowed);*/
return (FAILED(DXDevice->Reset(&D3DAPP)));
}
......
......@@ -4,8 +4,12 @@
Lights::Lights()
{
HowShadow = 0;
ShadowMap = SGCore_RTAdd(Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH), Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT), 1, D3DUSAGE_RENDERTARGET, D3DFMT_R16F, D3DPOOL_DEFAULT, "shadowmap", 1);
ShadowMap2 = SGCore_RTAdd(Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH), Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT), 1, D3DUSAGE_RENDERTARGET, D3DFMT_R16F, D3DPOOL_DEFAULT, "shadowmap2", 1);
const int *winr_width = GET_PCVAR_INT("winr_width");
const int *winr_height = GET_PCVAR_INT("winr_height");
ShadowMap = SGCore_RTAdd(*winr_width, *winr_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R16F, D3DPOOL_DEFAULT, "shadowmap", 1);
ShadowMap2 = SGCore_RTAdd(*winr_width, *winr_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R16F, D3DPOOL_DEFAULT, "shadowmap2", 1);
GlobalLight = -1;
m_isCastGlobalShadow = false;
......@@ -1253,6 +1257,12 @@ void Lights::ShadowSoft(bool randomsam, float size, bool isfirst)
if (isfirst)
HowShadow = 0;
static const int *winr_width = GET_PCVAR_INT("winr_width");
static const int *winr_height = GET_PCVAR_INT("winr_height");
static const float *p_near = GET_PCVAR_FLOAT("p_near");
static const float *p_far = GET_PCVAR_FLOAT("p_far");
LPDIRECT3DSURFACE9 RenderSurf,BackBuf;
if(HowShadow == 0)
......@@ -1289,13 +1299,13 @@ void Lights::ShadowSoft(bool randomsam, float size, bool isfirst)
if(randomsam)
{
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PPBlurDepthBasedNoise, "PixelSize", &float2_t(size / Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH), size / Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT)));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PPBlurDepthBasedNoise, "NearFar", &float2_t(Core_RFloatGet(G_RI_FLOAT_OBSERVER_NEAR), Core_RFloatGet(G_RI_FLOAT_OBSERVER_FAR)));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PPBlurDepthBasedNoise, "PixelSize", &float2_t(size / float(*winr_width), size / float(*winr_height)));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PPBlurDepthBasedNoise, "NearFar", &float2_t(*p_near, *p_far));
}
else
{
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PPBlurDepthBased, "PixelSize", &float2_t(size / Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH), size / Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT)));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PPBlurDepthBased, "NearFar", &float2_t(Core_RFloatGet(G_RI_FLOAT_OBSERVER_NEAR), Core_RFloatGet(G_RI_FLOAT_OBSERVER_FAR)));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PPBlurDepthBased, "PixelSize", &float2_t(size / float(*winr_width), size / float(*winr_height)));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PPBlurDepthBased, "NearFar", &float2_t(*p_near, *p_far));
}
......@@ -1316,7 +1326,10 @@ void Lights::ShadowSoft(bool randomsam, float size, bool isfirst)
void Lights::ToneMappingCom(DWORD timeDelta, float factor_adapted)
{
MLSet::GetArrDownScale4x4(Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH), Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT), MLSet::HDRSampleOffsets);
static const int *winr_width = GET_PCVAR_INT("winr_width");
static const int *winr_height = GET_PCVAR_INT("winr_height");
MLSet::GetArrDownScale4x4(*winr_width, *winr_height, MLSet::HDRSampleOffsets);
LPDIRECT3DSURFACE9 SurfSceneScale, BackBuf;
......
......@@ -1892,6 +1892,12 @@ void Materials::Render(ID id, float4x4* world)
{
MTL_PRE_COND_ID(id);
static const int *winr_width = GET_PCVAR_INT("winr_width");
static const int *winr_height = GET_PCVAR_INT("winr_height");
static const float *p_near = GET_PCVAR_FLOAT("p_near");
static const float *p_far = GET_PCVAR_FLOAT("p_far");
if (!world)
world = &(SMMatrixIdentity());
......@@ -2068,10 +2074,10 @@ void Materials::Render(ID id, float4x4* world)
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, tmpmaterial->PreShaderPS, "TimeDelta", &float2(CountTimeDelta, float(CurrTimeDelta) * 0.001f));
if (tmpmaterial->VS.IsTransWinSize)
SGCore_ShaderSetVRF(SHADER_TYPE_VERTEX, tmpmaterial->PreShaderVS, "WinSize", &float2_t(Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH), Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT)));
SGCore_ShaderSetVRF(SHADER_TYPE_VERTEX, tmpmaterial->PreShaderVS, "WinSize", &float2_t(*winr_width, *winr_height));
if (tmpmaterial->PS.IsTransWinSize)
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, tmpmaterial->PreShaderPS, "WinSize", &float2_t(Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH), Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT)));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, tmpmaterial->PreShaderPS, "WinSize", &float2_t(*winr_width, *winr_height));
//если материалом назначен альфа тест и не включен принудительный
if (tmpmaterial->IsAlphaTest && !IsForceblyAlphaTest)
......@@ -2119,7 +2125,7 @@ void Materials::Render(ID id, float4x4* world)
if (tmpmaterial->LightParam.TypeRefraction == MTLTYPE_TRANSPARENCY_ALPHA_LIGHT)
++(CurrIdSurf);
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, tmpmaterial->PreShaderPS, "NearFarIsUnlit", &float4_t(Core_RFloatGet(G_RI_FLOAT_OBSERVER_NEAR), Core_RFloatGet(G_RI_FLOAT_OBSERVER_FAR), zz, float(CurrIdSurf) / 255.f));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, tmpmaterial->PreShaderPS, "NearFarIsUnlit", &float4_t(*p_near, *p_far, zz, float(CurrIdSurf) / 255.f));
}
}
......
......@@ -30,11 +30,14 @@ namespace MLSet
void ReCalcSize()
{
SizeTexDepthGlobal.x = Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH) * CoefSizeDepthMapForGlobal;
SizeTexDepthGlobal.y = Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT) * CoefSizeDepthMapForGlobal;
static const int *winr_width = GET_PCVAR_INT("winr_width");
static const int *winr_height = GET_PCVAR_INT("winr_height");
SizeTexDepthLocal.x = Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH) * CoefSizeDepthMapForLocal;
SizeTexDepthLocal.y = Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT) * CoefSizeDepthMapForLocal;
SizeTexDepthGlobal.x = float(*winr_width) * CoefSizeDepthMapForGlobal;
SizeTexDepthGlobal.y = float(*winr_height) * CoefSizeDepthMapForGlobal;
SizeTexDepthLocal.x = float(*winr_width) * CoefSizeDepthMapForLocal;
SizeTexDepthLocal.y = float(*winr_height) * CoefSizeDepthMapForLocal;
}
void GetArrDownScale4x4(DWORD width, DWORD height, float2 arr[]);
......@@ -168,6 +171,11 @@ void MLSet::MLInit()
{
MLSet::DXDevice = SGCore_GetDXDevice();
const int *winr_width = GET_PCVAR_INT("winr_width");
const int *winr_height = GET_PCVAR_INT("winr_height");
const float *r_default_fov = GET_PCVAR_FLOAT("r_default_fov");
/*sprintf(MLSet::StdPathMaterial, "%s", Core_RStringGet(G_RI_STRING_PATH_GS_MTRLS));
sprintf(MLSet::StdPathMesh, "%s", Core_RStringGet(G_RI_STRING_PATH_GS_MESHES));
......@@ -314,7 +322,7 @@ void MLSet::MLInit()
//////////
float tmpcoefsizert = 1;
float2_t tmp_sizert = float2_t(Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH) * tmpcoefsizert, Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT) * tmpcoefsizert);
float2_t tmp_sizert = float2_t(float(*winr_width) * tmpcoefsizert, (*winr_height) * tmpcoefsizert);
//цвет (текстуры)
MLSet::IDsRenderTargets::ColorScene = SGCore_RTAdd(tmp_sizert.x, tmp_sizert.y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, "ds_color", tmpcoefsizert);
......@@ -337,7 +345,7 @@ void MLSet::MLInit()
while (true)
{
int tmpsize = 1 << (2 * tmpcount);
if (tmpsize >= Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH)*0.25 || tmpsize > Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT)*0.25)
if (tmpsize >= float(*winr_width)*0.25 || tmpsize > (*winr_height)*0.25)
break;
MLSet::IDsRenderTargets::ToneMaps[tmpcount] = SGCore_RTAdd(tmpsize, tmpsize, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R16F, D3DPOOL_DEFAULT, "qq", 0);
MLSet::IDsRenderTargets::SurfToneMap[tmpcount] = 0;
......@@ -348,13 +356,13 @@ void MLSet::MLInit()
MLSet::IDsRenderTargets::AdaptLumCurr = SGCore_RTAdd(1, 1, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R16F, D3DPOOL_DEFAULT, "", 0);
MLSet::IDsRenderTargets::AdaptLumLast = SGCore_RTAdd(1, 1, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R16F, D3DPOOL_DEFAULT, "", 0);
MLSet::IDsRenderTargets::LigthCom = SGCore_RTAdd(Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH), Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, "ds_lightcom", 1);
MLSet::IDsRenderTargets::LigthCom2 = SGCore_RTAdd(Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH), Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, "ds_lightcom2", 1);
MLSet::IDsRenderTargets::LigthCom3 = SGCore_RTAdd(Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH), Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, "ds_lightcom3", 1);
MLSet::IDsRenderTargets::LigthCom = SGCore_RTAdd(*winr_width, *winr_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, "ds_lightcom", 1);
MLSet::IDsRenderTargets::LigthCom2 = SGCore_RTAdd(*winr_width, *winr_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, "ds_lightcom2", 1);
MLSet::IDsRenderTargets::LigthCom3 = SGCore_RTAdd(*winr_width, *winr_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, "ds_lightcom3", 1);
MLSet::IDsRenderTargets::LigthComScaled = SGCore_RTAdd(Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH)*0.25f, Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT)*0.25f, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, "ds_lightcomscaled", 0.25);
MLSet::IDsRenderTargets::LigthComScaled = SGCore_RTAdd(float(*winr_width)*0.25f, float(*winr_height)*0.25f, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, "ds_lightcomscaled", 0.25);
MLSet::RefMProjPlane = SMMatrixPerspectiveFovLH(Core_RFloatGet(G_RI_FLOAT_OBSERVER_FOV), Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH) / Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT), MTl_REF_PROJ_NEAR, MTl_REF_PROJ_FAR);
MLSet::RefMProjPlane = SMMatrixPerspectiveFovLH(*r_default_fov, float(*winr_width) / float(*winr_height), MTl_REF_PROJ_NEAR, MTl_REF_PROJ_FAR);
MLSet::RefMProjCube = SMMatrixPerspectiveFovLH(SM_PI * 0.5f, 1, MTl_REF_PROJ_NEAR, MTl_REF_PROJ_FAR);
}
......
......@@ -115,6 +115,11 @@ void PSSM::OnLostDevice()
void PSSM::OnResetDevice()
{
static const int *winr_width = GET_PCVAR_INT("winr_width");
static const int *winr_height = GET_PCVAR_INT("winr_height");
static const float *r_default_fov = GET_PCVAR_FLOAT("r_default_fov");
for(int i=0;i<5;i++)
{
IsUpdate[i] = 0;
......@@ -129,8 +134,8 @@ void PSSM::OnResetDevice()
MLSet::DXDevice->CreateDepthStencilSurface(MLSet::SizeTexDepthGlobal.x, MLSet::SizeTexDepthGlobal.y, D3DFMT_D24X8,D3DMULTISAMPLE_NONE, 0, TRUE, &DepthStencilSurface, NULL);
FovRatio.x = Core_RFloatGet(G_RI_FLOAT_OBSERVER_FOV);
FovRatio.y = Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH) / Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT);
FovRatio.x = *r_default_fov;
FovRatio.y = float(*winr_width) / float(*winr_height);
float2 fOffset = float2(0.5, 0.5) - (float2(0.5f, 0.5f) / MLSet::SizeTexDepthGlobal);
float range = 1.0f;
......@@ -143,8 +148,16 @@ void PSSM::OnResetDevice()
void PSSM::Init()
{
FovRatio.x = Core_RFloatGet(G_RI_FLOAT_OBSERVER_FOV);
FovRatio.y = Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH) / Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT);
static const int *winr_width = GET_PCVAR_INT("winr_width");
static const int *winr_height = GET_PCVAR_INT("winr_height");
static const float *r_default_fov = GET_PCVAR_FLOAT("r_default_fov");
static const float *p_near = GET_PCVAR_FLOAT("p_near");
static const float *p_far = GET_PCVAR_FLOAT("p_far");
FovRatio.x = *r_default_fov;
FovRatio.y = float(*winr_width) / float(*winr_height);
for(int i=0;i<5;i++)
{
......@@ -157,7 +170,7 @@ void PSSM::Init()
Frustums[i] = SGCore_CrFrustum();
}
NearFar[0].x = Core_RFloatGet(G_RI_FLOAT_OBSERVER_NEAR);
NearFar[0].x = *p_near;
NearFar[0].y = MLSet::DistForPSSM.x;
NearFar[1].x = MLSet::DistForPSSM.x;
......@@ -170,8 +183,8 @@ void PSSM::Init()
NearFar[3].y = MLSet::DistForPSSM.w;
NearFar[4].x = Core_RFloatGet(G_RI_FLOAT_OBSERVER_NEAR);
NearFar[4].y = Core_RFloatGet(G_RI_FLOAT_OBSERVER_FAR);
NearFar[4].x = *p_near;
NearFar[4].y = *p_far;
MLSet::DXDevice->CreateDepthStencilSurface(MLSet::SizeTexDepthGlobal.x, MLSet::SizeTexDepthGlobal.y, D3DFMT_D24X8,D3DMULTISAMPLE_NONE, 0, TRUE, &DepthStencilSurface, NULL);
......@@ -187,8 +200,13 @@ void PSSM::Init()
void PSSM::UpdateFrustums(int split, const float3* poscam, const float3* dircam)
{
FovRatio.x = Core_RFloatGet(G_RI_FLOAT_OBSERVER_FOV);
FovRatio.y = Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH) / Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT);
static const int *winr_width = GET_PCVAR_INT("winr_width");
static const int *winr_height = GET_PCVAR_INT("winr_height");
static const float *r_default_fov = GET_PCVAR_FLOAT("r_default_fov");
FovRatio.x = *r_default_fov;
FovRatio.y = float(*winr_width) / float(*winr_height);
Frustums[split]->Update(&(Views[split]), &(Projs[split]));
......@@ -397,6 +415,14 @@ void PSSM::Flickering(float4x4 *matLVP,float size_x,float size_y)
void PSSM::GenShadow2(IDirect3DTexture9* shadowmap)
{
static const int *winr_width = GET_PCVAR_INT("winr_width");
static const int *winr_height = GET_PCVAR_INT("winr_height");
static const float *r_default_fov = GET_PCVAR_FLOAT("r_default_fov");
static const float *p_near = GET_PCVAR_FLOAT("p_near");
static const float *p_far = GET_PCVAR_FLOAT("p_far");
LPDIRECT3DSURFACE9 RenderSurf, BackBuf;
shadowmap->GetSurfaceLevel(0, &RenderSurf);
......@@ -442,8 +468,8 @@ void PSSM::GenShadow2(IDirect3DTexture9* shadowmap)
float3 observerpos;
Core_RFloat3Get(G_RI_FLOAT3_OBSERVER_POSITION, &observerpos);
SGCore_ShaderSetVRF(SHADER_TYPE_VERTEX, MLSet::IDsShaders::VS::ResPosDepth, "ParamProj", &float3_t(Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH), Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT), Core_RFloatGet(G_RI_FLOAT_OBSERVER_FOV)));
SGCore_ShaderSetVRF(SHADER_TYPE_VERTEX, MLSet::IDsShaders::VS::ResPosDepth, "NearFar", &float2_t(Core_RFloatGet(G_RI_FLOAT_OBSERVER_NEAR), Core_RFloatGet(G_RI_FLOAT_OBSERVER_FAR)));
SGCore_ShaderSetVRF(SHADER_TYPE_VERTEX, MLSet::IDsShaders::VS::ResPosDepth, "ParamProj", &float3_t(*winr_width, *winr_height, *r_default_fov));
SGCore_ShaderSetVRF(SHADER_TYPE_VERTEX, MLSet::IDsShaders::VS::ResPosDepth, "NearFar", &float2_t(*p_near, *p_far));
SGCore_ShaderSetVRF(SHADER_TYPE_VERTEX, MLSet::IDsShaders::VS::ResPosDepth, "ViewInv", &ViewInv);
......@@ -451,14 +477,14 @@ void PSSM::GenShadow2(IDirect3DTexture9* shadowmap)
{
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PSSM4, "PosCam", &observerpos);
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PSSM4, "PixelSize", &float2(BlurPixel / MLSet::SizeTexDepthGlobal.x, BlurPixel / MLSet::SizeTexDepthGlobal.y));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PSSM4, "NearFar", &float2_t(Core_RFloatGet(G_RI_FLOAT_OBSERVER_NEAR), Core_RFloatGet(G_RI_FLOAT_OBSERVER_FAR)));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PSSM4, "NearFar", &float2_t(*p_near, *p_far));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PSSM4, "DistSplit", &float4(NearFar[0].y, NearFar[1].y, NearFar[2].y, NearFar[3].y));
}
else
{
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PSSM3, "PosCam", &observerpos);
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PSSM3, "PixelSize", &float2(BlurPixel / MLSet::SizeTexDepthGlobal.x, BlurPixel / MLSet::SizeTexDepthGlobal.y));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PSSM3, "NearFar", &float2_t(Core_RFloatGet(G_RI_FLOAT_OBSERVER_NEAR), Core_RFloatGet(G_RI_FLOAT_OBSERVER_FAR)));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PSSM3, "NearFar", &float2_t(*p_near, *p_far));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::PSSM3, "DistSplit", &float4(NearFar[0].y, NearFar[1].y, NearFar[2].y, NearFar[3].y));
}
......@@ -716,6 +742,14 @@ void ShadowMapTech::End()
void ShadowMapTech::GenShadow2(IDirect3DTexture9* shadowmap)
{
static const int *winr_width = GET_PCVAR_INT("winr_width");
static const int *winr_height = GET_PCVAR_INT("winr_height");
static const float *r_default_fov = GET_PCVAR_FLOAT("r_default_fov");
static const float *p_near = GET_PCVAR_FLOAT("p_near");
static const float *p_far = GET_PCVAR_FLOAT("p_far");
LPDIRECT3DSURFACE9 RenderSurf, BackBuf;
shadowmap->GetSurfaceLevel(0, &RenderSurf);
MLSet::DXDevice->GetRenderTarget(0, &BackBuf);
......@@ -752,8 +786,8 @@ void ShadowMapTech::GenShadow2(IDirect3DTexture9* shadowmap)
else
SGCore_ShaderBind(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::GenShadowDirect9);
SGCore_ShaderSetVRF(SHADER_TYPE_VERTEX, MLSet::IDsShaders::VS::ResPosDepth, "ParamProj", &float3_t(Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH), Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT), Core_RFloatGet(G_RI_FLOAT_OBSERVER_FOV)));
SGCore_ShaderSetVRF(SHADER_TYPE_VERTEX, MLSet::IDsShaders::VS::ResPosDepth, "NearFar", &float2_t(Core_RFloatGet(G_RI_FLOAT_OBSERVER_NEAR), Core_RFloatGet(G_RI_FLOAT_OBSERVER_FAR)));
SGCore_ShaderSetVRF(SHADER_TYPE_VERTEX, MLSet::IDsShaders::VS::ResPosDepth, "ParamProj", &float3_t(*winr_width, *winr_height, *r_default_fov));
SGCore_ShaderSetVRF(SHADER_TYPE_VERTEX, MLSet::IDsShaders::VS::ResPosDepth, "NearFar", &float2_t(*p_near, *p_far));
float3 observerpos;
Core_RFloat3Get(G_RI_FLOAT3_OBSERVER_POSITION, &observerpos);
......@@ -1048,6 +1082,14 @@ void ShadowMapCubeTech::End()
void ShadowMapCubeTech::GenShadow2(IDirect3DTexture9* shadowmap)
{
static const int *winr_width = GET_PCVAR_INT("winr_width");
static const int *winr_height = GET_PCVAR_INT("winr_height");
static const float *r_default_fov = GET_PCVAR_FLOAT("r_default_fov");
static const float *p_near = GET_PCVAR_FLOAT("p_near");
static const float *p_far = GET_PCVAR_FLOAT("p_far");
LPDIRECT3DSURFACE9 RenderSurf, BackBuf;
shadowmap->GetSurfaceLevel(0, &RenderSurf);
......@@ -1074,8 +1116,8 @@ void ShadowMapCubeTech::GenShadow2(IDirect3DTexture9* shadowmap)
else
SGCore_ShaderBind(SHADER_TYPE_PIXEL, MLSet::IDsShaders::PS::GenShadowCube6);
SGCore_ShaderSetVRF(SHADER_TYPE_VERTEX, MLSet::IDsShaders::VS::ResPosDepth, "ParamProj", &float3_t(Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH), Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT), Core_RFloatGet(G_RI_FLOAT_OBSERVER_FOV)));
SGCore_ShaderSetVRF(SHADER_TYPE_VERTEX, MLSet::IDsShaders::VS::ResPosDepth, "NearFar", &float2_t(Core_RFloatGet(G_RI_FLOAT_OBSERVER_NEAR), Core_RFloatGet(G_RI_FLOAT_OBSERVER_FAR)));
SGCore_ShaderSetVRF(SHADER_TYPE_VERTEX, MLSet::IDsShaders::VS::ResPosDepth, "ParamProj", &float3_t(*winr_width, *winr_height, *r_default_fov));
SGCore_ShaderSetVRF(SHADER_TYPE_VERTEX, MLSet::IDsShaders::VS::ResPosDepth, "NearFar", &float2_t(*p_near, *p_far));
float pixel_size = BlurPixel / MLSet::SizeTexDepthLocal.x;
float3 observerpos;
......
......@@ -111,15 +111,16 @@ SX_LIB_API void SML_OnResetDevice()
SX_LIB_API void SML_Update(DWORD timeDelta)
{
/*MLSet::WinSize = *winsize;
MLSet::NearFar = *nearfar;
MLSet::ConstCurrCamPos = *poscam;
MLSet::MCamView = *mview;
MLSet::ProjFov = projfov;
MLSet::ProjRatio = MLSet::WinSize.x / MLSet::WinSize.y;*/
static const int *winr_width = GET_PCVAR_INT("winr_width");
static const int *winr_height = GET_PCVAR_INT("winr_height");
static const float *r_default_fov = GET_PCVAR_FLOAT("r_default_fov");
if (ArrMaterials)
ArrMaterials->Update(timeDelta);
MLSet::RefMProjPlane = SMMatrixPerspectiveFovLH(*r_default_fov, float(*winr_width) / float(*winr_height), MTl_REF_PROJ_NEAR, MTl_REF_PROJ_FAR);
MLSet::RefMProjCube = SMMatrixPerspectiveFovLH(SM_PI * 0.5f, 1, MTl_REF_PROJ_NEAR, MTl_REF_PROJ_FAR);
}
SX_LIB_API void SML_LigthsSettLCoefSizeDepth(float coef)
......
......@@ -1199,6 +1199,9 @@ void Emitter::Compute(const float4x4 * mat)
void Emitter::Render(DWORD timeDelta, float4x4* matrot, float4x4* matpos)
{
static const float *p_near = GET_PCVAR_FLOAT("p_near");
static const float *p_far = GET_PCVAR_FLOAT("p_far");
if (!Enable)
return;
......@@ -1246,8 +1249,8 @@ void Emitter::Render(DWORD timeDelta, float4x4* matrot, float4x4* matpos)
static float2_t NearFar;
static float3 ConstCamPos;
Core_RFloat3Get(G_RI_FLOAT3_OBSERVER_POSITION, &ConstCamPos);
NearFar.x = Core_RFloatGet(G_RI_FLOAT_OBSERVER_NEAR);
NearFar.y = Core_RFloatGet(G_RI_FLOAT_OBSERVER_FAR);
NearFar.x = *p_near;
NearFar.y = *p_far;
Core_RMatrixGet(G_RI_MATRIX_OBSERVER_VIEW, &MCamView);
Core_RMatrixGet(G_RI_MATRIX_OBSERVER_PROJ, &MCamProj);
......
......@@ -107,9 +107,12 @@ namespace PPSet
void PPSet::Init()
{
static const int *winr_width = GET_PCVAR_INT("winr_width");
static const int *winr_height = GET_PCVAR_INT("winr_height");
PPSet::DXDevice = SGCore_GetDXDevice();
PPSet::WinSize.x = Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH);
PPSet::WinSize.y = Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT);
PPSet::WinSize.x = *winr_width;
PPSet::WinSize.y = *winr_height;
Core_SetOutPtr();
PPSet::IDsShaders::VS::ResPos = SGCore_ShaderLoad(SHADER_TYPE_VERTEX, "pp_res_pos.vs", "pp_quad_render_res_pos", SHADER_CHECKDOUBLE_PATH);
......@@ -302,16 +305,14 @@ SX_LIB_API void SPP_RTNull()
SX_LIB_API void SPP_Update()
{
PP_PRECOND(_VOID);
/*PPSet::ConstCurrCamPos = *viewpos;
PPSet::ConstCurrCamDir = *viewdir;
PPSet::MCamViewPrev = PPSet::MCamView;
PPSet::MCamView = *view;
PPSet::MCamProj = *proj;
PPSet::WinSize = *winsize;
static const int *winr_width = GET_PCVAR_INT("winr_width");
static const int *winr_height = GET_PCVAR_INT("winr_height");
PPSet::ProjRatio = PPSet::WinSize.x / PPSet::WinSize.y;
PPSet::NearFar = *nearfar;
PPSet::ProjFov = projfov;*/
static const float *p_near = GET_PCVAR_FLOAT("p_near");
static const float *p_far = GET_PCVAR_FLOAT("p_far");
static const float *r_default_fov = GET_PCVAR_FLOAT("r_default_fov");
Core_RFloat3Get(G_RI_FLOAT3_OBSERVER_POSITION, &PPSet::ConstCurrCamPos);
......@@ -321,20 +322,20 @@ SX_LIB_API void SPP_Update()
Core_RMatrixGet(G_RI_MATRIX_OBSERVER_VIEW, &PPSet::MCamView);
Core_RMatrixGet(G_RI_MATRIX_OBSERVER_PROJ, &PPSet::MCamProj);
PPSet::WinSize.x = Core_RFloatGet(G_RI_FLOAT_WINSIZE_WIDTH);
PPSet::WinSize.y = Core_RFloatGet(G_RI_FLOAT_WINSIZE_HEIGHT);
PPSet::WinSize.x = *winr_width;
PPSet::WinSize.y = *winr_height;
PPSet::ProjRatio = PPSet::WinSize.x / PPSet::WinSize.y;
PPSet::NearFar.x = Core_RFloatGet(G_RI_FLOAT_OBSERVER_NEAR);
PPSet::NearFar.y = Core_RFloatGet(G_RI_FLOAT_OBSERVER_FAR);
PPSet::NearFar.x = *p_near;
PPSet::NearFar.y = *p_far;
PPSet::ProjFov = Core_RFloatGet(G_RI_FLOAT_OBSERVER_FOV);
PPSet::ProjFov = *r_default_fov;
}
//##########################################################################
SX_LIB_API void SPP_RenderFogLinear(float3_t* color, float4_t* param)
SX_LIB_API void SPP_RenderFogLinear(float3_t* color, float density)
{
PP_PRECOND(_VOID);
PP_PRECOND_SECOND(_VOID);
......@@ -354,7 +355,7 @@ SX_LIB_API void SPP_RenderFogLinear(float3_t* color, float4_t* param)
PPSet::DXDevice->SetTexture(0, SGCore_RTGetTexture(PPSet::IDsRenderTargets::Depth0));
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, PPSet::IDsShaders::PS::FogLinear, "FogColor", color);
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, PPSet::IDsShaders::PS::FogLinear, "Param", param);
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, PPSet::IDsShaders::PS::FogLinear, "FogDenisty", &density);
//SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, PPSet::IDsShaders::PS::FogLinear, "NearFar", &PPSet::NearFar);
SGCore_ShaderBind(SHADER_TYPE_VERTEX, PPSet::IDsShaders::VS::ScreenOut);
......
......@@ -174,12 +174,9 @@ SX_LIB_API void SPP_RenderDOF(float4_t* param, float sky_blur);
/*! linear fog, линейный туман, использует depth0 \n
color - цвет тумана (0-1) \n
param.x - интенсивность тумана \n
param.y - на сколько небо в тумане \n
param.z - минимальное значение тумана \n
param.w - максимальное значение тумана \n
примерные значения: 0.8, 1, 0.1, 0.9*/
SX_LIB_API void SPP_RenderFogLinear(float3_t* color, float4_t* param);
density - интенсивность тумана \n
примерные значения: 0.8*/
SX_LIB_API void SPP_RenderFogLinear(float3_t* color, float density);
/*! space screen ambient occulusion, глобальное освещение (точнее затенение) в пространстве экрана, использует depth1 \n
param.x - радиус \n
......
......@@ -96,11 +96,11 @@ void GData::InitAllMatrix()
static const float *p_near = GET_PCVAR_FLOAT("p_near");
static const float *p_far = GET_PCVAR_FLOAT("p_far");
static const float *cam_fov = GET_PCVAR_FLOAT("cam_fov");
static const float *r_default_fov = GET_PCVAR_FLOAT("r_default_fov");
GData::NearFar.x = *p_near;
GData::NearFar.y = *p_far;
GData::ProjFov = *cam_fov;
GData::ProjFov = *r_default_fov;
GData::MCamProj = SMMatrixPerspectiveFovLH(GData::ProjFov, vWinSize.x / vWinSize.y, GData::NearFar.x, GData::NearFar.y);
GData::MLightProj = SMMatrixPerspectiveFovLH(GData::ProjFov, vWinSize.x / vWinSize.y, GData::NearFar.x, G_DATA_LIGHT_FAR);
......@@ -111,9 +111,9 @@ void GData::InitAllMatrix()
Core_RMatrixSet(G_RI_MATRIX_OBSERVER_PROJ, &GData::MCamProj);
Core_RMatrixSet(G_RI_MATRIX_LIGHT_PROJ, &GData::MLightProj);
Core_RFloatSet(G_RI_FLOAT_OBSERVER_NEAR, GData::NearFar.x);
/*Core_RFloatSet(G_RI_FLOAT_OBSERVER_NEAR, GData::NearFar.x);
Core_RFloatSet(G_RI_FLOAT_OBSERVER_FAR, GData::NearFar.y);
Core_RFloatSet(G_RI_FLOAT_OBSERVER_FOV, GData::ProjFov);
Core_RFloatSet(G_RI_FLOAT_OBSERVER_FOV, GData::ProjFov);*/
}
void GData::IDsShaders::InitAllShaders()
......
......@@ -473,9 +473,9 @@ void SXRenderFunc::UpdateView()
Core_RMatrixSet(G_RI_MATRIX_OBSERVER_PROJ, &GData::MCamProj);
Core_RMatrixSet(G_RI_MATRIX_LIGHT_PROJ, &GData::MLightProj);
Core_RFloatSet(G_RI_FLOAT_OBSERVER_NEAR, GData::NearFar.x);
/*Core_RFloatSet(G_RI_FLOAT_OBSERVER_NEAR, GData::NearFar.x);
Core_RFloatSet(G_RI_FLOAT_OBSERVER_FAR, GData::NearFar.y);
Core_RFloatSet(G_RI_FLOAT_OBSERVER_FOV, GData::ProjFov);
Core_RFloatSet(G_RI_FLOAT_OBSERVER_FOV, GData::ProjFov);*/
GData::ObjCamera->ObjFrustum->Update(&(GData::MCamView), &(GData::MCamProj));
......@@ -1432,12 +1432,12 @@ void SXRenderFunc::RenderPostProcess(DWORD timeDelta)
fog_color = (float3_t*)(*pp_fog_color);
static const float * pp_fog_density = GET_PCVAR_FLOAT("pp_fog_density");
static const float * pp_fog_sky = GET_PCVAR_FLOAT("pp_fog_sky");
/*static const float * pp_fog_sky = GET_PCVAR_FLOAT("pp_fog_sky");
static const float * pp_fog_min = GET_PCVAR_FLOAT("pp_fog_min");
static const float * pp_fog_max = GET_PCVAR_FLOAT("pp_fog_max");
static const float * pp_fog_max = GET_PCVAR_FLOAT("pp_fog_max");*/
if (pp_fog_density && *pp_fog_density > 0.f && pp_fog_sky && pp_fog_min && pp_fog_max)
SPP_RenderFogLinear(fog_color, &float4_t(*pp_fog_density, *pp_fog_sky, *pp_fog_min, *pp_fog_max));
if (pp_fog_density && *pp_fog_density > 0.f /*&& pp_fog_sky && pp_fog_min && pp_fog_max*/)
SPP_RenderFogLinear(fog_color, *pp_fog_density /*&float4_t(*pp_fog_density, *pp_fog_sky, *pp_fog_min, *pp_fog_max)*/);
//SPP_RenderWhiteBlack(1);
static const bool * pp_bloom = GET_PCVAR_BOOL("pp_bloom");
......
......@@ -133,14 +133,18 @@ See the license in LICENSE
//!@}
/*! ничего не меняли */
#define RENDER_RESIZE_NONE 0
/*! ресайз */
#define RENDER_RESIZE_RESIZE 1
/*! переход между фуллскрин и окном */
#define RENDER_RESIZE_CHANGE 2
//! тип изменения размеров окна рендера
enum RENDER_RESIZE
{
/*! ничего не меняли */
RENDER_RESIZE_NONE = 0,
/*! ресайз */
RENDER_RESIZE_RESIZE,
/*! переход между фуллскрин и окном */
RENDER_RESIZE_CHANGE,
};
//! цвет очистки цветового буфера сцены по умолчанию
#define RENDER_DEFAUL_BACKGROUND_COLOR D3DCOLOR_ARGB(0,128,128,128)
......
......@@ -246,8 +246,8 @@ void SkyXEngine_Init(HWND hWnd3D, HWND hWndParent3D)
#ifndef SX_GAME
ISXCamera *pCamera = SGCore_CrCamera();
static const float *cam_fov = GET_PCVAR_FLOAT("cam_fov");
pCamera->SetFOV(*cam_fov);
static const float *r_default_fov = GET_PCVAR_FLOAT("r_default_fov");
pCamera->SetFOV(*r_default_fov);
SRender_SetCamera(pCamera);