stencil in brush preview
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user