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.15k stars 2.16k forks source link

Discrepancy between HW and SW T&L #604

Closed dbz400 closed 11 years ago

dbz400 commented 11 years ago

If you seen any games that discrepancy between HW and SW T&L , feel free to put here to see if we can fix it .

Dissidia Final Fantasy (too bright and incorrect texture in SW ) Trails in the Sky ( missing menu buttons, missing characters ingame with SW) Blade Dancer (missing background in SW) Kidou Senshi Gundam AGE Universe Accel ( missing background in SW ) Digimon World Re Digitize (incorrect background in SW ) Fate Extra (too bright in SW) Obscure : The Aftermath ( too bright in SW ) Ys: The Oath in Felghana ( missing character in SW)

realrunners commented 11 years ago

Sora no Kiseki FC/Trails in the Sky (missing menu buttons, missing characters ingame with SW)

dbz400 commented 11 years ago

Thanks but HW okay , right ?

realrunners commented 11 years ago

Yeah, HW is good. Characters are there and the menu button is visible.

dbz400 commented 11 years ago

Thanks .Will check this out

dbz400 commented 11 years ago

I narrow down to this code to fix it

Original : Color4 diff = (lightDiff * diffuse) * (dot \ lightScale);

Fix : Color4 diff = (lightDiff * diffuse) * (max(dot, 0.0f) \ lightScale);

1

dbz400 commented 11 years ago

I found out the cause of flashing at title screen in HW in Saint Omega as well . It caused by the u_ambient in the following statement , the same one :( , however , we cannot it remove it otherwise break other games

WRITE(p, " v_color0 = clamp(lightSum0 + u_ambient * %s + vec4(u_matemissive, 0.0), 0.0, 1.0);\n", ambient);
unknownbrackets commented 11 years ago

If it works in SW, try:

const char *ambient = (gstate.materialupdate & 1) ? (hasColor ? "a_color0" : "u_matambientalpha") : "vec4(u_matambientalpha.rgb, 1.0)";

This should replicate the (seemingly not totally correct) behavior of SW for that part.

-[Unknown]

dbz400 commented 11 years ago

Just tried .no luck . Interesting the title flashing exactly gone when u_ambient removed ......

Once fixed that one , only left the Dissidia Final Fantasy . I think SW and HW should be almost the same now at this stage

unknownbrackets commented 11 years ago

Hmm. So it's u_ambient? Interesting.

The SW does (boiled down):

Color4 lightSum0 = globalAmbient (u_ambient) * *ambient (%s) + materialEmissive (vec4(u_matemissive, 0.0));
foreach (light)
   lightSum0 += lightAmbient (vec4(u_lightambient%i, 1.0)) * *ambient (%s) + diff (diffuse%i);
colorOut0 = lightSum0 > 1.0f ? Color4(1.0f) : lightSum0;

Or in other words:

vec4 lightSum0 = u_ambient * %s + vec4(u_matemissive, 0.0);
foreach (light)
   lightSum0 += vec4(u_lightambient%i, 1.0) * %s + diffuse%i;
colorOut0 = lightSum0 > 1.0f ? vec4(1.0f) : lightSum0;

The shader uses slightly different logic:

vec4 lightSum0 = vec4(0.0);
foreach (light)
    lightSum0 += vec4(u_lightambient%i + diffuse%i, 0.0);
v_color0 = clamp(lightSum0 + u_ambient * %s + vec4(u_matemissive, 0.0), 0.0, 1.0);

Which could be rewritten as (for comparison):

vec4 lightSum0 = u_ambient * %s + vec4(u_matemissive, 0.0);
foreach (light)
    lightSum0 += vec4(u_lightambient%i + diffuse%i, 0.0);
v_color0 = clamp(lightSum0, 0.0, 1.0);

Without looking at it too hard right now (and without being very good at GLSL at all), there appear to be a few possible differences:

Edit: but note that HW is definitely more correct for some games I think?

-[Unknown]

dbz400 commented 11 years ago

so far i seen only Dissidia Final Fantasy renders more correct in HW than in SW mode . SW mode renders too bright , not too sure it is related to your point 2 or 3

unknownbrackets commented 11 years ago

Hard to tell. I think Blade Dancer (last I checked it) looks much better than HW than SW.

-[Unknown]

dbz400 commented 11 years ago

I see. let me include Blade Dancer in the list above as well .Btw, what are the difference ?

hrydgard commented 11 years ago

I think that alpha should not be included in the per-light stuff, and we should change the sw code accordingly (basically, use a Color3 instead of Color4 in most of the calculations).

unknownbrackets commented 11 years ago

Here's a screenshot, as you can see HW is much better:

bladedancer-hwsw

And here's a screenshot showing what it should look like (mostly the compass): http://www.pixlbit.com/media/725/2352.jpg

-[Unknown]

dbz400 commented 11 years ago

humm really big difference among them .

hrydgard commented 11 years ago

The flashing in Saint Seiya looks a bit like a CPU bug to me tbh, it looks like the initial fade in is intended but then it doesn't quite stop. So it's possible that it's correct to take that alpha into account.

dbz400 commented 11 years ago

i see. then may be we can ignore it at this moment since i see the flashing only in HW but SW is prefectly fine .

dbz400 commented 11 years ago

One more discrepancy found ...... this one is easy to adjust :)

