HLSL 的问题!

(我是初学请多多包涵)
我在调用hlsl 的时候使用的effect object,但是在调用pixel shader 的时候我希望可以用到position的数据,可是系统提示我 这是一个错误的sementic调用,但是我看见一些例子上面都有用到的, 我不知道是什么原因请高手可以给一个提示!

下面是fx 代码, 其实什么都没有用到,就是测试学习用的>

//--------------------------------------------------------------------------------------
// Global variables
//--------------------------------------------------------------------------------------
uniform float g_fTime; // App's time in seconds
uniform float4x4 g_mWorld; // World matrix for object
uniform float4x4 g_mWorldViewProjection; // World * View * Projection matrix
uniform float g_test;
uniform texture g_NormalSceneTexture;// < string name = "cellwall.jpg"; >;
uniform texture g_VerticesTexture; // texture for all the vertices used in ambient occlusion calculation
uniform float4 g_fLightDir = { 1.25, 1.25 , 1.25, 0.0 }; // light direction

sampler g_sampleNormal =
sampler_state
{
Texture = <g_NormalSceneTexture>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Point;
};

sampler g_sampleVertices =
sampler_state
{
Texture = <g_VerticesTexture>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Point;
};

struct VS_INPUT
{
float4 position: POSITION;
float2 Tex : TEXCOORD0;
float4 normal : NORMAL;
float4 Color : COLOR0;
};

struct VS_OUTPUT
{
float4 position : POSITION;
float4 color : COLOR;
float2 Tex : TEXCOORD0;
float2 texVetices : TEXCOORD1;
};

VS_OUTPUT VertScene( in VS_INPUT _in )
{

VS_OUTPUT output = (VS_OUTPUT)0;
output.position = mul( _in.position, g_mWorldViewProjection);
output.Tex = _in.Tex;
//output.normal = _in.normal;
return output;
}

float4 PixScene( VS_OUTPUT o ) : COLOR0
{
float4 returnColor;

//returnColor = tex2D( g_sampleNormal , o.Tex);
returnColor = tex2D( g_sampleVertices, o.Tex);
//returnColor = mul( returnColor, 500 );
//returnColor = mul( tex2D( g_verScene, o.Tex), returnColor);
return returnColor;
}

//--------------------------------------------------------------------------------------
// Techniques
//--------------------------------------------------------------------------------------
technique RenderScene
{
pass P0
{
VertexShader = compile vs_3_0 VertScene();
PixelShader = compile ps_3_0 PixScene();
}
}
[2657 byte] By [chiyuwang-chiyuwang] at [2008-3-14]
# 1
很遗憾,postion只对Vertex Shader 可见。如果要在PS中使用,请手动传递。

struct VS_OUTPUT
{
float4 position : POSITION;
float4 pixpos : COLOR1;//也可以用其他的
float4 color : COLOR;
float2 Tex : TEXCOORD0;
float2 texVetices : TEXCOORD1;
};

VS_OUTPUT VertScene( in VS_INPUT _in )
{

VS_OUTPUT output = (VS_OUTPUT)0;
output.position = output.pos = mul( _in.position, g_mWorldViewProjection);

return output;
}

然后在PS中使用pixpos.
QSlash at 2007-10-19 > top of Msdn China Tech,专题开发,技术,项目,游戏开发...
# 2
谢谢,谢谢
chiyuwang-chiyuwang at 2007-10-19 > top of Msdn China Tech,专题开发,技术,项目,游戏开发...
# 3
还有个问题, pixel shader可以用到那些东西,是不是只有COLOR 和 TEXCOORD
chiyuwang-chiyuwang at 2007-10-19 > top of Msdn China Tech,专题开发,技术,项目,游戏开发...