【Unite 2017 Tokyo】シェーダープログラミング入門!カスタムシェーダー、作るで!

>100 Views

May 08, 17

スライド概要

講演者:アルトゥロ・ヌネス(Unity Technologies)

こんな人におすすめ
・シェーダーを使用してビジュアル改良方法を学びたいプログラマー
・Unityのグラフィックスの仕組みやカスタムシェーダーで何が達成できるか知りたいアーティスト
・シェーダーの基本構造と使用方法を理解したい学生


受講者が得られる知見
・Unityのグラフィックス・パイプラインの仕組みとUnity シェーダーの基本構造
・カスタムシェーダーの作成方法
・頂点シェーダーとフラグメントシェーダーで使用される基本的な数学的コンセプト

講演動画:https://youtu.be/vv1DTGKnMuE

profile-image

リアルタイム3Dコンテンツを制作・運用するための世界的にリードするプラットフォームである「Unity」の日本国内における販売、サポート、コミュニティ活動、研究開発、教育支援を行っています。ゲーム開発者からアーティスト、建築家、自動車デザイナー、映画製作者など、さまざまなクリエイターがUnityを使い想像力を発揮しています。

シェア

またはPlayer版

埋め込む »CMSなどでJSが使えない場合

関連スライド

各ページのテキスト
2.

Introduction to Shader Programming

3.

Arturo Núñez Product Evangelist, Unity Technologies @ArturoNereu

4.

Shader A set of instructions that runs on the GPU

5.

DirectX 11 Grass Shader

6.

Amplify Shader Editor

7.

The Rendering Pipeline http://fragmentbuffer.com/gpu-performance-for-game-artists/

8.

Types of Shaders • Vertex Shaders • Fragment Shaders • Surface Shaders • More…

9.

The Vertex Shader • Input • Multiple vertices: position, normal, color • Output • New Position • Other Information

10.

The Fragment Shader • Input • Fragments to become Pixels • Output • Color of Pixel • Alpha of Pixel

11.

The Surface Shader • Auto-generated code approach. • Useful to interact with lighting models in a simple way.

12.

A Basic Shader

13.

We program our shaders using… • CG (C for Graphics) • ShaderLab

14.

CG • Similar to the “C” language. • Precision: • float • half • fixed • Variables with 1, 2, 3 or 4 values • • • • float a = 10.5; float2 uv = float2(0.5, 0.5); float3 normal = float3(0.2, 0.5, 0.3); float4 color = float4(1, 1, 0, 1);

15.

CG • We can access the values using “swizzling”: • float3 c = color.rgb; • foat3 c = color.xyz; • float2 c = color.yx; We operate in Parallel: float3 a = float3(4.5, 2.2, 3.3); float3 b = float3(2.5, 3.1, 1.4); float3 c = a + b;

16.

appdata_base struct appdata_base { float4 vertex : POSITION; // The vertex position in model space. float3 normal : NORMAL; // The vertex normal in model space. float4 texcoord : TEXCOORD0; // The first UV coordinate. };

17.

appdata_full struct appdata_full { float4 vertex : POSITION; // The vertex position in model space. float3 normal : NORMAL; // The vertex normal in model space. float4 texcoord : TEXCOORD0; // The first UV coordinate. float4 texcoord1 : TEXCOORD1; // The second UV coordinate. float4 tangent : TANGENT; // The tangent vector in Model Space. float4 color : COLOR; // Per-vertex color };

18.

SurfaceOutput struct SurfaceOutput { half3 Albedo; //Just the diffuse color. half3 Normal; //Tangent space normal, if written. half3 Emission; //Emission value in 0..1 range. half Specular; //Specular power in 0..1 range. half Gloss; //Specular intensity. half Alpha; //Alpha value for transparency. };

19.

References • Slides and demo Project: • https://github.com/ArturoNereu/ShaderProgramming_101 • Shader Programming online course: • http://cvgshader.teachable.com/courses/shader-development-usingunity-5 • Making Stuff Look Good in Videogames: • https://www.youtube.com/channel/UCEklP9iLcpExB8vp_fWQseg

20.

References • Alan Zucconi’s Shaders Tutorials: • http://www.alanzucconi.com/2015/06/10/a-gentle-introduction-toshaders-in-unity3d/ • Gerardo Horvilleur on Shaders (Spanish): • https://www.youtube.com/watch?v=vaiyuVlZuCk • Shadertoy: http://shadertoy.com

21.

Q&A

22.

おおきに !!