Commit Graph

  • 39fa8bcb14 Apply uv offsets only on non-repeating textures, to avoid overflow errors on textures near the texture page edges. Fixes wonky textures on maps like E1M1 and E1M8. master Nico de Poel 2023-02-16 18:50:59 +0100
  • 7205dbdc31 Loosened tolerance for vertex equality a bit more because wow, floats are really inaccurate huh? Fixes light sampling issues on E4M6 and E4M7. Nico de Poel 2023-02-16 15:12:28 +0100
  • 552678f67c Reduced amount of geometry artifacting from T-junctions by rounding repeating UVs down to a grid that will be shared by adjacent faces using the same textures. Sacrifices some performance again, but makes both geometry and lighting look a lot more solid. Nico de Poel 2023-02-14 16:12:31 +0100
  • 68eb9c10c8 Tessellate faces into bigger chunks when texture repeating is an option. This is kept conservative at just 2x2 cell sizes, because bigger polygons with more repeats will cause more texture warping and geometry glitching. This is already the biggest gain. Nico de Poel 2023-02-14 14:02:47 +0100
  • eb3de1b624 Pack repeatable textures first, followed by other textures in the remaining space. This is actually producing more efficient textures atlases. The hell. Nico de Poel 2023-02-14 13:18:49 +0100
  • 435b62f280 Reorganized the texture packing code to allow for multiple packing steps, with repeatable textures getting packed first. Nico de Poel 2023-02-14 12:44:59 +0100
  • 83dbee34e5 Use GPC to get rid of redundant vertices on some faces, which will reduce a bunch of them down to simple quads. This makes for slightly less additional vertex data required when storing bounds. Nico de Poel 2023-02-12 14:39:07 +0100
  • 7fd5f09a34 Add four bounding vertex references to each face, for more accurate behind-the-camera/frustum culling Nico de Poel 2023-02-12 14:19:18 +0100
  • 2626b9c67f A bit of cleanup: - Ditching the face vertex thing since we're not likely to use the low-quality render path in practice, and this saves a ton on extra vertex data - No need to build a world-space bounding box per face anymore Nico de Poel 2023-02-12 13:18:47 +0100
  • b0f7e971e8 Detect and link animated texture frames Nico de Poel 2023-02-12 01:16:22 +0100
  • b0e6083d13 Added a few source references Nico de Poel 2023-02-12 00:06:16 +0100
  • f35fd7287e Made an attempt at detecting T-junctions in geometry and correcting the vertices for that. It sort of works but it doesn't have the desired effect yet. Back to the drawing board. Nico de Poel 2023-02-10 18:01:12 +0100
  • 225ec746ec Updated vertex field names to match, to facilitate blitting to SVECTOR Nico de Poel 2023-02-09 16:24:18 +0100
  • c111a2090c Implemented a more accurate face area computation, allowing for more precise tessellation LOD selection. Also started putting face-related functions into a separate source file. Nico de Poel 2023-02-09 10:56:39 +0100
  • a4c3dba734 Allow easier bulk map conversion Nico de Poel 2023-02-08 11:47:23 +0100
  • f5ffefce4c Additional debugging output Nico de Poel 2023-02-08 10:55:40 +0100
  • 64865249a4 Removed the baselight addition during light sampling, as that was actually the cause of weird lighting bugs in some areas. This will probably be relevant again when implementing animated lights, but not right now. Nico de Poel 2023-02-08 10:51:04 +0100
  • b43dff99a2 Fixed a floating point rounding error preventing faces from being found for some world-space points. Fixes lighting bugs in a few areas. Nico de Poel 2023-02-07 21:46:14 +0100
  • 727c5bf724 Tweaked light sampling a bit more, should be more accurate to Quake's original implementation now (though it hardly makes any difference in practice) Nico de Poel 2023-02-07 20:24:15 +0100
  • ca08893253 Relaxed vector equality margin of error a little bit, hopefully leading to less instances of faces not being found for a given point Nico de Poel 2023-02-07 16:22:21 +0100
  • 0a077b426c Reworked lightmap sampling using a lightmap space transform and correctly rounding values, using the Quake source for reference. Finally fixes a bunch of lingering lighting artifacts. Nico de Poel 2023-02-07 12:54:08 +0100
  • ac84af48f2 Create a reusable texture space transform matrix per face, and use it to build up the texture boundaries. Nico de Poel 2023-02-07 12:09:06 +0100
  • b87102afb2 Export model face data Nico de Poel 2023-02-06 16:09:25 +0100
  • 197c657361 Prevent 16-bit overflow when storing face area; fixes wildly inconsistent tessellation LOD calculations Nico de Poel 2023-02-06 14:53:35 +0100
  • 8d51e7e252 Embed the texture atlas data inside the exported .ps1bsp file and name those files after the actual map. Makes it a bit easier to switch between maps for testing. Nico de Poel 2023-02-04 13:55:24 +0100
  • dfe7806450 Reorganized model data so as not to cause any memory alignment issues Nico de Poel 2023-02-02 15:06:21 +0100
  • 97a08243b5 Added a world spawn element with a generic sky color derived from the sky texture Nico de Poel 2023-02-02 12:47:53 +0100
  • 45796822cd Reorganized poly vertex data structure to allow for faster copying in the PS1 code Nico de Poel 2023-02-01 23:57:34 +0100
  • caaccee1dd Export model data for dynamic world objects Nico de Poel 2023-02-01 13:52:17 +0100
  • dc78b9700d Calculate average and dominant colors per texture, and use those to precalculate combined color * light values per face vertex, for cheap vertex colored drawing. Nico de Poel 2023-01-31 14:49:24 +0100
  • cc18611de8 Reorganized texture code so that the palette is loaded separately, and metadata used to calculate UVs are kept out of the exported file for PS1. Nico de Poel 2023-01-31 12:21:17 +0100
  • 9f1ed1f35f Draw lava, slime and teleporters as liquids, but not transparent. Nico de Poel 2023-01-31 11:21:08 +0100
  • c8d8d0b905 Added a few more file extensions to the ignore list Nico de Poel 2023-01-31 10:43:50 +0100
  • 64d9b16c12 Duplicate the Quake palette CLUT with transparency flag set, to use for water surfaces. Doesn't actually work yet but the solution should be something in this direction. Nico de Poel 2023-01-31 10:42:27 +0100
  • c6a8abbb7b Made the texture space transform available outside of Tessellator and used it to generate some more Face bounds data for later use. Nico de Poel 2023-01-31 10:41:31 +0100
  • fb66f93b46 Provide some additional data in the PS1 BSP file, including linked list pointers for leaf-based polygon sorting Nico de Poel 2023-01-30 14:44:25 +0100
  • cc1fcec7ea Also add leaf bounding sphere for optional per-leaf frustum culling. Nico de Poel 2023-01-29 12:41:14 +0100
  • c91e8e6167 Added bounding spheres to node data, used for frustum culling Nico de Poel 2023-01-29 12:29:38 +0100
  • 0df5801eba Export face vertex data again, to allow for simplified rendering routines Nico de Poel 2023-01-28 15:12:19 +0100
  • 93551117b1 Added surface flags, allowing for rendering of water surfaces Nico de Poel 2023-01-28 00:14:16 +0100
  • 4655246b69 Retired the concept of surface vertices, as UVs can in fact not be shared between polygons. I may revisit this idea when trying to compress data size, as lighting data can be shared between poly vertices. Nico de Poel 2023-01-27 15:53:27 +0100
  • ef9adf8de0 Introduced some matrix math to properly construct a texture space transform, that we can also invert to create a transform back to world space. Finally our tesselated polygons are working perfectly! Nico de Poel 2023-01-27 15:32:40 +0100
  • 4e11041b93 Desaturate palette colors to more closely match Quake's look, and made an exception for the big Quake sign on the start map, so it maintains a higher mip level. Nico de Poel 2023-01-27 13:32:20 +0100
  • fc281251ea Overhaul of geometry conversion: - Faces are now tessellated into one or more polygons, based on UV coordinates and texture tiling - Polygons have their own vertex index list and light/UV values per vertex - Lighting is sampled per polygon vertex, allowing for more light samples in general and more refined lighting - There are still problems with reconstruction of vertices for sloped surfaces, but this is enough of a result for a checkpoint commit Nico de Poel 2023-01-27 13:31:41 +0100
  • 4f99baea65 Encapsulated GPC-based tesselation into a Tesselator class, which now also produces normalized UVs per vertex-texture pair and a list of Polygon structs with texture and vertex index data. Nico de Poel 2023-01-26 11:36:58 +0100
  • f413e8c47f First test with GPC to cut faces into multiple polygons, based on a grid of texture boundaries. Reconstruct the texture space (s,t) coordinates back into world space. Store vertices and indices while avoiding duplicate vertices. Nico de Poel 2023-01-25 22:11:18 +0100
  • e5b2e6244a Imported General Polygon Clipper library, which could come in handy to cut up faces to accomplish texture tiling Nico de Poel 2023-01-25 19:12:04 +0100
  • 568f2450eb Added a new lighting sampler to take advantage of the improved lightmap indexing: use a pseudo-random jitter pattern to take multiple light samples in an area around the sample point, from all surrounding faces at a shallow angle. This further smooths out the lighting and reduces artifacts, while also better representing each face's entire lightmap. Nico de Poel 2023-01-25 11:40:10 +0100
  • 6d6766663b Realized we can include the UV offsets into the UVs stored in the exported map file, so we don't need to add those at runtime. Easy performance win. Nico de Poel 2023-01-25 11:15:14 +0100
  • 3bc9167885 Tweaked heuristics of the rectpack algorithm to produce better results for our non-square texture atlases. Ensure we don't exceed the maximum range of PS1 UV coordinates by limiting texture width and height. Nico de Poel 2023-01-25 10:52:48 +0100
  • fb3d1ac6a1 Upgraded dot product and cross product-related functions to doubles, to improve accuracy of various calculations Nico de Poel 2023-01-25 10:50:53 +0100
  • 161ef0acee Improved lightmap sampling accuracy. The generated UVs now more closely match what Quake is doing, we can reject invalid UVs, and we're getting less false rejects of valid faces to sample from. Nico de Poel 2023-01-24 21:32:55 +0100
  • 5e85e2c73a Modified texture packer to allow for arbitrary input bin sizes. Added transparency flag to final palette entry. Nico de Poel 2023-01-24 12:59:16 +0100
  • 0a19ca70f5 Texture atlasing tool now directly exports images in .TIM format for use on PS1 Nico de Poel 2023-01-23 16:07:28 +0100
  • 628955d7a0 Added code and resources for exporting TIM image files directly Nico de Poel 2023-01-23 10:58:53 +0100
  • 3e0706c9f9 Small tweaks to make a few textures on n64start a bit nicer Nico de Poel 2023-01-23 10:49:49 +0100
  • beb1ad6382 Fixed texture seams and bleeding caused by making our UVs one texel too large Nico de Poel 2023-01-23 03:20:07 +0100
  • 6c2d61b2dc Invent some texture UVs that remain within each face's UV bounds, to prevent tiling and still get some UVs that make at least a bit of sense. Nico de Poel 2023-01-22 20:07:53 +0100
  • 72d03aff9c Fixed some issues with texture atlas, page and ID generation. Texture references generally seem to be in order now, but UVs are still a problem. Nico de Poel 2023-01-22 18:34:18 +0100
  • d84a14973b First pass at converting texture info to PS1 VRAM data. Not quite right yet but it's starting to work. Nico de Poel 2023-01-22 14:48:03 +0100
  • 5137fe0a15 A bit of cleanup and moved the facesWithPoint function to world_t, for easier reuse Nico de Poel 2023-01-21 23:17:43 +0100
  • e0373524ca Further improvement to lightmapping system: - Added a function to find all faces that contain a given point. This is useful for both sampling lightmaps, and sampling textures later. - New face vertex lighting function simply collects all faces for a given vertex, and samples all relevant lightmaps for it - A whole bunch more experiments that were more complex and that went nowhere - Ironically all this doesn't really change the current quality of the lighting but hey, that's a result too. And this added code will prove useful soon enough. Nico de Poel 2023-01-21 21:37:48 +0100
  • 1882d246b9 A bit of cleanup ahead of attempting to make textures work Nico de Poel 2023-01-20 13:45:22 +0100
  • bf3bf810f6 Added computation of face area by projecting its vertices onto its plane and then generating a bounding box. Will be used for determining tessellation subdivisions. Nico de Poel 2023-01-20 13:11:49 +0100
  • 219fc6db32 Implemented an alternative method for computing lighting per face vertex, one that's simpler, faster and that produces better results. Still not quite perfect yet but about where I want it to be for now. Nico de Poel 2023-01-19 21:44:01 +0100
  • e65ce7b673 First attempt at calculating lighting per face-vertex with smoothing based on the angle between faces, using edge adjacency to determine neighbouring faces. Not quite right yet but it does get a result, and it's given me a good idea of what the correct solution for this should be. Nico de Poel 2023-01-19 16:58:02 +0100
  • a1e289f5fa Export plane type field, to allow optimizations for axis-aligned planes Nico de Poel 2023-01-19 12:32:28 +0100
  • eb548d13d8 Added plane and center point to face struct, for early backface culling. Nico de Poel 2023-01-19 11:52:30 +0100
  • f6da144c6a Padded some structs to make them 32-bit aligned Nico de Poel 2023-01-18 13:47:49 +0100
  • 86343e96a9 Added export of PVS data Nico de Poel 2023-01-17 21:35:43 +0100
  • 049a02fec7 Added conversion of plane, node and leaf data Nico de Poel 2023-01-17 14:16:38 +0100
  • a631e5a90d Reworked PS1BSP format to use dentry-style header info, and added structs for planes, nodes and leafs. Nico de Poel 2023-01-17 11:07:59 +0100
  • 9af577773d Improved lightmap sampling for face vertices Nico de Poel 2023-01-16 16:46:14 +0100
  • f596c008d7 Store sampled light data per face vertex, so we can individually light each face without having to average lighting values. Keeping averaged light per vertex intact for now, as sampling isn't quite perfect yet and I like to have some options. Nico de Poel 2023-01-16 15:17:21 +0100
  • c429529e88 Fixed lightmap sampling: - Implement bounds calculation per face instead of for all faces, which was silly - Face lightmap width and height calculations now match what Quake does - Added an export function for lightmap data, to make debugging easier - Include face baselight into vertex lighting, if/when that ever makes a difference Nico de Poel 2023-01-16 14:45:04 +0100
  • 9f9bf49a86 Sample lightmaps to accumulate and average lighting values per vertex, then store those in the exported BSP file. Nico de Poel 2023-01-15 21:42:25 +0100
  • ba68bc128e Write face vertex indices to output file instead of triangle data, which takes up less space and allows the PS1 code to decide how to draw the primitives. Nico de Poel 2023-01-15 17:15:34 +0100
  • 2f3facc4d8 Added a few more bits of BSP data, fixed edge list which is in fact an array of ints; the documentation was wrong. Nico de Poel 2023-01-12 18:56:32 +0100
  • 06e87e85a2 Added loading of nodes and leaves Nico de Poel 2022-09-29 10:19:51 +0200
  • bd339fc737 Separated file loading from BSP processing, making it easier to use data from different sources and also ensuring everything gets cleaned up properly at the end. Nico de Poel 2022-09-29 09:53:56 +0200
  • fac8e40425 Made an attempt to add some structure to the BSP file processing Nico de Poel 2022-09-24 19:05:08 +0200
  • a6cfcba95f Added documentation downloaded from Lameguy64 Nico de Poel 2022-09-23 10:22:13 +0200
  • 8f82f467a0 First import of PS1 MDL/BSP tools project, long overdue Nico de Poel 2022-09-23 10:21:13 +0200