   Lock backbuffer
  i have 2 render buffers: one as screen(R8G8B8) - using color as DWORD parametr,another 16bit(R5G6B5). Render scene 2 times - using diferrent render targets.When i draw object on 16 bit buffer i color it with flat color = object_index*8.On 32 bit buffer i use diffuse color for each point in object.Than i lock 16 bit buffer - trying to get picked object index.D3DLOCKED_RECT lRect; srfBack->LockRect(&lRect, 0, D3DLOCK_READONLY); BYTE* pBits = (BYTE*)lRect.pBits;WORD wPix = pBits[pt.y*lRect.Pitch + sizeof(WORD)*pt.x]; srfBack->UnlockRect(); The problem is - when i have 32 or less objects i get right index value, but if i have 33 objects - 33th index becomes 0, 34th - become 1, and so on..How i need to lock(or maybe initialize indices) to get right picked object index? Thanks.API - DX 8.0Win2003NVIDIA GeForce 4 MX440   
  What I think you're saying...color = index * 8;The * 8 is because there are 3 missing blue bits, and all 32 bit colors will be shifted by 3.What occurs when index = 32?32 * 8 = 0x010033 * 8 = 0x0108Here, we have a green of 1.  This green will be shifted by 2 because there are 2 missing green bits, leaving a value of 0.What you want:color = index % 32;  // low 5 bitscolor |= ((index/32)%64)<<5  // middle 6 bitscolor |= ((index/32/64)%32)<<11 // top 5 bitsNow, when the color is downsampled to 16 bit you should get the index you desire.edit much later in the day:  Actually, this is slightly wrong.  I've broken the index into the correct 3 parts, but placed them in the wrong bits.  I created a 16 bit color, not a 32 bit color.it should becolor = (index % 32)<<3;  // low 5 bits, placed in upper bits of blue.color |= ((index/32)%64)<<(8+2);  // middle 6 bits, placed in upper bits of greencolor |= ((index/32/64)%32)<<(16+3); // top 5 bits, placed in upper bits of red.[Edited by - Namethatnobodyelsetook on December 8, 2005 7:39:44 PM];  Thanks!I'll try it nn Friday 16th December. (I have holidays til Friday).   