wgpugd: A WebGPU Graphics Device for R

Related tags

Graphics wgpugd
Overview

wgpugd: A WebGPU Graphics Device for R

Overview

What is WebGPU?

WebGPU is an API that exposes the capabilities of GPU hardware.

What is wgpu?

As the name indicates, the wgpugd package uses wgpu, a pure-Rust implementation of the WebGPU standard. wgpu is what’s behind the WebGPU support of Firefox and Deno, and is widely used over the Rust’s graphics ecosystem.

Wait, Rust…? Can we use Rust in R??

Yes! extendr is the Rust framework for interacting with R.

Why WebGPU for R?

The main motivation is to add post-effect to graphics with WebGPU Shader Language (WGSL). But, of course, the power of GPU should simply contribute to high performance!

Installation

You can install the development version of wgpugd like so:

devtools::install_github("yutannihilation/wgpugd")

Usages

⚠️ wgpugd is currently at its verrry early stage of the development! ⚠️

png #> 2 knitr::include_graphics(file)">
library(wgpugd)
library(ggplot2)
#> Warning in register(): Can't find generic `scale_type` in package ggplot2 to
#> register S3 method.

file <- knitr::fig_path('.png')
wgpugd(file, 10, 10)

set.seed(10)
dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
ggplot(dsamp, aes(carat, price)) +
  geom_point(aes(colour = clarity)) +
  labs(title = "Now I can", y = "render", x ="texts!!!") +
  theme(text = element_text(size = 40), legend.position = "none")

dev.off()
#> png 
#>   2

knitr::include_graphics(file)

References

  • wgpugd uses extendr, a Rust extension mechanism for R, both to communicate with the actual graphics device implementation in Rust from R, and to access R’s graphics API from Rust.
  • If you are curious about developing a Rust program with wgpu, I’d recommend Learn Wgpu to get started.
  • lyon is a library for “path tessellation,” which is necessary to draw lines on GPU.
You might also like...
Standard Graphics is a command-line tool for printing 2D graphics from any language to any screen.
Standard Graphics is a command-line tool for printing 2D graphics from any language to any screen.

2D graphics in any programming language with just print statements!

A graphics engine that I made in rust for my high school graphics course.

A graphics engine that I made in rust for my high school graphics course.

RTS game/engine in Rust and WebGPU
RTS game/engine in Rust and WebGPU

What is this? A real time strategy game/engine written with Rust and WebGPU. Eventually it will be able to run in a web browser thanks to WebGPU. This

Native WebGPU implementation based on gfx-hal
Native WebGPU implementation based on gfx-hal

This is an active GitHub mirror of the WebGPU implementation in Rust, which now lives in "gfx/wgpu" of Mozilla-central. Issues and pull requests are a

Windowing support for Deno WebGPU.
Windowing support for Deno WebGPU.

deno_desktop Windowing support for Deno WebGPU. In very early stages at the moment. Usage const win = Deno.createWindow({ title: "Deno Desktop", w

A WebGPU implementation based on the excellent wgpu crate.

A WebGPU implementation based on the excellent wgpu crate.

A hardware-accelerated GPU terminal emulator powered by WebGPU, focusing to run in desktops, browsers, tvs and everywhere.
A hardware-accelerated GPU terminal emulator powered by WebGPU, focusing to run in desktops, browsers, tvs and everywhere.

Rio term tl;dr: Rio is a terminal built to run everywhere, as a native desktop applications by Rust/WebGPU or even in the browser powered by WebAssemb

Implementation of the RWKV language model in pure WebGPU/Rust.

Web-RWKV This is an implementation of the language model of RWKV in pure WebGPU. Compile and Run Install Rust. Run cargo run --release --example gen t

Game Of Life using webgpu, written in Rust
Game Of Life using webgpu, written in Rust

Game of Life using webgpu ✨ Description This is the implementation of the tutorial Your first WebGPU app in Rust where we're using webgpu to implement

🪄 Shader art using webgpu
🪄 Shader art using webgpu

✨ Shader art using webgpu ✨ This is the implementation of An introduction to Shader Art Coding in Rust using webgpu. 🔌 Setup You need: Rust compiler

Polaris is a music streaming application, designed to let you enjoy your music collection from any computer or mobile device.
Polaris is a music streaming application, designed to let you enjoy your music collection from any computer or mobile device.

Polaris is a music streaming application, designed to let you enjoy your music collection from any computer or mobile device. Polaris works by streami

An oauth2 client implementation providing the Device, Installed and Service Account flows.
An oauth2 client implementation providing the Device, Installed and Service Account flows.

yup-oauth2 is a utility library which implements several OAuth 2.0 flows. It's mainly used by google-apis-rs, to authenticate against Google services.

Trying embedded Rust on the Pinecil GD32VF103 RISC-V device.
Trying embedded Rust on the Pinecil GD32VF103 RISC-V device.

Pinecil GD32VF103 RISC-V Rust Demos My personal collection of Rust demos running on the PINE64 Pinecil portable soldering iron, featuring a GD32VF103T

Multi-device clipboard sharing.
Multi-device clipboard sharing.

share-clip 多设备剪切板共享 特性 采用 Rust 实现。便捷/高性能 基于 Redis(可轻松支持广域网/局域网的共享) 自动发现同身份下的机器 全数据 RSA 分段加密 (出于性能及其他原因考虑替换为 XSalsa20Poly1305 加密) 支持文本和图片 支持共享提示(macOS

Automate device security provisioning with edge intelligence.

UNiD Automate device security provisioning with edge intelligence Features Decentralized PKI(DPKI), DIDs, DKMS, and Credential Management End-to-End E

Cross-platform GUI written in Rust using ADB to debloat non-rooted android devices. Improve your privacy, the security and battery life of your device.
Cross-platform GUI written in Rust using ADB to debloat non-rooted android devices. Improve your privacy, the security and battery life of your device.

Universal Android Debloater GUI DISCLAIMER: Use it at your own risk. I am not responsible for anything that could happen to your phone. This software

An end-to-end encrypted, anonymous IP-hiding, decentralized, audio/video/file sharing/offline messaging multi-device platform built for both communications and application security and performance.

An end-to-end encrypted, anonymous IP-hiding, decentralized, audio/video/file sharing/offline messaging multi-device platform built for both communications and application security and performance.

zenoh-flow aims at providing a zenoh-based data-flow programming framework for computations that span from the cloud to the device.

Eclipse Zenoh-Flow Zenoh-Flow provides a zenoh-based dataflow programming framework for computations that span from the cloud to the device. ⚠️ This s

A tool that switch default audio playback device on windows.

AudioSwitch A tool built by Rust that can switch default audio playback device on windows. How to use specify which device you want to use Execute it

Comments
  • Clipping

    Clipping

    I thought clipping can be implemented by utilizing stencil buffer, but it means it takes more than one pass. So, probably I need to store the clipping information on uniform and reference it at the vertex shader stage.

    opened by yutannihilation 1
  • Narrow SDF

    Narrow SDF

    Currently, this vertex shader includes the whole screen, but only the area around circle is needed. Not sure about the performance gain by this, though.

    https://github.com/yutannihilation/wgpugd/blob/6aa3d001198e8eff54840d166b7afcd55132269a/src/rust/src/shaders/sdf_shape.wgsl#L35-L51

    opened by yutannihilation 0
  • Font is slightly smaller

    Font is slightly smaller

    The texts are about 10% smaller. Why?

    library(wgpugd)
    library(ragg)
    
    agg <- function(...) {
      agg_png(width = 7, height = 7, units = "in", ...)
    }
    
    do_text2 <- function(dev) {
      filename <- knitr::fig_path(paste0(deparse(substitute(dev)), ".png"))
      dev(filename = filename)
    
      grid::grid.text(
        x = grid::unit(0.5, "npc"),
        y = grid::unit(0.5, "npc"),
        label = "d",
        hjust = 0.5,
        vjust = 0,
        gp = grid::gpar(col = "brown", cex = 24, fontfamily = "Iosevka SS08")
      )
      
      f <- function(x, ...) {
        grid::grid.lines(
          x = grid::unit(c(0, 1), "npc"),
          y = grid::unit(rep(12, 2) * x, "points") + grid::unit(c(0.5, 0.5), "npc"),
          gp = grid::gpar(...)
        )
        invisible(NULL)
      }
      
      lapply(1:20, f, lty = 5, col = "purple", alpha = 0.7)
      lapply(0:2 * 10, f, col = "black")
    
      dev.off()
      
      knitr::include_graphics(filename)
    }
    
    do_text2(agg)
    do_text2(wgpugd)
    

    Created on 2022-02-20 by the reprex package (v2.0.1)

    opened by yutannihilation 0
Native WebGPU implementation based on gfx-hal

This is an active GitHub mirror of the WebGPU implementation in Rust, which now lives in "gfx/wgpu" of Mozilla-central. Issues and pull requests are a

Rust Graphics Mages 6.5k Jan 9, 2023
A vector graphics renderer using OpenGL with a Rust & C API.

bufro A vector graphics renderer using OpenGL with a Rust & C API. A Rust example can be found in examples/quickstart.rs (using glutin). A C example c

Aspect 9 Dec 15, 2022
Kiss3d - Keep it simple, stupid 3d graphics engine for Rust.

Kiss3d - Keep it simple, stupid 3d graphics engine for Rust.

Sébastien Crozet 1.2k Dec 26, 2022
A little cross-platform graphics engine written in rust.

Bismuth This is a version of my C++ graphics engine named Bismuth re-written with Rust. My goal is to learn more about the Rust language and make my g

Admiral サイタマ 1 Nov 1, 2021
Rust bindings to bgfx, a cross-platform, graphics API agnostic

Rust bindings to bgfx, a cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.

Daniel Collin 65 Dec 24, 2022
Graphite is a digital content creation software package for 2D graphics

Powerful 2D vector and raster editing. Procedural and nondestructive. Graphite is a digital content creation software package for 2D graphics, merging

Graphite 2.1k Jan 9, 2023
Generic framebuffer implementation in Rust for use with embedded-graphics library

Fraramebuffer implementation for Rust's Embedded-graphics Framebuffer approach helps to deal with display flickering when you update multiple parts of

Bernard Kobos 9 Nov 29, 2022
A 2D vector graphics library optimized for GUIs, written in Rust and wgpu

RootVG A 2D vector graphics library optimized for GUIs, written in Rust and wgpu How it Works Unlike other 2D vector graphics libraries which have a s

Meadowlark 14 Jul 10, 2024
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
Android Device Pool - A tool to run device tests against a pool of devices.

adp (Android Device Pool) What is this? A tool to run device tests against a pool of devices. It will 'checkout' a device to run your tests against an

Evan Tatarka 1 Oct 21, 2021