just reorganised files thats it
This commit is contained in:
139
Shaders/foliage.gdshader
Normal file
139
Shaders/foliage.gdshader
Normal file
@@ -0,0 +1,139 @@
|
||||
shader_type spatial;
|
||||
render_mode depth_draw_opaque, specular_schlick_ggx, depth_prepass_alpha ;
|
||||
//render_mode blend_mix, cull_disabled, depth_draw_opaque, specular_disabled;
|
||||
|
||||
uniform vec4 TopColor : source_color = vec4(0.24, 0.47, 0.27, 1.0);
|
||||
uniform vec4 BottomColor : source_color = vec4(0.13, 0.33, 0.25, 1.0);
|
||||
uniform sampler2D Alpha;
|
||||
uniform vec4 FresnelColor : source_color = vec4(0.58, 0.65, 0.33, 1.0);
|
||||
|
||||
uniform float WindScale : hint_range(1.0, 20.0) = 1.0;
|
||||
uniform float WindSpeed : hint_range(0.0, 20.0) = 4.0;
|
||||
uniform float WindStrength : hint_range(1.0, 20.0) = 5.0;
|
||||
uniform float WindDensity : hint_range(1.0, 20.0) = 5.0;
|
||||
uniform float ClampTop : hint_range(0.0, 1.0) = 1.0;
|
||||
uniform float ClampBtm : hint_range(-1.0, 0.0) = 0.0;
|
||||
uniform float MeshScale : hint_range(-5.0, 5.0) = -0.333;
|
||||
uniform float ColorRamp : hint_range(0.05, 5.0) = 0.3;
|
||||
|
||||
uniform float FaceRoationVariation : hint_range(-3.0, 3.0) = 1.0;
|
||||
|
||||
uniform float FresnelStrength : hint_range(-2.0, 2.0) = 0.5;
|
||||
uniform float FresnelBlend : hint_range(-1.0, 1.0) = 1.0;
|
||||
uniform bool DeactivateGlobalVariation;
|
||||
// Uniforms for wiggling
|
||||
uniform sampler2D WiggleNoise : hint_default_black;
|
||||
uniform float WiggleFrequency = 3.0;
|
||||
uniform float WiggleStrength = 0.1;
|
||||
uniform float WiggleSpeed = 1.0;
|
||||
uniform float WiggleScale = 3.0;
|
||||
|
||||
uniform float DistanceScale : hint_range(0.0, 5.0) = 0.5;
|
||||
uniform float DistanceStart = 0;
|
||||
uniform float DistanceScaleRange = 70;
|
||||
|
||||
vec2 rotateUV(vec2 uv, float rotation, vec2 mid)
|
||||
{
|
||||
float cosAngle = cos(rotation);
|
||||
float sinAngle = sin(rotation);
|
||||
return vec2(
|
||||
cosAngle * (uv.x - mid.x) + sinAngle * (uv.y - mid.y) + mid.x,
|
||||
cosAngle * (uv.y - mid.y) - sinAngle * (uv.x - mid.x) + mid.y
|
||||
);
|
||||
}
|
||||
|
||||
varying vec3 obj_vertex;
|
||||
void vertex()
|
||||
{
|
||||
float distanceScale = 1.0;
|
||||
vec3 world_pos = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz; //Generates world coordinates for vertecies
|
||||
vec3 distance_vector = world_pos - (INV_VIEW_MATRIX * vec4(0.0, 0.0, 0.0, 1.0)).xyz;
|
||||
float square_distance = distance_vector.x * distance_vector.x + distance_vector.y * distance_vector.y + distance_vector.z * distance_vector.z;
|
||||
float square_end = (DistanceScaleRange + DistanceStart) * (DistanceScaleRange + DistanceStart);
|
||||
float square_start = DistanceStart * DistanceStart;
|
||||
float square_range = square_end - square_start;
|
||||
|
||||
float distance_influence = clamp((square_distance - square_start) / square_range, 0.0, 1.0);
|
||||
//Camera-Orientation based on https://www.youtube.com/watch?v=iASMFba7GeI
|
||||
vec3 orient_2d = vec3(1.0, 1.0, 0.0) - vec3(UV.x, UV.y, 0.0);
|
||||
orient_2d *= 2.0;
|
||||
orient_2d -= vec3(1.0, 1.0, 0.0);
|
||||
orient_2d *= -1.0;
|
||||
orient_2d *= MeshScale;
|
||||
orient_2d *= (1.0 + distance_influence * DistanceScale);
|
||||
|
||||
//random tilt
|
||||
float angle = 6.248 * UV2.x * FaceRoationVariation;
|
||||
float cos_ang = cos(angle);
|
||||
float sin_ang = sin(angle);
|
||||
mat3 rotation = mat3(vec3(cos_ang, -sin_ang, 0.0),vec3(sin_ang, cos_ang, 0.0),vec3(0.0, 0.0, 0.0));
|
||||
|
||||
orient_2d *= rotation;
|
||||
|
||||
vec3 oriented_offset = reflect((INV_VIEW_MATRIX * vec4(orient_2d, 0.0)).xyz,INV_VIEW_MATRIX[0].xyz);
|
||||
//vec3 oriented_offset = (INV_VIEW_MATRIX * vec4(orient_2d, 0.0)).xyz;
|
||||
vec3 obj_oriented_offset = (vec4(oriented_offset, 0.0) * MODEL_MATRIX).xyz;
|
||||
|
||||
//Wind-Effect
|
||||
//adapted from: https://github.com/ruffiely/windshader_godot
|
||||
float contribution = 1.0 * (1.0 - float(DeactivateGlobalVariation));
|
||||
vec3 world_pos_eff = world_pos * contribution; //Generates world coordinates for vertecies
|
||||
// Removed using world_position due to dragging bug
|
||||
float positional_influence = -VERTEX.x + VERTEX.z -world_pos_eff.x + world_pos_eff.z;
|
||||
float offset = fract(positional_influence * (1.0 / WindScale) + (TIME * WindScale/1000.0)); //Generates linear curve that slides along vertecies in world space
|
||||
offset = min(1.0 - offset, offset); //Makes generated curve a smooth gradient
|
||||
offset = (1.0 - offset) * offset * 2.0; //Smoothes gradient further
|
||||
|
||||
float t = TIME + sin(TIME + offset + cos(TIME + offset * WindStrength * 2.0) * WindStrength); //Generates noise in world space value
|
||||
|
||||
//float mask = fract(v.y * wind_density) * v.y; //Generates vertical mask, so leaves on top move further than leaves on bottom
|
||||
//mask = clamp(mask, 0.0, 1.0); //Clamps mask
|
||||
|
||||
float mask = clamp(VERTEX.y* WindDensity, 0.0, 1.0) * (ClampTop - ClampBtm) + ClampBtm;
|
||||
|
||||
|
||||
float si = sin(t) / 20.0 * WindStrength * offset; //Generates clamped noise, adds strength, applies gradient mask
|
||||
float csi = cos(t)/ 20.0 * WindStrength * offset; //Generates clamped noise with offset, adds strength, applies gradient mask
|
||||
|
||||
vec3 wind_offset = vec3(VERTEX.x * si * mask, VERTEX.y * si * mask, VERTEX.z * csi * mask);
|
||||
|
||||
float col = VERTEX.y * ColorRamp;
|
||||
COLOR = vec4(col, positional_influence, distance_influence, 1.0);
|
||||
VERTEX += obj_oriented_offset + wind_offset;
|
||||
|
||||
obj_vertex = VERTEX;
|
||||
}
|
||||
|
||||
void fragment()
|
||||
{
|
||||
float rate_col1 = clamp(COLOR.r,0.0, 1.0);
|
||||
float rate_col2 = 1.0 - rate_col1;
|
||||
|
||||
float fresnel = pow(1.0 - clamp(dot(NORMAL, VIEW), 0.0, 1.0), 3.0);
|
||||
float fresnel_rate = clamp(rate_col1,0.1,1);
|
||||
|
||||
vec3 albedo = TopColor.rgb* rate_col1 + BottomColor.rgb * rate_col2;
|
||||
|
||||
vec3 fres_col = albedo *(1.0 - FresnelStrength);
|
||||
fres_col += FresnelColor.rgb * FresnelStrength;
|
||||
fres_col *= fresnel;
|
||||
fres_col *= fresnel_rate;
|
||||
fres_col *= FresnelBlend;
|
||||
//fres_col *= (1.0 - COLOR.b);
|
||||
|
||||
vec2 wiggle_uv = normalize(obj_vertex.xz) / WiggleScale;
|
||||
float wiggle = texture(WiggleNoise, wiggle_uv + TIME * WiggleSpeed).r;
|
||||
float wiggle_final_strength = wiggle * WiggleStrength;
|
||||
wiggle_final_strength *= clamp(sin(TIME * WiggleFrequency + COLOR.g * 0.2), 0.0, 1.0);
|
||||
vec2 uv = UV;
|
||||
uv = rotateUV(uv, wiggle_final_strength, vec2(0.5));
|
||||
uv = clamp(uv, 0.0, 1.0);
|
||||
vec3 tex = texture(Alpha, uv.xy).rgb;
|
||||
float x = COLOR.b;
|
||||
float alpha = clamp(tex.r + tex.g * 2.0 * COLOR.b ,0.0, 1.0);
|
||||
alpha = clamp((clamp(tex.g * 1.0 , 1.0 - x, 1.0) - (1.0 - x)) * 10.0 + tex.r, 0.0, 1.0);
|
||||
//albedo = vec3(COLOR.b,COLOR.b,COLOR.b);
|
||||
ALBEDO = albedo;
|
||||
ALPHA = alpha;
|
||||
EMISSION = fres_col;
|
||||
}
|
||||
1
Shaders/foliage.gdshader.uid
Normal file
1
Shaders/foliage.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dmb0yy3d7xwba
|
||||
50
Shaders/jitter.gdshader
Normal file
50
Shaders/jitter.gdshader
Normal file
@@ -0,0 +1,50 @@
|
||||
shader_type spatial;
|
||||
render_mode blend_mix,
|
||||
cull_disabled,
|
||||
depth_prepass_alpha,
|
||||
shadows_disabled,
|
||||
specular_disabled,
|
||||
vertex_lighting;
|
||||
|
||||
uniform bool affine_mapping = false;
|
||||
uniform sampler2D albedo : source_color, filter_nearest;
|
||||
uniform float alpha_scissor : hint_range(0, 1) = 0.5;
|
||||
uniform float jitter: hint_range(0, 1) = 0.25;
|
||||
uniform ivec2 resolution = ivec2(320, 240);
|
||||
|
||||
vec4 snap_to_position(vec4 base_position)
|
||||
{
|
||||
vec4 snapped_position = base_position;
|
||||
snapped_position.xyz = base_position.xyz / base_position.w;
|
||||
|
||||
vec2 snap_resulotion = floor(vec2(resolution) * (1.0 - jitter));
|
||||
snapped_position.x = floor(snap_resulotion.x * snapped_position.x) / snap_resulotion.x;
|
||||
snapped_position.y = floor(snap_resulotion.y * snapped_position.y) / snap_resulotion.y;
|
||||
|
||||
snapped_position.xyz *= base_position.w;
|
||||
return snapped_position;
|
||||
}
|
||||
|
||||
void vertex()
|
||||
{
|
||||
vec4 snapped_position = snap_to_position(PROJECTION_MATRIX * MODELVIEW_MATRIX * vec4(VERTEX, 1.0));
|
||||
if (affine_mapping)
|
||||
{
|
||||
POSITION = snapped_position;
|
||||
POSITION /= abs(POSITION.w);
|
||||
}
|
||||
else
|
||||
{
|
||||
POSITION = snapped_position;
|
||||
}
|
||||
}
|
||||
|
||||
void fragment()
|
||||
{
|
||||
vec4 color_base = COLOR;
|
||||
vec4 texture_color = texture(albedo, UV);
|
||||
|
||||
ALBEDO = (color_base * texture_color).rgb;
|
||||
ALPHA = texture_color.a * color_base.a;
|
||||
ALPHA_SCISSOR_THRESHOLD = alpha_scissor;
|
||||
}
|
||||
1
Shaders/jitter.gdshader.uid
Normal file
1
Shaders/jitter.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c5bffujq0l70k
|
||||
15
Shaders/pixelate.gdshader
Normal file
15
Shaders/pixelate.gdshader
Normal file
@@ -0,0 +1,15 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D SCREEN_TEXTURE: hint_screen_texture, filter_linear_mipmap;
|
||||
|
||||
uniform int pixel_size : hint_range(1, 64) = 4; // Pixel size
|
||||
uniform vec2 screen_size = vec2(1920.0, 1080.0); // Screen size (set manually)
|
||||
|
||||
void fragment() {
|
||||
//Pixel coordinates in screen space
|
||||
vec2 pixel_coords = floor(FRAGCOORD.xy / float(pixel_size)) * float(pixel_size);
|
||||
// Convert pixel coordinates to UVs for screen texture
|
||||
vec2 uv = pixel_coords / screen_size;
|
||||
// Get color from texture screen
|
||||
COLOR = texture(SCREEN_TEXTURE, uv);
|
||||
}
|
||||
1
Shaders/pixelate.gdshader.uid
Normal file
1
Shaders/pixelate.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dio8pftmnf0l0
|
||||
75
Shaders/pixeldither.gdshader
Normal file
75
Shaders/pixeldither.gdshader
Normal file
@@ -0,0 +1,75 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform bool shader_enabled = true;
|
||||
|
||||
uniform sampler2D palette;
|
||||
uniform sampler2D SCREEN_TEXTURE: hint_screen_texture, filter_linear_mipmap;
|
||||
uniform bool dithering = false;
|
||||
uniform int dithering_size : hint_range(1, 16) = 2;
|
||||
uniform int resolution_scale : hint_range(1, 64) = 2;
|
||||
uniform int quantization_level : hint_range(2, 64) = 64;
|
||||
|
||||
int dithering_pattern(ivec2 fragcoord) {
|
||||
const int pattern[] = {
|
||||
-4, +0, -3, +1,
|
||||
+2, -2, +3, -1,
|
||||
-3, +1, -4, +0,
|
||||
+3, -1, +2, -2
|
||||
};
|
||||
int x = fragcoord.x % 4;
|
||||
int y = fragcoord.y % 4;
|
||||
return pattern[y * 4 + x] * dithering_size;
|
||||
}
|
||||
|
||||
float color_distance(vec3 a, vec3 b) {
|
||||
vec3 diff = a - b;
|
||||
return dot(diff, diff);
|
||||
}
|
||||
|
||||
vec3 quantize_color(vec3 color, int levels) {
|
||||
if (levels <= 1) return vec3(0.0);
|
||||
float step = 1.0 / float(levels - 1);
|
||||
return round(color / step) * step;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec4 final_color;
|
||||
|
||||
if (!shader_enabled) {
|
||||
final_color = texture(SCREEN_TEXTURE, UV);
|
||||
} else {
|
||||
vec2 tex_size = vec2(textureSize(SCREEN_TEXTURE, 0));
|
||||
|
||||
if (tex_size.x <= 0.0 || tex_size.y <= 0.0) {
|
||||
final_color = vec4(0.0);
|
||||
} else {
|
||||
ivec2 texel_coord = ivec2(floor(UV * tex_size / float(resolution_scale)));
|
||||
vec3 color = texelFetch(SCREEN_TEXTURE, texel_coord * resolution_scale, 0).rgb;
|
||||
|
||||
if (dithering) {
|
||||
int dither = dithering_pattern(texel_coord);
|
||||
color += vec3(float(dither) / 255.0);
|
||||
}
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
color = quantize_color(color, quantization_level);
|
||||
|
||||
int palette_size = 64;
|
||||
float closest_distance = 9999.0;
|
||||
vec4 closest_color = vec4(0.0);
|
||||
|
||||
for (int i = 0; i < palette_size; i++) {
|
||||
float u = float(i) / float(palette_size - 1);
|
||||
vec3 palette_color = texture(palette, vec2(u, 0.0)).rgb;
|
||||
float dist = color_distance(color, palette_color);
|
||||
if (dist < closest_distance) {
|
||||
closest_distance = dist;
|
||||
closest_color = vec4(palette_color, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
final_color = closest_color;
|
||||
}
|
||||
}
|
||||
|
||||
COLOR = final_color;
|
||||
}
|
||||
1
Shaders/pixeldither.gdshader.uid
Normal file
1
Shaders/pixeldither.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://diugvmtoos1ti
|
||||
35
Shaders/playstation.gdshader
Normal file
35
Shaders/playstation.gdshader
Normal file
@@ -0,0 +1,35 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D SCREEN_TEXTURE: hint_screen_texture, filter_linear_mipmap;
|
||||
uniform int resolution_scale : hint_range(1, 64) = 1;
|
||||
|
||||
uniform float dither_spread = 1.0;
|
||||
uniform float dither_gamma = 1.0;
|
||||
|
||||
|
||||
void fragment() {
|
||||
vec2 tex_size = vec2(textureSize(SCREEN_TEXTURE, 0));
|
||||
ivec2 texel_coord = ivec2(floor(UV * tex_size / float(resolution_scale)));
|
||||
vec3 color = texelFetch(SCREEN_TEXTURE, texel_coord * resolution_scale, 0).rgb;
|
||||
|
||||
int ps1_dither_matrix[16] = {
|
||||
-4, 0, -3, 1,
|
||||
2, -2, 3, -1,
|
||||
-3, 1, -4, 0,
|
||||
3, -1, 2, -2
|
||||
};
|
||||
|
||||
// Index 1D dither matrix based on 2D screen coordinates
|
||||
float noise = float(ps1_dither_matrix[(int(texel_coord.x) % 4) + (int(texel_coord.y) % 4) * 4]);
|
||||
|
||||
// Apply dithering and quantize 24 bit srgb to 15 bit srgb according to https://psx-spx.consoledev.net/graphicsprocessingunitgpu/
|
||||
color = pow(color, vec3(1.0 / dither_gamma)); // Convert to srgb cause it imo looks better and is probably correct idk looks more correct than linear quantization
|
||||
color = round(color * 255.0 + noise); // Convert to 0-255 and add dither noise
|
||||
color = clamp(round(color), vec3(0), vec3(255)); // Clamp to 0-255 in case of overflow
|
||||
color = clamp(color / 8.0, vec3(0), vec3(31)); // Convert to 0-31 range
|
||||
color /= 31.0; // Convert back to 0-1 range
|
||||
|
||||
color = pow(color, vec3(dither_gamma)); // Convert back to linear
|
||||
|
||||
COLOR = vec4(color, 1.0);
|
||||
}
|
||||
1
Shaders/playstation.gdshader.uid
Normal file
1
Shaders/playstation.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dsn7gkhdg1xbb
|
||||
72
Shaders/psx.gdshader
Normal file
72
Shaders/psx.gdshader
Normal file
@@ -0,0 +1,72 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
render_mode unshaded;
|
||||
|
||||
#define MAXCOLORS 16
|
||||
|
||||
uniform bool enabled = true;
|
||||
uniform bool dithering = true;
|
||||
uniform int colors : hint_range(1, MAXCOLORS) = 12;
|
||||
uniform int dither_size: hint_range(1, 8) = 1;
|
||||
|
||||
float dithering_pattern(ivec2 fragcoord) {
|
||||
const float pattern[] = {
|
||||
0.00, 0.50, 0.10, 0.65,
|
||||
0.75, 0.25, 0.90, 0.35,
|
||||
0.20, 0.70, 0.05, 0.50,
|
||||
0.95, 0.40, 0.80, 0.30
|
||||
};
|
||||
|
||||
int x = fragcoord.x % 4;
|
||||
int y = fragcoord.y % 4;
|
||||
|
||||
return pattern[y * 4 + x];
|
||||
}
|
||||
|
||||
float reduce_color(float raw, float dither, int depth) {
|
||||
float div = 1.0 / float(depth);
|
||||
float val = 0.0;
|
||||
int i = 0;
|
||||
|
||||
while (i <= MAXCOLORS)
|
||||
{
|
||||
if (raw > div * (float(i + 1))) {
|
||||
i = i + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (raw * float(depth) - float(i) <= dither * 0.999)
|
||||
{
|
||||
val = div * float(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
val = div * float(i + 1);
|
||||
}
|
||||
return val;
|
||||
|
||||
i = i+1;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec4 raw = texture(TEXTURE, SCREEN_UV);
|
||||
ivec2 uv = ivec2(FRAGCOORD.xy / float(dither_size));
|
||||
|
||||
if (enabled == true){
|
||||
float dithering_value = 1.0;
|
||||
if (dithering)
|
||||
{
|
||||
dithering_value = dithering_pattern(uv);
|
||||
}
|
||||
|
||||
COLOR.r = reduce_color(raw.r, (dithering_value - 0.5) * dithering_value + 0.5, colors - 1);
|
||||
COLOR.g = reduce_color(raw.g, (dithering_value - 0.5) * dithering_value + 0.5, colors - 1);
|
||||
COLOR.b = reduce_color(raw.b, (dithering_value - 0.5) * dithering_value + 0.5, colors - 1);
|
||||
|
||||
} else {
|
||||
COLOR.rgb = raw.rgb;
|
||||
}
|
||||
}
|
||||
1
Shaders/psx.gdshader.uid
Normal file
1
Shaders/psx.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://y78cbva8erip
|
||||
30
Shaders/tiler.gdshader
Normal file
30
Shaders/tiler.gdshader
Normal file
@@ -0,0 +1,30 @@
|
||||
shader_type spatial;
|
||||
render_mode blend_mix;
|
||||
|
||||
uniform float scroll_speed : hint_range(0, 2) = 0.08;
|
||||
uniform float angle_degrees : hint_range(0, 360) = 45.0;
|
||||
uniform float repeat_x : hint_range(1, 20) = 20;
|
||||
uniform float repeat_y : hint_range(1, 20) = 12;
|
||||
uniform float row_offset : hint_range(0, 1) = 1;
|
||||
uniform sampler2D texture_to_scroll;
|
||||
|
||||
void fragment() {
|
||||
float angle_rad = radians(angle_degrees);
|
||||
|
||||
vec2 direction = vec2(cos(angle_rad), sin(angle_rad));
|
||||
|
||||
vec2 offset_uv = UV - (TIME * scroll_speed * direction);
|
||||
|
||||
float offset = fract(floor(offset_uv.y * repeat_y) * 0.5) > 0.0 ? (row_offset * 0.324) : 0.0;
|
||||
|
||||
offset_uv.x += offset;
|
||||
|
||||
vec2 scaled_uv = vec2(fract(offset_uv.x * repeat_x),
|
||||
fract(offset_uv.y * repeat_y));
|
||||
|
||||
vec2 texelSize = vec2(1.0) / vec2(textureSize(texture_to_scroll, 0));
|
||||
//vec2 snappedUV = round(scaled_uv / texelSize) * texelSize;
|
||||
|
||||
ALBEDO = texture(texture_to_scroll, offset_uv).rgb;
|
||||
ALPHA = texture(texture_to_scroll, offset_uv).a;
|
||||
}
|
||||
1
Shaders/tiler.gdshader.uid
Normal file
1
Shaders/tiler.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dmgdero70g5d5
|
||||
Reference in New Issue
Block a user