Soft Particle Chopper

This task is created by Jaanus Jaggo.

This time we have a combined task with multiple subtasks. The overall goal is to add nice and fluffy soft particles to our chopper scene.
Here is an article describing how these are done: http://blog.wolfire.com/2010/04/Soft-Particles.

Final result should look like this:

Here is the order we recommend you to should solve this task:

  1. Copy your chopper code from the Shaded Chopper task
  2. Modify the smoke shader code such that it outputs the particle image (use your knowledge from previous homework), don’t worry about additional parameters and depth calculations yet.
  3. Turn the material transparency on (now it should look like partially transparent smoke particle)
  4. Duplicate smoke particles such that it fills the floor
  5. Animate the particle by rotating it along z axis.

At this point you should have animated smoke particles which are moving and filling the bottom of the screen just like in older games. Unfortunately they will intersect hangar walls which breaks the immersion.

Continue with following subtasks:

  1. Calculate the linear representation of depth in the depthFragmentShader. You should use the equation from lecture slides or read this article: http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html (it gives a simpler form). You can evaluate your result by rendering it into screen instead of texture.
    Alternatively you can also send the view space Z from the vertex shader to the fragment shader and use that.
  2. Pass the background depth texture to the smoke shader and modify your shader such that it outputs the corresponding part of the depth texture instead of smoke one. (just for testing)

    (the color of your depth texture could be lighter than represented on this picture because your far plane is closer)
  1. Finally subtract the smoke fragment depth value from the background depth texture red channel value and use it to amplify the opacity of your smoke texture. The outcome should be nicely fading smoke as shown before.

JavaScript

Base code is located at:
https://cglearn.codelight.eu/files/course/8/SoftParticleChopperJS.zip

C++

Base code is located at:
https://cglearn.codelight.eu/files/course/8/SoftParticleChopperCPP.zip

Also, the result may vary a bit from the images above. It could be more like the following:

;