public Shader gaussianBlurShader; private Material gaussianBlurMaterial = null;
public Material material { get { gaussianBlurMaterial = CheckShaderAndCreateMaterial(gaussianBlurShader, gaussianBlurMaterial); return gaussianBlurMaterial; } }
// Blur iterations - larger number means more blur. //迭代次数,模糊范围,缩放系数 [Range(0, 4)] publicint iterations = 3; // Blur spread for each iteration - larger value means more blur [Range(0.2f, 3.0f)] publicfloat blurSpread = 0.6f; [Range(1, 8)] publicint downSample = 2; /// 1st edition: just apply blur // void OnRenderImage(RenderTexture src, RenderTexture dest) { // if (material != null) { // int rtW = src.width; // int rtH = src.height; //通过该函数分配了一块与屏幕图像大小相同的缓冲区,用来存放第一个pass的结果 // RenderTexture buffer = RenderTexture.GetTemporary(rtW, rtH, 0); // // // Render the vertical pass // Graphics.Blit(src, buffer, material, 0); // // Render the horizontal pass // Graphics.Blit(buffer, dest, material, 1); // // RenderTexture.ReleaseTemporary(buffer); // } else { // Graphics.Blit(src, dest); // } // }