hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.37k stars 2.18k forks source link

Remaining lighting issues #4140

Closed hrydgard closed 5 years ago

hrydgard commented 11 years ago

Bugs probably caused by something wrong with our lighting equations (possibly edge cases, NaNs, whatnot):

thedax commented 11 years ago

Monster Hunter's lighting in general is too dark(https://github.com/hrydgard/ppsspp/issues/2526). Also, cooking steaks in Monster Hunter is made much more difficult by the meat not changing in colour as it cooks, like the fish issue(it goes from a light red/raw to black if it burns).

xsacha commented 11 years ago

Is the bright Wipeout considered a lighting issue?

hrydgard commented 11 years ago

Most likely not.

hrydgard commented 10 years ago

I think all this is fixed except the strong light in Virtua Tennis, which might be an entirely separate issue. It occurs when the "strike power" meter is shown, before that it looks correct.

thedax commented 10 years ago

https://github.com/hrydgard/ppsspp/issues/2526 seems to have been fixed, so that can be marked off the list.

internetakias commented 10 years ago

Shouldn't Sonic Rivals 2 be included to the list?

unknownbrackets commented 10 years ago

This isn't really about bloom issues. Does that game look correct in softgpu? If yes, then it's probably not a lighting issue.

-[Unknown]

dbz400 commented 10 years ago

I think item 2 should be fixed .Item 4 is not .Wondering how about item 1 and 3?

vnctdj commented 10 years ago

Yes, the issue which occurs in Monster Hunter games is fixed :)

unknownbrackets commented 10 years ago

Is Virtua Tennis any better now?

-[Unknown]

ppmeis commented 10 years ago

@unknownbrackets Virtua Tennis World Tour is a bit better during gameplay but in near camera views players are too bright: image image

unknownbrackets commented 9 years ago

Does the GE debugger show anything when it's drawing the areas that are too bright?

-[Unknown]

ppmeis commented 9 years ago

@unknownbrackets here you have: image image

image image

unknownbrackets commented 9 years ago

It's using color doubling but the texture already looks reasonable imho. Unless we're doubling incorrectly (I don't think we are), not sure. Though, it's using a texture level bias. Does the other texture level look different, other than smaller? e.g. is it darker?

-[Unknown]

ppmeis commented 9 years ago

@unknownbrackets no, other texture levels look the same color and brightness.

unknownbrackets commented 8 years ago

If you change "Light 0 enable" (by double clicking) to off right when it's sitting with the face highlighted in red, and then click "Step Draw", does it make it darker, or is it the same?

-[Unknown]

unknownbrackets commented 7 years ago

It would be interesting if these issues reproduce now in softgpu (especially starting from the beginning.) If it's an issue of RAM not being updated somewhere, i.e. stencil or depth or w/e, then softgpu may handle it more correctly.

-[Unknown]

hrydgard commented 7 years ago

Apart from some black pixels (rounding issues) Virtua Tennis looks fine in the software renderer.

tennis

It's actually really strange that this is still buggy in the hardware renderer... i wonder what it could be.

By the way I'm going to turn off the "slow" warning in the software renderer :)

unknownbrackets commented 7 years ago

Well, frameskip does still help in softgpu, but sure, heh.

-[Unknown]

unknownbrackets commented 7 years ago

Blade Dancer also has an issue - both in softgpu and GLES.

ulus10124_00000

Also, double-checked that this wasn't somehow a bug in the real game. A few notes:

It uses the same lighting parameters for basically the entire scene. Probably the lighting parameters are being calculated too close?

-[Unknown]

hrydgard commented 7 years ago

What's incorrect in the screenshot? The dark triangle?

What do you mean by "calculated too close"? Sorry :)

unknownbrackets commented 7 years ago

Yes, the blue triangle is wrong. It shouldn't be there at all. Note that the same blue is darkening things like the steps, the walkway, the wall, etc. The amount of blue is correct on those things.

-[Unknown]

hrydgard commented 7 years ago

Could always be some inf or nan interpreted differently than the PSP, but that's just speculation...

unknownbrackets commented 7 years ago

Here's all the tabs when it draws it (PRIM_TRIANGLE_STRIP): https://gist.github.com/unknownbrackets/8f98e0511e1991932b21ef2cf565d974

Disabling the light 1 flag for only this draw makes it look approximately correct (but other things look wrong unless light 1 is manually re-enabled before continuing drawing.) I don't see any inf/nans, but maybe it's guardband related or something...

Quickly checked - JPCSP does not have this bug. However, it also renders the opening scene wrong (the girl is not translucent - which is a lighting bug in JPCSP.)

-[Unknown]

unknownbrackets commented 7 years ago

See ULUS10124_0001.zip ULUS10124_0002.zip for a dump of the Blade Dancer lighting issue. Will also add to the issue description.

Edit: Uploaded a new one since the old broke.

-[Unknown]

unknownbrackets commented 6 years ago

I'm not sure why, but #10411 has made the Blade Dancer issue stop happening in GLES. It still happens everywhere else and in softgpu.

This may be a case of "accidentally working", I'm not sure...

-[Unknown]

marosis commented 6 years ago

This issue have maybe Flat Out Head on too.

unknownbrackets commented 6 years ago

An interesting finding, the Blade Dancer bug doesn't happen in OpenGL in game... but it does happen from the dump. This makes me think it's an alignment issue or something.

-[Unknown]

unknownbrackets commented 5 years ago

Any change to the Virtua Tennis, NBA, or Flat Out Head On issues?

Could you try exporting a GE frame dump? These help a lot (already have one for NBA, sorry, see #4109.)

See here for instructions - it's not hard and works on Android too: https://github.com/hrydgard/ppsspp/wiki/How-to-create-a-frame-dump

You can zip that and then drag and drop it into a reply here.

-[Unknown]

hrydgard commented 5 years ago

vtennis.zip

Virtua Tennis still has problems, so here's a couple of frame dumps. In the first one (03), the character lighting is normal. In the second one (04), the lighting is wrong and too bright.

The change to the bad lighting happens when you hit X to start a ball strike, which shows the little meter. Presumably it sets some state that the rest of the drawing shouldn't care about but somehow does...

Here's a youtube video confirming what the normal lighting looks like: https://www.youtube.com/watch?v=TAhAGgeJthM

unknownbrackets commented 5 years ago

Texture for overly bright person: 0x04105720

For reference, the correct image for that frame: ules00126_ 4140_virtua_tennis_lighting

And the incorrect: virtua tennis wrong

Interestingly, softgpu also gets the lighting wrong and the shadows even worse. It also has an easy to fix bug breaking clearing, which I'll fix soon. What's interesting is: it used to work in the software renderer. This implies it's not a state thing.

If I disable light 0 (the only enabled light), the characters are too dark. This light uses powered diffuse + spec. If I remove specular from the equation, it looks right.

The shadow uses color doubling + standard blend, and the same lighting parameters. It also looks correct without specular. Curiously, softgpu loses the shadow after the first frame.

The check from #8403 doesn't help. Also, because getMaterialSpecularCoef is 1.0, pow doesn't really matter.

It's not possible that mode 2 is powered diffuse only, and not specular, is it? Hm.

-[Unknown]

unknownbrackets commented 5 years ago

Hardware tests so far indicate that mode 2 is powered diffuse only, no specular. Also makes this dump look perfect, except in softgpu (still not sure what's causing the shadow to evaporate after the first frame - it's drawn briefly... so weird.)

I'm seeing some other possible differences though. For example, lightdir = (0, 0, 0) seems to normalize to (0, 0, 1) for spot lights, and a clamping issue for spot lightScale.

It also seems like lighting is generally rounding down, not up, but that's a fairly minor accuracy issue...

Need to check more and see how games react to this, but later.

-[Unknown]

hrydgard commented 5 years ago

Nice! All of it makes sense, I think this will fix a lot of graphics issues. Did you confirm that specular is off if dot(light, normal) is <= 0.0?

With rounding down, do you mean when it gets rounded to the final screen color from float? I thought we were already effectively doing that, but maybe not... Come to think of it, should we maybe explicitly round down before multiplying with the texture color in case of MODULATE, hm... I mean, really we should probably do what Dolphin did and perform the fragment shading in fixed point, but that would not be good for perf on older mobile chips.

unknownbrackets commented 5 years ago

Yeah - many of the tests I'm running are giving me colors that are off by one, e.g. 00471d1d instead of 00461d1d (diffuse.) I'm running these tests with no texturing at all, actually.

Didn't create a test yet to confirm specular during diffuse + specular, still more to test...

-[Unknown]

hrydgard commented 5 years ago

Confirming that Virtua Tennis looks good now. For the record, it was the no-specular-during-powered-diffuse.

ppmeis commented 5 years ago

Tested with latest build. Now lightning seems to be fine, but now start menu has disappeared in some backends:

Vulkan: image ULES00126_0001.zip

OpenGL seems to be fine: image

Direct3D9: image

Direct3D11: image ULES00126_0002.zip

unknownbrackets commented 5 years ago

Near texture 0x08973d00 + several draws to VAIDISOVA. I think that's a separate issue related to depth.

It draws verts with a crazy high Z, depth clamp, and standard minz/maxz. It uses src >= depth test. This passes and it draws the BG and clamped depth. Lighting is disabled. Alpha test and blend, but 8c alpha sent.

Not clear what should be keeping it from drawing... it doesn't draw on a PSP running the same dump...

Should open a separate issue, since lighting is disabled.

-[Unknown]

hrydgard commented 5 years ago

As I don't think NBA Live 06 (#4109) is a lighting problem, I'm gonna close this. If we discover more lighting-related problems, let's open new game-specific issues.