Advertisement Jump to content
Sign in to follow this  
zz2

Can't find where parameter is specified in this shader

This topic is 1828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;  
    }  

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!