// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Estimate a surface normal from height samples // Not compiled or tested in-world // Setup: Use a spare owned prim. Set left/right/down/up heights, positive SPACING and strength. Touch for owner-only numeric output. // Stop / restore: Remove/disable; no colors or materials are applied. // Notes: Central differences assume evenly spaced samples. Strength changes slope scale; this does not create a normal-map asset. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Color calculation only. float LEFT=0.2; float RIGHT=0.5; float DOWN=0.3; float UP=0.4; float SPACING=1.0; float STRENGTH=2.0; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; if(SPACING<=0.0) { llOwnerSay("Positive spacing required."); return; } float dx=(RIGHT-LEFT)/(2.0*SPACING); float dy=(UP-DOWN)/(2.0*SPACING); llOwnerSay("Estimated normal="+(string)llVecNorm(<-dx*STRENGTH,-dy*STRENGTH,1.0>)); } }