I want to use a texture on certain vertices but not on all.
Is there a simple way to query inside the shader whether a texture is applied for a vertex/ fragment or not?
Because If no texture is defined for a vertex/ fragment the result of applying a texel onto it would be not what I want?
Thanks in advance
>>I want to use a texture on certain vertices but not on all.<<
Per vertex state can be flagged with vertex attributes.
>>Is there a simple way to query inside the shader whether a texture is applied for a vertex/ fragment or not?<<
okay so I have to pass some attribute e.g. UseTexture for every vertex I want to use the texture …
Just write another shader without this texture…
Shaders are not designed in way that you want to use them.
What do you mean with write another shader?
I searched this forum but found no satisfactory answer for my question of whether it is possible to write multiply shaders e.g. vertex shaders that get executed so for example vertex shader0, vertex shader 1, …
The second statement…
Yes I want to use this shader.
Even if there were such a thing, it would definitely be more expensive than doing one or more texture lookups.
Do you think so …
if there was some built in variable like bool gl_Texture_enabled and one could evaluate it …
One sets glEnable(GL_TEXTURE_2D); so this part of the state could be visible within a shader somehow or …?
In this case, you should know that, because it’s enabled in the OpenGL state and you can generate another shader which doesn’t use this texture at all, and will be faster than silly IsEnabled test per fragment.
BTW, glEnable(GL_TEXTURE_2D) is completely useless with fragment programs, because this state is for texture units (e.g. there are 4) and fragment programs work on texture image units (e.g. 16) which are always accessible.
OpenGL should have a default texture objects for all units (though I haven’t tested that), which means you can always source something (black transparent probably) except if the texture you downloaded is inconsistent.
So what you ask for is futile.
If you don’t have the OpenGL state acessible in that place, like you write a lib with shaders and other peoples applications use this, rethink your interface.
glEnable/Disable(GL_TEXTURE_?D) is ignored as soon as you use a fragment shader. The textures that are used by the shader are implicitly enabled, the others are not…
Thanks for your help and thoughts.
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.