Hi all,

I'm still a beginner in shading (started a month ago) but i've been able to implement some nice shader in my custom project (that I mostly use as a test bed for OpenGL and CG stuff) and so I know the basics. I know my question is more shader in general than GLSL but anyway...

I'm trying to implement this : http://www.catalinzima.com/2010/07/m...ic-2d-shadows/

Right now, I was able to do the white/black, distance and distort shader and get the desired result. But I'm at a lost on how to do the Horizontal Reduction Shader.

float4 HorizontalReductionPS(float2 TexCoord : TEXCOORD0) : COLOR0
float2 color = tex2D(inputSampler, TexCoord);
float2 colorR = tex2D(inputSampler, TexCoord + float2(TextureDimensions.x,0));

float2 result = min(color,colorR);
return float4(result,0,1);

From what I understand the shader compare the pixel color to its neighbor and output the lesser value. This is what's needed to determine the nearest collision with a shadow caster. But I don't know how to actually generate this reduced 2X512 texture! I'm I supposed to do a pass, then cut the texture in 2 and do it again until the width is 2? This part of the technique is kinda quickly explained and if you can give some more details on how to achieve this, I think I might actually be done since the last pass basically just use that texture and I could easily implement that (at least I think!)

If anyone could give me a hand with this, it would be really appreciated!

I can give sample code or the whole project for that matter if it's necessary.

Thanks in advance!