Skip to content
プロジェクト

概要

Vite plugin to use Slang shaders on the web.

デザイン・メディア

この数値の測り方

計測したスター増加

24時間
0
7日間
0
15日間
0
1か月
0

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

Size Version Downloads

vite-slang

Vite plugin for importing and compiling Slang shaders to run on the web (WebGL/WebGPU).

// vite.config.js
import { defineConfig } from 'vite'
import slang from 'vite-slang'

export default defineConfig({
  plugins: [slang()],
})

Usage

// shader.slang
struct VertexStageInput
{
    float4 position : POSITION0;
};

struct VertexStageOutput
{
    float4 positionClipSpace : SV_POSITION;
};

struct FragmentStageOutput
{
    float4 color : SV_TARGET;
};

[shader("vertex")]
VertexStageOutput vertexMain(VertexStageInput input) : SV_Position
{
    VertexStageOutput output;
    output.positionClipSpace = float4(input.position.xy, 1);
    return output;
}

[shader("fragment")]
FragmentStageOutput fragmentMain() : SV_Target
{
    FragmentStageOutput output;
    output.color = float4(0, 1, 0, 1);
    return output;
}
// app.js
import code from './shader.slang'
import { code, reflection } from './shader.slang'

const shader = device.createShaderModule({ code })

const pipeline = device.createRenderPipeline({
  vertex: {
    module: shader,
    entryPoint: 'vertexMain',
  },
  fragment: {
    module: shader,
    entryPoint: 'fragmentMain',
    targets: [{ format: 'bgra8unorm' }],
  },
  layout: 'auto',
})

console.log(reflection) // metadata about entry points, bindings, etc.

関連プロジェクトを探す

読み込み中…