立方体纹理(TextureCube)

立方体纹理是放置在立方体各个表面上的六个单独的方形纹理的集合。大多数情况下,它们用于在物体上显示无限远的反射,类似于天空盒在背景中显示远处的风景。一个展开的立方体纹理可能是这样的:

 立方体纹理(TextureCube)  - 图1

在 Cocos2d-x 中,这样创建立方体纹理:

C++

  1. // create a textureCube object with six texture assets
  2. auto textureCube = TextureCube::create("skybox/left.jpg", "skybox/right.jpg", "skybox/top.jpg", "skybox/bottom.jpg", "skybox/front.jpg", "skybox/back.jpg");
  3. // set cube map texture parameters
  4. Texture2D::TexParams tRepeatParams;
  5. tRepeatParams.magFilter = GL_NEAREST;
  6. tRepeatParams.minFilter = GL_NEAREST;
  7. tRepeatParams.wrapS = GL_MIRRORED_REPEAT;
  8. tRepeatParams.wrapT = GL_MIRRORED_REPEAT;
  9. textureCube->setTexParameters(tRepeatParams);
  10. // create and set our custom shader
  11. auto shader = GLProgram::createWithFilenames("cube_map.vert", "cube_map.frag");
  12. auto _state = GLProgramState::create(shader);
  13. // bind cube map texture to uniform
  14. state->setUniformTexture("u_cubeTex", textureCube);

原文: http://docs.cocos.com/cocos2d-x/manual/zh/3d/cubemap.html