Archive for December, 2009

Hello, World! program on HLSL


If someone is missing real “Hello, World” program written in a shader language, here it is.

Pixel shader HLSL, shader model 3.0  (in effects file); pixel shader only, that takes as input only u,v.

More serious challenge could be to write Quine program, but I have other things to do.

const int L[18]={
	0xad27,	0xa925,	0xED25,	0xa925,	0xaDB7,	0x0000,
	0x85eE,	0x852b,	0xad2b,	0xf92e,	0x712b,	0x51e9,	0x0000,
	0xC3CF,	0xc36f,	0xc326,	0xc360,	0xf3cf
float4 PS(float2 tex : TEXCOORD0):COLOR0
	float4 output = float4(0,tex.x,tex.y,1);
	int x= (1-tex.x)*16;
	int y= (1-tex.y)*18;
	//no bitwise ioerations on shadermodel 3 yet :(
	int mask=L[y]*2;
	for (int i = 0; i<16&& i <x; i++)
		mask*=0.5;output.r = ( frac(0.5*mask) < 0.1);
	return output;