Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Texture as Mask

Anonymous
Not applicable
Not sure if this would be the correct placement of this thread, but seen the question asked before in here.

I am a designer of code128 barcode in vb.net.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:

void main() {
 float mask = texture( tex, fragTexCoord).r;
   vec4 res = vec4(1.0,1.0,1.0, 1.0);

   if(mask > 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;
}
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.

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)
2 REPLIES 2

bobbell wrote:
Not sure if this would be the correct placement of this thread, but seen the question asked before in here.
I think this belongs in the Developer Forum.

David
David Maudlin / Architect

www.davidmaudlin.com

Digital Architecture

AC24 USA • iMac 27" 4.0GHz Quad-core i7 | 24 gb ram • MacBook Pro 2.8GHz | 16 gb ram • OSX10.15.7

Laszlo Nagy
Community Admin
Community Admin
I have split this question from that other thread and moved it to the Developer Forum.
....................................................................................................
Get Archicad Tips at https://twitter.com/laszlonagy
AMD Ryzen 1700X CPU, 48 GB RAM, Nvidia GTX 1060 6GB, 500 GB NVMe SSD
2x28" (2560x1440), WIN10 PRO ENG, AC20-AC25
Loving Archicad since 1995

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!