Jump to content


Photo

Ray-tracing collisions!


  • Please log in to reply
34 replies to this topic

#31 krele

krele

    GMC Member

  • GMC Member
  • 622 posts
  • Version:GM:Studio

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
  • 131 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
  • 622 posts
  • Version:GM:Studio

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
  • 131 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
  • 622 posts
  • Version:GM:Studio

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