de.grogra.imp3d.objects
Class SpotLight

java.lang.Object
  extended by de.grogra.persistence.ShareableBase
      extended by de.grogra.imp3d.objects.LightBase
          extended by de.grogra.imp3d.objects.PointLight
              extended by de.grogra.imp3d.objects.SpotLight
All Implemented Interfaces:
Raytraceable, Manageable, Shareable, Emitter, Light, Scattering

public class SpotLight
extends PointLight
implements Raytraceable

This class implements a spot light. Light rays are cast from the local origin, the central direction of the spot light is the local z-axis. Light rays with an angle α to the z-axis less than innerAngle have a maximal intensity, the intensity falls off to zero when the angle reaches outerAngle. The fall-off is governed by a cubic spline: Let

t = (cos α - cos outerAngle) / (cos innerAngle - cos outerAngle)
then the interpolation factor is
(3 - 2 t) t2

Author:
Ole Kniemeyer

Nested Class Summary
static class SpotLight.Type
           
 
Field Summary
static SpotLight.Type $TYPE
           
static SCOType.Field innerAngle$FIELD
           
static SCOType.Field outerAngle$FIELD
           
 
Fields inherited from class de.grogra.imp3d.objects.PointLight
attenuationDistance$FIELD, attenuationExponent$FIELD, power$FIELD
 
Fields inherited from class de.grogra.imp3d.objects.LightBase
color$FIELD, shadowless$FIELD
 
Fields inherited from interface de.grogra.ray.physics.Light
AMBIENT, AREA, DIRECTIONAL, NO_LIGHT, POINT, SKY
 
Fields inherited from interface de.grogra.ray.physics.Scattering
DELTA_FACTOR, IS_NON_OPAQUE, MIN_UNUSED_FLAG, NEEDS_NORMAL, NEEDS_POINT, NEEDS_TANGENTS, NEEDS_TRANSFORMATION, NEEDS_UV, RANDOM_RAYS_GENERATE_ORIGINS
 
Constructor Summary
SpotLight()
           
 
Method Summary
 void accept(LightVisitor visitor)
           
 RaytracerLeaf createRaytracerLeaf(java.lang.Object object, boolean asNode, long pathId, GraphState gs)
           
protected  void draw(Tuple3f color, RenderState rs)
           
 void generateRandomRays(Environment env, Vector3f out, Spectrum specOut, RayList rays, boolean photon, java.util.Random rnd)
          Pseudorandomly generates, for the given input, a set of scattered rays.
protected  float getDensityAt(Vector3f direction)
           
 float getInnerAngle()
           
 ManageableType getManageableType()
           
 float getOuterAngle()
           
 void setInnerAngle(float value)
           
 void setOuterAngle(float value)
           
 
Methods inherited from class de.grogra.imp3d.objects.PointLight
computeBSDF, computeExitance, generateRandomOrigins, getAttenuationDistance, getAttenuationExponent, getLightType, getPower, getTotalPower, setAttenuationDistance, setAttenuationExponent, setPower
 
Methods inherited from class de.grogra.imp3d.objects.LightBase
completeRay, getAverageColor, getColor, getFlags, isIgnoredWhenHit, isShadowless, setShadowless
 
Methods inherited from class de.grogra.persistence.ShareableBase
addReference, appendReferencesTo, fieldModified, getProvider, getStamp, initProvider, manageableReadResolve, manageableWriteReplace, removeReference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

$TYPE

public static final SpotLight.Type $TYPE

innerAngle$FIELD

public static final SCOType.Field innerAngle$FIELD

outerAngle$FIELD

public static final SCOType.Field outerAngle$FIELD
Constructor Detail

SpotLight

public SpotLight()
Method Detail

accept

public void accept(LightVisitor visitor)
Overrides:
accept in class PointLight

createRaytracerLeaf

public RaytracerLeaf createRaytracerLeaf(java.lang.Object object,
                                         boolean asNode,
                                         long pathId,
                                         GraphState gs)
Specified by:
createRaytracerLeaf in interface Raytraceable
Overrides:
createRaytracerLeaf in class PointLight

draw

protected void draw(Tuple3f color,
                    RenderState rs)
Overrides:
draw in class LightBase

generateRandomRays

public void generateRandomRays(Environment env,
                               Vector3f out,
                               Spectrum specOut,
                               RayList rays,
                               boolean photon,
                               java.util.Random rnd)
Description copied from interface: Scattering
Pseudorandomly generates, for the given input, a set of scattered rays. The scattered rays are generated such that they can be used for a Monte Carlo integration of a function f(ω;ν) over cos θ BSDF(ωi, νi; ωo, νo) in the following way: Let di and si denote the directions and spectra of the N generated rays (N = rays.size). Then, for every frequency ν the sum
1 / N ∑i si(ν) f(di; ν)
is an unbiased estimate for the integral
∫ cos θ f(ω; ν) g(ω, ν; out, μ) specOut(μ) dμ dω
θ is the angle between the surface normal and ω. The domain of integration is the whole sphere, since the bidirectional scattering distribution includes both reflection and transmission (BSDF = BRDF + BTDF).

If this Scattering instance is in fact a Light source, adjoint is true, and the BSDF is defined as BSDF(out, μ; ω, ν) = L1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted radiance at env.point, see Emitter. In this case, out is not used.

If this Scattering instance is in fact a Sensor, adjoint is false, and the BSDF is defined as BSDF(ω, ν; out, μ) = W1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted importance at env.point, see Emitter. In this case, out is not used.

Let pω be the probability density used for the ray direction (measured with respect to solid angle ω), then the field directionDensity of the ray i is set to pω(di). For ideal specular reflection or transmission, or for directional lights or sensors, pω is not a regular function, the value directionDensity will be set to a multiple of Scattering.DELTA_FACTOR.

The ray properties which are not mentioned in the given formulas are neither used nor modified. These are the origin and its density.

Specified by:
generateRandomRays in interface Scattering
Overrides:
generateRandomRays in class PointLight
Parameters:
env - the environment for scattering
out - the direction unit vector of the outgoing ray (i.e., pointing away from the surface)
specOut - the spectrum of the outgoing ray
rays - the rays to be generated
photon - represents out a light ray or an importance ray?
rnd - pseudorandom generator
See Also:
Scattering.computeBSDF(de.grogra.ray.physics.Environment, javax.vecmath.Vector3f, de.grogra.ray.physics.Spectrum, javax.vecmath.Vector3f, boolean, de.grogra.ray.physics.Spectrum)

getDensityAt

protected float getDensityAt(Vector3f direction)
Overrides:
getDensityAt in class PointLight

getInnerAngle

public float getInnerAngle()

getManageableType

public ManageableType getManageableType()
Specified by:
getManageableType in interface Manageable
Overrides:
getManageableType in class PointLight

getOuterAngle

public float getOuterAngle()

setInnerAngle

public void setInnerAngle(float value)

setOuterAngle

public void setOuterAngle(float value)