Pyrogenesis trunk
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
TerrainRenderer Class Reference

Class TerrainRenderer: Render everything related to the terrain, especially patches and water. More...

#include <TerrainRenderer.h>

Collaboration diagram for TerrainRenderer:
Collaboration graph
[legend]

Public Member Functions

 TerrainRenderer ()
 
 ~TerrainRenderer ()
 
void Initialize ()
 
void SetSimulation (CSimulation2 *simulation)
 Set the simulation context for this frame. More...
 
void Submit (int cullGroup, CPatch *patch)
 Submit: Add a patch for rendering in this frame. More...
 
void Submit (int cullGroup, CModelDecal *decal)
 Submit: Add a terrain decal for rendering in this frame. More...
 
void PrepareForRendering ()
 PrepareForRendering: Prepare internal data structures like vertex buffers for rendering. More...
 
void EndFrame ()
 EndFrame: Remove all patches from the list of submitted patches. More...
 
void RenderTerrainShader (Renderer::Backend::IDeviceCommandContext *deviceCommandContext, const CShaderDefines &context, int cullGroup, ShadowMap *shadow)
 Render textured terrain (including blends between different terrain types). More...
 
void RenderPatches (Renderer::Backend::IDeviceCommandContext *deviceCommandContext, int cullGroup, const CShaderDefines &defines, const CColor &color=CColor(0.0f, 0.0f, 0.0f, 1.0f))
 RenderPatches: Render all patches un-textured as polygons. More...
 
void RenderOutlines (Renderer::Backend::IDeviceCommandContext *deviceCommandContext, int cullGroup)
 RenderOutlines: Render the outline of patches as lines. More...
 
void RenderWater (Renderer::Backend::IDeviceCommandContext *deviceCommandContext, const CShaderDefines &context, int cullGroup, ShadowMap *shadow)
 RenderWater: Render water for all patches that have been submitted this frame. More...
 
void RenderWaterFoamOccluders (Renderer::Backend::IDeviceCommandContext *deviceCommandContext, int cullGroup)
 Renders terrain to a framebuffer to occlude shore foams. More...
 
CBoundingBoxAligned ScissorWater (int cullGroup, const CCamera &camera)
 Calculate a scissor rectangle for the visible water patches. More...
 
void RenderPriorities (CCanvas2D &canvas, int cullGroup)
 Render priority text for all submitted patches, for debugging. More...
 
void RenderTerrainOverlayTexture (Renderer::Backend::IDeviceCommandContext *deviceCommandContext, int cullGroup, const CVector2D &textureTransform, Renderer::Backend::ITexture *texture)
 Render texture unit 0 over the terrain mesh, with UV coords calculated by the given texture matrix. More...
 

Private Member Functions

bool RenderFancyWater (Renderer::Backend::IDeviceCommandContext *deviceCommandContext, const CShaderDefines &context, int cullGroup, ShadowMap *shadow)
 RenderFancyWater: internal rendering method for fancy water. More...
 
void RenderSimpleWater (Renderer::Backend::IDeviceCommandContext *deviceCommandContext, int cullGroup)
 RenderSimpleWater: internal rendering method for water. More...
 

Static Private Member Functions

static void PrepareShader (Renderer::Backend::IDeviceCommandContext *deviceCommandContext, Renderer::Backend::IShaderProgram *shader, ShadowMap *shadow)
 Set up all the uniforms for a shader pass. More...
 

Private Attributes

TerrainRendererInternalsm
 

Friends

class CPatchRData
 
class CDecalRData
 

Detailed Description

Class TerrainRenderer: Render everything related to the terrain, especially patches and water.

Constructor & Destructor Documentation

◆ TerrainRenderer()

TerrainRenderer::TerrainRenderer ( )

◆ ~TerrainRenderer()

TerrainRenderer::~TerrainRenderer ( )

Member Function Documentation

◆ EndFrame()

void TerrainRenderer::EndFrame ( )

EndFrame: Remove all patches from the list of submitted patches.

◆ Initialize()

void TerrainRenderer::Initialize ( )

◆ PrepareForRendering()

void TerrainRenderer::PrepareForRendering ( )

PrepareForRendering: Prepare internal data structures like vertex buffers for rendering.

All patches must have been submitted before the call to PrepareForRendering. PrepareForRendering must be called before any rendering calls.

◆ PrepareShader()

void TerrainRenderer::PrepareShader ( Renderer::Backend::IDeviceCommandContext deviceCommandContext,
Renderer::Backend::IShaderProgram shader,
ShadowMap shadow 
)
staticprivate

Set up all the uniforms for a shader pass.

◆ RenderFancyWater()

bool TerrainRenderer::RenderFancyWater ( Renderer::Backend::IDeviceCommandContext deviceCommandContext,
const CShaderDefines context,
int  cullGroup,
ShadowMap shadow 
)
private

RenderFancyWater: internal rendering method for fancy water.

Returns false if unable to render with fancy water.

◆ RenderOutlines()

void TerrainRenderer::RenderOutlines ( Renderer::Backend::IDeviceCommandContext deviceCommandContext,
int  cullGroup 
)

RenderOutlines: Render the outline of patches as lines.

preconditions : PrepareForRendering must have been called this frame before calling RenderOutlines.

Parameters
filteredIf true then only render objects that passed CullPatches.

◆ RenderPatches()

void TerrainRenderer::RenderPatches ( Renderer::Backend::IDeviceCommandContext deviceCommandContext,
int  cullGroup,
const CShaderDefines defines,
const CColor color = CColor(0.0f, 0.0f, 0.0f, 1.0f) 
)

RenderPatches: Render all patches un-textured as polygons.

preconditions : PrepareForRendering must have been called this frame before calling RenderPatches.

Parameters
filteredIf true then only render objects that passed CullPatches.
colorFill color of the patches.

◆ RenderPriorities()

void TerrainRenderer::RenderPriorities ( CCanvas2D canvas,
int  cullGroup 
)

Render priority text for all submitted patches, for debugging.

◆ RenderSimpleWater()

void TerrainRenderer::RenderSimpleWater ( Renderer::Backend::IDeviceCommandContext deviceCommandContext,
int  cullGroup 
)
private

RenderSimpleWater: internal rendering method for water.

◆ RenderTerrainOverlayTexture()

void TerrainRenderer::RenderTerrainOverlayTexture ( Renderer::Backend::IDeviceCommandContext deviceCommandContext,
int  cullGroup,
const CVector2D textureTransform,
Renderer::Backend::ITexture texture 
)

Render texture unit 0 over the terrain mesh, with UV coords calculated by the given texture matrix.

Intended for use by TerrainTextureOverlay.

◆ RenderTerrainShader()

void TerrainRenderer::RenderTerrainShader ( Renderer::Backend::IDeviceCommandContext deviceCommandContext,
const CShaderDefines context,
int  cullGroup,
ShadowMap shadow 
)

Render textured terrain (including blends between different terrain types).

preconditions : PrepareForRendering must have been called this frame before calling RenderTerrain.

Parameters
deviceCommandContextA context to submit commands.
shadowA prepared shadow map, in case rendering with shadows is enabled.

◆ RenderWater()

void TerrainRenderer::RenderWater ( Renderer::Backend::IDeviceCommandContext deviceCommandContext,
const CShaderDefines context,
int  cullGroup,
ShadowMap shadow 
)

RenderWater: Render water for all patches that have been submitted this frame.

preconditions : PrepareForRendering must have been called this frame before calling RenderWater.

◆ RenderWaterFoamOccluders()

void TerrainRenderer::RenderWaterFoamOccluders ( Renderer::Backend::IDeviceCommandContext deviceCommandContext,
int  cullGroup 
)

Renders terrain to a framebuffer to occlude shore foams.

◆ ScissorWater()

CBoundingBoxAligned TerrainRenderer::ScissorWater ( int  cullGroup,
const CCamera camera 
)

Calculate a scissor rectangle for the visible water patches.

◆ SetSimulation()

void TerrainRenderer::SetSimulation ( CSimulation2 simulation)

Set the simulation context for this frame.

Call at start of frame, before any other Submits.

◆ Submit() [1/2]

void TerrainRenderer::Submit ( int  cullGroup,
CModelDecal decal 
)

Submit: Add a terrain decal for rendering in this frame.

◆ Submit() [2/2]

void TerrainRenderer::Submit ( int  cullGroup,
CPatch patch 
)

Submit: Add a patch for rendering in this frame.

preconditions : PrepareForRendering must not have been called for this frame yet. The patch must not have been submitted in this frame yet (i.e. you can only submit a frame once).

Parameters
patchthe patch

Friends And Related Function Documentation

◆ CDecalRData

friend class CDecalRData
friend

◆ CPatchRData

friend class CPatchRData
friend

Member Data Documentation

◆ m

TerrainRendererInternals* TerrainRenderer::m
private

The documentation for this class was generated from the following files: