Search Unity

Super Raycast - Perfect collision detection against Renderers without colliders.

Discussion in 'Assets and Asset Store' started by neon_teebar, Jun 1, 2017.

  1. ShawnFrueh

    ShawnFrueh

    Joined:
    Sep 29, 2015
    Posts:
    7
    How do I add this to my scripts? When I type in SuperRaycast I get the error that it doesn't exist in the current context Do I need to use a namespace?
     
  2. ShawnFrueh

    ShawnFrueh

    Joined:
    Sep 29, 2015
    Posts:
    7
    It seems that the flickering goes away if you disable "Virtual Reality Supported" under player settings and then re-Enable it.
     
  3. ShawnFrueh

    ShawnFrueh

    Joined:
    Sep 29, 2015
    Posts:
    7
    Tried moving the scripts outside of the plugins folder. No luck :( Ended up breaking other scripts.
     
  4. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    It's not a component, you call it like you would call Physics.Raycast. There are demos included that demonstrate how to use it.
     
  5. ShawnFrueh

    ShawnFrueh

    Joined:
    Sep 29, 2015
    Posts:
    7
    Thanks for the reply. Looks like I got it working. There was just something goofy in my project that was conflicting with the plugin.

    I am trying to add an array of meshes and a max value. But I get an error when trying to do so.

    I am following this line:
    Code (CSharp):
    1. public static bool Raycast(Ray ray, Renderer[] renderers, out RaycastHitRenderer hitInfo, float maxDistance = float.MaxValue)//, bool improve = true)//, Texture texture = null)
    With this:
    Code (CSharp):
    1.  
    2. public GameObject[] hitObjs;
    3. private RaycastHitRenderer hit;
    4. private bool hitInRange;
    5. private Ray ray;
    6.  
    7. hitInRange = SuperRaycast.Raycast(ray, hitObjs, out hit, range);
    SuperRaycast does not like that order even though that is how it is outlined in SuperRaycast.cs
     
  6. ShawnFrueh

    ShawnFrueh

    Joined:
    Sep 29, 2015
    Posts:
    7
    Nvm, It takes a renderer not a game object. Works fine :) Thank you!
     
    neon_teebar likes this.
  7. HybridMedical

    HybridMedical

    Joined:
    Mar 19, 2015
    Posts:
    3
    We are getting some errors when using this in conjunction with Post Processing. Is this a limitation? Are there any workarounds if this is a known issue?
     
  8. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    First I've learned of this issue. Which version of Unity and which version of the Post Processing stack are you using? And what kind of errors did you get?

    It might not be fixable any time soon unfortunately, as I've had a hard time porting things to Unity 2017+.
     
  9. Burchmore500

    Burchmore500

    Joined:
    Oct 20, 2014
    Posts:
    11
    Hey,

    I just bought the asset and have a question regarding performance. To do a single SuperRaycast.LineTest against a single Renderer takes about 0.6ms according to the profiler (~0.3ms to Camera.Render, ~0.3ms to Gfx.ReadbackImage).

    Is this expected? I saw on the previous page you noted that a stress test of 1000x SuperRaycasts took ~0.5ms, so I'm not sure why I'm having performance issues. I'm running on an i5-6600k and a GTX970. Also, calling it seems to allocate 6.6KB garbage, which I would like to avoid if possible.

    Thanks,

    PS. Profiler Screenshot (In Projectile.Update is where I call SuperRaycast.LineTest):

     
    Last edited: Apr 23, 2018
  10. killeredy

    killeredy

    Joined:
    Sep 11, 2018
    Posts:
    1
    Hello!
    I recently acquired superRaycast and was very happy with the results on the pc.
    But I'm having trouble publishing to mobile. Few objects in the scene respond to the script.
    I do not know if I'm doing something wrong (I'm new to Unity and C #) or if the assets do not work on androids:
    Follow my scripts:


    if ((Input.touchCount > 0) && (Input.GetTouch(0).phase == TouchPhase.Began))
    {
    Ray raycast = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
    RaycastHitRenderer hitInfo;
    if (SuperRaycast.Raycast(raycast, out hitInfo))
    {
    Color myColor = hitInfo.renderer.material.color;
    string myName = hitInfo.renderer.name;
    showColorName(myColor, myName);
    }
    }

    **portuguese translator with goole.
     
  11. Gulliver

    Gulliver

    Joined:
    Jan 8, 2013
    Posts:
    101
    Hi. Just purchased and got bunch of errors like:

    RenderTexture.Create failed: format unsupported for random writes - 11.
    UnityEngine.Camera:Render()
    SuperRaycast:Raycast(Ray, Renderer[], RaycastHitRenderer&, Single) (at Assets/Plugins/Teebar/Super Raycast/SuperRaycast.cs:681)
    SuperRaycast:Raycast(Ray, GameObject, RaycastHitRenderer&) (at Assets/Plugins/Teebar/Super Raycast/SuperRaycast.cs:575)
    NE_Construction:edit_mapping(Single, Single) (at Assets/Scripts/NE_Scripts/NE_Construction.cs:113)
    Workshop:edit_mapping(Single, Single) (at Assets/Scripts/NE_Scripts/NE_Workshop.cs:1546)
    Workshop:update_workshop() (at Assets/Scripts/NE_Scripts/NE_Workshop.cs:1533)
    NE_Game:Update() (at Assets/Scripts/NE_Scripts/NE_Game.cs:484)
     
    spoonshoe likes this.
  12. DATA006

    DATA006

    Joined:
    Jul 14, 2018
    Posts:
    1
    Hey, Can it be used to shoot at a fps? I got this

    Sin título.png

    So, How can I replace it in my code?
     
  13. theazz

    theazz

    Joined:
    Oct 20, 2013
    Posts:
    60
    Anyone here know if this asset is still supported / the fella replies?
     
  14. sylvainbergeon

    sylvainbergeon

    Joined:
    Oct 25, 2017
    Posts:
    1
    Hi there,

    I’m currently working on a VR project, that’s not a game, but an interactive VR meeting room for physicists to observe 3D data coming out from complexe physics simulation (metal deformation at high speed).

    3D models are very heavy an reaches the 65k vertex.

    All works very well except the fact I uses colliders to allow users to point and click the surface to get and display numerical values.

    The use of convex colliders is very expensive when I move/rotate/scale the mesh around (physics recaluculation drops dow the frame rate to 15fps wich is unacceptable).

    I was wodering if your superRayCaster could help on this.

    I generally have only one meshRenderer at a time and don’t need to raycast on long distances.

    Any advise would be welcome.

    Thanks
     
  15. theazz

    theazz

    Joined:
    Oct 20, 2013
    Posts:
    60
    Depends how accurate and what example you're sampling. The asset still works but the dev has vanished the asset is quite cheap I'd suggest just trying it
     
  16. spoonshoe

    spoonshoe

    Joined:
    Jan 25, 2010
    Posts:
    9
    Same here - did you ever get a response outside teh forum?
     
  17. Gulliver

    Gulliver

    Joined:
    Jan 8, 2013
    Posts:
    101
    No
     
  18. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    306
    Hello
    What is the shader included in the package used for?
    Thank you
     
  19. SharkmanSam

    SharkmanSam

    Joined:
    Aug 2, 2013
    Posts:
    4
    Is this product still supported? I am having trouble with the SuperCast Ray at (seemingly) long distances. Even when doing the fastest method. Im using it on my Terrain.
     
  20. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hi. Is there an update for HDRP available or has someone an
    already ported it?

    I get an
    Thread group size must be above zero
    UnityEngine.Camera:Render()
    SuperRaycast:Raycast(Ray, Renderer[], RaycastHitRenderer&, Single) (at Assets/Plugins/Teebar/Super Raycast/SuperRaycast.cs:681)
    SuperRaycast:Raycast(Ray, RaycastHitRenderer&, Single, LayerMask) (at Assets/Plugins/Teebar/Super Raycast/SuperRaycast.cs:558)
    SuperRaycastDemo.MultiObjectExample:Update() (at Assets/Plugins/Teebar/Super Raycast/Demos/Scripts/MultiObjectExample.cs:111)

    in Unity 2019.3.0f3 with HDRP 7.1.7

    The SkinnedMeshDemo is still working.

    Also the
    BumpMapMultRendererDemo
    is partly working for object who have no objects behind.

    The left cube and capsule and all cubes and capsule on the border of the cube/capsule structure get collision (see console).

    SuperRaycastHDRP_2.JPG
     
    Last edited: Jan 11, 2020
  21. Demhaa

    Demhaa

    Joined:
    Jun 23, 2018
    Posts:
    35
    I wonder, since this uses a visual mesh's normals...
    Can this become its own mesh collider?
     
  22. ESTECH

    ESTECH

    Joined:
    Mar 2, 2017
    Posts:
    1
    Hello !

    Do you continue your work on this since URP and HDR and does this work with in ?
    I need your asset to use it with imported Mesh at runtime and it's seems to be really usefull !
     
  23. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    306
    I am also getting this errors on Mac

    neon_teebar Do you have a fix for this?

    Gulliver, have you found a workaround or another solution?

    Thanks
     
  24. Arlorean

    Arlorean

    Joined:
    Sep 7, 2014
    Posts:
    27
    The _Return uniform in the shader isn't set to RENDERER_ID (3) when a material is first added to the matPool cache. Commenting out the
    return mat;
    from within the if statement makes the RayCast work on the first call as well as subsequent ones for cached materials:
    upload_2021-3-12_13-33-49.png
    This might be why some people are saying it works intermittently.

    I'm using Unity 2020.2.2f1 with URP 10.2.2 and it all works correctly in the editor, although I had to ensure that my custom URP renderer included Layer 31 (which I named SuperRaycast) in the Opaque layer mask.

    upload_2021-3-12_13-40-53.png

    Internally the code uses Camera.Render() which the URP docs say is Not Supported so the asset may stop working at some point but for now it works pretty will for my needs.
     
    Fibonaccov likes this.
  25. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    Does this Asset work on Skinned Meshes in Unity 2019, 2020 and 2021? There doesn't seem to have been an update for 3 years so a bit concerned before I buy that it will work.
     
  26. Arlorean

    Arlorean

    Joined:
    Sep 7, 2014
    Posts:
    27
    One of the samples that comes included is a SkinnedMesh example and it worked for me in a URP project in 2020.2.2f1. It's great if you don't want to have colliders on everything but still want to do the occasional raycast. Add my fix above to make it work reliably on the first raycast. Hope this helps (I'm not the author BTW).
     
  27. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    Has anyone got this to work on mobile? In the project I am helping on it is not working and giving the error:
    RenderTexture.Create failed: format unsupported for random writes - RGBA32 SFloat
     
  28. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    I am helping a team which is using this Raycaster in a project, in my simple scene I use the raycast against a SkinnedMesh and it works just fine, I get the right collision point back. In their scene with the same objects it registers collisions but the collision point is totally wrong and seems to be returning a collision with the bounding volume instead. Below is a screenshot showing the problem, I create a ray from the mouse screenpos to the sphere object, and the black lines show the ray from the origin on the camera plane to the returned hitpoint. And you can see that the rays are hitting the bounding volume and not the front of the sphere. How can this be fixed.
    Screenshot 2021-04-06 003623.jpg
     
  29. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    Having done some more digging it seems it works fine if the Color Space is set to Gamma, if it is set to Linear then it doesn't work. Is there a fix for that?
     
  30. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    200
    is this still working in unity 2020? I used it back in 2017 and it was amazing.
     
  31. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    175
    The first post link are broken!
     
  32. HunterAhlquist

    HunterAhlquist

    Joined:
    Oct 6, 2013
    Posts:
    132
    Any chance this will be updated to provide triangleIndex information?
     
  33. nubdev

    nubdev

    Joined:
    Mar 30, 2013
    Posts:
    87
    Trying to use this for skinned mesh renderers, the example works fine but I see that it has a reference to the skinned mesh renderer it is cast against already included when calling the raycast. Since it seems the author has abandoned this project (no responses in this thread for a while), does anyone know if this is accurate and that you need a reference to the skinned mesh you are attempting to cast against before you cast the superraycast?
    This means then that you cannot just shoot a ray and return hits from any skinned meshes that cross its path?
    Seems to be the case