simple GL3 particles to image color change with distance from original position
Jul 10 2020 | 7:11 pm
Hello I am trying to adapt a particle shader so that my particles turn green as they get farther from their original position. I have had luck with the line
outputColor = inputColor + (vec4(0.0 1.0 0.0 0.0) * lengthOfTheDistanceFromOriginal);
The image starts in original position and when i switch to have the particles follow a target everything but the whites turn green as they leave their original position. Although when i bring the particles back to its original position it does not turn back into the original color and I wondering why and how to achieve this.
Thanks for any help. Hope this is enough info, can add a patch if need be.
Just in case this is helpful information lengthOfTheDistanceFromOriginal is derived from this code:
//force from position to original position particles RETURN vec3 dirOrig = vec3(iOrigPos.xy, 0.0) - iPosition; vec3 normDirOrig = normalize(dirOrig); float origDist = length(dirOrig);