Shader "Custom/holo"
{
	Properties
	{
   _MainTex("Albedo (RGB)", 2D) = "white" {}
	_Color("Color", Color) = (1,1,1,1)
	}
		SubShader
	{
	Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
	CGPROGRAM
	#pragma surface surf Lambert alpha:fade
	sampler2D _MainTex;
	float4 _Color;
	struct Input
	{
	float2 uv_MainTex;
	float3 viewDir;
	};
	void surf(Input IN, inout SurfaceOutput o)
	{
	fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
	//o.Albedo = 0;
	o.Emission = _Color.rgb;
	//rim
	float rim = saturate(dot(o.Normal, IN.viewDir));
	//o.Emission = pow(1 - rim, 3);
	o.Alpha = pow(1 - rim, 3);
	}
	ENDCG
	}
		FallBack "Diffuse"
}

 

 

++++

 

홀로그램 깜박임 추가

 

Shader "Custom/holo"
{
	Properties
	{
		_MainTex("Albedo (RGB)", 2D) = "white" {}
		_Color("Color", Color) = (1,1,1,1)
		_RimPow("Power", Range(1,10)) = 3
		_Speed("Speed", Range(1,5)) = 3
	}

		SubShader
	{
		Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
		CGPROGRAM
		#pragma surface surf Lambert alpha:fade
		sampler2D _MainTex;
		float4 _Color;
		float _RimPow;
		float _Speed;

		struct Input
		{
			float2 uv_MainTex;
			float3 viewDir;
		};

		void surf(Input IN, inout SurfaceOutput o)
		{
			fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
			//o.Albedo = 0;
			o.Emission = _Color.rgb;
			//rim
			float rim = saturate(dot(o.Normal, IN.viewDir));
			//o.Emission = pow(1 - rim, 3);
			//o.Alpha = pow(1 - rim, _RimPow);
			//o.Alpha = rim * sin(_Time.y * _Speed); // 홀로그램 깜박임
			//o.Alpha = rim * sin(_Time.y * 0.5 + 0.5); //하프 램버트
			o.Alpha = rim * sin(abs(_Time.y)); //절대 값
		}
		ENDCG
	}
		FallBack "Diffuse"
}

 

 

+++

월드 좌표계에 따른 변화

 

 

Shader "Custom/holo"
{
	Properties
	{
		_MainTex("Albedo (RGB)", 2D) = "white" {}
		
	}

		SubShader
	{
		Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
		CGPROGRAM
		#pragma surface surf Lambert alpha:fade
		sampler2D _MainTex;
		

		struct Input
		{
			float2 uv_MainTex;
			float3 viewDir;
			float worldPos;
		};

		void surf(Input IN, inout SurfaceOutput o)
		{
			fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
			o.Emission = IN.worldPos;
			float ndotv = saturate(dot(o.Normal, IN.viewDir));
			float rim = pow(1 - ndotv, 3);
			o.Alpha = 1;
		}
		ENDCG
	}
		FallBack "Diffuse"
}

 

 

+++

 

홀로그램 처럼 줄무늬가 위로 올라가는 효과 추가

 

Shader "Custom/holo"
{
	Properties
	{
	_MainTex("Albedo (RGB)", 2D) = "white" {}
	}
		SubShader
	{
	Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
	CGPROGRAM
	#pragma surface surf Lambert alpha:fade noambient
	sampler2D _MainTex;

	struct Input
	{
	float2 uv_MainTex;
	float3 viewDir;
	float3 worldPos;
	};
	void surf(Input IN, inout SurfaceOutput o)
	{

	fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
	//o.Emission = pow(frac(IN.worldPos.g * 3 - _Time.y), 30);
	//o.Emission = pow(frac(IN.worldPos.g), 30);


	//color
	o.Emission = float3(0, 1, 0);

	//holo effect
	float holo = pow(frac(IN.worldPos.g * 3 - _Time.y),30);

	//rim
	float ndotv = saturate(dot(o.Normal, IN.viewDir));
	float rim = pow(1 - ndotv, 3);

	float alpha = rim + holo;
	o.Alpha = alpha;
	}

	float4 Lighting_NoLight(SurfaceOutput s, float3 lightDir, float atten) {
		return float4(0, 0, 0, s.Alpha);
	}
	ENDCG
	}
		FallBack "Transparet/Diffuse"
}
반응형

+ Recent posts