Skip to content

Instantly share code, notes, and snippets.

@abhishtagatya
Created December 9, 2025 18:05
Show Gist options
  • Select an option

  • Save abhishtagatya/c4ca1285b92ba4ff6fbb024b3c5a0352 to your computer and use it in GitHub Desktop.

Select an option

Save abhishtagatya/c4ca1285b92ba4ff6fbb024b3c5a0352 to your computer and use it in GitHub Desktop.
struct texFunc {
float2 rotate(float2 uv, float angle) {
float2x2 rotMat = float2x2(cos(angle), sin(angle), -sin(angle), cos(angle));
return mul(uv - 0.5, rotMat) + 0.5;
}
float2 scale(float2 uv, float factor) {
return (uv - 0.5) * factor + 0.5;
}
} tf;
float3 normal = normalize(Normal);
float3 tangent = normalize(Tangent);
float3 bitangent = cross(normal, tangent);
float3 rayDir = -ViewDir;
float4 tex = Texture2DSample(Texture, TextureSampler, UV);
float2 uvStep;
uvStep.x = dot(rayDir, tangent) * Gap;
uvStep.y = dot(rayDir, bitangent) * Gap;
for (int i = 1; i <= Step; i++) {
if (tex.r < Threshold + i * Threshold * 5.0) {
float f = (Step - (i - 1)) / Step;
return float3(f,f,f);
}
UV += uvStep;
tex = Texture2DSample(Texture, TextureSampler, UV.xy);
}
return float3(1,1,1) / Step;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment