在效果文件中设置纹理

时间:2011-09-13 12:38:49

标签: c# directx mdx hlsl pixel-shader

我需要在着色器文件中传递纹理,但它给出了错误“无效调用”。请帮忙告诉我哪里做错了? 跟随是我写的代码。我可以设置除Texture之外的所有参数。

float   progress;       
float4 colBack;
float reverse; 

sampler input : register(s0); 
sampler Texture2 : register(s1);

//Code to get the parameterhandle
 progressHandle = transitionEffect.GetParameter(null, "progress"));
 reverseHandle= transitionEffect.GetParameter(null, "Reverse"));
Texture2Handle= transitionEffect.GetParameter(null, "Texture2"));
//Code to set the value
 transitionEffect.SetValue(progressHandle, progress);

 transitionEffect.SetValue(reverseHandle, Reverse);
transitionEffect.SetValue(Texture2Handle, smapleTexture);

1 个答案:

答案 0 :(得分:0)

我找到了解决方案,这可能会用于其他人同样的问题。

我需要使纹理结构在着色器文件中传递纹理。代码如下。

texture Texture;
sampler Texture2 = sampler_state
{
    texture = <Texture>;
    magfilter = LINEAR;
    minfilter = LINEAR;
    mipfilter = LINEAR;
    AddressU = mirror;
    AddressV = mirror;
};