//本来的colorTexture是颜色采样,无法显示深度,这里换成深度贴图 colorTexture = new Texture2D; colorTexture->setTextureSize(width, height); colorTexture->setSourceFormat(GL_DEPTH_COMPONENT); colorTexture->setSourceType(GL_FLOAT); colorTexture->setInternalFormat(GL_DEPTH_COMPONENT24); colorTexture->setFilter(Texture2D::MIN_FILTER, Texture2D::NEAREST); colorTexture->setFilter(Texture2D::MAG_FILTER, Texture2D::NEAREST); colorTexture->setWrap(Texture::WRAP_S, Texture::CLAMP_TO_EDGE); colorTexture->setWrap(Texture::WRAP_T, Texture::CLAMP_TO_EDGE);
// 在缓存到贴图时, 像机声明缓存的内容是深度, 但颜色也是能够的 cameraLight->attach(Camera::DEPTH_BUFFER/*Arcadia test 2019-04-11 COLOR_BUFFER或DEPTH_BUFFER均可以*/ , colorTexture.get(), 0, 0, false, 0, 0);