For those without...

Miscellaneous Forums/General Discussion/For those without...

BlitzMax... Here is a small demo I knocked up for someone who wanted to know how to do grayscale textures. These textures are converted by the GPU on the fly, there is no overhead.

Example with Render2Texture : http://indiepath.com/public/Example2.rar (HIT MOUSE BUTTON TO RANDOMISE THE dwFactor).

Here is the code for you DirectX type people :
Function SetMono(dwFactor:Int = $FFFF0000)
	PrimaryDevice.device.SetRenderState(D3DRS_TEXTUREFACTOR, dwFactor) 
  	PrimaryDevice.device.SetTextureStageState(0, D3DTSS_COLOROP,D3DTOP_DOTPRODUCT3)
  	PrimaryDevice.device.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE) 
  	PrimaryDevice.device.SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR)  
End Function

Function UnsetMono()
	PrimaryDevice.device.SetRenderState(D3DRS_TEXTUREFACTOR, $FFFFFFFF ) 
  	PrimaryDevice.device.SetTextureStageState(0, D3DTSS_COLOROP,D3DTOP_MODULATE)  
	PrimaryDevice.device.SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE)
	PrimaryDevice.device.SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE)
End Function


Cool!
it grayscales the image, but it also seems inverted as well.

Yeah it can do all kinds of stuff. The dwFactor variable is what does the magic, you can invert, calculate grey from Red, Green, Blue, Alpha or even a mix of all 4!

Hey, did you press the mouse button loads of times?

Pops up, and immediately disappears. Wonder if it's the same MipMapped problem I ran into earlier?

Did you try the code above in your own program?

Yup, the above as-is seems to work OK...

Oddly enough, I just re-downloaded the link above, and now it does work... Unless you uploaded a different version in the mean time, the only difference is that I played some other 3D game in between.

Yeah I changed it :D