opacity control
This commit is contained in:
@@ -113,13 +113,15 @@
|
|||||||
<node width="30%" dir="col">
|
<node width="30%" dir="col">
|
||||||
<node height="20" justify="center"><text text="Size" font-face="arial" font-size="11"/></node>
|
<node height="20" justify="center"><text text="Size" font-face="arial" font-size="11"/></node>
|
||||||
<node height="20" justify="center"><text text="Flow" font-face="arial" font-size="11"/></node>
|
<node height="20" justify="center"><text text="Flow" font-face="arial" font-size="11"/></node>
|
||||||
|
<node height="20" justify="center"><text text="Opacity" font-face="arial" font-size="11"/></node>
|
||||||
<node height="20" justify="center"><text text="Spacing" font-face="arial" font-size="11"/></node>
|
<node height="20" justify="center"><text text="Spacing" font-face="arial" font-size="11"/></node>
|
||||||
<node height="20" justify="center"><text text="Angle" font-face="arial" font-size="11"/></node>
|
<node height="20" justify="center"><text text="Angle" font-face="arial" font-size="11"/></node>
|
||||||
<node height="20" justify="center"><text text="Mixer" font-face="arial" font-size="11"/></node>
|
<node height="20" justify="center"><text text="Mixer" font-face="arial" font-size="11"/></node>
|
||||||
</node>
|
</node>
|
||||||
<border dir="col" align="center" grow="1" width="1">
|
<border dir="col" align="center" grow="1" width="1">
|
||||||
<node height="20" pad="1" width="100%"><slider-h id="tip-size" value=".5"/></node>
|
<node height="20" pad="1" width="100%"><slider-h id="tip-size" value=".5"/></node>
|
||||||
<node height="20" pad="1" width="100%"><slider-h id="tip-flow" value=".25"/></node>
|
<node height="20" pad="1" width="100%"><slider-h id="tip-flow" value=".15"/></node>
|
||||||
|
<node height="20" pad="1" width="100%"><slider-h id="tip-opacity" value="1"/></node>
|
||||||
<node height="20" pad="1" width="100%"><slider-h id="tip-spacing" value=".25"/></node>
|
<node height="20" pad="1" width="100%"><slider-h id="tip-spacing" value=".25"/></node>
|
||||||
<node height="20" pad="1" width="100%"><slider-h id="tip-angle"/></node>
|
<node height="20" pad="1" width="100%"><slider-h id="tip-angle"/></node>
|
||||||
<node height="20" pad="1" width="100%"><slider-h id="tip-mix"/></node>
|
<node height="20" pad="1" width="100%"><slider-h id="tip-mix"/></node>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public:
|
|||||||
float m_tip_size;
|
float m_tip_size;
|
||||||
float m_tip_spacing;
|
float m_tip_spacing;
|
||||||
float m_tip_flow;
|
float m_tip_flow;
|
||||||
|
float m_tip_opacity;
|
||||||
float m_tip_angle;
|
float m_tip_angle;
|
||||||
float m_jitter_scale;
|
float m_jitter_scale;
|
||||||
float m_jitter_angle;
|
float m_jitter_angle;
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ void ui::Canvas::clear()
|
|||||||
}
|
}
|
||||||
void ui::Canvas::stroke_end()
|
void ui::Canvas::stroke_end()
|
||||||
{
|
{
|
||||||
m_current_stroke = nullptr;
|
|
||||||
stroke_commit();
|
stroke_commit();
|
||||||
|
m_current_stroke = nullptr;
|
||||||
m_show_tmp = false;
|
m_show_tmp = false;
|
||||||
}
|
}
|
||||||
void ui::Canvas::stroke_draw()
|
void ui::Canvas::stroke_draw()
|
||||||
@@ -33,6 +33,8 @@ void ui::Canvas::stroke_draw()
|
|||||||
if (!(m_current_stroke && m_current_stroke->has_sample()))
|
if (!(m_current_stroke && m_current_stroke->has_sample()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
m_dirty = true;
|
||||||
|
|
||||||
m_tmp.bindFramebuffer();
|
m_tmp.bindFramebuffer();
|
||||||
|
|
||||||
GLint vp[4];
|
GLint vp[4];
|
||||||
@@ -134,6 +136,10 @@ void ui::Canvas::stroke_draw()
|
|||||||
}
|
}
|
||||||
void ui::Canvas::stroke_commit()
|
void ui::Canvas::stroke_commit()
|
||||||
{
|
{
|
||||||
|
if (!m_dirty)
|
||||||
|
return;
|
||||||
|
m_dirty = false;
|
||||||
|
|
||||||
m_fb.bindFramebuffer();
|
m_fb.bindFramebuffer();
|
||||||
|
|
||||||
// copy to tmp2 for layer blending
|
// copy to tmp2 for layer blending
|
||||||
@@ -158,7 +164,7 @@ void ui::Canvas::stroke_commit()
|
|||||||
ShaderManager::use(ui::kShader::StrokeLayer);
|
ShaderManager::use(ui::kShader::StrokeLayer);
|
||||||
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
||||||
ShaderManager::u_int(kShaderUniform::TexBG, 1);
|
ShaderManager::u_int(kShaderUniform::TexBG, 1);
|
||||||
ShaderManager::u_float(kShaderUniform::Alpha, .5); // TODO: if using opacity in commit, update blending to match the preview when rendering m_tmp in NodeCanvas
|
ShaderManager::u_float(kShaderUniform::Alpha, m_current_stroke->m_brush.m_tip_opacity); // TODO: if using opacity in commit, update blending to match the preview when rendering m_tmp in NodeCanvas
|
||||||
ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f));
|
ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f));
|
||||||
m_plane.draw_fill();
|
m_plane.draw_fill();
|
||||||
m_sampler.unbind();
|
m_sampler.unbind();
|
||||||
|
|||||||
@@ -9,14 +9,15 @@ NS_START
|
|||||||
|
|
||||||
class Canvas
|
class Canvas
|
||||||
{
|
{
|
||||||
Stroke* m_current_stroke = nullptr;
|
|
||||||
Plane m_plane;
|
Plane m_plane;
|
||||||
BrushMesh m_mesh;
|
BrushMesh m_mesh;
|
||||||
int m_current_layer_idx = 0;
|
int m_current_layer_idx = 0;
|
||||||
|
bool m_dirty = false;
|
||||||
public:
|
public:
|
||||||
int m_width;
|
int m_width;
|
||||||
int m_height;
|
int m_height;
|
||||||
bool m_use_instanced = false;
|
bool m_use_instanced = false;
|
||||||
|
Stroke* m_current_stroke = nullptr;
|
||||||
bool m_show_tmp = false;
|
bool m_show_tmp = false;
|
||||||
std::vector<Layer> m_layers;
|
std::vector<Layer> m_layers;
|
||||||
std::vector<Stroke> m_strokes;
|
std::vector<Stroke> m_strokes;
|
||||||
|
|||||||
@@ -1798,6 +1798,7 @@ public:
|
|||||||
NodeSliderH* m_tip_size;
|
NodeSliderH* m_tip_size;
|
||||||
NodeSliderH* m_tip_spacing;
|
NodeSliderH* m_tip_spacing;
|
||||||
NodeSliderH* m_tip_flow;
|
NodeSliderH* m_tip_flow;
|
||||||
|
NodeSliderH* m_tip_opacity;
|
||||||
NodeSliderH* m_tip_angle;
|
NodeSliderH* m_tip_angle;
|
||||||
NodeSliderH* m_jitter_scale;
|
NodeSliderH* m_jitter_scale;
|
||||||
NodeSliderH* m_jitter_angle;
|
NodeSliderH* m_jitter_angle;
|
||||||
@@ -1822,6 +1823,7 @@ public:
|
|||||||
init_slider(m_tip_size, "tip-size", &ui::Brush::m_tip_size);
|
init_slider(m_tip_size, "tip-size", &ui::Brush::m_tip_size);
|
||||||
init_slider(m_tip_spacing, "tip-spacing", &ui::Brush::m_tip_spacing);
|
init_slider(m_tip_spacing, "tip-spacing", &ui::Brush::m_tip_spacing);
|
||||||
init_slider(m_tip_flow, "tip-flow", &ui::Brush::m_tip_flow);
|
init_slider(m_tip_flow, "tip-flow", &ui::Brush::m_tip_flow);
|
||||||
|
init_slider(m_tip_opacity, "tip-opacity", &ui::Brush::m_tip_opacity);
|
||||||
init_slider(m_tip_angle, "tip-angle", &ui::Brush::m_tip_angle);
|
init_slider(m_tip_angle, "tip-angle", &ui::Brush::m_tip_angle);
|
||||||
init_slider(m_jitter_scale, "jitter-scale", &ui::Brush::m_jitter_scale);
|
init_slider(m_jitter_scale, "jitter-scale", &ui::Brush::m_jitter_scale);
|
||||||
init_slider(m_jitter_angle, "jitter-angle", &ui::Brush::m_jitter_angle);
|
init_slider(m_jitter_angle, "jitter-angle", &ui::Brush::m_jitter_angle);
|
||||||
@@ -1904,7 +1906,7 @@ public:
|
|||||||
ui::ShaderManager::use(kShader::TextureAlpha);
|
ui::ShaderManager::use(kShader::TextureAlpha);
|
||||||
ui::ShaderManager::u_int(kShaderUniform::Tex, 0);
|
ui::ShaderManager::u_int(kShaderUniform::Tex, 0);
|
||||||
ui::ShaderManager::u_mat4(kShaderUniform::MVP, mvp);
|
ui::ShaderManager::u_mat4(kShaderUniform::MVP, mvp);
|
||||||
ui::ShaderManager::u_float(kShaderUniform::Alpha, .5);
|
ui::ShaderManager::u_float(kShaderUniform::Alpha, m_canvas->m_current_stroke->m_brush.m_tip_opacity);
|
||||||
m_canvas->m_tmp.bindTexture();
|
m_canvas->m_tmp.bindTexture();
|
||||||
NodeBorder::m_plane.draw_fill();
|
NodeBorder::m_plane.draw_fill();
|
||||||
m_canvas->m_tmp.unbindTexture();
|
m_canvas->m_tmp.unbindTexture();
|
||||||
|
|||||||
Reference in New Issue
Block a user