{"id":21630083,"url":"https://github.com/virtualritz/nsi","last_synced_at":"2025-04-11T13:51:57.985Z","repository":{"id":43372809,"uuid":"246460561","full_name":"virtualritz/nsi","owner":"virtualritz","description":"High level Rust bindings for Illumination Research’s Nodal Scene Interface – ɴsɪ.","archived":false,"fork":false,"pushed_at":"2024-08-19T20:32:44.000Z","size":12613,"stargazers_count":14,"open_issues_count":6,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T10:05:14.155Z","etag":null,"topics":["3d-graphics","3delight","api","offline-rendering","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/virtualritz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-03-11T02:56:51.000Z","updated_at":"2024-09-21T12:38:06.000Z","dependencies_parsed_at":"2023-02-08T14:01:55.430Z","dependency_job_id":"ac59d8a6-02a1-41f2-9746-1ace6e6b77eb","html_url":"https://github.com/virtualritz/nsi","commit_stats":{"total_commits":168,"total_committers":4,"mean_commits":42.0,"dds":0.1785714285714286,"last_synced_commit":"e46d5ad562fc877128ac982e6c69f16cd15119dc"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualritz%2Fnsi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualritz%2Fnsi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualritz%2Fnsi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualritz%2Fnsi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/virtualritz","download_url":"https://codeload.github.com/virtualritz/nsi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248411971,"owners_count":21099036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d-graphics","3delight","api","offline-rendering","rust"],"created_at":"2024-11-25T02:09:43.626Z","updated_at":"2025-04-11T13:51:57.963Z","avatar_url":"https://github.com/virtualritz.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ɴsɪ\n\nHigh level Rust bindings for Illumination Research’s Nodal Scene\nInterface – [ɴsɪ](https://nsi.readthedocs.io/).\n\n[![Build](https://github.com/virtualritz/nsi/workflows/Build/badge.svg)](https://github.com/virtualritz/nsi/actions)\n[![Documentation](https://docs.rs/nsi/badge.svg)](https://docs.rs/nsi)\n[![Crate](https://img.shields.io/crates/v/nsi.svg)](https://crates.io/crates/nsi)\n[![Chat](https://badges.gitter.im/n-s-i/community.svg)](https://gitter.im/n-s-i/community)\n\nThis puts one of the most advanced 3D production offline renderers at\nyour fingertips in Rust – [3Delight](https://www.3delight.com/).\n\n![Moana Island, rendered with 3Delight|ɴsɪ](moana_island.jpg)\n*[The Moana Island Scene](https://www.technology.disneyanimation.com/islandscene),\nprovided courtesy of Walt Disney Pictures, rendered with 3Delight|ɴsɪ.*\n\nThis is a huge scene (72GB of data) made of 31 million instances,\n78 million polygons defining subdivision surface geometry and 2,300\n[Ptex](http://ptex.us/) textures. The above image was rendered in less\nthan two minutes (wall time) using\n[3Delight Cloud](https://documentation.3delightcloud.com/display/3DLC/Cloud+Rendering+Speed).\n\n## Example\n\n```rust\n// Create a context to send the scene to.\nlet ctx = nsi::Context::new(None)\n    .expect(\"Could not create NSI context.\");\n\n// Create a dodecahedron.\n\n// 12 regular pentagon faces.\nlet face_index: [i32; 60] =\n    [\n         0, 16,  2, 10,  8,  0,  8,  4, 14, 12,\n        16, 17,  1, 12,  0,  1,  9, 11,  3, 17,\n         1, 12, 14,  5,  9,  2, 13, 15,  6, 10,\n        13,  3, 17, 16,  2,  3, 11,  7, 15, 13,\n         4,  8, 10,  6, 18, 14,  5, 19, 18,  4,\n         5, 19,  7, 11,  9, 15,  7, 19, 18,  6,\n    ];\n\n// Golden ratio.\nlet phi: f32 = 0.5 * (1.0 + 5_f32.sqrt());\n\n// Golden ratio conjugate.\nlet phi_c: f32 = phi - 1.0;\n\n// 20 points @ 3 vertices.\nlet positions: [f32; 60] =\n    [\n         1.,     1.,     1.,     1.,     1.,    -1.,\n         1.,    -1.,     1.,     1.,    -1.,    -1.,\n        -1.,     1.,     1.,    -1.,     1.,    -1.,\n        -1.,    -1.,     1.,    -1.,    -1.,    -1.,\n         0.,     phi_c,  phi,    0.,     phi_c, -phi,\n         0.,    -phi_c,  phi,    0.,    -phi_c, -phi,\n         phi_c,  phi,    0.,     phi_c, -phi,    0.,\n        -phi_c,  phi,    0.,    -phi_c, -phi,    0.,\n         phi,    0.,     phi_c,  phi,    0.,    -phi_c,\n        -phi,    0.,     phi_c, -phi,    0.,    -phi_c,\n    ];\n\n// Create a new mesh node and call it 'dodecahedron'.\nctx.create(\"dodecahedron\", nsi::MESH, None);\n\n// Connect the 'dodecahedron' node to the scene's root.\nctx.connect(\"dodecahedron\", None, nsi::ROOT, \"objects\", None);\n\n// Define the geometry of the 'dodecahedron' node.\nctx.set_attribute(\n    \"dodecahedron\",\n    \u0026[\n        nsi::points!(\"P\", \u0026positions),\n        nsi::unsigneds!(\"P.indices\", \u0026face_index),\n        // 5 vertices per each face.\n        nsi::unsigneds!(\"nvertices\", \u0026[5; 12]),\n        // Render this as a subdivison surface.\n        nsi::string!(\"subdivision.scheme\",\n            \"catmull-clark\"\n        ),\n        // Crease each of our 30 edges a bit.\n        nsi::unsigneds!(\"subdivision.creasevertices\",\n            \u0026face_index\n        ),\n        nsi::floats!(\n            \"subdivision.creasesharpness\",\n            \u0026[10.; 30]\n        ),\n    ],\n);\n```\n\nAlso check out my\n[Diffusion Limited Aggregation play-thingy](https://github.com/virtualritz/rust-diffusion-limited-aggregation)\nor [Polyhedron Operators](https://github.com/virtualritz/polyhedron-operators)\nfor more example code (demonstrates render settings, sending meshes\nto the renderer, instancing, particle rendering, [OSL](https://github.com/imageworks/OpenShadingLanguage)\nshaders, environment (lights) and dumping a scene description to disk).\n\nPRs are most welcome!\n\n## Getting Pixels\n\nThe crate has support for streaming pixels from the renderer, via\ncallbacks (i.e. closures) during and/or after rendering via the\n`output` module. This module is enabled through the feature of the\nsame name.\n\nThere is a full example showing color conversion and writing data\nout to 8bit/channel PNG and 32bit/channel (float) OpenEXR formats.\n\n## Dependencies\n\nThis crate depends on `nsi-core` which in term requires a renderer that\nimplements the ɴsɪ API to generate images.\n\nCurrently the only renderer that does is 3Delight which, though\ncommercial, has been and is free for personal use since over twenty\nyears.\n\n\u003e ***Note:*** The free version of 3Delight will render with up to 12\ncores on your machine. For crazier projects you can use their cheap\ncloud rendering service that gives you access to unlimited CPU cores.\nWhen you register you get 1,000 cloud minutes for free which ain’t too\nshabby.\n\nThat being said – I hope this crate serves as inspiration for other\npeople writing renderers, particularly in Rust, to adopt this API for\nscene description.\n\n## Prerequisites\n\nBefore you start it is suggested that you [download a 3Delight\npackage](https://www.3delight.com/download) for your platform \u0026 install\nit (supported: Linux, macOS, Windows). This will allow you to create\npretty pictures with the examples straight away.\n\nIt will also install 3Delight Display which you can render to as an\nalternative to writing images to disk. When working with this crate\nthis is quite handy.\n\nYou can skip this step and build with the `download_3delight` feature.\nHowever, this will download an older version of 3Delight so this is\nnot suggested.\n\n## Cargo Features\n\n* `output` – Add support for streaming pixels from the renderer\n  to the calling context via closures.\n\n* `jupyter` – Add support for rendering to Jupyter notebooks (when\n  using a [Rust Jupyter kernel](https://github.com/google/evcxr)).\n\n* `toolbelt` – Add convenience methods to `Context`.\n\n* [`delight`](crate::delight) – Add some nodes \u0026 shaders specifi to\n  3Delight.\n\n* `nightly` – Enable some unstable features (suggested if you build\n  with a `nightly` toolchain)\n\n* `ustr_handles` – use [`ustr`](https://crates.io/crates/ustr) for\n  node handles. This will give a you a speed boost if your node names\n  aren't changing while an app using ɴsɪ is running but is not advised\n  otherwise (`ustr` are never freed).\n\n* `download_lib3delight` \u0026 `link_lib3delight` – See next section.\n\n## Linking Style\n\nThe 3Delight dynamic library (`lib3delight`) can either be linked to\nduring build or loaded at runtime.\n\nBy default the lib is *loaded at runtime*.\n\n* Load `lib3delight` at runtime (default). This has several advantages:\n\n  1. If you ship your application or library you can ship it without\n     the library. It can still run and will print an informative error\n     if the library can not be loaded.\n\n  2. A user can install an updated version of the renderer and stuff\n     will ‘just work’.\n\n* Dynamically link against `lib3delight`.\n\n  * `lib3delight` becomes a dependency. If it can not be found your\n    lib/app will not load/start.\n\n  * The feature is called `link_lib3delight`.\n\n  * You should disable default features (`default-features = false`).\n\n  * in this case:\n\n    ```toml\n    [dependencies]\n    nsi = { version = \"0.7\", default-features = false, features = [\"link_lib3delight\"] }\n    ```\n\n* Download `lib3delight` during build.\n\n  * `lib3delight` is downloaded during build. Note that this may be\n    an outdated version. This feature mainly exists for CI purposes.\n\n  * The feature is called `download_lib3delight`.\n\n## Documentation\n\nCrate documentation can be found at [docs.rs](https://docs.rs/nsi/).\n\nDocs for the C, C++, Lua \u0026 Python bindings as well as an introduction\nand deep dive into the API [can be found here](https://nsi.readthedocs.io/).\n\n## Getting Help\n\nI hang out on the [3Delight Discord](https://discord.gg/9J9WwqNj) (I\nhave the same user name as on GitHub). Ping me in the `#lobby` channel\nor send me a PM.\n\nThere is also a [3Delight Slack](https://join.slack.com/t/3delight/shared_invite/zt-eipakj10-lK84ZzUzWgDw0qJ3Z3KuOg)\nwhich has a dedicated, invitation only channel about ɴsɪ.\n\nIf you have more advanced questions or want to add support for the ɴsɪ\nAPI/export to ɴsɪ to your renderer/DCC app/whatever ping me and I get\nyou an invite.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtualritz%2Fnsi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvirtualritz%2Fnsi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtualritz%2Fnsi/lists"}