opengl - Drawing multiple objects with different textures -


do understand correctly typical way draw multiple objects each have different texture in opengl bind 1 texture @ time using glbindtexture , draw objects use it, bind different texture , same?

in other words, 1 texture can "active" drawing @ particular time, , last texture bound using glbindtexture. correct?

bind 1 texture @ time using glbindtexture , draw objects use it, bind different texture , same?

in other words, 1 texture can "active" drawing @ particular time

these 2 statements not same thing.

a single rendering operation can use single set of textures @ time. set defined textures bound various texture image units. number of texture image units available queryable through gl_max_combined_texture_image_units.

so multiple textures can "active" single rendering command.

however, that's not same thing binding bunch of textures , rendering several objects, each object uses some (or one, in case) of bound textures. could that, really, there's not point.

the association between glsl sampler , texture image unit part of program object state. it's the value set on sampler uniform. therefore, in order suggest, have bind bunch of textures, set uniform 1 of them, render, set uniform next, render, etc.

you still incurring of cost of binding textures. you're still incurring of overhead of changing uniforms. indeed, might less efficient, since normal way (bind, render, bind, render) doesn't involve changing uniform state.

plus, it's weird. generally, shouldn't changing uniform sampler state dynamically. define simple convention (diffuse texture comes unit 0, specular unit 1, etc), , stick convention. gl 3.x-class hardware required provide no less 48 texture image units (16 per stage), it's not you're going run out.

there mechanisms things not entirely unlike you're talking about. example, array textures can leveraged, though requires explicit shader logic , support. faster "bind bunch of textures" method, since you're binding one. also, uniform you'd changing regular data uniform rather sampler uniform, faster.

with array texture mechanism, can leverage instancing, assuming you're rendering same object different parameters.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -