Commit graph

59 commits

Author SHA1 Message Date
Ian Curtis 6f6c98c671 The translator map seems to work with paletted colour values too, and the result is not clamped. Colours are passed to the GPU as unsigned bytes to multiplying by 16 will overflow, so we do the logic in the shader. If we passed floats we could skip the shader logic. 2020-05-11 09:05:46 +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 3eeec35e7c Correctly emulate the real3d pro-1000 texture modes in our shader. 2018-10-13 13:29:45 +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 c1c2dedcfa remove dead variable 2018-08-09 21:57:51 +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 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 b184ca3e1b Clamping must be applied before the spotlight is applied on step 1.0 h/w. 2018-03-10 09:13:28 +00:00
Ian Curtis 99b5b9ba1b make the logic a bit clearer 2018-01-15 14:40:59 +00:00
Ian Curtis a1350d95a2 Update microtexture coordinate logic (Harry Tuttle) 2018-01-14 12:56:24 +00:00
Ian Curtis 62d9584b0d Shift fog maths to fragment shader to fix bug in virtua on. 2017-11-23 17:51:51 +00:00
Ian Curtis bddc86aba9 The vertex shader is run before clipping is done. If fogging values are calculated and clamped in the vertex shader it can interpolate bad values, since the range has been truncated. This happens if the polys overlap the near plane. The solution to clamp the values in the fragment shader. This fixes a bunch of fogging errors I long thought were transparency related errors in the ocean hunter. 2017-11-20 22:21:15 +00:00
Ian Curtis df44ad458b Update step 1.5 luminous logic with Harry's findings. Fixes various shading issues. 2017-11-05 13:25:33 +00:00
Ian Curtis 7f6df0cc84 Remove fixed shading check from specular. 2017-10-07 12:39:30 +00:00
Ian Curtis 43cf6b3bbf update spotlight code (Harry Tuttle) 2017-10-05 18:49:08 +00:00
Ian Curtis a3e2fb7906 Calculating the length of the vertex results in quite broken values for fogging when the vertices are traversing the view frustum. The hardware also wouldn't have been doing a square root per vertex for fogging. Simply using the z values is enough. Todo check clamping of values for the near/far planes. 2017-09-06 13:07:39 +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 50d1f95648 Changed fixed shaded logic for step 1.5 hw based upon Harry's findings 2017-08-25 22:40:39 +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 b1cc9a615d With fixed shading, when lighting is disabled, fixed shading appears to be a flat shaded version based upon the poly colour, instead of per vertex attributes. 2017-08-15 20:50:36 +00:00
Ian Curtis eac76f0908 simplify 2017-08-14 23:30:34 +00:00
Ian Curtis 81188bee07 fixed shading doesn't effect the alpha channel 2017-08-14 16:10:26 +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 57d0a513fd Technically matrix casts are only allowed in glsl 1.2 and later 2017-08-09 23:25:01 +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 1d338877fc cosmetic 2017-08-03 11:05:04 +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 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 2335f3173b Use c++11 raw string literals 2017-07-08 10:55:14 +00:00
Ian Curtis 3efb055344 Clamp the ambient light to a max of 0.75. LA Machine guns seems to use an ambient value of 1, which is full bright for everything. But for some reason the hardware seems to treat this as ~ 0.75. This fixes various missing shading in the game. This doesn't seem to have any negative effects on other games I have tested. Clamping in the shader as we might need the full range of values for fixed shading. 2017-06-29 19:05:30 +00:00
Ian Curtis ec3872d108 convert sun angle coordinate system outside of the shader 2017-06-25 19:50:02 +00:00
Ian Curtis 101e43213e cosmetic 2017-04-05 19:32:01 +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
Ian Curtis 69eac95846 Replace glsl 3 function. Apparently this doesn't work on OS X. 2017-03-28 20:24:44 +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 b19ceb0b6a Texture coordinates seem to be scaled relative to the fixed texture size of 256. Thanks to HarryTurtle for figuring this crazy logic out. The road in scud matches the arcade now almost perfectly. 2017-03-13 00:59:35 +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 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
Bart Trzynadlowski 458684eb22 Fixed new 3D engine's fragment shader to work on some older GPUs by reducing the number of discard statements to one 2016-08-24 22:21:18 +00:00
Ian Curtis 2086b1c9af Stencil layered polys, fixes shadow z fighting in some of the games. Other games maybe using stipple alpha (yuck), not sure yet. 2016-05-27 19:30:40 +00:00
Ian Curtis 3f9936d664 don't clamp after spot light code, looks much closer to h/w 2016-05-26 09:06:09 +00:00
Ian Curtis 89c987fae1 basic spotlight code 2016-05-26 00:08:12 +00:00
Ian Curtis 7e3c097a31 remove debug code 2016-05-16 17:26:53 +00:00