Tuesday, May 27, 2008

Attempts at a translucent FOV, Update

I tried to use translucent FOV in a game-like setting so that I can figure out what works and what not.




Initial results looked fine. Note that you cannot see deep into the mist.



















A couple of problems popped up. For example when you are inside a mist, the FOV is square instead of round. This is the result of the fact that the way I do the calculation, the limit of FOV is the point where all "light" is absorbed by the mists. Hence the distance calculation is really approximate and leads to a square FOV.

I had to use this approximate algorithm since the density of the mist may vary from point to point. Hence any kind of radius based calculation is out of question.










Another problem were strange angles the FOV. I realized they were cause by the step of the algorithm that preferentially chose which direction to choose the light from. The direction directly towards the light was given the top preference, with the other two directions being considered after that.








The first problem was solved by tweaking the extra falloff for diagonal moves. I just played around with the number until I arrived at a roughly circular shape.

For the second problem, I started picking up light from the brightest tile ( of the three tiles in the general direction of the light source).



These tweaks seem to have given me a reasonable algorithm. This is the result after the tweaks. The person is standing outside the mist.
















Another example with light and dense mist. Notice the different visible radius for the two kinds of mist. ( Light mist that is not visible kind of looks like dense mist, sorry about the mixup. I hope the picture is still understandable. )
Also note the FOV is roughly circular, although not perfect.




There is much scope for improvement, though I don't know how right now. I think in uniformly misty levels I will just use a smaller FOV radius, and use this algorithm only if I have mix of mist and clear area. ( Shadar Logoth, anyone ? )








On complaints that difference between light and dense fog is not obvious, I make light fog blue. Ugly as heck, but I hope this gets the point across. :P

1 comment:

Joni said...

Oops, I commented on the old article and didn't notice the new one :P

"I had to use this approximate algorithm since the density of the mist may vary from point to point. Hence any kind of radius based calculation is out of question."

Are you still using raycasting for that, or are you using permissive field of view, or something like that? Because if you are using raycasting, you could decrease the maximum length of each individual ray when they encounter a tile with mist, instead of decreasing the radius of the whole FOV. That's what I used to do with, for example, mountain tiles and it worked really well.