Copyright © Fred Weinhaus My scripts are available free of charge for non-commercial (non-profit) use, ONLY. For use of my scripts in commercial (for-profit) environments or non-free applications, please contact me (Fred Weinhaus) for licensing arrangements. My email address is fmw at alink dot net. If you: 1) redistribute, 2) incorporate any of these scripts into other free applications or 3) reprogram them in another scripting language, then you must contact me for permission, especially if the result might be used in a commercial or for-profit environment. Usage, whether stated or not in the script, is restricted to the above licensing arrangements. It is also subject, in a subordinate manner, to the ImageMagick license, which can be found at: http://www.imagemagick.org/script/license.php Please read the Pointers For Use on my home page to properly install and customize my scripts. |
Creates a colored sphere with a combination of diffuse and specular illumination. |
last modified: December 15, 2018
USAGE: sphere [-d diameter] [-c color] [-b bgcolor] [-t theta] [-p phi] [-l lambertian] [-s specular] [-e exponent] [infile] soutfile
-d .... diameter ......... desired diameter of sphere; integer>0; default=128; PURPOSE: To create a colored sphere with a combination of diffuse and specular illumination. DESCRIPTION: SPHERE creates a colored sphere with a combination of diffuse and specular illumination. Lighting is from a white light source. The diffuse term is computed from the Lambertian shading model. The specular term is computed from the Blinn-Phong approximation. ARGUMENTS: -d diameter ... DIAMETER of the sphere. Also controls the width and height of the output image. Values are integers>0. The default=128
-c color ... COLOR is the desired color for the sphere. The default=red.
Any valid IM color is allowed.
-b bgcolor ... BGCOLOR is the background color around the outside of the
sphere. The default=black. Any valid IM color is allowed. -t theta ... THETA is the white light azimuth angle measured counter clockwise from the positive x axis. Values are floats between 0 and 360 degrees. The default=135, which means the light is coming from the northwest. -p phi ... PHI is the white light altitude angle measure downward from zenith (vertical) towards horizontal. Values are floats between 0 and 180 degrees. A value of zero means the light is from above the sphere. The default=50. -l lambertian ... LAMBERTIAN is the amplitude of the diffuse lighting. Values are in the range 0<=float<=1. The default=0.9 -s specular ... SPECULAR is the amplitude of the specular lighting. Values are in the range 0<=float<=1. The default=0.6. A value of zero means not to compute the specular component. -e exponent ... EXPONENT is the specular exponent, which controls the area of the reflective effect. Larger values means smaller areas. Values are floats>0. The default=70. NOTE: If infile is provided, then it will be used in place of the color. The infile must be square and the diameter will obtained from the dimensions of the image. REQUIRMENTS: IM 6.5.4-3 or higher due to the use of -compose mathematics.
THEORY: See the following:
http://en.wikipedia.org/wiki/Lambertian_reflectance NOTE: This script may be a little slow due to the use in part of -fx. CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk. |
Lambertian vs Lambertian Plus Specular |
|
Lambertian |
Lambertian & Specular |
Variation On Specular Size |
||
Arguments: |
Arguments: |
Arguments: |
Variation On Specular Intensity |
||
Arguments: |
Arguments: |
Arguments: |
Variation On Background Color |
||
Arguments: |
Arguments: |
Arguments: |