Comments (5)
手元で試せず検証してないので、自分の考えがあっているのか、速くなるのかわからないのですが、
ここがちょっと計算が重複していて速くなる可能性がある感じがします。
sqrMagnitudeとnormalizedの計算の中で両方、x^2 + y^2 + z^2を計算しているので。
sqrMagnitude = x^2 + y^2 + z^2ですが、
ここで、
v = (x, y ,z)
d2 = x^2 + y^2 + z^2
d = sqrt(d2)とすれば、
sqrMagnitude = d2
normalized = (x / d, y / d, z /d)
なので、
normalized / sqrMagnitude = (x / (d * d2) , y / (d * d2), z / (d * d2));
となるので、normaizedを使わずに自力で平方根を使って計算するとsqrMagnitudeの値が使いまわせると思います。
(プログラムの可読性は少々落ちますが)
後、この際に平方根をMathfのほうのsqrtを使うと、doubleからfloatへのキャストをなくせると思います。
https://docs.unity3d.com/ja/2017.4/ScriptReference/Mathf.Sqrt.html
from holomagnet3.
CalculatorからMonobehaviourを外し、限界まで軽量化したが、1回計算するのに2 micro秒かかってしまう。数学関数のせい?これ以上はGPUに処理を移さないと無理。
from holomagnet3.
ご丁寧に見ていただいて、ありがとうございます。当方現在出張中ですが、帰り次第早急に実機にて検証したいと思います。
from holomagnet3.
1回の計算に2マイクロ秒かかっていたのが1マイクロ秒になりました。すごいです。ありがとうございます!
しかし…FPSはあいかわらず40。どうも違うところにボトルネックがあるようです。すいません!
from holomagnet3.
すでにだいぶ軽量化されているので絞れるところを見つけるのが結構、難しいですねぇ。
その上でどこがボトルネックなのか。
from holomagnet3.
Related Issues (20)
- Directional Indicatorを追加
- 磁場を動的に動かす HOT 1
- 磁力線の描画方法が厳密ではない HOT 3
- Port to Magic Leap One
- Port to Oculus Quest
- Port to iPad
- Port to ARCore
- Add Compasses around second bar magnet
- Remove all Singleton class from MRTK for porting other platforms HOT 1
- Enable simple Sharing
- ARマーカーに対応する
- Backupシーンを、ARマーカーがない場合の磁石2個シーンにする
- 棒磁石が動かない HOT 4
- MiraCast用にARマーカーのオフセットを調整
- Port to Aryzon
- Port to Dangla
- Port to Nreal
- シェーダの問題 HOT 4
- [質問]ScriptingBackEndに.NET4.6 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from holomagnet3.