Alpha on GL_Lines

Heya guys,



I’m doing some crazy shading attempts and I was wondering if and how I can alter the alpha value of a gl_line in a custom shader. I’ve tried numerous calls on both the frag as well as in the vert shader, but none seem to change the alpha value.



In short, my target is to have certain line ends with a alpha value of near 0, as well as others near 0.5 or so. At this point I’ve only seen alpha being 1.0. Best scenario would be that if I put an alpha value at one vert and another at the other end of the line, the inbetween would be blended from one alpha to the other. This sounds really default to me as polygon colors can do the same in opengl, as far as I remember.



Second, is it possible to change the line width of these lines in the shaders, dependent on the distance to the camera?

These things both sound logically possible to me but I can’t just figure out how to get there.



Any tips are greatly appreciated, been trying to get my head around this for over a few weeks now.



Greetings!

is it rendert in the transparent bucket?

There’s no way to change the line width dynamically I am afraid. Not supported by OpenGL.

For the alpha, you can do it by enabling alpha blending and then setting the vertex color alpha for each vert on the line.

Thanks for the pointer @Momoko_Fan, got it working in minutes thanks to that tip. Just need to fiddle around a bit to make it look right I think, some objects appear on top of it if depth writing is off while if it’s on, the alpha parts are drawn as black.

Make sure to put the lines in the transparent queue bucket

@Momoko_Fan yeah I was looking into that as @EmpirePhoenix named it, any suggestion for an example in the test projects or common matdefs I should look at?

setBucket or setQueueBucket on the geomtry/node your lines are in.

@EmpirePhoenix Works like a charm, any Idea tho what causes the lines to be more visible from one side then another? Can’t imagine they are facing a direction but whenever DepthWrite in On I notice visual differences from the sides, one side providing a clearly visibly effect while when chaging 180 degrees, the lines stay nearly invisible. Now most lines are nearly invisible but together they add up to a strong visible kind of volume, which is what I am after. Kinda strange how the direction I face influences the way the alpha is add up, perhaps something to do with the depth sorting? Works fine if I set depth Write off, I suppose the error occurs there, as they are all in a single geometry.



Edit: Wait, I think it works fine when depth write is off, just adding it to the bucket was enough. Thanks =]