I’m getting started with creating effects, however I can’t get them to work when I target the DirectX platform but when I target the OpenGL platform, it works fine. Is there anything that I am doing wrong in my effect file? Here’s my current shader:
How is it not working? Is not it compiling or are you just not seeing anything on screen?
I don’t see anything that jumps out in the shader file. I’m not familiar with exactly what limitations are added using level_9_1 instead of just vs_4_0 but I can’t imagine you’re doing anything not allowed by that as simple as this shader is.
Could you share you render call from C# where this shader gets applied? The only thing I could think of if you’re not seeing anything is that I don’t see any view or projection matrix applied, but you could be doing that in C# and I wouldn’t expect OpenGL to work without that either.
The effect compiles without errors, however it doesn’t show anything on the screen. My draw function is here:
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
effect.CurrentTechnique.Passes[0].Apply();
spriteBatch.Draw(planet, new Rectangle(0, 0, 200, 200), Color.White);
spriteBatch.End();
base.Draw(gameTime);
I also load my effect as effect = Content.Load<Effect>("myeffect");
And everything else are the defualts.
I’ve tried that, however visual studio says there is no begin function or end for an effect. I had tried the second neater option before, but it didn’t work either.
Thanks, I figured that removing the vertex shader from the effect made the effect turn everything red (as intended), thanks @Stainless. But when I went to add a sampler, it didn’t work, so thanks to @willmotil, I’ve worked out that it must have been the parameters in the pixel shader and/or the creation of the sampler state which caused nothing to show. Thank you.