sprite_shaders.tscn 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. [gd_scene load_steps=23 format=2]
  2. [ext_resource path="res://godotea.png" type="Texture" id=1]
  3. [sub_resource type="Shader" id=1]
  4. code = "shader_type canvas_item;
  5. uniform float outline_width=2.0;
  6. uniform vec4 outline_color: hint_color;
  7. void fragment(){
  8. vec4 col = texture(TEXTURE,UV);
  9. vec2 ps = TEXTURE_PIXEL_SIZE;
  10. float a;
  11. float maxa=col.a;
  12. float mina=col.a;
  13. a=texture(TEXTURE,UV+vec2(0,-outline_width)*ps).a;
  14. maxa=max(a,maxa);
  15. mina=min(a,mina);
  16. a=texture(TEXTURE,UV+vec2(0,outline_width)*ps).a;
  17. maxa=max(a,maxa);
  18. mina=min(a,mina);
  19. a=texture(TEXTURE,UV+vec2(-outline_width,0)*ps).a;
  20. maxa=max(a,maxa);
  21. mina=min(a,mina);
  22. a=texture(TEXTURE,UV+vec2(outline_width,0)*ps).a;
  23. maxa=max(a,maxa);
  24. mina=min(a,mina);
  25. COLOR=mix(col,outline_color,maxa-mina);
  26. }"
  27. [sub_resource type="ShaderMaterial" id=2]
  28. render_priority = 0
  29. shader = SubResource( 1 )
  30. shader_param/outline_width = null
  31. shader_param/outline_color = Color( 0, 1, 0.109375, 1 )
  32. _sections_unfolded = [ "shader_param" ]
  33. [sub_resource type="ShaderMaterial" id=3]
  34. render_priority = 0
  35. [sub_resource type="Shader" id=4]
  36. code = "shader_type canvas_item;
  37. uniform float outline_width = 2.0;
  38. uniform vec4 outline_color: hint_color;
  39. void fragment(){
  40. vec4 col = texture(TEXTURE, UV);
  41. vec2 ps = TEXTURE_PIXEL_SIZE;
  42. float a;
  43. float maxa = col.a;
  44. float mina = col.a;
  45. a = texture(TEXTURE, UV + vec2(0, -outline_width)*ps).a;
  46. maxa = max(a, maxa);
  47. mina = min(a, mina);
  48. a = texture(TEXTURE, UV + vec2(0, outline_width)*ps).a;
  49. maxa = max(a, maxa);
  50. mina = min(a, mina);
  51. a = texture(TEXTURE, UV + vec2(-outline_width,0)*ps).a;
  52. maxa = max(a, maxa);
  53. mina = min(a, mina);
  54. a = texture(TEXTURE, UV + vec2(outline_width, 0)*ps).a;
  55. maxa = max(a, maxa);
  56. mina = min(a, mina);
  57. COLOR = mix(col, outline_color, maxa-mina);
  58. }"
  59. [sub_resource type="ShaderMaterial" id=5]
  60. render_priority = 0
  61. shader = SubResource( 4 )
  62. shader_param/outline_width = 4.0
  63. shader_param/outline_color = Color( 0, 0, 0, 1 )
  64. _sections_unfolded = [ "Resource", "shader_param" ]
  65. [sub_resource type="Shader" id=6]
  66. code = "shader_type canvas_item;
  67. render_mode blend_premul_alpha;
  68. //this shader only works properly with premultiplied alpha blend mode
  69. uniform float aura_width = 2.0;
  70. uniform vec4 aura_color:hint_color;
  71. void fragment(){
  72. vec4 col = texture(TEXTURE, UV);
  73. vec2 ps = TEXTURE_PIXEL_SIZE;
  74. float a;
  75. float maxa = col.a;
  76. float mina = col.a;
  77. a = texture(TEXTURE, UV + vec2(0, -aura_width)*ps).a;
  78. maxa = max(a, maxa);
  79. mina = min(a, mina);
  80. a = texture(TEXTURE, UV + vec2(0, aura_width)*ps).a;
  81. maxa = max(a, maxa);
  82. mina = min(a, mina);
  83. a = texture(TEXTURE, UV + vec2(-aura_width, 0)*ps).a;
  84. maxa = max(a, maxa);
  85. mina = min(a, mina);
  86. a = texture(TEXTURE, UV + vec2(aura_width, 0)*ps).a;
  87. maxa = max(a, maxa);
  88. mina = min(a, mina);
  89. col.rgb *= col.a;
  90. COLOR = col;
  91. float auraa = (maxa-mina);
  92. COLOR.rgb += aura_color.rgb*(auraa);
  93. }"
  94. [sub_resource type="ShaderMaterial" id=7]
  95. render_priority = 0
  96. shader = SubResource( 6 )
  97. shader_param/aura_width = 6.0
  98. shader_param/aura_color = Color( 0.143326, 0.33235, 0.677765, 0.442 )
  99. _sections_unfolded = [ "shader_param" ]
  100. [sub_resource type="Shader" id=8]
  101. code = "shader_type canvas_item;
  102. render_mode blend_mix;
  103. uniform float radius = 4.0;
  104. void fragment(){
  105. vec4 col = texture(TEXTURE, UV);
  106. vec2 ps = TEXTURE_PIXEL_SIZE;
  107. col += texture(TEXTURE, UV + vec2(0, -radius)*ps);
  108. col += texture(TEXTURE, UV + vec2(0, radius)*ps);
  109. col += texture(TEXTURE, UV + vec2(-radius, 0)*ps);
  110. col += texture(TEXTURE, UV + vec2(radius, 0)*ps);
  111. col /= 5.0;
  112. COLOR = col;
  113. }"
  114. [sub_resource type="ShaderMaterial" id=9]
  115. render_priority = 0
  116. shader = SubResource( 8 )
  117. shader_param/radius = 4.0
  118. _sections_unfolded = [ "shader_param" ]
  119. [sub_resource type="Shader" id=10]
  120. code = "shader_type canvas_item;
  121. render_mode blend_mix;
  122. uniform float fattyness = 2.0;
  123. void fragment(){
  124. vec2 ruv = UV - vec2(0.5,0.5);
  125. vec2 dir = normalize(ruv);
  126. float len = length(ruv);
  127. len = pow(len*2.0, fattyness)*0.5;
  128. ruv = len*dir;
  129. vec4 col = texture(TEXTURE, ruv + vec2(0.5, 0.5));
  130. COLOR = col;
  131. }"
  132. [sub_resource type="ShaderMaterial" id=11]
  133. render_priority = 0
  134. shader = SubResource( 10 )
  135. shader_param/fattyness = 3.0
  136. _sections_unfolded = [ "shader_param" ]
  137. [sub_resource type="Shader" id=12]
  138. code = "shader_type canvas_item;
  139. render_mode blend_mix;
  140. uniform float radius = 5.0;
  141. uniform vec4 modulate:hint_color;
  142. void fragment(){
  143. vec2 ps = TEXTURE_PIXEL_SIZE;
  144. vec4 shadow = texture(TEXTURE, UV + vec2(-radius, -radius)*ps);
  145. shadow += texture(TEXTURE, UV + vec2(-radius, 0)*ps);
  146. shadow += texture(TEXTURE, UV + vec2(-radius, radius)*ps);
  147. shadow += texture(TEXTURE, UV + vec2(0, -radius)*ps);
  148. shadow += texture(TEXTURE, UV + vec2(0, radius)*ps);
  149. shadow += texture(TEXTURE, UV + vec2(radius, -radius)*ps);
  150. shadow += texture(TEXTURE, UV + vec2(radius, 0)*ps);
  151. shadow += texture(TEXTURE, UV + vec2(radius, radius)*ps);
  152. shadow /= 8.0;
  153. shadow *= modulate;
  154. vec4 col = texture(TEXTURE, UV);
  155. COLOR = mix(shadow, col, col.a);
  156. }"
  157. [sub_resource type="ShaderMaterial" id=13]
  158. render_priority = 0
  159. shader = SubResource( 12 )
  160. shader_param/radius = 8.0
  161. shader_param/modulate = Color( 0, 0, 0, 0.501961 )
  162. _sections_unfolded = [ "shader_param" ]
  163. [sub_resource type="Shader" id=14]
  164. code = "shader_type canvas_item;
  165. render_mode blend_mix;
  166. uniform vec2 offset = vec2(8,8);
  167. uniform vec4 modulate:hint_color;
  168. void fragment(){
  169. vec2 ps = TEXTURE_PIXEL_SIZE;
  170. vec4 shadow = vec4(modulate.rgb, texture(TEXTURE, UV - offset*ps).a*modulate.a);
  171. vec4 col = texture(TEXTURE, UV);
  172. COLOR = mix(shadow, col, col.a);
  173. }"
  174. [sub_resource type="ShaderMaterial" id=15]
  175. render_priority = 0
  176. shader = SubResource( 14 )
  177. shader_param/offset = Vector2( 20, 20 )
  178. shader_param/modulate = Color( 0.90625, 0.269043, 0.746948, 1 )
  179. _sections_unfolded = [ "shader_param" ]
  180. [sub_resource type="Shader" id=16]
  181. code = "shader_type canvas_item;
  182. render_mode blend_mix;
  183. uniform vec4 modulate:hint_color;
  184. void fragment(){
  185. COLOR = vec4(modulate.rgb, texture(TEXTURE, UV).a*modulate.a);
  186. }"
  187. [sub_resource type="ShaderMaterial" id=17]
  188. render_priority = 0
  189. shader = SubResource( 16 )
  190. shader_param/modulate = Color( 1, 0.0234375, 0.481201, 0.596706 )
  191. _sections_unfolded = [ "shader_param" ]
  192. [sub_resource type="Shader" id=18]
  193. code = "shader_type canvas_item;
  194. render_mode blend_premul_alpha;
  195. uniform float radius = 2.0;
  196. uniform float amount = 0.6;
  197. void fragment(){
  198. float r = radius;
  199. vec2 ps = TEXTURE_PIXEL_SIZE;
  200. vec4 col = texture(TEXTURE, UV);
  201. vec4 glow = col;
  202. glow += texture(TEXTURE, UV + vec2(-r, -r)*ps);
  203. glow += texture(TEXTURE, UV + vec2(-r, 0)*ps);
  204. glow += texture(TEXTURE, UV + vec2(-r, r)*ps);
  205. glow += texture(TEXTURE, UV + vec2(0, -r)*ps);
  206. glow += texture(TEXTURE, UV + vec2(0, r)*ps);
  207. glow += texture(TEXTURE, UV + vec2(r, -r)*ps);
  208. glow += texture(TEXTURE, UV + vec2(r, 0)*ps);
  209. glow += texture(TEXTURE, UV + vec2(r, r)*ps);
  210. r *= 2.0;
  211. glow += texture(TEXTURE, UV + vec2(-r, -r)*ps);
  212. glow += texture(TEXTURE, UV + vec2(-r, 0)*ps);
  213. glow += texture(TEXTURE, UV + vec2(-r, r)*ps);
  214. glow += texture(TEXTURE, UV + vec2(0, -r)*ps);
  215. glow += texture(TEXTURE, UV + vec2(0, r)*ps);
  216. glow += texture(TEXTURE, UV + vec2(r, -r)*ps);
  217. glow += texture(TEXTURE, UV + vec2(r, 0)*ps);
  218. glow += texture(TEXTURE, UV + vec2(r, r)*ps);
  219. glow /= 17.0;
  220. glow *= amount;
  221. col.rgb *= col.a;
  222. COLOR = glow + col;
  223. }"
  224. [sub_resource type="ShaderMaterial" id=19]
  225. render_priority = 0
  226. shader = SubResource( 18 )
  227. shader_param/radius = 12.0
  228. shader_param/amount = 0.5
  229. _sections_unfolded = [ "shader_param" ]
  230. [sub_resource type="Shader" id=20]
  231. code = "shader_type canvas_item;
  232. render_mode blend_mix;
  233. uniform float amount = 20.0;
  234. void fragment(){
  235. vec2 uv = UV*0.05;
  236. float a = fract(sin(dot(UV, vec2(12.9898, 78.233)))*438.5453);
  237. vec4 col = texture(TEXTURE, UV);
  238. col.a *= pow(a, amount);
  239. COLOR = col;
  240. }"
  241. [sub_resource type="ShaderMaterial" id=21]
  242. render_priority = 0
  243. shader = SubResource( 20 )
  244. shader_param/amount = 4.0
  245. _sections_unfolded = [ "shader_param" ]
  246. [node name="shaders" type="Node2D" index="0"]
  247. material = SubResource( 2 )
  248. position = Vector2( 263.737, 179.444 )
  249. scale = Vector2( 0.3, 0.3 )
  250. _sections_unfolded = [ "Material", "Region", "Transform" ]
  251. [node name="normal" type="Sprite" parent="." index="0"]
  252. material = SubResource( 3 )
  253. position = Vector2( -2.16144, 0 )
  254. texture = ExtResource( 1 )
  255. _sections_unfolded = [ "Material", "Offset" ]
  256. [node name="outline" type="Sprite" parent="." index="1"]
  257. material = SubResource( 5 )
  258. position = Vector2( 400, 0 )
  259. texture = ExtResource( 1 )
  260. _sections_unfolded = [ "Material", "Transform" ]
  261. [node name="aura" type="Sprite" parent="." index="2"]
  262. material = SubResource( 7 )
  263. position = Vector2( 800, 0 )
  264. texture = ExtResource( 1 )
  265. _sections_unfolded = [ "Animation", "Material", "Offset", "Region", "Transform", "Visibility", "Z Index" ]
  266. [node name="blur" type="Sprite" parent="." index="3"]
  267. material = SubResource( 9 )
  268. position = Vector2( 1200, 0 )
  269. texture = ExtResource( 1 )
  270. _sections_unfolded = [ "Material", "Transform" ]
  271. [node name="fatty" type="Sprite" parent="." index="4"]
  272. material = SubResource( 11 )
  273. position = Vector2( 1600, 0 )
  274. texture = ExtResource( 1 )
  275. _sections_unfolded = [ "Material", "Transform" ]
  276. [node name="dropshadow" type="Sprite" parent="." index="5"]
  277. material = SubResource( 13 )
  278. position = Vector2( 0, 800 )
  279. texture = ExtResource( 1 )
  280. _sections_unfolded = [ "Material", "Transform" ]
  281. [node name="offsetshadow" type="Sprite" parent="." index="6"]
  282. material = SubResource( 15 )
  283. position = Vector2( 400, 800 )
  284. texture = ExtResource( 1 )
  285. _sections_unfolded = [ "Material", "Transform" ]
  286. [node name="silouette" type="Sprite" parent="." index="7"]
  287. material = SubResource( 17 )
  288. position = Vector2( 800, 800 )
  289. texture = ExtResource( 1 )
  290. _sections_unfolded = [ "Material", "Transform" ]
  291. [node name="glow" type="Sprite" parent="." index="8"]
  292. material = SubResource( 19 )
  293. position = Vector2( 1200, 800 )
  294. texture = ExtResource( 1 )
  295. _sections_unfolded = [ "Material", "Transform", "Z Index" ]
  296. [node name="dissintegrate" type="Sprite" parent="." index="9"]
  297. material = SubResource( 21 )
  298. position = Vector2( 1600, 800 )
  299. texture = ExtResource( 1 )
  300. region_rect = Rect2( 141, 115, 39, 6 )
  301. _sections_unfolded = [ "Material", "Transform" ]