Professional Documents
Culture Documents
Filter Ed ps5
Filter Ed ps5
Filter Ed ps5
;LuminanceDiagEdgeBlit.nvp
;This pixel shader detects and displays edges. It assumes the same
;texture is sampled with appropriate offsets at all four texture units.
;An edge is detected if the difference of the diagonally-opposed samples
;is larger then some threshold.
;Algorithm:
;- sample all four texture stages
;- convert color-samples to luminance-values
;- computes the diagonal differences
;- square each difference (it is easier than abs())
;- add the two differences
;- multiply the result by large number to make visible
;- Invert the result to display edges black on white
; declare constants:
def c1, 0.3f, 0.59f, 0.11f, 0.0f ; luminance conversion constant
;mul_x2 r0, r0, r1 // and multiply with luminance for final result
// (brighten it a bit to bring out edges more)