// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Touch-sampled feathered rectangle mask // Not compiled or tested in-world // Setup: Put in a spare ordinary cube you own. Touch different places on one face to sample the procedural pattern at live surface coordinates. Edit the constants to design a pattern. // Stop / restore: Disable/remove. Only private owner messages are produced; no texture or tint is applied. // Notes: The feather is a linear transition outside the rectangle; the signed distance combines corner and edge distances. Surface coordinates depend on the viewer and mesh; ordinary prim faces are the clearest test surface. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Live surface-coordinate sampler. vector HALF=<0.6,0.4,0.0>; float FEATHER=0.15; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; vector uv=llDetectedTouchST(0); if(llDetectedTouchFace(0)<0||uv==TOUCH_INVALID_TEXCOORD) { llOwnerSay("Surface coordinates unavailable."); return; } vector p=2.0*uv-<1.0,1.0,0.0>; if(HALF.x<=0.0||HALF.y<=0.0||FEATHER<=0.0) { llOwnerSay("Invalid rectangle."); return; } float x=llFabs(p.x)-HALF.x; float y=llFabs(p.y)-HALF.y; float ox=x; float oy=y; if(ox<0.0)ox=0.0; if(oy<0.0)oy=0.0; float inside=x; if(y>inside)inside=y; if(inside>0.0)inside=0.0; float distance=llSqrt(ox*ox+oy*oy)+inside; float mask=1.0-distance/FEATHER; if(mask<0.0)mask=0.0; if(mask>1.0)mask=1.0; llOwnerSay("Soft rectangle mask="+(string)mask); } }