a little polishing

This commit is contained in:
Justin Garza
2024-12-17 20:34:49 -05:00
parent 002e7258f6
commit 020516e0da
5 changed files with 63 additions and 22 deletions
+1 -2
View File
@@ -136,7 +136,6 @@ void main() {
progress, 0.0, ((uSize.x + (uPadding*2.0)) / uSize.x)
,0.0, 1.0
);
progress = clamp(progress,0.0,1.0);
}
@@ -196,7 +195,7 @@ void main() {
vec3 color = cos(progress*uColorSpeed+uv.xyx+vec3(0,2,4)).xyz;
//coloroffset
float colorOffset = (uRandomColorOffset) ? hash12(uSeed) : uColorOffset ;
color = offsetHue(color, colorOffset);
color = offsetHue(color, colorOffset + 0.10);
//clamp and saturate
color = clamp(color * uColorSaturation,vec3(0.0),vec3(1.0));
+29 -4
View File
@@ -385,6 +385,15 @@ vec2 rotate(vec2 a, float angle) {
);
}
//rotates a given 2d vector, around a given center (angle is in radians)
vec2 rotate(vec2 a, float angle, vec2 center)
{
return vec2(
cos(angle) * (a.x - center.x) + sin(angle) * (a.y - center.y) + center.x,
cos(angle) * (a.y - center.y) - sin(angle) * (a.x - center.x) + center.y
);
}
// --------------------------------------------------------------------------------- noise
// These noise algorithms are based on implementations by various authors from
@@ -613,26 +622,42 @@ This ensures a linear transformation from the old range to the new range.
// Maps a float value from one range [oldMin, oldMax] to another range [newMin, newMax].
// This is useful for normalizing or scaling scalar values to fit within a desired range.
float remap(float value, float oldMin, float oldMax, float newMin, float newMax) {
return newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin);
return clamp(
newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin),
newMin,
newMax
);
}
// Remap for vec2
// Maps a 2D vector (vec2) from one range [oldMin, oldMax] to another range [newMin, newMax].
// Each component of the vec2 is individually scaled and transformed.
vec2 remap(vec2 value, vec2 oldMin, vec2 oldMax, vec2 newMin, vec2 newMax) {
return newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin);
return clamp(
newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin),
newMin,
newMax
);
}
// Remap for vec3
// Maps a 3D vector (vec3) from one range [oldMin, oldMax] to another range [newMin, newMax].
// Each component of the vec3 is individually scaled and transformed.
vec3 remap(vec3 value, vec3 oldMin, vec3 oldMax, vec3 newMin, vec3 newMax) {
return newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin);
return clamp(
newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin),
newMin,
newMax
);
}
// Remap for vec4
// Maps a 4D vector (vec4) from one range [oldMin, oldMax] to another range [newMin, newMax].
// Each component of the vec4 is individually scaled and transformed.
vec4 remap(vec4 value, vec4 oldMin, vec4 oldMax, vec4 newMin, vec4 newMax) {
return newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin);
return clamp(
newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin),
newMin,
newMax
);
}
+5 -13
View File
@@ -121,16 +121,6 @@ vec2 scaleUV(vec2 uv, vec2 scale)
return uv;
}
//rotates the UV
//needs to use this once since it rotates around the middle (i.e. 0.5)
vec2 rotateUV(vec2 uv, float rotation)
{
float mid = 0.5;
return vec2(
cos(rotation) * (uv.x - mid) + sin(rotation) * (uv.y - mid) + mid,
cos(rotation) * (uv.y - mid) - sin(rotation) * (uv.x - mid) + mid
);
}
//this returns the Spark
float getSpark(vec2 uv, vec2 center, float brightness, float size, float rotation)
@@ -142,7 +132,7 @@ float getSpark(vec2 uv, vec2 center, float brightness, float size, float rotatio
uv = (uv + vec2(0.5)) ;
uv = (uv - center) ;//Center UV coordinates, then scale to fit the star size
uv = scaleUV(uv, vec2(1.0 - size));
uv = rotateUV(uv, rotation); //rotate the UV
uv = rotate(uv, rotation, vec2(0.5)); //rotate the UV
//this is basically the brightness
float p = mix(-1.0,1000.0,easeInExpo(bn));
@@ -349,10 +339,11 @@ vec4 getRays(float progress)
0.0,1.0,
-5.0,1.0
);
ray = clamp(ray,0.0,1.0);
float alpha = clamp(uRaysColor.a * ray,0.0,1.0);
//return
return vec4(uRaysColor.r,uRaysColor.g,uRaysColor.b,uRaysColor.a * ray);
return vec4(uRaysColor.r,uRaysColor.g,uRaysColor.b,alpha);
}
@@ -452,6 +443,7 @@ void main() {
oColor = alphaOver(oColor, getRays(progress));
}
// If five-point stars are enabled, overlay them using stored alpha
if (uRingCount > 0.0 && uStarCount > 0.0)
{
+9 -2
View File
@@ -42,7 +42,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
</child>
<child>
<!-- <child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Random Color</property>
<property name="activatable-widget">aura-glow-random-color</property>
@@ -62,12 +62,19 @@ SPDX-License-Identifier: GPL-3.0-or-later
</object>
</child>
</object>
</child>
</child> -->
<child>
<object class="AdwActionRow" id="aura-glow-action-row">
<property name="title" translatable="yes">Color Offset</property>
<property name="subtitle" translatable="yes">Red</property>
<child>
<object class="GtkCheckButton" id="aura-glow-random-color">
<property name="label" translatable="yes">random</property>
<property name="valign">center</property>
<property name="active">true</property>
</object>
</child>
<child>
<object class="GtkScale" id="aura-glow-color-offset-scale">
<property name="valign">center</property>