-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01_getting_start.dib
More file actions
72 lines (53 loc) · 1.32 KB
/
01_getting_start.dib
File metadata and controls
72 lines (53 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!meta
{"kernelInfo":{"defaultKernelName":"csharp","items":[{"aliases":[],"name":"csharp"}]}}
#!markdown
## Build Project
#!pwsh
dotnet build "../ShaderNote.sln"
#!csharp
#r "../ShaderNote/bin/Debug/net7.0/ShaderNote.dll"
#r "nuget:Vortice.Direct3D11"
#r "nuget:Vortice.D3DCompiler"
#r "nuget:SixLabors.ImageSharp"
#!markdown
## Add Interactive Support
#!csharp
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);
#!markdown
## Render
#!csharp
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("POSITION0", 12, data: new Vector3[]
{
new(0,0,0),
new(1,0,0),
new(0,1,0),
new(1,1,0),
})
.WithVertexBuffer("TEXCOORD0", 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");
//View Result
render