-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ridge Racer: Headlight and sun glares not rendering, lighting issues #16083
Comments
Ok, that wasn't so hard, fix coming up. PPSSPP.v1.13.2-1131-gc76d7e844.-.UCES00002._.RIDGE.RACER.debug.2022-09-22.22-09-50.mp4 |
Filtering prims to 1-1345 is fine, but 1-1346 reproduces it so it must be caused somehow by that draw. The draw in question is a bloom, simple 58x32 draw from 8888 to the screen, using dither, alpha blend, and color test. Color test is simply != zero, and blend is fixed one + one (so the color test is pointless, maybe I should optimize it out...) Dither seems inoffensive as well. The bloom temporary is created at 1334/1438, so my guess is that's where things are going wrong. It copies in strips 128 wide from 5551 481x272 -> 8888 241x137. It then self-renders that down from 241x136 -> 121x68, also it rectangle strips. And then further from 120x68 -> 60x34, again self-render. From here, it does a no-texture reverse subtract blend, to get the bright parts. The another self-render, this time blending at offsets with a fixed + fixed blend of about 51% + 51%, to blur it. If I flush each of those using the GE debugger, there's no weird flickering, so it's definitely some hazard/threading issue... forcing 1339 and 1342 to use 1 thread makes the issue go away. What's weird is, both ought to have naturally decided on 1 thread since they're clearly render-to-self. Aha, it's because it just flushed in this scenario, due to the pending overlap. -[Unknown] |
Speaking of headlight glares, in one of the Android builds, the headlight glare only renders on one headlight as if the other one is broken and smashed. I dunno how to explain it and I got no screenshots of it. |
That's weird, huh. Will try. Regarding the dark car lighting issue, it's using specular lighting, but not seeing much of it (step 1000 is right in the middle of rendering the car "surface"). Might simply be something wrong with our lighting equations, although they have been through quite a lot of testing... Software transform doesn't make any difference (of course, if it had, it should have worked in the software renderer). It does apply an environment map right afterwards, but it's quite dark and does not seem to be enough to explain the lighting difference, even if blended wrongly somehow. Hm, the first vertex I get at step 1000 has a garbage normal... (Setting a breakpoint in Later, NormalizedOr001 in Anyway, I'm starting to doubt it's actually specular now, because fixing NormalizedOr001 and lowering the power coefficient from 16.0 to 1.0 gets me this: Which looks very different. But if it was drawing something into the environment map, it should have worked on software if it works on hardware... |
That's quite curious, does it happen with any car and track (at night), or some specific combination? |
It doesn't need a specific combination. It just has to be either night or in a tunnel where the headlight is enabled. |
Oh, interesting. But if you look at the little air intakes or whatever, looks like the correct light is coming from a different direction? There's a shine to it that's just not there with hacked specular: So maybe it's more than just the coef that's off. As for the toViewer thing, I figured that one out back in the day using the light demo from the homebrew PSPSDK, IIRC, it makes it match. The normalize thing seems to have been a false positive, it doesn't affect the results. |
I've managed to get a reliable repro, of the glitched sun sprite problem. I can only get it to happen on Android so far. Bayonet car (3rd, class 1) on Sunset Drive, on Pocophone F1, Ridge Racer 1 EUR. Unfortunately, can't replicate it on PC, strangely enough... I can see an additional texture being invalidated and decoded every frame when looking at the sun though. |
There is a second CLUT effect going on with the sun, similar to the highlights. I've caught it in a capture now. It again textures from the framebuffer and accumulates the results into a single pixel at 041fc000. Then it textures from 041fc000, drawing to the first 256 pixels of the top line of an 8888 render target at 0418c650, creating an alpha gradient from 0-255, which is presumably intended for use as a CLUT next. RGB are black or nearly so across the whole gradient. This is then loaded as a dynamic CLUT, and used with this strangely tall source texture, which contains a quarter of some flare shape at the bottom right: Weirdly, the output of that depal operation is 100% black though. Not sure what's going wrong... Oh looks like a bad scissor? Hm... The U/V range calculation there is wrong, the UVs coming in are already in texel coordinates. The reason it seems to fail differently on PC and Android is probably that because we're not filling the texture properly, we texture from DONT_CARE-initialized data. |
…e Racer With this wrong, we ended up drawing pixels that came from a DONT_CARE init of the depal temp buffer, which was a pile of garbage on Android and blank on PC. Now, we seem to end up not drawing anything because the depal operation results in transparent black into whatever is actually intended, but at least the screen isn't full of glitches when the sun is visible on Adreno. See issue #16083
…e Racer With this wrong, we ended up drawing pixels that came from a DONT_CARE init of the depal temp buffer, which was a pile of garbage on Android and blank on PC. Now, we seem to end up not drawing anything because the depal operation results in transparent black into whatever is actually intended, but at least the screen isn't full of glitches when the sun is visible on Adreno. See issue #16083
Hm, I discovered that the lens flare actually works occasionally on Sunset Drive, and the depal seems to miss the bottom/right column/row of the texture. Fixed that in 0c4935f . |
I'm gonna call this case closed for now, I think. |
I think we can keep it closed, but the lighting issue on the vehicle itself is still not resolved, right? -[Unknown] |
Oh, true. I'm gonna make a new issue for that one, not tagged with 1.14. |
Unrelated but after updating my PPSSPP client, the audio is high pitched now. Weird. |
I can't reproduce the vertical bar in sun glares. The missing second headlight does reproduce on devices without support for dual source blending. Very unclear how that affects things, but I can get it to repro even on PC if I forcibly disable the feature! Anyway, I'm leaving fixing the second headlight to the next version, now that I've figured out the reason why compatibility differs. |
I can still reproduce the vertical line in sun glares using the latest version 1.16.6. Even though I have a different GPU. Here's my settings file: CPU: Ryzen 6900HX |
ok, then we still need to look at that one too.. I do have a radeon now so once I get around to it, will test on that. |
@antoniodesousa I seem to visually detect the use of texture upscaling in your screenshot - do you get the line if you disable it? |
Hi @hrydgard , I just tested it without the texture upscaling but it made no difference. The issue only happens with the Vulkan backend. And most likely only to AMD GPUs. I use the Vulkan backend because:
|
ok, thanks for your input! I'll investigate more in the near future. |
@Back2Life888 just to clarify, in your screenshot, the broken part is the weird vertical line in the right half of the image, right, nothing else in addition to that? will investigate soon-ish. And thanks for the tip about which track to try. |
Yup, got it. |
Also, you said this about the sun glare being a pixel off and you fixing it tomorrow only for nothing to happen for almost half a month after you sent this message. Did anything happen with this or the pixel being off isn't the reason for the bug? |
It was just a guess and it seems to be more complicated. |
Updated to 1.17.1 and the sun glare is fixed for me |
Ah good, thanks for reporting! |
Also regarding the lighting with the original PSP Hardware, I looked at some footage of the game running in the original PSP hardware and it looks like the headlight glares are actually rendering shaders on the body of the car which is why it looks better in the og PSP Hardware. Maybe the headlight glare doesn't render that shader in PPSSPP which is why the cars are darker in the PPSSPP hardware. That's just my guess though. |
I was gonna say that we have a different issue about those lighting problems, but no, it's in this one: So I was wrong to close this, I thought this was mainly about the flares, which are solved (although require the "dual src blending" feature to function correctly). Reopening for that lighting problem. |
Updated to 1.17.1 and the sun glare is not fixed for me... at least no completely. This release improve it a lot but not completely fixed it. Now I get the vertical line randomly. Sometimes appears, other times there's no line at all during the whole race. Other times the vertical line appears segmented or just part of it shows up on the screen. Best track to test this is BASIC 01 -> Crimsonrock Pass. Anyways, much better now for sure. |
EDIT: Glares solved now, just the dark car lightning left to fix
There are reports that it does work on some old versions on AMD only, which is very strange.
Ridge Racer lens flare UCES00002_0002.zip
It does work in the software renderer, although for whatever reason it's kinda glitching a bit from frame to frame (something is not deterministic, or we get some accidental feedback effect?)
PPSSPP.v1.13.2-1131-gc76d7e844.debug.2022-09-22.21-33-50.mp4
In the hardware renderer, no flares:
It seems to be doing some actually not that complicated trickery. There's a strange draw that gathers a whole bunch of pixels (768 vertices making up 128 little rectangles) into a 1x1 render target at 0x041fff00 and adds them up using stencil (step 1301):
Stencil does end up as 255 but alpha stays at 0, so something is not going quite right there with our stencil operation substitution.
We're using dualsrc blend and writing alpha into Src1:
But the alpha part of the blend equation doesn't read from it, only the color? That seems wrong.Wait, no, it's the 0.00392 we want (increment by 1/255, if the pixel is not discarded, alpha test is happening).
But it's ONE instead of SRC_ALPHA in Alpha Src in the equation, that does seem wrong.Wait I'm confusing myself, we do want ONE * 0.00392.. Hm. No it does actually seem to accumulate OK?? Hm.Then it textures from the 1x1, rendering the highlight as a simple mesh, step 1302 (and oh, it seems it goes wrong here - the framebuffer/texture matching misses it, and creates an empty 1x1 texture instead):
It does do CLUT-from-framebuffer later in the frame but that's just for the speedometer, the lights are simpler.
The text was updated successfully, but these errors were encountered: