add rays radius slider
This commit is contained in:
@@ -39,6 +39,7 @@ void NodePanelGrid::init_controls()
|
||||
m_hm_lyaw = find<NodeSliderH>("grid-heightmap-lyaw");
|
||||
m_hm_lpitch = find<NodeSliderH>("grid-heightmap-lpitch");
|
||||
m_hm_ambient = find<NodeSliderH>("grid-heightmap-ambient");
|
||||
m_hm_radius = find<NodeSliderH>("grid-heightmap-radius");
|
||||
m_hm_shading = find<NodeComboBox>("grid-heightmap-shading");
|
||||
m_hm_texres = find<NodeComboBox>("grid-heightmap-texres");
|
||||
m_hm_samples = find<NodeComboBox>("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<uint8_t[]>(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<float> ray;
|
||||
ray.org[0] = pos.x;// + nor.x * 0.005;
|
||||
|
||||
Reference in New Issue
Block a user