Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destructive behaviour when lines overlap #2562

Open
petaflot opened this issue Dec 22, 2023 · 1 comment
Open

destructive behaviour when lines overlap #2562

petaflot opened this issue Dec 22, 2023 · 1 comment

Comments

@petaflot
Copy link

petaflot commented Dec 22, 2023

to reproduce

  • take 2 points we'll call a, b
  • draw a line between (a,b), with color (ie. bright yellow, (1,1,0,1) )
  • display to make sure line is here.
  • draw a line between (a,b), with color (ie. dark green with very low alpha, (0,1,0,.1) )
  • display again ; only second lime is shown

expected behaviour

display a line with a color somewhere between our 'bright yellow' and our 'dark green', in particular if there if last line added has alpha<1

@djhoese
Copy link
Member

djhoese commented Dec 22, 2023

I believe this is expected. You'd have to change the GL drawing state to something that works for your use case, but it may produce other artifacts. What you're describing is blending. You can see the LineVisual uses the "translucent" GL state preset here:

self.set_gl_state('translucent')

The properties used by this "preset" are defined here:

'translucent': dict(
depth_test=True,
cull_face=False,
blend=True,
blend_func=('src_alpha', 'one_minus_src_alpha', 'zero', 'one'),
blend_equation='func_add'),

You can customize this I believe by doing my_visual.set_gl_state(preset="additive") or passing specific property values as keyword arguments to this method. That said, I would have thought translucent would have done what you wanted given the options shown but maybe I'm not thinking about this hard enough. It could also be GPU dependent given you're likely using the "gl" method of drawing the lines. You could try the "agg" drawing method provided by the LineVisual and see if that changes your results.

Let me know what you think and how these goes. Otherwise if @rougier knows this off the top of his head he could maybe answer more concretely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants