Results 1 to 10 of 10

Thread: problem with mutitexturing in Qt

  1. #1
    Join Date
    Dec 2010
    Posts
    5
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default problem with mutitexturing in Qt

    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 !

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problem with mutitexturing in Qt

    How about passing an array of textures? What are the arguments of your shader program?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2010
    Posts
    5
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: problem with mutitexturing in Qt

    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,

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problem with mutitexturing in Qt

    And what exactly happens when you do this?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Dec 2010
    Posts
    5
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: problem with mutitexturing in Qt

    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

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problem with mutitexturing in Qt

    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:
    Qt Code:
    1. glActiveTextureARB(GL_TEXTURE0_ARB);
    2. glEnable(GL_TEXTURE_2D);
    3. glActiveTextureARB(GL_TEXTURE1_ARB);
    4. glEnable(GL_TEXTURE_1D);
    To copy to clipboard, switch view to plain text mode 

    Do you have something like that when your context is initialized? Note, this is all just a guess.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Dec 2010
    Posts
    5
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: problem with mutitexturing in Qt

    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

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problem with mutitexturing in Qt

    The only thing Qt does during setUniformValue() call is to call glUniform1*() functions.

    Maybe this helps somehow?

    http://softwareprodigy.blogspot.com/...opengl-es.html
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Dec 2010
    Posts
    5
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: problem with mutitexturing in Qt

    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

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problem with mutitexturing in Qt

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.