---
title: "Lower 3D render resolution without blurring game UI in C#"
url: https://recursiveai.org/onegame/cookbook/lower-3d-render-scale-keep-ui-sharp/
description: "Lower the 3D render resolution in OneGame without scaling the HUD. Render the scene at half width and height while keeping UI and input in window pixels."
version: "2.5.3"
---

Set `view.RenderScale = 0.5f` to halve the 3D width and height. The HUD still draws at window size.

```shell
dotnet add package RecursiveAI.OneGame.Host
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using OneGame.Host;

using var view = new SceneView3D();
view.RenderScale = 0.5f;
System.Console.WriteLine(view.RenderScale);
```

Sets half width and height on the view you pass to `Render3DStage`. Prints `0.5`. The full program below renders the 3D scene at 160 × 90 and captures the frame with UI at 320 × 180.

Unzip [the example](https://recursiveai.org/onegame/cookbook/lower-3d-render-scale-keep-ui-sharp/lower-3d-render-scale-keep-ui-sharp.zip), then `dotnet run`.

## Full program

If you copy the full program instead of using the zip, put `NotoSans-Regular.ttf` beside `Program.cs` and run from that folder. The zip includes this font for the host’s UI renderer. The scene geometry is one orange triangle, and the HUD is a white 16 × 16 pixel square at (8, 8). The program opens no window.

On Linux and Windows, the full program needs a working Vulkan driver. On Linux with no Vulkan driver available, OneGame 2.5.3 stopped before rendering with `GpuUnsupportedException: vkCreateInstance failed: ErrorIncompatibleDriver`.

```csharp
using System.Numerics;
using OneGame.Core;
using OneGame.Host;
using OneGame.Render3D;
using OneGame.UI;

using var definition = new ScaleGame();
using var game = GameInstance.Create(definition, new GameOptions
{
    Headless = true,
    Gpu = GpuMode.Required
});
const int width = 320, height = 180;
var full = game.Capture(width, height);
definition.View.RenderScale = 0.5f;
var half = game.Capture(width, height);
var stats = definition.Stats;
Console.WriteLine($"3D scene: {stats.RenderWidth} x {stats.RenderHeight}");
Console.WriteLine($"Frame with UI: {half.Width} x {half.Height}");
// The 16 x 16 HUD square sits over a flat area in both captures.
var identicalHud = Enumerable.Range(8, 16).All(y =>
{
    int start = (y * width + 8) * 4;
    return full.Rgba.AsSpan(start, 16 * 4).SequenceEqual(half.Rgba.AsSpan(start, 16 * 4));
});
var marker = (12 * width + 12) * 4;
Console.WriteLine($"HUD square white and unchanged: {identicalHud && half.Rgba[marker] == 255}");
Console.WriteLine($"Frame pixels changed: {!full.Rgba.SequenceEqual(half.Rgba)}");

sealed class ScaleGame : GameDefinition, IDisposable
{
    private Renderer3D renderer = null!;
    public SceneView3D View { get; } = new();
    public FrameStats3D Stats => renderer.LastStats;
    public override string Name => "Render scale example";
    public override void RegisterEntities(EntityRegistry registry) { }
    public override void Setup(World world) { }
    public override void DefineFonts(OneGame.Text.FontLibrary fonts) =>
        fonts.Add(File.ReadAllBytes("NotoSans-Regular.ttf"));

    public override void DefineScreens(ScreenSet screens) => screens.Add("main", _ =>
        Ui.Box().Style(s => s.Position(PositionMode.Absolute).Left(8).Top(8)
            .Size(16, 16).Background(Color.White)));

    public override IRenderStage CreateRenderStage(HostResources resources)
    {
        View.Describer = (_, writer) => writer.Model("triangle", Matrix4x4.Identity);
        return new Stage(resources, View, value => renderer = value);
    }

    public void Dispose() => View.Dispose();

    private sealed class Stage(HostResources resources, SceneView3D view, Action<Renderer3D> created)
        : Render3DStage(resources, view)
    {
        protected override void RendererCreated(Renderer3D renderer)
        {
            var material = renderer.CreateMaterial("orange", doubleSided: true,
                baseColor: new Vector4(1, 0.2f, 0.05f, 1));
            material.Style = MaterialStyle3D.Flat;
            View!.Models.SetMesh("triangle", material,
                [new(new(-2, 0, 0), Vector3.UnitZ, Vector2.Zero),
                 new(new(2, 0, 0), Vector3.UnitZ, Vector2.UnitX),
                 new(new(0, 3, 0), Vector3.UnitZ, Vector2.UnitY)], [0, 1, 2]);
            created(renderer);
        }

        protected override void UpdateScene(Scene3D scene, in FrameInfo frame)
        {
            scene.Camera = Camera3D.LookAt(new(0, 1.5f, 7), new(0, 1.5f, 0), Vector3.UnitY);
            scene.Environment.Background = BackgroundMode.Color;
            scene.Environment.BackgroundColor = new(0.02f, 0.03f, 0.05f);
            scene.Post.Bloom = false;
            scene.Post.ToneMapper = ToneMapper.None;
            scene.Samples = 1;
        }
    }
}
```

```text
3D scene: 160 x 90
Frame with UI: 320 x 180
HUD square white and unchanged: True
Frame pixels changed: True
```

If the HUD blurs in a custom render stage, check that the HUD is drawn into the final target after the 3D upscale, not into the smaller scene image.

## Variations

For a less aggressive scale, replace `0.5f` in the full program with:

```csharp
definition.View.RenderScale = 0.75f;
```

At the same 320 × 180 target this gives a 240 × 135 scene. Use `1f` to draw the scene at the full target size without an upscale pass.

## Related recipes

- [Build a game UI screen in C#](https://recursiveai.org/onegame/cookbook/game-ui-screen/)
- [Measure CPU and GPU frame time](https://recursiveai.org/onegame/cookbook/measure-cpu-and-gpu-frame-time/)

## The short answer

Set `SceneView3D.RenderScale` on the view your `Render3DStage` uses. A value of `0.5f` halves the width and height of the rendered 3D image, not the window. The stage draws 2D and UI over the full-size result, so you don’t have to change your HUD layout. If you manage a `Scene3D` directly without a view, set `Scene3D.RenderScale` and draw 2D and UI after the 3D pass has returned the image to target size.

## What is render resolution in games?

Render resolution is the size of the image the 3D renderer produces. It can differ from output resolution, the size of the final frame. A 1920 × 1080 window with a scale of `0.5f` uses a 960 × 540 3D image, which is one quarter of the original pixel count. The screen still receives a 1920 × 1080 frame. The 3D image has fewer pixels to describe its edges, so enlarging it can make those edges look softer. The HUD does not share that image.

OneGame rounds the scaled dimensions to whole pixels and keeps the camera’s aspect ratio based on the target. The renderer uses values from `0.25f` to `1f`; below `0.25f` it uses `0.25f`, and above `1f` or for `NaN` it uses full size. Sub-full-size frames use bilinear filtering when the renderer stretches the tone-mapped 3D image to the target. Check what was actually drawn with `FrameStats3D.RenderWidth` and `RenderHeight` after rendering.

## How do you lower the 3D resolution without scaling the HUD?

Keep the target at window size and change only the 3D view. The standard stage handles the order: render the world, enlarge it, then draw interface elements over it. A name tag painted on a mesh is part of the 3D scene and scales with it. A label drawn as UI is a separate layer; you can anchor it to a world position without drawing it into the scaled image.

Use the original target dimensions when projecting world positions or turning a pointer location into a picking ray. `SceneView3D.TryProject`, `Ray`, and `Pick` already work in target pixels. Multiplying the cursor by the render scale would feed them the wrong coordinates. Widths defined inside the 3D pass are different: a two-pixel 3D outline at half scale covers about four output pixels after the upscale. Adjust the outline in the renderer if that change matters to your game.
