Hello : )
I’ve started to get into GLSL and I am struggling to understand this issue and I would like to know what would be a solution to this problem. I found this example of how to make GLSL trails in the forum (GLSL vertex trail)
Basically it draws a trail that originates from a feedback TOP that is fed by a noise. The issue is that if the feedback TOP is fed empty values the trails clip at point 0.0 like shown in this gif.
If the input of the feedback doesn’t contain any empty values the trails don’t clip at 0.0.
In the GLSL Vertex Shader i have:
in int pointIndex;
uniform sampler2D sPointPositions;
void main()
{
vec3 positions = texture(sPointPositions, ivec2(pointIndex,TDInstanceID()), 0).rgb;
// is this better to be done in the vertex shader or the pixel shader?
if (positions.rgb != 0.0)
{
//a sort of logic that discarts the drawing of the vertex
//if the positions contains empty values i.e. rgb(0.0, 0.0, 0.0)
}
vec3 pointTranslation = texelFetch(sPointPositions, ivec2(pointIndex,TDInstanceID()), 0).rgb;
vec4 worldSpacePos = TDDeform(pointTranslation);
gl_Position = TDWorldToProj(worldSpacePos);
}
My guess is that you would need to discard the values that are empty so that they are not included in the final vector and then wouldn’t be drawn. But I am not sure how or where would this be coded, is it in the vertex shader of the GLSL Mat or the Pixel Shader?
This tox is a version of the original example and I tried to simplify it as I only need the lines to be shown.
glsl_trails_alpha_clip.tox (3.3 KB)
Any help or insight would be really appreciated : )
Thanks,
Sebi