Notice
Recent Posts
Recent Comments
Link
스토리지
[5.7] 외곽선 연습 본문
1. 두께와 색깔을 조절할 수 있는 Property 만들기
Shader "Custom/Test"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_StrokePower ("Stroke Power", Float) = 1
_MainTex ("Albedo (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
Cull Front
CGPROGRAM
#pragma surface surf NoLight noshadow noambient vertex:vert
float _StrokePower;
fixed4 _Color;
void vert(inout appdata_full v)
{
v.vertex.xyz += v.normal.xyz * _StrokePower / 100;
}
struct Input
{
float4 color:Color;
};
void surf (Input IN, inout SurfaceOutput o)
{
}
float4 LightingNoLight(SurfaceOutput s, float3 lightDir, float atten)
{
return float4(_Color.rgb, 1);
}
ENDCG
Cull Back
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
2. 외곽선 컬러나 두께에 애니메이션 넣기 (임시)
Shader "Custom/Test"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_StrokePower ("Stroke Power", Float) = 1
_Sample ("Sample", 2D) = "white" {}
_MainTex ("Albedo (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
Cull Front
CGPROGRAM
#pragma surface surf NoLight noshadow noambient vertex:vert
sampler2D _MainTex;
sampler2D _Sample;
float _StrokePower;
fixed4 _Color;
void vert(inout appdata_full v)
{
v.vertex.xyz += v.normal.xyz * _StrokePower / 100;
}
struct Input
{
float2 uv_MainTex;
float2 uv_Sample;
float4 color:Color;
};
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D (_Sample, IN.uv_Sample - _Time.y * 0.5);
o.Emission = float4(_Color.rgb, 1) * c.b * 3;
o.Alpha = 0;
}
float4 LightingNoLight(SurfaceOutput s, float3 lightDir, float atten)
{
return float4(s.Emission, s.Alpha);
}
ENDCG
Cull Back
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
색깔은 uv에 없어서 어떻게 해야할지 감이 잘 오지 않는다.
코드에서 쓴 방법말고 다른 방법이 있을것 같다.
'Unity > Shader' 카테고리의 다른 글
[5.7] Warped Diffuse (0) | 2021.05.07 |
---|---|
[5.7] 밝기에 따른 영역 나누기 (0) | 2021.05.07 |
[5.7] 외곽선 (0) | 2021.05.07 |
[5.7] BlinnPhong Specular 연습 (0) | 2021.05.07 |
[5.7] 홀로그램 및 Lambert & BlinnPhong 빛 연산 연습 (0) | 2021.05.07 |
Comments