コード例 #1
0
ファイル: SWNodeRemap.cs プロジェクト: Hengle/ShaderWeaver
        public override void AfterLoad()
        {
            base.AfterLoad();
            if (GetChildTexture() != null)
            {
                texChildOrigin  = GetChildTexture();
                texChildResized = SWTextureProcess.TextureResize(texChildOrigin, data.resolution, data.resolution);
            }
            if (textureEx != null)
            {
                if (data.resolution != textureEx.width)
                {
                    data.reso = (SWTexResolution)SWDataNode.resoList.IndexOf(textureEx.width);
                }
            }


            if (data.rd != null && data.rd.l != null && data.rd.l.pts != null)
            {
                for (int i = 0; i < data.rd.l.pts.Count; i++)
                {
                    var           pData = data.rd.l.pts [i];
                    RemapWayPoint pt    = new RemapWayPoint();
                    pt.uv       = pData.uv;
                    pt.matArrow = new Material(SWEditorUI.GetShader("RectTRS"));
                    lineInfo.pts.Add(pt);
                }
            }
        }
コード例 #2
0
 void GoLine()
 {
     CalUV();
     SWTextureProcess.ProcessMask_DrawLine(node.texMask, lastUV, uv, brush);
     lastUV          = uv;
     node.data.dirty = true;
 }
コード例 #3
0
        protected void ApplyWand_Dropper()
        {
            if (SWCommon.GetMouseDown(0, false) && al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY)))
            {
                CalUV();
                var firstNode = LayerMask_WandDropperNode(node);
                if (firstNode.texture == null)
                {
                    return;
                }

                //	SWTexture2DEx _tex = SWTextureProcess.TextureResize (firstNode.texture, texWidth, texHeight);
                SWTexture2DEx _tex = SWTextureProcess.TextureResizeTRS(firstNode.texture, texWidth, texHeight, firstNode.data.effectData);

                if (brush.mode == SWBrushMode.wand)
                {
                    SWTextureProcess.ProcessMask_Wand(node.texMask, _tex, uv, brush, tolerance);
                }
                else if (brush.mode == SWBrushMode.dropper)
                {
                    SWTextureProcess.ProcessMask_Dropper(node.texMask, _tex, uv, brush, tolerance);
                }
                lastUV          = uv;
                node.data.dirty = true;
                hasFirstPoint   = false;
            }
        }
コード例 #4
0
        public void Process(Vector2 uv, float _tolerance)
        {
            tasks = new List <PixelCom>();
            map   = new int[texSrcWidth, texSrcHeight];



            tolerance = _tolerance;
            int index = SWTextureProcess.TexUV2Index(texSrcWidth, texSrcHeight, uv);
            int x     = 0;
            int y     = 0;

            SWTextureProcess.TexUV2Index(texSrcWidth, texSrcHeight, uv, ref x, ref y);

            AddTask(x, y, index);

            while (tasks.Count > 0)
            {
                var n = new List <PixelCom> (tasks);
                tasks.Clear();
                foreach (var item in n)
                {
                    PerPixel(item);
                }
            }

            MissionEnd();
        }
コード例 #5
0
        void DrawLine()
        {
            if (node.lineInfo.pts.Count <= 2)
            {
                rData.l.st = false;
            }

            RepaintGetDirty();
            if (LineEditMode())
            {
                LineEditUpdate();
            }
            else
            {
                LinePlaceUpdate();
            }
            DrawPoints();

            //Draw Cursor
            if (focusedWindow == this)
            {
                if (al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY)) && drawRect.Contains(mousePos))
                {
                    if (LineEditMode())
                    {
                        Cursor.visible = true;
                    }
                    else
                    {
                        GUI.DrawTexture(new Rect(mousePos.x - brushSize * 1f, mousePos.y - brushSize * 1f, brushSize * 2f, brushSize * 2f), SWEditorUI.Texture(SWUITex.cursor));
                        GUI.DrawTexture(new Rect(mousePos.x - 8, mousePos.y - 8, 16, 16), SWEditorUI.Texture(SWUITex.cursorCenter));
                        Cursor.visible = false;
                    }
                }
                else
                {
                    Cursor.visible = true;
                }
            }
            //Key Command
            if (Event.current.type == EventType.KeyDown)
            {
                if (Event.current.keyCode == KeyCode.Return)
                {
                    if (node.lineInfo.pts.Count <= 1)
                    {
                        return;
                    }
                    node.data.dirty = true;
                    SWTextureProcess.ProcessRemap_Line(node.textureEx, node.lineInfo, brushSizeUV);
                }


                if (Event.current.keyCode == KeyCode.C)
                {
                    SWUndo.Record(node.lineInfo);
                    node.lineInfo.pts.Clear();
                }
            }
        }
コード例 #6
0
 void GoPoint()
 {
     hasFirstPoint = true;
     CalUV();
     SWTextureProcess.ProcessMask_DrawPoint(node.texMask, uv, brush);
     lastUV          = uv;
     node.data.dirty = true;
 }
        protected void ThreadMission_Pixel2(int i, int j)
        {
            base.ThreadMission_Pixel(i, j);
            Vector2 uv = SWTextureProcess.TexUV(texWidth, texHeight, i, j);

            for (int k = 0; k < info.pts.Count; k++)
            {
                var   p0  = info.pts [SWTextureProcess.LoopID(k - 1, info.pts.Count)];
                var   p1  = info.pts [SWTextureProcess.LoopID(k, info.pts.Count)];
                var   p2  = info.pts [SWTextureProcess.LoopID(k + 1, info.pts.Count)];
                float pcg = SWTextureProcess.PointOnSegPcgSign(uv, p1.uv, p2.uv);
                pcg = p1.pcg + (p2.pcg - p1.pcg) * pcg;
//				float innerDis = 0;
//				bool seg = SWTextureProcess.Point2SegOnlyDisSign (uv, p1.after, p2.pre,ref innerDis);

                if (texColorBuffer [(texHeight - j - 1) * texWidth + i].b <= 0.5)
                {
                    float dis1 = SWTextureProcess.Point2SegDis(uv, p0.uv, p1.uv);
                    float dis2 = SWTextureProcess.Point2SegDis(uv, p1.uv, p2.uv);


                    bool e1 = Vector2.Dot(uv - p1.pre, p0.uv - p1.pre) < 0;
                    bool e2 = Vector2.Dot(uv - p1.after, p2.uv - p1.after) < 0;


                    if (e1 && e2 && (dis1 <= size || dis2 <= size))
                    {
                        Vector2 v1 = p1.pre - p1.center;
                        Vector2 v2 = uv - p1.center;
                        Vector2 v3 = p1.after - p1.center;

                        float angle1   = Vector2.Angle(v2, v1);
                        float angleAll = Vector2.Angle(v1, v3);

                        pcg = p1.prePcg + (p1.afterPcg - p1.prePcg) * angle1 / angleAll;



//						float disSigned1 = -SWTextureProcess.Point2LineDisSign (uv, p0.uv, p1.uv);
//						float disSigned2 = -SWTextureProcess.Point2LineDisSign (uv, p1.uv, p2.uv);
//						float disSigned = disSigned1 + (disSigned2 - disSigned1) * angle1 /angleAll;
                        //float g =  ( disSigned / size+1)*0.5f;
                        float g = 0;
                        if (SWCommon.AngleSigned(v3, v1, new Vector3(0, 0, 1)) < 0)
                        {
                            g = Vector2.Distance(uv, p1.center) / (size * 2);
                        }
                        else
                        {
                            g = 1 - Vector2.Distance(uv, p1.center) / (size * 2);
                        }
                        float b = (pcg > 0.995f || pcg < 0.005f)? 1:0;
                        float a = GreenToAlpha(g);
                        texColorBuffer [(texHeight - j - 1) * texWidth + i] = new Color(pcg, g, b, a);
                    }
                }
            }
        }
コード例 #8
0
        public void Process(Vector2 uv, float _tolerance)
        {
            int index = SWTextureProcess.TexUV2Index(texSrcWidth, texSrcHeight, uv);

            colors.Add(texSrcColorBuffer [index]);

            tolerance = _tolerance;
            Process();
        }
コード例 #9
0
        void UpdateRemapWayPoint(RemapWayPoint pt, Vector2 mPos)
        {
            Vector2 m = mPos - drawRect.position;
            //lsy : new remap ratio
            var uv = SWTextureProcess.TexUV_NoClamp(oMin, oMin, (int)m.x, (int)m.y);

            pt.uv       = uv;
            pt.mousePos = mPos;
        }
コード例 #10
0
        public override void KeyCmd_HotkeyUp(KeyCode code)
        {
            base.KeyCmd_HotkeyUp(code);

            if (code == KeyCode.I && Event.current.control)
            {
                SWTextureProcess.ProcessMask_Invert(node.texMask);
            }
        }
コード例 #11
0
 public override void AfterLoad()
 {
     base.AfterLoad();
     if (GetChildTexture() != null)
     {
         texChildOrigin  = GetChildTexture();
         texChildResized = SWTextureProcess.TextureResize(texChildOrigin, 512, 512);
     }
     DrawNodeWindowEnd();
 }
コード例 #12
0
        protected override void ThreadMission_Pixel(int i, int j)
        {
            int index = SWTextureProcess.XYtoIndex(texWidth, texHeight, i, j);

            texColorBuffer [index] = new Color(
                0,
                1 - texColorBuffer [index].g,
                0,
                1 - texColorBuffer [index].a);
        }
コード例 #13
0
 void CalUV()
 {
     uv = Event.current.mousePosition;
     //deviation:draw point is a little bit looks like below mouse center
     uv += new Vector2(0, -1f);
     uv  = uv - drawRect.position;
     SWTexThread_Tex.centerX = Mathf.RoundToInt(uv.x);
     SWTexThread_Tex.centerY = Mathf.RoundToInt(uv.y);
     uv = SWTextureProcess.TexUV(texWidth, texHeight, uv.x, uv.y);
 }
コード例 #14
0
        public void Process(RemapLineInfo _info, float _size)
        {
            info = _info;
            size = _size;

            info.pts [0].pcg = 0;
            info.pts [info.pts.Count - 1].pcg = 1;
            float len = 0;

            //step 1:Cal Point Pcg
            for (int i = 0; i < info.pts.Count - 1; i++)
            {
                len += Vector2.Distance(info.pts[i].uv, info.pts[i + 1].uv);
            }
            for (int i = 1; i < info.pts.Count - 1; i++)
            {
                float dis = Vector2.Distance(info.pts[i].uv, info.pts[i - 1].uv);
                info.pts [i].pcg = info.pts [i - 1].pcg + dis / len;
            }
            //step 2:before after pcg   center
            for (int k = 0; k < info.pts.Count; k++)
            {
                var p0 = info.pts [SWTextureProcess.LoopID(k - 1, info.pts.Count)].uv;
                var p1 = info.pts [SWTextureProcess.LoopID(k, info.pts.Count)].uv;
                var p2 = info.pts [SWTextureProcess.LoopID(k + 1, info.pts.Count)].uv;


                float angle = Vector2.Angle(p2 - p1, p0 - p1);
                float x     = 90 - angle * 0.5f;
                float width = size * Mathf.Tan(x * Mathf.Deg2Rad);
                info.pts[k].pre   = p1 + (p0 - p1).normalized * width;
                info.pts[k].after = p1 + (p2 - p1).normalized * width;



                var me   = info.pts [SWTextureProcess.LoopID(k, info.pts.Count)];
                var item = info.pts [SWTextureProcess.LoopID(k - 1, info.pts.Count)];

                float dis = Vector2.Distance(me.uv, item.uv);
                info.pts [k].prePcg = me.pcg + (item.pcg - me.pcg) * width / dis;
                item = info.pts [SWTextureProcess.LoopID(k + 1, info.pts.Count)];
                dis  = Vector2.Distance(me.uv, item.uv);
                info.pts [k].afterPcg = me.pcg + (item.pcg - me.pcg) * width / dis;


                float     angleSigned = SWCommon.AngleSigned(p2 - p1, p1 - p0, new Vector3(0, 0, 1));
                Vector2   vv          = p1 - p0;
                Matrix4x4 m           = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, Mathf.Sign(angleSigned) * -90), Vector3.one);
                vv = m.MultiplyVector(vv);
                info.pts[k].center = info.pts[k].pre + vv.normalized * size;
            }

            Process();
        }
コード例 #15
0
        void DrawLine()
        {
            //Add Point
            if (SWCommon.GetMouseDown(0) && al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY)))
            {
                if (!al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY)))
                {
                    return;
                }
                if (!drawRect.Contains(mousePos))
                {
                    return;
                }

                SWUndo.Record(info);
                Vector2 m = Event.current.mousePosition;
                m = m - drawRect.position;
                m = SWTextureProcess.TexUV(size, size, (int)m.x, (int)m.y);

                RemapWayPoint pt = new RemapWayPoint();
                pt.uv       = m;
                pt.mousePos = mousePos;
                pt.matArrow = new Material(SWEditorUI.GetShader("RectTRS"));
                info.pts.Add(pt);
            }

            DrawPoints();

            //Draw Cursor
            if (focusedWindow == this)
            {
                if (al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY)) && drawRect.Contains(mousePos))
                {
                    GUI.DrawTexture(new Rect(mousePos.x - brushSize * 1f, mousePos.y - brushSize * 1f, brushSize * 2f, brushSize * 2f), SWEditorUI.Texture(SWUITex.cursor));
                    GUI.DrawTexture(new Rect(mousePos.x - 8, mousePos.y - 8, 16, 16), SWEditorUI.Texture(SWUITex.cursorCenter));
                    Cursor.visible = false;
                }
                else
                {
                    Cursor.visible = true;
                }
            }
            //Key Command
            if (Event.current.type == EventType.keyDown)
            {
                if (Event.current.keyCode == KeyCode.Return)
                {
                    node.data.dirty = true;
                    SWTextureProcess.ProcessRemap_Line(node.textureEx, info, brushSizeUV);
                }
            }
        }
コード例 #16
0
        protected override void ThreadMission_Pixel(int i, int j)
        {
            base.ThreadMission_Pixel(i, j);
            var   cc = texSrcColorBuffer[(texSrcHeight - j - 1) * texSrcWidth + i];
            float m  = SWTextureProcess.Match(cc, colors);

            if (m <= tolerance)
            {
                //Vector2 _uv = TexUV (t_Width, t_Height, i, j);
                int index = SWTextureProcess.XYtoIndex(texSrcWidth, texSrcHeight, i, j);
                SWTextureProcess.Brush_ApplyOnce(ref texColorBuffer[index], brush, 0);
            }
        }
コード例 #17
0
        protected override void ThreadMission_Pixel(int i, int j)
        {
            base.ThreadMission_Pixel(i, j);
            Vector2 _uv   = SWTextureProcess.TexUV(texWidth, texHeight, i, j);
            float   dis   = SWTextureProcess.Point2SegDis(_uv, startUV, endUV);
            float   isize = (float)brush.size / (float)SWWindowDrawMask.size;

            if (dis < isize)
            {
                float disPcg = dis / isize;
                SWTextureProcess.Brush_Apply(ref texColorBuffer [(texHeight - j - 1) * texWidth + i], brush, disPcg, i, j);
            }
        }
コード例 #18
0
 public override void KeyCmd_Delete()
 {
     base.KeyCmd_Delete();
     SWUndo.Record(node.lineInfo);
     if (node.textureEx == null)
     {
         node.textureEx = SWCommon.TextureCreate(node.data.resolution, node.data.resolution, TextureFormat.ARGB32);
     }
     else
     {
         SWTextureProcess.ProcessTexture_Clean(node.textureEx);
     }
     RepaintGetDirty();
 }
コード例 #19
0
 protected static Color[] TextureResizeBase(Color[] colorsOrigin, int oldW, int oldH, int newW, int newH)
 {
     Color[] colorsNew = new Color[newW * newH];
     for (int i = 0; i < newW; i++)
     {
         for (int j = 0; j < newH; j++)
         {
             int     index = XYtoIndex(newW, newH, i, j);
             Vector2 uv    = SWTextureProcess.TexUV(newW, newH, i, j);
             colorsNew[index] = SWTextureProcess.GetColor_UV(oldW, oldH, colorsOrigin, uv);
         }
     }
     return(colorsNew);
 }
コード例 #20
0
 public override void KeyCmd_Delete()
 {
     base.KeyCmd_Delete();
     SWUndo.Record(info);
     if (node.textureEx == null)
     {
         node.textureEx = SWCommon.TextureCreate(512, 512, TextureFormat.ARGB32);
     }
     else
     {
         SWTextureProcess.ProcessTexture_Clean(node.textureEx);
     }
     info.pts.Clear();
 }
コード例 #21
0
 public void GrayApply()
 {
     if (data.useGray)
     {
         data.dirty = true;
         if (textureGray != null)
         {
             texMask = SWTextureProcess.TextureResize(textureGray, 512, 512);
         }
         else
         {
             texMask = SWCommon.TextureCreate(512, 512, TextureFormat.ARGB32);
         }
     }
 }
コード例 #22
0
        void PerPixel(PixelCom p)
        {
            map [p.x, p.y] = 2;
            int   index = SWTextureProcess.XYtoIndex(texSrcWidth, texSrcHeight, p.x, p.y);
            float m     = SWTextureProcess.Match(texSrcColorBuffer [index], texSrcColorBuffer [p.colorFrom]);

            if (m <= tolerance)
            {
                SWTextureProcess.Brush_ApplyOnce(ref texColorBuffer [index], brush, 0);

                AddTask(p.x + 1, p.y, index);
                AddTask(p.x - 1, p.y, index);
                AddTask(p.x, p.y - 1, index);
                AddTask(p.x, p.y + 1, index);
            }
        }
コード例 #23
0
        public override void DrawTop()
        {
            Rect llRect = new Rect(0, 0, 0, 0);

            base.DrawTop();
            if (brush.mode == SWBrushMode.wand || brush.mode == SWBrushMode.dropper)
            {
                GUILayout.Label("Tolerance:", SWEditorUI.Style_Get(SWCustomStyle.eTxtSmallLight));
                llRect = GUILayoutUtility.GetLastRect();
                EditorGUILayout.IntSlider(spTolerance, 0, 255, "", GUILayout.Width(SWGlobalSettings.SliderWidth));
                Tooltip_Rec(SWTipsText.Mask_Tolerance, -llRect.width - 10, 0);
            }
            else
            {
                GUILayout.Label("Size:", SWEditorUI.Style_Get(SWCustomStyle.eTxtSmallLight));
                llRect = GUILayoutUtility.GetLastRect();
                EditorGUILayout.IntSlider(spBrushsize, BrushSizeMin, BrushSizeMax, "", GUILayout.Width(SWGlobalSettings.SliderWidth));
                Tooltip_Rec(SWTipsText.Mask_Size, -llRect.width - 10, 0);


                GUILayout.Space(al_spacingBig);
                GUILayout.Label("Opacity:", SWEditorUI.Style_Get(SWCustomStyle.eTxtSmallLight));
                llRect = GUILayoutUtility.GetLastRect();
                EditorGUILayout.Slider(spBrushTrans, 0, 1, "", GUILayout.Width(SWGlobalSettings.SliderWidth));
                Tooltip_Rec(SWTipsText.Mask_Opacity, -llRect.width - 10, 0);
            }

            GUI.color = SWEditorUI.ColorPalette(SWColorPl.light);



            Rect btRect2 = TopElementRect(position.width - 200, position.width - 100 - SWGlobalSettings.UIGap);

            ePopup_texRes.Show(btRect2);
            Tooltip_Rec(SWTipsText.Mask_TexSize, btRect2);

            Rect btRect = TopElementRect(position.width - 100, position.width - SWGlobalSettings.UIGap);

            if (GUI.Button(btRect, "Invert", SWEditorUI.MainSkin.button))
            {
                SWTextureProcess.ProcessMask_Invert(node.texMask);
            }
            GUI.color = Color.white;
            Tooltip_Rec(SWTipsText.Mask_Invert, btRect);
        }
コード例 #24
0
        IEnumerator ResizeTex(SWTexResolution temp)
        {
            yield return(new WaitForSeconds(0.1f));

            bool b = EditorUtility.DisplayDialog("Warning", "Change resolution may loss quality,continue?", "Yes", "No");

            pause = false;
            if (b)
            {
                //SWUndo.Record (node);
                node.data.reso = temp;

                EditorUtility.DisplayProgressBar("Texture resizing", "Please wait", 0.5f);
                node.UpdateTex();
                SWTextureProcess.TextureResize(node.textureEx, node.data.resolution);
                EditorUtility.ClearProgressBar();
            }
        }
コード例 #25
0
        public static SWTexture2DEx TextureResize(Texture2D tex, int newWidth, int newHeight)
        {
            SWTexture2DEx newTex       = SWCommon.TextureCreate(newWidth, newHeight, TextureFormat.ARGB32);
            var           colorsOrigin = tex.GetPixels();
            var           colors       = newTex.GetPixels();

            for (int i = 0; i < newWidth; i++)
            {
                for (int j = 0; j < newHeight; j++)
                {
                    Vector2 uv    = SWTextureProcess.TexUV(newWidth, newHeight, i, j);
                    int     index = TexUV2Index(newTex.width, newTex.height, uv);
                    colors[index] = SWTextureProcess.GetColor_UV(tex.width, tex.height, colorsOrigin, uv);
                }
            }
            newTex.SetPixels(colors);
            newTex.Apply();
            return(newTex);
        }
コード例 #26
0
        protected override void ThreadMission_Pixel(int i, int j)
        {
            base.ThreadMission_Pixel(i, j);
            Vector2 uv     = SWTextureProcess.TexUV(texSrcWidth, texSrcHeight, i, j);
            Vector2 fromUV = uv - offset;
            Vector2 dis    = fromUV - uv;
            float   alpha  = 0;
            float   pcg    = 0;
            Color   c      = SWTextureProcess.GetColor_UV(texSrcWidth, texSrcHeight, texSrcColorBuffer, uv);
            Color   c2     = SWTextureProcess.GetColor_UV(texSrcWidth, texSrcHeight, texSrcColorBuffer, uv - dis.normalized * 3f / 512f);
            Vector2 newUV  = uv - dis.normalized * pixelBack / 512f;
            int     newI   = 0;
            int     newJ   = 0;

            SWTextureProcess.TexUV2Index(texSrcWidth, texSrcHeight, newUV, ref newI, ref newJ);
            if (!IsImage(c) && !IsImage(c2))
            {
//				int index = 0;
                while (pcg <= 1)
                {
                    Vector2 xuv    = uv + dis * pcg;
                    Color   xColor = SWTextureProcess.GetColor_UV(texSrcWidth, texSrcHeight, texSrcColorBuffer, xuv);
                    Vector2 xpos   = uv;
                    xpos -= center;
                    xpos  = matrix.MultiplyPoint(xpos);
                    xpos += center;
                    if (xColor.a > 0)
                    {
                        alpha = pcg;
                        float g = alpha;
                        float b = 0;
                        float a = GreenToAlpha(g);
                        texColorBuffer [(texSrcHeight - newJ - 1) * texSrcWidth + newI] = new Color(xpos.x, alpha, b, a);
                        break;
                    }


                    pcg += accuracyUnit;
                }
            }
        }
