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 creating a skybox shader. 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 MistakesWhy am I getting just a black screen? The most likely cause of this is because the file format that you are using, combined with the settings that you have chosen (or not—it may be the default settings that are doing it) end up in a situation where things just don't work, and you just get a black screen. Partly, this goes back to the settings that were in use when you (or anyone) made the skybox image. If you made it, you can go back into the settings and change it. If you purchased the skybox image, or got it from my site, you might not have control over those settings. At its root, the problem is that as of XNA 4.0, XNA likes to premultiply the alpha channel into the red, green, and blue channels (for some good reasons, admittedly)—that's the default. If your image already has premultiplied alpha values, or you don't want to use premultiplied alpha values in your game (which is our case, for this shader), you need to go in and change the setting on your skybox texture. Here's how to do this: 1. Look at your Properties for the skybox image. |
Frequently Asked QuestionsNone listed yet… |
Sir,
First, I want to thank you for this great web site, I have learn alot from your examples… now I am having some problems with the skybox. it works great on my pc however nothing shows on the xbox - Are there different settings?? thank you in advance, Harry
Hi i'm using xna 4.0 and following ur tutorial but i have got a problem as when i implement the draw all i get is black screen (i think it is to do with setting the culling) have you got any thoughts. Cheers
mark
I am having the same problem. With XNA 4.0 there is only a black screen. Any ideas?
Same for me, any solution ?
Ok I found a solution, the problem is with textures (dds) I don't know what exactly, I took texture from Sky Sphere Tutorial from MSDN, I changed textures in their dds file on textures from this tutorial and it work :). If someone can explain this it would be great.
Hi and, also, thank you for this tutorial. I have used this information in XNA 3.1 and the build is successful but at runtime I get: ContentLoadException was unhandled- the error is pointing to the skyBoxTexture=Content.Load<TextureCube>(skyboxTexture);- I am not understanding what I am needing to change- the error continues as:
Error loading (my fbx file). File contains Microsoft.Xna.Framework.Graphics.Model but trying to load as Microsoft.Xna.Framework.Graphics.TextureCube
Any advice is greatly appreciated!
Hi Bruce, your problem appears to be a different one from what most of the other people are having.
The thing that makes the most sense to me about your problem is that you have copied and pasted a line of code, and didn't change everything you needed to. When you load your FBX file, make sure it says Content.Load<Model>("whateverYourModelIsCalled"); instead of Content.Load<TextureCube>("whateverYourModelIsCalled"); The angle brackets '<' and '>' in this case indicate what type of object to return, and if you tell it the wrong thing, it is going to complain.
The second possibility is that somehow, you have accidentally told the content manager to load your FBX file with the wrong content importer or processor. To check for this, find your FBX file in your content project, right click on it, and choose "Properties". (The Properties window might already be open.) Look in the Properties window for something that says Content Importer. For your FBX file, it should say something like Autodesk FBX - XNA Framework. Then also check the box that's labeled Content Processor. It should say Model - XNA Framework. If either box has the wrong thing, change it so that it says the right thing.
This might seem like a simplistic question but here I go— are models to be inserted with textures applied our without the textures (an fbx export in wireframe form)?
I'm not entirely sure what you're asking. (Is the 'our' a typo?) Would you mind clarifying?
Soory- in to big of a hurry!! When inserting a model into XNA, should the model always be a wireframed model or can it be textured? I have always had errors when inserting a model with textures applied. Even when I added the textures along with the model in my content.
Most model files have texture (image) files that are used on the model that they reference. The model file actually says something to the effect of "That's my image over there. Open it up and use it." XNA, by default, will recognize that and load the images the model says it needs. If, in addition, you specifically tell XNA to load a particular image that you know the model will use, it will, in fact, give you an error saying something like "You're trying to import this image multiple times, and ignoring the second, duplicate request is too easy of a solution, so instead, I'm going to explode and crash the compiler."
The solution is, if your model already references the image, then you don't need to actually include it in your project. (You can remove the image/texture by right clicking on it and choosing "Exclude from Project". This doesn't delete the image, because after all, your model needs it, but it does prevent XNA from trying to build the texture a second time and crashing.)
OK guys, I've played around with this for a very long time, and finally got to the bottom of everyone's black screen problems. I tried a large variety of different things, and narrowed it down specifically, to a problem with the texture itself. As Mike indicated, a different texture works….
So then I thought, great, I'm going to have to find the file setting that fixes it and rebuild all of my skyboxes.
As I was digging around in CubeMapGen I discovered that the problem was the color format for storing the pixels. 8-bit RGB worked without a hitch, but 8-bit RGBA, 16-bit RGBA, and float16 RGBA all failed. Once I caught on to the fact that all of the ones with an alpha channel failed, while the RGB one worked, it was easy to find a decent solution, without having to redo all of the skybox images.
Here's the basic fix in XNA 4.0:
1. Look at your Properties for the skybox image.
2. Open up the group under Content Processor.
3. Change Premultiply Alpha from the default true to false for the skybox image.
4. Profit! (Er… I mean… now it should work.)
This, by the way, is one of the significant breaking changes of XNA 4.0. The default, now, is to always premultiply the alpha channel into the other channels (a discussion for another day—if you really want the information, ask, and I'll give you some insights…) whenever you are loading a texture. This isn't what we want for this shader, though, so we need to simply turn it off using the steps above.
Hi, I'm working on a game developed using XNA , and i've implemented collision detection using bounding spheres around the enemies (it's a simple first person shooter game) , but when i collide with them , the sky box keep moving in an awkward way , if i don't collide with them , the sky box remains as it is
any suggestions ?
Thanks
Post preview:
Close preview