#[non_exhaustive]
pub enum SnippetHook {
Vertex,
VertexTransform,
VertexGlobals,
PointSize,
Fragment,
FragmentGlobals,
TextureCoordTransform,
LayerFragment,
TextureLookup,
}
Expand description
Location within a Pipeline
SnippetHook
is used to specify a location within a
Pipeline
where the code of the snippet should be used when it
is attached to a pipeline.
SnippetHook::VertexGlobals
Adds a shader snippet at the beginning of the global section of the shader for the vertex processing. Any declarations here can be shared with all other snippets that are attached to a vertex hook. Only the ‘declarations’ string is used and the other strings are ignored.
SnippetHook::FragmentGlobals
Adds a shader snippet at the beginning of the global section of the shader for the fragment processing. Any declarations here can be shared with all other snippets that are attached to a fragment hook. Only the ‘declarations’ string is used and the other strings are ignored.
SnippetHook::Vertex
Adds a shader snippet that will hook on to the vertex processing stage of the pipeline. This gives a chance for the application to modify the vertex attributes generated by the shader. Typically the snippet will modify color_out or position_out builtins.
The ‘declarations’ string in snippet
will be inserted in the
global scope of the shader. Use this to declare any uniforms,
attributes or functions that the snippet requires.
The ‘pre’ string in snippet
will be inserted at the top of the
main
fn before any vertex processing is done.
The ‘replace’ string in snippet
will be used instead of the
generated vertex processing if it is present. This can be used if
the application wants to provide a complete vertex shader and
doesn’t need the generated output from .
The ‘post’ string in snippet
will be inserted after all of the
standard vertex processing is done. This can be used to modify the
outputs.
SnippetHook::VertexTransform
Adds a shader snippet that will hook on to the vertex transform stage. Typically the snippet will use the modelview_matrix, projection_matrix and modelview_projection_matrix matrices and the position_in attribute. The hook must write to position_out. The default processing for this hook will multiply position_in by the combined modelview-projection matrix and store it on position_out.
The ‘declarations’ string in snippet
will be inserted in the
global scope of the shader. Use this to declare any uniforms,
attributes or functions that the snippet requires.
The ‘pre’ string in snippet
will be inserted at the top of the
main
fn before the vertex transform is done.
The ‘replace’ string in snippet
will be used instead of the
generated vertex transform if it is present.
The ‘post’ string in snippet
will be inserted after all of the
standard vertex transformation is done. This can be used to modify the
position_out in addition to the default processing.
SnippetHook::PointSize
Adds a shader snippet that will hook on to the point size
calculation step within the vertex shader stage. The snippet should
write to the builtin point_size_out with the new point size.
The snippet can either read point_size_in directly and write a
new value or first read an existing value in point_size_out
that would be set by a previous snippet. Note that this hook is
only used if Pipeline::set_per_vertex_point_size
is enabled
on the pipeline.
The ‘declarations’ string in snippet
will be inserted in the
global scope of the shader. Use this to declare any uniforms,
attributes or functions that the snippet requires.
The ‘pre’ string in snippet
will be inserted just before
calculating the point size.
The ‘replace’ string in snippet
will be used instead of the
generated point size calculation if it is present.
The ‘post’ string in snippet
will be inserted after the
standard point size calculation is done. This can be used to modify
point_size_out in addition to the default processing.
SnippetHook::Fragment
Adds a shader snippet that will hook on to the fragment processing stage of the pipeline. This gives a chance for the application to modify the fragment color generated by the shader. Typically the snippet will modify color_out.
The ‘declarations’ string in snippet
will be inserted in the
global scope of the shader. Use this to declare any uniforms,
attributes or functions that the snippet requires.
The ‘pre’ string in snippet
will be inserted at the top of the
main
fn before any fragment processing is done.
The ‘replace’ string in snippet
will be used instead of the
generated fragment processing if it is present. This can be used if
the application wants to provide a complete fragment shader and
doesn’t need the generated output from .
The ‘post’ string in snippet
will be inserted after all of the
standard fragment processing is done. At this point the generated
value for the rest of the pipeline state will already be in
color_out so the application can modify the result by altering
this variable.
SnippetHook::TextureCoordTransform
Adds a shader snippet that will hook on to the texture coordinate transformation of a particular layer. This can be used to replace the processing for a layer or to modify the results.
Within the snippet code for this hook there are two extra variables. The first is a mat4 called matrix which represents the user matrix for this layer. The second is called tex_coord and represents the incoming and outgoing texture coordinate. On entry to the hook, tex_coord contains the value of the corresponding texture coordinate attribute for this layer. The hook is expected to modify this variable. The output will be passed as a varying to the fragment processing stage. The default code will just multiply matrix by tex_coord and store the result in tex_coord.
The ‘declarations’ string in snippet
will be inserted in the
global scope of the shader. Use this to declare any uniforms,
attributes or functions that the snippet requires.
The ‘pre’ string in snippet
will be inserted just before the
fragment processing for this layer. At this point tex_coord
still contains the value of the texture coordinate attribute.
If a ‘replace’ string is given then this will be used instead of the default fragment processing for this layer. The snippet can modify tex_coord or leave it as is to apply no transformation.
The ‘post’ string in snippet
will be inserted just after the
transformation. At this point tex_coord will contain the
results of the transformation but it can be further modified by the
snippet.
SnippetHook::LayerFragment
Adds a shader snippet that will hook on to the fragment processing of a particular layer. This can be used to replace the processing for a layer or to modify the results.
Within the snippet code for this hook there is an extra vec4 variable called ‘layer’. This contains the resulting color that will be used for the layer. This can be modified in the ‘post’ section or it the default processing can be replaced entirely using the ‘replace’ section.
The ‘declarations’ string in snippet
will be inserted in the
global scope of the shader. Use this to declare any uniforms,
attributes or functions that the snippet requires.
The ‘pre’ string in snippet
will be inserted just before the
fragment processing for this layer.
If a ‘replace’ string is given then this will be used instead of the default fragment processing for this layer. The snippet must write to the ‘layer’ variable in that case.
The ‘post’ string in snippet
will be inserted just after the
fragment processing for the layer. The results can be modified by changing
the value of the ‘layer’ variable.
SnippetHook::TextureLookup
Adds a shader snippet that will hook on to the texture lookup part of a given layer. This gives a chance for the application to modify the coordinates that will be used for the texture lookup or to alter the returned texel.
Within the snippet code for this hook there are three extra variables available. ‘sampler’ is a sampler object representing the sampler for the layer where the snippet is attached. ‘tex_coord’ is a vec4 which contains the texture coordinates that will be used for the texture lookup. This can be modified. ‘texel’ will contain the result of the texture lookup. This can also be modified.
The ‘declarations’ string in snippet
will be inserted in the
global scope of the shader. Use this to declare any uniforms,
attributes or functions that the snippet requires.
The ‘pre’ string in snippet
will be inserted at the top of the
main
fn before any fragment processing is done. This is a
good place to modify the tex_coord variable.
If a ‘replace’ string is given then this will be used instead of a the default texture lookup. The snippet would typically use its own sampler in this case.
The ‘post’ string in snippet
will be inserted after texture lookup
has been preformed. Here the snippet can modify the texel
variable to alter the returned texel.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Vertex
A hook for the entire vertex processing stage of the pipeline.
VertexTransform
A hook for the vertex transformation.
VertexGlobals
A hook for declaring global data that can be shared with all other snippets that are on a vertex hook.
PointSize
A hook for manipulating the point
size of a vertex. This is only used if
Pipeline::set_per_vertex_point_size
is enabled on the
pipeline.
Fragment
A hook for the entire fragment processing stage of the pipeline.
FragmentGlobals
A hook for declaring global data wthat can be shared with all other snippets that are on a fragment hook.
TextureCoordTransform
A hook for applying the layer matrix to a texture coordinate for a layer.
LayerFragment
A hook for the fragment processing of a particular layer.
TextureLookup
A hook for the texture lookup stage of a given layer in a pipeline.
Trait Implementations
sourceimpl Clone for SnippetHook
impl Clone for SnippetHook
sourcefn clone(&self) -> SnippetHook
fn clone(&self) -> SnippetHook
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for SnippetHook
impl Debug for SnippetHook
sourceimpl Display for SnippetHook
impl Display for SnippetHook
sourceimpl Hash for SnippetHook
impl Hash for SnippetHook
sourceimpl Ord for SnippetHook
impl Ord for SnippetHook
sourceimpl PartialEq<SnippetHook> for SnippetHook
impl PartialEq<SnippetHook> for SnippetHook
sourceimpl PartialOrd<SnippetHook> for SnippetHook
impl PartialOrd<SnippetHook> for SnippetHook
sourcefn partial_cmp(&self, other: &SnippetHook) -> Option<Ordering>
fn partial_cmp(&self, other: &SnippetHook) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for SnippetHook
impl Eq for SnippetHook
impl StructuralEq for SnippetHook
impl StructuralPartialEq for SnippetHook
Auto Trait Implementations
impl RefUnwindSafe for SnippetHook
impl Send for SnippetHook
impl Sync for SnippetHook
impl Unpin for SnippetHook
impl UnwindSafe for SnippetHook
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Clamp<T> for T where
T: PartialOrd<T>,
impl<T> Clamp<T> for T where
T: PartialOrd<T>,
fn clamped(self, min: T, max: T) -> T
sourceimpl<Fr, To> IntoColor<To> for Fr where
To: FromColor<Fr>,
impl<Fr, To> IntoColor<To> for Fr where
To: FromColor<Fr>,
sourcefn into_color(self) -> To
fn into_color(self) -> To
Convert into color
impl<T> Pointable for T
impl<T> Pointable for T
impl<T> SetParameter for T
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
Sets value
as a parameter of self
.