Results 1 to 5 of 5

Thread: windowing effect problem

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    19

    windowing effect problem

    Now i am working on multi textures and trying to move one texture and keep one constant. dont know how to do? can you put some light on it.

    I have done multitexturing created two gl_Position and texcoordinates for both images

    and multiplied gl_Postion of one of the texture with urmatrix and which is a rotation matrix and updated the urmatrix so only texture rotates but both the textures are rotating

    pls help me out with it

    Thank you


    my vertex and fragment shaders are

    UserData *userData = esContext->userData;
    GLbyte vShaderStr[] =
    "attribute vec4 a_position0; \n"
    "attribute vec4 a_position1; \n"
    "attribute vec2 a_texCoord0; \n"
    "varying vec2 v_texCoord0; \n"
    "attribute vec2 a_texCoord1; \n"
    "varying vec2 v_texCoord1; \n"
    "uniform mat4 urMatrix; \n"

    "void main() \n"
    "{ \n"
    " gl_Position = a_position0; \n"
    " gl_Position = a_position1*urMatrix; \n"

    " v_texCoord0 = 1.0*a_texCoord0; \n"
    " v_texCoord1 = 1.0*a_texCoord1; \n"
    "} \n";

    GLbyte fShaderStr[] =
    "precision mediump float; \n"
    "varying vec2 v_texCoord0; \n"
    "varying vec2 v_texCoord1; \n"
    "uniform sampler2D s_baseMap; \n"
    "uniform sampler2D s_lightMap; \n"
    "void main() \n"
    "{ \n"
    " vec4 baseColor; \n"
    " vec4 lightColor; \n"
    " \n"
    " baseColor = texture2D( s_baseMap, v_texCoord0 ); \n"
    " lightColor = texture2D( s_lightMap, v_texCoord1 ); \n"
    " gl_FragColor = (baseColor) * (lightColor+0.25 ); \n"
    "}


    Thank you once again

  2. #2
    Junior Member
    Join Date
    Jun 2012
    Posts
    19

    Re: windowing effect problem

    i can post the code if someone can help

    thank you

  3. #3
    Junior Member
    Join Date
    Jun 2012
    Posts
    19

    Re: windowing effect problem

    Found the problem. i am rotating the entire quad but i just have to rotate the texture coordinates not the position.

    so its slike

    mat2 rotX = mat2(cosA, sinA, -sinA, cosA);
    vec4 a_pos = a_position; a_pos.xy = a_position.xy * rotZ;

    http://en.wikipedia.org/wiki/Rotation_m ... dimensions

  4. #4
    Junior Member
    Join Date
    Jun 2012
    Posts
    19

    Re: windowing effect problem

    I have loaded two textures on the quad. i want to rotate the upper texture. so i multiplied the upper texture coordinates with a uni mat2 as shown in the code below. How is it that i can declare and vary the angle of the 2d rotation matrix.


    how is it possible that i can vary the rotMatrix so that the upper texture rotates on time image. it would be good even if a,b,c,d of mat2(a,b,c,d)*a_texCoord1 can be varied and the output rendered to screen. I am using opengl es 2.0 on windows with esUtil framework as in examples of khoronos.


    Please find my shaders below
    Code :
     int Init ( ESContext *esContext )
             {
           UserData *userData = esContext->userData;
            GLbyte vShaderStr[] =  
          "attribute vec4 a_position0;   \n"
     
          "attribute vec2 a_texCoord0;   \n"
          "varying vec2 v_texCoord0;     \n"
          "attribute vec2 a_texCoord1;   \n"
          "uniform mat2 rotMatrix ;  \n" 
          "varying vec2 v_texCoord1;     \n"
     
     
          "void main()                  \n"
          "{                            \n"
        //  "int A; \n"
          "   gl_Position = a_position0; \n"
     
     
          "   v_texCoord0 = a_texCoord0;  \n"   //     ((angle*3.14)/180)
     
     
          "   v_texCoord1 = mat2 (0.7,-0.7,0.7,0.7)*a_texCoord1;  or rotMatrix*a_texCoord1;  \n"    
     
        //  "   v_texCoord1.x = cos((angle*3.14)/180)*a_texCoord1.x-sin((angle*3.14)/180)*a_texCoord1.y;  \n"
          //"   v_texCoord1.y = sin((angle*3.14)/180)*a_texCoord1.x+cos((angle*3.14)/180)*a_texCoord1.y;  \n"
          "}                            \n";
     
       GLbyte fShaderStr[] =  
          "precision mediump float;                            \n"
          "varying vec2 v_texCoord0;                            \n"
          "varying vec2 v_texCoord1;                            \n"
          "uniform sampler2D s_baseMap;                        \n"
          "uniform sampler2D s_lightMap;                       \n"
          "void main()                                         \n"
          "{                                                   \n"
          "  vec4 baseColor;                                   \n"
          "  vec4 lightColor;                                  \n"
          "                                                    \n"
          "  baseColor = texture2D( s_baseMap, v_texCoord0 );   \n"
          "  lightColor = texture2D( s_lightMap, v_texCoord1 ); \n"
          "  gl_FragColor = (baseColor) * (lightColor+0.25 );   \n"
          "}                                                   \n";
    Thank you

  5. #5
    Junior Member
    Join Date
    Jun 2012
    Posts
    19

    Re: windowing effect problem

    Thank you debinair

Similar Threads

  1. User Interfaces/Windowing Using OpenGL ES?
    By don in forum OpenGL ES general technical discussions
    Replies: 3
    Last Post: 11-03-2006, 01:28 AM
  2. Windowing system and OGL|ES.
    By code_comment in forum OpenGL ES general technical discussions
    Replies: 1
    Last Post: 04-20-2005, 01:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •