remove line thickness from the grid, add ambient light, fix lightmap texture resize
This commit is contained in:
@@ -38,6 +38,7 @@ void NodePanelGrid::init_controls()
|
||||
m_hm_height = find<NodeSliderH>("grid-heightmap-height");
|
||||
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_shading = find<NodeComboBox>("grid-heightmap-shading");
|
||||
m_hm_texres = find<NodeComboBox>("grid-heightmap-texres");
|
||||
m_hm_samples = find<NodeComboBox>("grid-heightmap-samples");
|
||||
@@ -139,8 +140,19 @@ void NodePanelGrid::init_controls()
|
||||
gl.restore();
|
||||
};
|
||||
m_hm_texres->on_select = [this](Node*, int index) {
|
||||
int rexres = get_texres();
|
||||
m_texture.create(rexres, rexres);
|
||||
int texres = get_texres();
|
||||
if (texres != m_texture.size().x)
|
||||
return;
|
||||
|
||||
// get the texture data and resize it
|
||||
m_texture.bind();
|
||||
Image img;
|
||||
img.create(m_texture.size().x, m_texture.size().y);
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, img.m_data.get());
|
||||
m_texture.unbind();
|
||||
Image resized = img.resize(texres, texres);
|
||||
m_texture.create(resized);
|
||||
m_texture.create_mipmaps();
|
||||
};
|
||||
int rexres = get_texres();
|
||||
m_texture.create(rexres, rexres);
|
||||
@@ -162,6 +174,11 @@ int NodePanelGrid::get_texres() const
|
||||
return atoi(m_hm_texres->m_items[m_hm_texres->m_current_index].c_str());
|
||||
}
|
||||
|
||||
float NodePanelGrid::get_ambient() const
|
||||
{
|
||||
return glm::pow(m_hm_ambient->get_value(), 3);
|
||||
}
|
||||
|
||||
float NodePanelGrid::get_thickness() const
|
||||
{
|
||||
return glm::lerp(m_line_range[0], m_line_range[1], m_hm_thickness->get_value());
|
||||
@@ -217,6 +234,7 @@ void NodePanelGrid::draw_heightmap(const glm::mat4& proj, const glm::mat4& camer
|
||||
ShaderManager::use(kShader::Lambert);
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, mvp);
|
||||
ShaderManager::u_vec3(kShaderUniform::LightDir, light_dir);
|
||||
ShaderManager::u_float(kShaderUniform::Ambient, get_ambient());
|
||||
m_hm_plane.draw_fill();
|
||||
}
|
||||
else if (m_shade_mode == ShadeMode::Flat)
|
||||
@@ -234,11 +252,13 @@ void NodePanelGrid::draw_heightmap(const glm::mat4& proj, const glm::mat4& camer
|
||||
ShaderManager::use(kShader::LambertLightmap);
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, mvp);
|
||||
ShaderManager::u_vec3(kShaderUniform::LightDir, light_dir);
|
||||
ShaderManager::u_float(kShaderUniform::Ambient, get_ambient());
|
||||
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
||||
m_sampler_linear.bind(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
m_texture.bind();
|
||||
m_hm_plane.draw_fill();
|
||||
m_texture.unbind();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,11 +280,7 @@ void NodePanelGrid::draw_heightmap(const glm::mat4& proj, const glm::mat4& camer
|
||||
m_hm_plane.draw_fill();
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
}
|
||||
float current_width = 1;
|
||||
glGetFloatv(GL_LINE_WIDTH, ¤t_width);
|
||||
glLineWidth(get_thickness());
|
||||
m_hm_plane.draw_stroke();
|
||||
glLineWidth(current_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -360,7 +376,7 @@ void NodePanelGrid::bake_uvs()
|
||||
int hit = 0;
|
||||
for (int s = 0; s < samples; s++)
|
||||
{
|
||||
auto dir = glm::normalize(light_dir + glm::sphericalRand(.1f));
|
||||
auto dir = glm::normalize(light_dir + glm::sphericalRand(.5f));
|
||||
|
||||
nanort::Ray<float> ray;
|
||||
ray.org[0] = pos.x;// + nor.x * 0.005;
|
||||
|
||||
Reference in New Issue
Block a user