Loading...
Searching...
No Matches
ShaderLibrary.h
Go to the documentation of this file.
1// Copyright (c) 2025 Dave R. Smith. All rights reserved.
2// Malena Framework — Proprietary Software. See LICENSE for terms.
3
4//
5// ShaderLibrary.h
6//
7
8#ifndef MALENA_SHADERLIBRARY_H
9#define MALENA_SHADERLIBRARY_H
10
12#include <string_view>
13#include <SFML/Graphics.hpp>
14#include <functional>
15
16namespace ml
17{
54 {
55 public:
64 struct Params
65 {
66 // ── Position / center ────────────────────────────────────────────
67 float centerX = 0.5f;
68 float centerY = 0.5f;
69
70 // ── Scale ────────────────────────────────────────────────────────
71 float minScale = 0.6f;
72 float maxScale = 1.5f;
73 float scaleWidth = 0.3f;
74
75 // ── Blur ─────────────────────────────────────────────────────────
76 float blurAmount = 2.0f;
77 float focusWidth = 0.2f;
78
79 // ── Color ─────────────────────────────────────────────────────────
80 sf::Glsl::Vec3 tintColor = {1.0f, 0.8f, 0.6f};
81 sf::Glsl::Vec3 glowColor = {1.0f, 1.0f, 0.8f};
82 float tintStrength = 0.3f;
83 float glowStrength = 0.3f;
84
85 // ── Fade / vignette ───────────────────────────────────────────────
86 float fadeWidth = 50.0f;
87 float strength = 0.5f;
88 float radius = 0.8f;
89
90 // ── 3D / perspective ──────────────────────────────────────────────
91 float perspective = 0.8f;
92 float rotationAngle = 0.5f;
93 float skewAmount = 0.3f;
94
95 // ── Animation ─────────────────────────────────────────────────────
96 float time = 0.0f;
97 float amplitude = 0.02f;
98 float frequency = 10.0f;
99 float pulseSpeed = 2.0f;
100 float pulseAmount = 0.05f;
101
102 // ── Miscellaneous ─────────────────────────────────────────────────
103 float parallaxStrength = 0.1f;
104 float reflectionHeight = 0.5f;
105 float reflectionAlpha = 0.4f;
106 float colorWidth = 0.25f;
107 float intensity = 0.8f;
108 float glowWidth = 0.3f;
109
110 // ── Auto-updated by Carousel ──────────────────────────────────────
111 sf::Vector2f textureSize = {720.0f, 480.0f};
112 float totalWidth = 720.0f;
113 };
114
139 enum class Style
140 {
141 DEFAULT,
142 FADE_EDGES,
143 BLUR_UNFOCUSED,
144 COVERFLOW_3D,
145 COLOR_TINT,
146 WAVE_DISTORTION,
147 DEPTH_OF_FIELD,
148 SCALE_CENTER,
149 VIGNETTE,
150 GRAYSCALE_EDGES,
151 REFLECTION,
152 ROTATION_3D,
153 PARALLAX,
154 GLOW_CENTER,
155 SLIDE_ANGLE,
156 SEPIA_TONE,
157 ZOOM_PULSE,
158 CUSTOM
159 };
160
161 // ── GLSL source getters ───────────────────────────────────────────────
162
164 static std::string_view fadeEdges();
166 static std::string_view scaleCenter();
168 static std::string_view blurUnfocused();
170 static std::string_view coverflow3D();
172 static std::string_view colorTint();
174 static std::string_view waveDistortion();
176 static std::string_view depthOfField();
178 static std::string_view vignette();
180 static std::string_view grayscaleEdges();
182 static std::string_view reflection();
184 static std::string_view rotation3D();
186 static std::string_view parallax();
188 static std::string_view glowCenter();
190 static std::string_view slideAngle();
192 static std::string_view sepiaTone();
194 static std::string_view zoomPulse();
195
206 static void applyUniforms(sf::Shader& shader, Style style, const Params& params);
207 };
208
209} // namespace ml
210
211#endif // MALENA_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.
#define MALENA_API
Definition Component.h:22
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.