//本來的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);