Best way to do simple per-pixel changes in a shader?

I’m looking for the solution that runs the fastest and that is the most compatible (naturally). It seems like this ought to be easy, but the documentation on Unity shaders seems to be fairly lacking for people who don’t already know general shaders.

I have two simple cases I’d like to be able to do based on sending a texture input (basically with no lighting, and just looking at the input texture as the only source of data):

  1. For any pixel that has alpha of 1, but is next to a pixel with alpha less than 1, render that pixel. Otherwise skip the pixel entirely.

  2. For any pixel that has an alpha greater than 0, render with color black but match the alpha of the pixel. For any pixel with alpha greater than 0.5, lower the alpha to 0.5.

I actually have other cases as well, but if I knew how to do these two I could easily do the others. The first case might not be possible since it requires being able to index into neighboring pixels, not just the pixel in question. The second one seems like it ought to be easily possible, if only I knew the syntax, though.

i can’t provide any help with code because i am in a same mess like you.
although i found this to be so helpful, its a free Visual Shader Editor for Unity.

http://forum.unity3d.com/threads/56180-Strumpy-Shader-Editor-4.0a-Massive-Improvements