Extensive work on virtually all of the visuals and the net code
This commit is contained in:
40
visuals/shaders/intersection.gdshader
Normal file
40
visuals/shaders/intersection.gdshader
Normal file
@@ -0,0 +1,40 @@
|
||||
shader_type spatial;
|
||||
render_mode blend_add, cull_disabled;
|
||||
|
||||
uniform vec4 intersection_color : source_color = vec4(1.0, 0.5, 0.0, 1.0);
|
||||
uniform float intersection_thickness = 0.5;
|
||||
uniform float intensity = 1.0f;
|
||||
uniform sampler2D DEPTH_TEXTURE : hint_depth_texture, filter_linear_mipmap;
|
||||
|
||||
void fragment() {
|
||||
// 1. Get linear depth of the scene (opaque objects)
|
||||
float depth = texture(DEPTH_TEXTURE, SCREEN_UV).x;
|
||||
vec3 ndc = vec3(SCREEN_UV * 2.0 - 1.0, depth);
|
||||
vec4 view = INV_PROJECTION_MATRIX * vec4(ndc, 1.0);
|
||||
view.xyz /= view.w;
|
||||
float linear_depth = -view.z;
|
||||
|
||||
// 2. Get linear depth of the current object
|
||||
float linear_frag_coord = -VERTEX.z;
|
||||
|
||||
// 3. Calculate difference
|
||||
float diff = linear_depth - linear_frag_coord;
|
||||
|
||||
// 4. Create intersection mask
|
||||
float intersect = clamp(diff / intersection_thickness, 0.0, 1.0);
|
||||
|
||||
// Invert so the intersection is 1.0
|
||||
intersect = 1.0 - intersect;
|
||||
|
||||
// Output color
|
||||
float strength = .25 + .75 * (1.0 + sin(TIME*3.0))/2.0;
|
||||
|
||||
ALPHA = max(.05, intersect * intersection_color.a * strength);
|
||||
if(ALPHA == .05){
|
||||
ALBEDO = intersection_color.rgb;
|
||||
}else{
|
||||
ALBEDO = intersection_color.rgb * strength;
|
||||
EMISSION = intersection_color.rgb * intensity * strength; // Glow effect
|
||||
}
|
||||
|
||||
}
|
||||
1
visuals/shaders/intersection.gdshader.uid
Normal file
1
visuals/shaders/intersection.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://byr88gb5fk3w2
|
||||
@@ -2,28 +2,33 @@ shader_type canvas_item;
|
||||
|
||||
uniform sampler2D chars;
|
||||
uniform sampler2D noise_tex;
|
||||
uniform float offset;
|
||||
|
||||
void fragment() {
|
||||
// Random character
|
||||
vec2 uv = fract(UV * 32.0); // loop uv 32 times for the characters (as the noise resolution is 32x32)
|
||||
//vec2 uv = vec2(0,0);
|
||||
float noise = texture(noise_tex, UV).g;
|
||||
noise = round(noise * 26.0) / 26.0; // make sure the color value are snapped by 0.1 (so its only 0.0, 0.1, 0.2, and so on) for perfect offset
|
||||
uv.x = (uv.x / 26.0); // offset
|
||||
uv.x += noise; // offset every character by the noise value
|
||||
uv.x += round(TIME * 0.5 * 26.0)/26.0; // animate characters with TIME, then snapped by 0.1 so it doesnt slide. 0.5 is the speed, you might want to change that
|
||||
noise = round(noise * 0.1) / 0.1; // make sure the color value are snapped by 0.1 (so its only 0.0, 0.1, 0.2, and so on) for perfect offset
|
||||
//uv.x = (uv.x / 26.0); // offset
|
||||
//uv.x = UV.x;
|
||||
//uv.x += noise; // offset every character by the noise value
|
||||
uv.x = fract(UV.x + round(TIME * 0.1 * 26.0)/26.0);
|
||||
//uv.x += round(TIME * 0.5 * 26.0)/26.0; // animate characters with TIME, then snapped by 0.1 so it doesnt slide. 0.5 is the speed, you might want to change that
|
||||
|
||||
// distortion
|
||||
float rain = UV.y; // this is a vertical gradient
|
||||
float distortion = texture(noise_tex, UV / vec2(1.0, 32.0)).g; // this will be used for distortion, using previous noise but only horizontal
|
||||
float distortion = texture(noise_tex, (UV + vec2(0,offset)) / vec2(1.0, 64.0)).g; // this will be used for distortion, using previous noise but only horizontal
|
||||
distortion = round(distortion * 26.0) / 26.0; // for precision reason, you need to round your distortion too, otherwise some character wouldnt be fully shown
|
||||
rain -= round(TIME * 0.2 * 32.0) / 32.0; // the 'rain' shouldn't move smoothly right? also, 0.2 is the speed
|
||||
rain -= round((TIME + offset) * 0.2 * 32.0) / 32.0; // the 'rain' shouldn't move smoothly right? also, 0.2 is the speed
|
||||
rain += distortion; // distort this gradient, turning it into a rain
|
||||
rain = fract(rain); // loop the rain
|
||||
rain = round(rain * 16.0) / 16.0; // pixelate the rain. Rounding by 32.0 or 8.0 is optional
|
||||
rain = pow(rain, 3.0); // this is not necessary, i just think that it looks good
|
||||
rain = round(rain * 128.0) / 128.0; // pixelate the rain. Rounding by 32.0 or 8.0 is optional
|
||||
rain = pow(rain, 5.0); // this is not necessary, i just think that it looks good
|
||||
rain *= 2.0; // this is also not important, just making the characters brighter
|
||||
|
||||
COLOR.rgb = texture(chars, uv).rgb * rain * vec3(0.0, 1.0, 0.0); // finally multiply them together then multiply with green for the color
|
||||
COLOR.rgb = texture(chars, vec2(uv.x, uv.y)).rgb * rain * vec3(0.0, 1.0, 0.0); // finally multiply them together then multiply with green for the color
|
||||
COLOR.a = rain;
|
||||
}
|
||||
|
||||
|
||||
|
||||
38
visuals/shaders/outline.gdshader
Normal file
38
visuals/shaders/outline.gdshader
Normal file
@@ -0,0 +1,38 @@
|
||||
shader_type spatial;
|
||||
render_mode unshaded, diffuse_lambert;
|
||||
|
||||
uniform float amount = 3.0f;
|
||||
uniform float intensity = 1.0f;
|
||||
uniform vec3 fresnel_color : source_color = vec3(1,1,1);
|
||||
uniform sampler2D noise_texture;
|
||||
varying float flux;
|
||||
|
||||
float fresnel(vec3 normal, vec3 view)
|
||||
{
|
||||
return pow((1.0 - clamp(dot(normalize(normal), normalize(view)), 0.0, 1.0 )), amount);
|
||||
}
|
||||
|
||||
vec3 fresnel_glow(vec3 normal, vec3 view)
|
||||
{
|
||||
return pow((1.0 - dot(normalize(normal), normalize(view))), amount) * fresnel_color * intensity;
|
||||
}
|
||||
|
||||
void vertex()
|
||||
{
|
||||
flux = .1 + .9 * texture(noise_texture, vec2(UV.x + TIME * .1, UV.y + TIME*.2)).r;
|
||||
}
|
||||
void fragment()
|
||||
{
|
||||
|
||||
vec3 base_color = vec3(0.0);
|
||||
vec3 basic_fresnel = fresnel_glow(NORMAL, VIEW);
|
||||
float f = texture(noise_texture, vec2(NORMAL.x + TIME * .1, NORMAL.y + TIME*.2)).r;
|
||||
ALBEDO = base_color + basic_fresnel * f;
|
||||
float fres_alpha = fresnel(NORMAL, VIEW);
|
||||
ALPHA = fres_alpha;
|
||||
}
|
||||
|
||||
//void light() {
|
||||
// // Called for every pixel for every light affecting the material.
|
||||
// // Uncomment to replace the default light processing function with this one.
|
||||
//}
|
||||
1
visuals/shaders/outline.gdshader.uid
Normal file
1
visuals/shaders/outline.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://g2hj3keuywp4
|
||||
Reference in New Issue
Block a user