{"id":19132364,"url":"https://github.com/taichi-dev/taichi_glsl","last_synced_at":"2025-08-12T22:41:53.331Z","repository":{"id":43709760,"uuid":"270243257","full_name":"taichi-dev/taichi_glsl","owner":"taichi-dev","description":"A Taichi extension library providing a set of GLSL-alike helper functions","archived":false,"fork":false,"pushed_at":"2022-02-22T12:52:57.000Z","size":278,"stargazers_count":69,"open_issues_count":8,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-15T21:40:43.669Z","etag":null,"topics":["graphics","math-library","python","rendering","taichi"],"latest_commit_sha":null,"homepage":"https://taichi-glsl.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/taichi-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-07T08:32:09.000Z","updated_at":"2024-11-10T09:56:17.000Z","dependencies_parsed_at":"2022-08-22T20:20:46.487Z","dependency_job_id":null,"html_url":"https://github.com/taichi-dev/taichi_glsl","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/taichi-dev/taichi_glsl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taichi-dev%2Ftaichi_glsl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taichi-dev%2Ftaichi_glsl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taichi-dev%2Ftaichi_glsl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taichi-dev%2Ftaichi_glsl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taichi-dev","download_url":"https://codeload.github.com/taichi-dev/taichi_glsl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taichi-dev%2Ftaichi_glsl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270148514,"owners_count":24535701,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["graphics","math-library","python","rendering","taichi"],"created_at":"2024-11-09T06:17:58.720Z","updated_at":"2025-08-12T22:41:53.180Z","avatar_url":"https://github.com/taichi-dev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Taichi GLSL\n===========\n\nTaichi GLSL is an extension library of the [Taichi Programming Language](https://github.com/taichi-dev/taichi), which provides a set of useful helper functions including but not limited to:\n\n1. Handy scalar functions like ``clamp``, ``smoothstep``, ``mix``, ``round``.\n2. GLSL-alike vector functions like ``normalize``, ``distance``, ``reflect``.\n3. Well-behaved random generators including ``randUnit3D``, ``randNDRange``.\n4. Handy vector and matrix initializer: ``vec`` and ``mat``.\n5. Handy vector component shuffle accessor like ``v.xy``.\n6. Handy field sampler including ``bilerp`` and ``sample``.\n7. Useful physics helper functions like ``boundReflect``.\n8. Shadertoy-alike inputed GUI base class ``Animation``.\n\n[[Clike me for documentation]](https://taichi-glsl.readthedocs.io)\n\n[![Build Status](https://img.shields.io/github/workflow/status/taichi-dev/taichi_glsl/Persubmit%20Checks)](https://github.com/taichi-dev/taichi_glsl/actions?query=workflow%3A%22Persubmit+Checks%22)\n[![Documentation Status](https://readthedocs.org/projects/taichi-glsl/badge?version=latest)](https://taichi-glsl.readthedocs.io/en/latest)\n[![Coverage Status](https://img.shields.io/codecov/c/github/taichi-dev/taichi_glsl)](https://codecov.io/gh/taichi-dev/taichi_glsl)\n[![Downloads](https://pepy.tech/badge/taichi-glsl/month)](https://pepy.tech/project/taichi-glsl/month)\n[![Latest Release](https://img.shields.io/github/v/release/taichi-dev/taichi_glsl)](https://github.com/taichi-dev/taichi_glsl/releases)\n\n\nInstallation\n------------\n\nInstall Taichi and Taichi GLSL with `pip`:\n\n```bash\n# Python 3.6/3.7/3.8 (64-bit)\npip install taichi taichi_glsl\n```\n\n\nHow to play\n-----------\n\nFirst, import Taichi and Taichi GLSL:\n```py\nimport taichi as ti\nimport taichi_glsl as ts\n```\n\n---\n\nThen, use `ts.xxx` helper functions in your Taichi kernels like this:\n```py\n@ti.kernel\ndef kern():\n  a = ts.vec(2.2, -3.3)   # deduced to be vec2\n  b = ts.normalize(a)     # get normalized vector\n  c = ts.clamp(a)         # element-wise, clamp to range [0, 1]\n  d = int(a)              # cast to ivec2, vector of integers\n  print(b, c, d)          # [0.554700, -0.832050] [1.000000, 0.000000] [2, -3]\n```\n\nHints\n-----\n\nIf you don't like the `ts.` prefix, import using:\n\n```py\nfrom taichi_glsl import *\n\n@ti.kernel\ndef kern():\n  a = vec(2.33, 6.66)\n  b = normalize(a)\n  ...\n```\n\nNote that this will import `taichi` as name `ti` as well.\n\n---\n\n`vec2`, `vec3` and `vec4` are simply `vec` in Taichi GLSL:\n\n```py\nv = vec(2.0, 3.0)            # vec2\nv = vec(2.0, 3.0, 4.0)       # vec3\nv = vec(2.0, 3.0, 4.0, 5.0)  # vec4\nv = vec(2, 3)                # ivec2 (since 2 is an integer)\n```\n\nThanks to the python syntax of `vec(*args)`.\n\nExample\n-------\n\nThe following codes shows up an [Shadertoy](https://shadertoy.com/new)-style rainbow UV\nin the window:\n\n```py\nimport taichi as ti\nimport taichi_glsl as ts\n\nti.init()\n\n\nclass MyAnimation(ts.Animation):\n    def on_init(self):\n        self.img = ti.Vector(3, ti.f32, (512, 512))\n        self.define_input()\n\n    @ti.kernel\n    def on_render(self):\n        for I in ti.grouped(self.img):\n            uv = I / self.iResolution\n            self.img[I] = ti.cos(uv.xyx + self.iTime +\n                                 ts.vec(0, 2, 4)) * 0.5 + 0.5\n\n\nMyAnimation().start()\n```\n\nCheck out more examples in the `examples/` folder.\n\n\nLinks\n-----\n\n* [Taichi Main Repo](https://github.com/taichi-dev/taichi)\n* [Taichi GLSL Documentation](https://taichi-glsl.readthedocs.io)\n* [Taichi THREE Repo](https://github.com/taichi-dev/taichi_three)\n* [Taichi Documentation](https://taichi.readthedocs.io/en/stable)\n* [Taichi 中文文档](https://taichi.readthedocs.io/zh_CN/stable)\n* [Forum Thread for Taichi GLSL](https://forum.taichi.graphics/t/taichi-glsl-a-handy-extension-library-for-taichi/867)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaichi-dev%2Ftaichi_glsl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaichi-dev%2Ftaichi_glsl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaichi-dev%2Ftaichi_glsl/lists"}