Texture2D._draw_rect_region is all white.

Aperta
#1,524 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva

Direzione di ricerca

Start with paged-texture.gd in the attached reproduction project and compare _draw_rect_region with the working _draw_rect implementation. Reproduce the white result through the scene’s TextureRect and inspect how the source rectangle is split and passed to each page’s draw_rect_region. Done means the requested region renders the correct texture content across pages without white output in tiled, scale, and keep modes.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug topic:2d usability
Tested versions

v26.3.rc.3.official [ccb92435b]

System information

Operating System: Debian GNU/Linux 13 KDE Plasma Version: 6.3.6 KDE Frameworks Version: 6.13.0 Qt Version: 6.8.2 Kernel Version: 6.12.107+deb13-amd64 (64-bit) Graphics Platform: Wayland Processors: 16 × AMD Ryzen 7 5700G with Radeon Graphics Memory: 16 GiB of RAM (15.0 GiB usable) Graphics Processor: AMD Radeon Graphics Product Name: B550M-ITX/ac

Issue description

I am trying to implement a paged texture resource.
The issue is _draw_rect_region is not being drawn its just all white.
I was using NinePatchRect and TextureRect control to test it.

Image
@tool class_name PagedTexture extends Texture2D

@export var pages       : Array[Texture2D]=[]
@export var page_width  := 160
@export var page_height := 144


func _get_width() -> int:
	return page_width
func _get_height() -> int:
	return page_height * pages.size()
	
func _draw(to_canvas_item: RID, pos: Vector2, modulate: Color, transpose: bool) -> void:
	if pages.size() == 0: return
	var offset := 0
	for page in pages:
		page.draw(to_canvas_item, Vector2(pos.x, pos.y+offset), modulate, transpose)
		offset += page_height

func _draw_rect(to_canvas_item: RID, dst_rect: Rect2, tile: bool, modulate: Color, transpose: bool) -> void:
	if pages.size() == 0: return
	
	# dst_size is the size of one page and how much we increment the dst_offset by.
	var dst_size    := dst_rect.size.y / pages.size()
	var dst_offset  := 0.0
	
	# loop over all pages :(
	for page in pages:
		
		# calculate the destination rectangle for this page.
		var dst_rect_part := Rect2(dst_rect.position.x, dst_rect.position.y+dst_offset, dst_rect.size.x, dst_size)
		if  page:
			page.draw_rect(to_canvas_item, dst_rect_part, tile, modulate, transpose)
		
		# offset that destination rectangle y.
		dst_offset += dst_size
 
func _draw_rect_region(to_canvas_item: RID, dst_rect: Rect2, src_rect: Rect2, modulate: Color, transpose: bool, clip_uv: bool) -> void:
	if pages.size() == 0: return
	
	# dst_size is the size of one page and how much we increment the dst_offset by.
	# src_size is the size of one page and how much we increment the src_offset by.
	var dst_size    := dst_rect.size.y / pages.size()
	var src_size    := src_rect.size.y / pages.size()
	var dst_offset  := 0.0
	var src_offset  := 0.0
	
	# find used page indices.
	var page_start  := (src_rect.position.y) / page_height
	var page_end    := (src_rect.position.y + src_rect.size.y) / page_height
	
	# if page_start is out of bounds return.
	if  page_start < 0 or page_start >= pages.size():
		return
		
	# loop over used page indices.
	for page_index in range(page_start, page_end):
		
		# if at anytime we are out of bounds break the loop.
		if page_index >= pages.size():
			break;
		
		# fetch the page we are drawing.
		var page          := pages[page_index]
		
		# calculate the destination and source rectangle for this page.
		var dst_rect_part := Rect2(dst_rect.position.x, dst_rect.position.y+dst_offset, dst_rect.size.x, dst_size)
		var src_rect_part := Rect2(src_rect.position.x, src_rect.position.y+src_offset, src_rect.size.x, src_size)
		if  page:
			page.draw_rect_region(
				to_canvas_item, 
				dst_rect_part,
				src_rect_part,
				modulate, transpose, clip_uv)
				
		# offset that destination and source rectangle y.
		dst_offset += dst_size
		src_offset += src_size

tiled mode width is correct, scale and keep mode height is correct.

Steps to reproduce
  • open the project
  • open the editor scene
  • open up the paged-texture.gd
  • mess with the texture rect in the scene
  • look at the code.
Minimal reproduction project (MRP)

quest.zip

Lingua principale
C++
Stelle
6.1k
Fork
337
Merge medio
5g 8h
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Redot-Engine/redot-engine

Tutte le issue di Redot-Engine/redot-engine

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.