https://www.reddit.com/r/NiGHTSintoDreams/comments/k34lu0/modding_nights_into_dreams/
https://drive.google.com/file/d/1a3zlf2-vSSQgiLnpRLF_FR_uvZIv_DKQ/view
https://docs.google.com/spreadsheets/d/19rGlVLG1wIo7gaaqIPSpV3GxabI_y7Lnbl6uBDie6BM/edit?usp=sharing
Trial and Error
---
I started by looking in code, before I realised I know nothing about DX9.
I tried decompiling "object.wvu" (I assume this is the right file, its the biggest) but I could not, I do not know what tools I need nor how to use them.
OpenGL is where I've had most of my graphical experience, when I want to debug my own OpenGL programs I use RenderDoc. RenderDoc does not have support for DX9.
I searched online for a debugger that does support DX9, NVidea Nsights shows up and says it does. I download the latest version and it doesn't like 32-bit applications. I run an old version that says that it WILL remove 32-bit support but it seems like it already HAS. I run an older version that was before the threat to remove 32-bit support and it did work with 32-bit programs - but not DX9 programs. I couldn't find which versions did support DX9 so I tried using a wrapper that would wrap DX9 functions with some newer graphics API. I tried dgvoodoo2, wined3d, forced3d9on12, dxvk and I couldn't get dxup to compile and then I gave up with this idea.
I then thought to try RenderDoc again, but this time with the wrappers. Most wrappers would not allow RenderDoc to launch the game at all. dgvoodoo2 did let the game launch, but RenderDoc said the game was still using DX9. dxvk let the game launch AND RenderDoc believed it was on Vulkan and DX9?
Despite this, I was having a hard time getting the game to capture so that I could debug. I tried the six main bosses, and only Gillwing seemed to not crash the game.
RenderDoc
---
Event Browser
NiGHTS is drawn at EID 737, but a segment of Gillwing's tail is drawn at EID 733. Not too many events happen is between. EID 734: The Vertex Buffer is switched to NiGHTS' Vertex Buffer which is to be expected. EID 735 binds some Descriptor Sets, I have no idea what a Descriptor Set is, but they are slightly different from Gillwing's. EID 736: Some constants are pushed but these are the same as Gillwing's and are just saying that a Vertex and Fragment shader are used.
Mesh Viewer
I compared the drawing of NiGHTS to the Gillwing Tail segment. The Vertex Buffer passes a Position, Normal, Color and Texture Coordinate into the Vertex Shader and it outputs a a bunch more variables. What is of note is the output Color for a Vertex. The starting color seems weird, so the Color input might be completely irrelevent, but I have included it here anyways.
NiGHTS: Vertex 0: Color: { 0.50196, 0.50196, 0.50196, 0.50196 } -> { 0.34677, 0.1, 0.1, 1.0 }
NiGHTS: Vertex 1: Color: { 0.50196, 0.50196, 0.50196, 0.50196 } -> { 0.3, 0.1, 0.1, 1.0 }
and so on for every vertex, all of which result in a variety of colors.
Gillwing Tail Segment: Vertex 0: Color: { 0.50196, 0.50196, 0.50196, 0.50196 } -> { 1.0, 1.0, 1.0, 1.0 }
Gillwing Tail Segment: Vertex 1: Color: { 0.50196, 0.50196, 0.50196, 0.50196 } -> { 1.0, 1.0, 1.0, 1.0 }
and so on for every vertex, all of which result in white.
None of the vertex attributes seemed weird, and there were no obvious commands to change anything.
Pipeline State
The Uniform Buffer has a different Byte Range? I do not know how, I imagine this is something to do with the Descriptor Set?
Regardless, what is different between them. RenderDoc sucks at comparing them, it seems I can only have one open at a time. I can export them, but I need to convert the values to and from hex, and I need to figure out where those values are in the Uniform Buffer view in RenderDoc.
f[20-23] (Element 36-39 in CSV, Offset 0x240 in Bytes) are what I imagine to be the Transformation Matrix. It is a 4x4 of floats, with 3 of them in a row at 0. Both NiGHTS and the Gillwing have different transformations, you would expect them to be different, the vertex attributes are too small to be transformed already (and that would be weird?). The information needs to be sent to the shader somehow.
What is of note is the only other difference in the file, f[38].x (Element 54's Data.X in CSV, Offset 0x360 in Bytes), is 1.0 (float) for NiGHTS and 0.0 for Gillwing. I couldn't find a way to change this value in RenderDoc, but I could change the shader.
Shader
Using the Edit button in RenderDoc seems to decompile the shader to Vulkan GLSL. Finding c.f[38].x (line 196) and replacing it with 1.0 resulted in the screenshot I sent last night.
Conclusions
I do not know what of this might apply to the base game. Assuming DX9 has Uniforms, or an equal to, then I imagine that in the rendering code NiGHTS sets some Uniform to 1, and everything else has it set to 0. "Uniform"s might not even be used, I don't think this Vulkan representation will look anything like the basegame code.
One solution might be to find where this "Uniform" is set in code, and change it to 1 for everyone.
Alternatively, find a way to decompile object.wvu, find where the "Uniform" is used, and hardcode 1.0 into it then recompile.
I do not know how to proceed from here.
I have attached the NiGHTS RenderDoc capture. Edit: oh thank goodness Discord increases the filesize, like, yesterday? otherwise I couldn't have
Edit2: Wait, thinking about it how are animations sent? Presumably the Vertex Shader needs that, and if all that is different between the Gillwing in the Uniforms is Tranformation and Lighting, then animation is done how? Manually to the vertices? I guess I don't really care right now 😛
https://drive.google.com/file/d/1CYbgjVzKMUBDefZpwLf7j9QLua2P0my_/view?usp=sharing