본문 바로가기

전체 글510

[Unity/Shader] 파트13-5 : Rim 라이트를 이용한 가짜 스펙큘러 만들기 rim을 뒤집은 것을 이용해 가짜 스펙큘러를 만든다. 그러면, 항상 내 시선 방향에 생기는 스펙큘러가 표현된다. 실제 세상에 조명이 하나만 있는 경우는 거의 없기에, 디테일 표현에 유용하다. 코드 Shader "Custom/Part13-2" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} _BumpMap ("NormalMap", 2D) = "bump" {} _SpecCol ("Specular Color", Color) = (1,1,1,1) _SpecPow ("Specular Power", Range(10,200)) = 100 _GlossTex ("Gloss Tex", 2D) = "white" {} } SubShader { Tags { "RenderT.. 2023. 8. 19.
[Unity/Shader] 파트13-4 : Rim 라이트를 커스텀 라이트로 옮기기 이전에는 surf 함수에서 연산했다. Specular 공식을 쓰면서 viewDir을 커스텀 라이트 안에서 사용할 수 있게 됐다. 따라서 커스텀 라이트 안에서 처리하도록 옮긴다. 코드 Shader "Custom/Part13-2" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} _BumpMap ("NormalMap", 2D) = "bump" {} _SpecCol ("Specular Color", Color) = (1,1,1,1) _SpecPow ("Specular Power", Range(10,200)) = 100 _GlossTex ("Gloss Tex", 2D) = "white" {} // * } SubShader { Tags { "RenderType.. 2023. 8. 19.
[Unity/Shader] 파트13-3 : Gloss 맵으로 스펙큘러 강도 조절하기 이전 코드에 이어서 Gloss 텍스쳐를 프로퍼티에 받아 적용하는 법을 실습한다. 코드 Shader "Custom/Part13-2" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} _BumpMap ("NormalMap", 2D) = "bump" {} _SpecCol ("Specular Color", Color) = (1,1,1,1) _SpecPow ("Specular Power", Range(10,200)) = 100 _GlossTex ("Gloss Tex", 2D) = "white" {} // * } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM // Physically based Sta.. 2023. 8. 19.
[Unreal/Niagara] 나이아가라 Random Seed 고정법 항상 동일한 결과를 얻고 싶을때 사용한다. 메시 Scale 메시 Orient Fixed Random Seed를 클릭하면 파티클별 랜덤이 아니게 된다. 따라서 모든 파티클이 동일한 orient를 가진다. 2023. 8. 18.
[Unity/Shader] 파트13-2 : Blinn Phong 스펙큘러 만들기 코드 Shader "Custom/Part13-2" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} _BumpMap ("NormalMap", 2D) = "bump" {} _SpecCol ("Specular Color", Color) = (1,1,1,1) // _SpecColor라고 쓰면 안된다. 유니티 내장 쉐이더에서 이미 쓰고 있는 용어다. _SpecPow ("Specular Power", Range(10,200)) = 100 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM // Physically based Standard lighting model, and enable shadows.. 2023. 8. 18.
[Unity/Shader] 파트13-1 : Blinn Phong 반사 이론 스펙큘러 만들 때 필요한 이론이다. 전통적인 방식은 Phong 반사이다. Phong 반사'뷰벡터로부터 반사된 방향에 라이트가 있으면, 그 부분의 하이라이트가 가장 높다'가 전제다. 뷰벡터를 노말 방향 기준으로 반사하는 반사벡터와, 조명 벡터의 내적으로 스펙큘러가 표현된다. R·L이다.위 공식 계산을 위해서는 R을 구해야한다. V벡터 기반으로 R벡터 계산법은 다음과 같다. R = 2N(L·N) - L 다만, 반사 벡터를 구하기 위해 내적을 한번 더 하는 단점이 있다.Bling Phong 퐁 공식을 간략화한 공식이다. 하프 벡터를 이용하는 공식이다. H·N이다.하프 벡터 구하는 법 길이가 같은 두 벡터를 더하고 노멀라이즈한다. 다음 장에서 실습한다. 2023. 8. 18.
[Unity/Shader] 파트12-3 : 홀로그램 제작 뷰포트 애니메이션 활성화 방법 핵심 제작법 외곽선 : 내적 줄무늬 : 월드 포지션을 frac한 것에 시간으로 offset을 준 것이다. 코드 Shader "Custom/Part12-1" { Properties { _BumpMap("NormalMap", 2D) = "bump" {} } SubShader { Tags { "RenderType"="Transparent" "Queue" = "Transparent" } // 반투명 재질로 적용 LOD 200 CGPROGRAM // Physically based Standard lighting model, and enable shadows on all light types #pragma surface surf nolight noambient alpha:fade //.. 2023. 8. 17.
[Unity/Shader] 파트12-2 : Rim 라이트 완성 12-1 내용에 이어서 Rim 라이트를 완성한다. 주의할 점은 하나다. 림라이트 계산시 노말을 이용하므로, 노말맵 계산이 이전에 이루어져야한다. 코드 Shader "Custom/Part12-1" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} _BumpMap("NormalMap", 2D) = "bump"{} _RimColor("RimColor", Color) = (1,1,1,1) _RimPower("RimPower", Range(1,10)) = 3 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM // Physically based Standard lighting model, and en.. 2023. 8. 16.
[Unity/Shader] 파트12-1 : Fresnel 공식 구현 뷰벡터와 노말을 내적한다. 외곽선을 얇게 만들기 위해 제곱한다. 코드 Shader "Custom/Part12-1" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM // Physically based Standard lighting model, and enable shadows on all light types #pragma surface surf Lambert noambient // Use shader model 3.0 target, to get nicer looking lighting #pragma target 3.0 sampler2D .. 2023. 8. 16.