# pixel shader not mixing with FF

This topic is 4984 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've got a nice working engine using the fixed function pipeline, and I'm in the process of using the programable pipeline in conjuction with my existing code. To start off, I wanted to implement a simple shader, which works quite well (vertices have already been transformed, so I don't change them)
// transformations
float2 WIND;

struct VS_OUTPUT
{
float4 Pos  : POSITION;
float2 Tex  : TEXCOORD0;
};

VS_OUTPUT VS(
float3 Pos  : POSITION,
float2 Tex  : TEXCOORD0)
{

VS_OUTPUT Out = (VS_OUTPUT)0;

Out.Pos = Pos;
Out.Tex.x = Tex + WIND.x;
Out.Tex.y = Tex + WIND.y;

return Out;
}

float4 PS() : COLOR
{
float4 color = { 1.0f, 0.0f, 1.0f, 1.0f };
return color;
}

{
pass P0
{
Lighting = False;

}
}


The texture coordinates get modified perfectly. I added the pixel shader to make sure that it can work, and this is where the problem comes into play. Although the vertex shader works, my pixel shader does not affect rendering at all. It seems to me that the fixed function code still overwrites what the shader does, i'm not exactly sure. Do I have to disable something using a IDirect3DDevice9 call? I can't just remove all my FF code, I'm going to have to have both work in conjunction, and I know it can be done (the vertex shader proves it) but it's the pixel shader I can't get to work. Also, the Lighting = False does not work, as FF lighting still affects the model. I'm assuming I have to disable this somewhere as well?

##### Share on other sites
Your vertex shader is wrong. You shouldn't pass out the position you get in, because the position you get is in object space and you're expected to return it in normalized screen space. Normally you'll just multiply with the concatenated world/view/projection matrix you'll pass as a parameter to the shader. Look at any sample in the Direct3D sample browser to see how it's done (like the simple HLSL sample).

##### Share on other sites
Actually it's not wrong, but it should be, I agree.

The problem is, that my main graphics engine sets the transform using device->SetTransform before rendering all objects.

For some reason my vertices come into the programable pipeline pre-transformed (by the ff calls from before). If I multiply the position by the model*view*proj matrices, things get all wacky, if I don't change the position, it looks exactly like it did before.

That's the inherant problem I'm facing, seems that the FF pipeline has already done some of the work I want my shader implementation to do. Ideally I'd like to just turn the entire FF pipeline off if I'm using a shader, but I don't know how to do that.

##### Share on other sites
You're probably doing something weird. If you load the effect from the file and render whatever data you have between the effect's beginpass() and endpass() methods, it doesn't matter what the device's fixed-function transforms are. The fixed function and the programmable pipelines do not work together on the same data -you have one or the other (but of course, you can use the fixed function pipeline to render some of your vertex buffers/meshes and the programmable pipeline (through effects) for other vbs/meshes). Again, the directx samples are a great place to see effects in action.

##### Share on other sites
I understand how the PP works, but it's harder to discern why it does not for my case. All the examples are using the PP and not both as I am forced to deal with at the moment.

Could it be something to do with the FF's BeginScene() call? Do I have to call EndScene() before my effect->Begin() and effect->End() calls?

For some reason my shader is getting data that has been modified by the FF pipeline, does anyone have any clue as to how this can happen?

##### Share on other sites
Quote:
 Original post by AtaruI understand how the PP works, but it's harder to discern why it does not for my case. All the examples are using the PP and not both as I am forced to deal with at the moment.Could it be something to do with the FF's BeginScene() call? Do I have to call EndScene() before my effect->Begin() and effect->End() calls?For some reason my shader is getting data that has been modified by the FF pipeline, does anyone have any clue as to how this can happen?

The only way that you could be getting fixed function TSS (baring some kind of driver bug) is you muck around with the state after calling BeginPass

e.g.

Effect->Begin(...)
Effect->BeginPass(uPass)

//the following line would disable the pixel shader
Render();

Effect->EndPass()
Effect->End

• 33
• 12
• 10
• 9
• 9
• ### Forum Statistics

• Total Topics
631354
• Total Posts
2999490
×