RenderShaderText

Functions

CID

GetClassID

RED_RC

LoadProgram

RED_RC

EvaluateFromInputParameters

void *

As

const void *

As

class T_As

As

class T_As

As

RenderShaderText

~RenderShaderText

Detailed Description

class RenderShaderText : public RED::RenderShader

Textured texts rendering shader.

@related Using Built-in Render Shaders, class RED::IMaterial, class RED::RenderShader, class RED::StateShader, class RED::RenderCode, Displaying Texts

This shader renders RED::ITextShape contents for texts that are using a font of the RED::FNT_TEXTURE kind. It can not be used with other kind of fonts.

The shader produces a simple color and an alpha value defined by the RED::RenderShaderParameter::REF_FONT_GLYPH_TEX value. The specified color is multiplied by the texture’s alpha value and written as final output.

This shader is packaged in the RED::IResourceManager::CreateTexturedFontMaterial material creation helper. This method can be used directly for all basic text rendering needs.

Note that this shader should be come after a state shader with the appropriate blending function being set (usually a RED::StateShader::ADDITIVE blending mode).

Please also note that textured texts have overlapping quad geometries for the glyphs that compose their strings.

This shader is implicitly using the following geometrical channels:

The text shader should be used in RED::MTL_PRELIT or RED::MTL_POSTLIT pass.

This shader creates two configurations:

See the REDRenderShaderText.h file documentation for the list of all #define statements used to name all parameters of this shader.

Public Functions

virtual void *As(const RED::CID &iCID)

Converts the object to an instance of the given type.

Parameters

iCID – Requested class.

Returns

An object pointer of the given class on success, NULL otherwise.

virtual const void *As(const RED::CID &iCID) const

Converts the object to an instance of the given type.

Parameters

iCID – Requested class.

Returns

An object pointer of the given class on success, NULL otherwise.

template<class T_As>
inline T_As *As()
template<class T_As>
inline const T_As *As() const
RenderShaderText(const RED::Color &iTextColor, RED::TEXT_ALPHA_MODE iInterpolation, bool iUseVertexColor, RED::Object *iResMgr, RED_RC &oErrorCode)

Constructor.

Sets the lighting to the color specified in iTextColor. The alpha value returned by the shader is based on the value of the RED::RenderShaderParameter::REF_FONT_GLYPH_TEX reference.

The additional iInterpolation parameter lets the caller choose the alpha interpolation that’ll be used by the shader. The alpha value comes from the linear filtering of the texture that contains the font glyphs:

  • TEXT_ALPHA_LINEAR: The alpha value produced by the shader is linearly interpolated. This is the base linear filter of the texture. Linear interpolated texts tend to be a bit blurry when seen as small items on screen. Their intensity vanishes when zoomed out.

  • TEXT_ALPHA_3A2_MINUS_2A3: The alpha value produced by the shader is modified using the 3*(a*a) - 2*(a*a*a) equation. This produces a sharper interpolation that improves text legibility if the text is not too small. Their intensity vanishes when zoomed out.

  • TEXT_ALPHA_SQRTA: The alpha value produced by the shader is modified using the sqrt(a) equation. This produces texts that seems a bit more bold than for the other modes. If the text is zoomed out, the intensity of the text remains and the text remains more visible.

  • XXX_DEPTH: These interpolation modes behave similarly to their base names ‘XXX’ mode, except that the shader uses the custom depth information defined by RED::ITextShape::SetDepth to generate the final depth of the text in the z-buffer. This is noticeably used to define a fine grain rendering order control of texts in complex drafting environments.

Parameters
  • iTextColor – Text color. Alpha is ignored.

  • iInterpolation – The text interpolation mode.

  • iUseVertexColor – If set to true, the text is colored using vertex colors of strings that are defined by calls to the RED::ITextShape::SetColor method. In this case, the value of iTextColor is ignored. If set to false, this is the value of iTextColor that is used instead.

  • iResMgr – The cluster’s resource manager.

  • oErrorCode – Indicates a construction failure when not returned set to RED_OK.

virtual ~RenderShaderText()

Destructor.

Public Static Functions

static inline RED::CID GetClassID()
static RED_RC LoadProgram(RED::String &oString, const RED::ShaderProgramID &iID)

Loads a shader program.

Generates a shader program that corresponds to the specified iID.

Parameters
  • oString – The created program string.

  • iID – The shader program unique ID.

Returns

RED_OK if the shader could be loaded,

RED_ALLOC_FAILURE if an allocation has failed,

RED_FAIL otherwise.

static RED_RC EvaluateFromInputParameters(RED::RenderShader *ioShader, RED::Object *iResMgr)

Evaluate a shader from its input parameters.

Parameters
  • ioShaderShader to redefine using its own input parameters.

  • iResMgr – The cluster’s resource manager.

Returns

RED_OK if the operation has succeeded,

RED_BAD_PARAM if iShader was not valid,

RED_BAD_PARAM if an invalid parameter was found during the evaluation,

RED_ALLOC_FAILURE if a memory allocation has failed,

Other RED_RC related to shader creation can be returned.