{"id":13664471,"url":"https://github.com/hecomi/uShaderTemplate","last_synced_at":"2025-04-26T01:32:04.228Z","repository":{"id":57203683,"uuid":"91967591","full_name":"hecomi/uShaderTemplate","owner":"hecomi","description":"This is an Unity editor extension for generating shader code from template files.","archived":false,"fork":false,"pushed_at":"2021-11-14T15:11:53.000Z","size":166,"stargazers_count":146,"open_issues_count":1,"forks_count":18,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-10-30T21:36:59.493Z","etag":null,"topics":["editor-extension","shader","unity"],"latest_commit_sha":null,"homepage":"http://tips.hecomi.com/entry/2017/10/24/014057","language":"C#","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/hecomi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-21T15:31:07.000Z","updated_at":"2024-09-01T19:20:15.000Z","dependencies_parsed_at":"2022-09-17T15:00:36.015Z","dependency_job_id":null,"html_url":"https://github.com/hecomi/uShaderTemplate","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hecomi%2FuShaderTemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hecomi%2FuShaderTemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hecomi%2FuShaderTemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hecomi%2FuShaderTemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hecomi","download_url":"https://codeload.github.com/hecomi/uShaderTemplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224022190,"owners_count":17242720,"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":["editor-extension","shader","unity"],"created_at":"2024-08-02T05:02:57.202Z","updated_at":"2024-11-10T22:30:39.569Z","avatar_url":"https://github.com/hecomi.png","language":"C#","funding_links":[],"categories":["C\\#"],"sub_categories":[],"readme":"uShaderTemplate\n===============\n\n**uShaderTemplate** is an editor asset to create shaders from templates.\n\nInstall\n-------\n\n- Unity Package\n  - Download the latest .unitypackage from [Release page](https://github.com/hecomi/uShaderTemplate/releases).\n- Git URL (UPM)\n  - Add `https://github.com/hecomi/uShaderTemplate.git#upm` to Package Manager.\n- Scoped Registry (UPM)\n  - Add a scoped registry to your project.\n    - URL: `https://registry.npmjs.com`\n    - Scope: `com.hecomi`\n  - Install uShaderTemplate in Package Manager. \n\nUsage\n-----\n\n1.  Prepare **Shader Template** file.\n2.  Create **Generator** from *Create \u003e Shader \u003e uShaderTemplate \u003e Generator*.\n3.  Input *Shader Name* and select *Shader Template* from the inspector.\n4.  Edit items in *Conditions*, *Variables*, and codes in code editors.\n5.  Press *Export (Ctrl+R)* button to create a shader from the Generator.\n\nOverview\n--------\n\nGenerator is an asset file that manages a generated shader, save parameters,\nand provide an interface to customize the shader with some rules\nwritten in **shader template**. The following image is an example of a Generator\ninspector which is automatically generated from shader template.\n\n![Inspector](https://raw.githubusercontent.com/wiki/hecomi/uShaderTemplate/inspector.png)\n\nThe interface is generated from\n*uShaderTemplate \u003e Examples \u003e Editor \u003e Resources \u003e ShaderTemplates \u003e 1. VertFrag.txt*.\nThis is the content of this file:\n\n**1. VertFrag.txt**\n\n```shader\nShader \"Custom/\u003cName\u003e\"\n{\n\nProperties\n{\n@block Properties\n_MainTex(\"Texture\", 2D) = \"white\" {}\n@endblock\n}\n\nSubShader\n{\n\nTags { \"Queue\"=\"\u003cQueue=Geometry|Transparent\u003e\" \"RenderType\"=\"\u003cRenderType=Opaque|Transparent\u003e\" }\nLOD \u003cLOD=100\u003e\n\nCGINCLUDE\n\n#include \"UnityCG.cginc\"\n\nstruct v2f\n{\n    float2 uv : TEXCOORD0;\n@if UseFog : true\n    UNITY_FOG_COORDS(1)\n@endif\n    float4 vertex : SV_POSITION;\n};\n\n@block VertexShader\nsampler2D _MainTex;\nfloat4 _MainTex_ST;\n\nv2f vert(appdata_full v)\n{\n    v2f o;\n    o.vertex = UnityObjectToClipPos(v.vertex);\n    o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);\n    UNITY_TRANSFER_FOG(o,o.vertex);\n    return o;\n}\n@endblock\n\n@block FragmentShader\nfixed4 frag(v2f i) : SV_Target\n{\n    fixed4 col = tex2D(_MainTex, i.uv);\n    UNITY_APPLY_FOG(i.fogCoord, col);\n    return col;\n}\n@endblock\n\nENDCG\n\nPass\n{\n    CGPROGRAM\n    #pragma vertex vert\n    #pragma fragment frag\n@if UseFog : true\n    #pragma multi_compile_fog\n@endif\n    ENDCG\n}\n\n}\n\nCustomEditor \"uShaderTemplate.MaterialEditor\"\n\n}\n```\n\nYou might have found some grammars like `@if foo`, `\u003cBar\u003e`, `@block baz`,\nand these are special grammmars available in template file.\nShader variant like `#pragma multi_compile` and `#pragma shader_feature`\ncannot customize the section outside `CGPROGRAM`, but with these grammar,\nyou can customize the all parts of the shader.\n\nIf you put template files like this in *Resources \u003e ShaderTemplates*,\nthey are automatically detected and shown in the *Shader Template* field\nin *Basic* section.\n\nGrammars in Shader Template\n---------------------------\n\n```shader\n// Condition:\n//   A toggle filed labeled \"Hoge Hoge\" will appear in Conditions section.\n//   Only when checked, the content will be output.\n@if HogeHoge\n#define HOGEHOGE\n@endif\n\n// You can use else block and give a default condition.\n@if HogeHoge2 : false\n#define HOGEHOGE2\n@else\n#define HOGEHOGE3\n@endif\n\n// Variable:\n//   The name with \u003c\u003e will appear in Variables section as a text field.\n//   You can give a default value with =, and =| will be pull-down list.\n#define Hoge \u003cHoge\u003e\n#define Fuga \u003cFuga=Hoge\u003e //\n#define Piyo \u003cPiyo=Hoge|Fuga|Piyo\u003e\n\n// Block:\n//    The content will be a code editor.\n//    Output shader has block like // @block ~ // @endblock and\n//    if you edit the content directly with your own editor like Vim,\n//    the result will be applied to the code editor in inspector.\n@block Moge\nfloat Moge2() { return _Move * _Moge; }\n@endblock\n```\n\nButtons\n-------\n\n![Buttons](https://raw.githubusercontent.com/wiki/hecomi/uShaderTemplate/buttons.png)\n\n* **Export(Ctrl+R)**\n  * Export shader from Generator. You can use *Ctrl + R* as a shortcut key\n    instead of pressing this button.\n* **Create Material**\n  * Create material from the generated shader.\n* **Reset to Default**\n  * Reset all parameters to the default parameters written in template.\n* **Update Template**\n  * If you edit the template file, please press this before the export.\n* **Reconvert All**\n  * Convert all generated shaders forcedly. This is useful when you edit\n    template file and want to apply the change to all shaders.\n\n\nConstants\n---------\n\n![Constants](https://raw.githubusercontent.com/wiki/hecomi/uShaderTemplate/constants.png)\n\nInstead of inputting variables in each inspector, you can use **Constants** asset\nas a shared variables among multiple Generators.\n\nSelect *Create \u003e Shader \u003e uShaderTemplate \u003e Constants* and add *Name* and *Value*\npair to *Values* field of the created Constants asset. Then, drag and drop it to\nthe *Constants* field of Generators which you want to apply the parameters to.\nPlease remember that if you modify a parameter in Constants,\nyou have to *Reconvert All* to apply the change to all generated shaders.\n\nIn a shader template, you can specify the default `Constants` using `@constants` line if you want it.\n\n```shader\nShader \"Custom/\u003cName\u003e\"\n{\n\n// you can insert this line anywhere in the template file.\n@constants uShaderTemplate/Constants/Custom Constants\n\nProperties\n{\n...\n```\n\n\nCallbacks\n---------\n\n`Generator` and `Constants` have virtual functions, `OnBeforeConvert()` and `OnAfterConvert()`.\nYou can create custom `Generator` and `Constants` inherited from these classes and override\nthem to add callbacks just before and after convert.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhecomi%2FuShaderTemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhecomi%2FuShaderTemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhecomi%2FuShaderTemplate/lists"}