Interpreting GLSL

Its a bit much to ask but can someone help me interpret this to Shaderlab. Seems fairly lightweight.
This is my first go around with hand coding shaders having used Strumpy up till now.

uniform float exposure;
 uniform float decay;
 uniform float density;
 uniform float weight;
 uniform vec2 lightPositionOnScreen;
 uniform sampler2D firstPass;
 const int NUM_SAMPLES = 100 ;

 void main()
 {

  vec2 deltaTextCoord = vec2( gl_TexCoord[0].st - lightPositionOnScreen.xy );
  vec2 textCoo = gl_TexCoord[0].st;
  deltaTextCoord *= 1.0 / float(NUM_SAMPLES) * density;
  float illuminationDecay = 1.0;


  for(int i=0; i < NUM_SAMPLES ; i++)
   {
     textCoo -= deltaTextCoord;
     vec4 sample = texture2D(firstPass, textCoo );
          sample *= illuminationDecay * weight;
          gl_FragColor += sample;
          illuminationDecay *= decay;
  }
  gl_FragColor *= exposure;
}

So far I’m up to this.

Shader "Custom/CrepRays" {
	Properties {
		_decay("_decay", Float) = 1
		_exposure("_exposure", Float) = 1
		_density("_density", Float) = 1
		_weight("_weight", Float) = 1
		_firstpass("_firstpass", 2D) = "black" {}
		_numSamples("_numSamples", Float) = 0
		
	}
	SubShader {
		
		CGPROGRAM
		#include "UnityCG.cginc"
		#pragma surface surf Lambert
		
		float _decay;
		float _exposure;
		float _density;
		float _weight;
		sampler2D _firstpass;
		float _numSamples;
		half2 deltaTextCoord;

		struct Input 
		{
			float2 texcoord : TEXCOORD2;
			float viewAngle : TEXCOORD1;
		};
		
		void main()
		{
			float2 deltaTextCoord;
			float2 textCoo;
			deltaTextCoord *= 1.0 / _numSamples * _density;
		}
		

		void surf (Input IN, inout SurfaceOutput o) 
		{
		
		}
		
		ENDCG
	}
}

The main problem is that you have to know what data should go into lightPositionOnScreen and gl_TexCoord[0].st . (I assume these are positions in screen coordinates, I don’t know how to specify them in Cg; google NVIDIA’s Cg tutorial to find out.) Furthermore, it looks like you need a grab pass and access the grabbed texture (see the Unity shaderlab documentation). And NUM_SAMPLES cannot be a uniform if it appears as limit of a loop.

What is that shader supposed to do? Godrays?
As all it does seems to be some radial blur with some weighting stuff.
This and the fact that it is just one function lead to the conclusion that it is a postprocessing effect which means that surface shaders are not the way to go ;).
Just look at some other prostprocessing effect, make all uniforms available in unity and replace the fragment shader with yours. As this is a very simple effect without any special effect chaining or matrices or whatever required, it should not be very hard to get it to work.

Basically yes, its a post process blur that emulates god rays. This is taken out of GPU Gems 3:
http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html

It seemed to me like a pretty good implementation. Yes Martin, lightPositionOnScreen would be the view direction for unity. After reading the article I have a basic understanding of what it does, its just writing something comparable is the challenge before me. What I don’t know is if this might perform any better than the Pro U3 sunshaft effect.

Thanks for the replies gents!