ID:2100210
 
Applies to:
Status: Open

Issue hasn't been assigned a status value.
The lighting system got a way to look smooth and nice by the power of Dream Maker - http://i.imgur.com/W5pY9Gg.png

But the vision system handled by the byond natively and looks bad comparing to smooth lighting. It drives me mad because i can't do nothing with this.
So, yeah. The void looks bad - http://i.imgur.com/vN90X6P.png
What you're asking for is basically native shadowcasting. That's extremely difficult to do well--maybe not impossible, but very difficult. Some people have added systems to do this, and I'm super impressed with what they did.

I'm open to suggestions as to how this could be done visually.
While I have no idea how it could be pulled off, man I'd love it. Even just basic opacity smoothing would be great, but actual shadowcasting? I'd squee like a little girl.
This has literally been my BYOND wishlist #1 for like, years.

I'd buy 10 memberships for 5 years each if this was added. Screencap this.
Make it happen, Lummox :)
+10000

(I don't really know why you included "again" though, it's never been like that).
(I don't really know why you included "again" though, it's never been like that).

It's a US politics meme.

They are morphing Donald Trump's catchphrase of "Make America Great Again" into Make the vision system great again

The 'again' is only there because it's in the original.
I dunno how relevant/useful this is to OP's message but this is something I've kept bookmarked for a while:

https://www.facebook.com/notes/monaco/ line-of-sight-in-a-tile-based-world/411301481995/
This is the algorithm that I've used in my old lighting system before the plane master updates.
http://www.roguebasin.com/ index.php?title=FOV_using_recursive_shadowcasting

I think perhaps the first step should be to update the field of view computation, so we don't only get choppy 45 degree lines. Secondly, I think some opacity gradient should be done for tiles along the border of your field of view? It might be ideal here for the opacity behavior to be capable of being overridden, like for some objects to be transparent along the edge of your field of view (like mobs), or other objects (like walls) to be fully opaque.
Native shadowcasting is the dream. I know how to do it in OpenGL (shader-based), as well as Unity (software-based), but in BYOND, I'm not too sure, I never really bothered because of the CPU hit that might occur anyway. I'd like to use native shadowcasting (shadows created by light sources, slightly transparent based on light) along with native vision blocking (same thing, except the "light" comes from the player, and the "shadows" are always completely black so that they block vision, and are only visible to the player it is attached to). Soft shadow versions would be even better.


Shadowcasting.

It works by having 225 different sprites for each of the positions an opaque object could be, and overlaying the appropriate ones on a /image object.
Huh, interesting. How long did it take to generate those sprites? Also, it's probably somewhat choppy, especially when using pixel movement, but interesting nonetheless.


This is something I did a while back, it's pretty plug n play. The only problem is I'm still trying to figure out how to get rid of those artifacts from the light source and reduce the jittery effect that happens every once in a while.
Have you tried the techniques here to reduce the jitter?: http://ncase.me/sight-and-light/

I can't really tell from the gif, the lines are too transparent/small.
In response to Kamuna
Kamuna wrote:
Have you tried the techniques here to reduce the jitter?: http://ncase.me/sight-and-light/

I can't really tell from the gif, the lines are too transparent/small.

Believe it or not that's the same website I used as reference to make this lol. And I'm pretty sure the jitter has something to do with BYOND setting transforms. It's honestly not that noticeable tho.
Ah, maybe an interpolation problem?
I figured you used the website (which is why I said I can't really tell), but I asked just in case.
I think you can do it without the artifacts and without the jitter.
Darkcampainger made a playable demo with raycasted shadows a while back (although a recent update to the behavior of plane masters broke the demo)
I also have no problem with trapezoidal shadows in my game either.

I could take a crack at this raycasting stuff later, if you'd like.
Darkcampainger's demo was pretty convoluted, though. Is the fastest way of raycasting using an object and shooting it out towards another object? I've used that, but only to detect dense objects between two players when one of them attacks. I'm just not sure how it would fare with 16 or 50 players happening every frame multiple times with a server running at 40-60 FPS. Perhaps an object pool per player would work well for that. When client-sided frame rate happens, I could be a lot more lenient, and therefore not care as much about the CPU usage as I do now (20 FPS server with 60 FPS client would allow for nearly double to triple CPU gain, in theory).

Also, how are you drawing the visibility polygons? Using an icon + matrix transformations? Perhaps I should experiment with this myself as well.
No. The correct way to raycast is to solve the geometry and algebra and determine the point of intersection between the ray and each line segment that makes up the collision polygon. Remember Ax + By + C = 0? Or, by rearranging that, you get y = m * x + b. The intersection point is found by finding the x and y coordinates that are solutions for both of the line equations for the ray and the line segment you are checking. If there is no solution, then there is no intersection. Once a solution is found, all you need to do then is check if it's within the line segment and if it's within the ray.

[EDIT]: Or alternatively, you can do it in parametric form, like they do here: https://rootllama.wordpress.com/2014/06/20/ ray-line-segment-intersection-test-in-2d/
The way you suggested is similar to the parametric form, but it's not accurate and just solving the equation algebraically greatly improves the computational time to solve for the intersection.


In my game, I build each shadow from 3 pieces: two triangular pieces and one square piece.

I do it like this, because then I can make soft shadows by using a gradient for my triangular pieces. Like so.
Page: 1 2