Skip to content

add a function to enable texel offset for tilemap#18209

Merged
minggo merged 2 commits intococos:v3.8.6from
minggo:add-option-to-enable-texel-offset
Jan 21, 2025
Merged

add a function to enable texel offset for tilemap#18209
minggo merged 2 commits intococos:v3.8.6from
minggo:add-option-to-enable-texel-offset

Conversation

@minggo
Copy link
Copy Markdown
Contributor

@minggo minggo commented Jan 17, 2025

@minggo minggo requested a review from qiuguohua January 17, 2025 05:50
@github-actions
Copy link
Copy Markdown

⚠️ Package size ⤴ 162 bytes, old: 5235727, new: 5235889

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -54535,8 +54535,21 @@
          * let properties = titledMap.getPropertiesForGID(GID);
          * cc.log("Properties: " + properties);
          */
         getPropertiesForGID(gid: __private._cocos_tiledmap_tiled_types__GID): __private._cocos_tiledmap_tiled_types__PropertiesInfo | undefined;
+        /**
+         * @en Enables or disables texel offset correction to fix rendering issues like grid edge artifacts.
+         * This function adjusts the texture coordinates of each grid in the tilemap by applying
+         * a 0.5-pixel offset, ensuring that grid edges do not show black lines or artifacts caused by
+         * texture sampling inaccuracies. This is especially useful for tile-based rendering systems.
+         * @zh 启用或禁用像素偏移修正,用于修复网格边缘的渲染问题(如黑线)。此函数通过对每个 tilemap 网格的纹理坐标应用 0.5 像素
+         * 的偏移来调整,确保网格边缘不会出现因纹理采样不准确导致的黑线或其他伪影问题。对基于图块的渲染系统特别有用。
+         *
+         * @param enable
+         * @en Whether to enable (true) or disable (false) the texel offset correction.
+         * @zh 是否启用 (true) 或禁用 (false) 像素偏移修正。
+         */
+        enableTexelOffset(enable: boolean): void;
         __preload(): void;
         onEnable(): void;
         onDisable(): void;
         _applyFile(): void;

@minggo minggo merged commit f5f9a5a into cocos:v3.8.6 Jan 21, 2025
@minggo minggo deleted the add-option-to-enable-texel-offset branch January 21, 2025 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants