DirectX 9 Shader Problem!

Feb 19, 2012 at 8:51pm
Hey there, so I have made a little hook for a small game that me and some friends play, basically I hade made it load a shader to make it grayscale so that we can add a nice "death" effect. The problem is that it works for me and a cpl of other people, but 2 of my friends get a weird result.

I get the grayscale result, but my 2 other friends get a "LSD" looking result.

The code is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
void PixelShader(LPDIRECT3DDEVICE9 pDevice){
	
	HRESULT hr;
	LPD3DXBUFFER pCode;
	DWORD dwShaderFlags = 0;
	LPD3DXBUFFER pBufferErrors = NULL;
	
	char info[255];
	GetPrivateProfileStringA("SHADERS", "DeathFile", "null", info, 4096, inifile);
	string SHADEFILE = "Visuals/";
	SHADEFILE.append(info);



	hr = D3DXCompileShaderFromFileA( SHADEFILE.c_str(), NULL, NULL, "main",
		"ps_2_0", dwShaderFlags, &pCode,
		&pBufferErrors, &g_pConstantTablePS );

	if( FAILED(hr) )
	{
		LPVOID pCompilErrors = pBufferErrors->GetBufferPointer();
		MessageBoxA(NULL, (const char*)pCompilErrors, "Pixel Shader Compile Error",
			MB_OK|MB_ICONEXCLAMATION);
	}

	// Create the vertex shader
	pDevice->CreatePixelShader( (DWORD*)pCode->GetBufferPointer(),
		&g_pPixelShader );
	pCode->Release();
}


And then I ofc run:
pDevice->SetPixelShader(g_pPixelShader);

Each loop to get the desired effect, the shader code Looks like this:
1
2
3
4
5
6
7
8
sampler2D  ImageSampler : register(S0);  //take ImageSampler from S0 register. 
    // 'uv' vector from TEXCOORD0 semantics is our texture coordinate, two floating point numbers in the range 0-1.
float4 main( float2 uv : TEXCOORD) : COLOR
{
    float4 color = tex2D( ImageSampler, uv); // get the color of texture at the current point
    color.rgb = dot(color.rgb, float3(0.3, 0.59, 0.11)); //compose correct luminance value
    return color;
} 


Hopefully someone can tell me why there might be a difference between computers.
We have made sure everyone has the correct Directx installations etc, the only difference between us that it works for, and those that have a problem is that one of the ones witha problem is using a Virtual Machine to run the game and has an internal GFX card, and the 2nd one is using an internal GFX card.
Feb 19, 2012 at 9:08pm
closed account (o1vk4iN6)
If they are using integrated graphics than they might not support some of the operations in your shader. It looks fairly straight forward but as far as integrated graphics cards go they probably don't support that much, especially if they are old computers. You can create another shader that simply forces it to become one color (just return the color, no operations), such as red to make sure that it is a problem with the shader and not something else. What game is this if I might ask?
Last edited on Feb 19, 2012 at 9:09pm
Feb 19, 2012 at 9:43pm
The game is called KalOnline :) it's a private server we are developing and we want to enhance the graphics because they arent the best.

Hmm, could you give me an example of how I would create that color shader? (Unsure of how to go about that).

The weird result he gets is pretty much that some objects (such as water) get a really weird effect, but some objects dont get any effect at all...
Feb 19, 2012 at 9:53pm
closed account (o1vk4iN6)
Without the source to the game, it might be hard to figure something like that out. If the only issue is with the water and it only happens with some people, the shader they are using might be different because of hardware limitations.


Feb 19, 2012 at 10:45pm
Well, I think you misunderstood what I meant to say :)

The correct result should be the whole screen turning gray pretty much, the whole game in grayscale.

The incorrect result (that they are getting) is that everything is normal colored (which should be gray) and the water looks like if the client is tripping on LSD for some reason xD. So the water isn't correctly colored either, nothing is :/.
Feb 20, 2012 at 12:41am
closed account (o1vk4iN6)
You can try a different method, "post processing" in which the screen is rendered, than you modify it before it is showed on the screen. This way no matter what the whole screen will be grey, which has some disadvantages such as the hud being affected as well. I've never used this type of method before so I can't be of any help other than you can search / try it instead.
Feb 20, 2012 at 11:53am
That's actually exactly what I am doing ^^ Which is why this is so weird! (The HUD etc is also gray for the ones that get the correct result) Which is why I'm so confused as to why it doesnt work :/...

An example of how it looks when it works:

http://blog.nwkal.com/wp-content/uploads/2012/02/shadersupport.png
Last edited on Feb 20, 2012 at 12:00pm
Topic archived. No new replies allowed.