项目
在 GitHub 查看
CodyJasonBennett/vite-slang
关于
Vite plugin to use Slang shaders on the web.
设计与媒体实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 0
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文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.
探索相关项目
加载中…