Shader Languages

The other day I wrote:

The other day Cody Russell was asking on IRC what we could do in the Mono universe to take advantage of some special instruction sets like SIMD or how to use C# to generate code for pixel shaders or vertex shaders.

One idea that we discussed was the creation of a library that would be able to expose this kind of functionality.

jeevan.james pointed out on the comments to that blog entry that there is already a project that is working on precisely this idea.

The project is called Brahma-FX and is hosted at SourceForge. And its implemented in a similar spirit that I described on that post.

They use C# as the language to express the shading operations, they decompile the code at runtime and compile that to the hardware specific shading system.

For example to invert an image, they write:


	public override void Compute (Vector2 kernel_position)
	{
		Vector4 color = Sample2D (0, kernel_position);
		Output = new Vector4 (1.0f - color.X, 1.0f - color.Y, 1.0f - color.Z, 1.0f);
	}
	

Currently they have a compiler only for DirectX (and stubs for OpenGL and XNA) it looks like a great project to contribute to.

Ananth's blog is here.

Posted on 19 Mar 2007 by Miguel de Icaza
This is a personal web page. Things said here do not represent the position of my employer.