Package org.sunflow.core.photonmap
Class GlobalPhotonMap
- java.lang.Object
-
- org.sunflow.core.photonmap.GlobalPhotonMap
-
- All Implemented Interfaces:
GlobalPhotonMapInterface
,PhotonStore
public final class GlobalPhotonMap extends java.lang.Object implements GlobalPhotonMapInterface
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
GlobalPhotonMap.NearestPhotons
(package private) static class
GlobalPhotonMap.Photon
-
Field Summary
Fields Modifier and Type Field Description private BoundingBox
bounds
private float
gatherRadius
private int
halfStoredPhotons
private boolean
hasRadiance
private int
log2n
private float
maxPower
private float
maxRadius
private int
numEmit
private int
numGather
private java.util.ArrayList<GlobalPhotonMap.Photon>
photonList
private GlobalPhotonMap.Photon[]
photons
private int
storedPhotons
-
Constructor Summary
Constructors Constructor Description GlobalPhotonMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allowDiffuseBounced()
Allow photons reflected diffusely?boolean
allowReflectionBounced()
Allow specularly reflected photons?boolean
allowRefractionBounced()
Allow refracted photons?private void
balance()
private void
balanceSegment(GlobalPhotonMap.Photon[] temp, int index, int start, int end)
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.private void
locatePhotons(GlobalPhotonMap.NearestPhotons np)
int
numEmit()
Number of photons to emit from this surface.void
precomputeRadiance()
void
prepare(Options options, BoundingBox sceneBounds)
Initialize this object for the specified scene size.void
store(ShadingState state, Vector3 dir, Color power, Color diffuse)
Store the specified photon.private void
swap(int i, int j)
-
-
-
Field Detail
-
photonList
private java.util.ArrayList<GlobalPhotonMap.Photon> photonList
-
photons
private GlobalPhotonMap.Photon[] photons
-
storedPhotons
private int storedPhotons
-
halfStoredPhotons
private int halfStoredPhotons
-
log2n
private int log2n
-
numGather
private int numGather
-
gatherRadius
private float gatherRadius
-
bounds
private BoundingBox bounds
-
hasRadiance
private boolean hasRadiance
-
maxPower
private float maxPower
-
maxRadius
private float maxRadius
-
numEmit
private int numEmit
-
-
Method Detail
-
prepare
public void prepare(Options options, BoundingBox sceneBounds)
Description copied from interface:PhotonStore
Initialize this object for the specified scene size.- Specified by:
prepare
in interfacePhotonStore
sceneBounds
- scene bounding box
-
store
public void store(ShadingState state, Vector3 dir, Color power, Color diffuse)
Description copied from interface:PhotonStore
Store the specified photon.- Specified by:
store
in interfacePhotonStore
- Parameters:
state
- shading statedir
- photon directionpower
- photon powerdiffuse
- diffuse color at the hit point
-
locatePhotons
private void locatePhotons(GlobalPhotonMap.NearestPhotons np)
-
balance
private void balance()
-
balanceSegment
private void balanceSegment(GlobalPhotonMap.Photon[] temp, int index, int start, int end)
-
swap
private void swap(int i, int j)
-
init
public void init()
Description copied from interface:PhotonStore
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 interfacePhotonStore
-
precomputeRadiance
public void precomputeRadiance()
-
getRadiance
public Color getRadiance(Point3 p, Vector3 n)
Description copied from interface:GlobalPhotonMapInterface
Lookup the global diffuse radiance at the specified surface point.- Specified by:
getRadiance
in interfaceGlobalPhotonMapInterface
- Parameters:
p
- surface positionn
- surface normal- Returns:
- an approximation of global diffuse radiance at this point
-
allowDiffuseBounced
public boolean allowDiffuseBounced()
Description copied from interface:PhotonStore
Allow photons reflected diffusely?- Specified by:
allowDiffuseBounced
in interfacePhotonStore
- Returns:
true
if diffuse bounces should be traced
-
allowReflectionBounced
public boolean allowReflectionBounced()
Description copied from interface:PhotonStore
Allow specularly reflected photons?- Specified by:
allowReflectionBounced
in interfacePhotonStore
- Returns:
true
if specular reflection bounces should be traced
-
allowRefractionBounced
public boolean allowRefractionBounced()
Description copied from interface:PhotonStore
Allow refracted photons?- Specified by:
allowRefractionBounced
in interfacePhotonStore
- Returns:
true
if refracted bounces should be traced
-
numEmit
public int numEmit()
Description copied from interface:PhotonStore
Number of photons to emit from this surface.- Specified by:
numEmit
in interfacePhotonStore
- Returns:
- number of photons
-
-