Shaders now are managed by a manger that can do hot reloading and it also will detect a bad shader and use an ERROR shader so you know it's busted visually.
This commit is contained in:
parent
a5b8e411e3
commit
35ced58cc9
14 changed files with 144 additions and 13 deletions
25
assets/shaders/modal.frag
Normal file
25
assets/shaders/modal.frag
Normal file
|
@ -0,0 +1,25 @@
|
|||
uniform sampler2D source;
|
||||
uniform sampler2D bloom;
|
||||
uniform vec2 offsetFactor;
|
||||
uniform float darkness;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 textureCoordinates = gl_TexCoord[0].xy;
|
||||
vec4 color = vec4(0.0);
|
||||
color += texture2D(source, textureCoordinates - 4.0 * offsetFactor) * 0.0162162162;
|
||||
color += texture2D(source, textureCoordinates - 3.0 * offsetFactor) * 0.0540540541;
|
||||
color += texture2D(source, textureCoordinates - 2.0 * offsetFactor) * 0.1216216216;
|
||||
color += texture2D(source, textureCoordinates - offsetFactor) * 0.1945945946;
|
||||
color += texture2D(source, textureCoordinates) * 0.2270270270;
|
||||
color += texture2D(source, textureCoordinates + offsetFactor) * 0.1945945946;
|
||||
color += texture2D(source, textureCoordinates + 2.0 * offsetFactor) * 0.1216216216;
|
||||
color += texture2D(source, textureCoordinates + 3.0 * offsetFactor) * 0.0540540541;
|
||||
color += texture2D(source, textureCoordinates + 4.0 * offsetFactor) * 0.0162162162;
|
||||
|
||||
vec4 sourceFragment = texture2D(source, gl_TexCoord[0].xy);
|
||||
vec4 bloomFragment = texture2D(bloom, gl_TexCoord[0].xy);
|
||||
float alpha = color.a;
|
||||
gl_FragColor = (color + sourceFragment - bloomFragment) * darkness;
|
||||
gl_FragColor.a = alpha;
|
||||
}
|
18
assets/shaders/ui_error.frag
Normal file
18
assets/shaders/ui_error.frag
Normal file
|
@ -0,0 +1,18 @@
|
|||
uniform vec2 u_resolution;
|
||||
uniform vec2 u_mouse;
|
||||
uniform float u_duration;
|
||||
uniform float u_time;
|
||||
uniform float u_time_end;
|
||||
uniform sampler2D texture;
|
||||
uniform bool is_shape;
|
||||
|
||||
void main() {
|
||||
if(is_shape) {
|
||||
vec4 color = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
gl_FragColor = gl_Color * color;
|
||||
} else {
|
||||
vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);
|
||||
vec4 color = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
gl_FragColor = gl_Color * color * pixel;
|
||||
}
|
||||
}
|
22
assets/shaders/ui_shader.frag
Normal file
22
assets/shaders/ui_shader.frag
Normal file
|
@ -0,0 +1,22 @@
|
|||
uniform vec2 u_resolution;
|
||||
uniform vec2 u_mouse;
|
||||
uniform float u_duration;
|
||||
uniform float u_time;
|
||||
uniform float u_time_end;
|
||||
uniform sampler2D texture;
|
||||
uniform bool is_shape;
|
||||
|
||||
void main() {
|
||||
if(is_shape) {
|
||||
float tick = (u_time_end - u_time) / u_duration;
|
||||
float blink = smoothstep(1.0, 0.5, tick);
|
||||
vec4 color = vec4(blink, blink, blink, 1.0);
|
||||
gl_FragColor = gl_Color * color;
|
||||
} else {
|
||||
vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);
|
||||
float tick = (u_time_end - u_time) / u_duration;
|
||||
float blink = smoothstep(1.0, 0.5, tick);
|
||||
vec4 color = vec4(blink, blink, blink, 1.0);
|
||||
gl_FragColor = gl_Color * color * pixel;
|
||||
}
|
||||
}
|
12
assets/shaders/ui_shape_shader.frag
Normal file
12
assets/shaders/ui_shape_shader.frag
Normal file
|
@ -0,0 +1,12 @@
|
|||
uniform vec2 u_resolution;
|
||||
uniform vec2 u_mouse;
|
||||
uniform float u_duration;
|
||||
uniform float u_time;
|
||||
uniform float u_time_end;
|
||||
|
||||
void main() {
|
||||
float tick = (u_time_end - u_time) / u_duration;
|
||||
float blink = smoothstep(1.0, 0.5, tick);
|
||||
vec4 color = vec4(blink, blink, blink, 1.0);
|
||||
gl_FragColor = gl_Color * color;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue