Scripting Support (C#)
advanced scriptingUmbra Soft Shadows · Scripting Support (C#)
Umbra. The main component is UmbraSoftShadows, a MonoBehaviour attached to the main directional light. Shadow settings are stored in an UmbraProfile (ScriptableObject).
Getting Started
Add using Umbra; at the top of your script. Access the component and its profile:
using Umbra;
UmbraSoftShadows umbra = FindFirstObjectByType<Light>().GetComponent<UmbraSoftShadows>();
umbra.profile.sampleCount = 32;
umbra.profile.lightSize = 10f;
UmbraSoftShadows
Properties
UmbraProfile profileThe currently used Umbra profile with all shadow settings.
ContactShadowsSource contactShadowsSourceSource of contact shadows: DirectionalLight (default) or PointLights.
Transform pointLightsTriggerObject whose position is used to determine if it is inside point light volumes.
bool debugShadowsEnables debug visualization of the shadow buffer.
Static Members
static UmbraSoftShadows instanceSingleton reference to the active UmbraSoftShadows instance.
static bool installedTrue when the render feature is installed and active.
static bool isDeferredTrue when the current camera is rendering in deferred mode.
UmbraProfile
Shadow Quality
ShadowSource shadowSourceWhich shadow generation system to use: UnityShadows, UmbraShadows (default), or OnlyContactShadows.
int sampleCountNumber of shadow map samples used to resolve shadows (1–64, default 16).
int earlyOutSamplesNumber of samples for early exit if the shadow is already fully resolved (1–64, default 32).
float lightSizeSize of the directional light, which influences the penumbra size (0–32, default 6).
bool enableContactHardeningMakes shadows sharper near the occluder (default true).
float contactStrengthMakes shadows sharper and stronger near the occluder (0–1, default 0.5).
float contactStrengthKneeModifies the shadow edge appearance (default 0.0001).
float distantSpreadMakes shadows smoother when far from the occluder (1–16, default 1).
int occludersCountNumber of shadow map samples to find occluders for improved penumbra (1–64, default 8).
float occludersSearchRadiusMultiplier for the occluder search radius in texture space (default 8). Higher values create more diffused penumbra.
Blur
int blurIterationsNumber of blur passes (0–3). Each pass increases shadow softness.
BlurType blurTypeSpecifies the blur method: Gaussian15 (default), Gaussian5, or Box.
float blurSpreadBlur kernel radius multiplier (0.5–5, default 1).
float blurEdgeSharpnessIncreases contrast on the shadow border (0–1).
float blurEdgeToleranceStrength of the edge weight when blurring (default 5).
float blurDepthAttenStartDistance from camera where blur starts to reduce (default 50).
float blurDepthAttenLengthBlur reduction intensity over distance (default 50).
float blurGrazingAttenuationBlur reduction when viewing shadows from a grazing angle (0–1).
Cascades
bool blendCascadesEnable blending between shadow cascades.
int posterizationShadow posterization level (1–10, default 1).
float cascade1BlendingStrengthBlending strength for cascade 1 (default 0.1).
float cascade2BlendingStrengthBlending strength for cascade 2 (default 0.1).
float cascade3BlendingStrengthBlending strength for cascade 3 (default 0.1).
float cascade1ScaleShadow smoothness multiplier for cascade 1 (default 1).
float cascade2ScaleShadow smoothness multiplier for cascade 2 (default 1).
float cascade3ScaleShadow smoothness multiplier for cascade 3 (default 1).
float cascade4ScaleShadow smoothness multiplier for cascade 4 (default 1).
Normals & Performance
NormalSource normalsSourceMethod used to obtain surface normals: ReconstructFromDepth (default, fastest), NormalsPass (more accurate), or GBufferNormals (deferred only).
NormalSource effectiveNormalsSource read-onlyGets the effective normals source. Falls back to ReconstructFromDepth when GBufferNormals is selected but camera is not in deferred mode.
LoopStep loopStepOptimizationReduces the number of samples while keeping shadow size: Default, x2, or x3.
bool frameSkipOptimizationResolves the shadow map every two frames, reusing the result from the previous frame.
float skipFrameMaxCameraDisplacementIf camera moves more than this distance, the cached shadow map is discarded (default 0.1).
float skipFrameMaxCameraRotationIf camera rotates more than this angle (degrees), the cached shadow map is discarded (default 5).
bool downsampleResolves screen-space shadows in a half-resolution buffer.
bool forceDepthPrepassForces a depth prepass so depth and normals are available even for forward-only materials in deferred mode.
bool preserveEdgesPrevents shadow blurring on geometry edges (default true).
Style
Style styleStylized look for shadows: Default or Textured.
Texture2D maskTextureOptional mask texture to create stylized shadows.
float maskScaleScale of the mask texture (default 1).
Contact Shadows
bool contactShadowsEnables screen-space contact shadows.
float contactShadowsIntensityMultiplierIntensity multiplier for contact shadows (0–1, default 0.85).
ContactShadowsInjectionPoint contactShadowsInjectionPointInjection point: ShadowTexture (default) or AfterOpaque.
ContactShadowsInjectionPoint actualContactShadowsInjectionPoint read-onlyGets the actual injection point, forcing AfterOpaque when shadowSource is OnlyContactShadows.
int contactShadowsSampleCountNumber of contact shadow samples (1–64, default 16).
float contactShadowsSteppingStep size for contact shadow ray marching (default 0.01).
float contactShadowsThicknessNearThickness of surfaces at near distance (default 0.5).
float contactShadowsThicknessDistanceMultiplierMultiplier for thickness over distance.
float contactShadowsJitterJitter amount for contact shadow rays (default 0.3).
float contactShadowsDistanceFadeAttenuates shadow intensity with distance to occluder (0–1, default 0.75).
float contactShadowsStartDistanceMinimum distance where contact shadows start.
float contactShadowsStartDistanceFadeFade distance at the start of contact shadows (default 0.01).
float contactShadowsNormalBiasOffset added to the pixel position to avoid self-occlusion (0.0001–0.25, default 0.1).
float contactShadowsVignetteSizeAttenuates contact shadows at screen edges (0–0.5, default 0.15).
float contactShadowsBiasBias to avoid self-occlusion (0–1, default 0.001).
float contactShadowsBiasFarBias applied at far distances (0–1, default 0.4). Use only if self-shadowing occurs.
float contactShadowsEdgeSoftnessSoftens the edges of contact shadows (0.01–0.5, default 0.1).
bool contactShadowsSoftEdgesEnables soft edges for contact shadows. Disable for better performance.
bool contactShadowsPlanarShadowsMakes contact shadows planar by ignoring the Y component of the light direction. Useful for ground shadows.
Overlay Shadows
bool overlayShadowsAdds an extra pass after opaque with custom colored shadows.
float overlayShadowsIntensityIntensity of the overlay shadow pass (default 0.5).
Color overlayShadowsColorColor of the overlay shadows (default black).
Transparent Receiver
bool transparentReceiverPlaneEnables a receiver plane to cast shadows from transparent objects.
float receiverPlaneAltitudeWorld-space altitude of the transparent receiver plane.
Methods
void ApplyPreset(UmbraPreset preset)Applies a built-in preset: Hard, Soft, Smooth, ExtraSmooth, Blurred, or Fast.
UmbraPointLightContactShadows
Attach this MonoBehaviour to a Point Light to enable contact shadows from that light. Requires a BoxCollider trigger to define the shadow volume.
BoxCollider boxColliderThe box collider defining the shadow volume. Auto-created on enable if not present.
float fadeDistanceFade distance at the volume boundary (default 1).
static Dictionary<Light, UmbraPointLightContactShadows> umbraPointLights read-onlyDictionary of all registered point lights and their contact shadow components.
float ComputeVolumeFade(Vector3 worldPosition)Returns a 0–1 fade value based on how close the world position is to the volume boundary.
Code Examples
using Umbra;
// Get Umbra and modify the profile
var umbra = FindFirstObjectByType<Light>().GetComponent<UmbraSoftShadows>();
umbra.profile.sampleCount = 32;
umbra.profile.lightSize = 10f;
umbra.profile.enableContactHardening = true;
// Apply a preset
umbra.profile.ApplyPreset(UmbraPreset.Smooth);
// Enable contact shadows
umbra.profile.contactShadows = true;
umbra.profile.contactShadowsSampleCount = 24;
// Enable overlay shadows with a blue tint
umbra.profile.overlayShadows = true;
umbra.profile.overlayShadowsColor = new Color(0f, 0f, 0.3f);
// Switch to point light contact shadows
umbra.contactShadowsSource = ContactShadowsSource.PointLights;
umbra.pointLightsTrigger = playerTransform;Suggest an improvement
Help us improve this documentation page.