{"id":20261306,"url":"https://github.com/actnwit/shaderity","last_synced_at":"2025-06-30T06:33:08.069Z","repository":{"id":38330849,"uuid":"210163828","full_name":"actnwit/shaderity","owner":"actnwit","description":"A useful shader toolset","archived":false,"fork":false,"pushed_at":"2025-05-08T11:59:32.000Z","size":1150,"stargazers_count":6,"open_issues_count":12,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-25T11:08:04.253Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/actnwit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-22T14:48:41.000Z","updated_at":"2025-05-08T11:59:36.000Z","dependencies_parsed_at":"2024-06-21T04:10:15.882Z","dependency_job_id":null,"html_url":"https://github.com/actnwit/shaderity","commit_stats":null,"previous_names":["emadurandal/shaderity"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actnwit%2Fshaderity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actnwit%2Fshaderity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actnwit%2Fshaderity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actnwit%2Fshaderity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/actnwit","download_url":"https://codeload.github.com/actnwit/shaderity/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actnwit%2Fshaderity/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":257439051,"owners_count":22546406,"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":[],"created_at":"2024-11-14T11:25:11.468Z","updated_at":"2025-06-30T06:33:08.025Z","avatar_url":"https://github.com/actnwit.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shaderity\r\n\r\nShaderity is a shader tool set.\r\n\r\nShaderity are composed from the several components.\r\n\r\n- shaderity: This. for runtime features\r\n    - [shaderity-loader](https://github.com/actnwit/shaderity-loader): for static features\r\n        - [shaderity-node](https://github.com/actnwit/shaderity-node): The internal component for shaderity-loader.\r\n\r\nThe name \"Shaderity\" was coined from the combination of \"Shader\" and \"Integrity\".\r\n\r\nBTW, Are you interested in node-based shader editing?\r\nPlease check our [shaderity-graph](https://github.com/actnwit/shaderity-graph) out.\r\n\r\n## Features\r\n\r\n### Runtime features\r\n\r\nWith this `shaderity`, you can do the following things:\r\n\r\n- Variables fill-in to GLSL code in runtime.\r\n- Transpile between GLSL ES 1.0 and GLSL ES 3.0 .\r\n\r\n### Static features\r\n\r\nWith [shaderity-loader](https://github.com/actnwit/shaderity-loader), you can do the following things:\r\n\r\n- Provide `#include` like statement for GLSL shader files. (similar syntax to glslify)\r\n- Embed GLSL shader files into TypeScript/JavaScript as a WebPack Loader.\r\n- Can be used in conjunction with glslify.\r\n\r\n## How to use\r\n\r\n### Converting GLSL ES 100 to GLSL ES 300\r\n\r\n```javascript\r\nconst Shaderity = require('shaderity');\r\n\r\nconst shaderObj = {\r\n    code:`\r\nprecision mediump float;\r\n\r\nvarying vec4 vColor;\r\nvarying vec4 vTexcoord;\r\n\r\nvoid main() {\r\n  gl_FlagColor = vColor;\r\n}\r\n`,\r\n    shaderStage: 'fragment'\r\n};\r\n\r\nconst convertedObj = shaderity.transformToGLSLES3(shaderObj);\r\nconsole.out(convertedObj.code);\r\n/*\r\nprecision mediump float;\r\n\r\nin vec4 vColor;\r\nin vec4 vTexcoord;\r\n\r\nvoid main() {\r\n  gl_FlagColor = vColor;\r\n}\r\n*/\r\n```\r\n\r\n## Reflection\r\n\r\nShaderity analogizes the names of attribute variables in the vertex shader for mapping to the CPU-side vertex attributes semantics.\r\n\r\nIn this sample, Shaderity determines that `a_position` is a `POSITION` semantics. `a_uv` is not in the current Shaderity's analogy dictionary, so it is `UNKNOWN` as is, but the comment `// \u003c semantic=TEXCOORD_0 \u003e` allows Shaderity to determine that it is a `TEXCOORD_0` semantics. \r\n\r\n```glsl\r\nin vec3 a_position;\r\nin vec2 a_uv; // \u003c semantic=TEXCOORD_0 \u003e\r\nout vec3 v_position;\r\n\r\nuniform vec4 u_worldMatrix;\r\nuniform sampler2D u_texture; // \u003csemantic=DataTexture, min=10, max=100, default=\u003e\r\n\r\nint main() {\r\n  gl_Position = a_position;\r\n  v_position = a_position;\r\n}\r\n```\r\n\r\nHere is the current analogy dictionary for vertex attribute variables.\r\n(The key of the map is written in regular expression. The matching is ignoreCase.)\r\n\r\nThe semantics (the values of the map) definitions are referenced from glTF2 specification.\r\nhttps://github.com/KhronosGroup/glTF/tree/master/specification/2.0#meshes\r\n\r\n```javascript\r\n    this.__attributeSemanticsMap.set('position', 'POSITION');\r\n    this.__attributeSemanticsMap.set('color$', 'COLOR_0');\r\n    this.__attributeSemanticsMap.set('color_?0', 'COLOR_0');\r\n    this.__attributeSemanticsMap.set('texcoord$', 'TEXCOORD_0');\r\n    this.__attributeSemanticsMap.set('texcoord_?0', 'TEXCOORD_0');\r\n    this.__attributeSemanticsMap.set('texcoord_?1', 'TEXCOORD_1');\r\n    this.__attributeSemanticsMap.set('normal', 'NORMAL');\r\n    this.__attributeSemanticsMap.set('tangent', 'TANGENT');\r\n    this.__attributeSemanticsMap.set('joint$', 'JOINTS_0');\r\n    this.__attributeSemanticsMap.set('bone$', 'JOINTS_0');\r\n    this.__attributeSemanticsMap.set('joint_?0', 'JOINTS_0');\r\n    this.__attributeSemanticsMap.set('bone_?0', 'JOINTS_0');\r\n    this.__attributeSemanticsMap.set('weight$', 'WEIGHTS_0');\r\n    this.__attributeSemanticsMap.set('weight_?0', 'WEIGHTS_0');\r\n```\r\n\r\nYou can get the reflection data by like this.\r\n\r\n```javascript\r\n  const shaderity = Shaderity.getInstance();\r\n  const reflection = shaderity.reflect(reflectionVertexES3);\r\n  expect(reflection.attributes[0]).toStrictEqual(\r\n    {\r\n      name: 'a_position',\r\n      type: 'vec3',\r\n      semantic: 'POSITION'\r\n    }\r\n    );\r\n  expect(reflection.attributes[1]).toStrictEqual(\r\n    {\r\n      name: 'a_uv',\r\n      type: 'vec2',\r\n      semantic: 'TEXCOORD_0'\r\n    }\r\n    );\r\n```\r\n\r\nYou can add other words to analogy dictionary by this method.\r\n\r\n```typescript\r\n  addAttributeSemanticsMap(map: Map\u003cstring, string\u003e) {\r\n    this.__attributeSemanticsMap = new Map([...this.__attributeSemanticsMap, ...map]);\r\n  }\r\n```\r\n\r\nYou can check more functionalities in [test/basic.test.js](./test/basic.test.js) .\r\n\r\n## LICENSE\r\n\r\nMIT License\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factnwit%2Fshaderity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Factnwit%2Fshaderity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factnwit%2Fshaderity/lists"}