protected internal override void OnLoad() { base.OnLoad(); renderTexture = new RenderTexture(MMW.RenderResolution); renderTexture.MagFilter = TextureMagFilter.Linear; renderTexture.MinFilter = TextureMinFilter.Linear; renderTexture.ColorFormat0 = MMW.Configuration.DefaultPixelFormat; renderTexture.Load(); dofShader = (DoFShader)MMW.GetAsset <Shader>("DoF"); if (dofShader == null) { dofShader = new DoFShader(); MMW.RegistAsset(dofShader); } if (GameObject != null) { Camera = GameObject.GetComponent <Camera>(); RenderTexture = Camera.TargetTexture; } blurRT = new RenderTexture(MMW.RenderResolution); blurRT.ColorFormat0 = MMW.Configuration.DefaultPixelFormat; blurRT.Load(); blur = new Blur(4.0f, 2); blur.OnLoad(); blur.RenderTexture = blurRT; orthoMatrix = Matrix4.CreateOrthographicOffCenter(-1, 1, -1, 1, -1, 1); }
protected internal override void OnLoad() { base.OnLoad(); // 書き出しRT bloomRT = new RenderTexture(MMW.RenderResolution); bloomRT.MagFilter = TextureMagFilter.Linear; bloomRT.MinFilter = TextureMinFilter.Linear; bloomRT.ColorFormat0 = MMW.Configuration.DefaultPixelFormat; bloomRT.Load(); // HDR抽出RT hdrRT = new RenderTexture(MMW.RenderResolution); hdrRT.MagFilter = TextureMagFilter.Linear; hdrRT.MinFilter = TextureMinFilter.Linear; hdrRT.ColorFormat0 = MMW.Configuration.DefaultPixelFormat; hdrRT.Load(); // Blur適用RT blurRTs = new RenderTexture[BlurNum]; blurs = new Blur[BlurNum]; var blurSizes = new Size[] { new Size(MMW.RenderResolution.Width / 4, MMW.RenderResolution.Height / 4), new Size(MMW.RenderResolution.Width / 8, MMW.RenderResolution.Height / 8), new Size(MMW.RenderResolution.Width / 16, MMW.RenderResolution.Height / 16), new Size(MMW.RenderResolution.Width / 32, MMW.RenderResolution.Height / 32), new Size(MMW.RenderResolution.Width / 64, MMW.RenderResolution.Height / 64), }; for (var i = 0; i < BlurNum; i++) { var size = blurSizes[i]; if (size.Width < 128) { size.Width = 128; } if (size.Height < 128) { size.Height = 128; } blurRTs[i] = new RenderTexture(size); blurRTs[i].MagFilter = TextureMagFilter.Linear; blurRTs[i].MinFilter = TextureMinFilter.Linear; blurRTs[i].WrapMode = TextureWrapMode.ClampToEdge; blurRTs[i].ColorFormat0 = MMW.Configuration.DefaultPixelFormat; blurRTs[i].Load(); blurs[i] = new Blur(Radius, 1); blurs[i].RenderTexture = blurRTs[i]; blurs[i].OnLoad(); } // HDR抽出シェーダ hdrShader = (ExtractHDRShader)MMW.GetAsset <Shader>("Extract HDR"); if (hdrShader == null) { hdrShader = new ExtractHDRShader(); MMW.RegistAsset(hdrShader); } // Bloomシェーダ bloomShader = (BloomShader)MMW.GetAsset <Shader>("Bloom"); if (bloomShader == null) { bloomShader = new BloomShader(); MMW.RegistAsset(bloomShader); } if (GameObject != null) { Camera = GameObject.GetComponent <Camera>(); RenderTexture = Camera.TargetTexture; } orthoMatrix = Matrix4.CreateOrthographicOffCenter(-1, 1, -1, 1, -1, 1); }