Sign in to follow this  
Goober King

[.net] XNA normal mapping[solved]

Recommended Posts

For our 4E contest I decided I would use XNA for various reasons. After getting somethings on screen it has become quite clear the basic effect isn't enough. I've decided I need to add normal mapping at the least or I'm dust. The only notable sources of information on integrating normal mapping with XNA all lead here There really isn't much there outside of the project file and a number of people all complaining that they can't get it to use their own models. Which is where I am as well. As near as I can tell is that it has been done but not often and only with 3dS and Maya neither of with are in my budget. I've been all over the code for hours and hours. My best lead is this.. ///Looks into the OpaqueData property on the "mesh" object, and looks for a /// a string containing the path to the normal map. The normal map is added /// to the Textures collection for each of the mesh's materials. The OpaqueData is part of XNA and I have no clue how it is set. The only thing is it looks like it reads from the properties list for the mesh object in the model's file. However adding the normal map file name to the list so it resembles the one in the sample file doesn't seem to work. What is more puzzling is that not even the sample model file will work if it is renamed, or copied. Even if you change the name back! Its a blasted text file for cryin' out loud. Currently I'm looking into weather I can set the string manually but the way things are going I doubt it. I'm missing something, or there is something in the dll file it uses, or aliens wont allow me to figure it out. I seriously doubt I have the brain power to write my own normal map processor and shader(I did try btw) and I think my game is going to suffer horribly. So has anyone actually managed to pull this off? I would have thought I would have found much more information on it. [Edited by - Goober King on October 14, 2007 8:53:42 AM]

Share this post


Link to post
Share on other sites
From what I can tell, and my knowledge is very limited, is that the normal map needs to be prebuilt into the model before hand. If you open the fbx file in a text editor and search for each normal map provided with the sample you will find explicit references to them. It would seem this is how the processor links the two, although I am not sure how to actually build the model with a material like that.

Have you considered going at it from the approach of not using XNA/Content Pipeline/etc? I am sure there is a way to apply the normal map purely by HLSL and C# code (outside of the content pipeline) to a model.

Share this post


Link to post
Share on other sites
Quote:
Original post by Krisc
From what I can tell, and my knowledge is very limited, is that the normal map needs to be prebuilt into the model before hand. If you open the fbx file in a text editor and search for each normal map provided with the sample you will find explicit references to them. It would seem this is how the processor links the two, although I am not sure how to actually build the model with a material like that.

Have you considered going at it from the approach of not using XNA/Content Pipeline/etc? I am sure there is a way to apply the normal map purely by HLSL and C# code (outside of the content pipeline) to a model.


From what I can tell the modeling tie in with normal mapping is rather loose. Enabling it in 3dsMAX and Maya seems to take little more than adding an attribute and within the sample model for the demo there is only one line I can find that seems to have anything to do with it. Which is simply Property "NormalMap" and the file name. The demo makes it sound like is just looks for the normal mapping file name and does it's thing. Adding the entry by hand may work but the bizarre problem that the demo wont even work with it's own model once renamed means that there is no way to know if everything was done right anyway.

In theory modifying the example should have been easier than writing my own HLSL normal mapping shader and the fact I can't get this to work concerns me about doing it myself. I already spent a few days trying to make a custom shader but never could get it to work right. I got stumped at basic lighting and normal mapping is a lot more complicated than that. As it is I've burned a lot of time getting nowhere.

Share this post


Link to post
Share on other sites
OK I finally got the thing to work it looks like, and as usual its something stupid. The part that was getting me was needing to set the model to actually use the normal map processor by clicking on the model file and setting to processor in the properties box. I didn't know you could assign different processor to each model there. I had seen something about it but wasn't sure where it was talking about. I was breaking the link if I copied the model not if I renamed it. Renaming the copy is what was causing it to fail.

Secondly you can simply add the file name in the mesh properties within the model file, which frees you from involving the modeler and can be done within VSE. looks something like
Property: "NormalMap", "Enum", "A+U",0, "SomeNormalMapFilename.tga"

Its hardly an involved process but perhaps a couple of sentences about on the download page would have save me a lot of trouble.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this