pixel shader wont load

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Eagle_Eye
Posts: 16
Joined: Sun Feb 08, 2009 11:04 pm

pixel shader wont load

Post by Eagle_Eye »

for some reason, the pixel shader wont load correctly, i should be seeing red as the color of the mesh i added the material to but i don't see it, the vertex shader loaded good as it didn't tell me that it didn't load the vertex shader, i don't know what to do.....
here is my shader code:

Code: Select all


float4x4 matViewProjection : ViewProjection;
float4 Color;
struct VS_OUT
{
    float4 Postion : POSITION;
    
};

VS_OUT vsmain(in float4 Pos : POSITION)
{
	VS_OUT Out;
	Out.Postion = mul(Position,matViewProjection);

	float4 Color = float4(1,0,0,0);
}

float4 psmain() : COLOR
{ 
   Color = float4(1,0,0,0);
   return Color;
}

I hope you can help me......
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

What do you see?
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Eagle_Eye
Posts: 16
Joined: Sun Feb 08, 2009 11:04 pm

Post by Eagle_Eye »

[img]

http://img.photobucket.com/albums/v238/ ... 1234137705

[/img]


this is what i see, the house should be red since i loaded the pixel shader along with the vertex shader so i don't know what to do, i mean it loaded the vertex shader, yet it can't load the pixel shader even though it's the same file?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Looks like the material isn't being set. Start at the shader example and see if you can get it working there, or post the code where you set the material on the node.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Eagle_Eye
Posts: 16
Joined: Sun Feb 08, 2009 11:04 pm

Post by Eagle_Eye »

Code: Select all


	video::IGPUProgrammingServices* gpu = g_pIrr->getVideoDriver()->getGPUProgrammingServices();

	s32 _Red= 0;

	if(gpu)
	{
		MYSHADERCONSTANCE* mc = new MYSHADERCONSTANCE();

		_Red = gpu->addHighLevelShaderMaterialFromFiles(
			"Red_Shader.hlsl", "vsmain", video::EVST_VS_1_1,
			"Red_Shader.hlsl,","psmain", video::EPST_PS_1_1,
			mc, video::E_MATERIAL_TYPE::EMT_TRANSPARENT_ADD_COLOR);
		
		if(_Red)
		{
			MessageBoxA(NULL,"Shader Loaded","Object",MB_OK);
		}
	}
	
	Level_Node->setMaterialType((E_MATERIAL_TYPE)_Red);

here is the code i used to load the material shaders and set it to the level_node, other then that i don't know what other code to give.
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

also, does the console give errors?
geckoman
Posts: 143
Joined: Thu Nov 27, 2008 11:05 am
Location: Germany
Contact:

Post by geckoman »

I see an error ->

Code: Select all

struct VS_OUT
{
    float4 Postion : POSITION;
   
};  
Should be Position instead of Postion. Maybe it helps
Eagle_Eye
Posts: 16
Joined: Sun Feb 08, 2009 11:04 pm

Post by Eagle_Eye »

this is what the console says

Code: Select all


Could not open pixel shader program file: Red_Shader.hlsl,

doesn't say why it can't open it though
Eagle_Eye
Posts: 16
Joined: Sun Feb 08, 2009 11:04 pm

Post by Eagle_Eye »

I tried the shader that comes with Irrlicht and it can't open it either so i don't know what i'm doing wrong......I could always use .FX files but those don't go well with Irrlicht Matrices..
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You see, this helps:
"Red_Shader.hlsl,","psmain", video::EPST_PS_1_1,
Maybe you spot the , inside your quotes, this is a simply typo :wink:
Eagle_Eye
Posts: 16
Joined: Sun Feb 08, 2009 11:04 pm

Post by Eagle_Eye »

Code: Select all


HLSL vertex shader compilation failed:
(12): error X3018: invalid subscript 'Postion'

and i fixed it, what could it be?
Eagle_Eye
Posts: 16
Joined: Sun Feb 08, 2009 11:04 pm

Post by Eagle_Eye »

Never mind, i got it to work, finally......from now on i'll look at the console to see any errors. thanks for all your help
Eagle_Eye
Posts: 16
Joined: Sun Feb 08, 2009 11:04 pm

Post by Eagle_Eye »

New problem, i can't seem to set the texture on a mesh using shaders, it gives me

Code: Select all


rror setting float array for HLSL variable

here is my shader code for this effect

Code: Select all


float4x4 matViewProjection : ViewProjection;

struct VS_INPUT 
{
   float4 Position : POSITION0;
   float2 TEX      : TEXCOORD0;
};

struct VS_OUTPUT 
{
   float4 Position : POSITION0;
   float2 TEX      : TEXCOORD0; 
};

VS_OUTPUT vs_main( VS_INPUT Input )
{
   VS_OUTPUT Output;

   Output.Position = mul( Input.Position, matViewProjection );
   
   Output.TEX = Input.TEX;
   
   return( Output );
   
}




texture Fieldstone_Tex
<
   string ResourceName = "..\\..\\..\\..\\..\\..\\..\\Program Files (x86)\\AMD\\RenderMonkey 1.82\\Examples\\Media\\Textures\\Fieldstone.tga";
>;
sampler2D Texture0 = sampler_state
{
   Texture = (Fieldstone_Tex);
};
sampler2D Texture1;
struct PS_OUT
{
   float2 Tex : TEXCOORD0;
   
};

float4 ps_main(in PS_OUT IN) : COLOR0
{   

   return( tex2D(Texture0,IN.Tex)  );
   
}

I'm setting the texture this way:

Code: Select all


ITexture* Field;
		services->setPixelShaderConstant("Texture0",(float*)&Field,1);


any ideas?
Post Reply