Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Can't find where parameter is specified in this shader

4: Adsense

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   

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





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.