The book of inspiration

October 28, 2009

C# to HLSL

Filed under: tech — Tags: , — zproxy @ 8:55 am

Jim has found a C# to HLSL compiler. Do you still think code is not data? :)

ThumbBl thumbB = new ThumbBl(canvas) {
  Background = Brushes.Blue, LeftTop = new PointBl(0,0), CanDrag = true
};
label.Effect.Custom = (input, uv) => {
  /*L1*/ PointBl p = label.RenderTransform.Inverse.
   Transform(thumbB.CenterPosition - label.LeftTop);
  /*L2*/ PointBl q = uv * label.Size;
  /*L3*/ DoubleBl d = (p - q).Length;
  /*L4*/ d = 1 - (d / 500).Min(1);
  /*L5*/ ColorBl clr = (d).Lerp(Colors.Black, Colors.Blue);
  /*L6*/ return ColorBl.FromScRgb
    ((input[uv].ScA).Min((1 - (d * d)).Max(.4)), clr.ScRGB);
};
About these ads

2 Comments »

  1. [...] jsc also support converting (C#, F#) IL to HLSL [...]

    Pingback by WebGL on Old Hardware with MESA « c# to javascript, actionscript — March 9, 2010 @ 8:04 am

  2. [...] you want to program your shaders in C# instead? It would look something like this once [...]

    Pingback by Write WebGL in C# with JSC « c# to javascript, actionscript — July 12, 2010 @ 7:09 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Shocking Blue Green. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 30 other followers

%d bloggers like this: