|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.sunflow.core.ShadingState
public final class ShadingState
Represents a point to be shaded and provides various options for the shading of this point, including spawning of new rays.
Method Summary | |
---|---|
void |
addSample(LightSample sample)
Add the specified light sample to the list of lights to be used |
Color |
diffuse(Color diff)
Computes a plain diffuse response to the current light samples and global illumination. |
void |
faceforward()
Flip the surface normals to ensure they are facing the current ray. |
OrthoNormalBasis |
getBasis()
Gets the local orthonormal basis for the current hit point. |
Matrix4 |
getCameraToWorld()
Get a transformation matrix that will transform camera space points into world space. |
float |
getCosND()
Cosine between the shading normal and the ray. |
int |
getDepth()
Get the current total tracing depth. |
int |
getDiffuseDepth()
Get the current diffuse tracing depth. |
Vector3 |
getGeoNormal()
Gets the geometric normal of the current hit point. |
Color |
getGlobalRadiance()
Returns the glboal diffuse radiance estimate given by the current GIEngine if present. |
Instance |
getInstance()
Get the instance which was intersected |
Color |
getIrradiance(Color diffuseReflectance)
Gets the total irradiance reaching the current point from diffuse surfaces. |
Vector3 |
getNormal()
Get shading normal at the hit point. |
Point3 |
getPoint()
Get hit point. |
int |
getPrimitiveID()
Get the primitive ID which was intersected |
double |
getRandom(int j,
int dim)
Get a QMC sample from an infinite sequence. |
double |
getRandom(int j,
int dim,
int n)
Get a QMC sample from a finite sequence of n elements. |
float |
getRasterX()
Get x coordinate of the pixel being shaded. |
float |
getRasterY()
Get y coordinate of the pixel being shaded. |
Ray |
getRay()
Gets the ray that is associated with this state. |
int |
getReflectionDepth()
Get the current reflection tracing depth. |
int |
getRefractionDepth()
Get the current refraction tracing depth. |
Color |
getResult()
Get the result of shading this point |
Shader |
getShader()
Get the shader to be used to shade this surface. |
int |
getShadowDepth()
|
boolean |
getTrianglePoints(Point3[] p)
Get the three triangle corners in object space if the hit object is a mesh, returns false otherwise. |
float |
getU()
Get u barycentric coordinate of the intersection point. |
Point2 |
getUV()
Get texture coordinates at the hit point. |
float |
getV()
Get v barycentric coordinate of the intersection point. |
float |
getW()
Get w barycentric coordinate of the intersection point. |
Matrix4 |
getWorldToCamera()
Get a transformation matrix that will transform world space points into camera space. |
boolean |
includeLights()
Checks to see if the shader should include emitted light. |
boolean |
includeSpecular()
Checks to see if the shader should include specular terms. |
void |
init()
Create objects needed for surface shading: point, normal, texture coordinates and basis. |
void |
initCausticSamples()
Add caustic samples to the current light sample set. |
void |
initLightSamples()
Initialize the use of light samples. |
boolean |
isBehind()
Returns true if the ray hit the surface from behind. |
java.util.Iterator<LightSample> |
iterator()
Allows iteration over current light samples. |
Color |
occlusion(int samples,
float maxDist)
Simple black and white ambient occlusion. |
Color |
occlusion(int samples,
float maxDist,
Color bright,
Color dark)
Ambient occlusion routine, returns a value between bright and dark depending on the amount of geometric occlusion in the scene. |
void |
setBasis(OrthoNormalBasis basis)
Define the orthonormal basis for the current hit point. |
void |
setModifier(Modifier modifier)
Record which modifier should be applied to the intersected surface |
void |
setShader(Shader shader)
Record which shader should be executed for the intersected surface. |
Color |
shade()
Run the shader at this surface point. |
Color |
specularPhong(Color spec,
float power,
int numRays)
Computes a phong specular response to the current light samples and global illumination. |
void |
storePhoton(Vector3 dir,
Color power,
Color diffuse)
Records a photon at the specified location. |
void |
traceDiffusePhoton(Ray r,
Color power)
Trace a new photon from the current location. |
ShadingState |
traceFinalGather(Ray r,
int i)
Trace a final gather ray and return the intersection result as a new render state |
Color |
traceGlossy(Ray r,
int i)
Returns the color obtained by recursively tracing the specified ray. |
Color |
traceReflection(Ray r,
int i)
Returns the color obtained by recursively tracing the specified ray. |
void |
traceReflectionPhoton(Ray r,
Color power)
Trace a new photon from the current location. |
Color |
traceRefraction(Ray r,
int i)
Returns the color obtained by recursively tracing the specified ray. |
void |
traceRefractionPhoton(Ray r,
Color power)
Trace a new photon from the current location. |
Color |
traceShadow(Ray r)
Trace a shadow ray against the scene, and computes the accumulated opacity along the ray. |
Color |
traceTransparency()
Trace transparency, this is equivalent to tracing a refraction ray in the incoming ray direction. |
Color |
traceTransparentShadow(float oldMaxT)
|
Vector3 |
transformNormalObjectToWorld(Vector3 n)
Transform the given normal from object space to world space. |
Vector3 |
transformNormalWorldToObject(Vector3 n)
Transform the given normal from world space to object space. |
Point3 |
transformObjectToWorld(Point3 p)
Transform the given point from object space to world space. |
Vector3 |
transformVectorObjectToWorld(Vector3 v)
Transform the given vector from object space to world space. |
Vector3 |
transformVectorWorldToObject(Vector3 v)
Transform the given vector from world space to object space. |
Point3 |
transformWorldToObject(Point3 p)
Transform the given point from world space to object space. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public final void init()
public final Color shade()
public final void faceforward()
public final float getRasterX()
public final float getRasterY()
public final float getCosND()
faceforward()
.
public final boolean isBehind()
faceforward()
.
true
if the surface was hit from behind.public final float getU()
public final float getV()
public final float getW()
public final Instance getInstance()
public final int getPrimitiveID()
public Point3 transformObjectToWorld(Point3 p)
Point3
object is returned.
p
- object space position to transform
public Point3 transformWorldToObject(Point3 p)
Point3
object is returned.
p
- world space position to transform
public Vector3 transformNormalObjectToWorld(Vector3 n)
Vector3
object is returned.
n
- object space normal to transform
public Vector3 transformNormalWorldToObject(Vector3 n)
Vector3
object is returned.
n
- world space normal to transform
public Vector3 transformVectorObjectToWorld(Vector3 v)
Vector3
object is returned.
v
- object space vector to transform
public Vector3 transformVectorWorldToObject(Vector3 v)
Vector3
object is returned.
v
- world space vector to transform
public final Color getResult()
public final void addSample(LightSample sample)
sample
- a valid light samplepublic final double getRandom(int j, int dim)
j
- sample number (starts from 0)dim
- dimension to sample
public final double getRandom(int j, int dim, int n)
j
- sample number (starts from 0)dim
- dimension to samplen
- number of samples
public final boolean includeLights()
true
if emitted light should be included,
false
otherwisepublic final boolean includeSpecular()
true
if specular terms should be included,
false
otherwisepublic final Shader getShader()
public final void setShader(Shader shader)
shader
- surface shader to use to shade the current intersection
pointpublic final void setModifier(Modifier modifier)
modifier
- modifier to use the change this shading statepublic final int getDepth()
public final int getDiffuseDepth()
public final int getReflectionDepth()
public final int getRefractionDepth()
public final Point3 getPoint()
public final Vector3 getNormal()
public final Point2 getUV()
public final Vector3 getGeoNormal()
public final OrthoNormalBasis getBasis()
null
if undefinedpublic final void setBasis(OrthoNormalBasis basis)
basis
- public final Ray getRay()
public final Matrix4 getCameraToWorld()
public final Matrix4 getWorldToCamera()
public final boolean getTrianglePoints(Point3[] p)
p
- array of 3 points
true
if the points were read succesfully,
false
otherwisepublic final void initLightSamples()
public final void initCausticSamples()
public final Color traceGlossy(Ray r, int i)
r
- ray to tracei
- instance number of this sample
public final Color traceReflection(Ray r, int i)
r
- ray to tracei
- instance number of this sample
public final Color traceRefraction(Ray r, int i)
r
- ray to tracei
- instance number of this sample
public final Color traceTransparency()
public final Color traceShadow(Ray r)
r
- ray to trace
public final void storePhoton(Vector3 dir, Color power, Color diffuse)
dir
- incoming direction of the photonpower
- photon powerdiffuse
- diffuse reflectance at the given pointpublic final void traceReflectionPhoton(Ray r, Color power)
r
- ray to trace photon alongpower
- power of the new photonpublic final void traceRefractionPhoton(Ray r, Color power)
r
- ray to trace photon alongpower
- power of the new photonpublic final void traceDiffusePhoton(Ray r, Color power)
r
- ray to trace photon alongpower
- power of the new photonpublic final Color getGlobalRadiance()
GIEngine
if present.
public final Color getIrradiance(Color diffuseReflectance)
diffuseReflectance
- diffuse reflectance at the current point, can
be used for importance tracking
public final ShadingState traceFinalGather(Ray r, int i)
r
- ray to shooti
- instance of the ray
public final Color occlusion(int samples, float maxDist)
samples
- number of sample raysmaxDist
- maximum length of the rays
public final Color occlusion(int samples, float maxDist, Color bright, Color dark)
samples
- number of sample raysmaxDist
- maximum length of the raysbright
- color when nothing is occludeddark
- color when fully occluded
public final Color diffuse(Color diff)
diff
- diffuse color
public final Color specularPhong(Color spec, float power, int numRays)
spec
- specular colorpower
- phong exponentnumRays
- number of glossy rays to trace
public java.util.Iterator<LightSample> iterator()
iterator
in interface java.lang.Iterable<LightSample>
public final int getShadowDepth()
public Color traceTransparentShadow(float oldMaxT)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |