Skip to content

bug: Mixing shell-less vertex with shelled fragment fails if vertex returns scalars #2440

@reczkok

Description

@reczkok
import tgpu, { d } from 'typegpu';

const root = await tgpu.init();

const Vertex = d.struct({
  position: d.vec3f,
  roughness: d.f32,
});

const vertexLayout = tgpu.vertexLayout(d.arrayOf(Vertex));

const fragment = tgpu.fragmentFn({
  in: { roughness: d.f32 },
  out: d.vec4f,
})(({ roughness }) => {
  'use gpu';
  return d.vec4f(roughness, 0, 0, 1);
});

root.createRenderPipeline({
  attribs: vertexLayout.attrib,

  // Shell-less vertex: roughness is inferred as value type `number`
  vertex: ({ position, roughness }) => {
    'use gpu';

    return {
      $position: d.vec4f(position, 1),
      roughness,
    };
  },

  // Typed fragment: roughness requires schema type `d.F32`
  fragment,

  targets: { format: 'rgba8unorm' },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions