Jump to content
  • Advertisement
Sign in to follow this  
deathwearer

Shader effect in XNA game

This topic is 2510 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Hi, thank for your answer.

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?.

Share this post


Link to post
Share on other sites
This branch of graphical techniques is referred to as "shadows". You should look up "shadow maps", you should be able to find plenty of reading material.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!