コード例 #27
0
 protected static Color[] TextureResizeTRSBase(Color[] colorsOrigin, int oldW, int oldH, int newW, int newH, EffectData data)
 {
     Color[] colorsNew = new Color[newW * newH];
     for (int i = 0; i < newW; i++)
     {
         for (int j = 0; j < newH; j++)
         {
             int     index = XYtoIndex(newW, newH, i, j);
             Vector2 uv    = TexUV(newW, newH, i, j);
             //////////////////////////////////////////////////////////////////////
             bool hasCol = TexUVTRS(ref uv, data);
             colorsNew[index] = SWTextureProcess.GetColor_UVNoClamp(oldW, oldH, colorsOrigin, uv);
             if (!hasCol)
             {
                 colorsNew [index] = new Color(0, 0, 0, 0);
             }
             //////////////////////////////////////////////////////////////////////
         }
     }
     return(colorsNew);
 }
コード例 #28
0
 /// <summary>
 /// Apply just before Update
 /// </summary>
 public void GrayApply()
 {
     if (data.useGray)
     {
         data.dirty = true;
         if (textureGray != null)
         {
             if (textureGray.width == textureGray.height && SWDataNode.resoList.Contains(textureGray.width))
             {
                 texMask = new SWTexture2DEx(textureGray);
             }
             else
             {
                 texMask = SWTextureProcess.TextureResize(textureGray, SWGlobalSettings.TexDefaultSize, SWGlobalSettings.TexDefaultSize);
             }
         }
         else
         {
             texMask = SWCommon.TextureCreate(SWGlobalSettings.TexDefaultSize, SWGlobalSettings.TexDefaultSize, TextureFormat.ARGB32);
         }
     }
 }
コード例 #29
0
        void ThreadMission_Pixel2(int i, int j)
        {
            int     index = SWTextureProcess.XYtoIndex(texWidth, texHeight, i, j);
            Vector2 uv    = SWTextureProcess.TexUV(texWidth, texHeight, i, j);
            Color   c     = texColorBuffer [index];

            float dis   = offset.magnitude * threhold;
            float alpha = -1;

            for (float v = 0; v < 1; v += 0.01f)
            {
                Vector2 newUV    = uv + dirHor * v * dis;
                int     newIndex = SWTextureProcess.TexUV2Index(texWidth, texHeight, newUV);
                Color   newC     = texColorBuffer[newIndex];
                if (newC.a == 0)
                {
                    alpha = v;
                    break;
                }


                newUV    = uv - dirHor * v * dis;
                newIndex = SWTextureProcess.TexUV2Index(texWidth, texHeight, newUV);
                newC     = texColorBuffer[newIndex];
                if (newC.a == 0)
                {
                    alpha = v;
                    break;
                }
            }

//			if (alpha < 0.5f)
//				alpha = 0;

            if (alpha >= 0)
            {
                texColorBuffer [index] = new Color(c.r, c.g, c.b, c.a * alpha);
            }
        }
コード例 #30
0
        protected override void ThreadMission_Pixel(int i, int j)
        {
            base.ThreadMission_Pixel(i, j);
            if (brush.size == 1)
            {
                if (i == centerX && j == centerY)
                {
                    SWTextureProcess.Brush_Apply(ref texColorBuffer [(texHeight - j - 1) * texWidth + i], brush, 0, i, j);
                }
                return;
            }

            Vector2 _uv   = SWTextureProcess.TexUV(texWidth, texHeight, i, j);
            float   dis   = Vector2.Distance(uv, _uv);
            float   isize = (float)brush.size / (float)SWWindowDrawMask.size;

            if (dis < isize)
            {
                float disPcg = dis / isize;
                SWTextureProcess.Brush_Apply(ref texColorBuffer [(texHeight - j - 1) * texWidth + i], brush, disPcg, i, j);
            }
        }