stencil in brush preview

This commit is contained in:
2017-10-22 19:58:20 +01:00
parent 856628162a
commit 2a92beca7b
6 changed files with 49 additions and 20 deletions

View File

@@ -29,7 +29,7 @@ void NodeStrokePreview::clone_finalize(Node* dest) const
void NodeStrokePreview::init_controls()
{
m_mesh.create();
m_sampler.create();
m_sampler.create(GL_LINEAR, GL_REPEAT);
m_sampler_brush.create();
m_sampler_brush.set_filter(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
TextureManager::load("data/thumbs/Round-Hard.png");
@@ -74,14 +74,24 @@ void NodeStrokePreview::draw_stroke()
m_stroke.m_prev_sample.origin = m_stroke.m_keypoints[0].pos;
auto samples = m_stroke.compute_samples();
auto& tex = TextureManager::get(m_brush.m_tex_id);
glActiveTexture(GL_TEXTURE0);
tex.bind();
m_sampler_brush.bind(0);
auto& stencil = TextureManager::get(const_hash("data/paper.jpg"));
glActiveTexture(GL_TEXTURE1);
stencil.bind();
m_sampler.bind(1);
if (true)
{
m_mesh.shader.use();
m_mesh.shader.u_vec4(kShaderUniform::Col, { 0, 0, 0, 1 });
m_mesh.shader.u_int(kShaderUniform::Tex, 0);
m_mesh.shader.u_int(kShaderUniform::TexStencil, 1); // stencil
m_mesh.shader.u_vec2(kShaderUniform::Resolution, { m_rtt.getWidth(), m_rtt.getHeight() });
m_mesh.shader.u_vec2(kShaderUniform::StencilOffset, glm::vec2(0));
m_mesh.shader.u_float(kShaderUniform::StencilAlpha, m_brush.m_tip_stencil);
m_mesh.draw(samples, proj);
}
//else
@@ -102,6 +112,7 @@ void NodeStrokePreview::draw_stroke()
//}
m_sampler_brush.unbind();
m_sampler.unbind();
tex.unbind();
glDisable(GL_BLEND);