Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

@typegpu/gl: builtin.position in fragment shaders has a bottom-left origin (gl_FragCoord)

Abierto
#3,215 1 comentario 0 reacciones 0 asignados Ver en GitHub

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

bug

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

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de software-mansion/TypeGPU

Todos los issues de software-mansion/TypeGPU

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.