Archived

This topic is now archived and is closed to further replies.

Guimo

Lightning the map

Recommended Posts

Has anybody wondered how the lightning methods for DiabloII work. Just walk and everything changes with a fluid movement... I have that problem now. I guess they are using Direct3D somehow but cant manage to copy the effect. If someone can tell me how... please... Thanks Guimo

Share this post


Link to post
Share on other sites
It would be pretty simple to do with the stencil buffer, just mark areas around light sources with a 1 on the stencil, and then draw a translucent dark poly over everything that isnt marked, so the lit areas arent darkened. To make it even nicer looking you could have a gradiant light texture around light sources so it goes from bright to dark and so forth.

Share this post


Link to post
Share on other sites
Just mak a light and always position it in the
centre of the screen.

You can easily calculate this by casting a ray
from near to far at width/2,height/2 and finding
the point at which it intersects plane = {0,1,0,0}.

Hope it helps

Mark.

Share this post


Link to post
Share on other sites
A lighting effect that I like is the line-of-sight effect in Nox - parts of the map that you can''t see are black, whilst parts you can see are drawn normally. When you walk around pillars, or past a window, the visibility of the map changes smoothly.

I''ve not played Diablo II, so I don''t know if that is the effect you''re reffering to, but it''s certainly an effect I''m interested in.


Uuuuuulrika-ka-ka-ka-ka-ka

Share this post


Link to post
Share on other sites
Exacltly, that moving effect is the one. Now, Maybe D3D can do it, but now I have a question.

Is it possible to use D3D just to iluminate a mesh (or vertex buffer) but not render it?

My app is 2D and designed also to work in low end computers (like the low res mode of DiabloII), I dont want to render using a 3D accelerator. (Maybe later but not now).

Guimo

Share this post


Link to post
Share on other sites
Hmm. If you were using the accelerator, you could use the stencil buffer, assuming your card has one. You can use that to figure out whether or not an object (a tile or unit, say) is visible from a particular point.

Without an accelerator, it'd probably be far too slow, although I'm just guessing on that.

One brute force method would be to cast a ray from each tile on the map to the player: if the ray reaches the player without being blocked, that tile (and anything on it, perhaps) is visible. Happily, you can speed things up by only checking tiles that are actually going to be drawn.

Another method I'm thinking about is similar in spirit to the bsp trees used by 3D games. For each map, we generate a list of corners, these are the corners obscuring groups of tiles. A line drawn from the player to a corner has an inside and outside: the inside faces away from the corner, and the outside faces towards the corner. The outside includes all those points that are obscured by the corner. I can't really describe it any better than that, because I'm not entirely sure about it, yet. Hopefully, you can get the idea of what I'm referring to. If and when I manage to make an algorithm that can determine visibility in this way (and assuming it's faster than the brute force method), I'll write up an article on it, if there's interest.

Uuuuuulrika-ka-ka-ka-ka-ka

Edited by - Mayrel on October 24, 2001 11:32:35 AM

Share this post


Link to post
Share on other sites
I was researching a little about it. To get a good light effect you must trace rays from your position (real position no tile position, that is, fine coordinates) to each vertex of a mesh. Each vertex is a corner of a tile, then the shade is the average of the points.

The problem is that you should try to intersect your rays with each object, so it can take a little time.

Ok, I''ll try to do it, hope it looks fine.

Guimo


Share this post


Link to post
Share on other sites