8

グラフィックペーパーからアルゴリズムを実装しようとしていますが、アルゴリズムの一部は、既知の半径の球をバッファーにレンダリングしています。彼らは、頂点シェーダーで位置とサイズを計算し、フラグメントシェーダーで適切なシェーディングを行うことによって、球をレンダリングすると言います。

彼らが実際にこれをどのように行ったかについての推測はありますか?位置と半径はワールド座標で知られており、投影は遠近法です。それは球が円として投影されることを意味しますか?

4

3 に答える 3

2

必要なもの、つまり境界二次曲面の計算について説明している論文を見つけました。見る:

http://web4.cs.ucl.ac.uk/staff/t.weyrich/projects/quadrics/pbg06.pdf

セクション3.2、バウンディングボックスの計算。ペーパーは頂点シェーダーでそれを行うことにも言及しているので、それはあなたが求めているものかもしれません。

いくつかの個人的な考え:

ただし、球のサイズをその半径で概算することにより、バウンディングボックスを概算できます。これを画面スペースに変換すると、正しいバウンディングボックスよりも少し大きくなりますが、それほど遠くはありません。もちろん、カメラがポイントに近すぎる場合、または球が大きすぎる場合、これは失敗します。しかし、それ以外の場合は、2つの類似した直角三角形の比率にすぎないため、計算するのに非常に最適です。

弦の長さがわかれば、その比率で正確な答えが得られますが、それは今のところ私を少し超えています。

代替テキストhttp://xavierho.com/temp/Sphere-Screen-Space.png

Of course, that's just a rough approximation, and has a large error sometimes, but it would get things going quickly, easy.

Otherwise, see paper linked above and use the correct way. =]

于 2010-04-28T07:47:45.377 に答える
1

The sphere will be projected as an ellipse unless it's at the cameras center as brainjam says.

The article that Xavier Ho links to describes the generalization of sphere projection (That is, quadratic projection). It is a very good read and I recommend it too. However, if you are only interested in sphere projection and more precisely the quadrilateral that bounds the projection then The Mechanics of Robust Stencil Shadows, page 6: Scissor Optimization details how to do it.

A Note on Xavier Ho's Approximation

I would like to add that the approximation that Xavier Ho suggests is, as he notes too, very approximative. I actually used it for a tile-based forward renderer to approximate light bounds in screen space. The following image shows how it neatly enables good performance with 400 omni (spherically bound) lights in a scene: Tile-based Rendering - Far View. However, just like Xavier Ho predicted the inaccuracy of the light bounds causes artifacts up close as seen here when zoomed in: Tile-based Rendering - Close view. The overlapping quadrilaterals fail to bound the lights completely and instead clip the edges revealing the tile grid.

于 2012-08-24T16:29:41.950 に答える
0

In general, a sphere is seen as an ellipse in perspective:

alt text
(source: jrank.org)

The above image is at the bottom of this article.

Section 6 of this article describes how the bounding trapezoid of the sphere's projection is obtained. Before computers, artists and draftsmen has to figure this out by hand.

于 2010-04-28T14:47:36.130 に答える