diff --git a/data/layout.xml b/data/layout.xml index 35d5245..3bad08e 100644 --- a/data/layout.xml +++ b/data/layout.xml @@ -298,6 +298,7 @@ + @@ -318,6 +319,7 @@ + diff --git a/src/node_panel_grid.cpp b/src/node_panel_grid.cpp index 2da1bff..e2f4438 100644 --- a/src/node_panel_grid.cpp +++ b/src/node_panel_grid.cpp @@ -39,6 +39,7 @@ void NodePanelGrid::init_controls() m_hm_lyaw = find("grid-heightmap-lyaw"); m_hm_lpitch = find("grid-heightmap-lpitch"); m_hm_ambient = find("grid-heightmap-ambient"); + m_hm_radius = find("grid-heightmap-radius"); m_hm_shading = find("grid-heightmap-shading"); m_hm_texres = find("grid-heightmap-texres"); m_hm_samples = find("grid-heightmap-samples"); @@ -141,7 +142,7 @@ void NodePanelGrid::init_controls() }; m_hm_texres->on_select = [this](Node*, int index) { int texres = get_texres(); - if (texres != m_texture.size().x) + if (texres == m_texture.size().x) return; // get the texture data and resize it @@ -177,6 +178,11 @@ int NodePanelGrid::get_texres() const return atoi(m_hm_texres->m_items[m_hm_texres->m_current_index].c_str()); } +float NodePanelGrid::get_radius() const +{ + return m_hm_radius->get_value() * 0.5f + 0.01f; +} + float NodePanelGrid::get_ambient() const { return glm::pow(m_hm_ambient->get_value(), 3); @@ -365,6 +371,7 @@ void NodePanelGrid::bake_uvs() auto data_out = std::make_unique(fb.getWidth() * fb.getHeight() * 4); const auto samples = get_samples(); + const auto radius = get_radius(); std::thread worker([&] { __block float* d_pos = data_pos.get(); @@ -395,7 +402,7 @@ void NodePanelGrid::bake_uvs() int hit = 0; for (int s = 0; s < samples; s++) { - auto dir = glm::normalize(light_dir + glm::sphericalRand(.5f)); + auto dir = glm::normalize(light_dir + glm::sphericalRand(radius)); nanort::Ray ray; ray.org[0] = pos.x;// + nor.x * 0.005; diff --git a/src/node_panel_grid.h b/src/node_panel_grid.h index 73f5b3b..6a11d95 100644 --- a/src/node_panel_grid.h +++ b/src/node_panel_grid.h @@ -51,6 +51,7 @@ public: NodeSliderH* m_hm_lyaw; NodeSliderH* m_hm_lpitch; NodeSliderH* m_hm_ambient; + NodeSliderH* m_hm_radius; NodeComboBox* m_hm_texres; NodeComboBox* m_hm_samples; NodeButton* m_render; @@ -75,6 +76,7 @@ public: void init_controls(); int get_samples() const; int get_texres() const; + float get_radius() const; float get_ambient() const; float get_thickness() const; float get_resolution() const;