XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

How to configure an EffectMaterialContent?

Last post 10/20/2009 2:21 AM by jwatte. 2 replies.
  • 10/20/2009 1:38 AM

    How to configure an EffectMaterialContent?

    I want to configure and write an EffectMaterialContent, using an effect and parameters that I get from somewhere else.
    I thought this would be simple -- just create an EffectMaterialContent, set the Effect to a reference to the effect, and the CompiledEffect to the appropriate compiled effect. Then just call SetTexture() with the textures I need in the effect.
    Except SetTexture() is protected, so I have to derive to XEffectMaterialContent to be able to set the value.
    Except when I do that, the automatic serialization of EffectMaterialContent breaks.

    So how do I use this class properly to write out a compiled effect with parameters, and read back in an Effect instance with the appropriate textures?

    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 10/20/2009 2:16 AM In reply to

    Re: How to configure an EffectMaterialContent?

    Answer
    Reply Quote
    EffectMaterialContent.Textures.Add("yourKey", new ExternalReference<TextureContent>(yourTexturePath));

    Maybe? The content pipeline is pretty powerful, I wish I knew more about it other than what I've seen in the samples.
  • 10/20/2009 2:21 AM In reply to

    Re: How to configure an EffectMaterialContent?

    Yes, I actually found this out by reading what the XFileImporter did using the .NET Reflector :-) Curious that the collection is public and can be modified, but the SetTexture() function is not, but there you have it.

    Now, if only I could figure out what magic incantations I need to sing to make a usable, configured Effect instance come out the other end, without having to duplicate all the work of the content pipeline myself...

    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
Page 1 of 1 (3 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG