   Shader with HLSL and Managed DirectX
  Hello, I have in fact 2 simple questions concerning this very basic vertex/pixel shader called from Managed directX :First Question :I set my texture in C# for one mesh, everything is fine, no problem, but how this sampler variable 'TextureSampler' received the texture I have set in C# ? For me it seems to be a global variable that is not initialized but use with text2d ?!?Here is the code concerned : sampler TextureSampler;...float4 Texture(PS_INPUT Input) : COLOR0{    return tex2D(TextureSampler, Input.Texcoord);};================================Second Question :What's the difference between these 2 semantics :myType myVariable : POSITIONmyType myVariable : POSITION0Shader ://=============================================================================float4x4 WorldViewProj;//// VERTEX SHADER////From Application to Vertex Shaderstruct VS_INPUT {    float4 Position : POSITION0;    float2 Texcoord : TEXCOORD0;};//From Vertex Shader to pixel processingstruct VS_OUTPUT {    float4 Position : POSITION0;    float2 Texcoord : TEXCOORD0;    float4 color : COLOR0;};VS_OUTPUT Transform(VS_INPUT Input){    VS_OUTPUT Output;    // Computing the View position of the 3D Point    Output.Position = mul(Input.Position, WorldViewProj);    // Passed the texture value of the 3D point without modifications    Output.Texcoord = Input.Texcoord;    //Light the Pixel    float4 mycolor = float4(1.0f, 1.0f,1.0f,0.0f);    Output.color = mycolor;    // Return Position+Texture value for each 3D point to the Pixel shader    return Output;}//// PIXEL SHADER//sampler TextureSampler;struct PS_INPUT {    float2 Texcoord : TEXCOORD0;};float4 Texture(PS_INPUT Input) : COLOR0{    return tex2D(TextureSampler, Input.Texcoord);};// The Shader User interface ==================================// Technique ://// TransformTexture : Will transform and apply texture.// //========================================================technique TransformTexture {    pass P0 {   VertexShader = compile vs_2_0 Transform();   PixelShader  = compile ps_2_0 Texture();    }}//=============================================================================[Edited by - SeeMe on June 1, 2006 4:33:12 AM]
  Hey bud,Here is the source for my simple texture example:float4x4matWorld;float4x4matWorldViewProj;textureasphalt;samplersampAsphalt = sampler_state{texture=(asphalt);minfilter=LINEAR;magfilter=LINEAR;mipfilter=LINEAR;};structVS_INPUT{float4Position:POSITION;float3Normal:NORMAL;float2Texture:TEXCOORD0;};structVS_OUTPUT{float4Position:POSITION;float3Normal:TEXCOORD0;float2Texture:TEXCOORD1;};VS_OUTPUTvs_main( VS_INPUTinput ){VS_OUTPUToutput=(VS_OUTPUT)0;output.Position=mul( input.Position, matWorldViewProj );output.Normal=mul( input.Normal, matWorld );output.Texture=input.Texture;return output;}float4ps_main( VS_OUTPUTinput ): COLOR{return tex2D( sampAsphalt, input.Texture );}techniquetexture1{pass P0{VertexShader= compile vs_2_0vs_main();PixelShader= compile ps_2_0ps_main();}}Hope that helps,Dave   ;  Tx you for your quick answer.I complelty agree with your code where you clearly initialize your sampler with a texture.The thing I don't understand is why, in my version it is also working perfectly (even If I'm not applying for the moment texture filters), and I really don't know where my sample is initialized to the texture.;  The only thing i can say is that it my just be assumed.Dave   ;  Heps,If I have well understood :In your shader call from C# with managed directX, I will have to use this type of initialization :myShader.SetValue("asphalt", myTexture); and remove my : myDevice.SetTexture(0, myTexture);.An other thing, yes I know I have a milion of question :DWhen : myDevice.SetTexture(0, myTexture); is done in C#, how can I find a reference of this texture from inside my shader ?[Edited by - SeeMe on June 1, 2006 4:30:07 AM];  I'm still trying to understang the "thing", the odd is that nobody seems to know about it (On this forum and on other one) !?!?How possible, as there are plenty of exemples on the net using this type of sampler declaration ?Do you know an other place where I could look ?Tx you   