-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshadow_material.tres
40 lines (35 loc) · 1.2 KB
/
shadow_material.tres
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
[gd_resource type="ShaderMaterial" load_steps=2 format=2]
[sub_resource type="Shader" id=1]
code = "/**
* Shadow 2D.
* License: CC0
* https://creativecommons.org/publicdomain/zero/1.0/
*/
shader_type canvas_item;
render_mode blend_mix;
uniform vec2 deform = vec2(2.0, 2.0);
uniform vec2 offset = vec2(0.0, 0.0);
uniform vec4 modulate : hint_color;
//uniform vec2 texture_size; //uncomment for GLES2
void fragment() {
vec2 ps = TEXTURE_PIXEL_SIZE;
vec2 uv = UV;
float sizex = float(textureSize(TEXTURE,int(ps.x)).x); //comment for GLES2
float sizey = float(textureSize(TEXTURE,int(ps.y)).y); //comment for GLES2
//float sizex = texture_size.x; //uncomment for GLES2
//float sizey = texture_size.y; //uncomment for GLES2
uv.y+=offset.y*ps.y;
uv.x+=offset.x*ps.x;
float decalx=((uv.y-ps.x*sizex)*deform.x);
float decaly=((uv.y-ps.y*sizey)*deform.y);
uv.x += decalx;
uv.y += decaly;
vec4 shadow = vec4(modulate.rgb, texture(TEXTURE, uv).a * modulate.a);
vec4 col = texture(TEXTURE, UV);
COLOR = mix(shadow, col, col.a);
}"
[resource]
shader = SubResource( 1 )
shader_param/deform = Vector2( 0, 4 )
shader_param/offset = Vector2( 0, 10 )
shader_param/modulate = Color( 0.341176, 0.337255, 0.337255, 0.572549 )