Skip to content

LeoYeAI/agent-master-skills / skills/animation-shader

animation-shader

Verified

READ this skill when implementing or configuring animation-style shaders (Toon/Cel Shaders) — including outlines, rim lighting, toon shading, MatCap, emission, dissolve, hatching, or any stylized rendering effect. Contains preset styles and feature-to-reference mappings for lilToon, Poiyomi, UTS2, RToon, SToon, and ToonShadingCollection. Works as a domain knowledge plugin alongside workflow skills (OpenSpec, SpecKit) or plan mode of an agent.

FileKindSize
SKILL.mdskill md17.0 KB
_meta.jsonconfig285 B
references/PoiyomiShaders/Details/01_Base_Main.mdmarkdown4.8 KB
references/PoiyomiShaders/Details/02_Lighting_Shadows.mdmarkdown4.9 KB
references/PoiyomiShaders/Details/03_Surface_Reflections.mdmarkdown3.9 KB
references/PoiyomiShaders/Details/04_Special_Effects.mdmarkdown3.4 KB
references/PoiyomiShaders/Details/05_Outline.mdmarkdown2.6 KB
references/PoiyomiShaders/Features.mdmarkdown2.1 KB
references/RToon/Details/01_Core_Shading.mdmarkdown5.3 KB
references/RToon/Details/02_ShadowT.mdmarkdown3.1 KB
references/RToon/Details/03_Outline.mdmarkdown4.6 KB
references/RToon/Details/04_MatCap_Reflection.mdmarkdown3.6 KB
references/RToon/Details/05_Gloss_Rim.mdmarkdown3.2 KB
references/RToon/Details/06_Advanced_Features.mdmarkdown3.3 KB
references/RToon/Features.mdmarkdown4.2 KB
references/SToon/Details/01_Core_Shading.mdmarkdown3.4 KB
references/SToon/Details/02_Outline.mdmarkdown2.9 KB
references/SToon/Details/03_Overlays.mdmarkdown3.1 KB
references/SToon/Details/04_Specular_Rim.mdmarkdown2.7 KB
references/SToon/Details/05_Artistic_Controls.mdmarkdown3.2 KB
references/SToon/Features.mdmarkdown2.6 KB
references/ToonShadingCollection/Details/01_ArtStyles.mdmarkdown2.5 KB
references/ToonShadingCollection/Details/02_Outline.mdmarkdown4.4 KB
references/ToonShadingCollection/Details/03_Diffuse.mdmarkdown4.5 KB
references/ToonShadingCollection/Details/04_Specular.mdmarkdown3.2 KB
references/ToonShadingCollection/Details/05_Environment.mdmarkdown3.1 KB
references/ToonShadingCollection/Details/06_PBR_Stylization.mdmarkdown4.6 KB
references/ToonShadingCollection/Details/07_Stylized_Features.mdmarkdown4.0 KB
references/ToonShadingCollection/Details/08_PostProcessing.mdmarkdown3.5 KB
references/ToonShadingCollection/Details/09_Lighting_Shadows.mdmarkdown3.1 KB
references/ToonShadingCollection/Details/10_Animation_VFX.mdmarkdown3.7 KB
references/ToonShadingCollection/Details/11_Modeling_Pipeline.mdmarkdown2.9 KB
references/ToonShadingCollection/Features.mdmarkdown2.1 KB
references/UnityChanToonShaderVer2/Details/01_DoubleShade.mdmarkdown3.6 KB
references/UnityChanToonShaderVer2/Details/02_ShadingGradeMap.mdmarkdown3.1 KB
references/UnityChanToonShaderVer2/Details/03_Outline.mdmarkdown2.7 KB
references/UnityChanToonShaderVer2/Details/04_SpecialFeatures.mdmarkdown3.6 KB
references/UnityChanToonShaderVer2/Features.mdmarkdown5.6 KB
references/lilToon/Details/01_Base_Main.mdmarkdown4.8 KB
references/lilToon/Details/02_Lighting_Shadows.mdmarkdown3.9 KB
references/lilToon/Details/03_Surface_Reflections.mdmarkdown4.2 KB
references/lilToon/Details/04_Special_Effects.mdmarkdown4.7 KB
references/lilToon/Details/05_Advanced.mdmarkdown3.9 KB
references/lilToon/Details/06_Variants.mdmarkdown3.4 KB
references/lilToon/Details/07_Variant_Features.mdmarkdown4.8 KB
references/lilToon/Details/08_Outline.mdmarkdown3.3 KB
references/lilToon/Features.mdmarkdown3.3 KB
workflow-standalone.mdmarkdown6.4 KB

references/PoiyomiShaders/Details/02_Lighting_Shadows.md

View on GitHub
# Lighting & Shadows

Poiyomi Shader uses a custom lighting pipeline that supports multiple lighting models (Standard, Toon, UTS2) and extensive configuration.

## 1. Light Data Pipeline
The shader calculates light data in the fragment shader before applying shading.

### Call Site
`Assets/_PoiyomiShaders/Shaders/8.1/Toon/Poiyomi.shader` (approx line 15941 in `frag`, actual calculation in `calculateShading` or inline).

### Lighting Modes (`_LightingColorMode`)
*   **0: Poi Custom**: Calculates Direct/Indirect color using Spherical Harmonics (SH) with luminance balancing to prevent overexposure while maintaining rich ambient light.
*   **1: Standard**: Uses Unity's standard `_LightColor0` and SH.
*   **2: UTS2**: Unity-Chan Toon Shader style (Max of SH and LightColor).
*   **3: OpenLit**: Matches OpenLit/lilToon lighting response.

### Light Direction (`_LightingDirectionMode`)
*   **0: Standard**: Uses `_WorldSpaceLightPos0`.
*   **1/2: Forced**: Uses a custom vector (`_LightngForcedDirection`) in Local or World space. Useful for stylized scenes or UI characters.
*   **3: UTS2**: Interpolates between Camera Up and Light Direction.

## 2. Shadow Calculation
Poiyomi calculates a "Light Map" value (0 to 1) representing how lit a pixel is.

### Properties
*   **`_ShadowStrength`**: Global multiplier for shadow intensity.
*   **`_LightingMapMode`**: How NdotL is treated (Normalized vs Saturated).
*   **`_LightingMinLightBrightness`**: Minimum brightness floor.

### Principles & Math (Pseudo-code)
The "Poi Custom" mode uses a unique algorithm to balance direct light and spherical harmonics.

```hlsl
// Calculate NdotL (Normal dot Light Direction)
float nDotL = dot(normal, lightDir);

// Attenuation (Shadows from other objects/Point light falloff)
float attenuation = UNITY_LIGHT_ATTENUATION(i, worldPos);

// Calculate Base LightMap
if (_LightingMapMode == 0) { // Poi Custom
    // 1. Get Spherical Harmonics (Ambient Light)
    float3 magic = BetterSH9(normalize(unity_SHAr + ...));
    float3 normalLight = _LightColor0.rgb + BetterSH9(0,0,0);
    
    // 2. Luminance Balancing
    // Ensures the light doesn't become too bright or washed out
    float magiLumi = calculateLuminance(magic);
    float normaLumi = calculateLuminance(normalLight);
    float target = calculateLuminance(magic * ratio + normalLight * ratio);
    
    // 3. Compute Direct/Indirect Color
    poiLight.directColor = properLightColor * (target / properLuminance);
    
    // 4. Ramp Calculation
    // Calculates a smooth ramp based on the difference between direct and indirect light
    float bw_direct = ((nDotL * 0.5 + 0.5) * lightColor * attenuation);
    float lightDifference = (topIndirect + lightColor) - bottomIndirect;
    
    // Final Light Map (0-1 value)
    lightMap = smoothstep(0, lightDifference, bw_direct - bottomIndirect);
} 
else if (_LightingMapMode == 1) { // Normalized
    // Maps NdotL from [-1, 1] to [0, 1]
    lightMap = (nDotL * 0.5 + 0.5) * attenuation;
}
else { // Saturated
    // Clamps negative NdotL to 0
    lightMap = saturate(nDotL) * attenuation;
}

// Apply Detail Shadows & AO
// _LightDataAOStrengthR controls blending
lightMap *= lerp(1, detailShadow, _LightingDetailShadowStrengthR);
lightMap *= lerp(1, occlusion, _LightDataAOStrengthR);
```

## 3. Shading Models
Once the `lightMap` is calculated, it's used to blend between Lit and Shadow colors.

### Multilayer Math (`_LightingMode == 1`)
Defines shadows using math gradients rather than a texture ramp.
*   **Layers**: Up to 3 shadow layers (Primary, Secondary, Tertiary).
*   **Properties**:
    *   `_ShadowBorder`: Position of the shadow edge (0-1).
    *   `_ShadowBlur`: Softness of the edge.
    *   `_ShadowColor`: Color of the shadow.
*   **Logic**:
    ```hlsl
    // Smoothstep creates a soft transition based on Border and Blur
    float shadow1 = smoothstep(_ShadowBorder - _ShadowBlur, _ShadowBorder + _ShadowBlur, lightMap);
    
    // Blend final color
    finalColor = lerp(_ShadowColor, LitColor, shadow1);
    ```

### Texture Ramp (`_LightingMode == 0`)
Uses a 1D gradient texture sampled by `lightMap`.
*   **`_ToonRamp`**: The gradient texture.
*   **`_ShadowOffset`**: Offsets the lookup value (animatable).
*   **Logic**:
    ```hlsl
    // Sample texture using lightMap as the U coordinate
    float4 rampColor = tex2D(_ToonRamp, float2(lightMap + _ShadowOffset, 0.5));
    finalColor *= rampColor;
    ```

## 4. Additional Features
*   **AO Maps (`_LightingAOMaps`)**: Separate Ambient Occlusion texture with RGBA channel support.
*   **Shadow Masks (`_LightingShadowMasks`)**: Texture to force areas to be permanently in shadow or lit (useful for fixing ugly face shadows).
*   **Subsurface Scattering (SSS)**: Simulated by blurring the lighting or using thickness maps to allow light through thin areas.
    *   **`_SSSThicknessMap`**: Defines thin areas (ears, fingers).
    *   **`_SSSColor`**: Color of the light passing through.
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 323kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 323kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 323kUpdated Claude CodeCodexVerifiedInstall