DirectX Greyscale that works
BlitzMax Forums/BlitzMax Beginners Area/DirectX Greyscale that works
| ||
This should work on all cards. I'm going to put it in the Render 2 Texture Module. 'If you want more physically correct luminance (the eye is more receptive to some colour 'components than others), the REC709 coefficients (For average PC monitor) are r=0.2125, 'g=0.7154, b=0.0721. Converted To the TEXTUREFACTOR constant (multiply by 255 And convert To Hex) 'it's: 0x0036B612 [since you have to round some of the coefficients, you lose some precision - 'really the r,g,b parts of the constant should add up To 255 so I'd an extra 1 to the blue. ' Source Color Default is the Red Channel. Function SetMono(state:Byte=True,dwFactor:Int = $0036B612,SourceCol:Int=$FF0000) If State SetColor((SourceCol Shr 16) & $FF,(SourceCol Shr 8) & $FF,SourceCol & $FF) PrimaryDevice.device.SetRenderState(D3DRS_TEXTUREFACTOR, dwFactor) PrimaryDevice.device.SetTextureStageState(1, D3DTSS_COLOROP,D3DTOP_DOTPRODUCT3) PrimaryDevice.device.SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE) PrimaryDevice.device.SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_TFACTOR) Else PrimaryDevice.device.SetRenderState(D3DRS_TEXTUREFACTOR, $FFFFFFFF ) PrimaryDevice.device.SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_MODULATE) PrimaryDevice.device.SetTextureStageState(1,D3DTSS_COLORARG1,D3DTA_TEXTURE) PrimaryDevice.device.SetTextureStageState(1,D3DTSS_COLORARG2,D3DTA_DIFFUSE) SetColor 255,255,255 EndIf End Function |
| ||
Can someone convert this to OGL? |
| ||
OK... This converts the entire pic by default to shades of red, at least for me... Can it also do the B&W? (Tweaking the SourceCol field will make the picture red, green of blue tinted, or a combination of the above... But not monochrome?) ATI Radeon 9600 Pro |
| ||
This : Gives : |
| ||
Thats how it looks on both my computers, one with onboard gfx, the other with n6600GT. |
| ||
Lol Crazy Man! I've tested on - Windows XP nVidia FX5200 - Windows XP nVidia GForce 3D thingie (crap old card) - Windows 98 Matrox G400 And it works! |
| ||
I get the same as Zawran on my W2K S3 laptop. |
| ||
Same here: Radeon 9600 Pro |
| ||
I get the same as xlsior and zawran here. If I use 'D3DTA_CURRENT', as per Mr O'Conner's original post, I end up with an inverted greyscale image. |
| ||
Doesn't work for a x850xt-pe as well. See Zawran. |
| ||
Doesn't work on radeon 9200, winxp ! same as zawran. |
| ||
I'm gonna check under the hood and make sure I did not change anything there :) |
| ||
I rebuilt BMAX from scratch and I still get Greyscale!!! |
| ||
I had an idea... Change all the "1"'s to "0"'sPrimaryDevice.device.SetTextureStageState(1, D3DTSS_COLOROP,D3DTOP_DOTPRODUCT3) Change to : PrimaryDevice.device.SetTextureStageState(0, D3DTSS_COLOROP,D3DTOP_DOTPRODUCT3)[/code] |
| ||
If I change the 1's to 0's, it gets green-shaded instead: Any non-zero value I tried returns the same half-bright image, both positive and negative numbers. When using 0, I notice the following: if I change the dwFactor to a different value, it affects the shade of the color directly: e.g. $00B63612 will give it a red hue, $000000FF will make it blue, etc... Using $00777777 for the dwFactor will make it full color, half-bright as well... I tseems like it is taking the RGB rather than luminecense? |
| ||
Same on my S3 but it all works fine on my 9800Pro |
| ||
Its green-shaded on both an onboard SiS 661FX and a n6600GT. |
| ||
(still) doesn't work here... |
| ||
Nah, you guys are winding me up. This has worked on every machine I have tested on. |
| ||
Nah, you guys are winding me up. This has worked on every machine I have tested on. |
| ||
the odd thing is that a wide range of cards all seem to misbehave in the same way - different manufacturers, chipset, etc. Yet others apparently are OK. Could there be any other factors, such as DirectX revision that play a role here? I'm using DX9c myself (of course that doesn't reaslly narrow it down either, considering that there are multiple different releases of that as well) |
| ||
Mm. i wish there was alil 2xmodulate blend mode in there somewhere :) that would have been swell |
| ||
:) Oh you people, you'll want blood next. |
| ||
we want the moon on a stick. Not to sound rude but have you done anything on the OpenGL version of the texturedPoly lib? I get an "unhandled exception:Attempt to access field or method of Null object" when trying to run your example code in OpenGL. Works fine as a cake in DX. |
| ||
Yeah I have fixed that rimmsy but not released it. |
| ||
To rule out any module meddling, I've re-installed 1.16 and I'm getting the same thing. I do have the latest version of DX9c (Dec 2005) and DXDiag reports it as being version 4.09.0000.0904, If that helps any. |
| ||
I have DX9.0c on my Radeon 9800Pro where this works and 9.0b on the S3 that doesn't. |
| ||
This is crazy! It works on some version of DX9 and not others! This is DX7 Code! |
| ||
MODULATE2XPrimaryDevice.device.SetTextureStageState(0, D3DTSS_COLOROP,D3DTOP_MODULATE2X) MODULATE4X PrimaryDevice.device.SetTextureStageState(0, D3DTSS_COLOROP,D3DTOP_MODULATE4X) NormalMode PrimaryDevice.device.SetTextureStageState(0, D3DTSS_COLOROP,D3DTOP_MODULATE) |
| ||
MOD2X and MOD4X work nice. |
| ||
Thank you for the effort im trying arround with the Modulate Modes but im just wondering how to use it the way that it was used in blitz3d. i mean that it wont erase whats behind. Just multiply so darker gets darker and lighter lighter. Its just what i need. can someone aim me in the right direction? |
| ||
"latest version of DX9c (Dec 2005)" Ahm, I use directx9.0c (Feb 2006)... :P MS seems to hate version numbers lately... ;) |
| ||
Take it up with Microsoft... http://www.microsoft.com/windows/directx/default.aspx |