
This library provides a simple fog effect for processing, for both P3D and OPENGL sketches.
It's fairly straight forwards to use:
import hardcorepawn.fog.*; fog myFog; float nearDist; float farDist; color fogColor; void setup() { size(200,200,P3D); //OPENGL also works myFog=new fog(this); nearDist=150; farDist=500; myFog.setupFog(nearDist,farDist); fogColor=color(64,128,256); myFog.setColor(fogColor); // other setup stuff ... } void draw() { //... draw all your 3d stuff here ... // you can also change the fog distance with OPENGL: // myFog.setDist(800,1200); myFog.doFog(); }
Function Specification:
fog(PApplet p)
This is the constructor for the fog system, the supplise argument should probbaly always be "this".
myFog.setupFog(float near, float far);
This command is used to set up how far from the camera you want the fog effect to begin, and how far from the camera it should be until things are entirely fogged.
Please note, that the camera is by default a distance away form the cordinates 0,0,0 so you may have to add a little to the "near" distance to get the fog starting where you want it.
myFog.setColor(color c);
This sets the fog colour to whatever is supplied. This will be the colour used when doFog() is called. There can only be one fog colour per scene, it is not possible to have different objects fogged different colours.
myFog.doFog();
This draws the fog over the scene, in P3D this is a per-pixel function, so can take a while if you have a large size.
Please note, if you are altering the z-buffer, or wanting to draw a 2D interface on top, do the fog before you do so, then the interface won't be fogged like the scene being drawn.