screen_shaders.tscn 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. [gd_scene load_steps=31 format=2]
  2. [ext_resource path="res://screen_shaders.gd" type="Script" id=1]
  3. [ext_resource path="res://art/burano.jpg" type="Texture" id=2]
  4. [ext_resource path="res://art/platformer.jpg" type="Texture" id=3]
  5. [ext_resource path="res://art/mountains.jpg" type="Texture" id=4]
  6. [ext_resource path="res://art/forest.jpg" type="Texture" id=5]
  7. [ext_resource path="res://art/vignette.png" type="Texture" id=6]
  8. [ext_resource path="res://art/white.png" type="Texture" id=7]
  9. [ext_resource path="res://art/filmgrain.png" type="Texture" id=8]
  10. [sub_resource type="Shader" id=1]
  11. code = "shader_type canvas_item;
  12. uniform sampler2D vignette;
  13. void fragment() {
  14. vec3 vignette_color = texture(vignette,UV).rgb;
  15. //screen texture stores gaussian blurred copies on mipmaps
  16. COLOR.rgb = textureLod(SCREEN_TEXTURE,SCREEN_UV,(1.0-vignette_color.r)*4.0).rgb;
  17. COLOR.rgb*= texture(vignette,UV).rgb;
  18. }"
  19. [sub_resource type="ShaderMaterial" id=2]
  20. render_priority = 0
  21. shader = SubResource( 1 )
  22. shader_param/vignette = ExtResource( 6 )
  23. _sections_unfolded = [ "shader", "shader_param" ]
  24. [sub_resource type="Shader" id=3]
  25. code = "shader_type canvas_item;
  26. uniform float amount : hint_range(0,5);
  27. void fragment() {
  28. COLOR.rgb = textureLod(SCREEN_TEXTURE,SCREEN_UV,amount).rgb;
  29. }"
  30. [sub_resource type="ShaderMaterial" id=4]
  31. render_priority = 0
  32. shader = SubResource( 3 )
  33. shader_param/amount = 4.0
  34. _sections_unfolded = [ "shader", "shader_param" ]
  35. [sub_resource type="Shader" id=5]
  36. code = "shader_type canvas_item;
  37. uniform float size_x=0.008;
  38. uniform float size_y=0.008;
  39. void fragment() {
  40. vec2 uv = SCREEN_UV;
  41. uv-=mod(uv,vec2(size_x,size_y));
  42. COLOR.rgb= textureLod(SCREEN_TEXTURE,uv,0.0).rgb;
  43. }
  44. "
  45. [sub_resource type="ShaderMaterial" id=6]
  46. render_priority = 0
  47. shader = SubResource( 5 )
  48. shader_param/size_x = null
  49. shader_param/size_y = null
  50. _sections_unfolded = [ "shader" ]
  51. [sub_resource type="Shader" id=7]
  52. code = "shader_type canvas_item;
  53. uniform float rotation=3.0;
  54. void fragment() {
  55. vec2 uv = SCREEN_UV;
  56. vec2 rel = uv-vec2(0.5,0.5);
  57. float angle = length(rel)*rotation;
  58. mat2 rot = mat2(vec2(cos(angle),-sin(angle)),vec2(sin(angle),cos(angle)));
  59. rel = rot * rel;
  60. uv = clamp(rel + vec2(0.5,0.5),vec2(0,0),vec2(1,1));
  61. COLOR.rgb= textureLod(SCREEN_TEXTURE,uv,0.0).rgb;
  62. }
  63. "
  64. [sub_resource type="ShaderMaterial" id=8]
  65. render_priority = 0
  66. shader = SubResource( 7 )
  67. shader_param/rotation = null
  68. _sections_unfolded = [ "shader" ]
  69. [sub_resource type="Shader" id=9]
  70. code = "shader_type canvas_item;
  71. uniform vec4 base : hint_color;
  72. void fragment() {
  73. vec3 c = textureLod(SCREEN_TEXTURE,SCREEN_UV,0.0).rgb;
  74. //float v = max(c.r,max(c.g,c.b));
  75. float v = dot(c,vec3(0.33333,0.33333,0.33333));
  76. v=sqrt(v);
  77. //v*=v;
  78. COLOR.rgb= base.rgb*v;
  79. }"
  80. [sub_resource type="ShaderMaterial" id=10]
  81. render_priority = 0
  82. shader = SubResource( 9 )
  83. shader_param/base = Color( 0.54451, 0.408353, 0.403137, 1 )
  84. _sections_unfolded = [ "shader", "shader_param" ]
  85. [sub_resource type="Shader" id=11]
  86. code = "shader_type canvas_item;
  87. void fragment() {
  88. vec3 c = textureLod(SCREEN_TEXTURE,SCREEN_UV,0.0).rgb;
  89. c=vec3(1.0)-c;
  90. COLOR.rgb=c;
  91. }
  92. "
  93. [sub_resource type="ShaderMaterial" id=12]
  94. render_priority = 0
  95. shader = SubResource( 11 )
  96. _sections_unfolded = [ "shader" ]
  97. [sub_resource type="Shader" id=13]
  98. code = "shader_type canvas_item;
  99. void fragment() {
  100. vec3 c = textureLod(SCREEN_TEXTURE,SCREEN_UV,0.0).rgb;
  101. c=mod(c+vec3(0.5),vec3(1.0));
  102. COLOR.rgb=c;
  103. }
  104. "
  105. [sub_resource type="ShaderMaterial" id=14]
  106. render_priority = 0
  107. shader = SubResource( 13 )
  108. _sections_unfolded = [ "shader" ]
  109. [sub_resource type="Shader" id=15]
  110. code = "shader_type canvas_item;
  111. void fragment() {
  112. vec3 c = textureLod(SCREEN_TEXTURE,SCREEN_UV,0.0).rgb;
  113. COLOR.rgb=normalize(c);
  114. }
  115. "
  116. [sub_resource type="ShaderMaterial" id=16]
  117. render_priority = 0
  118. shader = SubResource( 15 )
  119. _sections_unfolded = [ "shader" ]
  120. [sub_resource type="Shader" id=17]
  121. code = "shader_type canvas_item;
  122. uniform float brightness=0.8;
  123. uniform float contrast=1.5;
  124. uniform float saturation=1.8;
  125. void fragment() {
  126. vec3 c = textureLod(SCREEN_TEXTURE,SCREEN_UV,0.0).rgb;
  127. c.rgb = mix(vec3(0.0),c.rgb,brightness);
  128. c.rgb = mix(vec3(0.5),c.rgb,contrast);
  129. c.rgb = mix(vec3(dot(vec3(1.0),c.rgb)*0.33333),c.rgb,saturation);
  130. COLOR.rgb=c;
  131. }
  132. "
  133. [sub_resource type="ShaderMaterial" id=18]
  134. render_priority = 0
  135. shader = SubResource( 17 )
  136. shader_param/brightness = null
  137. shader_param/contrast = null
  138. shader_param/saturation = null
  139. _sections_unfolded = [ "shader" ]
  140. [sub_resource type="Shader" id=19]
  141. code = "shader_type canvas_item;
  142. uniform float frequency=60;
  143. uniform float depth = 0.005;
  144. void fragment() {
  145. vec2 uv = SCREEN_UV;
  146. uv.x += sin(uv.y*frequency+TIME)*depth;
  147. uv.x = clamp(uv.x,0,1);
  148. vec3 c = textureLod(SCREEN_TEXTURE,uv,0.0).rgb;
  149. COLOR.rgb=c;
  150. }
  151. "
  152. [sub_resource type="ShaderMaterial" id=20]
  153. render_priority = 0
  154. shader = SubResource( 19 )
  155. shader_param/frequency = null
  156. shader_param/depth = null
  157. _sections_unfolded = [ "shader" ]
  158. [sub_resource type="Shader" id=21]
  159. code = "shader_type canvas_item;
  160. uniform vec4 base : hint_color;
  161. uniform sampler2D grain;
  162. uniform float grain_strength=0.3;
  163. uniform sampler2D vignette;
  164. uniform float fps=12;
  165. uniform float stretch = 0.5;
  166. uniform float flashing=0.01;
  167. float make_grain(float time,vec2 uv) {
  168. vec2 ofs = vec2(sin(41.0*time*sin(time*123.0)),sin(27.0*time*sin(time*312.0)));
  169. return texture(grain,(uv+mod(ofs,vec2(1,1)))*stretch).r;
  170. }
  171. void fragment() {
  172. vec3 c = textureLod(SCREEN_TEXTURE,SCREEN_UV,0.0).rgb;
  173. //float v = max(c.r,max(c.g,c.b));
  174. float v = dot(c,vec3(0.33333,0.33333,0.33333));
  175. v=sqrt(v);
  176. //v*=v;
  177. float f = 1.0/fps;
  178. float g = make_grain(TIME-mod(TIME,f),UV);
  179. g=max(g,make_grain(TIME-mod(TIME,f)+f,UV)*0.5);
  180. g=max(g,make_grain(TIME-mod(TIME,f)+f*2.0,UV)*0.25);
  181. COLOR.rgb= base.rgb*v-vec3(g)*grain_strength;
  182. COLOR.rgb*=texture(vignette,UV).r;
  183. float ft = TIME * 0.002;
  184. COLOR.rgb+=vec3(sin(75.0*ft*sin(ft*123.0)))*flashing;
  185. }
  186. "
  187. [sub_resource type="ShaderMaterial" id=22]
  188. render_priority = 0
  189. shader = SubResource( 21 )
  190. shader_param/base = Color( 0.450274, 0.361255, 0.335059, 1 )
  191. shader_param/grain_strength = 0.3
  192. shader_param/fps = 12
  193. shader_param/stretch = 0.5
  194. shader_param/flashing = 0.01
  195. shader_param/grain = ExtResource( 8 )
  196. shader_param/vignette = ExtResource( 6 )
  197. _sections_unfolded = [ "shader", "shader_param" ]
  198. [node name="Control" type="Control"]
  199. anchor_left = 0.0
  200. anchor_top = 0.0
  201. anchor_right = 1.0
  202. anchor_bottom = 1.0
  203. rect_pivot_offset = Vector2( 0, 0 )
  204. rect_clip_content = false
  205. mouse_filter = 0
  206. size_flags_horizontal = 2
  207. size_flags_vertical = 2
  208. script = ExtResource( 1 )
  209. _sections_unfolded = [ "Pause" ]
  210. [node name="pictures" type="Control" parent="."]
  211. anchor_left = 0.0
  212. anchor_top = 0.0
  213. anchor_right = 1.0
  214. anchor_bottom = 1.0
  215. rect_pivot_offset = Vector2( 0, 0 )
  216. rect_clip_content = false
  217. mouse_filter = 0
  218. size_flags_horizontal = 2
  219. size_flags_vertical = 2
  220. [node name="burano" type="TextureRect" parent="pictures"]
  221. anchor_left = 0.0
  222. anchor_top = 0.0
  223. anchor_right = 0.0
  224. anchor_bottom = 0.0
  225. margin_right = 40.0
  226. margin_bottom = 40.0
  227. rect_pivot_offset = Vector2( 0, 0 )
  228. rect_clip_content = false
  229. mouse_filter = 1
  230. size_flags_horizontal = 2
  231. size_flags_vertical = 2
  232. texture = ExtResource( 2 )
  233. stretch_mode = 0
  234. [node name="roby" type="TextureRect" parent="pictures"]
  235. visible = false
  236. anchor_left = 0.0
  237. anchor_top = 0.0
  238. anchor_right = 0.0
  239. anchor_bottom = 0.0
  240. margin_right = 40.0
  241. margin_bottom = 40.0
  242. rect_pivot_offset = Vector2( 0, 0 )
  243. rect_clip_content = false
  244. mouse_filter = 1
  245. size_flags_horizontal = 2
  246. size_flags_vertical = 2
  247. texture = ExtResource( 3 )
  248. stretch_mode = 0
  249. [node name="mountains" type="TextureRect" parent="pictures"]
  250. visible = false
  251. anchor_left = 0.0
  252. anchor_top = 0.0
  253. anchor_right = 0.0
  254. anchor_bottom = 0.0
  255. margin_right = 40.0
  256. margin_bottom = 40.0
  257. rect_pivot_offset = Vector2( 0, 0 )
  258. rect_clip_content = false
  259. mouse_filter = 1
  260. size_flags_horizontal = 2
  261. size_flags_vertical = 2
  262. texture = ExtResource( 4 )
  263. stretch_mode = 0
  264. [node name="forest" type="TextureRect" parent="pictures"]
  265. visible = false
  266. anchor_left = 0.0
  267. anchor_top = 0.0
  268. anchor_right = 0.0
  269. anchor_bottom = 0.0
  270. margin_right = 40.0
  271. margin_bottom = 40.0
  272. rect_pivot_offset = Vector2( 0, 0 )
  273. rect_clip_content = false
  274. mouse_filter = 1
  275. size_flags_horizontal = 2
  276. size_flags_vertical = 2
  277. texture = ExtResource( 5 )
  278. stretch_mode = 0
  279. [node name="effects" type="Control" parent="."]
  280. anchor_left = 0.0
  281. anchor_top = 0.0
  282. anchor_right = 1.0
  283. anchor_bottom = 1.0
  284. rect_pivot_offset = Vector2( 0, 0 )
  285. rect_clip_content = false
  286. mouse_filter = 0
  287. size_flags_horizontal = 2
  288. size_flags_vertical = 2
  289. _sections_unfolded = [ "Rect" ]
  290. [node name="disabled" type="Control" parent="effects"]
  291. visible = false
  292. anchor_left = 0.0
  293. anchor_top = 0.0
  294. anchor_right = 0.0
  295. anchor_bottom = 0.0
  296. margin_right = 40.0
  297. margin_bottom = 40.0
  298. rect_pivot_offset = Vector2( 0, 0 )
  299. rect_clip_content = false
  300. mouse_filter = 0
  301. size_flags_horizontal = 2
  302. size_flags_vertical = 2
  303. [node name="vignette" type="TextureRect" parent="effects"]
  304. visible = false
  305. material = SubResource( 2 )
  306. anchor_left = 0.0
  307. anchor_top = 0.0
  308. anchor_right = 1.0
  309. anchor_bottom = 1.0
  310. rect_pivot_offset = Vector2( 0, 0 )
  311. rect_clip_content = false
  312. mouse_filter = 1
  313. size_flags_horizontal = 2
  314. size_flags_vertical = 2
  315. texture = ExtResource( 7 )
  316. expand = true
  317. stretch_mode = 0
  318. _sections_unfolded = [ "Material" ]
  319. [node name="blur" type="TextureRect" parent="effects"]
  320. visible = false
  321. material = SubResource( 4 )
  322. anchor_left = 0.0
  323. anchor_top = 0.0
  324. anchor_right = 1.0
  325. anchor_bottom = 1.0
  326. rect_pivot_offset = Vector2( 0, 0 )
  327. rect_clip_content = false
  328. mouse_filter = 1
  329. size_flags_horizontal = 2
  330. size_flags_vertical = 2
  331. texture = ExtResource( 7 )
  332. expand = true
  333. stretch_mode = 0
  334. _sections_unfolded = [ "Material" ]
  335. [node name="pixelize" type="TextureRect" parent="effects"]
  336. visible = false
  337. material = SubResource( 6 )
  338. anchor_left = 0.0
  339. anchor_top = 0.0
  340. anchor_right = 1.0
  341. anchor_bottom = 1.0
  342. rect_pivot_offset = Vector2( 0, 0 )
  343. rect_clip_content = false
  344. mouse_filter = 1
  345. size_flags_horizontal = 2
  346. size_flags_vertical = 2
  347. texture = ExtResource( 7 )
  348. expand = true
  349. stretch_mode = 0
  350. _sections_unfolded = [ "Material" ]
  351. [node name="whirl" type="TextureRect" parent="effects"]
  352. visible = false
  353. material = SubResource( 8 )
  354. anchor_left = 0.0
  355. anchor_top = 0.0
  356. anchor_right = 1.0
  357. anchor_bottom = 1.0
  358. rect_pivot_offset = Vector2( 0, 0 )
  359. rect_clip_content = false
  360. mouse_filter = 1
  361. size_flags_horizontal = 2
  362. size_flags_vertical = 2
  363. texture = ExtResource( 7 )
  364. expand = true
  365. stretch_mode = 0
  366. _sections_unfolded = [ "Material" ]
  367. [node name="sepia" type="TextureRect" parent="effects"]
  368. visible = false
  369. material = SubResource( 10 )
  370. anchor_left = 0.0
  371. anchor_top = 0.0
  372. anchor_right = 1.0
  373. anchor_bottom = 1.0
  374. margin_right = 14.0
  375. margin_bottom = -2.0
  376. rect_pivot_offset = Vector2( 0, 0 )
  377. rect_clip_content = false
  378. mouse_filter = 1
  379. size_flags_horizontal = 2
  380. size_flags_vertical = 2
  381. texture = ExtResource( 7 )
  382. expand = true
  383. stretch_mode = 0
  384. _sections_unfolded = [ "Material", "Visibility" ]
  385. [node name="negative" type="TextureRect" parent="effects"]
  386. visible = false
  387. material = SubResource( 12 )
  388. anchor_left = 0.0
  389. anchor_top = 0.0
  390. anchor_right = 1.0
  391. anchor_bottom = 1.0
  392. rect_pivot_offset = Vector2( 0, 0 )
  393. rect_clip_content = false
  394. mouse_filter = 1
  395. size_flags_horizontal = 2
  396. size_flags_vertical = 2
  397. texture = ExtResource( 7 )
  398. expand = true
  399. stretch_mode = 0
  400. _sections_unfolded = [ "Material" ]
  401. [node name="contrasted" type="TextureRect" parent="effects"]
  402. visible = false
  403. material = SubResource( 14 )
  404. anchor_left = 0.0
  405. anchor_top = 0.0
  406. anchor_right = 1.0
  407. anchor_bottom = 1.0
  408. rect_pivot_offset = Vector2( 0, 0 )
  409. rect_clip_content = false
  410. mouse_filter = 1
  411. size_flags_horizontal = 2
  412. size_flags_vertical = 2
  413. texture = ExtResource( 7 )
  414. expand = true
  415. stretch_mode = 0
  416. _sections_unfolded = [ "Material" ]
  417. [node name="normalized" type="TextureRect" parent="effects"]
  418. visible = false
  419. material = SubResource( 16 )
  420. anchor_left = 0.0
  421. anchor_top = 0.0
  422. anchor_right = 1.0
  423. anchor_bottom = 1.0
  424. rect_pivot_offset = Vector2( 0, 0 )
  425. rect_clip_content = false
  426. mouse_filter = 1
  427. size_flags_horizontal = 2
  428. size_flags_vertical = 2
  429. texture = ExtResource( 7 )
  430. expand = true
  431. stretch_mode = 0
  432. _sections_unfolded = [ "Material" ]
  433. [node name="BCS" type="TextureRect" parent="effects"]
  434. visible = false
  435. material = SubResource( 18 )
  436. anchor_left = 0.0
  437. anchor_top = 0.0
  438. anchor_right = 1.0
  439. anchor_bottom = 1.0
  440. margin_top = 3.0
  441. margin_bottom = -3.0
  442. rect_pivot_offset = Vector2( 0, 0 )
  443. rect_clip_content = false
  444. mouse_filter = 1
  445. size_flags_horizontal = 2
  446. size_flags_vertical = 2
  447. texture = ExtResource( 7 )
  448. expand = true
  449. stretch_mode = 0
  450. _sections_unfolded = [ "Material" ]
  451. [node name="mirage" type="TextureRect" parent="effects"]
  452. visible = false
  453. material = SubResource( 20 )
  454. anchor_left = 0.0
  455. anchor_top = 0.0
  456. anchor_right = 1.0
  457. anchor_bottom = 1.0
  458. rect_pivot_offset = Vector2( 0, 0 )
  459. rect_clip_content = false
  460. mouse_filter = 1
  461. size_flags_horizontal = 2
  462. size_flags_vertical = 2
  463. texture = ExtResource( 7 )
  464. expand = true
  465. stretch_mode = 0
  466. _sections_unfolded = [ "Material" ]
  467. [node name="old_film" type="TextureRect" parent="effects"]
  468. visible = false
  469. material = SubResource( 22 )
  470. anchor_left = 0.0
  471. anchor_top = 0.0
  472. anchor_right = 1.0
  473. anchor_bottom = 1.0
  474. margin_left = -3.0
  475. margin_right = 3.0
  476. rect_pivot_offset = Vector2( 0, 0 )
  477. rect_clip_content = false
  478. mouse_filter = 1
  479. size_flags_horizontal = 2
  480. size_flags_vertical = 2
  481. texture = ExtResource( 7 )
  482. expand = true
  483. stretch_mode = 0
  484. _sections_unfolded = [ "Material" ]
  485. [node name="picture" type="OptionButton" parent="."]
  486. anchor_left = 0.0
  487. anchor_top = 0.0
  488. anchor_right = 0.0
  489. anchor_bottom = 0.0
  490. margin_left = 8.0
  491. margin_top = 7.0
  492. margin_right = 131.0
  493. margin_bottom = 28.0
  494. rect_pivot_offset = Vector2( 0, 0 )
  495. rect_clip_content = false
  496. mouse_filter = 0
  497. size_flags_horizontal = 2
  498. size_flags_vertical = 2
  499. toggle_mode = false
  500. enabled_focus_mode = 2
  501. shortcut = null
  502. group = null
  503. flat = false
  504. align = 0
  505. selected = -1
  506. items = [ ]
  507. [node name="effect" type="OptionButton" parent="."]
  508. anchor_left = 0.0
  509. anchor_top = 0.0
  510. anchor_right = 0.0
  511. anchor_bottom = 0.0
  512. margin_left = 137.0
  513. margin_top = 7.0
  514. margin_right = 260.0
  515. margin_bottom = 28.0
  516. rect_pivot_offset = Vector2( 0, 0 )
  517. rect_clip_content = false
  518. mouse_filter = 0
  519. size_flags_horizontal = 2
  520. size_flags_vertical = 2
  521. toggle_mode = false
  522. enabled_focus_mode = 2
  523. shortcut = null
  524. group = null
  525. flat = false
  526. align = 0
  527. selected = -1
  528. items = [ ]
  529. [connection signal="item_selected" from="picture" to="." method="_on_picture_item_selected"]
  530. [connection signal="item_selected" from="effect" to="." method="_on_effect_item_selected"]