Skip to content

Instantly share code, notes, and snippets.

@GuyInGrey
Created March 17, 2021 15:33
Show Gist options
  • Save GuyInGrey/7301b05423459c3f5a77b7cdfea14df0 to your computer and use it in GitHub Desktop.
Save GuyInGrey/7301b05423459c3f5a77b7cdfea14df0 to your computer and use it in GitHub Desktop.
public readonly struct MandelbrotShader : IComputeShader
{
public readonly ReadWriteTexture2D<Rgba32, Float4> image;
public readonly Float4 viewport;
public readonly int maxIterations;
public readonly float power;
public MandelbrotShader(
ReadWriteTexture2D<Rgba32, Float4> image,
Float4 viewport,
int maxIterations,
float power
) {
this.image = image;
this.viewport = viewport;
this.maxIterations = maxIterations;
this.power = power;
}
public void Execute()
{
var pX = ThreadIds.X;
var pY = ThreadIds.Y;
var cX = Hlsl.Lerp(pX / image.Width, viewport.X, viewport.W);
var cY = Hlsl.Lerp(pY / image.Height, viewport.Y, viewport.Z);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment