I'm currently trying to learn 3D programming for XNA with various tutorials I found. So far so good, but I have couple of question regarding the HLSL flow in a XNA game (Might be the same for non-xna game, I don't know).
In one of the tutorial I read, the person explain how to create a specular lighting. I understand the concept but when trying to think on a larger scale (Like a real game case), I have trouble to see how it will be integraded. Let's make a scenario here :
I have a scene with 2 cube and one light source. I put two cube in a straight line, and place the lightsoure so only the first cube has light on it and place my camera just behind the lightsource. How do the HLSL shader knows that it musn't do the lighting on the second cube because the first one is blocking the light? Do I have to manage that in the game code and apply the effect on the model to draw based on the light position? If so, how do I manage the case that the cude are not correctly aligned and part of the light would show up on the second cube?
When one object is blocking another from light, then it is being occluded, if it's view-able in your scene, then normally this is where shadows would come into play. One way of finding out if a pixel on an object is obstructed by another object would be to use a depth-test (possibly from the light's point of view), however as this is something done in shadow mapping and other shadow techniques, it makes sense to do the job once not twice.
Speculative, or specular highlighting, is an effect that you can add to your lighting that gives the effect of "shininess" by emphasizing the brightest spots during lighting.
[disclaimer]: I'm also still learning, so if I've gotten anything wrong here, please someone point it out.
We are now on Tumblr, so please come and check out our site!
However I'm not sure it answer my question. Maybe I wasn't clear so I'll try to put it more simply.
I'd like to know how to manage lighting in a scene. How do I manage the drawing and the effect applied so if the object is not visible from my game lightsource (hided by another object, or partially hidded) so it won't be lighted?.