manifest.bml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. input
  2. filter: nearest
  3. // IMPORTANT:
  4. // Shader passes need to know details about the image in the mask_texture LUT
  5. // files, so set the following constants in user-preset-constants.h accordingly:
  6. // 1.) mask_triads_per_tile = (number of horizontal triads in mask texture LUT's)
  7. // 2.) mask_texture_small_size = (texture size of mask*texture_small LUT's)
  8. // 3.) mask_texture_large_size = (texture size of mask*texture_large LUT's)
  9. // 4.) mask_grille_avg_color = (avg. brightness of mask_grille_texture* LUT's, in [0, 1])
  10. // 5.) mask_slot_avg_color = (avg. brightness of mask_slot_texture* LUT's, in [0, 1])
  11. // 6.) mask_shadow_avg_color = (avg. brightness of mask_shadow_texture* LUT's, in [0, 1])
  12. // Shader passes also need to know certain scales set in this preset, but their
  13. // compilation model doesn't currently allow the preset file to tell them. Make
  14. // sure to set the following constants in user-preset-constants.h accordingly too:
  15. // 1.) bloom_approx_scale_x = scale_x2
  16. // 2.) mask_resize_viewport_scale = vec2(scale_x6, scale_y5)
  17. // Finally, shader passes need to know the value of geom_max_aspect_ratio used to
  18. // calculate scale_y5 (among other values):
  19. // 1.) geom_max_aspect_ratio = (geom_max_aspect_ratio used to calculate scale_y5)
  20. // Pass0: Linearize the input based on CRT gamma and bob interlaced fields.
  21. // (Bobbing ensures we can immediately blur without getting artifacts.)
  22. program
  23. filter: nearest
  24. vertex: first-pass-linearize-crt-gamma-bob-fields.vs
  25. fragment: first-pass-linearize-crt-gamma-bob-fields.fs
  26. format: rgba16f
  27. height: 100%
  28. width: 100%
  29. // Pass1: Resample interlaced (and misconverged) scanlines vertically.
  30. // Separating vertical/horizontal scanline sampling is faster: It lets us
  31. // consider more scanlines while calculating weights for fewer pixels, and
  32. // it reduces our samples from vertical*horizontal to vertical+horizontal.
  33. // This has to come right after ORIG_LINEARIZED, because there's no
  34. // "original_source" scale_type we can use later.
  35. program
  36. filter: linear
  37. vertex: scanlines-vertical-interlacing.vs
  38. fragment: scanlines-vertical-interlacing.fs
  39. height: 400%
  40. width: 100%
  41. format: rgba16f
  42. // Pass2: Do a small resize blur of ORIG_LINEARIZED at an absolute size, and
  43. // account for convergence offsets. We want to blur a predictable portion of the
  44. // screen to match the phosphor bloom, and absolute scale works best for
  45. // reliable results with a fixed-size bloom. Picking a scale is tricky:
  46. // a.) 400x300 is a good compromise for the "fake-bloom" version: It's low enough
  47. // to blur high-res/interlaced sources but high enough that resampling
  48. // doesn't smear low-res sources too much.
  49. // b.) 320x240 works well for the "real bloom" version: It's 1-1.5% faster, and
  50. // the only noticeable visual difference is a larger halation spread (which
  51. // may be a good thing for people who like to crank it up).
  52. // Note the 4:3 aspect ratio assumes the input has cropped geom_overscan (so it's
  53. // *intended* for an ~4:3 aspect ratio).
  54. program
  55. filter: linear
  56. vertex: bloom-approx.vs
  57. fragment: bloom-approx.fs
  58. format: rgba16f
  59. width: 320 px
  60. height: 240 px
  61. // Pass3: Vertically blur the input for halation and refractive diffusion.
  62. // Base this on BLOOM_APPROX: This blur should be small and fast, and blurring
  63. // a constant portion of the screen is probably physically correct if the
  64. // viewport resolution is proportional to the simulated CRT size.
  65. program
  66. filter: linear
  67. vertex: blur9fast-vertical.vs
  68. fragment: blur9fast-vertical.fs
  69. format: rgba16f
  70. height: 100%
  71. width: 100%
  72. // Pass4: Horizontally blur the input for halation and refractive diffusion.
  73. // Note: Using a one-pass 9x9 blur is about 1% slower.
  74. program
  75. filter: linear
  76. vertex: blur9fast-horizontal.vs
  77. fragment: blur9fast-horizontal.fs
  78. format: rgba16f
  79. height: 100%
  80. width: 100%
  81. // Pass5: Lanczos-resize the phosphor mask vertically. Set the absolute
  82. // scale_x5 == mask_texture_small_size.x (see IMPORTANT above). Larger scales
  83. // will blur, and smaller scales could get nasty. The vertical size must be
  84. // based on the viewport size and calculated carefully to avoid artifacts later.
  85. // First calculate the minimum number of mask tiles we need to draw.
  86. // Since curvature is computed after the scanline masking pass:
  87. // num_resized_mask_tiles = 2.0;
  88. // If curvature were computed in the scanline masking pass (it's not):
  89. // max_mask_texel_border = ~3.0 * (1/3.0 + 4.0*sqrt(2.0) + 0.5 + 1.0);
  90. // max_mask_tile_border = max_mask_texel_border/
  91. // (min_resized_phosphor_triad_size * mask_triads_per_tile);
  92. // num_resized_mask_tiles = max(2.0, 1.0 + max_mask_tile_border * 2.0);
  93. // At typical values (triad_size >= 2.0, mask_triads_per_tile == 8):
  94. // num_resized_mask_tiles = ~3.8
  95. // Triad sizes are given in horizontal terms, so we need geom_max_aspect_ratio
  96. // to relate them to vertical resolution. The widest we expect is:
  97. // geom_max_aspect_ratio = 4.0/3.0 // Note: Shader passes need to know this!
  98. // The fewer triads we tile across the screen, the larger each triad will be as a
  99. // fraction of the viewport size, and the larger scale_y5 must be to draw a full
  100. // num_resized_mask_tiles. Therefore, we must decide the smallest number of
  101. // triads we'll guarantee can be displayed on screen. We'll set this according
  102. // to 3-pixel triads at 768p resolution (the lowest anyone's likely to use):
  103. // min_allowed_viewport_triads = 768.0*geom_max_aspect_ratio / 3.0 = 341.333333
  104. // Now calculate the viewport scale that ensures we can draw resized_mask_tiles:
  105. // min_scale_x = resized_mask_tiles * mask_triads_per_tile /
  106. // min_allowed_viewport_triads
  107. // scale_y5 = geom_max_aspect_ratio * min_scale_x
  108. // # Some code might depend on equal scales:
  109. // scale_x6 = scale_y5
  110. // Given our default geom_max_aspect_ratio and min_allowed_viewport_triads:
  111. // scale_y5 = 4.0/3.0 * 2.0/(341.33333 / 8.0) = 0.0625
  112. // IMPORTANT: The scales MUST be calculated in this way. If you wish to change
  113. // geom_max_aspect_ratio, update that constant in user-preset-constants.h!
  114. program
  115. filter: linear
  116. format: rgba16f
  117. width: 64 px
  118. height: 6.25%
  119. vertex: mask-resize-vertical.vs
  120. fragment: mask-resize-vertical.fs
  121. pixmap: textures/TileableLinearApertureGrille15Wide8And5d5SpacingResizeTo64.png
  122. filter: linear
  123. wrap: repeat
  124. pixmap: textures/TileableLinearApertureGrille15Wide8And5d5Spacing.png
  125. filter: linear
  126. wrap: repeat
  127. pixmap: textures/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacingResizeTo64.png
  128. filter: linear
  129. wrap: repeat
  130. pixmap: textures/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacing.png
  131. filter: linear
  132. wrap: repeat
  133. pixmap: textures/TileableLinearShadowMaskEDPResizeTo64.png
  134. filter: linear
  135. wrap: repeat
  136. pixmap: textures/TileableLinearShadowMaskEDP.png
  137. filter: linear
  138. wrap: repeat
  139. // Pass6: Lanczos-resize the phosphor mask horizontally. scale_x6 = scale_y5.
  140. // TODO: Check again if the shaders actually require equal scales.
  141. program
  142. filter: nearest
  143. vertex: mask-resize-horizontal.vs
  144. fragment: mask-resize-horizontal.fs
  145. format: rgba16f
  146. // Pass7: Resample (misconverged) scanlines horizontally, apply halation, and
  147. // apply the phosphor mask.
  148. program
  149. filter: linear
  150. format: rgba16f
  151. height: 100%
  152. width: 100%
  153. vertex: scanlines-horizontal-apply-mask.vs
  154. fragment: scanlines-horizontal-apply-mask.fs
  155. pixmap: textures/TileableLinearApertureGrille15Wide8And5d5SpacingResizeTo64.png
  156. filter: linear
  157. wrap: repeat
  158. pixmap: textures/TileableLinearApertureGrille15Wide8And5d5Spacing.png
  159. filter: linear
  160. wrap: repeat
  161. pixmap: textures/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacingResizeTo64.png
  162. filter: linear
  163. wrap: repeat
  164. pixmap: textures/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacing.png
  165. filter: linear
  166. wrap: repeat
  167. pixmap: textures/TileableLinearShadowMaskEDPResizeTo64.png
  168. filter: linear
  169. wrap: repeat
  170. pixmap: textures/TileableLinearShadowMaskEDP.png
  171. filter: linear
  172. wrap: repeat
  173. // Pass 8: Compute a brightpass. This will require reading the final mask.
  174. program
  175. filter: linear
  176. format: rgba16f
  177. vertex: brightpass.vs
  178. fragment: brightpass.fs
  179. // Pass 9: Blur the brightpass vertically
  180. program
  181. filter: linear
  182. format: rgba16f
  183. vertex: bloom-vertical.vs
  184. fragment: bloom-vertical.fs
  185. // Pass 10: Blur the brightpass horizontally and combine it with the dimpass:
  186. program
  187. filter: linear
  188. format: rgba16f
  189. height: 100%
  190. width: 100%
  191. vertex: bloom-horizontal-reconstitute.vs
  192. fragment: bloom-horizontal-reconstitute.fs
  193. // Pass 11: Compute curvature/AA:
  194. program
  195. filter: linear
  196. format: rgba16f
  197. vertex: geometry-aa-last-pass.vs
  198. fragment: geometry-aa-last-pass.fs
  199. output
  200. filter: nearest