示例#1
0
            protected override void OnDraw(asd.RenderTexture2D dst, asd.RenderTexture2D src)
            {
                m_material2d.SetTexture2D("g_texture", src);
                m_material2d.SetVector3DF("g_values", new Vector3DF(640, 480, 200));

                DrawOnTexture2DWithMaterial(dst, m_material2d);
            }
示例#2
0
文件: Layer.cs 项目: wraikny/Altseed
        internal void EndDrawing()
        {
            if (!IsAlive)
            {
                return;
            }

            CoreLayer.EndDrawing();

            if (postEffects.Count > 0)
            {
                foreach (var p in postEffects)
                {
                    if (!p.IsEnabled)
                    {
                        continue;
                    }

                    Scene.CoreInstance.BeginPostEffect(p.CoreInstance);

                    var src_ = Scene.CoreInstance.GetSrcTarget();
                    var dst_ = Scene.CoreInstance.GetDstTarget();

                    RenderTexture2D src = GC.GenerateRenderTexture2D(src_, GenerationType.Get);
                    RenderTexture2D dst = GC.GenerateRenderTexture2D(dst_, GenerationType.Get);

                    p.Draw(dst, src);

                    Scene.CoreInstance.EndPostEffect(p.CoreInstance);
                }
            }
        }
示例#3
0
 static public swig.RenderTexture2D GetRenderTexture2D(RenderTexture2D o)
 {
     if (o == null)
     {
         return(null);
     }
     return((swig.RenderTexture2D)o.CoreInstance);
 }
示例#4
0
        internal void Draw(RenderTexture2D dst, RenderTexture2D src)
        {
            if (disposed)
            {
                throw new ObjectDisposedException(GetType().FullName);
            }

            OnDraw(dst, src);
        }
示例#5
0
        /// <summary>
        /// マテリアルを用いてテクスチャに画像を描画する。
        /// </summary>
        /// <param name="target">描画先</param>
        /// <param name="material">マテリアル</param>
        protected void DrawOnTexture2DWithMaterial(RenderTexture2D target, Material2D material)
        {
            if (disposed)
            {
                throw new ObjectDisposedException(GetType().FullName);
            }

            coreInstance.DrawOnTexture2DWithMaterial(IG.GetRenderTexture2D(target), IG.GetMaterial2D(material));
        }
示例#6
0
        protected override void OnDraw(RenderTexture2D dst, RenderTexture2D src)
        {
            Vector3DF weights = new Vector3DF();

            float[] ws         = new float[3];
            float   total      = 0.0f;
            float   dispersion = intensity * intensity;

            for (int i = 0; i < 3; i++)
            {
                float pos = 1.0f + 2.0f * i;
                ws[i]  = (float)Math.Exp(-0.5f * pos * pos / dispersion);
                total += ws[i] * 2.0f;
            }
            weights.X = ws[0] / total;
            weights.Y = ws[1] / total;
            weights.Z = ws[2] / total;

            material2dX.SetTexture2D("g_texture", src);
            material2dX.SetVector3DF("g_weight", weights);
            material2dX.SetTextureFilterType("g_texture", TextureFilterType.Linear);

            var size   = src.Size;
            var format = src.Format;

            if (tempTexture == null ||
                (!tempTexture.Size.Equals(size) ||
                 tempTexture.Format != format))
            {
                if (format == TextureFormat.R32G32B32A32_FLOAT)
                {
                    tempTexture = Engine.Graphics.CreateRenderTexture2D(size.X, size.Y, TextureFormat.R32G32B32A32_FLOAT);
                }
                else
                {
                    tempTexture = Engine.Graphics.CreateRenderTexture2D(size.X, size.Y, TextureFormat.R8G8B8A8_UNORM);
                }
            }

            DrawOnTexture2DWithMaterial(tempTexture, material2dX);

            material2dY.SetTexture2D("g_texture", tempTexture);
            material2dY.SetVector3DF("g_weight", weights);
            material2dY.SetTextureFilterType("g_texture", TextureFilterType.Linear);

            DrawOnTexture2DWithMaterial(dst, material2dY);
        }
