public class GaussianRenderState extends LinearConvolveRenderState
LinearConvolveRenderState.PassType
RenderState.EffectCoordinateSpace
Modifier and Type | Field and Description |
---|---|
private float |
inputRadiusX |
private float |
inputRadiusY |
private BaseTransform |
inputtx |
private boolean |
isShadow |
static float |
MAX_RADIUS |
private float |
passRadius |
private LinearConvolveRenderState.PassType |
passType |
private BaseTransform |
resulttx |
private float[] |
samplevectors |
private Color4f |
shadowColor |
private RenderState.EffectCoordinateSpace |
space |
private float |
spread |
private float |
spreadPass |
private int |
validatedPass |
private java.nio.FloatBuffer |
weights |
private float |
weightsValidRadius |
private float |
weightsValidSpread |
BLACK_COMPONENTS, MAX_COMPILED_KERNEL_SIZE, MAX_KERNEL_SIZE, MIN_EFFECT_RADIUS
RenderSpaceRenderState, UnclippedUserSpaceRenderState, UserSpaceRenderState
Constructor and Description |
---|
GaussianRenderState(float radius,
float dx,
float dy,
BaseTransform filtertx)
Constructs a
RenderState for a single dimensional, directional
Gaussian convolution (as for a MotionBlur operation). |
GaussianRenderState(float xradius,
float yradius,
float spread,
boolean isShadow,
Color4f shadowColor,
BaseTransform filtertx)
Constructs a
RenderState for a 2 dimensional Gaussian convolution. |
Modifier and Type | Method and Description |
---|---|
RenderState.EffectCoordinateSpace |
getEffectTransformSpace()
Return a hint indicating which coordinate space should be used for
the pixel filtering for this particular filtering operation.
|
(package private) static java.nio.FloatBuffer |
getGaussianWeights(java.nio.FloatBuffer weights,
int pad,
float radius,
float spread) |
Rectangle |
getInputClip(int i,
Rectangle filterClip)
Return the clip for the indicated input based on the indicated output
clip.
|
int |
getInputKernelSize(int pass)
Returns the size of the desired convolution kernel for the given pass
as it would be applied in the coordinate space indicated by the
LinearConvolveRenderState.getInputKernelSize(int) method. |
BaseTransform |
getInputTransform(BaseTransform filterTransform)
Return the transform that should be used to obtain pixel input from the
Effect inputs for this filter operation. |
int |
getPassKernelSize()
Returns the appropriate kernel size for the pass that was last
validated using validateInput().
|
Rectangle |
getPassResultBounds(Rectangle srcdimension,
Rectangle outputClip)
Returns the size of the scaled result image needed to hold the output
for the currently validated pass with the indicated input dimensions
and output clip.
|
float[] |
getPassShadowColorComponents()
For a shadow convolution operation, return the 4 float versions of
the color components, in the range
[0, 1] for the shadow color
to be substituted for the input colors. |
LinearConvolveRenderState.PassType |
getPassType()
Return a hint about the way that the weights will be applied to the
pixels for the currently validated pass.
|
float[] |
getPassVector()
Returns an array of 4 floats used to initialize a float4 Shader
constant with the relative starting location of the first weight
in the convolution kernel and the incremental offset between each
sample to be weighted and accumulated.
|
java.nio.FloatBuffer |
getPassWeights()
A
FloatBuffer padded out to the required size as specified by
the #getPeerSize() method filled with the convolution weights
needed for the currently validated pass. |
int |
getPassWeightsArrayLength()
Returns the maximum number of valid float4 elements that should be
referenced from the buffer returned by getWeights() for the currently
validated pass.
|
BaseTransform |
getResultTransform(BaseTransform filterTransform)
Return the transform that should be used to transform the results of
the filter operation.
|
Color4f |
getShadowColor()
Returns the
Color4f representing the shadow color if this
is a shadow operation. |
boolean |
isNop()
Returns true if the resulting operation is globally a NOP operation.
|
boolean |
isPassNop()
Returns true if the operation of the currently validated pass would
be a NOP operation.
|
boolean |
isShadow()
Returns true if this is a shadow convolution operation where a
constant color is substituted for the color components of the
output.
|
ImageData |
validatePassInput(ImageData src,
int pass)
Validates the
RenderState object for a given pass of the
convolution. |
private void |
validateWeights() |
getPassPeer, getPeerSize, nearOne, nearZero
public static final float MAX_RADIUS
private boolean isShadow
private Color4f shadowColor
private float spread
private RenderState.EffectCoordinateSpace space
private BaseTransform inputtx
private BaseTransform resulttx
private float inputRadiusX
private float inputRadiusY
private float spreadPass
private int validatedPass
private LinearConvolveRenderState.PassType passType
private float passRadius
private java.nio.FloatBuffer weights
private float[] samplevectors
private float weightsValidRadius
private float weightsValidSpread
public GaussianRenderState(float xradius, float yradius, float spread, boolean isShadow, Color4f shadowColor, BaseTransform filtertx)
RenderState
for a 2 dimensional Gaussian convolution.xradius
- the Gaussian radius along the user space X axisyradius
- the Gaussian radius along the user space Y axisspread
- the spread amountisShadow
- true if this is a shadow operationshadowColor
- the color of the shadow operationfiltertx
- the transform applied to the filter operationpublic GaussianRenderState(float radius, float dx, float dy, BaseTransform filtertx)
RenderState
for a single dimensional, directional
Gaussian convolution (as for a MotionBlur operation).radius
- the Gaussian radius along the indicated directiondx
- the delta X of the unit vector along which to apply the convolutiondy
- the delta Y of the unit vector along which to apply the convolutionfiltertx
- the transform applied to the filter operationstatic java.nio.FloatBuffer getGaussianWeights(java.nio.FloatBuffer weights, int pad, float radius, float spread)
public boolean isShadow()
LinearConvolveRenderState
Effect
from which
this RenderState
was instantiated and does not vary as the
filter operation progresses.isShadow
in class LinearConvolveRenderState
public Color4f getShadowColor()
LinearConvolveRenderState
Color4f
representing the shadow color if this
is a shadow operation.
This value is dependent only on the original Effect
from which
this RenderState
was instantiated and does not vary as the
filter operation progresses.getShadowColor
in class LinearConvolveRenderState
Color4f
for the shadow color, or nullpublic float[] getPassShadowColorComponents()
LinearConvolveRenderState
[0, 1]
for the shadow color
to be substituted for the input colors.
This method will only be called if LinearConvolveRenderState.isShadow()
returns true.getPassShadowColorComponents
in class LinearConvolveRenderState
public RenderState.EffectCoordinateSpace getEffectTransformSpace()
RenderState
getEffectTransform()
and getResultTransform()
methods will always be used to get the actual
transforms to be used to get input data and transform the results, but
this method can help to set the expectations of the caller to optimize
techniques.EffectSpace
value to describe the expected output
from the getEffectTransform(...)
and getResultTransform(...)
methods.public BaseTransform getInputTransform(BaseTransform filterTransform)
RenderState
Effect
inputs for this filter operation.
The returned transform is handed to all input Effect
objects
to obtain pixel data for the inputs.
Typically, the output of getInputTransform(transform)
and
getResultTransform(transform)
could be concatenated to produce
the original filterTransform
.filterTransform
- the BaseTransform
object for the filter operationBaseTransform
object to use for the input effectspublic BaseTransform getResultTransform(BaseTransform filterTransform)
RenderState
getInputTransform(transform)
and
getResultTransform(transform)
could be concatenated to produce
the original filterTransform
.filterTransform
- the BaseTransform
object for the filter operationBaseTransform
object to be applied to the result
texturepublic Rectangle getInputClip(int i, Rectangle filterClip)
RenderState
i
- the index of the input being processedfilterClip
- the output clip supplied to the given filter operationpublic ImageData validatePassInput(ImageData src, int pass)
LinearConvolveRenderState
RenderState
object for a given pass of the
convolution.
The supplied source image is provided so that the RenderState
object can determine if it needs to change its strategy for how the
convolution operation will be performed and to scale its data for
the getPass*()
methods relative to the source dimensions and
transform.validatePassInput
in class LinearConvolveRenderState
src
- the ImageData
object supplied by the source effectpass
- the pass of the operation being applied (usually horizontal
for pass 0 and vertical for pass 1)ImageData
to be used for the actual convolution
operationpublic Rectangle getPassResultBounds(Rectangle srcdimension, Rectangle outputClip)
LinearConvolveRenderState
getPassResultBounds
in class LinearConvolveRenderState
srcdimension
- the bounds of the input imageoutputClip
- the area needed for the final resultpublic LinearConvolveRenderState.PassType getPassType()
LinearConvolveRenderState
getPassType
in class LinearConvolveRenderState
LinearConvolveRenderState.PassType
that describes the filtering
operation for this pass of the algorithmpublic float[] getPassVector()
LinearConvolveRenderState
shadervec.x = vector[0] = incdx // X delta between subsequent samples shadervec.y = vector[1] = incdy // Y delta between subsequent samples shadervec.z = vector[2] = startdx // X offset to first convolution sample shadervec.w = vector[3] = startdy // Y offset to first convolution sampleThese values are used in the shader loop as follows:
samplelocation = outputpixellocation.xy + shadervec.zw; for (each weight) { sum += weight * sample(samplelocation.xy); samplelocation.xy += shadervec.xy; }The values are relative to the texture coordinate space which are normalized to the range [0,1] over the source texture.
getPassVector
in class LinearConvolveRenderState
[ incdx, incdy, startdx, startdy ]
public int getPassWeightsArrayLength()
LinearConvolveRenderState
getPassWeightsArrayLength
in class LinearConvolveRenderState
public java.nio.FloatBuffer getPassWeights()
LinearConvolveRenderState
FloatBuffer
padded out to the required size as specified by
the #getPeerSize()
method filled with the convolution weights
needed for the currently validated pass.getPassWeights
in class LinearConvolveRenderState
FloatBuffer
containing the kernel convolution weightspublic int getInputKernelSize(int pass)
LinearConvolveRenderState
LinearConvolveRenderState.getInputKernelSize(int)
method.
This value is calculated at the start of the render operation and
does not vary as the filter operation progresses, but it may not
represent the actual kernel size used when the indicated pass actually
occurs if the #validatePassInput()
method needs to choose
different values when it sees the incoming image source.getInputKernelSize
in class LinearConvolveRenderState
pass
- the pass for which the intended kernel size is desiredpublic int getPassKernelSize()
LinearConvolveRenderState
getPassKernelSize
in class LinearConvolveRenderState
public boolean isNop()
LinearConvolveRenderState
isNop
in class LinearConvolveRenderState
public boolean isPassNop()
LinearConvolveRenderState
isPassNop
in class LinearConvolveRenderState
private void validateWeights()