myst6re / makoureactor

Final Fantasy VII field archive editor
GNU General Public License v3.0
55 stars 11 forks source link

[Request] Field Models editor: Preview directional lighting in editor #119

Open HeyItsLollie opened 3 years ago

HeyItsLollie commented 3 years ago

Is it possible to add the results of "Global light" and "Directional light" to the preview window in the Field Models editor?

MakouReactor-FieldEditorMockup

jeromearz commented 3 years ago

Wow if you have results to share, please do! What we need is to add normals from the P file and then colored light sources. If someone wants to work on this, please starts from the develop branch

HeyItsLollie commented 3 years ago

Sorry, I should have mentioned, the images are just mock-ups! I was using screenshots from FF7-PC, but the lighting you see is the result of these lighting values.

For anyone willing to give it a try, as far as I can gather: You can get lighting direction by testing the position of the point at X,Y,Z against 0,0,0, and then apply the result locally to each mesh in the model, using the normals of each vertex. I've been told this is actually a classic lighting technique for 3D, so it should thankfully be well documented. It likely uses a vector dot product, eg: dot(vertexNormal, lightDirection)

Light intensity might be vertex length, measuring the distance between X,Y,Z and 0,0,0 (where the maximum length is 32768).

The lighting itself is effectively just vertex colors. "Global Light" tints the entire model uniformly, where White is full-bright, and Black is full-dark. "Directional Light" channels are blended additively per-mesh. CidLighting