Gravity Induced distortion effects


I wanted to make what looks like gravity wells and other gravity induced distortion to my background grid and this is how it’s turned out. I’m using newton’s law of gravitational attraction to loop through each pixel and find the forces that would be acting on it. Then I had to add a way to blend the neutral color into the distorted colors, otherwise I would get very noticeable noncontinuous jumps. What I didn’t realize until I looked it up this morning (after already getting an equation in place but some weird artifacting lead me to search out reasons why), did I realize I had independently come up with the equation for Alpha blending! It turns out that I had typo-d the variable that is suppose to be containing my lerp value (which acts as the alpha value) with another, similarly name variable, meaning that my logic was sound. So that was pretty cool! What a relief!

 

lerp: linear interpolation. This should be in the range of 0.0 to 1.0 However mine were going outside of that, the first time I debugged I noticed a 4.xx and knew that I had been doing math somewhere wrong long before this point of the code.

Leave a Reply

You must be logged in to post a comment.