Notice
Recent Posts
Recent Comments
Link
스토리지
[5.10] Cube Map 연습 본문
- 씬의 Skybox 설정
- Cube Property 받기
- SamplerCUBE로 큐브 받기
- Reflection 적용 (Input 구조체에 float3 worldRefl) => surf에서 적용 및 Input 구조체에 INTERNAL_DATA 작성
- float4 ref = texCUBE(SamplerCube, WorldReflectionVector(struct Input, float3))
- Emission 쪽에서 출력
- 값을 변경하며 적정값 찾기
- Bump Map은 WorldReflectionVector에 사용되어질꺼기 때문에 먼저 선언해주어야됨.
Shader "Custom/Skybox"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_BumpTex ("Albedo (RGB)", 2D) = "bump" {}
_Cube ("Cube Map", Cube) = "" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _BumpTex;
samplerCUBE _Cube;
struct Input
{
float2 uv_MainTex;
float2 uv_BumpTex;
float3 worldRefl;
INTERNAL_DATA
};
void surf (Input IN, inout SurfaceOutput o)
{
o.Normal = UnpackNormal(tex2D(_BumpTex, IN.uv_BumpTex));
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
float4 ref = texCUBE(_Cube, WorldReflectionVector(IN, o.Normal));
o.Albedo = c.rgb * 0.9;
o.Emission = ref.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
'Unity > Shader' 카테고리의 다른 글
렌더링 파이프라인 정리 (0) | 2021.10.05 |
---|---|
[5.10] Alpha Blending (0) | 2021.05.10 |
[5.8] 토요일 Shader 연습 (0) | 2021.05.08 |
[5.7] CubeMap (0) | 2021.05.07 |
[5.7] Warped Diffuse (0) | 2021.05.07 |
Comments