Jump to content


Photo

Ray-tracing collisions!


  • Please log in to reply
34 replies to this topic

#21 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16790 posts
  • Version:GM:Studio

Posted 29 July 2010 - 08:37 AM

here's the link:
http://host-a.net/Jo..._raytracing.gmk


Very interesting and quite fast... With an accuracy of 5 and a 250 px radius I got a steady 120fps... With a lower accuracy its good when there is a lot of collisions, but move it out of the area of the object so it draws the complete circle and the fps drops dramaticaly... I will be keeping this on HD for future use!!!
  • 0

#22 krele

krele

    GMC Member

  • GMC Member
  • 525 posts

Posted 15 August 2010 - 11:02 PM


here's the link:
http://host-a.net/Jo..._raytracing.gmk


Very interesting and quite fast... With an accuracy of 5 and a 250 px radius I got a steady 120fps... With a lower accuracy its good when there is a lot of collisions, but move it out of the area of the object so it draws the complete circle and the fps drops dramaticaly... I will be keeping this on HD for future use!!!

Glad you like it :D. It's fast, isn't it? =P
  • 0

#23 Ecstats

Ecstats

    GMC Member

  • New Member
  • 844 posts
  • Version:GM8

Posted 16 August 2010 - 03:12 AM

I made a small test (link) to compare your script to collision_line_first from gmlscripts.com, slightly modified. Raytracing is faster when in smaller rooms where the rays won't have to travel very far, however collision_line_first is faster when in more open areas. Perhaps one could try to dynamically swap between the two methods depending on how far away the walls are detected.
  • 0

#24 RamboFox

RamboFox

    Tainted Fortune

  • New Member
  • 992 posts

Posted 26 August 2010 - 10:40 AM

Not exactly a bug, but it is rather bothersome.

Posted Image

What's happening here is that the collision line is skipping pixels diagonally, and since there is no pixels in that diagonal line, it jumps straight between the two pixels on either side.
  • 0

#25 krele

krele

    GMC Member

  • GMC Member
  • 525 posts

Posted 26 August 2010 - 12:05 PM

Not exactly a bug, but it is rather bothersome.

Posted Image

What's happening here is that the collision line is skipping pixels diagonally, and since there is no pixels in that diagonal line, it jumps straight between the two pixels on either side.

It's a bad idea to even handle solid blocks like that. Just put another layer of blocks to close gaps like that. Or, more efficiently, use a solid map =)
  • 0

#26 slam drago

slam drago

    The slam drag

  • New Member
  • 422 posts
  • Version:GM:Studio

Posted 18 November 2011 - 06:27 PM

Interesting.

Sorry to bump dead topic.
  • 0

#27 krele

krele

    GMC Member

  • GMC Member
  • 525 posts

Posted 19 November 2011 - 01:30 PM

Interesting.

Sorry to bump dead topic.

Haha it's ok. Maybe this topic will receive more feedback =)
  • 0

#28 norisak

norisak

    GMC Member

  • GMC Member
  • 130 posts
  • Version:GM8

Posted 26 November 2011 - 01:49 PM

Thanks for this!
I managed to create some cool lighting effects from this!

Here are some screenshots:

Posted Image

Posted Image
  • 0

#29 krele

krele

    GMC Member

  • GMC Member
  • 525 posts

Posted 27 November 2011 - 03:42 AM

Thanks for this!
I managed to create some cool lighting effects from this!

Here are some screenshots:

Posted Image

Posted Image

I made this just so I could make a dark themed zombie game with field of vision mechanics, just like yours! Good job! =D
  • 0

#30 norisak

norisak

    GMC Member

  • GMC Member
  • 130 posts
  • Version:GM8

Posted 14 February 2012 - 09:10 PM

Posted Image
This is a trimmed screenshot of my game that is zoomed in. If you look at where to light hits the wall, it looks uneven. It seems that the lightrays randomly hits the wall, or one pixel into the wall, making it look like this.
I managed to fix this by modifying the script a little bit:

Spoiler

