add stencil alpha control to ui
This commit is contained in:
@@ -152,6 +152,7 @@
|
|||||||
<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 height="20" justify="center"><text text="Stencil" 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%" dir="row">
|
<node height="20" pad="1" width="100%" dir="row">
|
||||||
@@ -175,6 +176,7 @@
|
|||||||
</node>
|
</node>
|
||||||
</node>
|
</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>
|
||||||
|
<node height="20" pad="1" width="100%"><slider-h id="tip-stencil"/></node>
|
||||||
</border>
|
</border>
|
||||||
</node>
|
</node>
|
||||||
|
|
||||||
|
|||||||
@@ -248,6 +248,7 @@ void App::initShaders()
|
|||||||
"uniform mediump vec2 resolution;\n"
|
"uniform mediump vec2 resolution;\n"
|
||||||
"uniform mediump float alpha;\n"
|
"uniform mediump float alpha;\n"
|
||||||
"uniform mediump vec2 stencil_offset;\n"
|
"uniform mediump vec2 stencil_offset;\n"
|
||||||
|
"uniform mediump float stencil_alpha;\n"
|
||||||
"in mediump vec2 uv;\n"
|
"in mediump vec2 uv;\n"
|
||||||
"in mediump float q;\n"
|
"in mediump float q;\n"
|
||||||
#ifdef __IOS__
|
#ifdef __IOS__
|
||||||
@@ -257,7 +258,7 @@ void App::initShaders()
|
|||||||
#endif
|
#endif
|
||||||
"void main(){\n"
|
"void main(){\n"
|
||||||
" mediump vec2 uv2 = gl_FragCoord.st / resolution;\n"
|
" mediump vec2 uv2 = gl_FragCoord.st / resolution;\n"
|
||||||
" mediump float stencil = 1-(texture(tex_stencil, (uv2+stencil_offset) * 5.0).r * 0.9);\n"
|
" mediump float stencil = 1-(texture(tex_stencil, (uv2+stencil_offset) * 5.0).r * 0.9) * stencil_alpha;\n"
|
||||||
" mediump float brush_alpha = ( 1.0 - texture(tex, uv/q).r ) * alpha;\n"
|
" mediump float brush_alpha = ( 1.0 - texture(tex, uv/q).r ) * alpha;\n"
|
||||||
" mediump vec4 fg = vec4(col.rgb, brush_alpha);\n"
|
" mediump vec4 fg = vec4(col.rgb, brush_alpha);\n"
|
||||||
#ifdef __IOS__
|
#ifdef __IOS__
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public:
|
|||||||
float m_tip_flow = 0;
|
float m_tip_flow = 0;
|
||||||
float m_tip_opacity = 0;
|
float m_tip_opacity = 0;
|
||||||
float m_tip_angle = 0;
|
float m_tip_angle = 0;
|
||||||
|
float m_tip_stencil = 0;
|
||||||
bool m_tip_angle_follow = false;
|
bool m_tip_angle_follow = false;
|
||||||
bool m_tip_flow_pressure = false;
|
bool m_tip_flow_pressure = false;
|
||||||
bool m_tip_size_pressure = false;
|
bool m_tip_size_pressure = false;
|
||||||
|
|||||||
@@ -243,6 +243,7 @@ void ui::Canvas::stroke_draw()
|
|||||||
ShaderManager::u_vec4(kShaderUniform::Col, m_brush.m_tip_color);
|
ShaderManager::u_vec4(kShaderUniform::Col, m_brush.m_tip_color);
|
||||||
ShaderManager::u_vec2(kShaderUniform::Resolution, { m_width, m_height });
|
ShaderManager::u_vec2(kShaderUniform::Resolution, { m_width, m_height });
|
||||||
ShaderManager::u_vec2(kShaderUniform::StencilOffset, glm::vec2((rand()%1000)*0.001f, (rand()%1000)*0.001f));
|
ShaderManager::u_vec2(kShaderUniform::StencilOffset, glm::vec2((rand()%1000)*0.001f, (rand()%1000)*0.001f));
|
||||||
|
ShaderManager::u_float(kShaderUniform::StencilAlpha, m_brush.m_tip_stencil);
|
||||||
for (const auto& s : samples)
|
for (const auto& s : samples)
|
||||||
{
|
{
|
||||||
glm::vec2 dx(s.size * 0.5f, 0), dy(0, s.size * 0.5f);
|
glm::vec2 dx(s.size * 0.5f, 0), dy(0, s.size * 0.5f);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ void NodePanelStroke::set_params(const ui::Brush &b)
|
|||||||
m_tip_flow->m_value.x = glm::pow(b.m_tip_flow, 1.f/2.f);
|
m_tip_flow->m_value.x = glm::pow(b.m_tip_flow, 1.f/2.f);
|
||||||
m_tip_opacity->m_value.x = b.m_tip_opacity;
|
m_tip_opacity->m_value.x = b.m_tip_opacity;
|
||||||
m_tip_angle->m_value.x = b.m_tip_angle;
|
m_tip_angle->m_value.x = b.m_tip_angle;
|
||||||
|
m_tip_stencil->m_value.x = b.m_tip_stencil;
|
||||||
m_jitter_scale->m_value.x = b.m_jitter_scale;
|
m_jitter_scale->m_value.x = b.m_jitter_scale;
|
||||||
m_jitter_angle->m_value.x = b.m_jitter_angle;
|
m_jitter_angle->m_value.x = b.m_jitter_angle;
|
||||||
m_jitter_spread->m_value.x = b.m_jitter_spread;
|
m_jitter_spread->m_value.x = b.m_jitter_spread;
|
||||||
@@ -46,6 +47,7 @@ void NodePanelStroke::init_controls()
|
|||||||
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_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_tip_stencil, "tip-stencil", &ui::Brush::m_tip_stencil);
|
||||||
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);
|
||||||
init_slider(m_jitter_spread, "jitter-spread", &ui::Brush::m_jitter_spread);
|
init_slider(m_jitter_spread, "jitter-spread", &ui::Brush::m_jitter_spread);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public:
|
|||||||
NodeSliderH* m_tip_flow;
|
NodeSliderH* m_tip_flow;
|
||||||
NodeSliderH* m_tip_opacity;
|
NodeSliderH* m_tip_opacity;
|
||||||
NodeSliderH* m_tip_angle;
|
NodeSliderH* m_tip_angle;
|
||||||
|
NodeSliderH* m_tip_stencil;
|
||||||
NodeSliderH* m_jitter_scale;
|
NodeSliderH* m_jitter_scale;
|
||||||
NodeSliderH* m_jitter_angle;
|
NodeSliderH* m_jitter_angle;
|
||||||
NodeSliderH* m_jitter_spread;
|
NodeSliderH* m_jitter_spread;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ enum class kShaderUniform : uint16_t
|
|||||||
TexStroke = const_hash("tex_stroke"),
|
TexStroke = const_hash("tex_stroke"),
|
||||||
TexStencil= const_hash("tex_stencil"),
|
TexStencil= const_hash("tex_stencil"),
|
||||||
StencilOffset = const_hash("stencil_offset"),
|
StencilOffset = const_hash("stencil_offset"),
|
||||||
|
StencilAlpha = const_hash("stencil_alpha"),
|
||||||
Lock = const_hash("lock"),
|
Lock = const_hash("lock"),
|
||||||
Col = const_hash("col"),
|
Col = const_hash("col"),
|
||||||
Tof = const_hash("tof"),
|
Tof = const_hash("tof"),
|
||||||
|
|||||||
Reference in New Issue
Block a user