Compare commits
3 Commits
2023.228.0
...
2023.314.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94d7be96c0 | ||
|
|
4828838a3c | ||
|
|
2f3eb762c0 |
@@ -1,75 +0,0 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
const float TWOPI = 6.28318548;
|
||||
const float PI = 3.14159274;
|
||||
const float RING_FUDGE_FACTOR = 0.05;
|
||||
|
||||
const float GLOW_OVERSHOOT = 0.3;
|
||||
|
||||
uniform vec2 m_CenterPos;
|
||||
uniform float m_OuterRadius;
|
||||
uniform float m_InnerRadius;
|
||||
uniform float m_OuterGlowRadius;
|
||||
uniform float m_InnerGlowRadius;
|
||||
|
||||
uniform float m_Alpha;
|
||||
|
||||
uniform vec4 m_RingForegroundColour;
|
||||
uniform vec4 m_RingBackgroundColour;
|
||||
uniform vec4 m_GlowColour; // Normalized
|
||||
|
||||
uniform float m_Progress;
|
||||
|
||||
varying vec2 v_Position;
|
||||
|
||||
/**
|
||||
* Returns 1.0 if m_InnerRadius < dist < m_OuterRadius.
|
||||
*/
|
||||
float isRing(float dist)
|
||||
{
|
||||
return smoothstep(m_InnerRadius, m_InnerRadius + 1.0, dist)
|
||||
* smoothstep(m_OuterRadius, m_OuterRadius - 1.0, dist);
|
||||
}
|
||||
|
||||
/**
|
||||
* If m_InnerGlowRadius < dist < m_InnerRadius || m_OuterRadius < dist < m_OuterGlowRadius
|
||||
* returns the linear interpolation of the glow bewteen those bounds.
|
||||
* Returns 0 if no glow.
|
||||
*/
|
||||
float isGlow(float dist)
|
||||
{
|
||||
return smoothstep(m_InnerGlowRadius, m_InnerRadius, dist) // Before the ring
|
||||
* clamp(1.0 - isRing(dist), 0.0, 1.0) // During the ring
|
||||
* smoothstep(m_OuterGlowRadius, m_OuterRadius, dist); // After the ring
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// Radius from the center
|
||||
float dist = distance(v_Position, m_CenterPos);
|
||||
|
||||
// Top of area is at -PI / PI, bottom is 0
|
||||
float angle = atan(v_Position.x - m_CenterPos.x, v_Position.y - m_CenterPos.y);
|
||||
float startAngle = (0.5 - m_Progress) * TWOPI;
|
||||
|
||||
// Glow and AA reduction once the ring is too small
|
||||
float reduction = smoothstep(PI, PI - GLOW_OVERSHOOT, startAngle);
|
||||
|
||||
float activeRingAmount = smoothstep(startAngle - reduction * RING_FUDGE_FACTOR, startAngle, angle);
|
||||
|
||||
float activeGlowAmount = max(smoothstep(startAngle - GLOW_OVERSHOOT, startAngle + GLOW_OVERSHOOT, angle), // Start
|
||||
smoothstep(-PI + GLOW_OVERSHOOT, -PI - GLOW_OVERSHOOT, angle)) // Top (left)
|
||||
* reduction * smoothstep(PI + GLOW_OVERSHOOT / 2.0, PI - GLOW_OVERSHOOT / 2.0, angle); // Top (right)
|
||||
|
||||
activeGlowAmount += max(0.0, (1.0 - activeGlowAmount) * smoothstep(0.9, 1.0, m_Progress));
|
||||
|
||||
// Todo: Probably make darkening uniforms
|
||||
vec4 glowColour = isGlow(dist) * (activeGlowAmount + (1.0 - activeGlowAmount) * 0.2) * m_GlowColour;
|
||||
vec4 ringColour = isRing(dist) * (activeRingAmount * m_RingForegroundColour + (1.0 - activeRingAmount) * m_RingBackgroundColour);
|
||||
|
||||
gl_FragColor = (ringColour + glowColour) * m_Alpha;
|
||||
|
||||
//Todo: Discard fragments? idk...
|
||||
}
|
||||
@@ -1,21 +1,20 @@
|
||||
attribute vec2 m_Position;
|
||||
attribute vec4 m_Colour;
|
||||
attribute vec2 m_TexCoord;
|
||||
attribute vec4 m_TexRect;
|
||||
attribute float m_Time;
|
||||
layout(location = 0) in vec2 m_Position;
|
||||
layout(location = 1) in vec4 m_Colour;
|
||||
layout(location = 2) in vec2 m_TexCoord;
|
||||
layout(location = 3) in vec4 m_TexRect;
|
||||
layout(location = 4) in float m_Time;
|
||||
|
||||
varying vec2 v_MaskingPosition;
|
||||
varying vec4 v_Colour;
|
||||
varying vec2 v_TexCoord;
|
||||
varying vec4 v_TexRect;
|
||||
varying vec2 v_BlendRange;
|
||||
layout(location = 0) out vec2 v_MaskingPosition;
|
||||
layout(location = 1) out vec4 v_Colour;
|
||||
layout(location = 2) out vec2 v_TexCoord;
|
||||
layout(location = 3) out vec4 v_TexRect;
|
||||
layout(location = 4) out vec2 v_BlendRange;
|
||||
|
||||
uniform mat4 g_ProjMatrix;
|
||||
uniform mat3 g_ToMaskingSpace;
|
||||
uniform mat3 g_ToDrawingSpace;
|
||||
|
||||
uniform float g_FadeClock;
|
||||
uniform float g_FadeExponent;
|
||||
layout(std140, set = 1, binding = 0) uniform m_CursorTrailParameters
|
||||
{
|
||||
float g_FadeClock;
|
||||
float g_FadeExponent;
|
||||
};
|
||||
|
||||
void main(void)
|
||||
{
|
||||
@@ -24,10 +23,10 @@ void main(void)
|
||||
v_MaskingPosition = maskingPos.xy / maskingPos.z;
|
||||
|
||||
v_Colour = vec4(m_Colour.rgb, m_Colour.a * pow(clamp(m_Time - g_FadeClock, 0.0, 1.0), g_FadeExponent));
|
||||
|
||||
|
||||
v_TexCoord = m_TexCoord;
|
||||
v_TexRect = m_TexRect;
|
||||
v_BlendRange = vec2(0.0);
|
||||
|
||||
|
||||
gl_Position = g_ProjMatrix * vec4(m_Position, 1.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
varying highp vec2 v_Position;
|
||||
varying lowp vec4 v_Colour;
|
||||
layout(location = 0) in highp vec2 v_Position;
|
||||
layout(location = 1) in lowp vec4 v_Colour;
|
||||
|
||||
uniform highp vec2 flashlightPos;
|
||||
uniform highp vec2 flashlightSize;
|
||||
layout(std140, set = 0, binding = 0) uniform m_FlashlightParameters
|
||||
{
|
||||
highp vec2 flashlightPos;
|
||||
highp vec2 flashlightSize;
|
||||
lowp float flashlightDim;
|
||||
lowp float flashlightSmoothness;
|
||||
};
|
||||
|
||||
uniform lowp float flashlightDim;
|
||||
uniform lowp float flashlightSmoothness;
|
||||
layout(location = 0) out vec4 o_Colour;
|
||||
|
||||
lowp vec4 getColourAt(highp vec2, highp vec2, lowp vec4);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_FragColor = mix(getColourAt(flashlightPos - v_Position, flashlightSize, v_Colour), vec4(0.0, 0.0, 0.0, 1.0), flashlightDim);
|
||||
o_Colour = mix(getColourAt(flashlightPos - v_Position, flashlightSize, v_Colour), vec4(0.0, 0.0, 0.0, 1.0), flashlightDim);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
#include "sh_Utils.h"
|
||||
|
||||
varying mediump vec2 v_TexCoord;
|
||||
varying lowp vec4 v_Colour;
|
||||
layout(location = 1) in lowp vec4 v_Colour;
|
||||
layout(location = 2) in mediump vec2 v_TexCoord;
|
||||
|
||||
uniform lowp sampler2D m_Sampler;
|
||||
uniform lowp float progress;
|
||||
layout(set = 0, binding = 0) uniform lowp texture2D m_Texture;
|
||||
layout(set = 0, binding = 1) uniform lowp sampler m_Sampler;
|
||||
|
||||
layout(std140, set = 1, binding = 0) uniform m_AnimationData
|
||||
{
|
||||
lowp float progress;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 o_Colour;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 colour = toSRGB(texture2D(m_Sampler, v_TexCoord, -0.9));
|
||||
vec4 colour = toSRGB(texture(sampler2D(m_Texture, m_Sampler), v_TexCoord, -0.9));
|
||||
|
||||
gl_FragColor = colour.r < progress ? toSRGB(vec4(v_Colour.rgb, v_Colour.a * colour.a)) : vec4(0);
|
||||
o_Colour = colour.r < progress ? toSRGB(vec4(v_Colour.rgb, v_Colour.a * colour.a)) : vec4(0);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
attribute vec2 m_Position;
|
||||
attribute vec4 m_Colour;
|
||||
layout(location = 0) in vec2 m_Position;
|
||||
layout(location = 1) in vec4 m_Colour;
|
||||
|
||||
varying vec2 v_Position;
|
||||
varying vec4 v_Colour;
|
||||
|
||||
uniform mat4 g_ProjMatrix;
|
||||
layout(location = 0) out vec2 v_Position;
|
||||
layout(location = 1) out vec4 v_Colour;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
@@ -3,10 +3,15 @@
|
||||
#include "sh_Utils.h"
|
||||
#include "sh_Masking.h"
|
||||
|
||||
varying highp vec2 v_TexCoord;
|
||||
layout(location = 2) in highp vec2 v_TexCoord;
|
||||
|
||||
uniform mediump float thickness;
|
||||
uniform highp float texelSize;
|
||||
layout(std140, set = 0, binding = 0) uniform m_BorderData
|
||||
{
|
||||
mediump float thickness;
|
||||
highp float texelSize;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 o_Colour;
|
||||
|
||||
highp float dstToLine(highp vec2 start, highp vec2 end, highp vec2 pixelPos)
|
||||
{
|
||||
@@ -27,7 +32,7 @@ void main(void)
|
||||
// return if outside the triangle
|
||||
if (abs(pixelPos.x - 0.5) > 0.5 * pixelPos.y)
|
||||
{
|
||||
gl_FragColor = vec4(0.0);
|
||||
o_Colour = vec4(0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,5 +56,5 @@ void main(void)
|
||||
|
||||
lowp vec4 col = getRoundedColor(vec4(1.0), v_TexCoord);
|
||||
|
||||
gl_FragColor = vec4(col.rgb, col.a * alpha);
|
||||
o_Colour = vec4(col.rgb, col.a * alpha);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user