Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[RELEASED] crossSection tool

Discussion in 'Assets and Asset Store' started by tomekkie2, Jan 21, 2014.

  1. Ragami

    Ragami

    Joined:
    Jan 4, 2017
    Posts:
    10
    i already set model in method , bound is change but slider not change, how i change slider which follow bound object ?
     
  2. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    I have just updated these scripts to work with changing assignments at runtime.
    The cross-section gets activated on a given object with mouse click.

    3.gif
     

    Attached Files:

  3. berry4u

    berry4u

    Joined:
    Dec 27, 2017
    Posts:
    30
    Hi
    Applying the cross section tool I have some weird behavour when using two parallel planes in order to contain the visibility within a specific range.
    Everything works fine with a single plane but it seems that the video buffer is not refreshed when I use two planes. I uploaded a picture.
    This happens only in Game window, not in Scene window where everything works fine.

    Thank you.
     

    Attached Files:

    Last edited: Jul 23, 2020
  4. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    I can see only one single plane on this picture. Is it from game or scene window? What shows the other window?
     
  5. berry4u

    berry4u

    Joined:
    Dec 27, 2017
    Posts:
    30
    The issue happens zooming or panning but only in game window.
    Here attached two images of the same project (scene and game windows).
    In the cubeCapture image it is clear that the hidden part of the cube produces a sort of refraction which is in some way related with the issue. This refraction appears only with particular angles with camera.
    The cage is hidden
     

    Attached Files:

    Last edited: Jul 23, 2020
  6. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    What scene template is it and what shaders are on the object?
    Is it standard render pipeline? And what version of Unity?
     
  7. berry4u

    berry4u

    Joined:
    Dec 27, 2017
    Posts:
    30
    In order to test now made a project from scratch using Unity 2019.3.7f1 and standard render pipeline. Imported asset, created a simple Camera with pan rotation and zooming capability (similar to 3dMax Camera). Populated the scene with a single cube assigning CSBox1 Material and Clipping/Box/Standard shader. Imported CrossSectionBox assigning my cube to Model of Section Setup component.
    What I can observe (actually even in box_capped original example as visible in the snapshot here attached captured from your webgl online demo) is that for certain view angle the box cap interferes with rendering. Rotating slightly the camera the interference disappears (see image 2 captured from webgl online demo too). In my scene the issue is more visible and panning the camera objects leave a trail.
     

    Attached Files:

    Last edited: Jul 24, 2020
  8. Ragami

    Ragami

    Joined:
    Jan 4, 2017
    Posts:
    10
    thank you my problem is solve. love this plugin
     
  9. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    This is some issue with depth and depth writing and testing. I have checked this and looks like some manipulation of the rendering order of the cross-section materials fixes this. I specifically mean pushing the cross-section materials further in the rendering order, like changing the workflow from opaque to transparent. I definitely should setup the materials in the asset demo scenes properly, so the demo scenes would work without issues. Thanks for pointing that out.
     
  10. berry4u

    berry4u

    Joined:
    Dec 27, 2017
    Posts:
    30
    Thank you for trying to fix that. I think you are right because if I change the rendering mode of gameobject materials to fade or transparent but with A channel = 255 (so only moving their rendering order) the effect disappears. Let me know whether it works or not in order to help me to fix the issue in my scene in a similar way.
     
    Last edited: Jul 24, 2020
  11. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    This is when the green and beige materials are in opaque rendering queue:
    gif-5.gif
    And this is when the green and beige materials are in transparent rendering queue:
    gif-4.gif

    Obviously when you move one material in the queue and others are after it in the queue, you would probably also have to move these others.

    But this is a workaround.
    I just need to write a proper equation for the area hidden by box.
     
    Last edited: Jul 25, 2020
  12. Ragami

    Ragami

    Joined:
    Jan 4, 2017
    Posts:
    10
    Last edited: Jul 26, 2020
  13. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    From another side?
    gif-6.gif

    If this is what you are after - you can tick the inverse switch on the material/shader property or invert the "_SectionPlane" GlobalVector property on the shaders.
     
  14. Ragami

    Ragami

    Joined:
    Jan 4, 2017
    Posts:
    10
    yes this is what exactly i want but i want to change the value of slider and the cros from another side. i need it just for z axis. and i dont know to find the "_SectionPlane" what you said before.
     
  15. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    I have updated it that so now the sections can be referenced to local or world space.
    If it is local space - it can be any direction, any side, depending how you rotate the object.
    Adnotacja 2020-07-27 213006.png Adnotacja 2020-07-27 213130.png
     

    Attached Files:

  16. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    This is just not enough to include the subgraph.

    Take a close look the scenes with capping. All of them are based on stencils.

    The cross-section materials used in the capped sections have to include stencils.

    In my scenes I perform the stencil passes in three ways:
    1. Include in shader code (not possible using shader graph).
    2. Put additional invisible stencil materials on objects (This gives warning “The renderer has more materials than the Mesh has submeshes. ...” and this will not work with static batching).
    3. Use Render Object feature to get the objects selected by layermasks rendered more times with given materials, like in example scene: “single_plane_cap_urpGraph”

    Exposing the shader code and then adding the stencil is also an option. But when I see the ShaderGraph as an idea of writing shaders without the code and - it seems a contradiction to it, but it is no problem.
     
    Last edited: Jul 28, 2020
  17. Ragami

    Ragami

    Joined:
    Jan 4, 2017
    Posts:
    10
    Great !! thank you for your update , but in this case i have new problem , i cant make my object become static because that make my function will get error. maybe any solution from you about this ?
     
  18. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    This is not a problem, because the objects do not need to be static, it does not matter.
     
  19. Ragami

    Ragami

    Joined:
    Jan 4, 2017
    Posts:
    10
    https://imgur.com/a/uYvNVlp
    I mean like this, i just want rect gizmo position at Z like that without rotate the object.
     
  20. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    Can you place a container, set the desired orientation to in, then parent your object to it, and then set the model variable of the scripts to the container?
     
  21. Ragami

    Ragami

    Joined:
    Jan 4, 2017
    Posts:
    10
    Thank you , you save me again
     
    tomekkie2 likes this.
  22. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    It has just got fixed in the course of the most recent update so the opaque materials work well in the geometry render queue.
     
  23. berry4u

    berry4u

    Joined:
    Dec 27, 2017
    Posts:
    30
    Thank you so much tommekkie2. I'll work soon with it .
     
    Last edited: Aug 14, 2020
  24. berry4u

    berry4u

    Joined:
    Dec 27, 2017
    Posts:
    30
    Made some test.
    Actually an minor issue still remains. As you can see in the picture, by watching through the cage the sectioned cylinder occludes the environment.


    Just a new question. I'm wondering if is there some way (maybe a shader) to draw only the contour of sections, highlighting them instead than drawing caps? Of course shaders for sectioned object should render double sides in this case.
    This could be a good feature especially for architecture rendering.

    Thank you
     

    Attached Files:

    Last edited: Aug 18, 2020
  25. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    Currently this works like that:
    image_0000048.png

    The backfaces display unlit section material.
    The materials could have added an option to show the same material on both sides.
    Is that what you mean?
     
  26. goldv72

    goldv72

    Joined:
    Feb 13, 2020
    Posts:
    5
    Hi!
    I bought your product. There are many shaders for different cases. For example, crossesction/standard is not suitable for boxcapet and so on. Is there a universal shader for planarxyz, boxcapet, cornercapet?
     
  27. berry4u

    berry4u

    Joined:
    Dec 27, 2017
    Posts:
    30
    Oh, yes, it's absolutely what I'm looking for. I couldn't find this sample. I'm using standard render pipeline so maybe is that in urp part of asset (that I didn't downloaded)?
     
  28. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    In case of standard render pipeline - the outline effect is dependent on Unity Post-processing stack (v2). So if you get it into a project without the Post-processing stack (v2) installed you would get errors. That is why the outline effect assets are packed within the EdgeEffect.zip file. You have just to import the Post-processing stack (v2) in Package Manager and then unzip the file.
    In URP this feature is based on Renderer Features and not dependent on anything except the URP and is available just straightaway.
    You can also find it explained in instructions in crossSection_Doc.
     
    Last edited: Aug 19, 2020
  29. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    Thank you for your purchase.
    In most cases it is a matter of included keywords inside #pragma multi_compile statements in shader code like
    #pragma multi_compile __ CLIP_CORNER CLIP_PLANE CLIP_CUBE

    But some shaders like box capped need an additional stencil pass so it would be a waste to use in corner capped, plane capped and other scenarios, where this additional pass is not needed.
    Generally I think this could be area of improvement - to reduce a bit the number of shaders, making the remaining ones more versatile, with greater number of keywords. Thanks for pointing that out.
     
  30. h3space

    h3space

    Joined:
    Jul 28, 2020
    Posts:
    14
    Hi, does this asset work in HDRP?
     
  31. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    No, unfortunately.
     
  32. h3space

    h3space

    Joined:
    Jul 28, 2020
    Posts:
    14
    Thanks for the reply. Do you think we would be able to adapt the shaders manually to it, or it would be a huge effort?
     
  33. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    I can take a look.
    There is a number of setup scenes in the asset.
    It will depend on what specific setup you need.
     
    h3space likes this.
  34. goldv72

    goldv72

    Joined:
    Feb 13, 2020
    Posts:
    5
    thanks for reply!
    now most suitable shader for my application is Clipping/box/Autodesk Interactive.
     
  35. h3space

    h3space

    Joined:
    Jul 28, 2020
    Posts:
    14
    We would like to have a bounding box and clip everything outside of it. Shade the intersection faces and as bonus have an outline of the intersection edges. This alone would be great.

    Secondary but less critical, would be the inverse, clip everything inside a box, to allow 'corner cuts',
     
  36. berry4u

    berry4u

    Joined:
    Dec 27, 2017
    Posts:
    30
    Thank you for infos.
    BTW the issue about the render queue seems to me still present (even in the sample scene box_capped). At moment I'm still using the workaround of using transparent queue rendering of opaque materials. Obviously this causes a general loss of rendering quality (i.e. the shadows are not received properly)
     
  37. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    Apologies and thanks for letting me know.
    This is because the skybox is being rendered after opaques, after the area clipped by box and hidden by box is written to the z-buffer.
    A remedy is to setup a separate skybox camera.
    1. Create the skybox camera, with clear flags set to skybox and culling mask set to nothing. Set its depth one unit lower then the MainCamera; e.g. if the main camera depth is 1, set the skybox camera depth to 0.
    2. Parent the skybox camera to the main camera and then reset its local transform to zero position and quaternion.identity rotation.
    3. Set the main camera clear flags to depth only.
     
  38. berry4u

    berry4u

    Joined:
    Dec 27, 2017
    Posts:
    30
    Thank you so much for the support.
    It work perfectly!
     
  39. goldv72

    goldv72

    Joined:
    Feb 13, 2020
    Posts:
    5
    Hi!
    does your app work with colored pointcloud?
     
  40. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    It does not at the moment.
    This requires a point cloud shader, but now the asset does not contain any.
    So this is a matter of getting a point cloud shader and pasting some cross-section code snippets into it.
     
  41. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    I am just in process of porting the asset to HDRP.
    I am starting from some four most commonly used setups like plane, corner and box section.
    The hdrp version will work on shader graphs rather than coded lit, unlit etc. shaders.

    I am just wondering whether to split it o a separate asset, or rather include in form of unitypackage?
    Splitting might help me in more frequent asset updates by render pipelines.
    I would be just grateful for any suggestions.


    image_0000006.jpg
     
    Knipscher likes this.
  42. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    I have just got the stencil shaders to work on HDRP.
    Now I am getting the triplanar mapping to work on the cross-section cap shaders.

    image_0000008.jpg
     
  43. h3space

    h3space

    Joined:
    Jul 28, 2020
    Posts:
    14
    That's great. I vote to split into separate assets. Since we are at it, it would be nice to include an asmdef file for the scripts, and make it a package to work with the new package manager.
     
  44. reddotgames

    reddotgames

    Joined:
    Apr 5, 2011
    Posts:
    678
    Can sliced ares receive proper shadows and lightning in HDRP? Or is it solid like unlit?
     
  45. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    For sliced areas - I have used the simplest shaders, based on unlit shader - so they will not receive shadows at the moment.
     
    Last edited: Sep 28, 2020
  46. zashour

    zashour

    Joined:
    Sep 18, 2019
    Posts:
    10
    I have been using crossSection tool on Unity 2019.3.ob7 with no issues. Recently, I have upgraded to Unity 2020.1.5f1 for a new project, but I am getting a lot of errors as seen below:


    Assets/WorldSpaceTransitions/crossSection/scripts/SectionSetup.cs(74,31): error CS0104: 'Vector3' is an ambiguous reference between 'MathGeoLib.Vector3' and 'UnityEngine.Vector3'

    DllNotFoundException: MathGeoLib.Exports
    MathGeoLib.OrientedBoundingBox.Enclose (UnityEngine.Vector3 point) (at Assets/WorldSpaceTransitions/crossSection/MathGeoLib.Exports.v0.1/MathGeoLib/OrientedBoundingBox.cs:210)
    WorldSpaceTransitions.SectionSetup.OBB (WorldSpaceTransitions.SectionSetup+VertexData[] vdata, UnityEngine.Vector3 v1, UnityEngine.Vector3 v2, UnityEngine.Vector3 v3) (at Assets/WorldSpaceTransitions/crossSection/scripts/SectionSetup.cs:408)
    WorldSpaceTransitions.SectionSetup+<>c__DisplayClass25_1.<AccurateBounds>b__0 () (at Assets/WorldSpaceTransitions/crossSection/scripts/SectionSetup.cs:338)
    Threading.AsyncTask+<>c__DisplayClass9_0.<.ctor>b__0 () (at Assets/WorldSpaceTransitions/crossSection/Threading/AsyncTask.cs:31)
    System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) (at <fb001e01371b4adca20013e0ac763896>:0)
    System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <fb001e01371b4adca20013e0ac763896>:0)
    System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <fb001e01371b4adca20013e0ac763896>:0)
    System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) (at <fb001e01371b4adca20013e0ac763896>:0)
    System.Threading.ThreadHelper.ThreadStart () (at <fb001e01371b4adca20013e0ac763896>:0)
    UnityEngine.<>c:<RegisterUECatcher>b__0_0(Object, UnhandledExceptionEventArgs)
    MathGeoLib.NativeMethods:eek:bb_enclose(OrientedBoundingBox, Vector3)
    MathGeoLib.OrientedBoundingBox:Enclose(Vector3) (at Assets/WorldSpaceTransitions/crossSection/MathGeoLib.Exports.v0.1/MathGeoLib/OrientedBoundingBox.cs:210)
    WorldSpaceTransitions.SectionSetup:OBB(VertexData[], Vector3, Vector3, Vector3) (at Assets/WorldSpaceTransitions/crossSection/scripts/SectionSetup.cs:408)
    WorldSpaceTransitions.<>c__DisplayClass25_1:<AccurateBounds>b__0() (at Assets/WorldSpaceTransitions/crossSection/scripts/SectionSetup.cs:338)
    Threading.<>c__DisplayClass9_0:<.ctor>b__0() (at Assets/WorldSpaceTransitions/crossSection/Threading/AsyncTask.cs:31)
    System.Threading.ThreadHelper:ThreadStart()


    Build completed with a result of 'Failed'
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)


    UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors
    at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x00270] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:187
    at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:95
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)



    I tried to import the package several times with no luck.

    Please help!

    Thank you
     
  47. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    This is a DllNotFoundException.
    Check the MathGeoLib.Exports.dll file existence. It should be inside the crossSection/MathGeoLib.Exports.v0.1/binaries/x64/Release folder.
    The asset version for Unity 2019.3 should also work for 2020.x.
    But I made some updates, mainly regarding the URP, for Unity 2020.
    You could also try to reimport the newer asset version (if you did the old version only) from the AssetStore.
     
  48. zashour

    zashour

    Joined:
    Sep 18, 2019
    Posts:
    10
    I checked the dll file and it's there. I also tried the example scenes from the asset and they are all working fine.

    I am using Vurforia engine in my project. Is this the reason?
     
  49. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    I don't think so.
    It should not conflict with Vuforia.
    Did it work with Vuforia in 2019.3 ?
    What build target?
    I had similar problems today, when making a test build of the HDRP version for Windows. I had to modify the SectionSetup.cs script in order to succeed. Try the attached file.
    At the moment I am using this .dll file for setup being done in editor only, so I basically do not need it to get into the build.
     

    Attached Files:

    Last edited: Sep 28, 2020
  50. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    682
    I have just finished the basic HDRP version.
    image_0000009.jpg image_0000012.jpg

    So the corner and box scene will be included inside the HDRP version.
    The HDRP pipeline uses stencil buffers extensively, leaving only two bit for custom uses.
    I we tried to use more bits - it might lead to some colisions with HDRP - so we have to make it up.
    You can try the standalone Windows build:
    https://drive.google.com/file/d/1gP0Gqj4widD7bNTO3qrx6BCFACy_IoR0/view?usp=sharing.
     
    Last edited: Oct 14, 2020
unityunity