Jump to content
Sign in to follow this  

GLSL shader as live filter

Recommended Posts

Just come to my mind. Might be a little crazy though, but it might not be that hard to implement, and there's absolutely a lot of usage if implemented.


The idea is simple, allowing user to write their own live filter in GLSL. Something like this:

//haven't coded GLSL some time so this is more of a pseudo code
unity texture2D source; //the source image
unity vec2 sourceSize; //the rastered size of the source image in px
unity struct{
  //user-defineable sliders, document driven
  	* @name Slider A
   * @description The Slider A
  	* @minValue 0
   * @maxValue 100
  float sliderA;
  	* @name Slider A
   * @description The Slider A
  	* @minValue 0
   * @maxValue 100
  float sliderB;
} settings;

in vec2 pos; //the normalized position/coordination of the current fragment, aka pixel
out vec4 color; //the result this filter should produce

//the above part should be auto-generated, with the settings being generated using a GUI interface, even though user can type those in themselves

//below is a dummy filter that simply outputs whatever the source image is
  vec4 currentColor = texture(source,pos);
  return currentColor;

Which would already be GPU-friendly (since it's basically a fragment shader) and thus GPU acceleration can be automatically used. Also, by default this is 32-bit image editing ready.


I don't see many people would want to write their own filters, but those who want to could benefit from this, and other people can use their code without knowing how to write one, which means that Affinity Photo can have potentially unlimited amount of live filters.


There could be more features, for example side-chaining other images as secondary sources, but that would only be in the roadmap if this one is in first, thus not in the topic of this suggestion.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this