Thank you for the response. This seems to change the correct value, but the change is not reflecting in my rendering. Is their anything that would prevent my change from taking effect?
The purpose of this is I am building an editor for my engine. I want to have multiple layers for terrain painting. So you have the base layer, and then you can have layers on top of that. Each extra layer can be "painted" by lowering the alpha channel of which ever layer you like. So what I m trying to do is manually edit the alpha channel only at certain indices of the surface data(due to mouse dragging). I have manually set up a test case where I just lower the alpha to 50 percent ala 255 / 2 but it has zero effect. If I set the alpha channel to 0.5f in my shader before the alpha blending occurs, it works as expected. Will locking the surface of the texture and setting the alpha channel there not effect my alpha channel I receive in my shader? that seems to be the case right now.
Using your example this is what my test function looks like. It is simply supposed to adjust every texels alpha channel to 0.5f in my shader.
Shader(tested and verified to work)
blendResult.a = layerTwo.a + (1.0f - layerTwo.a) * layerOne.a;
blendResult.rgb = (1.0f / blendResult.a) * (layerTwo.a * layerTwo.rgb + (1.0f - layerTwo.a) * layerOne.a * layerOne.rgb);
color = blendResult;
//Get surface description
//Lock surface data
surf->LockRect(&surfaceData, 0, D3DLOCK_READONLY);
//Make pointer to directly edit surface data
BYTE* bytePointer = (BYTE*)surfaceData.pBits;
for (int y = 0; y < desc.Height; y++)
for (int x = 0; x < desc.Width; x++)
((byte *) &bytePointer[x]) = 255 / 2;
// 32bpp == 4 bytes and pitch may not be == width * 4
bytePointer += surfaceData.Pitch >> 2;
Edited by Slig Commando, 22 September 2013 - 10:06 AM.