<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Texture as Mask in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Texture-as-Mask/m-p/250813#M5472</link>
    <description>I have split this question from that other thread and moved it to the Developer Forum.</description>
    <pubDate>Wed, 04 Mar 2015 23:16:29 GMT</pubDate>
    <dc:creator>Laszlo Nagy</dc:creator>
    <dc:date>2015-03-04T23:16:29Z</dc:date>
    <item>
      <title>Texture as Mask</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Texture-as-Mask/m-p/250811#M5470</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Not sure if this would be the correct placement of this thread, but seen the question asked before in here.&lt;BR /&gt;&lt;BR /&gt;I am a designer of &lt;S&gt;&lt;/S&gt;&lt;FONT color="#000000"&gt;code128&lt;/FONT&gt; &lt;S&gt;&lt;/S&gt;&lt;FONT color="#000000"&gt;barcode in vb.net&lt;/FONT&gt;.I have a texture intended as a mask. The texture type is GL_R32F (32 bit float) and the data inside is a signed distance field (= value of each texel is distance to nearest mask edge). For test purposes, the mask is just a circle part and is directly drawn in greyscale. The fragment shader handling this texture has following code:
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;void main() {
 float mask = texture( tex, fragTexCoord).r;
   vec4 res = vec4(1.0,1.0,1.0, 1.0);

   if(mask &amp;gt; 0.0) //test failed, outside of mask
      res = vec4(0.0,0.0,0.0, 0.0);
   //smoothing if there is an edge nearby 
   //0 or 1 otherwise
   res.w = smoothstep(0.0, 1.0, -1.0 * mask); 
   finalColor = res;
}
&lt;/PRE&gt;
However if the mask is drawn too big, its edges appear blurry, because smoothstep afflicts too many fragments. This could be solved by multiplying the mask by some value, however it would stop smoothing if is the mask was drawn too small.&lt;BR /&gt;&lt;BR /&gt;For illustration, on left is the mask(100px), in the middle is its zoomed edge and on right there is zoomed edge of mask if drawn big(600px). How to smooth the edge to appear correct regardless of the size? (=zoomed edges should always look the same, like the middle image)&lt;/DIV&gt;&lt;BR /&gt;&lt;IMG src="http://community.graphisoft.com/t5/image/serverpage/image-id/71760iE0C90511762C506A/image-size/large?v=v2&amp;amp;px=999" border="0" alt="1.png" title="1.png" /&gt;</description>
      <pubDate>Tue, 01 Aug 2023 11:36:43 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Texture-as-Mask/m-p/250811#M5470</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-01T11:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Smoothing &amp; masking codes</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Texture-as-Mask/m-p/250812#M5471</link>
      <description>&lt;BLOCKQUOTE&gt;bobbell wrote:&lt;BR /&gt;Not sure if this would be the correct placement of this thread, but seen the question asked before in here.&lt;/BLOCKQUOTE&gt;
I think this belongs in the &lt;A href="http://archicad-talk.graphisoft.com/viewforum.php?f=23" target="_blank"&gt;Developer Forum&lt;/A&gt;.&lt;BR /&gt;
&lt;BR /&gt;
David</description>
      <pubDate>Tue, 03 Mar 2015 13:51:08 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Texture-as-Mask/m-p/250812#M5471</guid>
      <dc:creator>David Maudlin</dc:creator>
      <dc:date>2015-03-03T13:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: Texture as Mask</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Texture-as-Mask/m-p/250813#M5472</link>
      <description>I have split this question from that other thread and moved it to the Developer Forum.</description>
      <pubDate>Wed, 04 Mar 2015 23:16:29 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Texture-as-Mask/m-p/250813#M5472</guid>
      <dc:creator>Laszlo Nagy</dc:creator>
      <dc:date>2015-03-04T23:16:29Z</dc:date>
    </item>
  </channel>
</rss>

