82 lines
2.2 KiB
Plaintext
82 lines
2.2 KiB
Plaintext
Shader "AR/StylizedPenguin" {
|
|
|
|
Properties {
|
|
_MainTex ("Penguin Texture", 2D) = "white" {}
|
|
}
|
|
|
|
SubShader{
|
|
Tags { "RenderType" = "Opaque" }
|
|
|
|
Pass {
|
|
|
|
Cull Off
|
|
|
|
|
|
CGPROGRAM
|
|
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
#include "UnityCG.cginc"
|
|
|
|
|
|
fixed4 _Color;
|
|
|
|
struct Input {
|
|
float4 position : POSITION;
|
|
float4 color : COLOR;
|
|
float2 coord : TEXCOORD0;
|
|
half3 normal : NORMAL;
|
|
};
|
|
|
|
struct VertexToFragment {
|
|
float4 position : SV_POSITION;
|
|
float4 color : COLOR;
|
|
float2 coord : TEXCOORD0;
|
|
half3 normal : NORMAL;
|
|
};
|
|
|
|
VertexToFragment vert(Input IN) {
|
|
VertexToFragment OUT;
|
|
OUT.position = UnityObjectToClipPos( IN.position);
|
|
OUT.color = IN.color;
|
|
OUT.coord = IN.coord;
|
|
OUT.normal = UnityObjectToWorldNormal(IN.normal);
|
|
return OUT;
|
|
}
|
|
|
|
sampler2D _MainTex;
|
|
float2 _NoiseVector;
|
|
|
|
|
|
fixed4 frag(VertexToFragment IN) : SV_Target {
|
|
|
|
half4 c = tex2D(_MainTex, IN.coord);
|
|
|
|
float3 forward = mul((float3x3)unity_CameraToWorld, float3(0,0,1));
|
|
|
|
|
|
|
|
if (dot(normalize(forward), normalize(-1*IN.normal)) < 0.55) {
|
|
c.rgb = float3(0,0,0);
|
|
} else {
|
|
c.rgb = float3(255,255,255);
|
|
}
|
|
|
|
|
|
float rand = frac(sin(dot(IN.position, _NoiseVector)) * 43758.5453);
|
|
if (rand < 0.03) {
|
|
if (c.r == 0) {
|
|
c.rgb = float3(255, 255, 255);
|
|
} else {
|
|
c.rgb = float3(0,0,0);
|
|
}
|
|
}
|
|
|
|
return c;
|
|
}
|
|
|
|
ENDCG
|
|
}
|
|
}
|
|
} |