makes shaders round (#263)
This commit is contained in:
committed by
Pieter-Jan Briers
parent
f81ca7ceba
commit
ff4190b4e1
@@ -1,13 +1,17 @@
|
||||
float circle(in vec2 _st, in float _radius){
|
||||
vec2 dist = _st-vec2(0.5);
|
||||
return smoothstep(_radius-(_radius*0.01),
|
||||
_radius+(_radius*0.01),
|
||||
dot(dist,dist)*4.0);
|
||||
vec4 circle(in vec2 uv, in vec2 pos, float rad, in vec3 color) {
|
||||
float d = length(pos - uv) - rad;
|
||||
float t = clamp(d, 0.0, 1.0);
|
||||
return vec4(color, t);
|
||||
}
|
||||
|
||||
void fragment(){
|
||||
vec2 st = FRAGCOORD.xy*SCREEN_PIXEL_SIZE.xy;
|
||||
vec2 uv = FRAGCOORD.xy;
|
||||
vec2 res_xy = vec2(1.0/SCREEN_PIXEL_SIZE.x, 1.0/SCREEN_PIXEL_SIZE.y);
|
||||
vec2 center = res_xy*0.5;
|
||||
float radius = 0.05 * res_xy.y;
|
||||
|
||||
COLOR.rgb = vec3(0);
|
||||
COLOR.a = circle(st,0.05);
|
||||
}
|
||||
vec4 layer1 = vec4(vec3(0), 0.0);
|
||||
|
||||
vec4 layer2 = circle(uv, center, radius, vec3(0));
|
||||
|
||||
COLOR = mix(layer1, layer2, layer2.a);
|
||||
}
|
||||
@@ -1,9 +1,23 @@
|
||||
uniform float percentagedistanceshow = 0.1;
|
||||
uniform float gradientfalloffwidth = 0.2;
|
||||
uniform float percentagedistanceshow = 0.05;
|
||||
uniform float gradientfalloffwidth = 3.0;
|
||||
|
||||
vec4 circle(in vec2 uv, in vec2 pos, float rad, in vec3 color) {
|
||||
float d = length(pos - uv) - rad;
|
||||
float t = clamp(d, 0.0, 1.0);
|
||||
return vec4(color, t);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
float dist = distance(UV, vec2(0.5, 0.5));
|
||||
float fromdiskdist = dist - percentagedistanceshow;
|
||||
COLOR.a = max(0, min(1.0, 2.0*dist/percentagedistanceshow - 2.0));
|
||||
COLOR.rgb = vec3(1,1,1) - vec3(fromdiskdist,fromdiskdist,fromdiskdist)/gradientfalloffwidth;
|
||||
vec2 uv = FRAGCOORD.xy;
|
||||
vec2 res_xy = vec2(1.0/SCREEN_PIXEL_SIZE.x, 1.0/SCREEN_PIXEL_SIZE.y);
|
||||
vec2 center = res_xy*0.5;
|
||||
float radius = percentagedistanceshow * res_xy.y;
|
||||
|
||||
vec4 grad = vec4(0.8 - length( uv - center )/res_xy.y * gradientfalloffwidth);
|
||||
|
||||
vec4 layer1 = vec4(vec3(255.0),0.0);
|
||||
|
||||
vec4 layer2 = circle(uv, center, radius, grad.rgb);
|
||||
|
||||
COLOR = mix(layer1, layer2, layer2.a);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user