• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 72,  comments - 4,  trackbacks - 0
              2021年7月3日
            我的開放世界, wow一樣大的地圖






            posted @ 2021-07-03 20:35 flipcode 閱讀(210) | 評論 (0)編輯 收藏
              2020年4月2日
            云霧的作法很多,現在常用的是raymarching步進的方法。這里我用了另一個方案(類似視差貼圖的實現,算法這位道友寫的很清楚:https://zhuanlan.zhihu.com/p/83355147
            posted @ 2020-04-02 11:48 flipcode 閱讀(247) | 評論 (0)編輯 收藏
              2020年3月27日




            深度霧可以在后期處理通過深度圖反算得到世界坐標, 然后再用位置減去水平面位置,再除霧距得到霧化比進行處理。
            不用后期也可以,直接擺放渲染平面,然后在shader中用當前平面深度減去深度圖深度,再除霧距得到霧化比進行處理。上圖就是這種方式實現的載圖,對應shader如下:

            void vertexDataFunc( inout appdata_full v, out Input o )
            {
            UNITY_INITIALIZE_OUTPUT( Input, o );
            UNITY_TRANSFER_DITHER_CROSSFADE( o, v.vertex );
            float2 tex_pos;
            tex_pos.x = v.vertex.x;
            tex_pos.y = v.vertex.z;
            float rnd = sin(_Time.y*0.01f) + cos(_Time.y*0.01f)*10;
            o.wavecoord = float4(tex_pos + rnd, tex_pos*2.0 + rnd);
            }
            void surf( Input i , inout SurfaceOutputStandard o )
            {
            //UNITY_APPLY_DITHER_CROSSFADE(i);
            float _ScrollSpeed = 0.7f;
            fixed scrollValue = fixed2(_ScrollSpeed * sin(_Time.y), _ScrollSpeed * sin(_Time.y));
            fixed4 c = tex2D(_MainTex, i.wavecoord.xy);
            o.Albedo = c.rgb * _FogColor.rgb;
            o.Emission = _FogColor.rgb;
            float4 ase_screenPos = float4( i.screenPos.xyz , i.screenPos.w + 0.00000001 );
            float eyeDepth = LinearEyeDepth(UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture,UNITY_PROJ_COORD(ase_screenPos))));
            float clampResult = clamp((abs((
            eyeDepth
            - ase_screenPos.w)) * (0.1f+ _FogIntensity * 0.4f)), 0, _FogMaxIntensity);
            o.Alpha = clampResult;
            }
            另外迷霧太大,無法看清游戲,可以讓相機拉遠顯示迷霧,靠近則讓迷霧變淡處理,簡單地將_FogMaxIntensity修改下即可:
            _FogMaxIntensity = _FogMaxIntensity * pow(ase_screenPos.w * 0.01f, 3);
            posted @ 2020-03-27 18:07 flipcode 閱讀(511) | 評論 (0)編輯 收藏
              2020年3月26日

            有很多實現方案, 有人會想著用貼花去做,其實很沒必要,一種廉價又簡單的方式可以實現:將ps當前位置轉換到hexagon的uv空間再采樣hexagon貼圖即可, 即在地表繪制的ps中(或在后處理里),取得(或通過深度求得)世界位置并減去當前位置所在格子中心點的世界位置,得到相對格子的偏移,然后再轉為uv坐標。那么hexagon的屬性怎么得到?用另一張point貼圖在cpu中修改后傳入給shader即可(以上圖片中所示就是我用的這種方式實現的樣例)。
            posted @ 2020-03-26 20:55 flipcode 閱讀(267) | 評論 (0)編輯 收藏
            三國志14在尋路時可以顯示出所行走路徑,思考了下,可以用以下方式做到:

            實現方式:
            // uv=x,y, rotation = z
                    public static readonly kPathArrow[,] combineType =
                    {
                        // 右上,右上               右,                           右下,               左下,                 左,                    左上
                        {new kPathArrow(0, 60), new kPathArrow(5, 180),    new kPathArrow(2, 180), new kPathArrow(6, 120), new kPathArrow(7, 0), new kPathArrow(3, 0)},
                        // 右
                        {new kPathArrow(5, 180), new kPathArrow(1, 180),    new kPathArrow(4, 180), new kPathArrow(7, 180), new kPathArrow(6, 0), new kPathArrow(8, 180)},
                        // 右下
                        {new kPathArrow(2, 180), new kPathArrow(4, 180),    new kPathArrow(0, 180), new kPathArrow(3, 180), new kPathArrow(8, 0), new kPathArrow(6, 60)},
                        // 左下
                        {new kPathArrow(6, 120), new kPathArrow(7, 180),    new kPathArrow(3, 180), new kPathArrow(0, -120), new kPathArrow(5, 0), new kPathArrow(2, 0)},
                        // 左
                        {new kPathArrow(7, 0), new kPathArrow(6, 0),    new kPathArrow(8, 0),    new kPathArrow(5, 0), new kPathArrow(1, 0), new kPathArrow(4, 0)},
                        // 左上
                        {new kPathArrow(3, 0), new kPathArrow(8, 180),   new kPathArrow(6, 60), new kPathArrow(2, 0), new kPathArrow(4, 0), new kPathArrow(0, 0)},
                    };
                    private Vector3 RotVertex(Vector3 point, float rot)
                    {
                        Vector3 pos = point;
                        float cs = Mathf.Cos(rot);
                        float sn = Mathf.Sin(rot);
                        pos.x = point.x * cs + point.z * sn;
                        pos.z = -point.x * sn + point.z * cs;
                        return pos;
                    }
                    //----------------------------------------------------------------------------------------------
                    public void AddPathTile(int x, int z, int idx)
                    {
                        int enterDir = idx / (int)kHexGrid.HexDirection.MAX;
                        int outDir = idx % (int)kHexGrid.HexDirection.MAX;
                        kPathArrow pathArrow = combineType[enterDir, outDir];
                        int rowUV = pathArrow.idx / 3;
                        int colUV = pathArrow.idx % 3;
                        float rot = pathArrow.angle * Mathf.PI/180.0f;
                        Vector3 center = kHexGrid.ToWorldPos(x, z);
                        Vector2 centerUV = new Vector2(0.5f, 0.5f);
                        Vector2 uvStart = new Vector2(colUV * 1 / 3.0f, rowUV * 1 / 3.0f);
                        for (kHexGrid.HexDirection dir = kHexGrid.HexDirection.NE; dir <= kHexGrid.HexDirection.NW; dir++)
                        {
                            Vector3 v1 = center + new Vector3(0,0.01f,0);
                            Vector3 v2 = kHexGrid.cornerPos[(int)dir] + new Vector3(0, 0.01f, 0);
                            Vector3 v3 = kHexGrid.cornerPos[(int)dir + 1] + new Vector3(0, 0.01f, 0);
                            if (rot > 0.0001f || rot < -0.0001f)
                            {
                                v2 = RotVertex(v2, rot);
                                v3 = RotVertex(v3, rot);
                            }
                            AddTriangle(v1, center + v2, center + v3,
                                uvStart + centerUV * 1/3.0f, uvStart + kHexGrid.cornerUV[(int)dir] * 1 / 3.0f, uvStart + kHexGrid.cornerUV[(int)dir + 1] * 1 / 3.0f,
                                Color.white);
                        }
                    }
            丑圖效果:

            所用貼圖
            posted @ 2020-03-26 20:33 flipcode 閱讀(287) | 評論 (0)編輯 收藏
              2020年1月9日
            posted @ 2020-01-09 10:35 flipcode 閱讀(201) | 評論 (0)編輯 收藏
            自己用max建模弄的一個小場景,感覺基本夠用了,記錄下
            posted @ 2020-01-09 09:59 flipcode 閱讀(243) | 評論 (0)編輯 收藏
              2020年1月3日
            unity slg的方形和六邊形測試, 其中主要是坐標轉換,下面是我自己想出來的一種比較簡便高效的處理方法,實現方法如下:
               
                // 記錄下: 這是我看圖總結出的比較簡便的算法:)(flipcode@qq.com):
                    // 注意,傳入的xWorld要/edgeLength
                    public static Vector2 ToHexGrid(float xWorld, float yWorld)
                    {
                        float edgeLength = 1;
                        float halfGridWidth = edgeLength * 0.866025404f;
                        int iGY = (int)(yWorld / (1.5 * edgeLength));
                        bool odd = ((iGY & 1) != 0);
                        // 奇:
                        if (odd)
                        {
                            xWorld -= halfGridWidth;
                        }
                        int iGX = (int)(xWorld / (2 * halfGridWidth));
                        // 得到格子左下角坐標:
                        float OGX = iGX * (2 * halfGridWidth);
                        float OGY = iGY * (1.5f * edgeLength);
                        float refX = OGX + halfGridWidth;
                        float refY = OGY + edgeLength * 0.5f;
                        // 可能不在本格子內(因為可能位置在格格子下方的左下角或右下角):
                        bool bOutProbably = yWorld < refY;
                        if (bOutProbably)
                        {
                            // 得到Hex中心往下半個外邊長的位置:
                            float dx = Mathf.Abs(xWorld - refX) * (0.5f * edgeLength / halfGridWidth); // 乘( ../.. )使其變成正方形再來判斷
                            float dy = Mathf.Abs(yWorld - refY);
                            float dt = dx + dy;
                            // 在左半邊:
                            if (xWorld < refX)
                            {
                                // 不在本格子,而是在左下角:
                                if (dt > edgeLength * 0.5f)
                                {
                                    iGY--; // 不管奇偶,下部都要y--
                                           // 如果是偶數的左下,還要將x--
                                    if (false == odd)
                                    {
                                        iGX--;
                                    }
                                }
                            }
                            // 在右半邊
                            else
                            {
                                // 不在本格子, 而是在右下角:
                                if (dt > edgeLength * 0.5f)
                                {
                                    iGY--; // 不管奇偶,下部都要y--
                                           // 如果是奇數的右下,還要將x++
                                    if (odd)
                                    {
                                        iGX++;
                                    }
                                }
                            }
                        }
                        return new Vector2(iGX, iGY);
                    }
                    public static Vector3 ToWorldPos(int iGX, int iGY)
                    {
                        bool odd = ((iGY & 1) != 0);
                        // 得到格子左下角坐標:
                        float OGX = iGX * (2 * halfGridWidth);
                        float OGY = iGY * (1.5f * edgeLength);
                        // 奇數行要右移半個寬度:
                        if (odd)
                        {
                            OGX += halfGridWidth;
                        }
                        // 偏移轉到格子中心位置:
                        Vector3 pos = new Vector3(OGX + halfGridWidth, 0, OGY + edgeLength);
                        return pos;\
                    }

            下面是我畫的圖,非常丑,將就看

            b附上測試圖,已帶ai移動攻擊, 不過圖看不到:
            posted @ 2020-01-03 18:09 flipcode 閱讀(1359) | 評論 (0)編輯 收藏
            將我的u3d demo改用輕量管線來弄了下,加了點后期處理
            posted @ 2020-01-03 18:01 flipcode 閱讀(307) | 評論 (0)編輯 收藏
              2019年10月29日
            實現方式是生成了一個二叉樹,設定了深度及隨機閥值(到達則生成葉子),原理在nv的一個古老的例子: texturemask
            posted @ 2019-10-29 16:20 flipcode 閱讀(271) | 評論 (0)編輯 收藏
            僅列出標題  下一頁
            狠狠色噜噜狠狠狠狠狠色综合久久| 久久91精品国产91久久户| 久久亚洲欧美国产精品| 国产精品久久波多野结衣| 久久精品一区二区三区中文字幕| 亚洲色欲久久久久综合网| 成人久久精品一区二区三区| 国产成人久久777777| 色综合久久综精品| 丰满少妇高潮惨叫久久久| 久久夜色精品国产噜噜亚洲a| 好久久免费视频高清| 久久久久无码专区亚洲av| 无码国内精品久久人妻| 久久精品国产色蜜蜜麻豆| 香蕉久久夜色精品国产2020 | 国产免费久久精品99re丫y| 色综合色天天久久婷婷基地| 99久久综合国产精品免费| 色综合久久中文色婷婷| 青青草原精品99久久精品66| 久久久久97国产精华液好用吗| 久久久久久午夜成人影院| 久久精品国产亚洲AV无码偷窥| 国产一区二区精品久久岳| 久久国产精品偷99| 国产麻豆精品久久一二三| 亚洲级αV无码毛片久久精品| 久久久久久国产a免费观看不卡| 久久精品成人国产午夜| 久久久久亚洲av无码专区喷水| 欧美激情精品久久久久久| 亚洲综合精品香蕉久久网| 久久亚洲私人国产精品vA | 一级做a爱片久久毛片| 欧美久久综合性欧美| 久久婷婷五月综合国产尤物app| 久久精品免费全国观看国产| 久久综合视频网站| 亚洲精品高清国产一线久久| 日产精品久久久久久久|