Discuss and collaborate on GML scripts

You are not logged in.

#1 2014-03-03 05:13:21

Registered: 2014-03-03
Posts: 1

Shader Based Precise Collision?

As the title says, I got a wild hair idea about using GMS shader to run a pixel precise collision check.   What i'm asking you Xot is do think it's possible? I suck as shaders...  But the perhaps that you could use x/y  against u/v  with relative position offsets checks between the sprites in question to yield a pixel accurate check with shader type parallel execution that would hopefully kick the crap out of the existing serial single thread runner method.


#2 2014-03-03 18:53:13

Registered: 2007-08-18
Posts: 1,201

Re: Shader Based Precise Collision?

I do not think there would be an effective way to communicate the collision back to the CPU.

A pixel shader could conceivably draw collision areas to a render target using the alpha of a texture as input. But once you've sent the operation to the GPU, it's difficult/slow to get the data back. Your only options for reading the data would be scanning the area with surface_getpixel() or creating a global sprite and colliding with that. If you are doing that, there would be no point in using a pixel shader in the first place. Either method would be exceedingly slow.

I believe intelligent, limited collision checks are the best option. Use precise collision only when absolutely necessary.

Abusing forum power since 1986.


Board footer

Powered by FluxBB