org.sunflow.core

## Class LightSample

- java.lang.Object
- - org.sunflow.core.LightSample

    public class LightSample
    extends java.lang.Object

Represents a sample taken from a light source that faces a point being shaded.

### Constructor Summary

Constructors
Constructor and Description
`LightSample()` Creates a new light sample object (invalid by default).

### Method Summary

Methods
`float` `dot(Vector3 v)` Compute a dot product between the current shadow ray direction and the specified vector.
`Color` `getDiffuseRadiance()` Get diffuse radiance.
`Ray` `getShadowRay()` Get the sample's shadow ray.
`Color` `getSpecularRadiance()` Get specular radiance.
`void` `setRadiance(Color d, Color s)` Set the diffuse and specular radiance emitted by the current light source.
`void` `setShadowRay(Ray shadowRay)` Set the current shadow ray.
`void` `traceShadow(ShadingState state)` Trace the shadow ray, attenuating the sample's color by the opacity of intersected objects.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### LightSample

    public LightSample()

Creates a new light sample object (invalid by default).

### Method Detail

#### setShadowRay

    public void setShadowRay(Ray shadowRay)

Set the current shadow ray. The ray's direction is used as the sample's orientation.

Parameters:
  `shadowRay` - shadow ray from the point being shaded towards the light

#### traceShadow

    public final void traceShadow(ShadingState state)

Trace the shadow ray, attenuating the sample's color by the opacity of intersected objects.

Parameters:
  `state` - shading state representing the point to be shaded

#### getShadowRay

    public Ray getShadowRay()

Get the sample's shadow ray.

Returns:
  shadow ray

#### getDiffuseRadiance

    public Color getDiffuseRadiance()

Get diffuse radiance.

Returns:
  diffuse radiance

#### getSpecularRadiance

    public Color getSpecularRadiance()

Get specular radiance.

Returns:
  specular radiance

#### setRadiance

    public void setRadiance(Color d,
                   Color s)

Set the diffuse and specular radiance emitted by the current light source. These should usually be the same, but are distinguished to allow for non-physical light setups or light source types which compute diffuse and specular responses seperately.

Parameters:
  `d` - diffuse radiance
  `s` - specular radiance

#### dot

    public float dot(Vector3 v)

Compute a dot product between the current shadow ray direction and the specified vector.

Parameters:
  `v` - direction vector
Returns:
  dot product of the vector with the shadow ray direction