Loading...
Searching...
No Matches
ShaderLibrary.h
Go to the documentation of this file.
1//
2// ShaderLibrary.h
3//
4
5#ifndef SHADERLIBRARY_H
6#define SHADERLIBRARY_H
7
8#include <string_view>
9#include <SFML/Graphics.hpp>
10#include <functional>
11
12namespace ml
13{
50 {
51 public:
60 struct Params
61 {
62 // ── Position / center ────────────────────────────────────────────
63 float centerX = 0.5f;
64 float centerY = 0.5f;
65
66 // ── Scale ────────────────────────────────────────────────────────
67 float minScale = 0.6f;
68 float maxScale = 1.5f;
69 float scaleWidth = 0.3f;
70
71 // ── Blur ─────────────────────────────────────────────────────────
72 float blurAmount = 2.0f;
73 float focusWidth = 0.2f;
74
75 // ── Color ─────────────────────────────────────────────────────────
76 sf::Glsl::Vec3 tintColor = {1.0f, 0.8f, 0.6f};
77 sf::Glsl::Vec3 glowColor = {1.0f, 1.0f, 0.8f};
78 float tintStrength = 0.3f;
79 float glowStrength = 0.3f;
80
81 // ── Fade / vignette ───────────────────────────────────────────────
82 float fadeWidth = 50.0f;
83 float strength = 0.5f;
84 float radius = 0.8f;
85
86 // ── 3D / perspective ──────────────────────────────────────────────
87 float perspective = 0.8f;
88 float rotationAngle = 0.5f;
89 float skewAmount = 0.3f;
90
91 // ── Animation ─────────────────────────────────────────────────────
92 float time = 0.0f;
93 float amplitude = 0.02f;
94 float frequency = 10.0f;
95 float pulseSpeed = 2.0f;
96 float pulseAmount = 0.05f;
97
98 // ── Miscellaneous ─────────────────────────────────────────────────
99 float parallaxStrength = 0.1f;
100 float reflectionHeight = 0.5f;
101 float reflectionAlpha = 0.4f;
102 float colorWidth = 0.25f;
103 float intensity = 0.8f;
104 float glowWidth = 0.3f;
105
106 // ── Auto-updated by Carousel ──────────────────────────────────────
107 sf::Vector2f textureSize = {720.0f, 480.0f};
108 float totalWidth = 720.0f;
109 };
110
156
157 // ── GLSL source getters ───────────────────────────────────────────────
158
160 static std::string_view fadeEdges();
162 static std::string_view scaleCenter();
164 static std::string_view blurUnfocused();
166 static std::string_view coverflow3D();
168 static std::string_view colorTint();
170 static std::string_view waveDistortion();
172 static std::string_view depthOfField();
174 static std::string_view vignette();
176 static std::string_view grayscaleEdges();
178 static std::string_view reflection();
180 static std::string_view rotation3D();
182 static std::string_view parallax();
184 static std::string_view glowCenter();
186 static std::string_view slideAngle();
188 static std::string_view sepiaTone();
190 static std::string_view zoomPulse();
191
202 static void applyUniforms(sf::Shader& shader, Style style, const Params& params);
203 };
204
205} // namespace ml
206
207#endif // SHADERLIBRARY_H
Built-in GLSL shaders and uniform parameters for Carousel effects.
static std::string_view parallax()
Return the GLSL source for the PARALLAX style.
static std::string_view blurUnfocused()
Return the GLSL source for the BLUR_UNFOCUSED style.
static std::string_view glowCenter()
Return the GLSL source for the GLOW_CENTER style.
static void applyUniforms(sf::Shader &shader, Style style, const Params &params)
Push the appropriate Params fields as uniforms to shader.
static std::string_view zoomPulse()
Return the GLSL source for the ZOOM_PULSE style.
static std::string_view reflection()
Return the GLSL source for the REFLECTION style.
static std::string_view grayscaleEdges()
Return the GLSL source for the GRAYSCALE_EDGES style.
static std::string_view rotation3D()
Return the GLSL source for the ROTATION_3D style.
static std::string_view coverflow3D()
Return the GLSL source for the COVERFLOW_3D style.
static std::string_view waveDistortion()
Return the GLSL source for the WAVE_DISTORTION style.
static std::string_view depthOfField()
Return the GLSL source for the DEPTH_OF_FIELD style.
static std::string_view sepiaTone()
Return the GLSL source for the SEPIA_TONE style.
static std::string_view vignette()
Return the GLSL source for the VIGNETTE style.
static std::string_view slideAngle()
Return the GLSL source for the SLIDE_ANGLE style.
Style
Available built-in visual styles.
static std::string_view fadeEdges()
Return the GLSL source for the FADE_EDGES style.
static std::string_view colorTint()
Return the GLSL source for the COLOR_TINT style.
static std::string_view scaleCenter()
Return the GLSL source for the SCALE_CENTER style.
Definition Component.h:18
Vector3< float > Vec3
Vector2< float > Vector2f
All uniform parameters shared across the built-in shaders.
float intensity
General intensity multiplier.
float glowStrength
Glow intensity factor.
float blurAmount
Blur radius in pixels for unfocused items.
float fadeWidth
Edge fade width in pixels.
float parallaxStrength
Parallax scroll factor.
float tintStrength
Tint blend factor (0 = no tint, 1 = full).
float focusWidth
Normalized width of the in-focus zone.
float totalWidth
Total carousel width in pixels.
float reflectionHeight
Reflection zone height (normalized).
float time
Elapsed time in seconds (updated per frame).
float minScale
Minimum scale applied to off-center items.
sf::Glsl::Vec3 tintColor
RGB tint color.
float amplitude
Wave distortion amplitude (normalized).
float strength
General effect strength multiplier.
float pulseAmount
Pulse scale magnitude.
float colorWidth
Colored band width (normalized).
float skewAmount
Horizontal skew factor.
float pulseSpeed
Pulse animation speed in cycles per second.
float centerX
Normalized horizontal center (0–1).
sf::Vector2f textureSize
Render texture dimensions in pixels.
float reflectionAlpha
Reflection opacity.
float radius
Vignette radius (normalized, 0–1).
float perspective
Perspective distortion amount.
float scaleWidth
Normalized width of the scale transition zone.
float frequency
Wave distortion frequency.
float centerY
Normalized vertical center (0–1).
float rotationAngle
3D rotation angle in radians.
sf::Glsl::Vec3 glowColor
RGB glow color.
float glowWidth
Glow falloff width (normalized).
float maxScale
Maximum scale applied to the center item.