screen_shaders.tscn~ 12 KB

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