Page 2 of 4

Re: Monocle: Monaco-style line of sight engine

Posted: Tue Sep 10, 2013 2:57 pm
by Ranguna259
Can't shake the feeling that those are buildings .. I wonder why

Re: Monocle: Monaco-style line of sight engine

Posted: Tue Sep 10, 2013 4:18 pm
by Gravy
Added repo.

How come you don't like canvases? For multiple light sources, I could make it so you can pass which canvas to use. This would allow you to use the same canvas for multiple light sources.

Re: Monocle: Monaco-style line of sight engine

Posted: Tue Sep 10, 2013 4:28 pm
by Nixola
Many old PCs or laptops don't support canvases

Re: Monocle: Monaco-style line of sight engine

Posted: Tue Sep 10, 2013 7:10 pm
by Germanunkol
Forked your repo and added Gaussian Blur and Alpha support:
https://github.com/Germanunkol/Monocle

I'll create a pull request when this question has been answered/resolved...

I wasn't sure about alpha support, after all, you can always do that manually as a user, when drawing the canvas. But I'd like to make a version without canvases. Micha and me are working on a game where we want to use this (I tried it, it works real well so far 'cause we don't update shadows often, so we don't get the crashes) and we need alpha support and don't want to require shaders/canvases... So I want to make it all "switchable".

Re: Monocle: Monaco-style line of sight engine

Posted: Wed Sep 11, 2013 5:37 am
by Gravy
Looks great!

I'm working hard to figure out where the bugs are, but it's pretty tough at this point. There is still some strange behavior that happens when a projection edge hits an endpoint. As a last resort, I could pre-check for co-linearity among the player, the hanging edges, and all other edges, and, when I encounter it, add some small random value to the player's position. This is needless work though, so I'd rather get the logic I've already implemented working instead :-/

Re: Monocle: Monaco-style line of sight engine

Posted: Wed Sep 11, 2013 6:23 am
by Germanunkol
Hm. I don't know if it helps, but I get an almost reliable crash if I walk start at the starting point and move diagonally towards the bottom right corner. When passing the tile at (6,6) and staying really close to it, it usually crashes...

Re: Monocle: Monaco-style line of sight engine

Posted: Wed Sep 11, 2013 7:49 am
by Gravy
I haven't fixed the bugs, but I pushed a new version with a check on the line that was crashing, so it just stops drawing triangles instead of crashing. I also added a random value between -0.005 and 0.005 to the x and y at every frame. This way, even when there is dropout, it only lasts for a single frame. I've seen it mess up a few times, and my eye was barely able to register it.

One thing you can do with your version is to return a success flag when the draw triangles loop completes (i.e. when current_edge == start[1]; currently line 270). When the success flag returns false, rerun the update in the next frame. In fact, I might make this a feature, since the optimizations I'm planning will involve not rerunning the update every frame.

Overall, though, I'd say that Monocle is now usable :)

Re: Monocle: Monaco-style line of sight engine

Posted: Sun Sep 22, 2013 2:59 pm
by Davidobot
Sorry for the bump, but does anyone have a version of this that doesn't use canvases? And, is there a way to make the tiles that are visible slowly fade into darkness, so you could see the texture of the tile?

Re: Monocle: Monaco-style line of sight engine

Posted: Sun Sep 22, 2013 4:46 pm
by Germanunkol
I'm working on a version. If its turns out to be any good, I'll post it here...

Re: Monocle: Monaco-style line of sight engine

Posted: Sun Sep 22, 2013 5:39 pm
by Davidobot
Germanunkol wrote:I'm working on a version. If its turns out to be any good, I'll post it here...
Great! I'll be sure to check it out.