[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M792M8ZXF3PK03MH4PPXB9V0":3,"skill-same:01M792M8ZXF3PK03MH4PPXB9V0":62},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":31,"ownerHtmlUrl":32,"ownerBlogUrl":33,"ownerDescription":34,"updatedAt":35,"install":36,"resources":49},"01M792M8ZXF3PK03MH4PPXB9V0","unity-shaders",null,"Author materials and VFX with Shader Graph, HLSL and URP\u002FHDRP custom passes. Use when authoring URP\u002FHDRP shaders, Shader Graph, or visual effects.","poorvith-mp\u002Fskills-gamedev","poorvith-mp","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F277478855?v=4","01M78Z5K0YH1Z3PX815PGQ96ND","Poorvith M P","01M792GVN0NZ9V49H6Q6BE3S1S",5,"MIT","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-gamedev\u002Fblob\u002Fmain\u002Fskills\u002Funity-shaders\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: unity-shaders\nlast_reviewed: 2026-09-06\ngroup: Unity\ndescription: >-\n  Author materials and VFX with Shader Graph, HLSL and URP\u002FHDRP custom passes. Use when authoring\n  URP\u002FHDRP shaders, Shader Graph, or visual effects.\n---\n\n# unity-shaders\n\n## Core Philosophy\nReal-time shaders are programs executed concurrently across thousands of GPU cores for every single vertex and pixel on screen. In modern Unity (URP and HDRP), authoring game visual effects requires mastering both node-based Shader Graph and text-based HLSL. Writing efficient shaders is an exercise in computational frugality: every trigonometric function, dependent texture read, or unnecessary full-precision float in the fragment shader directly burns GPU fill-rate and tanks mobile\u002Fconsole frame rates.\n\n---\n\n## 4-Step Unity Shader & VFX Pipeline\n\n### Step 1: Pipeline Architecture: URP vs HDRP Custom Passes\n1. **Universal Render Pipeline (URP)**:\n   - Optimized for mobile, Nintendo Switch, VR, and PC.\n   - Single-pass forward and deferred rendering paths.\n   - Extensible via `ScriptableRendererFeature` and custom Render Passes.\n2. **High Definition Render Pipeline (HDRP)**:\n   - High-end PC and current-gen consoles (PS5, Xbox Series X).\n   - Compute-shader-driven deferred clustered lighting, volumetric fog, and ray-tracing.\n   - Extensible via `CustomPassVolume`.\n\n### Step 2: HLSL Structure & Precision Optimization\n1. **Precision Standard**:\n   - `float` (32-bit): World-space coordinates, UV coordinates, depth calculations.\n   - `half` (16-bit): Colors, normals, vector directions, ambient lighting calculations (saves 50% ALU register pressure on mobile GPUs).\n2. **Core Shader Pass Layout**:\n   - `Vertex Shader`: Transforms object-space vertices to clip space:\n     $$P_{\\text{clip}} = M_{\\text{projection}} \\times M_{\\text{view}} \\times M_{\\text{model}} \\times P_{\\text{local}}$$\n   - `Fragment \u002F Pixel Shader`: Calculates final RGBA color per rasterized pixel.\n\n### Step 3: Math & Procedural Effects (Dissolve, Rim Light, Fresnel)\n1. **Schlick's Fresnel Approximation (Rim Lighting)**:\n   $$F \\approx F_0 + (1 - F_0)(1 - \\vec{N} \\cdot \\vec{V})^5$$\n   - Where $\\vec{N}$ is surface normal and $\\vec{V}$ is normalized view direction vector.\n2. **Procedural Dissolve with Alpha Clipping**:\n   - Sample a Simplex\u002FVoronoi noise texture, subtract a `_Cutoff` property, and execute `clip(noise - cutoff)`.\n\n### Step 4: URP Custom Render Pass Architecture\n1. **Creating Custom Passes (`ScriptableRendererFeature`)**:\n   - Inject custom rendering logic into the URP frame: e.g. custom outline passes, thermal vision, or full-screen blit effects:\n     - Enqueue pass at `RenderPassEvent.AfterRenderingTransparents`.\n     - Allocate temporary render textures via `RTHandles`.\n\n---\n\n## Deliverable Format: Optimized URP Unlit Dissolve Shader (HLSL)\n\n```hlsl\nShader \"Custom\u002FURP_Dissolve\"\n{\n    Properties\n    {\n        _MainTex (\"Albedo Texture\", 2D) = \"white\" {}\n        _NoiseTex (\"Noise Texture\", 2D) = \"white\" {}\n        _Cutoff (\"Dissolve Cutoff\", Range(0, 1)) = 0.0\n        [HDR] _EdgeColor (\"Edge Burn Color\", Color) = (2.0, 0.5, 0.0, 1.0)\n        _EdgeWidth (\"Edge Width\", Range(0, 0.2)) = 0.05\n    }\n    SubShader\n    {\n        Tags { \"RenderType\"=\"Opaque\" \"RenderPipeline\"=\"UniversalPipeline\" }\n        LOD 100\n\n        Pass\n        {\n            Name \"ForwardLit\"\n            Tags { \"LightMode\"=\"UniversalForward\" }\n\n            HLSLPROGRAM\n            #pragma vertex vert\n            #pragma fragment frag\n            #include \"Packages\u002Fcom.unity.render-pipelines.universal\u002FShaderLibrary\u002FCore.hlsl\"\n\n            struct Attributes {\n                float4 positionOS : POSITION;\n                float2 uv         : TEXCOORD0;\n            };\n\n            struct Varyings {\n                float4 positionCS : SV_POSITION;\n                float2 uv         : TEXCOORD0;\n            };\n\n            TEXTURE2D(_MainTex);    SAMPLER(sampler_MainTex);\n            TEXTURE2D(_NoiseTex);   SAMPLER(sampler_NoiseTex);\n\n            CBUFFER_START(UnityPerMaterial)\n                float4 _MainTex_ST;\n                half4  _EdgeColor;\n                half   _Cutoff;\n                half   _EdgeWidth;\n            CBUFFER_END\n\n            Varyings vert(Attributes input) {\n                Varyings output;\n                output.positionCS = TransformObjectToHClip(input.positionOS.xyz);\n                output.uv = TRANSFORM_TEX(input.uv, _MainTex);\n                return output;\n            }\n\n            half4 frag(Varyings input) : SV_Target {\n                half noise = SAMPLE_TEXTURE2D(_NoiseTex, sampler_NoiseTex, input.uv).r;\n                clip(noise - _Cutoff); \u002F\u002F Discard pixel if below dissolve threshold\n\n                half4 albedo = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv);\n                \n                \u002F\u002F Calculate glowing burn edge\n                half edgeFactor = step(noise - _Cutoff, _EdgeWidth);\n                half4 finalColor = lerp(albedo, _EdgeColor, edgeFactor);\n                \n                return finalColor;\n            }\n            ENDHLSL\n        }\n    }\n}\n```\n\n---\n\n## Worked Example: 60 FPS Mobile GPU Optimization for Anime Water Shader\n\n- **Problem**: A stylized water shader caused the game to drop from 60 FPS to 24 FPS on iPhone 11 and Snapdragon mobile devices.\n- **Diagnosis**: Profiling in RenderDoc showed 8 dependent texture lookups in the fragment shader and universal 32-bit `float` precision causing high register spilling.\n- **Optimization**:\n  1. Converted all non-coordinate variables from `float` to `half`.\n  2. Pre-baked 3 procedural caustic noise octaves into a single RGB channel-packed lookup texture, replacing 3 runtime procedural noise calculations with 1 sample.\n- **Outcome**: Frame time on target mobile GPU dropped from 41ms to 14.8ms, locking the game at a stable 60 FPS.\n\n---\n\n## Verification Checklist\n\n- [ ] Properties wrapped inside `CBUFFER_START(UnityPerMaterial)` for SRP Batcher compatibility.\n- [ ] Mobile shaders utilize `half` precision for colors, directions, and lighting math.\n- [ ] Alpha test \u002F `clip()` avoided on mobile tiled GPUs where Early-Z rejection is critical.\n- [ ] Textures channel-packed (e.g. Roughness in R, Metallic in G, AO in B) to minimize texture samplers.\n- [ ] Custom passes integrated via `ScriptableRendererFeature` in URP.\n\n---\n\n## Anti-Patterns\n\n- **Breaking SRP Batcher**: Declaring shader uniforms outside of `CBUFFER_START(UnityPerMaterial)`, forcing Unity to issue unique draw calls per material.\n- **Over-Using Complex Math in Fragment Pass**: Running sin\u002Fcos\u002Fpow loops per pixel that could be calculated once in vertex shader and interpolated.\n- **Neglecting Depth Texture Performance**: Indiscriminately enabling `_CameraDepthTexture` on mobile hardware without verifying bandwidth overhead.\n","# unity-shaders\n\n## Core Philosophy\nReal-time shaders are programs executed concurrently across thousands of GPU cores for every single vertex and pixel on screen. In modern Unity (URP and HDRP), authoring game visual effects requires mastering both node-based Shader Graph and text-based HLSL. Writing efficient shaders is an exercise in computational frugality: every trigonometric function, dependent texture read, or unnecessary full-precision float in the fragment shader directly burns GPU fill-rate and tanks mobile\u002Fconsole frame rates.\n\n---\n\n## 4-Step Unity Shader & VFX Pipeline\n\n### Step 1: Pipeline Architecture: URP vs HDRP Custom Passes\n1. **Universal Render Pipeline (URP)**:\n   - Optimized for mobile, Nintendo Switch, VR, and PC.\n   - Single-pass forward and deferred rendering paths.\n   - Extensible via `ScriptableRendererFeature` and custom Render Passes.\n2. **High Definition Render Pipeline (HDRP)**:\n   - High-end PC and current-gen consoles (PS5, Xbox Series X).\n   - Compute-shader-driven deferred clustered lighting, volumetric fog, and ray-tracing.\n   - Extensible via `CustomPassVolume`.\n\n### Step 2: HLSL Structure & Precision Optimization\n1. **Precision Standard**:\n   - `float` (32-bit): World-space coordinates, UV coordinates, depth calculations.\n   - `half` (16-bit): Colors, normals, vector directions, ambient lighting calculations (saves 50% ALU register pressure on mobile GPUs).\n2. **Core Shader Pass Layout**:\n   - `Vertex Shader`: Transforms object-space vertices to clip space:\n     $$P_{\\text{clip}} = M_{\\text{projection}} \\times M_{\\text{view}} \\times M_{\\text{model}} \\times P_{\\text{local}}$$\n   - `Fragment \u002F Pixel Shader`: Calculates final RGBA color per rasterized pixel.\n\n### Step 3: Math & Procedural Effects (Dissolve, Rim Light, Fresnel)\n1. **Schlick's Fresnel Approximation (Rim Lighting)**:\n   $$F \\approx F_0 + (1 - F_0)(1 - \\vec{N} \\cdot \\vec{V})^5$$\n   - Where $\\vec{N}$ is surface normal and $\\vec{V}$ is normalized view direction vector.\n2. **Procedural Dissolve with Alpha Clipping**:\n   - Sample a Simplex\u002FVoronoi noise texture, subtract a `_Cutoff` property, and execute `clip(noise - cutoff)`.\n\n### Step 4: URP Custom Render Pass Architecture\n1. **Creating Custom Passes (`ScriptableRendererFeature`)**:\n   - Inject custom rendering logic into the URP frame: e.g. custom outline passes, thermal vision, or full-screen blit effects:\n     - Enqueue pass at `RenderPassEvent.AfterRenderingTransparents`.\n     - Allocate temporary render textures via `RTHandles`.\n\n---\n\n## Deliverable Format: Optimized URP Unlit Dissolve Shader (HLSL)\n\n```hlsl\nShader \"Custom\u002FURP_Dissolve\"\n{\n    Properties\n    {\n        _MainTex (\"Albedo Texture\", 2D) = \"white\" {}\n        _NoiseTex (\"Noise Texture\", 2D) = \"white\" {}\n        _Cutoff (\"Dissolve Cutoff\", Range(0, 1)) = 0.0\n        [HDR] _EdgeColor (\"Edge Burn Color\", Color) = (2.0, 0.5, 0.0, 1.0)\n        _EdgeWidth (\"Edge Width\", Range(0, 0.2)) = 0.05\n    }\n    SubShader\n    {\n        Tags { \"RenderType\"=\"Opaque\" \"RenderPipeline\"=\"UniversalPipeline\" }\n        LOD 100\n\n        Pass\n        {\n            Name \"ForwardLit\"\n            Tags { \"LightMode\"=\"UniversalForward\" }\n\n            HLSLPROGRAM\n            #pragma vertex vert\n            #pragma fragment frag\n            #include \"Packages\u002Fcom.unity.render-pipelines.universal\u002FShaderLibrary\u002FCore.hlsl\"\n\n            struct Attributes {\n                float4 positionOS : POSITION;\n                float2 uv         : TEXCOORD0;\n            };\n\n            struct Varyings {\n                float4 positionCS : SV_POSITION;\n                float2 uv         : TEXCOORD0;\n            };\n\n            TEXTURE2D(_MainTex);    SAMPLER(sampler_MainTex);\n            TEXTURE2D(_NoiseTex);   SAMPLER(sampler_NoiseTex);\n\n            CBUFFER_START(UnityPerMaterial)\n                float4 _MainTex_ST;\n                half4  _EdgeColor;\n                half   _Cutoff;\n                half   _EdgeWidth;\n            CBUFFER_END\n\n            Varyings vert(Attributes input) {\n                Varyings output;\n                output.positionCS = TransformObjectToHClip(input.positionOS.xyz);\n                output.uv = TRANSFORM_TEX(input.uv, _MainTex);\n                return output;\n            }\n\n            half4 frag(Varyings input) : SV_Target {\n                half noise = SAMPLE_TEXTURE2D(_NoiseTex, sampler_NoiseTex, input.uv).r;\n                clip(noise - _Cutoff); \u002F\u002F Discard pixel if below dissolve threshold\n\n                half4 albedo = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv);\n                \n                \u002F\u002F Calculate glowing burn edge\n                half edgeFactor = step(noise - _Cutoff, _EdgeWidth);\n                half4 finalColor = lerp(albedo, _EdgeColor, edgeFactor);\n                \n                return finalColor;\n            }\n            ENDHLSL\n        }\n    }\n}\n```\n\n---\n\n## Worked Example: 60 FPS Mobile GPU Optimization for Anime Water Shader\n\n- **Problem**: A stylized water shader caused the game to drop from 60 FPS to 24 FPS on iPhone 11 and Snapdragon mobile devices.\n- **Diagnosis**: Profiling in RenderDoc showed 8 dependent texture lookups in the fragment shader and universal 32-bit `float` precision causing high register spilling.\n- **Optimization**:\n  1. Converted all non-coordinate variables from `float` to `half`.\n  2. Pre-baked 3 procedural caustic noise octaves into a single RGB channel-packed lookup texture, replacing 3 runtime procedural noise calculations with 1 sample.\n- **Outcome**: Frame time on target mobile GPU dropped from 41ms to 14.8ms, locking the game at a stable 60 FPS.\n\n---\n\n## Verification Checklist\n\n- [ ] Properties wrapped inside `CBUFFER_START(UnityPerMaterial)` for SRP Batcher compatibility.\n- [ ] Mobile shaders utilize `half` precision for colors, directions, and lighting math.\n- [ ] Alpha test \u002F `clip()` avoided on mobile tiled GPUs where Early-Z rejection is critical.\n- [ ] Textures channel-packed (e.g. Roughness in R, Metallic in G, AO in B) to minimize texture samplers.\n- [ ] Custom passes integrated via `ScriptableRendererFeature` in URP.\n\n---\n\n## Anti-Patterns\n\n- **Breaking SRP Batcher**: Declaring shader uniforms outside of `CBUFFER_START(UnityPerMaterial)`, forcing Unity to issue unique draw calls per material.\n- **Over-Using Complex Math in Fragment Pass**: Running sin\u002Fcos\u002Fpow loops per pixel that could be calculated once in vertex shader and interpolated.\n- **Neglecting Depth Texture Performance**: Indiscriminately enabling `_CameraDepthTexture` on mobile hardware without verifying bandwidth overhead.\n",{"name":5,"group":24,"description":7,"last_reviewed":25},"Unity",1788652800000,"main","d661d370a67c4532034e3d1d87c4aec237077f34","skills\u002Funity-shaders",0,"https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-gamedev","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskillary","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp","poorvithmp.com","Shipping tools for problems people notice too late.","2026-10-02 21:32:36",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add poorvith-mp\u002Fskills-gamedev --skill unity-shaders",{"tool":42,"command":43},"bunx","bunx skills add poorvith-mp\u002Fskills-gamedev --skill unity-shaders",{"tool":45,"command":46},"pnpm","pnpm dlx skills add poorvith-mp\u002Fskills-gamedev --skill unity-shaders","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-gamedev\u002Fblob\u002Fmain\u002Fskills\u002Funity-shaders\u002FSKILL.md",true,[50,56],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"evals\u002Frouting.yaml","REFERENCE","参考文档",954,"https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-gamedev\u002Fblob\u002Fmain\u002Fskills\u002Funity-shaders\u002Fevals\u002Frouting.yaml",{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"unity-shaders.skill","OTHER","其他",3743,"https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-gamedev\u002Fblob\u002Fmain\u002Fskills\u002Funity-shaders\u002Funity-shaders.skill",[63,70,77,84,91,98],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M792N6JWJ1J9XBK6HKFHWRHA","unreal-worlds","Build open worlds with World Partition, Landscape, procedural foliage, HLOD and level streaming. Use when sculpting landscapes, biomes, or World Partition in Unreal.","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-gamedev\u002Fblob\u002Fmain\u002Fskills\u002Funreal-worlds\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M792N3JHMS0FWY4YJJ4X60PV","unreal-world-builder","Moved to unreal-worlds in skills-gamedev. Removed in v4.1.","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-gamedev\u002Fblob\u002Fmain\u002Fskills\u002Funreal-world-builder\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M792N0XGH0E9XK3ZCR34Z18B","unreal-technical-artist","Moved to unreal-tech-art in skills-gamedev. Removed in v4.1.","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-gamedev\u002Fblob\u002Fmain\u002Fskills\u002Funreal-technical-artist\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M792MXKCZ26XGP5RDQHDWRWS","unreal-tech-art","Own the UE5 visual pipeline: Material Editor, Niagara VFX and Procedural Content Generation. Use when creating Unreal materials, Niagara visual effects, or Lumen setups.","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-gamedev\u002Fblob\u002Fmain\u002Fskills\u002Funreal-tech-art\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M792MRZ9PB1MNFKPNVDB5AJP","unreal-systems","Work the C++\u002FBlueprint continuum with Nanite, Lumen and the Gameplay Ability System. Use when developing Unreal Engine gameplay in C++, Blueprints, or GAS.","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-gamedev\u002Fblob\u002Fmain\u002Fskills\u002Funreal-systems\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":19},"01M792MQGJ5S2EFDAD5BN5B8V3","unreal-systems-engineer","Moved to modernized catalog in skillary. Removed in v4.1.","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-gamedev\u002Fblob\u002Fmain\u002Fskills\u002Funreal-systems-engineer\u002FSKILL.md",[],[]]