Interface for shaders, which are used to control the appearance of objects drawn by a renderer. Generally, developers will not want to derive from this directly, rather they will want to derive from TypedShader, and create one or more specific derivations of the ShaderImplementation class.
More...
#include <Rendering/SceneComponents/Shaders/shader.h>
◆ Shader() [1/2]
◆ Shader() [2/2]
◆ ~Shader()
◆ activate()
Activating the shader sets up the target renderer so that when it draws the next object, it will be rendered using the technique the shader provides. If the shader's implementation makes use of hardware shader programs, the shader program will be bound to the device, causing the geometry of any models drawn while the shader is enabled to be rendered using the hardware shader.
For example, the usual order of events is as follows:
- Activate shader
- Bind geometry to the device
- Enable transform
- Draw primitives
NOTE: Most users will want to derive from TypedShader, which has already implemented this function. In this case, create an implementation class for the WSGLRenderer and include it as a template parameter to TypedShader when creating the shader subclass.
- Parameters
-
renderer | The renderer on which we are activating this shader. |
◆ addImplementation()
- Parameters
-
context | The rendering context to which this shader implementation belongs. This makes sure that each shader implementation (and therefore any state that it stores) is bound to a single context, and therefore renderers that share a context will share shader state. |
impl | The implementation object to be used to activate / deactivate on the target renderer. |
◆ appliesScreenSpaceAmbientOcclusion()
virtual bool appliesScreenSpaceAmbientOcclusion |
( |
| ) |
|
|
inlinevirtual |
◆ appliesSpecular()
virtual bool appliesSpecular |
( |
| ) |
|
|
inlinevirtual |
◆ appliesTransparency()
virtual bool appliesTransparency |
( |
| ) |
const |
|
pure virtual |
Subclasses must override this to specify whether they apply transparency to objects or not when they are enabled.
Implemented in BillboardImageShader, BlinnPhongShader, ColorStateShader, DepthShader, ElementColoringShader, HighlightElementShader, HighlightNodeShader, LambertShader, LineOfSightShader, NodeColoringShader, NormalShader, OctreeShader, NullShader, SymbolShader, TextureCoordShader, TextureProjectionShader, and VolumeShader.
◆ clone()
- Returns
- A clone of this object.
- Note
- Subclasses would normally return their own type rather than the Clonable type. The C++ language rules allow a more derived type to be returned from a virtual function and the compiler will still treat it as a valid override.
Implements Clonable.
Implemented in BillboardImageShader, BlinnPhongShader, ColorStateShader, DepthShader, ElementColoringShader, HighlightElementShader, HighlightNodeShader, LambertShader, LineOfSightShader, NodeColoringShader, NormalShader, OctreeShader, NullShader, SymbolShader, TextureCoordShader, TextureProjectionShader, VolumeShader, TypedShader< Derived >, TypedShader< BillboardImageShader >, TypedShader< BlinnPhongShader >, TypedShader< ColorStateShader >, TypedShader< DepthShader >, TypedShader< ElementColoringShader >, TypedShader< HighlightElementShader >, TypedShader< HighlightNodeShader >, TypedShader< LambertShader >, TypedShader< LineOfSightShader >, TypedShader< NodeColoringShader >, TypedShader< NormalShader >, TypedShader< OctreeShader >, TypedShader< SymbolShader >, TypedShader< TextureCoordShader >, TypedShader< TextureProjectionShader >, and TypedShader< VolumeShader >.
◆ deactivate()
- Parameters
-
renderer | The renderer on which we are activating this shader. |
- See also
- activate
◆ getId()
- Returns
- the identifier of this shader.
Every shader instance is required to have a unique identifier. Currently, the assignment of the shader's ID is managed at construction time through a static function.
- Note
- A Shader's ID is not guaranteed to be identical between sessions. Each time the workspace is loaded, shader Ids are re-generated.
◆ getMeshModelInterface()
Convenience function for returning a MeshModelInterface with a particular id from the specified model library. The modelSourceUpdateRequested flag will be set if the function was unable to retrieve data from its source this time round.
- Returns
- the model associated with the specified ID in the provided model library.
◆ getModelSourceUpdateRequested()
bool getModelSourceUpdateRequested |
( |
| ) |
const |
- Returns
- true if during the last 'activate' request, a model source update request was made.
- See also
- getMeshModelInterface
◆ getOptimizeOutInternalVolumeElements()
bool getOptimizeOutInternalVolumeElements |
( |
| ) |
const |
- Returns
- True if the geometry will optimize away (i.e. not use) volume (tetrahedral) elements that are fully internal.
◆ getSegmentLineWidth()
double getSegmentLineWidth |
( |
| ) |
const |
- Returns
- The desired width of segments when rendered with this shader.
◆ getTexturizer() [1/2]
◆ getTexturizer() [2/2]
◆ renderCurrentModel()
◆ renderCurrentModelGlyphs()
◆ setId()
- Parameters
-
id | The identifier to assign to this shader. |
A shader's ID is assumed by other parts of the code to be unique, so it is recommended that this function never be used - by either subclasses or external classes.
◆ setOptimizeOutInternalVolumeElements()
void setOptimizeOutInternalVolumeElements |
( |
bool |
val | ) |
|
- Parameters
-
val | If true, then the geometry render will optimize out internal volume (tetrahedral) elements. |
◆ setSegmentLineWidth()
void setSegmentLineWidth |
( |
double |
width | ) |
|
- Parameters
-
width | The desired width of segments when rendered with this shader. |