Search Unity

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

[RELEASED] crossSection tool

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

  1. AVL_OD1

    AVL_OD1

    Joined:
    Jan 22, 2019
    Posts:
    3
    Thank you for the quick response. I'm a little confused right now :)
    when i unzip the outlineEffect Folder inside the cross section folder i get the Error
    Assets\WorldSpaceTransitions\crossSection\OutlineEffect\EdgeDetection_Coloured.cs(9,43): error CS0246: The type or namespace name 'PostEffectsBase' could not be found (are you missing a using directive or an assembly reference?)​
    Which is the mentioned Effects/ImageEffects/Scripts/PostEffectsBase.cs from the legacy image effects library, which is no longer available.
    OK, so probably I'm missing something here, and I can achieve a cross section with an outline without unpacking the OutlineEffect.zip and downloading anything additional?
    What I'm aiming for would be cuttin through the geometry and make it hollow/seethrough, so i can se inside the model but also have an oultine where the geometry is cut.
     
  2. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    Apologies for not being precise enough.
    What I previously wrote - that is related to the latest package version, which I have uploaded using unity 2019.3.0f6.
    If you are using earlier Unity version - the previous package version gets downloaded - and just this one single script from Legacy Effects is missing.
     
    Last edited: Apr 2, 2020
  3. AVL_OD1

    AVL_OD1

    Joined:
    Jan 22, 2019
    Posts:
    3
    ah, thanks that resolves it. I'm currently still using 2018.4. Didn't know there was a later version for 2019.3 available
    thank you for the quick replies and support.
     
  4. trnq1ll0

    trnq1ll0

    Joined:
    Aug 30, 2019
    Posts:
    23
    Thanks for the plugin, I bought it.

    But I can't find a way to make it work the way I need it to.
    I need something that cuts a block out of an object. Like a cube that goes into the object and only the inner part of the object is cut out (similar to a milling machine maybe or a boolean subtraction in 3D programs). In effect the inverted result of the scene "box_capped_urp". And all cut surfaces, the four sides and the bottom should be textured.
    The "Cube section" demo should do just that. But this is not available for URP and my attempt to build it with the "CrossSectionBox_urp" prefab failed. Is it possible to achieve the desired result with the package?

    Maybe related bug: In the folder "materials_CS" many materials are also marked pink (broken). The complete scene "sphere_section_urp" seems to be broken in this matter.

    Thanks
     
    Last edited: Apr 8, 2020
  5. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    Yes, this should be possible. I will try to make a version of hatched cube section for urp and will let you know soon.
    If the material icons in the folder look pink - you can just right-click the folder to enable the context menu and then click on Reimport.

    UPDATE
    demo_0000120.jpg
    Is that what you mean?
     
    Last edited: Apr 9, 2020
    Xatom and trnq1ll0 like this.
  6. FriendNFoe

    FriendNFoe

    Joined:
    Sep 24, 2012
    Posts:
    5
    Hello, very nice work on this asset!

    I'm very interested in purchasing this, but our project is currently using HDRP. Do you know if it's currently supporte, or do you have plans to do it in the future? I know there are some limitations that come with it (ie. no stencil buffer)

    Thanks!
     
  7. CCHMC-burke

    CCHMC-burke

    Joined:
    Oct 29, 2019
    Posts:
    4
    Can't seem to get the URP support to work? How would I go about getting this to work for URP?
     
  8. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    The urp support takes a form of unitypackage.
    When looking at the package content you should notice crossSection_urp.unitypackage, and you should just unpack or import it.
     
  9. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    193
  10. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    Thanks for pointing it out.
    The shader graphs based on the PBR Master node do not seem to be affected by this.
    This is a custom shaders problem and there are already some resources on this, so I hope to find a fix.
    https://forum.unity.com/threads/shadow-cascades-weird-since-7-2-0.828453/
    l have found a fix.
    It was just a matter of following the recent changes by Unity in the LitForwardPass.hlsl file.
    The corrected file will be included in the nearest asset update.
    You can update it now using the below unitypackage.
     

    Attached Files:

    Last edited: May 3, 2020
    pojoih likes this.
  11. arrnav

    arrnav

    Joined:
    Nov 6, 2016
    Posts:
    34
    Hi, is there any way to get roughness at edges of cross sections? I have just bought your asset and want something like this -

    upload_2020-5-4_18-31-23.png

    As you can see, there is some roughness at the plane cut edges which looks realistic for my similar use case. Any idea how I can get this effect?
     
    Last edited: May 4, 2020
  12. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    A scene similar to this image is already included inside the asset.
    The colors there come from the backfaces of the cylinders.
    A way to get the textures there would be to combine this scene with the single plane capped or corner capped section.

    In both of these, as well in other capped section scenes inside the asset 2D textures for the caps are used.
    This would not be difficult to texture the caps with 3D textures instead 2D.

    Regarding the roughness - if you need it on the caps - some normal maps could be added to the cap material shaders.
    If you mean roughness on the edges - take a look on my other asset which is free.
    pie.png
     
    Last edited: May 4, 2020
  13. arrnav

    arrnav

    Joined:
    Nov 6, 2016
    Posts:
    34
    Thank you for your reply, I think that's one of the two questions solved for me.

    The main question I now have is how do I represent something like this -

    upload_2020-5-4_22-31-4.png

    Basically, I want to simulate cutting an object with a knife upto a certain depth. Mesh manipulation is expensive on mobile in realtime, that's why I chose your asset for my use case.

    So how can I replicate cutting this way?

    The cuts get deeper and deeper as the knife goes further in.

    What I have in mind is that the position of two cross section planes placed very close to each other on the Y Axis (forming a ' V ' shape) can be used to visually create the object slices, while using the same albedo texture from main object as the cross section material.

    The depth of the cut (Y-position of the two 'V' planes) will follow the Y-position of the knife moved by the user on touchscreen.

    The reason I was looking at the Pie scene is because the V cross cut shape is similar to what I want. But in that scene, the cutting axis is sideways. I want the cutting axis to be on the top of the main object producing V cuts as described above.

    Is my approach possible? If it is, is there an asset API I can follow? The code from the pie scene is not easily understood by me and it would be great if you can tell me how I can implement this.
     
  14. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    The starting scene to get an effect like that could be the single plane capped scene.

    Inside the single plane capped scene you can find the gizmo, so you can replace this by knife handle.

    Then you would have to replace the hatched cap plane with two planes (quads), texture these quads with albedo texture from the main object.

    You should set the two knife planes normals to the shader variables:
    Code (CSharp):
    1. Shader.SetGlobalVector("_SectionPlane", rightEdgeNormal);
    2. Shader.SetGlobalVector("_SectionPlane2", leftEdgeNormal);
    (In similiar way like in the PieSectionExample code).
    and while moving the knife handle down - update the global shader properties
    Code (CSharp):
    1. Shader.SetGlobalVector("_SectionPoint", knifeEdge.transform.position);
    and at the same time move the quads down.
    Obviously the rightEdgeNormal and leftEdgeNormal have to be equal to quads normals and "SectionPoint" can be any point on their intersection edge.

    So the cutting axis is defined the intersection of the planes and can be vertical like in the pie scene or horizontal like on your image.

    If you needed more cuts than one, i.e. an array of cuts, like on your image - a shader code modification would also be needed to replace vector properties by vector array properties.
     
  15. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    193
    I'm trying to port Sprite, UI and TextMesh Pro Shader to use crossection in Worldspace UI but cant find a right way. Any help or anyone who already achived this?
     
  16. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    keine problem.
    Is something like the below image what you mean?
    image_0000.jpg

    These are just two canvas duplicates, with rendermode option changed to WorldSpace, from the 25 - Sunny Days Example demo scene from TextMeshPro Examples&Extras.
    It is just clipping shader as the TextMeshPro objects have no volume.
    The shader conversion is just a matter of applying the same rules as to standard shaders.

    You are the first one to ask about the text and sprite cross-section shaders.
    I can adapt and include them into the assets if they are useful.
     
    pojoih likes this.
  17. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    193
    Would be most useful! We're using the Box Cap function of your asset to dvelop a zoomable AR Diorama and there are landmarks and UI Icons in World space, which should be cutout as well.

    I tried implementing it into the Textmesh Pro Mobile Shader, copied Depthpass from Unlit, added the pragmas and Pixel Shader "isFrontFace" variable but having a hard time modifying the Vertex Shader.
    Dankeschön :)
     

    Attached Files:

    Last edited: May 15, 2020
  18. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    image_0000.jpg
    I use "isFrontFace" variable to find out if we are rendering the inner or outer side of a mesh.
    In case of sprites or textmeshpro objects we have flat, usually double sided objects, with no inner side, so in this case this variable is irrelevant.
    Import the enclosed unitypackage and try.
    The unitypackage contains a complete set of TextMeshPro shaders, adapted for use with the cross-section asset. Basically all should work, but I have tested only these used in this demo scene. If some were not working or getting pink, please let me know.
    I have tested it with Standard (Legacy) render pipeline. Is that what you are using? As far as I know there is no lightweight pipeline version of TextMeshPro.
     

    Attached Files:

    Last edited: May 16, 2020
  19. S_Vitaly

    S_Vitaly

    Joined:
    Aug 13, 2014
    Posts:
    4
    Hi. Thanks for your asset.
    Tell please, is it possible to solve the problem of the disappearance of caps at sharp angles in the Pie scene?

     
  20. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    Yes, the solution are stencil buffers.
    Similar to used in the box capped scene.
    I am going to send the asset update to the AssetStore today and the new version of this scene will look like that:
    nowyGif.gif
     
    S_Vitaly likes this.
  21. S_Vitaly

    S_Vitaly

    Joined:
    Aug 13, 2014
    Posts:
    4
    Thank you very much for the solution and for your quick reply!
     
  22. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    Just have submitted the update now. It usually took a day or two before the update went live.
    Just let me know if you can't wait that long.
    I have just also made some new cute demos of the asset recently:

     
  23. XANTOMEN

    XANTOMEN

    Joined:
    Dec 18, 2012
    Posts:
    23
    Wow this asset is incredible, fascinating and highly underrated. I'd happily have paid more for it :D

    I bought it today, as I wanted to check if there was a better way to solve a problem that I feel I overengineered hard with my own solution and is not scalable, which is, basically, I made this:

    https://xantomen.com/wp-content/uploads/2020/05/dreamspaces_rock_slice.gif

    The overengineering part comes in that I'm basically rendering two heightmaps of each object group (in this case, Rocks) to a texture, one from the top, one from the bottom, and then I have a single fragment shader in a transparent sphere that paints both the terrain volume and the texture for the rock.

    Now, when checking your asset, I saw that you have gone for a similar approach with the Box_Capped_Advanced Scene, in which the cap is actually on the cutting planes, instead of in the object, and I'm very happy about having found the asset. Yet I'm finding a hard time thinking on how to port those behaviors into a Sphere, as I'm not great with shader stuff.

    So I was wondering, is there any future plan / interest in having the same you have for Box_Capped_Advanced (in URP) but with a Sphere as a Container, rather than a Box? (So, visible only things inside the Sphere, and cuts have textures on them)

    Or maybe it is possible for me to already achieve it using the current shaders, but I have not managed to? (I've attempted to tweak the sphere Scene to achieve this, using the Inverse flags in the Shaders and being selective about which material renders Front and which Back, but I don't think what I'm trying is possible this way)

    Whether that's on the works or not, please continue your amazing work!

    Xanto
     
  24. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    It is absolutely possible to achieve the effect similar to box_capped - with sphere or cylinder or cone.
    Possibly the below setup would work for you.
    It is all arranged using shaders and materials included already inside the asset.

    demo_0000123.jpg

    You can see some artifacts here.
    One kind of artifacts comes up because the big sphere as an Unity primitive has low subdivision level and doesn't overlap with sphere equation inside the shader file.
    The second artifact comes up in a form of truncation of the inner spheres, as seen on the top left sphere - for example.
    Shortly speaking this simple solution doesn't support backfaces, if a long solid inside the sphere were protruding on both ends - we would get a hole in hatching for the parts of the mesh clipped from the other side.
    We would have to write an additional stencil pass to fix this like it is done in case of box capped.
     
    Last edited: May 31, 2020
  25. XANTOMEN

    XANTOMEN

    Joined:
    Dec 18, 2012
    Posts:
    23
    Wow yes, that's exactly it! In URP? I'm very happy it can be done with the already existing assets, great tool flexibility then :D

    Then I don't know the part that isn't clicking in my brain to understand how to assemble that Scene as you did. When I try the Sphere shader on inverted I can't get it to fill in a textured cap like that. Would it be possible for you to share that demo Scene with me so I can see what I'm missing, or tell me what's the trick for the setup to work?

    Thank you for your quick reply!
     
  26. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    Yes, of course, I did this demo just to show and share if it fits what you need.
     

    Attached Files:

  27. XANTOMEN

    XANTOMEN

    Joined:
    Dec 18, 2012
    Posts:
    23
    Very nice, thank you! I get the config now, I think the main thing I wasn't getting was that the objects being cut also needed to render both faces :)

    I also found this artifact on the textures on the Scene as given (wacky uv artifact?). Happens whether it's the Unity sphere, an icosphere, or a better subdivided UV sphere:

    upload_2020-6-1_11-11-17.png

    Ok I have seen that in the current state I can't replace my previous approach for my Scene for this asset, for three reasons:

    1. The truncation problem you mentioned.
    2. The hatch caps being Unlit. (I have realtime light changes. Excuse my shader ignorance, is Unlit required for this effect to be viable, or otherwise, having it Lit a very tough problem to solve?)
    3. (Potentially minor) The wacky UV artifact.

    Thank you very much for the help so far, I'm gonna write a nice review, see if more people get to enjoy the asset.
     
  28. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    1. I will try to add the additional stencil pass to fix this.
    I guess whether the truncation poses a problem or not - it depends on the sizes of inner objects compared to the outer sphere size range. If the inner objects were small enough I would stay with the current setup because it's one pass less for each of the materials less to render for the hardware.
    2. I think I could change this to simple lit, so it could receive light and shades, as long as we disable the the shadow casting, otherwise the sphere would cast the shadows as a whole no matter the actual stencil values.
    3. The uv artifact is not an artifact, but it is the intended triplanar world space mapping.
    I needed some mapping other than object uv, which is not dependent on the object scale for the box in corner section.
    Possibly would be some better choice for sphere or cylinder, but at the moment I have no specific idea.
     
  29. XANTOMEN

    XANTOMEN

    Joined:
    Dec 18, 2012
    Posts:
    23
    Ok 1 and 2 sound great! I do not understand 3 much, but it's good to know it's intended behavior.
     
  30. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    This is how it looks now after the fixes.
    I have also changed the mapping to more homogeneous.
    demo_0000124.jpg
     
  31. XANTOMEN

    XANTOMEN

    Joined:
    Dec 18, 2012
    Posts:
    23
    Wow nice, that's wizardry to me :)
     
  32. DavidBVal

    DavidBVal

    Joined:
    Mar 13, 2017
    Posts:
    135
    I am considering buying this asset but I have a question. Does it require me to use specific shaders on my sectioned items? because then I can't use it, as I need my custom shaders.
     
  33. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    Yes, it does require to use the specific shaders on the sectioned items.

    The asset contains tens of shaders based on the Unity builtin ones, for both standard and lightweight render pipelines, as well as automated scripts to generate the cross section material duplicates on the gameobjects.

    If you need to use your own custom shaders - they can probably get adapted by copying the code snippets or subgraphs from the already existing shaders and pasting them into your custom ones.
     
  34. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    I am going to include the outline per object shader into the asset.
    I have started from the universal render pipeline, which is more complicated, because the URP doesn't support rendering with shader replacement and I had to use the stencil buffer to generate mask instead.
    The cross section outline shaders have option for applying separare colors for the object and section outlines.
    demo_0000125.jpg demo_0000129.jpg demo_0000130.jpg
     
    Last edited: Jun 17, 2020
  35. DavidBVal

    DavidBVal

    Joined:
    Mar 13, 2017
    Posts:
    135
    Thanks for the reply. BTW, the link to asset store on your first post is broken.
     
    tomekkie2 likes this.
  36. ArvisMag

    ArvisMag

    Joined:
    Sep 20, 2012
    Posts:
    2
    Hi! I would like to say thank you for your input in this asset. I went thru all this forum post from beginning to end I appreciate your dedication to make things work.

    I encountered some problem:



    I am Using Unity 2019.3.13f1. (URP) At first, I thought maybe it is something that I am doing wrong. I created a separate new URP project and imported Your solution, but the problem still persisted. In your WebGL Demo it is working as it should, but Unity + URP. Ther is a problem.

    Is there a quick solution or it is something that will be fixed in the next update?
     
  37. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    Thank you for letting me know.
    This is an unexpected behaviour and looks like this is a Unity bug.

    The new URP project generates the Assets/Settings folder with a number of setting files.
    The remedy is to delete the UniversalRP-HighQuality file from that folder.


    Everything in the scene looks right.
    The camera has AutoLoadPipelineAsset script attached with a reference to a custom setting inside the asset. But the other settings is being loaded.
    The camera properties in the inspector contain a Rendering foldout.
    The first of this Rendering foldout is the Renderer dropdown, showing the list of renderers assigned to URP-HighQuality, located inside the asset.
    But the console issues a warning Renderer at index 1 is missing, falling back to Default Renderer ForwardRenderer
    and in the playmode the other settings is being loaded.

    I have no idea why this is happening.
    I have checked these setting files guids, but the guids are separate, so this must be somethig other than a guid conflict.
     
  38. kiwiboys

    kiwiboys

    Joined:
    Oct 6, 2013
    Posts:
    5
    Hey, thanks for this awsome asset although I've been having some trouble with it. I believe it's all working as intended and I am using the cube_section scene as an experimentation area. I'm trying to use the box to draw windows in walls this works well when needing to draw it to the scene with a mouse drag but I need to use a window object as a mesh to "cut" a hole in the wall object and it needs to be able to support multiple windows. I'll post an example of what I'm trying to achieve below but is this possible? Or if you have any ideas on how I could achieve this that would be also very helpful. Thank you
    (I've edited the expected result in a photo editor This is the effect I am trying to achieve) Expected bE.PNG Resualt.PNG
     
  39. goldv72

    goldv72

    Joined:
    Feb 13, 2020
    Posts:
    5
    Hello!
    I became interested in your product, could you explain to me:
    can this program work with about 100,000 of objects in scene?
    Thanks
     
  40. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    The cube section works on the CLIP_CUBE keyword, which you can find in the shader files and section_clipping_CS.cginc included file.
    Add a new keyword, let's say CLIP_CUBES, and declare the variables associated with it in the section_clipping_CS.cginc file.
    These variables should include a VectorArray for the window positions.
    If the windows are not the same size you should also declare another VectorArray for the window sizes.
    You would also have to modify the PlaneClip function which determines when the pixels shoud be discarded.

    The asset already contains some patterns to follow, because multiple spheres (the CLIP_SPHERES keyword) and multiple tubes (infinite height cylinders the CLIP_TUBES keyword) are already developed.

    You can also find some additional reading here:
    https://www.alanzucconi.com/2016/10/24/arrays-shaders-unity-5-4/

    Then you can place the window opening meshes as the children of the wall and attach to the wall a script which would iterate through them and set the VectorArrays for the window openings to the shaders.
     
  41. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    It depends on the setup which you are going to use.
    The cross-section shaders are derived from standard shaders.
    If your scene already works with these objects when they are using standard shaders, - then if you use some of the simplest setups, which don't incur any additional draw calls - I guess it also should work.
     
  42. kiwiboys

    kiwiboys

    Joined:
    Oct 6, 2013
    Posts:
    5
    Hey, thanks so much for the direction! I'll definitely take a look.
     
    tomekkie2 likes this.
  43. goldv72

    goldv72

    Joined:
    Feb 13, 2020
    Posts:
    5
    Thanks for reply.
    my model is building from CADApplication and use simple shaders, materials, colors, etc. I mean, will it work without significant delays.
     
  44. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    image_0000030.jpg I have just added the selective edge post process effect, with separate color and visibility settings for the material front and section surfaces.
    This effect is available in both strandard and lightweight (URP) pipelines.
     
  45. Ragami

    Ragami

    Joined:
    Jan 4, 2017
    Posts:
    10
    is it still possible to make the slider according to the size of the object to be crossed?

    I am very difficult if I set the slider manually. thank you
     
  46. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    You can use the setup from scene "planar_xyz".
    The slider range is fitted to the object bounds.
    nowy2.gif
     
  47. Ragami

    Ragami

    Joined:
    Jan 4, 2017
    Posts:
    10
    https://imgur.com/a/X87gjEC
    sorry i mean like this if im add some object cant cross object until bottom. im wonder if any feature to get automaticly cross with according to the size of the object.
     
  48. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    Go to the SectionSetup component on the Planar_xyzSection gameObject and reenable it.
    Or reassign the model gameObject on it.
    This should force the recaclulation of the bound box.
    I should add a dedicated button for that in the next update.
     
  49. Ragami

    Ragami

    Joined:
    Jan 4, 2017
    Posts:
    10
    thank you my problem is solved im must reset script planar_xyz clipping section and section then im add object again to model.
    i found new trouble, why bound not change when i change another object in playing mode ?
     
    Last edited: Jul 22, 2020
  50. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    658
    Because it changes with OnValidate in Unity Editor.
    Use other method from SectionSetup script, SetModel(GameObject _model), when changing it at runtime or in playmode.
     
unityunity