add rays radius slider

This commit is contained in:
2019-01-19 20:39:25 +01:00
parent 9b5c0524f4
commit 3b41cbe365
3 changed files with 13 additions and 2 deletions

View File

@@ -298,6 +298,7 @@
<node height="20" justify="center"><text text="L-Yaw" font-face="arial" font-size="11"/></node>
<node height="20" justify="center"><text text="L-Pitch" font-face="arial" font-size="11"/></node>
<node height="20" justify="center"><text text="Ambient" font-face="arial" font-size="11"/></node>
<node height="20" justify="center"><text text="Radius" font-face="arial" font-size="11"/></node>
<node height="30" justify="center" margin="5 0 0 0"><text text="Samples" font-face="arial" font-size="11"/></node>
<node height="30" justify="center" margin="5 0 0 0"><text text="Tex Res." font-face="arial" font-size="11"/></node>
</node>
@@ -318,6 +319,7 @@
<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.1"/></node>
<node height="20" pad="1" width="100%"><slider-h id="grid-heightmap-ambient" value="0.0"/></node>
<node height="20" pad="1" width="100%"><slider-h id="grid-heightmap-radius" value="0.25"/></node>
<node height="30" pad="1" width="100%" dir="row" margin="5 0 0 0">
<combobox id="grid-heightmap-samples" width="100%" height="30" combo-list="1,4,8,16,32,64,128" default="2"/>
</node>

View File

@@ -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;

View File

@@ -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;