PDA

View Full Version : problem with mutitexturing in Qt



VENKATESH
31st December 2010, 06:40
I need mutitexturing,I wanted to access several textures in a shader.
But when you work with a shader, you can draw single texture, and do the "multi texturing" in the shader it self.
So my problem was how to pass several textures to the shader.

I tried to setuniformvalue from application to set different texture unit to hold the texture.But i could'nt suceed,i am not able to access multiple texture in shader.

Please suggest me the better solution to fix this issue.

Thanks !

wysota
31st December 2010, 11:34
How about passing an array of textures? What are the arguments of your shader program?

VENKATESH
2nd January 2011, 05:11
Thanks for your reply,

please find the steps below which i am using to access multiple textures in fragment shader.

s_Texture = program1.uniformLocation("Color_map");
n_Texture = program1.uniformLocation("Normal_map");

program1.setUniformValue(s_Texture,0);
program1.setUniformValue(n_Texture,1);
program1.bind;

In the Fragment shader
-----------------------
uniform sampler2D Color_map;
uniform sampler2D Normal_map;

varying vec3 viewvec;
varying vec2 v_texCoord;
varying vec3 LightVec;
void main()
{
...
}

Let me know if you need further information on this...

Thanks & Regards,

wysota
2nd January 2011, 10:21
And what exactly happens when you do this?

VENKATESH
2nd January 2011, 12:18
Thank you for your quick reply...

Here i briefly explain what exactly happens...

Actually i am trying to create a bump mapping shaders,i have calculated TBN matrix and i used in my shader.I am able to see a bump on the surface.But i noticed that my normal map is not loaded into shader.To cross check If i replace my color map with normal map then also i couldnt see it loading into my shaders,If i load only normap map from my application then i am able to access it,but problem occurs only if i use multitexture.
So Could you please tell me where is the misktake,Could you provide me a code snippet to send multiple textures to shaders.I hope this will solve all my problem.

Thanks & Regards

wysota
2nd January 2011, 12:40
Unfortunately my glsl knowledge is second to none so I can only help you based on the documentation available here and there. It seems Qt has nothing to do with this and the problem is only in the configuration of the environment. Since shader programs are tied to a specific GL context, maybe the problem is that you didn't initialize the context properly? To use multitexturing, you have to enable multiple texturing units first. In pure OpenGL this is done with something similar to:

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_1D);

Do you have something like that when your context is initialized? Note, this is all just a guess.

VENKATESH
2nd January 2011, 13:34
Thank you,

What you said is right.Before using the texture it has to be enabled.Yes,i am doing that and if i set "glActiveTexture" will solve my problem.But unfortunately in openGLES 2.0 doesnt have a support to use this API,rather than that we are setting the uniform value to make the texture unit Active.I dont know how Qt handles internally the texture unit of GLSL pipeline.If we could crack this it will useful for all developers.

Thanks in Advance

wysota
2nd January 2011, 13:41
The only thing Qt does during setUniformValue() call is to call glUniform1*() functions.

Maybe this helps somehow?

http://softwareprodigy.blogspot.com/2009/08/multitexturing-on-opengl-es.html

VENKATESH
5th January 2011, 07:00
could any one suggest me how to use openGL extension in Qt.I windows to access an extension API we usually done by getting proc address of API.Similarly how we can do it in QT.

Thanks in Advance

wysota
5th January 2011, 10:07
Qt is not a language, here you can do it the same way as you do in any C++ program. You can use QGLContext::getProcAddress() for a version of the call using Qt API.