Updated to 4.4
This commit is contained in:
parent
eaa26d1361
commit
1aff15069a
151 changed files with 593 additions and 100 deletions
1
Testbed/DistanceFaceWorld.gdshader.uid
Normal file
1
Testbed/DistanceFaceWorld.gdshader.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://boiay83j4p11x
|
||||
108
Testbed/FilmGrain.gdshader
Normal file
108
Testbed/FilmGrain.gdshader
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D screen_texture : hint_screen_texture;
|
||||
uniform float grain_amount : hint_range(0.0, 1.0) = 0.05; // Adjust the amount of grain
|
||||
uniform float grain_size : hint_range(0.1, 10.0) = 1.0; // Adjust the size of the grain
|
||||
uniform bool animate = false;
|
||||
|
||||
//void fragment() {
|
||||
//// Sample the original screen texture
|
||||
//vec4 original_color = texture(screen_texture, SCREEN_UV);
|
||||
//
|
||||
//float noise = 0.0;
|
||||
//
|
||||
//if (animate) {
|
||||
//// Generate random noise
|
||||
//noise = (fract(sin(dot(UV * TIME, vec2(12.9898, 78.233))) * 43758.5453) - 0.5) * 2.0;
|
||||
//} else {
|
||||
//noise = (fract(sin(dot(UV, vec2(12.9898, 78.233))) * 43758.5453) - 0.5) * 2.0;
|
||||
//}
|
||||
//// Add noise to the original color
|
||||
//original_color.rgb += noise * grain_amount * grain_size;
|
||||
//
|
||||
//// Clamp the final color to make sure it stays in the valid range
|
||||
//COLOR = clamp(original_color, 0.0, 1.0);
|
||||
//}
|
||||
|
||||
|
||||
// Feel free to steal this :^)
|
||||
// Consider it MIT licensed, you can link to this page if you want to.
|
||||
|
||||
#define SHOW_NOISE 0
|
||||
#define SRGB 0
|
||||
// 0: Addition, 1: Screen, 2: Overlay, 3: Soft Light, 4: Lighten-Only
|
||||
#define BLEND_MODE 4
|
||||
#define SPEED 1.0
|
||||
#define INTENSITY 0.05
|
||||
// What gray level noise should tend to.
|
||||
#define MEAN 0.0
|
||||
// Controls the contrast/variance of noise.
|
||||
#define VARIANCE 0.5
|
||||
|
||||
vec3 channel_mix(vec3 a, vec3 b, vec3 w) {
|
||||
return vec3(mix(a.r, b.r, w.r), mix(a.g, b.g, w.g), mix(a.b, b.b, w.b));
|
||||
}
|
||||
|
||||
float gaussian(float z, float u, float o) {
|
||||
return (1.0 / (o * sqrt(2.0 * 3.1415))) * exp(-(((z - u) * (z - u)) / (2.0 * (o * o))));
|
||||
}
|
||||
|
||||
vec3 madd(vec3 a, vec3 b, float w) {
|
||||
return a + a * b * w;
|
||||
}
|
||||
|
||||
vec3 screen(vec3 a, vec3 b, float w) {
|
||||
return mix(a, vec3(1.0) - (vec3(1.0) - a) * (vec3(1.0) - b), w);
|
||||
}
|
||||
|
||||
vec3 overlay(vec3 a, vec3 b, float w) {
|
||||
return mix(a, channel_mix(
|
||||
2.0 * a * b,
|
||||
vec3(1.0) - 2.0 * (vec3(1.0) - a) * (vec3(1.0) - b),
|
||||
step(vec3(0.5), a)
|
||||
), w);
|
||||
}
|
||||
|
||||
vec3 soft_light(vec3 a, vec3 b, float w) {
|
||||
return mix(a, pow(a, pow(vec3(2.0), 2.0 * (vec3(0.5) - b))), w);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec2 ps = vec2(1.0) / (1.0 / SCREEN_PIXEL_SIZE).xy;
|
||||
vec2 uv = SCREEN_UV; //coord * ps;
|
||||
COLOR = texture(screen_texture, uv);
|
||||
#if SRGB
|
||||
color = pow(color, vec4(2.2));
|
||||
#endif
|
||||
|
||||
float t = TIME * float(SPEED);
|
||||
float seed = dot(uv, vec2(12.9898, 78.233));
|
||||
float noise = fract(sin(seed) * 43758.5453 + t);
|
||||
noise = gaussian(noise, float(MEAN), float(VARIANCE) * float(VARIANCE));
|
||||
|
||||
#if SHOW_NOISE
|
||||
COLOR = vec4(noise);
|
||||
#else
|
||||
// Ignore these mouse stuff if you're porting this
|
||||
// and just use an arbitrary intensity value.
|
||||
float w = float(INTENSITY);
|
||||
|
||||
vec3 grain = vec3(noise) * (1.0 - COLOR.rgb);
|
||||
|
||||
#if BLEND_MODE == 0
|
||||
COLOR.rgb += grain * w;
|
||||
#elif BLEND_MODE == 1
|
||||
COLOR.rgb = screen(COLOR.rgb, grain, w);
|
||||
#elif BLEND_MODE == 2
|
||||
COLOR.rgb = overlay(COLOR.rgb, grain, w);
|
||||
#elif BLEND_MODE == 3
|
||||
COLOR.rgb = soft_light(COLOR.rgb, grain, w);
|
||||
#elif BLEND_MODE == 4
|
||||
COLOR.rgb = max(COLOR.rgb, grain * w);
|
||||
#endif
|
||||
|
||||
#if SRGB
|
||||
COLOR = pow(COLOR, vec4(1.0 / 2.2));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
1
Testbed/FilmGrain.gdshader.uid
Normal file
1
Testbed/FilmGrain.gdshader.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dlplsrexke1rc
|
||||
|
|
@ -15,22 +15,22 @@ float pristineGrid( vec2 uv, vec2 lineWidth)
|
|||
{
|
||||
vec2 ddx = dFdx(uv);
|
||||
vec2 ddy = dFdy(uv);
|
||||
|
||||
|
||||
vec2 uvDeriv = vec2(length(vec2(ddx.x, ddy.x)), length(vec2(ddx.y, ddy.y)));
|
||||
bvec2 invertLine = bvec2(lineWidth.x > 0.5, lineWidth.y > 0.5);
|
||||
|
||||
|
||||
vec2 targetWidth = vec2(
|
||||
invertLine.x ? 1.0 - lineWidth.x : lineWidth.x,
|
||||
invertLine.y ? 1.0 - lineWidth.y : lineWidth.y
|
||||
);
|
||||
|
||||
|
||||
vec2 drawWidth = clamp(targetWidth, uvDeriv, vec2(0.5));
|
||||
vec2 lineAA = uvDeriv * 1.5;
|
||||
vec2 gridUV = abs(fract(uv) * 2.0 - 1.0);
|
||||
|
||||
|
||||
gridUV.x = invertLine.x ? gridUV.x : 1.0 - gridUV.x;
|
||||
gridUV.y = invertLine.y ? gridUV.y : 1.0 - gridUV.y;
|
||||
|
||||
|
||||
vec2 grid2 = smoothstep(drawWidth + lineAA, drawWidth - lineAA, gridUV);
|
||||
|
||||
grid2 *= clamp(targetWidth / drawWidth, 0.0, 1.0);
|
||||
|
|
@ -40,18 +40,18 @@ float pristineGrid( vec2 uv, vec2 lineWidth)
|
|||
return mix(grid2.x, 1.0, grid2.y);
|
||||
}
|
||||
|
||||
void vertex()
|
||||
void vertex()
|
||||
{
|
||||
//UV = VERTEX.xz;
|
||||
}
|
||||
|
||||
void fragment()
|
||||
void fragment()
|
||||
{
|
||||
vec3 grid_0 = vec3(pristineGrid(UV * float(scale_0), vec2(line_scale_0)));
|
||||
vec3 grid_1 = vec3(pristineGrid(UV * float(scale_1), vec2(line_scale_1)));
|
||||
|
||||
|
||||
vec3 grid_3 = mix(grid_1 * color_1.rgb, grid_0 * color_0.rgb, grid_0);
|
||||
|
||||
|
||||
ALBEDO = grid_3;
|
||||
ALPHA = 1.5;
|
||||
}
|
||||
1
Testbed/GridTest.gdshader.uid
Normal file
1
Testbed/GridTest.gdshader.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dw683olkkdkd4
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_resource type="ShaderMaterial" load_steps=5 format=3 uid="uid://dv2oo7hlc5nyy"]
|
||||
|
||||
[ext_resource type="Shader" path="res://Testbed/DistanceFaceWorld.gdshader" id="1_edhah"]
|
||||
[ext_resource type="Shader" uid="uid://boiay83j4p11x" path="res://Testbed/DistanceFaceWorld.gdshader" id="1_edhah"]
|
||||
[ext_resource type="Texture2D" uid="uid://cilgpyanfb3a8" path="res://Testbed/textures/wood_table_001_diff_4k.jpg" id="2_hb1x7"]
|
||||
[ext_resource type="Texture2D" uid="uid://diamo44e2x4if" path="res://Testbed/textures/wood_table_001_disp_4k.png" id="3_eyslc"]
|
||||
[ext_resource type="Texture2D" uid="uid://b6ejmikbfrprs" path="res://Testbed/textures/wood_table_001_rough_4k.jpg" id="4_r705j"]
|
||||
|
|
@ -9,14 +9,14 @@
|
|||
render_priority = 0
|
||||
shader = ExtResource("1_edhah")
|
||||
shader_parameter/albedo = Color(1, 1, 1, 1)
|
||||
shader_parameter/texture_albedo = ExtResource("2_hb1x7")
|
||||
shader_parameter/distance_fade_min = 0.0
|
||||
shader_parameter/distance_fade_max = 0.0
|
||||
shader_parameter/roughness = 0.8
|
||||
shader_parameter/metallic_texture_channel = null
|
||||
shader_parameter/texture_metallic = ExtResource("3_eyslc")
|
||||
shader_parameter/metallic_texture_channel = Vector4(0, 0, 0, 0)
|
||||
shader_parameter/texture_roughness = ExtResource("4_r705j")
|
||||
shader_parameter/specular = 0.6
|
||||
shader_parameter/metallic = 0.5
|
||||
shader_parameter/uv1_scale = Vector3(1, 1, 1)
|
||||
shader_parameter/uv1_offset = Vector3(0, 0, 0)
|
||||
shader_parameter/texture_albedo = ExtResource("2_hb1x7")
|
||||
shader_parameter/texture_metallic = ExtResource("3_eyslc")
|
||||
shader_parameter/texture_roughness = ExtResource("4_r705j")
|
||||
|
|
|
|||
1
Testbed/UIBlur.gdshader.uid
Normal file
1
Testbed/UIBlur.gdshader.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://nkowetasi3ka
|
||||
Loading…
Add table
Add a link
Reference in a new issue