Skip to content
rookboom edited this page Nov 12, 2012 · 67 revisions

SharpShaders is a library that allows you to write GPU shader code in F#.

ColoredCube Golfball Marbled Lumpy Crinkled

Why write shaders in F#?

Shader translation using code quotations ####Examples

####Future Work

  • Runtime code compilation
    • It should be possible to edit an F# shader and immediately see the result at runtime (if the changed shader compiles of course)
  • Dynamic Shader Linking
    • The Dynamic attribute on shader functions should indicate that this function can be swapped at runtime
[<Dynamic>]
let marble = ...
[<Dynamic>]
let lumpy = ...
[<Dynamic>]
let crinkled = ...

let mutable surface = marble

[<PixelShader>]
member m.pixel(input:PSInput) =
    surface input

At runtime the surface shader can be swapped:

ps.surface <- ps.crinkled
Clone this wiki locally