I'm trying to create a shader which Ideally produces this:
And so far I've come up with this shader:
shader_type canvas_item;
uniform vec4 main_color : hint_color = vec4(1.0);
uniform float outter_radius : hint_range(0.0, 1.0) = 1.0;
uniform float inner_radius : hint_range(0.0, 1.0) = 1.0;
uniform float blur_radius : hint_range(0.0, 1.0) = 1.0;
void fragment() {
float dist_length=distance(UV, vec2(0.5));
COLOR=main_color;
if(dist_length<outter_radius && dist_length>inner_radius)
COLOR.a=(dist_length - inner_radius)/(outter_radius - inner_radius);
else if(dist_length<blur_radius && dist_length>outter_radius)
COLOR.a=(blur_radius - dist_length)/(blur_radius - outter_radius);
else
COLOR=vec4(0.0);
}
Which produces this:
But I'm stuck trying to add the speed lines, I tried combining this shader as such:
shader_type canvas_item;
uniform vec4 main_color : hint_color = vec4(1.0);
uniform float outter_radius : hint_range(0.0, 1.0) = 1.0;
uniform float inner_radius : hint_range(0.0, 1.0) = 1.0;
uniform float blur_radius : hint_range(0.0, 1.0) = 1.0;
uniform sampler2D noise;
uniform float sample_radius: hint_range(0.0, 1.0) = 0.5;
uniform vec4 line_color: hint_color = vec4(1.0);
uniform float center_radius: hint_range(0.0, 1.0) = 0.5;
const float pi = 3.14159265359;
void fragment() {
vec2 dist = UV - vec2(0.5);
float dist_length=length(dist);
float angle = atan(dist.y / dist.x);
vec2 sample = vec2(sample_radius * cos(angle), sample_radius * sin(angle));
float noise_value = texture(noise, sample).r;
if(dist_length<outter_radius){
vec4 lines_color=mix(line_color, vec4(0.0), noise_value);
lines_color = mix(lines_color, vec4(0.0), 1.0 - dist_length - center_radius);
COLOR=lines_color;
if(dist_length>inner_radius){
COLOR+=main_color;
COLOR.a=(dist_length - inner_radius)/(outter_radius - inner_radius);
}
}
else{
if(dist_length<blur_radius){
COLOR += main_color;
COLOR.a=(blur_radius - dist_length)/(blur_radius - outter_radius);
}
else
COLOR=vec4(0.0);
}
}
And even if I do get it to work I'm still left with the problem that the center won't be hollow as shown in the Ideal image
So is there any fix for this? or a completely different approach I should be taking?