Skip to content

Instantly share code, notes, and snippets.

@eddietree
Last active June 1, 2016 23:10
Show Gist options
  • Save eddietree/e34fb495b1c03559415405d8742786ae to your computer and use it in GitHub Desktop.
Save eddietree/e34fb495b1c03559415405d8742786ae to your computer and use it in GitHub Desktop.
aaron shader
v2f vert (appdata v)
{
v2f o;
v.vertex.x = frac(v.vertex.x + frac(_Time.y * .1));
//v.vertex.x = frac(v.vertex.x);
float cSize = _MainTex_TexelSize.z;
float4 cCd = float4(v.vertex.x, 0, 0, 0);
//cCd.x = floor(cCd.x * cSize) / cSize;
float4 p1 = tex2Dlod(_MainTex, float4(cCd.x - (1./cSize), cCd.yzw));
float4 p2 = tex2Dlod(_MainTex, float4(cCd));
float4 p3 = tex2Dlod(_MainTex, float4(cCd.x + (1./cSize), cCd.yzw));
float4 p4 = tex2Dlod(_MainTex, float4(cCd.x + (1./cSize), cCd.yzw));
// jitter endpoints
float randAngle = v.vertex.w;
float jitterDir0 = normalize(p3-p1);/
float jitterDir1 = perpendicular(jitterDir0);
float jitterRadius = 1.0; // MAYBE SMALLER?
float3 jitterOffset = jitterDir0 * cos(randAngle) + jitterDir1 * sin(randAngle);
p1.xyz += jitterOffset;
p2.xyz += jitterOffset;
p3.xyz += jitterOffset;
p4.xyz += jitterOffset;
pota curve = CatmullRomSpline(p1, p2, p3, p4, (cCd.x * cSize) );
//pota curve = CatmullRomSpline(p1, p2, p3, p4, _Offset);
o.vertex = mul(UNITY_MATRIX_MVP, curve.Pos);
return o;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment