This commit is contained in:
2025-02-07 17:04:43 -06:00
parent 33fd7ddf72
commit 8eec81c7f4
2249 changed files with 75331 additions and 685 deletions

View File

@@ -0,0 +1,31 @@
// [COMBO] {"material":"Blend mode","combo":"BLENDMODE","type":"imageblending","default":2}
#include "common_blending.h"
varying vec4 v_TexCoord;
uniform float g_Multiply; // {"material":"Multiply","default":1,"range":[0.0, 10.0]}
#if OPACITYMASK == 1
varying vec2 v_TexCoordOpacity;
#endif
uniform sampler2D g_Texture0; // {"material":"Framebuffer","hidden":true}
uniform sampler2D g_Texture1; // {"material":"Blend texture","mode":"rgbmask","default":"util/white"}
uniform sampler2D g_Texture2; // {"material":"Opacity mask","mode":"opacitymask","default":"util/white","combo":"OPACITYMASK"}
void main() {
vec4 albedo = texSample2D(g_Texture0, v_TexCoord.xy);
vec4 mask = texSample2D(g_Texture1, v_TexCoord.zw);
float blend = mask.a * g_Multiply;
#if OPACITYMASK == 1
blend *= texSample2D(g_Texture2, v_TexCoordOpacity).r;
#endif
albedo.rgb = ApplyBlending(BLENDMODE, albedo.rgb, mask.rgb, blend);
gl_FragColor = albedo;
}

View File

@@ -0,0 +1,26 @@
uniform mat4 g_ModelViewProjectionMatrix;
uniform vec4 g_Texture1Resolution;
#if OPACITYMASK == 1
uniform vec4 g_Texture2Resolution;
varying vec2 v_TexCoordOpacity;
#endif
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec4 v_TexCoord;
void main() {
gl_Position = mul(vec4(a_Position, 1.0), g_ModelViewProjectionMatrix);
v_TexCoord.xy = a_TexCoord;
v_TexCoord.zw = vec2(v_TexCoord.x * g_Texture1Resolution.z / g_Texture1Resolution.x,
v_TexCoord.y * g_Texture1Resolution.w / g_Texture1Resolution.y);
#if OPACITYMASK == 1
v_TexCoordOpacity = vec2(v_TexCoord.x * g_Texture2Resolution.z / g_Texture2Resolution.x,
v_TexCoord.y * g_Texture2Resolution.w / g_Texture2Resolution.y);
#endif
}

View File

@@ -0,0 +1,27 @@
varying vec4 v_TexCoord;
uniform sampler2D g_Texture0; // {"material":"Framebuffer","hidden":true}
uniform sampler2D g_Texture1; // {"material":"Mask","mode":"opacitymask","default":"util/white"}
uniform sampler2D g_Texture2; // {"material":"Prev","hidden":true}
#ifdef HLSL_SM30
uniform vec4 g_Texture0Resolution;
#endif
void main() {
vec2 blurredCoords = v_TexCoord.xy;
#ifdef HLSL_SM30
blurredCoords += 0.75 / g_Texture0Resolution.zw;
#endif
vec4 blurred = texSample2D(g_Texture0, blurredCoords);
vec4 albedoOld = texSample2D(g_Texture2, v_TexCoord.xy);
float mask = texSample2D(g_Texture1, v_TexCoord.zw).r;
blurred = mix(albedoOld, blurred, mask);
gl_FragColor = blurred;
}

View File

@@ -0,0 +1,16 @@
uniform mat4 g_ModelViewProjectionMatrix;
uniform vec4 g_Texture1Resolution;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec4 v_TexCoord;
void main() {
gl_Position = mul(vec4(a_Position, 1.0), g_ModelViewProjectionMatrix);
v_TexCoord.xy = a_TexCoord;
v_TexCoord.zw = vec2(v_TexCoord.x * g_Texture1Resolution.z / g_Texture1Resolution.x,
v_TexCoord.y * g_Texture1Resolution.w / g_Texture1Resolution.y);
}

View File

@@ -0,0 +1,19 @@
varying vec2 v_TexCoord[4];
uniform sampler2D g_Texture0; // {"material":"Framebuffer","hidden":true}
void main() {
float weight = 0.0;
vec4 result = CAST4(0.0);
for (int i = 0; i < 4; ++i)
{
vec4 sample = texSample2D(g_Texture0, v_TexCoord[i]);
result += sample * sample.a;
weight += sample.a;
}
gl_FragColor.rgb = result.rgb / max(0.001, weight);
gl_FragColor.a = result.a / 4.0;
}

View File

@@ -0,0 +1,17 @@
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord[4];
uniform vec4 g_Texture0Resolution;
void main() {
gl_Position = vec4(a_Position, 1.0);
vec2 offsets = 1.0 / g_Texture0Resolution.zw;
v_TexCoord[0] = a_TexCoord - offsets;
v_TexCoord[1] = a_TexCoord + vec2(offsets.x, -offsets.y);
v_TexCoord[2] = a_TexCoord + vec2(-offsets.x, offsets.y);
v_TexCoord[3] = a_TexCoord + offsets;
}

View File

@@ -0,0 +1,46 @@
#if KERNEL == 0
varying vec2 v_TexCoord[13];
#endif
#if KERNEL == 1
varying vec2 v_TexCoord[7];
#endif
#if KERNEL == 2
varying vec2 v_TexCoord[3];
#endif
uniform sampler2D g_Texture0; // {"material":"Framebuffer","hidden":true}
void main() {
#if KERNEL == 0
vec4 albedo = texSample2D(g_Texture0, v_TexCoord[0]) * 0.006299 +
texSample2D(g_Texture0, v_TexCoord[1]) * 0.017298 +
texSample2D(g_Texture0, v_TexCoord[2]) * 0.039533 +
texSample2D(g_Texture0, v_TexCoord[3]) * 0.075189 +
texSample2D(g_Texture0, v_TexCoord[4]) * 0.119007 +
texSample2D(g_Texture0, v_TexCoord[5]) * 0.156756 +
texSample2D(g_Texture0, v_TexCoord[6]) * 0.171834 +
texSample2D(g_Texture0, v_TexCoord[7]) * 0.156756 +
texSample2D(g_Texture0, v_TexCoord[8]) * 0.119007 +
texSample2D(g_Texture0, v_TexCoord[9]) * 0.075189 +
texSample2D(g_Texture0, v_TexCoord[10]) * 0.039533 +
texSample2D(g_Texture0, v_TexCoord[11]) * 0.017298 +
texSample2D(g_Texture0, v_TexCoord[12]) * 0.006299;
#endif
#if KERNEL == 1
vec4 albedo = texSample2D(g_Texture0, v_TexCoord[0]) * 0.071303 +
texSample2D(g_Texture0, v_TexCoord[1]) * 0.131514 +
texSample2D(g_Texture0, v_TexCoord[2]) * 0.189879 +
texSample2D(g_Texture0, v_TexCoord[3]) * 0.214607 +
texSample2D(g_Texture0, v_TexCoord[4]) * 0.189879 +
texSample2D(g_Texture0, v_TexCoord[5]) * 0.131514 +
texSample2D(g_Texture0, v_TexCoord[6]) * 0.071303;
#endif
#if KERNEL == 2
vec4 albedo = texSample2D(g_Texture0, v_TexCoord[0]) * 0.25 +
texSample2D(g_Texture0, v_TexCoord[1]) * 0.5 +
texSample2D(g_Texture0, v_TexCoord[2]) * 0.25;
#endif
gl_FragColor = albedo;
}

View File

@@ -0,0 +1,61 @@
// [COMBO] {"material":"Kernel size","combo":"KERNEL","type":"options","default":0,"options":{"13x13":0,"7x7":1,"3x3":2}}
uniform vec2 g_Scale; // {"material":"Scale","default":"1 1","linked":true,"range":[0.01, 2.0]}
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
#if KERNEL == 0
varying vec2 v_TexCoord[13];
#endif
#if KERNEL == 1
varying vec2 v_TexCoord[7];
#endif
#if KERNEL == 2
varying vec2 v_TexCoord[3];
#endif
uniform vec4 g_Texture0Resolution;
void main() {
gl_Position = vec4(a_Position, 1.0);
#if VERTICAL
float offsetX = 0.0f;
float offsetY = g_Scale.y / g_Texture0Resolution.w;
#else
float offsetX = g_Scale.x / g_Texture0Resolution.z;
float offsetY = 0.0f;
#endif
#if KERNEL == 0
v_TexCoord[0] = vec2(a_TexCoord.x - offsetX * 6.0, a_TexCoord.y - offsetY * 6.0);
v_TexCoord[1] = vec2(a_TexCoord.x - offsetX * 5.0, a_TexCoord.y - offsetY * 5.0);
v_TexCoord[2] = vec2(a_TexCoord.x - offsetX * 4.0, a_TexCoord.y - offsetY * 4.0);
v_TexCoord[3] = vec2(a_TexCoord.x - offsetX * 3.0, a_TexCoord.y - offsetY * 3.0);
v_TexCoord[4] = vec2(a_TexCoord.x - offsetX * 2.0, a_TexCoord.y - offsetY * 2.0);
v_TexCoord[5] = vec2(a_TexCoord.x - offsetX, a_TexCoord.y - offsetY);
v_TexCoord[6] = vec2(a_TexCoord.x, a_TexCoord.y);
v_TexCoord[7] = vec2(a_TexCoord.x + offsetX, a_TexCoord.y + offsetY);
v_TexCoord[8] = vec2(a_TexCoord.x + offsetX * 2.0, a_TexCoord.y + offsetY * 2.0);
v_TexCoord[9] = vec2(a_TexCoord.x + offsetX * 3.0, a_TexCoord.y + offsetY * 3.0);
v_TexCoord[10] = vec2(a_TexCoord.x + offsetX * 4.0, a_TexCoord.y + offsetY * 4.0);
v_TexCoord[11] = vec2(a_TexCoord.x + offsetX * 5.0, a_TexCoord.y + offsetY * 5.0);
v_TexCoord[12] = vec2(a_TexCoord.x + offsetX * 6.0, a_TexCoord.y + offsetY * 6.0);
#endif
#if KERNEL == 1
v_TexCoord[0] = vec2(a_TexCoord.x - offsetX * 3.0, a_TexCoord.y - offsetY * 3.0);
v_TexCoord[1] = vec2(a_TexCoord.x - offsetX * 2.0, a_TexCoord.y - offsetY * 2.0);
v_TexCoord[2] = vec2(a_TexCoord.x - offsetX, a_TexCoord.y - offsetY);
v_TexCoord[3] = vec2(a_TexCoord.x, a_TexCoord.y);
v_TexCoord[4] = vec2(a_TexCoord.x + offsetX, a_TexCoord.y + offsetY);
v_TexCoord[5] = vec2(a_TexCoord.x + offsetX * 2.0, a_TexCoord.y + offsetY * 2.0);
v_TexCoord[6] = vec2(a_TexCoord.x + offsetX * 3.0, a_TexCoord.y + offsetY * 3.0);
#endif
#if KERNEL == 2
v_TexCoord[0] = vec2(a_TexCoord.x - offsetX, a_TexCoord.y - offsetY);
v_TexCoord[1] = vec2(a_TexCoord.x, a_TexCoord.y);
v_TexCoord[2] = vec2(a_TexCoord.x + offsetX, a_TexCoord.y + offsetY);
#endif
}

View File

@@ -0,0 +1,26 @@
// [COMBO] {"material":"Invert","combo":"INVERT","type":"options","default":0}
varying vec2 v_TexCoord;
uniform sampler2D g_Texture0; // {"material":"Framebuffer","hidden":true}
uniform float g_KeyAlpha; // {"material":"Write alpha","default":0,"range":[0,1]}
uniform float g_KeyFuzz; // {"material":"Fuzziness","default":0,"range":[0,1]}
uniform float g_KeyTolerance; // {"material":"Tolerance","default":0.1,"range":[0,1]}
uniform vec3 g_KeyColor; // {"material":"Color", "type": "color", "default":"1 1 1"}
void main() {
vec4 albedo = texSample2D(g_Texture0, v_TexCoord.xy);
float delta = length(g_KeyColor - albedo.rgb); // [0, SQRT_3]
float blend = smoothstep(0.001, 0.002 + g_KeyFuzz, delta - g_KeyTolerance);
#if INVERT == 1
blend = 1.0 - blend;
#endif
albedo.a *= mix(g_KeyAlpha, 1.0, blend);
gl_FragColor = albedo;
}

View File

@@ -0,0 +1,12 @@
uniform mat4 g_ModelViewProjectionMatrix;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
void main() {
gl_Position = mul(vec4(a_Position, 1.0), g_ModelViewProjectionMatrix);
v_TexCoord.xy = a_TexCoord;
}

View File

@@ -0,0 +1,46 @@
// [COMBO] {"material":"Background","combo":"BACKGROUND","type":"options","default":1}
#include "common.h"
varying vec2 v_TexCoord;
uniform sampler2D g_Texture0; // {"material":"Framebuffer","hidden":true}
uniform float g_Size; // {"material":"Size","default":1,"range":[0.01, 1]}
uniform float g_Scale; // {"material":"Distortion","default":1,"range":[0, 2.5]}
uniform vec2 g_Center; // {"material":"Center","default":"0.5 0.5"}
void main() {
//vec4 albedo = texSample2D(g_Texture0, v_TexCoord.xy);
float aperture = 178.0;
float apertureHalf = 0.5 * aperture * (M_PI / 180.0);
float maxFactor = sin(apertureHalf);
vec2 uv;
vec2 xy = (v_TexCoord.xy - g_Center) * 2.0 / g_Size;
float d = length(xy);
float alpha = 1.0;
if (d < (2.0 - maxFactor))
{
d = length(xy * maxFactor);
float z = sqrt(1.0 - d * d);
float r = atan2(d, z) / M_PI;
float phi = atan2(xy.y, xy.x);
uv.x = r * cos(phi) * g_Size + g_Center.x;
uv.y = r * sin(phi) * g_Size + g_Center.y;
}
else
{
uv = v_TexCoord.xy;
#if BACKGROUND == 0
alpha = 0.0;
#endif
}
vec4 albedo = texSample2D(g_Texture0, mix(v_TexCoord.xy, uv, g_Scale));
albedo.a *= alpha;
gl_FragColor = albedo;
}

View File

@@ -0,0 +1,12 @@
uniform mat4 g_ModelViewProjectionMatrix;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
void main() {
gl_Position = mul(vec4(a_Position, 1.0), g_ModelViewProjectionMatrix);
v_TexCoord.xy = a_TexCoord;
}

View File

@@ -0,0 +1,37 @@
// [COMBO] {"material":"Greyscale","combo":"GREYSCALE","type":"options","default":0}
varying vec4 v_TexCoord;
uniform sampler2D g_Texture0; // {"material":"Framebuffer","hidden":true}
uniform sampler2D g_Texture1; // {"material":"Mask","mode":"opacitymask","default":"util/white"}
uniform sampler2D g_Texture2; // {"material":"Prev","hidden":true}
#ifdef HLSL_SM30
uniform vec4 g_Texture0Resolution;
#endif
uniform float g_Amount; // {"material":"Strength","default":1.0,"range":[0.01, 5]}
void main() {
vec2 blurredCoords = v_TexCoord.xy;
#ifdef HLSL_SM30
blurredCoords += 0.75 / g_Texture0Resolution.zw;
#endif
vec4 blurred = texSample2D(g_Texture0, blurredCoords);
vec4 albedo = texSample2D(g_Texture2, v_TexCoord.xy);
vec3 delta = albedo.rgb - blurred.rgb;
#if GREYSCALE == 1
delta = CAST3(dot(vec3(0.11, 0.59, 0.3), delta));
#endif
vec3 enhanced = albedo.rgb + delta * g_Amount;
float mask = texSample2D(g_Texture1, v_TexCoord.zw).r;
albedo.rgb = mix(albedo.rgb, enhanced.rgb, mask);
gl_FragColor = albedo;
}

