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

Blue Creek Apt. Room 105 - Some geometry's normals reversed/non-conformed? #6

Closed
Polymega opened this Issue May 29, 2018 · 19 comments

Comments

Projects
None yet
3 participants
@Polymega

Polymega commented May 29, 2018

ap76.map

@Bigmanjapan if you're up to the task I'd like to keep giving you some challenges. There seems to be no stopping your momentum at this point!

In Room 105 of Blue Creek Apt. there seems to be, for all intents and purposes, normals reversed/non-conformed on a few pieces of geometry (the door to the coin puzzle furniture and the carpet off to the side):

Edit: Another video example of normals adjustments: https://youtu.be/G-K7WT9IIok?t=12m15s

2018-05-28 18-00-16

This seems to only be an issue for the PC build (PC vs PS2 example):
https://youtu.be/W4a_w7fS1KI

I have no clue if this can possibly be resolved through hex editing but if anyone can determine this it is you. Also, I'm not 100% sure this is due to reversed geometry normals or something totally different... it just happens to look like reversed normals is all.

@Polymega

This comment has been minimized.

Polymega commented May 31, 2018

Here's a video confirming it's an issue with the polygon's normals:

https://youtu.be/uHtYwrNOEJo

However, it was not as I suspected: The normals are facing the correct direction but they are not conformed to an appropriate angle. If I set the normals to "Set to Face" in Maya the issue is fixed.

I am fairly certain this cannot be fixed on our end so I'll close this ticket in the near future; I'll leave it up a little longer in case anyone can think of a clever solution.

@Bigmanjapan

This comment has been minimized.

Bigmanjapan commented Jun 1, 2018

Did you open ap76.map file in Maya in that video?

@Polymega

This comment has been minimized.

Polymega commented Jun 1, 2018

I did. I exported the level (as OBJ) through the SH Level Viewer. The normals retained their information through the export which confirmed this was the issue when I opened it in Maya.

@Polymega

This comment has been minimized.

Polymega commented Jun 1, 2018

May need to keep an eye on this:
http://lazov.ru/mr/index.php

In development:
Normal vectors support

@Bigmanjapan

This comment has been minimized.

Bigmanjapan commented Jun 3, 2018

Is there any specific import setting you do in Maya during .obj files importing? Maya crashes if I try to open them. Metasequoia 4 works fine tho.

@Polymega

This comment has been minimized.

Polymega commented Jun 3, 2018

It doesn't import into Maya without opening it in another program and re-saving it. If you try to open it in Maya as-is you'll get the error message "Index Out of range for face creation." There are ways to fix this but it requires a lot of time and trial and error.

I opened the file in Photoshop (Photoshop can open 3D files!) and exported to Collada 3D (.dae). Then I was able to import the file in Maya.

In the past, I also had my friend open the OBJs in Rhino 3D and export for me as well.

I use Maya simply because that was the software I was trained/educated to use.

@Bigmanjapan

This comment has been minimized.

Bigmanjapan commented Jun 5, 2018

I nulled almost all of ap76.map and shading on carpet and cabinet is still preset:

default

There are still very small chunks of data that control those texture leftovers which I will inspect more.

I tried importing ap76.obj file alone (without .tga and ap76.mtl files) in Photoshop CS3 and it rendered the model without any shading.

If you open ap76.mtl in hex editor, you'll see strings of information like this:

newmtl 2215_mtl
Kd 1.0000 1.000 1.000
Ka 1.0000 1.000 1.000
Ks 1.0000 1.000 1.000
illum 0
d 1.000000
map_Kd 2215.tga

http://paulbourke.net/dataformats/mtl/ discribes this format thoroughly.

The issue is that .obj / .tga / .mtl files are compressed (?) when they are stored in a single .map file and data between them is not in 1:1 format — there is no understanding what to hex edit in .map file yet.

