Setting up dynamic shadows and reflections for graphics

Our video game development company runs independent projects, jointly creates games with the client and provides additional operational services. Expertise of our team allows us to cover all gaming platforms and develop an amazing product that matches the customer’s vision and players preferences.
Showing 1 of 1 servicesAll 242 services
Setting up dynamic shadows and reflections for graphics
Complex
~3 business days
FAQ
Our competencies
What are the stages of Game Development?
Latest works
  • image_games_mortal_motors_495_0.webp
    Game development for Mortal Motors
    663
  • image_games_a_turnbased_strategy_game_set_in_a_fantasy_setting_with_fire_and_sword_603_0.webp
    A turn-based strategy game set in a fantasy setting, With Fire and Sword
    859
  • image_games_second_team_604_0.webp
    Game development for the company Second term
    490
  • image_games_phoenix_ii_606_0.webp
    3D animation - teaser for the game Phoenix 2.
    533

Setting Up Dynamic Shadows and Reflections for Graphics

Dynamic shadows and reflections are the most GPU-hungry parts of the render pipeline. Configuring them "by default" doesn't work: each project requires its own balance between quality and performance. On mobile, a 2-megapixel Shadow Map for a single Directional Light is catastrophic. On desktop, the absence of Screen Space Reflections in a first-person shooter is immediately noticeable.

Shadows: Where Performance Is Lost

Shadow Casting works via an additional render pass—Shadow Caster Pass. Each object in the shadow-view zone is re-rendered with a depth shader to a Shadow Map texture. The more sources with shadows, the more additional passes.

Most painful—Spot Light or Point Light with Shadow Casting enabled on mobile platforms. Point Light renders Shadow Map as a cubemap—6 faces, 6 render passes for one source. On a scene with 5 such sources, that's 30 additional render passes each frame. On mobile, this doesn't fit the 16-ms budget.

Practical approach: keep Shadow Casting only on Directional Light (main directional source), switch Point and Spot Lights to non-shadow mode and compensate for their absence via Blob Shadow projector or Decal with soft shadow under character. Player won't notice the shadow is "fake" if its shape is believable.

Shadow Distance is critical to set appropriately. In Unity this is Quality Settings → Shadow Distance. Typical mistake—leave default 150 units for a mobile top-down project where far visibility is 30 units. Everything beyond this distance Unity still renders to Shadow Map but never displays.

Shadow Cascades for Directional Light

Directional Light with single Shadow Map without cascades gives either detailed shadows nearby with poor distant quality, or covers full distance at low resolution nearby. Shadow Cascades divide the Shadow Map into zones: near zone gets high resolution, far zone—low.

For PC projects, 4 cascades is standard. For mobile—2 cascades maximum, ideally 1 with small Shadow Distance. Default cascade distribution in Unity is uniform, but logarithmic works better: 0.05 / 0.15 / 0.35—most of Shadow Map resolution goes to first meters in front of camera where shadow detail is most noticeable.

Shadow Normal Bias and Shadow Bias—parameters determining whether there's "shadow acne" (striped self-shadow artifacts) or "peter panning" (shadows separated from objects). Normal Bias 0.4, Bias 0.05 is the starting point for most scenes. For thin objects (leaves, grilles), Normal Bias should be lowered to 0.1–0.2, otherwise shadow disappears completely.

Reflections: Screen Space vs Probe-Based

Screen Space Reflections (SSR)—postprocessing effect, working only with what's in frame. Cheap and convincing for horizontal surfaces (floor, water), but breaks at screen edges and doesn't show what's behind camera. In HDRP configured via Volume → Screen Space Reflection, key parameter—Minimum Smoothness (surfaces below this value don't get SSR, which is correct—matte surfaces don't reflect).

Reflection Probes work where SSR fails: vertical surfaces, ceiling reflection in floor, interiors. Baked Reflection Probe—snapshot of cubic panorama at specific point in space, baked beforehand. Realtime Reflection Probe recalculates during gameplay.

Problem with Baked Probes—static nature. If scene has animated objects (flags, water, characters), they don't appear in reflection. Compromise: Realtime Probe with Refresh Mode On Awake for objects that rarely change (opening door), and Baked for everything else.

Box Projection is mandatory for interiors. Without it, Reflection Probe behaves as infinitely distant source, and reflection doesn't align with real room geometry. With Box Projection and correctly configured Box Size, mirror on wall shows correct perspective.

Case Study: Water With Reflection on Mobile

Project with isometric view required river with believable reflections on Android. SSR—unavailable (OpenGL ES 3.0 on target devices poorly handles postprocess stack). Baked Reflection Probe gave static picture without sky.

Solution: custom water shader in ShaderGraph with UV distortion via Normal Map (simulating waves) + Reflection Probe in Realtime mode with Refresh Mode Every Frame, but with very low Shadow Resolution (128×128)—it reflected only sky and horizon. For dynamic objects (boats), added Planar Reflection Camera—separate camera rendering scene with flipped Y-axis to Render Texture, which water shader blends with Reflection Probe via Fresnel-dependence. Result looked convincing at cost of one additional 60%-resolution render pass.

Diagnostics and Tools

Frame Debugger breaks down Shadow Caster Pass by each source—immediately visible who "eats" time. GPU Usage in Profiler shows ms for each render pass with Shadow Casting.

For Reflection Probes—Rendering Debugger in Reflections → Probe Volume view: shows which probe affects specific surface and whether Box Projection is correct.

Task Timeline
Configure shadows for one scene (PC/console) 1–3 days
Configure shadows with mobile optimization 3–7 days
Reflection Probes for interior complex 3–5 days
Full shadows + reflections pipeline, multiple platforms 2–4 weeks

Cost calculated individually after analyzing render pipeline and target platforms.