In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to use shader to achieve Gaussian blur on the screen, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
1. Create a new C# script, the modified script must be hung on the camera
Using UnityEngine;using System.Collections;/// High-period blur / public class GaussianBlur: PostEffectsBase {/ / adjusts the number of Gaussian blur iterations [Range (0,4)] public int iterations = 3; / / the fuzzy range [Range (0.2f, 3.0f)] public float blurSpread = 0.6f / / the larger the zoom factor / / downSample, the fewer pixels you need to process, and you can further improve the blur program, / / but too large downSample may pixel the image. [Range (1,8)] public int downSample = 2; public Shader gaussianBlurShader; private Material gaussianBlurMaterial = null; public Material material {get {gaussianBlurMaterial = CheckShaderAndCreateMaterial (gaussianBlurShader, gaussianBlurMaterial); return gaussianBlurMaterial }} void OnRenderImage (RenderTexture src, RenderTexture dest) {if (material! = null) {/ / uses scaling to desample the image, thus reducing the number of pixels to be processed and improving performance. Int rtW = src.width / downSample; int rtH = src.height / downSample; / / allocates a buffer because Gaussian blur needs to call two Pass, and we need to use an intermediate cache to / / store the blurred results after the first Pass is executed. RenderTexture buffer0 = RenderTexture.GetTemporary (rtW, rtH, 0); / / sets the filtering mode of the temporary rendered texture to bilinear. In this way, when we call the first Pass, the number of / / pixels we need to deal with is a fraction of the original. Downsampling the image can not only reduce the number of pixels to be processed and improve the performance, but also get a better blur effect with appropriate mining reduction. Buffer0.filterMode = FilterMode.Bilinear; Graphics.Blit (src, buffer0); / / the number of Gaussian blur iterations for (int iS0; I
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.