3 ms·
Suggestion change the line `${lib};const {sin,cos,tan,random,PI,sqrt,hypot,atan,atan2} = Math; ${code}; return main;` to `${lib};const {${Object.get
by Lerc 2y ago
Suggestion
change the line
`${lib};const {sin,cos,tan,random,PI,sqrt,hypot,atan,atan2} = Math; ${code}; return main;`
to
`${lib};const {${Object.getOwnPropertyNames(Math)}} = Math; ${code}; return main;
To bring in all of Math into context without having to list them all individually.
- Lerc 2y agoMaybe also adding smoothstep and clamp as traditional shader building blocks functions. You can still define them in inline with not too many characters though so maybe it's ok. https://garten.salat.dev/fake-shaders3.html#Zy5kaW09NjQ7bGV0IG1haW49KHt0LHgseX0sbyk9PiB7CmNvbnN0IHttaW4sbWF4LHJvdW5kfT1NYXRoCmxldCBjbGFtcD1hPT5taW4obWF4KGEsMCksMSkKbGV0IHNzPSh2LGE9MCxiPTEsdz12KnYqdioodioodio2LTE1KSsxMCkpPT4oMS4wLXcpKmErKHcqYik7IApsZXQgdT0yKngtMSx2PTEtMip5LHo9c3FydCh1KnUrdip2KQpsZXQgbT0oMioqKCgyKnkpKzYpKQpsZXQgVj0gIAogICAgcm91bmQoeikqKHYqcm91bmQoeSkKICsgIGNsYW1wKCAoeCptXnYqbSkgL20vMiApICogcm91bmQoMSAtIHkpKQogKyAoMSAtIGNsYW1wKHJvdW5kKHopKSkgKiAoMSAtIHNzKHopICsgc3MoeCAqICgxIC0geSkgKiAtMS4wMDkpKTsKCm8ucj1jbGFtcCgtVikKby5nPTAKby5iPWNsYW1wKFYpCn0= https://garten.salat.dev/fake-shaders3.html#Zy5kaW09NjQ7bGV0...
- eddyflux 2y agowow that's cool