Manual exposure: the source
Open the live demo · Read the guide · View on GitHub
Regions the guide quotes: scene (line 23), settings (line 46), check (line 62).
1/// `RenderSettings.exposure`: the linear multiplier the composite applies
2/// before the tone curve, set by hand rather than metered.
3///
4/// Quoted by `exposure.md` and shown whole in the Source tab.
5library;
7import 'package:flutter3d/flutter3d.dart';
8import 'package:flutter3d_showcase/src/demo/demo.dart';
9import 'package:vector_math/vector_math.dart';
11final class ExposureDemo extends ShowcaseDemo {
12 double exposure = 2.4;
15 void configureView(DemoContext context) {
16 context.orbit
17 ..distance = 5.0
18 ..pitch = 0.1;
19 }
22 Scene build(DemoContext context) {
23 final Material lantern = Material(
24 name: 'lantern',
25 baseColor: Vector4(0.9, 0.85, 0.6, 1.0),
26 emissive: Vector3(2.0, 1.7, 0.9),
27 );
28 final MeshNode box = MeshNode(
29 DeviceMesh.upload(
30 context.device,
31 CuboidShape(size: Vector3(1.4, 1.4, 1.4)).build(),
32 ),
33 lantern,
34 name: 'lantern',
35 );
36 return Scene()
37 ..add(box)
38 ..add(
39 LightNode(name: 'sun', intensity: 1.5)
40 ..setLocalForward(Vector3(-0.3, -0.6, -0.7)),
41 );
42 }
45 RenderSettings settings(DemoContext context) => RenderSettings(
46 exposure: exposure,
47 );
50 List<DemoControl> controls(DemoContext context) => <DemoControl>[
51 SliderControl(
52 'Exposure',
53 min: 0.1,
54 max: 4,
55 value: () => exposure,
56 onChanged: (double v) => exposure = v,
57 ),
58 ];
61 void verify(Scene scene, FrameResult frame) {
62 if ((frame.exposure - exposure).abs() > 1e-6) {
63 throw StateError(
64 'the frame was composited at ${frame.exposure}, not the '
65 '$exposure this page asked for',
66 );
67 }
68 if (frame.drawCalls < 1) {
69 throw StateError('the lantern was not drawn');
70 }
71 }
72}