Another issue is that (as far as I understand) visuals we actaully see in the game window are stored in VRAM and memory scanners like Cheat Engine can't access VRAM which leads to time consuming issue of always reloading a savefile to see any changes made to .map files. When changing stuff in .cam / .kg2 / .cld files via CE you can see changes right away on the screen.

It is possible to edit .map files on the fly in PCSX2 since the emulator allocates VRAM as a common RAM but, as we know, .map files are different between the platforms so it has no practical use.

@Polymega

This comment has been minimized.

Polymega commented Jun 5, 2018

Holy shit that's impressive what you've done so far.

I nulled almost all of ap76.map and shading on carpet and cabinet is still preset:

Yeah, it seems to be that the vertex normal information is "baked in" to the geometry itself which is typical and standard for such things.

The issue is that .obj / .tga / .mtl files are compressed (?) when they are stored in a single .map file and data between them is not in 1:1 format — there is no understanding what to hex edit in .map file yet.

This will be the roadblock then. OBJs have their vertex normal information as vn, according to this page. There may be a way to edit this through a piece of software like 3D Model Researcher but, even if that software can open/explore the file, I don't believe it can save any changes done to it and back to the correct format for the game to use.

Although it does seem like, with 3D Model Researcher, it can guide you to the right hex regions for the models? I'll be honest: I watched some of the video examples for this software and it's all confusing to me... And, of course, there's also no guarantee it could even open a .map file to begin with.

Although this is interesting:

vn x y z

The vertex normal command specifies a normal vector. A lot of times these aren't used, because the 'f' face command will use the order the 'v' commands are given to determine the normal instead. Like the 'vt' commands, they don't mean anything until grouped with a vertex in the 'f' face command.

I bolded the relevant part as this is what I did in Maya to fix the issue: I simply set the vertex normals to conform to the face.

@Bigmanjapan

This comment has been minimized.

Bigmanjapan commented Jun 6, 2018

I see, thanks for the info. That will take some time to research.
Maybe @Nisto can help with this? Since he did extractors for PS2 SH2 builds.

John_Modest's "Silent Hill Texture Explorer 2.1" program can import .tga files back into .map files, so it should be possible to do the same with .obj files. Judging from his program, tga files are compressed via DXT1 or DXT2 formats, so that's something.

@Polymega

This comment has been minimized.

Polymega commented Jun 6, 2018

John_Modest's "Silent Hill Texture Explorer 2.1" program

I remember I emailed him sometime back in mid 2017 but I think he no longer uses that email address. :( I tried searching for him but there's no other info I could find on the web to get in touch with him.

@Bigmanjapan

This comment has been minimized.

Bigmanjapan commented Jul 7, 2018

@Polymega even Russian community lost touch with John_Modest long time ago (he is Russian btw).

plywood checked how normals behave in the coin cabinet room on Xbox version. Same issues.

https://youtu.be/sDIu82SdgfA

@Polymega

This comment has been minimized.

Polymega commented Nov 16, 2018

@Bigmanjapan @elishacloud @AeroWidescreen

Hi team,

I wanted to share some good and exciting news with you all. I've been in contact with Stan @sbobovyc Bobovych, a multifaceted programmer/engineer, over the past month or so, and he has cracked open the secrets to the game's 3D data within the .map files.

This isn't his first time reverse engineering a game file as seen in one of his earlier blog posts here (and it was this same post that initially led me to him). With his expertise and knowledge in such work he graciously accepted my request to look into and solve the bad normals for this room.

You can read his first blog post on researching/testing/experimenting with the game's .map file on his site here.

image

To you programmers here, I'm sure this would be an interesting and fascinating read. And while we've been stumped with cracking this riddle since the beginning, if, after reading his post, any revelations come to you with how to see the solution through, please do chime in!

To any fans currently reading this: If you'd like to send Stan a "thank you" tip for his time and skills put towards this fix, please consider sending him a donation here. He's doing this on his spare/free time having never played the game before, so this is a pretty big deal for him to share his talents helping our fanbase out.

And to Stan: Thank you so much again for all that you are doing!

@FrozenFish24

This comment has been minimized.

FrozenFish24 commented Nov 24, 2018

carpet
cabinet
ap76.zip

How's this look?

@Polymega

This comment has been minimized.

Polymega commented Nov 24, 2018

Holy!! Okay, well, let me boot up the game soon as well and give her a test run. Looking at just your pictures it looks seeeeexy!

This is awesome!

@Polymega

This comment has been minimized.

Polymega commented Nov 24, 2018

@FrozenFish24 that's the ticket! Everything looks fantastic! Thank you!

This is also great because now I can package up all the recent, new fix files and release them as v1.0.3 of the Enhanced Edition Essential Files for others to grab and enjoy.

I'll start work on making an update video covering all this as well. Thank you again!

@FrozenFish24

This comment has been minimized.

FrozenFish24 commented Nov 24, 2018

Great, glad I didn't introduce any new oddities. Looking forward to the video, the work you guys have done is really impressive!

@Polymega

This comment has been minimized.

Polymega commented Nov 24, 2018

Looking forward to the video, the work you guys have done is really impressive!

Love your modesty. :) If you contribute, you're part of the team. Welcome to the team!

