简体   繁体   English

最有效的纹理Splat OpenGL的方法?

[英]Most efficient way to texture splat opengl?

I have to combine up to 17 textures and then render it to a quad (well, 2 triangles) using openGL. 我必须组合多达17个纹理,然后使用openGL将其渲染为一个四边形(很好,2个三角形)。 I have to render a great deal of these quads - perhaps 500. 我必须渲染很多这些四边形-可能是500。

I was wondering what the fastest/best method to doing so: 我想知道这样做最快/最好的方法是什么:

A. render in many passes B. combine textures in FBO and render once C. use opengl multitexture and render in a few passes D. combine textures with CPU, upload to opengl texture, then render E. other? A.多遍渲染B.在FBO中组合纹理并渲染一次C.使用opengl多重纹理并在几遍中渲染D.将纹理与CPU组合,上传到opengl纹理,然后渲染E.其他?

Multiple passes means multiple pixel shader execution as well as multiple ROP/blending operations, which can easily become a bottleneck both on last generation and current generation hardware. 多次通过意味着要执行多个像素着色器以及进行多个ROP /混合操作,这很容易成为上一代和当前一代硬件的瓶颈。 As such, stuffing it all into one pass or few passes (C) should be advantageous. 这样,将其全部塞入一遍或几遍(C)应该是有利的。

I'm not sure about the "combine in a FBO" thing, although I cannot provide hard evidence for that, it "feels" like it would likely be slower (since you will have at least 2 FBO rebinds and at least one pipeline stall). 我不确定“将FBO组合”,尽管我无法提供确凿的证据,但它“感觉”起来好像会更慢(因为您将至少有2个FBO重新绑定并且至少有一个管线停滞)。 Though of course it depends... if you combine the same 17 textures once and draw the single combined texture a thousand times, it may very well be faster. 尽管这当然取决于...如果您一次组合相同的17个纹理并绘制一千次,则可能会更快。 If you have a dozen or so different combinations of how those 17 textures are combined, it will likely look different. 如果您对这17种纹理的组合方式有十几种不同的组合,则外观可能会有所不同。

Modern GPUs should have no issue sampling up to 17 textures in a fragment shader (GL 3.x hardware has a minimum of 48), and it is straightforward. 现代GPU在片段着色器中采样多达17个纹理应该没有问题(GL 3.x硬件最少有48个),而且很简单。

A, B and C should be the same performance wise. A,B和C在性能上应该相同。

It all comes to how powerful your GPU and CPU are. 一切都取决于您的GPU和CPU的功能。 That would decide whether to use one of a,b or c, or d. 那将决定是否使用a,b或c或d中的一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM