Planned feature: Image Convolution
Displaying 1-2 of 2 total.
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.

To raise awareness of engine development, I decided to make a thread. I figure announcing this will keep people interested in new features. To discuss other features down the road, I'll make probably other threads.


What is a Convolution kernel exactly? I won't bore you with the math terms, but they basically allow you to define a bunch of special effects on images.

Blurring, sharpening, softening, edge detection, edge enhancement. Any of these sound familiar? They're basic things in pretty much any paint program that has some form of filters. And they're defined with "convolution kernels", which are basically just a matrix of numbers applied to each pixel and its neighbours.

The GIMP documentation on Convolution Matrices, and other internet sources have the exact numbers needed to perform different effects.

They're pretty handy, since by just using a couple numbers, you can define a variety of nifty effects on images.

The proposed functions would be like this:

// Convolve an image using a 3x3 kernel
void Convolve3x3(int image,
int a1, int a2, int a3,
int b1, int b2, int b3,
int c1, int c2, int c3

// Convolve an image using a 5x5 kernel
void Convolve5x5(int image,
int a1, int a2, int a3, int a4, int a5,
int b1, int b2, int b3, int b4, int b5,
int c1, int c2, int c3, int c4, int c5,
int d1, int d2, int d3, int d4, int d5,
int e1, int e2, int e3, int e4, int e5

And here's a couple examples:

// A 5x5 guassian blur filter.
1, 2, 3, 2, 1,
2, 4, 6, 4, 2,
3, 6, 9, 6, 3,
2, 4, 6, 4, 2,
1, 2, 3, 2, 1

// A 3x3 edge-detection filter
0, 1, 0,
1, -4, 1,
0, 1, 0

The implementation shouldn't be too tricky. In fact, Kael, pretty much gave me the source from his fury2 graphics library. So it's just a matter of converting that over to work with Verge.

At any rate, what does this mean, you might wonder.

Well, as a result, blur effects and other image processing can be made a lot faster than it is with current solutions people made in their VC or Lua code. So instead of coding a blur effect in VC, you'll just pass an image-handle, and 9 or 25 numbers, and you'll get a pretty substantial speed benefit. Not to mention, less wheel reinvention. You can just use someone else's filter numbers, shove 'em in, and rock.

It'll still be slow, obviously, since this is software graphics, but it's pretty much one of the fastest ways for blur effects, while still allowing tons of flexibility over any other special effects people want on their images.


Posted on 2009-08-23 02:09:34 (last edited on 2009-08-23 13:30:14)


I think your idea is practical. Maybe Ben Eldritch could use it for blurring the map when I get into a battle in Serinor. This reply is so late that it probably doesn't mean anything. (I'd love to get back into working on Serinor version 2 {when someone get's around to reading this}.)

Posted on 2011-10-14 20:29:43

Displaying 1-2 of 2 total.
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford. is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.