hch
7 小时以前 d6dd2be840dec2914709fcb9cf0c230a83285079
0312 优化文字包边第一次打开界面可能变粗的问题
2个文件已修改
7 ■■■■ 已修改文件
Materials/OutlineMat.mat 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Shader/OutlineEx.shader 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Materials/OutlineMat.mat
@@ -44,7 +44,7 @@
        m_Scale: {x: 1, y: 1}
        m_Offset: {x: 0, y: 0}
    - _MainTex:
        m_Texture: {fileID: 0}
        m_Texture: {fileID: 2800000, guid: 7cd825c6867461a4090871836190730f, type: 3}
        m_Scale: {x: 1, y: 1}
        m_Offset: {x: 0, y: 0}
    - _MaskTex:
Shader/OutlineEx.shader
@@ -134,7 +134,10 @@
                const fixed sinArray[12] = { 0, 0.5, 0.866, 1, 0.866, 0.5, 0, -0.5, -0.866, -1, -0.866, -0.5 };
                const fixed cosArray[12] = { 1, 0.866, 0.5, 0, -0.5, -0.866, -1, -0.866, -0.5, 0, 0.5, 0.866 };
                float2 pos = IN.texcoord + _MainTex_TexelSize.xy * float2(cosArray[pIndex], sinArray[pIndex]) * IN.normal.z*0.2;    //normal.z 存放 _OutlineWidth
                // 使用绝对UV偏移,系数基于512x512纹理的参考值
                // 原公式: _MainTex_TexelSize.xy * offset * width * 0.2 = (1/512) * offset * width * 0.2 ≈ 0.00039 * offset * width
                float2 uvOffset = float2(cosArray[pIndex], sinArray[pIndex]) * IN.normal.z * 0.0004;
                float2 pos = IN.texcoord + uvOffset;
                return IsInRect(pos, IN.uv1, IN.uv2) * (tex2D(_MainTex, pos) + _TextureSampleAdd).w * IN.tangent.w;        //tangent.w  存放 _OutlineColor.w
            }