Starting with custom 2D Filter

Hey everyone!
I wanted to start learning to write custom 2D Filter. After an introduction from my brother I am confident that I can learn a little bit in that area!
Is there a proper bgl api where I can find important variable names.

For example stuff like this:

uniform float bgl_RenderedTextureWidth;
uniform float bgl_RenderedTextureHeigth;
uniform sampler2D bgl_RenderedTexture;

At the moment this are variables I have found in other scripts. I know there is also one for the zbuffer. But I don’t know a place where I can look stuff like that up!
How did you guys start with your custom 2DFilters?

I would appreciate any help! Thanks alot!


Z-Buffer: uniform sampler2D bgl_DepthTexture;

How I started: I just dissected Scripts mostly by martinsh/mpan – I still do.

Be aware that Filters with one or more FOR Instace(s) run slower than writing each single Iteration manually with the according Values. (SolarLune has made me aware of this.)

Look at at the bgl api

1 Like

This is one of those poorly documented areas of blender (it’s not documented in bgl, as far as I can tell). You’ll basically have to read the source.

Here’s the source of a relevant file: link.

Relevant tutorials I did in the past: GLSL Basics and the (incomplete) Outline effect.

Piggybacking off of Goran’s link, you can also find the filters for almost all of the built-in 2D filters there, with the exception of motion blur, for some reason. Possibly others, too, but I’m not sure. Also, thanks for that link, Goran. I didn’t know you could browse the source online (I thought you had to download it).

EDIT: As a side-note, I have no idea who edited it in, but there seems to be a pretty useful set of tutorials on GLSL shaders on Wikibooks.