Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Shaderお絵描き初級編
Search
hacha
November 28, 2018
Programming
730
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Shaderお絵描き初級編
2018/11/28 Gotanda.unity #9 でのLTスライドです。
プロジェクトはこちら
https://github.com/hacha/ForGotandaUnity_9
hacha
November 28, 2018
Other Decks in Programming
See All in Programming
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
8
2.2k
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
180
R8 の設定見直しでアプリサイズ削減
andpad
0
220
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
290
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
1
440
最近”作らせてる” ローカルAIアプリの話
akit37
0
470
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
6.6k
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
ChromeでローカルLLM
ryu1013
0
140
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
240
Featured
See All Featured
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
Raft: Consensus for Rubyists
vanstee
142
7.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
480
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
Git: the NoSQL Database
bkeepers
PRO
433
67k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Transcript
γΣʔμʔ͓ֆඳ͖ॳڃฤ @hacha 2018/11/28 Gotanda.unity #9 in Unity Technologies Japan @ۜ࠲
ࣗݾհ • hacha(@hacha) • ϑϦʔϥϯεͷΤϯδχΞ ओʹιγϟήͱ͔ϞόΠϧ͚ήʔϜ։ൃ ࠷ۙMRؔͷ͜ͱͬͯͨΓ
ࠓճ͢༰ • QuadʹϑϥάϝϯτγΣʔμʔͰ ͳΜ͔ͪΐͬͱΠΠΧϯδͷ༷Λඳ͘ • γΣʔμʔͰ༷Λඳָ͘͠͞Λ͑Δ ࠓճ͞ͳ͍༰ • HLSLͷࡉ͔͍จ๏ͱ͔આ໌͠·ͤΜɻ ͋·Γ͍͜͠ͱ͍ͯ͠ͳ͍ͷͰɺͬͯ
Δ͜ͱͷχϡΞϯεΛ΅ΜΓ௫ΜͰΒ͑ Εɻ
Step1 ৭ΛృΔ fixed4 frag (v2f_img i) : SV_Target { return
fixed4(1, 0, 0, 1); } ൘ϙϦΛਅͬʹϕλృΓ͢Δɻ ϑϥάϝϯτγΣʔμʔͷ෦͚ͩൈਮ 3(#"ͷΛฦ͢ͱɺͦͷ৭Ͱృͬͯ͘ΕΔɻ ͦΕ͕ϑϥάϝϯτγΣʔμʔͬͯͭͩɻ
Step2 നࠇͷάϥσʔγϣϯʹ͢Δ fixed4 frag (v2f_img i) : SV_Target { //
i.uv ʹUV࠲ඪͷ͕ೖ͍ͬͯΔ float c = i.uv.x * i.uv.y; return fixed4(c, c, c, 1); } ϕλృΓ͡Ό໘ന͘ͳ͍ͷͰɺάϥσʔγϣϯʹ ͢Δɻ
Step2 നࠇͷάϥσʔγϣϯʹ͢Δ γΣʔμʔͰQuadʹԿ͔ඳͬͯ͘͜ͱͭ·Γ 0.0ʙ1.0ͷͷೖྗʹରͯ͠ɺԿΒ͔ͷRGBAͷ Λฦ͢͜ͱ
Step3 ԁΛඳ͘ fixed4 frag (v2f_img i) : SV_Target { float2
pos = i.uv; // 0.0ʙ1.0 ͷൣғͷ pos Λ -1.0ʙ1.0 ͷൣғʹͳΔΑ͏ม pos = pos * 2.0 - 1.0; // ԁΛඳ͘ float c = 1.0 - length(pos); return fixed4(c, c, c, 1); } த৺͔ΒͷڑʹԠͯ͡৭͕มΘΔΑ͏ʹ͍ͯ͠ Δɻ
Step4 ಈ͔͢ fixed4 frag (v2f_img i) : SV_Target { float2
pos = i.uv; // 0.0ʙ1.0 ͷൣғͷ pos Λ -1.0ʙ1.0 ͷൣғʹͳΔΑ͏ม pos = pos * 2.0 - 1.0; // ԁΛඳ͘ float c = 1.0 - length(pos); // ࣌ؒܦաͰ͕มΘΔΑ͏ʹ͢Δ c = frac(c + _Time.x * 5.0); return fixed4(c, c, c, 1); } _TimeͬͯͷఆٛࡁΈͷ࣌ؒͰɺ૿͑ଓ͚Δɻ ͦͷ··͠ࠐΉͱ1Λ͑ͪΌ͏ͷͰɺfrac()ؔͰ 0.0ʙ1.0ͷൣғʹͳΔΑ͏ௐɻ
Step4 ಈ͔͢ frac(x)ؔɺxͷখ෦Λฦؔ͢ɻ ͭ·ΓΛ0.0ʙ1.0ͷൣғͷ܁Γฦ͠ʹͰ͖Δɻ ͪͳΈʹ͜ͷਤGraphToyͰඳ͍ͯ·͢ɻ ͪΐͬͱࣜΛ֬ೝ͍ͨ࣌͠ʹศརʂ http://www.iquilezles.org/apps/graphtoy/ y=x ͱ y=frac(x)
ͷରൺΠϝʔδ
Step5 ৭Λ͚Δ { ʙ͜ΕҎલলུʙ return fixed4(c, c, c, 1); }
{ ʙ͜ΕҎલলུʙ fixed4 ret = hsv2rgb(c, 1.0, 1.0); // ผ్ఆٛͯ͠·͢ return ret; } ͜͜·ͰRGB͕શͯಉ͡Ͱฦ͍ͯͨ͠ͷͰࠇ͔Βനͷάϥσʔγϣϯͩͬͨɻ HSV͔ΒRGBʹมͯ͠ฦ͢Α͏ʹͯ͠ΈΔɻ hsv2rgb()ͷৄࡉׂѪɻͦ͏͍͏͕ࣜ͋ΔͬΆ͍ͷΛ͖͚࣋ͬͯͨͩͳΜͰɻ
Step5 ৭Λ͚Δ HSV৭ۭؒͱʁ ͳΔ΄ͲɺΑ͔͘ΒΜ͕Hͷ͚ͩΠδΕ ΧϥϑϧʹͳΔͬΆ͍ɻ
Step6 ϙελϦθʔγϣϯ { ʙ͜ΕҎલলུʙ c = floor(c * 6.0) /
6.0; fixed4 ret = hsv2rgb(c, 1.0, 1.0); return ret; } ͋͑ͯ৭ௐΛམͱ͢ͱύΩοͱͯ͠ΠΠΧϯδʹ ͳΔɻ
Step6 ϙελϦθʔγϣϯ y=x ͱ y=floor(x * 6.0) / 6.0 ͷରൺΠϝʔδ
0.0ʙ1.0ͷͷൣғΛɺ0.0ʙ6.0ʹҾ͖৳ͯ͠ floor()ͰখҎԼΓࣺ͔ͯͯΒ ·ͨ0.0ʙ1.0ͷൣғʹ͢ɻ ͭ·ΓͷσΟςΟʔϧ͕ݮΔɺΈ͍ͨͳɻ
Step7 ฒΔ { float2 pos = i.uv; // 0.0ʙ1.0 ͷൣғΛ
0.0ʙ2.0 ͷൣғʹ্ͨ͠Ͱɺ࠶ 0.0ʙ1.0 ʹԡ͠ࠐΊΔ pos.x = frac(pos.x * 2.0); pos.y = frac(pos.y * 2.0); // 0.0ʙ1.0 ͷൣғͷ pos Λ -1.0ʙ1.0 ͷൣғʹͳΔΑ͏ม pos = pos * 2.0 - 1.0; // ԁΛඳ͘ // ҎԼུ }
Step7 ฒΔ y=x ͱ y=frac(x * 2.0) ͷରൺΠϝʔδ 0.0ʙ1.0ͷͷൣғΛɺ0.0ʙ2.0ʹҾ͖৳ͯ͠ frac()Ͱখ෦ͷΈऔΓग़͢ɻ
ͭ·Γ0.0ʙ1.0ͷൣғ͕2ճݱΕΔɻ
Step8 దʹࣜΛ͍͡Δ ͱΓ͍͔͋͑ͣͭ͘ύϥϝʔλΛ͍͡ΕΔΑ͏ʹ ͓͍ͯͯ͠ɺ͜͜·Ͱͷࣜʹదʹͨ͠Γֻ͚ ͨΓͯ͠ΈΔɻ ֶʹऑ͍ਓɺԿͱͳ͍ͬͯ͘͡มԽͨ͠ͷ ΛݟͯԿނͦ͏ͳͬͨͷ͔ߟ͑ͯΈΔͱษڧʹͳ Δɻͱࢥ͏ɻ
Step9 nanoKONTROL2Λങ͏ KORGͷMIDIίϯτϩʔϥʔ https://www.korg.com/jp/products/ computergear/nanokontrol2/
nanoKONTROL2ͷ͕͜͜ΠΠʂ • ϚςϦΞϧϓϩύςΟΛෳಉ࣌ʹ͍ ͡ΕΔʂ • ཧతʹखͰΛૢ࡞͢Δͱָ͍͠ʂ • ֶʹ৮ΕͯΔײʂ • ٬؍తʹεΰΠײ͕ग़Δʂ
• Կͱͳ͘ϓϩͬΆ͍ʂ
nanoKONTROL2Λ͓͏ʂ ɾࢀߟϦϯΫ MIDIίϯτϩʔϥʔNanoKONTROL2ΛUnityΞφ ϩάೖྗσόΠεͱͯ͠ར༻͢Δ http://psychic-vr-lab.com/blog/unity/ midi%E3%82%B3%E3%83%B3%E3%83%88%E 3%83%AD%E3%83%BC%E3%83%A9%E3%83 %BCnanokontrol2%E3%82%92unity%E3%82%A 2%E3%83%8A%E3%83%AD%E3%82%B0%E5% 85%A5%E5%8A%9B%E3%83%87%E3%83%90
%E3%82%A4%E3%82%B9%E3%81%A8/
Enjoy Shader!!