Nico de Poel
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.
3 years ago
Nico de Poel
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.
3 years ago
Nico de Poel
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.
3 years ago
Nico de Poel
fd77b80afc
First implementation of dynamic world object (model) rendering.
Still very basic, with plenty of sorting and clipping issues.
3 years ago
Nico de Poel
090cde5f89
Included face area value in tessellation LOD level calculation.
Could probably use some more finetuning in practice, but this is already pretty good.
3 years ago
Nico de Poel
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.
3 years ago
Nico de Poel
5442b2d4c9
Added a draw function for flat colored quads, useful for debugging
3 years ago
Nico de Poel
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.
3 years ago
Nico de Poel
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.
3 years ago
Nico de Poel
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.
3 years ago
Nico de Poel
4146238e1e
Moved frustum planes to fast scratchpad RAM for another appreciable speed boost.
3 years ago
Nico de Poel
a7e29ee420
Fixed issue with model data memory alignment, officially using model #0 now to draw the static world geometry.
3 years ago
Nico de Poel
de12e4269f
Minor stuff
3 years ago
Nico de Poel
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.
3 years ago
Nico de Poel
26d541e48f
Eliminated recursion from the BSP traversal, using fast RAM to hold the node stack. Yet another appreciable speed boost.
3 years ago
Nico de Poel
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.
3 years ago
Nico de Poel
32237fc6ec
Fixed a few issues and further optimized the quad drawing code.
3 years ago
Nico de Poel
38e91f4c3a
BSP file now includes model data for dynamic world objects
3 years ago
Nico de Poel
542a81b68c
Draw lava, slime and teleporters as liquids, but not transparent.
3 years ago
Nico de Poel
ae080953f7
Rewrote the other face drawing functions to ditch the vertex copying stage too.
3 years ago
Nico de Poel
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.
3 years ago
Nico de Poel
ba83d78aa8
Removed the need for global variables for sorting leafs and faces
3 years ago
Nico de Poel
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
3 years ago
Nico de Poel
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
3 years ago
Nico de Poel
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.
3 years ago
Nico de Poel
812bcb6a63
Some micro-optimizations in the face drawing code. The PS1 really does favor simple counters over pointer arithmetic.
3 years ago
Nico de Poel
b0893a902d
Added support for leaf-based frustum culling, but leaving it disabled for now.
3 years ago
Nico de Poel
ea2b963653
Implemented per-node frustum culling based on bounding spheres.
3 years ago
Nico de Poel
0f450cf6b1
Added initial frustum calculation based on screen parameters and view matrix.
3 years ago
Nico de Poel
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.
3 years ago
Nico de Poel
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
3 years ago
Nico de Poel
85a8b332c5
Some reorganization of face drawing code; allow better separation between drawing methods, and require the "enable texturing" check only once ahead of drawing.
3 years ago
Nico de Poel
c9bee9d500
Draw water surfaces as unlit textured polygons
3 years ago
Nico de Poel
73903474e4
Moved polygon drawing routines into a separate header file
3 years ago
Nico de Poel
3b5a59dae6
Geometry, textures and lighting now all working correctly.
Ditched the concept of surface vertices, as UVs cannot be shared between polygons.
3 years ago
Nico de Poel
ebbc01c672
Overhaul of geometry representation, with correct UV'ing and more finely tesselated surfaces.
3 years ago
Nico de Poel
989ec0bafb
Simplified toggle behavior for button inputs, and added an option to toggle texturing with the circle button.
3 years ago
Nico de Poel
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
3 years ago
Nico de Poel
a478a7c1ed
Fixed a silly mistake in the primitive buffer allocation space check
3 years ago
Nico de Poel
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.
3 years ago
Nico de Poel
5549e3f126
Textures are now showing up somewhat correctly!
Most of the actual changes are on the data conversion side.
3 years ago
Nico de Poel
297ae187f6
Fixed some issues with texture atlas generation.
The image is at least stable now, but textures are still not drawing properly.
3 years ago
Nico de Poel
76a6dc92d5
First pass at implementing texturing of face polygons.
Not quite right yet but things are starting to work.
3 years ago
Nico de Poel
c8c44b352f
A bit of cleanup ahead of attempting to make textures work
3 years ago
Nico de Poel
36c409115a
Use per-face vertex lighting for improved geometry definition and less light leaking between sharp-angled surfaces.
3 years ago
Nico de Poel
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.
3 years ago
Nico de Poel
59d838f501
Small optimization to BSP tree traversal, by making the child node selection branchless
3 years ago
Nico de Poel
b0d36ab11b
Sped up plane calculations by making use of axis-aligned properties
3 years ago
Nico de Poel
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.
3 years ago
Nico de Poel
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
3 years ago