Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
chart_shader_presets.hpp
Go to the documentation of this file.
1#pragma once
2
3// Named chart-shader presets: ready-made `half4 shade(PulpChart g)` sources for
4// the bevelled caps, inset tracks, tubes and LED light pipes audio UIs are
5// built from. Each preset is ordinary SkSL fed to the existing chart API —
6// `Canvas::draw_sdf_shape_with_shader` in C++, `setWidgetShaderChart` or
7// `setWidgetShaderChartPreset` from JS — so it works on every charted shape
8// (flat arc, ring, flat and rounded segment, stadium) and can be copied and
9// edited like hand-written source.
10//
11// Shading reads the chart's cross-section: `u = cross / halfWidth` runs from
12// -1 to +1 across the band, a height profile over `u` gives a surface normal
13// along the chart normal (tan.y, -tan.x), and a directional light is applied
14// with Lambert diffuse and Blinn-Phong specular. Colours are decoded from sRGB
15// to linear before any lighting arithmetic and encoded back afterwards, and a
16// flat face facing the viewer reproduces the authored colour exactly.
17
19
20#include <string>
21#include <string_view>
22#include <vector>
23
24namespace pulp::view {
25
32
35inline constexpr float kChartGlowSigmaMax = 256.0f;
36
64
67 std::string sksl;
71 float reach = 0.0f;
73 std::string error;
74};
75
78const std::vector<std::string>& chart_shader_preset_names();
79
85 const ChartShaderPresetOptions& options = {});
86
90float chart_glow_reach(float sigma, float intensity);
91
93bool parse_chart_profile(std::string_view name, ChartProfile& out);
94
95} // namespace pulp::view
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
constexpr float kChartGlowSigmaMax
Largest accepted glow_sigma.
Definition chart_shader_presets.hpp:35
const std::vector< std::string > & chart_shader_preset_names()
The preset names: bevel, inset-channel, tube, light-pipe, centre-highlight and glow.
bool parse_chart_profile(std::string_view name, ChartProfile &out)
Parse a profile name (round, flat, chamfer).
ChartProfile
Cross-section of a tube or light pipe across its band.
Definition chart_shader_presets.hpp:27
@ flat
a flat face with a narrow rounded rim at each edge
Definition chart_shader_presets.hpp:29
@ chamfer
a flat centre with 45 degree chamfers on the outer 40%
Definition chart_shader_presets.hpp:30
@ round
a cylinder: the normal turns smoothly from edge to edge
Definition chart_shader_presets.hpp:28
ChartShaderPreset make_chart_shader_preset(std::string_view name, const ChartShaderPresetOptions &options={})
Build the named preset's chart shader with options baked in as constants.
float chart_glow_reach(float sigma, float intensity)
Distance past which a glow of sigma and intensity is below one 8-bit step (intensity * exp(-r^2 / (2 ...
Definition canvas.hpp:52
static constexpr Color rgba8(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Construct from 8-bit channels [0,255] — convenience for legacy/hex code.
Definition canvas.hpp:61
Definition chart_shader_presets.hpp:37
float light_elevation_deg
Height of the light above the surface, 0 (grazing) to 90 (overhead).
Definition chart_shader_presets.hpp:50
canvas::Color accent
Emissive colour (sRGB) for light-pipe, glow and the highlight of centre-highlight.
Definition chart_shader_presets.hpp:43
float bevel_width
Fraction of the half width the bevel or channel wall occupies, (0, 1].
Definition chart_shader_presets.hpp:57
float glow_sigma
glow: Gaussian falloff outside the band, in local units, from 0 to kChartGlowSigmaMax.
Definition chart_shader_presets.hpp:62
ChartProfile profile
Cross-section for tube and light-pipe.
Definition chart_shader_presets.hpp:55
float intensity
Strength of the highlight, specular or glow, >= 0. Zero removes it.
Definition chart_shader_presets.hpp:59
canvas::Color color
Material colour (sRGB) for bevel, inset-channel, tube and the base of centre-highlight.
Definition chart_shader_presets.hpp:40
bool pressed
bevel only: a pressed bevel sinks instead of rising, which reverses which edge catches the light.
Definition chart_shader_presets.hpp:53
float light_angle_deg
Direction the light comes from, in screen degrees counter-clockwise from the right: 90 is from above,...
Definition chart_shader_presets.hpp:48
Definition chart_shader_presets.hpp:65
std::string sksl
SkSL defining half4 shade(PulpChart g); empty when refused.
Definition chart_shader_presets.hpp:67
float reach
Draw-rect reach the preset needs on every side: for glow, whose light lives outside the band,...
Definition chart_shader_presets.hpp:71
std::string error
Why the request was refused; empty on success.
Definition chart_shader_presets.hpp:73