con un clic
shader-graph-best-practices
// Node budgets, custom lighting, sub-graphs, precision control, and mobile workflows for Unity Shader Graph
// Node budgets, custom lighting, sub-graphs, precision control, and mobile workflows for Unity Shader Graph
Generate AI videos with Luma Dream Machine via AceDataCloud API. Use when creating videos from text prompts, generating videos from reference images, extending existing videos, or any video generation task with Luma. Supports text-to-video, image-to-video, and video extension.
Single-pass post-processing, URP Renderer Features, and mobile-safe screen effects for Unity
GPU architecture, precision types, fillrate, overdraw, baked lighting, and LOD optimization for Unity mobile/WebGL shaders
Channel packing, variant reduction, shader_feature vs multi_compile, and build size optimization for Unity
Mobile-optimized water shaders with depth coloring, foam, Gerstner waves, refraction, and caustics for Unity URP
WebGL 1.0/2.0 shader restrictions, variant stripping, loop/indexing rules, and browser deployment workarounds for Unity
| name | shader-graph-best-practices |
| description | Node budgets, custom lighting, sub-graphs, precision control, and mobile workflows for Unity Shader Graph |
Use this skill when the user is working with Unity Shader Graph (the node-based visual shader editor) for URP or HDRP. Triggers include: "Shader Graph", "node-based shader", "sub-graph", "custom function node", "Shader Graph mobile", "Shader Graph optimization", "custom lighting Shader Graph", "Shader Graph precision", or any visual shader authoring workflow in Unity. Also trigger when the user references Ben Cloward, Cyanilux, or Daniel Ilett Shader Graph tutorials.
Keep node count under 100 for mobile targets. Each node compiles to shader instructions. Above ~100 nodes, mobile GPUs hit instruction cache limits and performance drops sharply. Use Sub Graphs to organize, but they don't reduce instruction count.
Set graph-level precision to Half for mobile. In the Graph Inspector, change Precision to "Half". Override individual nodes to "Float" only for positions and UVs.
Use Sub Graphs to organize, not to optimize. Sub Graphs improve readability but compile inline — they don't reduce instruction count. However, they enable reuse across graphs, which reduces total project maintenance.
Custom Function nodes are the escape hatch. When Shader Graph can't express something efficiently (or uses too many nodes for a simple operation), write a Custom Function node in HLSL. This is especially useful for lighting access, complex math, and platform-specific branching.
Shader Graph generates all required passes automatically (ForwardLit, ShadowCaster, DepthOnly, DepthNormals, Meta). You don't need to worry about multi-pass like in HLSL — but you also can't optimize individual passes.
Shader Graph's default Lit target uses PBR (Physically Based Rendering). For mobile, you often want simpler lighting. Use Cyanilux's custom lighting sub-graphs:
The Cyanilux/URP_ShaderGraphCustomLighting package adds these sub-graph nodes to Shader Graph:
saturate(dot(Normal, LightDirection)) * LightColorThis gives you full control over lighting complexity — critical for mobile where PBR's multi-texture GGX/Smith BRDF is often too expensive.
BAD: Multiply → Add → Multiply → Saturate (4 nodes)
GOOD: Custom Function node with: saturate(a * b + c) * d (1 node)
The ShaderGraphVariables package adds Register Variable and Get Variable nodes. This prevents recalculating the same value multiple times in complex graphs — the equivalent of a local variable in code.
texture-packing-variant-stripping skill)| Node | Cost | Alternative |
|---|---|---|
| Fresnel Effect | Medium | Manual: 1 - saturate(dot(ViewDir, Normal)) then Power |
| Voronoi | High | Pre-bake to texture |
| Gradient Noise | High | Use Simple Noise or pre-bake to texture |
| Triplanar | High (3 texture samples) | Use on specific meshes only, not terrain |
| Normal From Height | High | Use actual normal maps instead |
| Custom Render Texture | High | Pre-bake when possible |
Unity 6 introduced Full Screen Shader Graph for post-processing effects. Use with URP's Full Screen Pass Renderer Feature:
Mobile consideration: Each Full Screen pass is a full-screen blit. Combine effects into a single Full Screen graph whenever possible.