morris / vstools

Toolset for Vagrant Story (2000, Square), written in JavaScript with Three.js
https://morris.github.io/vstools/
MIT License
100 stars 9 forks source link

Use PS1-type vertex color formula #15

Closed scurest closed 3 years ago

scurest commented 3 years ago

Hey, I love the viewer.

I noticed the vertex color formula is off. The PS1 combines texture and vertex color with 2 * texcolor * vertcolor instead of the usual texcolor * vertcolor (used by Three's MeshBasicMaterial). Here's a patch that replaces MeshBasicMaterial with a shader that does the PS1 formula.

Comparison with map009 (Entrance to Darkness):

Entrance to Darkness Comparison

Actually when using vertex colors with textures, 0x80 (128/255) is "fully bright" (no change to the texture), so the factor is a bit less than 2, 1.9922 (=255/128).

I don't know anything about Three so I wrote the new ShaderMaterial by closely following the MeshBasicMaterial shaders (1, 2). The factor is added to the vertex shader. I also noticed MeshBasicMaterial does some linear color space conversion stuff that I don't think should be there so I left it out.

I feel like it's a bit messy but hopefully you can make something of it anyway -A-

morris commented 3 years ago

this is brilliant!!! thank you so much - don't have a lot of time to double check but seems to work very well. merging <3