June 2013
Intermediate to advanced
346 pages
8h 42m
English
What goes up must come down. Isaac Newton became famous because he observed the effects of gravity on apples falling from a tree; our particles will look better if we add some gravity to them as well.
On earth, everyone feels an acceleration of 9.8 meters per second squared, and if we ignore the effects of wind resistance, then the longer something falls, the faster it goes. We can easily reproduce this effect in our code by adding a gravity adjustment to our vertex shader. Let’s open up particle_vertex_shader.glsl and add the following line of code after the assignment to v_ElapsedTime:
| Particles/res/raw/particle_vertex_shader.glsl | |
| | float gravityFactor = v_ElapsedTime * v_ElapsedTime / 8.0; |
This will calculate an accelerating ...
Read now
Unlock full access