Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Implementing a 2D Distance Field
#1
Pregunta 
I am hoping to use a live camera texture as the basis of a collider. I found a post from 2017 that looks promising:


Quote:- Each frame, render the silhouette of your mesh to a full-screen render texture. White silhouette against a black background.
- Blur the silhouette (using separable linear gaussian blur, if possible). This essentially gives you a sort-of distance field of your humanoid.
- Now the fun part. Use a fullscreen grid-like mesh to create your particles (use a geometry shader to emit a quad per vertex) and read the previous blurred texture at each particles' location. The whiter your texture, the closer you are to the body silhouette. You can use a threshold to control how close your particles are allowed to get to the silhouette. To get a gradient direction (a "normal") to project the particles, just take the derivative of this black/white map.


The first two steps have been achieved, but I'm unsure how to "use a threshold to control how close your particles are allowed to get to the silhouette." Can this be implemented as an extension to the existing ObiColliderBase or ObiDistanceField, or would it have to be an entirely separate set of scripts that modify the position and velocity of each particle? The latter has been advised against in this post:

Quote:You could get particle positions/velocities every frame and implement your own collision detection in C#, but it will be challenging to get it running at an acceptable speed for more than a couple thousand particles.

Any thoughts or examples would be extremely helpful. Thank you!
Reply


Messages In This Thread
Implementing a 2D Distance Field - by mitch_bi - 18-06-2019, 05:19 PM