RenderShaderSectionCut

Functions

CID

GetClassID

RED_RC

LoadProgram

RED_RC

EvaluateFromInputParameters

void *

As

const void *

As

class T_As

As

class T_As

As

RenderShaderSectionCut

RenderShaderSectionCut

~RenderShaderSectionCut

Detailed Description

class RenderShaderSectionCut : public RED::RenderShader

Section cutting plane calculation shader.

@related Using Built-in Render Shaders, Cutting Geometries: A Practical Example, class RED::IMaterial, class RED::RenderShader, class RED::StateShader, class RED::RenderCode

The section cut shader is embedded into a complete helper that apply section cutting to a material: See RED::IMaterial::SetCuttingPlane for details.

This shader is used in a preparation step to apply a cutting plane to any visible geometry. It calculates the necessary display mask that isolates all fragments that must remain visible after application of the cutting plane. One single cutting plane can be specified at a time.

All rendered fragments on the positive side of the plane are discared.

This shader uses the following geometrical channels:

  • RED::MCL_VERTEX: Vertex array of the rendered meshes.

  • Specified normal channels for the edge setup.

The RenderShaderSectionCut can be used in a direct lighting configuration, usually in the RED::MTL_PRELIT pass of the material.

This shader creates two platform configurations in direct lighting:

See the REDRenderShaderSectionCut.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
RenderShaderSectionCut(const float iPlaneEquation[4], RED::Object *iResMgr, RED_RC &oErrorCode)

Constructor.

Parameters
  • iPlaneEquation – Cutting plane equation. 4 values must be supplied in the array, in the order A, B, C, D that define each plane equation by A*x + B*y + C*z + D = 0. Coefficients must be in world space coordinates.

  • iResMgr – The cluster’s resource manager.

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

RenderShaderSectionCut(RED::MESH_CHANNEL iVertexChannel, RED::MESH_CHANNEL iNormal1Channel, RED::MESH_CHANNEL iNormal2Channel, bool iDrawBorder, bool iDrawContour, float iCreaseAngle, const float iPlaneEquation[4], RED::Object *iResMgr, RED_RC &oErrorCode)

Constructor for edges.

This construction method uses the same setup parameters as the RED::RenderShaderEdges. It’s intended for use to apply section cutting on geometries that are rendered using the RED::RenderShaderEdges.

This shader must go to the RED::MTL_PRELIT rendering pass.

Parameters
  • iVertexChannel – Source channel with vertex information.

  • iNormal1Channel – First adjacent triangle normal channel.

  • iNormal2Channel – Second adjacent triangle normal channel.

  • iDrawBorder – Render border edges?

  • iDrawContour – Render contour edges?

  • iCreaseAngle – Crease angle below which inner edges will be filtered (in radians). Set to RED_PI to discard all inner edges.

  • iPlaneEquation – Cutting plane equation. 4 values must be supplied in the array, in the order A, B, C, D that define each plane equation by A*x + B*y + C*z + D = 0. Coefficients must be in world space coordinates.

  • iResMgr – The cluster’s resource manager.

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

virtual ~RenderShaderSectionCut()

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.