   CG Shader Usage
  I am learning Cg shading language by reading this http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter01.htmlI have some problems understanding how can a shader affect only one model in a scene?I have looked over the D3D examples that come with the Cg toolkit but all the shaders affect all the models in the scene.Say i want to load 2 .x meshes and apply a vertex shader that changes the color of one mesh to yellow how would i do that? i searched in the directx documentation but i could not find any solution for my problemCan somebody please point me to some documentation that can help me out?   
  The simplest way to look at it is think of a shader as an asset... just like a texture or a mesh or a normal map. At render time for Object 1, you "activate" Object 1's shader and then "draw" Object 1's Mesh. When you are done drawing Object 1, you "deactivate" Object 1's Shader ... and then go to render Object 2 the same way.. by turning on Object 2's Shader . There are ways of making this work better too... say you have a shader, like you said, that makes an object a certain color. you can pass that color as an argument (3 floats) from when you go to draw each Object's Mesh. Then all you need to have is 1 shader, which then can make any object have any given color.Make sense? To summarize:RenderFrame    Draw_Object_One  Turn On This Objects Shader  pass the shader the color green (0,1,0)  draw object 1's mesh  turn off this objects shader   Done Drawing Object One   Draw Object Two  Turn On This Objects Shader (because we pass in color it can be the same)  pass the shader the color red (1,0,0)  draw object 1's mesh  turn off this objects shader   Done With Object twoDone Render Frame;  Thanks for the simple explanation, that helped me to understand how it works :)   