Troubleshooting this TutorialSometimes, even though you try hard to understand the information in a tutorial, things don't work out quite like you want it to. This page is here to help you resolve any problems you might be having with the tutorial on using shaders in XNA. The Common Mistakes section describes common problems that people have when doing the things in this tutorial, and how to resolve them. The Frequently Asked Questions section describes questions that people have that aren't related to mistakes, but rather, trying to understand the stuff better or exploring how it can be used. If your problem or concern isn't addressed here, feel free to add a comment below, so that I know where you're having trouble. I like to keep these pages fairly clean, so I may remove comments that I felt like have been addressed. If I remove your comment and you don't feel like the problem has been fixed, repost the question and we'll take another look at it. If a tutorial has a mistake in it, I will fix the mistake and reply to the comment with a brief explanation. However, after a couple of weeks I'll likely go back and remove the original comment as well as my reply, because, hopefully, the problem will have been fixed, and it won't be a concern any more. |
Common MistakesNone listed yet… |
Frequently Asked QuestionsNone listed yet… |
Shouldn't the World matrix and mesh.ParentBone.Transform be multiplied in opposite order in DrawModelWithEffect function?
With this code model draws correctly until i rotate or scale World matrix. But when i change that order it works again :)
I think this also apply to other tutorials
Regards :)
try this.
Turn 180 degrees and walk 2 steps.
then go back to start walk 2 steps and turn 180 degrees.
You won't be at the same position.
It is the same with the matrixes.
I know this is an old post but this may help somebody
One question, and I hate to bother you with it, but how does this apply to 2D games? I'm trying to learn how to implement a lighting system, and you've started me down the right path. This tutorial is very easy to dive into, but I'm not sure how to apply a shader to something that doesn't have vertexes. I've seen videos, so I know it can be done, but almost all of the tutorials pertain to 3D game design.
That's a good question. As a starting point, you should check out another tutorial in this set, a little later on: Post-Processing Effects. That might be closer to what you're looking for.
It definitely was a good starting point. I wanted to do a pixel shader on individual tiles comprising the background, and I got the first one up and running. There's a lot I don't know yet, but just seeing that one quick tutorial gave me most of the tools I'll need to do the bulk of the work on the lighting system. Thanks.
I ran this basic tutorial using my own model from Blender. A simple cube exported as an .fbx. However, when attempting to use the shader, I get a NullPointerException apparently because my tag value is null. Why does this happen? Searches tell me that It's something to do with the content processor?
It's either a bug in the Blender FBX exporter, or a bug in XNA's FBX content importer or content processor. If it's a bug in XNA, there's probably not much you can do. What I'd suggest trying is to play around with whatever export settings you have in Blender and see if that fixes it. If not, try the .X format. XNA can import that as well, and I'd be surprised if Blender can't handle that.
Well I tried monkeying around with export settings in Blender, then exporting in .3ds from Blender and using Autodesk's latest converter to convert it to .fbx, Exporting from blender in .x and even your Helicopter model and I'm still getting a null pointer exception in all cases. :/ I'm looking around for answers but I'm still in the dark thus far. I'm using the Default XNA FBX Importer, and the default Model content processor. I guess it's worth mentioning that the model is an untextured, unanimated cube. Just a cube mesh with gray sides.
Any help would be appreciated.
*EDIT:* It appears the tag property isn't what's throwing the exception. I set the value to the value "tag" and the NRE was still thrown so it's something else.
I'm lost. there are a number of variables set to null and I have no clue which is throwing the exception. Parent, sharedbonematrices, among others… I'm going to try your source and see if it runs any different.
So I made a whole new project entirely of your source and I still had the NRE thrown at the same place it's the line:
I must be the processor or something :/
*FIXED!*
It was a problem with my effects file, I had the variable called "world" not "World". I used your source for the file and it worked fine -_-;;
all that heartache over a typo.
I tried the tutorial with MonoGame using a project targetting OpenGL platforms (more precisely, through the ’MonoGame Cross-Platform Desktop Application (OpenGL)’ (mgdesktopgl) template), and only had a black result, with no helicopter visible.
So I took a look at the documentation, and I have just solved this problem: for OpenGL projects, default values for effect parameters do not work. So I uncommented both lines from Game1.cs assigning to AmbientColor and AmbientIntensity, and it worked (with a greenish helicopter)!
(remove spaces)
docs.monogame . net/articles/content/custom_effects.html
(found from docs.monogame . net/articles/migrate_xna.html)
Note that the previous documentation page also shows how you can use preprocessor directives to write conditionals, according to the target platform for example, so you might want to consider using it to avoid getting into the kind of trouble I was in.
Post preview:
Close preview