I'm trying to get www.two-kings.de 's tutorial #18 to work but the pixel shader doesn't seem to compile. The executable they delivered worked on my computer but if I compile myself and run the program then the pixel shader fails)
I'm trying to isolate the problem so I made the following little C program
#include <d3dx9.h>
#include <stdio.h>
#include <D3DX9Shader.h>
#pragma comment (lib, "d3dx9.lib")
LPDIRECT3DPIXELSHADER9 pixelShader = NULL;
LPD3DXBUFFER code = NULL;
int main() {
HRESULT result;
result = D3DXCompileShaderFromFile( "pixel.psh", //filepath
NULL, //macro's
NULL, //includes
"ps_main", //main function
"ps_1_1", //shader profile
0, //flags
&code, //compiled operations
NULL, //errors
NULL); //constants
if(FAILED(result))
printf("failed: %p %d %d\n",result,result,D3DERR_INVALIDCALL);
printf("failed: %p %d %d\n",result,result,D3DXERR_INVALIDDATA);
printf("failed: %p %d %d\n",result,result,E_OUTOFMEMORY);
Return 0;
}
Here is the supposed pixel shader
// Pixel shader input structure
struct PS_INPUT
{
float4 Position : POSITION;
float2 Texture : TEXCOORD0;
};
// Pixel shader output structure
struct PS_OUTPUT
{
float4 Color : COLOR0;
};
// Global variables
sampler2D Tex0;
// Name: Simple Pixel Shader
// Type: Pixel shader
// Desc: Fetch texture and blend with constant color
//
PS_OUTPUT ps_main( in PS_INPUT In )
{
PS_OUTPUT Out; //create an output pixel
Out.Color = tex2D(Tex0, In.Texture); //do a texture lookup
Out.Color *= float4(0.9f, 0.8f, 0.4, 1); //do a simple effect
return Out; //return output pixel
}
And sure enough it fails but with none of the standard error values sch as D3DXERR_INVALIDDATA or something like that.
The vertex shader compiles fine.