Hi!
I'm currently using 3D Studio Max to create scenes, then export them into .x file format and then import with a standard content pipeline. What I miss is that after the content pipeline processes my scenes I can't find the shader's parameter values I've set up in 3D Studio Max. Is there a way to overcome this problem?
Any help appreciated,
Pawel Jarzebski
I am tasked with writing an application to output high definition 2D graphics to a television. I don...
By zachnelson
Hi, i read a paper from nvidia about shadowmaps( http://developer.nvidia.com/attach/6769 ) and it te...
By key_46
I am trying to find out how many bytes in total have been allocated for D3D resources in our program...
By su_zeelot
HiI have a usercontrol that draws an image from a file. The image in the form is also able to be dra...
By denham
HiI'm currently wrestling with the coordinate system. I have three 3d objects (.3ds) that I want to ...
By slayerizer
Over at http://XBOX360Homebrew a competition has been running during the beta, for those who haven't...
By darkside
If I have a bunch of 3d pixels, lets say in this format (I could maybe chage it if required):R, G, B...
By neederofvbhelp
I am putting this up hopeing it will be a community driven FAQ. If you see something asked often pos...
By percent20, 1 Comments
Hi,I am new to XNA and C# as well. I am using the code from here (http://andyq.no-ip.com/blog/?p=16)...
By pic, 4 Comments
I managed to have an MDI child form which uses directX, it's somehow convoluted, but it works, the p...
By onishiro, 4 Comments
Hi, I find that XNA is a very interresting tools, powerful and offering a lot of possibilities for t...
By christophedesplanches, 1 Comments
Greetings!I have a development team working on an Xbox Live Arcade title for the Xbox 360 using XNA ...
By madmojo1, 9 Comments
Hi All,I has c# + directX 9c 3D games develop experience. I want to try start develop xna 3D games. ...
By brian_tsim, 2 Comments
I was simply wondering if I could use the beta to build a game to be released in the beta timeframe?...
By amadrias, 2 Comments
I am new to programing and I am a little confused with one part of the tutorial (towards the bottom)...
By forbidenmaster, 4 Comments
Well I'm not a user of 3D Studio Max and so I'm not familiar with exactly what is supported by its X file exporter, but once you get a Model imported into an XNA project, and assuming each ModelMeshPart within your Model has a valid Effect (FX file) associated with it, you can access the HLSL global parameters of the effect (which is what I assume you are referring to) by making a call similar to the following:
MyModel.Meshes[0].MeshParts[0].Effect.Parameters["WorldViewProj"].SetValue(worldViewProjection);
In the above example, WorldViewProj is the HLSL global variable name and worldViewProjection is the Matrix in your XNA project that you want to assign to the HLSL variable.
If you Model does not have effects automatically associated with it after import, you can use the Content Pipeline to manually load in each Effect (FX file) and then associate each effect with each MeshPart similar to:
Effect MyEffect = MyContentManager.Load<Effect>("MyEffect");
MyModel.Meshes[0].MeshParts[0].Effect = MyEffect;
If you load the effect in this way, you have a direct reference for the effect, so you can also set parameters with just:
MyEffect.Parameters["WorldViewProj"].SetValue(worldViewProjection);
You also need to set the Effect.CurrentTechnique property for each Effect, and then to draw each ModelMeshPart (using its associated Effect) within a given ModelMesh on your Model, call:
MyModel.Meshes[0].Draw();
There is no need to manually iterate through the passes of each Effect. As I understand it, the Draw() call should take care of it.
kyle_w | Wed, 05 Sep 2007 10:04:00 GMT |
Kyle,
Thanks for your answer - what you tell is exactly true but I must have not been clear enough with my question, sorry about this.
In environment like 3D Studio Max you can set parameters to some values and then natural would be something like:
MyModel.Meshes[0].MeshParts[0].Effect.Parameters["GlowStrenght"].SetValue(0.75);
where 0.75 is an example of value I set in 3D Studio Max during scene design. KW and Panda x file exporters do export those values, but the XNA importer doesn't import them and I wonder what is the way programmers use to get those data anyway...
Pawel
pawelj | Wed, 05 Sep 2007 10:05:00 GMT |
Well, to my knowledge, the only rendering variables that get actually stored in the X file on export are those associated with Fixed Function Pipeline material settings. These FFP materials get stored on import as BasicEffect objects within the Model.Meshes[].Effects[] collection, so you could iterate through them and read or modify their properties as shown in this example:
http://msdn2.microsoft.com/en-us/library/bb197293.aspx
However there is no "GlowStrength" property on a BasicEffect. If the properties exposed by BasicEffect are still not what you are referring to, then what makes you think these parameters are even being exported into the X file?
My advice is to use 3D Studio Max simply to create the shape of the mesh and properly lay out its UV map, then use a tool like ATI's RenderMonkey to design the materials for the object and export them as FX files. Here's a link:
http://ati.amd.com/developer/rendermonkey/index.html
kyle_w | Wed, 05 Sep 2007 10:06:00 GMT |
I was nearly positive that XNA does in fact set these values if they are specified in the file. Are you sure that the .fx file you are using has a global parameter named "GlowStrength?" You are using your own .fx file, correct?
leclerc9 | Wed, 05 Sep 2007 10:07:00 GMT |
GlowStrength was just an example - yes, I have a custom .fx file with a parameter like:
float GlowStrength : DiffuseMap <
string UIName = "Glow strength";
string UIType = "MaxSpinner";
float UIMin = 0.0f;
float UIMax = 1.0f;
float UIStep = 0.1f;
> = 1.0f;
This one makes 3D Studio Max draw a control on the material editor that lets me edit the glow value. Then the value I set in 3D Studio gets exported into .x file:
EffectParamFloats {
"GlowStrength";
1;
0.750000;
}
And when I set it during the game runtime:
MyEffect.Parameters["GlowStrength"].SetValue(*);
Where * would mean the 0.750000 but I don't know how to get those data there... This is a feature all proffesional game projects need but somehow XNA lacks it directly (just like the animation feature) - what are the ways to support this? Is there any example on the web of how somebody did that?
Thanks,
Pawel
pawelj | Wed, 05 Sep 2007 10:08:00 GMT |
Well if you are saying that this "EffectParamFloats" is getting saved into the X file, then it must be a custom template and you must therefore create your own custom parser to get the data out of the X file. Here is some information on the X file format:
http://local.wasp.uwa.edu.au/~pbourke/dataformats/directx/#xfilefrm_Templates
On the other hand, if you have assigned a default value to the GlowStrength parameter inside the FX file, which in your above example the default value would appear to be 1.0f, then you should be able to read this default value using:
float GlowStrength = MyEffect.Parameters["GlowStrength"].GetValueSingle();
Note that the "float" data type is just a C# alias for the .NET Framework System.Single data type. Other methods such as GetValueMatrix() and GetValueVector3(), etc are available. It seems like your best bet is just to manually copy the appropriate default values into your FX file. Although there is a little labor involved, you only have to do it once.
kyle_w | Wed, 05 Sep 2007 10:09:00 GMT |
This is great! Although you did not realize that, the function you pointed out GetValueSingle() does exactly what I need!
Great thanks!
Pawel
pawelj | Wed, 05 Sep 2007 10:10:00 GMT |
The .x model importer in the content pipeline already recognises the effect param templates, you dont need to create your own parser. The parameters in the .x file are imported into the EffectMaterialContent.OpaqueData dictionary.
If you are using the standard Model processor then the effect parameters are set automatically. When you load a Model that uses an fx file, an Effect object is created and the parameters are set with the values that were in the .x file.
This is why, when you get the "GlowStrength" value from your effect it has the value 0.75.
Cheers,
Leaf.
leaf | Wed, 05 Sep 2007 10:11:00 GMT |