Skip to content

Repository files navigation

ShaderNote

用于快速验证着色器效果的工具。

入门

usingShaderNote;usingSystem.Numerics;NoteDevicenoteDevice=newNoteDevice();varrender=noteDevice.GetRecord().WithVertexShader("Shaders/VertexShader.hlsl").WithPixelShader("Shaders/PixelShader.hlsl").WithIndexBuffer(data:newushort[]{0,2,1,1,2,3}).WithVertexBuffer(0,12,data:newVector3[]{new(0,0,0),new(1,0,0),new(0,1,0),new(1,1,0),}).WithVertexBuffer(1,8,data:newVector2[]{new(0,0),new(1,0),new(0,1),new(1,1),}).WithSampler(0).WithImage(0,"sample.png").WithDrawIndexed(6);render.Save("test.png");

在Polyglot Notebooks使用Shader Note

  1. 安装.Net 7 SDK

  2. 在Visual Studio Code中安装Polyglot Notebooks扩展

  3. 注册格式

usingMicrosoft.DotNet.Interactive.Formatting;usingShaderNote;Formatter.Register<RenderRecord>((w)=>{varresult=w.Render();stringhtml=result.GetHtml();result.Dispose();returnhtml;},HtmlFormatter.MimeType);
  1. 将RenderRecord类型置于单元格最后,不要加分号。
varrender=noteDevice.GetRecord().WithVertexShader("Shaders/VertexShader.hlsl").WithPixelShader("Shaders/PixelShader.hlsl").WithIndexBuffer(data:newushort[]{0,2,1,1,2,3}).WithVertexBuffer(0,12,data:newVector3[]{new(0,0,0),new(1,0,0),new(0,1,0),new(1,1,0),}).WithVertexBuffer(1,8,data:newVector2[]{new(0,0),new(1,0),new(0,1),new(1,1),}).WithSampler(0).WithImage(0,"sample.png").WithDrawIndexed(6);//用于显示
render

你可以在examples文件夹下找到示例。

About

Write and debug Shader in an easy way.

Resources

Stars

9 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages