Jazz2::Rendering::UpscaleRenderPass class

Upscales input image usually to a native resolution.

Final output pass that renders the low-resolution scene through a rescale shader to the native output resolution, optionally routing it through an AntialiasingSubpass. Exposes the input scene node that the rest of the rendering attaches to.

Base classes

class nCine::SceneNode
Base node of the scene graph transformation hierarchy.

Derived classes

class UpscaleRenderPassWithClipping
Upscales input image usually to a native resolution, additionaly supports 3 independent layers (background layer, clipped main layer, overlay layer).

Public static functions

static auto CalculateViewSize(std::int32_t targetWidth, std::int32_t targetHeight, std::int32_t defaultWidth, std::int32_t defaultHeight) -> Vector2i
Returns the logical view size for a target (drawable) of the given size.

Constructors, destructors, conversion operators

UpscaleRenderPass()
Creates a new instance.

Public functions

void Initialize(std::int32_t width, std::int32_t height, std::int32_t targetWidth, std::int32_t targetHeight, std::int32_t supersample = 1, bool overlay = false) virtual
Initializes the render pass.
void Register() virtual
Registers the render pass into the viewport chain.
auto OnDraw(RenderQueue& renderQueue) -> bool override
Called when the node needs to be drawn, returning true if a command was added.
auto GetNode() const -> SceneNode*
Returns the input scene node.
auto GetViewSize() const -> Vector2i
Returns size of the input image (the logical coordinate space, not the supersampled texture).
auto GetTargetSize() const -> Vector2f
Returns size of the upscaled target image.
auto GetSupersample() const -> std::int32_t
Returns the render-resolution multiplier the pass actually applied (1 if not supersampled).

Protected types

class AntialiasingSubpass
Optional antialiasing subpass.

Constants

static std::int32_t DefaultViewWidth constexpr
Upper bound of the logical view, which every handler's own DefaultWidth/DefaultHeight is.
static std::int32_t DefaultViewHeight constexpr
static std::int32_t ReferenceViewHeight constexpr
Height of the 16:9 view every screen in the game was laid out against.

Function documentation

static Vector2i Jazz2::Rendering::UpscaleRenderPass::CalculateViewSize(std::int32_t targetWidth, std::int32_t targetHeight, std::int32_t defaultWidth, std::int32_t defaultHeight)

Returns the logical view size for a target (drawable) of the given size.

The default size is the upper bound of the view - a smaller target gets a view of its own size, a larger one is aspect-fitted into the bound. The bound is scaled by PreferencesCache::RenderingResolutionPercent, which is what makes the preference the most the scene (and everything drawn in the same coordinate space) is rendered at. Every handler that owns an upscale pass lays itself out through this, so the menu's view is the same size the level's will be, and the lighting buffer (a fraction of the viewport, see PlayerViewport) follows it.

void Jazz2::Rendering::UpscaleRenderPass::Initialize(std::int32_t width, std::int32_t height, std::int32_t targetWidth, std::int32_t targetHeight, std::int32_t supersample = 1, bool overlay = false) virtual

Initializes the render pass.

Parameters
width Width of the input image
height Height of the input image
targetWidth Width of the upscaled target image
targetHeight Height of the upscaled target image
supersample Render-resolution multiplier for the input image (1 = native); the scene is still drawn in width×height coordinates, but rasterized into a supersample× larger texture
overlay If true, renders an RGBA layer at native resolution (transparent where nothing is drawn) and composites it alpha-blended on top of everything else; used for the HUD so it stays crisp regardless of the scene's supersampling

std::int32_t Jazz2::Rendering::UpscaleRenderPass::GetSupersample() const

Returns the render-resolution multiplier the pass actually applied (1 if not supersampled).

Not necessarily the value requested in Initialize() - supersampling is refused on the direct tier (no framebuffers) and on Vita, so callers that adapt to it must ask the pass, not assume.

Variable documentation

static std::int32_t Jazz2::Rendering::UpscaleRenderPass::DefaultViewWidth constexpr

Upper bound of the logical view, which every handler's own DefaultWidth/DefaultHeight is.

720x405 is a 16:9 box, which is the shape of every display the game runs on except the televisions. Those are 4:3, and there the bound is what decides whether the view is rendered at something close to the panel's own resolution or at something much smaller that the hardware then stretches: a 4:3 display fits a 405-line view as 540x405, which a 480-line framebuffer then upscales by a sixth. 640x480 lets the fit reach the panel instead - 640x480 on an NTSC Dreamcast, Wii and GameCube, and 597x448 on the PlayStation 2, whose 448 lines cap the height - so on those modes the vertical mapping is 1:1 and the sprites are drawn at the size they are shown at.

"On those modes" is the caveat: the numbers here are the NTSC ones. A console running a 50 Hz PAL mode renders taller - libogc's TVPal528IntDf is 640x528 - and the fit still returns 640x480 there, because the view's width is bounded by the framebuffer's 640 columns and its height then follows from the 4:3 display aspect. That leaves a 1.1x vertical upscale on the way out. It is a deliberate trade rather than an oversight: the alternative is a 704x528 view, which would map 1:1 vertically but has to be squeezed horizontally into the same 640 columns, costing more fill and a softer picture for the same geometry. Shapes are correct either way - that is what IGfxDevice::displayAspect() guarantees - and only the resampling differs.

It costs fill rate in proportion: about 1.2x the pixels on the PlayStation 2 and 1.4x on the other three, which PreferencesCache::RenderingResolutionPercent scales back down for anyone who would rather have the frame rate.

Only the 4:3 consoles are listed. A widescreen Wii is unaffected either way (its view is bounded by the framebuffer's 640 columns, not by this, and comes out 640x360 whichever bound is in force), and every remaining console already has a panel shorter than 405 lines - the Nintendo 64, the 3DS and the PSP all render 1:1 as they are.

static std::int32_t Jazz2::Rendering::UpscaleRenderPass::ReferenceViewHeight constexpr

Height of the 16:9 view every screen in the game was laid out against.

The same as DefaultViewHeight everywhere except the 4:3 televisions, which render taller than that - so anything drawn at a fixed pixel size (rather than as a fraction of the view) leaves the difference as bare background there. A layout that has to make up that difference measures it against this, not against the bound, which on those consoles is the taller number.