Giter Club home page Giter Club logo

shadernote's Introduction

ShaderNote

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

入门

using ShaderNote;
using System.Numerics;
NoteDevice noteDevice = new NoteDevice();

var render = noteDevice.GetRecord()
    .WithVertexShader("Shaders/VertexShader.hlsl")
    .WithPixelShader("Shaders/PixelShader.hlsl")
    .WithIndexBuffer(data: new ushort[] { 0, 2, 1, 1, 2, 3 })
    .WithVertexBuffer(0, 12, data: new Vector3[]
    {
        new(0,0,0),
        new(1,0,0),
        new(0,1,0),
        new(1,1,0),
    })
    .WithVertexBuffer(1, 8, data: new Vector2[]
    {
        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. 注册格式

using Microsoft.DotNet.Interactive.Formatting;
using ShaderNote;

Formatter.Register<RenderRecord>((w)=>
{
    var result = w.Render();
    string html = result.GetHtml();
    result.Dispose();
    return html;
},HtmlFormatter.MimeType);
  1. 将RenderRecord类型置于单元格最后,不要加分号。
var render = noteDevice.GetRecord()
    .WithVertexShader("Shaders/VertexShader.hlsl")
    .WithPixelShader("Shaders/PixelShader.hlsl")
    .WithIndexBuffer(data: new ushort[] { 0, 2, 1, 1, 2, 3 })
    .WithVertexBuffer(0, 12, data: new Vector3[]
    {
        new(0,0,0),
        new(1,0,0),
        new(0,1,0),
        new(1,1,0),
    })
    .WithVertexBuffer(1, 8, data: new Vector2[]
    {
        new(0,0),
        new(1,0),
        new(0,1),
        new(1,1),
    })
    .WithSampler(0)
    .WithImage(0, "sample.png")
    .WithDrawIndexed(6);
//用于显示
render

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

shadernote's People

Contributors

sselecirpym avatar

Stargazers

王先生 avatar Daachun avatar Sixerrr avatar Runarry avatar Reguluz avatar DearIce avatar  avatar  avatar RoarlisF/KP31 avatar

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.