Sometimes I get shader compiler errors that don't really help me to spot the problem fast. Sometimes I don't write shaders for months, so it takes me always some time to get back into groove. Moreover I "ain't no" Shader-Guru so Shader issues are not always obvious to me.
So today it was time to rig up a new one, so I started with a basic structure. I have a couple of shaders from past projects that I use as reference but they don't use a common terminology or structure. Something I like to change. Therefore I set up those two structs for the VS/PS input streams and, as I had no real pixel shader code ready, I thought that I'll simply output the vertex position as dummy data until things are more detailed.
Bad decision. Compiler error says "invalid input semantic 'POSITION'". I was like "what the …". I mean if you don't have it as part of the struct/stream, it complains that it needs POSITION to be filled. Moreover I have plenty of shaders where POSITION is part of the struct and therefore part of the Input …. well the last part of the sentence is a bit wrong.
You can't access POSITION from within the Pixel Shader and that's what generates this compiler error. It's OK to have it in the struct so it can be filled by the Vertex Shader but don't use that field in the Pixel Shader. If you have to, you need to write the value inside the Vertex Shader into another register that can be used by the Pixel Shader.
Pretty obvious now … still the compiler error message could be more clear… 😉
Yeah, I've been there 😉 Wolfgang Engel wrote a very insightful post on his blog about shader workflow and structuring.http://diaryofagraphicsprogrammer.blogspot.com/2008/09/shader-workflow.html Good reading !
Pingback: Dom’s Base - About interactive 3D content and tech, 3dvia Virtools, maxscript, 3ds max, music and more