Ian Curtis
06b43c45b3
Ocean hunter in the middle of the game is passing a few matrices with FLT_MAX inside them, which blows apart our near/far calculation. The hardware must have some method to sanitize the near/far for instance if you render something extremely close to the origin you will also blow apart any near/far calc.
2019-11-02 20:11:48 +00:00
Ian Curtis
714f6a123a
skip invalid culling nodes
2019-07-28 12:14:13 +00:00
Ian Curtis
17f4103123
A culling node must follow immediately after a viewport.
2019-07-26 16:39:58 +00:00
Ian Curtis
8094c2e2b7
Composite the alpha layers at the end of rendering. To do this we need to mask the alpha pixels with the opaque pixels from the next priority layer. Fixes some overlapping shadows in vf3tb that have different priority layers. I assume that was a game bug, but it works on the real h/w.
2019-01-21 14:30:42 +00:00
Ian Curtis
bf4d725970
Smooth texture repeat makes no sense for alpha/contour textures with pixel dilate. HW seems to treat them as non smooth anyway. Also implement some line of sight stuff, used by Scud. Really need to check the threading/synchronisation of the register reads but it basically works.
2018-10-19 20:59:46 +00:00
Ian Curtis
42eaa7f3d8
fix copy paste error :]
2018-10-14 10:05:24 +00:00
Ian Curtis
3eeec35e7c
Correctly emulate the real3d pro-1000 texture modes in our shader.
2018-10-13 13:29:45 +00:00
Ian Curtis
3dbfa73734
Both lemans24 and dirt devils are rendering some totally transparent objects as the first model in each viewport. The HW seems to skip these entirely, and including them breaks our near/far plane calculations leading to Z fighting.
2018-09-19 20:43:41 +00:00
Ian Curtis
e3255e45f3
Tweak the ratio for the near plane. Fixes missing text on the map indicator at the start of spikeout. The vertices are 0.003 units apart so a tonne of precision is required at the near plane to not depth test out.
2018-09-18 21:46:38 +00:00
Ian Curtis
c5b156d95d
remove debug code
2018-09-18 21:20:15 +00:00
Ian Curtis
5dab9910e2
avoid double matrix load
2018-09-16 08:43:13 +00:00
Ian Curtis
b5f9ad9651
Quad rendering engine. Set QuadRendering = 1 in the ini file to use, or -quad-rendering at the end of the command line to use.
2018-09-13 12:50:34 +00:00
Ian Curtis
e4f5f0bcaf
Sega bass fishing is starting some off the meshes with a shared vertex. Without having a previous vertex to share with, the values were just uninitialised and junk. The hardware itself seems to hold the value from the previous mesh, and sega bass fishing relies on this undefined behaviour to function correctly. Storing the cached vertices as member variables instead of locally to the function means it holds the values from the last mesh, and uses those values instead of random garbage.
2018-09-02 21:36:24 +00:00
Ian Curtis
9f5a19a04a
Use correct PCI IDs (Harry Tuttle)
2018-07-09 08:06:06 +00:00
Ian Curtis
f9be1259c0
Opaque polys definitely depth test with less than or equal. Virtua striker is drawing co-planar polys for the bar gfx
2018-06-17 11:30:01 +00:00
Ian Curtis
c7ffd0a808
Draw transparent polys to separate layers and composite at the end. This solves a tonne of transparency errors we had been battling with for a long time. The model3 is strange in the fact it only supports a max of two translucent overlapped polys. They are not blended into the frame normally. Doing this means the topmost translucent polys only are visible in the scene, the equivalent of doing a depth pass first, but without the added cost.
2018-06-16 21:31:29 +00:00
Ian Curtis
f9f43ca66b
2018-05-28 12:55:13 +00:00
Ian Curtis
c1e0e3728b
optimise hash function and parse out transparency layer select bit
2018-05-28 11:59:48 +00:00
Ian Curtis
4d275ba49e
Parse siblings after children. It's the only way to get Daytona water fall to look correct without h/w poly sorting.
2018-05-03 18:37:49 +00:00
Bart Trzynadlowski
3f9b1b76e5
Added a stretch mode (-stretch) and modified new renderer's viewport code (hopefully correctly) to handle aspect ratio correction and widening the way the legacy one does.
2018-05-03 03:46:44 +00:00
Ian Curtis
c6b86c0812
Render the opaque part of texture transparency in the first pass. Fixes numerous transparency related issues in lemans24 and some in ocean hunter. I don't really know if this is the 'correct' way of solving this because the real3d pro-1000 is a complete black box. There is still a lot we don't understand about how it handles transparency.
2018-05-02 20:10:02 +00:00
Ian Curtis
d21e71dced
work around for non working jtag code in star wars
2018-03-21 10:26:05 +00:00
Ian Curtis
8266eecabb
Parse out line of sight position. Only known to be used by scud.
2018-01-15 21:27:21 +00:00
Ian Curtis
22a6166b82
fix Ian's bad maths :)
2018-01-15 13:08:39 +00:00
Ian Curtis
a1350d95a2
Update microtexture coordinate logic (Harry Tuttle)
2018-01-14 12:56:24 +00:00
Ian Curtis
863ea95013
simplify maths
2018-01-10 20:37:21 +00:00
Ian Curtis
adb5196625
comment out unneeded code
2018-01-10 16:12:33 +00:00
Ian Curtis
d708ce9ba2
top/bottom were swapped for off axis projection
2018-01-10 16:08:02 +00:00
Ian Curtis
6efa03112e
Rewrite projection maths based upon previously unknown viewport values. The previous values used roughly worked as the normals for frustum planes. Perhaps they were only used for culling and not actually rendering, as sometimes the values don't work correctly.
2018-01-08 18:35:42 +00:00
Ian Curtis
bc7f1e9fac
Fixed shading also works with untextured polys. Fixes some shading issues in La machineguns. (Harry Tuttle)
2017-11-07 00:15:57 +00:00
Ian Curtis
eb798ed15e
Star wars is the only game to pass unsigned fixed shaded values (per vertex brightness) to the renderer. Originally we thought that the specular flag would turn on unsigned values since it's the only game to set specular with these polys, but this logic turned out to be incorrect. The JTAG interface seems to config the GPU to turn on this functionality. (Harry Tuttle)
2017-10-05 19:15:00 +00:00
Ian Curtis
43cf6b3bbf
update spotlight code (Harry Tuttle)
2017-10-05 18:49:08 +00:00
Bart Trzynadlowski
55bb02d4e5
- New work-in-progress frame timing code (disabled by default, compile with NEW_FRAME_TIMING defined to activate it)
...
- New JTAG emulation, moved into its own class, CJTAG
- Removed game-specific sun clamp hacks from CNew3D (JTAG and Real3D emulation will call the appropriate method to configure this at run-time)
- Removed JTAG from Real3D save state data and reused some of that space for new state variables having to do with the internal JTAG-based config as well as new frame timing state variables
2017-09-24 20:52:48 +00:00
Ian Curtis
2786d95795
add interface for sun clamp
2017-09-02 14:54:16 +00:00
Ian Curtis
266c911133
Optimise vertex data to cut down on unnecessary copying
2017-08-30 21:45:25 +00:00
Ian Curtis
165926aa06
Modern hardware does backface culling in window space by calculating the face normal for the polygon, then doing a dot product against the view vector. The real3d pro-1000 on the other hand passes a pre-calculated face normal for each polygon which is used for culling. We were using this face normal to rewind the polygons so that regular backface culling would work. This worked 99.9% of the time. However this was failing on some models in Virtua Striker. The reason was because the pre-calculated face normals being passed were actually completely different to the actual face normals for the poly (not just inverted like you would expect). This broke our code. The solution was to emulate face culling directly in the vertex shader using the pre-calculated face normals directly. Only minimally tested this but hopefully there are no obvious regressions.
2017-08-29 10:27:29 +00:00
Ian Curtis
b21ed49512
cosmetic
2017-08-21 23:00:29 +00:00
Ian Curtis
cd5978773a
Harry made some important discoveries with regards to fixed shading on the model 3 (per vertex poly brightness values). Firstly values are allowed to be negative, and they are used as a drop in replacement in the standard lighting equation for the normal dot light vector. This quite radically changes the brightness in LA Machine guns, but now correctly matches the arcade.
2017-08-19 20:06:31 +00:00
Ian Curtis
0efd4dac39
Finish fixed shading for 2.0 hardware. I'm pretty sure it actually works identically to step 1.5 hardware. The oddball is LA machine guns where the viewport ambient doesn't seem to effect the brightness. But the ambient works differently in this game because it uses the unclamped light model. Still need to investigate if the diffuse factor effects fixed shading.
2017-08-15 23:21:57 +00:00
Ian Curtis
2422caadc6
Pad struct and align on 4 byte boundary.
2017-08-15 20:45:08 +00:00
Ian Curtis
eac76f0908
simplify
2017-08-14 23:30:34 +00:00
Ian Curtis
c12e4c3215
Fixed shading (per vertex poly colours) on step 1.5 hardware have the viewport ambient value added to them. This fixes various shading on scud. To do this had to switch the maths to the vertex shader.
2017-08-14 09:14:06 +00:00
Ian Curtis
8f622714a7
Fix attribute locations. glBindAttribLocation must be called linking
2017-08-11 11:59:41 +00:00
Bart Trzynadlowski
a315627401
Added support for loading shaders from files for new engine and tile renderer. Changed help text to reflect new engine being default.
2017-08-11 00:41:10 +00:00
Ian Curtis
d7403afda6
use generic vertex attributes
2017-08-10 15:43:03 +00:00
Ian Curtis
5709ee2659
Sometime ago I managed to work out that specular on the model3 is not real specular, and really is just an extension of diffuse lighting. But attempts were derailed by corner cases and the fact we were not handling the normals correctly. Anyway Harry managed to successfully come up with an algorithm, and coefficients that give an almost perfect match to specular on the model3, based soley on observations from video footage! He also worked out that the lighting on hardware 1.5 onwards appears to be unclamped (ie greater than 1). This quite radically changes the brightness of some of the games, but much better matches the original hardware.
2017-08-09 16:56:56 +00:00
Ian Curtis
3fc28159eb
Add the unclamped light model we know exists to the shaders.
2017-08-03 10:41:18 +00:00
Ian Curtis
b1bd877b82
Ski champ for some reason is passing denormalised numbers for the modelscale. This is causing a NaN in our shader killing the lighting for these models, so we simply skip these, since they are essentially zero anyway. Thanks to Harry for finding this bug :)
2017-08-01 23:48:53 +00:00
Ian Curtis
9aa3f13777
We were force normalising the result of matrix * normal, which looked correct in most cases. But this didn't preserve the scaling of the matrix, or the scaling of the model normals which resulted in many over bright areas. On it's own this generally worked, but games like Star Wars looked quite broken. Harry correctly figured out if you scale these normals by the scaling value that is sometimes present in the culling nodes the lighting looks correct. Still more work to do to correctly figure out the model3's lighting model.
2017-07-29 16:30:30 +00:00
Ian Curtis
a9b49c1676
Implement unclamped light model based upon Harry's findings. Unknown how this is turned on/off.
2017-07-22 17:15:14 +00:00
Ian Curtis
9e9a549283
remove WIP code
2017-06-25 20:09:45 +00:00
Ian Curtis
ec3872d108
convert sun angle coordinate system outside of the shader
2017-06-25 19:50:02 +00:00
Ian Curtis
97781108e8
A second go at fixing the fixed lighting in star wars .. Fixed shading is per vertex poly colours. For some reason in star wars they are treated as unsigned values instead of signed, like in every other game. These polys are all marked with specular enabled, where as in the rest of the games they are missing this flag. That's the only difference I can find.
2017-06-21 17:04:53 +00:00
Ian Curtis
1532168af7
fix double offset
2017-06-20 21:44:58 +00:00
Ian Curtis
b00315b072
Revert previous fixed shading changes. Implement new logic for fixed shading on step 1.5 hardware based upon Harry's findings.
2017-06-20 20:13:42 +00:00
Ian Curtis
260daa1b91
Fix the fix shading in star wars. Fixed shading still needs some work for mag truck and dirt devils to match the arcade.
2017-06-17 16:05:54 +00:00
Ian Curtis
73a7d2760d
cosmetic
2017-06-07 23:16:22 +00:00
Ian Curtis
1193069709
Tweak scroll fog logic again .. should fix missing 2d fogging in Spikeout.
2017-06-07 23:14:01 +00:00
Ian Curtis
45741b24d2
rewrite scroll fog logic
2017-05-06 16:47:31 +00:00
Ian Curtis
80004b0dad
Remove debug code
2017-04-25 00:31:39 +00:00
Ian Curtis
7694e4eb0c
minor culling node optimisations
2017-04-25 00:10:55 +00:00
Ian Curtis
ff936c588b
don't need cast, conversion is implicit
2017-04-20 19:46:40 +00:00
Ian Curtis
912bb0e7cf
better state handling
2017-04-20 19:43:41 +00:00
Ian Curtis
9b226ed478
parse out some culling node values
2017-04-17 10:40:07 +00:00
Ian Curtis
3c78571615
There are 2 bits in the polyheader labelled discard. When both are set ie in sega rally, the polygons are totally discarded. Scud seems to set bit 1 which seems halve the opacity.
2017-04-15 19:00:46 +00:00
Ian Curtis
21836c088c
The real3d has a flag that allows the hw to skip polygons so that they aren't rendered. Sega rally2 uses this for the dust effects. Triangles or quads that have this flag are junk, and look like random corruption if you try to draw them. We assumed polys that shared vertices with these bad polygons were also bad. It turns out the last few shared vertices in these polys were in fact valid, and thus the entire quad/triangle strip should be drawn and not discarded.
2017-04-14 23:41:11 +00:00
Ian Curtis
fc50bdee98
light parameters must be clamped (HarryTuttle)
2017-04-14 00:08:17 +00:00
Ian Curtis
391aafd4c1
Virtua fighter has a few massive polys that shouldn't be visible. It looks like these polys have a bad matrix, but the node distances are all zero. This means the bounding box that encapsulates them is of size zero. Skipping over these entirely seems to fix the issue.
2017-04-12 15:47:57 +00:00
Ian Curtis
edfb521a9b
Daytona seems to use this completely undocumented feature of the real3d pro-1000, the ability to invert texture colours. This patch fixes the colours on the cars, and the signs which should flash by alternating their colours.
2017-04-05 17:57:38 +00:00
Ian Curtis
f0e00c5dc7
Rewrite the spot light code, and implement the missing fog logic. (HarryTuttle)
2017-04-02 21:03:59 +00:00
Bart Trzynadlowski
f34e25dfc7
Massive internal change: removed CConfig object and replaced it with a hierarchical config object system (Util::Config::Node). Games are now defined in an XML file. Hopefully I didn't break too many things :/
2017-03-27 03:19:15 +00:00
Ian Curtis
ff624afb4d
The mipmap data in some games seems to being sent behind the base textures, and when the base textures are bound and created the mipmap chain is not yet valid in memory. To fix this, we invalidate the base textures, when the mipmap chain is updated.
2017-03-25 00:06:24 +00:00
Ian Curtis
9780f333b4
The model3 has this weird issue where the 2d and 3d planes are misaligned by 2 pixels. Originally I made a quick hack that shifted subviewports 2 pixels. But apparently that wasn't enough, as the issue effects everything. Thanks to HarryTuttle for pointing this out, and making a patch :)
2017-03-19 01:33:45 +00:00
Ian Curtis
dcd018ab7e
Change microtexture scaling values. Seem to much better match expected output. (thanks HarryTuttle)
2017-03-12 19:00:00 +00:00
Ian Curtis
503c88df11
fix the bad projection matrix in dirt devils and lost world
2017-03-07 01:29:07 +00:00
Ian Curtis
f173c3c3ce
The hardware actually seems to treat the quad primitive as a triangle strip. The winding order can actually change between the first and second 'triangle' inside the quad, leading our code to incorrectly backface cull the 2nd triangle. So we must re-calculate the winding order for the 2nd triangle. This fixes a massive missing poly in the road in la machine guns, probably other games too. The hardware is unaffected by the winding order, as it doesn't calculate the poly normal from the vertices directly, instead it uses the provided normal in the poly header.
2017-02-21 23:35:40 +00:00
Ian Curtis
5b9741bd5d
Support high priority polygons. They are treated as a separate overlay plane by the h/w. Fixes some missing fx in harley.
2017-02-20 17:22:32 +00:00
Ian Curtis
4a116190b5
When the translator map?? bit is enabled the colour format seems to be 4-5bit. Max observed value is 16. Scaling these values up seems to produce the correct colours in harley and dirt devils.
2017-02-16 17:20:42 +00:00
Ian Curtis
7407d03036
Put a check in there, in case near values come out really close to zero. Fixes a slight corner case in lemans24. A check probably should have been there originally :)
2017-02-08 16:14:50 +00:00
Ian Curtis
24cbeed526
Dynamically calculate near/far frustum planes for each viewport priority layer by clipping the overlapping meshes with the 4 frustum planes. A bit brute forcy, but the results are great.
2017-02-07 14:05:03 +00:00
Ian Curtis
144125a62e
mark the nodes without valid distances set
2017-02-05 15:36:05 +00:00
Ian Curtis
c82dc55485
cosmetics
2016-12-22 22:11:19 +00:00
Ian Curtis
72dd0dbf98
only need to cull against 4 clipping planes
2016-12-22 22:09:13 +00:00
Ian Curtis
20a9514aa2
For scroll fog set the viewport to the entire area, allows fog to work in widescreen mode
2016-12-15 19:27:08 +00:00
Ian Curtis
ca7046729e
properly cache un-normalised texture coordinates, fixes a texturing regression in Daytona
2016-12-15 12:10:52 +00:00
Ian Curtis
f355e2d062
fix microtexture colours
2016-12-15 00:45:32 +00:00
Ian Curtis
89e75a9803
Only check scroll fog value from the first viewport from each priority layer. Seems to fix problems with background fogging.
2016-12-14 19:57:05 +00:00
Ian Curtis
2c23268d88
Support microtexture relative scale. The exact scaling values are not known, but a 2x difference between each level seems highly likely. We know from visual inspection from scud that the first level is exactly 4. The SDK has a function that accepts a float input for scale and does this. lod = (1/scale) + 0.5. If lod>3 lod = 3. So this is our best guess.
2016-12-09 14:13:46 +00:00
Ian Curtis
da8b63b44b
The model3 shares vertices between polygons. But it also seems to do this for polygons with different textures. This means the texture coordinate for potentially different sizes textures is shared. Currently this was broken leading to some corrupted looking textures. The fix is to simply cache the old texture coordinates, and recalculate the normalised coordinates in the new texture coordinate space.
2016-12-06 14:39:46 +00:00
Ian Curtis
10a5d2c0e1
refactor
2016-12-06 12:25:34 +00:00
Ian Curtis
eece2d75b4
tweak scroll fog logic
2016-12-04 22:37:49 +00:00
Ian Curtis
a310e8e5cf
minor optimisations
2016-11-28 17:32:25 +00:00
Ian Curtis
abc8c24b69
Only check the geometry for culling with valid node distances. We will need this later.
2016-11-27 19:30:46 +00:00
Ian Curtis
fe60d115d2
Revert changes .. if we clip against the real3d clipping planes, our wide screen hack won't work anymore.
2016-11-26 01:19:51 +00:00
Ian Curtis
665fa90425
Get clipping planes directly from the viewport data. Also no need to clip against a far plane
2016-11-26 01:12:08 +00:00
Ian Curtis
84ae8f035c
Skip processing the mipmap section of memory. The real3d doesn't create mipmaps down to 1x1 that is needed to do mipmapping properly on modern hardware anyway.
2016-11-21 09:04:56 +00:00
Ian Curtis
483ba2f398
Fix the shading in scud. When lighting is disabled the fixed shading intensities appear to be offset values added to the colour value.
2016-11-11 17:50:27 +00:00
Ian Curtis
2f49012786
change scroll fog logic to parse the lower priority viewports first
2016-10-09 18:10:57 +00:00
Ian Curtis
f0a15febd1
implement scroll fog, fixes a tonne of missing fx
2016-10-09 16:34:12 +00:00
Ian Curtis
ef11990d19
Parse out scrollfog value used for blending over the 2d background.
2016-10-08 15:41:16 +00:00