Convert Figma logo to code with AI

Unity-Technologies logoUniversalRenderingExamples

This project contains a collection of Custom Renderer examples. This will be updated as we refine the feature and add more options.

2,029
412
2,029
37

Top Related Projects

Unity Graphics - Including Scriptable Render Pipeline

Demo Project using the Universal RP from Unity3D

Streaming server for Unity

Additional tools for Visual Effect Artists

Quick Overview

Unity-Technologies/UniversalRenderingExamples is a repository containing sample projects and scenes that demonstrate the capabilities of Unity's Universal Render Pipeline (URP). It showcases various rendering techniques and features, providing developers with practical examples to learn from and implement in their own projects.

Pros

  • Offers a wide range of rendering examples using URP
  • Provides ready-to-use scenes and projects for learning and experimentation
  • Regularly updated to reflect the latest URP features and best practices
  • Includes detailed documentation and explanations for each example

Cons

  • May require a specific Unity version for optimal compatibility
  • Some examples might be complex for beginners to understand
  • Limited to URP-specific features, not applicable to other rendering pipelines
  • Requires a basic understanding of Unity and rendering concepts

Code Examples

Since this repository primarily consists of Unity projects and scenes rather than a code library, there are no specific code examples to showcase. The examples are best explored within the Unity editor itself.

Getting Started

To get started with the UniversalRenderingExamples:

  1. Clone the repository:

    git clone https://github.com/Unity-Technologies/UniversalRenderingExamples.git
    
  2. Open Unity Hub and add the cloned project.

  3. Open the project using the Unity version specified in the repository's documentation.

  4. Explore the sample scenes in the project, which can be found in the "Assets/Scenes" folder.

  5. Read the accompanying documentation for each example to understand the implemented techniques and how to use them in your own projects.

Competitor Comparisons

Unity Graphics - Including Scriptable Render Pipeline

Pros of Graphics

  • More comprehensive coverage of Unity's graphics systems
  • Includes source code for multiple rendering pipelines
  • Offers a wider range of graphics-related tools and utilities

Cons of Graphics

  • Larger and more complex repository, potentially harder to navigate
  • May include experimental or work-in-progress features
  • Requires more in-depth knowledge of Unity's graphics architecture

Code Comparison

UniversalRenderingExamples:

[SerializeField]
private UniversalRendererData m_RendererData = null;

private void OnEnable()
{
    m_RendererData.SetDirty();
}

Graphics:

public class HDRenderPipeline : RenderPipeline
{
    protected override void Render(ScriptableRenderContext renderContext, Camera[] cameras)
    {
        BeginFrameRendering(renderContext, cameras);
    }
}

The UniversalRenderingExamples code focuses on Universal Render Pipeline specifics, while the Graphics repository includes implementations for multiple rendering pipelines, including the High Definition Render Pipeline shown in the example.

Demo Project using the Universal RP from Unity3D

Pros of BoatAttack

  • Full game demo showcasing URP capabilities in a real-world scenario
  • Includes advanced water simulation and boat physics
  • Demonstrates multiplayer functionality

Cons of BoatAttack

  • More complex and potentially overwhelming for beginners
  • Focused on a specific game genre, which may not be relevant for all projects
  • Larger repository size due to additional assets and features

Code Comparison

BoatAttack (Water shader example):

float3 waterColor = SAMPLE_TEXTURE2D(_WaterColorMap, sampler_WaterColorMap, uv).rgb;
float3 foamColor = SAMPLE_TEXTURE2D(_FoamColorMap, sampler_FoamColorMap, uv).rgb;
float3 finalColor = lerp(waterColor, foamColor, foamMask);

UniversalRenderingExamples (Simple lit shader example):

half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap));
half3 diffuse = albedoAlpha.rgb * _BaseColor.rgb;
half3 emission = SampleEmission(uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap));

Both repositories showcase Universal Render Pipeline (URP) features, but BoatAttack provides a more comprehensive, game-specific implementation, while UniversalRenderingExamples offers a broader range of rendering techniques applicable to various projects. The code snippets illustrate the difference in complexity and specificity between the two repositories.

Streaming server for Unity

Pros of UnityRenderStreaming

  • Enables real-time streaming of Unity content to web browsers
  • Supports WebRTC for low-latency video and audio streaming
  • Allows for remote input and control of Unity applications

Cons of UnityRenderStreaming

  • More complex setup and configuration compared to UniversalRenderingExamples
  • Requires additional server infrastructure for WebRTC signaling
  • May have higher performance overhead due to streaming requirements

Code Comparison

UnityRenderStreaming:

public class RenderStreaming : MonoBehaviour
{
    [SerializeField] private RenderStreamingSettings settings;
    private SignalingManager signalingManager;
    
    void Start()
    {
        signalingManager = new SignalingManager(settings);
    }
}

UniversalRenderingExamples:

public class URPRenderer : MonoBehaviour
{
    [SerializeField] private UniversalRenderPipelineAsset urpAsset;
    
    void Start()
    {
        QualitySettings.renderPipeline = urpAsset;
    }
}

The code snippets show that UnityRenderStreaming requires more setup for streaming functionality, while UniversalRenderingExamples focuses on configuring the Universal Render Pipeline. UnityRenderStreaming involves managing signaling and WebRTC connections, whereas UniversalRenderingExamples primarily deals with rendering settings and pipeline configuration.

Additional tools for Visual Effect Artists

Pros of VFXToolbox

  • Focused on visual effects and particle systems
  • Includes tools for texture generation and manipulation
  • Provides utilities for VFX Graph optimization

Cons of VFXToolbox

  • More specialized and less general-purpose than UniversalRenderingExamples
  • May require additional knowledge of VFX systems
  • Potentially steeper learning curve for beginners

Code Comparison

VFXToolbox (Texture generation example):

public class TextureGenerator : MonoBehaviour
{
    public int width = 512;
    public int height = 512;
    public FilterMode filterMode = FilterMode.Bilinear;
    public TextureWrapMode wrapMode = TextureWrapMode.Repeat;
}

UniversalRenderingExamples (Rendering setup example):

public class ExampleRenderPipelineAsset : RenderPipelineAsset
{
    protected override RenderPipeline CreatePipeline()
    {
        return new ExampleRenderPipeline(this);
    }
}

The VFXToolbox code focuses on texture generation parameters, while UniversalRenderingExamples deals with rendering pipeline setup. This reflects their different purposes: VFXToolbox is tailored for visual effects work, while UniversalRenderingExamples provides a broader range of rendering examples and techniques.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

This project is no longer maintained and will not work in Unity 2022 or newer.

Universal Rendering Examples

This project contains a collection of Custom Renderer examples. This will be updated as we refine the feature and add more options.
Current support : 2019.3.0f6 or later with UniversalRP 7.2.0

CustomRendererExamples

Usage of the project

  • Clone the repo/Download the zip down to your computer
  • Load in Unity version 2019.3.0f6 or later.
  • Each scene contains a different example
  • Upon loading the scene the Universal Render Pipeline asset is switched automatically to the one for the specific example

Project layout

  • _CompletedDemos/XXX This contains the demo data and scene files.
  • External Assets This folder contains shared assets such as meshes and textures.
  • Scripts Folder that contains some custom renderer features and utility scripts

Click here for more details about the individual examples

Examples

There are three examples currently in this project, they are:

First Person Objects

This demo showcases a setup to render first person perspective objects with a FOV(Field Of View) that differs from the game scene rendering FOV, this is common in first person games where the FOV needed for the experience is too wide for the objects held in hand ends up distorted.

FOV

  • Can be found at _CompletedDemos/FPSCameraCompleted/FPSCameraDemo.unity
  • Uses the Render Objects (Experimental) feature that is provided with the Universal Render Pipeline Package
  • Different FOV for GameObjects with the Layer set to First Person Objects
  • Depth settings to avoid rendering inside close objects like walls
  • Stencil settings to properly handle transparencies

Toon Outline

Showcases a setup to create an effect of Toon styled outlines, there are two approaches in the example, a post-process one and a hull mesh approach. One example uses a custom RendererFeature and both use custom shaders.

FOV

  • Can be found at _CompletedDemos/ToonOutlinePostprocessCompleted/ToonOutlinePost.unity
  • Uses the Blit custom feature(Blit.cs and BlitPass.cs) that is provided with this project for the OutlinePostEffect custom renderer
  • Custom Sobel Filter shader with Posterize option
  • Uses the Render Objects (Experimental) feature that is provided with the Universal Render Pipeline Package for the OutlineHullEffect custom renderer
  • Custom Toon Outline shader based of Unity Basic Toon shader

Object Occlusion

Showcases a setup useful to create effects when an object moves behind another one. Zero code needed, Shadergraph used for dither effect.

FOV

  • Can be found at _CompletedDemos/UnityOcclusionDemoCompleted/UnityOcclusionDemo.unity
  • Uses the Render Objects (Experimental) feature that is provided with the Universal Render Pipeline Package
  • Shadergraph made Dither shader for the effect