Shift fog maths to fragment shader to fix bug in virtua on.
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.
Fixed shading also works with untextured polys. Fixes some shading issues in La machineguns. (Harry Tuttle)
Update step 1.5 luminous logic with Harry's findings. Fixes various shading issues.
Finish the hash function (Harry Tuttle)
Remove fixed shading check from specular.
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)
update visual studio project
update spotlight code (Harry Tuttle)
add missing header
Fix the sky in one of the levels in virtua on. The problem was caused by the fact we didn't split the mesh by the fog % burn through, so all the polys had the same value. We could use a vertex attrib, but % burn through fog is so rarely used and when it is, normally every poly in the mesh has the same value.
update project files
work around for visual studio bug
fix missing header
cannot specify explicit initializer for arrays - fix for visual studio
I'll update it when I have a bit of time :)
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.
add interface for sun clamp
Optimise vertex data to cut down on unnecessary copying
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-calcula...
Changed fixed shaded logic for step 1.5 hw based upon Harry's findings
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.
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.
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.
Pad struct and align on 4 byte boundary.
fixed shading doesn't effect the alpha channel
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.
Fix attribute locations. glBindAttribLocation must be called linking
make the new3d engine default :] Legacy engine can still be selected using -legacy3d in the command line
use generic vertex attributes
Technically matrix casts are only allowed in glsl 1.2 and later
Remove debug code
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 ...
Add the unclamped light model we know exists to the shaders.
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 :)
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 ...
Implement unclamped light model based upon Harry's findings. Unknown how this is turned on/off.
Use c++11 raw string literals
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.
remove WIP code
convert sun angle coordinate system outside of the shader
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.
fix double offset
Revert previous fixed shading changes. Implement new logic for fixed shading on step 1.5 hardware based upon Harry's findings.
remove debug code
Fix the fix shading in star wars. Fixed shading still needs some work for mag truck and dirt devils to match the arcade.
Tweak scroll fog logic again .. should fix missing 2d fogging in Spikeout.
rewrite scroll fog logic
Remove debug code
minor culling node optimisations
don't need cast, conversion is implicit
better state handling
parse out some culling node values
There are 2 bits in the polyheader labelled dis...
The real3d has a flag that allows the hw to ski...
light parameters must be clamped (HarryTuttle)
Virtua fighter has a few massive polys that sho...
remove unused variable
add missing include
add missing include
Daytona seems to use this completely undocument...
more whitespace ..
white space ..
Cache dereferenced values. Cuts loading time fr...
Rewrite the spot light code, and implement the ...
MSYS2 compile fix (HarryTuttle)
Replace glsl 3 function. Apparently this doesn'...
fix compile warnings
fix project files
fix multiple default constructors
add missing include
The mipmap data in some games seems to being se...
Just use 1 hash map for the textures, instead o...
calculate the correct number of mipmap textures
Originally to do mipmapping, I just used the ba...
use 32bit types
fix scissor code for native resolution (thanks ...
remove debug code
The model3 has this weird issue where the 2d an...
Texture coordinates seem to be scaled relative ...
Change microtexture scaling values. Seem to muc...
More fixes to microtexture coordinates. They go...
Fix microtexture texture coordinates (thanks Ha...
fix the bad projection matrix in dirt devils an...
The hardware actually seems to treat the quad p...
Support high priority polygons. They are treate...
I have the same issue
Add high priority poly function. Used by harley.
When the translator map?? bit is enabled the co...
Put a check in there, in case near values come ...
Dynamically calculate near/far frustum planes f...