BC46 / freelancer-hd-edition

Freelancer: HD Edition is a mod that aims to improve every aspect of the game Freelancer (2003) while keeping the look and feel as close to vanilla as possible.
https://www.moddb.com/mods/freelancer-hd-edition
158 stars 14 forks source link

Per-pixel lighting #205

Open damil42 opened 9 months ago

damil42 commented 9 months ago

The light / shadow in some scenes are really ugly. It's because the game seems to be using per-vertex lighting instead of per-pixel. I just wonder if we can change that?

pixel-vs-vertex-lighting Left: Per-Pixel - Right: Per-Vertex

demo

Here you can see jumping light on face. This demo isn't the best example. It's just a quick random shot. In some other scenes the lighting on the meshes is worse than here. I think it's because per-vertex lighting. I'm not sure we can change that. But it would improve the lighting when using per-pixel. You are more familiar with the game resources etc. What do you think? It this possible?

BC46 commented 9 months ago

DirectX does not offer any sort of pixel shading out of the box. DirectX 8 and 9 have D3DSHADE_PHONG defined, but unfortunately it's not implemented. A while ago I did some experiments in Freelancer with dgVoodoo's Phong Shading option. It definitely improved the lighting, but at the same time it introduced several lighting-related bugs.

One way to get pixel shading to work in Freelancer natively, is to implement a custom pixel shader using a more-modern DirectX version. Even though this is not really feasible at the moment, I think any sort of pixel shader implementation would beat DirectX 8's default Gouraud shading.

Though I must point out that in the example you shared, the FL scene clearly suffers from the infamous Win10+ lighting bug, which makes the lighting appear harsher than it actually is. This video shows what the lighting in this scene is supposed to look like: https://youtu.be/3_oOf09RO68?si=U8-wrEVtSQ8X4ZL9&t=754. Freelancer: HD Edition already includes multiple unique fixes for the lighting bug out of the box, so I don't think there's much else we can do in that regard.

Although implementing a custom pixel shader is a possibility, at this point we might as well wait for Schmackbolzen's OpenGL renderer to be finalized.