Centroid, centroid everywhere, but not an edge to find

Had coffee. Rebooted. Today’s problem was all about detecting edges of ploy’s. Not going into the reason why, but needed to detect these in multi-sampling mode. So here’s the fun way to do it. Use the screen position passed into the pixel shader, this is the exact position, so in MSAA mode it can be on a partial pixel. Okay, so how do you get the edge? Well you need a value thats always inside the poly. So you pass in the position again, but this time you pass it in with the ‘centroid’ modifier. This means it will always be in the centre of a pixel. What do you do then? Well it’s quite simple, you subtract one from the other, if the difference isn’t zero then you have an edge pixel. Can it be optimised more? Well yes, but you have to be a bit clever. You need to pass in the position, but set it to no-interpolation, then do the interpolation manually, but once with normal and once with centroid.

Walked Sasha, Dillon wasn’t interested again. After much thunder and rain I managed a fairly dry run this evening, another eight odd miles. Started the rough cut on the new video, about half way through. This one will take a while.

Flying tomorrow.

Leave a Reply

Your email address will not be published. Required fields are marked *