Skip to content

Instantly share code, notes, and snippets.

@zmarcos
Last active February 19, 2020 03:42
Show Gist options
  • Save zmarcos/23ce117765b3b9909e95761b763cf103 to your computer and use it in GitHub Desktop.
Save zmarcos/23ce117765b3b9909e95761b763cf103 to your computer and use it in GitHub Desktop.
Godot 2D overlay shader (version 1)
[gd_scene load_steps=31 format=2]
[sub_resource type="VisualShaderNodeInput" id=1]
input_name = "light_pass"
[sub_resource type="VisualShaderNodeSwitch" id=2]
[sub_resource type="VisualShaderNodeTexture" id=3]
source = 1
[sub_resource type="VisualShaderNodeInput" id=4]
input_name = "screen_uv"
[sub_resource type="VisualShaderNodeScalarSwitch" id=5]
default_input_values = [ 0, false, 1, 1.0, 2, 1.0 ]
[sub_resource type="VisualShaderNodeInput" id=6]
input_name = "uv"
[sub_resource type="VisualShaderNodeTexture" id=7]
source = 2
[sub_resource type="VisualShaderNodeExpression" id=8]
size = Vector2( 501, 306 )
expression = "o0=i0;
LIGHT.w=0.0;
if(i1 > 0.0){
LIGHT.w=1.0;
}
"
[sub_resource type="VisualShaderNodeInput" id=9]
input_name = "texture"
[sub_resource type="VisualShaderNodeInput" id=10]
input_name = "light_color"
[sub_resource type="VisualShaderNodeInput" id=11]
input_name = "uv"
[sub_resource type="VisualShaderNodeTexture" id=12]
source = 5
[sub_resource type="VisualShader" id=13]
code = "shader_type canvas_item;
render_mode blend_disabled;
void vertex() {
// Output:0
}
void fragment() {
// Input:10
float n_out10p0;
n_out10p0 = float(AT_LIGHT_PASS ? 1.0 : 0.0);
// Input:16
vec3 n_out16p0;
n_out16p0 = vec3(SCREEN_UV,0.0);
// Texture:15
vec3 n_out15p0;
float n_out15p1;
{
vec4 _tex_read = textureLod( SCREEN_TEXTURE , n_out16p0.xy , 0.0 );
n_out15p0 = _tex_read.rgb;
n_out15p1 = _tex_read.a;
}
// Input:5
vec3 n_out5p0;
n_out5p0 = vec3(UV,0.0);
// Texture:7
vec3 n_out7p0;
float n_out7p1;
{
vec4 _tex_read = texture( TEXTURE , n_out5p0.xy );
n_out7p0 = _tex_read.rgb;
n_out7p1 = _tex_read.a;
}
// VectorSwitch:14
vec3 n_out14p0;
if(n_out10p0>0.0?true:false)
{
n_out14p0=n_out15p0;
}
else
{
n_out14p0=n_out7p0;
}
// ScalarSwitch:22
float n_out22p0;
if(n_out10p0>0.0?true:false)
{
n_out22p0=n_out15p1;
}
else
{
n_out22p0=n_out7p1;
}
// Output:0
COLOR.rgb = n_out14p0;
COLOR.a = n_out22p0;
}
void light() {
// Input:2
vec3 n_out2p0;
n_out2p0 = LIGHT_COLOR.rgb;
// Input:3
vec3 n_out3p0;
n_out3p0 = vec3(UV,0.0);
// Input:12
// Texture:4
vec3 n_out4p0;
float n_out4p1;
{
vec4 TEXTURE_tex_read = texture( TEXTURE , n_out3p0.xy );
n_out4p0 = TEXTURE_tex_read.rgb;
n_out4p1 = TEXTURE_tex_read.a;
}
// Expression:11
vec3 n_out11p0;
n_out11p0=vec3(0.0, 0.0, 0.0);
{
n_out11p0=n_out2p0;
LIGHT.w=0.0;
if(n_out4p1 > 0.0){
LIGHT.w=1.0;
}
}
// Output:0
LIGHT.rgb = n_out11p0;
}
"
mode = 1
modes/blend = 5
flags/light_only = false
nodes/fragment/0/position = Vector2( 1000, 80 )
nodes/fragment/5/node = SubResource( 6 )
nodes/fragment/5/position = Vector2( 40, 280 )
nodes/fragment/7/node = SubResource( 7 )
nodes/fragment/7/position = Vector2( 280, 320 )
nodes/fragment/10/node = SubResource( 1 )
nodes/fragment/10/position = Vector2( 40, 80 )
nodes/fragment/14/node = SubResource( 2 )
nodes/fragment/14/position = Vector2( 520, 80 )
nodes/fragment/15/node = SubResource( 3 )
nodes/fragment/15/position = Vector2( 280, 180 )
nodes/fragment/16/node = SubResource( 4 )
nodes/fragment/16/position = Vector2( 20, 180 )
nodes/fragment/22/node = SubResource( 5 )
nodes/fragment/22/position = Vector2( 760, 240 )
nodes/fragment/connections = PoolIntArray( 5, 0, 7, 0, 10, 0, 14, 0, 7, 0, 14, 2, 16, 0, 15, 0, 15, 0, 14, 1, 14, 0, 0, 0, 10, 0, 22, 0, 7, 1, 22, 2, 15, 1, 22, 1, 22, 0, 0, 1 )
nodes/light/0/position = Vector2( 1100, 40 )
nodes/light/2/node = SubResource( 10 )
nodes/light/2/position = Vector2( 220, 80 )
nodes/light/3/node = SubResource( 11 )
nodes/light/3/position = Vector2( 20, 260 )
nodes/light/4/node = SubResource( 12 )
nodes/light/4/position = Vector2( 220, 180 )
nodes/light/11/node = SubResource( 8 )
nodes/light/11/position = Vector2( 720, 140 )
nodes/light/11/size = Vector2( 501, 306 )
nodes/light/11/input_ports = "0,1,i0;1,0,i1;"
nodes/light/11/output_ports = "0,1,o0;"
nodes/light/11/expression = "o0=i0;
LIGHT.w=0.0;
if(i1 > 0.0){
LIGHT.w=1.0;
}
"
nodes/light/12/node = SubResource( 9 )
nodes/light/12/position = Vector2( 20, 360 )
nodes/light/connections = PoolIntArray( 3, 0, 4, 0, 12, 0, 4, 2, 11, 0, 0, 0, 4, 1, 11, 1, 2, 0, 11, 0 )
[sub_resource type="ShaderMaterial" id=14]
shader = SubResource( 13 )
[sub_resource type="Animation" id=15]
resource_name = "anim1"
length = 5.0
loop = true
tracks/0/type = "bezier"
tracks/0/path = NodePath("Viewport/Custom2D:position:x")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"points": PoolRealArray( 55, -0.25, 0, 0.25, 0, 0.559654, -0.25, 0, 0.25, 0, 113.972, -0.25, 0, 0.25, 0 ),
"times": PoolRealArray( 0, 2, 5 )
}
tracks/1/type = "bezier"
tracks/1/path = NodePath("Viewport/Custom2D:position:y")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"points": PoolRealArray( 25, -0.25, 0, 0.25, 0, 125.796, -0.25, 0, 0.25, 0, 178.094, -0.25, 0, 0.25, 0 ),
"times": PoolRealArray( 0, 2, 5 )
}
[sub_resource type="OpenSimplexNoise" id=16]
[sub_resource type="NoiseTexture" id=17]
flags = 3
width = 16
noise = SubResource( 16 )
[sub_resource type="AtlasTexture" id=18]
flags = 3
atlas = SubResource( 17 )
region = Rect2( 0, 0, 128, 128 )
[sub_resource type="OpenSimplexNoise" id=19]
[sub_resource type="NoiseTexture" id=20]
width = 128
height = 128
noise = SubResource( 19 )
[sub_resource type="OccluderPolygon2D" id=21]
closed = false
polygon = PoolVector2Array( -42.1672, 25.7201, -0.167198, -1.27988, 95.8328, 10.7201, 58.8328, 104.72, -22.1672, 90.7201, -38.1672, 14.7201 )
[sub_resource type="Gradient" id=22]
colors = PoolColorArray( 0, 0, 0, 1, 1, 0, 0, 1 )
[sub_resource type="GradientTexture" id=23]
gradient = SubResource( 22 )
[sub_resource type="ArrayMesh" id=24]
surfaces/0 = {
"aabb": AABB( 0, 0, 0, 128, 128, 0 ),
"array_data": PoolByteArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 60, 0, 0, 0, 67, 0, 0, 0, 67, 0, 60, 0, 60 ),
"array_index_data": PoolByteArray( ),
"blend_shape_data": [ ],
"format": 359441,
"index_count": 0,
"primitive": 4,
"skeleton_aabb": [ ],
"vertex_count": 3
}
[sub_resource type="MeshTexture" id=25]
mesh = SubResource( 24 )
base_texture = SubResource( 23 )
image_size = Vector2( 128, 128 )
[sub_resource type="OpenSimplexNoise" id=26]
[sub_resource type="NoiseTexture" id=27]
noise = SubResource( 26 )
[sub_resource type="MeshTexture" id=28]
mesh = SubResource( 24 )
base_texture = SubResource( 27 )
image_size = Vector2( 128, 128 )
[sub_resource type="GDScript" id=29]
script/source = "extends Node2D
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_Custom2D_draw():
draw_circle(position, 22.0, Color(1,0,1))
draw_circle(position - Vector2(15,15), 11.0, Color(1,1,0,0.5))
draw_circle(position + Vector2(15,15), 11.0, Color(0,1,1,0.5))
pass # Replace with function body.
"
[sub_resource type="ViewportTexture" id=30]
viewport_path = NodePath("Viewport")
[node name="Main" type="Node2D"]
material = SubResource( 14 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "anim1"
anims/anim1 = SubResource( 15 )
[node name="GrayWall" type="Sprite" parent="."]
position = Vector2( 33.1493, 196.338 )
texture = SubResource( 18 )
centered = false
region_rect = Rect2( 0, 0, 32, 32 )
__meta__ = {
"_editor_description_": ""
}
[node name="Light2D" type="Light2D" parent="GrayWall"]
light_mask = 2
position = Vector2( 64, 64 )
texture = SubResource( 20 )
color = Color( 0.109804, 0.952941, 0.203922, 1 )
mode = 2
range_item_cull_mask = 2
shadow_enabled = true
shadow_item_cull_mask = 2
__meta__ = {
"_edit_lock_": true,
"_editor_description_": ""
}
[node name="LightOccluder2D" type="LightOccluder2D" parent="GrayWall"]
visible = false
light_mask = 2
position = Vector2( 39.0179, 14.4599 )
occluder = SubResource( 21 )
light_mask = 2
__meta__ = {
"_editor_description_": ""
}
[node name="TriRed" type="Sprite" parent="."]
light_mask = 2
use_parent_material = true
position = Vector2( 110, 173 )
texture = SubResource( 25 )
__meta__ = {
"_editor_description_": ""
}
[node name="TriNoise" type="Sprite" parent="."]
light_mask = 2
use_parent_material = true
position = Vector2( 173, 388 )
rotation = 3.64948
texture = SubResource( 28 )
centered = false
__meta__ = {
"_editor_description_": ""
}
[node name="Viewport" type="Viewport" parent="."]
size = Vector2( 256, 256 )
transparent_bg = true
hdr = false
usage = 0
render_target_v_flip = true
[node name="Custom2D" type="Node2D" parent="Viewport"]
position = Vector2( 0.559654, 125.796 )
script = SubResource( 29 )
[node name="ViewportSprite" type="Sprite" parent="."]
light_mask = 2
use_parent_material = true
position = Vector2( 130, 198 )
z_index = 1
texture = SubResource( 30 )
[connection signal="draw" from="Viewport/Custom2D" to="Viewport/Custom2D" method="_on_Custom2D_draw"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment