So I decided to go ahead and try to do a bloom style effect.
From what I can tell, the simplified process is as follows:
1. Render frame to texture.
2. Modify the pixels of the render-to-texture result to create a black and white version of the texture.
3. Render the frame for display, using the render-to-texture result as an alpha mask.
I am embarrassed to admit that I am having problems with step 2, specifically reading the pixels back for manipulation.
To be clear, I am accessing the pixels in VRAM without copying the texture back to main RAM. Is that a problem?
Here is my render-to-texture allocation:
Code: Select all
pvr_ptr_t RENDER_TEXTURE = pvr_mem_malloc(RENDER_TEXTURE_W * RENDER_TEXTURE_H * 2);
pvr_ptr_t BLOOM_TEXTURE = pvr_mem_malloc(RENDER_TEXTURE_W * RENDER_TEXTURE_H * 2);
I can access and modify the 'bloom' texture, for example this will create a red texture in VRAM:
Code: Select all
GLushort * src = (GLushort *)RENDER_TEXTURE;
GLushort * dst = (GLushort *)BLOOM_TEXTURE;
GLushort x, y;
for(y = 0; y < 480; y++ )
{
for( x = 0; x < 640; x++ )
*dst++ = 0xF000;
src += 1024 - 640;
dst += 1024 - 640;
}
But if I try to copy the render-to-texture result to the Bloom Texture, I end up with all black pixels
Code: Select all
GLushort * src = (GLushort *)RENDER_TEXTURE;
GLushort * dst = (GLushort *)BLOOM_TEXTURE;
GLushort x, y;
for(y = 0; y < 480; y++ )
{
for( x = 0; x < 640; x++ )
*dst++ = *src++;
src += 1024 - 640;
dst += 1024 - 640;
}
I know the render-to-texture is fine, because I can render that on a quad and see the result is ok.
Anybody have any advice here? Thanks in advance!