GithubHelp home page GithubHelp logo

alaingalvan / webgpu-seed Goto Github PK

View Code? Open in Web Editor NEW
290.0 7.0 28.0 189 KB

πŸ”ΊπŸŒ± An example on how to render a hello triangle with WebGPU.

Home Page: https://alain.xyz/blog/raw-webgpu

License: The Unlicense

TypeScript 95.25% HTML 4.75%
webgpu typescript typings definitions types typescript-definitions dts

webgpu-seed's Introduction

Cover Art

πŸ”Ί WebGPU Seed

License Unit Tests

A WebGPU repo you can use to get started with your own renderer.

Setup

First install:

Then type the following in any terminal your such as VS Code's Integrated Terminal.

# πŸ‘ Clone the repo
git clone https://github.com/alaingalvan/webgpu-seed

# πŸ’Ώ go inside the folder
cd webgpu-seed

# πŸ”¨ Start installing dependencies, building, and running at localhost:8080
npm start

Refer to this blog post on designing web libraries and apps for more details on Node.js, packages, etc.

Project Layout

As your project becomes more complex, you'll want to separate files and organize your application to something more akin to a game or renderer, check out this post on game engine architecture and this one on real time renderer architecture for more details.

β”œβ”€ πŸ“‚ node_modules/   # πŸ‘Ά Dependencies
β”‚  β”œβ”€ πŸ“ gl-matrix      # βž• Linear Algebra
β”‚  └─ πŸ“ ...            # πŸ•š Other Dependencies (TypeScript, Webpack, etc.)
β”œβ”€ πŸ“‚ src/            # 🌟 Source Files
β”‚  β”œβ”€ πŸ“„ index.html     #  πŸ“‡ Main HTML file
β”‚  └─ πŸ“„ renderer.ts    # πŸ”Ί Triangle Renderer
β”œβ”€ πŸ“„ .gitignore      # πŸ‘οΈ Ignore certain files in git repo
β”œβ”€ πŸ“„ package.json    # πŸ“¦ Node Package File
β”œβ”€ πŸ“„ license.md      # βš–οΈ Your License (Unlicense)
└─ πŸ“ƒreadme.md        # πŸ“– Read Me!

webgpu-seed's People

Contributors

alaingalvan avatar armansito avatar beaufortfrancois avatar rbtcollins avatar toji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

webgpu-seed's Issues

Buffer example image position VBO

Hi - I think the signs or order are off in this image from the blog post? They don't match what's in the VBO in the code. Thanks!!

image

TypeError: m.device.createBufferMapped is not a function

Uncaught (in promise) TypeError: m.device.createBufferMapped is not a function
at e (main.js:1)
at c. (main.js:1)
at main.js:1
at Object.next (main.js:1)
at main.js:1
at new Promise ()
at n (main.js:1)
at c.initializeResources (main.js:1)
at c. (main.js:1)
at main.js:1

Shaders haven't been updated for new @ syntax

In your blog post, you've updated the shaders for the new WGSL @attribute syntax, but in this repo, the vertex and fragment shaders still follow the old-style double square-brackets syntax.

[[stage(fragment)]]
fn main([[location(0)]] inColor: vec3<f32>) -> [[location(0)]] vec4<f32> {
return vec4<f32>(inColor, 1.0);
}

struct VSOut {
[[builtin(position)]] Position: vec4<f32>;
[[location(0)]] color: vec3<f32>;
};
[[stage(vertex)]]
fn main([[location(0)]] inPos: vec3<f32>,
[[location(1)]] inColor: vec3<f32>) -> VSOut {
var vsOut: VSOut;
vsOut.Position = vec4<f32>(inPos, 1.0);
vsOut.color = inColor;
return vsOut;
}

P.S. Thank you for the excellent posts πŸ‘

Out of date again

Uncaught (in promise) TypeError: Failed to execute 'createRenderPipeline' on 'GPUDevice': required member vertex is undefined.
    at t.default.<anonymous> (main.js:1)
    at Generator.next (<anonymous>)
    at n (main.js:1)

Blogpost: UBO in shader syntax.

Under Shader Modules,

vsOut.Position = modelViewProj * vec4<f32>(inPos, 1.0);
should be
vsOut.Position = uniforms.modelViewProj * vec4<f32>(inPos, 1.0);

The former doesn't compile and throws an error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.