UnityCelShaderFX
API index
Scripting Documentation
Section titled “Scripting Documentation”Namespaces
Section titled “Namespaces”using CelShaderFX; // Core types, settings, presetsusing CelShaderFX.BuiltIn; // Built-In pipeline componentsusing CelShaderFX.URP; // URP pipeline componentsusing CelShaderFX.HDRP; // HDRP pipeline componentsusing CelShaderFX.Advanced; // Modular controllerusing CelShaderFX.Modules; // Individual effect modulesCore Classes
Section titled “Core Classes”CelShaderSettings
Section titled “CelShaderSettings”ScriptableObject containing all effect parameters.
Namespace: CelShaderFX
File: Runtime/Scripts/Core/CelShaderSettings.cs
Creating an Instance
// Via Unity Editor// Right-click > Create > CelShaderFX > Settings
// Via Scriptvar settings = ScriptableObject.CreateInstance<CelShaderSettings>();Properties - Cel Shading
| Property | Type | Description |
|---|---|---|
| enableCelShading | bool | Enable cel shading effect |
| celBandCount | int | Number of color bands (2-16) |
| celSoftness | float | Band transition softness (0-1) |
| celSaturation | float | Color saturation (0-2) |
| useRampTexture | bool | Use custom gradient texture |
| rampTexture | Texture2D | Custom shading ramp |
| useColorPalette | bool | Enable palette quantization |
| paletteColor1-4 | Color | Palette colors |
| paletteSoftness | float | Palette blending |
Properties - Outline
| Property | Type | Description |
|---|---|---|
| enableOutline | bool | Enable outline effect |
| outlineMethod | OutlineMethod | Detection algorithm |
| outlineThickness | float | Line width (0.5-5) |
| outlineColor | Color | Line color |
| outlineDepthThreshold | float | Depth sensitivity |
| outlineNormalThreshold | float | Normal sensitivity |
| outlineDepthWeight | float | Depth edge weight |
| outlineNormalWeight | float | Normal edge weight |
| outlineCurvatureWeight | float | Curvature edge weight |
| outlineDistanceFade | float | Distance fade amount |
Properties - Kuwahara
| Property | Type | Description |
|---|---|---|
| enableKuwahara | bool | Enable Kuwahara filter |
| kuwaharaVariant | KuwaharaVariant | Filter variant |
| kuwaharaRadius | int | Kernel radius (2-8) |
| kuwaharaSharpness | float | Edge sharpness |
| kuwaharaAnisotropy | float | Flow alignment |
Properties - Hatching
| Property | Type | Description |
|---|---|---|
| enableHatching | bool | Enable hatching |
| hatchingMode | HatchingMode | Coordinate space |
| hatchingType | HatchingType | Generation method |
| hatchDensity | float | Line density |
| hatchRotation | float | Primary angle |
| hatchSecondaryAngle | float | Cross-hatch angle |
| hatchLineThickness | float | Line width |
| hatchLineSpacing | float | Line spacing |
| hatchLayers | int | Number of layers |
| hatchLineWobble | float | Irregularity |
| hatchLineTaper | float | End tapering |
| hatchWorldSpaceWeight | float | World space weight |
| hatchViewSpaceWeight | float | View space weight |
| hatchScreenSpaceWeight | float | Screen space weight |
| hatchIntensityMin | float | Min luminance |
| hatchIntensityMax | float | Max luminance |
| hatchColor | Color | Line color |
| hatchPatternTexture | Texture2D | TAM texture |
| hatchToneCount | int | TAM tone count |
| hatchInvertTexture | bool | Invert TAM |
Properties - Dithering
| Property | Type | Description |
|---|---|---|
| enableDithering | bool | Enable dithering |
| ditheringMode | DitheringMode | Dither algorithm |
| ditheringLevels | int | Color levels |
| ditheringStrength | float | Effect strength |
| ditheringScale | float | Pattern scale |
Properties - Halftone
| Property | Type | Description |
|---|---|---|
| enableHalftone | bool | Enable halftone |
| halftoneShape | HalftoneShape | Pattern shape |
| halftoneScale | float | Pattern size |
| halftoneAngle | float | Pattern rotation |
| halftoneSoftness | float | Edge softness |
| enableCMYK | bool | CMYK mode |
| cyanAngle | float | Cyan screen angle |
| magentaAngle | float | Magenta screen angle |
| yellowAngle | float | Yellow screen angle |
| blackAngle | float | Black screen angle |
Properties - Watercolor
| Property | Type | Description |
|---|---|---|
| enableWatercolor | bool | Enable watercolor |
| watercolorEdgeDarkening | float | Edge accumulation |
| watercolorGranulation | float | Pigment settling |
| watercolorPaperStrength | float | Paper texture |
| watercolorWorldSpace | bool | World projection |
| watercolorNoiseScale | float | Noise scale |
| paperTexture | Texture2D | Paper texture |
Properties - Painterly
| Property | Type | Description |
|---|---|---|
| enablePainterly | bool | Enable painterly |
| painterlyStrokeMode | PainterlyStrokeMode | Stroke direction |
| painterlyBrushSize | float | Brush width |
| painterlyBrushStrength | float | Effect intensity |
| painterlyColorVariation | float | Color randomness |
| brushTexture | Texture2D | Brush texture |
| canvasTexture | Texture2D | Canvas texture |
| canvasStrength | float | Canvas intensity |
Enumerations
public enum KuwaharaVariant { Basic, Generalized, Anisotropic }public enum OutlineMethod { Sobel, Roberts, Canny, DoG }public enum HatchingMode { ScreenSpace, WorldSpace, Blended }public enum HatchingType { Procedural, Texture, Hybrid }public enum DitheringMode { Bayer2x2, Bayer4x4, Bayer8x8, BlueNoise, ErrorDiffusion }public enum HalftoneShape { Dots, Lines, Diamonds, Crosshatch }public enum PainterlyStrokeMode { Auto, Directional, Radial }CelShaderConstants
Section titled “CelShaderConstants”Static class containing shader property IDs and default values.
Namespace: CelShaderFX
File: Runtime/Scripts/Core/CelShaderConstants.cs
Shader Property IDs
// Access cached property IDs for efficient shader parameter settingpublic static readonly int EnableCelShading; // "_EnableCelShading"public static readonly int CelBandCount; // "_CelBandCount"public static readonly int EnableOutline; // "_EnableOutline"public static readonly int OutlineThickness; // "_OutlineThickness"// ... etc for all shader propertiesShader Paths
public static readonly string SHADER_PATH_BUILTIN = "Hidden/CelShaderFX/BuiltIn/CelEffect";public static readonly string SHADER_PATH_URP = "Hidden/CelShaderFX/URP/CelEffect";public static readonly string SHADER_PATH_HDRP = "Hidden/CelShaderFX/HDRP/CelEffect";Default Values
public const int DEFAULT_CEL_BANDS = 4;public const float DEFAULT_CEL_SOFTNESS = 0.05f;public const float DEFAULT_OUTLINE_THICKNESS = 1.0f;// ... etcCelShaderPreset
Section titled “CelShaderPreset”ScriptableObject for saving and loading effect configurations.
Namespace: CelShaderFX
File: Runtime/Scripts/Core/CelShaderPreset.cs
Methods
// Apply preset to settings (full)public void ApplyTo(CelShaderSettings settings);
// Apply preset with interpolation (0 = keep current, 1 = full preset)public void ApplyTo(CelShaderSettings settings, float blend);
// Capture current settings to this presetpublic void CaptureFrom(CelShaderSettings settings);Example
// Load preset from Resourcesvar animePreset = Resources.Load<CelShaderPreset>("DefaultPresets/Anime");
// Apply to current settingsanimePreset.ApplyTo(mySettings);
// Or blend 50%animePreset.ApplyTo(mySettings, 0.5f);Controller Classes
Section titled “Controller Classes”CelPostProcessEffect
Section titled “CelPostProcessEffect”Main component for Built-In Render Pipeline.
Namespace: CelShaderFX.BuiltIn
File: Runtime/Scripts/BuiltIn/CelPostProcessEffect.cs
Properties
| Property | Type | Description |
|---|---|---|
| settings | CelShaderSettings | Effect settings asset |
| material | Material | Generated material (read-only) |
Methods
// Force refresh of material parameterspublic void RefreshMaterial();
// Apply a presetpublic void ApplyPreset(CelShaderPreset preset);Usage
// Get referencevar effect = Camera.main.GetComponent<CelPostProcessEffect>();
// Modify settings at runtimeeffect.settings.enableOutline = true;effect.settings.outlineThickness = 2f;
// Apply presetvar preset = Resources.Load<CelShaderPreset>("DefaultPresets/Anime");effect.ApplyPreset(preset);CelModularController
Section titled “CelModularController”Advanced controller for programmatic effect control.
Namespace: CelShaderFX.Advanced
File: Runtime/Scripts/Advanced/CelModularController.cs
Properties
| Property | Type | Description |
|---|---|---|
| Kuwahara | KuwaharaModule | Kuwahara module |
| CelShading | CelShadingModule | Cel shading module |
| Outline | OutlineModule | Outline module |
| Hatching | HatchingModule | Hatching module |
| Dithering | DitheringModule | Dithering module |
| Halftone | HalftoneModule | Halftone module |
| Watercolor | WatercolorModule | Watercolor module |
| Painterly | PainterlyModule | Painterly module |
| Material | Material | Render material |
| IsInitialized | bool | Init status |
Methods
// Apply all module changes to materialpublic void ApplyAllModules();
// Mark as dirty (will auto-apply next frame)public void SetDirty();
// Enable/disable effects by namepublic void EnableEffect(string effectName);public void DisableEffect(string effectName);public void ToggleEffect(string effectName);public bool IsEffectEnabled(string effectName);
// Bulk operationspublic void EnableAllEffects();public void DisableAllEffects();public void ResetAllModules();
// Quick presetspublic void ApplyAnimePreset();public void ApplyMangaPreset();public void ApplyWatercolorPreset();public void ApplyOilPaintPreset();
// Debugpublic string GetStatusSummary();public void LogStatus();Events
// Fired when any module is toggledpublic event Action<string, bool> OnModuleToggled;
// Fired after modules are appliedpublic event Action OnModulesApplied;
// Fired before/after renderingpublic event Action<Material> OnBeforeRender;public event Action OnAfterRender;Example
using CelShaderFX.Advanced;
public class EffectController : MonoBehaviour{ private CelModularController cel;
void Start() { cel = GetComponent<CelModularController>();
// Subscribe to events cel.OnModuleToggled += (name, enabled) => { Debug.Log($"{name} is now {(enabled ? "ON" : "OFF")}"); }; }
public void SetAnimeStyle() { cel.DisableAllEffects();
cel.CelShading.enabled = true; cel.CelShading.bands = 4; cel.CelShading.softness = 0.05f;
cel.Outline.enabled = true; cel.Outline.thickness = 1.5f; cel.Outline.color = Color.black;
cel.ApplyAllModules(); }
public void ToggleOutlines() { cel.ToggleEffect("outline"); }}Module Classes
Section titled “Module Classes”CelShaderModuleBase
Section titled “CelShaderModuleBase”Abstract base class for all effect modules.
Namespace: CelShaderFX.Modules
File: Runtime/Scripts/Modules/CelShaderModuleBase.cs
Properties
| Property | Type | Description |
|---|---|---|
| ModuleName | string | Display name |
| ModuleDescription | string | Description |
| ExecutionOrder | int | Processing order |
| IsEnabled | bool | Enable state |
Methods
// Apply this module to a materialpublic abstract void ApplyToMaterial(Material material);
// Reset to default valuespublic abstract void ResetToDefaults();
// Called on inspector changepublic virtual void OnValidate();Individual Modules
Section titled “Individual Modules”All modules inherit from CelShaderModuleBase and expose their specific parameters as public fields.
KuwaharaModule
public class KuwaharaModule : CelShaderModuleBase{ public bool enabled; public CelShaderSettings.KuwaharaVariant variant; public int radius; // 2-8 public float sharpness; // 0.5-16 public float anisotropy; // 0-1
// Presets public void ApplySubtleOilPaintPreset(); public void ApplyStrongOilPaintPreset(); public void ApplyAnisotropicPreset(); public void ApplyAnimePreset();}CelShadingModule
public class CelShadingModule : CelShaderModuleBase{ public bool enabled; public int bands; // 2-16 public float softness; // 0-1 public float saturation; // 0-2 public bool useRampTexture; public Texture2D rampTexture; public bool useColorPalette; public Color paletteColor1, paletteColor2, paletteColor3, paletteColor4; public float paletteSoftness;
// Presets public void ApplyAnimePreset(); public void ApplyTwoTonePreset(); public void ApplySoftToonPreset();}OutlineModule
public class OutlineModule : CelShaderModuleBase{ public bool enabled; public CelShaderSettings.OutlineMethod method; public float thickness; // 0.5-5 public Color color; public float depthThreshold; // 0.01-1 public float normalThreshold; // 10-90 public float depthWeight; // 0-2 public float normalWeight; // 0-2 public float curvatureWeight; // 0-2 public float distanceFade; // 0-0.1
// Presets public void ApplyAnimePreset(); public void ApplySketchPreset(); public void ApplyComicPreset(); public void ApplySubtlePreset(); public void ApplyDoGPreset();}HatchingModule
public class HatchingModule : CelShaderModuleBase{ public bool enabled; public CelShaderSettings.HatchingMode mode; public CelShaderSettings.HatchingType type; public float density; public float rotation; public float secondaryAngle; public float lineThickness; public float lineSpacing; public int layers; public float lineWobble; public float lineTaper; public float worldSpaceWeight; public float viewSpaceWeight; public float screenSpaceWeight; public float intensityMin; public float intensityMax; public Color color; public Texture2D patternTexture; public Texture2D crossHatchTexture; public int toneCount; public bool invertTexture;
// Presets public void ApplyMangaPreset(); public void ApplySketchPreset(); public void ApplyEngravingPreset(); public void ApplyTexturePreset(); public void ApplyHybridPreset();}DitheringModule
public class DitheringModule : CelShaderModuleBase{ public bool enabled; public CelShaderSettings.DitheringMode mode; public int colorLevels; public float strength; public float scale;
// Presets public void ApplyRetroPreset(); public void ApplyFilmGrainPreset(); public void Apply1BitPreset();}HalftoneModule
public class HalftoneModule : CelShaderModuleBase{ public bool enabled; public CelShaderSettings.HalftoneShape shape; public float scale; public float angle; public float softness; public bool enableCMYK; public float cyanAngle; public float magentaAngle; public float yellowAngle; public float blackAngle;
// Presets public void ApplyPopArtPreset(); public void ApplyNewspaperPreset(); public void ApplyVintagePreset();}WatercolorModule
public class WatercolorModule : CelShaderModuleBase{ public bool enabled; public float edgeDarkening; public float granulation; public float paperStrength; public bool worldSpace; public float noiseScale; public Texture2D paperTexture;
// Presets public void ApplyLoosePreset(); public void ApplyTightPreset(); public void ApplyVintagePreset(); public void ApplySubtlePreset(); public void ApplyChineseBrushPreset();}PainterlyModule
public class PainterlyModule : CelShaderModuleBase{ public bool enabled; public CelShaderSettings.PainterlyStrokeMode strokeMode; public float brushSize; public float brushStrength; public float colorVariation; public Texture2D brushTexture; public Texture2D canvasTexture; public float canvasStrength;
// Presets public void ApplyOilPaintPreset(); public void ApplyImpressionistPreset(); public void ApplyPaletteKnifePreset();}URP Classes
Section titled “URP Classes”CelRenderFeature
Section titled “CelRenderFeature”Renderer feature for URP.
Namespace: CelShaderFX.URP
File: Runtime/Scripts/URP/CelRenderFeature.cs
// Add to URP Renderer Asset via Inspector// No direct scripting typically neededCelVolumeComponent
Section titled “CelVolumeComponent”Volume override for URP.
Namespace: CelShaderFX.URP
File: Runtime/Scripts/URP/CelVolumeComponent.cs
// Used in Volume profiles// Access via VolumeManager or Volume.profileHDRP Classes
Section titled “HDRP Classes”CelCustomPostProcess
Section titled “CelCustomPostProcess”Custom post-process for HDRP.
Namespace: CelShaderFX.HDRP
File: Runtime/Scripts/HDRP/CelCustomPostProcess.cs
// Register in HDRP Default Settings// Used in Volume profilesUtility Classes
Section titled “Utility Classes”CelShaderModuleManager
Section titled “CelShaderModuleManager”Manages module execution order and application.
Namespace: CelShaderFX.Modules
public class CelShaderModuleManager{ // Register a module public void RegisterModule(CelShaderModuleBase module);
// Unregister a module public void UnregisterModule(string moduleName);
// Get module by name public CelShaderModuleBase GetModule(string name);
// Apply all enabled modules to material public void ApplyToMaterial(Material material);}Code Examples
Section titled “Code Examples”Runtime Effect Toggle
Section titled “Runtime Effect Toggle”using UnityEngine;using CelShaderFX.Advanced;
public class EffectToggle : MonoBehaviour{ private CelModularController cel;
void Start() { cel = Camera.main.GetComponent<CelModularController>(); }
void Update() { // Toggle outline with O key if (Input.GetKeyDown(KeyCode.O)) { cel.ToggleEffect("outline"); }
// Toggle cel shading with C key if (Input.GetKeyDown(KeyCode.C)) { cel.ToggleEffect("cel"); } }}Smooth Preset Transition
Section titled “Smooth Preset Transition”using UnityEngine;using CelShaderFX;using System.Collections;
public class PresetTransition : MonoBehaviour{ public CelShaderSettings settings; public CelShaderPreset targetPreset; public float transitionDuration = 1f;
public void TransitionToPreset() { StartCoroutine(DoTransition()); }
private IEnumerator DoTransition() { float elapsed = 0f;
while (elapsed < transitionDuration) { elapsed += Time.deltaTime; float t = elapsed / transitionDuration;
// Smooth easing t = t * t * (3f - 2f * t);
targetPreset.ApplyTo(settings, t); yield return null; }
// Ensure we reach exactly 100% targetPreset.ApplyTo(settings, 1f); }}Dynamic Outline Based on Distance
Section titled “Dynamic Outline Based on Distance”using UnityEngine;using CelShaderFX.Advanced;
public class DynamicOutline : MonoBehaviour{ public CelModularController cel; public Transform target; public float minDistance = 5f; public float maxDistance = 20f; public float minThickness = 0.5f; public float maxThickness = 3f;
void Update() { if (target == null) return;
float distance = Vector3.Distance(Camera.main.transform.position, target.position); float t = Mathf.InverseLerp(minDistance, maxDistance, distance);
cel.Outline.thickness = Mathf.Lerp(maxThickness, minThickness, t); cel.SetDirty(); }}Weather-Based Effect
Section titled “Weather-Based Effect”using UnityEngine;using CelShaderFX.Advanced;
public class WeatherEffects : MonoBehaviour{ public CelModularController cel;
public void SetSunnyWeather() { cel.DisableAllEffects(); cel.CelShading.enabled = true; cel.CelShading.bands = 4; cel.CelShading.saturation = 1.2f; cel.Outline.enabled = true; cel.Outline.thickness = 1f; cel.ApplyAllModules(); }
public void SetRainyWeather() { cel.DisableAllEffects(); cel.Watercolor.enabled = true; cel.Watercolor.edgeDarkening = 0.6f; cel.Watercolor.granulation = 0.4f; cel.CelShading.enabled = true; cel.CelShading.saturation = 0.8f; cel.ApplyAllModules(); }
public void SetFoggyWeather() { cel.DisableAllEffects(); cel.Kuwahara.enabled = true; cel.Kuwahara.radius = 3; cel.CelShading.enabled = true; cel.CelShading.softness = 0.3f; cel.ApplyAllModules(); }}For installation and setup, see Quick Start Guide.For effect details, see User Manual.
Opens our feedback form in a new tab with the tool name pre-filled.