Sign in to follow this  
wild_pointer

Relationship between ID3DXMesh and ID3DXEffect

Recommended Posts

I was looking at D3DXLoadMeshFromX and noticed that, if the X file had them, you can get a list of effects for the mesh. Does this mean you can use multiple effects to render a mesh? At the same time, in trying to answer my question, I've also noted lots of xna rendering code that looks something like:
foreach (ModelMesh mesh in Model.Meshes)
{
  foreach (BasicEffect effect in mesh.Effects)
  {
    // set some parameters on effect
  }
                
  mesh.Draw();
}
I've been structuring my code assuming every mesh would have a single effect associated with it. I could also render to a texture and use any number of post processing effects. Am I terribly wrong and/or short sighted in this?

Share this post


Link to post
Share on other sites
Quote:
Am I terribly wrong and/or short sighted in this?

Terribly wrong? No.

Short-sighted? Perhaps.

It depends on what x-files you may want to display. If you're only going to use your own files (pretty common for most apps) and you're always going to have a single effect, why not? On the other hand, writing an app that will display any mesh is a pretty extensive project and there are several good mesh viewers out there already.

Share this post


Link to post
Share on other sites
Sometimes you may want multiple effects affecting the overall mesh. Meaning, MeshSubset1 uses Shader1.fx, MeshSubset2 uses Shader2.fx. But sometimes you may wish to use a single fx for the whole mesh.

Maybe for example
Human mesh might use Parallax Occlusion Mapping Effect File for details on the armour subset. but for the hands and skin etc, you may choose to use a Normal Mapping Effect File instead.

(This may not be a good example, just something that came up while writing)

Hopes this helps.

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