Both a valid vertex shader and pixel shader (or valid effect) must be set on the device before draw operations may be performed.
Any suggestion on where to go from here I'm trying to understand the basic concept of XNA's 3D engine. thanks before
This is the basic procedure for applying an effect from the XNA docs:
http://msdn2.microsoft.com/en-us/library/bb203872.aspx
Well the main difference I noticed between the MSDN sample shader and yours is that the sample is set to compile as vs_2_0 and ps_1_1 while your shader is set for vs_3_0 and ps_3_0. Perhaps your video card does not support Shader Model 3.0.
The only other difference I noticed is that in your pixel shader definition you are using the COLOR0 semantic where as in the MSDN sample they use the COLOR semantic. I'm not sure if this matters.
The COLOR/COLOR0 semantic difference shouldn't matter, it's just the number of register your variable is in.
As Kyle says, it could be due to your card not supporting shader model 3. Try compiling as vs_2_0 and ps_1_1. It's the only thing that stands out to me.
Well the "method call is invalid" error seems to be related to your texture while it seems that the other error may in fact be related to the vertex and pixel shader compilation versions. I recommend that you leave it set as vs_2_0 and ps_1_1 in your code for now. Obviously the texture is not an issue in the MSDN sample since it doesn't use a texture.
Did you change the COLOR0 semantic to COLOR in your pixel shader as I suggested
I also noticed that the WorldViewProj variable in the MSDN sample has a WORLDVIEWPROJECTION semantic on it. I recommend that you add this in your effect.
Lastly, you indicated that the "method call is invalid" error occurs on the line that attempts to assign your texture to the effect right If not, please post the full code line where the error occurs as well as the line where you load the texture and the line where you assign the texture to the effect.
Well I assume that the LoadGraphicsContent method you are showing here is your own custom method because the LoadGraphicsContent method on the Game class only has a bool loadAllContent parameter. I also assume that you are saying that the effect you just posted is the one that fails while the MSDN sample that I posted a link for earlier is the one that works.
You are not showing what value is being assigned to the myTexture string variable. The value of this variable needs to match the asset name of the texture as it appears in the properties of the texture in Solution Explorer.
A sampler is used to return a sample of a texture at a particular texture coordinate, and can also perform certain types of filtering. So you might have an effect file that specifies a texture, and then a sampler that uses that texture.
texture tex0;
sampler3D s_3D = sampler_state {
texture = (tex0);
mipfilter = LINEAR;
addressu = wrap;
};
Then, you could have a function somewhere in your effect file that uses the sampler to pick out values from that texture, using the settings described in the sampler. In other words, return the values of sampler s_3D at coordinate tex. So samplers are used to 'sample' textures, based on settings described in the sample state.
float3 sample_3D(float3 tex : TEXCOORD0) : COLOR
{
return tex3D(s_3D, tex);
}