add noise parameter to the brush settings
This commit is contained in:
@@ -155,6 +155,7 @@
|
|||||||
<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 height="20" justify="center"><text text="Stencil" font-face="arial" font-size="11"/></node>
|
||||||
<node height="20" justify="center"><text text="Wet" font-face="arial" font-size="11"/></node>
|
<node height="20" justify="center"><text text="Wet" font-face="arial" font-size="11"/></node>
|
||||||
|
<node height="20" justify="center"><text text="Noise" font-face="arial" font-size="11"/></node>
|
||||||
</node>
|
</node>
|
||||||
<border dir="col" align="center" grow="1" width="1" flood-events="1">
|
<border dir="col" align="center" grow="1" width="1" flood-events="1">
|
||||||
<node height="30" pad="1" width="100%" dir="row">
|
<node height="30" pad="1" width="100%" dir="row">
|
||||||
@@ -183,6 +184,7 @@
|
|||||||
<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>
|
<node height="20" pad="1" width="100%"><slider-h id="tip-stencil"/></node>
|
||||||
<node height="20" pad="1" width="100%"><slider-h id="tip-wet"/></node>
|
<node height="20" pad="1" width="100%"><slider-h id="tip-wet"/></node>
|
||||||
|
<node height="20" pad="1" width="100%"><slider-h id="tip-noise"/></node>
|
||||||
</border>
|
</border>
|
||||||
</node>
|
</node>
|
||||||
|
|
||||||
|
|||||||
@@ -258,6 +258,7 @@ void App::initShaders()
|
|||||||
"uniform mediump vec4 col;\n"
|
"uniform mediump vec4 col;\n"
|
||||||
"uniform mediump vec2 resolution;\n"
|
"uniform mediump vec2 resolution;\n"
|
||||||
"uniform mediump float alpha;\n"
|
"uniform mediump float alpha;\n"
|
||||||
|
"uniform mediump float noise;\n"
|
||||||
"uniform mediump vec2 stencil_offset;\n"
|
"uniform mediump vec2 stencil_offset;\n"
|
||||||
"uniform mediump float stencil_alpha;\n"
|
"uniform mediump float stencil_alpha;\n"
|
||||||
"uniform mediump float wet;\n"
|
"uniform mediump float wet;\n"
|
||||||
@@ -268,6 +269,7 @@ void App::initShaders()
|
|||||||
#else
|
#else
|
||||||
"out mediump vec4 frag;\n"
|
"out mediump vec4 frag;\n"
|
||||||
#endif
|
#endif
|
||||||
|
"mediump float rand(vec2 co) { return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); }\n"
|
||||||
"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.0 - (texture(tex_stencil, (uv2+stencil_offset) * 2.0).r * 0.9) * stencil_alpha;\n"
|
" mediump float stencil = 1.0 - (texture(tex_stencil, (uv2+stencil_offset) * 2.0).r * 0.9) * stencil_alpha;\n"
|
||||||
@@ -278,6 +280,7 @@ void App::initShaders()
|
|||||||
#else
|
#else
|
||||||
" mediump vec4 bg = texture(tex_bg, uv2);\n"
|
" mediump vec4 bg = texture(tex_bg, uv2);\n"
|
||||||
#endif
|
#endif
|
||||||
|
" fg.a *= 1.0-rand(uv2+uv)*noise;\n"
|
||||||
" if (fg.a == 0.0) discard;\n"
|
" if (fg.a == 0.0) discard;\n"
|
||||||
" mediump float contribution = (1.0 - bg.a) * fg.a * stencil;\n"
|
" mediump float contribution = (1.0 - bg.a) * fg.a * stencil;\n"
|
||||||
" mediump float alpha_tot = bg.a + contribution;"
|
" mediump float alpha_tot = bg.a + contribution;"
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public:
|
|||||||
float m_tip_angle = 0;
|
float m_tip_angle = 0;
|
||||||
float m_tip_stencil = 0;
|
float m_tip_stencil = 0;
|
||||||
float m_tip_wet = 0;
|
float m_tip_wet = 0;
|
||||||
|
float m_tip_noise = 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;
|
||||||
|
|||||||
@@ -247,6 +247,7 @@ void ui::Canvas::stroke_draw()
|
|||||||
//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);
|
ShaderManager::u_float(kShaderUniform::StencilAlpha, m_brush.m_tip_stencil);
|
||||||
ShaderManager::u_float(kShaderUniform::Wet, m_brush.m_tip_wet);
|
ShaderManager::u_float(kShaderUniform::Wet, m_brush.m_tip_wet);
|
||||||
|
ShaderManager::u_float(kShaderUniform::Noise, m_brush.m_tip_noise);
|
||||||
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);
|
||||||
|
|||||||
@@ -490,7 +490,7 @@ void CanvasModeMaskFree::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
|
|||||||
|
|
||||||
void CanvasModeMaskFree::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera)
|
void CanvasModeMaskFree::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera)
|
||||||
{
|
{
|
||||||
if (!m_points.empty())
|
if (m_points.size() > 3)
|
||||||
{
|
{
|
||||||
if (m_dragging)
|
if (m_dragging)
|
||||||
{
|
{
|
||||||
@@ -623,7 +623,7 @@ void CanvasModeMaskLine::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
|
|||||||
|
|
||||||
void CanvasModeMaskLine::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera)
|
void CanvasModeMaskLine::on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera)
|
||||||
{
|
{
|
||||||
if (!m_points.empty())
|
if (m_points.size() > 3)
|
||||||
{
|
{
|
||||||
if (m_active_tool)
|
if (m_active_tool)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ void NodePanelStroke::update_controls()
|
|||||||
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_tip_stencil->m_value.x = b.m_tip_stencil;
|
||||||
|
m_tip_wet->m_value.x = b.m_tip_wet;
|
||||||
|
m_tip_noise->m_value.x = b.m_tip_noise;
|
||||||
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;
|
||||||
@@ -55,6 +57,7 @@ void NodePanelStroke::init_controls()
|
|||||||
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_tip_stencil, "tip-stencil", &ui::Brush::m_tip_stencil);
|
||||||
init_slider(m_tip_wet, "tip-wet", &ui::Brush::m_tip_wet);
|
init_slider(m_tip_wet, "tip-wet", &ui::Brush::m_tip_wet);
|
||||||
|
init_slider(m_tip_noise, "tip-wet", &ui::Brush::m_tip_noise);
|
||||||
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);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public:
|
|||||||
NodeSliderH* m_tip_angle;
|
NodeSliderH* m_tip_angle;
|
||||||
NodeSliderH* m_tip_stencil;
|
NodeSliderH* m_tip_stencil;
|
||||||
NodeSliderH* m_tip_wet;
|
NodeSliderH* m_tip_wet;
|
||||||
|
NodeSliderH* m_tip_noise;
|
||||||
NodeSliderH* m_jitter_scale;
|
NodeSliderH* m_jitter_scale;
|
||||||
NodeSliderH* m_jitter_angle;
|
NodeSliderH* m_jitter_angle;
|
||||||
NodeSliderH* m_jitter_spread;
|
NodeSliderH* m_jitter_spread;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ enum class kShaderUniform : uint16_t
|
|||||||
Resolution = const_hash("resolution"),
|
Resolution = const_hash("resolution"),
|
||||||
Highlight = const_hash("highlight"),
|
Highlight = const_hash("highlight"),
|
||||||
BlendMode = const_hash("blend_mode"),
|
BlendMode = const_hash("blend_mode"),
|
||||||
|
Noise = const_hash("noise"),
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class kShader : uint16_t
|
enum class kShader : uint16_t
|
||||||
|
|||||||
Reference in New Issue
Block a user