Switch hello world WinRT shader to primary constructor
このコミットが含まれているのは:
1 親
f4efb00a96
コミット
147f3af32f
1ファイル変更
+8
-17
@@ -14,10 +14,10 @@ public sealed partial class HelloWorldEffect : CanvasEffect
|
||||
/// </summary>
|
||||
private static readonly CanvasEffectNode<PixelShaderEffect<Shader>> EffectNode = new();
|
||||
|
||||
/// <inheritdoc cref="Shader.time"/>
|
||||
/// <summary><inheritdoc cref="Shader(float, Int2)" path="/param[@name='time']/node()"/></summary>
|
||||
private float time;
|
||||
|
||||
/// <inheritdoc cref="Shader.dispatchSize"/>
|
||||
/// <summary><inheritdoc cref="Shader(float, Int2)" path="/param[@name='dispatchSize']/node()"/></summary>
|
||||
private Rect dispatchArea;
|
||||
|
||||
/// <summary>
|
||||
@@ -55,8 +55,10 @@ public sealed partial class HelloWorldEffect : CanvasEffect
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The D2D1 shader for <see cref="HelloWorldEffect"/>.
|
||||
/// A hello world effect that displays a color gradient.
|
||||
/// </summary>
|
||||
/// <param name="time">The current time since the start of the application.</param>
|
||||
/// <param name="dispatchSize">The dispatch size for the current output.</param>
|
||||
[D2DEffectDisplayName(nameof(HelloWorldEffect))]
|
||||
[D2DEffectDescription("A hello world effect that displays a color gradient.")]
|
||||
[D2DEffectCategory("Render")]
|
||||
@@ -65,25 +67,14 @@ public sealed partial class HelloWorldEffect : CanvasEffect
|
||||
[D2DRequiresScenePosition]
|
||||
[D2DShaderProfile(D2D1ShaderProfile.PixelShader50)]
|
||||
[D2DGeneratedPixelShaderDescriptor]
|
||||
[AutoConstructor]
|
||||
internal readonly partial struct Shader : ID2D1PixelShader
|
||||
internal readonly partial struct Shader(float time, int2 dispatchSize) : ID2D1PixelShader
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time since the start of the application.
|
||||
/// </summary>
|
||||
private readonly float time;
|
||||
|
||||
/// <summary>
|
||||
/// The dispatch size for the current output.
|
||||
/// </summary>
|
||||
private readonly int2 dispatchSize;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public float4 Execute()
|
||||
{
|
||||
int2 xy = (int2)D2D.GetScenePosition().XY;
|
||||
float2 uv = xy / (float2)this.dispatchSize;
|
||||
float3 color = 0.5f + (0.5f * Hlsl.Cos(this.time + new float3(uv, uv.X) + new float3(0, 2, 4)));
|
||||
float2 uv = xy / (float2)dispatchSize;
|
||||
float3 color = 0.5f + (0.5f * Hlsl.Cos(time + new float3(uv, uv.X) + new float3(0, 2, 4)));
|
||||
|
||||
return new(color, 1f);
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする