|
coastline 0.0.4
|
The renderer of a frame. More...
#include <scenerenderer.h>
Public Member Functions | |
| ~SceneRenderer () | |
| Release renderer resources before the associated window and GPU device are destroyed. | |
| SceneRenderer (const SceneRenderer &)=delete | |
| Prevent copying pipelines, frame targets, and queued draws. | |
| SceneRenderer & | operator= (const SceneRenderer &)=delete |
| Prevent assignment of pipelines, frame targets, and queued draws. | |
| GpuWindow & | Window () |
| void | SetFrontendCamera (std::optional< Matrix4 > view) |
| const std::optional< Matrix4 > & | FrontendCamera () const |
| void | Begin (std::array< float, 4 > clear) |
| Start a frame, cleared to a colour. | |
| void | SetTextureTime (std::uint32_t milliseconds) |
| Set the time the animated textures of the frame show, from 0 at Begin(). | |
| void | SetSnow (bool snow, bool tint) |
| Set whether the textures of the snow of a track show the snow, false from Begin(). | |
| void | SetHiddenInstanceFlags (std::uint32_t flags) |
| Set the instances of a track the frame does not draw, none from Begin(). | |
| void | SetInstanceMatrices (std::function< const float *(int)> matrix) |
| Place the instances of a track at the matrices the race moves them to, the default places from Begin(). | |
| void | SetFog (std::optional< Fog > fog) |
| Set the fog the models of the frame are drawn in, none from Begin(). | |
| void | SetMirrored (bool mirrored) |
| Set whether the models drawn after it are drawn through a projection that mirrors them across, their faces then turning the other way, not from Begin(). | |
| void | SetViewport (std::optional< SDL_Rect > view) |
| Set the rectangle of the frame the draws after it fill, as a view of a split screen fills its part of the screen, the whole frame from Begin(). | |
| void | SetGhost (bool ghost) |
| Set whether the models drawn after it are ghosts, not from Begin(). | |
| void | SetDamage (const CarDamage &damage) |
| Set the damage the damaged images of the models drawn after it show, not from Begin(). | |
| std::shared_ptr< const VertexDisplacement > | CreateDisplacement (std::span< const std::array< float, 3 > > offsets) |
| Upload how far each vertex of a model is moved. | |
| void | SetDisplacement (std::shared_ptr< const VertexDisplacement > displacement) |
| Set how far the vertices of the models drawn after it are moved, those without a pose of a vertex animation and with no more vertices than the displacement, not from Begin(). | |
| void | SetDrawnInOrder (bool inOrder) |
| Set whether the models drawn after it draw their translucent parts straight after their opaque parts, before the next draw, rather than after every opaque draw, not from Begin(). | |
| void | DrawModel (const RenderModel &model, const Matrix4 &world, const Matrix4 &viewProjection, const Lighting &lighting, std::optional< MorphPose > pose, bool depth, std::optional< SDL_Rect > scissor=std::nullopt) |
| Draw a model, its opaque parts now and its translucent ones after every opaque draw. | |
| void | DrawModel (const RenderModel &model, const Matrix4 &world, const Matrix4 &viewProjection, const Lighting &lighting, std::vector< MorphPose > poses, bool depth, std::optional< SDL_Rect > scissor=std::nullopt) |
| Draw a model whose vertices take the sum of the poses of several vertex animations, each moving its own vertices, as the parts of the start lights move. | |
| void | DrawReflectingModel (const RenderModel &model, const Matrix4 &world, const Matrix4 &viewProjection, const Lighting &lighting, const Reflection &reflection, std::optional< SDL_Rect > scissor=std::nullopt) |
| Draw a car whose parts with texture coordinates from their normals and no texture of their own reflect the sky. | |
| void | DrawHighlight (const RenderModel &model, const Matrix4 &world, const Matrix4 &viewProjection, const Highlight &highlight) |
| Draw the specular highlight of a car over the parts drawn before it. | |
| void | DrawShadowedModel (const RenderModel &model, const Matrix4 &world, const Matrix4 &viewProjection, const Lighting &lighting, std::vector< int > instances, std::vector< CarShadow > shadows) |
| Draw instances of a track in an order, with the shadows of cars on the instances near them. | |
| void | DrawQuads (std::span< const FlatVertex > corners, const FlatMaterial &material, const Matrix4 &projection, bool depthTest=false) |
| Draw flat quads over everything drawn before them, blended by their alpha. | |
| void | DrawBufferedQuads (RenderQuadBuffer &buffer, std::span< const std::uint32_t > order, const FlatMaterial &material, const Matrix4 &projection, bool depthTest=false) |
Draw persistent slots in order, using the same material and depth rules as DrawQuads(). | |
| void | End (const std::filesystem::path *capture, const std::function< void(SDL_GPUCommandBuffer *, SDL_GPUTexture *, Uint32, Uint32)> &overlay={}) |
| Draw the frame and present it. | |
| void | RenderInto (SDL_GPUCommandBuffer *commands, SDL_GPUTexture *target, Uint32 width, Uint32 height, bool clear=false) |
| Record draws into a target without submitting the command buffer. | |
Static Public Member Functions | |
| static std::unique_ptr< SceneRenderer > | Create (GpuWindow &window, bool outputOverlay=false) |
| Create the pipelines of the renderer for a window. | |
Friends | |
| class | RenderDocument |
| class | RenderModel |
| class | RenderTexture |
| class | RenderQuadBuffer |
The renderer of a frame.
Begin() starts it, the draws record what it shows, and End() uploads the vertices of the flat draws, draws the frame, and presents it.
| coastline::SceneRenderer::~SceneRenderer | ( | ) |
Release renderer resources before the associated window and GPU device are destroyed.
|
delete |
Prevent copying pipelines, frame targets, and queued draws.
|
static |
Create the pipelines of the renderer for a window.
| window | The window to draw into. |
| outputOverlay | Whether to omit depth and multisampled targets for an output overlay. |
|
delete |
Prevent assignment of pipelines, frame targets, and queued draws.
| GpuWindow & coastline::SceneRenderer::Window | ( | ) |
| void coastline::SceneRenderer::SetFrontendCamera | ( | std::optional< Matrix4 > | view | ) |
| view | Optional eye-space free-camera transform for menus and logos. |
| const std::optional< Matrix4 > & coastline::SceneRenderer::FrontendCamera | ( | ) | const |
| void coastline::SceneRenderer::Begin | ( | std::array< float, 4 > | clear | ) |
Start a frame, cleared to a colour.
| clear | The red, green, blue, and alpha of the clear, from 0 to 1. |
| void coastline::SceneRenderer::SetTextureTime | ( | std::uint32_t | milliseconds | ) |
Set the time the animated textures of the frame show, from 0 at Begin().
| milliseconds | The time, such as the elapsed time of a race. |
| void coastline::SceneRenderer::SetSnow | ( | bool | snow, |
| bool | tint ) |
Set whether the textures of the snow of a track show the snow, false from Begin().
| snow | Whether the race is in the snow. |
| tint | Whether a race in the snow also draws the primitive and environment colours of the snow and holds the animated textures that stay still in the snow on their first frame. |
| void coastline::SceneRenderer::SetHiddenInstanceFlags | ( | std::uint32_t | flags | ) |
Set the instances of a track the frame does not draw, none from Begin().
| flags | The TRACK_INSTANCE_ flags, any of which hides an instance. |
| void coastline::SceneRenderer::SetInstanceMatrices | ( | std::function< const float *(int)> | matrix | ) |
Place the instances of a track at the matrices the race moves them to, the default places from Begin().
| matrix | The 16 values of the matrix of an instance by its number, or none for its place in the model. |
| void coastline::SceneRenderer::SetFog | ( | std::optional< Fog > | fog | ) |
Set the fog the models of the frame are drawn in, none from Begin().
| fog | The fog, or none. |
| void coastline::SceneRenderer::SetMirrored | ( | bool | mirrored | ) |
Set whether the models drawn after it are drawn through a projection that mirrors them across, their faces then turning the other way, not from Begin().
| mirrored | Whether the projection mirrors the frame. |
| void coastline::SceneRenderer::SetViewport | ( | std::optional< SDL_Rect > | view | ) |
Set the rectangle of the frame the draws after it fill, as a view of a split screen fills its part of the screen, the whole frame from Begin().
The draws are cut to the rectangle, and the fog and the hidden instances of each draw are those set when it is made.
| view | The rectangle in pixels, or none for the whole frame. |
| void coastline::SceneRenderer::SetGhost | ( | bool | ghost | ) |
Set whether the models drawn after it are ghosts, not from Begin().
Every part of a ghost is drawn after the opaque draws, its colour by itself added to the frame without writing the depth, as BRD3D draws a ghost.
| ghost | Whether the models are ghosts. |
| void coastline::SceneRenderer::SetDamage | ( | const CarDamage & | damage | ) |
Set the damage the damaged images of the models drawn after it show, not from Begin().
| damage | The levels of damage of the sides of a car. |
| std::shared_ptr< const VertexDisplacement > coastline::SceneRenderer::CreateDisplacement | ( | std::span< const std::array< float, 3 > > | offsets | ) |
Upload how far each vertex of a model is moved.
| offsets | The displacement of each vertex, in the units of the document of the model. |
| void coastline::SceneRenderer::SetDisplacement | ( | std::shared_ptr< const VertexDisplacement > | displacement | ) |
Set how far the vertices of the models drawn after it are moved, those without a pose of a vertex animation and with no more vertices than the displacement, not from Begin().
| displacement | The displacement, or none. |
| void coastline::SceneRenderer::SetDrawnInOrder | ( | bool | inOrder | ) |
Set whether the models drawn after it draw their translucent parts straight after their opaque parts, before the next draw, rather than after every opaque draw, not from Begin().
| inOrder | Whether the models are drawn in order. |
| void coastline::SceneRenderer::DrawModel | ( | const RenderModel & | model, |
| const Matrix4 & | world, | ||
| const Matrix4 & | viewProjection, | ||
| const Lighting & | lighting, | ||
| std::optional< MorphPose > | pose, | ||
| bool | depth, | ||
| std::optional< SDL_Rect > | scissor = std::nullopt ) |
Draw a model, its opaque parts now and its translucent ones after every opaque draw.
| model | The model. |
| world | The place of the model. |
| viewProjection | The camera and its projection, to a depth from 0 to 1. |
| lighting | The lights of the model. |
| pose | The pose of its vertices, or none for the pose of the document. |
| depth | Whether the model tests and writes the depth. |
| scissor | The rectangle of the frame in pixels the model is cut to, or none for the whole frame. |
| void coastline::SceneRenderer::DrawModel | ( | const RenderModel & | model, |
| const Matrix4 & | world, | ||
| const Matrix4 & | viewProjection, | ||
| const Lighting & | lighting, | ||
| std::vector< MorphPose > | poses, | ||
| bool | depth, | ||
| std::optional< SDL_Rect > | scissor = std::nullopt ) |
Draw a model whose vertices take the sum of the poses of several vertex animations, each moving its own vertices, as the parts of the start lights move.
| model | The model. |
| world | The place of the model. |
| viewProjection | The camera and its projection, to a depth from 0 to 1. |
| lighting | The lights of the model. |
| poses | The pose of each animation, the first 64 of them. |
| depth | Whether the model tests and writes the depth. |
| scissor | The rectangle of the frame in pixels the model is cut to, or none for the whole frame. |
| void coastline::SceneRenderer::DrawReflectingModel | ( | const RenderModel & | model, |
| const Matrix4 & | world, | ||
| const Matrix4 & | viewProjection, | ||
| const Lighting & | lighting, | ||
| const Reflection & | reflection, | ||
| std::optional< SDL_Rect > | scissor = std::nullopt ) |
Draw a car whose parts with texture coordinates from their normals and no texture of their own reflect the sky.
| model | The model. |
| world | The place of the model. |
| viewProjection | The camera and its projection, to a depth from 0 to 1. |
| lighting | The lights of the model. |
| reflection | The reflection of the sky. |
| scissor | The rectangle of the frame in pixels the model is cut to, or none for the whole frame. |
| void coastline::SceneRenderer::DrawHighlight | ( | const RenderModel & | model, |
| const Matrix4 & | world, | ||
| const Matrix4 & | viewProjection, | ||
| const Highlight & | highlight ) |
Draw the specular highlight of a car over the parts drawn before it.
| model | The model of the highlighted parts. |
| world | The place of the model. |
| viewProjection | The camera and its projection, to a depth from 0 to 1. |
| highlight | The highlight. |
| void coastline::SceneRenderer::DrawShadowedModel | ( | const RenderModel & | model, |
| const Matrix4 & | world, | ||
| const Matrix4 & | viewProjection, | ||
| const Lighting & | lighting, | ||
| std::vector< int > | instances, | ||
| std::vector< CarShadow > | shadows ) |
Draw instances of a track in an order, with the shadows of cars on the instances near them.
| model | The model of the track. |
| world | The place of the model. |
| viewProjection | The camera and its projection, to a depth from 0 to 1. |
| lighting | The lights of the model. |
| instances | The instances drawn, in their order, with -1 for the nodes of no instance. |
| shadows | The shadows of the cars, laid on an instance one after another in their order, the first MAX_CAR_SHADOWS of those that fall on it. |
| void coastline::SceneRenderer::DrawQuads | ( | std::span< const FlatVertex > | corners, |
| const FlatMaterial & | material, | ||
| const Matrix4 & | projection, | ||
| bool | depthTest = false ) |
Draw flat quads over everything drawn before them, blended by their alpha.
| corners | Four corners for each quad, clockwise from the top left. |
| material | How the quads are coloured. |
| projection | The matrix from the space of the corners to the screen. |
| depthTest | Whether the quads are hidden behind what is nearer, as the puffs of a race are, without writing the depth. |
| void coastline::SceneRenderer::DrawBufferedQuads | ( | RenderQuadBuffer & | buffer, |
| std::span< const std::uint32_t > | order, | ||
| const FlatMaterial & | material, | ||
| const Matrix4 & | projection, | ||
| bool | depthTest = false ) |
Draw persistent slots in order, using the same material and depth rules as DrawQuads().
The buffer must remain valid until End().
| buffer | Quad storage created with this renderer's device. |
| order | The zero-based slots in draw order, copied when this call records the draw. |
| material | The textures and combiner; textures must remain valid through submission. |
| projection | The matrix from corner coordinates into clip space. |
| depthTest | Whether nearer geometry hides quads, without writing depth. |
| void coastline::SceneRenderer::End | ( | const std::filesystem::path * | capture, |
| const std::function< void(SDL_GPUCommandBuffer *, SDL_GPUTexture *, Uint32, Uint32)> & | overlay = {} ) |
Draw the frame and present it.
| capture | A PNG file to write the frame to, or null. |
| overlay | Optional draws at output resolution after presentation filters. |
| void coastline::SceneRenderer::RenderInto | ( | SDL_GPUCommandBuffer * | commands, |
| SDL_GPUTexture * | target, | ||
| Uint32 | width, | ||
| Uint32 | height, | ||
| bool | clear = false ) |
Record draws into a target without submitting the command buffer.
| commands | The acquired command buffer; the caller submits it after this call. |
| target | The colour target, compatible with GpuWindow::FrameFormat(). |
| width | The positive target width in pixels. |
| height | The positive target height in pixels. |
| clear | Whether to clear the target to Begin()'s colour instead of preserving pixels. |
|
friend |
|
friend |
|
friend |
|
friend |