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

    30.4%
  2. URP

    53.6%
  3. HDRP

    15.9%
  4. other

    0 vote(s)
    0.0%
  1. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    47
    Thanks tomekkie2, I'll double check!
     
  2. Plummers

    Plummers

    Joined:
    Oct 29, 2015
    Posts:
    35
    Hi Tomekkie2,
    I am trying to get a scene working with 25 cubes which each have a capped section box. They each need to have their own cross-sections and be independent of each other. Currently only one works at a time. I'm using URP. Do you think this is possible to do with your asset? Thanks upload_2023-3-13_18-20-23.png
     
  3. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    I think it is possible after some modifications.
    One of the option could be using:
    • separate material sets for the boxes content.
    • separate material sets for the box caps, working on separate stencil values.
    Replace the CappedSectionFollow script with a dedicated version of it, you can name it CappedSectionFollowIndividual.
    The CappedSectionFollowIndividual should have a materials variable for all materials contained in a given box.
    Then the script sequences from CappedSectionFollow script
    Code (CSharp):
    1.                 Matrix4x4 m = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
    2.                 Shader.SetGlobalMatrix("_WorldToObjectMatrix", m.inverse);
    3.                 Shader.SetGlobalVector("_SectionScale", transform.localScale);
    in new CappedSectionFollowIndividual script should be replaced by something like that:
    Code (CSharp):
    1.                 Matrix4x4 m = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
    2.                 foreach (Material mat in allMaterials)
    3.                 {
    4.                     mat.SetMatrix("_WorldToObjectMatrix", m.inverse);
    5.                     mat.SetVector("_SectionScale", transform.localScale);
    6.                 }
    so the new script would work on the local material instead global shader level.

    A lot depends on the number of materials you need to have in the boxes, and whether you need separate caps for them, because you can have up to 256 stencils only.
     
    Last edited: Mar 14, 2023
  4. Plummers

    Plummers

    Joined:
    Oct 29, 2015
    Posts:
    35
    Thanks so much for getting back so fast. Yeah got multiple boxes working in your box_capped_urp scene. Separate caps are now what I really need, is this a much harder thing to do? Not too many materials inside each box, probably 15-20.
     
  5. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    A question is how many stencils do you have available, because possibly you are starting from a new scene, but you also may be already using them somewhere. Multiplying 20 by 25 boxes gives 500, which is almost twice too many. If you can reduce that to available stencils number, I guess you could go on in small steps starting from getting to work single box with the new script, then two and so on.
     
  6. Plummers

    Plummers

    Joined:
    Oct 29, 2015
    Posts:
    35
    We can get the number down to less than 10 per box, it limits our design slightly but we really want to get this feature working as it will improve the look of the game so much. Can you point us in the right direction to get the cross-sections working on more than one box? Many thanks!

    Here's what we have so far:
    upload_2023-3-14_14-45-16.png
     
  7. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    Telling the truth - I guess it would be easier to get it working in the built-in render pipeline.
    image_059_0000.png
    This image comes from a modified box_capped scene for the built-in render pipeline.
    These are duplicated boxes, with material instanced at runtime, thus ensuring separate sets for boxes. The instances have assigned separate stencil values.

    My so far modifications for CappedSectionFollowIndividual script would work for the built-in render pipeline, but for URP they basically should basically also include materials used by RenderObjects material override features.

    Much also depends on the shaders you are using. If you could use scripted shaders like CrossSectionURP/LitAndCapPrepare which has included stencils - would be easier than using shader graphs which can't have stencils included, so stencils would have to be added using RenderObjects overrides.

    The simplest way would be using CrossSectionURP/LitAndCapPrepare shader or similar and a number of materials on caps and do without RenderObjects.
     
    Last edited: Mar 15, 2023
  8. Plummers

    Plummers

    Joined:
    Oct 29, 2015
    Posts:
    35
    Thanks again for taking the time to help. I think I am almost there, I've set up material instances and now have multiple boxes with caps. However I don't really understand how to set my own cap colours. I see for example:
    CSBoxCapPrepare01_urp with stencil mask set to 1. But where do I find this list of stencils to edit? I can't find it anywhere.
     
  9. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    The below image explains the box_capped_adv_stBatch_urp scene.
    crossSectionAssetBoxCappedInstruction.png
    The material overrride materials, like CSBoxCapPrepare01_urp use CrossSectionURP/CapPrepare shader and do not directly provide any visual effect, they write stencils only, using extra pass.

    For your case - I have already suggested not using shader graphs, because you would not need to use RenderObjects and these kind of materials, which makes it look over complicated.

    Inside the CrossSectionURP/LitAndCapPrepare you have the stencils included already at no extra pass cost. You would be able to have the stencils assigned on the cylinder materials directly.

    Then you can have assigned a number of cap materials like in the above scene.

    You have only to make sure the separate stencil sets for the boxes, I mean if - suppose the first box has four materials, using stencil values 1,2,3,4 - then in the second box - if that also had four materials - you could use stencil values 5,6,7,8 - and so on.
     
  10. GNouvelUR1

    GNouvelUR1

    Joined:
    Mar 16, 2022
    Posts:
    2
    Hi tomekkie2,
    I'm using your plugin for a fixed cross section on object. I have used the Corner_Capped example to start. It could be ok, but I don't understand how I could fixe the rotation of the CrossSectionCorner. As soon as I play the scene, the rotation is OK the first time, but after the Stop, rotation values come back to undesired values. I also would like to not show the planes, so I deactivate MeshRenderer componants. It works fine at first play, but they are re-enabled after the Stop. I don't understand this behaviour...
     
  11. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    The crossSection box and crossSection corner match their sizes to the actual object bounds with OnValidate function, while they can be oriented either to object or to world.
    I agree it would make more sense replace the world orientation option with actual box rotation option, and then it will meet your expectations.
    Thank you for pointing this out.
    I will change this at the nearest asset update.
    If you don't need the planes - instead of the crossSection corner - possibly you could just use an empty GameObject, attaching a modified version of CappedSectionFollow script to it.
     
    Last edited: Apr 1, 2023
  12. GNouvelUR1

    GNouvelUR1

    Joined:
    Mar 16, 2022
    Posts:
    2
    Thank you... I noticed that Postion and Scale of the CrossSectionCorner Object Transform were kept, and only Rotation is modified according to the target. So I added an empty GO with the correct rotation and gave it as reference for Sectionsetup.

    And for the planes, I did a script to deactivate them at startup, and it works fine.
     
  13. santos9991

    santos9991

    Joined:
    Oct 31, 2018
    Posts:
    17
    Hello,
    I'm using HDRP and I'd like the cube to cut where it is, in other words, in reverse.
     
  14. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    179
    Hi,

    We have some problems with certain models which do have:
    • Intersecting geometry
    • Winding order issues in the geometry
    • Holes in the geometry

    Something we find online:

    The VFACE semantic in Unity's surface shader is used to determine whether a fragment is being rendered from the front or back face of a triangle. However, the results can sometimes be incorrect for certain triangles, which can lead to unexpected rendering artifacts.

    One common cause of incorrect results with VFACE is when the mesh has non-manifold geometry or overlapping faces. Non-manifold geometry refers to meshes with edges that are shared by more than two faces, while overlapping faces are triangles that occupy the same space in 3D space. In such cases, the orientation of the triangle's normal can be ambiguous, causing incorrect results with VFACE.

    Another possible cause of incorrect results with VFACE is when the mesh has inconsistent winding order. In a mesh with inconsistent winding order, some triangles may have their vertices specified in clockwise order, while others have them specified in counterclockwise order. This can lead to inconsistent orientation of the normal vectors, causing incorrect results with VFACE.

    To resolve these issues, it is important to ensure that your meshes have clean, manifold geometry and consistent winding order. You may need to fix issues with your mesh in a modeling software before importing it into Unity. Additionally, you may consider using alternative techniques for determining the front/back facing of triangles, such as using the dot product of the surface normal and view direction.


    We tried also to replace the VFACE in the shaders with the dot product stuff, but this did not help.

    Do you have any idea to fix the capping / hatching issues for certain geometry at runtime (without changing the mesh)?

    Please find attached a screenshot showcasing the issue. We wrote you an email, too.

    Thank you.
     

    Attached Files:

  15. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    Basically the meshes for the CrossSection asset should be perfect: not intersecting, closed, with no coplanar faces.
    I would say they should be 3d printable. This is one of the asset's limitations.

    I have also tried to find solutions to fix some imperfections. When the meshes butt together with faces getting coplanar - the retractBackfaces backfaces feature on the crossSection shaders moves the backfaces a bit in the viewing direction to prevent z-fighting.

    I guess you are using the built-in render pipeline.
    You can find some scenes with intersected geometry in the Assets\WorldSpaceTransitions\crossSection (Built In)\Intersected_geometry folder.
    These are capped setups with capping planes and based on stencil.
    avatar.gif
    This is the result I am getting with your avatar mesh in the intersected_geometry scene.
    Your mesh needs to have an extra stencil material on it in order to get this.

    Regarding the use of VFACE versus dot product - I have tried both, getting similar results.
    I am also using the face detection in stencil operations like CompBack/CompFront and PassBack/PassFront and these work like VFACE.
     
    Last edited: Apr 18, 2023
  16. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    179
    Thank you!

    We have to handle custom models where we cannot guarantee that the models fulfill the 3d printable criteria. Is there an other way to overcome this, e.g. other 3D programs can do this, too. Do you have an idea?
     
  17. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    The limitations affect displaying the section surface.
    If you could skip this, you might not display the backfaces at all or display them in the original color instead of section color.
    In other words you might consider using only the clipping functionality, which works on any model.
     
  18. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    179
    Thanks, that's exactly what we did now.
     

    Attached Files:

    tomekkie2 likes this.
  19. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,384
    This approach seems to work well for geomertry. Has anyone tackled how to clip colliders yet so physics raycasts will work in alignment with clipped render meshes? Or, some other approach to deal with accurate raycasts into clipped objects?
     
  20. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    This has been already tackled even inside the asset.
    These images were taken in the single_plane_capped demo scene.
    CS_interaction.gif
    You can also try it in the webgl demo here:
    https://virtualplayground.d2.pl/crossSection/
    If you start the webgl player there will be a scene selection menu on the bottom left of the screen - go to the single_plane_capped demo scene.

    Is that what you mean?

    Unfortunately in the current version of the asset this is not working properly, but the fix is just to copy the script attached to the Interaction GameObject and paste it to the TestGameObject GameObject.

    Anyway the script raycasts all the gameobjects and then filters hits, leaving only these affecting the given GameObject and located below the section plane.

    This has also been already discussed on this forum here:
    https://forum.unity.com/threads/crosssection-tool.223790/page-7#post-6427457
     
    Last edited: May 9, 2023
  21. Luymaa

    Luymaa

    Joined:
    Jul 22, 2022
    Posts:
    1
    Hello Tomekkie2,

    I have a problem when I try to build on Android. Here is the error:

    InvalidOperationException: The previously scheduled job OrientedBounds:BoundsJob writes to the Unity.Collections.NativeArray`1[UnityEngine.Vector3] BoundsJob.vertices. You must call JobHandle.Complete() on the job OrientedBounds:BoundsJob, before you can deallocate the Unity.Collections.NativeArray`1[UnityEngine.Vector3] safely.
    Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckDeallocateAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <4746c126b0b54f3b834845974d1a9190>:0)
    Unity.Collections.LowLevel.Unsafe.DisposeSentinel.Dispose (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle& safety, Unity.Collections.LowLevel.Unsafe.DisposeSentinel& sentinel) (at <4746c126b0b54f3b834845974d1a9190>:0)
    Unity.Collections.NativeArray`1[T].Dispose () (at <4746c126b0b54f3b834845974d1a9190>:0)
    WorldSpaceTransitions.SectionSetup.OnDisable () (at Assets/WorldSpaceTransitions/crossSection/scripts/SectionSetup.cs:584)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)

    On my scene I have two "gameObjects" each with a CrossSectionBox_urp with the CappedSectionFollowIndividual script so that each gameObject can be independent
     

    Attached Files:

    Last edited: May 15, 2023
  22. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    What version of the asset are you using?
    I have recently updated the asset and then made another update again because of some errors (different from these), the newest update should come live tomorrow.
    Try if you can make a build from any other demo scene. You can send me your scene in form of unitypackage - especially if the error is specific to this scene only.
     
    Last edited: May 15, 2023
  23. marstrom96

    marstrom96

    Joined:
    Feb 19, 2022
    Posts:
    4
    Hello, After applying the shaders, Is there a way to exlude them from being cropped?
    Want to have a selection tool to crop items that i select. Am using the CrossSectionBox_Urp
     
  24. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    1. Make your items using standard Unity materials and shaders, which are supported in CrossSection. Make cross section duplicates for all these materials. Apply cross section shaders to these duplicates. These shaders will need to have the CLIP_BOX keyword included in their multicompile statements.
    2. Apply the cross section materials to your selected item on the selection event.

    You can also take look here:
    https://virtualplayground.d2.pl/wiki/CrossSection_FAQ - question no. 2
    or here at the top of this forum page:
    https://forum.unity.com/threads/crosssection.223790/page-12#post-8873418
     
  25. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    I guess you mean something like in the scenes:
    • cuboid_capped
    • primitives_capped
    • cuboid_capped_urp
    • primitives_capped_urp
    Cutting the inside of primitive is generally simpler than cutting the outside and doesn't require extra stencil pass, the stencil directives can stay in the normal color pass.
    There is no hdrp version of these scenes in the asset at the moment.
    You could follow the above scenes, duplicating the materials for the HDRP version,possibly also adding CLIP_CUBOID keyword to the shader if necessary.
     
  26. DhiaSendi

    DhiaSendi

    Joined:
    May 16, 2018
    Posts:
    42
    Hi @tomekkie2
    Thank you very much for the great asset!
    just bought it and I'm still playing around the features,
    Is it possible to achieve something animated like that for specific objects (layers)?
    ezgif.com-optimize.gif
     
  27. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    Yes it is and it is already included in the asset as a pie section.
    I have already shown it on this forum thread here:
    https://forum.unity.com/threads/crosssection.223790/page-5#post-5914139
    It works not for specific layers as much as for specific materials, i.e. cross-section materials.
    If you like some elements to stay unaffected - just leave the existing materials on them and apply the cross-section materials just to elements you want to get affected.
     
    Last edited: May 31, 2023
  28. DhiaSendi

    DhiaSendi

    Joined:
    May 16, 2018
    Posts:
    42
    Thank you @tomekkie2 for the quick reply,
    I experimented with pie section, it works like a charm, however my goal is to get the 90 degree of the face revealed, but I get it for the back.
    Could you please take a look and let me know what do you think.
    Code (CSharp):
    1.     void Start()
    2.     {
    3.         Shader.DisableKeyword("CLIP_NONE");
    4.         Shader.EnableKeyword("CLIP_PIE");
    5.         //we have declared: "material.EnableKeyword("CLIP_PLANE");" on all the crossSectionStandard derived materials - in the CrossSectionStandardShaderGUI editor script - so we have to switch it off
    6.         Renderer[] allrenderers = gameObject.GetComponentsInChildren<Renderer>();
    7.         foreach (Renderer r in allrenderers)
    8.         {
    9.             Material[] mats = r.sharedMaterials;
    10.             foreach (Material m in mats) m.DisableKeyword("CLIP_PLANE");
    11.         }
    12.         normal1 = Vector3.up;
    13.         normal2 = Quaternion.AngleAxis(angle, transform.right) * normal1;
    14.         Shader.SetGlobalVector("_SectionPoint", transform.position);
    15.         Shader.SetGlobalVector("_SectionPlane", transform.up);
    16.         Shader.SetGlobalVector("_SectionPlane2", normal2);
    17.         if (quadPlane2) quadPlane2.rotation = Quaternion.LookRotation(normal1, transform.up);
    18.         if (quadPlane1) quadPlane1.rotation = Quaternion.LookRotation(normal1, transform.up);
    19.     }
    20.  
    21.     void Update()
    22.     {
    23.      if (isCutting)
    24.      {
    25.        if(time < 1)
    26.           {
    27.               angle = Mathf.Lerp(-179, desiredAngle, time);
    28.               time += Time.deltaTime/timeToReach;
    29.        
    30.           }
    31.      }
    32.        normal2 = Quaternion.AngleAxis(angle, transform.right) * transform.up;
    33.        Shader.SetGlobalVector("_SectionPlane2", normal2);
    34.        if (quadPlane2)
    35.             quadPlane2.rotation = Quaternion.LookRotation(normal2, transform.right);
    36.  
    ezgif.com-optimize (2).gif
     
  29. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    Looking at it I just think my example scene looks well and works well, but it is currently intended for the vertical axis, when the cutting planes intersect along the vertical axis.
    I think I should rewrite the shader code to make it flexible, so it would work for any planes intersecting along any axis.
    So I think I my answer for your first question was a bit reckless and I have misled you a bit.
    But for the time being you could take a look at the primitives_capped scene and use the prism (wedge) primitive in order to get the desired effect.
    This should work well for any orientation of wedge primitive and for the angles below 180 degrees, but you should recalculate your degrees into the x-scale of wedge primitive.
    You could also modify the prism (wedge) mesh, leaving only two (out of five) faces on it.
     
    DhiaSendi likes this.
  30. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    I have reworked the pie section scenario enabling just arbitrary axis rotation, the changes will be included in the next update.
    g3.gif
     
    Last edited: Jun 5, 2023
    DhiaSendi likes this.
  31. marstrom96

    marstrom96

    Joined:
    Feb 19, 2022
    Posts:
    4
    Greatings, The box colliders and mesh renderers on the CrossSectionBox_URP turn off whenever i try turning them on in prefab mode. Whenever I leave the prefab mode, the colliders and renderers are turned off. Anyone have a fix?
     
  32. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    This is an intended behaviour.
    The design concept it to hide the box and its interactions when no model is assigned.
    That is why the renderers and colliders are disabled.
    This is managed by the SectionSetup script.
     
  33. dbillings

    dbillings

    Joined:
    Mar 3, 2020
    Posts:
    6
    is there any way to render the caps in front of objects that are intersecting but behind the crosssection plane?
    for example this cross section would ideally not be able to see the front faces of the cylinder behind the plane and would be uninterrupted hatching caps
    upload_2023-7-6_15-3-12.png
     
  34. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    Yes, there is, although it adds some extra complications.
    You can take a look at the intersected_geometry scenes.
    intersection.gif
    The above gif animaton, was taken in the built-in render pipeline.
    The meshes inside Test GameObject have two materials on them.
    The IntersectedPrepare material uses the Geometry render queue, the Intersected material - Alpha Test queue (i.e. works in the Cutout mode), cap materials use the Geometry + 1 queue.
     
    Last edited: Jul 14, 2023
  35. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    491
    Is there an option to show division lines (red lines on the picture) wihtout cutting out the mesh?
    sample.png

    I need same effect with multuple line, ideally the should be rendered overlapping the model shader
     
  36. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    Yes there is.
    Just take a look at the crossSection(Built In) edge_effect scene:
    image_002_0000.jpg
    The asset includes the selective edge post processing effect.
    It has option to display all or only the cut edges and separate color settings for cut and original edges.

    But judging from your image I am not sure if it is really what you are after.
    Maybe you mean isolines, which should be coded separately for a given base plane and distance between the planes.
     
  37. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    I am not sure what you are going to achieve.

    The image you have attached is a demo of my volumetric timber shader.
    None of the shaders do create any meshes there.
    The meshes inside the trunk come from the crossSection corner object and the volumetric timber shader is applied to them.
     
  38. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    491
    Sorry, I even didn't import that package. I am on URP. Is that still possible on URP?
     
  39. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    Yes.
    In built-in render pipeline this requires the POSTPROCESSING package.
    In URP no additional packages are needed.

    This is a screenshot from the single_plane_cap_outl_urp scene.
    A dedicated edge material is used and needs the all edges option turned on for this effect.

    image_003_0000.jpg
     
  40. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    491
    Now I get what you mean. No, simple edge is not what I been asking for, I don't have any problems with that. I need the effect same as I provided in the screenshot, where red lines are representing contour of the mesh in multiple places. So, it's kind of x4 criss sections with edge applied, but not hiding the mesh itself
     
  41. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    The displayed inside of the mesh comes from the back sides of the mesh.
    Means the mesh needs to be closed so the back side has no holes.
    Otherwise the section surface will not display properly.
    Like on the gif below, where I have switched the backfaces off on one of the three submeshes.
    trump-2.gif
     
  42. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    This is beyond the scope of Cross-Section asset.
    Generally it is a matter of using additional planar mapping or adding a code like this:
    Code (CSharp):
    1.     if(abs(dot((inputData.positionWS - _SectionPoint), _SectionPlane)%0.2f)<0.01f) color.rgb = float3(1,0,0);
    Into the LitPassFragment function inside the LitForwardPass.hlsl file (Universal Render Pipeline/Lit shader).
    • 0.2 f - represents distance between the isolines
    • 0.01f - represents the isoline width
    image_001_0000.jpg
     
  43. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    491
    Unfortunately some variables are missing from your sample
    im.png
     
  44. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    First of all this code is not supposed to work if inserted in this place.
    The color.rgb value gets reassigned just one line below.
    So you should move this line one line below or embrace the line below in "else{...}".

    If inserted into cross-section shader - the variables should be already defined there.
    If it is an older cross-section asset version - and I have changed the variable names in the meantime - the global shader variables should be named the same as in the GizmoFollow script attached to Gizmo in a single_plane demo scene.
     
    novaVision likes this.
  45. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    491
    @tomekkie2
    I got 2 other problems here (both using Pie cross-section mode):
    1. materials are blinking when at the moment when this code is executed:
      Code (CSharp):
      1. Shader.DisableKeyword("CLIP_NONE");
      2. Shader.EnableKeyword("CLIP_PIE");
      I can't leave it like that. Don't have any idea how to fix it.
      Video is here
    2. when `_SectionPlane` and `_SectionPlane2` are set, if I rotate the object in the scene, the normals become kind of inverted.
      Video is here
      Actually, working on the pie cross-section I already asked myself - how does the shader understand which part of the "pie" to show and what to hide. That's why I did everythignthe same as in your URP pie demo scene, but met that issue. Checked the normals I am passing - they are correct.
     
  46. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    This is the previous version of pie-section and it is supposed to work with vertical axis only.
    However the latest version, according to the above post, is supposed to work with any axis.
    You may need to make some adaptations to the example scene script in order to get it to work in your case.
     
  47. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    491
    But what about "blinking" issue (#1)?
     
  48. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    Both issues may occur in the older version when using with non vertical axis.
     
  49. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    491
    Got it, thanks.
    Unfortunately, trying to update asset tot 2.17 (I had 2.15 before) I get list of errors in Editor. Looks like, by some reason, scripts cant recognize `UnityEngine.InputSystem` namespace.
    I am on Unity 2022.3, Both input systems are acrtive in project settings. I have no issues with that namespace anywehre else, only your asset scripts complaining.
     

    Attached Files:

    • img.png
      img.png
      File size:
      168.5 KB
      Views:
      26
  50. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    949
    My apologies.
    There are some errors in the installer script.
    I have already submitted the new version, 2.18.
    For the time being you can try to disable the installer script in some way or I can send you PM with a link to the awaiting version.