Added a simple "HelloWorld" shader based on shadertoy/new to the SwapChain sample shaders to make it easier to understand and get started with making custom shaders.

このコミットが含まれているのは:
patan77 committed 2021-10-19 11:47:15 +02:00
1 親 d935bc1a09
コミット aebdf002d6
2ファイル変更
+30

検索条件に一致するファイルはありません

+1
ファイルの表示
@@ -20,6 +20,7 @@ namespace ComputeSharp.SwapChain
/// </summary>
private static readonly Win32Application[] Samples = new Win32Application[]
{
new SwapChainApplication<HelloWorld>(static time => new((float)time.TotalSeconds)),
new SwapChainApplication<ColorfulInfinity>(static time => new((float)time.TotalSeconds)),
new SwapChainApplication<FractalTiling>(static time => new((float)time.TotalSeconds)),
new SwapChainApplication<TwoTiledTruchet>(static time => new((float)time.TotalSeconds)),
+29
ファイルの表示
@@ -0,0 +1,29 @@
namespace ComputeSharp.SwapChain.Shaders
{
/// <summary>
/// A simple shader to get started with based on shadertoy new shader template.
/// Ported from <see href="https://www.shadertoy.com/new"/>.
/// </summary>
///
[AutoConstructor]
internal readonly partial struct HelloWorld : IPixelShader<Float4>
{
/// <summary>
/// The current time since the start of the application.
/// </summary>
public readonly float time;
/// <inheritdoc/>
public Float4 Execute()
{
// Normalized ScreenSpace UV coordinates from 0.0f to 1.0f
Float2 uv = new Float2(ThreadIds.Normalized.X, ThreadIds.Normalized.Y);
// Time varying pixel color
Float3 col = 0.5f + 0.5f * Hlsl.Cos(time + new Float3(uv, uv.X) + new Float3(0, 2, 4));
// Output to screen
return new(col, 1f);
}
}
}