bgfx icon indicating copy to clipboard operation
bgfx copied to clipboard

Read back Cubemap fail

Open ArionTT opened this issue 5 years ago • 1 comments

This is my code:

	if (m_reading == m_renderFrame)
	{
		m_reading = 0;
	}
	//Pass3 save position and normal map data
	if (!m_reading)
	{
		m_count++;
		for (int face = 0; face < 6; face++)
		{
			bgfx::blit(PASS_BAKE_END_ID, m_blitSkybox, 0, 0, 0, face, m_convertCubemap, 0, 0, 0, face, m_readWidth, m_readHeight);
		}
		m_reading = bgfx::readTexture(m_blitSkybox, m_readData);

		if (m_count > 20)
		{
			//isDone = true;
			m_count = 0;
                    }
           }

In this code, I have successfully blit skybox texture to m_blitSkybox, and it have bean create by this:

	m_blitSkybox = bgfx::createTextureCube(uint16_t(1024),  false, 1, bgfx::TextureFormat::RGBA32F,
			0 | BGFX_TEXTURE_BLIT_DST
			| BGFX_TEXTURE_READ_BACK);

the m_readData is float array, and size is widthheight6*4. But I just can't read it back. The value of m_readData is always ZERO.

ArionTT avatar Sep 29 '19 08:09 ArionTT

I find that there may be a problem with readTexture for cubemap in gl renderer. When texture is cubemap, the target passed to glGetTexImage is GL_TEXTURE_CUBE_MAP, but it should be GL_TEXTURE_CUBE_MAP_* to specify a face of cubmap.

A solution is to check texture.isCubeMap() in readTexture and use the gles way.

Reference: https://www.khronos.org/opengl/wiki/GLAPI/glGetTexImage

Xrysnow avatar Mar 31 '20 10:03 Xrysnow