示例#7
0
        /// <summary>
        /// 描画先として指定可能なテクスチャを生成する。
        /// </summary>
        /// <param name="width">横幅</param>
        /// <param name="height">縦幅</param>
        /// <param name="format">フォーマット</param>
        /// <returns>テクスチャ</returns>
        public RenderTexture2D CreateRenderTexture2D(int width, int height, TextureFormat format)
        {
            var rt = CoreInstance.CreateRenderTexture2D_Imp(width, height, (swig.TextureFormat)format);
            var p  = rt.GetPtr();

            var existing = GC.Texture2Ds.GetObject(p);

            if (existing != null)
            {
                return((RenderTexture2D)existing);
            }

            var ret = new RenderTexture2D(rt);

            GC.Texture2Ds.AddObject(p, ret);
            return(ret);
        }
示例#8
0
        public override void OnDraw(RenderTexture2D dst, RenderTexture2D src)
        {
            Vector3DF weights = new Vector3DF();
            float[] ws = new float[3];
            float total = 0.0f;
            float dispersion = intensity * intensity;
            for (int i = 0; i < 3; i++)
            {
                float pos = 1.0f + 2.0f * i;
                ws[i] = (float)Math.Exp(-0.5f * pos * pos / dispersion);
                total += ws[i] * 2.0f;
            }
            weights.X = ws[0] / total;
            weights.Y = ws[1] / total;
            weights.Z = ws[2] / total;

            material2dX.SetTexture2D("g_texture", src);
            material2dX.SetVector3DF("g_weight", weights);
            material2dX.SetTextureFilterType("g_texture", TextureFilterType.Linear);

            var size = src.Size;
            var format = src.Format;

            if (tempTexture == null ||
                (tempTexture.Size != size || tempTexture.Format != format))
            {
                if (format == TextureFormat.R32G32B32A32_FLOAT)
                {
                    tempTexture = Engine.Graphics.CreateRenderTexture2D(size.X, size.Y, TextureFormat.R32G32B32A32_FLOAT);
                }
                else
                {
                    tempTexture = Engine.Graphics.CreateRenderTexture2D(size.X, size.Y, TextureFormat.R8G8B8A8_UNORM);
                }
            }

            DrawOnTexture2DWithMaterial(tempTexture, material2dX);

            material2dY.SetTexture2D("g_texture", tempTexture);
            material2dY.SetVector3DF("g_weight", weights);
            material2dY.SetTextureFilterType("g_texture", TextureFilterType.Linear);

            DrawOnTexture2DWithMaterial(dst, material2dY);
        }
示例#9
0
        /// <summary>
        /// ネイティブのインスタンスからラッパー側のインスタンスを生成する。
        /// </summary>
        /// <param name="o"></param>
        /// <param name="type"></param>
        internal static RenderTexture2D GenerateRenderTexture2D(swig.RenderTexture2D o, GenerationType type)
        {
            if (o == null)
            {
                return(null);
            }
            var p = o.GetPtr();

            var existing = GC.Texture2Ds.GetObject(p);

            existing = GenerateInternal(existing, o, type);
            if (existing != null)
            {
                return((RenderTexture2D)existing);
            }

            var ret = new RenderTexture2D(o);

            GC.Texture2Ds.AddObject(p, ret);
            return(ret);
        }
示例#10
0
文件: Layer.cs 项目: neofuji/Altseed
        internal void EndDrawing()
        {
            commonObject.EndDrawing();

            if (postEffects.Count > 0)
            {
                foreach (var p in postEffects)
                {
                    Scene.CoreScene.BeginPostEffect(p.SwigObject);

                    var src_ = Scene.CoreScene.GetSrcTarget();
                    var dst_ = Scene.CoreScene.GetDstTarget();

                    RenderTexture2D src = GC.GenerateRenderTexture2D(src_, GC.GenerationType.Get);
                    RenderTexture2D dst = GC.GenerateRenderTexture2D(dst_, GC.GenerationType.Get);

                    p.OnDraw(dst, src);

                    Scene.CoreScene.EndPostEffect(p.SwigObject);
                }
            }
        }
示例#11
0
        internal override void OnUpdateInternal()
        {
            coreObject.StartAddingPostEffect(postEffects.Count);

            int count = 0;

            foreach (var p in postEffects)
            {
                coreObject.BeginPostEffect(p.CoreInstance);

                var src_ = coreObject.GetSrcForPostEffect(count);
                var dst_ = coreObject.GetDstForPostEffect(count);

                RenderTexture2D src = GC.GenerateRenderTexture2D(src_, GenerationType.Get);
                RenderTexture2D dst = GC.GenerateRenderTexture2D(dst_, GenerationType.Get);

                p.Draw(dst, src);

                coreObject.EndPostEffect(p.CoreInstance);

                count++;
            }
        }
