In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use the Unity programmable rendering pipeline. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Why do you need SRP
The only rendering pipes built into Unity are Forward and Deferred, as shown in the following figure.
Unity built-in rendering pipeline
These two built-in pipes have their own advantages and disadvantages, and you can't see the source code, so if it's very inconvenient to modify in order to show a particular visual effect, SRP is born. In addition, writing an appropriate SRP according to the needs of the project can also reduce DC and improve operational efficiency.
How to use SRP
Installation
After downloading Unity2018 from here, you bring your own SRP and you don't need to install it separately.
Use
Next, I will make a SRP that just paints the screen green step by step. Maybe you don't quite understand the meaning of each step, but please finish it patiently and look back at each step.
Step 1: inherit RenderPipeline and write the actual rendering code class.
Public class BasicPipeInstance: RenderPipeline {/ / the color to be painted private Color m_ClearColor = Color.black; public BasicPipeInstance (Color clearColor) {m_ClearColor = clearColor } / / rendering function, where ScriptableRenderContext is the context of rendering, / / is used to execute CommandBuffer, and CommandBuffer is the processing of rendering pipeline every step / / CommandBuffer is something that existed before Unity. For more information, please learn more about Baidu Google public override void Render (ScriptableRenderContext context, Camera [] cameras) {/ / does not so much yet: () base.Render (context, cameras) / / clear buffers to the configured color var cmd = new CommandBuffer (); cmd.ClearRenderTarget (true, true, m_ClearColor); context.ExecuteCommandBuffer (cmd); cmd.Release (); context.Submit ();}}
Step 2: inherit RenderPipelineAsset and write the class that generates the SRP data file.
Public class BasicAssetPipe: RenderPipelineAsset {public Color clearColor = Color.green;#if UNITY_EDITOR [UnityEditor.MenuItem ("SRP-Demo/01-CreateBasicAssetPipeline")] static void CreateBasicAssetPipeline () {/ / generate ScriptableObject var instance = ScriptableObject.CreateInstance (); / / Save ScriptableObject as a file UnityEditor.AssetDatabase.CreateAsset (instance, "Assets/BasicAssetPipe.asset") } # endif protected override IRenderPipeline InternalCreatePipeline () {/ / should be called at run time to generate SRP return new BasicPipeInstance (clearColor);}}
Step 3: create a SRP asset, as shown below.
Create SRP asset
At this point, a BasicAssetPipe.asset file will be generated in the Assets folder.
Step 4: set BasicAssetPipe.asset to the currently used SRP.
Open Editor- > Project Settings- > Graphics, and then drag the BasicAssetPipe.asset file to Scriptable Render Pipeline Settings, as shown below.
SRP Settin
Then you can see the game turn green.
Thank you for reading! This is the end of this article on "how to use Unity programmable rendering pipeline". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.