Skip to content

UnityCelShaderFX

API index


using CelShaderFX;              // Core types, settings, presets
using CelShaderFX.BuiltIn;      // Built-In pipeline components
using CelShaderFX.URP;          // URP pipeline components
using CelShaderFX.HDRP;         // HDRP pipeline components
using CelShaderFX.Advanced;     // Modular controller
using CelShaderFX.Modules;      // Individual effect modules

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 Script
var settings = ScriptableObject.CreateInstance<CelShaderSettings>();

Properties - Cel Shading

PropertyTypeDescription
enableCelShadingboolEnable cel shading effect
celBandCountintNumber of color bands (2-16)
celSoftnessfloatBand transition softness (0-1)
celSaturationfloatColor saturation (0-2)
useRampTextureboolUse custom gradient texture
rampTextureTexture2DCustom shading ramp
useColorPaletteboolEnable palette quantization
paletteColor1-4ColorPalette colors
paletteSoftnessfloatPalette blending

Properties - Outline

PropertyTypeDescription
enableOutlineboolEnable outline effect
outlineMethodOutlineMethodDetection algorithm
outlineThicknessfloatLine width (0.5-5)
outlineColorColorLine color
outlineDepthThresholdfloatDepth sensitivity
outlineNormalThresholdfloatNormal sensitivity
outlineDepthWeightfloatDepth edge weight
outlineNormalWeightfloatNormal edge weight
outlineCurvatureWeightfloatCurvature edge weight
outlineDistanceFadefloatDistance fade amount

Properties - Kuwahara

PropertyTypeDescription
enableKuwaharaboolEnable Kuwahara filter
kuwaharaVariantKuwaharaVariantFilter variant
kuwaharaRadiusintKernel radius (2-8)
kuwaharaSharpnessfloatEdge sharpness
kuwaharaAnisotropyfloatFlow alignment

Properties - Hatching

PropertyTypeDescription
enableHatchingboolEnable hatching
hatchingModeHatchingModeCoordinate space
hatchingTypeHatchingTypeGeneration method
hatchDensityfloatLine density
hatchRotationfloatPrimary angle
hatchSecondaryAnglefloatCross-hatch angle
hatchLineThicknessfloatLine width
hatchLineSpacingfloatLine spacing
hatchLayersintNumber of layers
hatchLineWobblefloatIrregularity
hatchLineTaperfloatEnd tapering
hatchWorldSpaceWeightfloatWorld space weight
hatchViewSpaceWeightfloatView space weight
hatchScreenSpaceWeightfloatScreen space weight
hatchIntensityMinfloatMin luminance
hatchIntensityMaxfloatMax luminance
hatchColorColorLine color
hatchPatternTextureTexture2DTAM texture
hatchToneCountintTAM tone count
hatchInvertTextureboolInvert TAM

Properties - Dithering

PropertyTypeDescription
enableDitheringboolEnable dithering
ditheringModeDitheringModeDither algorithm
ditheringLevelsintColor levels
ditheringStrengthfloatEffect strength
ditheringScalefloatPattern scale

Properties - Halftone

PropertyTypeDescription
enableHalftoneboolEnable halftone
halftoneShapeHalftoneShapePattern shape
halftoneScalefloatPattern size
halftoneAnglefloatPattern rotation
halftoneSoftnessfloatEdge softness
enableCMYKboolCMYK mode
cyanAnglefloatCyan screen angle
magentaAnglefloatMagenta screen angle
yellowAnglefloatYellow screen angle
blackAnglefloatBlack screen angle

Properties - Watercolor

PropertyTypeDescription
enableWatercolorboolEnable watercolor
watercolorEdgeDarkeningfloatEdge accumulation
watercolorGranulationfloatPigment settling
watercolorPaperStrengthfloatPaper texture
watercolorWorldSpaceboolWorld projection
watercolorNoiseScalefloatNoise scale
paperTextureTexture2DPaper texture

Properties - Painterly

PropertyTypeDescription
enablePainterlyboolEnable painterly
painterlyStrokeModePainterlyStrokeModeStroke direction
painterlyBrushSizefloatBrush width
painterlyBrushStrengthfloatEffect intensity
painterlyColorVariationfloatColor randomness
brushTextureTexture2DBrush texture
canvasTextureTexture2DCanvas texture
canvasStrengthfloatCanvas 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 }

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 setting
public 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 properties

