Shader on Unity
2 0 1 7 0 9 2 1
S A K U R A G I Y O S H I M A S A
Speaker
(@ysrhspyoshi)
22
MA
Overwatch
Introduction : Shader . ProgrammableShader
Problem :
Approach : Shader
Experiment :
Application :
Discussion
Contents
Introduction
https://github.com/SakuragiYoshimasa/shader_test_unity
Shader
Programmable shader → Shader .
GPU .
Rendering Pipeline in Unity : http://elringus.me/blend-modes-in-unity/
Programmable Shader
3D
.
VERTEX FRAGMENT SURFACE
Unity
.( )
V/F shader
Rendering Pipeline in Unity : http://elringus.me/blend-modes-in-unity/
Example : Fragment
Example : Vertex /w S
https://vimeo.com/235104527
https://github.com/SakuragiYoshimasa/shader_test_unity
Vertex Shader Vertex Stream , .
Fragment Shader .
Surface Shader .
Summary of Introduction
Problem
,
update
, FPS .
Approach
Approach xyz rgb ,
.
Index RenderTexture .
Shader RenderTexture .
Graphics.DrawMeshInstancedIndirect
Read from Render Texture
Write to Render Texture
Shader
Experiment
https://github.com/SakuragiYoshimasa/shader_lt
Task Setting
Sphere
100 * 100 10000
Shader Instantiate
Update
statistics
Shader : T1
SetPass call FPS .
10000 .
Shader : T2
RenderTexture RenderTexture
Shader : T2
RenderTexture RenderTexture
100*100 RT
v
u1.0
1.0
100
100
Example: unity_InstanceID = 5050
u = float(5050 / 100) / 100.0 = 0.5
v = float(550 % 100) / 100.0 = 0.5
RGB = (r, g, b)
offset .
Results
T1 T2
RenderTexture ,
.
Application
https://github.com/SakuragiYoshimasa/ShaderLab
2 5
Unity Animation SkinnedMesh
Verts : 5(div)*33(seg)*4096
2 6
Unity SkinnedMesh Animation World
Shader Vertex Baking
2 7
Shader Vertex Baking
Camera Replaced Shader Rendering * * https://docs.unity3d.com/Manual/SL-ShaderReplacement.html
0
1
2
3
4
5
Position Buffer ( Render Texture)
Normal Buffer ( Render Texture)
Rendering 0 1 2 3 4 5
0 1 2 3 4 5
. Unite2017 .
2 8
Shader Vertex Baking
Camera Replaced Shader Rendering * * https://docs.unity3d.com/Manual/SL-ShaderReplacement.html
Rendering
PositionExtractShader
2 9
Shader Vertex Baking
*1 texture
.
3 0
.
.
Mesh
.
Idea
.
, ,
.
3 1
.
, ,
.
index ,
.
Compute Shader
3 2
Compute Shader :
shader .
Mac OS
Metal API .
.
3 3
Buffer ComputeShader
Thread ID
Dispatch
3 4
ComputeShader
pragma Kernel
Quatanion Writable .
3 5
.
Graphics.DrawMeshInstancedIndirect 4096
positionBuffer , rotationBuffer World .
3 6
:
, 5 33 .
ID .
3 7
: Vertex Shader
ID
,
ID
3 8
: Vertex Shader
3 9
: Vertex Shader
,
4 0
PostProcessing
https://vimeo.com/235104558
4 1
UP
, RTVJ ,
, .
( Unite .)
C .
Graphic.Blit RenderTexture Shader
,
Kodelife Atom Shader .
Discussion
Thank You For Listening!

Shader on Unity @Lit!関西LT会