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
    Hi all,
    I have just updated the CrossSection asset for Unity 2021.2.0f1, URP 12.1.0 and HDRP 12.1.0. .

    This time it took the AssetStore team barely an hour to accept the update since my upload, so they really deserve words of praise.

    I would also like to invite the asset users to take part in a poll I have prepared on my page:
    https://virtualplayground.d2.pl/wiki/CrossSection#POLL
     
  2. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    After the last update the CrossSection selective edge effect is also supported in HDRP.
    image_003_0000.png

    I have also tested the crossSection (HDRP) package in Unity 2022.1.0b with HDRP 13.1.0 and it runs well there.
     
    Last edited: Jan 2, 2022
  3. mchangxe

    mchangxe

    Joined:
    Jun 16, 2019
    Posts:
    69
    Any idea on what to do when there's a normal geometry inside the object that is currently getting cross sectioned??? You can see that the intersection is weird because part of the section surface should cover the body of the panther:
     

    Attached Files:

  4. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    You can apply the inverted section to the body inside.
    Some of the cross-section shaders have a boolean invert property exposed and just try to use that for the inside body.
     
    Last edited: Jan 11, 2022
  5. mchangxe

    mchangxe

    Joined:
    Jun 16, 2019
    Posts:
    69
    yup that worked perfectly, I realized that I can do this 5min after asking the question lol. Great functionality.

    I got a never problem that I can't get over now, for the hatch surface, will I be able to apply some kind of bump map to make it not uniformly flat?
     
  6. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    I guess that should not be a problem.
    I have assumed that asset users would - for the section plane - prefer flat surface to contrast it with the sectioned object.
    But in fact any shader (including these with bump maps - instead of simple color/texture) could be used as far as the stencil pass is added to it.
    A more detailed answer would depend on what render pipeline (built-in or URP or HDRP) you are using.
     
  7. mchangxe

    mchangxe

    Joined:
    Jun 16, 2019
    Posts:
    69
    I'm using URP sir
     
  8. mchangxe

    mchangxe

    Joined:
    Jun 16, 2019
    Posts:
    69
    so I just threw in a random normal map and tried to get some bumps to show on the hatching, but to no avail..... any ideas?

    Screen Shot 2022-01-12 at 10.05.08 PM.png
     
  9. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Here you can see the HeightMapOn material from Samples/Universal RP/12.1.0/URP Package Samples/Shaders/Lit/Materials - applied as Renderer Feature to the SectionPlaneHatched renderer.
    m11.gif

    You can see the editor setup here:
    Zrzut ekranu (92).png

    Alternatively the SectionPlaneHatched renderer could have a material with a special shader with stencil pass at the top and then all the Lit shader passes copied using "UsePass".
    You can use the shader from the unitypackage below.
     

    Attached Files:

    Last edited: Jan 12, 2022
  10. Marek_Bakalarczuk

    Marek_Bakalarczuk

    Joined:
    Dec 28, 2012
    Posts:
    112
    Well I did a room cross section, but there is no cap on cut plane.
    Is it related to model?
     
  11. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Can be. The meshes have to be closed tightly and not intersecting.
    It can also be a matter of material or rendering settings, especially stencils.

    Depending on rendering pipeline:
    • In case of built-in pipeline - the shader on materials on the object need to include the stencil pass with proper settings.(in the box section the stencil pass should be separate). The materials applied to the cut plane also need to have stencils set properly.
    • In case of URP the shader on materials on the object need to include the stencil pass with proper settings (if scripted shader). If shadergraph, which doesn't support stencils - the stencils need to be applied by adding a supplementary stencil materials directly on the objects or by RenderObjects. Things to check are: renderer assigned in camera rendering settings and RenderObject settings including materials and layer masks. The object parts should stay in the corresponding layers.
    • In case of HDRP the stencil passes are added using DrawRenderersCusttomPass'es. Means these are to check as well as VolumeMask on the camera Environment settings.
    What is there on the cut plane?
     
  12. mchangxe

    mchangxe

    Joined:
    Jun 16, 2019
    Posts:
    69
    hey again, is there a tutorial on how to get edges to show up in urp? I checked the demo out and got it working but when I tried to get edge to show up in my own scene by using the render pipeline assets included in the package nothing changes.
     
  13. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    1. Check if the proper RenderPipelineAsset is loaded. A way to ensure that - is to attach the AutoLoadPipelineAsset script to the camera. The script should have the right pipeline asset assigned.
    2. Go to the main camera, the rendering section and check the renderer assigned.
    3. Examine the renderer's settings.
    To get the outlines to work - the renderer should contain three renderer features:
    • MaskFeature - the purpose of this is to generate a selective masks for front faces and backfaces of the sliced objects. This is to get the outlines on the sliced objects only, not on the background objects. This is also to get edges on the boundaries between the front and back faces. The selection filter is layer mask defined in the mask feature setting and the sticed objects need to stay within the mask defined here.
    • CrossSectionDepthNormalsFeature - this is to get edges where normals change direction on the sliced object outside the cutting plane. Again the selection filter is layer mask defined in the depth normals feature setting and the sliced objects need to stay within the mask defined here.
    • EdgeFeature - this is the camera effect postprocessing the texture input from these two features above and combining it with camera color texture.
    I have added a manual page with some screenshots on this:
    https://virtualplayground.d2.pl/wiki/Manual#-_URP_.28Universal.29_pipeline
     
    Last edited: Jan 23, 2022
  14. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Hi, there is a case of applying a timber material to section cap in URP, using render objectcs with material and stencil overrides.
    timber_section.gif
     
  15. kaegipeter86

    kaegipeter86

    Joined:
    Apr 21, 2020
    Posts:
    1
    Hi,
    would it be a big deal to adjust the edge outlining feature also to support "retract backfaces"?

    Thanks
     
  16. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Not that big.
    This is not supported at that moment, but I can add it at the nearest asset update, or even update the the shader code and send you the updated files quite soon if you like, just tell me the render pipeline you need it for.
     
  17. Jackk_

    Jackk_

    Joined:
    May 2, 2017
    Posts:
    49
    Support for Prisms, (Triangular shaped cuts):

    @tomekkie2 and I have been in discussions about extending the asset to allow the creation a Triangular prism "cut" effect, and scaling to multiple (as I require a sword slicing effect for a game I am working on). To summarise the points he has made thus far.
    upload_2022-2-15_15-25-9.png
    This is a diagram showing my wanted effect (not possible with base version as there is only support for multiple tubes(cylinder shape) and multiple boxes (cube).

    The steps he gave me were very useful as I was unsure of what needed modifying as I am not the best with shaders
    upload_2022-2-15_15-31-35.png
    2.1. First you have to activate/define new variables for prism keywords, say CLIP_PRISM for single and CLIP_PRISMS for multiple prisms.

    The proposed additions are in red.

    There are two copies of section_clipping_CS.cginc file in the asset, separate for built-in and URP, but the code is basically the same.

    Code (CSharp):
    1.  
    2. ...
    3.  
    4. #if CLIP_BOXES || CLIP_PRISMS
    5.  
    6.        uniform float4x4 _WorldToBoxMatrixes[64];
    7.        uniform float4  _SectionScales[64]; // if prisms have individual scales
    8.  
    9.        uniform int _boxCount = 0;
    10.  
    11. #endif
    12.  
    13.  
    14. #if CLIP_PRISMS
    15.  
    16.        uniform int _prismCount = 0;[
    17.  
    18. #endif
    19.  
    20.  
    21. #if CLIP_TUBES || CLIP_SPHERES
    22.         uniform float4 _centerPoints[64];
    23.  
    24.        uniform float _Radiuses[64];
    25.  
    26.        uniform int _centerCount = 0;
    27.  
    28. #endif
    29.  
    30.  
    31. #if CLIP_BOX ||  CLIP_CORNER || CLIP_CUBE|| CLIP_PRISM
    32.  
    33.     uniform float4x4 _WorldToBoxMatrix;
    34.  
    35. #endif
    36.  
    37.  
    38. #if RAY_ORIGIN
    39.  
    40.    uniform float4 _RayOrigin; //debug in editor with colormask != None
    41.  
    42. #endif
    43.  
    44.  
    45. #if CLIP_BOX || CLIP_CUBE|| CLIP_PRISM
    46.  
    47.     float4 _SectionScale;
    48.  
    49. #endif
    50.  
    51. ...
    52.  

    2.2. Second you have update the Clip function
    Code (CSharp):
    1.  
    2. ...
    3.  
    4. #if CLIP_PRISM
    5.  
    6.     _clip = clipPrismInside(posWorld, _WorldToBoxMatrix, 0.5*_SectionScale.xyz);
    7.  
    8.     if(_clip) discard;
    9.  
    10. #endif
    11.  
    12.  
    13. #if CLIP_PRISMS
    14.  
    15.     bool _clipPrisms = false;
    16.  
    17.     int _prismCountTruncated = min(_prismCount, 64);//let's assume 64 as maximum prism count expected
    18.  
    19.    for (int i = 0; i < _prismCountTruncated; i++)
    20.  
    21.    {
    22.  
    23.        _clipPrisms = _clipPrisms || !clipPrism(posWorld, _WorldToBoxMatrixes, 0.5*_SectionScales[i].xyz);
    24.  
    25.    }
    26.  
    27.     _clip = _clip || !_clipPrisms;
    28.  
    29.     if (_clip) discard;
    30.  
    31. #endif
    32.  
    33. ...
    34.  

    2.3. Update shaders multicompile pragmas with keywords (essentially add the keyword CLIP_PRISM and or CLIP_PRISMS to the pragma of the shaders in the asset


    2.4. Set and update shader variables from c# scipt using:

    in case of single prism:

    Shader.SetGlobalMatrix //transform matrix

    Shader.SetGlobalVector //scale


    in case of multiple prisms:

    Shader.SetGlobalMatrixArray

    Shader.SetGlobalVectorArray

    Shader.SetGlobalInt //the actual prism number


    This got me to this stage

    https://i.gyazo.com/07856325af5927130eea10caf98510c2.mp4

    I successfully now have a cut, but the textures for the sliced edges was off.
    I managed to solve that by adding two child quads with the same shader quads use in many examples and the problem was fixed.

    Now onto creating multiple "Prisms":

    I modified the code so that now we pass an array of matricies into the shader rather than just the one, but it would not work:
    https://i.gyazo.com/7bc4529b63981509935926d0987cc45c.mp4

    Here you can see the faces of the cuts inside the cylinder it hasn't clipped the two prisms I have in the array

    @tomekkie2 I believe you have worked on an example of what I'm trying to implement?
    note: I am not sure if you're aware but I am using URP in my example as that's what my game requires
     
    Last edited: Feb 15, 2022
  18. visualjoy

    visualjoy

    Joined:
    Aug 23, 2016
    Posts:
    38
    Hi,
    First question:
    CLIP_BOX in PhysicalMaterial3DsMax(HDRP) its seems not working like in CLIP_PLANE on example box_capped_hdrp. You could be check if scene works with this shader?

    Second question:
    When I import to a new project with HDRP in renderer pipeline and crossSection with HDRP package, its seems scenes like the objects which need the materials has pink fallback instead of applied the shader:
    upload_2022-2-15_16-7-6.png

    And seems instead of a shader, its showing Hidden/InternalErrorShader:
    upload_2022-2-15_16-7-52.png

    Version: 2.91
    Unity: 2020.3.26f1
    OS: Windows 10 21H1

    Theres something I missing?
     
  19. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Yes, I couldn't resist the temptation to check my draft codes out. For a start I did it for a single prism.
    image_020_0000.png image_019_0000.png
    I didn't avoid some errors in my draft codes, but finally I got it working.
    Good if you are using URP, because I believe it is the best choice for new projects. Unfortunately I made this testing example in built-in render pipeline, but you should not have major problems in porting it to URP.
    You can use the CrossSectionURP/LitAndCapPrepare shader for your snake. Remember to add CLIP_PRISM to all #pragma multicompile directives in the shader.

    The horizontal projection of he prism is here:
    prism1.png
    The height of it is also one unit, i.e. 1m
    The prism has a stencil hatch material on, so in normal circumstances it is not visible. Only the selection outline is visible in editor like on the image.
    The normals are also inverted.

    Here is the illustration for the prism clipping function in local coordinates:
    prism2.png
    and the function itself:
    Code (JavaScript):
    1. #if CLIP_PRISM || CLIP_PRISMS
    2.     // txx - world-to-prism transformation
    3.     // po - point in world space
    4.     // poo - point in prism object space
    5.     bool clipPrismInside(in float3 po, in float4x4 txx, in float3 rad)
    6.     {
    7.         float3 poo = (mul(txx, float4(po, 1.0))).xyz;
    8.         bool clip = (abs(poo.y) - rad.y) < 0; // top and bottom – same as for box
    9.         clip = clip && (poo.z > -2 * poo.x*rad.z / rad.x - rad.z); //– a leading edge
    10.         clip = clip && (poo.z > 2 * poo.x*rad.z/ rad.x - rad.z);// – second leading edge
    11.         clip = clip && (poo.z < rad.z);// – back side
    12.         return clip;
    13.     }
    14. #endif
     
    Last edited: Feb 16, 2022
    Jackk_ likes this.
  20. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Maybe you didn't import or unpack crossSection (URP&HDRP).unitypackage and you are missing the shaders?
    Beside crossSection (HDRP) this one is also necessary.
    I can see your project files on the second screenshot, maybe it got hidden below, maybe it is not present.
    How do you know this is supposed to be PhysicalMaterial3DsMax shader ? the material inspector shows Hidden/InternalError shader.
     
    Last edited: Feb 16, 2022
    newguy123 likes this.
  21. Jackk_

    Jackk_

    Joined:
    May 2, 2017
    Posts:
    49
    Good stuff, Did you manage to replicate for multiple prisms as what you have there is more or less where I've gotten to, from the last bit of my post you can see it just doesn't like the whole "multiple prism" shader code and I can't pinpoint why

    Thanks for the quick response :)
     
    Last edited: Feb 16, 2022
  22. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    I will try to get it working for multiple prisms, so then you would be able to compare the code with your URP version.

    Your single prism version seems to work fine, but shows some capping texture defects, possibly the normals on the prism are not directed inwards or the prism orientation and scale is not consistent with that passed on to shader.
     
    Jackk_ likes this.
  23. Jackk_

    Jackk_

    Joined:
    May 2, 2017
    Posts:
    49
    Yep I fixed that by adding two quads as children to the "PRISM" object that the capping textures seemingly magically map to, but I never sent a screenshot of the fix so it has been fixed since what you last saw of the single prism! And thank you that will prove very useful :)
     
  24. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    I got the multi - prisms to work as well.
    image_022_0000.png
    The reason I did not work might be logical errors in the draft code for section_clipping_CS.cginc .

    Finaly this bit of code should look like this:
    Code (JavaScript):
    1.         #if CLIP_PRISMS
    2.         bool _clipPrisms = false;
    3.         int _prismCountTruncated = min(_prismCount, 64);//let's assume 64 as maximum prism count expected
    4.         for (int i = 0; i < _prismCountTruncated; i++)
    5.         {
    6.             _clipPrisms = _clipPrisms || clipPrismInside(posWorld, _WorldToBoxMatrixes[i], 0.5*_SectionScales[i].xyz);
    7.         }
    8.         _clip = _clip || _clipPrisms;
    9.         if (_clip) discard;
    10.         #endif
     
    Jackk_ likes this.
  25. Jackk_

    Jackk_

    Joined:
    May 2, 2017
    Posts:
    49
    Nice one, I have updated the section_clipping_CS.cginc file in the URP directory. However, I am still faced with the same issue as previously. I can see by your example scene you seem to have written a shader called "Clipping/Wedge/Standard" for the built-in renderer which may fix my issue if it were to work on URP I don't know how to transfer it to URP if you could help?

    for clarity here's the current issue:


    I have made 2 cuts on this sphere but they don't show externally
    but they do internally as shown below:


    here's the materials for reference
    the cap material I've assigned to the "wedge" prefab


    the surface shader attached to the sphere:


    It is possible my properties aren't configured correctly I suppose but everything seems okay to me? Any help would be greatly appreciated! Thanks again :)
     
  26. Jackk_

    Jackk_

    Joined:
    May 2, 2017
    Posts:
    49
    @tomekkie2 IGNORE this turns out the pragma for clip_prisms wasn't added

    Thank you!
     
    tomekkie2 likes this.
  27. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Possibly I could add a primitives library to the asset?
    Replace the multi-tube demo scene with multi-primitive with selectable options for cylinders, spheres, prisms, cones, boxes. More primitives?
    Then change #pragma multi_compile to #pragma shader_feature, so the build times and sizes would not suffer too much on that?
    Would it add much value to the asset? What do you think?
     
  28. TBG

    TBG

    Joined:
    Apr 15, 2013
    Posts:
    4
    Hi

    The asset looks really great for what we need on a new project but will need to have mulple boxes sliced in, is there a way to do use the single plane from the demos on a few different objects in the same scene
     
  29. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    I guess you mean a number of planes working independently on a number of objects. Right?
    A way to get it to work on the material local variables.
    I remember answering similar questions on this thread.
    https://forum.unity.com/threads/crosssection-tool.223790/page-3#post-4028041
    https://forum.unity.com/threads/crosssection-tool.223790/page-3#post-4676987
    If it is not what you mean or if you need any further explanations - let me know.
     
  30. Jackk_

    Jackk_

    Joined:
    May 2, 2017
    Posts:
    49
    I think that would be very useful to those like me who will want to use your asset for cutting into things multiple types with certain shapes! Great idea in fact :)
    Thanks for all your help as well
     
  31. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Thanks for the suggestion.
    I have prepared a few primitives for the future asset update, so there finally I am ending up with six of them:
    • box
    • sphere
    • cone
    • cylinder
    • prism
    • tetrahedron
    All the primitives support non-uniform scaling, so also ellipsoids, elliptical cylinders and cones will be available as well.

    primitives-1.gif
    image_035_0000.png image_038_0000.png image_040_0000.png
     
    Jackk_ likes this.
  32. TBG

    TBG

    Joined:
    Apr 15, 2013
    Posts:
    4
    HI

    Yes thats exactly right for what we need, I am looking through the previous posts as well.

    Is there a video of how this works or an example scene I can look at

    Regards
     
  33. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Yes.
    The scene, where these images were taken, is included inside the asset.
    You can find it here: crossSection (Built In)/scenes/single_plane_individual.unity.
    Just open this scene, enter the playmode and you will see image from the second link.
     
  34. TBG

    TBG

    Joined:
    Apr 15, 2013
    Posts:
    4
    This looks like what we need on local material, is there a way to have multiple section planes as in one for each object/material?

    Also does this work in URP?
     
  35. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Regarding multiple section planes - the space gets divided into a greater number of regions and you should decide which regions to crop and which to keep.
    In case of a single plane there will be two regions one above and the the second below the plane.
    If two planes - there will be three regions if the planes are paralell or four regions, like in the pie section scene inside the asset.
    Generally the number of spaces equals to

    according to https://mathworld.wolfram.com/SpaceDivisionbyPlanes.html .

    The asset contains examples with:
    - 2 intersecting planes (pie section),
    - 3 perpendicular planes (corner section) and
    - 6 planes (box section).

    These examples should also work on the local per material basis.

    All that should basically work the same way in URP.
     
  36. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Hi,
    I have just updated the CrossSection asset with these primitives:

    image_043_0000.png

    Sphere and cube was already present before, but in the new version these can also be nonuniformly scaled.
     
  37. Ortegamarcin

    Ortegamarcin

    Joined:
    Apr 11, 2017
    Posts:
    1
    Hello,
    Me and @tomekkie2 disscussed about using this asset with shader graphs only. We have ended up with some useful stuff. If anybody needs to use section with shader graph, @tomekkie2 will provide neat solution in future update.

    For now you can use custom function to clip and connect it to alpha clip threshold to make it work as below: sg.png
    Just write custom node in hlsl file of that clipping which you need, based on section_clipping_CS.cginc file.
    Don't forget that _SectionPoint, _SectionPlane, _Radius, _WorldToObjectMatrix, _SectionPlane2 etc. variables are already defined in that cginc, so you don't have to add them in SG blackboard to manage through script.


    Btw I want to adjust _SectionColor for each object with different materials. Unfortunately, Render Object and material override with StencilMask on Quad with "Hatch" Shader allows only to change color depending on layer.
    Is there any chance to change _SectionColor with Shader Graph, so each material will have different color?
     
    Last edited: Apr 11, 2022
  38. alex6111

    alex6111

    Joined:
    Mar 24, 2022
    Posts:
    1
    Hi,
    I switched my project to URP.
    I tryed to setup a cross section with edge rendering and several cutting planes.
    The single plane setup work fine, but I didn'n't find any urp Example with multiple cross section planes or corner or boxes.
    I where a way to enable multiple cross section Planes with edge rendering using URP? SinglePlaneSectionURPwithEdgeRendering.JPG

    I tryed to combine example without any succes.
    MultiplePlaneSectionURPwithEdgeRendering.JPG
     
  39. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,245
    Trying out this tool for the 1st time in a HDRP scene. Trying any of the demos I get an error:

    upload_2022-4-7_17-9-8.png
     
    Last edited: Apr 7, 2022
  40. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Which Unity, HDRP, CrossSection version are you using?
    The last version of the asset was uploaded from Unity 2021.2.0f1 and HDRP 12.1.0. and this script - UnlitStencilShowGUI - didn't cause errors in the original project.
    If it does cause - the script can be removed in CrossSection version >= 2.9, because it is a shaderGUI intended for a shader, which got removed. The removed shader was replaced by other shader working with DrawRenderersCustomPass - since CrossSection version 2.9. The new shader uses the default shaderGUI.
     
    Last edited: Apr 9, 2022
  41. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951

    The crossSection asset includes several multiple planes configurations:
    • pie
    • corner
    • box
    • cuboid (single and multiple)
    • prism (single and multiple)
    • tetrahedron (single and multiple)
    The example scenes for the above configurations do not contain the selective edge effect for the reason to keep them simple.
    You can also adapt the selective edge effect settings from some other scene or just follow these instructions: https://virtualplayground.d2.pl/wiki/Manual_2.10#-_URP_.28Universal.29_pipeline

    One of the simplest cases of multiple plane section is corner section and afler adding outlines you can get an effect like this:

    You can see it working in this webgl demo:
    https://virtualplayground.d2.pl/crossSection_urp_examples/
     
    Last edited: Apr 9, 2022
  42. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Thank you, @Ortegamarcin.
    I have just written a detailed instruction on how to add CrossSection to any shader graph.
    https://virtualplayground.d2.pl/wik...aphs_-_adding_CrossSection_to_any_ShaderGraph

    As long as the cross section fill - in the cross section shaders can come from:
    I wanted to keep my instruction simple, so I have chosen the second case which is simpler because neither the _SectionColor property nor the Utility/Logic/is Front Face node are needed when the backfaces are hidden by section surface mesh.

    I case of basic cross section setups the cross section fill comes from _SectionColor which can be set directly on the cross section material level.

    In case of capped cross section setups - in URP or HDRP - materials on the cut mesh are assigned to corresponding materials on the section surface mesh by layers.
     
  43. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    Hi @tomekkie2
    I'm trying to implement your asset. I'm also using post processing for the weather/fog and it's overlaying the section like in the screenshot. The section color is black. Do you have any suggestions on how to overcome this issue? I guess it's something about the order of rendering.
    Thank you in advance.

     
    Last edited: May 22, 2022
  44. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Do you mean built-in render pipeline with Post Processing Stack v2?
    It should work: https://forum.unity.com/threads/crosssection-tool.223790/page-7#post-6811790
     
  45. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    @tomekkie2, sorry I'll be more precise. Everything seems to be working with cross section, but in my scene I'm also using the Enviro sky plugin which renders the sky and fog through a post processing effect. In the screenshot I'm cutting through a box with a black section plane and you can see how that sky is rendered on top of the section plane produced by your asset. I of course want the sky to render behind the section plane for the illusion to work. It must have to do with the render queue?
     
  46. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    I guess you are using the built-in render pipeline and your sky plugin uses the depth texture.
    I am wondering what depth texture shader your plugin uses.
    Probably it is the standard Unity depth-normal shader.
    And now I like to emphasize that my cross-section shaders do support Post Processing Stack v2, but a modified depth-normal shader has to be used.
    I am using the Hidden/Internal-CrossSectionDepthNormalsTexture shader and you can find it inside the asset.
    This is just the standard Unity depth-normal shader with a subshader added.
    The subshader tag is Clipping, same as in the cross-section shaders.

    You can also take a look at the scenes packed inside EdgeEffect(Post Processing).unitypackage.
    The camera in these scenes has CameraDepthNormalSettings script, which makes camera to use this dedicated depth-normal shader instead of the standard one.
     
    Last edited: May 23, 2022
  47. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    @tomekkie2 yes, I'm using the built-in. Thank you for the explanation, there is definitely something for me to try out. I'll give it a go!
     
  48. guoboism

    guoboism

    Joined:
    Feb 22, 2016
    Posts:
    10
    Hi, I just bought the plugin and still testing.
    I try to use cross section to show objects hidden by obstacles.
    One problem is the object being sectioned should still leave complete shadow. In other words, I need cross-section not to affect shadow casting. Is this possible?
     
  49. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Yo can use baked shadows or you can remove cross-section code from shadow pass.
     
  50. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    Hi again @tomekkie2
    I'm getting good results now. I have two quick last question:

    Performance: Your cross section standard shader is a variation of the standard built-in shader as I understand it (I'm using Legacy shaders). Does this mean that if I disable the keyword "CLIP_PLANE" and enable "CLIP_NONE" and my geometry has no other shader than just your modified standard shader, it perfoms exactly as the built-in standard shader? I only want to occasionally turn on cross section on large scenes with many objects and I want to make sure it performs the best when it is turned off. Or is there something else I need to switch off - I'm building on your single section plane example.

    Ambient occlusion: My ambient occlusion interferes with the back face breaking the illusion of a plane. Is there a way around that:



    Thank you once again!
     
    Last edited: Jun 4, 2022