• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Shader effect in XNA game

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1deathwearer  Members

Posted 26 January 2012 - 02:43 PM

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?

### #2Tarika  Members

Posted 26 January 2012 - 10:24 PM

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!

### #3deathwearer  Members

Posted 01 February 2012 - 02:46 PM

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

### #4MJP  Moderators

Posted 01 February 2012 - 06:43 PM

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.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.