유니티/쉐이더
05/03 유니티 쉐이더 Sphere에 색 적용하기
박준희
2021. 5. 3. 12:17
알베도는 물체가 빛을 받았을때 반사하는 정도를 나타내는 단위
반사와 색상을 같이 계산
이미션 표면에 방출되는 빛의 색상과 강도를 제어
빛의 영향을 안받음
알베도와 이미션은 최종적으로 더해짐
더 밝아짐
색의 덧셈, 곱셈
수치가 넘어가도 1까지만 색상 표현
넘어가는 수치까지 표현하는 것을 HRD라고 함
연산시 주의사항
같은 자리수만 연산
예외적으로 한자리와는 언제나 가능하다
ex float3(0,1,0) + 1
Shader "Custom/Test"
{
Properties
{
_Brightness ("change Brightness!!", Range(0, 1)) = 0.5
_TestColor ("Test Color!!", Color) = (1,1,1,1)
_TestFloat("Test Float!!", Float) = 0.5
_TestVector ("Test Vector!", Vector) = (1,1,1,1)
//tex2D
//float계열로 분류 되지 않는 sampler
//텍스쳐는 UV좌표와 함께 계산되어야 float4로 출력 할수 있다
//아직 UV와 계산되지 않는 텍스쳐는 색상 (float4)로 나타낼수 없다
//이때까지를 smapler 부른다
_TestTexture("Test Texture!", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
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
struct Input
{
float2 uv_MainTex;
};
float4 _TestColor;
void surf (Input IN, inout SurfaceOutputStandard o)
{
o.Albedo = _TestColor.rgb;
o.Alpha = _TestColor.a;
}
ENDCG
}
FallBack "Diffuse"
}