SlideShare ist ein Scribd-Unternehmen logo
1 von 43
ゲーム作りの雰囲気
~ビームを出そう!
190625 平山尚
私はゲーム作ってるんですが、
皆さんは作ってませんよね?
何、話せばいいの?
わからないので、好きにする!!
たまたまこの二日くらいやってたことで行きます。
ゲーム屋の日常をご観賞ください。
ビームとは何か?
なんかドバーっと光る線が
敵に飛んでって壊す奴。
ビームって線だよね?
線ってどうやって描くの?
普通は三角形つなげて描く。
GPU(Graphics Processing Unit)は三角を書く機械。
でも、今のスマホは
PLAYSTATION3くらい速い。
豪華に行こう。
線=つながった点
点をいっぱい描くぜ。
それっぽい
それぞれは三角に丸い絵を貼ってる
カメラに垂直を保てばペラく見えない
せっかく光の粒なんだし、
ホワァッっと消えたら良くね?
粒子ごとに運動方程式。
積分はオイラーでいいや。
a = f/m
v’ = v + Δt×a
p’ = p + Δt×v
力をランダムに加えれば、
風とか、大気中の粒子の衝突とか、
感じ出るよね?
感じ出てきたぞ
当たったら、火花出るでしょ普通。
これも粒子だよね
装甲の破片が赤熱して散ってるなら、
重いんだし落ちるよね。
重力加えよう。
f = new Vector3(0f, -gravity, 0f);
散らす方向は?
球面にランダムに散らして、その方角に飛ばそう。
角度2つθ、φをランダムに決めるけど、それだと極で
密になっちゃうから工夫がいるね。
縦角度θの輪の長さはcosθに比例するから、cosθを積
分して累積分布関数にして、逆関数取ればいいね!
yAngle = Random.Range(-Mathf.PI, Mathf.PI);
var r = Random.Range(0f, 1f);
xAngle = Mathf.Asin((2f * r) - 1f);
まあまあかな。
なんか、クッソ重いんだけど。
気づいたら3万個出てた。
16msごとに3万個積分しようってんだから、そりゃヤ
バいよ。
速くすっか。
とりあえずスレッド。
粒子同士の依存関係はない。
グループ分けしてスレッドにブン投げる。
スレッドプール
スレッドを作るのも止めるのもOS処理が走る。
スレッドは決まった数作りっぱにして、仕事
をキューに積んで、ヒマになった奴が仕事取る。
速くなった。
下がスレッド。上のメインス
レッドはそれを待ってる。
いっぱい出る
でもなんかさみしい。
光なのにまぶしくないぞ
まぶしい?
蛍光灯写真。
はみ出してる。
はみ出せばまぶしい!!
ポストプロセスしよう!!
GPU並列計算で光を広げちゃえ!!!
参考:https://techblog.kayac.com/unity-light-weight-bloom-effect
まぶしい!!!!
で、できたのがこんなの(デモ)
• 板をカメラに向けるベクトル演算
• キャッシュ効率を鑑みたデータ構造のC#実装
• スレッドプール実装と同期
• ほどよく被写体を写すカメラ制御の数学
あたりもコツがあります。省略。
こんな感じな私の日常です。
ゲーム作るの、楽しそうでしょ?
ありがとうございました!!
twitter: https://twitter.com/hirasho
デモコード: https://github.com/hiryma/UnitySamples/tree/master/ParticleBeams

Weitere ähnliche Inhalte

Empfohlen

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Empfohlen (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

190625 LT 「ビーム」

Hinweis der Redaktion

  1. 普通は四角形ですが、正三角形を使うと頂点3/4、インデクス1/2で、描画面積は同じです。テクスチャはクランプにするか、余白を多く取りましょう。
  2. 実際はForward-Backward Eulerです。p’ = p + Δt×v’と、 v’を使います。機械によっては若干遅いかもしれませんが、ほとんど同負荷で積分の安定性が上がるので便利です。
  3. 実際には、ビームベクトルを敵法線に対して反射させたベクトルを中心に、Phongの式と同じ感じでcosの累乗で分布を作っています。
  4. JobSystemも試しましたが、データ量と計算量の比が悪く、コピーのオーバーヘッドで遅くなったので、自前でやりました。 なお、Updateで計算キック、LateUpdateで待ち合わせをしており、1フレ結果が遅れて良いならかなり性能を上げられます。また、実際の製品であればUpdateでやることがもっとたくさんあるので、並列性はより生きるでしょう。
  5. Fire16ボタンを押すと16本のビームが出ます。
  6. スレッドプールによる並列化ですが、 同じ配列の異なる要素を複数スレッドでアクセスして安全か? ということを確認していないので、 安全を期すなら配列もスレッドごとに分けた方が良いと思われます。