View File

@@ -0,0 +1,16 @@
uniform mat4 g_ModelViewProjectionMatrix;
uniform vec4 g_Texture1Resolution;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec4 v_TexCoord;
void main() {
gl_Position = mul(vec4(a_Position, 1.0), g_ModelViewProjectionMatrix);
v_TexCoord.xy = a_TexCoord;
v_TexCoord.zw = vec2(v_TexCoord.x * g_Texture1Resolution.z / g_Texture1Resolution.x,
v_TexCoord.y * g_Texture1Resolution.w / g_Texture1Resolution.y);
}

View File

@@ -0,0 +1,19 @@
varying vec2 v_TexCoord[4];
uniform sampler2D g_Texture0; // {"material":"Framebuffer","hidden":true}
void main() {
float weight = 0.0;
vec4 result = CAST4(0.0);
for (int i = 0; i < 4; ++i)
{
vec4 sample = texSample2D(g_Texture0, v_TexCoord[i]);
result += sample * sample.a;
weight += sample.a;
}
gl_FragColor.rgb = result.rgb / max(0.001, weight);
gl_FragColor.a = result.a / 4.0;
}

View File

@@ -0,0 +1,17 @@
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord[4];
uniform vec4 g_Texture0Resolution;
void main() {
gl_Position = vec4(a_Position, 1.0);
vec2 offsets = 1.0 / g_Texture0Resolution.zw;
v_TexCoord[0] = a_TexCoord - offsets;
v_TexCoord[1] = a_TexCoord + vec2(offsets.x, -offsets.y);
v_TexCoord[2] = a_TexCoord + vec2(-offsets.x, offsets.y);
v_TexCoord[3] = a_TexCoord + offsets;
}

View File

@@ -0,0 +1,46 @@
#if KERNEL == 0
varying vec2 v_TexCoord[13];
#endif
#if KERNEL == 1
varying vec2 v_TexCoord[7];
#endif
#if KERNEL == 2
varying vec2 v_TexCoord[3];
#endif
uniform sampler2D g_Texture0; // {"material":"Framebuffer","hidden":true}
void main() {
#if KERNEL == 0
vec4 albedo = texSample2D(g_Texture0, v_TexCoord[0]) * 0.006299 +
texSample2D(g_Texture0, v_TexCoord[1]) * 0.017298 +
texSample2D(g_Texture0, v_TexCoord[2]) * 0.039533 +
texSample2D(g_Texture0, v_TexCoord[3]) * 0.075189 +
texSample2D(g_Texture0, v_TexCoord[4]) * 0.119007 +
texSample2D(g_Texture0, v_TexCoord[5]) * 0.156756 +
texSample2D(g_Texture0, v_TexCoord[6]) * 0.171834 +
texSample2D(g_Texture0, v_TexCoord[7]) * 0.156756 +
texSample2D(g_Texture0, v_TexCoord[8]) * 0.119007 +
texSample2D(g_Texture0, v_TexCoord[9]) * 0.075189 +
texSample2D(g_Texture0, v_TexCoord[10]) * 0.039533 +
texSample2D(g_Texture0, v_TexCoord[11]) * 0.017298 +
texSample2D(g_Texture0, v_TexCoord[12]) * 0.006299;
#endif
#if KERNEL == 1
vec4 albedo = texSample2D(g_Texture0, v_TexCoord[0]) * 0.071303 +
texSample2D(g_Texture0, v_TexCoord[1]) * 0.131514 +
texSample2D(g_Texture0, v_TexCoord[2]) * 0.189879 +
texSample2D(g_Texture0, v_TexCoord[3]) * 0.214607 +
texSample2D(g_Texture0, v_TexCoord[4]) * 0.189879 +
texSample2D(g_Texture0, v_TexCoord[5]) * 0.131514 +
texSample2D(g_Texture0, v_TexCoord[6]) * 0.071303;
#endif
#if KERNEL == 2
vec4 albedo = texSample2D(g_Texture0, v_TexCoord[0]) * 0.25 +
texSample2D(g_Texture0, v_TexCoord[1]) * 0.5 +
texSample2D(g_Texture0, v_TexCoord[2]) * 0.25;
#endif
gl_FragColor = albedo;
}

View File

@@ -0,0 +1,61 @@
// [COMBO] {"material":"Kernel size","combo":"KERNEL","type":"options","default":0,"options":{"13x13":0,"7x7":1,"3x3":2}}
uniform vec2 g_Scale; // {"material":"Scale","default":"1 1","linked":true,"range":[0.01, 2.0]}
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
#if KERNEL == 0
varying vec2 v_TexCoord[13];
#endif
#if KERNEL == 1
varying vec2 v_TexCoord[7];
#endif
#if KERNEL == 2
varying vec2 v_TexCoord[3];
#endif
uniform vec4 g_Texture0Resolution;
void main() {
gl_Position = vec4(a_Position, 1.0);
#if VERTICAL
float offsetX = 0.0f;
float offsetY = g_Scale.y / g_Texture0Resolution.w;
#else
float offsetX = g_Scale.x / g_Texture0Resolution.z;
float offsetY = 0.0f;
#endif
#if KERNEL == 0
v_TexCoord[0] = vec2(a_TexCoord.x - offsetX * 6.0, a_TexCoord.y - offsetY * 6.0);
v_TexCoord[1] = vec2(a_TexCoord.x - offsetX * 5.0, a_TexCoord.y - offsetY * 5.0);
v_TexCoord[2] = vec2(a_TexCoord.x - offsetX * 4.0, a_TexCoord.y - offsetY * 4.0);
v_TexCoord[3] = vec2(a_TexCoord.x - offsetX * 3.0, a_TexCoord.y - offsetY * 3.0);
v_TexCoord[4] = vec2(a_TexCoord.x - offsetX * 2.0, a_TexCoord.y - offsetY * 2.0);
v_TexCoord[5] = vec2(a_TexCoord.x - offsetX, a_TexCoord.y - offsetY);
v_TexCoord[6] = vec2(a_TexCoord.x, a_TexCoord.y);
v_TexCoord[7] = vec2(a_TexCoord.x + offsetX, a_TexCoord.y + offsetY);
v_TexCoord[8] = vec2(a_TexCoord.x + offsetX * 2.0, a_TexCoord.y + offsetY * 2.0);
v_TexCoord[9] = vec2(a_TexCoord.x + offsetX * 3.0, a_TexCoord.y + offsetY * 3.0);
v_TexCoord[10] = vec2(a_TexCoord.x + offsetX * 4.0, a_TexCoord.y + offsetY * 4.0);
v_TexCoord[11] = vec2(a_TexCoord.x + offsetX * 5.0, a_TexCoord.y + offsetY * 5.0);
v_TexCoord[12] = vec2(a_TexCoord.x + offsetX * 6.0, a_TexCoord.y + offsetY * 6.0);
#endif
#if KERNEL == 1
v_TexCoord[0] = vec2(a_TexCoord.x - offsetX * 3.0, a_TexCoord.y - offsetY * 3.0);
v_TexCoord[1] = vec2(a_TexCoord.x - offsetX * 2.0, a_TexCoord.y - offsetY * 2.0);
v_TexCoord[2] = vec2(a_TexCoord.x - offsetX, a_TexCoord.y - offsetY);
v_TexCoord[3] = vec2(a_TexCoord.x, a_TexCoord.y);
v_TexCoord[4] = vec2(a_TexCoord.x + offsetX, a_TexCoord.y + offsetY);
v_TexCoord[5] = vec2(a_TexCoord.x + offsetX * 2.0, a_TexCoord.y + offsetY * 2.0);
v_TexCoord[6] = vec2(a_TexCoord.x + offsetX * 3.0, a_TexCoord.y + offsetY * 3.0);
#endif
#if KERNEL == 2
v_TexCoord[0] = vec2(a_TexCoord.x - offsetX, a_TexCoord.y - offsetY);
v_TexCoord[1] = vec2(a_TexCoord.x, a_TexCoord.y);
v_TexCoord[2] = vec2(a_TexCoord.x + offsetX, a_TexCoord.y + offsetY);
#endif
}

View File

@@ -0,0 +1,48 @@
// [COMBO] {"material":"Blend mode","combo":"BLENDMODE","type":"imageblending","default":9}
// [COMBO] {"material":"Pulse alpha","combo":"PULSEALPHA","type":"options","default":0}
// [COMBO] {"material":"Pulse color","combo":"PULSECOLOR","type":"options","default":1}
#include "common_blending.h"
varying vec2 v_TexCoord;
uniform sampler2D g_Texture0; // {"material":"Framebuffer","hidden":true}
uniform sampler2D g_Texture1; // {"material":"Noise","default":"util/noise"}
uniform float g_Time;
uniform float g_PulseSpeed; // {"material":"Pulse speed","default":3,"range":[0,10]}
uniform float g_PulseAmount; // {"material":"Pulse amount","default":1,"range":[0,2]}
uniform vec2 g_PulseThresholds; // {"material":"Pulse bounds","default":"0 1"}
uniform float g_NoiseSpeed; // {"material":"Noise speed","default":0.1,"range":[0,0.5]}
uniform float g_NoiseAmount; // {"material":"Noise amount","default":0,"range":[0,2]}
uniform float g_Power; // {"material":"Power","default":1,"range":[0,4]}
uniform vec3 g_TintColor1; // {"material":"Tint low", "type": "color", "default":"1 1 1"}
uniform vec3 g_TintColor2; // {"material":"Tint high", "type": "color", "default":"1 1 1"}
void main() {
vec4 albedo = texSample2D(g_Texture0, v_TexCoord.xy);
//float delta = length(g_KeyColor - albedo.rgb); // [0, SQRT_3]
//float blend = smoothstep(0.001, 0.002 + g_KeyFuzz, delta - g_KeyTolerance);
//albedo.a *= mix(g_KeyAlpha, 1.0, blend);
float pulse = smoothstep(g_PulseThresholds.x, g_PulseThresholds.y, sin(g_Time * g_PulseSpeed) * 0.5 + 0.5) * g_PulseAmount;
float noise = texSample2D(g_Texture1, vec2(g_Time, g_Time * 0.333) * g_NoiseSpeed).r * g_NoiseAmount;
pulse += noise;
pulse = pow(pulse, g_Power);
#if PULSECOLOR
albedo.rgb = ApplyBlending(BLENDMODE, albedo.rgb * g_TintColor1, albedo.rgb * g_TintColor2, pulse);
#endif
#if PULSEALPHA
albedo.a *= pulse;
#endif
gl_FragColor = saturate(albedo);
}

View File

@@ -0,0 +1,13 @@
uniform mat4 g_ModelViewProjectionMatrix;
uniform vec4 g_Texture1Resolution;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
void main() {
gl_Position = mul(vec4(a_Position, 1.0), g_ModelViewProjectionMatrix);
v_TexCoord.xy = a_TexCoord;
}

View File

@@ -0,0 +1,19 @@
// [COMBO] {"material":"Blend mode","combo":"BLENDMODE","type":"imageblending","default":2}
#include "common_blending.h"
varying vec2 v_TexCoord;
uniform sampler2D g_Texture0; // {"material":"Framebuffer","hidden":true}
uniform float g_BlendAlpha; // {"material":"Alpha","default":1,"range":[0,1]}
uniform vec3 g_TintColor; // {"material":"Color", "type": "color", "default":"1 1 1"}
void main() {
vec4 albedo = texSample2D(g_Texture0, v_TexCoord.xy);
albedo.rgb = ApplyBlending(BLENDMODE, albedo.rgb, g_TintColor, g_BlendAlpha);
gl_FragColor = albedo;
}

View File

@@ -0,0 +1,12 @@
uniform mat4 g_ModelViewProjectionMatrix;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
void main() {
gl_Position = mul(vec4(a_Position, 1.0), g_ModelViewProjectionMatrix);
v_TexCoord.xy = a_TexCoord;
}