View Full Version : how to determine whether a texture is valid
06-09-2005, 03:24 AM
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
06-09-2005, 04:31 AM
>>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?<<
06-09-2005, 06:14 AM
okay so I have to pass some attribute e.g. UseTexture for every vertex I want to use the texture ...
06-09-2005, 03:45 PM
Just write another shader without this texture...
Shaders are not designed in way that you want to use them.
06-09-2005, 09:45 PM
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.
Originally posted by powerpad:
Is there a simple way to query inside the shader whether a texture is applied for a vertex/ fragment or not?Even if there were such a thing, it would definitely be more expensive than doing one or more texture lookups.
06-10-2005, 01:06 AM
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 ...?
06-10-2005, 01:30 AM
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.
06-10-2005, 01:30 AM
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...
06-13-2005, 12:58 AM
Thanks for your help and thoughts.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.