If I may ask, how deep/extensive is your background with this type of work? Elisha is working on removing the need for WineD3D for Nvidia cards but he's currently stuck on the last thing to fix: Preventing chunks of the wall from disappearing when the camera is too close to the geometry.

Are you familiar with such issues in games? Any clue on how to approach this fix? This particular task is a milestone for us because, once we remove the need for WineD3D for Nvidia cards, we can unify the installation process for everyone and then start looking in to making a bonafide installer for all the fixes (instead of making people download each fix, one-by-one). That, and WineD3D causes most problems for people when trying to play the game.

Here's Elisha's earlier notes on what he thinks the issue might be:

I already took a quick look at the chunks of the wall disappearing issue. This appears to be an issue with how Nvidia handles vertices. Troubleshooting vertex issues are not fun or easy! The screens that have this issue have 10’s of thousands vertices. I don’t have any tools to work with vertices (if I had the Silent Hill 2 source code then I could use off the shelf tools and this would be easy) so I need to do this by hand (i.e. create my own specific code/tools to help me troubleshoot this). First I need to create code to extract all the vertices, then figure out exactly which vertex has the issue (it looks like it is only one, or at most two, vertices in each screen) and then I need to figure out why that vertex has an issue. I have never worked with vertices before, so this will be a good learning experience! Note: to understand vertices check out these pages:

@FrozenFish24

This comment has been minimized.

FrozenFish24 commented Nov 24, 2018

Welcome to the team!

🤣

If I may ask, how deep/extensive is your background with this type of work?

I've reversed a handful of binary formats here and there, mostly textures and archives. I have very little experience with graphics APIs though. This is the first 3D format I've attempted.

First I need to create code to extract all the vertices, then figure out exactly which vertex has the issue (it looks like it is only one, or at most two, vertices in each screen) and then I need to figure out why that vertex has an issue.

If he's thinking the problem lies in the actual vertex properties within the map files then I might be able to help. I can dump out the vertex buffers from the map files pretty easily and locate specific vertices using Blender. I'll have a look tomorrow.

@Polymega

This comment has been minimized.

Polymega commented Nov 24, 2018

Thank you kindly! Any research will surely help just the same as what was done here with the vertex normals.

Just a forewarning: There isn't necessarily a particular set of rooms (.map files) that experience this issue on Nvidia cards; it's more like any time, any where, when the camera gets too close to geometry it does this when not using WineD3D with Nvidia.

Another example: When you and Maria are being chased down the tight hospital corridor by Pyramid Head you will see chunks of the walls loading/unloading consistently as you keep running.

@Polymega Polymega closed this Nov 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment