Skip to content

About

IRMF Shader Editor

Resources

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

example with value ranges

Try it out!

This is work-in-progress - the editor is not fully functional yet.

Note that nothing is saved in the editor! You must copy/paste your shader source and save it locally or all edits will be lost!

Summary

IRMF is a file format used to describe GLSL ES, WGSL, or TSL shaders that define the materials in a 3D object with infinite resolution. IRMF completely eliminates the need for software slicers, STL, and G-code files used in 3D printers.

I believe that IRMF shaders will some day revolutionize the 3D-printing industry.

Shader languages

The editor renders all three IRMF languages:

language Renderer Requirements
glsl three.js r110 WebGL WebGL2
wgsl hand-written raw WebGPU pipeline WebGPU
tsl modern three.js WebGPURenderer + NodeMaterial WebGPU, or WebGL2 fallback

TSL models are executable JavaScript that build a three.js node graph. The editor evaluates them in the page, so it asks for confirmation the first time a particular TSL URL is loaded, showing the exact source URL. Approval is per URL and per page load, never session-wide. TSL is pinned to three.js 0.180.0 (see the import map in index.html); each example records its tslVersion.

The evaluator shadows network, filesystem, DOM, and host-process handles and rejects #include, export, and dynamic import(). These are guardrails, not a hardened sandbox: a determined body can still reach JavaScript internals. Treat any TSL model you did not write as untrusted code.

You can load a local example with /?file=/examples/<dir>/<base>-tsl.irmf when the test server mounts the corpus (see tests/e2e/README.md).

See github.com/gmlewis/irmf for more details.

LYGIA support

As of 2022-10-26, support has been added for using the LYGIA Shader Library at: https://lygia.xyz !

This means that you can add lines to your IRMF shaders like this:

#include "lygia/math/decimation.glsl"

and the source will be retrieved (and cached) from the LYGIA server.

Remote includes are executable shader code, so the editor asks for permission once per include host on each page load, only fetches HTTPS URLs from lygia.xyz and raw.githubusercontent.com, and caps the number and size of includes. #include is rejected in TSL bodies, where it would be remote JavaScript execution. Inline code you do not want fetched at load time.

Security

An IRMF file is executable code. The editor treats every model as untrusted:

  • ?file= only accepts same-origin paths (protocol-relative URLs such as //evil.example/x.irmf are rejected in Go and again in fetchTextSync);
  • models loaded from a URL require confirmation that names the source URL;
  • TSL approval is per source and per page load;
  • remote includes require per-host consent and are size/count limited;
  • a GitHub include that names a branch or tag is rejected unless you approve that specific mutable include in a separate prompt; commit-pinned includes need no such prompt;
  • #include is rejected in TSL bodies;
  • material names, titles, and compiler diagnostics are written with textContent, never innerHTML, and material names are not passed to dat.GUI's HTML-based .name() (they render as text);
  • shader bodies are capped at 16 MiB decoded and .irmf files at 64 MiB.

GLSL and WGSL still reach the GPU driver, and TSL still runs JavaScript in the page. For hostile input, use a separate browser profile or a sandboxed deployment; the same caveat applies to the native slicers.

Congratulations and thanks go to Patricio Gonzalez Vivo for making the LYGIA server available for anyone to use, and also for the amazing tool glslViewer!

IRMF Shader Editor Status

This is the very start of the in-browser IRMF shader editor, built on Microsoft's amazing open-source Monaco Editor.

The technology stack used is Go compiled to WebAssembly using the extremely handy tool go-wasm-cli.

Easy installation: npm i -g go-wasm-cli.

The goal is to allow people to easily design their IRMF shaders and visualize the models in real time from this static web app. All processing will be done with WebGL within the client browser. People will edit their model, then copy/paste the code to their local filesystem to save it offline. This keeps the app super-simple and prevents abuse by not storing anything on the server.

FAQ

How does it work?

This editor dices up your model (the IRMF shader) into slices (planes) that are perpendicular (normal) to your eye (the camera). Because the planes are all stacked together and render the model at different depths from your eye, it appears that you are being shown a solid, when in actuality, you are being shown a lot of very thin slices of your model all stacked together.

Here is a picture showing what is happening:

How it works

The camera is "above" the slicing planes (on the +Z axis) looking "down" through the stacked planes. As the camera rotates around, the planes also rotate to always face the camera, but slice through the model at different locations.

Why do I see jaggies in my model?

"I thought this thing had infinite resolution... what's up?"

The IRMF shader itself has infinite resolution because it is just math, but we have to dice up the design in order to display it. We also need to keep it performant, so we need to limit the number of slices to render. But as a result of slicing the model, high detail models (especially those with curves) will show more jaggies than others.

Here is a picture demonstrating the jaggies:

Jaggies

The bottom line is that I haven't figured out how to render the object yet without jaggies. This too, will be the art that the 3D printer manufacturers will be providing. They will figure out how to best slice your model at the highest resolutions possible so that you don't get jaggies in the resulting model.


License

Copyright 2019 Glenn M. Lewis. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

IRMF Shader Editor

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages