Processing - DepthShader library
This is a simple library to shade according to ''screendepth''. Instead of simply using the Z-coordinate to shade an object, this library enables shading regardless of translation, rotation and/or scaling. In other words, it will enable you to shade an object according to its apparent depth on screen, regardless of transformations.
Usage
- Download the .ZIP and unpack it in the libraries folder of your Processing installation
- (re)start Processing
- Check out the example here
How It Works
The DepthShader class keeps track of minimum and maximum values
returned by the .screenZ()
method and uses mappers (see below) to map each x,y,z
How to make your own mapping class
Mappers are implementations of the interface DepthMapperpublic float map(float
value, float min, float max, float from, float to)
Description of parameters:
value |
current depthvalue to consider |
min |
minimum recorded depthvalue |
max |
maximum recorded depthvalue |
from |
lower end of range to map depthvalues to (passed as argument to constructor of DepthShader class) |
to |
higher end of range to map depthvalues to (passed as argument to constructor of DepthShader class) |
Check out the demo code for examples on how to implement a mapper.
Source
The sourcecode is included in the library .JAR file.
See also
This sketch also uses this library.