Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Can't find where parameter is specified in this shader


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 zz2   Members   -  Reputation: 275

Like
0Likes
Like

Posted 16 January 2014 - 10:01 AM

Hi! I'm trying to figure out where it is specified if the curve is convex or concave in this sample shader provided in this article: Rendering Vector Art on the GPU. Does it need to be rendered in two batches one for convex triangles and one for concave triangles?

       float4 QuadraticPS(float2 p : TEXCOORD0,  
      float4 color : COLOR0) : COLOR  
    {  
      // Gradients  
       float2 px = ddx(p);  
      float2 py = ddy(p);  
      // Chain rule  
       float fx = (2*p.x)*px.x - px.y;  
      float fy = (2*p.x)*py.x - py.y;  
      // Signed distance  
       float sd = (p.x*p.x - p.y)/sqrt(fx*fx + fy*fy);  
      // Linear alpha  
       float alpha = 0.5 - sd;  
      if (alpha > 1)       // Inside  
        color.a = 1;  
      else if (alpha < 0)  // Outside  
       clip(-1);  
      else                   
       // Near boundary  
        color.a = alpha;  
      return color;  
    }  


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS