Code Monkey home page Code Monkey logo

universalrenderingexamples's Introduction

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

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

universalrenderingexamples's People

Contributors

hybridherbst avatar jonasmortensen avatar kaychang-unity avatar phi-lira avatar thomas-zeng avatar verasl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

universalrenderingexamples's Issues

Blit/ScreenQuad source/destination size resolutions?

Is there a way to get the source and/or destination render target sizes?
During the Execute method 'context' and 'renderingData' doesn't seem to contain anything regarding that.
If I wanted to use these render feature pipeline to create a downsampled/blurred targets, how can I go about it? is there a way to get render target sizes via their RenderTargetIdentifier ids?

The task at hand is very basic -> GetTemporaryRenderTarget(id, srcWidth / 2, srcHeight / 2);

Thanks in advance.

Edit: My bad, the source resolution is on the cameraData's cameraRenderDescriptor, however, chaining one blit after another might not work as there's no way to know what's the latest render target id freshly downsampled resolution. Workarounds might be possible by binding the info of one to the other.

pink shaders

i'm starting to wonder if github desktop chewed on the files...
image

Request: How to pass information to pass?

I've been struggling to understand how to pass information into a custom rendering pass such as textures specific to a particular character.

A concrete example that would help me a lot to understand how everything worked: If I wanted to make each character in the outline example using the hull method have a different colored outline.

'CameraData.renderer' is inaccessible due to its protection level

I added KawaseBlur render feature to my project from the 3DCharacterUI project and unity complains:

'CameraData.renderer' is inaccessible due to its protection level

It seems as though the renderer is no longer accessible from "renderingData.cameraData" in the execute method of ScriptableRenderPass. It must be marked protected at some point in development. Is there a new way to access the renderer, or even better the "cameraColorTarget" from this Execute function? I am using Unity 2019.4.1.1f1 / UniversalRP 7.3.1

'RectMask2D' does not contain a definition for 'padding'

Library\PackageCache\[email protected]\Scripts\Runtime\TMP_DefaultControls.cs(191,22): error CS1061: 'RectMask2D' does not contain a definition for 'padding' and no accessible extension method 'padding' accepting a first argument of type 'RectMask2D' could be found (are you missing a using directive or an assembly reference?)

using 2019.4.4f1, URP7.3.1. any ideas about that?

DrawFullscreenPass no suitable method found to override

Assets\Scripts\Runtime\RenderPasses\DrawFullscreenPass.cs(26,30): error CS0115: 'DrawFullscreenPass.OnCameraSetup(CommandBuffer, ref RenderingData)': no suitable method found to override

using version 2019.4.4f1, URP7.3.1.
anyone have ideas?

Cull Front etc would be nice for ShaderGraphs

Any chance you could add Cull Front etc to the URP so we can reproduce the outline shader in the toon project in Shadergraph? (bc yeah editing 64 k of lines after compiling the graph for just that is a bit to much, which btw also doesnt work bc error at line 40)
Also is there an option to combine materials into a meta shader to act as passes? bc Unity keeps telling me stacking materials for their specific purposes each is more inefficient than to have a mega shader that has every functionality built in, which yeah, is nice but kinda defeats the meaningful dogma that is hailed throughout programming: modularity.

and yeah 3086 different variants? so this is what IT liberalism looks like. instead of a standard every machine has to abide by and convert it for its own application. wow. never heard of ISO right or IEEE, or IETF or any standard any other Industry relies on... But hey its the nebulous and way too complicated IT world. Standardization is impossible here... Remember all the schims used for webdevelopment, yeah that lacking standard is making a lot of people going bald. How about you introduce a standard when you got a big enough market share you can impose on manufacturers, together with unreal Engine. BC this is BS

URP Custom Render Feature / Pass Breaks Based on Quality

I have been trying to build my own URP customer render feature / pass, but while it creates the feature, it will never call AddRenderPasses to add the pass, unless you remove the render pipeline asset from Quality.

To fix the problem, you must:
Goto the setting: Project Settings > Quality > Rendering
Set the Render Pipeline Asset to None
I can't see any relevant Quality settings that might turn on/off render features.

image

This capability works fine in Universal Rendering Examples from Unity on GitHub. I created a simple project to try and enable the specific Sobel Outline pass. I worked through every setting and configuration to finally found that is the only difference with the examples project and that solved this.

Why is this happening? Is this a bug or known behavior?

If it is a known behavior, how do you suggest replacing the functionality of the Quality capability?

My Versions
Unity 2020.2.0f1
URP 10.2.2

Thank you so much for any help with this.

3D Skybox in VR

Hi,

I'm facing issues getting the 3D Skybox to work in VR. After I add the TrackedPoseDriver script to the player cam, the planets get clipped during rotation.

error with open by unity2019.1.10f1

Library/PackageCache/[email protected]/Editor/LookDev/Compositor.cs(203,37): error CS0122: 'RenderDoc' is inaccessible due to its protection level

Library/PackageCache/[email protected]/Editor/Gizmo/HierarchicalBox.cs(254,92): error CS0103: The name 'EditorSnapSettings' does not exist in the current context

Library/PackageCache/[email protected]/Runtime/2D/Light2D.cs(135,33): error CS0234: The type or namespace name 'NotKeyableAttribute' does not exist in the namespace 'UnityEngine.Animations' (are you missing an assembly reference?)
.....
and many other errors.
does this project test by unity 2019.1?

DrawFullscreenPass flipping output

I am attempting to use a different material to pass into DrawFullscreen Pass. I have also implemented the feature on a 2D Renderer Data, which maybe isn't as intended. It seems to work except that the final image is getting flipped upside down and backwards. Any thoughts on how I might resolve this? It looks like a standard Blit supported a way of inverting scale/offset that might of doing a trick. Hoping for a solution that doesn't involve updating the shader, but maybe that's a possibility as well. Thanks.

BlitPass with Texture target

BlitPass with a texture target doesn't currently work.

I was able to fix it locally by adding:
cmd.GetTemporaryRT(destination.id, opaqueDesc, filterMode);
right before
Blit(cmd, source, destination.Identifier(), blitMaterial, blitShaderPassIndex);
on line 71 of BlitPass.cs, however I'm not confident that my solution is correct or complete.

Gradient Fog for Oculus Quest VR

I tested the gradient fog sample for Oculus Quest because I've been wanting to learn more about custom post-processing effects/shaders, and I've been looking for a good looking + performant way of doing fog for Quest VR. But I came up on a handful of issues, some I was able to solve, not sure if correctly though. But I haven't found a way to get past the last issue.

Unity Version: 2020.2.0b14
URP Version: 10.2.1
Device: Oculus Quest 2

1st Issue:
When building out the sample scene, or when switching between scenes using the same gradient fog render pipeline assets, this error was spat out seemingly every frame with nothing being displayed in either scene or game views:

Your script should either check if it is null or you should not destroy the object.
UnityEngine.Material.SetFloat (System.String name, System.Single value) (at <e414e10bfe5f45729ff122f3359de21b>:0)
GradientFog+GradientFogPass.Setup (UnityEngine.Rendering.RenderTargetIdentifier cameraColorTarget) (at Assets/_CompletedDemos/GradientFog/Rendering/GradientFog.cs:36)
GradientFog.AddRenderPasses (UnityEngine.Rendering.Universal.ScriptableRenderer renderer, UnityEngine.Rendering.Universal.RenderingData& renderingData) (at Assets/_CompletedDemos/GradientFog/Rendering/GradientFog.cs:98)
UnityEngine.Rendering.Universal.ScriptableRenderer.AddRenderPasses (UnityEngine.Rendering.Universal.RenderingData& renderingData) (at Library/PackageCache/[email protected]/Runtime/ScriptableRenderer.cs:648)
UnityEngine.Rendering.Universal.ForwardRenderer.Setup (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.RenderingData& renderingData) (at Library/PackageCache/[email protected]/Runtime/ForwardRenderer.cs:289)
UnityEngine.Rendering.Universal.UniversalRenderPipeline.RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.CameraData cameraData, System.Boolean anyPostProcessingEnabled) (at Library/PackageCache/[email protected]/Runtime/UniversalRenderPipeline.cs:377)
UnityEngine.Rendering.Universal.UniversalRenderPipeline.RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Camera camera) (at Library/PackageCache/[email protected]/Runtime/UniversalRenderPipeline.cs:296)
UnityEngine.Rendering.Universal.UniversalRenderPipeline.Render (UnityEngine.Rendering.ScriptableRenderContext renderContext, UnityEngine.Camera[] cameras) (at Library/PackageCache/[email protected]/Runtime/UniversalRenderPipeline.cs:251)
UnityEngine.Rendering.RenderPipeline.InternalRender (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Camera[] cameras) (at <e414e10bfe5f45729ff122f3359de21b>:0)
UnityEngine.Rendering.RenderPipelineManager.DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset pipe, System.IntPtr loopPtr, System.Collections.Generic.List`1[T] renderRequests, Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle safety) (at <e414e10bfe5f45729ff122f3359de21b>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Solution:
I was able to get past this by updating the Setup method in GradientFog.cs to this:

public void Setup(RenderTargetIdentifier cameraColorTarget)
        {
            source = cameraColorTarget;
            if (fogMaterial)
            {
                fogMaterial.SetFloat("_StartDist", settings.StartDistance);
                fogMaterial.SetFloat("_EndDist", settings.EndDistance);
                fogMaterial.SetColor("_NearCol", settings.NearColor);
                fogMaterial.SetColor("_MidCol", settings.MiddleColor);
                fogMaterial.SetColor("_FarCol", settings.FarColor);
            }
            else
            {
                Debug.LogWarning("No fogMaterial? making new...");
                m_TempTex.Init("_TempTex");
                fogMaterial = new Material(Shader.Find("Shader Graphs/GradientFogGraph"));
            }
        }

Seemed to let me switch scenes and build successfully after this change.

2nd Issue:
After 1st successful build, I tried running in headset, but nothing ever showed up.
I checked the adb device log and found this being spat out repetitiously:

2020/12/06 19:24:26.005 19820 19843 Error Unity ArgumentNullException: Value cannot be null.
2020/12/06 19:24:26.005 19820 19843 Error Unity Parameter name: shader
2020/12/06 19:24:26.005 19820 19843 Error Unity   at GradientFog+GradientFogPass..ctor () [0x00000] in <00000000000000000000000000000000>:0 
2020/12/06 19:24:26.005 19820 19843 Error Unity   at GradientFog.Create () [0x00000] in <00000000000000000000000000000000>:0 
2020/12/06 19:24:26.005 19820 19843 Error Unity   at UnityEngine.Rendering.Universal.ScriptableRenderer..ctor (UnityEngine.Rendering.Universal.ScriptableRendererData data) [0x00000] in <00000000000000000000000000000000>:0 
2020/12/06 19:24:26.005 19820 19843 Error Unity   at UnityEngine.Rendering.Universal.ForwardRenderer..ctor (UnityEngine.Rendering.Universal.ForwardRendererData data) [0x00000] in <00000000000000000000000000000000>:0 
2020/12/06 19:24:26.005 19820 19843 Error Unity   at UnityEngine.Rendering.Universal.ForwardRendererData.Create () [0x00000] in <00000000000000000000000000000000>:0 
2020/12/06 19:24:26.005 19820 19843 Error Unity   at UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset.CreateRenderers () [0x00000] in <00000000000000000000000000000000>:0 
2020/12/06 19:24:26.005 19820 19843 Error Unity   at UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset.CreatePipeline () [0x00000] in <00000000000000000000000000000000>:0 
2020/12/06 19:24:26.005 19820 19843 Error Unity   at UnityEngine.Rendering.RenderPipelineAsset.Inte

Solution:
So to get past this I figured to include the 'GradientFogGraph' shader graph within "Always Included Shaders" in Graphics in Project Settings. Not sure if that was the correct way to handle it, but it kind of worked and the error no longer showed up in the adb log for the second build.

3rd Issue:
After the above fix, when running in headset, all I see is white. But I can tell the app is running and not frozen because adb says it's running at 72fps, and when the app started I could see the Oculus OVR Screen Fade happen. Which is simply a plane in-front of the cameras that fade from black to transparent as an intro loader thing.

I tried fiddling with different settings for the gradient fog, but nothing changed the outcome of a solid white display in the build.
I also test through oculus link in editor and the fog looked great in both multi-pass and multi-view.
Not sure what to try next to try and get it to work the same in build so any help/suggestions would be greatly appreciated!

URP Mirror example

Is it possible to add a URP mirror example? One that works in stereo render single pass mode for VR, to account for player avatar presence.

Blur effect not work in android

Unity 2021.3.5,the effect works well in Editor,but when I package the blur scene into apk, the effect not work in android。

Shadowmap copy

How can I copy or expose shadowmap from directional light so I can sample it later from a transparent shader?

Tesselation demo scene all pink

I can see the mesh tesselating in the wireframe view, but the material renders "broken pink" even when you put textures in the slots.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.