   How do Shaders work?
  Hi all, I'm pretty new to graphics programming and currently trying to build an engine of a sorts in DirectX 10.I pretty much had to work off of Frank Luna's tutorials that he has in his book, Introduction to 3D Game Programming with DirectX 10, to get to where I am now. Currently, I have a working Model class that, using ASSIMP, loads any model I want and applies diffuse and spec textures on it as well.I currently have 3 FX files, model.fx (which is a modified .fx file that Luna made), light.fx, and lighthelper.fx (both of which are the exact same as Luna's). My model loader uses model.fx to render the model and apply textures onto it.I also made a Lighting class, which uses light.fx and lighthelper.fx... but lo and behold, upon runtime, the lights aren't doing anything, even though I've done everything correctly in the class itself.The way Luna did his tutorials was that he had his Main class apply all the shaders while his other classes just set up the variables. I did not like this and attempted to move the shaders into their respective classes. This has worked for my model class but it doesn't seem to work for my lighting class. My friend, who admits he doesn't know shaders all too well, says its because even though my lighting class is probably doing everything correctly, it doesn't see my model shader and can't apply anything to it.So, I ask again, how do shaders work? Do I really need to have the shader work done in one main class? Or can I have my shaders work in their classes where they're needed? I honestly don't know shaders very well at all (other than how to implement them within the code) and would appreciate if I also got an article or tutorial on how to write shaders properly and the possibilities I have with them.But right now I want a direct answer on whether or not I can do what I want and have each class handle the shaders on their own.   
  You have to activate the shader, then when you render your triangles, the shader is working on those triangles. Then, you switch to a different shader and keep repeating the process.   ;  Like I tell everyone one new to graphics programming, before you start delving into a particular API, take the time out to understand the fundamentals behind graphics programming. It will save you a lot of time and effort in the long run. "How does shader work?" If you understood how the graphics pipeline work (a fundamental concept in graphics program) then it would be easier to visualize how shader work. Simply copying, pasting and modify shaders won't really help if you don't understand 1. How shader works 2. The effect that the shader is trying to acheive. As someone who is just getting started in graphics programming I would avoid going directly to API specific books. Instead pick up a book like Computer Graphics : Practice & Principles, or something thats platform agnostic. DirectX is complex on its own and not understanding how stuff work on a fundamental basis will only serve to complicate the matter.   