Black opaque background on transparent Phaser.Text textures in Phaser 4.2.1 on older iOS WebGL
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 85/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript
- Lĩnh vực
- game-dev
Hướng nghiên cứu
Tìm tệp shader WebGL ApplyTint.glsl trong cây mã nguồn Phaser. Thêm điều kiện bảo vệ trả về sớm được cung cấp cho các texel có alpha bằng không trước phép chia khử tiền nhân, để khắc phục vấn đề nền đen đục trên các thiết bị iOS WebGL cũ. Xác minh bản sửa bằng mã mẫu kết xuất văn bản đi kèm và xác nhận văn bản trong suốt được kết xuất chính xác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version
- Phaser Version: 4.2.1
- Operating system: iPad OS 16.4
Description
Problem
In our game Tvers (www.nrk.no/spill/tvers) we got reports from people playing on older iPads that there were black backgrounds behind out letter tiles after we upgraded to Phaser 4.2.1. We spent a lot of time trying to debug the behaviour and traced it to a division by zero issue in ApplyTint.glsl.
On older iOS devices (<= iPad OS 16.4), Phaser Text objects with black fill rendered on top of a transparent background show as black rectangles with faint aliased edges. On newer devices the transparency works as expected. In Phaser 3.8 this was not a problem.
Cause
The WebGL tint shader (ApplyTint.glsl) performs an unpremultiply of the text texture:
vec3 unpremultTexture = texture.rgb / texture.a;
Outside the character glyph, the canvas-generated texture stores pixels with RGB = 0 and alpha = 0. Dividing zero by zero results in undefined behavior (NaN or Infinity). How the shader handles that NaN varies between GPUs/drivers. On the affected devices it propagates, producing a visible opaque black rectangle instead of transparent.
Fix
Guard the division by returning early for zero-alpha texels:
if (texture.a <= 0.0) {
return vec4(0.0);
}
vec3 unpremultTexture = texture.rgb / texture.a;
Example Test Code
const textStyling = {
fontSize: '80px',
color: 'black',
fontFamily: 'sans-serif',
fontStyle: 'bold',
padding: { x: 10, y: 10 },
}
const background = this.scene.add
.image(0, 0, 'tile')
.setTint(palette.boardSquare)
.setTintMode(Phaser.TintModes.FILL)
const letter = this.scene.add.text(0, 0, this.letter, textStyling)
Phaser.Display.Align.In.Center(letter, background)
- Ngôn ngữ chính
- JavaScript
- Star
- 40.5k
- Fork
- 7.2k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của phaserjs/phaser
-
Type definition for TilemapLayer.getTileAt is wrongCó thể đã có người làm @hkbughk đã nhận 14 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Shader.preDestroy leaks its ShaderQuad's vertex buffer and VAO on every create/destroy cycle (4.2.1)Có thể đã có người làm @k1epg01ng129-eng đã nhận 12 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 2 ngày
-
flipY renders tile incorrectlyCó thể đã có người làm @vtxe02023274 đã nhận 6 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 2 ngày
-
WebGL stroke of a Polygon drops a vertex when its origin-shifted position equals the previous raw vertexCó thể đã có người làm @ICOM725 đã nhận 51 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
phaserjs/phaser#7361 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
MouseManager.stopListeners never removes the wheel listener — destroyed Game stays retained through the canvasCó thể đã có người làm @schulerj89 đã nhận 90 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của phaserjs/phaser
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
flarum/framework#5301 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
AOSSIE-Org/BabyNest#284 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
status:untriaged
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
midnightntwrk/servicedesk#275 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
seek4science/seek#2762 ·
Maintainer thường phản hồi trong vòng 5 ngày