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. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    Hi @tomekkie2
    I'm moving into URP and HDRP territory. You have been so kind as to add the vertex color option on the standard SRP shader. What would be the easiest way to add vertex color to a crosssection standard HDRP/URP lit shader that doesn't include heavy shader graphs? I thought you might have a simple tip or example that I can start with. I played around with your examples with no luck.

    Thank you very much in advance.
    Regards Thomas
     
    Last edited: Jul 26, 2023
  2. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    I guess in case of URP it could be four additions done to "GBuffer" and "ForwardLit" passes inside LitGBufferPass.hlsl and ForwardLitPass.hlsl. files:
    • in Attributes:
      half4 color: COLOR0;
    • in Varyings:
      half4 color: COLOR0;
    • in vertex function:
      output.color = input.color;
    • in fragment function:
      surfaceData.albedo *= input.color;
     
    Last edited: Jul 27, 2023
    Archtica likes this.
  3. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    494
    @tomekkie2 sorry I got another problem with Edges using latest asset version
    Here is the video
    I can't understand why edge is almost transparent. You can find that edge thickness upper range is set to 10 - I modified it because max size of 4 didn't fit for my scene, the edge was tiny.
     
  4. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Is this happening in your scene only or also in the demo scenes, where I could reproduce?
    And which Unity version is it?
     
  5. unity_2451C087C01993D824AB

    unity_2451C087C01993D824AB

    Joined:
    Oct 8, 2022
    Posts:
    10

    Hello tomekkie, Thank you for your amazing work.

    I am also trying to make cylinder shape slicer and downloaded the package that you uploaded, but it is not working.

    Can you give me some advices or some help?

    Thank you
     

    Attached Files:

  6. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    494
    No, same edge material works fine in samples scene. Of course my project is pretty complex and has many other rendering features. I followed all steps from documentation and made complete copy of your cap_outl_urp scene, but still have this issue.

    I just wish to get soem tip where to check else, what can affect that weird transparent looking
     
    Last edited: Jul 28, 2023
  7. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    This package is not included in the asset.
    But for me it works if imported to any of newer version.
    Possibly the base crossSection URP package is not imported to your project.
     
  8. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    I can't think of any specific reasons, that could cause this. I did not make any significant changes recently. Possibly you could start from the demo scene and then activate other features one by one.
     
  9. unity_2451C087C01993D824AB

    unity_2451C087C01993D824AB

    Joined:
    Oct 8, 2022
    Posts:
    10
    maybe I made some mistake, when I did the setup.

    I am little confuse what to import, since there are many folders and files.
    Is there any documents or files I can read how to do urp setup?
    Thank you



    +) I found some urp packages to import, but the materials are still pink
     

    Attached Files:

    Last edited: Jul 28, 2023
  10. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    If all materials in the urp scene are pink, check if you have Universal Render Pipeline installed. The next thing to check is if you have selected it in the ProjectSettings/Graphics/ScriptableRenderPipelineSettings.

    In the 2.16 version have added install wizard which guides the user through the installation wizard and unpacks the necessary packages.
     
  11. unity_2451C087C01993D824AB

    unity_2451C087C01993D824AB

    Joined:
    Oct 8, 2022
    Posts:
    10
    I just deleted everything and reimport urp packages, and it works. Thank you.


    Sorry for asking many questions, but I have one more.

    I am trying to change the color of sliced area of cylinder, but when I change the material color, it changes 'tube' material but the 'cylinder' remains the same.
     

    Attached Files:

  12. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    It changes tube material, because the green material is on the tube.
    You can see it on the image you have attached.

    You should also note that the scene is intended for cylinder and plane section.

    The example is not intended for multiple cylinders and only one SingleCylinderSection object should be active at a time.

    If you need 2 or more cylinders on the scene - go to the Primitives_capped_urp scene.

    plane&cyl.gif
     
  13. unity_2451C087C01993D824AB

    unity_2451C087C01993D824AB

    Joined:
    Oct 8, 2022
    Posts:
    10

    I only need the single cylinder, but I am not sure which material to fix to change the color of sliced part of the cylinder.
     
  14. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Take a look.
    Zrzut ekranu 2023-07-29 150604.png
     
  15. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    494
    Sorry, but seems I need to return to this question. I read what your replied many times, checked it with actual 2.18 WorldSpaceTransitions/crossSection (URP)/URP/shaders/LitForwardPass.hlsl file and still didn't understand, where to place that lane.. To many defines and ifs, I am totally confused
    upload_2023-7-31_21-37-46.png
     
  16. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Regarding the isolines shader - the only thing it can share in common with the cross-section are the plane variables.
    The line should be placed where the output color is being calculated inside the fragment function.
     
  17. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    494
    I set everything up, and during the testing I found few problems:
    1. I have multiple cross-section objects in the scene. This means multiple objects uses CrossSectionURP/Lit shader at the same time but in most cases I don't wish all these objects being affected by a cross section plane or pie method. Of course, one of the solution would be just switch materials when needed from URP/Lit to CrossSectionURP/Lit and back, but maybe there is some flag or property in the shader to include/exclude object from cross-sections?
    2. There is an issue when any other object (with the regular URP/Lit shader) placed behind the target cross-section object. By some reason I see the edges of that distant obejct. No layers mistake here, I got a special layer for cross-sections and all the rest objects are in the different layers. I tried different shaders and option but nothing helps. Please check it here
      issue#2.png
    3. cross section cap render artifact here using any of the cap materials from the samples. I saw this artefact only in this particular place, all the rest seems ok. Weird.
      issue#3.png issue#3_2.png
    4. And from the same screnshot you may see the info box about shader is epensive on current platform. I am developing for mobile, and would be great to use some optimizaed alternative, but I didn't find any in the samples or shaders set you have. Did I miss something?
      issue#3_2.png
     
  18. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951

    1. If multiple objects use CrossSectionURP/Lit shader at the same time - the question is if they also use the same materials or separate materials or material sets?
      If materials are separate then yes, the cross-section plane (or corner or anything) could be limited to selected materials only. In that case the scripts enabling shader keywords should be modified:
      Instead of operating on global shader keywords
      Shader.EnableKeyword("CLIP_PLANE");

      - they should iterate through all the materials on the object enabling
      material.EnableKeyword("CLIP_PLANE");

      keywords on the local material level.

    2. This is probably some case of intersection.
      The cross-section demo scenes contain other objects (with the regular URP/Lit shader) in the background and these objects do not interfere with cross-section in any way.

    3. I guess this can be another case of intersection.
      I can't tell without testing the mesh myself.

    I find this message hard to believe, because this shader is really very plain. Maybe the reason is the shader code is based on built-in unlit shader template. I have changed it to URP template in the newest 2.19 (just uploaded and pending review). Possibly this could supress this message.​
     
    Last edited: Aug 6, 2023
  19. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    I have added new demo scene with HDRP tesselation and vertex modification material samples.
    image_004_0000.jpg
    image_003_0000.jpg
     
  20. Irshad777

    Irshad777

    Joined:
    Feb 23, 2023
    Posts:
    8
    I'm facing a problem after upgrading my Unity project from 2021.3.26f1 to 2022.2.21f1 or 2022.3.6f1. I get this error saying - "Assets\WorldSpaceTransitions\crossSection (HDRP)\Editor\ShaderGUI\UnlitStencilShowGUI.cs(57,13): error CS0103: The name 'BaseLitGUI' does not exist in the current context". I'm attaching the sreenshots for reference.

    It seems like a file called 'BaseLitGUI' seems to be missing from HDRP package.

    I tried:
    - Reimporting everything
    - Change between Unity versions above 2022.x from 2021.3.26f1
    - Removing and adding HDRP package
    - Removing and adding Crossection package.
    - Restarting Unity and PC.

    Any help is appreciated!
     

    Attached Files:

  21. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Did you find a solution?
    Because I can't reproduce it.
    The UnlitStencilShowGUI script which for you is generating error in 57 line - has in the 2022.2 version 43 lines in total.
    and the CS_LitGUI script script which for you is generating error in 83 and later lines - has in the 2022.2 version 47 lines in total.
    None of the scripts derives from BaseLitGUI. Both derive from HDShaderGUI.
    If you have totally removed the previous version - these errors should not happen.
     
  22. Irshad777

    Irshad777

    Joined:
    Feb 23, 2023
    Posts:
    8
    Thanks for the reply, I'll try it and let you know.
     
  23. Irshad777

    Irshad777

    Joined:
    Feb 23, 2023
    Posts:
    8

    Hi, I did give it a try but this doesn't seem to work. Basically any other version beyond what I was using (2021.3.6f1) is not working. Is there any lead on the problem I can look towards?
     
  24. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Maybe you could give me some more information, because nothing has changed and I haven't had any other reports on these problems.
     
  25. Irshad777

    Irshad777

    Joined:
    Feb 23, 2023
    Posts:
    8
    My Project Link

    The link above contains a unity package. The package contains a empty HDRP project with CrossSection plugin imported at Unity Version 2022.3.8f1. I am still unable to come up with a solution for the error I am recieving even from a default HDRP project. It would be great if you can look into it.
     
  26. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    The project contains the old cross-section version, which is not supposed to work with 2022.3.8f1.

    The best is to remove the cross-section from the project and to install it again, using package manager.

    The recent version of cross-section package contains the installation wizard. The installation wizard window will popup after using package manager. You should then select the HDRP render pipeline inside the installation wizard and continue the update process.

    It could be better to keep the cross-section package in the original location and not to move it to the "plugins" folder.
     
  27. Irshad777

    Irshad777

    Joined:
    Feb 23, 2023
    Posts:
    8
    Okay I will give it a shot
     
  28. Irshad777

    Irshad777

    Joined:
    Feb 23, 2023
    Posts:
    8
    Thanks a bunch! It's working for me again. Appreciate the help!
     
    tomekkie2 likes this.
  29. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    494
    I could reproduce it in your sample scene with my model. Will send you the model in private message
     

    Attached Files:

  30. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    The probable reason is that your model doesn't pass the STL check.
    The STL check shows 64 open edge errors in the place where these artifacts show up.
     
  31. SciePro

    SciePro

    Joined:
    Jan 4, 2016
    Posts:
    26
    @tomekkie2 Would your asset also work on a HDRP Lit tesselation shader with subsurface scattering activated?
     
  32. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    No, it wouldn't.
    At the moment only the pixel shaders using the discard function are supported.
     
  33. Maurizio96

    Maurizio96

    Joined:
    Jun 22, 2021
    Posts:
    1
    Hi guys, I would really appreciate your help :)

    I've created this example scene to simplify the problem.
    In the scene, I have two SinglePlaneSections simultaneously, but each of them should only clip a specific puppet.
    Let's consider the scene initially with both puppets but the two planes deactivated.

    upload_2023-9-19_13-3-3.png

    When activating a single plane, the "SetTarget" method is called, which I've provided below.

    upload_2023-9-19_13-3-10.png

    In this situation, everything works as expected because only one puppet has the active keyword, while the other won't undergo clipping from the plane it's not interested in.

    upload_2023-9-19_13-3-16.png

    My problem arises when the other plane is also activated, meaning both puppets have their keywords enabled.
    However, as you can see from the image below, the second puppet refers to the wrong clipping plane because it has no reference to which of the two planes it is subject to.

    upload_2023-9-19_13-3-22.png
     
    novaVision likes this.
  34. wechat_os_Qy0_d5rjQ_em6jBpcn23QxyhQ

    wechat_os_Qy0_d5rjQ_em6jBpcn23QxyhQ

    Joined:
    Jul 13, 2023
    Posts:
    3
    Hello, this is a very powerful plugin, but I encountered some issues during use. When switching between two different models for slicing, there is a high probability that the CrossSectionBox's transform will be incorrect unless I manually click on 'calculate bounds' to reset it, I use code to call the RecalculateBounds() method in sectionsetup.cs, and there is a high probability that the transform of CrossSectionBox will be incorrect. The following is how I called the method var seqg=crossSectionBox. GetComponent<SectionSetup();
    Seqg. model=aaaaModel;
    Seqg RecalculateBounds(), Is there any solution for this? Thank you

     
  35. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    gif4.gif View attachment 1307963
    Assign separate material sets for the puppets.
    In the example below two Lego toys are surrounded with rings.
    The rings have attached script with the OnMouseDown function:

    Code (CSharp):
    1.         void OnMouseDown()
    2.         {
    3.             val = !val;
    4.             Debug.Log(matList.Count.ToString());
    5.             foreach (Material m in matList)
    6.             {
    7.                 if (val)
    8.                 {
    9.                     m.EnableKeyword("CLIP_PLANE");
    10.                     m.DisableKeyword("CLIP_NONE");
    11.                 }
    12.                 else
    13.                 {
    14.                     m.EnableKeyword("CLIP_NONE");
    15.                     m.DisableKeyword("CLIP_PLANE");
    16.                 }
    17.                 m.SetVector("_SectionPoint", transform.position);
    18.                 m.SetVector("_SectionPlane", transform.forward);
    19.             }
    20.         }
    where matList is a shared materials list on the toy object.
     
    Last edited: Sep 21, 2023
    UnityForge likes this.
  36. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    You were going to place some images, but I can't see them here.
     
  37. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    494
    How do you think, would it be possible to animate the cross-section shader using object UV coordinates for a bended object? I hope this image will help to understand the idea. Please ignore blue text. img.png

    For now, if I am not wrong, the cross-section plane shader is in a world space, not object
     
  38. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    494
    Yeah, this feature would be awesome. I also met this problem.
     
  39. GrooGadgets

    GrooGadgets

    Joined:
    Apr 2, 2009
    Posts:
    71
    Hey @tomekkie2 sorry if this question has been asked before (I did a search before posting). Does this asset support skinned meshes with bone animation and/or blendshapes?
     
  40. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    You are asking about animating cap textures by mesh uv values.
    It is possible, but in my examples with capped sections I am using triplanar shaders mapping in world space, not in object space - for cap materials. That is because I am using quads as the cap meshes and these quads are scaled and I wanted get them mapped not dependent on their scale.
    The fact is - if we are speaking about URP pipeline - you can use any other standard material - including based on object space uv - for caps. You have only to assign it to the SectionPlaneCapped mesh using material and stencil override in Render Objects in Universal Renderer Data.
    When the cap material is working on the object space uv data - you can animate the texture with modyfing object uv data.
    If your picture shows the capped cross-section - there should be two objects on it - the cross-section object and cap object. If the red uv points belong to the cap (not the the cross-section object) - modifying their values should take effect on the cap texture.
     
  41. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    The asset does not include any special support for skinned meshes with bone animation.
    I think it does not matter whether the mesh is skinned or not or bone animated or not as long as there are no intersections.
     
  42. GrooGadgets

    GrooGadgets

    Joined:
    Apr 2, 2009
    Posts:
    71
    Thanks for finally replying to my question, although haven't exactly given me an answer. Will this asset work on a skinned mesh renderer or not? Have you tried it on a simple closed-mesh object with bones or blendshapes?
     
  43. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    I haven't tried these kind of objects before.
    If you took a look at the example scenes, what is the scenario where you would like to use it?
    The asset calculates boundbox of the GameObject. This happens once, when the cross-section is applied to it. I guess when the mesh is animated the boundbox might be changing over time or some extra size should be added to it or the calculations would have to include all the animation frames.
    I think I could test it on the models from 3DBeginnerTutorial from Unity Techologies from Asset Store in order to formulate the detailed answer.
     
  44. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    494
    @tomekkie2 another question regardign cross-section for multuple object which may overlap other cross-section object or any other object with standard Lit material.

    Here are some screenshots:
    sample1.png

    You may see that 1st (red) and blue (2nd) layers with cross-section LitAndCapPrepare material overlaps each others in some areas, and that's can't be fixed easily in terms of mesh modification. There is a problem with mesh with standard Lit material as well - for some reason I see it completely, while only part of the object should be visible.

    What I expected to see is plabe section will render each cross-section cap independantly to these factors. I tried to play with materials settings, sorting orders, etc. I also tried to implement cross-section by a RenderObjects splitting them by layers, but this didn't help.

    That's a simple cube test scene representing same problem, but it can be reproduced easily in any URP scene from samples just moving the cylinders a bit to overlap each other.
    sample2.png

    Is there a way to reach desired result? I hadn't simular case before using cross-section shader on multiple objects with overlaps same time.
     
  45. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,060
    possible bug:
    was testing the "box_capped" scene,
    if drag Z or Zneg, it drags bottom plane or others?

    Also,
    it it possible to draw the cutout plane area with flipped normals or in transparent pass?
    currently AO makes the clipped (_sectioncolor) area too dark..

    upload_2023-11-28_11-41-48.png
     
    Last edited: Nov 28, 2023 at 9:41 AM
  46. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    I can't reproduce anything wrong with the "box_capped" scene; Z or Zneg drags side planes along the box Z axis; top and bottom planes should be draggable by Y or Yneg. Could you tell me more about this possible bug? It is still the same script from the beginning of this scene and no one has reported me anything on that.

    If you don't like AO to appear over the _sectionColor - use the capped section:

    This (built-in) demo scene is included in the asset.
    https://forum.unity.com/threads/crosssection.223790/page-7#post-6837800
     
    Last edited: Dec 2, 2023 at 5:39 PM
  47. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    951
    Generally intersecting objects are not supported by the cross-section asset.
    The cross-section objects should not intersect between themselves or with other scene objects.
    Only some special cases - where intersecting objects share same materials or are embedded into each other like russian dolls - can be set up to render properly with extra materials and extra render passes.
    Some of these can be found in the Intersected_geometry folder in the asset.