(program	
 (constant_buffer p (@properties)
  [(:= color float4) 
   (:= rect_position float2) 
   (:= rect_scale float2) 
   (:= resolution float2) 
   (:= texture Texture2D) 
   (:= sampler Sampler)])

 (struct PS_Input
  [(:= uv float2 (@uv)) 
   (:= pos float4 (@pos))])

 (fun vertex vs_main -> PS_Input
  [(:= pos float4 (@position))] 
  (:= res float2 p.resolution) 
  (:= scale float2 p.rect_scale) 
  (:= rect_pos float2 p.rect_position) 
  (:= center float2 rect_pos) 
  (:= half_size float2 (float2 (/ scale.x 2) (/ scale.y 2))) 
  (:= dst_pos float4 (float4 (+ (* pos.x half_size.x) center.x) (+ (* pos.y half_size.y) center.y) 0 1)) 
  (:= result PS_Input) 
  (:= src_p0 float2 (float2 0 1)) 
  (:= src_p1 float2 (float2 1 0)) 
  (:= src_half_size float2 (/ (- src_p1 src_p0) 2)) 
  (:= src_center float2 (/ (+ src_p1 src_p0) 2)) 
  (:= src_pos float2 (+ (* (float2 pos.x pos.y) src_half_size) src_center)) 
  (= result.uv (float2 1 1)) 
  (= result.pos (float4 (- (/ (* 2 dst_pos.x) res.x) 1) (- (/ (* 2 dst_pos.y) res.y) 1) 0 1)) 
  (return result))

 (fun pixel ps_main -> float4 (@target0)
  [(:= input PS_Input)] 
  (:= color float4 p.color) 
  (return color)))