Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: Textured Cube - a newbie question

Threaded View

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2012
    Posts
    12

    Textured Cube - a newbie question

    Hi there,

    The question is very simple: I want to draw a cube with 6 different textures on 6 surfaces of the cube, what is the "proper" way to design the fragment shader?

    My initial thought is that: using a flag in the fragment shader, for example,

    uniform int surface;

    main () {

    if (surface == 0) // front surface, for example
    {
    vec4 texColor0 = texture(frontTexture, TexCoord);
    .............
    }
    if (surfac == 1) // back surface
    {...............
    }
    ..............
    }

    and when draw the cube, the 6 surfaces will be drawn separately with proper value of "surface" passed to fragment shader.

    However, I do not like this idea, and wondering any other proper ways to do this??

    Thanks.
    Last edited by Power2012; 12-03-2012 at 05:30 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
  •