Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 1 (5 posts)

How does BasicEffect know which texture to use on a model?

Last post 9/22/2009 5:08 AM by guysherman.com. 4 replies.
  • 9/22/2009 1:30 AM

    How does BasicEffect know which texture to use on a model?

    I'm kinda stumped about how the BasicEffect class is able to find out which texture to render a model with (from just the model object).  I know that models can have textures built in, but I'm unsure about how to access them without loading them separately.

    Right now I have to load up the texture, set a parameter on the shader to the texture and then render.

    So I guess the questions are:
    1. Can I find a model's texture from the model object?
    2. Is it possible to have the shader know which texture to use (without setting a parameter) when it draws a model?
  • 9/22/2009 1:56 AM In reply to

    Re: How does BasicEffect know which texture to use on a model?

    1. Yes, you need to get the texture effect parameter from the modelmesh's effect
    2. Sure, build it into the model. But that just sets the parameter itself, there is no way for it to just "know"
  • 9/22/2009 4:04 AM In reply to

    Re: How does BasicEffect know which texture to use on a model?

    FortisVenaliter Productions:
    1. Yes, you need to get the texture effect parameter from the modelmesh's effect
    2. Sure, build it into the model. But that just sets the parameter itself, there is no way for it to just "know"


    Thanks,  that means that the texture is associated with the BasicEffect when the model is imported with the content processor then?
  • 9/22/2009 4:39 AM In reply to

    Re: How does BasicEffect know which texture to use on a model?

    If I recall, it is associated with the stored effect, not sure if its a basiceffect, though. I don't even use the built in Model class usually, because I want my own functionality attached
  • 9/22/2009 5:08 AM In reply to

    Re: How does BasicEffect know which texture to use on a model?

    If the .x does not reference a specific effect, it will load with BasicEffect by default (a factor of the XNA Content Pipeline). You can access the texture using the "BasicTexture" parameter for the effect instance on a ModelMeshPart.

    I'm not sure what happens if your model has a custom effect referenced in it.
Page 1 of 1 (5 posts) Previous Discussion Next Discussion