├── .gitattributes ├── .gitignore ├── .vscode └── launch.json ├── README.md ├── cli ├── README.md ├── cli.js ├── compiler-dist │ ├── compiler.d.ts │ ├── compiler.js │ ├── readme.md │ ├── shadeup-compiler.js │ └── tree-sitter-shadeup.wasm ├── electron │ ├── icon.ico │ ├── icon.png │ ├── index.html │ └── main.js ├── index.js ├── package-lock.json ├── package.json ├── test │ ├── main.d.ts │ ├── main.js │ ├── other.js │ ├── other.shadeup │ └── vite-project │ │ ├── .gitignore │ │ ├── index.html │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── public │ │ └── vite.svg │ │ ├── src │ │ ├── index.ts │ │ ├── logoPath.shadeup │ │ ├── main.d.ts │ │ ├── main.js │ │ ├── main.shadeup │ │ ├── style.css │ │ ├── typescript.svg │ │ └── vite-env.d.ts │ │ └── tsconfig.json └── vite │ ├── .gitignore │ ├── index.html │ ├── main.js │ ├── package-lock.json │ ├── package.json │ ├── public │ └── vite.svg │ ├── runner.d.ts │ ├── runner.js │ ├── style.css │ └── vite.config.js ├── extension └── vscode │ ├── package-lock.json │ └── shadeup │ ├── .vscodeignore │ ├── CHANGELOG.md │ ├── README.md │ ├── Shadeup-tmLanguage.json │ ├── client │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── extension.ts │ ├── testFixture │ │ ├── completion.txt │ │ └── diagnostics.txt │ └── tsconfig.json │ ├── icon.png │ ├── lang.ts │ ├── language-configuration.json │ ├── package-lock.json │ ├── package.json │ ├── server │ ├── compiler-dist │ │ ├── compiler.d.ts │ │ ├── compiler.js │ │ ├── readme.md │ │ ├── shadeup-compiler.umd.cjs │ │ └── tree-sitter-shadeup.wasm │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── server.ts │ └── tsconfig.json │ ├── shadeup.tmlanguage.json │ ├── syntaxes │ └── shadeup.tmLanguage.json │ └── tsconfig.json ├── lang ├── README.md ├── shadeup-frontend │ ├── .gitignore │ ├── f.js │ ├── f.ts │ ├── index.html │ ├── lib │ │ ├── ariadne-ts │ │ │ └── src │ │ │ │ ├── _extensions.ts │ │ │ │ ├── browser.ts │ │ │ │ ├── data │ │ │ │ ├── Display.ts │ │ │ │ ├── Formatter.ts │ │ │ │ ├── Iter.ts │ │ │ │ ├── Option.ts │ │ │ │ ├── Range.ts │ │ │ │ ├── Result.ts │ │ │ │ ├── Show.ts │ │ │ │ ├── Span.ts │ │ │ │ └── Write.ts │ │ │ │ ├── index.ts │ │ │ │ ├── lib │ │ │ │ ├── Characters.ts │ │ │ │ ├── Color.ts │ │ │ │ ├── ColorGenerator.ts │ │ │ │ ├── Config.ts │ │ │ │ ├── Label.ts │ │ │ │ ├── LabelInfo.ts │ │ │ │ ├── Report.ts │ │ │ │ ├── ReportBuilder.ts │ │ │ │ ├── ReportKind.ts │ │ │ │ ├── Source.ts │ │ │ │ ├── SourceGroup.ts │ │ │ │ └── chalk │ │ │ │ │ └── chalk │ │ │ │ │ ├── license │ │ │ │ │ ├── readme.md │ │ │ │ │ └── source │ │ │ │ │ ├── index.d.ts │ │ │ │ │ ├── index.js │ │ │ │ │ ├── utilities.js │ │ │ │ │ └── vendor │ │ │ │ │ ├── ansi-styles │ │ │ │ │ ├── index.d.ts │ │ │ │ │ └── index.js │ │ │ │ │ └── supports-color │ │ │ │ │ ├── browser.d.ts │ │ │ │ │ ├── browser.js │ │ │ │ │ ├── index.d.ts │ │ │ │ │ └── index.js │ │ │ │ ├── stringFormat.ts │ │ │ │ ├── utils │ │ │ │ ├── binary_search_by_key.ts │ │ │ │ ├── include_str.ts │ │ │ │ └── index.ts │ │ │ │ └── write.ts │ │ ├── environment │ │ │ ├── Errors.ts │ │ │ ├── ShadeupEnvironment.ts │ │ │ ├── TypescriptEnvironment.ts │ │ │ ├── quickCache.json │ │ │ ├── tagGraph.ts │ │ │ └── validate.ts │ │ ├── fast-diff │ │ │ └── diff.js │ │ ├── generator │ │ │ ├── eval.js │ │ │ ├── glsl.ts │ │ │ ├── header.glsl │ │ │ ├── header.wgsl │ │ │ ├── root.ts │ │ │ ├── toposort.ts │ │ │ ├── transform.ts │ │ │ ├── tsWalk.ts │ │ │ ├── util.ts │ │ │ └── wgsl.ts │ │ ├── main.ts │ │ ├── parser │ │ │ ├── AstContext.ts │ │ │ ├── index.ts │ │ │ ├── node.cjs │ │ │ ├── tree-sitter-javascript.wasm │ │ │ ├── tree-sitter-shadeup.wasm │ │ │ ├── tree-sitter.wasm │ │ │ ├── wasm.ts │ │ │ └── web-tree-sitter │ │ │ │ └── tree-sitter.js │ │ └── std │ │ │ ├── all.ts │ │ │ ├── generate-static-math.ts │ │ │ ├── global.d.ts │ │ │ ├── math.ts │ │ │ ├── static-math-db.ts │ │ │ └── static-math.ts │ ├── package-lock.json │ ├── package.json │ ├── public │ │ └── vite.svg │ ├── src │ │ ├── index.ts │ │ ├── main.ts │ │ └── vite-env.d.ts │ ├── test.js │ ├── test.ts │ ├── tsconfig.json │ ├── vfs.js │ └── vite.config.ts ├── shadeup │ ├── alert.ts │ ├── compiler │ │ ├── assets.json │ │ ├── assets.ts │ │ ├── common.ts │ │ ├── generateDocs.ts │ │ ├── generateTsCache.ts │ │ ├── interface.ts │ │ ├── simple.ts │ │ └── worker.ts │ ├── engine │ │ ├── adapters │ │ │ ├── adapter.ts │ │ │ ├── webgl.ts │ │ │ └── webgpu.ts │ │ ├── amd.ts │ │ ├── engine-headless.ts │ │ ├── engine.ts │ │ ├── frame-embed.html │ │ ├── frame-headless.html │ │ ├── frame-preview.html │ │ ├── frame.html │ │ ├── gltf.js │ │ ├── input │ │ │ ├── input.ts │ │ │ └── keyboardKeys.ts │ │ ├── requirejs.js │ │ ├── setZero.ts │ │ ├── shader.ts │ │ ├── ui │ │ │ ├── components │ │ │ │ ├── Button.svelte │ │ │ │ ├── Checkbox.svelte │ │ │ │ ├── Combo.svelte │ │ │ │ ├── FloatingPanel.svelte │ │ │ │ ├── Group.svelte │ │ │ │ ├── Host.svelte │ │ │ │ ├── Label.svelte │ │ │ │ ├── Slider.svelte │ │ │ │ ├── Text.svelte │ │ │ │ └── host.scss │ │ │ ├── puck.ts │ │ │ └── ui.ts │ │ ├── util.ts │ │ └── virtual-webgl2.js │ ├── environment.ts │ ├── environmentWorker.ts │ ├── frame.html │ ├── library │ │ ├── buffer.ts │ │ ├── color.ts │ │ ├── common.shadeup │ │ ├── drawAttributes.ts │ │ ├── drawCount.ts │ │ ├── drawIndexed.ts │ │ ├── examples │ │ │ ├── deferred.shadeup │ │ │ ├── shadow-map.shadeup │ │ │ └── transparency.shadeup │ │ ├── files.ts │ │ ├── geo.shadeup │ │ ├── mesh.shadeup │ │ ├── mesh.ts │ │ ├── native.ts │ │ ├── paint.ts │ │ ├── physics.ts │ │ ├── sdf.shadeup │ │ ├── std.ts │ │ ├── test.shadeup │ │ ├── texture.ts │ │ ├── textures.shadeup │ │ ├── types.ts │ │ └── ui.ts │ ├── monaco │ │ └── connector.ts │ ├── runner.ts │ ├── symbol.ts │ ├── vite.config.js │ └── worker.ts └── tree-sitter │ ├── .gitignore │ ├── .prettierrc │ ├── Cargo.lock │ ├── Cargo.toml │ ├── binding.gyp │ ├── bindings │ ├── node │ │ ├── binding.cc │ │ └── index.js │ └── rust │ │ ├── build.rs │ │ └── lib.rs │ ├── build │ ├── Release │ │ ├── obj │ │ │ └── tree_sitter_shadeup_binding │ │ │ │ ├── bindings │ │ │ │ └── node │ │ │ │ │ └── binding.obj │ │ │ │ ├── src │ │ │ │ ├── parser.obj │ │ │ │ └── scanner.obj │ │ │ │ ├── tree_sit.A95203FA.tlog │ │ │ │ ├── CL.command.1.tlog │ │ │ │ ├── CL.read.1.tlog │ │ │ │ ├── CL.write.1.tlog │ │ │ │ ├── link.command.1.tlog │ │ │ │ ├── link.read.1.tlog │ │ │ │ ├── link.write.1.tlog │ │ │ │ ├── tree_sitter_shadeup_binding.lastbuildstate │ │ │ │ └── tree_sitter_shadeup_binding.write.1u.tlog │ │ │ │ ├── tree_sitter_shadeup_binding.node.recipe │ │ │ │ └── win_delay_load_hook.obj │ │ ├── tree_sitter_shadeup_binding.exp │ │ ├── tree_sitter_shadeup_binding.iobj │ │ ├── tree_sitter_shadeup_binding.ipdb │ │ ├── tree_sitter_shadeup_binding.lib │ │ ├── tree_sitter_shadeup_binding.node │ │ └── tree_sitter_shadeup_binding.pdb │ ├── binding.sln │ ├── config.gypi │ ├── tree_sitter_shadeup_binding.vcxproj │ └── tree_sitter_shadeup_binding.vcxproj.filters │ ├── grammar.js │ ├── grammer-fixed.js │ ├── javascript.js │ ├── package-lock.json │ ├── package.json │ ├── parser.exp │ ├── parser.lib │ ├── parser.obj │ ├── readme.md │ ├── scanner.obj │ ├── shadeup-javascript.js │ ├── src │ ├── grammar.json │ ├── node-types.json │ ├── parser.c │ ├── scanner.c │ └── tree_sitter │ │ └── parser.h │ ├── test.shadeup │ ├── tree-sitter-javascript.wasm │ └── typescript.js ├── package-lock.json ├── package.json ├── package ├── __lib.d.ts ├── __lib.js ├── __lib.shadeup ├── engine-dist │ ├── DRACOLoader-4fcd2f44.js │ ├── GLTFLoader-94b38cf6.js │ ├── host-937690bb.js │ ├── host-f3c963cd.js │ ├── host-fa5c0296.js │ ├── shadeup-engine.js │ ├── style.css │ ├── three.module-c8091b37.js │ ├── ui-37189365.js │ └── ui-f4b4a003.js ├── engine.js ├── index.js ├── library.js ├── main.d.ts ├── math.d.ts ├── package-lock.json ├── package.json └── util │ └── concat.js └── unreal-engine ├── .editorconfig ├── .gitattributes ├── .gitignore ├── .prettierignore ├── README.md ├── archive.js ├── archives ├── ComputeShader_base.zip ├── ComputeShader_basemat.zip ├── ComputeShader_mat.zip ├── ComputeShader_pi.zip ├── ComputeShader_rt.zip ├── CustomProxy_Plugin │ ├── Resources │ │ └── Icon128.png │ ├── ShadeupExamplePlugin.uplugin │ ├── ShadeupExamplePlugin.uplugin.back │ └── Source │ │ ├── CustomProxy │ │ ├── CustomProxy.Build.cs │ │ ├── Private │ │ │ └── CustomProxy.cpp │ │ └── Public │ │ │ └── CustomProxy.h │ │ └── ShadeupTestPlugin │ │ ├── Private │ │ └── ShadeupExamplePlugin.cpp │ │ ├── Public │ │ └── ShadeupExamplePlugin.h │ │ └── ShadeupExamplePlugin.Build.cs ├── CustomProxy_base.zip ├── CustomProxy_stream.zip ├── IndirectInstancing_base.zip ├── IndirectInstancing_grid.zip ├── IndirectInstancing_inst.zip ├── MaterialNodeOutput_dynamic.zip ├── MaterialNodeOutput_fn.zip ├── MaterialNodeOutput_input.zip └── MaterialNodeOutput_output.zip ├── build └── grammar.js ├── cli.js ├── examples ├── pixel.shadeup └── version2.shadeup ├── extension └── shadeup │ ├── .vscode │ └── launch.json │ ├── .vscodeignore │ ├── CHANGELOG.md │ ├── README.md │ ├── icon.svg │ ├── language-configuration.json │ ├── logo.svg │ ├── package.json │ ├── syntaxes │ └── shadeup.tmLanguage.json │ └── vsc-extension-quickstart.md ├── index.js ├── p.shadeup ├── package-lock.json ├── package.json ├── resources └── img │ ├── discord.png │ ├── logo.png │ └── logo.svg ├── src ├── file.js ├── grammar.ne ├── parse.js ├── plugin_template │ ├── Resources │ │ └── Icon128.png │ ├── ShadeupExamplePlugin.uplugin │ └── Source │ │ └── ShadeupTestPlugin │ │ ├── Private │ │ └── ShadeupExamplePlugin.cpp │ │ ├── Public │ │ └── ShadeupExamplePlugin.h │ │ └── ShadeupExamplePlugin.Build.cs ├── string.ne ├── template │ ├── ModulePrivate.cpp │ ├── ModulePublic.h │ ├── Plugin │ │ ├── MyPlugin.uplugin │ │ ├── Shaders │ │ │ ├── Compute │ │ │ │ └── Private │ │ │ │ │ └── Template.usf │ │ │ └── Factory │ │ │ │ └── Private │ │ │ │ └── Template.ush │ │ └── Source │ │ │ └── Module │ │ │ ├── Private │ │ │ ├── ActorTemplate.cpp │ │ │ ├── ComputeTemplate.cpp │ │ │ ├── ComputeTemplate.h │ │ │ ├── FactoryTemplate.cpp │ │ │ ├── FactoryTemplate.h │ │ │ ├── ModuleTemplate.cpp │ │ │ ├── ProxyTemplate.cpp │ │ │ └── ProxyTemplate.h │ │ │ ├── Public │ │ │ ├── ActorTemplate.h │ │ │ └── ModuleTemplate.h │ │ │ └── Template.Build.cs │ ├── Template.Build.cs │ ├── compute.cpp │ └── lib │ │ ├── ShadeupLib.cpp │ │ ├── ShadeupLib.h │ │ └── readme.md ├── templates │ ├── compute │ │ └── simple-compute-shader │ │ │ └── Plugin │ │ │ ├── Shaders │ │ │ └── [MODULE] │ │ │ │ └── Private │ │ │ │ └── [NAME] │ │ │ │ ├── $base[NAME].usf │ │ │ │ ├── $basemat[NAME].usf │ │ │ │ ├── $mat[NAME].usf │ │ │ │ ├── $pi[NAME].usf │ │ │ │ └── $rt[NAME].usf │ │ │ └── Source │ │ │ └── [MODULE] │ │ │ ├── Private │ │ │ └── [NAME] │ │ │ │ ├── [NAME].cpp │ │ │ │ └── [NAME].h │ │ │ └── Public │ │ │ └── [NAME] │ │ │ ├── $base[NAME]_readme.md │ │ │ ├── $basemat[NAME]_readme.md │ │ │ ├── $mat[NAME]_readme.md │ │ │ ├── $pi[NAME]_readme.md │ │ │ ├── $rt[NAME]_readme.md │ │ │ └── [NAME].h │ ├── instancing │ │ ├── compute-indirect-drawing │ │ │ └── Plugin │ │ │ │ ├── Shaders │ │ │ │ └── [MODULE] │ │ │ │ │ └── Private │ │ │ │ │ └── [NAME] │ │ │ │ │ ├── [NAME].ush │ │ │ │ │ ├── [NAME]Compute.usf │ │ │ │ │ └── [NAME]VertexFactory.ush │ │ │ │ └── Source │ │ │ │ └── [MODULE] │ │ │ │ ├── Private │ │ │ │ └── [NAME] │ │ │ │ │ ├── [NAME]Actor.cpp │ │ │ │ │ ├── [NAME]Component.cpp │ │ │ │ │ ├── [NAME]SceneProxy.cpp │ │ │ │ │ ├── [NAME]SceneProxy.h │ │ │ │ │ ├── [NAME]VertexFactory.cpp │ │ │ │ │ └── [NAME]VertexFactory.h │ │ │ │ └── Public │ │ │ │ └── [NAME] │ │ │ │ ├── $base[NAME]_readme.md │ │ │ │ ├── [NAME]Actor.h │ │ │ │ └── [NAME]Component.h │ │ └── compute-instanced-static-mesh-component │ │ │ └── Plugin │ │ │ ├── Shaders │ │ │ └── [MODULE] │ │ │ │ └── Private │ │ │ │ └── [NAME] │ │ │ │ ├── [NAME].ush │ │ │ │ ├── [NAME]Compute.usf │ │ │ │ └── [NAME]VertexFactory.ush │ │ │ └── Source │ │ │ └── [MODULE] │ │ │ ├── Private │ │ │ └── [NAME] │ │ │ │ ├── [NAME]Actor.cpp │ │ │ │ ├── [NAME]Component.cpp │ │ │ │ ├── [NAME]SceneProxy.cpp │ │ │ │ ├── [NAME]SceneProxy.h │ │ │ │ ├── [NAME]VertexFactory.cpp │ │ │ │ └── [NAME]VertexFactory.h │ │ │ └── Public │ │ │ └── [NAME] │ │ │ ├── $inst[NAME]_readme.md │ │ │ ├── [NAME]Actor.h │ │ │ └── [NAME]Component.h │ └── nodes │ │ ├── dynamic │ │ └── Plugin │ │ │ └── Source │ │ │ └── [MODULE] │ │ │ ├── Private │ │ │ └── [NAME]MaterialExpression.cpp │ │ │ └── Public │ │ │ ├── [NAME]MaterialExpression.h │ │ │ └── [NAME]_readme.md │ │ ├── fn │ │ └── Plugin │ │ │ └── Source │ │ │ └── [MODULE] │ │ │ ├── Private │ │ │ └── [NAME]MaterialExpression.cpp │ │ │ └── Public │ │ │ └── [NAME]MaterialExpression.h │ │ ├── input │ │ └── Plugin │ │ │ └── Source │ │ │ └── [MODULE] │ │ │ ├── Private │ │ │ └── [NAME]MaterialExpression.cpp │ │ │ └── Public │ │ │ └── [NAME]MaterialExpression.h │ │ └── output │ │ └── Plugin │ │ └── Source │ │ └── [MODULE] │ │ ├── Private │ │ └── [NAME]MaterialExpression.cpp │ │ └── Public │ │ └── [NAME]MaterialExpression.h ├── types │ ├── actor.js │ ├── base.js │ ├── compute.js │ ├── factory.js │ ├── shader.js │ ├── template.js │ └── value.js ├── util.js └── whitespace.ne ├── test.hlsl ├── test.js └── test.shadeup /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "args": [ 13 | "--extensionDevelopmentPath=${workspaceFolder}/extension/vscode/shadeup", 14 | "${workspaceFolder}/cli/test/vite-project/src/" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Shadeup logo

2 | 3 |

Shadeup

4 | 5 | ## Write **WebGPU** shaders without the boilerplate 6 | 7 | Repository for the Shadeup ecosystem and tooling [Shadeup.dev](https://shadeup.dev/) 8 | 9 | This currently includes: 10 | 11 | - [Shadeup Language](./lang) - partial codebase 12 | - [Shadeup Compiler Tools](./cli) `npm i -g @shadeup/cli` 13 | - [Shadeup Engine Package](./package) `npm i shadeup` 14 | - [Shadeup - Unreal Engine](./unreal-engine) `npm i -g @shadeup/unreal` 15 | - [Shadeup VS Code extension](./extension/vscode) - [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=Shadeup.shadeup-vscode) 16 | 17 | --- 18 | -------------------------------------------------------------------------------- /cli/compiler-dist/compiler.d.ts: -------------------------------------------------------------------------------- 1 | export function makeLSPCompiler(): Promise; 2 | -------------------------------------------------------------------------------- /cli/compiler-dist/readme.md: -------------------------------------------------------------------------------- 1 | modify the output of shadeup-compiler.js to: 2 | 3 | 1. remove the tree sitter wasm strings 4 | 2. Replace getShadeupParse with: 5 | 6 | async function getShadeupParser() { 7 | return global.shadeupParser(); 8 | } 9 | 10 | 3. import fs and replace e4.readFileSync e4 trace up to \_\_viteexternal with fs 11 | -------------------------------------------------------------------------------- /cli/compiler-dist/tree-sitter-shadeup.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/cli/compiler-dist/tree-sitter-shadeup.wasm -------------------------------------------------------------------------------- /cli/electron/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/cli/electron/icon.ico -------------------------------------------------------------------------------- /cli/electron/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/cli/electron/icon.png -------------------------------------------------------------------------------- /cli/electron/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Shadeup Preview 6 | 10 | 11 | 12 | 16 | 17 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /cli/electron/main.js: -------------------------------------------------------------------------------- 1 | import { app, BrowserWindow } from "electron/main"; 2 | import path from "node:path"; 3 | const __dirname = path.dirname( 4 | new URL(import.meta.url).pathname.replace(/^\//g, "") 5 | ); 6 | 7 | function createWindow() { 8 | const win = new BrowserWindow({ 9 | width: 800, 10 | height: 600, 11 | autoHideMenuBar: true, 12 | icon: path.join(__dirname, "icon.ico"), 13 | webPreferences: {}, 14 | }); 15 | 16 | win.loadFile("index.html"); 17 | } 18 | 19 | app.whenReady().then(() => { 20 | createWindow(); 21 | 22 | app.on("activate", () => { 23 | if (BrowserWindow.getAllWindows().length === 0) { 24 | createWindow(); 25 | } 26 | }); 27 | }); 28 | 29 | app.on("window-all-closed", () => { 30 | if (process.platform !== "darwin") { 31 | app.quit(); 32 | } 33 | }); 34 | -------------------------------------------------------------------------------- /cli/index.js: -------------------------------------------------------------------------------- 1 | throw new Error("This is a CLI only package"); 2 | -------------------------------------------------------------------------------- /cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@shadeup/cli", 3 | "version": "1.3.0", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1", 9 | "cli": "node cli.js" 10 | }, 11 | "bin": { 12 | "shadeup": "./cli.js" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/AskingQuestions/Shadeup" 17 | }, 18 | "author": "AskingQuestions ", 19 | "license": "MIT", 20 | "dependencies": { 21 | "@typescript/vfs": "^1.5.0", 22 | "boxen": "^7.0.0", 23 | "colors": "^1.4.0", 24 | "commander": "^9.2.0", 25 | "electron": "^28.2.2", 26 | "inquirer": "^8.2.4", 27 | "shadeup": "^1.3.6", 28 | "typescript": "^5.3.3", 29 | "uglify-js": "^3.17.4", 30 | "vite": "^5.1.1", 31 | "web-tree-sitter": "^0.20.8" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cli/test/main.d.ts: -------------------------------------------------------------------------------- 1 | import * as __ from "/std_math"; 2 | export declare function main(): void; 3 | export declare function giveFloat(): __.float; 4 | -------------------------------------------------------------------------------- /cli/test/other.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/cli/test/other.js -------------------------------------------------------------------------------- /cli/test/other.shadeup: -------------------------------------------------------------------------------- 1 | pub fn drawer() { 2 | return shader { out.color = 1.xxxx; }; 3 | } -------------------------------------------------------------------------------- /cli/test/vite-project/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /cli/test/vite-project/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + TS 8 | 9 | 10 |
11 | 12 | 13 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /cli/test/vite-project/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vite-project", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc && vite build", 9 | "preview": "vite preview" 10 | }, 11 | "devDependencies": { 12 | "typescript": "^5.2.2", 13 | "vite": "^5.1.1" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /cli/test/vite-project/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cli/test/vite-project/src/index.ts: -------------------------------------------------------------------------------- 1 | import { makeShadeupInstance } from "./main"; 2 | 3 | const canvas = document.querySelector("#canvas")!; 4 | (async () => { 5 | let engine = await makeShadeupInstance(canvas); 6 | await engine.enableUI(); 7 | console.log(engine); 8 | let tex = await engine.loadTexture2dFromURL( 9 | "https://i.imgur.com/XxtTu4t.jpeg" 10 | ); 11 | engine.files.main.setTexture(tex); 12 | 13 | let model = await engine.loadModelFromURL( 14 | "https://s3-eu-west-1.amazonaws.com/fetchcfd/original/file-1571050371399.glb" 15 | ); 16 | // console.log(model); 17 | // engine.files.main.setModel(model); 18 | // engine.files.main.setSpawning(true); 19 | // engine.files.main.useTex(await engine); 20 | })(); 21 | 22 | function sizeCanvas() { 23 | canvas.width = window.innerWidth * devicePixelRatio; 24 | canvas.height = window.innerHeight * devicePixelRatio; 25 | } 26 | 27 | sizeCanvas(); 28 | 29 | window.addEventListener("resize", sizeCanvas); 30 | -------------------------------------------------------------------------------- /cli/test/vite-project/src/main.d.ts: -------------------------------------------------------------------------------- 1 | import * as __ from "shadeup/math"; 2 | 3 | declare namespace ShadeupFiles { 4 | declare namespace main { 5 | /**__SHADEUP_STRUCT_INJECTION_HOOK__*/ 6 | export declare function setTexture(newTex: texture2d<__.float4>): void; 7 | export declare function setModel(newModel: Model): void; 8 | export declare function main(): void; 9 | } 10 | } 11 | 12 | export declare function makeShadeupInstance( 13 | canvas: HTMLCanvasElement 14 | ): Promise<{ 15 | /** 16 | * Set to false to pause 17 | */ 18 | playing: boolean; 19 | 20 | canvas: HTMLCanvasElement; 21 | 22 | adapter: any; 23 | hooks: { 24 | beforeFrame?: () => {}; 25 | afterFrame?: () => {}; 26 | reset?: () => {}; 27 | }[]; 28 | start: () => void; 29 | 30 | env: { 31 | camera: { 32 | position: __.float3; 33 | rotation: __.float4; 34 | width: __.float; 35 | height: __.float; 36 | fov: __.float; 37 | near: __.float; 38 | far: __.float; 39 | }; 40 | camera2d: { 41 | position: __.float2; 42 | zoom: __.float; 43 | }; 44 | deltaTime: __.float; 45 | frame: __.int; 46 | keyboard: any; 47 | mouse: any; 48 | screenSize: __.float2; 49 | time: __.float; 50 | }; 51 | 52 | /** 53 | * Used to pass values into the shadeup env (accessed as env.input("name") inside) 54 | */ 55 | inputValues: Map; 56 | 57 | enableUI: () => Promise; 58 | 59 | loadTextureFromImageLike: ( 60 | img: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas | HTMLVideoElement 61 | ) => Promise<__.texture2d<__.float4>>; 62 | loadTexture2dFromURL: (url: string) =? Promise<__.texture2d<__.float4>>; 63 | loadModelFromURL(urlGltf: string) => Promise<__.texture2d<__.float4>>; 64 | 65 | files: typeof ShadeupFiles; 66 | }>; 67 | -------------------------------------------------------------------------------- /cli/test/vite-project/src/main.shadeup: -------------------------------------------------------------------------------- 1 | // Create a cube at the origin (0.xyz) 2 | // with a size of 100 units (100.xyz) 3 | let cube = mesh::box(0.xyz, 100.xyz); 4 | let tex = texture2d(10.xy); 5 | 6 | tex.draw(shader { 7 | out.color = 1.xxxx; 8 | }); 9 | 10 | pub fn setTexture(newTex: texture2d) { 11 | tex = newTex; 12 | } 13 | pub fn setModel(newModel: Model) { 14 | cube = newModel.parts[0].mesh.scale(20.xxx); 15 | 16 | tex = newModel.parts[0].material.color; 17 | } 18 | 19 | fn main() { 20 | ui::button("Hello, world!"); 21 | 22 | draw( 23 | cube, 24 | shader { 25 | out.position = 26 | env.camera.getCombinedMatrix() 27 | * 28 | (quat::rotate(quat::fromEulerAngles((0, env.time, 0)), in.position), 1); 29 | }, 30 | shader { 31 | // Calculate the normal of the surface 32 | let normal = normalize(in.normal); 33 | 34 | // Calculate the direction of the light 35 | let lightDir = normalize((2, 4.0, 0.5)); 36 | 37 | // Calculate the diffuse lighting 38 | let diffuse = max(dot(normal, lightDir), 0.0) * tex.sample(in.uv); 39 | 40 | // Output the color 41 | out.color = (diffuse.xyz, 1); 42 | } 43 | ); 44 | } 45 | -------------------------------------------------------------------------------- /cli/test/vite-project/src/style.css: -------------------------------------------------------------------------------- 1 | :root { 2 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; 3 | line-height: 1.5; 4 | font-weight: 400; 5 | 6 | color-scheme: light dark; 7 | color: rgba(255, 255, 255, 0.87); 8 | background-color: #242424; 9 | 10 | font-synthesis: none; 11 | text-rendering: optimizeLegibility; 12 | -webkit-font-smoothing: antialiased; 13 | -moz-osx-font-smoothing: grayscale; 14 | } 15 | 16 | a { 17 | font-weight: 500; 18 | color: #646cff; 19 | text-decoration: inherit; 20 | } 21 | a:hover { 22 | color: #535bf2; 23 | } 24 | 25 | body { 26 | margin: 0; 27 | display: flex; 28 | place-items: center; 29 | min-width: 320px; 30 | min-height: 100vh; 31 | } 32 | 33 | h1 { 34 | font-size: 3.2em; 35 | line-height: 1.1; 36 | } 37 | 38 | #app { 39 | max-width: 1280px; 40 | margin: 0 auto; 41 | padding: 2rem; 42 | text-align: center; 43 | } 44 | 45 | .logo { 46 | height: 6em; 47 | padding: 1.5em; 48 | will-change: filter; 49 | transition: filter 300ms; 50 | } 51 | .logo:hover { 52 | filter: drop-shadow(0 0 2em #646cffaa); 53 | } 54 | .logo.vanilla:hover { 55 | filter: drop-shadow(0 0 2em #3178c6aa); 56 | } 57 | 58 | .card { 59 | padding: 2em; 60 | } 61 | 62 | .read-the-docs { 63 | color: #888; 64 | } 65 | 66 | button { 67 | border-radius: 8px; 68 | border: 1px solid transparent; 69 | padding: 0.6em 1.2em; 70 | font-size: 1em; 71 | font-weight: 500; 72 | font-family: inherit; 73 | background-color: #1a1a1a; 74 | cursor: pointer; 75 | transition: border-color 0.25s; 76 | } 77 | button:hover { 78 | border-color: #646cff; 79 | } 80 | button:focus, 81 | button:focus-visible { 82 | outline: 4px auto -webkit-focus-ring-color; 83 | } 84 | 85 | @media (prefers-color-scheme: light) { 86 | :root { 87 | color: #213547; 88 | background-color: #ffffff; 89 | } 90 | a:hover { 91 | color: #747bff; 92 | } 93 | button { 94 | background-color: #f9f9f9; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /cli/test/vite-project/src/typescript.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cli/test/vite-project/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /cli/test/vite-project/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "module": "ESNext", 6 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | 16 | /* Linting */ 17 | "strict": true, 18 | "noUnusedLocals": true, 19 | "noUnusedParameters": true, 20 | "noFallthroughCasesInSwitch": true 21 | }, 22 | "include": ["src"] 23 | } 24 | -------------------------------------------------------------------------------- /cli/vite/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? -------------------------------------------------------------------------------- /cli/vite/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite App 8 | 9 | 10 |
11 |
12 | 13 |
14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /cli/vite/main.js: -------------------------------------------------------------------------------- 1 | import "./style.css"; 2 | import { makeShadeupInstance } from "./runner"; 3 | 4 | const canvas = document.querySelector("#canvas"); 5 | (async () => { 6 | let engine = await makeShadeupInstance(canvas, { 7 | ui: true, 8 | }); 9 | })(); 10 | 11 | function sizeCanvas() { 12 | canvas.width = window.innerWidth * devicePixelRatio; 13 | canvas.height = window.innerHeight * devicePixelRatio; 14 | } 15 | 16 | sizeCanvas(); 17 | 18 | window.addEventListener("resize", sizeCanvas); 19 | -------------------------------------------------------------------------------- /cli/vite/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vite-project", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vite build", 9 | "preview": "vite preview" 10 | }, 11 | "devDependencies": { 12 | "vite": "^5.1.0" 13 | }, 14 | "dependencies": { 15 | "shadeup": "^1.3.6" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /cli/vite/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cli/vite/runner.js: -------------------------------------------------------------------------------- 1 | export const makeShadeupInstance = async (canvas) => { 2 | return { 3 | enableUI: async () => {}, 4 | }; 5 | }; 6 | -------------------------------------------------------------------------------- /cli/vite/style.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | margin: 0; 4 | padding: 0; 5 | font-family: "Roboto", sans-serif; 6 | background-color: black; 7 | overflow: hidden; 8 | } 9 | .puck { 10 | position: absolute; 11 | width: 20px; 12 | height: 20px; 13 | border-radius: 50%; 14 | /* transform: translate(-50%, -50%); */ 15 | background-color: #3a3a3a; 16 | box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16); 17 | cursor: grab; 18 | display: flex; 19 | justify-content: center; 20 | align-items: center; 21 | color: rgb(80, 80, 80); 22 | user-select: none; 23 | font-family: monospace; 24 | line-height: 12px; 25 | font-size: 12px; 26 | } 27 | 28 | .puck[data-down="true"] { 29 | cursor: grabbing; 30 | } 31 | 32 | .puck span { 33 | height: 14px; 34 | } 35 | -------------------------------------------------------------------------------- /cli/vite/vite.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('vite').UserConfig} */ 2 | export default { 3 | // ... 4 | }; 5 | -------------------------------------------------------------------------------- /extension/vscode/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": {} 6 | } 7 | -------------------------------------------------------------------------------- /extension/vscode/shadeup/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | .gitignore -------------------------------------------------------------------------------- /extension/vscode/shadeup/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "shadeup" extension will be documented in this file. 4 | 5 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 6 | 7 | ## [Unreleased] 8 | 9 | - Initial release -------------------------------------------------------------------------------- /extension/vscode/shadeup/README.md: -------------------------------------------------------------------------------- 1 | ![logo](https://raw.githubusercontent.com/AskingQuestions/Shadeup/main/unreal-engine/resources/img/logo.png) 2 | 3 | # Shadeup Language Support [BETA] 4 | 5 | ### [shadeup.dev](https://shadeup.dev) 6 | 7 | This extension provides language support for the Shadeup language. 8 | 9 | ## Features 10 | 11 | - Syntax highlighting for Shadeup files 12 | - Shadeup language server 13 | - Intellisense 14 | - Diagnostics 15 | - Hover 16 | - File icon for Shadeup files 17 | 18 | ## Release Notes 19 | 20 | ### 1.0.0 21 | 22 | Initial release 23 | -------------------------------------------------------------------------------- /extension/vscode/shadeup/client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lsp-shadeup-client", 3 | "description": "VSCode part of a language server", 4 | "author": "Microsoft Corporation", 5 | "license": "MIT", 6 | "version": "0.0.1", 7 | "publisher": "shadeup", 8 | "engines": { 9 | "vscode": "^1.75.0" 10 | }, 11 | "dependencies": { 12 | "vscode-languageclient": "^9.0.1" 13 | }, 14 | "devDependencies": { 15 | "@types/vscode": "^1.75.1", 16 | "@vscode/test-electron": "^2.3.8" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /extension/vscode/shadeup/client/testFixture/completion.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/extension/vscode/shadeup/client/testFixture/completion.txt -------------------------------------------------------------------------------- /extension/vscode/shadeup/client/testFixture/diagnostics.txt: -------------------------------------------------------------------------------- 1 | ANY browsers, ANY OS. -------------------------------------------------------------------------------- /extension/vscode/shadeup/client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es2020", 5 | "lib": ["es2020"], 6 | "outDir": "out", 7 | "rootDir": "src", 8 | "sourceMap": true 9 | }, 10 | "include": ["src"], 11 | "exclude": ["node_modules", ".vscode-test"] 12 | } 13 | -------------------------------------------------------------------------------- /extension/vscode/shadeup/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/extension/vscode/shadeup/icon.png -------------------------------------------------------------------------------- /extension/vscode/shadeup/language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)", 3 | "comments": { 4 | // symbol used for single line comment. Remove this entry if your language does not support line comments 5 | "lineComment": "//", 6 | // symbols used for start and end a block comment. Remove this entry if your language does not support block comments 7 | "blockComment": ["/*", "*/"] 8 | }, 9 | // symbols used as brackets 10 | "brackets": [ 11 | ["{", "}"], 12 | ["[", "]"], 13 | ["(", ")"] 14 | ], 15 | // symbols that are auto closed when typing 16 | "autoClosingPairs": [ 17 | ["{", "}"], 18 | ["[", "]"], 19 | ["(", ")"], 20 | ["\"", "\""], 21 | ["'", "'"] 22 | ], 23 | // symbols that can be used to surround a selection 24 | "surroundingPairs": [ 25 | ["{", "}"], 26 | ["[", "]"], 27 | ["(", ")"], 28 | ["\"", "\""], 29 | ["'", "'"] 30 | ], 31 | "folding": { 32 | "markers": { 33 | "start": "^\\\\s*//\\\\s*#?region\\\\b", 34 | "end": "^\\\\s*//\\\\s*#?endregion\\\\b" 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /extension/vscode/shadeup/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shadeup-vscode", 3 | "displayName": "Shadeup for VS Code", 4 | "description": "Shadeup language server and tools", 5 | "version": "1.0.0", 6 | "engines": { 7 | "vscode": "^1.85.0" 8 | }, 9 | "publisher": "Shadeup", 10 | "keywords": [ 11 | "shadeup", 12 | "language", 13 | "syntax", 14 | "highlighting" 15 | ], 16 | "icon": "icon.png", 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/AskingQuestions/shadeup" 20 | }, 21 | "main": "./client/out/extension", 22 | "categories": [ 23 | "Programming Languages" 24 | ], 25 | "contributes": { 26 | "languages": [ 27 | { 28 | "id": "shadeup", 29 | "aliases": [ 30 | "Shadeup", 31 | "shadeup" 32 | ], 33 | "extensions": [ 34 | ".shadeup" 35 | ], 36 | "configuration": "./language-configuration.json", 37 | "icon": { 38 | "light": "./icon.png", 39 | "dark": "./icon.png" 40 | } 41 | } 42 | ], 43 | "grammars": [ 44 | { 45 | "language": "shadeup", 46 | "scopeName": "source.shadeup", 47 | "path": "./shadeup.tmlanguage.json" 48 | } 49 | ] 50 | }, 51 | "scripts": { 52 | "vscode:prepublish": "npm run compile", 53 | "compile": "tsc -b", 54 | "watch": "tsc -b -w", 55 | "lint": "eslint ./client/src ./server/src --ext .ts,.tsx", 56 | "postinstall": "cd client && npm install && cd ../server && npm install && cd .." 57 | }, 58 | "devDependencies": { 59 | "@types/mocha": "^10.0.6", 60 | "@types/node": "^18.14.6", 61 | "@typescript-eslint/eslint-plugin": "^6.14.0", 62 | "@typescript-eslint/parser": "^6.14.0", 63 | "eslint": "^8.56.0", 64 | "mocha": "^10.2.0", 65 | "typescript": "^5.3.3" 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /extension/vscode/shadeup/server/compiler-dist/compiler.d.ts: -------------------------------------------------------------------------------- 1 | export function makeLSPCompiler(): Promise; 2 | -------------------------------------------------------------------------------- /extension/vscode/shadeup/server/compiler-dist/compiler.js: -------------------------------------------------------------------------------- 1 | const { makeSimpleShadeupEnvironment } = require("./shadeup-compiler.umd.cjs"); 2 | const Parser = require("web-tree-sitter"); 3 | 4 | const path = require("path"); 5 | const { fileURLToPath } = require("url"); 6 | 7 | module.exports.makeLSPCompiler = async function makeLSPCompiler() { 8 | await Parser.init(); 9 | const parser = new Parser(); 10 | const Lang = await Parser.Language.load( 11 | path.resolve(path.dirname(__filename), "tree-sitter-shadeup.wasm") 12 | ); 13 | parser.setLanguage(Lang); 14 | 15 | global.shadeupParser = () => { 16 | return parser; 17 | }; 18 | 19 | const env = await makeSimpleShadeupEnvironment(true); 20 | 21 | return env; 22 | }; 23 | -------------------------------------------------------------------------------- /extension/vscode/shadeup/server/compiler-dist/readme.md: -------------------------------------------------------------------------------- 1 | modify the output of shadeup-compiler.js to: 2 | 3 | 1. remove the tree sitter wasm strings 4 | 2. Replace getShadeupParse with: 5 | 6 | async function getShadeupParser() { 7 | return global.shadeupParser(); 8 | } 9 | 10 | 3. import fs and replace e4.readFileSync e4 trace up to \_\_viteexternal with fs 11 | -------------------------------------------------------------------------------- /extension/vscode/shadeup/server/compiler-dist/tree-sitter-shadeup.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/extension/vscode/shadeup/server/compiler-dist/tree-sitter-shadeup.wasm -------------------------------------------------------------------------------- /extension/vscode/shadeup/server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lsp-sample-server", 3 | "description": "Example implementation of a language server in node.", 4 | "version": "1.0.0", 5 | "author": "Microsoft Corporation", 6 | "license": "MIT", 7 | "engines": { 8 | "node": "*" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/Microsoft/vscode-extension-samples" 13 | }, 14 | "dependencies": { 15 | "@typescript/vfs": "^1.5.0", 16 | "typescript": "^5.3.3", 17 | "uglify-js": "^3.17.4", 18 | "vscode-languageserver": "^9.0.1", 19 | "vscode-languageserver-textdocument": "^1.0.11", 20 | "web-tree-sitter": "^0.20.8" 21 | }, 22 | "scripts": {} 23 | } 24 | -------------------------------------------------------------------------------- /extension/vscode/shadeup/server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2020", 4 | "lib": ["es2020"], 5 | "module": "commonjs", 6 | "moduleResolution": "node", 7 | "sourceMap": true, 8 | "strict": true, 9 | "outDir": "out", 10 | "rootDir": "src" 11 | }, 12 | "include": ["src"], 13 | "exclude": ["node_modules", ".vscode-test"] 14 | } 15 | -------------------------------------------------------------------------------- /extension/vscode/shadeup/syntaxes/shadeup.tmLanguage.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", 3 | "name": "Shadeup", 4 | "patterns": [ 5 | { 6 | "include": "#keywords" 7 | }, 8 | { 9 | "include": "#strings" 10 | } 11 | ], 12 | "repository": { 13 | "keywords": { 14 | "patterns": [{ 15 | "name": "keyword.control.shadeup", 16 | "match": "\\b(if|while|for|return)\\b" 17 | }] 18 | }, 19 | "strings": { 20 | "name": "string.quoted.double.shadeup", 21 | "begin": "\"", 22 | "end": "\"", 23 | "patterns": [ 24 | { 25 | "name": "constant.character.escape.shadeup", 26 | "match": "\\\\." 27 | } 28 | ] 29 | } 30 | }, 31 | "scopeName": "source.shadeup" 32 | } -------------------------------------------------------------------------------- /extension/vscode/shadeup/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es2020", 5 | "lib": ["es2020"], 6 | "outDir": "out", 7 | "rootDir": "src", 8 | "sourceMap": true 9 | }, 10 | "include": ["src"], 11 | "exclude": ["node_modules", ".vscode-test"], 12 | "references": [{ "path": "./client" }, { "path": "./server" }] 13 | } 14 | -------------------------------------------------------------------------------- /lang/README.md: -------------------------------------------------------------------------------- 1 |

Shadeup logo

2 | 3 |

Shadeup Lang

4 | 5 | Here lies a partial mirror of the shadeup language tools. 6 | 7 | > [!NOTE] 8 | > Running/building this standalone is not possible at the moment, but this is in the works. 9 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite App 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/_extensions.ts: -------------------------------------------------------------------------------- 1 | declare global { 2 | interface Array { 3 | enumerate(): [number, T][]; 4 | filter_map(fn: (value: T, index: number) => B | null): B[]; 5 | max_by_key(fn: (value: T, index: number) => any): T; 6 | chain(arg: any): this; 7 | } 8 | } 9 | 10 | (Array.prototype as any).enumerate = function (): [number, B][] { 11 | let i = 0; 12 | let rv: [number, B][] = []; 13 | for (let item of this) rv.push([i++, item]); 14 | return rv; 15 | }; 16 | 17 | (Array.prototype as any).filter_map = function ( 18 | this, 19 | fn: (value: typeof this, index: number) => B | null 20 | ): B[] { 21 | return this.map(fn).filter((n) => n !== null) as B[]; 22 | }; 23 | 24 | (Array.prototype as any).max_by_key = function ( 25 | this, 26 | fn: (value: typeof this, index: number) => number 27 | ): typeof this { 28 | const max = (self: number[]) => { 29 | return Math.max.apply(null, self); 30 | }; 31 | 32 | return max(this.map(fn)) as any; 33 | }; 34 | 35 | (Array.prototype as any).chain = function (this, that) { 36 | return this.concat(that); 37 | }; 38 | 39 | declare global { 40 | interface Number { 41 | saturating_sub(n: number): number; 42 | max(n: number): number; 43 | min(n: number): number; 44 | } 45 | } 46 | 47 | (Number.prototype as any).saturating_sub = function (n: number): number { 48 | return this.valueOf() - n; 49 | }; 50 | 51 | (Number.prototype as any).max = function (n: number): number { 52 | return Math.max(this.valueOf(), n); 53 | }; 54 | 55 | (Number.prototype as any).min = function (n: number): number { 56 | return Math.min(this.valueOf(), n); 57 | }; 58 | 59 | export const __dummy = 1; 60 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/browser.ts: -------------------------------------------------------------------------------- 1 | import "./_extensions" 2 | export { Display } from "./data/Display" 3 | export { Range } from './data/Range' 4 | export { mkStringWriter } from './data/Write' 5 | export { Color, Fixed } from './lib/Color' 6 | export { ColorGenerator } from "./lib/ColorGenerator" 7 | export { Config } from "./lib/Config" 8 | export { Label } from './lib/Label' 9 | export { Report } from './lib/Report' 10 | export { ReportKind } from './lib/ReportKind' 11 | export { Source, sources } from './lib/Source' 12 | export { format } from "./write" 13 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/data/Display.ts: -------------------------------------------------------------------------------- 1 | import { isCallback } from "../utils"; 2 | import { ColorFn } from "../lib/Color"; 3 | import { isOption, type Option } from "./Option"; 4 | 5 | export interface Display { 6 | fg(color: Option): any; 7 | bg(color: Option): any; 8 | chars(): string; 9 | display(): string; 10 | map(fn: (d: any) => any): this; 11 | unwrap_or_else(d: () => string): string; 12 | } 13 | 14 | export class Display implements Display { 15 | constructor(value: string | Display) { 16 | this.value = typeof value === "string" ? value : value.value 17 | } 18 | fg(color: Option | ColorFn): this { 19 | if (isOption(color)) { 20 | let func = (color.is_some() ? color.unwrap() : (a: any) => a) as any 21 | this.value = func(this.value) 22 | } else if (isCallback(color)) { 23 | this.value = color(this.value) 24 | } 25 | return this 26 | }; 27 | bg(color: Option | ColorFn): this { 28 | if (isOption(color)) { 29 | let func = (color.is_some() ? color.unwrap() : (a: any) => a) as any 30 | this.value = func(this.value) 31 | } else if (isCallback(color)) { 32 | this.value = color(this.value) 33 | } 34 | return this 35 | }; 36 | chars(): string { 37 | return this.value 38 | }; 39 | map(fn: (d: string) => string): Display { 40 | return new Display(fn(this.value)) 41 | }; 42 | display(): string { 43 | return this.value 44 | }; 45 | toString(): string { 46 | return this.value 47 | } 48 | unwrap_or_else(d: () => string): string { 49 | return this.value ?? d() 50 | }; 51 | 52 | private value: string 53 | 54 | static is = (o: any): o is Display => o instanceof Display 55 | } 56 | 57 | export const isDisplay = Display.is; 58 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/data/Formatter.ts: -------------------------------------------------------------------------------- 1 | import { none, type Option } from './Option'; 2 | import { mkStringWriter, type Write, StdoutWriter } from './Write'; 3 | 4 | export enum Alignment { 5 | Left = 'Left', 6 | Right = 'Right', 7 | Center = 'Center' 8 | } 9 | 10 | export interface Formatter { 11 | flags: number; 12 | fill: string; 13 | align: Alignment; 14 | width: Option; 15 | precision: Option; 16 | buf: Write | null; 17 | } 18 | 19 | export const formatter = new (class implements Formatter { 20 | flags: number = 0; 21 | fill: string = ''; 22 | align: Alignment = Alignment.Left; 23 | width: Option = none(); 24 | precision: Option = none(); 25 | buf: Write | null = null; 26 | })(); 27 | 28 | // formatter.buf = new StdoutWriter(); 29 | 30 | export const stringFormatter = () => 31 | new (class implements Formatter { 32 | flags: number = 0; 33 | fill: string = ''; 34 | align: Alignment = Alignment.Left; 35 | width: Option = none(); 36 | precision: Option = none(); 37 | buf = mkStringWriter(); 38 | unwrap() { 39 | return this.buf.unwrap(); 40 | } 41 | })(); 42 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/data/Iter.ts: -------------------------------------------------------------------------------- 1 | export class Iter {} 2 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/data/Range.ts: -------------------------------------------------------------------------------- 1 | import { isNumber, isString } from '../utils'; 2 | import { Span, SpanInit } from './Span'; 3 | 4 | export class Range extends Span { 5 | public SourceId: any = null; 6 | 7 | public source(): any { 8 | return this.SourceId; 9 | } 10 | 11 | public len(): number { 12 | return Math.abs(this.start - this.end); 13 | } 14 | public contains(item: any): boolean { 15 | return item >= this.start && item < this.end; 16 | } 17 | 18 | static is(o: any): o is Range { 19 | return o instanceof Range; 20 | } 21 | 22 | static from(o: SpanInit): Range { 23 | if (isNumber(o[0]) && isNumber(o[1])) return new Span(o[0], o[1]); 24 | 25 | if (isString(o[0]) && Range.is(o[1])) { 26 | const s = new Range(o[1].start, o[1].end); 27 | s.SourceId = o[0]; 28 | return s; 29 | } 30 | 31 | throw new Error(`Invalid SpanInit`); 32 | } 33 | 34 | static new(start: number, end: number): Span { 35 | return new Range(start, end); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/data/Result.ts: -------------------------------------------------------------------------------- 1 | export type Result = Ok | Err; 2 | 3 | class Ok { 4 | constructor(private value: T) {} 5 | map(fn: (value: T) => R): Result { 6 | return ok(fn(this.value)) 7 | } 8 | map_or(d: R, fn: (val: T) => R): Result { 9 | return ok(fn(this.value)) 10 | } 11 | or(d: Result): Result { 12 | return this 13 | } 14 | is_ok(): this is Ok { return true } 15 | is_err(): this is Err { return false } 16 | unwrap(): T { 17 | return this.value 18 | } 19 | unwrap_or_else(d: (v: T) => R): R { 20 | return d(this.value) 21 | } 22 | static is(o: Result): o is Ok { 23 | return o instanceof Ok 24 | } 25 | } 26 | 27 | export class Err { 28 | constructor(private value: E) {} 29 | map(fn: (value: E) => R): Result { 30 | return ok(fn(this.value)) 31 | } 32 | map_or(d: R, fn: (val: T) => R): Result { 33 | return ok(d) 34 | } 35 | or(d: Result): Result { 36 | return d 37 | } 38 | unwrap(): E { 39 | return this.value 40 | } 41 | unwrap_or_else(d: (v: E) => R): R { 42 | return d(this.value) 43 | } 44 | is_ok(): this is Ok { return false } 45 | is_err(): this is Err { return true } 46 | static is(o: Result): o is Err { 47 | return o instanceof Err 48 | } 49 | } 50 | 51 | export const ok = (value: T): Result => { 52 | return new Ok(value); 53 | } 54 | 55 | export const err = (value: E): Result => { 56 | return new Err(value) 57 | } 58 | 59 | export const isResult = (o: any): o is Result => { 60 | return o instanceof Ok || o instanceof Err 61 | } 62 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/data/Show.ts: -------------------------------------------------------------------------------- 1 | 2 | import { Formatter } from "./Formatter"; 3 | import { isOption } from "./Option"; 4 | import { isResult } from "./Result"; 5 | import { isCallback, range } from "../utils"; 6 | import { write } from "../write"; 7 | 8 | export class Show { 9 | constructor(public self: any) {} 10 | fmt(f: Formatter): void { 11 | 12 | if (isOption(this.self)) { 13 | this.self.map(x => new Show(x).fmt(f)) 14 | return 15 | } 16 | if (isResult(this.self)) { 17 | this.self.map(x => new Show(x).fmt(f)) 18 | return 19 | } 20 | if (typeof this.self === "string") { 21 | write(f.buf, "{}", this.self) 22 | return 23 | } 24 | // TODO: this is all probably wrong 25 | if (Array.isArray(this.self) && this.self.length === 2) { 26 | if (isCallback(this.self[1])) { 27 | for (let x of this.self[0]) { 28 | const func = this.self[1]; 29 | func(f, x) 30 | } 31 | } else { 32 | for (let _ of range(0, this.self[1])) { 33 | write(f.buf, "{}", this.self[0]) 34 | } 35 | } 36 | } 37 | else { 38 | const x = this.self[0]; 39 | write(f.buf, "{}", x) 40 | return 41 | } 42 | } 43 | 44 | static is = (o: any): o is Show => o instanceof Show 45 | } 46 | 47 | export const isShow = Show.is 48 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/data/Span.ts: -------------------------------------------------------------------------------- 1 | import { isNumber, isString, range } from "../utils"; 2 | import { Range } from "./Range"; 3 | 4 | export type SpanInit = [src: string, range: Range] | [start: number, end: number]; 5 | 6 | export class Span { 7 | constructor( 8 | private _start: number, 9 | private _end: number, 10 | ) {} 11 | /// The identifier used to uniquely refer to a source. In most cases, this is the fully-qualified path of the file. 12 | SourceId: any; 13 | 14 | /// Get the identifier of the source that this span refers to. 15 | source() { return this.SourceId } 16 | 17 | set start(value: number) { this._start = value }; 18 | get start(): number { return this._start }; 19 | set end(value: number) { this._end = value }; 20 | get end(): number { return this._end }; 21 | 22 | /// Get the length of this span (difference between the start of the span and the end of the span). 23 | len(): number { 24 | return this.end.saturating_sub(this.start) 25 | }; 26 | 27 | /// Determine whether the span contains the given offset. 28 | contains(offset: number): boolean { 29 | return range(this.start, this.end).includes(offset); 30 | }; 31 | 32 | static is = (o: any): o is Span => o instanceof Span 33 | 34 | static from(o: SpanInit) { 35 | if (isNumber(o[0]) && isNumber(o[1])) 36 | return new Span(o[0], o[1]) 37 | 38 | if (isString(o[0]) && Range.is(o[1])) { 39 | const s = new Span(o[1].start, o[1].end); 40 | s.SourceId = o[0] 41 | return s 42 | } 43 | 44 | throw new Error(`Invalid SpanInit`) 45 | } 46 | } 47 | 48 | export const isSpan = Span.is 49 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/data/Write.ts: -------------------------------------------------------------------------------- 1 | import { format } from '../write'; 2 | import { ok, Result } from './Result'; 3 | 4 | export interface Write { 5 | write_str(s: string): Result; 6 | write_char(c: string): Result; 7 | write_fmt(...args: any[]): Result; 8 | } 9 | 10 | export class StdoutWriter implements Write { 11 | write_str(s: string): Result { 12 | throw new Error('Function not implemented'); 13 | } 14 | write_char(c: string): Result { 15 | throw new Error('Function not implemented'); 16 | } 17 | write_fmt(...args: any[]): Result { 18 | console.log(format(...args)); 19 | return ok(null); 20 | } 21 | } 22 | 23 | class StderrWriter implements Write { 24 | write_str(s: string): Result { 25 | throw new Error('Function not implemented'); 26 | } 27 | write_char(c: string): Result { 28 | throw new Error('Function not implemented'); 29 | } 30 | write_fmt(...args: any[]): Result { 31 | process.stderr.write(format(...args)); 32 | return ok(null); 33 | } 34 | } 35 | 36 | class StringWriter implements Write { 37 | private value: string[] = []; 38 | write_str(s: string): Result { 39 | this.value.push(s); 40 | return ok(null); 41 | } 42 | write_char(c: string): Result { 43 | this.value.push(c); 44 | return ok(null); 45 | } 46 | write_fmt(...args: any[]): Result { 47 | this.value.push(format(...args)); 48 | return ok(null); 49 | } 50 | map(fn: (value: string) => any) { 51 | return fn(this.unwrap()); 52 | } 53 | unwrap() { 54 | return this.value.join(''); 55 | } 56 | } 57 | 58 | export const stdoutWriter = new StdoutWriter(); 59 | export const stderrWriter = new StderrWriter(); 60 | export const mkStringWriter = () => new StringWriter(); 61 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/index.ts: -------------------------------------------------------------------------------- 1 | import "./_extensions" 2 | export { Display } from "./data/Display" 3 | export { Range } from './data/Range' 4 | export { Color, Fixed } from './lib/Color' 5 | export { ColorGenerator } from "./lib/ColorGenerator" 6 | export { Config } from "./lib/Config" 7 | export { Label } from './lib/Label' 8 | export { Report } from './lib/Report' 9 | export { ReportKind } from './lib/ReportKind' 10 | export { Source, sources } from './lib/Source' 11 | export { include_str } from './utils/include_str' 12 | export { format } from "./write" 13 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/lib/Characters.ts: -------------------------------------------------------------------------------- 1 | 2 | export interface iCharacters { 3 | hbar: string; 4 | vbar: string; 5 | xbar: string; 6 | vbar_break: string; 7 | vbar_gap: string; 8 | 9 | uarrow: string; 10 | rarrow: string; 11 | 12 | ltop: string; 13 | mtop: string; 14 | rtop: string; 15 | lbot: string; 16 | rbot: string; 17 | mbot: string; 18 | 19 | lbox: string; 20 | rbox: string; 21 | 22 | lcross: string; 23 | rcross: string; 24 | 25 | underbar: string; 26 | underline: string; 27 | } 28 | 29 | export abstract class Characters { 30 | static unicode(): iCharacters { 31 | return { 32 | hbar: '─', 33 | vbar: '│', 34 | xbar: '┼', 35 | vbar_break: '·', 36 | vbar_gap: '⋮', 37 | uarrow: '▲', 38 | rarrow: '▶', 39 | ltop: '╭', 40 | mtop: '┬', 41 | rtop: '╮', 42 | lbot: '╰', 43 | mbot: '┴', 44 | rbot: '╯', 45 | lbox: '[', 46 | rbox: ']', 47 | lcross: '├', 48 | rcross: '┤', 49 | underbar: '┬', 50 | underline: '─', 51 | }; 52 | } 53 | 54 | static ascii(): iCharacters { 55 | return { 56 | hbar: '-', 57 | vbar: '|', 58 | xbar: '+', 59 | vbar_break: '*', 60 | vbar_gap: ':', 61 | uarrow: '^', 62 | rarrow: '>', 63 | ltop: ',', 64 | mtop: 'v', 65 | rtop: '.', 66 | lbot: '`', 67 | mbot: '^', 68 | rbot: '\'', 69 | lbox: '[', 70 | rbox: ']', 71 | lcross: '|', 72 | rcross: '|', 73 | underbar: '|', 74 | underline: '^', 75 | }; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/lib/Color.ts: -------------------------------------------------------------------------------- 1 | import chalk, { ChalkInstance } from './chalk/chalk/source/index'; 2 | 3 | const options: any = { enabled: true, level: 2 }; 4 | const c = chalk; 5 | 6 | export const colors = { 7 | blue: c.blue, 8 | green: c.green, 9 | red: c.red, 10 | yellow: c.yellow 11 | }; 12 | 13 | export const bgColors = { 14 | blue: c.bgBlue, 15 | green: c.bgGreen, 16 | red: c.bgRed, 17 | yellow: c.bgYellow 18 | }; 19 | 20 | export type ColorFn = ((s: string) => string) | ChalkInstance; 21 | 22 | export abstract class Color { 23 | static Fixed = Fixed; 24 | } 25 | 26 | export function Fixed(n: number) { 27 | return c.ansi256(n); 28 | } 29 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/lib/ColorGenerator.ts: -------------------------------------------------------------------------------- 1 | 2 | import { ColorFn, Fixed } from "./Color" 3 | import { clamp, range, wrapping_add_usize } from "../utils" 4 | 5 | /// A type that can generate distinct 8-bit colors. 6 | export class ColorGenerator { 7 | constructor( 8 | public state: [number, number, number], 9 | public min_brightness: number, 10 | ) {} 11 | 12 | /// Create a new [`ColorGenerator`] with the given pre-chosen state. 13 | /// 14 | /// The minimum brightness can be used to control the colour brightness (0.0 - 1.0). The default is 0.5. 15 | static from_state(state: [number, number, number], min_brightness: number): ColorGenerator { 16 | return new ColorGenerator(state, clamp(min_brightness, 0.0, 1.0)) 17 | } 18 | 19 | /// Create a new [`ColorGenerator`] with the default state. 20 | static new(): ColorGenerator { 21 | return ColorGenerator.default() 22 | } 23 | 24 | /// Generate the next colour in the sequence. 25 | next(out?: [number, ColorFn][]): ColorFn { 26 | for (let i of range(0, 3)) { 27 | // magic constant, one of only two that have this property! 28 | const rhs = 40503 * (i * 4 + 1130) 29 | const c = wrapping_add_usize(this.state[i], rhs) 30 | const u16 = parseInt(`${c.toString(2).slice(-16)}`, 2) 31 | this.state[i] = u16; 32 | } 33 | 34 | const value = Math.floor(16 35 | + ((this.state[2] / 65535.0 * (1.0 - this.min_brightness) + this.min_brightness) * 5.0 36 | + (this.state[1] / 65535.0 * (1.0 - this.min_brightness) + this.min_brightness) * 30.0 37 | + (this.state[0] / 65535.0 * (1.0 - this.min_brightness) + this.min_brightness) * 180.0) % 256) 38 | 39 | const colorFn = Fixed(value); 40 | out?.push([value, colorFn]) 41 | return colorFn 42 | } 43 | 44 | static default(): ColorGenerator { 45 | return new ColorGenerator([30000, 15000, 35000], 0.5) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/lib/LabelInfo.ts: -------------------------------------------------------------------------------- 1 | 2 | import { Range } from "../data/Range"; 3 | import { Label } from "./Label"; 4 | 5 | export enum LabelKind { 6 | Inline = 'Inline', 7 | Multiline = 'Multiline', 8 | } 9 | 10 | export class LabelInfo { 11 | constructor( 12 | public kind: LabelKind, 13 | public label: Label, 14 | ) {} 15 | } 16 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/lib/ReportKind.ts: -------------------------------------------------------------------------------- 1 | import { Formatter } from "../data/Formatter"; 2 | import { write } from "../write"; 3 | 4 | /// A type that defines the kind of report being produced. 5 | 6 | export class ReportKind { 7 | constructor(...args: any[]) {} 8 | fmt(f: Formatter): any { 9 | if (this instanceof ReportKind.Error) 10 | return write(f.buf, "Error"); 11 | if (this instanceof ReportKind.Warning) 12 | return write(f.buf, "Warning"); 13 | if (this instanceof ReportKind.Advice) 14 | return write(f.buf, "Advice"); 15 | if (this instanceof ReportKind.Custom) 16 | return write(f.buf, "{}", this.s); 17 | throw 'invalid ReportKind'; 18 | } 19 | /// The report is an error and indicates a critical problem that prevents the program performing the requested 20 | /// action. 21 | static Error = class Error extends ReportKind { }; 22 | /// The report is a warning and indicates a likely problem, but not to the extent that the requested action cannot 23 | /// be performed. 24 | static Warning = class Warning extends ReportKind { }; 25 | /// The report is advice to the user about a potential anti-pattern of other benign issues. 26 | static Advice = class Advice extends ReportKind { }; 27 | /// The report is of a kind not built into Ariadne. 28 | static Custom = class Custom extends ReportKind { 29 | constructor(public s: any, public color: any) { 30 | super() 31 | } 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/lib/SourceGroup.ts: -------------------------------------------------------------------------------- 1 | import { Span } from "../data/Span"; 2 | import { Range } from "../data/Range"; 3 | import { LabelInfo } from "./LabelInfo"; 4 | 5 | export class SourceGroup { 6 | constructor( 7 | public src_id: string, 8 | public span: Range, 9 | public labels: LabelInfo[] 10 | ) { } 11 | } 12 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/lib/chalk/chalk/license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Sindre Sorhus (https://sindresorhus.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/lib/chalk/chalk/source/utilities.js: -------------------------------------------------------------------------------- 1 | // TODO: When targeting Node.js 16, use `String.prototype.replaceAll`. 2 | export function stringReplaceAll(string, substring, replacer) { 3 | let index = string.indexOf(substring); 4 | if (index === -1) { 5 | return string; 6 | } 7 | 8 | const substringLength = substring.length; 9 | let endIndex = 0; 10 | let returnValue = ''; 11 | do { 12 | returnValue += string.slice(endIndex, index) + substring + replacer; 13 | endIndex = index + substringLength; 14 | index = string.indexOf(substring, endIndex); 15 | } while (index !== -1); 16 | 17 | returnValue += string.slice(endIndex); 18 | return returnValue; 19 | } 20 | 21 | export function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) { 22 | let endIndex = 0; 23 | let returnValue = ''; 24 | do { 25 | const gotCR = string[index - 1] === '\r'; 26 | returnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\r\n' : '\n') + postfix; 27 | endIndex = index + 1; 28 | index = string.indexOf('\n', endIndex); 29 | } while (index !== -1); 30 | 31 | returnValue += string.slice(endIndex); 32 | return returnValue; 33 | } 34 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/lib/chalk/chalk/source/vendor/supports-color/browser.d.ts: -------------------------------------------------------------------------------- 1 | export {default} from './index.js'; 2 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/lib/chalk/chalk/source/vendor/supports-color/browser.js: -------------------------------------------------------------------------------- 1 | /* eslint-env browser */ 2 | 3 | const level = (() => { 4 | if (navigator.userAgentData) { 5 | const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium'); 6 | if (brand && brand.version > 93) { 7 | return 3; 8 | } 9 | } 10 | 11 | if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) { 12 | return 1; 13 | } 14 | 15 | return 0; 16 | })(); 17 | 18 | const colorSupport = level !== 0 && { 19 | level, 20 | hasBasic: true, 21 | has256: level >= 2, 22 | has16m: level >= 3, 23 | }; 24 | 25 | const supportsColor = { 26 | stdout: colorSupport, 27 | stderr: colorSupport, 28 | }; 29 | 30 | export default supportsColor; 31 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/lib/chalk/chalk/source/vendor/supports-color/index.d.ts: -------------------------------------------------------------------------------- 1 | import type {WriteStream} from 'node:tty'; 2 | 3 | export type Options = { 4 | /** 5 | Whether `process.argv` should be sniffed for `--color` and `--no-color` flags. 6 | 7 | @default true 8 | */ 9 | readonly sniffFlags?: boolean; 10 | }; 11 | 12 | /** 13 | Levels: 14 | - `0` - All colors disabled. 15 | - `1` - Basic 16 colors support. 16 | - `2` - ANSI 256 colors support. 17 | - `3` - Truecolor 16 million colors support. 18 | */ 19 | export type ColorSupportLevel = 0 | 1 | 2 | 3; 20 | 21 | /** 22 | Detect whether the terminal supports color. 23 | */ 24 | export type ColorSupport = { 25 | /** 26 | The color level. 27 | */ 28 | level: ColorSupportLevel; 29 | 30 | /** 31 | Whether basic 16 colors are supported. 32 | */ 33 | hasBasic: boolean; 34 | 35 | /** 36 | Whether ANSI 256 colors are supported. 37 | */ 38 | has256: boolean; 39 | 40 | /** 41 | Whether Truecolor 16 million colors are supported. 42 | */ 43 | has16m: boolean; 44 | }; 45 | 46 | export type ColorInfo = ColorSupport | false; 47 | 48 | export function createSupportsColor(stream?: WriteStream, options?: Options): ColorInfo; 49 | 50 | declare const supportsColor: { 51 | stdout: ColorInfo; 52 | stderr: ColorInfo; 53 | }; 54 | 55 | export default supportsColor; 56 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/utils/binary_search_by_key.ts: -------------------------------------------------------------------------------- 1 | import { err, ok, Result } from '../data/Result'; 2 | 3 | 4 | export function binary_search_by_key(arr: T[], x: any, fn: (o: T) => number): Result { 5 | 6 | let start = 0, end = arr.length - 1, mid, val; 7 | 8 | // Iterate while start not meets end 9 | while (start < end) { 10 | 11 | // Find the mid index 12 | mid = Math.floor((start + end) / 2); 13 | 14 | val = fn(arr[mid]); 15 | 16 | // If element is present at mid, return True 17 | if (val === x) 18 | return ok(mid); 19 | 20 | 21 | // Else look in left or right half accordingly 22 | else if (val < x) 23 | start = mid + 1; 24 | 25 | else 26 | end = mid - 1; 27 | } 28 | 29 | return err(get_sorted_index(arr, x, fn)); 30 | } 31 | function get_sorted_index(arr: any[], x: any, fn: any) { 32 | let low = 0, high = arr.length; 33 | 34 | while (low < high) { 35 | let mid = (low + high) >>> 1; 36 | if (x > fn(arr[mid])) 37 | low = mid + 1; 38 | else 39 | high = mid; 40 | } 41 | 42 | return low; 43 | } 44 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/utils/include_str.ts: -------------------------------------------------------------------------------- 1 | // import { readFileSync } from 'fs'; 2 | import { join } from 'path'; 3 | 4 | export function include_str(path: string): string { 5 | // return readFileSync(join(process.cwd(), path)).toString(); 6 | return ''; 7 | } 8 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/ariadne-ts/src/write.ts: -------------------------------------------------------------------------------- 1 | import sf from './stringFormat.js'; 2 | import { Display, isDisplay } from './data/Display'; 3 | import { stringFormatter } from './data/Formatter'; 4 | import { isOption, Option } from './data/Option'; 5 | import { isResult, Result } from './data/Result'; 6 | import { Write } from './data/Write'; 7 | import { isShow, Show } from './data/Show'; 8 | 9 | export type Displayable = 10 | | Display 11 | | Show 12 | | Option 13 | | Result 14 | | string 15 | | number; 16 | 17 | export function write(w: W, ...args: Displayable[]) { 18 | w.write_fmt(format(...args.map(fromRust))); 19 | } 20 | 21 | export function format(...args: Displayable[]): string { 22 | const [head, ...rest] = args.map(fromRust); 23 | return sf(head, ...rest); 24 | } 25 | 26 | function fromRust(node: Displayable): string { 27 | if (isDisplay(node)) { 28 | return node.display(); 29 | } 30 | if (isShow(node)) { 31 | let f = stringFormatter(); 32 | node.fmt(f); 33 | return f.unwrap(); 34 | } 35 | if (isOption(node)) { 36 | return node.unwrap_or_else(() => '') as string; 37 | } 38 | if (isResult(node)) { 39 | return node.unwrap_or_else(() => '<(Unwrap Err)>'); 40 | } 41 | return node.toString(); 42 | } 43 | 44 | export function writeln(w: W, ...args: Displayable[]) { 45 | let val = format(...args.map(fromRust)); 46 | w.write_fmt(val); 47 | w.write_fmt('\n'); 48 | } 49 | 50 | export function eprintln(...args: Displayable[]): void { 51 | console.error(format(...args)); 52 | } 53 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/environment/Errors.ts: -------------------------------------------------------------------------------- 1 | import ts from 'typescript'; 2 | 3 | export function nicerError(e: ts.DiagnosticMessageChain | ts.DiagnosticRelatedInformation) { 4 | if (e.code == 1070) { 5 | return 'Static/public methods are not supported on traits'; 6 | } 7 | 8 | return e.messageText.toString(); 9 | } 10 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/generator/eval.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/shadeup-frontend/lib/generator/eval.js -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/generator/tsWalk.ts: -------------------------------------------------------------------------------- 1 | import ts from 'typescript'; 2 | import { SourceNode } from './root'; 3 | 4 | export type TSVisitData = { 5 | ast: ts.Node; 6 | checker: ts.TypeChecker; 7 | getType: () => ts.Type; 8 | 9 | /** Visits the node and evaluates the handler */ 10 | c: (ast: ts.Node) => SourceNode | string; 11 | 12 | /** Generates a SourceNode based on the current ast node */ 13 | s: (c: (SourceNode | string)[]) => SourceNode; 14 | 15 | /** Generates a SourceNode based on the provided ast node*/ 16 | sWith: (c: (SourceNode | string)[], n: ts.Node) => SourceNode; 17 | }; 18 | 19 | export type TSVisitHandler = (data: TSVisitData) => SourceNode | string; 20 | 21 | export type TSVisitMapper = { 22 | function: TSVisitHandler; 23 | if: TSVisitHandler; 24 | identifier: TSVisitHandler; 25 | number: TSVisitHandler; 26 | string: TSVisitHandler; 27 | program: TSVisitHandler; 28 | expression_statement: TSVisitHandler; 29 | binary_expression: TSVisitHandler; 30 | function_declaration: TSVisitHandler; 31 | }; 32 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/generator/util.ts: -------------------------------------------------------------------------------- 1 | import ts from 'typescript'; 2 | 3 | export function resolveNodeName(c: ts.Node) { 4 | return `${c.getSourceFile().fileName.replaceAll('/', '_').replaceAll('.', '_')}_${c.getStart()}`; 5 | } 6 | 7 | export function cleanName(name: string) { 8 | return name 9 | .replaceAll('file:///', '') 10 | .replaceAll('.', '_dot_') 11 | .replaceAll('/', '_slash_') 12 | .replaceAll('-', '_dash_'); 13 | } 14 | 15 | export function closest(node: ts.Node, cb: (node: ts.Node) => boolean) { 16 | while (node) { 17 | if (cb(node)) return node; 18 | node = node.parent!; 19 | } 20 | return null; 21 | } 22 | 23 | /** 24 | * Finds any @shadeup=tag(xyz) tags on a function declaration 25 | */ 26 | export function findShadeupTags(declar: ts.FunctionDeclaration | ts.MethodDeclaration): string[] { 27 | let matcher = /=tag\((.+)\)$/g; 28 | let doc = ts.getJSDocTags(declar); 29 | 30 | for (let d of doc) { 31 | if (d.tagName.text !== 'shadeup') continue; 32 | 33 | if (typeof d.comment === 'string') { 34 | let matches = matcher.exec(d.comment); 35 | if (matches) { 36 | return matches[1].split(',').map((s) => s.trim()); 37 | } 38 | } 39 | } 40 | return []; 41 | } 42 | 43 | export function getFunctionDeclarationFromCallExpression( 44 | checker: ts.TypeChecker, 45 | node: ts.CallExpression 46 | ): ts.FunctionDeclaration | undefined { 47 | if (ts.isCallExpression(node)) { 48 | let exprSmybol = checker.getSymbolAtLocation(node.expression); 49 | if (exprSmybol && exprSmybol.flags & ts.SymbolFlags.Alias) { 50 | exprSmybol = checker.getAliasedSymbol(exprSmybol); 51 | } 52 | if (exprSmybol) { 53 | let funcDeclar = exprSmybol.getDeclarations()?.[0]; 54 | 55 | if (funcDeclar && ts.isFunctionDeclaration(funcDeclar)) { 56 | return funcDeclar; 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/main.ts: -------------------------------------------------------------------------------- 1 | import { SourceMapConsumer } from 'source-map'; 2 | import { compile } from './generator/root'; 3 | import { getShadeupParser } from './parser'; 4 | import { AstContext } from './parser/AstContext'; 5 | 6 | import sourceMappingURL from 'source-map/lib/mappings.wasm?url'; 7 | import { ShadeupEnvironment } from './environment/ShadeupEnvironment'; 8 | 9 | export async function initTest() { 10 | let env = new ShadeupEnvironment(); 11 | await env.init(); 12 | await env.writeFile( 13 | '/file.ts', 14 | ` 15 | import "./other"; 16 | ` 17 | ); 18 | 19 | let s = ''; 20 | 21 | await env.writeFile( 22 | '/other.ts', 23 | ` 24 | struct Reference { 25 | id: int; 26 | } 27 | 28 | struct BoundingBox { 29 | min: float3; 30 | max: float3; 31 | 32 | references: Reference[3]; 33 | } 34 | 35 | struct Player { 36 | health: float; 37 | pos: float2; 38 | bb: BoundingBox; 39 | } 40 | 41 | let outsideRef = 1; 42 | 43 | let x = shader { 44 | let p = Player { 45 | health: float(outsideRef), 46 | }; 47 | }; 48 | ` 49 | ); 50 | await env.regenerate(); 51 | let errors = await env.errors(); 52 | for (let e of errors) { 53 | document.write(`
${e.message}
`); 54 | document.body.style.backgroundColor = 'black'; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/parser/AstContext.ts: -------------------------------------------------------------------------------- 1 | import { SyntaxNode } from 'web-tree-sitter'; 2 | import { GLSLShader } from '../generator/glsl'; 3 | 4 | type AstDiagnostic = { 5 | message: string; 6 | node: SyntaxNode; 7 | }; 8 | 9 | export class AstContext { 10 | fileName: string; 11 | impls: Map = new Map(); 12 | implsFor: Map = new Map(); 13 | shaders: GLSLShader[] = []; 14 | diagnostics: AstDiagnostic[] = []; 15 | globals: string[] = []; 16 | 17 | constructor(fileName: string) { 18 | this.fileName = fileName; 19 | } 20 | 21 | report(node: SyntaxNode, message: string) { 22 | this.diagnostics.push({ message, node }); 23 | } 24 | 25 | addImpl(name: string, node: SyntaxNode) { 26 | if (this.impls.has(name)) { 27 | this.impls.get(name)!.push(node); 28 | } else { 29 | this.impls.set(name, [node]); 30 | } 31 | } 32 | 33 | addImplFor(name: string, node: SyntaxNode) { 34 | if (this.implsFor.has(name)) { 35 | this.implsFor.get(name)!.push(node); 36 | } else { 37 | this.implsFor.set(name, [node]); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/parser/index.ts: -------------------------------------------------------------------------------- 1 | import Parser from 'web-tree-sitter'; 2 | import treeSitterShadeupURL from './tree-sitter-shadeup.wasm?url'; 3 | import treeSitterURL from 'web-tree-sitter/tree-sitter.wasm?url'; 4 | 5 | let wasm: Promise | null = null; 6 | 7 | function isBrowser() { 8 | if (typeof window !== 'undefined') { 9 | return true; 10 | } 11 | if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { 12 | return true; 13 | } 14 | return false; 15 | } 16 | 17 | export async function getShadeupParser() { 18 | // if (typeof process === 'object') { 19 | // // let nodeParser = (await import('./node.cjs')).default; 20 | // return nodeParser(); 21 | // } else { 22 | // if (isBrowser()) { 23 | 24 | let url = treeSitterURL; 25 | let shadeUrl = treeSitterShadeupURL; 26 | // if (typeof window === 'undefined') { 27 | // url = './tree-sitter.wasm'; 28 | // shadeUrl = './tree-sitter-shadeup.wasm'; 29 | // } 30 | // if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { 31 | // url = treeSitterURL; 32 | // shadeUrl = treeSitterShadeupURL; 33 | // } 34 | // console.log('Loading parser', url, Parser); 35 | await Parser.init({ 36 | locateFile(scriptName: string, scriptDirectory: string) { 37 | return url; 38 | } 39 | }); 40 | 41 | const parser = new Parser(); 42 | 43 | parser.setLanguage(await Parser.Language.load(shadeUrl)); 44 | 45 | return parser; 46 | // } else { 47 | // // let nodeParser = (await import('./node.cjs')).default; 48 | // // return nodeParser(); 49 | // return global.shadeupParser(); 50 | // } 51 | } 52 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/parser/node.cjs: -------------------------------------------------------------------------------- 1 | const ParserNode = require('tree-sitter'); 2 | const ShadeupParser = require('../../../tree-sitter/bindings/node/index'); 3 | 4 | module.exports = function () { 5 | const parser = new ParserNode(); 6 | parser.setLanguage(ShadeupParser); 7 | return parser; 8 | }; 9 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/parser/tree-sitter-javascript.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/shadeup-frontend/lib/parser/tree-sitter-javascript.wasm -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/parser/tree-sitter-shadeup.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/shadeup-frontend/lib/parser/tree-sitter-shadeup.wasm -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/parser/tree-sitter.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/shadeup-frontend/lib/parser/tree-sitter.wasm -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/parser/wasm.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/shadeup-frontend/lib/parser/wasm.ts -------------------------------------------------------------------------------- /lang/shadeup-frontend/lib/std/static-math-db.ts: -------------------------------------------------------------------------------- 1 | export const simpleFunctions = [ 2 | ['add', '+'], 3 | ['sub', '-'], 4 | ['div', '/'], 5 | ['mul', '*'], 6 | ['mod', '%'], 7 | ['bitand', '&'], 8 | ['bitor', '|'], 9 | ['bitxor', '^'], 10 | ['lshift', '<<'], 11 | ['rshift', '>>'] 12 | ]; 13 | 14 | export const singleFunctions = [ 15 | ['bitnot', (a) => `~${a}`], 16 | ['negate', (a) => `-${a}`], 17 | ['positive', 'Math.abs'], 18 | ['abs', 'Math.abs'], 19 | ['floor', 'Math.floor'], 20 | ['ceil', 'Math.ceil'], 21 | ['round', 'Math.round'], 22 | ['sign', 'Math.sign'], 23 | ['cos', 'Math.cos'], 24 | ['sin', 'Math.sin'], 25 | ['tan', 'Math.tan'], 26 | ['acos', 'Math.acos'], 27 | ['asin', 'Math.asin'], 28 | ['atan', 'Math.atan'], 29 | ['cosh', 'Math.cosh'], 30 | ['sinh', 'Math.sinh'], 31 | ['tanh', 'Math.tanh'], 32 | ['acosh', 'Math.acosh'], 33 | ['asinh', 'Math.asinh'], 34 | ['atanh', 'Math.atanh'], 35 | ['exp', 'Math.exp'], 36 | ['log', 'Math.log'], 37 | ['log2', 'Math.log2'], 38 | ['log10', 'Math.log10'], 39 | ['sqrt', 'Math.sqrt'] 40 | ]; 41 | 42 | export const makeVectors = [ 43 | ['int', '|0'], 44 | ['float', ''], 45 | ['uint', '>>>0'] 46 | ]; 47 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shadeup-frontend", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "files": [ 7 | "src" 8 | ], 9 | "main": "./dist/shadeup-frontend.umd.cjs", 10 | "module": "./dist/shadeup-frontend.js", 11 | "types": "./dist/src/index.d.ts", 12 | "exports": { 13 | ".": { 14 | "import": "./dist/shadeup-frontend.js", 15 | "require": "./dist/shadeup-frontend.umd.cjs" 16 | } 17 | }, 18 | "scripts": { 19 | "dev": "vite", 20 | "build": "tsc && vite build", 21 | "build:math": "tsx lib/std/generate-static-math.ts > lib/std/static-math.ts" 22 | }, 23 | "dependencies": { 24 | "@esbuild-plugins/node-globals-polyfill": "^0.2.3", 25 | "@rollup/plugin-node-resolve": "^15.0.1", 26 | "@typescript/vfs": "^1.4.0", 27 | "ansi_up": "^5.1.0", 28 | "ariadne-ts": "^0.1.5-alpha.10", 29 | "assert": "^2.0.0", 30 | "chalk": "^5.3.0", 31 | "fast-diff": "^1.2.0", 32 | "fast-sha256": "^1.3.0", 33 | "js-sha256": "^0.9.0", 34 | "lz-string": "^1.4.4", 35 | "punycode": "^2.3.0", 36 | "source-map": "^0.8.0-beta.0", 37 | "string-format": "^2.0.0", 38 | "toposort": "^2.0.2", 39 | "tree-sitter": "^0.20.5", 40 | "tsutils": "^3.21.0", 41 | "typescript": "^4.9.5", 42 | "web-tree-sitter": "^0.20.7" 43 | }, 44 | "devDependencies": { 45 | "@types/node": "^18.14.2", 46 | "@types/string-format": "^2.0.0", 47 | "@types/toposort": "^2.0.3", 48 | "rollup-plugin-polyfill-node": "^0.12.0", 49 | "tsx": "^3.12.7", 50 | "typescript": "^4.9.4", 51 | "vite": "^4.4.7", 52 | "vite-plugin-dts": "^2.0.2" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/src/index.ts: -------------------------------------------------------------------------------- 1 | if (typeof process === 'undefined') { 2 | (global as any).process = { env: {} }; 3 | } 4 | 5 | export { ShadeupEnvironment } from '../lib/environment/ShadeupEnvironment'; 6 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/src/main.ts: -------------------------------------------------------------------------------- 1 | import { initTest } from '../lib/main'; 2 | 3 | initTest(); 4 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "module": "ESNext", 6 | "lib": ["ESNext", "DOM"], 7 | "moduleResolution": "Node", 8 | "sourceMap": true, 9 | "resolveJsonModule": true, 10 | "isolatedModules": true, 11 | "esModuleInterop": true, 12 | "noEmit": true, 13 | "skipLibCheck": true 14 | }, 15 | "include": ["src", "lib"] 16 | } 17 | -------------------------------------------------------------------------------- /lang/shadeup-frontend/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | // import nodePolyfills from 'rollup-plugin-polyfill-node'; 3 | import dts from 'vite-plugin-dts'; 4 | // import nodeResolve from '@rollup/plugin-node-resolve'; 5 | 6 | export default defineConfig({ 7 | esbuild: { 8 | keepNames: true 9 | }, 10 | 11 | build: { 12 | lib: { 13 | entry: './src/index.ts', 14 | name: 'shadeup-frontend', 15 | fileName: 'shadeup-frontend' 16 | }, 17 | target: 'esnext', 18 | sourcemap: false 19 | }, 20 | resolve: { 21 | alias: { 22 | punycode: 'punycode/punycode.js' 23 | // '#ansi-styles': 'chalk/source/vendor/ansi-styles/index.js', 24 | // '#supports-color': 'chalk/source/vendor/supports-color/index.js' 25 | } 26 | }, 27 | optimizeDeps: { 28 | esbuildOptions: { 29 | define: { 30 | global: 'globalThis' 31 | } 32 | } 33 | }, 34 | plugins: [dts()] 35 | }); 36 | -------------------------------------------------------------------------------- /lang/shadeup/alert.ts: -------------------------------------------------------------------------------- 1 | export type ShadeupAlert = { 2 | level: 'info' | 'warning' | 'error'; 3 | message: string; 4 | location: Number; 5 | line?: Number; 6 | column?: Number; 7 | }; 8 | -------------------------------------------------------------------------------- /lang/shadeup/compiler/assets.json: -------------------------------------------------------------------------------- 1 | [ 2 | ["heightmaps/crater-lake-color", "image"], 3 | ["heightmaps/crater-lake", "image"], 4 | ["heightmaps/grand-canyon", "image"], 5 | ["heightmaps/rugged", "image"], 6 | ["models/bunny", "model"], 7 | ["models/cornell-box", "model"], 8 | ["models/dragon", "model"], 9 | ["models/erato", "model"], 10 | ["models/head", "model"], 11 | ["models/sponza", "model"], 12 | ["models/suzanne", "model"], 13 | ["models/teapot", "model"], 14 | ["textures/bark/arm", "image"], 15 | ["textures/bark/color", "image"], 16 | ["textures/bark/displacement", "image"], 17 | ["textures/bark/normal", "image"], 18 | ["textures/beach/arm", "image"], 19 | ["textures/beach/color", "image"], 20 | ["textures/beach/displacement", "image"], 21 | ["textures/beach/normal", "image"], 22 | ["textures/brick/arm", "image"], 23 | ["textures/brick/color", "image"], 24 | ["textures/brick/displacement", "image"], 25 | ["textures/brick/normal", "image"], 26 | ["textures/pebbles/arm", "image"], 27 | ["textures/pebbles/color", "image"], 28 | ["textures/pebbles/displacement", "image"], 29 | ["textures/pebbles/normal", "image"], 30 | ["textures/stone-path/arm", "image"], 31 | ["textures/stone-path/color", "image"], 32 | ["textures/stone-path/displacement", "image"], 33 | ["textures/stone-path/normal", "image"], 34 | ["textures/wood/arm", "image"], 35 | ["textures/wood/color", "image"], 36 | ["textures/wood/normal", "image"] 37 | ] 38 | -------------------------------------------------------------------------------- /lang/shadeup/compiler/assets.ts: -------------------------------------------------------------------------------- 1 | import type { AssetFileType } from '../../components/common/Asset'; 2 | 3 | import builtInAssets from './assets.json'; 4 | 5 | export function buildAssetsFile(content: string) { 6 | let out = ` 7 | import { 8 | float4, 9 | float3, 10 | float, 11 | float2, 12 | bool, 13 | int, 14 | int2, 15 | int3, 16 | int4, 17 | uint, 18 | uint2, 19 | uint3, 20 | uint4, 21 | uint8 22 | } from '/std_math'; 23 | 24 | import { Mesh, Model } from '/_std/mesh'; 25 | import { texture2d } from '/_std/texture'; 26 | 27 | declare global {\n`; 28 | let typeMapping: { [key in AssetFileType]: string } = { 29 | image: 'texture2d', 30 | audio: 'unknown', 31 | video: 'unknown', 32 | binary: 'buffer', 33 | text: 'string', 34 | model: 'Model' 35 | }; 36 | 37 | try { 38 | let parsed = JSON.parse(content); 39 | 40 | parsed.forEach((asset: { name: string; type: AssetFileType; previewId: string }) => { 41 | let docCom = `![thumb](https://assets.shadeup.dev/`; 42 | out += ` 43 | /** 44 | * ${docCom}${asset.previewId}) 45 | */ 46 | function load(asset: '${asset.name}'): ${typeMapping[asset.type]}; 47 | `; 48 | }); 49 | } catch (e) { 50 | console.error(e); 51 | } 52 | 53 | for (let asset of builtInAssets) { 54 | out += ` 55 | /** 56 | * Built-in asset: ${asset[0]} 57 | */ 58 | function load(asset: '${asset[0]}'): ${typeMapping[asset[1] as AssetFileType]}; 59 | `; 60 | } 61 | 62 | return out + `}`; 63 | } 64 | 65 | export const defaultAssets = builtInAssets; 66 | -------------------------------------------------------------------------------- /lang/shadeup/compiler/generateTsCache.ts: -------------------------------------------------------------------------------- 1 | import { 2 | ShadeupEnvironment, 3 | type ShadeupGenericDiagnostic 4 | } from '../../../../shadeup-frontend/lib/environment/ShadeupEnvironment'; 5 | import type { 6 | MessageMainToWorker, 7 | MessageWorkerToMain, 8 | ShadeupDiagnostic, 9 | ShadeupRenderedFile 10 | } from './common'; 11 | import { 12 | lookupIndexMappingRange, 13 | reverseLookupIndexMapping 14 | } from '../../../../shadeup-frontend/lib/generator/root'; 15 | import { indexToRowColumn } from '../../../../shadeup-frontend/lib/environment/ShadeupEnvironment'; 16 | import ts from 'typescript'; 17 | import files from '../library/files'; 18 | 19 | export async function generateTsCache() { 20 | let env = new ShadeupEnvironment(); 21 | env.emitLogs = false; 22 | await env.init(); 23 | env.stdEmitCache.clear(); 24 | await env.writeFile( 25 | '/file.ts', 26 | ` 27 | 28 | ` 29 | ); 30 | 31 | let writes: Promise[] = []; 32 | 33 | let initFiles = ['/file.ts']; 34 | 35 | let start = performance.now(); 36 | 37 | for (let [path, contents] of Object.entries(files.ts)) { 38 | let p = '/_std/' + path + '.ts'; 39 | if (path == 'std') p = '/std.ts'; // So we can import it via import ui from "std"; 40 | 41 | writes.push(env.writeFileTypescript(p, contents)); 42 | initFiles.push(p); 43 | } 44 | 45 | for (let [path, contents] of Object.entries(files.shadeup)) { 46 | let p = '/_std/' + path + '.ts'; 47 | writes.push(env.writeFile(p, contents, true)); 48 | initFiles.push(p); 49 | } 50 | 51 | await Promise.all(writes); 52 | 53 | await env.regenerate(); 54 | let outs = await env.errors(); 55 | for (let out of outs) { 56 | if (out.error) { 57 | console.log(out.error); 58 | } 59 | } 60 | 61 | return env.stdEmitCache; 62 | } 63 | -------------------------------------------------------------------------------- /lang/shadeup/compiler/simple.ts: -------------------------------------------------------------------------------- 1 | import { ShadeupEnvironment } from '../../../../shadeup-frontend/lib/environment/ShadeupEnvironment'; 2 | 3 | import files from '../library/files'; 4 | 5 | export async function makeSimpleShadeupEnvironment() { 6 | let env = new ShadeupEnvironment(); 7 | env.emitLogs = false; 8 | await env.init(); 9 | await env.writeFile( 10 | '/file.ts', 11 | ` 12 | 13 | ` 14 | ); 15 | 16 | let writes: Promise[] = []; 17 | 18 | let initFiles = ['/file.ts']; 19 | 20 | let start = performance.now(); 21 | 22 | for (let [path, contents] of Object.entries(files.ts)) { 23 | let p = '/_std/' + path + '.ts'; 24 | if (path == 'std') p = '/std.ts'; // So we can import it via import ui from "std"; 25 | 26 | writes.push(env.writeFileTypescript(p, contents)); 27 | initFiles.push(p); 28 | } 29 | 30 | for (let [path, contents] of Object.entries(files.shadeup)) { 31 | let p = '/_std/' + path + '.ts'; 32 | writes.push(env.writeFile(p, contents, true)); 33 | initFiles.push(p); 34 | } 35 | 36 | return env; 37 | } 38 | -------------------------------------------------------------------------------- /lang/shadeup/engine/engine-headless.ts: -------------------------------------------------------------------------------- 1 | import type { ShadeupRenderedFile } from '../compiler/common'; 2 | import { globalDefine, globalRequire } from './amd'; 3 | import { initInput, type MouseState } from './input/input'; 4 | import { keyboardKeys } from './input/keyboardKeys'; 5 | import { ShadeupShaderInstance, ShadeupShaderSource } from './shader'; 6 | import { initUI } from './ui/ui'; 7 | import { parse_type, stringify_type, translateIdentifier, translateNumericToGLSL } from './util'; 8 | 9 | window.addEventListener('message', async function (e: MessageEvent) { 10 | var mainWindow = e.source; 11 | if (mainWindow == null) return; 12 | 13 | var result = ''; 14 | if (e.data.type == 'frame') { 15 | try { 16 | let files: ShadeupRenderedFile[] = e.data.files; 17 | console.log(e.data); 18 | 19 | for (let file of files) { 20 | console.log(file); 21 | (() => { 22 | let define = (deps: string[], func: Function) => { 23 | globalDefine(file.path, deps, func); 24 | }; 25 | define; 26 | try { 27 | const postMessage = (v: any) => mainWindow.postMessage(v, e.origin); 28 | eval(file.contents); 29 | } catch (e) { 30 | console.log(e); 31 | result = e.message; 32 | } 33 | })(); 34 | } 35 | try { 36 | let outs = globalRequire(['/main.js'])[0]; 37 | 38 | if (typeof outs.main === 'function') { 39 | let result = await outs.main(); 40 | mainWindow.postMessage({ gid: (window as any)['LONG_GID'], data: result }, e.origin); 41 | } else { 42 | result = 'main is not a function'; 43 | } 44 | } catch (e) { 45 | console.log(e); 46 | result = e.message; 47 | } 48 | } catch (e) { 49 | console.error(e); 50 | result = 'eval() threw an exception.'; 51 | } 52 | mainWindow.postMessage(result, e.origin); 53 | } 54 | }); 55 | -------------------------------------------------------------------------------- /lang/shadeup/engine/frame-embed.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Shadeup engine 5 | 65 | 66 | 67 |
68 | 69 | 70 |
71 |
72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /lang/shadeup/engine/frame-headless.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Shadeup engine (headless) 5 | 6 | 7 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /lang/shadeup/engine/frame-preview.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Shadeup engine 5 | 69 | 70 | 71 |
72 | 73 | 74 |
75 |
76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /lang/shadeup/engine/setZero.ts: -------------------------------------------------------------------------------- 1 | // Only add setZeroTimeout to the window object, and hide everything 2 | // else in a closure. 3 | (function () { 4 | var timeouts = []; 5 | var messageName = 'zero-timeout-message'; 6 | 7 | // Like setTimeout, but only takes a function argument. There's 8 | // no time argument (always zero) and no arguments (you have to 9 | // use a closure). 10 | function setZeroTimeout(fn) { 11 | timeouts.push(fn); 12 | window.postMessage(messageName, '*'); 13 | } 14 | 15 | function handleMessage(event) { 16 | if (event.source == window && event.data == messageName) { 17 | event.stopPropagation(); 18 | if (timeouts.length > 0) { 19 | var fn = timeouts.shift(); 20 | fn(); 21 | } 22 | } 23 | } 24 | 25 | window.addEventListener('message', handleMessage, true); 26 | 27 | // Add the one thing we want added to the window object. 28 | window.setZeroTimeout = setZeroTimeout; 29 | })(); 30 | 31 | export {}; 32 | declare global { 33 | interface Window { 34 | setZeroTimeout(fn: () => void): void; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lang/shadeup/engine/ui/components/Button.svelte: -------------------------------------------------------------------------------- 1 | 5 | 6 |
7 | 15 |
16 | -------------------------------------------------------------------------------- /lang/shadeup/engine/ui/components/Checkbox.svelte: -------------------------------------------------------------------------------- 1 | 5 | 6 |
7 | 18 | { 24 | setValue(e.target.checked); 25 | value = e.target.checked; 26 | }} 27 | /> 28 |
29 | 30 | 35 | -------------------------------------------------------------------------------- /lang/shadeup/engine/ui/components/Combo.svelte: -------------------------------------------------------------------------------- 1 | 6 | 7 |
8 | 21 |
22 | -------------------------------------------------------------------------------- /lang/shadeup/engine/ui/components/Group.svelte: -------------------------------------------------------------------------------- 1 | 11 | 12 |
13 | 40 |
41 |
45 |
46 | {#each children as child, i} 47 |
51 | 58 |
59 | {/each} 60 |
61 |
62 | -------------------------------------------------------------------------------- /lang/shadeup/engine/ui/components/Host.svelte: -------------------------------------------------------------------------------- 1 | 9 | 10 |
11 | {#each children as child} 12 | 19 | {/each} 20 |
21 | -------------------------------------------------------------------------------- /lang/shadeup/engine/ui/components/Label.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 |
{value}
6 | -------------------------------------------------------------------------------- /lang/shadeup/engine/ui/components/Slider.svelte: -------------------------------------------------------------------------------- 1 | 23 | 24 | (dragging = false)} on:mousemove={handleMove} /> 25 | 26 |
27 |
{ 30 | dragging = true; 31 | handleMove(event); 32 | }} 33 | class="track w-full h-4 relative flex items-center" 34 | > 35 |
36 |
40 |
41 | { 49 | setValue(parseFloat(e.target.value)); 50 | value = parseFloat(e.target.value); 51 | }} 52 | /> 53 | { 60 | setValue(parseFloat(e.target.value)); 61 | value = parseFloat(e.target.value); 62 | }} 63 | /> 64 |
65 | -------------------------------------------------------------------------------- /lang/shadeup/engine/ui/components/Text.svelte: -------------------------------------------------------------------------------- 1 | 5 | 6 |
7 | { 12 | setValue(e.target.value); 13 | value = e.target.value; 14 | }} 15 | /> 16 |
17 | -------------------------------------------------------------------------------- /lang/shadeup/engine/ui/components/host.scss: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | @layer base { 6 | html { 7 | @apply text-white; 8 | } 9 | } 10 | 11 | .floating-panel { 12 | > .control-button:first-child, 13 | > .control-combo:first-child, 14 | > .control-input:first-child, 15 | > .control-label:first-child, 16 | > .control-select:first-child, 17 | > .control-text:first-child { 18 | @apply mt-2; 19 | } 20 | 21 | > .control-button:last-child, 22 | > .control-combo:last-child, 23 | > .control-input:last-child, 24 | > .control-label:last-child, 25 | > .control-select:last-child, 26 | > .control-text:last-child { 27 | @apply mb-1; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lang/shadeup/engine/ui/ui.ts: -------------------------------------------------------------------------------- 1 | import { initPuck } from './puck'; 2 | import Host from './components/Host.svelte'; 3 | 4 | export function initUI(canvas: HTMLCanvasElement) { 5 | let { frame, puck, preFrame, slider, controls } = initPuck(canvas); 6 | 7 | return { 8 | frame() { 9 | frame(); 10 | }, 11 | preFrame() { 12 | preFrame(); 13 | }, 14 | puck, 15 | slider, 16 | controls: controls 17 | // controls: host 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /lang/shadeup/frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Shadeup sandbox 5 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /lang/shadeup/library/drawAttributes.ts: -------------------------------------------------------------------------------- 1 | import { buffer } from '/_std/buffer'; 2 | import { float4, float3, float, float2, bool, int, uint } from '/std_math'; 3 | 4 | export function drawAttributes( 5 | indexBuffer: buffer, 6 | buffers: 7 | | Map> 8 | | { 9 | [key in keyof T]: buffer; 10 | }, 11 | vertexShader: shader, 12 | pixelShader: shader 13 | ) { 14 | __shadeup_dispatch_draw_attributes(indexBuffer, buffer, vertexShader, pixelShader); 15 | } 16 | -------------------------------------------------------------------------------- /lang/shadeup/library/drawCount.ts: -------------------------------------------------------------------------------- 1 | import { buffer } from '/_std/buffer'; 2 | import { float4, float3, float, float2, bool, int, uint } from '/std_math'; 3 | 4 | export function drawCount(triCount: number, vertexShader: shader, pixelShader: shader) { 5 | __shadeup_dispatch_draw_count(triCount, vertexShader, pixelShader); 6 | } 7 | -------------------------------------------------------------------------------- /lang/shadeup/library/files.ts: -------------------------------------------------------------------------------- 1 | import std from './std.ts?raw'; 2 | import ui from './ui.ts?raw'; 3 | import native from './native.ts?raw'; 4 | import buffer from './buffer.ts?raw'; 5 | import texture from './texture.ts?raw'; 6 | import physics from './physics.ts?raw'; 7 | import drawIndexed from './drawIndexed.ts?raw'; 8 | import drawCount from './drawCount.ts?raw'; 9 | import drawAttributes from './drawAttributes.ts?raw'; 10 | import paint from './paint.ts?raw'; 11 | import mesh from './mesh.shadeup?raw'; 12 | import geo from './geo.shadeup?raw'; 13 | import textures from './textures.shadeup?raw'; 14 | import common from './common.shadeup?raw'; 15 | import sdf from './sdf.shadeup?raw'; 16 | 17 | export default { 18 | shadeup: { 19 | mesh, 20 | textures, 21 | common, 22 | sdf, 23 | geo 24 | }, 25 | ts: { 26 | std, 27 | ui, 28 | native, 29 | paint, 30 | buffer, 31 | texture, 32 | drawIndexed, 33 | drawAttributes, 34 | drawCount, 35 | physics 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /lang/shadeup/library/geo.shadeup: -------------------------------------------------------------------------------- 1 | struct GeoSegment { 2 | start: float2, 3 | end: float2, 4 | kind: int, 5 | arcRadius: float, 6 | arcStart: float, 7 | arcEnd: float 8 | } 9 | 10 | struct GeoPoly { 11 | segments: GeoSegment[] 12 | } 13 | 14 | trait Geometry { 15 | fn area(self) -> float; 16 | fn perimeter(self) -> float; 17 | fn discretize(self) -> GeoPoly; 18 | } 19 | 20 | impl Geometry for GeoPoly { 21 | pub fn area(self) -> float { 22 | return 0.0; 23 | } 24 | 25 | pub fn perimeter(self) -> float { 26 | return 0.0; 27 | } 28 | 29 | pub fn discretize(self) -> GeoPoly { 30 | return self.clone(); 31 | } 32 | } -------------------------------------------------------------------------------- /lang/shadeup/library/mesh.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/shadeup/library/mesh.ts -------------------------------------------------------------------------------- /lang/shadeup/library/std.ts: -------------------------------------------------------------------------------- 1 | export { ui } from '/_std/ui'; 2 | export { mesh, Mesh } from '/_std/mesh'; 3 | export { sdf } from '/_std/sdf'; 4 | export { geo } from '/_std/geo'; 5 | export * from '/_std/native'; 6 | -------------------------------------------------------------------------------- /lang/shadeup/library/test.shadeup: -------------------------------------------------------------------------------- 1 | 2 | // Option 1 3 | let idx = buffer::new(); 4 | let buf = buffer::new(); 5 | let otherBuf = buffer::new(); 6 | 7 | drawIndexed(idx, shader { 8 | let pos = buf[in.index].xyz; 9 | out.position = pos; 10 | out.custom("test", pos.x); 11 | }, shader { 12 | let px = in.custom("test"); 13 | let c = otherBuf[round(px)]; 14 | out.color = c.xyzw; 15 | }); 16 | 17 | // Option 2 18 | let idx = buffer::new(); 19 | let buf = buffer::new(); 20 | let otherBuf = buffer::new(); 21 | 22 | drawIndexed(idx, shader -> ({test: float}) { 23 | let pos = buf[in.index].xyz; 24 | out.position = pos; 25 | out.test = pos.x; 26 | }, shader <- ({test: float}) { 27 | let px = in.test; 28 | let c = otherBuf[round(px)]; 29 | out.color = c.xyzw; 30 | }); 31 | 32 | // Option 3 33 | 34 | let idx = buffer::new(); 35 | let buf = buffer::new(); 36 | let otherBuf = buffer::new(); 37 | 38 | drawIndexed(idx, shader<{}, {test: float}> { 39 | let pos = buf[in.index].xyz; 40 | out.position = pos; 41 | out.test = pos.x; 42 | }, shader<{test: float}, {}> { 43 | let px = in.test; 44 | let c = otherBuf[round(px)]; 45 | out.color = c.xyzw; 46 | }); -------------------------------------------------------------------------------- /lang/shadeup/library/textures.shadeup: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/shadeup/library/textures.shadeup -------------------------------------------------------------------------------- /lang/shadeup/library/types.ts: -------------------------------------------------------------------------------- 1 | export type bool = boolean; 2 | export type float = number & { _opaque_float: 2 }; 3 | export type int = number & { _opaque_int: 1 } & float; 4 | export type uint = number & { _opaque_uint: 1 } & float & int; 5 | type scalar = float | int; 6 | 7 | export type float2 = [float, float]; 8 | export type float3 = [float, float, float]; 9 | export type float4 = [float, float, float, float]; 10 | export type int2 = [int, int]; 11 | export type int3 = [int, int, int]; 12 | export type int4 = [int, int, int, int]; 13 | 14 | type anyFloat = float2 | float3 | float4; 15 | type anyInt = int2 | int3 | int4; 16 | 17 | type vector2 = float2 | int2; 18 | type vector3 = float3 | int3; 19 | type vector4 = float4 | int4; 20 | 21 | type vector = vector2 | vector3 | vector4; 22 | 23 | type vectorOrScalar = vector | scalar; 24 | 25 | type float2x2 = [float, float, float, float]; 26 | type float3x3 = [float, float, float, float, float, float, float, float, float]; 27 | type float4x4 = [ 28 | float, 29 | float, 30 | float, 31 | float, 32 | float, 33 | float, 34 | float, 35 | float, 36 | float, 37 | float, 38 | float, 39 | float, 40 | float, 41 | float, 42 | float, 43 | float 44 | ]; 45 | -------------------------------------------------------------------------------- /lang/shadeup/library/ui.ts: -------------------------------------------------------------------------------- 1 | export namespace ui { 2 | export function puck(position: float2): float2 { 3 | return (window as any)._SHADEUP_UI_PUCK(position); 4 | } 5 | 6 | export function draggable(position: float2, radius: float = 10): float2 { 7 | return (window as any)._SHADEUP_UI_PUCK(position, radius, true); 8 | } 9 | 10 | export function textbox(value: string): string { 11 | return (window as any)._SHADEUP_UI_CONTROL('textbox', value); 12 | } 13 | 14 | export function slider(value: float, min: float, max: float): float { 15 | return (window as any)._SHADEUP_UI_SLIDER(value, { min, max }); 16 | } 17 | 18 | export function label(text: string): void { 19 | return (window as any)._SHADEUP_UI_CONTROL('label', text); 20 | } 21 | 22 | export function checkbox(value: bool): bool { 23 | return (window as any)._SHADEUP_UI_CONTROL('checkbox', value); 24 | } 25 | 26 | export function combo(value: string, options: string[]): string { 27 | return (window as any)._SHADEUP_UI_CONTROL('combo', value, { options }); 28 | } 29 | 30 | export function group(text: string): void { 31 | return (window as any)._SHADEUP_UI_CONTROL('group', text); 32 | } 33 | 34 | export function button(text: string): bool { 35 | return (window as any)._SHADEUP_UI_CONTROL('button', false, { text }); 36 | } 37 | 38 | export function pop(): void { 39 | (window as any)._SHADEUP_UI_CONTROL('pop'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lang/shadeup/symbol.ts: -------------------------------------------------------------------------------- 1 | export class ShadeupExternalSymbol { 2 | name: string = ''; 3 | kind: string = ''; 4 | 5 | outType: string = ''; 6 | parameters: [string, string, boolean][] = []; 7 | 8 | fields: [string, string][] = []; 9 | methods: ShadeupExternalSymbol[] = []; 10 | 11 | js: string = ''; 12 | 13 | constructor(name: string, kind: string) { 14 | this.name = name; 15 | this.kind = kind; 16 | } 17 | 18 | static makeFunction( 19 | name: string, 20 | outType: string, 21 | parameters: [string, string, boolean][], 22 | source: string 23 | ): ShadeupExternalSymbol { 24 | let symbol = new ShadeupExternalSymbol(name, 'function'); 25 | symbol.outType = outType; 26 | symbol.parameters = parameters; 27 | symbol.js = source; 28 | 29 | return symbol; 30 | } 31 | 32 | static makeVariable(name: string, outType: string): ShadeupExternalSymbol { 33 | const symbol = new ShadeupExternalSymbol(name, 'variable'); 34 | symbol.outType = outType; 35 | return symbol; 36 | } 37 | 38 | static makeType( 39 | name: string, 40 | fields: [string, string][], 41 | methods: ShadeupExternalSymbol[] 42 | ): ShadeupExternalSymbol { 43 | let symbol = new ShadeupExternalSymbol(name, 'type'); 44 | symbol.fields = fields; 45 | symbol.methods = methods; 46 | return symbol; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lang/shadeup/vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'; 3 | import wasm from 'vite-plugin-wasm'; 4 | // const prefix = `monaco-editor/esm/vs`; 5 | import { sveltekit } from '@sveltejs/kit/vite'; 6 | import nodeResolve from '@rollup/plugin-node-resolve'; 7 | import createExternal from 'vite-plugin-external'; 8 | export default defineConfig({ 9 | plugins: [ 10 | wasm(), 11 | nodeResolve(), 12 | createExternal({ 13 | externals: { 14 | typescript: 'typescript', 15 | chalk: 'chalk', 16 | '@typescript/vfs': '@typescript/vfs' 17 | } 18 | }) 19 | ], 20 | build: { 21 | commonjsOptions: { 22 | transformMixedEsModules: true 23 | }, 24 | lib: { 25 | // Could also be a dictionary or array of multiple entry points 26 | entry: './compiler/simple.ts', 27 | name: 'ShadeupCompiler', 28 | // the proper extensions will be added 29 | fileName: 'shadeup-compiler' 30 | }, 31 | outDir: '../../../compiler-api/', 32 | sourcemap: false 33 | }, 34 | esbuild: { 35 | keepNames: false 36 | }, 37 | resolve: { 38 | alias: { 39 | src: '/src', 40 | punycode: 'punycode/punycode.js', 41 | '/std_math': '../shadeup-frontend/lib/std/math.ts' 42 | } 43 | }, 44 | worker: { 45 | format: 'es', 46 | plugins: [wasm()] 47 | }, 48 | optimizeDeps: { 49 | esbuildOptions: { 50 | define: { 51 | self: 'globalThis', 52 | global: 'globalThis' 53 | }, 54 | plugins: [ 55 | NodeGlobalsPolyfillPlugin({ 56 | process: true, 57 | buffer: true 58 | }) 59 | ] 60 | } 61 | }, 62 | server: { 63 | fs: { 64 | // Allow serving files from one level up to the project root 65 | allow: ['..'] 66 | } 67 | } 68 | }); 69 | -------------------------------------------------------------------------------- /lang/tree-sitter/.gitignore: -------------------------------------------------------------------------------- 1 | target -------------------------------------------------------------------------------- /lang/tree-sitter/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "useTabs": true, 3 | "singleQuote": true, 4 | "trailingComma": "none", 5 | "printWidth": 100, 6 | 7 | "pluginSearchDirs": ["."], 8 | "overrides": [ 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /lang/tree-sitter/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "aho-corasick" 7 | version = "0.7.20" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" 10 | dependencies = [ 11 | "memchr", 12 | ] 13 | 14 | [[package]] 15 | name = "cc" 16 | version = "1.0.79" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" 19 | 20 | [[package]] 21 | name = "memchr" 22 | version = "2.5.0" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 25 | 26 | [[package]] 27 | name = "regex" 28 | version = "1.7.1" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" 31 | dependencies = [ 32 | "aho-corasick", 33 | "memchr", 34 | "regex-syntax", 35 | ] 36 | 37 | [[package]] 38 | name = "regex-syntax" 39 | version = "0.6.28" 40 | source = "registry+https://github.com/rust-lang/crates.io-index" 41 | checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" 42 | 43 | [[package]] 44 | name = "tree-sitter" 45 | version = "0.20.9" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | checksum = "d4423c784fe11398ca91e505cdc71356b07b1a924fc8735cfab5333afe3e18bc" 48 | dependencies = [ 49 | "cc", 50 | "regex", 51 | ] 52 | 53 | [[package]] 54 | name = "tree-sitter-shadeup" 55 | version = "0.0.1" 56 | dependencies = [ 57 | "cc", 58 | "tree-sitter", 59 | ] 60 | -------------------------------------------------------------------------------- /lang/tree-sitter/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tree-sitter-shadeup" 3 | description = "shadeup grammar for the tree-sitter parsing library" 4 | version = "0.0.1" 5 | keywords = ["incremental", "parsing", "shadeup"] 6 | categories = ["parsing", "text-editors"] 7 | repository = "https://github.com/tree-sitter/tree-sitter-shadeup" 8 | edition = "2021" 9 | license = "MIT" 10 | 11 | build = "bindings/rust/build.rs" 12 | include = [ 13 | "bindings/rust/*", 14 | "grammar.js", 15 | "queries/*", 16 | "src/*", 17 | ] 18 | 19 | [lib] 20 | path = "bindings/rust/lib.rs" 21 | 22 | [dependencies] 23 | tree-sitter = "~0.20.3" 24 | 25 | [build-dependencies] 26 | cc = "1.0" 27 | -------------------------------------------------------------------------------- /lang/tree-sitter/binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | { 4 | "target_name": "tree_sitter_shadeup_binding", 5 | "include_dirs": [ 6 | " 3 | #include "nan.h" 4 | 5 | using namespace v8; 6 | 7 | extern "C" TSLanguage * tree_sitter_shadeup(); 8 | 9 | namespace { 10 | 11 | NAN_METHOD(New) {} 12 | 13 | void Init(Local exports, Local module) { 14 | Local tpl = Nan::New(New); 15 | tpl->SetClassName(Nan::New("Language").ToLocalChecked()); 16 | tpl->InstanceTemplate()->SetInternalFieldCount(1); 17 | 18 | Local constructor = Nan::GetFunction(tpl).ToLocalChecked(); 19 | Local instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked(); 20 | Nan::SetInternalFieldPointer(instance, 0, tree_sitter_shadeup()); 21 | 22 | Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("shadeup").ToLocalChecked()); 23 | Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance); 24 | } 25 | 26 | NODE_MODULE(tree_sitter_shadeup_binding, Init) 27 | 28 | } // namespace 29 | -------------------------------------------------------------------------------- /lang/tree-sitter/bindings/node/index.js: -------------------------------------------------------------------------------- 1 | try { 2 | module.exports = require('../../build/Release/tree_sitter_shadeup_binding'); 3 | } catch (error1) { 4 | if (error1.code !== 'MODULE_NOT_FOUND') { 5 | throw error1; 6 | } 7 | try { 8 | module.exports = require('../../build/Debug/tree_sitter_shadeup_binding'); 9 | } catch (error2) { 10 | if (error2.code !== 'MODULE_NOT_FOUND') { 11 | throw error2; 12 | } 13 | throw error1; 14 | } 15 | } 16 | 17 | try { 18 | module.exports.nodeTypeInfo = require('../../src/node-types.json'); 19 | } catch (_) {} 20 | -------------------------------------------------------------------------------- /lang/tree-sitter/bindings/rust/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let src_dir = std::path::Path::new("src"); 3 | 4 | let mut c_config = cc::Build::new(); 5 | c_config.include(&src_dir); 6 | c_config 7 | .flag_if_supported("-Wno-unused-parameter") 8 | .flag_if_supported("-Wno-unused-but-set-variable") 9 | .flag_if_supported("-Wno-trigraphs"); 10 | let parser_path = src_dir.join("parser.c"); 11 | c_config.file(&parser_path); 12 | 13 | // If your language uses an external scanner written in C, 14 | // then include this block of code: 15 | 16 | let scanner_path = src_dir.join("scanner.c"); 17 | c_config.file(&scanner_path); 18 | println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap()); 19 | 20 | c_config.compile("parser"); 21 | println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap()); 22 | 23 | // If your language uses an external scanner written in C++, 24 | // then include this block of code: 25 | 26 | /* 27 | let mut cpp_config = cc::Build::new(); 28 | cpp_config.cpp(true); 29 | cpp_config.include(&src_dir); 30 | cpp_config 31 | .flag_if_supported("-Wno-unused-parameter") 32 | .flag_if_supported("-Wno-unused-but-set-variable"); 33 | let scanner_path = src_dir.join("scanner.cc"); 34 | cpp_config.file(&scanner_path); 35 | cpp_config.compile("scanner"); 36 | println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap()); 37 | */ 38 | } 39 | -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/bindings/node/binding.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/bindings/node/binding.obj -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/src/parser.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/src/parser.obj -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/src/scanner.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/src/scanner.obj -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sit.A95203FA.tlog/CL.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sit.A95203FA.tlog/CL.command.1.tlog -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sit.A95203FA.tlog/CL.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sit.A95203FA.tlog/CL.read.1.tlog -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sit.A95203FA.tlog/CL.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sit.A95203FA.tlog/CL.write.1.tlog -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sit.A95203FA.tlog/link.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sit.A95203FA.tlog/link.command.1.tlog -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sit.A95203FA.tlog/link.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sit.A95203FA.tlog/link.read.1.tlog -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sit.A95203FA.tlog/link.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sit.A95203FA.tlog/link.write.1.tlog -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sit.A95203FA.tlog/tree_sitter_shadeup_binding.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.31.31103:TargetPlatformVersion=10.0.19041.0:VcpkgTriplet=x64-windows: 2 | Release|x64|C:\Users\Jeremy\Documents\Programing\shadeup-lang\tree-sitter\build\| 3 | -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sit.A95203FA.tlog/tree_sitter_shadeup_binding.write.1u.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sit.A95203FA.tlog/tree_sitter_shadeup_binding.write.1u.tlog -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/tree_sitter_shadeup_binding.node.recipe: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | C:\Users\Jeremy\Documents\Programing\shadeup-lang\tree-sitter\build\Release\tree_sitter_shadeup_binding.node 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/win_delay_load_hook.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/obj/tree_sitter_shadeup_binding/win_delay_load_hook.obj -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/tree_sitter_shadeup_binding.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/tree_sitter_shadeup_binding.exp -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/tree_sitter_shadeup_binding.iobj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/tree_sitter_shadeup_binding.iobj -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/tree_sitter_shadeup_binding.ipdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/tree_sitter_shadeup_binding.ipdb -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/tree_sitter_shadeup_binding.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/tree_sitter_shadeup_binding.lib -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/tree_sitter_shadeup_binding.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/tree_sitter_shadeup_binding.node -------------------------------------------------------------------------------- /lang/tree-sitter/build/Release/tree_sitter_shadeup_binding.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/build/Release/tree_sitter_shadeup_binding.pdb -------------------------------------------------------------------------------- /lang/tree-sitter/build/binding.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 2015 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tree_sitter_shadeup_binding", "tree_sitter_shadeup_binding.vcxproj", "{A95203FA-3C2D-17B0-C550-33B4BBC444B3}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Release|x64 = Release|x64 8 | Debug|x64 = Debug|x64 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {A95203FA-3C2D-17B0-C550-33B4BBC444B3}.Release|x64.ActiveCfg = Release|x64 12 | {A95203FA-3C2D-17B0-C550-33B4BBC444B3}.Release|x64.Build.0 = Release|x64 13 | {A95203FA-3C2D-17B0-C550-33B4BBC444B3}.Debug|x64.ActiveCfg = Debug|x64 14 | {A95203FA-3C2D-17B0-C550-33B4BBC444B3}.Debug|x64.Build.0 = Debug|x64 15 | EndGlobalSection 16 | GlobalSection(SolutionProperties) = preSolution 17 | HideSolutionNode = FALSE 18 | EndGlobalSection 19 | EndGlobal 20 | -------------------------------------------------------------------------------- /lang/tree-sitter/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tree-sitter-shadeup", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "tree-sitter-shadeup", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "dependencies": { 12 | "nan": "^2.17.0" 13 | }, 14 | "devDependencies": { 15 | "tree-sitter-cli": "^0.20.8", 16 | "tree-sitter-javascript": "^0.19.0" 17 | } 18 | }, 19 | "node_modules/nan": { 20 | "version": "2.17.0", 21 | "resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz", 22 | "integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==" 23 | }, 24 | "node_modules/tree-sitter-cli": { 25 | "version": "0.20.8", 26 | "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.8.tgz", 27 | "integrity": "sha512-XjTcS3wdTy/2cc/ptMLc/WRyOLECRYcMTrSWyhZnj1oGSOWbHLTklgsgRICU3cPfb0vy+oZCC33M43u6R1HSCA==", 28 | "dev": true, 29 | "hasInstallScript": true, 30 | "bin": { 31 | "tree-sitter": "cli.js" 32 | } 33 | }, 34 | "node_modules/tree-sitter-javascript": { 35 | "version": "0.19.0", 36 | "resolved": "https://registry.npmjs.org/tree-sitter-javascript/-/tree-sitter-javascript-0.19.0.tgz", 37 | "integrity": "sha512-SNykDdNgmlJZhX02ZIu0TQF9P7t847jV7769SxA9XrZ2QXjofQsVTMEi9+LpXZKsI0UoFYI25FnZm3fFm0z2yw==", 38 | "dev": true, 39 | "hasInstallScript": true, 40 | "dependencies": { 41 | "nan": "^2.12.1" 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lang/tree-sitter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tree-sitter-shadeup", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "bindings/node", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "dependencies": { 10 | "nan": "^2.17.0" 11 | }, 12 | "devDependencies": { 13 | "tree-sitter-cli": "^0.20.8", 14 | "tree-sitter-javascript": "^0.19.0" 15 | }, 16 | "author": "", 17 | "license": "ISC" 18 | } 19 | -------------------------------------------------------------------------------- /lang/tree-sitter/parser.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/parser.exp -------------------------------------------------------------------------------- /lang/tree-sitter/parser.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/parser.lib -------------------------------------------------------------------------------- /lang/tree-sitter/parser.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/parser.obj -------------------------------------------------------------------------------- /lang/tree-sitter/readme.md: -------------------------------------------------------------------------------- 1 | To build (when docker is running): 2 | 3 | ```bash 4 | wsl 5 | tree-sitter build-wasm ./ --docker 6 | ``` 7 | -------------------------------------------------------------------------------- /lang/tree-sitter/scanner.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/scanner.obj -------------------------------------------------------------------------------- /lang/tree-sitter/tree-sitter-javascript.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/lang/tree-sitter/tree-sitter-javascript.wasm -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "plist": "^3.1.0", 4 | "tmlanguage-generator": "^0.5.2" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /package/__lib.d.ts: -------------------------------------------------------------------------------- 1 | import * as __ from "shadeup/math"; 2 | 3 | declare namespace ShadeupFiles { 4 | declare namespace __lib { 5 | export {}; 6 | } 7 | } 8 | 9 | export declare function makeShadeupInstance( 10 | canvas: HTMLCanvasElement, 11 | options?: { 12 | preferredAdapter?: "webgl" | "webgpu"; 13 | limits?: GPUSupportedLimits; 14 | ui?: boolean; 15 | } 16 | ): Promise<{ 17 | /** 18 | * Set to false to pause 19 | */ 20 | playing: boolean; 21 | 22 | canvas: HTMLCanvasElement; 23 | 24 | adapter: any; 25 | hooks: { 26 | beforeFrame?: () => void; 27 | afterFrame?: () => void; 28 | reset?: () => void; 29 | }[]; 30 | start: () => void; 31 | 32 | env: { 33 | camera: { 34 | position: __.float3; 35 | rotation: __.float4; 36 | width: __.float; 37 | height: __.float; 38 | fov: __.float; 39 | near: __.float; 40 | far: __.float; 41 | }; 42 | camera2d: { 43 | position: __.float2; 44 | zoom: __.float; 45 | }; 46 | deltaTime: __.float; 47 | frame: __.int; 48 | keyboard: any; 49 | mouse: any; 50 | screenSize: __.float2; 51 | time: __.float; 52 | }; 53 | 54 | /** 55 | * Used to pass values into the shadeup env (accessed as env.input("name") inside) 56 | */ 57 | inputValues: Map; 58 | 59 | enableUI: () => Promise; 60 | 61 | loadTextureFromImageLike: ( 62 | img: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas | HTMLVideoElement 63 | ) => Promise<__.texture2d<__.float4>>; 64 | loadTexture2dFromURL: (url: string) => Promise<__.texture2d<__.float4>>; 65 | loadModelFromURL: (urlGltf: string) => Promise<__.texture2d<__.float4>>; 66 | 67 | files: typeof ShadeupFiles; 68 | }>; 69 | -------------------------------------------------------------------------------- /package/__lib.shadeup: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/package/__lib.shadeup -------------------------------------------------------------------------------- /package/index.js: -------------------------------------------------------------------------------- 1 | import { 2 | linkIntoEngine, 3 | makeShadeupEngine, 4 | } from "./engine-dist/shadeup-engine.js"; 5 | import { linkShadeupLibrary } from "./library.js"; 6 | 7 | export const bindShadeupEngine = (fn) => { 8 | return async (canvas, options) => { 9 | const engine = await import("./engine"); 10 | const localEngineContext = await makeShadeupEngine(canvas, options); 11 | if (options && options.ui) { 12 | await localEngineContext.enableUI(); 13 | } 14 | await linkIntoEngine(localEngineContext, (def) => { 15 | linkShadeupLibrary(def, localEngineContext); 16 | fn(def, localEngineContext); 17 | }); 18 | return localEngineContext; 19 | }; 20 | }; 21 | -------------------------------------------------------------------------------- /package/main.d.ts: -------------------------------------------------------------------------------- 1 | export declare function main(): void; 2 | -------------------------------------------------------------------------------- /package/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shadeup", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "shadeup", 9 | "version": "1.0.0", 10 | "license": "MIT" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shadeup", 3 | "version": "1.4.0", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1", 9 | "build:lib": "npx shadeup -v && npx shadeup build __lib.shadeup && node util/concat.js" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/AskingQuestions/Shadeup" 14 | }, 15 | "author": "AskingQuestions ", 16 | "license": "MIT" 17 | } 18 | -------------------------------------------------------------------------------- /package/util/concat.js: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | import path from "path"; 3 | 4 | let code = "// Generated file\n"; 5 | 6 | code += "export const linkShadeupLibrary = (define, localEngineContext) => {\n"; 7 | 8 | code += `const __shadeup_gen_shader = 9 | localEngineContext.__shadeup_gen_shader.bind(localEngineContext); 10 | const __shadeup_make_shader_inst = 11 | localEngineContext.__shadeup_make_shader_inst.bind(localEngineContext); 12 | const __shadeup_register_struct = 13 | localEngineContext.__shadeup_register_struct.bind(localEngineContext); 14 | const env = localEngineContext.env; 15 | 16 | `; 17 | 18 | const blankCode = fs.readFileSync("__lib.js", "utf8"); 19 | 20 | code += blankCode; 21 | 22 | code += "};\n"; 23 | 24 | fs.writeFileSync("library.js", code); 25 | -------------------------------------------------------------------------------- /unreal-engine/.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | indent_style = tab 3 | indent_size = 4 -------------------------------------------------------------------------------- /unreal-engine/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /unreal-engine/.prettierignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/.prettierignore -------------------------------------------------------------------------------- /unreal-engine/README.md: -------------------------------------------------------------------------------- 1 |

Shadeup logo

2 | 3 |

4 | Version 5 | License 6 |

7 | 8 |

Shadeup - Unreal Engine

9 | 10 | ## More shaders less boilerplate 11 | 12 | Shadeup is a CLI-based scaffolding tool for rapidly whipping up shaders in Unreal Engine 13 | 14 | --- 15 | 16 | Shadeup helps with the following: 17 | 18 | 📜 Compute shaders 19 | 20 | ⠶ Indirect instancing 21 | 22 | ↝ Custom Material Nodes 23 | 24 | --- 25 | 26 | ## Installation & Usage 27 | 28 | ```sh 29 | $ npm install shadeup 30 | ``` 31 | 32 | ```sh 33 | $ cd MyUnrealProject 34 | $ shadeup # This will start the scaffolding wizard 35 | ``` 36 | 37 | For more information visit [unreal.shadeup.dev](https://unreal.shadeup.dev/docs) 38 | -------------------------------------------------------------------------------- /unreal-engine/archives/ComputeShader_base.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/archives/ComputeShader_base.zip -------------------------------------------------------------------------------- /unreal-engine/archives/ComputeShader_basemat.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/archives/ComputeShader_basemat.zip -------------------------------------------------------------------------------- /unreal-engine/archives/ComputeShader_mat.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/archives/ComputeShader_mat.zip -------------------------------------------------------------------------------- /unreal-engine/archives/ComputeShader_pi.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/archives/ComputeShader_pi.zip -------------------------------------------------------------------------------- /unreal-engine/archives/ComputeShader_rt.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/archives/ComputeShader_rt.zip -------------------------------------------------------------------------------- /unreal-engine/archives/CustomProxy_Plugin/Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/archives/CustomProxy_Plugin/Resources/Icon128.png -------------------------------------------------------------------------------- /unreal-engine/archives/CustomProxy_Plugin/ShadeupExamplePlugin.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 1, 4 | "VersionName": "1.0", 5 | "FriendlyName": "ShadeupExamplePlugin", 6 | "Description": "", 7 | "Category": "Other", 8 | "CreatedBy": "", 9 | "CreatedByURL": "", 10 | "DocsURL": "", 11 | "MarketplaceURL": "", 12 | "SupportURL": "", 13 | "CanContainContent": true, 14 | "IsBetaVersion": false, 15 | "IsExperimentalVersion": false, 16 | "Installed": false, 17 | "Modules": [ 18 | { 19 | "Name": "ShadeupExamplePlugin", 20 | "Type": "Runtime", 21 | "LoadingPhase": "Default" 22 | }, 23 | { 24 | "Name": "CustomProxy", 25 | "Type": "Runtime", 26 | "LoadingPhase": "PostConfigInit" 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /unreal-engine/archives/CustomProxy_Plugin/ShadeupExamplePlugin.uplugin.back: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 1, 4 | "VersionName": "1.0", 5 | "FriendlyName": "ShadeupExamplePlugin", 6 | "Description": "", 7 | "Category": "Other", 8 | "CreatedBy": "", 9 | "CreatedByURL": "", 10 | "DocsURL": "", 11 | "MarketplaceURL": "", 12 | "SupportURL": "", 13 | "CanContainContent": true, 14 | "IsBetaVersion": false, 15 | "IsExperimentalVersion": false, 16 | "Installed": false, 17 | "Modules": [ 18 | { 19 | "Name": "ShadeupExamplePlugin", 20 | "Type": "Runtime", 21 | "LoadingPhase": "Default" 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /unreal-engine/archives/CustomProxy_Plugin/Source/CustomProxy/CustomProxy.Build.cs: -------------------------------------------------------------------------------- 1 | using UnrealBuildTool; 2 | 3 | public class CustomProxy: ModuleRules 4 | 5 | { 6 | 7 | public CustomProxy(ReadOnlyTargetRules Target) : base(Target) 8 | 9 | { 10 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 11 | 12 | PrivateIncludePaths.AddRange(new string[] 13 | { 14 | "Runtime/Renderer/Private", 15 | "CustomProxy/Private" 16 | }); 17 | if (Target.bBuildEditor == true) 18 | { 19 | PrivateDependencyModuleNames.Add("TargetPlatform"); 20 | } 21 | PublicDependencyModuleNames.Add("Core"); 22 | PublicDependencyModuleNames.Add("Engine"); 23 | PublicDependencyModuleNames.Add("MaterialShaderQualitySettings"); 24 | 25 | PrivateDependencyModuleNames.AddRange(new string[] 26 | { 27 | "CoreUObject", 28 | "Renderer", 29 | "RenderCore", 30 | "RHI", 31 | "Projects" 32 | }); 33 | 34 | if (Target.bBuildEditor == true) 35 | { 36 | 37 | PrivateDependencyModuleNames.AddRange( 38 | new string[] { 39 | "UnrealEd", 40 | "MaterialUtilities", 41 | "SlateCore", 42 | "Slate" 43 | } 44 | ); 45 | 46 | CircularlyReferencedDependentModules.AddRange( 47 | new string[] { 48 | "UnrealEd", 49 | "MaterialUtilities", 50 | } 51 | ); 52 | } 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /unreal-engine/archives/CustomProxy_Plugin/Source/CustomProxy/Private/CustomProxy.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "CustomProxy.h" 4 | 5 | #include "Misc/Paths.h" 6 | #include "Misc/FileHelper.h" 7 | #include "RHI.h" 8 | #include "GlobalShader.h" 9 | #include "RHICommandList.h" 10 | #include "RenderGraphBuilder.h" 11 | #include "RenderTargetPool.h" 12 | #include "Runtime/Core/Public/Modules/ModuleManager.h" 13 | #include "Interfaces/IPluginManager.h" 14 | 15 | #define LOCTEXT_NAMESPACE "FCustomProxy" 16 | 17 | void FCustomProxy::StartupModule() 18 | { 19 | // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module 20 | 21 | FString PluginShaderDir = FPaths::Combine(IPluginManager::Get().FindPlugin(TEXT("ShadeupExamplePlugin"))->GetBaseDir(), TEXT("Shaders/CustomProxy/Private")); 22 | AddShaderSourceDirectoryMapping(TEXT("/CustomProxyShaders"), PluginShaderDir); 23 | } 24 | 25 | void FCustomProxy::ShutdownModule() 26 | { 27 | // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, 28 | // we call this function before unloading the module. 29 | } 30 | 31 | #undef LOCTEXT_NAMESPACE 32 | 33 | IMPLEMENT_MODULE(FCustomProxy, ShadeupExamplePlugin) -------------------------------------------------------------------------------- /unreal-engine/archives/CustomProxy_Plugin/Source/CustomProxy/Public/CustomProxy.h: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/ModuleManager.h" 7 | 8 | class FCustomProxy : public IModuleInterface 9 | { 10 | public: 11 | 12 | /** IModuleInterface implementation */ 13 | virtual void StartupModule() override; 14 | virtual void ShutdownModule() override; 15 | }; 16 | -------------------------------------------------------------------------------- /unreal-engine/archives/CustomProxy_Plugin/Source/ShadeupTestPlugin/Private/ShadeupExamplePlugin.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "ShadeupExamplePlugin.h" 4 | 5 | #define LOCTEXT_NAMESPACE "FShadeupExamplePluginModule" 6 | 7 | void FShadeupExamplePluginModule::StartupModule() 8 | { 9 | // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module 10 | } 11 | 12 | void FShadeupExamplePluginModule::ShutdownModule() 13 | { 14 | // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, 15 | // we call this function before unloading the module. 16 | } 17 | 18 | #undef LOCTEXT_NAMESPACE 19 | 20 | IMPLEMENT_MODULE(FShadeupExamplePluginModule, ShadeupExamplePlugin) -------------------------------------------------------------------------------- /unreal-engine/archives/CustomProxy_Plugin/Source/ShadeupTestPlugin/Public/ShadeupExamplePlugin.h: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/ModuleManager.h" 7 | 8 | class FShadeupExamplePluginModule : public IModuleInterface 9 | { 10 | public: 11 | 12 | /** IModuleInterface implementation */ 13 | virtual void StartupModule() override; 14 | virtual void ShutdownModule() override; 15 | }; 16 | -------------------------------------------------------------------------------- /unreal-engine/archives/CustomProxy_Plugin/Source/ShadeupTestPlugin/ShadeupExamplePlugin.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class ShadeupExamplePlugin : ModuleRules 6 | { 7 | public ShadeupExamplePlugin(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PublicIncludePaths.AddRange( 12 | new string[] { 13 | // ... add public include paths required here ... 14 | } 15 | ); 16 | 17 | 18 | PrivateIncludePaths.AddRange( 19 | new string[] { 20 | // ... add other private include paths required here ... 21 | } 22 | ); 23 | 24 | 25 | PublicDependencyModuleNames.AddRange( 26 | new string[] 27 | { 28 | "Core", 29 | // ... add other public dependencies that you statically link with here ... 30 | } 31 | ); 32 | 33 | 34 | PrivateDependencyModuleNames.AddRange( 35 | new string[] 36 | { 37 | "CoreUObject", 38 | "Engine", 39 | "Slate", 40 | "SlateCore", 41 | // ... add private dependencies that you statically link with here ... 42 | } 43 | ); 44 | 45 | 46 | DynamicallyLoadedModuleNames.AddRange( 47 | new string[] 48 | { 49 | // ... add any modules that your module loads dynamically here ... 50 | } 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /unreal-engine/archives/CustomProxy_base.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/archives/CustomProxy_base.zip -------------------------------------------------------------------------------- /unreal-engine/archives/CustomProxy_stream.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/archives/CustomProxy_stream.zip -------------------------------------------------------------------------------- /unreal-engine/archives/IndirectInstancing_base.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/archives/IndirectInstancing_base.zip -------------------------------------------------------------------------------- /unreal-engine/archives/IndirectInstancing_grid.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/archives/IndirectInstancing_grid.zip -------------------------------------------------------------------------------- /unreal-engine/archives/IndirectInstancing_inst.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/archives/IndirectInstancing_inst.zip -------------------------------------------------------------------------------- /unreal-engine/archives/MaterialNodeOutput_dynamic.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/archives/MaterialNodeOutput_dynamic.zip -------------------------------------------------------------------------------- /unreal-engine/archives/MaterialNodeOutput_fn.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/archives/MaterialNodeOutput_fn.zip -------------------------------------------------------------------------------- /unreal-engine/archives/MaterialNodeOutput_input.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/archives/MaterialNodeOutput_input.zip -------------------------------------------------------------------------------- /unreal-engine/archives/MaterialNodeOutput_output.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/archives/MaterialNodeOutput_output.zip -------------------------------------------------------------------------------- /unreal-engine/examples/version2.shadeup: -------------------------------------------------------------------------------- 1 | // More expressive 2 | 3 | import { Cube } from "geometry"; 4 | 5 | // Geometry is pretty simple 6 | struct Geometry { 7 | vertices: vec; 8 | indices: vec; 9 | normals: vec; 10 | } 11 | 12 | impl Geometry { 13 | fn translate(float3 Translation) -> Geometry { 14 | return Geometry { 15 | vertices: vertices.map(v => v + Translation), 16 | indices, 17 | normals 18 | }; 19 | } 20 | 21 | fn operator+(float3 Translation) { 22 | } 23 | } 24 | 25 | main { 26 | 27 | draw(Cube); 28 | 29 | draw(Cube + float3(1, 0, 0) * 2); 30 | } -------------------------------------------------------------------------------- /unreal-engine/extension/shadeup/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "args": [ 13 | "--extensionDevelopmentPath=${workspaceFolder}" 14 | ] 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /unreal-engine/extension/shadeup/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | .gitignore 4 | vsc-extension-quickstart.md 5 | -------------------------------------------------------------------------------- /unreal-engine/extension/shadeup/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "shadeup" extension will be documented in this file. 4 | 5 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 6 | 7 | ## [Unreleased] 8 | 9 | - Initial release -------------------------------------------------------------------------------- /unreal-engine/extension/shadeup/icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /unreal-engine/extension/shadeup/language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | // symbol used for single line comment. Remove this entry if your language does not support line comments 4 | "lineComment": "//", 5 | // symbols used for start and end a block comment. Remove this entry if your language does not support block comments 6 | "blockComment": [ "/*", "*/" ] 7 | }, 8 | // symbols used as brackets 9 | "brackets": [ 10 | ["{", "}"], 11 | ["[", "]"], 12 | ["(", ")"] 13 | ], 14 | // symbols that are auto closed when typing 15 | "autoClosingPairs": [ 16 | ["{", "}"], 17 | ["[", "]"], 18 | ["(", ")"], 19 | ["\"", "\""], 20 | ["'", "'"] 21 | ], 22 | // symbols that can be used to surround a selection 23 | "surroundingPairs": [ 24 | ["{", "}"], 25 | ["[", "]"], 26 | ["(", ")"], 27 | ["\"", "\""], 28 | ["'", "'"] 29 | ] 30 | } -------------------------------------------------------------------------------- /unreal-engine/extension/shadeup/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /unreal-engine/extension/shadeup/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shadeup", 3 | "displayName": "Shadeup", 4 | "description": "Shadeup Syntax Highlighting", 5 | "version": "0.0.1", 6 | "engines": { 7 | "vscode": "^1.66.0" 8 | }, 9 | "categories": [ 10 | "Programming Languages" 11 | ], 12 | "contributes": { 13 | "languages": [{ 14 | "id": "shadeup", 15 | "aliases": ["Shadeup", "shadeup"], 16 | "extensions": [".shadeup"], 17 | "configuration": "./language-configuration.json", 18 | "icon": { 19 | "light": "./icon.svg", 20 | "dark": "./icon.svg" 21 | } 22 | }], 23 | "grammars": [{ 24 | "language": "shadeup", 25 | "scopeName": "source.shadeup", 26 | "path": "./syntaxes/shadeup.tmLanguage.json", 27 | "embeddedLanguages": { 28 | "meta.embedded.block.hlsl": "hlsl" 29 | } 30 | }] 31 | } 32 | } -------------------------------------------------------------------------------- /unreal-engine/extension/shadeup/vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your VS Code Extension 2 | 3 | ## What's in the folder 4 | 5 | * This folder contains all of the files necessary for your extension. 6 | * `package.json` - this is the manifest file in which you declare your language support and define the location of the grammar file that has been copied into your extension. 7 | * `syntaxes/shadeup.tmLanguage.json` - this is the Text mate grammar file that is used for tokenization. 8 | * `language-configuration.json` - this is the language configuration, defining the tokens that are used for comments and brackets. 9 | 10 | ## Get up and running straight away 11 | 12 | * Make sure the language configuration settings in `language-configuration.json` are accurate. 13 | * Press `F5` to open a new window with your extension loaded. 14 | * Create a new file with a file name suffix matching your language. 15 | * Verify that syntax highlighting works and that the language configuration settings are working. 16 | 17 | ## Make changes 18 | 19 | * You can relaunch the extension from the debug toolbar after making changes to the files listed above. 20 | * You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. 21 | 22 | ## Add more language features 23 | 24 | * To add features such as intellisense, hovers and validators check out the VS Code extenders documentation at https://code.visualstudio.com/docs 25 | 26 | ## Install your extension 27 | 28 | * To start using your extension with Visual Studio Code copy it into the `/.vscode/extensions` folder and restart Code. 29 | * To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension. 30 | -------------------------------------------------------------------------------- /unreal-engine/index.js: -------------------------------------------------------------------------------- 1 | throw new Error("This is a CLI only package (for now)"); 2 | -------------------------------------------------------------------------------- /unreal-engine/p.shadeup: -------------------------------------------------------------------------------- 1 | @module "TestShader" 2 | 3 | compute MyGradientShader { 4 | Parameters = [ 5 | { 6 | Name = "Texture"; 7 | Type = RWTexture2D; 8 | } 9 | ]; 10 | 11 | Public = { 12 | static void ShaderEnvironment(const FMaterialShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment) override 13 | { 14 | OutEnvironment.SetDefine(TEXT("CUSTOM_GLOBAL_DEF"), "1"); 15 | } 16 | }; 17 | 18 | Shader = { 19 | [numthreads(32, 32, 1)] 20 | void Main(uint3 ThreadId : SV_DispatchThreadID) { 21 | Texture[ThreadId.x, ThreadId.y] = float4(ThreadId.x / 128.f, ThreadId.y / 128.f, 0.0, 1.0); 22 | } 23 | }; 24 | } 25 | 26 | actor MyGradientActor { 27 | Public = { 28 | MaterialInterface Material; 29 | }; 30 | 31 | Private = { 32 | RenderTarget RenderTarget; 33 | 34 | void Make() override { 35 | RenderTarget = AddRenderTarget(128, 128, Format.R8G8B8A8_UNORM); 36 | auto Plane = AddPlane(); 37 | Plane.SetMaterial(0, Material); 38 | 39 | Material.SetTextureParameter("Texture", RenderTarget); 40 | } 41 | 42 | void Tick(float DeltaTime) override { 43 | auto shader = MyGradientShader::Prepare(); 44 | shader.SetTextureParameter("Texture", RenderTarget); 45 | shader.Dispatch(128, 128, 1); 46 | } 47 | }; 48 | } -------------------------------------------------------------------------------- /unreal-engine/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@shadeup/unreal", 3 | "version": "1.2.1", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "build": "npx nearleyc ./src/grammar.ne -o ./build/grammar.js", 9 | "parse": "npm run build && node test.js", 10 | "test": "echo \"Error: no test specified\" && exit 1", 11 | "cli": "node cli.js" 12 | }, 13 | "bin": { 14 | "shadeup-unreal": "./cli.js" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/AskingQuestions/Shadeup" 19 | }, 20 | "author": "AskingQuestions ", 21 | "license": "MIT", 22 | "dependencies": { 23 | "@typescript/vfs": "^1.5.0", 24 | "boxen": "^7.0.0", 25 | "colors": "^1.4.0", 26 | "commander": "^9.2.0", 27 | "inquirer": "^8.2.4", 28 | "nearley": "^2.20.1", 29 | "typescript": "^5.3.3", 30 | "uglify-js": "^3.17.4", 31 | "web-tree-sitter": "^0.20.8" 32 | }, 33 | "devDependencies": { 34 | "archiver": "^5.3.1" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /unreal-engine/resources/img/discord.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/resources/img/discord.png -------------------------------------------------------------------------------- /unreal-engine/resources/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/resources/img/logo.png -------------------------------------------------------------------------------- /unreal-engine/resources/img/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /unreal-engine/src/parse.js: -------------------------------------------------------------------------------- 1 | import nearley from "nearley"; 2 | import grammar from "../build/grammar.js"; 3 | import fs from "fs"; 4 | import { ParsedFile } from "./file.js"; 5 | 6 | export function parse(file) { 7 | const parser = new nearley.Parser(nearley.Grammar.fromCompiled(grammar)); 8 | 9 | let f; 10 | 11 | try { 12 | f = fs.readFileSync(file, "utf8"); 13 | } catch (e) { 14 | console.error(`Could not read file "${file}". ` + e); 15 | return; 16 | } 17 | 18 | try { 19 | parser.feed(f); 20 | } catch (e) { 21 | console.error(`${file} ` + e); 22 | return; 23 | } 24 | 25 | if (parser.results.length === 0) { 26 | console.error(`Parsing error. Are you missing a semicolon or curly brace?`); 27 | return; 28 | } 29 | 30 | let lines = []; 31 | for (let i = 0; i < f.length; i++) { 32 | if (f[i] === "\n") { 33 | lines.push(i); 34 | } 35 | } 36 | 37 | return new ParsedFile(file, parser.results[0], lines); 38 | } -------------------------------------------------------------------------------- /unreal-engine/src/plugin_template/Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/src/plugin_template/Resources/Icon128.png -------------------------------------------------------------------------------- /unreal-engine/src/plugin_template/ShadeupExamplePlugin.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 1, 4 | "VersionName": "1.0", 5 | "FriendlyName": "ShadeupExamplePlugin", 6 | "Description": "", 7 | "Category": "Other", 8 | "CreatedBy": "", 9 | "CreatedByURL": "", 10 | "DocsURL": "", 11 | "MarketplaceURL": "", 12 | "SupportURL": "", 13 | "CanContainContent": true, 14 | "IsBetaVersion": false, 15 | "IsExperimentalVersion": false, 16 | "Installed": false, 17 | "Modules": [ 18 | { 19 | "Name": "ShadeupExamplePlugin", 20 | "Type": "Runtime", 21 | "LoadingPhase": "Default" 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /unreal-engine/src/plugin_template/Source/ShadeupTestPlugin/Private/ShadeupExamplePlugin.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "ShadeupExamplePlugin.h" 4 | 5 | #define LOCTEXT_NAMESPACE "FShadeupExamplePluginModule" 6 | 7 | void FShadeupExamplePluginModule::StartupModule() 8 | { 9 | // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module 10 | } 11 | 12 | void FShadeupExamplePluginModule::ShutdownModule() 13 | { 14 | // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, 15 | // we call this function before unloading the module. 16 | } 17 | 18 | #undef LOCTEXT_NAMESPACE 19 | 20 | IMPLEMENT_MODULE(FShadeupExamplePluginModule, ShadeupExamplePlugin) -------------------------------------------------------------------------------- /unreal-engine/src/plugin_template/Source/ShadeupTestPlugin/Public/ShadeupExamplePlugin.h: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/ModuleManager.h" 7 | 8 | class FShadeupExamplePluginModule : public IModuleInterface 9 | { 10 | public: 11 | 12 | /** IModuleInterface implementation */ 13 | virtual void StartupModule() override; 14 | virtual void ShutdownModule() override; 15 | }; 16 | -------------------------------------------------------------------------------- /unreal-engine/src/plugin_template/Source/ShadeupTestPlugin/ShadeupExamplePlugin.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class ShadeupExamplePlugin : ModuleRules 6 | { 7 | public ShadeupExamplePlugin(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PublicIncludePaths.AddRange( 12 | new string[] { 13 | // ... add public include paths required here ... 14 | } 15 | ); 16 | 17 | 18 | PrivateIncludePaths.AddRange( 19 | new string[] { 20 | // ... add other private include paths required here ... 21 | } 22 | ); 23 | 24 | 25 | PublicDependencyModuleNames.AddRange( 26 | new string[] 27 | { 28 | "Core", 29 | // ... add other public dependencies that you statically link with here ... 30 | } 31 | ); 32 | 33 | 34 | PrivateDependencyModuleNames.AddRange( 35 | new string[] 36 | { 37 | "CoreUObject", 38 | "Engine", 39 | "Slate", 40 | "SlateCore", 41 | // ... add private dependencies that you statically link with here ... 42 | } 43 | ); 44 | 45 | 46 | DynamicallyLoadedModuleNames.AddRange( 47 | new string[] 48 | { 49 | // ... add any modules that your module loads dynamically here ... 50 | } 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /unreal-engine/src/string.ne: -------------------------------------------------------------------------------- 1 | # Matches various kinds of string literals 2 | 3 | # Double-quoted string 4 | dqstring -> "\"" dstrchar:* "\"" {% function(d) {return d[1].join(""); } %} 5 | sqstring -> "'" sstrchar:* "'" {% function(d) {return d[1].join(""); } %} 6 | btstring -> "`" [^`]:* "`" {% function(d) {return d[1].join(""); } %} 7 | 8 | dstrchar -> [^\\"\n] {% id %} 9 | | "\\" strescape {% 10 | function(d) { 11 | return JSON.parse("\""+d.join("")+"\""); 12 | } 13 | %} 14 | 15 | sstrchar -> [^\\'\n] {% id %} 16 | | "\\" strescape 17 | {% function(d) { return JSON.parse("\""+d.join("")+"\""); } %} 18 | | "\\'" 19 | {% function(d) {return "'"; } %} 20 | 21 | strescape -> ["\\/bfnrt] {% id %} 22 | | "u" [a-fA-F0-9] [a-fA-F0-9] [a-fA-F0-9] [a-fA-F0-9] {% 23 | function(d) { 24 | return d.join(""); 25 | } 26 | %} -------------------------------------------------------------------------------- /unreal-engine/src/template/ModulePrivate.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "${MODULE_NAME}.h" 4 | 5 | #include "Misc/Paths.h" 6 | #include "Misc/FileHelper.h" 7 | #include "RHI.h" 8 | #include "GlobalShader.h" 9 | #include "RHICommandList.h" 10 | #include "RenderGraphBuilder.h" 11 | #include "RenderTargetPool.h" 12 | #include "Runtime/Core/Public/Modules/ModuleManager.h" 13 | #include "Interfaces/IPluginManager.h" 14 | 15 | #define LOCTEXT_NAMESPACE "F${MODULE_NAME}" 16 | 17 | void F${MODULE_NAME}::StartupModule() 18 | { 19 | // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module 20 | 21 | FString PluginShaderDir = FPaths::Combine(IPluginManager::Get().FindPlugin(TEXT("${PLUGIN_NAME}"))->GetBaseDir(), TEXT("Shaders/${MODULE_NAME}/Private")); 22 | AddShaderSourceDirectoryMapping(TEXT("/${MODULE_NAME}Shaders"), PluginShaderDir); 23 | } 24 | 25 | void F${MODULE_NAME}::ShutdownModule() 26 | { 27 | // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, 28 | // we call this function before unloading the module. 29 | } 30 | 31 | #undef LOCTEXT_NAMESPACE 32 | 33 | IMPLEMENT_MODULE(F${MODULE_NAME}, ${PLUGIN_NAME}) -------------------------------------------------------------------------------- /unreal-engine/src/template/ModulePublic.h: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/ModuleManager.h" 7 | 8 | class F${MODULE_NAME} : public IModuleInterface 9 | { 10 | public: 11 | 12 | /** IModuleInterface implementation */ 13 | virtual void StartupModule() override; 14 | virtual void ShutdownModule() override; 15 | }; 16 | -------------------------------------------------------------------------------- /unreal-engine/src/template/Plugin/MyPlugin.uplugin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/src/template/Plugin/MyPlugin.uplugin -------------------------------------------------------------------------------- /unreal-engine/src/template/Plugin/Shaders/Compute/Private/Template.usf: -------------------------------------------------------------------------------- 1 | #include "/Engine/Public/Platform.ush" 2 | 3 | ${ 4 | instance.parameters.map(p => `${p.hlslType} ${p.name};`).join('\n') 5 | } 6 | 7 | ${instance.shader()} -------------------------------------------------------------------------------- /unreal-engine/src/template/Plugin/Source/Module/Private/ActorTemplate.cpp: -------------------------------------------------------------------------------- 1 | #include "Actors/${instance.nameWithoutPrefix}.h" 2 | 3 | ${instance.code("PrivateInclude")} 4 | 5 | ${NAME}::${NAME}() { 6 | PrimaryActorTick.bCanEverTick = true; 7 | PrimaryActorTick.bStartWithTickEnabled = true; 8 | 9 | ThisActor = this; 10 | 11 | SceneComponent = CreateDefaultSubobject(TEXT("SceneComponent")); 12 | SetRootComponent(SceneComponent); 13 | 14 | Setup(); 15 | 16 | bIsInConstructor = false; 17 | } 18 | 19 | void ${NAME}::BeginPlay() { 20 | Super::BeginPlay(); 21 | } 22 | 23 | ${instance.code("Body")} -------------------------------------------------------------------------------- /unreal-engine/src/template/Plugin/Source/Module/Private/ModuleTemplate.cpp: -------------------------------------------------------------------------------- 1 | #include "${MODULE_NAME}/Public/${MODULE_NAME}.h" 2 | 3 | #include "Misc/Paths.h" 4 | #include "Misc/FileHelper.h" 5 | #include "RHI.h" 6 | #include "GlobalShader.h" 7 | #include "RHICommandList.h" 8 | #include "RenderGraphBuilder.h" 9 | #include "RenderTargetPool.h" 10 | #include "Runtime/Core/Public/Modules/ModuleManager.h" 11 | #include "Interfaces/IPluginManager.h" 12 | 13 | #define LOCTEXT_NAMESPACE "${MODULE_NAME}Module" 14 | 15 | void F${MODULE_NAME}Module::StartupModule() 16 | { 17 | // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module 18 | 19 | // Maps virtual shader source directory to the plugin's actual shaders directory. 20 | FString PluginShaderDir = FPaths::Combine(IPluginManager::Get().FindPlugin(TEXT("${PLUGIN_NAME}"))->GetBaseDir(), TEXT("Shaders/${MODULE_NAME}/Private")); 21 | AddShaderSourceDirectoryMapping(TEXT("/${MODULE_NAME}Shaders"), PluginShaderDir); 22 | } 23 | 24 | void F${MODULE_NAME}Module::ShutdownModule() 25 | { 26 | // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, 27 | // we call this function before unloading the module. 28 | } 29 | 30 | #undef LOCTEXT_NAMESPACE 31 | 32 | IMPLEMENT_MODULE(F${MODULE_NAME}Module, ${MODULE_NAME}) -------------------------------------------------------------------------------- /unreal-engine/src/template/Plugin/Source/Module/Public/ActorTemplate.h: -------------------------------------------------------------------------------- 1 | #include "GameFramework/Actor.h" 2 | 3 | // Shadeup provided helper functions 4 | #include "ShadeupLib.h" 5 | 6 | // Commonly included headers 7 | #include "Engine/Texture.h" 8 | #include "Engine/TextureRenderTarget2D.h" 9 | #include "Components/StaticMeshComponent.h" 10 | 11 | // User defined includes 12 | ${instance.code("Include")} 13 | 14 | #include "${instance.nameWithoutPrefix}.generated.h" 15 | 16 | UCLASS() 17 | class ${NAME} : public AActor, public ShadeupActorHelpers_${MODULE_NAME} 18 | { 19 | GENERATED_BODY() 20 | 21 | public: 22 | UPROPERTY(EditAnywhere, BlueprintReadWrite) 23 | class USceneComponent* SceneComponent; 24 | 25 | ${NAME}(); 26 | 27 | ${instance.code("Header")} 28 | 29 | protected: 30 | // Called when the game starts or when spawned 31 | virtual void BeginPlay() override; 32 | }; -------------------------------------------------------------------------------- /unreal-engine/src/template/Plugin/Source/Module/Public/ModuleTemplate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CoreMinimal.h" 4 | 5 | #include "Modules/ModuleInterface.h" 6 | #include "Modules/ModuleManager.h" 7 | 8 | #include "RenderGraphResources.h" 9 | #include "Runtime/Engine/Classes/Engine/TextureRenderTarget2D.h" 10 | 11 | class ${SCOPE} F${MODULE_NAME}Module : public IModuleInterface 12 | { 13 | public: 14 | 15 | /** IModuleInterface implementation */ 16 | virtual void StartupModule() override; 17 | virtual void ShutdownModule() override; 18 | }; 19 | -------------------------------------------------------------------------------- /unreal-engine/src/template/Plugin/Source/Module/Template.Build.cs: -------------------------------------------------------------------------------- 1 | using UnrealBuildTool; 2 | 3 | public class TestShader: ModuleRules 4 | 5 | { 6 | 7 | public TestShader(ReadOnlyTargetRules Target) : base(Target) 8 | 9 | { 10 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 11 | 12 | PrivateIncludePaths.AddRange(new string[] 13 | { 14 | "Runtime/Renderer/Private", 15 | "TestShader/Private" 16 | }); 17 | if (Target.bBuildEditor == true) 18 | { 19 | PrivateDependencyModuleNames.Add("TargetPlatform"); 20 | } 21 | PublicDependencyModuleNames.Add("Core"); 22 | PublicDependencyModuleNames.Add("Engine"); 23 | PublicDependencyModuleNames.Add("MaterialShaderQualitySettings"); 24 | 25 | PrivateDependencyModuleNames.AddRange(new string[] 26 | { 27 | "CoreUObject", 28 | "Renderer", 29 | "RenderCore", 30 | "RHI", 31 | "Projects" 32 | }); 33 | 34 | if (Target.bBuildEditor == true) 35 | { 36 | 37 | PrivateDependencyModuleNames.AddRange( 38 | new string[] { 39 | "UnrealEd", 40 | "MaterialUtilities", 41 | "SlateCore", 42 | "Slate" 43 | } 44 | ); 45 | 46 | CircularlyReferencedDependentModules.AddRange( 47 | new string[] { 48 | "UnrealEd", 49 | "MaterialUtilities", 50 | } 51 | ); 52 | } 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /unreal-engine/src/template/Template.Build.cs: -------------------------------------------------------------------------------- 1 | using UnrealBuildTool; 2 | 3 | public class ${MODULE_NAME}: ModuleRules 4 | 5 | { 6 | 7 | public ${MODULE_NAME}(ReadOnlyTargetRules Target) : base(Target) 8 | 9 | { 10 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 11 | 12 | PrivateIncludePaths.AddRange(new string[] 13 | { 14 | "Runtime/Renderer/Private", 15 | "${MODULE_NAME}/Private" 16 | }); 17 | if (Target.bBuildEditor == true) 18 | { 19 | PrivateDependencyModuleNames.Add("TargetPlatform"); 20 | } 21 | PublicDependencyModuleNames.Add("Core"); 22 | PublicDependencyModuleNames.Add("Engine"); 23 | PublicDependencyModuleNames.Add("MaterialShaderQualitySettings"); 24 | 25 | PrivateDependencyModuleNames.AddRange(new string[] 26 | { 27 | "CoreUObject", 28 | "Renderer", 29 | "RenderCore", 30 | "RHI", 31 | "Projects" 32 | }); 33 | 34 | if (Target.bBuildEditor == true) 35 | { 36 | 37 | PrivateDependencyModuleNames.AddRange( 38 | new string[] { 39 | "UnrealEd", 40 | "MaterialUtilities", 41 | "SlateCore", 42 | "Slate" 43 | } 44 | ); 45 | 46 | CircularlyReferencedDependentModules.AddRange( 47 | new string[] { 48 | "UnrealEd", 49 | "MaterialUtilities", 50 | } 51 | ); 52 | } 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /unreal-engine/src/template/compute.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AskingQuestions/Shadeup/8b25bf92c1aab62a48b6bc838f23dc33fb0a2285/unreal-engine/src/template/compute.cpp -------------------------------------------------------------------------------- /unreal-engine/src/template/lib/ShadeupLib.h: -------------------------------------------------------------------------------- 1 | // Shared shadeup helpers 2 | #ifndef SHADEUP_LIB_${MODULE_NAME} 3 | #define SHADEUP_LIB_${MODULE_NAME} 4 | 5 | #include "Engine/TextureRenderTarget2D.h" 6 | #include "Kismet/GameplayStatics.h" 7 | #include "Kismet/KismetRenderingLibrary.h" 8 | #include "Components/StaticMeshComponent.h" 9 | 10 | // Actor helpers included in every shadeup actor defined 11 | 12 | class ShadeupActorHelpers_${MODULE_NAME} { 13 | public: 14 | enum MeshShape { 15 | Cube, 16 | Sphere, 17 | Cylinder, 18 | Plane 19 | }; 20 | 21 | AActor* ThisActor; 22 | 23 | bool bIsInConstructor = true; 24 | 25 | UTextureRenderTarget2D* AddRenderTarget(const int32 Width, const int32 Height, ETextureRenderTargetFormat Format = ETextureRenderTargetFormat::RTF_RGBA8_SRGB); 26 | 27 | TObjectPtr AddStaticMesh(const FString& Name, const MeshShape& Shape, const FVector& Location = FVector(0.f), const FRotator& Rotation = FRotator(0.f), const FVector& Scale = FVector(1.f)); 28 | 29 | // Called in the actor constructor 30 | virtual void Setup(); 31 | }; 32 | 33 | 34 | #endif -------------------------------------------------------------------------------- /unreal-engine/src/template/lib/readme.md: -------------------------------------------------------------------------------- 1 | # src/lib 2 | 3 | Provides shared c++ code for generated files. e.g. Shadeup Actor with some helper methods for creating render targets or components -------------------------------------------------------------------------------- /unreal-engine/src/templates/compute/simple-compute-shader/Plugin/Shaders/[MODULE]/Private/[NAME]/$base[NAME].usf: -------------------------------------------------------------------------------- 1 | #include "/Engine/Public/Platform.ush" 2 | 3 | Buffer Input; 4 | RWBuffer Output; 5 | 6 | [numthreads(THREADS_X, THREADS_Y, THREADS_Z)] 7 | void ${this.answers.name}( 8 | uint3 DispatchThreadId : SV_DispatchThreadID, 9 | uint GroupIndex : SV_GroupIndex ) 10 | { 11 | // Outputs one number 12 | Output[0] = Input[0] * Input[1]; 13 | } -------------------------------------------------------------------------------- /unreal-engine/src/templates/compute/simple-compute-shader/Plugin/Shaders/[MODULE]/Private/[NAME]/$basemat[NAME].usf: -------------------------------------------------------------------------------- 1 | #include "/Engine/Generated/Material.ush" 2 | #include "/Engine/Public/Platform.ush" 3 | 4 | float2 Position; 5 | RWBuffer OutputColor; 6 | 7 | [numthreads(THREADS_X, THREADS_Y, THREADS_Z)] 8 | void ${this.answers.name}( 9 | uint3 DispatchThreadId : SV_DispatchThreadID, 10 | uint GroupIndex : SV_GroupIndex ) 11 | { 12 | float4 SvPosition = float4(Position.xy, 0, 0); 13 | 14 | FMaterialPixelParameters MaterialParameters = MakeInitializedMaterialPixelParameters(); 15 | 16 | // There are various inputs we can provide to the material graph via FMaterialPixelParameters 17 | // See: https://github.com/EpicGames/UnrealEngine/blob/5.0/Engine/Shaders/Private/MaterialTemplate.ush#L262 18 | 19 | MaterialParameters.VertexColor = half4(1, 1, 0, 1); 20 | 21 | FPixelMaterialInputs PixelMaterialInputs = (FPixelMaterialInputs)0; 22 | 23 | // This is the call to the material graph 24 | CalcMaterialParameters(MaterialParameters, PixelMaterialInputs, SvPosition, true); 25 | 26 | // PixelMaterialInputs is a struct that contains the outputs of the material graph 27 | // Use the provided helper methods ( GetMaterialXYZ(...) ) to access the outputs 28 | // See: https://github.com/EpicGames/UnrealEngine/blob/5.0/Engine/Shaders/Private/MaterialTemplate.ush#L2485 29 | 30 | OutputColor[0] = float4(GetMaterialBaseColor(PixelMaterialInputs), 0); 31 | 32 | // You can also access custom output nodes via their respective names 33 | // e.g. GetMyCustomMaterialOutput0(MaterialParameters) 34 | // See: Custom node example 35 | } -------------------------------------------------------------------------------- /unreal-engine/src/templates/compute/simple-compute-shader/Plugin/Shaders/[MODULE]/Private/[NAME]/$mat[NAME].usf: -------------------------------------------------------------------------------- 1 | #include "/Engine/Generated/Material.ush" 2 | #include "/Engine/Public/Platform.ush" 3 | 4 | RWTexture2D RenderTarget; 5 | 6 | [numthreads(THREADS_X, THREADS_Y, THREADS_Z)] 7 | void ${this.answers.name}( 8 | uint3 DispatchThreadId : SV_DispatchThreadID, 9 | uint GroupIndex : SV_GroupIndex ) 10 | { 11 | float4 SvPosition = float4(DispatchThreadId.xy, 0, 0); 12 | 13 | FMaterialPixelParameters MaterialParameters = MakeInitializedMaterialPixelParameters(); 14 | 15 | // There are various inputs we can provide to the material graph via FMaterialPixelParameters 16 | // See: https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/MaterialTemplate.ush#L262 17 | 18 | MaterialParameters.VertexColor = half4(1, 1, 0, 1); 19 | 20 | FPixelMaterialInputs PixelMaterialInputs = (FPixelMaterialInputs)0; 21 | 22 | // This is the call to the material graph 23 | CalcMaterialParameters(MaterialParameters, PixelMaterialInputs, SvPosition, true); 24 | 25 | // PixelMaterialInputs is a struct that contains the outputs of the material graph 26 | // Use the provided helper methods ( GetMaterialXYZ(...) ) to access the outputs 27 | // See: https://github.com/chendi-YU/UnrealEngine/blob/master/Engine/Shaders/MaterialTemplate.usf#L1298 28 | 29 | RenderTarget[DispatchThreadId.xy] = GetMaterialBaseColor(PixelMaterialInputs); 30 | } -------------------------------------------------------------------------------- /unreal-engine/src/templates/compute/simple-compute-shader/Plugin/Shaders/[MODULE]/Private/[NAME]/$pi[NAME].usf: -------------------------------------------------------------------------------- 1 | #include "/Engine/Public/Platform.ush" 2 | 3 | // Calculate π using the monte carlo method 4 | // https://en.wikipedia.org/wiki/Monte_Carlo_method 5 | 6 | // Output has 1 element: [numInCircle] 7 | RWBuffer Output; 8 | 9 | // Seed the random number generator 10 | float Seed = 0.0f; 11 | 12 | float random( float2 p ) 13 | { 14 | float2 r = float2( 15 | 23.14069263277926, 16 | 2.665144142690225 17 | ); 18 | return frac( cos( dot(p,r) ) * 12345.6789 ); 19 | } 20 | 21 | [numthreads(THREADS_X, THREADS_Y, THREADS_Z)] 22 | void ${this.answers.name}( 23 | uint3 DispatchThreadId : SV_DispatchThreadID, 24 | uint GroupIndex : SV_GroupIndex ) 25 | { 26 | float2 RandomPosition = float2( 27 | random(float2(GroupIndex * THREADS_X + DispatchThreadId.x, 10 + Seed)), 28 | random(float2(GroupIndex * THREADS_X + DispatchThreadId.x, 20 * Seed)) 29 | ); 30 | float Dist = length(RandomPosition); 31 | 32 | if (Dist < 1.0f) { 33 | uint Dummy; 34 | InterlockedAdd(Output[0], 1, Dummy); 35 | } 36 | } -------------------------------------------------------------------------------- /unreal-engine/src/templates/compute/simple-compute-shader/Plugin/Shaders/[MODULE]/Private/[NAME]/$rt[NAME].usf: -------------------------------------------------------------------------------- 1 | #include "/Engine/Public/Platform.ush" 2 | 3 | RWTexture2D RenderTarget; 4 | 5 | [numthreads(THREADS_X, THREADS_Y, THREADS_Z)] 6 | void ${this.answers.name}( 7 | uint3 DispatchThreadId : SV_DispatchThreadID, 8 | uint GroupIndex : SV_GroupIndex ) 9 | { 10 | // Simple checkerboard 11 | int x = floor(DispatchThreadId.x / 16.f); 12 | int y = floor(DispatchThreadId.y / 16.f); 13 | int c = (x + y % 2) % 2; 14 | 15 | RenderTarget[DispatchThreadId.xy] = float3(c, c, c); 16 | } -------------------------------------------------------------------------------- /unreal-engine/src/templates/compute/simple-compute-shader/Plugin/Source/[MODULE]/Private/[NAME]/[NAME].h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CoreMinimal.h" 4 | #include "${MODULE_NAME}/Public/${MODULE_NAME}.h" 5 | #include "MeshPassProcessor.h" 6 | #include "RHICommandList.h" 7 | #include "RenderGraphBuilder.h" 8 | #include "RenderTargetPool.h" 9 | #include "MeshMaterialShader.h" 10 | #include "ShaderParameterUtils.h" 11 | #include "RHIStaticStates.h" 12 | #include "Shader.h" 13 | #include "RHI.h" 14 | #include "GlobalShader.h" 15 | #include "RenderGraphUtils.h" 16 | #include "ShaderParameterStruct.h" 17 | #include "UniformBuffer.h" 18 | #include "RHICommandList.h" 19 | #include "ShaderCompilerCore.h" 20 | #include "EngineDefines.h" 21 | #include "RendererInterface.h" 22 | #include "RenderResource.h" 23 | #include "RenderGraphResources.h" 24 | 25 | #include "RenderGraphResources.h" 26 | #include "Runtime/Engine/Classes/Engine/TextureRenderTarget2D.h" 27 | 28 | #define NUM_THREADS_${NAME}_X ${instance.threadCounts[0]} 29 | #define NUM_THREADS_${NAME}_Y ${instance.threadCounts[1]} 30 | #define NUM_THREADS_${NAME}_Z ${instance.threadCounts[2]} -------------------------------------------------------------------------------- /unreal-engine/src/templates/compute/simple-compute-shader/Plugin/Source/[MODULE]/Public/[NAME]/$base[NAME]_readme.md: -------------------------------------------------------------------------------- 1 | # ${NAME} usage 2 | 3 | ## Blueprint 4 | 5 | 1. Right-click in any blueprint editor and add the node: "ExecuteBaseComputeShader" 6 | 2. This should give you a node with 2 inputs and 1 output. The output = A \* B 7 | 3. Enjoy, and get digging into the code 8 | 9 | ## C++ 10 | 11 | \`\`\`cpp 12 | // Params struct used to pass args to our compute shader 13 | F${NAME}DispatchParams Params(1, 1, 1); 14 | 15 | // Fill in your input parameters here 16 | Params.XYZ = 123; 17 | 18 | // These are defined/used in: 19 | // 1. Private/${NAME}/${NAME}.cpp under BEGIN_SHADER_PARAMETER_STRUCT 20 | // 2. Public/${NAME}/${NAME}.h under F${NAME}DispatchParams 21 | // 3. Private/${NAME}/${NAME}.cpp under F${NAME}Interface::DispatchRenderThread 22 | 23 | // Executes the compute shader and blocks until complete. You can place outputs in the params struct 24 | F${NAME}Interface::Dispatch(Params); 25 | \`\`\` 26 | 27 | Feel free to delete this file 28 | -------------------------------------------------------------------------------- /unreal-engine/src/templates/compute/simple-compute-shader/Plugin/Source/[MODULE]/Public/[NAME]/$basemat[NAME]_readme.md: -------------------------------------------------------------------------------- 1 | # ${NAME} usage 2 | 3 | ## Blueprint 4 | 5 | 1. Create new/open a material and check off the Use with Virtual Heightfield Mesh _(this is to prevent the compute shader from being compiled against every material in the engine)_ 6 | 2. Right-click in any blueprint editor and add the node: "Execute Base Material Compute Shader" 7 | 3. Pass in a context actor (run "Get Actor By Class" and set the class to "Actor") 8 | 4. Enjoy, and get digging into the code 9 | 10 | Feel free to delete this file 11 | -------------------------------------------------------------------------------- /unreal-engine/src/templates/compute/simple-compute-shader/Plugin/Source/[MODULE]/Public/[NAME]/$mat[NAME]_readme.md: -------------------------------------------------------------------------------- 1 | # ${NAME} usage 2 | 3 | ## Blueprint 4 | 5 | 1. Create new/open a material and check off the Use with Virtual Heightfield Mesh _(this is to prevent the compute shader from being compiled against every material in the engine)_ 6 | 2. Create a new render target with the size set to a multiple of 32 7 | 3. Right-click in any blueprint editor and add the node: "Execute Material RTCompute Shader" 8 | 4. Pass in a context actor (run "Get Actor By Class" and set the class to "Actor"), material, and render target 9 | 5. Enjoy, and get digging into the code 10 | 11 | Feel free to delete this file 12 | -------------------------------------------------------------------------------- /unreal-engine/src/templates/compute/simple-compute-shader/Plugin/Source/[MODULE]/Public/[NAME]/$pi[NAME]_readme.md: -------------------------------------------------------------------------------- 1 | # ${NAME} usage 2 | 3 | ## Blueprint 4 | 5 | 1. Right-click in any blueprint editor and add the node: "CalculatePIComputeShader" 6 | 2. Pass in a moderately high non-even number under 256k for the number of samples 7 | 3. Enjoy, and get digging into the code 8 | 9 | ## C++ 10 | 11 | \`\`\`cpp 12 | // Params struct used to pass args to our compute shader 13 | F${NAME}DispatchParams Params(1, 1, 1); 14 | 15 | // Fill in your input parameters here 16 | Params.XYZ = 123; 17 | 18 | // These are defined/used in: 19 | // 1. Private/${NAME}/${NAME}.cpp under BEGIN_SHADER_PARAMETER_STRUCT 20 | // 2. Public/${NAME}/${NAME}.h under F${NAME}DispatchParams 21 | // 3. Private/${NAME}/${NAME}.cpp under F${NAME}Interface::DispatchRenderThread 22 | 23 | // Executes the compute shader and blocks until complete. You can place outputs in the params struct 24 | F${NAME}Interface::Dispatch(Params); 25 | \`\`\` 26 | 27 | Feel free to delete this file 28 | -------------------------------------------------------------------------------- /unreal-engine/src/templates/compute/simple-compute-shader/Plugin/Source/[MODULE]/Public/[NAME]/$rt[NAME]_readme.md: -------------------------------------------------------------------------------- 1 | # ${NAME} usage 2 | 3 | ## Blueprint 4 | 5 | 1. Right-click in any blueprint editor and add the node: "Execute RTCompute Shader" 6 | 2. Pass in a render target 7 | 3. Enjoy, and get digging into the code 8 | 9 | Find the main shader code under \`Plugin/Shaders/Module/Private/${NAME}/${NAME}.usf\` 10 | 11 | Feel free to delete this file 12 | -------------------------------------------------------------------------------- /unreal-engine/src/templates/instancing/compute-indirect-drawing/Plugin/Source/[MODULE]/Private/[NAME]/[NAME]Actor.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "${MODULE_NAME}/Public/${NAME}/${NAME}Actor.h" 4 | #include "${MODULE_NAME}/Public/${NAME}/${NAME}Component.h" 5 | 6 | A${NAME}::A${NAME}(const FObjectInitializer& ObjectInitializer) 7 | : Super(ObjectInitializer) 8 | { 9 | RootComponent = ${NAME}Component = CreateDefaultSubobject(TEXT("${NAME}Component")); 10 | } 11 | -------------------------------------------------------------------------------- /unreal-engine/src/templates/instancing/compute-indirect-drawing/Plugin/Source/[MODULE]/Private/[NAME]/[NAME]Component.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | // Adapted from the VirtualHeightfieldMesh plugin 3 | 4 | #include "${MODULE_NAME}/Public/${NAME}/${NAME}Component.h" 5 | 6 | #include "Engine/World.h" 7 | #include "${NAME}SceneProxy.h" 8 | 9 | U${NAME}Component::U${NAME}Component(const FObjectInitializer& ObjectInitializer) 10 | : Super(ObjectInitializer) 11 | { 12 | CastShadow = true; 13 | bCastContactShadow = false; 14 | bUseAsOccluder = true; 15 | bAffectDynamicIndirectLighting = false; 16 | bAffectDistanceFieldLighting = false; 17 | bNeverDistanceCull = true; 18 | #if WITH_EDITORONLY_DATA 19 | bEnableAutoLODGeneration = false; 20 | #endif 21 | Mobility = EComponentMobility::Static; 22 | } 23 | 24 | void U${NAME}Component::OnRegister() 25 | { 26 | Super::OnRegister(); 27 | } 28 | 29 | void U${NAME}Component::OnUnregister() 30 | { 31 | Super::OnUnregister(); 32 | } 33 | 34 | void U${NAME}Component::ApplyWorldOffset(const FVector& InOffset, bool bWorldShift) 35 | { 36 | Super::ApplyWorldOffset(InOffset, bWorldShift); 37 | MarkRenderStateDirty(); 38 | } 39 | 40 | bool U${NAME}Component::IsVisible() const 41 | { 42 | return Super::IsVisible(); 43 | } 44 | 45 | FBoxSphereBounds U${NAME}Component::CalcBounds(const FTransform& LocalToWorld) const 46 | { 47 | return FBoxSphereBounds(FBox(FVector(0.f, 0.f, 0.f), FVector(10000.f))).TransformBy(LocalToWorld); 48 | } 49 | 50 | FPrimitiveSceneProxy* U${NAME}Component::CreateSceneProxy() 51 | { 52 | return new F${NAME}SceneProxy(this); 53 | } 54 | 55 | void U${NAME}Component::SetMaterial(int32 InElementIndex, UMaterialInterface* InMaterial) 56 | { 57 | if (InElementIndex == 0 && Material != InMaterial) 58 | { 59 | Material = InMaterial; 60 | MarkRenderStateDirty(); 61 | } 62 | } 63 | 64 | void U${NAME}Component::GetUsedMaterials(TArray& OutMaterials, bool bGetDebugMaterials) const 65 | { 66 | if (Material != nullptr) 67 | { 68 | OutMaterials.Add(Material); 69 | } 70 | } -------------------------------------------------------------------------------- /unreal-engine/src/templates/instancing/compute-indirect-drawing/Plugin/Source/[MODULE]/Public/[NAME]/$base[NAME]_readme.md: -------------------------------------------------------------------------------- 1 | # ${NAME} usage 2 | 3 | ## World 4 | 5 | 1. Open the "Add Actors" panel and search for "Example Indirect Instancing" 6 | 2. Drag and drop that actor into your world 7 | 3. Enjoy, and get digging into the code 8 | 9 | ## Notes 10 | 11 | - Shadows are broken until UE 5.1. See: https://github.com/EpicGames/UnrealEngine/blob/d11782b9046e9d0b130309591e4efc57f4b8b037/Engine/Plugins/Experimental/VirtualHeightfieldMesh/Source/VirtualHeightfieldMesh/Private/VirtualHeightfieldMeshSceneProxy.cpp#L538 12 | - The mesh will flicker as you move it. 13 | 14 | Feel free to delete this file 15 | -------------------------------------------------------------------------------- /unreal-engine/src/templates/instancing/compute-indirect-drawing/Plugin/Source/[MODULE]/Public/[NAME]/[NAME]Actor.h: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GameFramework/Actor.h" 7 | #include "${NAME}Actor.generated.h" 8 | 9 | UCLASS(hidecategories = (Cooking, Input, LOD), MinimalAPI) 10 | class A${NAME} : public AActor 11 | { 12 | GENERATED_UCLASS_BODY() 13 | 14 | private: 15 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) 16 | class U${NAME}Component* ${NAME}Component; 17 | 18 | protected: 19 | }; 20 | -------------------------------------------------------------------------------- /unreal-engine/src/templates/instancing/compute-indirect-drawing/Plugin/Source/[MODULE]/Public/[NAME]/[NAME]Component.h: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | // Adapted from the VirtualHeightfieldMesh plugin 3 | 4 | #pragma once 5 | 6 | #include "CoreMinimal.h" 7 | #include "Components/PrimitiveComponent.h" 8 | #include "${NAME}Component.generated.h" 9 | 10 | class UMaterialInterface; 11 | 12 | UCLASS(Blueprintable, ClassGroup = Rendering, hideCategories = (Activation, Collision, Cooking, HLOD, Navigation, Object, Physics, VirtualTexture)) 13 | class ${SCOPE} U${NAME}Component : public UPrimitiveComponent 14 | { 15 | GENERATED_UCLASS_BODY() 16 | 17 | protected: 18 | /** Material applied to each instance. */ 19 | UPROPERTY(EditAnywhere, Category = Rendering) 20 | UMaterialInterface* Material = nullptr; 21 | 22 | public: 23 | 24 | UMaterialInterface* GetMaterial() const { return Material; } 25 | 26 | protected: 27 | //~ Begin UActorComponent Interface 28 | virtual void OnRegister() override; 29 | virtual void OnUnregister() override; 30 | virtual void ApplyWorldOffset(const FVector& InOffset, bool bWorldShift) override; 31 | //~ End UActorComponent Interface 32 | 33 | //~ Begin USceneComponent Interface 34 | virtual bool IsVisible() const override; 35 | virtual FBoxSphereBounds CalcBounds(const FTransform& LocalToWorld) const override; 36 | //~ EndUSceneComponent Interface 37 | 38 | //~ Begin UPrimitiveComponent Interface 39 | virtual FPrimitiveSceneProxy* CreateSceneProxy() override; 40 | virtual bool SupportsStaticLighting() const override { return true; } 41 | virtual void SetMaterial(int32 ElementIndex, class UMaterialInterface* Material) override; 42 | virtual UMaterialInterface* GetMaterial(int32 Index) const override { return Material; } 43 | virtual void GetUsedMaterials(TArray& OutMaterials, bool bGetDebugMaterials = false) const override; 44 | //~ End UPrimitiveComponent Interface 45 | }; 46 | -------------------------------------------------------------------------------- /unreal-engine/src/templates/instancing/compute-instanced-static-mesh-component/Plugin/Shaders/[MODULE]/Private/[NAME]/[NAME].ush: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | // Adapted from the VirtualHeightfieldMesh plugin 3 | 4 | #pragma once 5 | 6 | /** Structure used for tracking work queues in persistent wave style shaders. */ 7 | struct InstanceInfo 8 | { 9 | uint Num; 10 | }; 11 | 12 | /** Item description used when traversing the virtual page table quad tree. Packs as uint so store in Buffer declared as uint. */ 13 | struct MeshItem 14 | { 15 | float3 Position; 16 | float3 Rotation; 17 | float3 Scale; 18 | }; 19 | 20 | MeshItem InitMeshItem(float3 Pos, float3 Rot, float3 Scale) 21 | { 22 | MeshItem Item; 23 | Item.Position = Pos; 24 | Item.Rotation = Rot; 25 | Item.Scale = Scale; 26 | return Item; 27 | } -------------------------------------------------------------------------------- /unreal-engine/src/templates/instancing/compute-instanced-static-mesh-component/Plugin/Source/[MODULE]/Private/[NAME]/[NAME]Actor.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "${MODULE_NAME}/Public/${NAME}/${NAME}Actor.h" 4 | #include "${MODULE_NAME}/Public/${NAME}/${NAME}Component.h" 5 | 6 | A${NAME}::A${NAME}(const FObjectInitializer& ObjectInitializer) 7 | : Super(ObjectInitializer) 8 | { 9 | RootComponent = ${NAME}Component = CreateDefaultSubobject(TEXT("${NAME}Component")); 10 | } 11 | -------------------------------------------------------------------------------- /unreal-engine/src/templates/instancing/compute-instanced-static-mesh-component/Plugin/Source/[MODULE]/Public/[NAME]/$inst[NAME]_readme.md: -------------------------------------------------------------------------------- 1 | # ${NAME} usage 2 | 3 | ## World 4 | 5 | 1. Open the "Add Actors" panel and search for "Example Indirect Instancing" 6 | 2. Drag and drop that actor into your world 7 | 3. Apply a material and mesh 8 | 4. Select the "ExampleIndirectInstancingComponent" under the details hierarchy and click the "Add Instances" button to add more instances 9 | 5. Use your camera and fly into the meshes, they should be pushed away 10 | 6. Enjoy, and get digging into the code 11 | 12 | ## Notes 13 | 14 | - Shadows are broken until UE 5.1. See: https://github.com/EpicGames/UnrealEngine/blob/d11782b9046e9d0b130309591e4efc57f4b8b037/Engine/Plugins/Experimental/VirtualHeightfieldMesh/Source/VirtualHeightfieldMesh/Private/VirtualHeightfieldMeshSceneProxy.cpp#L538 15 | - Vertex velocities are not set up so you'll see some ghosting when using any type of temporal anti-aliasing (this is on my todo list to add) 16 | 17 | Feel free to delete this file 18 | -------------------------------------------------------------------------------- /unreal-engine/src/templates/instancing/compute-instanced-static-mesh-component/Plugin/Source/[MODULE]/Public/[NAME]/[NAME]Actor.h: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GameFramework/Actor.h" 7 | #include "${NAME}Actor.generated.h" 8 | 9 | UCLASS(hidecategories = (Cooking, Input, LOD), MinimalAPI) 10 | class A${NAME} : public AActor 11 | { 12 | GENERATED_UCLASS_BODY() 13 | 14 | private: 15 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) 16 | class U${NAME}Component* ${NAME}Component; 17 | 18 | protected: 19 | }; 20 | -------------------------------------------------------------------------------- /unreal-engine/src/templates/nodes/dynamic/Plugin/Source/[MODULE]/Public/[NAME]_readme.md: -------------------------------------------------------------------------------- 1 | # ${NAME} usage 2 | 3 | ## Material Graph 4 | 5 | 1. Right-click and search for "Shadeup" and add the relevant node 6 | 2. Enjoy, and get digging into the code 7 | 8 | Feel free to delete this file 9 | -------------------------------------------------------------------------------- /unreal-engine/src/templates/nodes/fn/Plugin/Source/[MODULE]/Public/[NAME]MaterialExpression.h: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | /** 4 | * Absolute value material expression for user-defined materials 5 | * 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "CoreMinimal.h" 11 | #include "UObject/ObjectMacros.h" 12 | #include "MaterialExpressionIO.h" 13 | #include "Materials/MaterialExpression.h" 14 | #include "${NAME}MaterialExpression.generated.h" 15 | 16 | UCLASS(MinimalAPI, collapsecategories, hidecategories=Object) 17 | class UMaterialExpression${NAME} : public UMaterialExpression 18 | { 19 | GENERATED_UCLASS_BODY() 20 | 21 | /** Link to the input expression to be evaluated */ 22 | UPROPERTY() 23 | FExpressionInput Input; 24 | 25 | 26 | //~ Begin UMaterialExpression Interface 27 | #if WITH_EDITOR 28 | virtual int32 Compile(class FMaterialCompiler* Compiler, int32 OutputIndex) override; 29 | virtual void GetCaption(TArray& OutCaptions) const override; 30 | #endif 31 | //~ End UMaterialExpression Interface 32 | 33 | }; 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /unreal-engine/src/templates/nodes/input/Plugin/Source/[MODULE]/Public/[NAME]MaterialExpression.h: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | /** 4 | * Absolute value material expression for user-defined materials 5 | * 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "CoreMinimal.h" 11 | #include "UObject/ObjectMacros.h" 12 | #include "MaterialExpressionIO.h" 13 | #include "Materials/MaterialExpression.h" 14 | #include "${NAME}MaterialExpression.generated.h" 15 | 16 | UCLASS(MinimalAPI, collapsecategories, hidecategories=Object) 17 | class UMaterialExpression${NAME} : public UMaterialExpression 18 | { 19 | GENERATED_UCLASS_BODY() 20 | 21 | 22 | //~ Begin UMaterialExpression Interface 23 | #if WITH_EDITOR 24 | virtual int32 Compile(class FMaterialCompiler* Compiler, int32 OutputIndex) override; 25 | virtual void GetCaption(TArray& OutCaptions) const override; 26 | #endif 27 | //~ End UMaterialExpression Interface 28 | 29 | }; 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /unreal-engine/src/templates/nodes/output/Plugin/Source/[MODULE]/Public/[NAME]MaterialExpression.h: -------------------------------------------------------------------------------- 1 | // Copyright Epic Games, Inc. All Rights Reserved. 2 | 3 | /** 4 | * Absolute value material expression for user-defined materials 5 | * 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "CoreMinimal.h" 11 | #include "UObject/ObjectMacros.h" 12 | #include "MaterialExpressionIO.h" 13 | #include "Materials/MaterialExpressionCustomOutput.h" 14 | #include "${NAME}MaterialExpression.generated.h" 15 | 16 | UCLASS(MinimalAPI, collapsecategories, hidecategories=Object) 17 | class UMaterialExpression${NAME} : public UMaterialExpressionCustomOutput 18 | { 19 | GENERATED_UCLASS_BODY() 20 | 21 | /** Input pin */ 22 | UPROPERTY(meta = (RequiredInput = "false", ToolTip = "Here's the tooltip text.")) 23 | FExpressionInput MyInput1; 24 | 25 | /** Input pin */ 26 | UPROPERTY(meta = (RequiredInput = "false", ToolTip = "Here's the tooltip text.")) 27 | FExpressionInput MyInput2; 28 | 29 | /** This is available in the material editor when selecting this node */ 30 | UPROPERTY(EditAnywhere, Category = "MyCategory") 31 | float CustomEditorParameter; 32 | 33 | //~ Begin UMaterialExpression Interface 34 | #if WITH_EDITOR 35 | virtual int32 Compile(class FMaterialCompiler* Compiler, int32 OutputIndex) override; 36 | virtual void GetCaption(TArray& OutCaptions) const override; 37 | #endif 38 | //~ End UMaterialExpression Interface 39 | 40 | //~ Begin UMaterialExpressionCustomOutput Interface 41 | virtual int32 GetNumOutputs() const override; 42 | virtual FString GetFunctionName() const override; 43 | virtual FString GetDisplayName() const override; 44 | //~ End UMaterialExpressionCustomOutput Interface 45 | }; 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /unreal-engine/src/types/actor.js: -------------------------------------------------------------------------------- 1 | import BaseGenerator from "./base.js"; 2 | 3 | export default class ActorGenerator extends BaseGenerator { 4 | verify() { 5 | super.verify(); 6 | 7 | if (this.name[0] != "A") { 8 | this.error(this.data.identifier, `Actor name must start with the letter "A" (Change "${this.name}" to "A${this.name}")`); 9 | } 10 | 11 | this.nameWithoutPrefix = this.name.substr(1, this.name.length - 1); 12 | } 13 | 14 | generate() { 15 | super.generate(); 16 | 17 | this.includeLib(); 18 | 19 | this.output({ 20 | context: this.data, 21 | template: "Plugin/Source/Module/Private/ActorTemplate.cpp", 22 | output: `Source/${this.file.module}/Private/Actors/${this.nameWithoutPrefix}.cpp`, 23 | data: this 24 | }); 25 | 26 | this.output({ 27 | context: this.data, 28 | template: "Plugin/Source/Module/Public/ActorTemplate.h", 29 | output: `Source/${this.file.module}/Public/Actors/${this.nameWithoutPrefix}.h`, 30 | data: this 31 | }); 32 | } 33 | } -------------------------------------------------------------------------------- /unreal-engine/src/types/compute.js: -------------------------------------------------------------------------------- 1 | import ShaderGenerator from "./shader.js"; 2 | import ParsedValue from "./value.js"; 3 | 4 | export default class ComputeGenerator extends ShaderGenerator { 5 | verify() { 6 | super.verify(); 7 | // console.log([...this.properties.entries()].map(e => `${e[0]} = ${JSON.stringify(e[1].flatten())}`)); 8 | 9 | this.ShaderBase = this.prop("ExtendMaterial", false) ? "Material" : "Global"; 10 | 11 | this.checkRoot("NumThreads", "array", "Compute shader must have a NumThreads array property (did you forget to add NumThreads=[1, 1, 1]; ?)"); 12 | this.threadCounts = this.prop("NumThreads", []); 13 | if (this.threadCounts.length !== 3) { 14 | this.error(this.properties.get("NumThreads").data, "NumThreads must have exactly 3 elements"); 15 | } 16 | 17 | this.threadCounts = this.threadCounts.map(v => v.value()); 18 | } 19 | 20 | generate() { 21 | super.generate(); 22 | 23 | this.output({ 24 | context: this.data, 25 | template: "Plugin/Shaders/Compute/Private/Template.usf", 26 | output: `Shaders/${this.file.module}/Private/${this.name}.usf`, 27 | data: this 28 | }); 29 | 30 | this.output({ 31 | context: this.data, 32 | template: "Plugin/Source/Module/Private/ComputeTemplate.cpp", 33 | output: `Source/${this.file.module}/Private/Compute/${this.name}.cpp`, 34 | data: this 35 | }); 36 | 37 | this.output({ 38 | context: this.data, 39 | template: "Plugin/Source/Module/Private/ComputeTemplate.h", 40 | output: `Source/${this.file.module}/Private/Compute/${this.name}.h`, 41 | data: this 42 | }); 43 | } 44 | 45 | shader() { 46 | return super.shader().replace("void " + this.name, `[numthreads(${this.threadCounts.join(", ")})]\nvoid ` + this.name) 47 | } 48 | } -------------------------------------------------------------------------------- /unreal-engine/src/types/factory.js: -------------------------------------------------------------------------------- 1 | import ShaderGenerator from "./shader.js"; 2 | import ParsedValue from "./value.js"; 3 | 4 | export default class FactoryGenerator extends ShaderGenerator { 5 | verify() { 6 | super.verify(); 7 | 8 | if (this.name[0] != "F") { 9 | this.error(this.data.identifier, `Vertex Factory name must start with the letter "F" (Change "${this.name}" to "F${this.name}")`); 10 | } 11 | 12 | this.nameWithoutPrefix = this.name.substr(1, this.name.length - 1); 13 | } 14 | 15 | generate() { 16 | super.generate(); 17 | 18 | this.output({ 19 | context: this.data, 20 | template: "Plugin/Shaders/Factory/Private/Template.ush", 21 | output: `Shaders/${this.file.module}/Private/${this.nameWithoutPrefix}.ush`, 22 | data: this 23 | }); 24 | 25 | this.output({ 26 | context: this.data, 27 | template: "Plugin/Source/Module/Private/FactoryTemplate.cpp", 28 | output: `Source/${this.file.module}/Private/Factory/${this.nameWithoutPrefix}.cpp`, 29 | data: this 30 | }); 31 | 32 | this.output({ 33 | context: this.data, 34 | template: "Plugin/Source/Module/Private/FactoryTemplate.h", 35 | output: `Source/${this.file.module}/Private/Factory/${this.nameWithoutPrefix}.h`, 36 | data: this 37 | }); 38 | } 39 | 40 | shader() { 41 | return super.shader(); 42 | } 43 | } -------------------------------------------------------------------------------- /unreal-engine/src/types/value.js: -------------------------------------------------------------------------------- 1 | export default class ParsedValue { 2 | constructor(file, data) { 3 | this.file = file; 4 | this.data = data; 5 | 6 | this.type = data.value.type; 7 | } 8 | 9 | value() { 10 | if (this.type == "number") { 11 | return parseFloat(this.data.value.text); 12 | }else if (this.type == "string") { 13 | return this.data.value.text; 14 | }else if (this.type == "boolean") { 15 | return this.data.value.value; 16 | }else if (this.type == "identifier") { 17 | return this.data.value.text; 18 | }else if (this.type == "array") { 19 | return this.data.value.values.map(v => { 20 | let pv = new ParsedValue(this.file, v); 21 | return pv; 22 | }); 23 | }else if (this.type == "block") { 24 | let props = {}; 25 | props.$data = this.data; 26 | for (let prop of this.data.value.items) { 27 | if (prop.type == "property") { 28 | let name = prop.identifier.text; 29 | let value = new ParsedValue(this.file, prop.value); 30 | props[name] = value; 31 | } 32 | } 33 | 34 | return props; 35 | } 36 | } 37 | 38 | flatten() { 39 | if (this.type == "array") { 40 | return this.value().map(v => v.flatten()); 41 | }else if (this.type == "block") { 42 | let v = this.value(); 43 | for (let k of Object.keys(v)) { 44 | v[k] = v[k].flatten(); 45 | } 46 | return v; 47 | }else{ 48 | return this.value(); 49 | } 50 | } 51 | 52 | error(context, message) { 53 | this.file.error(context, message); 54 | } 55 | 56 | getType(value) { 57 | let t = typeof value; 58 | if (t === "object") { 59 | if (Array.isArray(t)) { 60 | return "array"; 61 | } 62 | } 63 | 64 | return t; 65 | } 66 | } -------------------------------------------------------------------------------- /unreal-engine/src/util.js: -------------------------------------------------------------------------------- 1 | const TYPE_TABLE = { 2 | "half": "half", 3 | "float": "float", 4 | "double": "double", 5 | "int": "int", 6 | "uint": "uint", 7 | "bool": "bool", 8 | "float2": "FVector2D", 9 | "float3": "FVector", 10 | "float4": "FVector4", 11 | "float4x4": "FMatrix", 12 | }; 13 | 14 | const REVERSE_TYPE_TABLE = Object.entries(TYPE_TABLE).reduce((acc, [key, value]) => { 15 | acc[value] = key; 16 | return acc; 17 | }, {}); 18 | 19 | export default { 20 | RemoveFrontWhitespace: function(str) { 21 | let lines = str.split("\n"); 22 | let minChars = Infinity; 23 | for (let l of lines) { 24 | if ((/^\s*$/.test(l))) { 25 | continue; 26 | } 27 | let chars = l.length - l.trimLeft().length; 28 | 29 | if (chars < minChars) { 30 | minChars = chars; 31 | } 32 | } 33 | 34 | let regex = new RegExp("^\\s{" + minChars + "}", "gm"); 35 | 36 | for (let i = 0; i < lines.length; i++) { 37 | lines[i] = lines[i].replace(regex, ""); 38 | } 39 | 40 | return lines.join("\n"); 41 | }, 42 | ExtractTemplate(type) { 43 | let m = type.match(/^([A-Za-z_0-9]+)(<[A-Za-z_0-9<>]+>)?$/); 44 | let name = m[1]; 45 | let template = m[2]; 46 | 47 | return {name, template}; 48 | }, 49 | ConvertType(type, tab) { 50 | let d = this.ExtractTemplate(type); 51 | 52 | if (d.template) { 53 | return d.name + "<" + this.ConvertType(d.template.substring(1, d.template.length - 1), tab) + ">"; 54 | }else{ 55 | return tab[d.name] || d.name; 56 | } 57 | }, 58 | TypeToCPP(type) { 59 | return this.ConvertType(type, TYPE_TABLE); 60 | }, 61 | TypeToHLSL(type) { 62 | return this.ConvertType(type, REVERSE_TYPE_TABLE); 63 | } 64 | }; -------------------------------------------------------------------------------- /unreal-engine/src/whitespace.ne: -------------------------------------------------------------------------------- 1 | # Whitespace: `_` is optional, `__` is mandatory. 2 | _ -> wschar:* {% function(d) {return null;} %} 3 | __ -> wschar:+ {% function(d) {return null;} %} 4 | 5 | wschar -> [ \t\r\n\v\f] {% id %} -------------------------------------------------------------------------------- /unreal-engine/test.hlsl: -------------------------------------------------------------------------------- 1 | #define x 123 -------------------------------------------------------------------------------- /unreal-engine/test.js: -------------------------------------------------------------------------------- 1 | const nearley = require("nearley"); 2 | const grammar = require("./build/grammar.js"); 3 | const fs = require("fs"); 4 | 5 | // Create a Parser object from our grammar. 6 | const parser = new nearley.Parser(nearley.Grammar.fromCompiled(grammar)); 7 | 8 | // Parse something! 9 | parser.feed(fs.readFileSync("./test.shadeup", "utf8")); 10 | 11 | // parser.results is an array of possible parsings. 12 | console.log(JSON.stringify(parser.results, null, 2)); // [[[[["foo"],"\n"]]]] -------------------------------------------------------------------------------- /unreal-engine/test.shadeup: -------------------------------------------------------------------------------- 1 | @plugin "MyPlugin" 2 | @module "TestShader" 3 | 4 | compute Basic { 5 | Permutations = [ 6 | { 7 | Type = int 8 | Name = "TEST" 9 | Range = 1 10 | } 11 | ] 12 | 13 | Shader = { 14 | 15 | [numthreads(32, 32, 1)] 16 | void Main(uint3 ThreadId : SV_DispatchThreadID) { 17 | 18 | } 19 | 20 | }; 21 | } --------------------------------------------------------------------------------