public override void OnRender() { if (mCacheRT == null) { mCacheRT = RenderTexture.GetTemporary(mContext.CurrentRenderRT.descriptor); } if (mBloomAreaRT == null) { mBloomAreaRT = RenderTexture.GetTemporary(mContext.CurrentRenderRT.descriptor); } if (mBloomBlur1RT == null) { var descriptor = mContext.CurrentRenderRT.descriptor; mBloomBlur1RT = RenderTexture.GetTemporary(descriptor.width >> 1, descriptor.height >> 1, descriptor.depthBufferBits, descriptor.colorFormat); } if (mBloomBlur2RT == null) { var descriptor = mContext.CurrentRenderRT.descriptor; mBloomBlur2RT = RenderTexture.GetTemporary(descriptor.width >> 1, descriptor.height >> 1, descriptor.depthBufferBits, descriptor.colorFormat); } StarGlowMaterial.SetFloat(mStreak_Length_ID, Model.streak_Length); StarGlowMaterial.SetFloat(mThreshold_ID, Model.threshold); Graphics.Blit(mContext.CurrentRenderRT, mCacheRT); //-----------------------------------------------------------Mode0. StarGlowMaterial.SetFloat(mMode_ID, 0); Graphics.Blit(mContext.CurrentRenderRT, mBloomAreaRT, StarGlowMaterial, PASS2_EXTRACTHDR); Graphics.Blit(mBloomAreaRT, mBloomBlur1RT, StarGlowMaterial, PASS1_XBLUR); Graphics.Blit(mBloomBlur1RT, mBloomBlur2RT, StarGlowMaterial, PASS1_XBLUR); Graphics.Blit(mBloomBlur2RT, mBloomBlur1RT, StarGlowMaterial, PASS1_XBLUR); StarGlowMaterial.SetTexture(mBloomTex_ID, mBloomBlur1RT); Graphics.Blit(mContext.CurrentRenderRT, mCacheRT, StarGlowMaterial, PASS0_BASS); Graphics.Blit(mCacheRT, mContext.CurrentRenderRT); //-------------------------------------------------------------------. //-----------------------------------------------------------Mode1. StarGlowMaterial.SetFloat(mMode_ID, 1); Graphics.Blit(mBloomAreaRT, mBloomBlur1RT, StarGlowMaterial, PASS1_XBLUR); Graphics.Blit(mBloomBlur1RT, mBloomBlur2RT, StarGlowMaterial, PASS1_XBLUR); Graphics.Blit(mBloomBlur2RT, mBloomBlur1RT, StarGlowMaterial, PASS1_XBLUR); StarGlowMaterial.SetTexture(mBloomTex_ID, mBloomBlur1RT); Graphics.Blit(mContext.CurrentRenderRT, mCacheRT, StarGlowMaterial, PASS0_BASS); Graphics.Blit(mCacheRT, mContext.CurrentRenderRT); //-------------------------------------------------------------------. }
public override void OnEnable() { base.OnEnable(); mStreak_Length_ID = Shader.PropertyToID("_Streak_Length"); mBloomTex_ID = Shader.PropertyToID("_BloomTex"); mMode_ID = Shader.PropertyToID("_Mode"); mThreshold_ID = Shader.PropertyToID("_Threshold"); StarGlowMaterial.SetFloat("_StarGlowTexOverlayAlpha", 0.5f); }