@rosetears/aili-pi 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (531) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +109 -0
  3. package/THIRD_PARTY_NOTICES.md +64 -0
  4. package/extensions/index.ts +6 -0
  5. package/install.sh +5 -0
  6. package/manifests/adapter-evidence.json +45 -0
  7. package/manifests/capabilities.json +124 -0
  8. package/manifests/live-verification.json +26 -0
  9. package/manifests/provenance.json +71 -0
  10. package/manifests/roles.json +474 -0
  11. package/manifests/sbom.json +7797 -0
  12. package/manifests/skill-compatibility.json +8100 -0
  13. package/manifests/subagent-provenance.json +37 -0
  14. package/package.json +91 -0
  15. package/prompts/build.md +8 -0
  16. package/prompts/define.md +8 -0
  17. package/prompts/ideate.md +8 -0
  18. package/prompts/local-review.md +8 -0
  19. package/prompts/ship.md +8 -0
  20. package/roles/agent-evaluator.md +47 -0
  21. package/roles/ai-regression-scout.md +47 -0
  22. package/roles/browser-qa-runner.md +47 -0
  23. package/roles/code-reviewer.md +47 -0
  24. package/roles/code-scout.md +47 -0
  25. package/roles/convergence-reviewer.md +55 -0
  26. package/roles/doc-researcher.md +47 -0
  27. package/roles/e2e-artifact-runner.md +47 -0
  28. package/roles/implementer.md +47 -0
  29. package/roles/opensource-sanitizer.md +47 -0
  30. package/roles/plan-auditor.md +47 -0
  31. package/roles/pr-test-analyzer.md +47 -0
  32. package/roles/security-auditor.md +47 -0
  33. package/roles/silent-failure-reviewer.md +47 -0
  34. package/roles/spec-miner.md +47 -0
  35. package/roles/test-coverage-reviewer.md +47 -0
  36. package/roles/test-engineer.md +48 -0
  37. package/roles/web-performance-auditor.md +47 -0
  38. package/roles/web-researcher.md +47 -0
  39. package/scripts/apply-adapter-evidence.ts +73 -0
  40. package/scripts/bootstrap.sh +180 -0
  41. package/scripts/generate-provenance.ts +143 -0
  42. package/scripts/local-package-e2e.ts +51 -0
  43. package/scripts/sync-roles.ts +213 -0
  44. package/scripts/sync-skills.ts +356 -0
  45. package/scripts/validate-runtime.ts +11 -0
  46. package/skills/academic-paper-review/SKILL.md +81 -0
  47. package/skills/agents-md-initialization/SKILL.md +121 -0
  48. package/skills/agents-md-initialization/references/agents-template.md +83 -0
  49. package/skills/agents-md-initialization/references/agents_md.py +215 -0
  50. package/skills/ai-regression-scout/SKILL.md +24 -0
  51. package/skills/aili-delivery-flow/SKILL.md +125 -0
  52. package/skills/aili-delivery-flow/references/artifact-contracts.md +138 -0
  53. package/skills/aili-delivery-flow/references/backend-routing.md +40 -0
  54. package/skills/aili-delivery-flow/references/build-execution-loop.md +113 -0
  55. package/skills/aili-delivery-flow/references/build-goal-mode.md +3 -0
  56. package/skills/aili-delivery-flow/references/direct-vs-delegated-work.md +38 -0
  57. package/skills/aili-delivery-flow/references/implementation-packages.md +54 -0
  58. package/skills/aili-delivery-flow/references/lifecycle.md +127 -0
  59. package/skills/aili-delivery-flow/references/protocols/acceptance-test-plan.md +18 -0
  60. package/skills/aili-delivery-flow/references/protocols/alignment-questionnaire.md +10 -0
  61. package/skills/aili-delivery-flow/references/protocols/closeout-report.md +101 -0
  62. package/skills/aili-delivery-flow/references/protocols/compact-evidence-pack.md +46 -0
  63. package/skills/aili-delivery-flow/references/protocols/idea-brief.md +10 -0
  64. package/skills/aili-delivery-flow/references/protocols/implementation-package.md +53 -0
  65. package/skills/aili-delivery-flow/references/protocols/research-evidence-pack.md +19 -0
  66. package/skills/aili-delivery-flow/references/protocols/review-report.md +7 -0
  67. package/skills/aili-delivery-flow/references/protocols/spec-draft.md +12 -0
  68. package/skills/aili-delivery-flow/references/protocols/subagent-result.md +60 -0
  69. package/skills/aili-delivery-flow/references/protocols/subagent-task-packet.md +29 -0
  70. package/skills/aili-delivery-flow/references/protocols/worktree-context.md +109 -0
  71. package/skills/aili-delivery-flow/references/questionnaire-policy.md +62 -0
  72. package/skills/aili-delivery-flow/references/review-repair-loop.md +16 -0
  73. package/skills/aili-delivery-flow/references/test-document-policy.md +35 -0
  74. package/skills/android-native-dev/SKILL.md +722 -0
  75. package/skills/android-native-dev/references/accessibility.md +209 -0
  76. package/skills/android-native-dev/references/adaptive-screens.md +231 -0
  77. package/skills/android-native-dev/references/design-style-guide.md +365 -0
  78. package/skills/android-native-dev/references/functional-requirements.md +229 -0
  79. package/skills/android-native-dev/references/motion-system.md +203 -0
  80. package/skills/android-native-dev/references/performance-stability.md +223 -0
  81. package/skills/android-native-dev/references/privacy-security.md +244 -0
  82. package/skills/android-native-dev/references/testing.md +554 -0
  83. package/skills/android-native-dev/references/visual-design.md +246 -0
  84. package/skills/api-and-interface-design/SKILL.md +318 -0
  85. package/skills/browser-qa/SKILL.md +32 -0
  86. package/skills/browser-testing-with-devtools/SKILL.md +323 -0
  87. package/skills/build-failure-repair/SKILL.md +49 -0
  88. package/skills/chart-visualization/SKILL.md +73 -0
  89. package/skills/ci-cd-and-automation/SKILL.md +353 -0
  90. package/skills/code-review-and-quality/SKILL.md +375 -0
  91. package/skills/code-review-quality-gates/SKILL.md +132 -0
  92. package/skills/code-simplification/SKILL.md +371 -0
  93. package/skills/comment-accuracy-review/SKILL.md +37 -0
  94. package/skills/consulting-analysis/SKILL.md +69 -0
  95. package/skills/context-engineering/SKILL.md +375 -0
  96. package/skills/coverage-review/SKILL.md +24 -0
  97. package/skills/data-analysis/SKILL.md +74 -0
  98. package/skills/deprecation-and-migration/SKILL.md +222 -0
  99. package/skills/documentation-and-adrs/SKILL.md +330 -0
  100. package/skills/e2e-artifact-handling/SKILL.md +30 -0
  101. package/skills/evidence-scoped-retrospective/SKILL.md +156 -0
  102. package/skills/explain-by-allegory/SKILL.md +99 -0
  103. package/skills/flutter-dev/SKILL.md +162 -0
  104. package/skills/flutter-dev/references/animations.md +497 -0
  105. package/skills/flutter-dev/references/bloc-state.md +281 -0
  106. package/skills/flutter-dev/references/forms.md +656 -0
  107. package/skills/flutter-dev/references/gorouter-navigation.md +257 -0
  108. package/skills/flutter-dev/references/localization.md +510 -0
  109. package/skills/flutter-dev/references/networking.md +566 -0
  110. package/skills/flutter-dev/references/performance.md +305 -0
  111. package/skills/flutter-dev/references/platform-specific.md +417 -0
  112. package/skills/flutter-dev/references/project-structure.md +273 -0
  113. package/skills/flutter-dev/references/riverpod-state.md +232 -0
  114. package/skills/flutter-dev/references/testing.md +364 -0
  115. package/skills/flutter-dev/references/widget-patterns.md +233 -0
  116. package/skills/frontend-dev/SKILL.md +468 -0
  117. package/skills/frontend-dev/canvas-fonts/ArsenalSC-OFL.txt +93 -0
  118. package/skills/frontend-dev/canvas-fonts/ArsenalSC-Regular.ttf +0 -0
  119. package/skills/frontend-dev/canvas-fonts/BigShoulders-Bold.ttf +0 -0
  120. package/skills/frontend-dev/canvas-fonts/BigShoulders-OFL.txt +93 -0
  121. package/skills/frontend-dev/canvas-fonts/BigShoulders-Regular.ttf +0 -0
  122. package/skills/frontend-dev/canvas-fonts/Boldonse-OFL.txt +93 -0
  123. package/skills/frontend-dev/canvas-fonts/Boldonse-Regular.ttf +0 -0
  124. package/skills/frontend-dev/canvas-fonts/BricolageGrotesque-Bold.ttf +0 -0
  125. package/skills/frontend-dev/canvas-fonts/BricolageGrotesque-OFL.txt +93 -0
  126. package/skills/frontend-dev/canvas-fonts/BricolageGrotesque-Regular.ttf +0 -0
  127. package/skills/frontend-dev/canvas-fonts/CrimsonPro-Bold.ttf +0 -0
  128. package/skills/frontend-dev/canvas-fonts/CrimsonPro-Italic.ttf +0 -0
  129. package/skills/frontend-dev/canvas-fonts/CrimsonPro-OFL.txt +93 -0
  130. package/skills/frontend-dev/canvas-fonts/CrimsonPro-Regular.ttf +0 -0
  131. package/skills/frontend-dev/canvas-fonts/DMMono-OFL.txt +93 -0
  132. package/skills/frontend-dev/canvas-fonts/DMMono-Regular.ttf +0 -0
  133. package/skills/frontend-dev/canvas-fonts/EricaOne-OFL.txt +94 -0
  134. package/skills/frontend-dev/canvas-fonts/EricaOne-Regular.ttf +0 -0
  135. package/skills/frontend-dev/canvas-fonts/GeistMono-Bold.ttf +0 -0
  136. package/skills/frontend-dev/canvas-fonts/GeistMono-OFL.txt +93 -0
  137. package/skills/frontend-dev/canvas-fonts/GeistMono-Regular.ttf +0 -0
  138. package/skills/frontend-dev/canvas-fonts/Gloock-OFL.txt +93 -0
  139. package/skills/frontend-dev/canvas-fonts/Gloock-Regular.ttf +0 -0
  140. package/skills/frontend-dev/canvas-fonts/IBMPlexMono-Bold.ttf +0 -0
  141. package/skills/frontend-dev/canvas-fonts/IBMPlexMono-OFL.txt +93 -0
  142. package/skills/frontend-dev/canvas-fonts/IBMPlexMono-Regular.ttf +0 -0
  143. package/skills/frontend-dev/canvas-fonts/IBMPlexSerif-Bold.ttf +0 -0
  144. package/skills/frontend-dev/canvas-fonts/IBMPlexSerif-BoldItalic.ttf +0 -0
  145. package/skills/frontend-dev/canvas-fonts/IBMPlexSerif-Italic.ttf +0 -0
  146. package/skills/frontend-dev/canvas-fonts/IBMPlexSerif-Regular.ttf +0 -0
  147. package/skills/frontend-dev/canvas-fonts/InstrumentSans-Bold.ttf +0 -0
  148. package/skills/frontend-dev/canvas-fonts/InstrumentSans-BoldItalic.ttf +0 -0
  149. package/skills/frontend-dev/canvas-fonts/InstrumentSans-Italic.ttf +0 -0
  150. package/skills/frontend-dev/canvas-fonts/InstrumentSans-OFL.txt +93 -0
  151. package/skills/frontend-dev/canvas-fonts/InstrumentSans-Regular.ttf +0 -0
  152. package/skills/frontend-dev/canvas-fonts/InstrumentSerif-Italic.ttf +0 -0
  153. package/skills/frontend-dev/canvas-fonts/InstrumentSerif-Regular.ttf +0 -0
  154. package/skills/frontend-dev/canvas-fonts/Italiana-OFL.txt +93 -0
  155. package/skills/frontend-dev/canvas-fonts/Italiana-Regular.ttf +0 -0
  156. package/skills/frontend-dev/canvas-fonts/JetBrainsMono-Bold.ttf +0 -0
  157. package/skills/frontend-dev/canvas-fonts/JetBrainsMono-OFL.txt +93 -0
  158. package/skills/frontend-dev/canvas-fonts/JetBrainsMono-Regular.ttf +0 -0
  159. package/skills/frontend-dev/canvas-fonts/Jura-Light.ttf +0 -0
  160. package/skills/frontend-dev/canvas-fonts/Jura-Medium.ttf +0 -0
  161. package/skills/frontend-dev/canvas-fonts/Jura-OFL.txt +93 -0
  162. package/skills/frontend-dev/canvas-fonts/LibreBaskerville-OFL.txt +93 -0
  163. package/skills/frontend-dev/canvas-fonts/LibreBaskerville-Regular.ttf +0 -0
  164. package/skills/frontend-dev/canvas-fonts/Lora-Bold.ttf +0 -0
  165. package/skills/frontend-dev/canvas-fonts/Lora-BoldItalic.ttf +0 -0
  166. package/skills/frontend-dev/canvas-fonts/Lora-Italic.ttf +0 -0
  167. package/skills/frontend-dev/canvas-fonts/Lora-OFL.txt +93 -0
  168. package/skills/frontend-dev/canvas-fonts/Lora-Regular.ttf +0 -0
  169. package/skills/frontend-dev/canvas-fonts/NationalPark-Bold.ttf +0 -0
  170. package/skills/frontend-dev/canvas-fonts/NationalPark-OFL.txt +93 -0
  171. package/skills/frontend-dev/canvas-fonts/NationalPark-Regular.ttf +0 -0
  172. package/skills/frontend-dev/canvas-fonts/NothingYouCouldDo-OFL.txt +93 -0
  173. package/skills/frontend-dev/canvas-fonts/NothingYouCouldDo-Regular.ttf +0 -0
  174. package/skills/frontend-dev/canvas-fonts/Outfit-Bold.ttf +0 -0
  175. package/skills/frontend-dev/canvas-fonts/Outfit-OFL.txt +93 -0
  176. package/skills/frontend-dev/canvas-fonts/Outfit-Regular.ttf +0 -0
  177. package/skills/frontend-dev/canvas-fonts/PixelifySans-Medium.ttf +0 -0
  178. package/skills/frontend-dev/canvas-fonts/PixelifySans-OFL.txt +93 -0
  179. package/skills/frontend-dev/canvas-fonts/PoiretOne-OFL.txt +93 -0
  180. package/skills/frontend-dev/canvas-fonts/PoiretOne-Regular.ttf +0 -0
  181. package/skills/frontend-dev/canvas-fonts/RedHatMono-Bold.ttf +0 -0
  182. package/skills/frontend-dev/canvas-fonts/RedHatMono-OFL.txt +93 -0
  183. package/skills/frontend-dev/canvas-fonts/RedHatMono-Regular.ttf +0 -0
  184. package/skills/frontend-dev/canvas-fonts/Silkscreen-OFL.txt +93 -0
  185. package/skills/frontend-dev/canvas-fonts/Silkscreen-Regular.ttf +0 -0
  186. package/skills/frontend-dev/canvas-fonts/SmoochSans-Medium.ttf +0 -0
  187. package/skills/frontend-dev/canvas-fonts/SmoochSans-OFL.txt +93 -0
  188. package/skills/frontend-dev/canvas-fonts/Tektur-Medium.ttf +0 -0
  189. package/skills/frontend-dev/canvas-fonts/Tektur-OFL.txt +93 -0
  190. package/skills/frontend-dev/canvas-fonts/Tektur-Regular.ttf +0 -0
  191. package/skills/frontend-dev/canvas-fonts/WorkSans-Bold.ttf +0 -0
  192. package/skills/frontend-dev/canvas-fonts/WorkSans-BoldItalic.ttf +0 -0
  193. package/skills/frontend-dev/canvas-fonts/WorkSans-Italic.ttf +0 -0
  194. package/skills/frontend-dev/canvas-fonts/WorkSans-OFL.txt +93 -0
  195. package/skills/frontend-dev/canvas-fonts/WorkSans-Regular.ttf +0 -0
  196. package/skills/frontend-dev/canvas-fonts/YoungSerif-OFL.txt +93 -0
  197. package/skills/frontend-dev/canvas-fonts/YoungSerif-Regular.ttf +0 -0
  198. package/skills/frontend-dev/references/asset-prompt-guide.md +43 -0
  199. package/skills/frontend-dev/references/env-setup.md +33 -0
  200. package/skills/frontend-dev/references/minimax-cli-reference.md +133 -0
  201. package/skills/frontend-dev/references/minimax-image-guide.md +65 -0
  202. package/skills/frontend-dev/references/minimax-music-guide.md +216 -0
  203. package/skills/frontend-dev/references/minimax-tts-guide.md +78 -0
  204. package/skills/frontend-dev/references/minimax-video-guide.md +82 -0
  205. package/skills/frontend-dev/references/minimax-voice-catalog.md +685 -0
  206. package/skills/frontend-dev/references/motion-recipes.md +407 -0
  207. package/skills/frontend-dev/references/troubleshooting.md +85 -0
  208. package/skills/frontend-dev/scripts/minimax_image.py +137 -0
  209. package/skills/frontend-dev/scripts/minimax_music.py +157 -0
  210. package/skills/frontend-dev/scripts/minimax_tts.py +127 -0
  211. package/skills/frontend-dev/scripts/minimax_video.py +187 -0
  212. package/skills/frontend-dev/templates/generator_template.js +223 -0
  213. package/skills/frontend-dev/templates/viewer.html +599 -0
  214. package/skills/frontend-ui-engineering/SKILL.md +367 -0
  215. package/skills/fullstack-dev/SKILL.md +819 -0
  216. package/skills/fullstack-dev/references/api-design.md +444 -0
  217. package/skills/fullstack-dev/references/auth-flow.md +165 -0
  218. package/skills/fullstack-dev/references/db-schema.md +706 -0
  219. package/skills/fullstack-dev/references/django-best-practices.md +466 -0
  220. package/skills/fullstack-dev/references/environment-management.md +78 -0
  221. package/skills/fullstack-dev/references/release-checklist.md +278 -0
  222. package/skills/fullstack-dev/references/technology-selection.md +254 -0
  223. package/skills/fullstack-dev/references/testing-strategy.md +404 -0
  224. package/skills/git-workflow-and-versioning/SKILL.md +446 -0
  225. package/skills/github-evidence-triage/SKILL.md +115 -0
  226. package/skills/harness-evolution/SKILL.md +59 -0
  227. package/skills/harness-evolution/references/activation-matrix.md +13 -0
  228. package/skills/harness-evolution/references/approval-policy.md +20 -0
  229. package/skills/harness-evolution/references/change-report-template.md +33 -0
  230. package/skills/harness-evolution/references/component-taxonomy.md +19 -0
  231. package/skills/harness-evolution/references/verdict-policy.md +13 -0
  232. package/skills/harness-issue-triage/SKILL.md +72 -0
  233. package/skills/harness-issue-triage/references/component-diagnosis.md +25 -0
  234. package/skills/harness-issue-triage/references/triage-report-template.md +34 -0
  235. package/skills/harness-optimization-audit/SKILL.md +125 -0
  236. package/skills/idea-refine/SKILL.md +191 -0
  237. package/skills/idea-refine/references/upstream/addyosmani-agent-skills/6bcfeb9dae52b11eaad23511acc165109746dbc3/LICENSE +21 -0
  238. package/skills/idea-refine/references/upstream/addyosmani-agent-skills/6bcfeb9dae52b11eaad23511acc165109746dbc3/NOTICE.md +9 -0
  239. package/skills/idea-refine/references/upstream/addyosmani-agent-skills/6bcfeb9dae52b11eaad23511acc165109746dbc3/idea-refine/SKILL.upstream.md +178 -0
  240. package/skills/idea-refine/references/upstream/addyosmani-agent-skills/6bcfeb9dae52b11eaad23511acc165109746dbc3/idea-refine/examples.md +238 -0
  241. package/skills/idea-refine/references/upstream/addyosmani-agent-skills/6bcfeb9dae52b11eaad23511acc165109746dbc3/idea-refine/frameworks.md +99 -0
  242. package/skills/idea-refine/references/upstream/addyosmani-agent-skills/6bcfeb9dae52b11eaad23511acc165109746dbc3/idea-refine/refinement-criteria.md +113 -0
  243. package/skills/idea-refine/references/upstream/addyosmani-agent-skills/6bcfeb9dae52b11eaad23511acc165109746dbc3/idea-refine/scripts/idea-refine.upstream.sh +15 -0
  244. package/skills/incremental-implementation/SKILL.md +252 -0
  245. package/skills/ios-application-dev/SKILL.md +212 -0
  246. package/skills/ios-application-dev/references/accessibility.md +259 -0
  247. package/skills/ios-application-dev/references/graphics-animation.md +350 -0
  248. package/skills/ios-application-dev/references/layout-system.md +199 -0
  249. package/skills/ios-application-dev/references/metal-shader.md +178 -0
  250. package/skills/ios-application-dev/references/navigation-patterns.md +175 -0
  251. package/skills/ios-application-dev/references/swift-coding-standards.md +757 -0
  252. package/skills/ios-application-dev/references/swiftui-design-guidelines.md +1167 -0
  253. package/skills/ios-application-dev/references/system-integration.md +401 -0
  254. package/skills/ios-application-dev/references/uikit-components.md +297 -0
  255. package/skills/local-review-gate/SKILL.md +207 -0
  256. package/skills/local-review-gate/references/addyosmani-code-review-rubric.md +33 -0
  257. package/skills/local-review-gate/references/codex-github-compatibility.md +26 -0
  258. package/skills/local-review-gate/references/ecc-code-review-adaptation.md +40 -0
  259. package/skills/local-review-gate/references/graphify-local-review.md +33 -0
  260. package/skills/local-review-gate/references/orchestration-adaptation.md +51 -0
  261. package/skills/local-review-gate/references/review-repair-lane-adaptation.md +46 -0
  262. package/skills/local-review-gate/references/upstream-provenance.md +61 -0
  263. package/skills/mature-project-pattern-research/SKILL.md +155 -0
  264. package/skills/mature-project-pattern-research/references/research-rubric.md +45 -0
  265. package/skills/minimax-docx/LICENSE +21 -0
  266. package/skills/minimax-docx/SKILL.md +273 -0
  267. package/skills/minimax-docx/assets/styles/academic_styles.xml +250 -0
  268. package/skills/minimax-docx/assets/styles/corporate_styles.xml +284 -0
  269. package/skills/minimax-docx/assets/styles/default_styles.xml +449 -0
  270. package/skills/minimax-docx/assets/xsd/aesthetic-rules.xsd +470 -0
  271. package/skills/minimax-docx/assets/xsd/business-rules.xsd +130 -0
  272. package/skills/minimax-docx/assets/xsd/common-types.xsd +159 -0
  273. package/skills/minimax-docx/assets/xsd/wml-subset.xsd +589 -0
  274. package/skills/minimax-docx/references/cjk_typography.md +357 -0
  275. package/skills/minimax-docx/references/cjk_university_template_guide.md +184 -0
  276. package/skills/minimax-docx/references/comments_guide.md +191 -0
  277. package/skills/minimax-docx/references/design_good_bad_examples.md +829 -0
  278. package/skills/minimax-docx/references/design_principles.md +819 -0
  279. package/skills/minimax-docx/references/openxml_element_order.md +308 -0
  280. package/skills/minimax-docx/references/openxml_encyclopedia_part1.md +4061 -0
  281. package/skills/minimax-docx/references/openxml_encyclopedia_part2.md +2820 -0
  282. package/skills/minimax-docx/references/openxml_encyclopedia_part3.md +3381 -0
  283. package/skills/minimax-docx/references/openxml_namespaces.md +82 -0
  284. package/skills/minimax-docx/references/openxml_units.md +72 -0
  285. package/skills/minimax-docx/references/scenario_a_create.md +284 -0
  286. package/skills/minimax-docx/references/scenario_b_edit_content.md +295 -0
  287. package/skills/minimax-docx/references/scenario_c_apply_template.md +456 -0
  288. package/skills/minimax-docx/references/track_changes_guide.md +200 -0
  289. package/skills/minimax-docx/references/troubleshooting.md +506 -0
  290. package/skills/minimax-docx/references/typography_guide.md +294 -0
  291. package/skills/minimax-docx/references/xsd_validation_guide.md +158 -0
  292. package/skills/minimax-docx/scripts/doc_to_docx.sh +40 -0
  293. package/skills/minimax-docx/scripts/docx_preview.sh +37 -0
  294. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Cli/MiniMaxAIDocx.Cli.csproj +19 -0
  295. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Cli/Program.cs +18 -0
  296. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/AnalyzeCommand.cs +147 -0
  297. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/ApplyTemplateCommand.cs +322 -0
  298. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/CreateCommand.cs +324 -0
  299. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/DiffCommand.cs +155 -0
  300. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/EditContentCommand.cs +487 -0
  301. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/FixOrderCommand.cs +108 -0
  302. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/MergeRunsCommand.cs +122 -0
  303. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/ValidateCommand.cs +107 -0
  304. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/MiniMaxAIDocx.Core.csproj +15 -0
  305. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/CommentSynchronizer.cs +169 -0
  306. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/ElementOrder.cs +80 -0
  307. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/NamespaceConstants.cs +42 -0
  308. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/RunMerger.cs +81 -0
  309. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/StyleAnalyzer.cs +81 -0
  310. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/TrackChangesHelper.cs +99 -0
  311. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/UnitConverter.cs +23 -0
  312. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/AestheticRecipeSamples.cs +1832 -0
  313. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/AestheticRecipeSamples_Batch1.cs +910 -0
  314. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/AestheticRecipeSamples_Batch2.cs +999 -0
  315. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/AestheticRecipeSamples_Batch3.cs +1048 -0
  316. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/AestheticRecipeSamples_Batch4.cs +1038 -0
  317. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/CharacterFormattingSamples.cs +1020 -0
  318. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/DocumentCreationSamples.cs +1121 -0
  319. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/FieldAndTocSamples.cs +624 -0
  320. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/FootnoteAndCommentSamples.cs +675 -0
  321. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/HeaderFooterSamples.cs +838 -0
  322. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/ImageSamples.cs +917 -0
  323. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/ListAndNumberingSamples.cs +826 -0
  324. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/ParagraphFormattingSamples.cs +1199 -0
  325. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/StyleSystemSamples.cs +1487 -0
  326. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/TableSamples.cs +1163 -0
  327. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/TrackChangesSamples.cs +595 -0
  328. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Typography/CjkHelper.cs +39 -0
  329. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Typography/FontDefaults.cs +24 -0
  330. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Typography/PageSizes.cs +20 -0
  331. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Validation/BusinessRuleValidator.cs +224 -0
  332. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Validation/GateCheckValidator.cs +148 -0
  333. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Validation/ValidationResult.cs +23 -0
  334. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Validation/XsdValidator.cs +69 -0
  335. package/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.slnx +4 -0
  336. package/skills/minimax-docx/scripts/env_check.sh +196 -0
  337. package/skills/minimax-docx/scripts/setup.ps1 +274 -0
  338. package/skills/minimax-docx/scripts/setup.sh +504 -0
  339. package/skills/minimax-pdf/README.md +222 -0
  340. package/skills/minimax-pdf/SKILL.md +218 -0
  341. package/skills/minimax-pdf/design/design.md +381 -0
  342. package/skills/minimax-pdf/scripts/cover.py +1579 -0
  343. package/skills/minimax-pdf/scripts/fill_inspect.py +200 -0
  344. package/skills/minimax-pdf/scripts/fill_write.py +242 -0
  345. package/skills/minimax-pdf/scripts/make.sh +491 -0
  346. package/skills/minimax-pdf/scripts/merge.py +112 -0
  347. package/skills/minimax-pdf/scripts/palette.py +521 -0
  348. package/skills/minimax-pdf/scripts/reformat_parse.py +374 -0
  349. package/skills/minimax-pdf/scripts/render_body.py +1052 -0
  350. package/skills/minimax-pdf/scripts/render_cover.js +111 -0
  351. package/skills/minimax-xlsx/SKILL.md +156 -0
  352. package/skills/minimax-xlsx/references/create.md +691 -0
  353. package/skills/minimax-xlsx/references/edit.md +684 -0
  354. package/skills/minimax-xlsx/references/fix.md +37 -0
  355. package/skills/minimax-xlsx/references/format.md +768 -0
  356. package/skills/minimax-xlsx/references/ooxml-cheatsheet.md +231 -0
  357. package/skills/minimax-xlsx/references/read-analyze.md +97 -0
  358. package/skills/minimax-xlsx/references/validate.md +772 -0
  359. package/skills/minimax-xlsx/scripts/formula_check.py +422 -0
  360. package/skills/minimax-xlsx/scripts/libreoffice_recalc.py +248 -0
  361. package/skills/minimax-xlsx/scripts/shared_strings_builder.py +163 -0
  362. package/skills/minimax-xlsx/scripts/style_audit.py +575 -0
  363. package/skills/minimax-xlsx/scripts/xlsx_add_column.py +395 -0
  364. package/skills/minimax-xlsx/scripts/xlsx_insert_row.py +274 -0
  365. package/skills/minimax-xlsx/scripts/xlsx_pack.py +87 -0
  366. package/skills/minimax-xlsx/scripts/xlsx_reader.py +362 -0
  367. package/skills/minimax-xlsx/scripts/xlsx_shift_rows.py +396 -0
  368. package/skills/minimax-xlsx/scripts/xlsx_unpack.py +130 -0
  369. package/skills/minimax-xlsx/templates/minimal_xlsx/[Content_Types].xml +9 -0
  370. package/skills/minimax-xlsx/templates/minimal_xlsx/_rels/.rels +6 -0
  371. package/skills/minimax-xlsx/templates/minimal_xlsx/xl/_rels/workbook.xml.rels +19 -0
  372. package/skills/minimax-xlsx/templates/minimal_xlsx/xl/sharedStrings.xml +33 -0
  373. package/skills/minimax-xlsx/templates/minimal_xlsx/xl/styles.xml +160 -0
  374. package/skills/minimax-xlsx/templates/minimal_xlsx/xl/workbook.xml +30 -0
  375. package/skills/minimax-xlsx/templates/minimal_xlsx/xl/worksheets/sheet1.xml +70 -0
  376. package/skills/newsletter-generation/SKILL.md +71 -0
  377. package/skills/oss-release-readiness/SKILL.md +47 -0
  378. package/skills/parallel-subagent-dispatch/SKILL.md +58 -0
  379. package/skills/performance-optimization/SKILL.md +364 -0
  380. package/skills/planning-and-task-breakdown/SKILL.md +290 -0
  381. package/skills/pptx-generator/SKILL.md +275 -0
  382. package/skills/pptx-generator/references/design-system.md +392 -0
  383. package/skills/pptx-generator/references/editing.md +162 -0
  384. package/skills/pptx-generator/references/pitfalls.md +112 -0
  385. package/skills/pptx-generator/references/pptxgenjs.md +420 -0
  386. package/skills/pptx-generator/references/slide-types.md +413 -0
  387. package/skills/pr-test-analysis/SKILL.md +24 -0
  388. package/skills/react-native-dev/SKILL.md +180 -0
  389. package/skills/react-native-dev/references/animations.md +254 -0
  390. package/skills/react-native-dev/references/components.md +124 -0
  391. package/skills/react-native-dev/references/engineering.md +527 -0
  392. package/skills/react-native-dev/references/forms.md +300 -0
  393. package/skills/react-native-dev/references/native-capabilities.md +163 -0
  394. package/skills/react-native-dev/references/navigation.md +271 -0
  395. package/skills/react-native-dev/references/networking.md +346 -0
  396. package/skills/react-native-dev/references/performance.md +215 -0
  397. package/skills/react-native-dev/references/state-management.md +230 -0
  398. package/skills/react-native-dev/references/styling.md +117 -0
  399. package/skills/react-native-dev/references/testing.md +341 -0
  400. package/skills/requirements-grilling/SKILL.md +447 -0
  401. package/skills/requirements-grilling/references/ADR-FORMAT.md +46 -0
  402. package/skills/requirements-grilling/references/CONTEXT-FORMAT.md +41 -0
  403. package/skills/requirements-grilling/references/INTERVIEW-PACKET-FORMAT.md +62 -0
  404. package/skills/requirements-grilling/references/MIT-LICENSE-MATT-POCOCK.md +25 -0
  405. package/skills/requirements-grilling/references/upstream/addyosmani-agent-skills/6bcfeb9dae52b11eaad23511acc165109746dbc3/LICENSE +21 -0
  406. package/skills/requirements-grilling/references/upstream/addyosmani-agent-skills/6bcfeb9dae52b11eaad23511acc165109746dbc3/NOTICE.md +9 -0
  407. package/skills/requirements-grilling/references/upstream/addyosmani-agent-skills/6bcfeb9dae52b11eaad23511acc165109746dbc3/interview-me/SKILL.upstream.md +225 -0
  408. package/skills/requirements-grilling/references/upstream/mattpocock-skills/9603c1cc8118d08bc1b3bf34cf714f62178dea3b/LICENSE +21 -0
  409. package/skills/requirements-grilling/references/upstream/mattpocock-skills/9603c1cc8118d08bc1b3bf34cf714f62178dea3b/NOTICE.md +12 -0
  410. package/skills/requirements-grilling/references/upstream/mattpocock-skills/9603c1cc8118d08bc1b3bf34cf714f62178dea3b/batch-grill-me/SKILL.upstream.md +15 -0
  411. package/skills/requirements-grilling/references/upstream/mattpocock-skills/9603c1cc8118d08bc1b3bf34cf714f62178dea3b/grill-me/SKILL.upstream.md +7 -0
  412. package/skills/requirements-grilling/references/upstream/mattpocock-skills/9603c1cc8118d08bc1b3bf34cf714f62178dea3b/grilling/SKILL.upstream.md +12 -0
  413. package/skills/review-pipeline/SKILL.md +38 -0
  414. package/skills/rose-memory/SKILL.md +210 -0
  415. package/skills/rose-memory/references/README.md +48 -0
  416. package/skills/rose-memory/references/memory_cli.py +2384 -0
  417. package/skills/rose-memory/references/schema.sql +315 -0
  418. package/skills/security-and-hardening/SKILL.md +369 -0
  419. package/skills/session-handoff/SKILL.md +88 -0
  420. package/skills/session-handoff/references/upstream/mattpocock-skills/391a2701dd948f94f56a39f7533f8eea9a859c87/LICENSE +21 -0
  421. package/skills/session-handoff/references/upstream/mattpocock-skills/391a2701dd948f94f56a39f7533f8eea9a859c87/NOTICE.md +9 -0
  422. package/skills/session-handoff/references/upstream/mattpocock-skills/391a2701dd948f94f56a39f7533f8eea9a859c87/productivity/handoff/SKILL.upstream.md +16 -0
  423. package/skills/session-handoff/scripts/session_handoff.py +764 -0
  424. package/skills/shader-dev/SKILL.md +316 -0
  425. package/skills/shader-dev/reference/ambient-occlusion.md +382 -0
  426. package/skills/shader-dev/reference/analytic-ray-tracing.md +651 -0
  427. package/skills/shader-dev/reference/anti-aliasing.md +71 -0
  428. package/skills/shader-dev/reference/atmospheric-scattering.md +571 -0
  429. package/skills/shader-dev/reference/camera-effects.md +80 -0
  430. package/skills/shader-dev/reference/cellular-automata.md +635 -0
  431. package/skills/shader-dev/reference/color-palette.md +481 -0
  432. package/skills/shader-dev/reference/csg-boolean-operations.md +466 -0
  433. package/skills/shader-dev/reference/domain-repetition.md +436 -0
  434. package/skills/shader-dev/reference/domain-warping.md +419 -0
  435. package/skills/shader-dev/reference/fluid-simulation.md +425 -0
  436. package/skills/shader-dev/reference/fractal-rendering.md +525 -0
  437. package/skills/shader-dev/reference/lighting-model.md +639 -0
  438. package/skills/shader-dev/reference/matrix-transform.md +535 -0
  439. package/skills/shader-dev/reference/multipass-buffer.md +571 -0
  440. package/skills/shader-dev/reference/normal-estimation.md +418 -0
  441. package/skills/shader-dev/reference/particle-system.md +589 -0
  442. package/skills/shader-dev/reference/path-tracing-gi.md +602 -0
  443. package/skills/shader-dev/reference/polar-uv-manipulation.md +521 -0
  444. package/skills/shader-dev/reference/post-processing.md +375 -0
  445. package/skills/shader-dev/reference/procedural-2d-pattern.md +439 -0
  446. package/skills/shader-dev/reference/procedural-noise.md +551 -0
  447. package/skills/shader-dev/reference/ray-marching.md +396 -0
  448. package/skills/shader-dev/reference/sdf-2d.md +724 -0
  449. package/skills/shader-dev/reference/sdf-3d.md +805 -0
  450. package/skills/shader-dev/reference/sdf-tricks.md +63 -0
  451. package/skills/shader-dev/reference/shadow-techniques.md +476 -0
  452. package/skills/shader-dev/reference/simulation-physics.md +644 -0
  453. package/skills/shader-dev/reference/sound-synthesis.md +578 -0
  454. package/skills/shader-dev/reference/terrain-rendering.md +839 -0
  455. package/skills/shader-dev/reference/texture-mapping-advanced.md +87 -0
  456. package/skills/shader-dev/reference/texture-sampling.md +553 -0
  457. package/skills/shader-dev/reference/volumetric-rendering.md +608 -0
  458. package/skills/shader-dev/reference/voronoi-cellular-noise.md +486 -0
  459. package/skills/shader-dev/reference/voxel-rendering.md +701 -0
  460. package/skills/shader-dev/reference/water-ocean.md +445 -0
  461. package/skills/shader-dev/reference/webgl-pitfalls.md +41 -0
  462. package/skills/shader-dev/techniques/ambient-occlusion.md +364 -0
  463. package/skills/shader-dev/techniques/analytic-ray-tracing.md +542 -0
  464. package/skills/shader-dev/techniques/anti-aliasing.md +124 -0
  465. package/skills/shader-dev/techniques/atmospheric-scattering.md +522 -0
  466. package/skills/shader-dev/techniques/camera-effects.md +115 -0
  467. package/skills/shader-dev/techniques/cellular-automata.md +531 -0
  468. package/skills/shader-dev/techniques/color-palette.md +380 -0
  469. package/skills/shader-dev/techniques/csg-boolean-operations.md +491 -0
  470. package/skills/shader-dev/techniques/domain-repetition.md +333 -0
  471. package/skills/shader-dev/techniques/domain-warping.md +414 -0
  472. package/skills/shader-dev/techniques/fluid-simulation.md +1175 -0
  473. package/skills/shader-dev/techniques/fractal-rendering.md +436 -0
  474. package/skills/shader-dev/techniques/lighting-model.md +527 -0
  475. package/skills/shader-dev/techniques/matrix-transform.md +455 -0
  476. package/skills/shader-dev/techniques/multipass-buffer.md +922 -0
  477. package/skills/shader-dev/techniques/normal-estimation.md +318 -0
  478. package/skills/shader-dev/techniques/particle-system.md +1203 -0
  479. package/skills/shader-dev/techniques/path-tracing-gi.md +623 -0
  480. package/skills/shader-dev/techniques/polar-uv-manipulation.md +373 -0
  481. package/skills/shader-dev/techniques/post-processing.md +788 -0
  482. package/skills/shader-dev/techniques/procedural-2d-pattern.md +346 -0
  483. package/skills/shader-dev/techniques/procedural-noise.md +554 -0
  484. package/skills/shader-dev/techniques/ray-marching.md +467 -0
  485. package/skills/shader-dev/techniques/sdf-2d.md +631 -0
  486. package/skills/shader-dev/techniques/sdf-3d.md +589 -0
  487. package/skills/shader-dev/techniques/sdf-tricks.md +100 -0
  488. package/skills/shader-dev/techniques/shadow-techniques.md +776 -0
  489. package/skills/shader-dev/techniques/simulation-physics.md +1542 -0
  490. package/skills/shader-dev/techniques/sound-synthesis.md +490 -0
  491. package/skills/shader-dev/techniques/terrain-rendering.md +408 -0
  492. package/skills/shader-dev/techniques/texture-mapping-advanced.md +121 -0
  493. package/skills/shader-dev/techniques/texture-sampling.md +382 -0
  494. package/skills/shader-dev/techniques/volumetric-rendering.md +375 -0
  495. package/skills/shader-dev/techniques/voronoi-cellular-noise.md +458 -0
  496. package/skills/shader-dev/techniques/voxel-rendering.md +985 -0
  497. package/skills/shader-dev/techniques/water-ocean.md +490 -0
  498. package/skills/shader-dev/techniques/webgl-pitfalls.md +170 -0
  499. package/skills/shipping-and-launch/SKILL.md +334 -0
  500. package/skills/silent-failure-hunting/SKILL.md +24 -0
  501. package/skills/source-driven-development/SKILL.md +223 -0
  502. package/skills/spec-driven-development/SKILL.md +235 -0
  503. package/skills/spec-driven-development/references/upstream/addyosmani-agent-skills/6bcfeb9dae52b11eaad23511acc165109746dbc3/LICENSE +21 -0
  504. package/skills/spec-driven-development/references/upstream/addyosmani-agent-skills/6bcfeb9dae52b11eaad23511acc165109746dbc3/NOTICE.md +9 -0
  505. package/skills/spec-driven-development/references/upstream/addyosmani-agent-skills/6bcfeb9dae52b11eaad23511acc165109746dbc3/spec-driven-development/SKILL.upstream.md +206 -0
  506. package/skills/strategy-stress-test/SKILL.md +185 -0
  507. package/skills/systematic-literature-review/SKILL.md +77 -0
  508. package/skills/test-document-generator/SKILL.md +152 -0
  509. package/skills/test-document-generator/references/test-document-template.md +45 -0
  510. package/skills/test-driven-development/SKILL.md +399 -0
  511. package/skills/write-skills/GLOSSARY.md +113 -0
  512. package/skills/write-skills/SKILL.md +133 -0
  513. package/skills/write-skills/references/upstream/mattpocock-skills/391a2701dd948f94f56a39f7533f8eea9a859c87/LICENSE +21 -0
  514. package/skills/write-skills/references/upstream/mattpocock-skills/391a2701dd948f94f56a39f7533f8eea9a859c87/NOTICE.md +9 -0
  515. package/skills/write-skills/references/upstream/mattpocock-skills/391a2701dd948f94f56a39f7533f8eea9a859c87/productivity/writing-great-skills/GLOSSARY.md +201 -0
  516. package/skills/write-skills/references/upstream/mattpocock-skills/391a2701dd948f94f56a39f7533f8eea9a859c87/productivity/writing-great-skills/SKILL.upstream.md +83 -0
  517. package/src/runtime/child-guard.ts +70 -0
  518. package/src/runtime/conflicts.ts +25 -0
  519. package/src/runtime/contracts.ts +9 -0
  520. package/src/runtime/doctor.ts +134 -0
  521. package/src/runtime/global-resources.ts +152 -0
  522. package/src/runtime/index.ts +23 -0
  523. package/src/runtime/lifecycle.ts +19 -0
  524. package/src/runtime/native-integrations.ts +44 -0
  525. package/src/runtime/path-boundaries.ts +69 -0
  526. package/src/runtime/registry.ts +213 -0
  527. package/src/runtime/roles.ts +64 -0
  528. package/src/runtime/rose-context.ts +24 -0
  529. package/src/runtime/subagents.ts +426 -0
  530. package/templates/APPEND_SYSTEM.md +12 -0
  531. package/upstream/aili-workflows.lock.json +3226 -0
@@ -0,0 +1,805 @@
1
+ # 3D Signed Distance Fields (3D SDF) — Detailed Reference
2
+
3
+ This document is a detailed supplement to [SKILL.md](SKILL.md), covering prerequisites, step-by-step explanations, mathematical derivations, and advanced usage.
4
+
5
+ ## Prerequisites
6
+
7
+ - **GLSL Basics**: uniform variables (`iTime`, `iResolution`, `iMouse`), `fragCoord` coordinate system
8
+ - **Vector Math**: built-in functions like `dot`, `cross`, `normalize`, `length`, `reflect`
9
+ - **Rays and Cameras**: understanding how to generate rays from screen pixels (ray origin + ray direction)
10
+ - **Implicit Surface Concept**: f(p) = 0 defines the surface, f(p) > 0 is outside, f(p) < 0 is inside
11
+
12
+ ## Step-by-Step Detailed Explanation
13
+
14
+ ### Step 1: SDF Primitive Library
15
+
16
+ **What**: Define basic geometric distance functions.
17
+
18
+ **Why**: All SDF scenes are composed of basic primitives. Each primitive is a pure function that takes a point in space and returns the shortest distance to that primitive's surface. The accuracy of these primitives directly determines the efficiency of sphere tracing — accurate SDFs allow larger step sizes.
19
+
20
+ **Code**:
21
+
22
+ ```glsl
23
+ // Sphere: p=sample point, r=radius
24
+ float sdSphere(vec3 p, float r) {
25
+ return length(p) - r;
26
+ }
27
+
28
+ // Box: p=sample point, b=half-size (xyz dimensions)
29
+ float sdBox(vec3 p, vec3 b) {
30
+ vec3 d = abs(p) - b;
31
+ return min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0));
32
+ }
33
+
34
+ // Ellipsoid (approximate): p=sample point, r=three-axis radii
35
+ float sdEllipsoid(vec3 p, vec3 r) {
36
+ float k0 = length(p / r);
37
+ float k1 = length(p / (r * r));
38
+ return k0 * (k0 - 1.0) / k1;
39
+ }
40
+
41
+ // Torus: p=sample point, t.x=major radius, t.y=tube radius
42
+ float sdTorus(vec3 p, vec2 t) {
43
+ return length(vec2(length(p.xz) - t.x, p.y)) - t.y;
44
+ }
45
+
46
+ // Capsule (two endpoints + radius): useful for skeleton/limb modeling
47
+ float sdCapsule(vec3 p, vec3 a, vec3 b, float r) {
48
+ vec3 pa = p - a, ba = b - a;
49
+ float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
50
+ return length(pa - ba * h) - r;
51
+ }
52
+
53
+ // Cylinder (vertical): h.x=radius, h.y=half-height
54
+ float sdCylinder(vec3 p, vec2 h) {
55
+ vec2 d = abs(vec2(length(p.xz), p.y)) - h;
56
+ return min(max(d.x, d.y), 0.0) + length(max(d, 0.0));
57
+ }
58
+
59
+ // Plane (y=0)
60
+ float sdPlane(vec3 p) {
61
+ return p.y;
62
+ }
63
+ ```
64
+
65
+ ### Step 2: Boolean Operations and Smooth Blending
66
+
67
+ **What**: Define combination operations between primitives — union, subtraction, intersection, and their smooth variants.
68
+
69
+ **Why**: Union merges multiple primitives into one scene; subtraction carves one object out of another; intersection keeps the overlapping region. Smooth variants (`smin`/`smax`) use a control parameter `k` to produce smooth blend transitions — one of SDF's most powerful capabilities over traditional modeling, achieving organic forms without additional geometry.
70
+
71
+ **Code**:
72
+
73
+ ```glsl
74
+ // === Hard Boolean Operations ===
75
+
76
+ // Union: take the nearer surface
77
+ float opUnion(float d1, float d2) { return min(d1, d2); }
78
+
79
+ // Subtraction: subtract d2 from d1
80
+ float opSubtraction(float d1, float d2) { return max(d1, -d2); }
81
+
82
+ // Intersection: keep the overlapping region
83
+ float opIntersection(float d1, float d2) { return max(d1, d2); }
84
+
85
+ // Union with material ID (vec2.x stores distance, vec2.y stores material ID)
86
+ vec2 opU(vec2 d1, vec2 d2) { return (d1.x < d2.x) ? d1 : d2; }
87
+
88
+ // === Smooth Boolean Operations ===
89
+
90
+ // Smooth union: k=blend radius (larger = smoother, typical values 0.1~0.5)
91
+ float smin(float a, float b, float k) {
92
+ float h = max(k - abs(a - b), 0.0);
93
+ return min(a, b) - h * h * 0.25 / k;
94
+ }
95
+ // vec2 version of smin: for smooth blending of vec2(distance, materialID)
96
+ vec2 smin(vec2 a, vec2 b, float k) {
97
+ float h = max(k - abs(a.x - b.x), 0.0);
98
+ float d = min(a.x, b.x) - h * h * 0.25 / k;
99
+ float m = (a.x < b.x) ? a.y : b.y;
100
+ return vec2(d, m);
101
+ }
102
+
103
+ // Smooth subtraction / smooth max
104
+ float smax(float a, float b, float k) {
105
+ float h = max(k - abs(a - b), 0.0);
106
+ return max(a, b) + h * h * 0.25 / k;
107
+ }
108
+ ```
109
+
110
+ ### Step 3: Scene Definition (map Function)
111
+
112
+ **What**: Write the `map()` function that combines the above primitives and operations into a complete 3D scene.
113
+
114
+ **Why**: `map(p)` is the core of the SDF rendering pipeline — it returns the distance from any point p in space to the nearest scene surface (plus optional material information). Ray marching, normal computation, shadows, and AO all depend on this function. All geometric complexity of the scene is encapsulated here.
115
+
116
+ **Code**:
117
+
118
+ ```glsl
119
+ // Returns vec2(distance, materialID)
120
+ vec2 map(vec3 p) {
121
+ // Ground
122
+ vec2 res = vec2(p.y, 0.0); // Material 0: ground
123
+
124
+ // Sphere (displaced to y=0.5)
125
+ float d1 = sdSphere(p - vec3(0.0, 0.5, 0.0), 0.4);
126
+ res = opU(res, vec2(d1, 1.0)); // Material 1: sphere
127
+
128
+ // Box
129
+ float d2 = sdBox(p - vec3(1.5, 0.4, 0.0), vec3(0.3, 0.4, 0.3));
130
+ res = opU(res, vec2(d2, 2.0)); // Material 2: box
131
+
132
+ // Blend two spheres with smin for organic blob effect
133
+ float d3 = sdSphere(p - vec3(-1.2, 0.5, 0.0), 0.3);
134
+ float d4 = sdSphere(p - vec3(-1.5, 0.8, 0.2), 0.25);
135
+ float dBlob = smin(d3, d4, 0.3);
136
+ res = opU(res, vec2(dBlob, 3.0)); // Material 3: blob
137
+
138
+ return res;
139
+ }
140
+ ```
141
+
142
+ ### Step 4: Raymarching
143
+
144
+ **What**: Implement the sphere tracing loop — cast a ray from the camera and step along the ray direction until hitting a surface or exceeding the maximum distance.
145
+
146
+ **Why**: Sphere tracing exploits the "safe distance" property of SDFs — the current SDF value tells us there is absolutely no surface within that radius, so we can safely advance that far. This is much more efficient than fixed-step volumetric ray marching, typically achieving precise results in 64-128 steps.
147
+
148
+ **Code**:
149
+
150
+ ```glsl
151
+ #define MAX_STEPS 128 // Adjustable: step count, 64=fast/coarse, 256=precise/slow
152
+ #define MAX_DIST 40.0 // Adjustable: max trace distance
153
+ #define SURF_DIST 0.0001 // Adjustable: surface detection threshold
154
+
155
+ vec2 raycast(vec3 ro, vec3 rd) {
156
+ vec2 res = vec2(-1.0, -1.0);
157
+ float t = 0.01;
158
+
159
+ for (int i = 0; i < MAX_STEPS && t < MAX_DIST; i++) {
160
+ vec2 h = map(ro + rd * t);
161
+ if (abs(h.x) < SURF_DIST * t) {
162
+ res = vec2(t, h.y);
163
+ break;
164
+ }
165
+ t += h.x; // Key: step distance = SDF value
166
+ }
167
+ return res; // .x=hit distance, .y=materialID; -1 means no hit
168
+ }
169
+ ```
170
+
171
+ ### Step 5: Normal Computation
172
+
173
+ **What**: Compute the surface normal at the hit point by taking the finite-difference gradient of the SDF.
174
+
175
+ **Why**: The gradient direction of the SDF is the surface normal direction. We use the tetrahedron trick (4 `map` calls) instead of central differences (6 calls), saving performance and avoiding compiler inline bloat from inlining `map()` multiple times.
176
+
177
+ **Code**:
178
+
179
+ ```glsl
180
+ // Tetrahedron normal computation (recommended, only 4 map calls)
181
+ vec3 calcNormal(vec3 pos) {
182
+ vec2 e = vec2(1.0, -1.0) * 0.5773 * 0.0005; // Adjustable: epsilon
183
+ return normalize(
184
+ e.xyy * map(pos + e.xyy).x +
185
+ e.yyx * map(pos + e.yyx).x +
186
+ e.yxy * map(pos + e.yxy).x +
187
+ e.xxx * map(pos + e.xxx).x
188
+ );
189
+ }
190
+
191
+ // Anti-compiler-inline version (suitable for complex map functions)
192
+ // Uses a loop to prevent compiler unrolling, uses a loop to prevent compiler unrolling
193
+ #define ZERO (min(iFrame, 0))
194
+ vec3 calcNormalLoop(vec3 pos) {
195
+ vec3 n = vec3(0.0);
196
+ for (int i = ZERO; i < 4; i++) {
197
+ vec3 e = 0.5773 * (2.0 * vec3((((i+3)>>1)&1), ((i>>1)&1), (i&1)) - 1.0);
198
+ n += e * map(pos + 0.0005 * e).x;
199
+ }
200
+ return normalize(n);
201
+ }
202
+ ```
203
+
204
+ ### Step 6: Soft Shadows
205
+
206
+ **What**: Cast a secondary ray from the surface point toward the light source, and estimate shadow softness based on the minimum distance encountered along the way.
207
+
208
+ **Why**: Hard shadows only determine "occluded or not" (0/1), while SDF soft shadows use intermediate distance information to estimate "how close to being occluded." In the formula `k*h/t`, `k` controls shadow softness — larger `k` produces sharper shadows, smaller `k` produces softer shadows. This is one of SDF rendering's killer features.
209
+
210
+ **Code**:
211
+
212
+ ```glsl
213
+ // k=shadow sharpness (2=very soft, 32=near hard), mint=start offset, tmax=max distance
214
+ float calcSoftshadow(vec3 ro, vec3 rd, float mint, float tmax, float k) {
215
+ float res = 1.0;
216
+ float t = mint;
217
+ for (int i = 0; i < 24; i++) { // Adjustable: shadow step count
218
+ float h = map(ro + rd * t).x;
219
+ float s = clamp(k * h / t, 0.0, 1.0);
220
+ res = min(res, s);
221
+ t += clamp(h, 0.01, 0.2);
222
+ if (res < 0.004 || t > tmax) break;
223
+ }
224
+ res = clamp(res, 0.0, 1.0);
225
+ return res * res * (3.0 - 2.0 * res); // Smooth Hermite interpolation
226
+ }
227
+ ```
228
+
229
+ ### Step 7: Ambient Occlusion (AO)
230
+
231
+ **What**: Sample several points along the normal direction and compare actual SDF values with expected distances to estimate occlusion.
232
+
233
+ **Why**: SDFs naturally provide distance information for cheap AO approximation: if the SDF value at a sample point along the normal is much smaller than its distance to the surface, nearby occluding geometry exists. This method is more physically accurate than traditional SSAO and requires only 5 `map` calls.
234
+
235
+ **Code**:
236
+
237
+ ```glsl
238
+ float calcAO(vec3 pos, vec3 nor) {
239
+ float occ = 0.0;
240
+ float sca = 1.0;
241
+ for (int i = 0; i < 5; i++) { // Adjustable: number of sample layers
242
+ float h = 0.01 + 0.12 * float(i) / 4.0; // Adjustable: sample spacing
243
+ float d = map(pos + h * nor).x;
244
+ occ += (h - d) * sca;
245
+ sca *= 0.95;
246
+ }
247
+ return clamp(1.0 - 3.0 * occ, 0.0, 1.0);
248
+ }
249
+ ```
250
+
251
+ ### Step 8: Camera and Rendering Pipeline
252
+
253
+ **What**: Build a look-at camera matrix, generate screen rays, and chain together the entire rendering pipeline.
254
+
255
+ **Why**: Mapping screen pixels to 3D rays is the starting point of raymarching. The look-at matrix builds an orthonormal basis from the camera position, target point, and up direction, making camera control intuitive. The final pipeline chains all steps: ray generation, ray marching, normals, lighting/shadows/AO, and post-processing.
256
+
257
+ **Code**:
258
+
259
+ ```glsl
260
+ // Camera look-at matrix
261
+ mat3 setCamera(vec3 ro, vec3 ta, float cr) {
262
+ vec3 cw = normalize(ta - ro);
263
+ vec3 cp = vec3(sin(cr), cos(cr), 0.0);
264
+ vec3 cu = normalize(cross(cw, cp));
265
+ vec3 cv = cross(cu, cw);
266
+ return mat3(cu, cv, cw);
267
+ }
268
+
269
+ // Render: input ray, output color
270
+ vec3 render(vec3 ro, vec3 rd) {
271
+ // Background color (sky gradient)
272
+ vec3 col = vec3(0.7, 0.7, 0.9) - max(rd.y, 0.0) * 0.3;
273
+
274
+ // Raycast intersection
275
+ vec2 res = raycast(ro, rd);
276
+ float t = res.x;
277
+ float m = res.y; // Material ID
278
+
279
+ if (m > -0.5) {
280
+ vec3 pos = ro + t * rd;
281
+ vec3 nor = calcNormal(pos);
282
+
283
+ // Material color (varies by ID)
284
+ vec3 mate = 0.2 + 0.2 * sin(m * 2.0 + vec3(0.0, 1.0, 2.0));
285
+
286
+ // Lighting
287
+ vec3 lig = normalize(vec3(-0.5, 0.4, -0.6));
288
+ float dif = clamp(dot(nor, lig), 0.0, 1.0);
289
+ dif *= calcSoftshadow(pos, lig, 0.02, 2.5, 8.0);
290
+ float amb = 0.5 + 0.5 * nor.y;
291
+ float occ = calcAO(pos, nor);
292
+
293
+ col = mate * (dif * vec3(1.3, 1.0, 0.7) + amb * occ * vec3(0.4, 0.6, 1.0) * 0.6);
294
+
295
+ // Fog (exponential decay)
296
+ col = mix(col, vec3(0.7, 0.7, 0.9), 1.0 - exp(-0.0001 * t * t * t));
297
+ }
298
+
299
+ return clamp(col, 0.0, 1.0);
300
+ }
301
+ ```
302
+
303
+ ## Variant Detailed Descriptions
304
+
305
+ ### Variant 1: Dynamic Organic Body (Smooth Blob Animation)
306
+
307
+ **Difference from the basic version**: Replaces static primitives with multiple animated spheres blended via `smin`, producing lava/fluid-like organic effects. A common technique for organic fluid-like effects.
308
+
309
+ **Key modified code**:
310
+
311
+ ```glsl
312
+ // Replace scene definition in map()
313
+ vec2 map(vec3 p) {
314
+ float d = 2.0;
315
+ for (int i = 0; i < 16; i++) { // Adjustable: number of spheres
316
+ float fi = float(i);
317
+ float t = iTime * (fract(fi * 412.531 + 0.513) - 0.5) * 2.0;
318
+ d = smin(
319
+ sdSphere(p + sin(t + fi * vec3(52.5126, 64.627, 632.25)) * vec3(2.0, 2.0, 0.8),
320
+ mix(0.5, 1.0, fract(fi * 412.531 + 0.5124))),
321
+ d,
322
+ 0.4 // Adjustable: blend radius
323
+ );
324
+ }
325
+ return vec2(d, 1.0);
326
+ }
327
+ ```
328
+
329
+ ### Variant 2: Infinite Repeating Corridor (Domain Repetition)
330
+
331
+ **Difference from the basic version**: Uses `mod()` to repeat spatial coordinates infinitely. A common domain repetition technique. Can layer `hash()` to introduce random variation per repeating cell.
332
+
333
+ **Key modified code**:
334
+
335
+ ```glsl
336
+ // Linear domain repetition
337
+ float repeat(float v, float c) {
338
+ return mod(v, c) - c * 0.5;
339
+ }
340
+
341
+ // Angular domain repetition (repeat count times in polar coordinate direction)
342
+ float amod(inout vec2 p, float count) {
343
+ float an = 6.283185 / count;
344
+ float a = atan(p.y, p.x) + an * 0.5;
345
+ float c = floor(a / an);
346
+ a = mod(a, an) - an * 0.5;
347
+ p = vec2(cos(a), sin(a)) * length(p);
348
+ return c; // Returns sector index
349
+ }
350
+
351
+ vec2 map(vec3 p) {
352
+ // Repeat every 4 units along the z axis
353
+ p.z = repeat(p.z, 4.0);
354
+ // Add bending offset along x axis
355
+ p.x += 2.0 * sin(p.z * 0.1);
356
+
357
+ float d = -sdBox(p, vec3(2.0, 2.0, 20.0)); // Invert = corridor interior
358
+ d = max(d, -sdBox(p, vec3(1.8, 1.8, 1.9))); // Subtract interior space
359
+ d = min(d, sdCylinder(p - vec3(1.5, -2.0, 0.0), vec2(0.1, 2.0))); // Add pillars
360
+ return vec2(d, 1.0);
361
+ }
362
+ ```
363
+
364
+ ### Variant 3: Character/Creature Modeling (Organic Character Modeling)
365
+
366
+ **Difference from the basic version**: Uses `sdEllipsoid` + `sdCapsule` (sdStick) to compose body parts, `smin` to connect with smooth transitions, and `smax` to carve indentations (mouth). Combined with procedural animation to drive joints. A standard approach for character SDF modeling.
367
+
368
+ **Key modified code**:
369
+
370
+ ```glsl
371
+ // Stick primitive (different radii at each end, suitable for limbs)
372
+ vec2 sdStick(vec3 p, vec3 a, vec3 b, float r1, float r2) {
373
+ vec3 pa = p - a, ba = b - a;
374
+ float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
375
+ return vec2(length(pa - ba * h) - mix(r1, r2, h * h * (3.0 - 2.0 * h)), h);
376
+ }
377
+
378
+ vec2 map(vec3 pos) {
379
+ // Body (ellipsoid)
380
+ float d = sdEllipsoid(pos, vec3(0.25, 0.3, 0.25));
381
+
382
+ // Head (sphere, connected with smin)
383
+ float dHead = sdEllipsoid(pos - vec3(0.0, 0.35, 0.02), vec3(0.12, 0.15, 0.13));
384
+ d = smin(d, dHead, 0.1);
385
+
386
+ // Arms (sdStick)
387
+ vec2 arm = sdStick(abs(pos.x) > 0.0 ? vec3(abs(pos.x), pos.yz) : pos,
388
+ vec3(0.18, 0.2, -0.05),
389
+ vec3(0.35, -0.1, -0.15), 0.03, 0.05);
390
+ d = smin(d, arm.x, 0.04);
391
+
392
+ // Mouth (carved with smax)
393
+ float dMouth = sdEllipsoid(pos - vec3(0.0, 0.3, 0.15), vec3(0.08, 0.03, 0.1));
394
+ d = smax(d, -dMouth, 0.03);
395
+
396
+ return vec2(d, 1.0);
397
+ }
398
+ ```
399
+
400
+ ### Variant 4: Symmetry Exploitation
401
+
402
+ **Difference from the basic version**: Leverages geometric symmetry (mirror/rotational invariance) to reduce N repeated elements' SDF evaluations to N/k. For example, octahedral symmetry can reduce 18 elements to 4 evaluations. The key is mapping the input point to the symmetry's fundamental domain.
403
+
404
+ **Key modified code**:
405
+
406
+ ```glsl
407
+ // Fold a point into the octahedral fundamental domain
408
+ vec2 rot45(vec2 v) {
409
+ return vec2(v.x - v.y, v.y + v.x) * 0.707107;
410
+ }
411
+
412
+ vec2 map(vec3 p) {
413
+ float d = sdSphere(p, 0.12); // Center sphere
414
+
415
+ // Exploit symmetry: original 18 gears reduced to 4 evaluations
416
+ vec3 qx = vec3(rot45(p.zy), p.x);
417
+ if (abs(qx.x) > abs(qx.y)) qx = qx.zxy;
418
+
419
+ vec3 qy = vec3(rot45(p.xz), p.y);
420
+ if (abs(qy.x) > abs(qy.y)) qy = qy.zxy;
421
+
422
+ vec3 qz = vec3(rot45(p.yx), p.z);
423
+ if (abs(qz.x) > abs(qz.y)) qz = qz.zxy;
424
+
425
+ vec3 qa = abs(p);
426
+ qa = (qa.x > qa.y && qa.x > qa.z) ? p.zxy :
427
+ (qa.z > qa.y) ? p.yzx : p.xyz;
428
+
429
+ // Only 4 gear() evaluations needed instead of 18
430
+ d = min(d, gear(qa, 0.0));
431
+ d = min(d, gear(qx, 1.0));
432
+ d = min(d, gear(qy, 1.0));
433
+ d = min(d, gear(qz, 1.0));
434
+
435
+ return vec2(d, 1.0);
436
+ }
437
+ ```
438
+
439
+ ### Variant 5: PBR Material Rendering Pipeline
440
+
441
+ **Difference from the basic version**: Replaces simplified Blinn-Phong with GGX microfacet BRDF, combined with a material ID system to assign different roughness/metalness to each primitive. A standard approach for PBR raymarching.
442
+
443
+ **Key modified code**:
444
+
445
+ ```glsl
446
+ // GGX/Trowbridge-Reitz NDF
447
+ float D_GGX(float NoH, float roughness) {
448
+ float a = roughness * roughness;
449
+ float a2 = a * a;
450
+ float d = NoH * NoH * (a2 - 1.0) + 1.0;
451
+ return a2 / (3.14159 * d * d);
452
+ }
453
+
454
+ // Schlick Fresnel approximation
455
+ vec3 F_Schlick(float VoH, vec3 f0) {
456
+ return f0 + (1.0 - f0) * pow(1.0 - VoH, 5.0);
457
+ }
458
+
459
+ // Replace lighting section in render()
460
+ vec3 pbrLighting(vec3 pos, vec3 nor, vec3 rd, vec3 albedo, float roughness, float metallic) {
461
+ vec3 lig = normalize(vec3(-0.5, 0.4, -0.6));
462
+ vec3 hal = normalize(lig - rd);
463
+ vec3 f0 = mix(vec3(0.04), albedo, metallic);
464
+
465
+ float NoL = max(dot(nor, lig), 0.0);
466
+ float NoH = max(dot(nor, hal), 0.0);
467
+ float VoH = max(dot(-rd, hal), 0.0);
468
+
469
+ float D = D_GGX(NoH, roughness);
470
+ vec3 F = F_Schlick(VoH, f0);
471
+
472
+ vec3 spec = D * F * 0.25; // Simplified specular term
473
+ vec3 diff = albedo * (1.0 - metallic) / 3.14159;
474
+
475
+ float shadow = calcSoftshadow(pos, lig, 0.02, 2.5);
476
+ return (diff + spec) * NoL * shadow * vec3(1.3, 1.0, 0.7) * 3.0;
477
+ }
478
+ ```
479
+
480
+ ## Performance Optimization in Detail
481
+
482
+ ### 1. Bounding Volume Acceleration
483
+
484
+ Use an overall AABB or bounding sphere to constrain the search range. Perform analytical ray intersection first to narrow the `tmin`/`tmax` range, avoiding wasted steps in empty regions. A common optimization in advanced raymarching shaders.
485
+
486
+ ```glsl
487
+ // Ray-AABB intersection (call before raycast)
488
+ vec2 iBox(vec3 ro, vec3 rd, vec3 rad) {
489
+ vec3 m = 1.0 / rd;
490
+ vec3 n = m * ro;
491
+ vec3 k = abs(m) * rad;
492
+ vec3 t1 = -n - k;
493
+ vec3 t2 = -n + k;
494
+ return vec2(max(max(t1.x, t1.y), t1.z),
495
+ min(min(t2.x, t2.y), t2.z));
496
+ }
497
+ ```
498
+
499
+ ### 2. Per-Object Bounding
500
+
501
+ In `map()`, first check with a cheap sdBox whether the current point is near a primitive. Only compute the precise SDF when close. A standard per-object culling technique.
502
+
503
+ ```glsl
504
+ // Inside map():
505
+ if (sdBox(pos - objectCenter, boundingSize) < res.x) {
506
+ // Only compute precise SDF when bounding box distance is closer than current nearest
507
+ res = opU(res, vec2(sdComplexShape(pos), matID));
508
+ }
509
+ ```
510
+
511
+ ### 3. Adaptive Step Size
512
+
513
+ Allow larger precision tolerance at distance, stricter up close. Based on the `abs(h.x) < (0.0001 * t)` check found in nearly all advanced shaders.
514
+
515
+ ### 4. Preventing Compiler Inlining
516
+
517
+ Complex `map()` functions get inlined 4 times inside `calcNormal`, causing compilation time to explode. Use a loop + `ZERO` macro to prevent inlining. A well-known technique to prevent excessive compiler inlining.
518
+
519
+ ```glsl
520
+ #define ZERO (min(iFrame, 0)) // Compiler cannot prove this is 0 at compile time, so it won't unroll the loop
521
+ ```
522
+
523
+ ### 5. Symmetry Exploitation
524
+
525
+ If the scene has rotational/mirror symmetry, fold the point into the fundamental domain and evaluate only once. Achieves significant speedup (e.g., 18-to-4 reduction) or infinite repetition.
526
+
527
+ ## Combination Suggestions in Detail
528
+
529
+ ### 1. SDF + Noise Displacement
530
+
531
+ Add noise on top of the `map()` return value to add organic details to smooth surfaces (terrain, skin textures).
532
+
533
+ ```glsl
534
+ float d = sdSphere(p, 1.0);
535
+ d += 0.05 * (sin(p.x * 10.0) * sin(p.y * 10.0) * sin(p.z * 10.0)); // Simple displacement
536
+ // Or use fbm noise: d += 0.1 * fbm(p * 4.0);
537
+ ```
538
+
539
+ **Note**: Noise displacement breaks the SDF's Lipschitz condition (|grad f| <= 1). You need to multiply the step size by a safety factor (e.g., 0.5~0.7) to avoid penetration.
540
+
541
+ ### 2. SDF + Bump Mapping
542
+
543
+ Instead of modifying the SDF itself, add detail perturbation only in the normal computation. Better performance than noise displacement since it doesn't affect ray marching. A common technique in SDF rendering.
544
+
545
+ ```glsl
546
+ vec3 calcNormalBumped(vec3 pos) {
547
+ vec3 n = calcNormal(pos);
548
+ // Add high-frequency detail to the normal
549
+ n += 0.1 * vec3(fbm(pos.yz * 20.0) - 0.5, 0.0, fbm(pos.xy * 20.0) - 0.5);
550
+ return normalize(n);
551
+ }
552
+ ```
553
+
554
+ ### 3. SDF + Domain Warping
555
+
556
+ Warp spatial coordinates before entering `map()` to achieve bending, twisting, polar coordinate transforms, and other effects. A common spatial warping technique.
557
+
558
+ ```glsl
559
+ // Cartesian to polar ring space: straight corridor becomes a ring structure
560
+ vec2 displaceLoop(vec2 p, float r) {
561
+ return vec2(length(p) - r, atan(p.y, p.x));
562
+ }
563
+ ```
564
+
565
+ ### 4. SDF + Procedural Animation
566
+
567
+ Bone/joint angles vary with time, driving SDF primitive positions. `smin` ensures smooth transitions at joints. Common techniques for procedural character animation (squash & stretch, bone chain IK).
568
+
569
+ ```glsl
570
+ // Squash and stretch deformation
571
+ float p = 4.0 * t1 * (1.0 - t1); // Parabolic bounce
572
+ float sy = 0.5 + 0.5 * p; // Stretch in y direction
573
+ float sz = 1.0 / sy; // Compress in z direction (preserve volume)
574
+ vec3 q = pos - center;
575
+ float d = sdEllipsoid(q, vec3(0.25, 0.25 * sy, 0.25 * sz));
576
+ ```
577
+
578
+ ### 5. SDF + Motion Blur
579
+
580
+ Average multiple frames sampled across the time dimension. A standard temporal supersampling technique.
581
+
582
+ ```glsl
583
+ // Randomly offset time in mainImage
584
+ float time = iTime;
585
+ #if AA > 1
586
+ time += 0.5 * float(m * AA + n) / float(AA * AA) / 24.0; // Intra-frame time jitter
587
+ #endif
588
+ ```
589
+
590
+ ## Extended SDF Primitives Reference
591
+
592
+ ### Rounded Box — `sdRoundBox(vec3 p, vec3 b, float r)`
593
+
594
+ - `p`: sample point
595
+ - `b`: half-size dimensions (before rounding)
596
+ - `r`: rounding radius — edges and corners are rounded by this amount
597
+
598
+ ### Box Frame — `sdBoxFrame(vec3 p, vec3 b, float e)`
599
+
600
+ - `p`: sample point
601
+ - `b`: outer half-size dimensions
602
+ - `e`: edge thickness — the wireframe thickness of the box edges
603
+
604
+ ### Cone — `sdCone(vec3 p, vec2 c, float h)`
605
+
606
+ - `p`: sample point
607
+ - `c`: vec2(sin, cos) of the cone's opening angle
608
+ - `h`: height of the cone
609
+
610
+ ### Capped Cone — `sdCappedCone(vec3 p, float h, float r1, float r2)`
611
+
612
+ - `p`: sample point
613
+ - `h`: half-height
614
+ - `r1`: bottom radius
615
+ - `r2`: top radius
616
+
617
+ ### Round Cone — `sdRoundCone(vec3 p, float r1, float r2, float h)`
618
+
619
+ - `p`: sample point
620
+ - `r1`: bottom sphere radius
621
+ - `r2`: top sphere radius
622
+ - `h`: height between sphere centers
623
+
624
+ ### Solid Angle — `sdSolidAngle(vec3 p, vec2 c, float ra)`
625
+
626
+ - `p`: sample point
627
+ - `c`: vec2(sin, cos) of the solid angle
628
+ - `ra`: radius
629
+
630
+ ### Octahedron — `sdOctahedron(vec3 p, float s)`
631
+
632
+ - `p`: sample point
633
+ - `s`: size (distance from center to vertex)
634
+
635
+ ### Pyramid — `sdPyramid(vec3 p, float h)`
636
+
637
+ - `p`: sample point
638
+ - `h`: height of the pyramid (base is a unit square centered at origin)
639
+
640
+ ### Hex Prism — `sdHexPrism(vec3 p, vec2 h)`
641
+
642
+ - `p`: sample point
643
+ - `h.x`: hexagonal radius (circumradius)
644
+ - `h.y`: half-height along z axis
645
+
646
+ ### Cut Sphere — `sdCutSphere(vec3 p, float r, float h)`
647
+
648
+ - `p`: sample point
649
+ - `r`: sphere radius
650
+ - `h`: cut plane height (cuts sphere at y=h)
651
+
652
+ ### Capped Torus — `sdCappedTorus(vec3 p, vec2 sc, float ra, float rb)`
653
+
654
+ - `p`: sample point
655
+ - `sc`: vec2(sin, cos) of the cap angle
656
+ - `ra`: major radius
657
+ - `rb`: tube radius
658
+
659
+ ### Link — `sdLink(vec3 p, float le, float r1, float r2)`
660
+
661
+ - `p`: sample point
662
+ - `le`: half-length of the elongation
663
+ - `r1`: major radius of the torus cross-section
664
+ - `r2`: tube radius
665
+
666
+ ### Plane (arbitrary) — `sdPlane(vec3 p, vec3 n, float h)`
667
+
668
+ - `p`: sample point
669
+ - `n`: plane normal (must be normalized)
670
+ - `h`: offset from origin along the normal
671
+
672
+ ### Rhombus — `sdRhombus(vec3 p, float la, float lb, float h, float ra)`
673
+
674
+ - `p`: sample point
675
+ - `la`, `lb`: half-diagonals of the rhombus in XZ plane
676
+ - `h`: half-height (extrusion in Y)
677
+ - `ra`: rounding radius
678
+
679
+ ### Triangle (unsigned) — `udTriangle(vec3 p, vec3 a, vec3 b, vec3 c)`
680
+
681
+ - `p`: sample point
682
+ - `a`, `b`, `c`: triangle vertex positions
683
+ - Returns unsigned (non-negative) distance
684
+
685
+ ## Deformation Operators Reference
686
+
687
+ ### Round — `opRound(float d, float r)`
688
+
689
+ Softens edges of any SDF by subtracting a radius. Apply to the result of any SDF.
690
+
691
+ ```glsl
692
+ // Round a box with radius 0.1
693
+ float d = opRound(sdBox(p, vec3(1.0)), 0.1);
694
+ ```
695
+
696
+ ### Onion — `opOnion(float d, float t)`
697
+
698
+ Hollows out any SDF into a shell of thickness `t`. Can be stacked for concentric shells.
699
+
700
+ ```glsl
701
+ // Hollow sphere shell, 0.1 thick
702
+ float d = opOnion(sdSphere(p, 1.0), 0.1);
703
+ // Double shell
704
+ float d = opOnion(opOnion(sdSphere(p, 1.0), 0.1), 0.05);
705
+ ```
706
+
707
+ ### Elongate — `opElongate(vec3 p, vec3 h, vec3 center, vec3 size)`
708
+
709
+ Stretches a shape along one or more axes by `h`. The shape is stretched without distortion — it inserts a linear segment.
710
+
711
+ ```glsl
712
+ // Elongate along Y to stretch a box
713
+ vec3 q = abs(p) - vec3(0.0, 0.5, 0.0);
714
+ float d = sdBox(max(q, 0.0), vec3(0.3)) + min(max(q.x, max(q.y, q.z)), 0.0);
715
+ ```
716
+
717
+ ### Twist — `opTwist(vec3 p, float k)`
718
+
719
+ Rotates the XZ cross-section around the Y axis proportionally to height. Returns transformed coordinates to pass into any SDF.
720
+
721
+ ```glsl
722
+ // Twisted box: k controls twist rate (radians per unit height)
723
+ vec3 q = opTwist(p, 3.0);
724
+ float d = sdBox(q, vec3(0.5));
725
+ ```
726
+
727
+ ### Cheap Bend — `opCheapBend(vec3 p, float k)`
728
+
729
+ Bends geometry along the X axis. Returns transformed coordinates.
730
+
731
+ ```glsl
732
+ // Bent box
733
+ vec3 q = opCheapBend(p, 2.0);
734
+ float d = sdBox(q, vec3(0.5, 0.3, 0.5));
735
+ ```
736
+
737
+ ### Displacement — `opDisplace(float d, vec3 p)`
738
+
739
+ Adds procedural sinusoidal surface detail. Breaks Lipschitz bound, so reduce ray march step size by 0.5-0.7.
740
+
741
+ ```glsl
742
+ float d = sdSphere(p, 1.0);
743
+ d = opDisplace(d, p); // Adds bumpy surface detail
744
+ ```
745
+
746
+ ## 2D-to-3D Constructors Reference
747
+
748
+ ### Revolution — `opRevolution(vec3 p, float sdf2d_result, float o)`
749
+
750
+ Creates a 3D solid of revolution by rotating a 2D SDF around the Y axis. Compute the 2D SDF at `vec2(length(p.xz) - o, p.y)` and pass the result.
751
+
752
+ ```glsl
753
+ // Create a torus-like shape by revolving a 2D circle
754
+ vec2 q = vec2(length(p.xz) - 1.0, p.y); // offset=1.0
755
+ float d2d = length(q) - 0.3; // 2D circle radius=0.3
756
+ float d3d = opRevolution(p, d2d, 1.0); // revolve around Y
757
+ ```
758
+
759
+ ### Extrusion — `opExtrusion(vec3 p, float d2d, float h)`
760
+
761
+ Extends any 2D SDF along the Z axis with finite height `h`. The 2D SDF is evaluated in the XY plane and capped at `+/- h` along Z.
762
+
763
+ ```glsl
764
+ // Extrude a 2D shape 0.2 units in both directions
765
+ float d2d = sdCircle2D(p.xy, 0.5); // any 2D SDF
766
+ float d3d = opExtrusion(p, d2d, 0.2); // finite extrusion
767
+ ```
768
+
769
+ ## Symmetry Operators Reference
770
+
771
+ ### Mirror X — `opSymX(vec3 p)`
772
+
773
+ Mirrors across the X axis using `abs(p.x)`. Model only one half and get bilateral symmetry for free. Place at the start of `map()`.
774
+
775
+ ```glsl
776
+ vec2 map(vec3 p) {
777
+ p = opSymX(p); // Mirror: only model x >= 0 side
778
+ float d = sdSphere(p - vec3(1.0, 0.5, 0.0), 0.3);
779
+ // Automatically appears at both x=+1 and x=-1
780
+ return vec2(d, 1.0);
781
+ }
782
+ ```
783
+
784
+ ### Mirror XZ — `opSymXZ(vec3 p)`
785
+
786
+ Four-fold symmetry across both X and Z axes. Model one quadrant, get four copies.
787
+
788
+ ```glsl
789
+ vec2 map(vec3 p) {
790
+ p = opSymXZ(p); // Four-fold symmetry
791
+ float d = sdBox(p - vec3(2.0, 0.5, 2.0), vec3(0.3));
792
+ // Appears in all four quadrants
793
+ return vec2(d, 1.0);
794
+ }
795
+ ```
796
+
797
+ ### Arbitrary Mirror — `opMirror(vec3 p, vec3 dir)`
798
+
799
+ Mirrors across an arbitrary plane defined by its normal `dir` (must be normalized). Reflects any point on the negative side to the positive side.
800
+
801
+ ```glsl
802
+ // Mirror across a 45-degree plane
803
+ vec3 q = opMirror(p, normalize(vec3(1.0, 0.0, 1.0)));
804
+ float d = sdSphere(q - vec3(1.0, 0.5, 0.0), 0.3);
805
+ ```