Created
August 13, 2014 10:38
-
-
Save sugi-cho/fab5424d8d9e0929bce2 to your computer and use it in GitHub Desktop.
generate blur renderTexture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void GetBlurTex(RenderTexture targetTexture, int iteration, int ds){ | |
RenderTexture rt = targetTexture; | |
float | |
widthMod = 1f / (1f * (1 << ds)); | |
int | |
rtW = rt.width, | |
rtH = rt.height; | |
for(int i = 0; i < iteration; i++){ | |
float iterationOffs = (float)i; | |
bMat.SetVector("_Parameter", new Vector4(bSize * widthMod + iterationOffs, -bSize * widthMod - iterationOffs, 0, 0)); | |
RenderTexture rt2 = RenderTexture.GetTemporary(rtW, rtH, 0, rt.format); | |
rt2.filterMode = FilterMode.Bilinear; | |
Graphics.Blit(rt, rt2, bMat, 1); | |
RenderTexture.ReleaseTemporary(rt); | |
rt = rt2; | |
rt2 = RenderTexture.GetTemporary(rtW, rtH, 0, rt.format); | |
rt2.filterMode = FilterMode.Bilinear; | |
Graphics.Blit(rt, rt2, bMat, 2); | |
RenderTexture.ReleaseTemporary(rt); | |
rt = rt2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment