Shader "Yee/AnisotropicSpec" {

Properties {

_Color ("Color", Color) = (1,1,1,1)

_MainTex ("Albedo (RGB)", 2D) = "white" {}

[Normal]_Normal("Normal", 2D) = "bump"{}

_NormalPow("NormalPow", Range(0, 3)) = 1


_AnisoAngleX("AnisoAngle", float) = 0

_AnisoAngleY("AnisoAngle", float) = 0

_AnisoAngleZ("AnisoAngle", float) = 0

_AnisoOffset("AnisoOffset", Range(-1, 1)) = -0.2

[powslide(100)]_AnisoPow("AnisoPow", Range(1, 100)) = 1

[HDR]_SpecColor2("SpecColor2", Color) = (1, 1, 1, 1)



}

SubShader {

Tags { "RenderType"="Opaque" }

LOD 200


cull off


CGPROGRAM

// Physically based Standard lighting model, and enable shadows on all light types

#pragma surface surf NoLighting fullforwardshadows


// Use shader model 3.0 target, to get nicer looking lighting

#pragma target 3.0


sampler2D _MainTex;

sampler2D _Normal;


struct Input {

float2 uv_MainTex;

float2 uv_Normal;

};


fixed4 _Color;

half _NormalPow;

half _AnisoAngleX;

half _AnisoAngleY;

half _AnisoAngleZ;

half _AnisoOffset;

half _AnisoPow;

half3 _SpecColor2;


// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.

// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.

// #pragma instancing_options assumeuniformscaling

UNITY_INSTANCING_BUFFER_START(Props)

// put more per-instance properties here

UNITY_INSTANCING_BUFFER_END(Props)


void surf (Input IN, inout SurfaceOutput o) {

// Albedo comes from a texture tinted by color

fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;

o.Normal = lerp(o.Normal, UnpackNormal(tex2D(_Normal, IN.uv_Normal)), _NormalPow);

o.Albedo = c.rgb;

o.Alpha = c.a;

}


//์ด๋ฐฉ์„ฑ ํ•˜์ด๋ผ์ดํŠธ ๊ณ„์‚ฐ

fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed3 viewDir, fixed atten)

{

fixed4 c;


fixed3 h = normalize(normalize(lightDir) + normalize(viewDir)); //๋ผ์ดํŠธ๊ฐ๋„, ๋ทฐ๊ฐ๋„ ๋…ธ๋ฉ€๋ผ์ด์ฆˆ

//half NdotL = saturate(dot(s.Normal, lightDir)); //S๋…ธ๋ฉ€, ๋ผ์ดํŠธ ๊ฐ๋„ ๋‚ด์ 


half HdotA = dot(normalize(s.Normal + half3(_AnisoAngleX, _AnisoAngleY, _AnisoAngleZ)), h); //๋…ธ๋ฉ€ + ์ปค์Šคํ…€์•ต๊ธ€์„ ๋ผ์ดํŠธ, ๋ทฐ๊ฐ๋„๋…ธ๋ฉ€๋ผ์ด์ฆˆ์™€ ๋‚ด์ 

half aniso = max(0, sin(radians(HdotA + _AnisoOffset) * 180));


c.rgb = saturate(pow(aniso, _AnisoPow)) * _SpecColor2;

//c.rgb = s.Albedo;

c.a = s.Alpha;

return c;

}

ENDCG

}

FallBack "Diffuse"

}



๋จธ๋ฆฌ์นด๋ฝ์—์„œ ๋งŽ์ด ์‚ฌ์šฉ๋˜๋Š” ์ด๋ฐฉ์„ฑ ์ŠคํŽ™ํ˜๋Ÿฌ ์‰์ด๋”์ž…๋‹ˆ๋‹ค.

์ฐธ๊ณ  ํ•˜์‹ค๋ถ„์€ ์ฐธ๊ณ  ํ•˜์‹œ๊ธธ.....


๋ถ•๊ดด3๋„ ๋จธ๋ฆฌ์นด๋ฝ ํ•˜์ด๋ผ์ดํŠธ ์ด๋ ‡๊ฒŒ ์ฒ˜๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค.


์•ŒํŒŒ ๊ณ„์‚ฐ์‹์€ ๊ท€์ฐฎ์•„์„œ ์•ˆ๋„ฃ์—ˆ๋Š”๋ฐ ์ถ”๊ฐ€ํ•ด์„œ ๋„ฃ์œผ์‹œ๋ฉด ๋  ๊ฒƒ ๊ฐ™๋„ค์š” =_=a

(์•ŒํŒŒ ํ…์Šค์ณ๊ฐ€ ์—†์—ˆ์Œ.... ์ฟจ๋Ÿญ)


์ฐธ๊ณ ๋กœ ์œ ๋‹ˆํ‹ฐ HDRP์—์„œ๋ถ€ํ„ฐ๋Š” ๊ธฐ๋ณธ ์ œ๊ณต์ธ๊ฑด ํ•จ์ •..... ใ…‹