godot/demos/2d/sprite_shaders/sprite_shaders.tscn
2016-04-02 14:39:08 +02:00

164 lines
8.1 KiB
Plaintext

[gd_scene load_steps=20 format=1]
[ext_resource path="res://cubio.png" type="Texture" id=1]
[sub_resource type="CanvasItemShader" id=1]
_code = { "fragment":"uniform float outline_width=2.0;\nuniform color outline_color=vec4(0,0,0,1);\n\nvec4 col = tex(TEXTURE,UV);\nvec2 ps = TEXTURE_PIXEL_SIZE;\nfloat a;\nfloat maxa=col.a;\nfloat mina=col.a;\na=tex(TEXTURE,UV+vec2(0,-outline_width)*ps).a;\nmaxa=max(a,maxa); \nmina=min(a,mina);\na=tex(TEXTURE,UV+vec2(0,outline_width)*ps).a;\nmaxa=max(a,maxa); \nmina=min(a,mina);\na=tex(TEXTURE,UV+vec2(-outline_width,0)*ps).a;\nmaxa=max(a,maxa); \nmina=min(a,mina);\na=tex(TEXTURE,UV+vec2(outline_width,0)*ps).a;\nmaxa=max(a,maxa); \nmina=min(a,mina);\n\nCOLOR=mix(col,outline_color,maxa-mina);", "fragment_ofs":0, "light":"", "light_ofs":0, "vertex":"", "vertex_ofs":0 }
[sub_resource type="CanvasItemMaterial" id=2]
shader/shader = SubResource( 1 )
shader/shading_mode = 0
shader_param/outline_width = 2.0
shader_param/outline_color = Color( 0, 0, 0, 1 )
[sub_resource type="CanvasItemShader" id=3]
_code = { "fragment":"//this shader only works properly with premultiplied alpha blend mode\nuniform float aura_width=2.0;\nuniform color aura_color=vec4(0.4,0.7,0.3,1);\n\nvec4 col = tex(TEXTURE,UV);\nvec2 ps = TEXTURE_PIXEL_SIZE;\nfloat a;\nfloat maxa=col.a;\nfloat mina=col.a;\na=tex(TEXTURE,UV+vec2(0,-aura_width)*ps).a;\nmaxa=max(a,maxa); \nmina=min(a,mina);\na=tex(TEXTURE,UV+vec2(0,aura_width)*ps).a;\nmaxa=max(a,maxa); \nmina=min(a,mina);\na=tex(TEXTURE,UV+vec2(-aura_width,0)*ps).a;\nmaxa=max(a,maxa); \nmina=min(a,mina);\na=tex(TEXTURE,UV+vec2(aura_width,0)*ps).a;\nmaxa=max(a,maxa); \nmina=min(a,mina);\ncol.rgb*=col.a;\nCOLOR=col;//mix(col,aura_color,maxa-mina);\nfloat auraa=(maxa-mina);\n\nCOLOR.rgb+=aura_color.rgb*(maxa-mina);", "fragment_ofs":0, "light":"", "light_ofs":0, "vertex":"", "vertex_ofs":0 }
[sub_resource type="CanvasItemMaterial" id=4]
shader/shader = SubResource( 3 )
shader/shading_mode = 0
shader_param/aura_width = 2.0
shader_param/aura_color = Color( 0.4, 0.7, 0.3, 1 )
[sub_resource type="CanvasItemShader" id=5]
_code = { "fragment":"uniform float radius=2.0;\n\nvec4 col = tex(TEXTURE,UV);\nvec2 ps = TEXTURE_PIXEL_SIZE;\ncol+=tex(TEXTURE,UV+vec2(0,-radius)*ps);\ncol+=tex(TEXTURE,UV+vec2(0,radius)*ps);\ncol+=tex(TEXTURE,UV+vec2(-radius,0)*ps);\ncol+=tex(TEXTURE,UV+vec2(radius,0)*ps);\ncol/=5.0;\nCOLOR=col;", "fragment_ofs":0, "light":"", "light_ofs":0, "vertex":"", "vertex_ofs":0 }
[sub_resource type="CanvasItemMaterial" id=6]
shader/shader = SubResource( 5 )
shader/shading_mode = 0
shader_param/radius = 4.0
[sub_resource type="CanvasItemShader" id=7]
_code = { "fragment":"uniform float fattyness=2.0;\n\nvec2 ruv=(UV-vec2(0.5,0.5));\nfloat len = length(ruv);\nvec2 dir = normalize(ruv);\nlen=pow(len*2.0,fattyness)*0.5;\nruv=len*dir;\nvec4 col = tex(TEXTURE,ruv+vec2(0.5,0.5));\nCOLOR=col;", "fragment_ofs":0, "light":"", "light_ofs":0, "vertex":"", "vertex_ofs":0 }
[sub_resource type="CanvasItemMaterial" id=8]
shader/shader = SubResource( 7 )
shader/shading_mode = 0
shader_param/fattyness = 2.0
[sub_resource type="CanvasItemShader" id=9]
_code = { "fragment":"\nuniform float radius=5.0;\nuniform color modulate=color(0,0,0,0.7);\n\nvec2 ps = TEXTURE_PIXEL_SIZE;\n\nvec4 shadow = tex(TEXTURE,UV+vec2(-radius,-radius)*ps);\nshadow += tex(TEXTURE,UV+vec2(-radius,0)*ps);\nshadow += tex(TEXTURE,UV+vec2(-radius,radius)*ps);\nshadow += tex(TEXTURE,UV+vec2(0,-radius)*ps);\nshadow += tex(TEXTURE,UV+vec2(0,radius)*ps);\nshadow += tex(TEXTURE,UV+vec2(radius,-radius)*ps);\nshadow += tex(TEXTURE,UV+vec2(radius,0)*ps);\nshadow += tex(TEXTURE,UV+vec2(radius,radius)*ps);\nshadow/=8;\nshadow*=modulate;\n\nvec4 col = tex(TEXTURE,UV);\nCOLOR=mix(shadow,col,col.a);", "fragment_ofs":0, "light":"", "light_ofs":0, "vertex":"", "vertex_ofs":0 }
[sub_resource type="CanvasItemMaterial" id=10]
shader/shader = SubResource( 9 )
shader/shading_mode = 0
shader_param/radius = 5.0
shader_param/modulate = Color( 0, 0, 0, 0.7 )
[sub_resource type="CanvasItemShader" id=11]
_code = { "fragment":"\nuniform vec2 offset=vec2(8,8);\nuniform color modulate=color(0.5,0,0.1,0.5);\n\nvec2 ps = TEXTURE_PIXEL_SIZE;\n\nvec4 shadow = vec4(modulate.rgb,tex(TEXTURE,UV-offset*ps).a*modulate.a);\nvec4 col = tex(TEXTURE,UV);\n\nCOLOR=mix(shadow,col,col.a);", "fragment_ofs":0, "light":"", "light_ofs":0, "vertex":"", "vertex_ofs":0 }
[sub_resource type="CanvasItemMaterial" id=12]
shader/shader = SubResource( 11 )
shader/shading_mode = 0
shader_param/offset = Vector2( 8, 8 )
shader_param/modulate = Color( 0.5, 0, 0.1, 0.5 )
[sub_resource type="CanvasItemShader" id=13]
_code = { "fragment":"\nuniform color modulate=color(0.2,0.4,1.0,0.8);\nCOLOR = vec4(modulate.rgb,tex(TEXTURE,UV).a*modulate.a);\n\n\n", "fragment_ofs":0, "light":"", "light_ofs":0, "vertex":"", "vertex_ofs":0 }
[sub_resource type="CanvasItemMaterial" id=14]
shader/shader = SubResource( 13 )
shader/shading_mode = 0
shader_param/modulate = Color( 0.013125, 0.194829, 0.406815, 0.818237 )
[sub_resource type="CanvasItemShader" id=15]
_code = { "fragment":"\nuniform float radius=2.0;\nuniform float amount=0.6;\nfloat r = radius;\nvec2 ps = TEXTURE_PIXEL_SIZE;\n\nvec4 col = tex(TEXTURE,UV);\n\nvec4 glow = col;\nglow += tex(TEXTURE,UV+vec2(-r,-r)*ps);\nglow += tex(TEXTURE,UV+vec2(-r,0)*ps);\nglow += tex(TEXTURE,UV+vec2(-r,r)*ps);\nglow += tex(TEXTURE,UV+vec2(0,-r)*ps);\nglow += tex(TEXTURE,UV+vec2(0,r)*ps);\nglow += tex(TEXTURE,UV+vec2(r,-r)*ps);\nglow += tex(TEXTURE,UV+vec2(r,0)*ps);\nglow += tex(TEXTURE,UV+vec2(r,r)*ps);\nr*=2.0;\nglow += tex(TEXTURE,UV+vec2(-r,-r)*ps);\nglow += tex(TEXTURE,UV+vec2(-r,0)*ps);\nglow += tex(TEXTURE,UV+vec2(-r,r)*ps);\nglow += tex(TEXTURE,UV+vec2(0,-r)*ps);\nglow += tex(TEXTURE,UV+vec2(0,r)*ps);\nglow += tex(TEXTURE,UV+vec2(r,-r)*ps);\nglow += tex(TEXTURE,UV+vec2(r,0)*ps);\nglow += tex(TEXTURE,UV+vec2(r,r)*ps);\n\nglow/=17.0;\nglow*=amount;\ncol.rgb*=col.a;\nCOLOR=glow+col;", "fragment_ofs":0, "light":"", "light_ofs":0, "vertex":"", "vertex_ofs":0 }
[sub_resource type="CanvasItemMaterial" id=16]
shader/shader = SubResource( 15 )
shader/shading_mode = 0
shader_param/radius = 2.0
shader_param/amount = 0.5
[sub_resource type="CanvasItemShader" id=17]
_code = { "fragment":"\nuniform float amount = 20;\nvec2 uv = UV*0.05;\nfloat a = fract(sin(dot(UV ,vec2(12.9898,78.233))) * 438.5453);\nvec4 col = tex(TEXTURE,UV);\ncol.a*=pow(a,amount);\nCOLOR = col;\n\n\n", "fragment_ofs":0, "light":"", "light_ofs":0, "vertex":"", "vertex_ofs":0 }
[sub_resource type="CanvasItemMaterial" id=18]
shader/shader = SubResource( 17 )
shader/shading_mode = 0
shader_param/amount = 2.0
[node name="shaders" type="Node2D"]
[node name="normal" type="Sprite" parent="."]
transform/pos = Vector2( 95.4559, 131.272 )
texture = ExtResource( 1 )
[node name="outline" type="Sprite" parent="."]
material/material = SubResource( 2 )
transform/pos = Vector2( 246.456, 128.272 )
texture = ExtResource( 1 )
[node name="aura" type="Sprite" parent="."]
visibility/blend_mode = 4
material/material = SubResource( 4 )
transform/pos = Vector2( 398.185, 130.624 )
texture = ExtResource( 1 )
[node name="blur" type="Sprite" parent="."]
material/material = SubResource( 6 )
transform/pos = Vector2( 548.503, 123.04 )
texture = ExtResource( 1 )
[node name="fatty" type="Sprite" parent="."]
material/material = SubResource( 8 )
transform/pos = Vector2( 696.518, 125.393 )
texture = ExtResource( 1 )
[node name="dropshadow" type="Sprite" parent="."]
material/material = SubResource( 10 )
transform/pos = Vector2( 97.4079, 389.709 )
texture = ExtResource( 1 )
[node name="offsetshadow" type="Sprite" parent="."]
material/material = SubResource( 12 )
transform/pos = Vector2( 254.821, 384.238 )
texture = ExtResource( 1 )
[node name="silouette" type="Sprite" parent="."]
material/material = SubResource( 14 )
transform/pos = Vector2( 418.854, 387.184 )
texture = ExtResource( 1 )
[node name="glow" type="Sprite" parent="."]
visibility/blend_mode = 4
material/material = SubResource( 16 )
transform/pos = Vector2( 563.75, 385.42 )
texture = ExtResource( 1 )
[node name="dissintegrate" type="Sprite" parent="."]
material/material = SubResource( 18 )
transform/pos = Vector2( 708.613, 385.444 )
texture = ExtResource( 1 )