Package icyllis.arc3d.granite
Class GeometryStep.ProgramImpl
java.lang.Object
icyllis.arc3d.granite.GeometryStep.ProgramImpl
- Enclosing class:
GeometryStep
Every
GeometryStep
must be capable of creating a subclass of ProgramImpl. The
ProgramImpl emits the shader code that implements the GeometryProcessor, is attached to the
generated backend API pipeline/program and used to extract uniform data from
GeometryProcessor instances.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
emitCode
(VertexGeomBuilder vertBuilder, FPFragmentBuilder fragBuilder, VaryingHandler varyingHandler, UniformHandler uniformHandler, ShaderCaps shaderCaps, GeometryStep geomProc, String outputColor, String outputCoverage, int[] texSamplers) Emits the code from this geometry processor into the shaders.protected abstract void
onEmitCode
(VertexGeomBuilder vertBuilder, FPFragmentBuilder fragBuilder, VaryingHandler varyingHandler, UniformHandler uniformHandler, ShaderCaps shaderCaps, GeometryStep geomProc, String outputColor, String outputCoverage, int[] texSamplers, ShaderVar localPos, ShaderVar worldPos) The local pos is used to specify the output variable storing draw's local position.abstract void
setData
(UniformDataManager manager, GeometryStep geomProc) A ProgramImpl instance can be reused with any GeometryProcessor that produces the same key.protected static Matrix
setTransform
(UniformDataManager pdm, int uniform, Matrix matrix, Matrix state) A helper for setting the matrix on a uniform handle initialized through writeOutputPosition or writeLocalCoord.protected static void
writePassthroughWorldPosition
(VertexGeomBuilder vertBuilder, ShaderVar inPos, ShaderVar outPos) protected static void
writeWorldPosition
(VertexGeomBuilder vertBuilder, ShaderVar inPos, String matrixName, ShaderVar outPos) Helpers for adding code to write the transformed vertex position.
-
Constructor Details
-
ProgramImpl
public ProgramImpl()
-
-
Method Details
-
setTransform
protected static Matrix setTransform(@Nonnull UniformDataManager pdm, int uniform, @Nonnull Matrix matrix, @Nullable Matrix state) A helper for setting the matrix on a uniform handle initialized through writeOutputPosition or writeLocalCoord. Automatically handles elided uniforms, scale+translate matrices, and state tracking (if provided state pointer is non-null).- Parameters:
matrix
- the matrix to set, must be immutablestate
- the current state- Returns:
- new state, eiter matrix or state
-
writePassthroughWorldPosition
protected static void writePassthroughWorldPosition(VertexGeomBuilder vertBuilder, ShaderVar inPos, ShaderVar outPos) -
writeWorldPosition
protected static void writeWorldPosition(VertexGeomBuilder vertBuilder, ShaderVar inPos, String matrixName, ShaderVar outPos) Helpers for adding code to write the transformed vertex position. The first simple version just writes a variable named by 'posName' into the position output variable with the assumption that the position is 2D. The second version transforms the input position by a view matrix and the output variable is 2D or 3D depending on whether the view matrix is perspective.- Parameters:
inPos
- the local variable or the attribute, type must be either vec2 or vec3
-
emitCode
public final void emitCode(VertexGeomBuilder vertBuilder, FPFragmentBuilder fragBuilder, VaryingHandler varyingHandler, UniformHandler uniformHandler, ShaderCaps shaderCaps, GeometryStep geomProc, String outputColor, String outputCoverage, int[] texSamplers) Emits the code from this geometry processor into the shaders. For any FP in the pipeline that has its input coords implemented by the GP as a varying, the varying will be accessible in the returned map and should be used when the FP code is emitted. The FS variable containing the GP's output local coords is also returned. -
setData
A ProgramImpl instance can be reused with any GeometryProcessor that produces the same key. This function reads data from a GeometryProcessor and updates any uniform variables required by the shaders created in emitCode(). The GeometryProcessor parameter is guaranteed to be of the same type and to have an identical processor key as the GeometryProcessor that created this ProgramImpl. -
onEmitCode
protected abstract void onEmitCode(VertexGeomBuilder vertBuilder, FPFragmentBuilder fragBuilder, VaryingHandler varyingHandler, UniformHandler uniformHandler, ShaderCaps shaderCaps, GeometryStep geomProc, String outputColor, String outputCoverage, int[] texSamplers, ShaderVar localPos, ShaderVar worldPos) The local pos is used to specify the output variable storing draw's local position. It can be either a vec2 or a vec3, or void. It can only be void when no FP needs local coordinates. This variable can be an attribute or local variable, but should not itself be a varying. PipelineBuilder automatically determines if this must be passed to the FP.The world pos is used to specify the output variable storing its world (device) position. It can either be a vec2 or a vec3 (in order to handle perspective).
-