Commit Graph

  • 1b7c80a21d Moved tessellation LOD stuff entirely into face culling function. This means tessellation will now also be applied to brush model faces. master Nico de Poel 2023-02-17 16:44:17 +0100
  • d5ab868cbf No need to bother with function pointers for drawing anymore, really. Nico de Poel 2023-02-17 15:14:54 +0100
  • 0ea3df5de9 Selection between textured/untextured face drawing functions moved one abstraction level higher. This eliminates redundant texture window swaps when drawing untextured, and is a bit faster overall as well. Nico de Poel 2023-02-17 11:54:52 +0100
  • 861b06f2d2 Updated map files with UVs fixed for repeating textures. Nico de Poel 2023-02-17 11:43:08 +0100
  • 87c5517bdd Swap texture window only when the twin value changes. Further reduces texture window commands, especially when drawing non-tiling faces. Also cleans up the drawing code a bit. Nico de Poel 2023-02-17 11:42:44 +0100
  • 7c0c15019c Swap texture window only when the texture changes between faces. Saves a bit on performance, though could be even better if we checked for texture window changes instead of texture ID. Nico de Poel 2023-02-14 20:55:47 +0100
  • 5bd322d33b Use texture windows to allow repeating textures on select faces. This reduces polycounts and file sizes significantly, at the expense of more texture warping and less refined lighting. Nico de Poel 2023-02-14 14:15:40 +0100
  • 1c4bd55cdb Added a front frustum plane which isn't really used for anything yet, but it could be interesting for testing different depth culling approaches. Nico de Poel 2023-02-13 16:03:31 +0100
  • 2122ae3421 Use face bounding quad to check if it may be partially inside the frustum, and force tessellation if it is. I really don't like the additional CPU load required to do this, but it is necessary to reduce the amount of near-camera polygon clipping. Nico de Poel 2023-02-12 14:53:11 +0100
  • 5ecf96428d Use catPrim and addPrims to add the tessellated quads to the OT in a slightly more efficient fashion. Nico de Poel 2023-02-11 13:42:35 +0100
  • 2167011f96 Commentary and TODOs Nico de Poel 2023-02-10 15:49:13 +0100
  • de12999cbb Minor rearrangement for "readability" Nico de Poel 2023-02-10 15:28:00 +0100
  • 2a3a8108f3 Removed the nop's before the INTPL instruction as they don't seem to be necessary. Real hardware is fine with this too. Nico de Poel 2023-02-10 15:15:09 +0100
  • abc328430c Undid some of the rearrangement that made the code not want to run on real hardware. Doesn't make any difference for the optimizations made so far. Nico de Poel 2023-02-10 15:11:12 +0100
  • 4e39f28228 Made use of the fact that we use monochrome lighting to combine light and UVs into a single lerp Nico de Poel 2023-02-10 14:43:34 +0100
  • 07f87c4ca2 Made a custom vertex lerp macro using pure GTE assembly code Nico de Poel 2023-02-10 14:37:25 +0100
  • 909b32f4c0 Some rearrangement that will hopefully allow single light values to be lerped right alongside UVs, saving on one lerp per vertex. Nico de Poel 2023-02-10 13:21:03 +0100
  • d7ec9a85a4 Interpolate vertex color and UV values using GTE instructions as well Nico de Poel 2023-02-10 12:38:03 +0100
  • cdc205f59a First successful experiment with vertex interpolation using GTE intpl instructions. Nico de Poel 2023-02-10 12:25:13 +0100
  • 7888f44bb8 Revert "Intersperse GTE instructions with vertex lerping and quad building code to mask load/store delays." Nico de Poel 2023-02-10 10:25:41 +0100
  • 4f886bd40c Intersperse GTE instructions with vertex lerping and quad building code to mask load/store delays. Makes a noticeable difference in drawing performance. Nico de Poel 2023-02-09 14:18:11 +0100
  • e0e43d6e39 Reordered some vertex code to allow for optimized GTE load/stores Nico de Poel 2023-02-09 14:01:57 +0100
  • 58b2e8dc20 Wrapped vertex copying code into a macro to make the quad drawing code more readable. Added some generic n-bit blitting macros and started using them. Nico de Poel 2023-02-09 13:08:04 +0100
  • 02b19a67dc First implementation of near-camera polygon tessellation, which surprisingly actually worked on the first try! Currently still rather inefficient, making no use of GTE for interpolation yet. Still only one tessellation level too. Nico de Poel 2023-02-09 12:56:19 +0100
  • c08858eb90 Updated map files with lighting issues fixed Nico de Poel 2023-02-08 13:26:08 +0100
  • 9474739c26 Sort faces for brush models into the overall faces list. This works well to draw models correctly by themselves, but when placed in the world they may still have clipping issues with other models and/or neighboring leafs. Nico de Poel 2023-02-07 16:18:50 +0100
  • ba1e384f69 Keep track of the leaf a model is in, so that it doesn't need to be looked up every frame but instead only when the model moves. Nico de Poel 2023-02-07 11:51:32 +0100
  • fd77b80afc First implementation of dynamic world object (model) rendering. Still very basic, with plenty of sorting and clipping issues. Nico de Poel 2023-02-06 15:46:59 +0100
  • 090cde5f89 Included face area value in tessellation LOD level calculation. Could probably use some more finetuning in practice, but this is already pretty good. Nico de Poel 2023-02-06 15:00:11 +0100
  • 4f92d4c7e3 Getting close to a formula for determining tessellation LOD that takes camera position, direction, face normal and distance into account. Still need to involve face area into this as well. Nico de Poel 2023-02-06 14:11:21 +0100
  • 916d20a5db Display PAL and NTSC on the debug status text, making it easier to distinguish what we're outputting when. Nico de Poel 2023-02-06 13:33:21 +0100
  • 5442b2d4c9 Added a draw function for flat colored quads, useful for debugging Nico de Poel 2023-02-06 12:50:25 +0100
  • 21101b3287 Added a special case for drawing faces that are single triangles. This is just as fast in DuckStation and shows a small performance increase on real hardware, so worth the effort. Nico de Poel 2023-02-05 11:57:01 +0100
  • 2344e8ba42 Unrolled quad strip drawing loop to up to three quads at a time, sharing transformed vertices between them. Not actually a performance improvement and I'm not sure why. Sidelining this for now. unrollquadloop Nico de Poel 2023-02-05 00:47:42 +0100
  • 3b89d01ec1 Embedded the texture atlas data inside the .ps1bsp file and name those files after the actual map. Makes it a bit easier to switch between maps for testing, and this is the kind of direction we want to go in anyway. Nico de Poel 2023-02-04 13:52:58 +0100
  • ef0d2ad723 Changed dot product and point-plane distance functions to use vector pointers as input. Matters nothing for performance, but it does lead to some slightly cleaner and more consistent code. Nico de Poel 2023-02-04 11:56:44 +0100
  • 4146238e1e Moved frustum planes to fast scratchpad RAM for another appreciable speed boost. Nico de Poel 2023-02-03 16:15:47 +0100
  • a7e29ee420 Fixed issue with model data memory alignment, officially using model #0 now to draw the static world geometry. Nico de Poel 2023-02-02 15:07:05 +0100
  • de12e4269f Minor stuff Nico de Poel 2023-02-02 14:41:35 +0100
  • 2cb5bcb856 Added support for setting the clear color to a generic sky color. This is very basic and it does exacerbate the gaps between polygons on some maps, but at least we get to have something of a sky. Nico de Poel 2023-02-02 12:49:18 +0100
  • 26d541e48f Eliminated recursion from the BSP traversal, using fast RAM to hold the node stack. Yet another appreciable speed boost. Nico de Poel 2023-02-02 11:37:40 +0100
  • 520e62922c Perform backface culling early to save on a bunch of needless linked list iterations. Moved primitive buffer check and generalized it. It's fine to only check for the worst case scenario. Nico de Poel 2023-02-02 10:58:59 +0100
  • 32237fc6ec Fixed a few issues and further optimized the quad drawing code. Nico de Poel 2023-02-01 21:03:43 +0100
  • 4f2d70cc82 Added some macros to make the optimized drawing code more readable, and applied the same optimization to water drawing. Nico de Poel 2023-02-01 19:54:24 +0100
  • 74a36f0938 Found a 10% performance boost by simply reordering data access when filling in polygon data, and by blitting UV and RGB values with a single copy. Nico de Poel 2023-02-01 19:40:01 +0100
  • 38e91f4c3a BSP file now includes model data for dynamic world objects Nico de Poel 2023-02-01 13:51:36 +0100
  • 97d23f0bc9 Removed unused texture metadata fields. Only the texture page and precalculated per-vertex UVs are needed to draw textured polygons. Nico de Poel 2023-01-31 12:22:29 +0100
  • 542a81b68c Draw lava, slime and teleporters as liquids, but not transparent. Nico de Poel 2023-01-31 11:21:41 +0100
  • 314b52e99e Added a separate CLUT for transparent surfaces, and set semi-transparency mode on water polygons. Nico de Poel 2023-01-31 10:49:48 +0100
  • ae080953f7 Rewrote the other face drawing functions to ditch the vertex copying stage too. Nico de Poel 2023-01-30 17:29:10 +0100
  • be7eb87685 Ditched the copy-to-scratch-RAM step for drawing textured faces, which apparently is no longer needed to run on real hardware. Simpler code, less work to do, better performance. An all-round win. Nico de Poel 2023-01-30 17:19:49 +0100
  • ba83d78aa8 Removed the need for global variables for sorting leafs and faces Nico de Poel 2023-01-30 14:08:41 +0100
  • 4d138b4199 Added an extra face sorting step so we can draw faces in front-to-back order: - Nodes are traversed front-to-back, leafs are sorted back-to-front - Leaf faces are collected back-to-front to ensure faces shared between leaves are drawn in the correct order - Faces to be drawn are then sorted front-to-back and drawn in that order - This obsoletes the need for any kind of depth calculations, and makes the primitive buffer cutoff work as intended Nico de Poel 2023-01-30 14:01:04 +0100
  • a8d3bf567b First pass at leaf-based rendering order: - Sort leafs first into a linked list, before drawing their faces - Depth value for faces is determined by the leaf order, OT position is calculated once per leaf - Removes the need for per-primitive depth calculation & check, so those are removed - Moved primitive buffer check out of the primitive drawing routines and to the start of each face drawing function - Triangle drawing routines now only draw a single triangle, no loops involved - Simplified drawing routines where possible - Face drawing is still happening in back-to-front order, so this needs another good look at Nico de Poel 2023-01-30 12:52:25 +0100
  • 5e738340b8 Added box-frustum test code, used to experiment with more accurate per-leaf bounding box frustum culling. Not really worth it as it only makes things slower in the end. Nico de Poel 2023-01-29 18:51:15 +0100
  • 812bcb6a63 Some micro-optimizations in the face drawing code. The PS1 really does favor simple counters over pointer arithmetic. Nico de Poel 2023-01-29 18:23:29 +0100
  • b0893a902d Added support for leaf-based frustum culling, but leaving it disabled for now. Nico de Poel 2023-01-29 12:40:25 +0100
  • ea2b963653 Implemented per-node frustum culling based on bounding spheres. Nico de Poel 2023-01-29 12:28:46 +0100
  • ec0eebce3c Fixed frustum calculation and implemented point and sphere tests. Now also tested and looking decent. Nico de Poel 2023-01-29 00:57:01 +0100
  • 0f450cf6b1 Added initial frustum calculation based on screen parameters and view matrix. Nico de Poel 2023-01-28 22:48:16 +0100
  • b1e568e5c3 Added check to backface culling to see if the face is behind the camera. This will be required if we ditch depth-based culling in favor of leaf-based depth. Also makes for a nice speed boost in some scenarios already. Nico de Poel 2023-01-28 15:47:29 +0100
  • 7232e061d7 Added a fast face drawing routine, which is basically what we had before: - Faces directly point to vertices using the face vertex buffer - Draw faces as quad strips from the original face data, without tessellation Nico de Poel 2023-01-28 15:14:04 +0100
  • 85a8b332c5 Some reorganization of face drawing code; allow better separation between drawing methods, and require the "enable texturing" check only once ahead of drawing. Nico de Poel 2023-01-28 12:53:50 +0100
  • c9bee9d500 Draw water surfaces as unlit textured polygons Nico de Poel 2023-01-28 00:14:51 +0100
  • 73903474e4 Moved polygon drawing routines into a separate header file Nico de Poel 2023-01-27 23:57:40 +0100
  • 8b34fb1950 Small tweaks: made background black to cover up seams, defined a few flags Nico de Poel 2023-01-27 23:53:31 +0100
  • 3b5a59dae6 Geometry, textures and lighting now all working correctly. Ditched the concept of surface vertices, as UVs cannot be shared between polygons. Nico de Poel 2023-01-27 15:54:27 +0100
  • ebbc01c672 Overhaul of geometry representation, with correct UV'ing and more finely tesselated surfaces. Nico de Poel 2023-01-27 13:33:58 +0100
  • 62cfb91f1c Made some tweaks after experimenting with interlaced mode: - VSync needs to be enabled for interlaced mode to work at all - Y offset does not need to be doubled in interlaced mode Nico de Poel 2023-01-27 13:27:09 +0100
  • 989ec0bafb Simplified toggle behavior for button inputs, and added an option to toggle texturing with the circle button. Nico de Poel 2023-01-25 12:56:30 +0100
  • 9c1cbd467e Small tweaks: - Math functions return results in 32-bit int, cast back to short is done only where necessary - Changed GTE screen distance to obtain an exact 90 degree horizontal FOV in 4:3 mode Nico de Poel 2023-01-25 12:44:50 +0100
  • a478a7c1ed Fixed a silly mistake in the primitive buffer allocation space check Nico de Poel 2023-01-25 12:42:41 +0100
  • b43767ebb8 Realized we can include the UV offsets into the UVs stored in the preprocessed map file, so we don't need to add those at runtime. Easy performance win. Nico de Poel 2023-01-25 11:16:05 +0100
  • 35d91b1de2 Switched to map atlas image file generated directly by the preprocessing tool, rather than a .pcx converted by img2tim. This one fixes the holes in the textures on pure black pixels. Nico de Poel 2023-01-24 10:30:00 +0100
  • 6a3554511b Simplified controls, so that strafe left/right only moves on the X/Y plane, while up/down only moves along the Z axis. Nico de Poel 2023-01-23 07:25:59 +0100
  • 5549e3f126 Textures are now showing up somewhat correctly! Most of the actual changes are on the data conversion side. Nico de Poel 2023-01-23 03:18:09 +0100
  • 297ae187f6 Fixed some issues with texture atlas generation. The image is at least stable now, but textures are still not drawing properly. Nico de Poel 2023-01-22 18:35:10 +0100
  • 76a6dc92d5 First pass at implementing texturing of face polygons. Not quite right yet but things are starting to work. Nico de Poel 2023-01-22 14:50:01 +0100
  • 1a88f6e052 Fixed the wonky camera rotation, though the left/right vectors are still off. Nico de Poel 2023-01-20 14:07:51 +0100
  • c8c44b352f A bit of cleanup ahead of attempting to make textures work Nico de Poel 2023-01-20 13:45:04 +0100
  • 0c0de31b78 Experimenting with tessellation subdivision formula: using dot product for backface culling as a parameter of camera-to-face distance and angle. Also includes face area as a parameter: the larger the face, the more subdivisions it'll need. Visualizing this with colors, blended with the lighting data. tess_experiment Nico de Poel 2023-01-20 12:59:33 +0100
  • 36c409115a Use per-face vertex lighting for improved geometry definition and less light leaking between sharp-angled surfaces. Nico de Poel 2023-01-20 10:54:31 +0100
  • 1796d75c20 Made the framerate counter show 100ths of a second Nico de Poel 2023-01-19 14:33:45 +0100
  • 586ee71c3c Added anamorphic 16:9 widescreen support because why the heck not? Nico de Poel 2023-01-19 14:24:31 +0100
  • e1d239150e Made polygon building faster by checking ahead of time if we have enough primitive buffer space, instead of checking it per polygon. Also the primitive buffer management is now all done through inline functions. Nico de Poel 2023-01-19 14:01:28 +0100
  • 59d838f501 Small optimization to BSP tree traversal, by making the child node selection branchless Nico de Poel 2023-01-19 12:44:27 +0100
  • b0d36ab11b Sped up plane calculations by making use of axis-aligned properties Nico de Poel 2023-01-19 12:25:34 +0100
  • bbf87bbf58 Implemented backface culling per face, by adding plane and center point fields to the face struct and checking the plane's normal against the camera vector to the center point. This eliminates the need for per-polygon normal clipping and reduces the amount of redundant vertex copying, for a measurable speed boost. Nico de Poel 2023-01-19 11:51:24 +0100
  • ddffc8860e Fixes to make things work on real hardware again: - Struct pointers need to be 32-bit aligned, otherwise the PS1 will crash - For this purpose, some structs have been padded to make them a multiple of 4 bytes in size - Vector data needs to be copied into scratch RAM at a 32-bit aligned address Nico de Poel 2023-01-18 13:47:11 +0100
  • 3a7ea8d4b3 Debugging work: - Load map data using a macro, so I can easily change the implementation for all data chunks. - Implemented a visdata function that loads all 1's, so that every leaf will be drawn. - Point-to-plane distance now uses copies of input vectors. May or may not be faster. - Fixed fps counter rounding and disabled vsync so we can see the true framerate Nico de Poel 2023-01-18 11:30:32 +0100
  • a05a800da0 Implemented PVS decompression, leaf visibility check using PVS data, and front-to-back traversal of the BSP tree. Nico de Poel 2023-01-17 21:28:56 +0100
  • b7da18d0c8 First bits of code involving BSP traversal with front/back selection and math: determine the leaf that the camera is currently in. Nico de Poel 2023-01-17 18:04:45 +0100
  • 337406c03f Use the node and leaf data to traverse the entire BSP tree and draw all attached faces. This already gets rid of all the collision volumes that were being drawn before. Nico de Poel 2023-01-17 15:15:30 +0100
  • 37f619dc94 Load plane, node and leaf data, and iterate through leaves to draw faces. Nico de Poel 2023-01-17 14:17:47 +0100
  • 0e1bb7a5bf Reworked PS1BSP format to use dentry-style header info Nico de Poel 2023-01-17 11:08:35 +0100
  • c5783982e1 Added a more aggressive inlining macro. Not sure if it makes any difference now, but it's nice to have the option. Nico de Poel 2023-01-16 22:54:26 +0100
  • dfa6ec2f85 Split face drawing off into a separate function, and made triangle fan and triangle strip available again as alternative options, for comparison. Also using triangle fan as a special case for faces with three vertices, i.e. a simple single triangle. Nico de Poel 2023-01-16 22:38:54 +0100
  • d3efa8e590 Keep track of and display total polycount Nico de Poel 2023-01-16 22:16:59 +0100
  • 75ae399d38 Implemented quad strip topology for rendering faces, which is actually a good bit simpler than triangle strips. Nico de Poel 2023-01-16 22:03:16 +0100
  • 7606d89998 Implemented triangle strip topology for drawing faces Nico de Poel 2023-01-16 16:43:35 +0100