Last active
July 24, 2024 05:11
-
-
Save zmarcos/069a48ff7091c431ac82dff0fd319bc9 to your computer and use it in GitHub Desktop.
Checkers Shadow Material
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[gd_resource type="ShaderMaterial" load_steps=7 format=2] | |
[sub_resource type="VisualShaderNodeGlobalExpression" id=1] | |
size = Vector2( 690, 490 ) | |
expression = "float checker(vec3 uva){ | |
vec3 c = uva; | |
c *= 40.0;//square modifier, recommended values (20,40,80,160) | |
c = mod(trunc(c), 2.0); | |
float r = 0.0; | |
if(c.x > 0.0 && c.y < 1.0){ | |
r = 1.0; | |
} | |
if(c.x < 1.0 && c.y > 0.0){ | |
r = 1.0; | |
} | |
return r; | |
} | |
float luma(vec3 cor){ | |
return (cor.r * 0.2126) + (cor.g * 0.7152) + (cor.b * 0.0722); | |
} | |
vec3 correct_ratio(vec3 uva, vec3 vport){ | |
vec3 r = uva; | |
float ratio = vport.x / vport.y; | |
r.x *= ratio; | |
return r; | |
}" | |
[sub_resource type="VisualShaderNodeExpression" id=2] | |
size = Vector2( 639, 348 ) | |
expression = "o0 = checker(correct_ratio(i0, i1)); | |
o1 = 1.0; | |
o2 = i2; | |
vec3 c = texture(SCREEN_TEXTURE, i0.xy).rgb; | |
o2 = c; | |
float l = luma(c); | |
if((l < 0.1)&&(l > 0.01)){ | |
//o1 = 0.0; | |
if(o0 > 0.0){ | |
o2 = i2; | |
} | |
}" | |
[sub_resource type="VisualShaderNodeInput" id=3] | |
input_name = "viewport_size" | |
[sub_resource type="VisualShaderNodeColorUniform" id=4] | |
uniform_name = "color1" | |
[sub_resource type="VisualShaderNodeInput" id=5] | |
input_name = "screen_uv" | |
[sub_resource type="VisualShader" id=6] | |
code = "shader_type spatial; | |
render_mode diffuse_toon, specular_disabled, unshaded, shadows_disabled, ambient_light_disabled; | |
uniform vec4 color1 : hint_color; | |
// GlobalExpression:0 | |
float checker(vec3 uva){ | |
vec3 c = uva; | |
c *= 40.0;//square modifier, recommended values (20,40,80,160) | |
c = mod(trunc(c), 2.0); | |
float r = 0.0; | |
if(c.x > 0.0 && c.y < 1.0){ | |
r = 1.0; | |
} | |
if(c.x < 1.0 && c.y > 0.0){ | |
r = 1.0; | |
} | |
return r; | |
} | |
float luma(vec3 cor){ | |
return (cor.r * 0.2126) + (cor.g * 0.7152) + (cor.b * 0.0722); | |
} | |
vec3 correct_ratio(vec3 uva, vec3 vport){ | |
vec3 r = uva; | |
float ratio = vport.x / vport.y; | |
r.x *= ratio; | |
return r; | |
} | |
void vertex() { | |
// Output:0 | |
} | |
void fragment() { | |
// Input:8 | |
vec3 n_out8p0; | |
n_out8p0 = vec3(SCREEN_UV,0.0); | |
// Input:21 | |
vec3 n_out21p0; | |
n_out21p0 = vec3(VIEWPORT_SIZE, 0.0); | |
// ColorUniform:23 | |
vec3 n_out23p0; | |
float n_out23p1; | |
n_out23p0 = color1.rgb; | |
n_out23p1 = color1.a; | |
// Expression:20 | |
float n_out20p0; | |
float n_out20p1; | |
vec3 n_out20p2; | |
n_out20p0=0.0; | |
n_out20p1=0.0; | |
n_out20p2=vec3(0.0, 0.0, 0.0); | |
{ | |
n_out20p0 = checker(correct_ratio(n_out8p0, n_out21p0)); | |
n_out20p1 = 1.0; | |
n_out20p2 = n_out23p0; | |
vec3 c = texture(SCREEN_TEXTURE, n_out8p0.xy).rgb; | |
n_out20p2 = c; | |
float l = luma(c); | |
if((l < 0.1)&&(l > 0.01)){ | |
//n_out20p1 = 0.0; | |
if(n_out20p0 > 0.0){ | |
n_out20p2 = n_out23p0; | |
} | |
} | |
} | |
// Output:0 | |
ALBEDO = n_out20p2; | |
ALPHA = n_out20p1; | |
} | |
void light() { | |
// Output:0 | |
} | |
" | |
graph_offset = Vector2( 0, -10.7877 ) | |
modes/diffuse = 4 | |
modes/specular = 4 | |
flags/ambient_light_disabled = true | |
flags/shadows_disabled = true | |
flags/unshaded = true | |
nodes/fragment/0/position = Vector2( 1040, 40 ) | |
nodes/fragment/8/node = SubResource( 5 ) | |
nodes/fragment/8/position = Vector2( 20, 40 ) | |
nodes/fragment/19/node = SubResource( 1 ) | |
nodes/fragment/19/position = Vector2( 20, 400 ) | |
nodes/fragment/19/size = Vector2( 690, 490 ) | |
nodes/fragment/19/input_ports = "" | |
nodes/fragment/19/output_ports = "" | |
nodes/fragment/19/expression = "float checker(vec3 uva){ | |
vec3 c = uva; | |
c *= 40.0;//square modifier, recommended values (20,40,80,160) | |
c = mod(trunc(c), 2.0); | |
float r = 0.0; | |
if(c.x > 0.0 && c.y < 1.0){ | |
r = 1.0; | |
} | |
if(c.x < 1.0 && c.y > 0.0){ | |
r = 1.0; | |
} | |
return r; | |
} | |
float luma(vec3 cor){ | |
return (cor.r * 0.2126) + (cor.g * 0.7152) + (cor.b * 0.0722); | |
} | |
vec3 correct_ratio(vec3 uva, vec3 vport){ | |
vec3 r = uva; | |
float ratio = vport.x / vport.y; | |
r.x *= ratio; | |
return r; | |
}" | |
nodes/fragment/20/node = SubResource( 2 ) | |
nodes/fragment/20/position = Vector2( 340, 40 ) | |
nodes/fragment/20/size = Vector2( 639, 348 ) | |
nodes/fragment/20/input_ports = "0,1,i0;1,1,i1;2,1,i2;" | |
nodes/fragment/20/output_ports = "0,0,o0;1,0,o1;2,1,o2;" | |
nodes/fragment/20/expression = "o0 = checker(correct_ratio(i0, i1)); | |
o1 = 1.0; | |
o2 = i2; | |
vec3 c = texture(SCREEN_TEXTURE, i0.xy).rgb; | |
o2 = c; | |
float l = luma(c); | |
if((l < 0.1)&&(l > 0.01)){ | |
//o1 = 0.0; | |
if(o0 > 0.0){ | |
o2 = i2; | |
} | |
}" | |
nodes/fragment/21/node = SubResource( 3 ) | |
nodes/fragment/21/position = Vector2( 20, 120 ) | |
nodes/fragment/23/node = SubResource( 4 ) | |
nodes/fragment/23/position = Vector2( 20, 200 ) | |
nodes/fragment/connections = PoolIntArray( 8, 0, 20, 0, 21, 0, 20, 1, 20, 2, 0, 0, 20, 1, 0, 1, 23, 0, 20, 2 ) | |
[resource] | |
shader = SubResource( 6 ) | |
shader_param/color1 = Color( 0, 0, 0, 1 ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment