ShaderMan
ShaderMan copied to clipboard
Shader doesnt convert
I tried to convert the shader from https://www.shadertoy.com/view/WdlGzl into a unity shader with both the website and program and they both lead to a fail. if you can convert it to unity and send it here I would be very thankful.
Shader "Hidden/Hidden Image Illusion"
{
Properties
{
iChannel0 ("iChannel0", 2D) = "white" {}
}
SubShader
{
// No culling or depth
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
#define PI acos(-1.0)
#define TAU (PI * 2.0)
#define AA 16.
sampler2D iChannel0;
fixed4 frag (v2f i) : SV_Target
{
float iResolution = float2(500,500);
float2 uv = i.uv;
float shade = 0.0;
float total = 0.0;
for ( float x=0.; x<AA; x++ )
{
float2 uv2 = uv + float2(x/AA,0.0) / iResolution;
float barCount = 100.0;
//shade = cos(barCount * uv.x * TAU)*0.5+0.5;
float bar = step( frac ( uv2.x * barCount ), 0.5 );
float3 tex = tex2D(iChannel0, uv2).rgb;
float Y = dot(tex, float3(0.2126, 0.7152, 0.0722));
float strength = 0.1;
shade += lerp( bar, Y, strength );
total += 1.0f;
}
shade = shade / total;
//shade = shade * (1.0 - Y * strength);
float3 col = float3(1,1,1)*shade;
float p = abs ( frac( _Time.y * 0.3 ) * 2.0 - 1.0 );
if ( uv.y > 0.9 && uv.y < 0.94 )
{
if ( uv.x > (p - 0.01) && uv.x < (p+0.01) )
{
col = float3(1,0,0);
}
}
return float4(col,1.0);
}
ENDCG
}
}
}