# Class Shader

java.lang.Object
org.jmol.util.Shader

public class Shader extends Object

All functions. Implements the shading of RGB values to support shadow and lighting highlights.

Each RGB value has 64 shades. shade[0] represents ambient lighting. shade[63] is white ... a full specular highlight.

Author:
  Miguel, miguel@jmol.org, Bob Hanson, hansonr@stolaf.edu, N David Brown -- cel shading

## Field Summary

Fields
Modifier and Type
Field
Description
`byte[][][]`
`ellipsoidShades`
`static final int`
`maxSphereCache`
`int`
`nIn`
`int`
`nOut`
`static final int`
`SHADE_INDEX_LAST`
`static final byte`
`SHADE_INDEX_NOISY_LIMIT`
`static final byte`
`SHADE_INDEX_NORMAL`
`byte[]`
`sphereShadeIndexes`
/////////////////////////////////////////////////////////////
`int[][]`
`sphereShapeCache`

## Constructor Summary

Constructors
Constructor
Description
`Shader()`

## Method Summary

Modifier and Type
Method
Description
`void`
`createEllipsoidShades()`
`int`
`getEllipsoidShade(float x, float y, float z, int radius, M4 mDeriv)`
`byte`
`getShadeB(float x, float y, float z)`
`int`
`getShadeFp8(float x, float y, float z)`
`int`
`getShadeIndex(float x, float y, float z)`
`byte`
`getShadeN(float x, float y, float z, float r)`
`int`
`nextRandom8Bit()`
Implements RANDU algorithm for random noise in lighting/shading.
`void`
`setLastColix(int argb, boolean asGrey)`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### SHADE_INDEX_LAST

public static final int SHADE_INDEX_LAST

See Also:
  - Constant Field Values

### SHADE_INDEX_NORMAL

public static final byte SHADE_INDEX_NORMAL

See Also:
  - Constant Field Values

### SHADE_INDEX_NOISY_LIMIT

public static final byte SHADE_INDEX_NOISY_LIMIT

See Also:
  - Constant Field Values

### sphereShadeIndexes

public byte[] sphereShadeIndexes
/////////////////////////////////////////////////////////////

### maxSphereCache

public static final int maxSphereCache

See Also:
  - Constant Field Values

### sphereShapeCache

public int[][] sphereShapeCache

### ellipsoidShades

public byte[][][] ellipsoidShades

### nOut

public int nOut

### nIn

public int nIn

## Constructor Details

### Shader

public Shader()

## Method Details

### setLastColix

public void setLastColix(int argb, boolean asGrey)

### getShadeIndex

public int getShadeIndex(float x, float y, float z)

### getShadeB

public byte getShadeB(float x, float y, float z)

### getShadeFp8

public int getShadeFp8(float x, float y, float z)

### getShadeN

public byte getShadeN(float x, float y, float z, float r)

### nextRandom8Bit

public int nextRandom8Bit()

Implements RANDU algorithm for random noise in lighting/shading.

RANDU is the classic example of a poor random number generator. But it is very cheap to calculate and is good enough for our purposes.

Returns:
  Next random

### getEllipsoidShade

public int getEllipsoidShade(float x, float y, float z, int radius, M4 mDeriv)

### createEllipsoidShades

public void createEllipsoidShades()