Shader 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;
// ... etc

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 preset
public void CaptureFrom(CelShaderSettings settings);

Example

// Load preset from Resources
var animePreset = Resources.Load<CelShaderPreset>("DefaultPresets/Anime");
// Apply to current settings
animePreset.ApplyTo(mySettings);
// Or blend 50%
animePreset.ApplyTo(mySettings, 0.5f);

Main component for Built-In Render Pipeline.

Namespace: CelShaderFX.BuiltIn

File: Runtime/Scripts/BuiltIn/CelPostProcessEffect.cs

Properties

PropertyTypeDescription
settingsCelShaderSettingsEffect settings asset
materialMaterialGenerated material (read-only)

Methods

// Force refresh of material parameters
public void RefreshMaterial();
// Apply a preset
public void ApplyPreset(CelShaderPreset preset);

Usage

// Get reference
var effect = Camera.main.GetComponent<CelPostProcessEffect>();
// Modify settings at runtime
effect.settings.enableOutline = true;
effect.settings.outlineThickness = 2f;
// Apply preset
var preset = Resources.Load<CelShaderPreset>("DefaultPresets/Anime");
effect.ApplyPreset(preset);

Advanced controller for programmatic effect control.

Namespace: CelShaderFX.Advanced

File: Runtime/Scripts/Advanced/CelModularController.cs

Properties

PropertyTypeDescription
KuwaharaKuwaharaModuleKuwahara module
CelShadingCelShadingModuleCel shading module
OutlineOutlineModuleOutline module
HatchingHatchingModuleHatching module
DitheringDitheringModuleDithering module
HalftoneHalftoneModuleHalftone module
WatercolorWatercolorModuleWatercolor module
PainterlyPainterlyModulePainterly module
MaterialMaterialRender material
IsInitializedboolInit status

Methods

// Apply all module changes to material
public void ApplyAllModules();
// Mark as dirty (will auto-apply next frame)
public void SetDirty();
// Enable/disable effects by name
public void EnableEffect(string effectName);
public void DisableEffect(string effectName);
public void ToggleEffect(string effectName);
public bool IsEffectEnabled(string effectName);
// Bulk operations
public void EnableAllEffects();
public void DisableAllEffects();
public void ResetAllModules();
// Quick presets
public void ApplyAnimePreset();
public void ApplyMangaPreset();
public void ApplyWatercolorPreset();
public void ApplyOilPaintPreset();
// Debug
public string GetStatusSummary();
public void LogStatus();

Events

// Fired when any module is toggled
public event Action<string, bool> OnModuleToggled;
// Fired after modules are applied
public event Action OnModulesApplied;
// Fired before/after rendering
public 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");
   }
}

Abstract base class for all effect modules.

Namespace: CelShaderFX.Modules

File: Runtime/Scripts/Modules/CelShaderModuleBase.cs

Properties

PropertyTypeDescription
ModuleNamestringDisplay name
ModuleDescriptionstringDescription
ExecutionOrderintProcessing order
IsEnabledboolEnable state

Methods

// Apply this module to a material
public abstract void ApplyToMaterial(Material material);
// Reset to default values
public abstract void ResetToDefaults();
// Called on inspector change
public virtual void OnValidate();

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();
}

Renderer feature for URP.

Namespace: CelShaderFX.URP

File: Runtime/Scripts/URP/CelRenderFeature.cs

// Add to URP Renderer Asset via Inspector
// No direct scripting typically needed

Volume override for URP.

Namespace: CelShaderFX.URP

File: Runtime/Scripts/URP/CelVolumeComponent.cs

// Used in Volume profiles
// Access via VolumeManager or Volume.profile

Custom post-process for HDRP.

Namespace: CelShaderFX.HDRP

File: Runtime/Scripts/HDRP/CelCustomPostProcess.cs

// Register in HDRP Default Settings
// Used in Volume profiles

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);
}

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");
       }
   }
}
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);
   }
}
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();
   }
}
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.

Report an issue with this tool

Opens our feedback form in a new tab with the tool name pre-filled.