Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Problems about the construction of normalization cubemap

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Newbie Newbie
    Join Date
    Jun 2013

    Question Problems about the construction of normalization cubemap

    Hi, guys
    I want to implement a normalization cubemap which transforms the arbitary directional vectors into its normal form, and
    I have studied the following reference sources:

    paul's projects:

    openGL cubemap specification:

    The problem is that I don't understand the following code snippet from paul's project for the construction of
    normalization cubemap:
    Code :
    unsigned char * data=new unsigned char[32*32*3];
    		printf("Unable to allocate memory for texture data for cube map\n");
    		return false;
    	//some useful variables
    	int size=32;
    	float offset=0.5f;
    	float halfSize=16.0f;
    	VECTOR3D tempVector;
    	unsigned char * bytePtr;
    	//positive x
    	for(int j=0; j<size; j++)
    		for(int i=0; i<size; i++)
    			bytePtr[0]=(unsigned char)(tempVector.GetX()*255);
    			bytePtr[1]=(unsigned char)(tempVector.GetY()*255);
    			bytePtr[2]=(unsigned char)(tempVector.GetZ()*255);
    					0, GL_RGBA8, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, data);

    I have two questions here:
    1. We all know the first element of array which is supplied as texture data corresponds to the lower-left corner of texture image, but in this
    case the for loop just start by adding the directional vector with x > 0 , y > 0 and z > 0 to the first element of array, and the direction pointed
    by that vector is not the lower-left corner if when we think the face of cubemap as texture image and view it from positive x-axis to the
    negative x-axis. Is this code error or do I misunderstand something?

    2. Why do we need to add the offset to change the components of directional vector?

    I got stuck for this problem about two days, any suggestions or reference source will be appreciated.
    Last edited by Moonloki; 06-16-2013 at 05:49 AM.

Posting Permissions

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