org.sunflow.core.photonmap

Class GridPhotonMap

Implemented Interfaces:
GlobalPhotonMapInterface, PhotonStore

public class GridPhotonMap
extends java.lang.Object
implements GlobalPhotonMapInterface

Constructor Summary

GridPhotonMap(int numEmit, int numGather, float gatherRadius)

Method Summary

boolean
allowDiffuseBounced()
Allow photons reflected diffusely?
boolean
allowReflectionBounced()
Allow specularly reflected photons?
boolean
allowRefractionBounced()
Allow refracted photons?
Color
getRadiance(Point3 p, Vector3 n)
Lookup the global diffuse radiance at the specified surface point.
void
init()
Initialize the map after all photons have been stored.
int
numEmit()
Number of photons to emit from this surface.
void
precomputeRadiance(boolean includeDirect, boolean includeCaustics)
void
prepare(BoundingBox sceneBounds)
Initialize this object for the specified scene size.
int
size()
void
store(ShadingState state, Vector3 dir, Color power, Color diffuse)
Store the specified photon.

Constructor Details

GridPhotonMap

public GridPhotonMap(int numEmit,
                     int numGather,
                     float gatherRadius)

Method Details

allowDiffuseBounced

public boolean allowDiffuseBounced()
Allow photons reflected diffusely?
Specified by:
allowDiffuseBounced in interface PhotonStore
Returns:
true if diffuse bounces should be traced

allowReflectionBounced

public boolean allowReflectionBounced()
Allow specularly reflected photons?
Specified by:
allowReflectionBounced in interface PhotonStore
Returns:
true if specular reflection bounces should be traced

allowRefractionBounced

public boolean allowRefractionBounced()
Allow refracted photons?
Specified by:
allowRefractionBounced in interface PhotonStore
Returns:
true if refracted bounces should be traced

getRadiance

public Color getRadiance(Point3 p,
                         Vector3 n)
Lookup the global diffuse radiance at the specified surface point.
Specified by:
getRadiance in interface GlobalPhotonMapInterface
Parameters:
p - surface position
n - surface normal
Returns:
an approximation of global diffuse radiance at this point

init

public void init()
Initialize the map after all photons have been stored. This can be used to balance a kd-tree based photon map for example.
Specified by:
init in interface PhotonStore

numEmit

public int numEmit()
Number of photons to emit from this surface.
Specified by:
numEmit in interface PhotonStore
Returns:
number of photons

precomputeRadiance

public void precomputeRadiance(boolean includeDirect,
                               boolean includeCaustics)

prepare

public void prepare(BoundingBox sceneBounds)
Initialize this object for the specified scene size.
Specified by:
prepare in interface PhotonStore
Parameters:
sceneBounds - scene bounding box

size

public int size()

store

public void store(ShadingState state,
                  Vector3 dir,
                  Color power,
                  Color diffuse)
Store the specified photon.
Specified by:
store in interface PhotonStore
Parameters:
state - shading state
dir - photon direction
power - photon power
diffuse - diffuse color at the hit point