You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WGSL中vec4f与全1mat4f相乘结果异常的WebGPU技术问题

首次尝试WebGPU遇到的矩阵乘法异常问题

我首次尝试WebGPU时碰到一个问题:在其他渲染框架中,vec4与全1矩阵相乘后,输出结果应与原vec4一致,但在WGSL中执行该操作却出现了异常。

正常显示的代码

@vertex
fn vs_main(in: VertexInput) -> VertexOutput {
    var out: VertexOutput;

    let world_position: vec4f = vec4f(in.position, 0.0, 1.0);

    out.position = world_position;
    out.color = in.color;

    return out;
}

此时方块可以正常显示:
方块正常显示

异常情况的代码

@vertex
fn vs_main(in: VertexInput) -> VertexOutput {
    var out: VertexOutput;

    let world_position: vec4f = mat4x4f(
        1.0, 1.0, 1.0, 1.0,
        1.0, 1.0, 1.0, 1.0, 
        1.0, 1.0, 1.0, 1.0,
        1.0, 1.0, 1.0, 1.0
    ) * vec4f(in.position, 0.0, 1.0);

    out.position = world_position;
    out.color = in.color;

    return out;
}

此时无法显示任何内容:
无内容显示

内容的提问来源于stack exchange,提问作者Jove

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 04:53:16