This shader with this draw call, will result in no output. (Transparent or not visible) However, many other .fx also did result in a disappearing texture. Even following code returns nothing:
float4 c = 0;
c = tex2D(TextureSampler, texCoord);
return c;
Am I missing something? Also, using spriteBatch.Begin(SpriteSortMode.Immediate…); kinda grinds my gear. If I interpret the doc correct, after every .draw(); the GPU will receive the texture and instantly draw it. Isn’t that very unperformant? Can I use pixel/vertex shader and still draw in batches?
Do you have any links to tutorials or something? I am totally new to shaders and I want to read myself into.
I did copy and paste your code, but I guess I have to apply it somewhere. (Or at least call it?)
While searching for Shader tuts online, I only discovered obsolete ones.
A kick start would be great.
Because GLSL does not use semantics (the TEXCOORD0 stuff and so on) the alignment gets messed up if you do not use the same inputs as the vertex shader outputs.
For tutorials, you can use any XNA tutorials which should be a lot easier to find than MG ones. I recommend:
There’s some things to keep in mind when writing shaders. Check out the ‘Effect Writing Tips’ section on this page.
If you’re using Visual Studio, I also recommend installing the HlslTools extension. It adds stuff like autocomplete, live error highlighting and HLSL built-in function documentation.
It works like a charm! The VS Extension does really help. Very much appreciated.
So, MonoGame does only use OpenGL? I thought it supports DX and GL. Kinda like Unity. (Transcompiling shader language for both cases) In case of GLSL, I have to stick to those tutorials, right?
All shaders are written in HLSL, that’s the code you’re using above. MonoGame supports DirectX as well as OpenGL. When you target a platform that uses OpenGL, MonoGame translates the HLSL code (to be more specific it compiles it first and translates the bytecode) to GLSL using a tool called MojoShader. So if you’re going with tutorials not specifically for MonoGame or XNA, you’ll want to look at HLSL tutorials.