示例#12
0
 /**
  * @brief
  */
 /// <summary>
 /// オーバーライドして、毎フレーム描画される処理を記述できる。
 /// </summary>
 public virtual void OnDraw(RenderTexture2D dst, RenderTexture2D src)
 {
 }
示例#13
0
 /// <summary>
 /// マテリアルを用いてテクスチャに画像を描画する。
 /// </summary>
 /// <param name="target">描画先</param>
 /// <param name="material">マテリアル</param>
 public void DrawOnTexture2DWithMaterial(RenderTexture2D target, Material2D material)
 {
     SwigObject.DrawOnTexture2DWithMaterial(IG.GetRenderTexture2D(target), IG.GetMaterial2D(material));
 }
示例#14
0
        public override void OnDraw(RenderTexture2D dst, RenderTexture2D src)
        {
            Vector4DF weights1 = new Vector4DF();
            Vector4DF weights2 = new Vector4DF();

            float[] ws = new float[8];
            float total = 0.0f;
            float dispersion = intensity * intensity;
            for (int i = 0; i < 8; i++)
            {
                float pos = 1.0f + 2.0f * i;
                ws[i] = (float)Math.Exp(-0.5f * pos * pos / dispersion);
                total += ws[i] * 2.0f;
            }
            weights1.X = ws[0] / total;
            weights1.Y = ws[1] / total;
            weights1.Z = ws[2] / total;
            weights1.W = ws[3] / total;
            weights2.X = ws[4] / total;
            weights2.Y = ws[5] / total;
            weights2.Z = ws[6] / total;
            weights2.W = ws[7] / total;

            var size = src.Size;
            var format = src.Format;

            if (tempTexture0 == null ||
                (tempTexture0.Size != size / 2 || tempTexture0.Format != format))
            {
                if (format == TextureFormat.R32G32B32A32_FLOAT)
                {
                    tempTexture0 = Engine.Graphics.CreateRenderTexture2D(size.X / 2, size.Y / 2, TextureFormat.R32G32B32A32_FLOAT);
                    tempTexture1 = Engine.Graphics.CreateRenderTexture2D(size.X / 4, size.Y / 4, TextureFormat.R32G32B32A32_FLOAT);
                    tempTexture2 = Engine.Graphics.CreateRenderTexture2D(size.X / 8, size.Y / 8, TextureFormat.R32G32B32A32_FLOAT);
                    tempTexture3 = Engine.Graphics.CreateRenderTexture2D(size.X / 16, size.Y / 16, TextureFormat.R32G32B32A32_FLOAT);

                    downsampledTexture0 = Engine.Graphics.CreateRenderTexture2D(size.X / 2, size.Y / 2, TextureFormat.R32G32B32A32_FLOAT);
                    downsampledTexture1 = Engine.Graphics.CreateRenderTexture2D(size.X / 4, size.Y / 4, TextureFormat.R32G32B32A32_FLOAT);
                    downsampledTexture2 = Engine.Graphics.CreateRenderTexture2D(size.X / 8, size.Y / 8, TextureFormat.R32G32B32A32_FLOAT);
                    downsampledTexture3 = Engine.Graphics.CreateRenderTexture2D(size.X / 16, size.Y / 16, TextureFormat.R32G32B32A32_FLOAT);
                }
                else
                {
                    tempTexture0 = Engine.Graphics.CreateRenderTexture2D(size.X / 2, size.Y / 2, TextureFormat.R8G8B8A8_UNORM);
                    tempTexture1 = Engine.Graphics.CreateRenderTexture2D(size.X / 4, size.Y / 4, TextureFormat.R8G8B8A8_UNORM);
                    tempTexture2 = Engine.Graphics.CreateRenderTexture2D(size.X / 8, size.Y / 8, TextureFormat.R8G8B8A8_UNORM);
                    tempTexture3 = Engine.Graphics.CreateRenderTexture2D(size.X / 16, size.Y / 16, TextureFormat.R8G8B8A8_UNORM);

                    downsampledTexture0 = Engine.Graphics.CreateRenderTexture2D(size.X / 2, size.Y / 2, TextureFormat.R8G8B8A8_UNORM);
                    downsampledTexture1 = Engine.Graphics.CreateRenderTexture2D(size.X / 4, size.Y / 4, TextureFormat.R8G8B8A8_UNORM);
                    downsampledTexture2 = Engine.Graphics.CreateRenderTexture2D(size.X / 8, size.Y / 8, TextureFormat.R8G8B8A8_UNORM);
                    downsampledTexture3 = Engine.Graphics.CreateRenderTexture2D(size.X / 16, size.Y / 16, TextureFormat.R8G8B8A8_UNORM);
                }
            }

            downsample.SetTexture2D("g_texture", src);
            downsample.SetTextureFilterType("g_texture", TextureFilterType.Linear);
            downsample.SetVector2DF("g_offset", new Vector2DF(1.0f / (float)size.X, 1.0f / (float)size.Y));
            DrawOnTexture2DWithMaterial(downsampledTexture0, downsample);

            downsample.SetTexture2D("g_texture", downsampledTexture0);
            downsample.SetTextureFilterType("g_texture", TextureFilterType.Linear);
            downsample.SetVector2DF("g_offset", new Vector2DF(2.0f / (float)size.X, 2.0f / (float)size.Y));
            DrawOnTexture2DWithMaterial(downsampledTexture1, downsample);

            downsample.SetTexture2D("g_texture", downsampledTexture1);
            downsample.SetTextureFilterType("g_texture", TextureFilterType.Linear);
            downsample.SetVector2DF("g_offset", new Vector2DF(4.0f / (float)size.X, 4.0f / (float)size.Y));
            DrawOnTexture2DWithMaterial(downsampledTexture2, downsample);

            downsample.SetTexture2D("g_texture", downsampledTexture2);
            downsample.SetTextureFilterType("g_texture", TextureFilterType.Linear);
            downsample.SetVector2DF("g_offset", new Vector2DF(8.0f / (float)size.X, 8.0f / (float)size.Y));
            DrawOnTexture2DWithMaterial(downsampledTexture3, downsample);

            Material2D blurX = null;
            if (isLuminanceMode)
            {
                blurX = material2dX_Lum;
            }
            else
            {
                blurX = material2dX;
            }

            // ブラー1
            blurX.SetTexture2D("g_blurredTexture", downsampledTexture1);
            blurX.SetVector4DF("g_weight1", weights1);
            blurX.SetVector4DF("g_weight2", weights2);
            blurX.SetFloat("g_threshold", threshold);
            blurX.SetFloat("g_exposure", exposure);
            blurX.SetTextureFilterType("g_blurredTexture", TextureFilterType.Linear);
            DrawOnTexture2DWithMaterial(tempTexture1, blurX);

            material2dY.SetTexture2D("g_blurredTexture", tempTexture1);
            material2dY.SetVector4DF("g_weight1", weights1);
            material2dY.SetVector4DF("g_weight2", weights2);
            material2dY.SetTextureFilterType("g_blurredTexture", TextureFilterType.Linear);
            DrawOnTexture2DWithMaterial(downsampledTexture1, material2dY);

            // ブラー2
            blurX.SetTexture2D("g_blurredTexture", downsampledTexture2);
            blurX.SetVector4DF("g_weight1", weights1);
            blurX.SetVector4DF("g_weight2", weights2);
            blurX.SetFloat("g_threshold", threshold);
            blurX.SetFloat("g_exposure", exposure);
            blurX.SetTextureFilterType("g_blurredTexture", TextureFilterType.Linear);
            DrawOnTexture2DWithMaterial(tempTexture2, blurX);

            material2dY.SetTexture2D("g_blurredTexture", tempTexture2);
            material2dY.SetVector4DF("g_weight1", weights1);
            material2dY.SetVector4DF("g_weight2", weights2);
            material2dY.SetTextureFilterType("g_blurredTexture", TextureFilterType.Linear);
            DrawOnTexture2DWithMaterial(downsampledTexture2, material2dY);

            // ブラー3
            blurX.SetTexture2D("g_blurredTexture", downsampledTexture3);
            blurX.SetVector4DF("g_weight1", weights1);
            blurX.SetVector4DF("g_weight2", weights2);
            blurX.SetFloat("g_threshold", threshold);
            blurX.SetFloat("g_exposure", exposure);
            blurX.SetTextureFilterType("g_blurredTexture", TextureFilterType.Linear);
            DrawOnTexture2DWithMaterial(tempTexture3, blurX);

            material2dY.SetTexture2D("g_blurredTexture", tempTexture3);
            material2dY.SetVector4DF("g_weight1", weights1);
            material2dY.SetVector4DF("g_weight2", weights2);
            material2dY.SetTextureFilterType("g_blurredTexture", TextureFilterType.Linear);
            DrawOnTexture2DWithMaterial(downsampledTexture3, material2dY);

            // 合計
            materialSum.SetTexture2D("g_blurred0Texture", downsampledTexture1);
            materialSum.SetTexture2D("g_blurred1Texture", downsampledTexture2);
            materialSum.SetTexture2D("g_blurred2Texture", downsampledTexture3);
            materialSum.SetTexture2D("g_originalTexture", src);
            materialSum.SetTextureFilterType("g_blurred0Texture", TextureFilterType.Linear);
            materialSum.SetTextureFilterType("g_blurred1Texture", TextureFilterType.Linear);
            materialSum.SetTextureFilterType("g_blurred2Texture", TextureFilterType.Linear);
            materialSum.SetTextureFilterType("g_originalTexture", TextureFilterType.Linear);

            DrawOnTexture2DWithMaterial(dst, materialSum);
        }