The change I made was that when ray collides with the wall, it goes back 1 pixel, and collision checks that last bit with extra precision. This will cause a few more collision checks (up to four), but it will make the light hit the wall smoothly.
  • 0

#31 krele

krele

    GMC Member

  • GMC Member
  • 525 posts

Posted 16 February 2012 - 01:21 PM

Posted Image
This is a trimmed screenshot of my game that is zoomed in. If you look at where to light hits the wall, it looks uneven. It seems that the lightrays randomly hits the wall, or one pixel into the wall, making it look like this.
I managed to fix this by modifying the script a little bit:

The change I made was that when ray collides with the wall, it goes back 1 pixel, and collision checks that last bit with extra precision. This will cause a few more collision checks (up to four), but it will make the light hit the wall smoothly.


I'm not exactly sure why that happens in your game. Are your solids rectangular or not? It's pixel-perfect no matter what I throw this example in, from curves to flats it makes no difference to me. Could it possibly be the way you're drawing the light?
  • 0

#32 norisak

norisak

    GMC Member

  • GMC Member
  • 130 posts
  • Version:GM8

Posted 20 February 2012 - 02:46 PM

I'm not exactly sure why that happens in your game. Are your solids rectangular or not? It's pixel-perfect no matter what I throw this example in, from curves to flats it makes no difference to me. Could it possibly be the way you're drawing the light?


I use the trianglefan vertex just like you. As for the solid wall, the game creates a downscaled version of the walls to collide with, and saves it as a sprite. Then the wall object takes the sprite and upscales it again with image_xscale and yscale, and that is the object I that use as wall in the raytrace script.
  • 0

#33 krele

krele

    GMC Member

  • GMC Member
  • 525 posts

Posted 21 February 2012 - 09:53 AM


I'm not exactly sure why that happens in your game. Are your solids rectangular or not? It's pixel-perfect no matter what I throw this example in, from curves to flats it makes no difference to me. Could it possibly be the way you're drawing the light?


I use the trianglefan vertex just like you. As for the solid wall, the game creates a downscaled version of the walls to collide with, and saves it as a sprite. Then the wall object takes the sprite and upscales it again with image_xscale and yscale, and that is the object I that use as wall in the raytrace script.

I'm 80% sure something goes wrong there. Are your scales integers, reals?
  • 0

#34 norisak

norisak

    GMC Member

  • GMC Member
  • 130 posts
  • Version:GM8

Posted 22 February 2012 - 02:28 PM



I'm not exactly sure why that happens in your game. Are your solids rectangular or not? It's pixel-perfect no matter what I throw this example in, from curves to flats it makes no difference to me. Could it possibly be the way you're drawing the light?


I use the trianglefan vertex just like you. As for the solid wall, the game creates a downscaled version of the walls to collide with, and saves it as a sprite. Then the wall object takes the sprite and upscales it again with image_xscale and yscale, and that is the object I that use as wall in the raytrace script.

I'm 80% sure something goes wrong there. Are your scales integers, reals?


The scales are integers, and power of 2.
I currently use 8 to scale, so each 32x32 block is 4x4 on the downscaled version.
  • 0

#35 krele

krele

    GMC Member

  • GMC Member
  • 525 posts

Posted 23 February 2012 - 02:30 PM




I'm not exactly sure why that happens in your game. Are your solids rectangular or not? It's pixel-perfect no matter what I throw this example in, from curves to flats it makes no difference to me. Could it possibly be the way you're drawing the light?


I use the trianglefan vertex just like you. As for the solid wall, the game creates a downscaled version of the walls to collide with, and saves it as a sprite. Then the wall object takes the sprite and upscales it again with image_xscale and yscale, and that is the object I that use as wall in the raytrace script.

I'm 80% sure something goes wrong there. Are your scales integers, reals?


The scales are integers, and power of 2.
I currently use 8 to scale, so each 32x32 block is 4x4 on the downscaled version.


Do you round the values of your vertexes? Have you tried to use "Interpolate colors between pixels" option to see if this persists?
  • 1




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users