Source

Branch

1/ @steverockan

@AgileJebrim

Answering blind: hierarchically. Split into chunks as large as possible, sum up chunks in a single pass, write results to a new texture, repeat until 1 pixel texture. Maybe have to becareful about precision.

2/ @AgileJebrim

@steverockan

Textures would be slow.