Commit d85dd261 authored by Byurrrer's avatar Byurrrer

размеры облаков теперь устаналвиваются автоматически во время загрузки уровня,...

размеры облаков теперь устаналвиваются автоматически во время загрузки уровня, добавил  управление светом в редакторе материалов, поправил освещение (спекуляр был в тени, добавил микрорельеф в тени)
parent 66d41099
......@@ -107,6 +107,7 @@ PSO_Lbuffer main(VSO_ResPos IN)
half fSpecular = GetSpecular(vParam, fNdotH, fNdotV, fNdotL, fLdotV, fHdotV);
half fAbsDiffuse = saturate(fNdotL);
half fMdiffuse = saturate(fNdotL * 0.5 + 0.5);
half fDiffuse = fAbsDiffuse;
//закрываем баг с отставанием теней
......@@ -124,13 +125,13 @@ PSO_Lbuffer main(VSO_ResPos IN)
fDiffuse *= max(fOriginShadow, 0.2);
else
//иначе выбираем значения тени из диапазона, на основании силы света
fDiffuse *= max(fShadow, lerp(0.01, 0.07,g_vLightColor.w));
fDiffuse *= max(fShadow, lerp(0.01, 0.07, g_vLightColor.w));
#endif
OUT.vAmdient.xyz = g_vLightColor.xyz * g_vLightColor.xyz * g_vLightPowerDist.x * fAttenuation;
OUT.vAmdient.w = fDiffuse * vParam.w * g_vLightPowerDist.x * fAttenuation;
OUT.vAmdient.w = fDiffuse * fMdiffuse * vParam.w * g_vLightPowerDist.x * fAttenuation;
OUT.vSpecular = fSpecular * fDiffuse * fAttenuation * g_vLightPowerDist.x;
OUT.vSpecular = fSpecular * fAbsDiffuse * fAttenuation * g_vLightPowerDist.x;
return OUT;
}
\ No newline at end of file
......@@ -111,6 +111,7 @@ PSO_Gbuffer CreateGbuffer(half4 vColor, half3 vNormal, half4 vParam, half4 vPosi
OUT.vColor = vColor;
vNormal = normalize(vNormal);
//OUT.vNormal.xyz = vNormal;
OUT.vNormal.xy = NormalEncode(vNormal);
OUT.vNormal.w = vNearFarLayers.z;
OUT.vNormal.z = vNearFarLayers.w;
......
......@@ -20,7 +20,7 @@ half4 g_vNearFarLayers;
PSO_Gbuffer main(VSO_SceneCommon IN)
{
ClipFar(IN.vPos.z,g_vNearFarLayers.y);
ClipFar(IN.vPos.z, g_vNearFarLayers.y);
IN.vNormal = normalize(IN.vNormal);
return CreateGbuffer(tex2D(g_sColor,IN.vTexUV), IN.vNormal, tex2D(g_sParameters,IN.vTexUV), IN.vPos, g_vNearFarLayers);
......
......@@ -22,7 +22,7 @@ half4 g_vNearFarLayers;
PSO_Gbuffer main(VSO_SceneCommon IN)
{
ClipFar(IN.vPos.z,g_vNearFarLayers.y);
ClipFar(IN.vPos.z, g_vNearFarLayers.y);
IN.vNormal = normalize(IN.vNormal);
half3 vNormal = MixNormalMicro(IN.vNormal, Color2Normal(tex2D(g_sNormals0, IN.vTexUV).xyz) * g_vParam.z);
......
......@@ -21,7 +21,7 @@ half3 g_vBoundMin : register(GREEN_R_BBMIN);
void main(in VSI_Green IN, out VSO_SceneCommon OUT)
{
OUT.vNormal = GreenComRotation(IN.vNormal, IN.vInstSinCosRot);
OUT.vNormal = GreenComRotation(normalize(IN.vNormal), IN.vInstSinCosRot);
OUT.vPosition = GreenTransformPos(
GreenComRotation(IN.vPosition, IN.vInstSinCosRot),
......
......@@ -15,7 +15,7 @@ half4x4 g_mWVP;
void main(in VSI_Green IN, out VSO_SceneCommon OUT)
{
OUT.vNormal = (GreenComRotation(IN.vNormal,IN.vInstSinCosRot));
OUT.vNormal = (GreenComRotation(normalize(IN.vNormal),IN.vInstSinCosRot));
OUT.vPosition = GreenTransformPos(
GreenComRotation(IN.vPosition,IN.vInstSinCosRot),
......
......@@ -17,7 +17,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin
SGCore_SkyBoxLoadTex("sky_2_cube.dds");
SGCore_SkyCloudsLoadTex("sky_oblaka.dds");
SGCore_SkyCloudsSetWidthHeightPos(1000, 1000, &float3(0, 0, 0));
//SGCore_SkyCloudsSetWidthHeightPos(1000, 1000, &float3(0, 0, 0));
SLevel_Load("stalker_atp", true);
......
......@@ -179,6 +179,13 @@ void CLevel::load(const char *szName, bool isGame)
String str = config->getKey("level", "type");
if (stricmp(str.c_str(), "outdoor") == 0)
{
SGCore_SkyBoxCr();
SGCore_SkyCloudsCr();
float3 vMin, vMax;
SGeom_ModelsGetMinMax(&vMin, &vMax);
SGCore_SkyCloudsSetWidthHeightPos((vMax.x - vMin.x) * 2.f, (vMax.z - vMin.z) * 2.f, &float3((vMax + vMin) * 0.5));
ID gid = SML_LigthsCreatePoint(
&float3(60, 60, 0),
0,
......
......@@ -190,11 +190,19 @@ void PPSet::Init()
pRnsSampler->LockRect(0, &LockedRect, 0, 0);
float3 vRnd;
for (int i = 0; i < (*r_win_width) * (*r_win_height); ++i)
{
((DWORD*)LockedRect.pBits)[i] = D3DCOLOR_ARGB(255, rand() % 255, rand() % 255, rand() % 255);
//memcpy(LockedRect.pBits + (i * sizeof(DWORD)), aRndColors, sizeof(uint32_t));
vRnd.x = randf(0, 1);
vRnd.y = randf(0, 1);
vRnd.z = randf(0, 1);
vRnd = SMVector3Normalize(vRnd);
((DWORD*)LockedRect.pBits)[i] = D3DCOLOR_ARGB(255, DWORD(vRnd.x * 255.0), DWORD(vRnd.y * 255.0), DWORD(vRnd.z * 255.0));
}
pRnsSampler->UnlockRect(0);
//SGCore_LoadTexLoadTextures();
......@@ -294,8 +302,17 @@ SX_LIB_API void SPP_OnDeviceReset()
pRnsSampler->LockRect(0, &LockedRect, 0, 0);
float3 vRnd;
for (int i = 0; i < (*r_win_width) * (*r_win_height); ++i)
((DWORD*)LockedRect.pBits)[i] = D3DCOLOR_ARGB(255, rand() % 255, rand() % 255, rand() % 255);
{
vRnd.x = randf(0, 1);
vRnd.y = randf(0, 1);
vRnd.z = randf(0, 1);
vRnd = SMVector3Normalize(vRnd);
((DWORD*)LockedRect.pBits)[i] = D3DCOLOR_ARGB(255, DWORD(vRnd.x * 255.0), DWORD(vRnd.y * 255.0), DWORD(vRnd.z * 255.0));
}
pRnsSampler->UnlockRect(0);
......
......@@ -214,7 +214,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin
SGCore_SkyBoxLoadTex("sky_2_cube.dds");
SGCore_SkyCloudsLoadTex("sky_oblaka.dds");
SGCore_SkyCloudsSetWidthHeightPos(2000, 2000, &float3(0, 0, 0));
//SGCore_SkyCloudsSetWidthHeightPos(2000, 2000, &float3(0, 0, 0));
SkyXEngine_RunGenPreview();
......
......@@ -21,6 +21,38 @@ LRESULT SXMaterialEditor_ButtonRotAngle0_Click(HWND hwnd, UINT msg, WPARAM wPara
return 0;
}
LRESULT SXMaterialEditor_ButtonLigthColor_Click(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static COLORREF aCustClr[16];
CHOOSECOLOR oChooseColor;
ZeroMemory(&oChooseColor, sizeof(CHOOSECOLOR));
oChooseColor.hwndOwner = hwnd;
oChooseColor.lStructSize = sizeof(CHOOSECOLOR);
oChooseColor.lpCustColors = aCustClr;
oChooseColor.Flags = CC_FULLOPEN | CC_RGBINIT;
ID idGlobalLight = SML_LigthsGetGlobal();
float3 vColor;
SML_LigthsGetColor(idGlobalLight, &vColor);
oChooseColor.rgbResult = RGB(DWORD(vColor.x * 255.0), DWORD(vColor.y * 255.0), DWORD(vColor.z * 255.0));
if (ChooseColor(&oChooseColor))
{
vColor.x = float(GetRValue(oChooseColor.rgbResult)) / 255.0;
vColor.y = float(GetGValue(oChooseColor.rgbResult)) / 255.0;
vColor.z = float(GetBValue(oChooseColor.rgbResult)) / 255.0;
SML_LigthsSetColor(idGlobalLight, &vColor);
SXMaterialEditor::StaticLigthColor->setColorBrush(oChooseColor.rgbResult);
SXMaterialEditor::EditLigthColorR->setText(String(vColor.x).c_str());
SXMaterialEditor::EditLigthColorG->setText(String(vColor.y).c_str());
SXMaterialEditor::EditLigthColorB->setText(String(vColor.z).c_str());
}
return 0;
}
LRESULT SXMaterialEditor_ButtonTex_Click(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
char tmppath[1024];
......
......@@ -3,7 +3,7 @@
#define __BUTTONS_CALLBACK_H
#include <common/string.h>
#include <windows.h>
#include <sxguiwinapi/sxgui.h>
#include <mtllight/sxmtllight.h>
#include <render/sxrender.h>
......@@ -15,6 +15,8 @@ LRESULT SXMaterialEditor_ButtonSkyBox_Click(HWND hwnd, UINT msg, WPARAM wParam,
LRESULT SXMaterialEditor_ButtonRotAngle0_Click(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT SXMaterialEditor_ButtonLigthColor_Click(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT SXMaterialEditor_ButtonTex_Click(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT SXMaterialEditor_ButtonVS_Click(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
......
......@@ -34,6 +34,70 @@ LRESULT SXMaterialEditor_EditSkyBox_Enter(HWND hwnd, UINT msg, WPARAM wParam, LP
return 0;
}
LRESULT SXMaterialEditor_EditLigthColorR_Enter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
char szStr[32];
szStr[0] = 0;
SXMaterialEditor::EditLigthColorR->getText(szStr, 32);
ID idGlobalLight = SML_LigthsGetGlobal();
if (idGlobalLight > -1)
{
float3 vColor;
SML_LigthsGetColor(idGlobalLight, &vColor);
sscanf(szStr, "%f", &vColor.x);
SML_LigthsSetColor(idGlobalLight, &vColor);
SXMaterialEditor::StaticLigthColor->setColorBrush(RGB(DWORD(vColor.x * 255.0), DWORD(vColor.y * 255.0), DWORD(vColor.z * 255.0)));
}
return 0;
}
LRESULT SXMaterialEditor_EditLigthColorG_Enter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
char szStr[32];
szStr[0] = 0;
SXMaterialEditor::EditLigthColorG->getText(szStr, 32);
ID idGlobalLight = SML_LigthsGetGlobal();
if (idGlobalLight > -1)
{
float3 vColor;
SML_LigthsGetColor(idGlobalLight, &vColor);
sscanf(szStr, "%f", &vColor.y);
SML_LigthsSetColor(idGlobalLight, &vColor);
SXMaterialEditor::StaticLigthColor->setColorBrush(RGB(DWORD(vColor.x * 255.0), DWORD(vColor.y * 255.0), DWORD(vColor.z * 255.0)));
}
return 0;
}
LRESULT SXMaterialEditor_EditLigthColorB_Enter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
char szStr[32];
szStr[0] = 0;
SXMaterialEditor::EditLigthColorB->getText(szStr, 32);
ID idGlobalLight = SML_LigthsGetGlobal();
if (idGlobalLight > -1)
{
float3 vColor;
SML_LigthsGetColor(idGlobalLight, &vColor);
sscanf(szStr, "%f", &vColor.z);
SML_LigthsSetColor(idGlobalLight, &vColor);
SXMaterialEditor::StaticLigthColor->setColorBrush(RGB(DWORD(vColor.x * 255.0), DWORD(vColor.y * 255.0), DWORD(vColor.z * 255.0)));
}
return 0;
}
LRESULT SXMaterialEditor_EditTex_Enter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
char szStr[SXGC_LOADTEX_MAX_SIZE_DIRNAME];
......
......@@ -13,6 +13,12 @@
LRESULT SXMaterialEditor_EditSkyBox_Enter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT SXMaterialEditor_EditLigthColorR_Enter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT SXMaterialEditor_EditLigthColorG_Enter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT SXMaterialEditor_EditLigthColorB_Enter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT SXMaterialEditor_EditTex_Enter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT SXMaterialEditor_EditVS_Enter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
......
This diff is collapsed.
......@@ -47,6 +47,16 @@ namespace SXMaterialEditor
extern ISXGUIStatic* StaticTypeModel;
extern ISXGUIComboBox* ComboBoxTypeModel;
extern ISXGUIStatic* StaticLigthColorText;
extern ISXGUIStatic* StaticLigthColorR;
extern ISXGUIEdit* EditLigthColorR;
extern ISXGUIStatic* StaticLigthColorG;
extern ISXGUIEdit* EditLigthColorG;
extern ISXGUIStatic* StaticLigthColorB;
extern ISXGUIEdit* EditLigthColorB;
extern ISXGUIButton* ButtonLigthColor;
extern ISXGUIStatic* StaticLigthColor;
extern ISXGUIStatic* StaticPenetration;
extern ISXGUIEdit* EditHitChance;
extern ISXGUITrackBar* TrackBarHitChance;
......
......@@ -486,6 +486,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin
SML_LigthsSetEnable(SML_LigthsGetCount() - 1, true);
SML_LigthsSetName(SML_LigthsGetCount() - 1, "sun");
SXMaterialEditor::EditLigthColorR->setText("1");
SXMaterialEditor::EditLigthColorG->setText("1");
SXMaterialEditor::EditLigthColorB->setText("1");
SXMaterialEditor::StaticLigthColor->setColorBrush(RGB(255, 255, 255));
SGCore_LoadTexAllLoad();
SXMaterialEditor::InitMtl(SRender_SimModelGetIDMtl());
......
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