Skip to main content

View

A View encompasses all the state needed for rendering a Scene.

Overview

The View specifies:
  • The Scene to render
  • The Camera viewpoint
  • The Viewport rectangle
  • Rendering parameters (shadows, post-processing, etc.)
View instances are heavy objects that cache rendering data. Avoid using many View objects.

Creation and destruction

Create using Engine::createView() and destroy using Engine::destroy():
#include <filament/View.h>
#include <filament/Engine.h>
using namespace filament;

Engine* engine = Engine::create();

View* view = engine->createView();
// ... configure and use view ...
engine->destroy(view);

Basic configuration

Set scene and camera

Scene* scene = engine->createScene();
Camera* camera = engine->createCamera(entity);

view->setScene(scene);
view->setCamera(camera);

Set viewport

viewport
Viewport
Rectangular region to render into
Viewport viewport(0, 0, 1920, 1080);
view->setViewport(viewport);

Set render target

By default, the view renders to the swap chain. Set a custom render target for off-screen rendering:
RenderTarget* rt = RenderTarget::Builder()
    .texture(RenderTarget::AttachmentPoint::COLOR, colorTexture)
    .texture(RenderTarget::AttachmentPoint::DEPTH, depthTexture)
    .build(*engine);

view->setRenderTarget(rt);

Rendering quality

Anti-aliasing

// FXAA (fast, low quality)
view->setAntiAliasing(View::AntiAliasing::FXAA);

// TAA (high quality, requires motion vectors)
View::TemporalAntiAliasingOptions taa;
taa.enabled = true;
taa.filterWidth = 1.0f;
taa.feedback = 0.04f;
view->setTemporalAntiAliasingOptions(taa);
view->setAntiAliasing(View::AntiAliasing::TAA);

// MSAA (highest quality, expensive)
View::MultiSampleAntiAliasingOptions msaa;
msaa.enabled = true;
msaa.sampleCount = 4;  // 4x MSAA
view->setMultiSampleAntiAliasingOptions(msaa);

Tone mapping

#include <filament/ToneMapper.h>

// ACES tone mapper
view->setToneMapping(View::ToneMapping::ACES);

// PBR Neutral
view->setToneMapping(View::ToneMapping::PBR_NEUTRAL);

// Custom tone mapper
ToneMapper* tm = new GenericToneMapper(/* params */);
view->setToneMapper(tm);

Color grading

ColorGrading* cg = ColorGrading::Builder()
    .quality(ColorGrading::QualityLevel::HIGH)
    .exposure(0.0f)
    .nightAdaptation(0.0f)
    .whiteBalance(6500.0f, 0.0f)
    .channelMixer({1,0,0}, {0,1,0}, {0,0,1})
    .contrast(1.0f)
    .saturation(1.0f)
    .build(*engine);

view->setColorGrading(cg);

Post-processing effects

Bloom

View::BloomOptions bloom;
bloom.enabled = true;
bloom.levels = 6;
bloom.resolution = 360;       // Resolution of first level
bloom.strength = 0.1f;
bloom.threshold = true;       // Threshold mode
bloom.dirt = dirtTexture;     // Lens dirt texture

view->setBloomOptions(bloom);

Depth of field

View::DepthOfFieldOptions dof;
dof.enabled = true;
dof.focusDistance = 10.0f;    // Focus at 10 meters
dof.blurScale = 1.0f;
dof.maxApertureDiameter = 0.01f;
dof.filter = View::DepthOfFieldOptions::Filter::MEDIAN;

view->setDepthOfFieldOptions(dof);

Vignette

View::VignetteOptions vignette;
vignette.enabled = true;
vignette.midPoint = 0.5f;
vignette.roundness = 0.5f;
vignette.feather = 0.5f;
vignette.color = {0, 0, 0, 1};

view->setVignetteOptions(vignette);

Shadow configuration

// Shadow type
view->setShadowType(View::ShadowType::VSM);

// VSM shadow options
View::VsmShadowOptions vsm;
vsm.anisotropy = 0;
vsm.mipmapping = false;
vsm.minVarianceScale = 0.5f;
vsm.lightBleedReduction = 0.15f;

view->setVsmShadowOptions(vsm);

// Soft shadows (PCSS/DPCF)
View::SoftShadowOptions soft;
soft.penumbraScale = 1.0f;
soft.penumbraRatioScale = 1.0f;

view->setSoftShadowOptions(soft);

Ambient occlusion

View::AmbientOcclusionOptions ssao;
ssao.enabled = true;
ssao.radius = 0.3f;           // AO radius in meters
ssao.power = 1.0f;
ssao.bias = 0.0005f;
ssao.resolution = 0.5f;       // Half resolution
ssao.intensity = 1.0f;
ssao.bilateralThreshold = 0.05f;
ssao.quality = View::QualityLevel::HIGH;
ssao.lowPassFilter = View::QualityLevel::MEDIUM;
ssao.upsampling = View::QualityLevel::HIGH;
ssao.minHorizonAngleRad = 0.0f;
ssao.ssct.enabled = false;    // Screen-space cone tracing

view->setAmbientOcclusionOptions(ssao);

Screen-space reflections

View::ScreenSpaceReflectionsOptions ssr;
ssr.enabled = true;
ssr.thickness = 0.1f;         // Surface thickness
ssr.bias = 0.01f;
ssr.maxDistance = 3.0f;       // Max ray distance
ssr.stride = 2.0f;

view->setScreenSpaceReflectionsOptions(ssr);

Dynamic resolution

Automatically adjust rendering resolution to maintain target frame rate:
View::DynamicResolutionOptions dr;
dr.enabled = true;
dr.minScale = {0.5f, 0.5f};   // Min 50% scale
dr.maxScale = {1.0f, 1.0f};   // Max 100% scale
dr.quality = View::QualityLevel::MEDIUM;
dr.homogeneousScaling = false; // Allow non-uniform scaling

view->setDynamicResolutionOptions(dr);

Fog

View::FogOptions fog;
fog.enabled = true;
fog.distance = 50.0f;         // Fog starts at 50m
fog.maximumOpacity = 1.0f;
fog.height = 0.0f;            // Ground level
fog.heightFalloff = 1.0f;
fog.color = {0.5f, 0.6f, 0.7f};
fog.density = 0.1f;
fog.inScatteringStart = 0.0f;
fog.inScatteringSize = -1.0f; // Disabled
fog.fogColorFromIbl = false;

view->setFogOptions(fog);

Blend mode

Control how the view blends with the render target:
// Opaque (default)
view->setBlendMode(View::BlendMode::OPAQUE);

// Translucent (blend with clear color)
view->setBlendMode(View::BlendMode::TRANSLUCENT);

Visibility masks

Control which renderables are visible using layers:
// Set visible layers (8 layers: 0-7)
view->setVisibleLayers(0xFF, 0x01);  // Select layers

Post-processing enabled

Disable all post-processing:
view->setPostProcessingEnabled(false);

Sample count

Set MSAA sample count:
view->setSampleCount(4);  // 4x MSAA

Stereoscopic rendering

For VR/AR rendering:
View::StereoscopicOptions stereo;
stereo.enabled = true;

view->setStereoscopicOptions(stereo);

Camera

Camera configuration

Scene

Entity container

Post-processing

Learn about effects

Shadows

Shadow configuration

Build docs developers (and LLMs) love