Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- dfs
- DP
- Class
- Material
- C#
- loop
- 기초
- Tutorial
- 프로그래밍
- 문제풀이
- UE5
- Programming
- 시작해요 언리얼 2022
- Unity
- Algorithm
- Basic
- w3school
- Unreal Engine 5
- 오류
- dynamic
- github
- String
- c++
- 백준
- guide
- 파이썬
- W3Schools
- parameter
- python
- 재귀
Archives
- Today
- Total
행복한 개구리
Unity Shader 21.05.14. Skybox 본문
Shader "Custom/skybox"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_BumpTex("BumpTexture", 2D) = "bump" {}
_Cube("CubeMap", Cube) = "cube" {}
}
SubShader
{
Tags { "RenderType" = "Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Standard
samplerCUBE _Cube;
sampler2D _MainTex;
sampler2D _BumpTex;
struct Input
{
float2 uv_MainTex;
float2 uv_BumpTex;
float3 worldRefl;
float3 worldNormal;
INTERNAL_DATA
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
o.Normal = UnpackNormal(tex2D(_BumpTex, IN.uv_BumpTex));
float3 worldNormal = WorldReflectionVector(IN, o.Normal);
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
float4 refl = texCUBE(_Cube, worldNormal);
o.Albedo = c.rgb * refl.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
들어간 범프텍스쳐와 메인텍스쳐, 그리고 큐브맵(여기선 하늘)을 이용한 코드이다. 큐브맵을 외형에 적용시키는것은 texCUBE를 쓰는것으로 크게 다르지 않지만 매개변수로 Input의 worldRefl이라는 반사값이 들어가고, 범프텍스쳐의 질감까지 반사시키려면 WorldReflectionVector를 이용하여 노멀값을 구한 뒤, refl이라는 반사값에 할당해주어야한다. 사진의 검도 큐브맵반사가 적용되어 있는데, 칼에는 노멀값이 적용되지 않았다.
**주의할 점은 INTERNAL_DATA를 Input구조체안에 꼭 선언해야한다.
'Unity > 복습' 카테고리의 다른 글
Unity ML 21.05.17. 복습 - ML (0) | 2021.05.18 |
---|---|
Unity Shader 21.05.15. Diffuse Warping (0) | 2021.05.15 |
Unity Shader 21.05.14. 하프벡터 빛효과 + 외곽선, 홀로그램 (0) | 2021.05.14 |
Unity Shader 21.05.13. 불 효과만들기 (0) | 2021.05.14 |
Unity 복습 21.05.11. PUN2 - 로비 구현2 (0) | 2021.05.12 |