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
}
}