Search code examples
c#directxmdxhlslpixel-shader

Set texture in effect file


I need to pass texture in shader file, but it is giving me error "Invalid call". Please help to tell where i am doing wrong ? Follow is code which is i have written. I am able to set all the parameter except 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);

Solution

  • I found the solution, this may be use for someone else for the same problem.

    I need to make Texture structure to pass the texture in shader file. code as follow.

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