public class PhongLighting extends CoreEffect<RenderState>
Effect.AccelType| Modifier and Type | Field and Description |
|---|---|
private float |
diffuseConstant |
private Light |
light |
private float |
specularConstant |
private float |
specularExponent |
private float |
surfaceScale |
DefaultInput| Constructor and Description |
|---|
PhongLighting(Light light)
Constructs a new
PhongLighting effect for the given
Light, with default values for all other properties,
using the default input for source data. |
PhongLighting(Light light,
Effect bumpInput,
Effect contentInput)
Constructs a new
PhongLighting effect for the given
Light and the given bump and content input Effects
with default values for all other properties. |
| Modifier and Type | Method and Description |
|---|---|
BaseBounds |
getBounds(BaseTransform transform,
Effect defaultInput)
Returns the bounding box that will be affected by this filter
operation when viewed under the specified
transform,
given its list of input Effects and the specified
defaultInput effect. |
Effect |
getBumpInput()
Returns the bump input for this
Effect. |
Effect |
getContentInput()
Returns the content input for this
Effect. |
private Effect |
getContentInput(Effect defaultInput) |
float |
getDiffuseConstant()
Returns the diffuse constant.
|
DirtyRegionContainer |
getDirtyRegions(Effect defaultInput,
DirtyRegionPool regionPool)
Returns the dirty region container containing dirty regions affected
by this filter operation.
|
Light |
getLight()
Returns the light source.
|
RenderState |
getRenderState(FilterContext fctx,
BaseTransform transform,
Rectangle outputClip,
java.lang.Object renderHelper,
Effect defaultInput)
Returns the object representing the rendering strategy and state for
the filter operation characterized by the specified arguments.
|
Rectangle |
getResultBounds(BaseTransform transform,
Rectangle outputClip,
ImageData... inputDatas) |
float |
getSpecularConstant()
Returns the specular constant.
|
float |
getSpecularExponent()
Returns the specular exponent.
|
float |
getSurfaceScale()
Returns the surface scale.
|
boolean |
reducesOpaquePixels()
Whether an opacity for any pixel is different (lower)
than the corresponding pixel in the default input.
|
void |
setBumpInput(Effect bumpInput)
Sets the bump input for this
Effect to a specific
Effect or to the default input if input is
null. |
void |
setContentInput(Effect contentInput)
Sets the content input for this
Effect to a specific
Effect or to the default input if input is
null. |
void |
setDiffuseConstant(float diffuseConstant)
Sets the diffuse constant.
|
void |
setLight(Light light)
Sets the light source.
|
void |
setSpecularConstant(float specularConstant)
Sets the specular constant.
|
void |
setSpecularExponent(float specularExponent)
Sets the specular exponent.
|
void |
setSurfaceScale(float surfaceScale)
Sets the surface scale.
|
Point2D |
transform(Point2D p,
Effect defaultInput)
Transform the specified point
p from the coordinate space
of the primary content input to the coordinate space of the effect
output. |
Point2D |
untransform(Point2D p,
Effect defaultInput)
Transform the specified point
p from the coordinate space
of the output of the effect into the coordinate space of the
primary content input. |
filterImageDatas, getAccelType, getPeer, updatePeerKey, updatePeerKeyfilter, untransformClipcombineBounds, combineBounds, createCompatibleImage, ensureTransform, getCompatibleImage, getDefaultedInput, getDefaultedInput, getInputs, getNumInputs, getState, releaseCompatibleImage, setInput, transformBoundsprivate float surfaceScale
private float diffuseConstant
private float specularConstant
private float specularExponent
private Light light
public PhongLighting(Light light)
PhongLighting effect for the given
Light, with default values for all other properties,
using the default input for source data.
This is a convenience constructor that automatically generates a
bump map using the default input.light - the light sourcejava.lang.IllegalArgumentException - if light is nullpublic PhongLighting(Light light, Effect bumpInput, Effect contentInput)
PhongLighting effect for the given
Light and the given bump and content input Effects
with default values for all other properties.light - the light sourcebumpInput - the input containing the bump mapcontentInput - the input containing the content datajava.lang.IllegalArgumentException - if light is nullpublic final Effect getBumpInput()
Effect.Effectpublic void setBumpInput(Effect bumpInput)
Effect to a specific
Effect or to the default input if input is
null.bumpInput - the bump input for this Effectpublic final Effect getContentInput()
Effect.Effectpublic void setContentInput(Effect contentInput)
Effect to a specific
Effect or to the default input if input is
null.contentInput - the content input for this Effectpublic Light getLight()
public void setLight(Light light)
light - the light sourcejava.lang.IllegalArgumentException - if light is nullpublic float getDiffuseConstant()
public void setDiffuseConstant(float diffuseConstant)
Min: 0.0
Max: 2.0
Default: 1.0
Identity: n/a
diffuseConstant - the diffuse constant valuejava.lang.IllegalArgumentException - if diffuseConstant is outside
the allowable rangepublic float getSpecularConstant()
public void setSpecularConstant(float specularConstant)
Min: 0.0
Max: 2.0
Default: 1.0
Identity: n/a
specularConstant - the specular constant valuejava.lang.IllegalArgumentException - if specularConstant is outside
the allowable rangepublic float getSpecularExponent()
public void setSpecularExponent(float specularExponent)
Min: 0.0
Max: 40.0
Default: 1.0
Identity: n/a
specularExponent - the specular exponent valuejava.lang.IllegalArgumentException - if specularExponent is outside
the allowable rangepublic float getSurfaceScale()
public void setSurfaceScale(float surfaceScale)
Min: 0.0
Max: 10.0
Default: 1.0
Identity: n/a
surfaceScale - the surface scale valuejava.lang.IllegalArgumentException - if surfaceScale is outside
the allowable rangepublic BaseBounds getBounds(BaseTransform transform, Effect defaultInput)
Effecttransform,
given its list of input Effects and the specified
defaultInput effect.
Note that the returned bounds can be smaller or larger than one
or more of the inputs.getBounds in class FilterEffect<RenderState>transform - the transform the effect will be viewed underdefaultInput - the default input Effect to be used in
all cases where a filter has a null inputpublic Rectangle getResultBounds(BaseTransform transform, Rectangle outputClip, ImageData... inputDatas)
getResultBounds in class Effectpublic Point2D transform(Point2D p, Effect defaultInput)
Effectp from the coordinate space
of the primary content input to the coordinate space of the effect
output.
In essence, this method asks the question "Which output coordinate
is most affected by the data at the specified coordinate in the
primary source input?"
The definition of which input represents the primary content input
and how the coordinate space of that input compares to the coordinate
space of the result varies from effect to effect.
Note that some effects may have a reasonable definition of how to
map source coordinates to destination coordinates, but not the
reverse.
In particular, effects which map source coordinates discontiguously
into the result may have several output coordinates that are affected
by a given input coordinate and may choose to return one of many
equally valid answers, or an undefined result such as NaN,
or some other anomalous value.
Most effects perform simple transformations of the color of each
pixel and so represent an identity transform and return the point
unchanged.
transform in class FilterEffect<RenderState>p - the point in the coordinate space of the primary content
input to be transformeddefaultInput - the default input Effect to be used in
all cases where a filter has a null inputpublic Point2D untransform(Point2D p, Effect defaultInput)
Effectp from the coordinate space
of the output of the effect into the coordinate space of the
primary content input.
In essence, this method asks the question "Which source coordinate
contributes most to the definition of the output at the specified
coordinate?"
The definition of which input represents the primary content input
and how the coordinate space of that input compares to the coordinate
space of the result varies from effect to effect.
Note that some effects may have a reasonable definition of how to
map destination coordinates back to source coordinates, but not the
reverse.
In particular, effects which produce entirely synthetic results not
based on any content input may not be able to give a meaningful
result to this query and may return undefined coordinates such as
0, Infinity, or NaN.
Most effects perform simple transformations of the color of each
pixel and so represent an identity transform and return the point
unchanged.
untransform in class FilterEffect<RenderState>p - the point in the coordinate space of the result output
to be transformeddefaultInput - the default input Effect to be used in
all cases where a filter has a null inputpublic RenderState getRenderState(FilterContext fctx, BaseTransform transform, Rectangle outputClip, java.lang.Object renderHelper, Effect defaultInput)
FilterEffectFilterContext object may be null.
outputClip and renderHelper may always be null just
as they may be null for a given filter operation.getRenderState in class FilterEffect<RenderState>fctx - the context object that would be used by the Renderer
if this call is preparing for a render operation, or nulltransform - the transform for the output of this operationoutputClip - the clip rectangle that may restrict this operation, or nullrenderHelper - the rendering helper object that can be used to shortcut
this operation under certain conditions, or nulldefaultInput - the Effect to be used in place of any null inputspublic boolean reducesOpaquePixels()
EffectreducesOpaquePixels in class Effectpublic DirtyRegionContainer getDirtyRegions(Effect defaultInput, DirtyRegionPool regionPool)
EffectgetDirtyRegions in class EffectdefaultInput - the default input Effect to be used in
all cases where a filter has a null inputregionPool - the pool of dirty regions