1

First of all, I have very little knowledge of what shaders can do, and i am very interested in making vertex lighting. I am attempting to use a 3d colormap which would be used to calculate the vertex color at that position of the world, and also interpolate the color by using the nearby colors from the colormap.

I cant use typical OpenGL lighting because its probably too slow and theres a lot of lights i need to render. I am going to "render" the lights at the colormap first, and then i could either manually map every vertex drawn with the corresponding color from the colormap.

...Or i could somehow automate this process, so i wouldnt have to change the color values of vertexes myself, but a shader could perhaps do this for me?

Questions is... is this possible, and if it is: what i need to know to make it possible?

Edit: Note that i also need to update the lightmap efficiently, without caring about the size of the lightmap, so the update should be done only at that specific part of the lightmap i want to update.

4

3 に答える 3

0

固定関数のパイプライン機能を使用できない場合、頂点ごとのライティングを行う最善の方法は、頂点シェーダーで頂点ごとにすべてのライティング計算を行うことです。その後、フラグメント シェーダーに渡すと、顔。

多数の光源を使用する場合のパフォーマンスの問題に対処するもう 1 つの方法は、遅延レンダリングを使用することです。これは、実際に表示されているジオメトリの照明計算のみを行うためです。

于 2010-11-19T23:53:35.973 に答える
0

それは可能ですが、現在のハードウェアでは有効ではありません。

ライト ボリュームを 3D テクスチャにレンダリングします。ラスタライザーは 2D サーフェスで機能するため、ボリュームを軸の 1 つに沿って分割する必要があります。分割は、次のいずれかの方法で実行できます。

  • スプリットごとに異なるドローコール
  • glInstanceID に基づくレイヤー選択によるインスタンス化された描画 (ジオメトリ シェーダーが必要)
  • 単一の描画呼び出しから直接ジオメトリ シェーダーで分岐する

実装するには、GL-3 の仕様と例を読むことをお勧めします。簡単なことではありませんし、複雑なシーンの結果を十分に速くすることもできません。

于 2011-02-11T16:53:35.603 に答える
0

やりたいことは、ライトをカラーマップにレンダリングしてから、カラーマップをテクスチャとして使用することですが、デカールモードの代わりに変調モードに設定することで、既存の色を単に置き換えるのではなく乗算します。.

ただし、これは 1 つの点で異なります。頂点に影響を与えるだけでなく、個々のフラグメント (本質的にはピクセル) にマップされます。

編集: 私が考えていたのは 3D テクスチャではなく、キューブ マップでした。基本的に、「世界」のすべてを囲む仮想立方体を作成します。その立方体の面ごとに 2D テクスチャを作成します。色をキューブ マップにレンダリングします。次に、頂点に色を付けるには、中心から頂点を通って立方体まで光線を (仮想的に) 外側に伸ばします。キューブ マップでヒットしたピクセルは、その頂点の照明の色を示します。

更新は比較的効率的である必要があります。上部、下部、前面などに通常の 2D テクスチャがあり、必要に応じてそれらを更新します。

于 2010-11-19T16:34:01.433 に答える