English 中文(简体)
界定自己的制服,以重新使用全球升温潜能值的开放式GL变量。 为什么? [闭门]
原标题:Defining own uniforms over re-using built-in OpenGL variables in GLSL. Why? [closed]

我正在撰写3D制图引擎。

我听说,在你的粉碎方案中使用太多的统一变量是坏的,因为这可能造成经济放缓。

另一方面,有些人说,重新使用一些内在变量,例如冰川-TextureMatrix是一种坏的做法。

How should I organize creating my shader programs ? Should I write plenty of uniforms for each mechanism or can I rely on those built-in variables ? For example, should I use built-in gl_LightSource or define own uniform array with light source informations, so I can have more lights on my scene? I also know about deferred rendering techniques but I want to do basic multiple lights first.

或者,哪些内在变量是科索沃再利用?

What are (dis)advantages of each of these practices?

最佳回答

我从未听说过,制服可能会使螺旋放缓,他们喜欢汇编时常数(或应当)。

关于使用内在变量,它建议不使用这些变量,因为这些变量在公开的GL3.0和公开的GL核心特征中被折旧,因此无法使用。 为了便于规划,他们被拆除。 你们可以确定你们想要的东西的变数,这是罚款。

So, it s just a matter of programmability, if you are learning and want to use them, it s also fine.

问题回答

问题在于,在现代的3D图形节目中,APIC对如何绘制你的场面和将更多的控制权转移给开发商的假设较少。 无论是开放式的,还是直接的3D,都是如此。 大部分场地都使用透镜、颜色、正常状态、文字坐标等,导致固定管道。 然而,如果我想要为微粒发动机开出阵地和动脉,那么什么呢? 这将把重力和时间纳入统一的变量。

因此,为了回答你的问题,假定你想要发展现代图象,停止使用任何预先界定的制服,界定你自己的所有。 截至3月,预设的军装已经走过,由你确切界定你需要做什么来做事。 对于固定管道的老板来说,这常常被视为倒退了一步。 “WHAT”? 我是否实施了已经罚款的矩阵? 然而,他们很快发现,当他们看到不再需要打上500个不同的可观的电话,而只是预示着这种说法时,这种代价就会大打折扣。

简言之,生活在两个世界中(使用沙子和所有固定管道功能)是一种坏的想法。 如果固定管道能做你们需要做的一切,就要遵守开放式2号协议,然后才找到你目前熟悉的方法。 如果你需要先进的过滤器,就会渗入开放式3+,而永远不会回头。

在开放式GL-4中,所有预先界定的制服都已经走过,但我通常只是使用旧名称,以便我能够重新使用我的老板。

使用现成制服是一种坏的做法,因为:

  1. You start to use them, and they are enough for you.
  2. You need more, so you ll make a special logic for custom attributes.
  3. You can use custom attributes for everything, and they are supported, so why to keep obsolete built-in logic?
  4. You migrate on OpenGL 3+ core context / ES 2 and forget about built-ins.

我早就走过这些步骤,最后说了——如果我最初用纯GL-3开始的话,生活就会比较容易。

关于业绩的原始问题的评论。

  • If a built-in uniform has no special behavior then there it is no faster than one that is defined by you. There s nothing in the pre-defined uniforms that you can t do.
  • All of the built-in uniforms that I can think of have special behavior. For example, lights are transformed to eye space, lighting model coefficients are pre-multiplied. So the driver may have to do work to keep the uniforms that model the fixed function pipeline in sync. I don t know what implementations will do this work always vs. skip this work when possible...ymmv.
  • You may get better flexibility with custom uniforms. For example, you can t put the default uniforms in a UBO even if you want to.
  • While a number of people have suggested not using the built-ins, the driver writers may have spent more time optimizing things like matrix transforms than your schedule permits; if you do remove built-ins for custom uniforms, audit performance to make sure your CPU-side performance is good enough.

最后,在不使用UBO的情况下,司机可<>/em>在更换灯具时必须更新所有制服。 因此,更加一致可能会减缓变化。

In all cases, unfortunately the only thing you can really do is take good measurements; the GL makes no guarantees as to what s optimized in the driver.





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?