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/SToon/Details/01_Core_Shading.md

View on GitHub
# Core Shading Logic (核心光照逻辑)

SToon 的光照模型构建在 URP 的标准光照流程之上,但对光照衰减(Attenuation)和漫反射(Diffuse)部分进行了大量的风格化处理。

## 1. Light Ramp Modes (光照渐变模式)

Shader 提供了三种主要的光照模式,通过关键字 `_USELIGHTRAMP_STEP`, `_USELIGHTRAMP_DIFFUSERAMP`, `_USELIGHTRAMP_POSTERIZE` 切换。

### A. Step (硬切割)
这是最简单的 Toon Shading 形式。
*   **逻辑**: 使用 `smoothstep` 对 NdotL (结合 ShadowAttenuation) 进行二值化或硬过渡处理。
*   **代码片段**:
    ```glsl
    // temp_output_1188_0 是 NdotL * Attenuation
    float smoothstepResult444 = smoothstep( ( _StepOffset + 0.5 - 0.009 ) , ( _StepOffset + 0.5 ) , temp_output_1188_0);
    float4 lerpResult1619 = lerp( _ShadowColor , _MainLightColor , saturate( smoothstepResult444 ));
    ```
*   **参数**:
    *   `_StepOffset`: 调整明暗交界线的位置。

### B. Diffuse Ramp (渐变贴图)
使用一张 1D 纹理(通常是 Gradient)来映射光照强度。
*   **逻辑**: 将 NdotL 映射到纹理 UV 的 x 轴。
*   **代码片段**:
    ```glsl
    // appendResult356.x = _LightRampOffset + NdotL
    // clamp 防止采样越界
    float2 clampResult358 = clamp( appendResult356 , 0.01 , 0.98 );
    // 采样 Ramp 贴图
    float4 lerpResult1617 = lerp( tex2D( _LightRampTexture, float2( 0.02,0 ) ) , ( tex2D( _LightRampTexture, clampResult358 ) * _MainLightColor ) , staticSwitch1470);
    ```
*   **优点**: 可以制作丰富多彩的阴影过渡(例如皮肤阴影带点红色)。

### C. Posterize (色调分离)
通过数学计算将连续的光照强度离散化为几个阶梯。
*   **逻辑**:
    ```glsl
    float Posterize1331( float In, float Steps ) {
        return floor(In / (1 / Steps)) * (1 / Steps);
    }
    // ...
    float In1331 = pow( saturate( ( NdotL + ( _DiffusePosterizeOffset * -1.0 ) ) ) , _DiffusePosterizePower );
    float localPosterize1331 = Posterize1331( In1331 , round( _DiffusePosterizeSteps ) );
    ```
*   **参数**:
    *   `_DiffusePosterizeSteps`: 色阶数量(如 3 阶、4 阶)。
    *   `_DiffusePosterizePower`: 伽马校正,控制色阶的分布密度。

## 2. Additional Lights (多光源处理)

额外的点光源/聚光灯也经过了特殊的风格化处理,特别是它们的衰减(Falloff)也可以被 Posterize。

### Implementation
```glsl
float3 AdditionalLight( ... )
{
    // ... 遍历光源 ...
    // 计算 NdotL
    float3 DotVector = dot(light.direction, WorldNormal);
    
    // 计算最大通道强度 (Max Component)
    float maxColor = max(colout.r,max(colout.g,colout.b));
    
    // 平滑阶梯化 (Smoothstep based banding)
    float3 outColor = smoothstep(SMin, SMax, maxColor) * light.color;
    Color += outColor;
}
```
*   这确保了即使是额外的点光源,投射在物体上也不会产生写实的柔和衰减,而是保持卡通的硬边风格。

## 3. Shadows (阴影)

*   **Shadow Color**: 阴影颜色是显式定义的 `_ShadowColor`,而不是简单的变黑。
*   **混合逻辑**:
    ```glsl
    // staticSwitch1470 包含了 ShadowMap 的采样结果和 ShadowStrength
    float4 lerpResult1626 = lerp( _ShadowColor , lerpResult1619 , staticSwitch1470);
    ```
*   这意味着受阴影遮蔽的区域会直接显示 `_ShadowColor`,而不是 `BaseColor * ShadowColor`。这允许美术完全控制阴影区的色相(例如冷暖对比)。
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: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated 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: 322kUpdated Claude CodeCodexVerifiedInstall