   Hardware Skinning and Other Effects Together?
  I am just wondering how is it possible to run 2 effects file simulatanously. For example, in my animated mesh, i used a effect file to do the animation and skinning, however the mesh also require another effect file that handles the Reflective lighting of my mesh.How do i solve this problem other than rewritting the effect file to contain both effects. Because the lighting effect is only needed for a small part of my mesh, which is the hands of the mesh.I tried to load and run 2 technique together and it crashed instead.   
  You definetely won't be able to run 2 different techniques at a time :) Two things I can think of are the Fragment Linker technology and deferred shading.In the first DX runtime makes you able to link together two or more microcodes(or HLSL fragments compiled in assembler), unfortunately I don't have extensible knowledge of this technology, so I can't certainly say whether it would help you solve the problem or not, but what I can say is that optimizations won't work properly here, since they work just on per-fragment basis not cross-fragment.IMHO I would prefer deferred shading, besides it would solve your problem(it doesn't rely on the actual geometry, rather on the output of the rendering), it would hopefully bring some speed benefits but a couple of disadvantages and limitations as well(more memory consuption, usually less precision, some effects can't be paired with deferred shading..).   ;  Another simple method is to create an include file with standard calls in it and your actual effects are just combinations of function calls.stdcode.hBoneFunc(){...do bones}LightFunc(){...do lights}Then your specialized effect file, or code generated shader is simply:#include "stdcode.h"ShaderFunc(){BoneFunc()LightFunc()};  The solution will depend on what PS version you want to support, since versions before PS_2_0 don't have enough instruction slots for many effects.Using fragments is for situations where you have a large number of functions created to support various VS and PS versions.The simplest solution would be to have separate VS and/or PS functions for the special effects, and use passes to call them.  You could make pass P0 the default for rendering the mesh subsets and pass P1 the one you use for the hands.  Then when drawing the mesh subsets you just do BeginPass(0) or BeginPass(1) depending on how you want to draw that subset.;  Can do you most of the lighting in the pixel shader?  In the vertex shader, where the skinning actually takes place, just calculate any generic values that all your lighting equations may need, then make sure you have the same input for all your lighting pixel shaders.   ;Quote:Original post by xycsoscyxCan do you most of the lighting in the pixel shader?  In the vertex shader, where the skinning actually takes place, just calculate any generic values that all your lighting equations may need, then make sure you have the same input for all your lighting pixel shaders.If you have normal maps available, then yes, you can do lighting in the pixel shader (be aware that normally you can do less lights per pass, due to lower PS instruction counts).  However, if you don't have these, then there really isn't a benefit - rather, you just duplicate more processing (there are many more pixels than vertices) and get the same output.However, you can mix and match.  If you have a lot of lights, some can be per-pixel, while the rest are regular per-vertex lights.   ;  You can do the light calculation in either the vertex or pixel shader, unless you are using a normal map texture.  It is the specular component that should be done in the pixel shader to give the smoothest results.   ;  Thanks for the reply so far. I do know how to use fragment linker. But the problem lies because this mesh is created by a artist. hence the artist use various effect files for each subsets of the mesh. I then load the mesh as a X file and i am suppose to apply the skinning effect on the overall mesh to do the animation.If i am to use different passes. Can I then run both passes? Eg pass(1) to do the skinning, and pass(2) to do the lighting etc...But even this requires me to rewrite the effect file. And when there are many meshes, it becomes not efficent. A way i thought of using is to do software skinning, but i heard it is a bad practice, hence i was wondering if i could find other solutions.Thanks so far.   ;  The shader/effect file programming is not very flexible.  You can't do the following:BeginPass(0);DrawSubset(i); //perform skinning in shaderEndPass();BeginPass(1);DrawSubset(i); // now perform lighting/effectEndPass();You gotta do it all in one Pass, unless you are going to render to a texture in the first call and use it as input to the second.  That would be more work (and less efficient) though than just re-writing the shader code.You could add the skinning part as a subroutine and add a call to it in the other effect passes.  Since it is done in the vertex shader, you may have enough instruction slots to do it.  How much you can do in the shader depends on the shader versions you use along with the target computer's graphics card capabilities.I am reading the book Programming Vertex and Pixel Shaders now.  It shows the usual VS_x_x and PS_x_x resource limits and the D3DCAPS9 elements that need to be checked when it depends on the card.   ;  Actually, that's not completely true.  You can look into Deferred Rendering.  Render things into your buffers (position, normals, etc), then read that back in lighting passes; you already performed skinning/etc in the first pass, where you render your data into textures, then read those textures back as you render a quad over the screen and use that data as input for your lighting equations.The problem here comes with different types of surfaces per material, so you'd actually need another buffer that holds a material index.  When rendering lighting, you'd need to do a pass per type, but you can save some time by clipping pixels that shouldn't be rendered (clip if the material index is not equal to the current type for that pixel).   