Colour grade: the source
Open the live demo · Read the guide · View on GitHub
Regions the guide quotes: whole (line 31), ranges (line 34), lens (line 36).
1/// A colour grade: contrast, saturation and warmth for the whole picture, a tint
2/// for the shadows and another for the highlights, and the marks a lens leaves.
3///
4/// Quoted by `color_grading.md` and shown whole in the Source tab.
5library;
7import 'package:flutter3d/flutter3d.dart';
8import 'package:flutter3d_showcase/pages/post/post_stage.dart';
9import 'package:flutter3d_showcase/src/demo/demo.dart';
10import 'package:vector_math/vector_math.dart';
12final class ColorGradingDemo extends ShowcaseDemo {
13 double contrast = 1.15;
14 double saturation = 1.2;
15 double temperature = 0.15;
16 double coolShadows = 0.03;
17 double warmHighlights = 0.15;
18 double vignette = 0.45;
19 double grain = 0.03;
20 double aberration = 0.004;
23 void configureView(DemoContext context) => PostStage.frame(context);
26 Scene build(DemoContext context) => PostStage.build(context).scene;
29 RenderSettings settings(DemoContext context) => RenderSettings(
30 look: LookSettings(
31 contrast: contrast,
32 saturation: saturation,
33 temperature: temperature,
34 lift: Vector3(0.0, 0.0, coolShadows),
35 gain: Vector3(1.0 + warmHighlights, 1.0 + warmHighlights * 0.4, 1.0),
36 vignette: vignette,
37 grain: grain,
38 chromaticAberration: aberration,
39 ),
40 );
43 List<DemoControl> controls(DemoContext context) => <DemoControl>[
44 SliderControl(
45 'Contrast',
46 min: 0.5,
47 max: 1.8,
48 value: () => contrast,
49 onChanged: (double v) => contrast = v,
50 ),
51 SliderControl(
52 'Saturation',
53 min: 0,
54 max: 2,
55 value: () => saturation,
56 onChanged: (double v) => saturation = v,
57 ),
58 SliderControl(
59 'Temperature',
60 min: -1,
61 max: 1,
62 value: () => temperature,
63 onChanged: (double v) => temperature = v,
64 ),
65 SliderControl(
66 'Cool shadows',
67 min: 0,
68 max: 0.15,
69 value: () => coolShadows,
70 onChanged: (double v) => coolShadows = v,
71 ),
72 SliderControl(
73 'Warm highlights',
74 min: 0,
75 max: 0.5,
76 value: () => warmHighlights,
77 onChanged: (double v) => warmHighlights = v,
78 ),
79 SliderControl(
80 'Vignette',
81 min: 0,
82 max: 1,
83 value: () => vignette,
84 onChanged: (double v) => vignette = v,
85 ),
86 SliderControl(
87 'Grain',
88 min: 0,
89 max: 0.1,
90 value: () => grain,
91 onChanged: (double v) => grain = v,
92 ),
93 SliderControl(
94 'Colour fringe',
95 min: 0,
96 max: 0.015,
97 value: () => aberration,
98 onChanged: (double v) => aberration = v,
99 format: (double v) => v.toStringAsFixed(3),
100 ),
101 ];
104 void verify(Scene scene, FrameResult frame) {
105 if (!passRan(frame, 'composite')) {
106 throw StateError('the composite pass, which grades the frame, is absent');
107 }
108 }
109}