Guest User

PhiOS v0.1 readme

a guest
Dec 6th, 2016
1,394
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PhiOS (ASCII Rendering Engine for Unity)
  2. --------------------------------------------
  3. VERSION: v0.1
  4. LAST UPDATED: 06/12/2016
  5. AUTHOR: https://twitter.com/phi6
  6. LICENSE: CC BY 4.0
  7. https://creativecommons.org/licenses/by/4.0/
  8. --------------------------------------------
  9.  
  10. This is the first (base) version of PhiOS, which provides cell rendering, cell stacking/layers,
  11. foreground & background colors, cell transition animations, bitmap font support & rudimentary mouse input.
  12.  
  13. The layered windowing system and scrollable UI widgets are not included in this release (yet).
  14. All that stuff will be in future extended versions. SOON™
  15.  
  16. Note: PhiOS does NOT include any post-processing image effects (all that fancy stuff like scanlines,
  17. bloom, CRT monitor distortion, glitches etc... that you may have seen on previous screenshots).
  18. These are all provided by third party plugins, please see the Third Party Effects section below
  19. if you want to replicate your display to look like this.
  20.  
  21. Disclaimer: There will probably be bugs and incomplete/missing features! This engine was always intended
  22. to be part of a larger game project, and not as a tool released to the public. However, I'm putting it
  23. out there anyway due to popular request. Code is provided as-is.
  24.  
  25. QUICKSTART
  26. ----------
  27. 1. Import the PhiOS_Base_0_1.unitypackage into your project.
  28.  
  29. 2. The best place to start is to check out the ExampleScene under the PhiOS/Scenes folder.
  30.  
  31. 3. ExampleScene contains 2 GameObject prefabs, PhiOS_Bootstrap and Scene_Example.
  32. The PhiOS_Bootstrap object is required in all Unity scenes that make use of an ASCII display.
  33. The Scene_Example object contains a MonoBehaviour script showing examples of basic functionality.
  34.  
  35. 4. Study the code in the Example.cs script (the one attached to the Scene_Example object) and you'll be
  36. rendering, clearing and animating cells in no time.
  37.  
  38. FONTS
  39. -----
  40. PhiOS uses the default REXPaint Codepage 437 font to help you get started quickly.
  41. You can also use your own fonts in one of two ways :-
  42.  
  43. 1. Use a REXPaint-compatible font tileset. This is the preferred method.
  44. - Simply copy and paste the REXPaint font .png directly into your Unity project.
  45. The higher the resolution the better, so I upscaled the default 20x20 font to 60x60 using
  46. Nearest Neighbour scaling in order to preserve the hard pixels.
  47. - Your .png texture should be imported into Unity with the Alpha From Grayscale and bilinear
  48. filtering enabled.
  49. - Create a new material for your font texture, you can use my Phigames/Alpha Vertex Color shader
  50. but any transparent vertex color shader will work.
  51. - Assign this material to the BitmapFont MonoBehaviour component on the Display object of the
  52. bootstrap in your scene hierarchy, under the REXPaint CP437 header.
  53. - Make sure "Use REX Paint Font" IS ticked.
  54. - Ensure texture size and grid size is correct for your .png font texture.
  55. - Bilinear filtering will cause some bleeding artifacts, so set your bleed here to counteract
  56. this. The bleed value of 3 works well with the default font.
  57. - You can use the Quad Height Scale variable to vertically stretch your font. Square fonts
  58. (scale of 1) are preferable for topdown map tiles, but this is less readable as text. The default 1.4
  59. scale seems to be a nice compromise between readable text and aesthetically pleasing map tiles.
  60.  
  61. OR...
  62.  
  63. 2. Convert a TTF to bitmap using BMFont. I used the following settings to generate the font used by
  64. PhiOS (Source Code Pro from the Font Squirrel website, license is included).
  65. > Font Settings: Size 72px, do not include kerning pairs, use TTF outline, hinting, smoothing,
  66. super sampling level 4
  67. > Export Options: 0 padding, 5 spacing, equalize cell heights, 2048x2048 texture size, white text
  68. with alpha, XML file format, .png textures
  69. - You will require both the .fnt (XML) and .png exported files, drop them both into your Unity project.
  70. - Your .png texture should be imported into Unity with both alpha options and bilinear filtering enabled.
  71. - Create a new material for your font texture, you can use my Phigames/Alpha Vertex Color shader
  72. but any transparent vertex color shader will work.
  73. - Assign your .fnt and material to the BitmapFont MonoBehaviour component on the Display object
  74. of the bootstrap in your scene hierarchy, under the BMFont header.
  75. - Make sure "Use REX Paint Font" is NOT ticked.
  76. - Ensure your glyph height and glyph width (default is 72x34) matches the values in your .fnt (XML) file.
  77. - You can use the Quad Height Scale variable to vertically stretch your font, but as you're using a
  78. TTF it's probably best to keep this at 1, unless you want to artificially make your font square.
  79.  
  80. DISPLAY GRID SIZE
  81. -----------------
  82. By default, PhiOS uses a fixed display width of 80 characters, and then automatically calculates
  83. the height based on the font used, the quad height scale and the screen aspect ratio. It will then
  84. adjust the camera's orthographic size in order to fit the display to the edges of the screen as tightly
  85. as possible.
  86.  
  87. If you wish, you can disable the automatic grid height, for cases where you might want a fixed grid
  88. size regardless of screen aspect ratio. Go to the Display MonoBehaviour component on the Display
  89. object of the bootstrap in your scene hierarchy, and untick Auto Display Height. You are now able
  90. to set your grid height manually.
  91.  
  92. API QUICKSTART
  93. --------------
  94. Check the Example.cs script for examples of basic functionality.
  95. Things to note :-
  96. - Make sure you wait until Display.IsInitialized() returns true before updating any cells.
  97. - Grab the cell you want to update by calling Display.CellAt(layer, x, y)
  98. - Update the cell content using Cell.SetContent()
  99. - Clear the cell using Cell.Clear()
  100. - Check out the SetContent() and Clear() function overloads. You can have separate foreground and
  101. background colors, as well as gradual fade transitions between cell updates.
  102. - Only cells on the highest layers are drawn, everything below that cell on lower layers is ignored.
  103. - x,y coordinates start at top left of the screen (0,0)
  104. - Negative layers are reserved layers, and are actually drawn on top of everything else. An example
  105. of this is the mouse cursor, which draws at layer -1. Lower negative layers (such as -2) are prioritized
  106. over higher negative ones.
  107. - You can set a cell to cycle through characters of a string as part of its update transition.
  108. Handy for creating cyberpunky/hacking/glitching effects.
  109. - You can implement one of the action interfaces (IClickAction, IDragAction, IHoverAction, IScrollAction)
  110. and set them to a specific cell in order to capture mouse input for that cell. Or just disable the Mouse
  111. object entirely if you do not require mouse input.
  112.  
  113. THIRD PARTY EFFECTS
  114. -------------------
  115. My screenshots and videos show a variety of post-processing image effects to achieve a certain cyberpunk
  116. CRT aesthetic that I'm using for my games. You can replicate this look by using the following third party
  117. plugins :-
  118. - Bloom from Unity's Standard Effects asset package.
  119. - AnalogTV and Vintage from Thomas Hourdel's Colorful asset package.
  120. - Dirty Lens from Sonic Ether's Natural Bloom asset package.
  121.  
  122. CONTACT
  123. -------
  124. Shout at me on Twitter @phi6 if I've forgotten to explain something important. I'm not officially providing
  125. any significant amount of support for this, but off the record I'm generally happy to help if I can!
  126.  
  127. Good luck, and be sure to poke me if you've made something cool! :)
RAW Paste Data