Skip to content

macetini/URP-Shield-Shader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity URP Shield Shader

A lightweight, customizable shield shader made for Unity Universal Render Pipeline (URP). Designed for quick integration into projects that need energy shields, force fields, or any semi-transparent protective effects with rim lighting, fresnel, distortion and optional impact ripples.

This repository contains shader assets and example materials that are tuned for runtime performance in URP while still offering a good range of artistic control.


Features

  • URP-ready Shader (ShaderLab + HLSL for Universal RP)
  • Fresnel / rim lighting control for edge glow
  • Base color / tint + emissive color support
  • Distortion / refraction-like view-dependent offset
  • Procedural noise / animated scroll for energy movement
  • Impact ripple / shockwave parameters for hit feedback
  • Normal map support for surface detail
  • HDR emission friendly (works with URP post-processing)
  • Low-cost variant options for mobile/low-end targets

Requirements

  • Unity 2019.4+ (recommended 2020.3 LTS or newer)
  • Universal Render Pipeline (URP) 7.x — 12.x (shader targets URP; if you use a different URP version you may need to recompile or adjust include paths)
  • Basic familiarity with creating Materials and assigning shaders in Unity

Installation

  1. Clone or download this repository into your Unity project's Assets folder, or import the package provided in the repo.
  2. Make sure your Project uses URP:
    • Install URP from the Package Manager if not already installed.
    • Assign a URP Asset in Project Settings > Graphics and in the Render Pipeline Asset slot.
  3. Locate the shader files under Assets/ShieldShader/Shaders and the sample materials under Assets/ShieldShader/Materials.

Quick Start — Using the Shader

  1. Create a new Material: Right-click in Project window → Create → Material.
  2. In the Inspector, change the Shader for the material to:
    • ShieldShader/URP (or the name exposed in the Shader file in this repo)
  3. Assign the Material to the mesh you want to be a shield (a sphere, capsule, or custom mesh).
  4. Tweak shader properties in the Material inspector to match the visual style you want.

Shader Properties (common)

These are the typical properties exposed by the shader. Exact names may vary slightly depending on the shader file; open the Material inspector for the exact property names.

  • Base Color / Tint — main color of the shield surface
  • Opacity / Alpha — overall transparency
  • Fresnel Power — controls rim falloff for edge glow
  • Rim Color — color of the fresnel rim highlight
  • Emission Color & Intensity — makes the shield glow (HDR-capable)
  • Distortion Strength — view-dependent offset / refraction effect
  • Noise Texture — animated scroll or noise texture for energy patterns
  • Noise Speed / Tiling — control animation and density of noise
  • Normal Map — surface detail for lighting interaction
  • Ripple Strength / Speed / Frequency — parameters for impact ripples
  • Fade Edge / Thickness — softens or sharpens the shield border
  • Cull Mode / Render Queue — options for double-sided or single-sided and render order
  • Performance Mode / LOD — simplified mode for lower-end targets (fewer samples, no refraction)

Example: Triggering an Impact Ripple

A ripple effect can be driven from script by updating material properties (example C# pseudo-code):

// Example: send an impact to the shield material
Material shieldMat = myShieldRenderer.sharedMaterial;
shieldMat.SetVector("_ImpactPos", transform.InverseTransformPoint(hitPoint));
shieldMat.SetFloat("_ImpactStrength", 1.0f);
shieldMat.SetFloat("_ImpactStartTime", Time.time);

(Replace property names with those in the material inspector for this shader.)


Best Practices & Performance Tips

  • Use the simplified/low-cost shader variant on mobile or VR.
  • Reduce noise texture resolution and sampling frequency for cheaper cost.
  • Combine multiple shield instances into fewer materials when they share the same properties (batches better).
  • Avoid high emission intensity and large bloom on many simultaneous objects — it can be expensive.

Troubleshooting

  • No effect visible: Ensure URP is active and the material shader is the URP-compatible shader.
  • Shader compilation errors: Check URP package version and includes — the shader may need small edits if your URP version changed include paths.
  • Transparent sorting issues: For complex scenes, you may need to adjust render queues or enable Depth Prepass depending on your needs.

Extending / Customizing

  • Add support for local-space deformation (vertex displacement) if you want dynamic shield meshes.
  • Hook up a surface flow map (UV scroll) for directional energy movement.
  • Integrate with particle systems for impact VFX and sound.

Contributing

Contributions are welcome. Please open an issue or submit a pull request with a clear description of the change and why it helps. If you add shader features, include a small demo scene showing the feature.


License

Specify the license here (e.g., MIT). If there is no license file in this repository, add one or clarify usage expectations.


Credits

  • Author: macetini
  • Created for: Unity URP projects wanting an editable shield/force-field visual

If you'd like, I can:

  • Add an example scene and a small demo script that triggers ripples on mouse click.
  • Produce a compact "mobile" shader variant and explain the changes required.
  • Update the README with exact inspector property names after you confirm the shader file names.

About

Unity3d URP Shield Shader

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors