ProtoArt / spritec

The Sprite Compiler turns your 3D models into 2D spritesheets
https://protoart.me/
Mozilla Public License 2.0
32 stars 5 forks source link

Improve Blender Lighting Hack #194

Open sunjay opened 4 years ago

sunjay commented 4 years ago

It's currently really hard to match the colors produced by a Blender-exported 3D model. It's possible that this isn't Blender-specific, but that's the main 3D program we're targeting right now.

Notice how different the colors in these two images are:

isodog isodog pixel art

The left is a render produced by Blender and the right is an image produced by spritec (without the intensity hack in #193). The colors having different brightnesses indicates a lighting issue to me. While the colors are certainly affected by our use of toon shading, I think a larger issue at play is the lighting hack we had to implement because of a bug in Blender's glTF exporter:

https://github.com/ProtoArt/spritec/blob/7404bf94f1ba3738e055cb97ec7afb31b4361017/src/scene/light_type.rs#L66-L69

I chose to divide by 1000.0 because Blender lights start at 1000 W and this makes the default light have an intensity of 1.0. In practice however, this is not a good approximation. We should play around with the way we normalize the Blender light values. Since Watt is a unit of power, maybe the relationship is actually exponential? (i.e. maybe we should take the log?)

Another possible solution: Maybe we should just give in and implement glTF's physically-based lighting model?