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 | 31 |
Tags
- Programming
- 시작해요 언리얼 2022
- 문제풀이
- 재귀
- 오류
- Unreal Engine 5
- w3school
- Unity
- 백준
- c++
- loop
- Material
- DP
- Class
- 파이썬
- dynamic
- github
- Basic
- C#
- python
- parameter
- dfs
- Tutorial
- Algorithm
- W3Schools
- guide
- String
- UE5
- 프로그래밍
- 기초
Archives
- Today
- Total
행복한 개구리
Unity Shader 21.05.13. 불 효과만들기 본문
Shader "Custom/Test1"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_MainTex2("Albedo2 (RGB)", 2D) = "white" {}
_MainTex3("Albedo3 (RGB)", 2D) = "white" {}
_CrushCoef("CrushCoef", Float) = 0
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue" = "Transparent"}
LOD 200
CGPROGRAM
#pragma surface surf Standard alpha:fade
sampler2D _MainTex;
sampler2D _MainTex2;
sampler2D _MainTex3;
float _CrushCoef;
struct Input
{
float2 uv_MainTex;
float2 uv_MainTex2;
float2 uv_MainTex3;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
float4 c3 = tex2D(_MainTex3, float2(IN.uv_MainTex3.x, IN.uv_MainTex3.y - _Time.y));
float4 c2 = tex2D(_MainTex2, float2(IN.uv_MainTex2.x, IN.uv_MainTex2.y - _Time.y));
fixed4 c = tex2D(_MainTex, float2(IN.uv_MainTex.x, IN.uv_MainTex.y - 0.035) + c2 * _CrushCoef);
o.Emission = c.rgb * c3.rgb;
o.Alpha = c.a * c2.a;
}
ENDCG
}
FallBack "Diffuse"
}
1. c는 메인텍스쳐, c2는 데이터텍스쳐, c3는 불 안에서 일렁거림을 주는 텍스쳐이다.
2. alpha:fade를 빼먹지 않도록 조심하자.
3. 겹치는 부분이 더욱 진한 값을 갖게하기위해 c.rgb * c3.rgb를 했고 둘 중 하나라도 알파값이 0인부분은 출력되지 않게(둘이 겹치는 부분만 출력되게끔) c.a* c3.a를 사용했다.
4.그리고 _CrushCoef값의 조절을 통해 일그러짐 정도를 조절할 수 있다.(여기서는 0.5로 설정해놓았다.)
5.마지막으로 c의 y좌표에 0.035를 뺀 이유는 텍스쳐의 기본위치가 잘못되어 위쪽에서 불이 새는 것 처럼 보이길래 위치를 조정한 것이다.
'Unity > 복습' 카테고리의 다른 글
Unity Shader 21.05.14. Skybox (0) | 2021.05.15 |
---|---|
Unity Shader 21.05.14. 하프벡터 빛효과 + 외곽선, 홀로그램 (0) | 2021.05.14 |
Unity 복습 21.05.11. PUN2 - 로비 구현2 (0) | 2021.05.12 |
Unity 복습 21.05.10. UGUI - DailyReward (0) | 2021.05.10 |
Unity 복습 21.05.10. Shader - AlphaBlending (0) | 2021.05.10 |