Unity Shader - zzragida/UnityDocs GitHub Wiki
Reference
- Unity Shader System: http://www.slideshare.net/MrDustinLee/unity-shadersystemfinal
- http://forum.unity3d.com/threads/strumpy-shader-editor-now-open-source.56180/
- Unity Manual for Shaders : http://docs.unity3d.com/Manual/Shaders.html
- Best Practices for Shaders : https://developer.apple.com/library/ios/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/BestPracticesforShaders/BestPracticesforShaders.html
- Render to Texel Baker : https://www.assetstore.unity3d.com/kr/#!/content/4153
- Sprite Packer with Legacy Particle Emitter to Shuriken converter : http://u3d.as/content/forest-johnson/sprite-packer-with-legacy-particle-emitter-to-shuriken-converter-/34E
- https://cgcookie.com/unity/cgc-courses/noob-to-pro-shader-writing-for-unity-4-beginner/
- http://wiki.unity3d.com/index.php/Shaders
- https://en.wikipedia.org/wiki/Shader
- https://visualstudiogallery.msdn.microsoft.com/ed812631-a7d3-4ca3-9f84-7efb240c7bb5
- http://www.alanzucconi.com/2015/06/10/a-gentle-introduction-to-shaders-in-unity3d/
Tools
- Strumpy Shader Editor
- Shader Forge
- Shader Unity Support for Visual Studio
What is Shader?
- ์ปดํจํฐ์๊ฒ ์ด๋ป๊ฒ ํน๋ณํ๊ฑฐ๋ ์ ๋ํฌํ๊ฒ ์ฌ๋ฌผ(something)์ ๊ทธ๋ฆด์ง ์๋ ค(tell)์ฃผ๋ ํ๋ก๊ทธ๋จ
- A definition in layman's terms might be given as "a program that tells a computer how to draw something in a specific and unique way". from Wikipedia
์ ๋ํฐ ์์ด๋ ๊ตฌ์กฐ(Unity Shader Structure)
์ ๋ํฐ ๋ฉํฐํ๋ซํผ ์ํคํ ์ณ(Unity Multi Platform Architecture)
- ์ ๋ํฐ๋ ๋ฉํฐํ๋ซํผ ์์ง์ด๊ธฐ ๋๋ฌธ์ CPU, GPU ๋ชจ๋ ๋ฉํฐ ํ๋ซํผ์์ ๋์ํ๊ธฐ ์ํ ๊ตฌ์กฐ๋ฅผ ๊ฐ์ง๊ณ ์์
- ์์ด๋์ ๊ฒฝ์ฐ ShaderLab์ด๋ผ๋ ์ถ์ ์คํฌ๋ฆฝํธ ์ธ์ด๋ฅผ ์ฌ์ฉํ์ฌ ๋ฉํฐ ํ๋ซํผ์์ ๋์ํ๋ ์์ด๋ ์ฝ๋๋ฅผ ์์ ํ ์ ์์
์์ด๋ ์คํฌ๋ฆฝํธ Shader Script(ShaderLab)
-
Abstract shader script layer for multiplatform system
-
Multi-Device
- Supports old mobile hardwares (DX 7/8)
- Supports modern mobile hardwares (DX9, Shader Model 2)
- Supports PC and Console hardwares (Shader Model 3)
- Supports Extreme PC hardwares (DX11, Shader Model 5)
-
Multi-Library
- OpenGL
- OpenGL E/S
- DirectX
-
Multi-Language
- GLSL
- Cg
- HLSL
-
๊ธฐ๋ณธ ๊ตฌ์กฐ
Shader "Custom/Simple" {
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "Queue" = "Geometry + 1" }
Pass
{
SetTexture [_MainTex] { combine texture }
}
}
FallBack "Diffuse"
}
-
Shader Lab Syntax - Properties
-
์ ๋ํฐ ์ธ์คํํฐ์์ ์์ด๋์ ์ ๋ฌํ ๋ค์ํ ๊ฐ์ ์ฌ์ฉ์๊ฐ ํธ๋ฆฌํ๊ฒ ์ค์ ํ ์ ์๋๋ก ๋ง๋ ์ธํฐํ์ด์ค
- Float textbox
- Float Range Slides
- Vector4 textboxes
- Color Picker
- 2D Texture (POT)
- 2D Texture (NPOT)
- Cube Texture
-
Shader Lab Syntax - SubShader
-
์ ๋ํฐ๋ ํ๋์ ์์ด๋์์ ๋ค์ํ ํ๋์จ์ด๋ฅผ ์ง์ํ๊ธฐ ์ํด ์๋ธ์์ด๋๋ผ๋ ๊ตฌ๋ฌธ์ ์ ๊ณตํจ
-
๊ฐ์ฅ ์์ ์ ์๋ ์์ด๋๋ถํฐ ์คํ๋๋ฉฐ, ํ๋์จ์ด์ ํธํ์ด ์๋๋ฉด ๋ค์ ์๋ธ์์ด๋๊ฐ ์คํ๋จ
-
๋ชจ๋ ์์ด๋ ๊ตฌ๋์ ์คํจํ๋ฉด ํด๋ฐฑ(FallBack)์ ์ ์๋ ์์ด๋๊ฐ ๋์ ์คํ๋จ
SubShader
{
// First Priority Shader Code
( Designed for high-level PC )
}
SubShader
{
// Second Priority Shader Code
( Designed for mid-level PC )
}
SubShader
{
// Third Priority Shader Code
( Designed for low-level PC )
}
// Alternative Shader Code
FallBack "VertextLit"
-
SubShader Format - Tag
-
์๋ธ์์ด๋์ ๊ตฌ์กฐ๋ฅผ ํฌ๊ฒ ๋ ๋๋ง์ ์คํ ์์์ ์ค์ ์ ์ง์ ํ๋ ํ๊ทธ(Tag) ๊ตฌ๋ฌธ๊ณผ ๋ ๋๋ง์ ํํํ๋ ํจ์ค(Pass)๋ก ๋๋์ด ์ง
-
์ ๋ํฐ๋ 0๋ถํฐ 5000๋ฒ๊น์ง ๋ ๋๋ง ์์๋ฅผ ์ง์ ํ๊ฒ ๋๋๋ฐ ์ซ์๊ฐ ์๋ ์ด๋ฆ์ ๊ธฐ๋ฐ์ผ๋ก ์ด ์์๋ฅผ ์ง์ ํ๊ฒ ๋จ
- Background = 1000
- Geometry = 2000
- AlphaTest = 2450
- Transparent = 3000
- Overlay = 4000
- ์๋ฅผ๋ค์ด Tags { "Queue" = "Geometry+1" }์ Geometry(2000)์ 1์ ๋ํ 2001์ ์๋ฏธํจ
-
SubShader Format - Pass
-
์ง์ค๋ฉํธ๋ฆฌ(Geometry)์ ๋ ๋๋ง ๋ฐฉ๋ฒ์ ์ง์ ํ๋ ๊ตฌ๋ฌธ
-
ํจ์ค ๊ตฌ๋ฌธ์ ์ฌ๋ฌ๊ฐ๋ฅผ ์ฌ์ฉํ์ฌ ์ด์ ํจ์ค์์ ๋์จ ๊ฒฐ๊ณผ๋ฌผ์ ๊ธฐ๋ฐ์ผ๋ก ๊ณ์ ์ถ๊ฐ์ ์ธ ํํ์ ํ ์ ์์
-
ํจ์ค ๊ตฌ๋ฌธ์ ํตํด ๋ฌผ์ฒด์ ๋ ๋๋ง์ด ์ํ๋๋๋ฐ, ์ด ๋ ๋๋ง์ ์ฌ๋ฌ๋ถ๋ค์ด ์นด๋ฉ๋ผ์์ ์ง์ ํ ๋ ๋๋ง ๋ฐฉ๋ฒ์ ํตํด์ ์ํ๋จ
-
์ด๋ฌํ ๋ ๋๋ง ๋ฐฉ๋ฒ์ ์ ๋ํฐ์์๋ ์ด๋ฅผ ๋ ๋๋ง ํจ์ค(Rendering Path)๋ผ๊ณ ํจ
- Pass Tag : ๋ ๋๋ง ์ค์ ์ ์ง์
- Render State : GPU์ ๋ ๋ ์คํ ์ดํธ๋ฅผ ์ค์
- ์ค์ ์์ด๋ ์ฝ๋ ์กฐ๊ฐ
์ ๋ํฐ ๋ ๋๋ง ํ์ดํ๋ผ์ธ(Unity Rendering Pipeline)
๋ฒํ ์ค ๋ฆฟ(Vertex Lit)
- ์ค๋๋ ํ๋์จ์ด์์ ๋์ํ๋๋ก ์ค๊ณ๋จ(Designed for old hardware)
- Direct X 7/8 compatible
- Final pixel is calculated by interpolation between vertices
- ์ฅ์
- Simple and Fast
- No overhead in CPU side
- Useful to lightmapping in mobile
- ๋จ์
- Cookie, Lightprobe, Shadow are not available
- Number of light has limit
- Can't express pre-pixel expression. ex) Normal mapping
- ๋ฒํ ์ค ๋ฆฟ์ ํ๋์จ์ด ํน์ ์๋ํฐ ์ค์ ์ ๋ฐ๋ผ 3๊ฐ์ง ์ค ํ๋์ ๊ณผ์ ์ด ์งํ๋จ
- ์ด๋ค ๊ณผ์ ์ด ์ฌ์ฉ๋ ์ง๋ ์ ๋ํฐ๊ฐ ์๋์ผ๋ก ์์์ ์ค์ ํด ์ค
- Vertex Pass
- Just simple vertex lit mode
- No lightmap support
- VertexLM Pass
- For old smartphone
- Encodes lightmap by Double LDR
- VertexLMRGBM Pass
- For modern smartphone
- Encodes lightmap by RGBM
ํฌ์๋(Forward)
- ๊ฐ์ฅ ์ผ๋ฐ์ ์ธ ๋ ๋๋ง ๋ฐฉ๋ฒ(Common rendering pipeline)
- DirectX 9
- Per-pixel calculation
- ์ฅ์
- Lightprobe, cookie, shadow are available
- Can render object by independent lighting model
- ๋จ์
- Lighting computation increases linearly by number of lights
- Only directional light support shadow
- Unity supports additional shader keyword (fullforwardshadows)
- ํฌ์๋ ๋ฐฉ์์ ๊ฐ์ฅ ์ค์ํ ์ ์ ์ค์ํ ๋น๊ณผ ์ค์ํ์ง ์์ ๋น์ ๊ตฌ๋ถํ๋ ์ผ์
- ์ด๋ ๋ผ์ดํธ ์ปดํฌ๋ํธ ์ค์ ์์ ์ง์ ์ง์ ์ ํ ์ ์๋๋ฐ, ์ค์ํ ๋น์ ๊ฐ์ฅ ์ธํ ์ํฐ(Intensity)๊ฐ ๋์ ๋๋ ์ ๋ ๋ผ์ดํธ(Directional Light) ์
- ๊ทธ๋ก๊ธฐ ๋ผ์ดํธ ์ปดํฌ๋ํธ์์ Render Mode๊ฐ Important๋ก ์ค์ ๋ ๋น์
- ์ค์ํ ๋น์ ํ์ง์ค์ ์์ Pixel Light Count์ ์ค์ ๋ ์๋งํผ ์ง์ ํ ์ ์์ผ๋ฉฐ, ๋๋จธ์ง๋ ์ ์ค์ํ ๋น์ด ๋จ
- ํฌ์๋ ๋ฐฉ์์ ๋น์ ๊ฐ์์ ๋ฐ๋ผ ๊ณ์ฐ๋์ด ์ฆ๊ฐํ๊ธฐ ๋๋ฌธ์, ์ด๋ฅผ ์ค์ ํ๋ ๊ฒ์ ์ต์ ํ์ ํฐ ์ํฅ์ ์ค
- ํ์ง ์ค์ ์ ํฝ์
๋ผ์ดํธ ์นด์ดํธ(Pixel Light Count) ์ค์ ์ด ์ค์ํ ๋น์ ์๋ฅผ ์ง์ ํ๋ ์ผ์ธ๋ฐ, ์ ๋ํฐ๋ ์ค์ํ ๋น์ ๊ณต๋ค์ฌ์ ๋ ๋๋งํ๊ณ , ์ ์ค์ํ ๋น์ ์ ๋ง ๋์ถฉ ๋ ๋๋ง ํจ
- Light Setting in Forward Pipeline
- Important Light
- The largest intensity directional light
- Uses in per-pixel calculation
- Pixel Light Count
- Not Important Light
- Next 4 lights use for per-vertex calculation
- Rest lights are approximated by SH(Spherical Harmonics)
๋ํผ๋ ๋ ๋๋ง(Deferred Lighting)
- ์ต์ ๋ ๋๋ง ๋ฐฉ๋ฒ(Modern rendering pipeline)
- ์ฅ์
- No number of light limit
- Useful to complex scene rendering at once
- ๋จ์
- Mobile doesn't support this currently
- Supports only Blinn-Phong lighting model
- Doesn't support transparent object
- Only forward supports transparent objects
์ ๋ํฐ ์์ด๋ ํ๋ก๊ทธ๋๋ฐ(Unity Shader Programming)
๊ณ ์ ํจ์ ํ๋ก๊ทธ๋จ(Fixed Function Program)
- ๋ฒํ
์ค ๋ฆฟ ๋ ๋๋ง ๋ฐฉ์์ ์ ํฉํ ํ๋ก๊ทธ๋จ ๋ฐฉ๋ฒ(Mataches vertex lit rendering pipeline)
- Shader model 1.x
- Provides special keywords for rendering operation
- ๊ณ ๊ธ ์ธ์ด๋ฅผ ํตํด์ ํ๋ก๊ทธ๋๋ฐ์ด ๋ถ๊ฐ๋ฅ ํจ
- ์ฌํํ์ง๋ง ๋น ๋ฅด์ง ๋๋ฌธ์, ๋ชจ๋ฐ์ผ์์๋ ํ๋ฆฌํฐ์๋ง ๋ฌธ์ ๊ฐ ์๋ค๋ฉด ์ฑ๋ฅ์ ์ํด ์ฌ์ฉ์ ๊ณ ๋ คํด๋ณด๋ ๊ฒ๋ ์ข์
๋ฒํ ์ค/ํ๋๊ทธ๋จผํธ ํ๋ก๊ทธ๋จ(Vertex / Fragment Program)
- ์ผ๋ฐ์ ์ผ๋ก ๋ง์ด ์ฌ์ฉํ๋ ์์ด๋ ํ๋ก๊ทธ๋๋ฐ(Command shader programming)
- Unity provides keywords for coding snippet area
- CGPROGRAM, GLSLPROGRAM
- ์ ๋ํฐ๋ ๋ ๊ฐ์ง ์ธ์ด๋ฅผ ๋ชจ๋ ์ง์ํ์ง๋ง, ๋ฉํฐํ๋ซํผ ์์ด๋๋ฅผ ๋ง๋ค๋ ค๋ ํ๋ค๋ฉด Cg๋ฅผ ์ฌ์ฉํด์ผ ํจ
- ์์ด๋๋ฉ ๋ฌธ๋ฒ์ผ๋ก ์์ด๋ ์ฝ๋๋ฅผ Cg๋ก ๋ง๋ค์ด์ฃผ๋ฉด, ์ต์ข HLSL ์์ด๋ ์ฝ๋๊ฐ ๋ง๋ค์ด์ด์ ๋๊ณ , ๋ด๋ถ ๋ณํ๊ธฐ์ ์ํด์ HLSL์ฝ๋๋ฅผ GLSL๋ก ์๋์ผ๋ก ๋ณํ๋จ
- ์ด๋ ๊ฒ ๋ณํ๋ GLSL ์ฝ๋๋ ์ ๋ํฐ GLSL ์ตํฐ๋ง์ด์ ๋ฅผ ํตํด ์ต์ ํ๋์ด ์ต์ข ์์ด๋ ์ฝ๋๊ฐ ์์ฑ๋จ
- ๋ฐ๋ผ์ Cg๋ก ์ง ์์ด๋ ์ฝ๋๊ฐ OpenGL์์ ๋์ํ๋๊ฒ ๊ฐ๋ฅํด ์ง
์ํผ์ค ์์ด๋ ํ๋ก๊ทธ๋จ(Surface Shader Program)
- ๋ณต์กํ ์์ด๋ ์ฝ๋๋ฅผ ์ฌํํ๊ฒ ํ๊ธฐ ์ํ ํ๋ก๊ทธ๋จ
- Simplified version of vertex/fragment program by unit way.
- Automatically converts vertex/fragment code for various situations.
- ์ํผ์ค ์์ด๋๊ฐ ๋จ์ํ ์ด์ ๋ ์์ง์์ ์๋์ผ๋ก ๋ฒํ ์ค/ํ๋๊ทธ๋จผํธ ์์ด๋ ์ฝ๋๋ก ๋ณํํด์ฃผ๊ธฐ ๋๋ฌธ์
- Cg๋ HLSL ์์ด๋ ์ฝ๋๋ฅผ ์ด์ฉํด์ ์ฝ๋๋ฅผ ์์ฑํ๋ฉด ๋จ
- Surface Shader Program => Generate by Unity Engine => Vertex/Fragment Program
- ๊ธฐ๋ณธ๊ตฌ์กฐ
- Surface Shader Program = Surface Code + Light Code
์ํผ์ค ์์ด๋ ์์ฑ(Writing Surface Shaders)
์์ ์์(Work Flow)
- Create > Shader > Standard Surface Shader / Unlit Shader / Image Effect Shader / Compute Shader
- Write code in surf function
- Attach material
์ํผ์ค ์ถ๋ ฅ ๊ตฌ์กฐ(Surface Output Structure)
SurfaceOutput (<= Unity4)
SurfaceOutputStandard or SurfaceOutputStandardSpecular (>= Unity5)
Surface Output
// SurfaceOutput (>= Unity4)
struct SurfaceOutput
{
fixed3 Albedo; // diffuse color
fixed3 Normal; // tangent space normal, if written
fixed3 Emission;
half Specular; // specular power in 0..1 range
fixed Gloss; // specular intensity
fixed Alpha; // alpha for transparencies
};
// SurfaceOutputStandard (>= Unity5)
struct SurfaceOutputStandard
{
fixed3 Albedo; // base (diffuse or specular) color
fixed3 Normal; // tangent space normal, if written
half3 Emission;
half Metallic; // 0=non-metal, 1=metal
half Smoothness; // 0=rough, 1=smooth
half Occlusion; // occlusion (default 1)
fixed Alpha; // alpha for transparencies
};
// SurfaceOutputStandardSpecular (>= Unity5)
struct SurfaceOutputStandardSpecular
{
fixed3 Albedo; // diffuse color
fixed3 Specular; // specular color
fixed3 Normal; // tangent space normal, if written
half3 Emission;
half Smoothness; // 0=rough, 1=smooth
half Occlusion; // occlusion (default 1)
fixed Alpha; // alpha for transparencies
};
์ํผ์ค ์์ด๋ ์ปดํ์ผ ๋ฐฉ๋ฒ์ง์ (Surface Shader compile directives)
- Surface shader is placed inside CGPROGRAM ~~ ENDCG block
- It must be placed inside SubShader block, not inside Pass. Surface shader will compile into multiple passes itself
- It uses #pragma surface ... directive to indicate it's a surface shader
- #progma surface surfaceFunction lightModel [optional|params]
ํ์ ํ๋ผ๋ฏธํฐ(Required parameters)
- surfaceFunction
- lightModel
์ต์ ํ๋ผ๋ฏธํฐ(Optional parameters)
-
Transparency and alpha testing
- alpha or alpha:auto
- alpha:fade
- alpha:premul
- alphatest:VariableName
- keepalpha
- decal:add
- decal:blend
-
Custom modifier functions
- vertex:VertexFunction
- finalcolor:ColorFunction
-
Shadows and Tessellation
- addshadow
- fullforwardshadows
- tessellation:TessFunction
-
Code generation options
- exclude_path:deferred, exclude_path:forward, exclude_path:prepass
- noshadow
- noambient
- novertexlights
- nolightmap
- nodynlightmap
- nodirlightmap
- nofog
- nometa
- noforwardadd
-
Miscellaneous options
- softvegetation
- interpolateview
- halfsview
- approxview
- dualforward
์ํผ์ค ์์ด๋ ์ ๋ ฅ ๊ตฌ์กฐ(Surface Shader input structure)
- float3 viewDir
- float4 with COLOR semantic
- float4 screenPos
- float3 worldPos
- float3 worldRefl
- float3 worldNormal
- float3 worldRefl; INTERNAL_DATA
- float3 worldNormal; INTERNAL_DATA
Surface Shader Examples
- http://docs.unity3d.com/Manual/SL-SurfaceShaderExamples.html
- Custom Lighting models int Surface Shaders
- http://docs.unity3d.com/Manual/SL-SurfaceShaderLighting.html
- Surface Shader Lighting Examples
- http://docs.unity3d.com/Manual/SL-SurfaceShaderLightingExamples.html
- Surface Shaders with DX11 Tessellation
- http://docs.unity3d.com/Manual/SL-SurfaceShaderTessellation.html
๋จธํ ๋ฆฌ์ผ๊ณผ ์์ด๋(Material and Shader)
Blue Car : Car Texture + Custom/Bodywork Shader + Blue car Material Red Car : Car Texture + Custom/Bodywork Shader + Red car Material Wheel : Car Texture + Standard Shader + Wheel Material
์คํ ๋ค๋ ์์ด๋(Standard Shader)
- ์ ๋ํฐ5์์๋ ์คํ ๋ค๋ ์์ด๋๋ผ๊ณ ๋ถ๋ฆฌ๋ ์๋ก์ด ํ์ ์ ๋ด์ฅ ์์ด๋๋ฅผ ๋์ ํจ(Unity 5 introduces a new type of built-in shader called the Standard Shader.)
- ์คํ ๋ค๋ ์์ด๋์๋ ๋ฌผ๋ฆฌ์ ๊ธฐ๋ฐ ์์ด๋๋ผ๋ ํจ์ฌ ๋ ๊ณ ๊ธ์ค๋ฌ์ด ์กฐ๋ช ๋ชจ๋ธ์ ํตํฉํจ(The Standard Shader also incorporates a much more advanced lighting model called PBS(Physically Based Shading).)
- ๋ฌผ๋ฆฌ๊ธฐ๋ฐ ์์ด๋ฉ(Physically Based Shading via PBS)
- Energy conservation
- HDR(High Dynamic Range)
์ปจํ ์คํธ์ ์ปจํ ํธ(The Context and the Content)
- When thinking about lighting in Unity 5, it is handy to divide concepts into what we call the Context, which is information on the lighting that exists in the scene (coming from the skybox, lights and shadows, GI, etc) and the Content, which is usually authored directly by you and describes what is in the environment (materials, geometries, animation, etc).
- Most times the distinction will be obvious, but not always.
- For instance, a skybox is graphical Content, that can control some of the lighting Context of your scene.
์ปจํ ์คํธ(The Context)
The Default Lighting Context Skyboxes Global Illumination ์ปจํ ํธ(The Content) The Material Editor
๋ฉํ๋ฆญ vs ์คํํ๋ฌ ์ํฌํ๋ก์ฐ(Metalic vs Specular Workflow)
-
์คํ ๋ค๋ ์์ด๋๋ฅผ ์ฌ์ฉํ์ฌ ๋ฉํฐ๋ฆฌ์ผ์ ์์ฑํ ๋ Standard์ Standard (Specular Setup) ๋๊ฐ์ง์ค์์ ์ ์ ํ๊ฒ์ ์ ํํ ์ ์๋ค(When creating a material using the Standard shader you will have the choice of using one of two flavours, โStandardโ and โStandard (Specular setup)โ.)
-
Standard: The shader exposes a โmetallicโ value that states whether the material is metallic or not. In the case of a metallic material, the Albedo color will control the color of your specular reflection and most light will be reflected as specular reflections. Non metallic materials will have specular reflections that are the same color as the incoming light and will barely reflect when looking at the surface face-on.
-
Standard (Specular setup): Choose this shader for the classic approach. A Specular color is used to control the color and strength of specular reflections in the material. This makes it possible to have a specular reflection of a different color than the diffuse reflection for instance.
๋จธํ ๋ฆฌ์ผ ํ๋ผ๋ฏธํฐ(Material Parameters)
-
๋ ๋๋ง ๋ชจ๋(Rendering Mode)
-
http://docs.unity3d.com/Manual/StandardShaderMaterialParameterRenderingMode.html
- Opaque - Is the default, and suitable for normal solid objects with no transparent areas.
- Cutout - Allows you to create a transparent effect that has hard edges between the opaque and transparent areas. In this mode, there are no semi-transparent areas, the texture is either 100% opaque, or invisible. This is useful when using transparency to creat the shape of =materials such as leaves, or cloth with holes and tatters.
- Transparent - Suitable for rendering realistic transparent materials such as clear plastic or glass. In this mode, the material itself will take on transparency values (based on the textureโs alpha channel and the alpha of the tint colour), however reflections and lighting highlights will remain visible at full clarity as is the case with real transparent materials.
- Fade - Allows the transparency values to entirely fade an object out, including any specular highlights or reflections it may have. This mode is useful if you want to animate an object fading in or out. It iss not suitable for rendering realistic transparent materials such as clear plastic or glass because the reflections and highlights will also be faded out.
-
์๋ฒ ๋ ์์๊ณผ ํฌ๋ช ๋(Albedo Color and Transparency)
-
์คํํ๋ฌ ๋ชจ๋(Specular Mode:Specular)
- http://docs.unity3d.com/Manual/StandardShaderMaterialParameterSpecular.html
- Standard (Specular setup) ์์ด๋๋ฅผ ์ฌ์ฉํ ๋๋ง ํ์ฑํ ๋จ
-
๋ฉํ๋ฆญ ๋ชจ๋(Metallic Mode:Metallic)
- http://docs.unity3d.com/Manual/StandardShaderMaterialParameterMetallic.html
- Standard ์์ด๋๋ฅผ ์ฌ์ฉํ ๋๋ง ํ์ฑํ ๋จ
-
๋ถ๋๋ฌ์(Smoothness)
- http://docs.unity3d.com/Manual/StandardShaderMaterialParameterSmoothness.html
- Standard์ Standard (Specular setup) ์์ด๋ ์ฌ์ฉ์ ๋ชจ๋ ์ค์ ๊ฐ๋ฅ
-
๋ ธ๋ฉ๋งต(Normal Map (Bump Mapping))
-
Height Map (Parallax Mapping)
-
์คํด๋ฃจ์ ๋งต(Occlusion Map)
-
๋ฐฉ์ฌ(Emission)
-
Secondary Maps (Detail Maps) & Detail Mask
-
The Fresnel Effect
๋จธํ ๋ฆฌ์ผ ์ฐจํธ(Material Charts)
๋ฉํ๋ฆญ ์ค์ ์ ์ํ ์ฐจํธ(Reference Chart for Metallic settings)
- Standard ์์ด๋์ Metallic
์คํํ๋ฌ ์ค์ ์ ์ํ ์ฐจํธ(Reference Chart for Specular settings)
- Standard (Specular setup) ์์ด๋์ Specular
์คํฌ๋ฆฝํธ๋ฅผ ํตํด์ ๋จธํ ๋ฆฌ์ผ ์์ฑ์ ๋ณด๋ฅผ ์ ๊ทผํ๊ฑฐ๋ ์์ ํ๋ ๋ฐฉ๋ฒ(Accessing and Modifying Material parameters vis script)
๋นํธ์ธ ์์ด๋(Built-in Shaders)
-
Mobile / Background ์์ด๋
- ๋ผ์ดํ ์ํฅ๋ ๋ฐ์ง ์๊ณ ๋จ์ง ํ ์ค์ณ๋ง ์ถ๋ ฅํ๋ ์ด ๊ฐ๋จํ ์์ด๋์ ๋๋ค. ZWrite๋ ํ์ง ์์
- ์ฆ ์ด๊ฒ์ ๋ง๊ทธ๋๋ก ์๊ฑฐ๋ฆฌ ๋ฐฐ๊ฒฝ์ฉ ์์ด๋.
- ์ค์นด์ด๋ฐ์ค๋ ์๋๊ณ ๋ฉ๋ฆฌ ๋ณด์ด๋ ์๊ฒฝ ํ ์ฅ์ง๋ฆฌ ์ด๋ฏธ์ง ๊ฐ์ ๊ฒฝ์ฐ์ ์ธ ์ ์๋ ์์ด๋์ ๋๋ค. 0.5g
-
Mobile / Bumped Specular
- ๋ณด์ด๋ ๊ทธ๋๋ก, ๋ชจ๋ฐ์ผ์ฉ์ผ๋ก ๋ง๋ ์คํํ๋ฌ๊ฐ ํฌํจ๋ ๋ ธ๋ง๋งต ์ฌ์ฉ ์์ด๋์ ๋๋ค.
- ์ข ๋ ๊ฐ๋ตํ ๋ ํน์ง์ ๊ฐ์ง๊ณ ์๋๋ฐ,
- ๋ฉ์ธ ์นผ๋ผ๋ ์คํํ๋ฌ ์นผ๋ผ๋ฅผ ์ง์ ํ ์ ์์ต๋๋ค.
- ์คํํ๋ฌ์์ ์ฌ์ฉํ๋ ๋ผ์ดํธ ๋ฐฉํฅ์ ๋ฒํ ์ค์์ ๋์ถฉ ๋ฐ์์ ์ต๋๋ค.
- ๋ ธ๋ง๋งต์ ํ์ผ๋ง์ด๋ ์ต์ ์ ๋ฒ ์ด์ค ํ ์ค์ณ์ ์ค์ ๊ฐ์ ๋ฐ๋ฆ ๋๋ค.
- ๋ํผ๋ ๋ผ์ดํ ์ ์ง์ํ์ง ์์ต๋๋ค. ๋ผ์ดํธ๋งต๋ ์ง์ํ์ง ์์ต๋๋ค.
- ๋๋ ์ ๋ ๋ผ์ดํธ 1๊ฐ๋ง ์ง์๋๊ณ , ๋๋จธ์ง ๋ผ์ดํธ๋ค์ ๋ฒํ ์ค ๋ผ์ดํธ๋ ๊ตฌ๋ฉด์กฐํ ๋ผ์ดํธ๋ก ์๋ํฉ๋๋ค.
- ์ผ๋ฐ์ ์ธ ๋ฒํ/์คํํ๋ฌ๋ณด๋ค๋ ์ข ๊ฐ๋ณ๊ฒ ๋์ด ์๊ธด ํฉ๋๋ค๋ง, ๊ทธ๋๋ ๋ ธ๋ง๋งต ์ฐ์ฐ์ด ๋๋ฏ๋ก ๋ชจ๋ฐ์ผ์์ ํจ๋ถ๋ก ์ฌ์ฉํด์๋ ๊ณค๋ํฉ๋๋ค. 3g
-
Mobile / Bumped Specular (1 Directional Light) ์์ ๋ฒํ ์คํํ๋ฌ ์์ด๋์ ๋์ผํ์ง๋ง, ๋จ ํ๊ฐ์ง๋ง ๋ค๋ฆ ๋๋ค.
- ๋๋ ์ ๋ ๋ผ์ดํธ 1๊ฐ๋ง ์ง์๋๊ณ , ๋๋จธ์ง ๋ผ์ดํธ๋ ๋ฌด์๋ฉ๋๋ค. ์ฆ ์์ ์์ด๋๋ณด๋ค ์์ฃผ ์ฝ๊ฐ ๊ฐ๋ณ๋ค๊ณ ํ ์ ์์ต๋๋ค. 2.7g
- Mobile / Particles / Additive ์ด์ ์ ์ฌ์ฉํ๋ ์ผ๋ฐ์ ์ธ Add ์์ด๋์ ๊ฑฐ์ ๊ฐ์ผ๋ฉฐ, ๋ค๋ฅธ์ ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
- Tint Color๊ฐ ์์ต๋๋ค.
- ์ค๋ฌด์ค ํํฐํด ์ต์ ์ด ์์ต๋๋ค.
- ์ํํ ์คํธ๊ฐ ์์ต๋๋ค (์ ์๋ ์์๋?)
- ์นผ๋ผ๋ง์คํฌ๊ฐ ์์ต๋๋ค. ์ฌ์ค์ ๊ทธ ์ธ๋ ๋์ผํ๊ฒ ์ ์๋์ด ์์ต๋๋ค. ์ข ๋ ๊ฐ๋ฒผ์์ง ๋ฒ์ ์ด๋ผ๊ณ ํ ์ ์์ต๋๋ค. 1.5g
-
Mobile / Particles / Alpha Blended ์ด์ ์ ์ฌ์ฉํ๋ ์ํ ๋ธ๋ ๋ฉ ์์ด๋์ ๋์ผํ๋ฉฐ, ๋ค๋ฅธ์ ์ ์์ Add ์์ด๋์ ๊ฐ์ต๋๋ค.
-
Mobile / Particles / Multiply ์ด์ ์ ์ฌ์ฉํ๋ ๋ฉํฐ ์์ด๋์ ๋์ผํ๋ฉฐ, ๋ค๋ฅธ์ ์ ์๋์ ๊ฐ์ต๋๋ค.
- ์ค๋ฌด์ค ํํฐํด ์ต์ ์ด ์์ต๋๋ค.
- ์ํํ ์คํธ๊ฐ ์์ต๋๋ค
- ์นผ๋ผ๋ง์คํฌ๊ฐ ์์ต๋๋ค. ์ญ์ ์ด์ ์ ์ฌ์ฉํ๋ ์์ด๋์ ๋์ผํ๋ ์ฝ๊ฐ์ฉ ๊ฐ๋ณ๊ฒ ์ ์๋ ๊ฒ ์ธ์ ์ฐจ์ด๊ฐ ์์ต๋๋ค .
- Mobile / Particles / VertexLit Blended ์ด์ ์ ์ฌ์ฉํ๋ ๋ฒํ ์ค๋ผ์ดํธ ๋ธ๋ ๋๋ ์์ด๋์ ๋์ผํ๋ฉฐ, ๋ค๋ฅธ์ ์ ์๋์ ๊ฐ์ต๋๋ค.
- ์ํํ ์คํธ๊ฐ ์์ต๋๋ค.
- ์นผ๋ผ๋ง์คํฌ๊ฐ ์์ต๋๋ค. ์ดํ ์๋
-
Mobile / Skybox ์ด์ ์ ์ฌ์ฉํ๋ ์ค์นด์ด๋ฐ์ค ์์ด๋์ฒ๋ผ 6๋ฉด์ ํ ์ค์ณ๋ฅผ ์ง์ด ๋ฃ์ต๋๋ค. ๊ทธ๋ ์ง๋ง ๋จ์ง Tint Color ๋ง์ด ์ ๊ฑฐ๋์ด ์์ต๋๋ค. ์ฌ์ค์ ๊ฑฐ์ ๊ฐ์ง๋ง ์์ฃผ ์ด์ง ๊ฐ๋ฒผ์ด ์ ๋์ ๋๋ค. ๋๋ถ๋ถ, ๊ธฐ๋ฅ๋ค์ ๊ผญ ์ ๊ฑฐํ ๋งํผ ํจ๊ณผ๊ฐ ์ปค ๋ณด์ด์ง ์์ต๋๋ค.
-
Mobile / VertexLit ๊ธฐ๋ณธ์ ์ธ ๋ฒํ ์ค ์นผ๋ผ ์์ด๋์์ ์ผ๋ถ ๊ธฐ๋ฅ์ด ์ญ์ ๋ ์์ด๋์ ๋๋ค.
- per material ์นผ๋ผ๊ฐ ์ญ์ ๋์ด ์์ต๋๋ค.
- ์คํํ๋ฌ๊ฐ ์์ต๋๋ค.
- emission์ด ์์ต๋๋ค. ๊ทธ ์ธ๋ ๋์ผํฉ๋๋ค. ์ฌ์ค์ ๋ชจ๋ฐ์ผ ์์ด๋๋ผ๊ณ ํด์ ํน๋ณํ๊ฒ ๋ง๋ค์ด ์ง ๊ฒ์ ์์ผ๋ฉฐ, ๋จ์ง ๊ธฐ๋ฅ์ด ๋ช ๊ฐ์ฉ ์ญ์ ๋ ์ ๋์ ๋๋ค. ์ฆ ์ผ๋ฐ ๊ฒ์์ฉ ์์ด๋๋ '๊ฐ๋ฒผ์ด ์์ด๋ ๋ผ๋ฉด' ๋ชจ๋ฐ์ผ์์๋ ๋๋ถ๋ถ ๋๊ฐ์ด ๋์๊ฐ๋ฉฐ, ์ฌ์ฉ์ ์ ์ฝ์ด ์์ต๋๋ค. ์ดํํธ ์์ด๋๋ค๋ ๋ชจ๋ฐ์ผ์ฉ์ผ๋ก ์ปจ๋ฒํ ํด ๋๋๋ก ํด์ผ๊ฒ ๋ค์...
ํ๋์จ์ด ๊ทธ๋ํฝ ํธํ์ฑ๊ณผ ์๋ฎฌ๋ ์ด์ (Graphics Hardware Capabilities and Emulation)
- http://docs.unity3d.com/Manual/GraphicsEmulation.html
- Shader Model Emulation
- Edit > Graphics Emulation > No Emulation / Shader Model 3 / Shader Model 2
์ถ๊ฐ์ ์ผ๋ก ํ์ธํ ๊ฒ๋ค
- ์์ด๋ ํฌ์ง์ ๋ชจ๋ฐ์ผ ๋๋ฐ์ด์ค ํธํ์ฑ ํ์ธ์์ (Shader Forge for Mobile)
- ์์ด๋ ์ฝ๋์ ๋ชจ๋ฐ์ผ ๋๋ฐ์ด์ค ํธํ์ฑ ์์
- ์์ด๋ ์ต์ ํ ์ผ์ด์ค ์คํฐ๋
- http://www.slideshare.net/AlexanderDolbilov/google-i-o-2014
- http://aras-p.info/texts/files/FastMobileShaders_siggraph2011.pdf
- http://malideveloper.arm.com/downloads/Unite_2013-Optimizing_Unity_Games_for_Mobile_Platforms.pdf
- https://developer.nvidia.com/sites/default/files/akamai/gamedev/docs/Optimizing%20Tegra%20Apps%20and%20Games%20using%20Unity.pdf
- https://software.intel.com/sites/default/files/managed/c8/14/Unity-Optimizations-for-x86-Android-V2_92.pdf
- ๋ชจ๋ฐ์ผ GPU ์ ์กฐ์ฌ๋ณ ์์ด๋ ํ๋กํ์ผ๋ง/๋๋ฒ๊น ์์ http://hwstats.unity3d.com/mobile/