示例#15
0
 /**
 @brief
 */
 /// <summary>
 /// オーバーライドして、毎フレーム描画される処理を記述できる。
 /// </summary>
 public virtual void OnDraw(RenderTexture2D dst, RenderTexture2D src)
 {
 }
示例#16
0
        /// <summary>
        /// 描画先として指定可能なテクスチャを生成する。
        /// </summary>
        /// <param name="width">横幅</param>
        /// <param name="height">縦幅</param>
        /// <param name="format">フォーマット</param>
        /// <returns>テクスチャ</returns>
        public RenderTexture2D CreateRenderTexture2D(int width, int height, TextureFormat format)
        {
            var rt = graphics.CreateRenderTexture2D_Imp(width,height, (swig.TextureFormat)format);
            var p = rt.GetPtr();

            var existing = GC.Texture2Ds.GetObject(p);
            if (existing != null)
            {
                return (RenderTexture2D)existing;
            }

            var ret = new RenderTexture2D(rt);
            GC.Texture2Ds.AddObject(p, ret);
            return ret;
        }
示例#17
0
 public override void OnDraw(RenderTexture2D dst, RenderTexture2D src)
 {
     material2d.SetTexture2D("g_texture", src);
     DrawOnTexture2DWithMaterial(dst, material2d);
 }
