implement shading modes switch for heightmap
This commit is contained in:
@@ -285,9 +285,9 @@
|
|||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node height="30" pad="1" width="100%" dir="row">
|
<node height="30" pad="1" width="100%" dir="row">
|
||||||
<combobox id="grid-heightmap-shading" text="Normal" width="100%" height="30" combo-list="Transparent,Flat,Solid" default="0"/>
|
<combobox id="grid-heightmap-shading" width="100%" height="30" combo-list="Transparent,Flat,Solid" default="0"/>
|
||||||
</node>
|
</node>
|
||||||
<node height="20" pad="1" width="100%"><slider-h id="grid-heightmap-wireframe"/></node>
|
<node height="20" pad="1" width="100%"><slider-h id="grid-heightmap-wireframe" value="1.0"/></node>
|
||||||
<node height="20" pad="1" width="100%"><slider-h id="grid-heightmap-height" value="0.25"/></node>
|
<node height="20" pad="1" width="100%"><slider-h id="grid-heightmap-height" value="0.25"/></node>
|
||||||
<node height="20" pad="1" width="100%"><slider-h id="grid-heightmap-lyaw" value="0.5"/></node>
|
<node height="20" pad="1" width="100%"><slider-h id="grid-heightmap-lyaw" value="0.5"/></node>
|
||||||
<node height="20" pad="1" width="100%"><slider-h id="grid-heightmap-lpitch" value="0.5"/></node>
|
<node height="20" pad="1" width="100%"><slider-h id="grid-heightmap-lpitch" value="0.5"/></node>
|
||||||
@@ -1120,10 +1120,11 @@ Here's a list of what's available in this release.
|
|||||||
<!--Colors-->
|
<!--Colors-->
|
||||||
<!--<panel-color id="panel-color"/>-->
|
<!--<panel-color id="panel-color"/>-->
|
||||||
<!--Grids-->
|
<!--Grids-->
|
||||||
<panel-grid/>
|
<!--<panel-grid/>-->
|
||||||
</scroll>
|
</scroll>
|
||||||
</node>
|
</node>
|
||||||
<!-- timeline -->
|
<!-- timeline -->
|
||||||
|
<!--
|
||||||
<node height="100%" width="1" grow="1" dir="col" justify="flex-start" rtl="ltr">
|
<node height="100%" width="1" grow="1" dir="col" justify="flex-start" rtl="ltr">
|
||||||
<border color=".3 .3 .3 .4" height="50" width="100%" pad="10" dir="row">
|
<border color=".3 .3 .3 .4" height="50" width="100%" pad="10" dir="row">
|
||||||
<text text="Timeline: " font-face="arial" font-size="11" margin="8 10 0 0"/>
|
<text text="Timeline: " font-face="arial" font-size="11" margin="8 10 0 0"/>
|
||||||
@@ -1133,6 +1134,7 @@ Here's a list of what's available in this release.
|
|||||||
</node>
|
</node>
|
||||||
</border>
|
</border>
|
||||||
</node>
|
</node>
|
||||||
|
-->
|
||||||
|
|
||||||
<!--<node height="100%" width="1" grow="1" dir="col" align="center" justify="flex-start" rtl="ltr">
|
<!--<node height="100%" width="1" grow="1" dir="col" align="center" justify="flex-start" rtl="ltr">
|
||||||
<border border-color="0 0 0 0" thickness="2" color=".2 .2 .2 .6" pad="10" dir="row" margin="2 0 0 0">
|
<border border-color="0 0 0 0" thickness="2" color=".2 .2 .2 .6" pad="10" dir="row" margin="2 0 0 0">
|
||||||
|
|||||||
@@ -297,16 +297,28 @@ void NodeCanvas::draw()
|
|||||||
* glm::scale(glm::vec3(1, glm::pow(App::I.grid->m_hm_height->get_value() - 0.5f, 3.f) * 10.f, 1))
|
* glm::scale(glm::vec3(1, glm::pow(App::I.grid->m_hm_height->get_value() - 0.5f, 3.f) * 10.f, 1))
|
||||||
* glm::eulerAngleX(glm::radians(90.f));
|
* glm::eulerAngleX(glm::radians(90.f));
|
||||||
|
|
||||||
|
|
||||||
// DRAW SOLID
|
// DRAW SOLID
|
||||||
glDisable(GL_BLEND);
|
if (App::I.grid->m_shade_mode == NodePanelGrid::ShadeMode::Solid)
|
||||||
ShaderManager::use(kShader::Lambert);
|
{
|
||||||
ShaderManager::u_mat4(kShaderUniform::MVP, mvp);
|
glDisable(GL_BLEND);
|
||||||
auto light_yaw = App::I.grid->m_hm_lyaw->get_value() * glm::pi<float>() * 2.f;
|
ShaderManager::use(kShader::Lambert);
|
||||||
auto light_pitch = App::I.grid->m_hm_lpitch->get_value();
|
ShaderManager::u_mat4(kShaderUniform::MVP, mvp);
|
||||||
auto light_pos = glm::vec3(sinf(light_yaw), cosf(light_yaw), light_pitch);
|
auto light_yaw = App::I.grid->m_hm_lyaw->get_value() * glm::pi<float>() * 2.f;
|
||||||
ShaderManager::u_vec3(kShaderUniform::LightDir, glm::normalize(-light_pos));
|
auto light_pitch = App::I.grid->m_hm_lpitch->get_value();
|
||||||
App::I.grid->m_hm_plane.draw_fill();
|
auto light_pos = glm::vec3(sinf(light_yaw), cosf(light_yaw), light_pitch);
|
||||||
|
ShaderManager::u_vec3(kShaderUniform::LightDir, glm::normalize(-light_pos));
|
||||||
|
App::I.grid->m_hm_plane.draw_fill();
|
||||||
|
}
|
||||||
|
else if (App::I.grid->m_shade_mode == NodePanelGrid::ShadeMode::Flat)
|
||||||
|
{
|
||||||
|
ShaderManager::use(kShader::Color);
|
||||||
|
ShaderManager::u_vec4(kShaderUniform::Col, glm::vec4(
|
||||||
|
glm::vec3(1.f - App::I.grid->m_groud_value->get_value()),
|
||||||
|
App::I.grid->m_groud_opacity->get_value()
|
||||||
|
));
|
||||||
|
ShaderManager::u_mat4(kShaderUniform::MVP, mvp);
|
||||||
|
App::I.grid->m_hm_plane.draw_fill();
|
||||||
|
}
|
||||||
|
|
||||||
// DRAW GRIDS
|
// DRAW GRIDS
|
||||||
if (App::I.grid->m_hm_wireframe->get_value() > 0.f)
|
if (App::I.grid->m_hm_wireframe->get_value() > 0.f)
|
||||||
@@ -319,9 +331,12 @@ void NodeCanvas::draw()
|
|||||||
App::I.grid->m_hm_wireframe->get_value()
|
App::I.grid->m_hm_wireframe->get_value()
|
||||||
));
|
));
|
||||||
ShaderManager::u_mat4(kShaderUniform::MVP, mvp);
|
ShaderManager::u_mat4(kShaderUniform::MVP, mvp);
|
||||||
//glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
if (App::I.grid->m_shade_mode == NodePanelGrid::ShadeMode::Transparent)
|
||||||
//App::I.grid->m_hm_plane.draw_fill();
|
{
|
||||||
//glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||||
|
App::I.grid->m_hm_plane.draw_fill();
|
||||||
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
|
}
|
||||||
App::I.grid->m_hm_plane.draw_stroke();
|
App::I.grid->m_hm_plane.draw_stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ void NodeComboBox::clone_copy(Node* dest) const
|
|||||||
void NodeComboBox::loaded()
|
void NodeComboBox::loaded()
|
||||||
{
|
{
|
||||||
NodeButton::loaded();
|
NodeButton::loaded();
|
||||||
|
m_text->set_text(m_data[m_current_index].c_str());
|
||||||
|
m_selected_child_index = m_current_index;
|
||||||
on_click = [this](Node* target) {
|
on_click = [this](Node* target) {
|
||||||
NodePopupMenu* popup = new NodePopupMenu;
|
NodePopupMenu* popup = new NodePopupMenu;
|
||||||
popup->init();
|
popup->init();
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ void NodePanelGrid::init_controls()
|
|||||||
m_hm_height = find<NodeSliderH>("grid-heightmap-height");
|
m_hm_height = find<NodeSliderH>("grid-heightmap-height");
|
||||||
m_hm_lyaw = find<NodeSliderH>("grid-heightmap-lyaw");
|
m_hm_lyaw = find<NodeSliderH>("grid-heightmap-lyaw");
|
||||||
m_hm_lpitch = find<NodeSliderH>("grid-heightmap-lpitch");
|
m_hm_lpitch = find<NodeSliderH>("grid-heightmap-lpitch");
|
||||||
|
m_hm_shading = find<NodeComboBox>("grid-heightmap-shading");
|
||||||
|
|
||||||
|
m_hm_preview->SetHeight(0);
|
||||||
|
m_hm_plane.create(1, 1, 100);
|
||||||
|
|
||||||
//m_hm_height->on_value_changed = update_hm;
|
//m_hm_height->on_value_changed = update_hm;
|
||||||
m_groud_resolution->on_value_changed = [this](Node* target, float v) {
|
m_groud_resolution->on_value_changed = [this](Node* target, float v) {
|
||||||
@@ -46,9 +50,10 @@ void NodePanelGrid::init_controls()
|
|||||||
m_hm_plane.create(1, 1, 100 * v * 5.f);
|
m_hm_plane.create(1, 1, 100 * v * 5.f);
|
||||||
LOG("resolution value %f", v);
|
LOG("resolution value %f", v);
|
||||||
};
|
};
|
||||||
m_hm_preview->SetHeight(0);
|
|
||||||
|
|
||||||
m_hm_plane.create(1, 1, 100);
|
m_hm_shading->on_select = [this](Node*, int index) {
|
||||||
|
m_shade_mode = (ShadeMode)index;
|
||||||
|
};
|
||||||
|
|
||||||
m_hm_load->on_click = [this](Node*) {
|
m_hm_load->on_click = [this](Node*) {
|
||||||
App::I.pick_image([this](std::string path) {
|
App::I.pick_image([this](std::string path) {
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
class NodePanelGrid : public Node
|
class NodePanelGrid : public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum class ShadeMode : uint8_t { Transparent, Flat, Solid };
|
||||||
|
|
||||||
NodeSliderH* m_groud_opacity;
|
NodeSliderH* m_groud_opacity;
|
||||||
NodeSliderH* m_groud_value;
|
NodeSliderH* m_groud_value;
|
||||||
NodeSliderH* m_groud_resolution;
|
NodeSliderH* m_groud_resolution;
|
||||||
@@ -29,6 +31,7 @@ public:
|
|||||||
HeightmapPlane m_hm_plane;
|
HeightmapPlane m_hm_plane;
|
||||||
Image m_hm_image;
|
Image m_hm_image;
|
||||||
std::string m_file_path;
|
std::string m_file_path;
|
||||||
|
ShadeMode m_shade_mode{ ShadeMode::Transparent };
|
||||||
|
|
||||||
virtual Node* clone_instantiate() const override;
|
virtual Node* clone_instantiate() const override;
|
||||||
virtual void clone_finalize(Node* dest) const override;
|
virtual void clone_finalize(Node* dest) const override;
|
||||||
|
|||||||
Reference in New Issue
Block a user