@typegpu/gl: builtin.position in fragment shaders has a bottom-left origin (gl_FragCoord)
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
- Área
- backend
Línea de trabajo
Start by reading packages/typegpu-gl/src/glslGenerator.ts, especially glslInputForBuiltin, and trace how fragment position is translated for the GL fallback. Compare the coordinate behavior with WebGPU and inspect how draw targets expose their height; the proposal leaves the implementation choice open. Done means fragment position has consistent top-left coordinates across both backends, with coverage for the reported top-band repro.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
In a fragment shader, d.builtin.position is translated directly to gl_FragCoord (glslInputForBuiltin in packages/typegpu-gl/src/glslGenerator.ts). The two use different origins:
- WGSL
@builtin(position): (0, 0) is the top-left of the framebuffer, +y down. - GLSL
gl_FragCoord: (0, 0) is the bottom-left, +y up.
So any shader that works in pixel coordinates (dithering, pixel grids, textureLoad with the fragment position, screen-space effects) renders vertically flipped on the GL fallback compared to WebGPU.
Repro
const fragment = tgpu.fragmentFn({ in: { pos: d.builtin.position }, out: d.vec4f })(({ pos }) => {
'use gpu';
// Red band along the top 10 pixels.
return std.select(d.vec4f(0, 0, 0, 1), d.vec4f(1, 0, 0, 1), pos.y < 10);
});
- WebGPU root: the red band is at the top.
initWithGL()root: the red band is at the bottom.
Proposal
Emit a flipped coordinate, e.g. vec4(gl_FragCoord.x, u_targetHeight - gl_FragCoord.y, gl_FragCoord.zw). The target height would be a uniform set per draw from the color attachment. Alternatively, render upside down and flip on presentation, so the builtins and texture orientation match WebGPU everywhere.
Workaround
Derive pixel coordinates from an interpolated UV varying instead of the position builtin.
Found in @typegpu/gl 0.12.6. Related: #1637.
- Lenguaje dominante
- TypeScript
- Estrellas
- 3.3k
- Forks
- 141
- Merge medio
- 3 d 8 h
- PR fusionados (30 d)
- 72
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de software-mansion/TypeGPU
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
software-mansion/TypeGPU#3276 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
software-mansion/TypeGPU#3219 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
texture.write(VideoFrame) uses the padded coded size instead of the visible sizePosiblemente ocupada @RaphaelFakhri la tomó hace 9 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
software-mansion/TypeGPU#3213 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
impr: Error message in examplesAbiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
software-mansion/TypeGPU#3008 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
software-mansion/TypeGPU#2948 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
Todos los issues de software-mansion/TypeGPU
Issues similares
-
Shell: serve the home app's Cookie Policy on a hard reloadPosiblemente ocupada @2001anshkaushik la tomó hoy. Abiertofeature module:ai
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
rocketride-org/rocketride-server#2899 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
wazuh/wazuh-dashboard-plugins#9551 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
gofish-graphics/gofish-graphics#1252 ·
Los mantenedores suelen responder en 1 día
-
optimization P3 size:XS
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
josephfung/curia#2366 ·
Los mantenedores suelen responder en 1 día
-
stranded-follow-up sweep trusts any issue whose body carries the marker as the tracking issueAbiertotype:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
nightgauge/nightgauge#2688 ·
Los mantenedores suelen responder en 1 día