示例#18
0
        public override void OnDraw(RenderTexture2D dst, RenderTexture2D src)
        {
            Vector4DF weights1 = new Vector4DF();
            Vector4DF weights2 = new Vector4DF();

            float[] ws         = new float[8];
            float   total      = 0.0f;
            float   dispersion = intensity * intensity;

            for (int i = 0; i < 8; i++)
            {
                float pos = 1.0f + 2.0f * i;
                ws[i]  = (float)Math.Exp(-0.5f * pos * pos / dispersion);
                total += ws[i] * 2.0f;
            }
            weights1.X = ws[0] / total;
            weights1.Y = ws[1] / total;
            weights1.Z = ws[2] / total;
            weights1.W = ws[3] / total;
            weights2.X = ws[4] / total;
            weights2.Y = ws[5] / total;
            weights2.Z = ws[6] / total;
            weights2.W = ws[7] / total;

            var size   = src.Size;
            var format = src.Format;

            if (tempTexture0 == null ||
                (tempTexture0.Size != size / 2 || tempTexture0.Format != format))
            {
                if (format == TextureFormat.R32G32B32A32_FLOAT)
                {
                    tempTexture0 = Engine.Graphics.CreateRenderTexture2D(size.X / 2, size.Y / 2, TextureFormat.R32G32B32A32_FLOAT);
                    tempTexture1 = Engine.Graphics.CreateRenderTexture2D(size.X / 4, size.Y / 4, TextureFormat.R32G32B32A32_FLOAT);
                    tempTexture2 = Engine.Graphics.CreateRenderTexture2D(size.X / 8, size.Y / 8, TextureFormat.R32G32B32A32_FLOAT);
                    tempTexture3 = Engine.Graphics.CreateRenderTexture2D(size.X / 16, size.Y / 16, TextureFormat.R32G32B32A32_FLOAT);

                    downsampledTexture0 = Engine.Graphics.CreateRenderTexture2D(size.X / 2, size.Y / 2, TextureFormat.R32G32B32A32_FLOAT);
                    downsampledTexture1 = Engine.Graphics.CreateRenderTexture2D(size.X / 4, size.Y / 4, TextureFormat.R32G32B32A32_FLOAT);
                    downsampledTexture2 = Engine.Graphics.CreateRenderTexture2D(size.X / 8, size.Y / 8, TextureFormat.R32G32B32A32_FLOAT);
                    downsampledTexture3 = Engine.Graphics.CreateRenderTexture2D(size.X / 16, size.Y / 16, TextureFormat.R32G32B32A32_FLOAT);
                }
                else
                {
                    tempTexture0 = Engine.Graphics.CreateRenderTexture2D(size.X / 2, size.Y / 2, TextureFormat.R8G8B8A8_UNORM);
                    tempTexture1 = Engine.Graphics.CreateRenderTexture2D(size.X / 4, size.Y / 4, TextureFormat.R8G8B8A8_UNORM);
                    tempTexture2 = Engine.Graphics.CreateRenderTexture2D(size.X / 8, size.Y / 8, TextureFormat.R8G8B8A8_UNORM);
                    tempTexture3 = Engine.Graphics.CreateRenderTexture2D(size.X / 16, size.Y / 16, TextureFormat.R8G8B8A8_UNORM);

                    downsampledTexture0 = Engine.Graphics.CreateRenderTexture2D(size.X / 2, size.Y / 2, TextureFormat.R8G8B8A8_UNORM);
                    downsampledTexture1 = Engine.Graphics.CreateRenderTexture2D(size.X / 4, size.Y / 4, TextureFormat.R8G8B8A8_UNORM);
                    downsampledTexture2 = Engine.Graphics.CreateRenderTexture2D(size.X / 8, size.Y / 8, TextureFormat.R8G8B8A8_UNORM);
                    downsampledTexture3 = Engine.Graphics.CreateRenderTexture2D(size.X / 16, size.Y / 16, TextureFormat.R8G8B8A8_UNORM);
                }
            }

            downsample.SetTexture2D("g_texture", src);
            downsample.SetTextureFilterType("g_texture", TextureFilterType.Linear);
            downsample.SetVector2DF("g_offset", new Vector2DF(1.0f / (float)size.X, 1.0f / (float)size.Y));
            DrawOnTexture2DWithMaterial(downsampledTexture0, downsample);

            downsample.SetTexture2D("g_texture", downsampledTexture0);
            downsample.SetTextureFilterType("g_texture", TextureFilterType.Linear);
            downsample.SetVector2DF("g_offset", new Vector2DF(2.0f / (float)size.X, 2.0f / (float)size.Y));
            DrawOnTexture2DWithMaterial(downsampledTexture1, downsample);

            downsample.SetTexture2D("g_texture", downsampledTexture1);
            downsample.SetTextureFilterType("g_texture", TextureFilterType.Linear);
            downsample.SetVector2DF("g_offset", new Vector2DF(4.0f / (float)size.X, 4.0f / (float)size.Y));
            DrawOnTexture2DWithMaterial(downsampledTexture2, downsample);

            downsample.SetTexture2D("g_texture", downsampledTexture2);
            downsample.SetTextureFilterType("g_texture", TextureFilterType.Linear);
            downsample.SetVector2DF("g_offset", new Vector2DF(8.0f / (float)size.X, 8.0f / (float)size.Y));
            DrawOnTexture2DWithMaterial(downsampledTexture3, downsample);

            Material2D blurX = null;

            if (isLuminanceMode)
            {
                blurX = material2dX_Lum;
            }
            else
            {
                blurX = material2dX;
            }

            // ブラー1
            blurX.SetTexture2D("g_blurredTexture", downsampledTexture1);
            blurX.SetVector4DF("g_weight1", weights1);
            blurX.SetVector4DF("g_weight2", weights2);
            blurX.SetFloat("g_threshold", threshold);
            blurX.SetFloat("g_exposure", exposure);
            blurX.SetTextureFilterType("g_blurredTexture", TextureFilterType.Linear);
            DrawOnTexture2DWithMaterial(tempTexture1, blurX);

            material2dY.SetTexture2D("g_blurredTexture", tempTexture1);
            material2dY.SetVector4DF("g_weight1", weights1);
            material2dY.SetVector4DF("g_weight2", weights2);
            material2dY.SetTextureFilterType("g_blurredTexture", TextureFilterType.Linear);
            DrawOnTexture2DWithMaterial(downsampledTexture1, material2dY);

            // ブラー2
            blurX.SetTexture2D("g_blurredTexture", downsampledTexture2);
            blurX.SetVector4DF("g_weight1", weights1);
            blurX.SetVector4DF("g_weight2", weights2);
            blurX.SetFloat("g_threshold", threshold);
            blurX.SetFloat("g_exposure", exposure);
            blurX.SetTextureFilterType("g_blurredTexture", TextureFilterType.Linear);
            DrawOnTexture2DWithMaterial(tempTexture2, blurX);

            material2dY.SetTexture2D("g_blurredTexture", tempTexture2);
            material2dY.SetVector4DF("g_weight1", weights1);
            material2dY.SetVector4DF("g_weight2", weights2);
            material2dY.SetTextureFilterType("g_blurredTexture", TextureFilterType.Linear);
            DrawOnTexture2DWithMaterial(downsampledTexture2, material2dY);

            // ブラー3
            blurX.SetTexture2D("g_blurredTexture", downsampledTexture3);
            blurX.SetVector4DF("g_weight1", weights1);
            blurX.SetVector4DF("g_weight2", weights2);
            blurX.SetFloat("g_threshold", threshold);
            blurX.SetFloat("g_exposure", exposure);
            blurX.SetTextureFilterType("g_blurredTexture", TextureFilterType.Linear);
            DrawOnTexture2DWithMaterial(tempTexture3, blurX);

            material2dY.SetTexture2D("g_blurredTexture", tempTexture3);
            material2dY.SetVector4DF("g_weight1", weights1);
            material2dY.SetVector4DF("g_weight2", weights2);
            material2dY.SetTextureFilterType("g_blurredTexture", TextureFilterType.Linear);
            DrawOnTexture2DWithMaterial(downsampledTexture3, material2dY);

            // 合計
            materialSum.SetTexture2D("g_blurred0Texture", downsampledTexture1);
            materialSum.SetTexture2D("g_blurred1Texture", downsampledTexture2);
            materialSum.SetTexture2D("g_blurred2Texture", downsampledTexture3);
            materialSum.SetTexture2D("g_originalTexture", src);
            materialSum.SetTextureFilterType("g_blurred0Texture", TextureFilterType.Linear);
            materialSum.SetTextureFilterType("g_blurred1Texture", TextureFilterType.Linear);
            materialSum.SetTextureFilterType("g_blurred2Texture", TextureFilterType.Linear);
            materialSum.SetTextureFilterType("g_originalTexture", TextureFilterType.Linear);

            DrawOnTexture2DWithMaterial(dst, materialSum);
        }
示例#19
0
 /// <summary>
 /// マテリアルを用いてテクスチャに画像を描画する。
 /// </summary>
 /// <param name="target">描画先</param>
 /// <param name="material">マテリアル</param>
 public void DrawOnTexture2DWithMaterial(RenderTexture2D target, Material2D material)
 {
     SwigObject.DrawOnTexture2DWithMaterial(IG.GetRenderTexture2D(target), IG.GetMaterial2D(material));
 }
示例#20
0
 public override void OnDraw(RenderTexture2D dst, RenderTexture2D src)
 {
     material2d.SetTexture2D("g_texture", src);
     DrawOnTexture2DWithMaterial(dst, material2d);
 }
示例#21
0
 /**
  * @brief
  */
 /// <summary>
 /// オーバーライドして、毎フレーム描画される処理を記述できる。
 /// </summary>
 protected virtual void OnDraw(RenderTexture2D dst, RenderTexture2D src)
 {
 }
示例#22
0
 public static swig.RenderTexture2D GetRenderTexture2D(RenderTexture2D o)
 {
     if (o == null) return null;
     return (swig.RenderTexture2D)o.CoreInstance;
 }