Hi!
tl;dr I really want to write a "Crop" shader, any pointers? :P
So I have literally no experience with writing GLSL shaders, or ANY shaders for that matter. I'm trying to create a (seemingly) simple "Crop" shader. I've been looking through the documentation and files that Scirra provides, but I can't seem to wrap my mind around it!
I then found my ol' files from MMF2 which had a similar "Crop" shader (Not owned by me, part of the "Complex-softwares" pack I downloaded yearrrrs ago) that I decided to edit and tinker with to figure out how to port the shader into the GLSL language.
Since I'm not entirely understanding what I am doing (I get a few things but barely anything), I have ended up trying many different combinations of words and replacing things here and there, and I simply can't get it to work. I have failed to get any sort of effect EXCEPT making my sprite's alpha channel get affected. I guess that's something!
So the way this particular crop works, is that you get several parameters to edit (Left, Right, Top, Bottom, Alpha). You would specify the amount of pixels to modify from each parameter, and then the alpha would transform those pixels to the alpha specified.
So say you have this sprite:
<img src="https://dl.dropboxusercontent.com/u/7765312/C2/Croppy/1.png" border="0" />
And you then set "Bottom" to something like 10, and Alpha to 0, it should give this result:
<img src="https://dl.dropboxusercontent.com/u/7765312/C2/Croppy/2.png" border="0" />
I will attach what I've attempted, I'm pretty eager to learn about how to actually solve this and how it works. If it's also much to ask for, I'd LOVE to be able to retain the angle if the sprite is rotated; so following the previous example with Bottom and Alpha, the crop would appear like this when the sprite is rotated:
<img src="https://dl.dropboxusercontent.com/u/7765312/C2/Croppy/4.png" border="0" />
IN AN IDEA WORLD: If I was a pro shader writer, I wouldn't make this exact shader for Crop, I would instead, have only 2 parameters, "Amount" and "Angle", in which you specify an angle in which the crop will come from, and "Amount" would be how many pixels it crops off (That way, You could specify 45degree angles whilst the sprite's angle is 0.)
Here's my failed attempt (along with the shader I'm trying to port):
dl.dropboxusercontent.com/u/7765312/C2/Croppy/crop.zip
Thanks!