Commit ee1f395f authored by Byurrrer's avatar Byurrrer

добавил edge detecter, доделал антиальясинг, поменял шрифт у дебаг сообщения +...

добавил edge detecter, доделал антиальясинг, поменял шрифт у дебаг сообщения + добавил нужные таймеры для него, поправил баг в редакторе материалов при вращении симуляционной модели, поправил баги в редакторах при измении размеров окна рендера, добавил возможность перехода в абсолютный фуллскрин и к предыдущим размерам окна при нажитии f8 но только в фуллскрин режиме
parent a63ead4a
......@@ -3,3 +3,5 @@ echo "Executing editor config file"
unbind f10
cl_mode_editor 1
rs_stats 1
\ No newline at end of file
......@@ -17,7 +17,11 @@ half2 PixelSize;
half4 main(vs_out_pp IN) : COLOR0
{
half4 sampleCenter = tex2Dlod(Tex0, half4(IN.TexUV + half2(0.f, 0.f) * PixelSize,0.f,0.f));
half4 sampleCenter = tex2Dlod(Tex0, half4(IN.TexUV,0.f,0.f));
half fEdgeDetected = tex2Dlod(Tex1, half4(IN.TexUV,0.f,0.f));
[branch]if(fEdgeDetected.x == 0.f)
return sampleCenter;
half4 sampleVertNeg1 = tex2Dlod(Tex0, half4(IN.TexUV + half2(0.0, -3.5) * PixelSize, 0.f, 0.f));
half4 sampleVertNeg2 = tex2Dlod(Tex0, half4(IN.TexUV + half2(0.0, -7.5) * PixelSize, 0.f, 0.f));
......@@ -72,5 +76,7 @@ half4 main(vs_out_pp IN) : COLOR0
aaResult = lerp(aaResult, longBlurVert, pass1EdgeAvgHoriz);
}
//return tex2Dlod(Tex1, half4(IN.TexUV,0.f,0.f));
return half4(aaResult.rgb, sampleCenter.a);
return lerp(half4(aaResult.rgb, sampleCenter.a), sampleCenter, 1-fEdgeDetected.x);
}
\ No newline at end of file
......@@ -11,12 +11,17 @@ Directionally Localized Anti Aliasing
#define DLAA_MUL_VAL 0.333f
sampler2D Tex0:register(s0);
sampler2D Tex1:register(s1);
half2 PixelSize;
half4 main(vs_out_pp IN) : COLOR0
{
half4 sampleCenter = tex2Dlod(Tex0, half4(IN.TexUV + half2(0.f, 0.f) * PixelSize,0.f,0.f));
half4 sampleCenter = tex2Dlod(Tex0, half4(IN.TexUV,0.f,0.f));
half fEdgeDetected = tex2Dlod(Tex1, half4(IN.TexUV,0.f,0.f));
[branch]if(fEdgeDetected.x == 0.f)
return sampleCenter;
half4 sampleHorizNeg0 = tex2Dlod(Tex0, half4(IN.TexUV + half2(-1.5f, 0.f) * PixelSize, 0.f, 0.f));
half4 sampleHorizPos0 = tex2Dlod(Tex0, half4(IN.TexUV + half2( 1.5f, 0.f) * PixelSize, 0.f, 0.f));
......@@ -46,5 +51,7 @@ half4 main(vs_out_pp IN) : COLOR0
half4 aaResult = lerp(sampleCenter, avgHoriz, blurAmountHoriz);
aaResult = lerp(aaResult, avgVert, blurAmountVert);
return half4(aaResult.rgb, sampleCenter.a);
//return tex2Dlod(Tex1, half4(IN.TexUV,0.f,0.f));
return half4(aaResult.rgb, sampleCenter.a);
return lerp(half4(aaResult.rgb, sampleCenter.a), sampleCenter, 1-fEdgeDetected.x);
}
\ No newline at end of file
/*
ppe_edge_detected.ps
выделение границ
*/
#include <../struct.h>
#define DLAA_MUL_VAL 0.333
sampler2D Texture0:register(s0);
half2 PixelSize;
half4 main(vs_out_pp IN) : COLOR0
{
/*half4 Center = tex2D(Texture0, IN.TexUV);
half4 UpLeft = tex2D(Texture0, IN.TexUV + half2(-0.5, -0.5) * PixelSize);
half4 UpRight = tex2D(Texture0, IN.TexUV + half2( 0.5, -0.5) * PixelSize);
half4 DownLeft = tex2D(Texture0, IN.TexUV + half2(-0.5, 0.5) * PixelSize);
half4 DownRight = tex2D(Texture0, IN.TexUV + half2( 0.5, 0.5) * PixelSize);
half4 diff = abs(((UpLeft + UpRight + DownLeft + DownRight) * 4.0) - (Center * 16.0));
half edgeMask = dot(diff.xyz, DLAA_MUL_VAL);
return half4(Center.rgb, edgeMask);*/
half fDepthCenter = tex2D(Texture0, IN.TexUV);
half fDepthUpLeft = tex2D(Texture0, IN.TexUV + half2(-1, -1) * PixelSize);
half fDepthUpRight = tex2D(Texture0, IN.TexUV + half2( 1, -1) * PixelSize);
half fDepthDownLeft = tex2D(Texture0, IN.TexUV + half2(-1, 1) * PixelSize);
half fDepthDownRight = tex2D(Texture0, IN.TexUV + half2( 1, 1) * PixelSize);
half diff = abs(((fDepthUpLeft + fDepthUpRight + fDepthDownLeft + fDepthDownRight)*0.25f) - (fDepthCenter));
half edgeMask = step(lerp(0.00001f, 0.001f, fDepthCenter), diff);//dot(diff.xyz, DLAA_MUL_VAL);
return edgeMask;
}
......@@ -15,6 +15,7 @@ half3 Param;
half2 PixelSize;
sampler2D FrameSampler:register(s0);
sampler2D EdgeDetectedSampler:register(s1);
half2 GetNormal(half2 texuv)
{
......@@ -42,11 +43,16 @@ half2 GetNormal(half2 texuv)
half4 main(vs_out_pp IN) : COLOR0
{
half4 Scene0 = tex2Dlod(FrameSampler, half4(IN.TexUV.xy, 0, 0));
half fEdgeDetected = tex2Dlod(EdgeDetectedSampler, half4(IN.TexUV,0.f,0.f));
[branch]if(fEdgeDetected.x == 0.f)
return Scene0;
half2 Normal = GetNormal(IN.TexUV.xy);
Normal = clamp(Normal, -1, 1) * PixelSize;
half4 Scene0 = tex2Dlod(FrameSampler, half4(IN.TexUV.xy, 0, 0));
half4 Scene1 = tex2Dlod(FrameSampler, half4(IN.TexUV.xy + Normal.xy, 0, 0));
half4 Scene2 = tex2Dlod(FrameSampler, half4(IN.TexUV.xy - Normal.xy, 0, 0));
half4 Scene3 = tex2Dlod(FrameSampler, half4(IN.TexUV.xy + half2(Normal.x, -Normal.y), 0, 0));
......
......@@ -19,17 +19,19 @@ bind f12 screenshot
bind f11 save_worktex
bind f10 change_mode_window
bind f9 shader_reload
bind f8 change_mode_window_abs
cl_mode_editor 1
r_default_fov 1.046
rs_stats 2
pp_ssao 1
pp_bloom true
pp_lensflare true
pp_lensflare_usebloom true
pp_dlaa false
pp_nfaa false
pp_dlaa true
pp_nfaa true
pp_motionblur true
pp_motionblur_coef 0.1
......
......@@ -228,6 +228,8 @@ QT стиль документирования (!) и QT_AUTOBRIEF - корот
#ifndef __SKYXENGINE_H
#define __SKYXENGINE_H
#define SKYXENGINE_VERSION "0.9.3"
#include <windows.h>
#include <ctime>
#include <gdefines.h>
......
......@@ -125,13 +125,12 @@ void GCoreInit(HWND hwnd, int width, int heigth, bool windowed, DWORD create_dev
D3DXFONT_DESC LF;
ZeroMemory(&LF, sizeof(D3DXFONT_DESC));
LF.Height = 10; //
LF.Width = 6; //
LF.Weight = 6; // ,
// 0() - 1000()
LF.Height = 14;
LF.Width = 7;
LF.Weight = 10;
LF.Italic = 0;
LF.CharSet = DEFAULT_CHARSET;
LF.FaceName[0] = 0;
sprintf(LF.FaceName, "Courier New");
D3DXCreateFontIndirect(DXDevice, &LF, &FPSText);
......
This diff is collapsed.
......@@ -225,7 +225,7 @@ SX_LIB_API void SPP_RenderCBG(float3_t* param);
param.x - strength, множитель нормали, усиляет влияние нормали \n
param.y - scale, охватываемый масштаб \n
param.z - notmal map, вывести сформированные нормали \n
рекомендуемые параметры: 2, 1, 0*/
рекомендуемые параметры: 1, 2, 0*/
SX_LIB_API void SPP_RenderNFAA(float3_t* param);
//! dlaa (Directionally Localized Anti Aliasing)
......
#include "render_func.h"
/*
namespace SXRenderFunc
{
namespace Delay
......@@ -26,7 +26,7 @@ namespace SXRenderFunc
float FreeValF3 = 0;
};
};
*/
inline void SXRenderFunc::SetSamplerFilter(DWORD id, DWORD value)
{
......@@ -134,7 +134,8 @@ void SXRenderFunc::ComDeviceLost()
SXRenderFunc::InitModeWindow();
bool bf = SGCore_OnDeviceReset(*winr_width, *winr_height, *winr_windowed);
g_fnReportf(REPORT_MSG_LEVEL_WARNING, "winr_width %d, winr_height %d, winr_windowed %d \n", *winr_width, *winr_height, *winr_windowed);
if (bf)
{
//если все-таки функция зашла сюда значит что-то было неосвобождено
......@@ -413,12 +414,12 @@ void SXRenderFunc::InitModeWindow()
if (!(*winr_windowed))
{
SetWindowLong(GData::Handle3D, GWL_STYLE, WS_POPUP);
SetWindowLong(GData::Handle3D, GWL_STYLE, GetWindowLong(GData::Handle3D, GWL_STYLE) | WS_POPUP);
ShowWindow(GData::Handle3D, SW_MAXIMIZE);
}
else
{
SetWindowLong(GData::Handle3D, GWL_STYLE, WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX);
SetWindowLong(GData::Handle3D, GWL_STYLE, GetWindowLong(GData::Handle3D, GWL_STYLE) ^ WS_POPUP);
RECT rc;
GetWindowRect(GData::Handle3D, &rc);
......@@ -449,6 +450,55 @@ void SXRenderFunc::ChangeModeWindow()
*resize = RENDER_RESIZE_CHANGE;
}
void SXRenderFunc::FullScreenChangeSizeAbs()
{
static bool *winr_windowed = (bool*)GET_PCVAR_BOOL("winr_windowed");
if (winr_windowed == NULL || (*winr_windowed))
return;
int iCountModes = 0;
static const DEVMODE *pModes = SGCore_GetModes(&iCountModes);
static int iFullScreenWidth = 800;
static int iFullScreenHeight = 600;
if (pModes)
{
iFullScreenWidth = pModes[iCountModes - 1].dmPelsWidth;
iFullScreenHeight = pModes[iCountModes - 1].dmPelsHeight;
pModes = 0;
}
static int * winr_width = (int*)GET_PCVAR_INT("winr_width");
static int * winr_height = (int*)GET_PCVAR_INT("winr_height");
if (!winr_width || !winr_height)
return;
static int winr_width_old = *winr_width;
static int winr_height_old = *winr_height;
if (*winr_width == iFullScreenWidth && *winr_height == iFullScreenHeight)
{
*winr_width = winr_width_old;
*winr_height = winr_height_old;
}
else
{
winr_width_old = *winr_width;
winr_height_old = *winr_height;
*winr_width = iFullScreenWidth;
*winr_height = iFullScreenHeight;
//g_fnReportf(REPORT_MSG_LEVEL_WARNING, "iFullScreenWidth %d, iFullScreenHeight %d \n", iFullScreenWidth, iFullScreenHeight);
}
static int *resize = (int*)GET_PCVAR_INT("resize");
*resize = RENDER_RESIZE_CHANGE;
}
//##########################################################################
void SXRenderFunc::UpdateView()
......@@ -489,14 +539,15 @@ void SXRenderFunc::UpdateView()
GData::DefaultAnimIDArr = SXAnim_ModelsAddArrForCom();
}
void SXRenderFunc::OutputDebugInfo(DWORD timeDelta, bool needGameTime)
int SXRenderFunc::OutputDebugInfo(DWORD timeDelta, bool needGameTime, const char *szStr)
{
GData::DXDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
GData::DXDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
GData::DXDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
GData::DXDevice->SetRenderState(D3DRS_ZWRITEENABLE, D3DZB_TRUE);
static DWORD FrameCount=0;
static int FrameCount = 0;
static int FrameCount2 = 0;
static float TimeElapsed=0;
static float FpsValue = 0;
static char FpsStr[1024];
......@@ -505,71 +556,45 @@ void SXRenderFunc::OutputDebugInfo(DWORD timeDelta, bool needGameTime)
++FrameCount;
TimeElapsed += ((float)timeDelta) * 0.001f;
static const int * rs_stats = GET_PCVAR_INT("rs_stats");
if (TimeElapsed >= 1.0f && rs_stats)
{
FpsValue = (float)FrameCount / TimeElapsed;
if ((*rs_stats) > 0)
sprintf(debugstr, "FPS %.1f\n", FpsValue);
static bool isNulled = false;
if (TimeElapsed >= 1.0f && rs_stats)
{
FpsValue = (float)FrameCount / TimeElapsed;
if (needGameTime)
{
tm g_tm;
time_t g_time = Core_TimeUnixCurrGet(Core_RIntGet(G_RI_INT_TIMER_GAME));
localtime_s(&g_tm, &g_time);
if ((*rs_stats) > 0)
sprintf(debugstr, "FPS %.1f\n", FpsValue);
sprintf(debugstr + strlen(debugstr), "\nGame time : %d %d %d %d %d %d\n", 1900 + g_tm.tm_year, g_tm.tm_mon, g_tm.tm_mday, g_tm.tm_hour, g_tm.tm_min, g_tm.tm_sec);
}
if (needGameTime)
{
tm g_tm;
time_t g_time = Core_TimeUnixCurrGet(Core_RIntGet(G_RI_INT_TIMER_GAME));
localtime_s(&g_tm, &g_time);
if ((*rs_stats) == 2)
{
sprintf(debugstr + strlen(debugstr), "\ncount poly : %d\n", Core_RIntGet(G_RI_INT_COUNT_POLY) / FrameCount);
sprintf(debugstr + strlen(debugstr), "count DIPs : %d\n\n", Core_RIntGet(G_RI_INT_COUNT_DIP) / FrameCount);
sprintf(debugstr + strlen(debugstr), "Pos camera : [%.2f, %.2f, %.2f]\n", GData::ConstCurrCamPos.x, GData::ConstCurrCamPos.y, GData::ConstCurrCamPos.z);
sprintf(debugstr + strlen(debugstr), "Dir camera : [%.2f, %.2f, %.2f]\n", GData::ConstCurrCamDir.x, GData::ConstCurrCamDir.y, GData::ConstCurrCamDir.z);
/*sprintf(debugstr + strlen(debugstr), "\nDELAY:\n");
sprintf(debugstr + strlen(debugstr), "\tUpdateShadow : %.3f\n", float(SXRenderFunc::Delay::UpdateShadow) / float(FrameCount) * 0.001f);
sprintf(debugstr + strlen(debugstr), "\tRenderMRT : %.3f\n", float(SXRenderFunc::Delay::RenderMRT) / float(FrameCount) * 0.001f);
sprintf(debugstr + strlen(debugstr), "\tComLighting : %.3f\n", float(SXRenderFunc::Delay::ComLighting) / float(FrameCount) * 0.001f);
sprintf(debugstr + strlen(debugstr), "\tPostProcess : %.3f\n", float(SXRenderFunc::Delay::PostProcess) / float(FrameCount) * 0.001f);
sprintf(debugstr + strlen(debugstr), "\tComReflection : %.3f\n", float(SXRenderFunc::Delay::ComReflection) / float(FrameCount) * 0.001f);
sprintf(debugstr + strlen(debugstr), "\tGeomSortGroup : %.3f\n", float(SXRenderFunc::Delay::GeomSortGroup) / float(FrameCount) * 0.001f);
sprintf(debugstr + strlen(debugstr), "\tUpdateParticles : %.3f\n", float(SXRenderFunc::Delay::UpdateParticles) / float(FrameCount) * 0.001f);
sprintf(debugstr + strlen(debugstr), "\n\tUpdateVisibleFor\n");
sprintf(debugstr + strlen(debugstr), "\t\tCamera\t: %.3f\n", float(SXRenderFunc::Delay::UpdateVisibleForCamera) / float(FrameCount) * 0.001f);
sprintf(debugstr + strlen(debugstr), "\t\tLight\t: %.3f\n", float(SXRenderFunc::Delay::UpdateVisibleForLight) / float(FrameCount) * 0.001f);
sprintf(debugstr + strlen(debugstr), "\t\tReflection\t: %.3f\n", float(SXRenderFunc::Delay::UpdateVisibleForReflection) / float(FrameCount) * 0.001f);
sprintf(debugstr + strlen(debugstr), "\n\tPresent : %.3f\n", float(SXRenderFunc::Delay::Present) / float(FrameCount) * 0.001f);
sprintf(debugstr + strlen(debugstr), "\nFreeVal : %d\n", SXRenderFunc::Delay::FreeVal);
sprintf(debugstr + strlen(debugstr), "\nFreeValF1 : %f\n", SXRenderFunc::Delay::FreeValF1);
sprintf(debugstr + strlen(debugstr), "\nFreeValF2 : %f\n", SXRenderFunc::Delay::FreeValF2);
sprintf(debugstr + strlen(debugstr), "\nFreeValF3 : %f\n", SXRenderFunc::Delay::FreeValF3);*/
}
sprintf(debugstr + strlen(debugstr), "\nGame time : %d %d %d %d %d %d\n", 1900 + g_tm.tm_year, g_tm.tm_mon, g_tm.tm_mday, g_tm.tm_hour, g_tm.tm_min, g_tm.tm_sec);
}
Core_RIntSet(G_RI_INT_COUNT_POLY, 0);
Core_RIntSet(G_RI_INT_COUNT_DIP, 0);
TimeElapsed = 0.0f;
FrameCount = 0;
SXRenderFunc::Delay::UpdateShadow = 0;
SXRenderFunc::Delay::RenderMRT = 0;
SXRenderFunc::Delay::ComLighting = 0;
SXRenderFunc::Delay::PostProcess = 0;
SXRenderFunc::Delay::ComReflection = 0;
SXRenderFunc::Delay::GeomSortGroup = 0;
SXRenderFunc::Delay::UpdateVisibleForCamera = 0;
SXRenderFunc::Delay::UpdateVisibleForLight = 0;
SXRenderFunc::Delay::UpdateVisibleForReflection = 0;
SXRenderFunc::Delay::Present = 0;
if ((*rs_stats) == 2)
{
sprintf(debugstr + strlen(debugstr), szStr);
}
Core_RIntSet(G_RI_INT_COUNT_POLY, 0);
Core_RIntSet(G_RI_INT_COUNT_DIP, 0);
TimeElapsed = 0.0f;
FrameCount2 = FrameCount;
FrameCount = 0;
isNulled = true;
}
else
isNulled = false;
if (rs_stats && (*rs_stats) > 0)
SGCore_DbgMsg(debugstr);
return (isNulled ? FrameCount2 : 0);
}
//##########################################################################
......@@ -1471,14 +1496,16 @@ void SXRenderFunc::RenderPostProcess(DWORD timeDelta)
SPP_RenderDOF(&float4_t(0, 200, 0, 100), 0);
static const bool * pp_nfaa = GET_PCVAR_BOOL("pp_nfaa");
if (pp_nfaa && (*pp_nfaa))
SPP_RenderNFAA(&float3_t(1, 2, 0));
static const bool * pp_dlaa = GET_PCVAR_BOOL("pp_dlaa");
if (pp_dlaa && (*pp_dlaa))
SPP_RenderDLAA();
static const bool * pp_nfaa = GET_PCVAR_BOOL("pp_dlaa");
if (pp_nfaa && (*pp_nfaa))
SPP_RenderNFAA(&float3_t(1, 1, 0));
static const bool * pp_motionblur = GET_PCVAR_BOOL("pp_motionblur");
static const float * pp_motionblur_coef = GET_PCVAR_FLOAT("pp_motionblur_coef");
if (pp_motionblur && (*pp_motionblur))
......
......@@ -62,7 +62,7 @@ namespace SXRenderFunc
void UpdateView();
//! вывод отладочной текстовой информации в окно рендера
void OutputDebugInfo(DWORD timeDelta, bool needGameTime);
int OutputDebugInfo(DWORD timeDelta, bool needGameTime, const char *szStr = 0);
//! обработка видимости для источников света
void ComVisibleForLight();
......@@ -131,8 +131,10 @@ namespace SXRenderFunc
//! изменить режим рендера (оконный/полноэкранный)
void ChangeModeWindow();
void FullScreenChangeSizeAbs();
//! время задержек/ожидания выполнения некоторых функций рендера
namespace Delay
/*namespace Delay
{
extern int64_t UpdateVisibleForCamera;
extern int64_t UpdateVisibleForLight;
......@@ -152,7 +154,7 @@ namespace SXRenderFunc
extern float FreeValF1;
extern float FreeValF2;
extern float FreeValF3;
};
};*/
};
#endif
......
......@@ -198,7 +198,7 @@ SX_LIB_API int SRender_SimModelGetNumCurrModel()
SX_LIB_API void SRender_SimModelSetRotationY(float Rotation)
{
GData::Editors::SimModel->Rotation = Rotation;
GData::Editors::SimModel->Rotation.y = Rotation;
}
SX_LIB_API float SRender_SimModelGetRotationY()
......@@ -275,9 +275,9 @@ SX_LIB_API void SRender_UpdateView()
SXRenderFunc::UpdateView();
}
SX_LIB_API void SRender_OutputDebugInfo(DWORD timeDelta, bool needGameTime)
SX_LIB_API int SRender_OutputDebugInfo(DWORD timeDelta, bool needGameTime, const char *szStr)
{
SXRenderFunc::OutputDebugInfo(timeDelta, needGameTime);
return SXRenderFunc::OutputDebugInfo(timeDelta, needGameTime, szStr);
}
......@@ -368,4 +368,9 @@ SX_LIB_API void SRender_SaveWorkTex()
SX_LIB_API void SRender_ChangeModeWindow()
{
SXRenderFunc::ChangeModeWindow();
}
SX_LIB_API void SRender_FullScreenChangeSizeAbs()
{
SXRenderFunc::FullScreenChangeSizeAbs();
}
\ No newline at end of file
......@@ -325,7 +325,7 @@ SX_LIB_API void SRender_ComVisibleReflection();
SX_LIB_API void SRender_UpdateView();
//! вывод отладочной текстовой информации в окно рендера
SX_LIB_API void SRender_OutputDebugInfo(DWORD timeDelta, bool needGameTime);
SX_LIB_API int SRender_OutputDebugInfo(DWORD timeDelta, bool needGameTime, const char *szStr = 0);
//! построение G буфера, то есть рендер всей сцены
......@@ -384,6 +384,9 @@ SX_LIB_API void SRender_SaveWorkTex();
//! изменить режим рендера (оконный/полноэкранный)
SX_LIB_API void SRender_ChangeModeWindow();
//! переключение в режиме fullscreen в абсолютный fullscreen и обратно
SX_LIB_API void SRender_FullScreenChangeSizeAbs();
//!@} sxrender
#endif
\ No newline at end of file
This diff is collapsed.
......@@ -467,7 +467,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin
SGCore_SkyBoxLoadTex("sky/sky_2_cube.dds");
SXMaterialEditor::EditSkyBox->SetText("sky/sky_2_cube.dds");
SRender_GetCamera()->SetPosition(&float3(0, 0, -1.2 * 100));
SRender_GetCamera()->SetPosition(&float3(0, 0, -100));
SRender_SimModelAdd("sphere.dse");
......
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