Unity Shader Study02

//"Albedo (RGB) 이곳은 RGB채널만 입력하는 곳으로 알파는 사용하지 않고 RGB채널만 사용, 2D는 이 인터페이스가 2D만 받는 곳이라는 뜻, white 는 아무것도 들어있지 않은 초기상태에 white라는 뜻
 
Properties {
  _MainTex ("Albedo (RGB)", 2D) = "white" {}
 }

 
//이후 sampler로 받게 된다.

  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;

//이후 input 구조체 안에서 uv를 받아온다.
//uv 는 vertex가 가지고 있다. u와 v 2개의 숫자로 이루어지는 uv는 float2이고, _MainTex의 uv라는 뜻으로 아래와 같이 쓰여진다.

  struct Input {
   float2 uv_MainTex;
  };


//text2D라는 함수를 이용하여 화면에 출력하는것
//_MainTex 는 밖에 선언된 샘플러, uv_MainTex는 Input 안에 있는 uv로 IN.uv_MainTex라는 구조체로 구성된다.
  void surf (Input IN, inout SurfaceOutputStandard o) {
   fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
   o.Albedo = c.rgb;
   o.Alpha = c.a;
  }


//Greyscale로 만들기 :    o.Albedo = (c.r + c.g + c.b)/3; RGB세 값을 더하여 3으로 나눈다.
//lerp(X,Y,s) X와 Y는 단위 s는 float
//   o.Albedo = lerp(c.rgb, d.rgb, 0.5);  lerp 안에는 단위 수와 그사이값을 조정하는 float이 있다.
//Image에 알파채널이 있는 경우 검은색은 0 흰색은 1이다.회색은 0.5

  fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; //can add color to UV
//u is _MainTex.x v is _MainTex.y
//o.Emission = float3(IN.uv_MainTex.x,IN.uv_MainTex.y, 0); //U is red Vis Green


fixed4 c = tex2D (_MainTex, IN.uv_MainTex + _Time.y);  //can make uv flow
   fixed4 c = tex2D (_MainTex, float2(IN.uv_MainTex.x + _Time.y, IN.uv_MainTex.y)); //make uv flow x direction
   fixed4 c = tex2D (_MainTex, float2(IN.uv_MainTex.x + _Time.y * _FlowSpeed, IN.uv_MainTex.y));   //Set flow speed


//   o.Emission = c.rgb;  texture의 rgb값을 emission에 넣으면 빛의 영향을 받지 않는다.

  Tags { "RenderType"="Transparent" "Queue"="Transparent"}
  LOD 200
  CGPROGRAM
  #pargma surface surf Standard alpha : fade  // 반투명을 만들어 준다.


// >< Making Fire ShaderScript

_________________________________________________________________________________
Shader "Unique/Edu01/SurfaceShader04" {
 Properties {
  _MainTex ("Albedo (RGB)", 2D) = "white" {}
     _MainTex2 ("Albedo (RGB)", 2D) = "white" {}
 }
 SubShader {
  Tags { "RenderType"="Transparent" "Queue"="Transparent"}
  LOD 200
  CGPROGRAM
  #pragma surface surf Standard alpha:fade
  sampler2D _MainTex;
     sampler2D _MainTex2;
  struct Input {
   float2 uv_MainTex;
   float2 uv_MainTex2;
  };
  UNITY_INSTANCING_CBUFFER_START(Props)
   // put more per-instance properties here
  UNITY_INSTANCING_CBUFFER_END
  void surf (Input IN, inout SurfaceOutputStandard o) {
   fixed4 d = tex2D(_MainTex2, float2(IN.uv_MainTex2.x, IN.uv_MainTex2.y - _Time.y));
   fixed4 c = tex2D (_MainTex, IN.uv_MainTex + d.r);
   //fixed4 d = tex2D(_MainTex2, float2(IN.uv_MainTex2.x + _Time.y, IN.uv_MainTex.y));
   //o.Albedo = c.rgb;
   o.Emission = c.rgb;   //light will not interfere texture
   o.Alpha = c.a;
   //o.Emission = c.rgb * d.rgb;   //light will not interfere texture
   //o.Alpha = c.a * d.a *1.5;
  }
  ENDCG
 }
 FallBack "Diffuse"
}
__________________________________________________________________________________

Metalic : roughness, smoothness :reflection

Ambient Occlusion 매우 구석지거나 복잡한 물체들로 가려져 환경광도 닿지 못하는 부분

댓글

이 블로그의 인기 게시물

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

UNREAL Android build information

Shader informations nice blog ~ ~