Author Topic: [FF7PC] Post bug reports here [use The Reunion thread instead]  (Read 85259 times)

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: [FF7PC] The Big Bug List - post bug reports here
« Reply #25 on: 2017-05-10 05:07:44 »
Yeah, I agree. I've started mixing and matching. But if this fails, it may just be as Kal said and the whole thing is crapped out.

Kaldarasha

  • *
  • Posts: 2449
  • Prince of Model Editing
    • View Profile
Re: [FF7PC] The Big Bug List - post bug reports here
« Reply #26 on: 2017-05-10 19:09:57 »
I guess I knew what's going on. See this:

(seen from the models position: Red comes from the right, green from below behind and blue from upper behind)

The light is calculated by the camera position.

The PSOne has a co-processor called the Graphics Transform Engine, which is meant to perform many 3D operations like matrix-vector multiplication, lighting and fog. It was fixed-point
  • (aka: integer) based and couldn't work with floating point numbers. The X, Y and Z coordinates of vectors are stored as 16-bit values: 1-bit for sign, 3-bits for integral part and 12-bits for the decimal part. It only supported 3x3 rotation matrices with translation being a separate operation using vectors with 32-bit XYZ integer components (no fractional parts).


This seems to be one reason behind the wobbliness: while drawing a scene, the objects's polygons must be transformed from their local space into world space (at the very least one rotate and one translate command) and then from world into camera space (another rotate and translate). Since translation is integer-only (no fractional), it will "snap" around, the severity depending on the scale of the scene elements. Also, if you have multiple rotations and translations stacking on top of each other, the precision errors will build up quickly.

