Bouncy Castle Rendering Toolkit 1.0

org.bouncycastle.graphics.rt
Class Shader

java.lang.Object
  |
  +--org.bouncycastle.graphics.rt.Shader
Direct Known Subclasses:
CookTorranceShader

public abstract class Shader
extends java.lang.Object

The base class for Shaders.


Field Summary
protected  float alpha
           
protected  Matrix4f trans
           
protected  World world
           
 
Constructor Summary
Shader(World world)
           
 
Method Summary
protected  float clamp(float a)
          utility method to allow a value to be clamped between 0 and 1.
protected  void processObject(java.lang.Object obj)
          apply default handling to the given object as part of shader construction.
protected  void processParameters(ParametersMap params)
          apply the default parameters for a shader, from the passed in parameters table.
protected  void readObject(RMLReader in)
          initialise a shader from a RMLReader.
 void setAlpha(double alpha)
          set the alpha value (coverage value) for this object.
abstract  void shade(Hit hit, Pixel p)
           
 void toShaderSpace(Point3f p)
          transform the given point into shader space
 void toShaderSpace(Vector3f v)
          transform the given vector into shader space
 void transform(Matrix4f trans)
          apply the given 4x4 transform to the shader space.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alpha

protected float alpha

trans

protected Matrix4f trans

world

protected World world
Constructor Detail

Shader

public Shader(World world)
Method Detail

readObject

protected void readObject(RMLReader in)
                   throws java.io.IOException
initialise a shader from a RMLReader.

processParameters

protected void processParameters(ParametersMap params)
apply the default parameters for a shader, from the passed in parameters table.

processObject

protected void processObject(java.lang.Object obj)
apply default handling to the given object as part of shader construction.

setAlpha

public void setAlpha(double alpha)
set the alpha value (coverage value) for this object.

transform

public void transform(Matrix4f trans)
apply the given 4x4 transform to the shader space. Note with shaders, the inverse of the transform is used.

This has the effect that when a shader is bound to a group of objects, the shader space will move with the objects when we apply the same transform as we do to the objects. It also means that to make a texture smaller we scale down rather than up, which works for this author...


toShaderSpace

public void toShaderSpace(Vector3f v)
transform the given vector into shader space

toShaderSpace

public void toShaderSpace(Point3f p)
transform the given point into shader space

clamp

protected float clamp(float a)
utility method to allow a value to be clamped between 0 and 1.

shade

public abstract void shade(Hit hit,
                           Pixel p)

Bouncy Castle Rendering Toolkit 1.0