Unity Shader Study04

  // o.Occlusion = tex2D(_Occlusion, IN.uv_MainTex); //occlusion은 uv와 같은 텍스쳐를 받아야 된다.

Standard Shader
struct SurfaceOutputStandard
{
fixed3 Albedo; // 기본색상
fixed3 Normal; //
fixed3 Emission; // 빛의 영향을 받지 않는 색상
half Metallic; // 재질이 금속인지
half Smothness;  //재질이 매끈한지
half Occlusion; //차폐 영역
half Alpha; //알파
}

Lambert,Blinn Phong
struct SurfaceOutput
{
half3 Albedo;
half3 Normal;
half3 Emission;
half Specular; //Specular의 넓이. 얼마나 넓은 하이라이트가 나오는가 , 수치가 높으면 하이라이트가 작아진다.
half Gloss;  // Specular의 강도. 순수한 Specular의 Opacity같은 느낌
half Alpha;
}


Lambert : 단순 라이트 구조
Blinn Phong 램버트 공식에 가벼운 Specular 공식을 더한 구조
Standard : 물리 기반 쉐이더 주변 환경을 반사해 Specular을 구현하며 Diffuse 와 Specular가 에너지 보존 법칙에 의해 자동적으로 계산 되는 것

조명 벡터와 표면벡터가 마주볼때 가장 밝다.

0.5, 0.5로 위치방향을 나타낼 수 있다.


벡터 위치와 위치 사이의 벡터 방향을 이용하여 바라보는 방향을 연산

Shader "Unique/Edu01/Shader06_Me&S,Bumb" {
 Properties {
  _MainTex ("Albedo (RGB)", 2D) = "white" {}
  _Glossiness ("Smoothness", Range(0,1)) = 0.5
  _Metallic ("Metallic", Range(0,1)) = 0.0
  _BumpMap("Normalmap", 2D) = "bump"{}
  _Occlusion("Occlusion", 2D) = "white" {}
 }
 SubShader {
  Tags { "RenderType"="Opaque" }
 
  CGPROGRAM
  // Physically based Standard lighting model, and enable shadows on all light types
  #pragma surface surf Standard fullforwardshadows
  // Use shader model 3.0 target, to get nicer looking lighting
  #pragma target 3.0
  sampler2D _MainTex;
     sampler2D _BumpMap;
  sampler2D _Occlusion;
  struct Input {
   float2 uv_MainTex;
   float2 uv_BumpMap;
  };
  half _Glossiness;
  half _Metallic;
  fixed4 _Color;
  // 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_CBUFFER_START(Props)
   // put more per-instance properties here
  UNITY_INSTANCING_CBUFFER_END
  void surf (Input IN, inout SurfaceOutputStandard o) {
   // Albedo comes from a texture tinted by color
   fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
   fixed4 n = tex2D(_BumpMap, IN.uv_BumpMap);
   o.Albedo = c.rgb;
   o.Metallic = _Metallic;
   o.Smoothness = _Glossiness;
   o.Normal = n;
   o.Occlusion = tex2D(_Occlusion, IN.uv_MainTex); //occlusion은 uv와 같은 텍스쳐를 받아야 된다.
   o.Alpha = c.a;
  }
  ENDCG
 }
 FallBack "Diffuse"

댓글

이 블로그의 인기 게시물

About AActor!!! "UObject" has no member "BeginPlay"

UNREAL Android build information

C++ 생성자 위임 (delegating constructor)