SW

        if (dot >= 0)
        {
            Color4 lightSpec(gstate_c.lightColor[2][l], 0.0f);
            lightSum1 += (lightSpec * *specular * (powf(dot, specCoef_)*lightScale));
        }

HW

            WRITE(p, "  if (dot%i > 0.0)\n", i);
            WRITE(p, "    lightSum1 += u_lightspecular%i * %s * (pow(dot%i, u_matspecular.a) * (dot%i * lightScale%i));\n", i, specular, i, i, i);

FIX

        if (dot > 0.0f)
        {
            Color4 lightSpec(gstate_c.lightColor[2][l], 0.0f);
            lightSum1 += lightSpec * *specular * (powf(dot, specCoef_) * (dot * lightScale));
        }
dbz400 commented 11 years ago

@hrydgard .thanks for fixing it in 8749ad0 .Just wonder do we still need (dot * lightScale) in SW just like HW one ?

hrydgard commented 11 years ago

I don't know which is right, I suspect SW is right there actually but not sure.

dbz400 commented 11 years ago

I see. let me test it out if dot removed in HW will break any games ....

dbz400 commented 11 years ago

@hrydgard ,if SW rendering too bright in all games , what likely issue you can think of ? i want to narrow down the scope of debug

dbz400 commented 11 years ago

Saint Seiya Omega flashing at title screen in HW mode fixed in commit 0982a2929 .It explained why previously remove the u_ambient get rid of the flashing .... cheers

dbz400 commented 11 years ago

Added one more in the list

Kidou Senshi Gundam AGE Universe Accel ( missing background in SW ) - Partially Fixed

dbz400 commented 11 years ago

Digimon World Re Digitize title screen looks really nice now in HW mode:+1:

1

daniel229 commented 11 years ago

FATE EXTRA HW ON 01

HW OFF 02

dbz400 commented 11 years ago

thanks .i think the background of HW mode is wrong and should be the one from SW . (mixed ? )

If possible , can you run it in jpcsp to see how it looks like ?

SW mode always too bright .......:(

daniel229 commented 11 years ago

jpcsp looks like SW 03

dbz400 commented 11 years ago

Thanks . I will take a look

dbz400 commented 11 years ago

@daniel229 , i own this game . do you mind giving the save that can goto this point ?

daniel229 commented 11 years ago

sure,load this save,then press circle, will reach that point soon.

here is the savefile. http://www.mediafire.com/?b7qdraky3da6sb4

Carter07 commented 11 years ago

Obscure: The aftermath

Hw on: 1111

Hw off: 2222

dbz400 commented 11 years ago

Carter07 and Daniel , do u mind testing it in git 408 or earlier version ? to see if same issue occurs . I suspect 409 may cause lighting issue in SW mode though help displaying thing in other games

daniel229 commented 11 years ago

Tested git 408, SW mode still too bright.HW mode even worse.

git 408 HW on 01

dbz400 commented 11 years ago

HW worse I think it is because missing dirty_ambient which has been fixed later . Looks like 409 is not likely causing the bright issue in SW hum

Carter07 commented 11 years ago

The issue with sw transform in obscure is old, in fact also 0.5 release has the same problem.

dbz400 commented 11 years ago

i see . thanks both of you .

dbz400 commented 11 years ago

are they look better in SW mode by fix 0eabc80c3efc7 ?

daniel229 commented 11 years ago

Fate Extra still the same,too bright.

dbz400 commented 11 years ago

i see. Looks like HW mode is much better than SW in most of the games (see the issue list above)

Carter07 commented 11 years ago

Obscure in sw mode is fixed in build 504. However when the character is under light he becames blonde with sw transform :)

1111

222222

dbz400 commented 11 years ago

Nice . At least it fixes the too bright issue in this game :)

dbz400 commented 11 years ago

@daniel229 , just wonder fate extra works better now in latest build ?

daniel229 commented 11 years ago

No improvement.

dbz400 commented 11 years ago

I see .

realrunners commented 11 years ago

Ys: The Oath in Felghana: Grid of shadows and characters in HW and correct shadows and no characters in SW 2013-02-24_115742 2013-02-24_115752

dbz400 commented 11 years ago

Thanks for report . Will take a look .

daniel229 commented 11 years ago

Fairy Tail: Zeref Awakens HW on 01

HW off 02

dbz400 commented 11 years ago

interesting in HW mode :)

RodrigoCard commented 11 years ago

I tested Megaman X Maverick Hunter right now on Xperia Play, and there are discrepancies in HW mode like in Fairy Tail: Zeref Awakens.

The Megaman model is shifted to the right side