Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

CrossSection

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

?

What render pipeline are you using or going to use with the CrossSection Asset?

  1. Built-in

    31.4%
  2. URP

    52.9%
  3. HDRP

    15.7%
  4. other

    0 vote(s)
    0.0%
  1. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Performance of the cross-section shaders which are based on standard shaders - with the crossSection keywords off or set to CLIP_NONE should be similar to their source shaders, but excluding these ones with extra stencil pass (in case of built-in render pipeline).
    I mean these shaders:
    - CrossSection/Surface/Box (based on the Surface shader)
    - CrossSection/Standard/Box (a remake of Standard shader)
    - CrossSection/Standard (Specular setup)/Box (a remake of Standard Specular setup shader)
    - CrossSection/Autodesk Interactive/Box (a remake of Autodesk Interactive shader)
    where the stencil areas do not overlap the backface areas of basic pass areas and an additional separate stencil pass is added and is being rendered all the time no matter the keyword actually selected.

    Ambient occlusion - a way around that could be to use single plane capped setup or to modify the AO shader to not contribute anything on backfaces.
     
    Archtica likes this.
  2. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    220
    Hey, I tried to get back the CLIP_TUBES feature in the CrossSectionURP Lit and LitAndCapPrepare Shaders. I've read here that you can just put the keyword back in the multicompile section of each pass in the shader files. This did work for the CrossSectionURP/Unlit Shader but not for the lit shaders. In the SimpleLit Shader, it's already active (what a mess ;).
    Can you help with this?

    EDIT: Seems like a Unity hiccup, had to manually disable the CLIP_NONE Keyword and now it works
     
    Last edited: Jun 7, 2022
  3. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    220
    Is this seethough by any means preventable? I've used the URP Examples.
    My use case is a squared diorama scene which I wanna show a cylidrical view with CLIP_TUBES in AR from. The Hatch isn't shown when the backface of the opposite site is not included in the hatch geometry. Is it possible in any way that "all backfaces" are written to the stencil buffer?

    HatchProblem.gif

    HatchProblem3.gif
     
    Last edited: Jun 8, 2022
  4. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Is this exactly an example scene from the CrossSection asset? Looks like something was missing there.

    Yes it is preventable. The stencil pass should be based on cylinder intersection code. The backface areas where ray from camera intersects cylinder should write to stencil buffer.
    The section_clipping_CS.cginc file already contains the code
    • for the box intersection used in the box capped section
    • for the sphere intersection used in the sphere capped section
    • for the pie intersection used in the pie section
    A code for cylinder intersection should be added and then implemented to fix this.
     
    Last edited: Jun 10, 2022
  5. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    220
    Yes this is the unedited standard demo scene. I've created and empty project in Unity 2021.3.4 to test this again. This happens for me in the buildin and the urp examples.

    I've created a small package for demonstration. You have to add the newest Crossection Package and extract URP Assets (although this happens in buildin as well). It happens with all CLIP Types. My example is using the CLIP_SPHERE. You can clearly see the part of the backfaces of the diorama not intersecting with the hats are transparent. Problem seems to be the "inverse" function, as I only want to see stuff inside the cylinder/sphere/tube.

    https://local.vr-bits.de/ClipErrorProject.7z

    HatchProblem3.gif
     
    Last edited: Jun 9, 2022
  6. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Thanks for letting me know. I will check it.
    _________________________________
    I have opened your project, then imported the crossSection asset.

    One of the URP shader files, i.e. CapLitWithStencils.shader is located in wrong folder, deprived access to the included file, move it to the shaders folder. But I think it is not used in these scenes.

    All the demo scenes, both these for urp as well as built-in work as intended.

    Also the sphere_capped_urp scene - for me - works as intended.

    Your project contains only one scene, the TestScene.
    I would expect this scene to be and edited version of the sphere_capped_urp.
    However your TestScene is missing the pipeline asset - so you can't expect get the backfaces to display correctly.
     
    Last edited: Jun 10, 2022
    pojoih likes this.
  7. unity_hx1ew7EJjvQ_hg

    unity_hx1ew7EJjvQ_hg

    Joined:
    Nov 4, 2021
    Posts:
    3
    Hello, I'm trying to set up the asset and I've encountered an issue when trying to build the project.

    The project is using Unity 2021.3.4f1 with URP. I'm building on a Mac for iOS.

    The error I'm getting:

    Assets/WorldSpaceTransitions/crossSection/scripts/SectionSetup.cs(474,44): error CS0246: The type or namespace name 'ShaderUtil' could not be found (are you missing a using directive or an assembly reference?)


    I can run the sample scenes in the editor just fine, but I can't build the project.

    Could you please let me know what might be causing the issue?
     
  8. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    This code is intended for use in Unity Editor, so I will put it inside
    #if UNITY_EDITOR
    ........
    #endif

    compilation directives and this will fix the issue.
     
  9. unity_hx1ew7EJjvQ_hg

    unity_hx1ew7EJjvQ_hg

    Joined:
    Nov 4, 2021
    Posts:
    3
    It builds now. Thank you! :)

    I had to add #if to both `getSubstitute` and `CheckShaders`.
     
    tomekkie2 likes this.
  10. unity_hx1ew7EJjvQ_hg

    unity_hx1ew7EJjvQ_hg

    Joined:
    Nov 4, 2021
    Posts:
    3
    [SOLVED]

    Unfortunately, I've encountered another build issue.

    I've added the crossSection scripts to my GOs and I've applied the shader "CrossSectionURP/LitAndCapPrepare" to my materials.

    When I test in the editor everything seems to work correctly, however, when I try to build for iOS I'm getting errors during the shader compilation stage:

    Code (CSharp):
    1. Shader error in 'CrossSectionURP/LitAndCapPrepare': redefinition of '_primCountTruncated' at (URP)/shaders/section_clipping_CS.cginc(312) (on metal)
    2.  
    3. Compiling Subshader: 0, Pass: DepthOnly, Vertex program with CLIP_CYLINDERS CLIP_PRISMS
    4. Platform defines: SHADER_API_MOBILE UNITY_ENABLE_REFLECTION_BUFFERS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_LIGHTMAP_DLDR_ENCODING UNITY_NO_DXT5nm UNITY_NO_RGBM UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF3
    5. Disabled keywords: CLIP_BOX CLIP_CONE CLIP_CONES CLIP_CORNER CLIP_CUBOID CLIP_CUBOIDS CLIP_CYLINDER CLIP_ELLIPSOID CLIP_ELLIPSOIDS CLIP_NONE CLIP_PLANE CLIP_PRISM CLIP_SPHERE CLIP_SPHERE_OUT CLIP_TETRA CLIP_TETRAS DOTS_INSTANCING_ON INSTANCING_ON SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHTMAP_RGBM_ENCODING UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_FULL_STANDARD_SHADER UNITY_PBS_USE_BRDF1 UNITY_PBS_USE_BRDF2 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_VIRTUAL_TEXTURING
    There are 4 errors in the same file, but on different lines: 312, 321, 330, and 339.

    I'd appreciate your help.

    EDIT: Update - When I comment out the lines with duplicated declarations, I get undeclared identifier errors on the following lines. Hmm...

    EDIT: Update 2 - It's alive! I needed to comment out all the declarations and put this code on line 301:

    Code (CSharp):
    1. #if CLIP_PRISMS || CLIP_CYLINDERS || CLIP_TETRAS || CLIP_CONES || CLIP_ELLIPSOIDS || CLIP_CUBOIDS || CLIP_BOXES
    2.         int _primCountTruncated = min(_primCount, 64);//let's assume 64 as maximum prism count expected
    3.         #endif
     
    Last edited: Jun 9, 2022
    tomekkie2 likes this.
  11. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Thank you. I will make an update including these fixes soon.
    ________________________________________________

    EDIT: Update

    The asset is updated already.
     
    Last edited: Jun 13, 2022
    unity_hx1ew7EJjvQ_hg likes this.
  12. AaronChen2022

    AaronChen2022

    Joined:
    Apr 18, 2022
    Posts:
    8
    Hi, what a great tool! Can the CLIP_PLANE and CLIP_CYLINDER work together on one mesh? Thanks
     
  13. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    Hi @tomekkie2 I'm getting great results so far.
    I've moved to my Android Oculus version of the app and it seems that retract backface doesn't work on Android OpenGLES3 Standard, can you confirm that?
    It works fine on standalone, Oculus Link and also in the Unity editor of the Oculus Android app, but in the build I get z fighting. I'm using your single plane capped method with a little bit of backface extrusion to avoid fighting.

    Regards
     
    Last edited: Jun 21, 2022
  14. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    No, the short answer is they can't.

    The multicompile statement
    #pragma multi_compile __ CLIP_PLANE CLIP_SPHERE CLIP_BOX CLIP_CORNER CLIP_SPHERE_OUT CLIP_PRISM CLIP_PRISMS CLIP_CYLINDERS CLIP_CYLINDER ...

    produces shader variants with one keyword enabled at a time.
    So the solution could to be create a new keyword, something like CLIP_CYLINDER_AND_PLANE and add it into the multi_compile statement.
    Then add a code inside the section_clipping_CS.cginc file for that new keyword.

    In case of non capped setup the task would be relatively simple.

    In case of capped setup the task would be more complicated, because of capping meshes. The mutual location of camera, cylinder and plane would also matter.
     
  15. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    I can't see any reasons for that at the moment.
    Possibly this could have something to do with distance accuracy.
    Are you using the built-in render pipeline?
     
  16. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    Yes, I'm using built-in. I tried increasing backface extrusion alot without getting rid of the fighting. It stays the same. Everything is fine in the editor but not in the built version.
    Can I do something to test/combat accuracy issues? It sounds feasible.

    Edit: This is the built version with a large backface extrusion value (1.0). It's like it doen't have any effect. I normally have it at something like 0.0005. Where the objects meet eachother and the ground plane, there is z fighting:



    And here it is running from the editor as expected with a small backface extrusion:

     
    Last edited: Jun 22, 2022
  17. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    So looks like this is a matter of feature not working at all, rather than matter of any accuracy setting.

    But I think this has nothing to do with Android OpenGLES3 settings, because it works in Android demos both built-in and urp, at least on my Samsung Galaxy phones (A7, S8).
     
  18. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    Hi @tomekkie2
    I now tested on regular Android (Samsung S10) both AR and a scene and backface extrusion has no effect here either, same as Oculus Android.
    Does backface extrusion work in your Android demos? As mentioned I'm using your basic capped single plane. I use your crosssection/standard shader and everything is good in the editor.

    Regular scene:

    AR:
     
    Last edited: Jun 24, 2022
  19. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    These are screenshots from my A7 2018 phone:
    Screenshot_20220624-143311_CS20212_demo.jpg Screenshot_20220624-143404_CS20212_demo.jpg
    You can also run this test apk on your phone.
    https://virtualplayground.d2.pl/crossSection/test/cs_retract_backfaces_test_builtin.apk
     
  20. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    Great @tomekkie2 I'm guessing it is in made in built-in, I just need to nail it myself :)
    I guess it is also built with the sample scenes from you package, so I'll have a closer look at that to see what I'm missing.
    Thank you and have a nice day!
     
    Last edited: Jun 24, 2022
    tomekkie2 likes this.
  21. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    I'm trying to section a vertex colored mesh. The geometry is clipping, but the back face is reflective. I'm on built-in using your crosssection/surface/vertexcolor with the single plane method (no cap). Am i missing a keyword? I only use CLIP_PLANE

     
  22. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    When replacing shaders with crosssection/surface/vertexcolor in single plane scene, the shader seems to work right.
    But where does the yellow color come from?
    Is this a cube primitive?
    Or a cube primitive with normals inverted?
     
  23. AaronChen2022

    AaronChen2022

    Joined:
    Apr 18, 2022
    Posts:
    8
    Thank you for your reply, could you add this feature in the next version? It is a really useful feature in some cases, thanks!
     
  24. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    It's not a primitive, but a vertex colored mesh with same yellow color on all vertices. The same thing happens with a cube directly from Unity. I tried flipping the normals with the result of yellow on the inside and black reflective material on the outside, so it's not the normals it seems...No problem with your standard shader in the same scene.
    And also I cannot cap with this shader, but maybe it doesn't support that.

     
    Last edited: Jul 2, 2022
  25. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    Dear @tomekkie2
    After many, many, many hours of debugging I found the reason why back face extraction doesn't work on Android and Oculus in my case. Disabling the keyword _EMISSION at runtime causes the backface extraction to fail or not be applied. This is not a problem in all other builds:

    Code (CSharp):
    1. material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.EmissiveIsBlack;
    2. material.DisableKeyword("_EMISSION");
    I still have reflection on the vertex color like explained above. Do you know why? That is my last non working element.
     
    Last edited: Jul 2, 2022
  26. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    My apologies!
    Looks like some lines were missing or wrong in this shader code.
    Try this one from the unitypackage.
    This is a replacement for SurfaceStd.shader file, so start from deleting this file.
    I have added vertex color as a shader feature.

    So with this new shader
    the cubes with top vertices blue and bottom vertices red produce results like that:
    image_058_0000.png

    With vertex color feature off:
    image_057_0000.png

    With the stencil directives added capping works. image_059_0000.png

    With capping off.
    image_060_0000.png
     

    Attached Files:

    Archtica likes this.
  27. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Would it be so useful, really?
    Do you mean an uncapped version? It would be complicated to add capping to it.
    Note that I have also to keep the keywords number in multi_compile statements low in order to reduce the number of shader variants, build time and build size.
    Possibly using shader_features (which gets compiled and included only when used) instead multi_compile could be better option for less common variants.
     
  28. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    Thank you @tomekkie2, it's nice to have as part of the surface shader.
    Did you have a look at the _EMISSION problem I ran into, it's a headache for me. It seems to be a bug.
     
  29. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Yes, I have checked this.
    Looks like the "_EMISSION" keyword were blocking the mesh vertices displacement.

    With baked global illumination on and black emission color this doesn't happen - the vertices displacement work as expected, no matter the emission keyword.

    But globalIlluminationFlags do not seem to have any effect on this at all.

    I have no idea why is that.
     
    Last edited: Jul 3, 2022
  30. Channabasappa

    Channabasappa

    Joined:
    Jan 29, 2017
    Posts:
    3
    Hi @tomekkie2

    I want to show cross sections of the human heart, lungs and other parts of the body. The idea is that the user will use a plane in any orientation to cut a part in any direction and see the inside view from that angle, similar to this
    . Does your tool support these kinds of complex models?
     
  31. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Yes it does support all sorts of models, no matter how complex they are, as long as Unity can handle them.

    But, unfortunately, the demands for the models are very high.

    The meshes have to be closed and not intersecting. That means that many surfaces obtained from 3d scanning may not be suitable without special treatment.

    Generally models which can pass a 3d printability test should be o.k.
     
  32. AaronChen2022

    AaronChen2022

    Joined:
    Apr 18, 2022
    Posts:
    8
    Hi, yes it is useful, my case is clipping 2 meshes use plane and cylinder, but the surface are not clipped, could you add this feature to the plugin or give me some suggestion about how to do it? Thanks
    upload_2022-7-8_11-23-38.png
     

    Attached Files:

  33. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    plane&cyl.gif
    If you don't need the section capping it is not difficult.

    First of all make a correction in the section_clipping_CS.cginc file:
    Replace this
    #if CLIP_CYLINDER
    _clip = clipCylinderInside(posWorld, _WorldToObjectMatrix, 0.5*_SectionScale.xyz);
    #endif

    with this
    #if CLIP_CYLINDER
    _clip = _clip || clipCylinderInside(posWorld, _WorldToObjectMatrix, 0.5*_SectionScale.xyz);
    #endif

    - in order to include the previously calculated plane clipping.

    Then, inside the shader code, below each of these lines:
    #pragma multi_compile __ CLIP_PLANE ...


    - add another line for cylinder:
    #pragma multi_compile __ CLIP_CYLINDER


    The cylinder on this gif image is the same as one in the primitives_capped scene.
    and this is the script updating the shaders:

    Code (CSharp):
    1. public class SingleCylinderSection : MonoBehaviour
    2. {
    3.     // Start is called before the first frame update
    4.     void Start()
    5.     {
    6.         UpdateSection();
    7.     }
    8.  
    9.     // Update is called once per frame
    10.     void Update()
    11.     {
    12.         if (transform.hasChanged) UpdateSection();
    13.     }
    14.     void OnEnable()
    15.     {
    16.         Shader.EnableKeyword("CLIP_CYLINDER");
    17.     }
    18.  
    19.     void OnDisable()
    20.     {
    21.         Shader.DisableKeyword("CLIP_CYLINDER");
    22.     }
    23.  
    24.     void UpdateSection()
    25.     {
    26.         Matrix4x4 mx = transform.localToWorldMatrix;
    27.         Shader.SetGlobalMatrix("_WorldToObjectMatrix", mx.inverse);
    28.         Shader.SetGlobalVector("_SectionScale", Vector3.one);
    29.     }
    30. }
    I can send you this simple scene from gif image in form of unitypackage if you like.
     
  34. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    Hi again @tomekkie2, thank you for your answer
    I've been testing different things and the above also seems to break/block the normal map in the crosssection/standard shader.
     
  35. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    I have changed some settings (unfortunately not aware which ones) and can't reproduce it any more.:mad:
    Does it also affect Standard shader or CrossSection/Standard only?
     
  36. AaronChen2022

    AaronChen2022

    Joined:
    Apr 18, 2022
    Posts:
    8
    Thank you! but it is not right from some angle, for example: how to handle it? Thanks
    upload_2022-7-10_18-21-46.png
     
  37. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    I've only tested it on CrossSection/Standard and normal map stops working when i disable emmision keyword it seems. I'm away at the moment but will do some more testing when I come home.
     
  38. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    plane&cyl2.gif
    Generally this may require using a number of stencil shaders, materials and passes added using render objects or as multiple materials.
    This gif image shows only a simple case:
    - the ceiling's thickness is uniform and the cylindrical surface is made from a tube length (cylinder surface with no bottoms) with inverted normals.
    - the tube uses cross-section material (and CLIP_PLANE keyword).
    - the box uses cross-section material (both CLIP_PLANE and CLIP_CYLINDER keywords).
     
  39. AaronChen2022

    AaronChen2022

    Joined:
    Apr 18, 2022
    Posts:
    8
    Wow, what a great work! but which material should I use on tube? I tried hatchshow_1_ urp and capPrepare_1_urp but both failed, can you give me some details or send the project to me? Thanks a lot!
    upload_2022-7-12_22-58-17.png
    upload_2022-7-12_22-59-25.png
     
    Last edited: Jul 13, 2022
  40. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Just any cross-section material, with stencils added, and CLIP_PLANE keyword.
    Try this unity package.
    I have used a modified copy of CrossSection/SimpleLit shader on boxes (with stencils and CLIP_CYLINDER keyword added) and CrossSection/LitAndCapPrepare shader on tube.
     

    Attached Files:

  41. AaronChen2022

    AaronChen2022

    Joined:
    Apr 18, 2022
    Posts:
    8
    Thank you! You are really a good man, you help me a lot, best wishes to you!
     
    tomekkie2 likes this.
  42. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    I have also observed normal and height maps to fail when the _EMISSION keyword is switched off. And I have also observed this on Standard, Standard(Specular Setup) and Autodesk Interactive shaders.

    All that happens when you try to switch off the _EMISSION keyword, which was switched on at the build time.

    I think that is because there is no shader variant with no _EMISSION keyword inside build.

    This is the result of these directives:
    #pragma shader_feature_fragment _EMISSION

    So you are just not supposed to switch this keyword off at runtime and that is the reason why the shader behaves in unpredictable way.
    My guess is not only Android, but also other build targets are affected by this.
    But it works in editor.

    When you change these directives to:
    #pragma multi_compile_fragment __ _EMISSION

    the variants without the _EMISSION keyword will get into the builds and all will also work in builds.
     
    Last edited: Jul 15, 2022
  43. AaronChen2022

    AaronChen2022

    Joined:
    Apr 18, 2022
    Posts:
    8
    I found a little problem that the tube out of the box can not be discarded, if I disable the plane, it works, how to fix it? Thanks
    upload_2022-7-14_9-59-42.png
    upload_2022-7-14_9-59-53.png
     
  44. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    My apologies.
    I forgot to save the scene.
    This is the update and the scene where the gif was taken is plane&cyl_urp_2.

    The tube length should correspond to the box ceiling thickness (should be a bit longer).

    Getting this to work for any cylinder length may require using a number of stencil shaders, materials and passes added using render objects or as multiple materials and would make it much more complicated.

    Note that the current shader on the tube is not good if you wanted to switch the SinglePlaneSection at runtime.
    Because when you switch the SinglePlaneSection off, the CLIP_CYLINDER keyword turns on on it.
     

    Attached Files:

  45. AaronChen2022

    AaronChen2022

    Joined:
    Apr 18, 2022
    Posts:
    8
    Thank you!
     
    tomekkie2 likes this.
  46. irshadgirachirshu

    irshadgirachirshu

    Joined:
    Sep 14, 2020
    Posts:
    7
    How do I change the intersection object from plane/sphere to a custom mesh? Is it even possible??
     
  47. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Only the solid surfaces, that can be given by math formulas are possible.
    Some primitives, like cylinder, triangular prism, ellipsoid, tetrahedron are already included inside the asset and you can also see them in the demo scenes.
    https://forum.unity.com/threads/crosssection-tool.223790/page-9#post-7910737
    Other primitives can also be added in similiar way.
     
    Last edited: Jul 18, 2022
  48. irshadgirachirshu

    irshadgirachirshu

    Joined:
    Sep 14, 2020
    Posts:
    7
    Thanks!
    Also, is these a way we can have multiple instances of the plane section in URP? I tried but the Gismos class restricts instances and when you comment out the part of that code, still only one of them work. Is there a possible sollution or a work around?
     
  49. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    The asset assumes a case with single cross-section plane and a number of materials driven by global cross-section variables.
    But you can modify it, remove singleton patterns and use separate material sets on a number of objects, and use cross-section variables on local material level on these objects.
     
    irshadgirachirshu likes this.
  50. irshadgirachirshu

    irshadgirachirshu

    Joined:
    Sep 14, 2020
    Posts:
    7
    I'm having these errors on moving the project with cross section from version [2020.3.18f] to [2021.3.6f1] and [2021.3.1f]
    Seems like something is missing in the cross section plugin. Anyone knows what's going wrong here? Screenshot 2022-07-26 094628.png

    [EDIT]:
    You have to just remove and install the package again from package manager since some files don't get through when you upgrade/downgrade the unity version
     
    Last edited: Jul 26, 2022