If I'm correct, then every shader effect should be rendered in the world space. Though, I don't know if the PC version does render in that way.  :-[
« Last Edit: 2017-05-10 19:14:47 by Kaldarasha »

luksy

  • *
  • Posts: 375
    • View Profile
Re: [FF7PC] The Big Bug List - post bug reports here
« Reply #27 on: 2017-05-10 20:08:47 »
The double transform itself is nothing unusual, are you saying the PC and PS1 versions apply lighting at different stages?

Kaldarasha

  • *
  • Posts: 2449
  • Prince of Model Editing
    • View Profile
Re: [FF7PC] The Big Bug List - post bug reports here
« Reply #28 on: 2017-05-10 20:33:37 »
That would explain why swapping the values between the axis doesn't work and how such a bug could occur. I guess the port team didn't notice that there was a difference in the look.

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: [FF7PC] The Big Bug List - post bug reports here
« Reply #29 on: 2017-05-10 21:30:19 »
Are we sure that's what is causing the fault?  Could it not just be a mix up of the X Y Z values - or the global light not being processed correctly?  What happens if you mess about with the X Y Z order?

Kaldarasha

  • *
  • Posts: 2449
  • Prince of Model Editing
    • View Profile
Re: [FF7PC] The Big Bug List - post bug reports here
« Reply #30 on: 2017-05-10 22:18:17 »
Did that already and you won't get any good result. That's why I got the idea with the colored light and the cube to see where actually the axis are. I post tomorrow more pictures which show only one axis (color at the time) and another scene.

Edit:
Now where I think about it maybe the the game was meant to use the field orientation but wrongly use the orientation of the camera. ???
« Last Edit: 2017-05-10 22:40:51 by Kaldarasha »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: [FF7PC] The Big Bug List - post bug reports here
« Reply #31 on: 2017-05-10 23:39:39 »
What is your global light set to in your test?  Black 0 0 0?  I guess I'd need a way to put the model into the game too though.  Someone else like Green_Goblin would have to do this test for us for the PSX version.

Why did they even do this anyway?  Why do all models have differerent light on different fields?  Was all this nonsense really necessary?
« Last Edit: 2017-05-10 23:41:56 by DLPB »

Kaldarasha

  • *
  • Posts: 2449
  • Prince of Model Editing
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #32 on: 2017-05-12 21:16:39 »
The Global light is uninteresting because it only handles the brightness of the model.
Here some pictures with only one color active:


x-axis
positive valuenegative value

y-axis
positive valuenegative value

z-axis
positive valuenegative value

Here is the cube for testing (inside is the Cloud model, Kimera refused for some reason to use only the cube attached to the skeleton).
https://mega.nz/#!GdVzCYZa!7cD9leLanRd8WjPAd881QHjYxZl1TKuUr_1Y7Hizv10

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #33 on: 2017-05-12 21:20:39 »
I may be being thick here since I don't understand this stuff well enough, but where is the bug?  How should these look?

Kaldarasha

  • *
  • Posts: 2449
  • Prince of Model Editing
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #34 on: 2017-05-12 22:56:24 »
That's the big problem, I don't know where the bug has its origin. The values in the flevel.lgp are the same as on the psx files. The y and z seems to be wrong displayed. The y value should come from above of the model, but on PC it comes from the front. Let me demonstrate it with Kimera
PC


PSX


From the tests I made the light is somehow connected to the camera. Now is the question, is that behavior wrong or does have the PSX different values for the camera when calculating the light?
I simply cannot imagine that they added some factors or mixed something up. It seems more practical to me that they didn't understand what the PSX did do and they have written their own way to implement the light.

As I said it's a very minor bug, which we can't solve yet at last I have no time to deal with it further. But maybe when MR gets the preview for the light we can fix it manually.

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #35 on: 2017-05-13 10:31:34 »
Looking at your pics again, it does look like Z and Y are wrong way around?  The Z should go inside and out, not up and down. Depends how it decides what X Y Z is.  We need to see this test on the PSX somehow.


Kal... do all the colours work fine too with each direction?  If you test all three X with red 4000, then all three Y with 4000  etc (but one at a time).
« Last Edit: 2017-05-13 10:43:43 by DLPB »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #36 on: 2017-05-13 23:28:41 »
http://vignette1.wikia.nocookie.net/finalfantasy/images/e/e4/Sephiroth-FFVIIArt.png/revision/latest?cb=20141008012137

Sep's hair is grey not white... so turns out grey would prob be closer anyway.  But whatever.  I tracked down part of game that adds all shading.  This is what happens when it's nopped (68EAC5):


https://ibb.co/dF2bvk

perhaps even if all else fails, we can just add our own shading to the models and forget real time?

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #37 on: 2017-05-14 04:25:20 »
I'm beginning to wonder whether the PC version is actually correct colour and the PSX is wrong due to how it is forced to use colour. PC can have a full range, whereas the PSX could not, right?  Sep's hair is more correct in PC for example - and certainly is correct to the model itself, which is all grey. The sin colour looks right in PC too.

I am experimenting now changing light using the engine... so I may be able to get the psx look eventually anyway.

JWP

  • *
  • Posts: 194
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #38 on: 2017-05-14 10:39:27 »
If it helps, here's what a frame rendering looks like in ff7 when using Aali's opengl driver:
gliInterceptLog.txt

(I'm using a modified version of glintercept to add FF7 related data)
and the shaders that were in memory at the time:
Code: [Select]

//== PROGRAM LINK STATUS = TRUE
//== PROGRAM VALIDATE STATUS = TRUE

//======================================================
//   Vertex Shader 2
//======================================================

//== SHADER COMPILE STATUS = TRUE
#version 110

uniform int vertextype;
uniform bool fb_texture;
uniform int blend_mode;

uniform mat4 d3dprojection_matrix;
uniform mat4 d3dviewport_matrix;

void main()
{
vec4 pos = gl_Vertex;

gl_FrontColor.rgba = gl_Color.bgra;

// TLVERTEX
if(vertextype == 3)
{
pos.w = 1.0 / pos.w;
pos.xyz *= pos.w;
pos = gl_ProjectionMatrix * pos;
}
// LVERTEX and VERTEX
else
{
pos = d3dviewport_matrix * d3dprojection_matrix * gl_ModelViewMatrix * pos;

if(gl_FrontColor.a > 0.5) gl_FrontColor.a = 0.5;
}

// BLEND_NONE
if(blend_mode == 4) gl_FrontColor.a = 1.0;
// BLEND_25P
else if(blend_mode == 3) gl_FrontColor.a = 0.25;

gl_TexCoord[0] = gl_MultiTexCoord0;

if(fb_texture) gl_TexCoord[0].t = 1.0 - gl_TexCoord[0].t;

gl_Position = pos;
}

//======================================================
//   Fragment Shader 3
//======================================================

//== SHADER COMPILE STATUS = TRUE
#version 110

uniform int vertextype;

uniform sampler2D tex;
uniform bool texture;
uniform bool fb_texture;
uniform bool modulate_alpha;

void main()
{
vec4 color = gl_Color;
vec4 texture_color;

texture_color = texture2D(tex, gl_TexCoord[0].st);

if(texture)
{
if(fb_texture && texture_color.rgb == vec3(0.0, 0.0, 0.0)) discard;

if(texture_color.a == 0.0) discard;

color *= texture_color;

if(!modulate_alpha) color.a = texture_color.a;
}

gl_FragColor = color;
}

interestingly, I can't see any calls to the lighting functions in opengl, so I wonder if the lighting calcs are just done with the shader.
« Last Edit: 2017-05-14 10:46:03 by JWP »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #39 on: 2017-05-14 12:27:46 »
The function I posted above seems to handle all light calcs. Not sure if that relates to a shader calc somewhere.

JWP

  • *
  • Posts: 194
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #40 on: 2017-05-14 13:28:51 »
I nooped the function and the only difference between the 2 log traces was the texture used, so the change is either in a texture or a value not explicitly stated e.g. matrices or stuff in the buffers.
I think the texture changes are more likely to be animations though e.g. sea/eyes.
« Last Edit: 2017-05-14 13:51:07 by JWP »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #41 on: 2017-05-14 18:27:06 »
All i think it does it assign colour and brightness to the model from that other function.  When it's removed, all shading disappears too.  It's not at all complex. Somewhere in there I think there is probably an easy way to tweak the calcs to make the light behave like psx.  I already made all the models brighter in one of the functions by just adding fmul 1.5 to red green blue. But that's assuming the colour in psx wasn't there by the very nature of NTSC/PAL colour.

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #42 on: 2017-05-14 23:56:45 »
I asked JWP to add me a contrast and gamma changing shader. It does seem to make the game better.  Pretty sure 1.2 is closer to the PSX levels than what we have currently, which is overly dark. I have also added min max levels to the shader.  I am learning.

But I am doing some tests.  In any case, I am still not sold on the idea that there is any problem here other than PC colour being more correct than the PSX was.
« Last Edit: 2017-05-15 01:25:30 by DLPB »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #43 on: 2017-05-16 01:30:02 »
Covarr brought to my attention a shading issue in del3 (Costa del Sol with the beach), where Cloud's head is shaded differently to PSX. I think this is unrelated to the shading issue we have been discussing.

Field Model graphic filter - UNKNOWN9
Wait 1 frame
Field Model graphic filter - UNKNOWN9


is being set on the characters in this field, which makes them shine and shimmer as they walk. It looks pretty poor to be honest in PC version, since it's the KAWAI function, which is broken. The effect is hardly even noticeable on the PSX version.

Speaking of KAWAI, the field opcode function is only a basic set up. It sends values that are used in the main function (called all the time to draw and sort all 3d objects) at 6392BB.  For example, the main operation to be carried out is found at points like 63959E
« Last Edit: 2017-05-16 02:42:53 by DLPB »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #44 on: 2017-05-16 03:58:31 »
Also, I don't think the "shading issue" is all that much of a problem.  When you compare to PSX, using my own tweaked shaders, the colour and so on is superior in PC (right).

https://e63i.imgup.net/test1fef9.png

Something tells me that the image Kaldarasha uploaded has had some brightness added to it by emulator or what not.  It's not what mednafen outputs.  I'll check the truck scene soon.


Edit.

As I suspected... that picture by Kaldarasha has been modified from what a direct output gives (probably captured from Youtube or something)

https://d76i.imgup.net/mednafenfffffd.png

That is the PSX output of the truck scene.  Yeah, the shading is still not the same on PC... but it's pretty small fry isn't it when you look at the overall difference in quality including colour / filtering and so on.  I'll see if I can tweak graphics to make PC do what the PSX is.  The shading is certainly wrong on PC.
« Last Edit: 2017-05-16 04:32:18 by DLPB »

luksy

  • *
  • Posts: 375
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #45 on: 2017-05-16 05:26:38 »
Could this be anything to do with

Quote
The Playstations RGB values aren't linear to normal RGB values (as used on PCs). The min/max values are of course the same, but the medium values differ:
  Intensity        PC      PSX
  Minimum          0       0
  Medium (circa)   16      8
  Maximum          31      31
Ie. on the PSX, the intensity increases steeply from 0 to 15, and less steeply from 16 to 31.

http://problemkaputt.de/psx-spx.htm


DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #46 on: 2017-05-16 05:32:39 »
It's certainly possible, but I know sod all about how ff7 is even calculating the so called shading :P  If this is the issue, perhaps a shader could correct it?

Covarr

  • Covarr-Let
  • Administrator
  • *
  • Posts: 3941
  • Just Covarr. No "n".
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #47 on: 2017-05-16 14:01:17 »
Could this be anything to do with

http://problemkaputt.de/psx-spx.htm



I doubt it. Lighting isn't just operating at a weird steepness. It's almost as if it's reversed.

PSX left, PC right:


What can be seen here is that the angle itself seems to be near-completely wrong. In the PSX version, the light source appears to be coming from below and to the right. In the PC version, it's coming from above and to the left. It's especially obvious in his hair; the brightest areas in the PSX version are the darkest in the PC version, and vice versa. As strictly backwards as it is, I'm inclined to think it's a calculation error, with some variable being sign flipped, or subtracted from 255 instead of added to 0, or something like that.

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #48 on: 2017-05-16 16:14:55 »
I think I've tracked down the dodgy function.  Here's how mine looks after a few multiplications were nopped:

https://pasteboard.co/71xZaBQQY.png

obesebear

  • *
  • Posts: 1389
    • View Profile
Re: [FF7PC] The Bug Database - post bug reports here
« Reply #49 on: 2017-05-16 22:16:39 »
Also, I don't think the "shading issue" is all that much of a problem.  When you compare to PSX, using my own tweaked shaders, the colour and so on is superior in PC (right).

https://e63i.imgup.net/test1fef9.png

A bit off topic, but why is the background such better quality on the psx?