This commit is contained in:
korenkonder
2024-12-12 01:32:41 +03:00
parent 014ac36020
commit cf6d2e56bf
9 changed files with 302 additions and 42 deletions
+1 -6
View File
@@ -472,12 +472,7 @@ namespace rndr {
shad->curr_render_textures[0] = &shad->render_textures[0];
shad->curr_render_textures[1] = &shad->render_textures[1];
shad->curr_render_textures[2] = &shad->render_textures[2];
for (int32_t i = 1; i < 3; i++) {
shad->curr_render_textures[i]->Bind();
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
}
shad->clear_textures();
}
shader::unbind();
gl_state_bind_framebuffer(0);
+21 -4
View File
@@ -21,6 +21,16 @@ Shadow::~Shadow() {
free();
}
void Shadow::clear_textures() {
for (int32_t i = 1; i < 3; i++)
for (int32_t j = 0; j < 4; j++) {
curr_render_textures[i]->Bind(j);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
}
gl_state_bind_framebuffer(0);
}
void Shadow::ctrl() {
for (int32_t i = 0; i < 2; i++)
shadow_enable[i] = false;
@@ -293,10 +303,10 @@ int32_t Shadow::init() {
{ 0x200, 0x200, 0, GL_R32F , GL_ZERO },
};
shadow_texture_init_params* v3 = init_params;
for (int32_t i = 0; i < 7; i++, v3++)
if (render_textures[i].Init(v3->width, v3->height,
v3->max_level, v3->color_format, v3->depth_format) < 0)
shadow_texture_init_params* init_param = init_params;
for (int32_t i = 0; i < 7; i++, init_param++)
if (render_textures[i].Init(init_param->width, init_param->height,
init_param->max_level, init_param->color_format, init_param->depth_format) < 0)
return -1;
for (int32_t i = 0; i < 3; i++) {
@@ -349,6 +359,13 @@ void Shadow::reset() {
field_208 = (z_far - z_near) * 0.5f;
}
void Shadow::set_distance(float_t value) {
if (fabs(value) > 0.000001f)
distance = value;
else
distance = 1.0f;
}
void shadow_ptr_init() {
shadow_ptr = new Shadow;
}
+2
View File
@@ -59,11 +59,13 @@ struct Shadow {
Shadow();
virtual ~Shadow();
void clear_textures();
void ctrl();
void free();
float_t get_shadow_range();
int32_t init();
void reset();
void set_distance(float_t value);
};
extern void shadow_ptr_init();
+15
View File
@@ -13,6 +13,7 @@
#include "../graphics/material.hpp"
#include "../graphics/post_process.hpp"
#include "../graphics/render_settings.hpp"
#include "../graphics/shadow.hpp"
#include "graphics/background_color.hpp"
classes_data graphics_classes[] = {
@@ -100,6 +101,20 @@ classes_data graphics_classes[] = {
0,
0,
},
{
"Shadow##Graphics",
CLASSES_IN_CONTEXT_MENU,
(classes_init_func)shadow_dw_init,
CLASSES_DATA_NO_FUNC,
CLASSES_DATA_NO_FUNC,
{
CLASS_DW,
false,
CLASS_DATA_NO_DATA,
},
0,
0,
},
{
"Global Material##Graphics",
CLASSES_IN_CONTEXT_MENU,
+10 -10
View File
@@ -255,25 +255,25 @@ namespace dw {
}
float_t Font::GetFontGlyphHeight() {
float_t Font::GetFontGlyphHeight() const {
return font.glyph.y;
}
vec2 Font::GetFontGlyphSize() {
vec2 Font::GetFontGlyphSize() const {
vec2 size;
size.x = GetFontGlyphWidth();
size.y = GetFontGlyphHeight();
return size;
}
float_t Font::GetFontGlyphWidth() {
float_t Font::GetFontGlyphWidth() const {
float_t glyph_height = font.glyph.x;
if (half_width)
return glyph_height * 0.5f;
return glyph_height;
}
std::string Font::GetName() {
std::string Font::GetName() const {
return name;
}
@@ -291,19 +291,19 @@ namespace dw {
}
float_t p_Font::GetFontGlyphHeight() {
float_t p_Font::GetFontGlyphHeight() const {
return ptr->GetFontGlyphHeight();
}
vec2 p_Font::GetFontGlyphSize() {
vec2 p_Font::GetFontGlyphSize() const {
return ptr->GetFontGlyphSize();
}
float_t p_Font::GetFontGlyphWidth() {
float_t p_Font::GetFontGlyphWidth() const {
return ptr->GetFontGlyphWidth();
}
std::string p_Font::GetName() {
std::string p_Font::GetName() const {
return ptr->GetName();
}
@@ -2044,11 +2044,11 @@ namespace dw {
return items[index];
}
size_t List::GetItemCount() {
size_t List::GetItemCount() const {
return items.size();
}
size_t List::GetMaxItemsVisible() {
size_t List::GetMaxItemsVisible() const {
if (!v_bar)
return items.size();
else if (max_items >= items.size())
+21 -21
View File
@@ -61,10 +61,10 @@ namespace dw {
~Font();
float_t GetFontGlyphHeight();
vec2 GetFontGlyphSize();
float_t GetFontGlyphWidth();
std::string GetName();
float_t GetFontGlyphHeight() const;
vec2 GetFontGlyphSize() const;
float_t GetFontGlyphWidth() const;
std::string GetName() const;
void SetGlyphSize(float_t glyph_width, float_t glyph_height);
};
@@ -79,10 +79,10 @@ namespace dw {
~p_Font();
float_t GetFontGlyphHeight();
vec2 GetFontGlyphSize();
float_t GetFontGlyphWidth();
std::string GetName();
float_t GetFontGlyphHeight() const;
vec2 GetFontGlyphSize() const;
float_t GetFontGlyphWidth() const;
std::string GetName() const;
void SetGlyphSize(float_t glyph_width, float_t glyph_height);
};
@@ -543,8 +543,8 @@ namespace dw {
void ClearItems();
std::string GetItemStr(size_t index) const;
std::wstring GetItem(size_t index) const;
size_t GetItemCount();
size_t GetMaxItemsVisible();
size_t GetItemCount() const;
size_t GetMaxItemsVisible() const;
void ResetSelectedItem();
void SetMaxItems(size_t value);
void SetScrollBarParams();
@@ -560,19 +560,19 @@ namespace dw {
AddItem(str);
}
inline std::string GetHoveredItemStr() {
inline std::string GetHoveredItemStr() const {
return GetItemStr(hovered_item);
}
inline std::wstring GetHoveredItem() {
inline std::wstring GetHoveredItem() const {
return GetItem(hovered_item);
}
inline std::string GetSelectedItemStr() {
inline std::string GetSelectedItemStr() const {
return GetItemStr(selected_item);
}
inline std::wstring GetSelectedItem() {
inline std::wstring GetSelectedItem() const {
return GetItem(selected_item);
}
@@ -630,43 +630,43 @@ namespace dw {
list->ClearItems();
}
inline std::string GetItemStr(size_t index) {
inline std::string GetItemStr(size_t index) const {
if (list)
return list->GetItemStr(index);
return {};
}
inline std::wstring GetItem(size_t index) {
inline std::wstring GetItem(size_t index) const {
if (list)
return list->GetItem(index);
return {};
}
inline size_t GetItemCount() {
inline size_t GetItemCount() const {
if (list)
return list->GetItemCount();
return 0;
}
inline std::string GetHoveredItemStr() {
inline std::string GetHoveredItemStr() const {
if (list)
return list->GetHoveredItemStr();
return {};
}
inline std::wstring GetHoveredItem() {
inline std::wstring GetHoveredItem() const {
if (list)
return list->GetHoveredItem();
return {};
}
inline std::string GetSelectedItemStr() {
inline std::string GetSelectedItemStr() const {
if (list)
return list->GetSelectedItemStr();
return {};
}
inline std::wstring GetSelectedItem() {
inline std::wstring GetSelectedItem() const {
if (list)
return list->GetSelectedItem();
return {};
+221
View File
@@ -0,0 +1,221 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "shadow.hpp"
#include "../../CRE/render_context.hpp"
#include "../dw.hpp"
extern render_context* rctx_ptr;
class ShadowDw : public dw::Shell {
public:
dw::RowLayout* layout;
dw::Slider* distance_slider;
dw::Slider* shadow_ambient_slider;
dw::Slider* shadow_range_factor_slider;
float_t distance;
int32_t near_blur;
int32_t far_blur;
float_t field_1AC;
float_t field_1B0;
float_t shadow_ambient;
float_t shadow_range_factor;
Shadow* shadow_ptr;
ShadowDw();
virtual ~ShadowDw() override;
virtual void Draw() override;
virtual void Hide() override;
static void EnableSelfShadowCallback(dw::Widget* data);
static void EnableShadowCallback(dw::Widget* data);
static void DistanceCallback(dw::Widget* data);
static void FarBlurCallback(dw::Widget* data);
static void NearBlurCallback(dw::Widget* data);
static void ShadowAmbientCallback(dw::Widget* data);
static void ShadowRangeFactorCallback(dw::Widget* data);
static void ShowStageShadowCallback(dw::Widget* data);
static void ShowTextureCallback(dw::Widget* data);
};
ShadowDw* shadow_dw;
void shadow_dw_init() {
if (!shadow_dw) {
shadow_dw = new ShadowDw;
shadow_dw->sub_1402F38B0();
}
else
shadow_dw->Disp();
}
ShadowDw::ShadowDw() {
shadow_ptr = shadow_ptr_get();
distance = shadow_ptr->distance;
near_blur = shadow_ptr->near_blur;
far_blur = shadow_ptr->far_blur;
field_1AC = shadow_ptr->field_2D0;
field_1B0 = shadow_ptr->field_2D4;
shadow_ambient = shadow_ptr->shadow_ambient;
shadow_range_factor = shadow_ptr->shadow_range_factor;
SetText("SHADOW");
rect.pos = 0.0f;
SetSize({ 320.0f, 200.0f });
const float_t glyph_height = font.GetFontGlyphHeight();
layout = new dw::RowLayout(dw::HORIZONTAL);
distance_slider = dw::Slider::Create(this, (dw::Flags)(dw::FLAG_800
| dw::HORIZONTAL), 0.0f, 0.0f, 192.0f, glyph_height, "Distance");
distance_slider->SetParams(distance, 0.01f, 20.0f, 1.0f, 0.1f, 1.0f);
distance_slider->format = "%5.2f";
distance_slider->AddSelectionListener(
new dw::SelectionListenerOnHook(ShadowDw::DistanceCallback));
dw::Slider* near_blur_slider = dw::Slider::Create(this, (dw::Flags)(dw::FLAG_800
| dw::HORIZONTAL), 0.0f, 0.0f, 192.0f, glyph_height, "Near Blur");
near_blur_slider->SetParams((float_t)near_blur, 0.0f, 10.0f, 1.0f, 1.0f, 1.0f);
near_blur_slider->format = "%2.0f";
near_blur_slider->AddSelectionListener(
new dw::SelectionListenerOnHook(ShadowDw::NearBlurCallback));
dw::Slider* far_blur_slider = dw::Slider::Create(this, dw::Flags(dw::FLAG_800
| dw::HORIZONTAL), 0.0f, 0.0f, 192.0f, glyph_height, "Far Blur");
far_blur_slider->SetParams((float_t)far_blur, 1.0f, 10.0f, 1.0f, 1.0f, 1.0f);
far_blur_slider->format = "%2.0f";
far_blur_slider->AddSelectionListener(
new dw::SelectionListenerOnHook(ShadowDw::FarBlurCallback));
shadow_ambient_slider = dw::Slider::Create(this, (dw::Flags)(dw::FLAG_800
| dw::HORIZONTAL), 0.0f, 0.0f, 192.0f, glyph_height, "Shadow Ambient");
shadow_ambient_slider->SetParams(shadow_ambient, 0.0f, 1.0f, 0.1f, 0.025f, 0.1f);
shadow_ambient_slider->format = "%5.3f";
shadow_ambient_slider->AddSelectionListener(
new dw::SelectionListenerOnHook(ShadowDw::ShadowAmbientCallback));
const char* shadow_range_factor_text;
if (dw::translate)
shadow_range_factor_text = u8"Shadow Range Factor";
else
shadow_range_factor_text = u8"シャドウ範囲係数";
shadow_range_factor_slider = dw::Slider::Create(this, (dw::Flags)(dw::FLAG_800
| dw::HORIZONTAL), 0.0f, 0.0f, 192.0f, glyph_height, shadow_range_factor_text);
shadow_range_factor_slider->SetParams(shadow_range_factor, 1.0f, 2.0f, 0.1f, 0.01f, 0.1f);
shadow_range_factor_slider->format = "%4.2f";
shadow_range_factor_slider->AddSelectionListener(
new dw::SelectionListenerOnHook(ShadowDw::ShadowRangeFactorCallback));
dw::Button* show_texture = new dw::Button(this, dw::CHECKBOX);
show_texture->SetText("Show Texture");
show_texture->SetValue(shadow_ptr->show_texture);
show_texture->callback = ShadowDw::ShowTextureCallback;
dw::Button* show_stage_shadow = new dw::Button(this, dw::CHECKBOX);
show_stage_shadow->SetText("Show Stage Shadow");
show_stage_shadow->SetValue(rctx_ptr->render_manager->show_stage_shadow);
show_stage_shadow->callback = ShadowDw::ShowStageShadowCallback;
dw::Button* enable_shadow = new dw::Button(this, dw::CHECKBOX);
enable_shadow->SetText("ENABLE SHADOW");
enable_shadow->SetValue(rctx_ptr->render_manager->shadow);
enable_shadow->callback = ShadowDw::EnableShadowCallback;
dw::Button* enable_self_shadow = new dw::Button(this, dw::CHECKBOX);
enable_self_shadow->SetText("ENABLE SELF SHADOW");
enable_self_shadow->SetValue(shadow_ptr_get()->self_shadow);
enable_self_shadow->callback = ShadowDw::EnableSelfShadowCallback;
}
ShadowDw::~ShadowDw() {
}
void ShadowDw::Draw() {
shadow_ambient = shadow_ptr->shadow_ambient;
shadow_ambient_slider->SetValue(shadow_ambient);
shadow_range_factor = shadow_ptr->shadow_range_factor;
shadow_range_factor_slider->SetValue(shadow_range_factor);
dw::Shell::Draw();
}
void ShadowDw::Hide() {
SetDisp();
}
void ShadowDw::EnableSelfShadowCallback(dw::Widget* data) {
dw::Button* button = dynamic_cast<dw::Button*>(data);
if (button)
shadow_ptr_get()->self_shadow = button->value;
}
void ShadowDw::EnableShadowCallback(dw::Widget* data) {
dw::Button* button = dynamic_cast<dw::Button*>(data);
if (button)
rctx_ptr->render_manager->shadow = button->value;
}
void ShadowDw::DistanceCallback(dw::Widget* data) {
dw::Slider* slider = dynamic_cast<dw::Slider*>(data);
if (slider) {
const float_t value = slider->GetValue();
shadow_dw->distance = value;
shadow_dw->shadow_ptr->set_distance(value);
}
}
void ShadowDw::FarBlurCallback(dw::Widget* data) {
dw::Slider* slider = dynamic_cast<dw::Slider*>(data);
if (slider) {
const int32_t value = (int32_t)slider->GetValue();
shadow_dw->far_blur = value;
shadow_dw->shadow_ptr->far_blur = value;
}
}
void ShadowDw::NearBlurCallback(dw::Widget* data) {
dw::Slider* slider = dynamic_cast<dw::Slider*>(data);
if (slider) {
const int32_t value = (int32_t)slider->GetValue();
shadow_dw->near_blur = value;
shadow_dw->shadow_ptr->near_blur = value;
}
}
void ShadowDw::ShadowAmbientCallback(dw::Widget* data) {
dw::Slider* slider = dynamic_cast<dw::Slider*>(data);
if (slider) {
const float_t value = slider->GetValue();
shadow_dw->shadow_ambient = value;
shadow_dw->shadow_ptr->shadow_ambient = value;
}
}
void ShadowDw::ShadowRangeFactorCallback(dw::Widget* data) {
dw::Slider* slider = dynamic_cast<dw::Slider*>(data);
if (slider) {
const float_t value = slider->GetValue();
shadow_dw->shadow_range_factor = value;
shadow_dw->shadow_ptr->shadow_range_factor = value;
}
}
void ShadowDw::ShowStageShadowCallback(dw::Widget* data) {
dw::Button* button = dynamic_cast<dw::Button*>(data);
if (button)
rctx_ptr->render_manager->show_stage_shadow = button->value;
}
void ShadowDw::ShowTextureCallback(dw::Widget* data) {
dw::Button* button = dynamic_cast<dw::Button*>(data);
if (button) {
shadow_dw->shadow_ptr->show_texture = button->value;
shadow_dw->shadow_ptr->clear_textures();
}
}
+10
View File
@@ -0,0 +1,10 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../../KKdLib/default.hpp"
extern void shadow_dw_init();
+1 -1
View File
@@ -35,7 +35,7 @@ classes_data classes[] = {
CLASS_DATA_NO_DATA,
},
graphics_classes,
9,
11,
},
{
"Information",