How to Apply 3D Effects and Shadows to Shapes

How to Apply 3D Effects and Shadows to Shapes

This guide shows how to apply 2D and 3D visual effects to PowerPoint shapes using Aspose.Slides FOSS for .NET. Use shape.EffectFormat for 2D effects such as outer shadow, glow, blur, and soft edge. Use shape.ThreeDFormat for 3D appearance including bevel, camera perspective, light rig, material, and depth. Both effect systems can be combined on the same shape.


Prerequisites

Add the following package reference to your project by running the dotnet CLI install command:

dotnet add package Aspose.Slides.Foss

Add an Outer Drop Shadow

Call shape.EffectFormat.EnableOuterShadowEffect() to activate the outer shadow, then configure OuterShadowEffect.BlurRadius, Direction, and Distance to control its appearance:

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Drawing;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(
    ShapeType.Rectangle, 100, 100, 300, 120
);
shape.AddTextFrame("Shadowed Shape");

var ef = shape.EffectFormat;
ef.EnableOuterShadowEffect();
ef.OuterShadowEffect.BlurRadius = 10;       // softness in points
ef.OuterShadowEffect.Direction = 315;       // 315 degrees = upper-left
ef.OuterShadowEffect.Distance = 8;          // offset in points
ef.OuterShadowEffect.ShadowColor.Color = Color.FromArgb(128, 0, 0, 0);

prs.Save("shadow.pptx", SaveFormat.Pptx);

Common Direction values: 0=right, 45=lower-right, 90=down, 180=left, 270=up, 315=upper-left.


Add a Glow Effect

Call shape.EffectFormat.EnableGlowEffect() to activate the glow, then set GlowEffect.Radius and GlowEffect.Color.Color to control its spread and color:

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Drawing;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(
    ShapeType.Ellipse, 150, 100, 250, 250
);

var ef = shape.EffectFormat;
ef.EnableGlowEffect();
ef.GlowEffect.Radius = 20;
ef.GlowEffect.Color.Color = Color.Gold;

prs.Save("glow.pptx", SaveFormat.Pptx);

Apply a Gaussian Blur

Apply a Gaussian blur to a shape by calling shape.EffectFormat.SetBlurEffect(radius, grow) where radius controls the blur spread in points:

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(
    ShapeType.Rectangle, 100, 100, 350, 180
);
shape.EffectFormat.SetBlurEffect(radius: 10, grow: true);

prs.Save("blur.pptx", SaveFormat.Pptx);

grow: true expands the blur region beyond the shape boundary; grow: false clips the blur inside the shape.


Apply a 3D Bevel

Access shape.ThreeDFormat.BevelTop and set BevelType, Width, and Height to add a raised 3D border around the shape:

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(
    ShapeType.Rectangle, 150, 150, 280, 120
);
shape.AddTextFrame("3D Button");

var tdf = shape.ThreeDFormat;
tdf.BevelTop.BevelType = BevelPresetType.Circle;
tdf.BevelTop.Width = 12;
tdf.BevelTop.Height = 6;

prs.Save("bevel.pptx", SaveFormat.Pptx);

BevelPresetType values: Circle, RelaxedInset, CoolSlant, Divot, Riblet, HardEdge, Slope, Convex


3D Bevel with Camera and Light Rig

Set ThreeDFormat.Camera.CameraType, LightRig.LightType, Material, and Depth together to achieve a fully rendered 3D appearance:

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(
    ShapeType.Rectangle, 150, 150, 280, 120
);
shape.AddTextFrame("Metal Button");

var tdf = shape.ThreeDFormat;
tdf.BevelTop.BevelType = BevelPresetType.Circle;
tdf.BevelTop.Width = 10;
tdf.BevelTop.Height = 5;
tdf.Camera.CameraType = CameraPresetType.PerspectiveAbove;
tdf.LightRig.LightType = LightRigPresetType.Balanced;
tdf.LightRig.Direction = LightingDirection.Top;
tdf.Material = MaterialPresetType.Metal;
tdf.Depth = 20;

prs.Save("3d-metal.pptx", SaveFormat.Pptx);

Combine Shadow and 3D Bevel

Both effect systems can be active simultaneously on the same shape:

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Drawing;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(
    ShapeType.RoundCornerRectangle, 150, 150, 320, 130
);
shape.AddTextFrame("Premium Card");

// Solid fill
shape.FillFormat.FillType = FillType.Solid;
shape.FillFormat.SolidFillColor.Color = Color.FromArgb(255, 30, 80, 180);

// 3D bevel
var tdf = shape.ThreeDFormat;
tdf.BevelTop.BevelType = BevelPresetType.Circle;
tdf.BevelTop.Width = 8;
tdf.Camera.CameraType = CameraPresetType.PerspectiveAbove;
tdf.Material = MaterialPresetType.Plastic;

// Drop shadow
var ef = shape.EffectFormat;
ef.EnableOuterShadowEffect();
ef.OuterShadowEffect.BlurRadius = 12;
ef.OuterShadowEffect.Direction = 270;
ef.OuterShadowEffect.Distance = 6;
ef.OuterShadowEffect.ShadowColor.Color = Color.FromArgb(80, 0, 0, 0);

prs.Save("premium-card.pptx", SaveFormat.Pptx);

Check and Remove Effects

Use EffectFormat.IsNoEffects to detect whether any effects are active, and call DisableOuterShadowEffect() or DisableGlowEffect() to remove individual effects:

using Aspose.Slides.Foss;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(
    ShapeType.Rectangle, 100, 100, 200, 100
);
var ef = shape.EffectFormat;

ef.EnableOuterShadowEffect();
ef.EnableGlowEffect();
Console.WriteLine($"Has effects: {!ef.IsNoEffects}");  // True

ef.DisableOuterShadowEffect();
ef.DisableGlowEffect();
Console.WriteLine($"Has effects: {!ef.IsNoEffects}");  // False

See Also

 English