<<< What is a skybox?     Index     Further reading >>>

6. Skybox shader code

  • Vertex shader

    
    #version 150
    
    in vec4 vPosition; // vertex pos
    uniform mat4 mP;   // perpsective
    uniform mat4 mV;   // view
    uniform mat4 mM;   // model
    
    out vec3 texCoords;
    
    void main( void )
    {
        texCoords = normalize( vPosition.xyz );
        gl_Position = mP*mV*mM*vPosition;
    }
    
    
  • Fragment shader

    
    #version 150
    
    out vec4 vFragColor;
    uniform samplerCube cubeMap;
    in vec3 texCoords;
    
    void main( void )
    {
        vFragColor = texture( cubeMap, texCoords );
    }
    
    

<<< What is a skybox?     Index     Further reading >>>