Skip to content

Instantly share code, notes, and snippets.

@sugi-cho
Created August 13, 2014 10:38
Show Gist options
  • Save sugi-cho/fab5424d8d9e0929bce2 to your computer and use it in GitHub Desktop.
Save sugi-cho/fab5424d8d9e0929bce2 to your computer and use it in GitHub Desktop.
generate blur renderTexture
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