Very simple to setup.
Works on shaders.
Works well on closed and not intersecting meshes as can be seen on the screenshots below and demos.
Intersectig meshes are also supported with retract backfaces shader feature or by set of dedicated stencil materials shaders.
The complex demos show the crossSection tool applied to some free models from the AssetStore.
There is a number of crossection shaders examples in this thread. The basic idea is exactly the same. But Iâve challenged myself with the idea of a crossection tool and I wanted a bit better and more versatile ones.
Means you wonât get this effect on these models with shaders from the thread. I actually use a set of substitute shaders for some selected Unity built-in shaders.
BTW. The links keep on working for me. Does anyone else find them broken?
Not any more.
Try now.
Terribly sorry and great thanks for letting me know.
The scene is loaded dynamically and I just changed the script name, rebuilt the loading scene and forgot to rebuild the target scene, so it lost a reference to the script.
I have just reuploaded the package with more shaders, including Unity PBR Standard shader.
I have also added a gizmo for rotating the crosssection plane.
You can have a look at the new demo scenes from the here:
WebPlayer build: http://virtualplayground.d2.pl/crossSection/cs.html
[WebGLbuild: http://virtualplayground.d2.pl/crossSection/
(WebPlayer build fully works as intended, while WebGL not - regarding PBR shaders)
This is intended for making (faked) cross sections on complex GameObjects, using various materials with build-in Unity shaders - rather than a shaders collection.
I have never used the Shader Forge, but tried to find out on the web if it is possible to define clippling planes and backface passes with Shader Forge and havenât found anything.
It took me awhile to get the hang of working with this, but it works really well.
I put together a quick demo that shows how to use it with prefabs (basically analyze the prefab materials up front, but apply the changes to an instance without wrecking the materials on other instances of the same prefab), and perhaps more importantly, how to quickly and easily use a GameObject to get the right position and angle of the desired clipping plane.
The demo isnât interactive, but the code is fairly heavily commented and of course, if you can modify the location of the Marker object in the Prefab. Hope it helps. (And Tomasz, if you find it useful, please feel free to add it to your AssetStore package.)
Thanks for your valuable contribution.
Together with other posts It makes me understand that i have overcomplicated the issue a bit by setting the SectionOffset parameter.
I guess it is messing the whole thing and I should just drop it, leaving just SectionPoint.
Then allow for moving the SectionPoint within the rendeners.bounds of the GameObject and rotating the plane normal aroud the SectionPiont with the move/rotate gizmo.
I would be going to change that at the nearest chance.
I just purchased your clipping asset to use the spherical clipping feature.
However, I canât seem to get it working in a simple situation. Iâve tested the example scene and it works fine. But I canât seem to rework the SphereSectionExample script to work for a standard clipping situation, with a game object being used to determine the clipping sphereâs position.
In other words, Iâm trying to have the clipping sphere follow a gameobject, as you can do with the other clipping methods. But I canât seem to get it working - at most I get the standard clipping even though Iâm using the sphere script.
So how should I set up the sphere clipping to achieve this?
Thanks.
EDIT Nevermind, turns out I just didnât have the proper CrossSection shader applied (one with the sphere feature on it.) Thanks for the great asset! I do have one request: do you think you will add support for rectangle or square clipping bounds? Or would it be easy to add myself? And I do have one more issue: it seems that, at least with the sphere shader, the clipped objectsâ shadows are still visible. Is there a fix for this? I could screenshot the issue if needed.
I just had considered some features as experimental and didnât include them in all of the shaders to limit the number of variants possible.
You could check the directives inside the shader; it could be something like:
to include all of them actually.
Clipped object shadows: - it is not possible to dynamically update the baked shadows in the baked shadows lighting mode; try the realtime shadows instead.
The below is the sample of what I have got, when trying to add the cube clipping. Is that what you are after? It is a bit more complicated than sphere clipping because the orientation matters here (in sphere does not).
BTW I have just thought that cylinder clipping might also be interesting as you could make a âbulletingâ effect using that; Unity has introduced new coding feature:
Shader.SetGlobalVectorArray
It could be used to set an array of clipping cylinders or spheres.
Iâll try your suggestion out. I actually was using realtime shadows, however now that I think about it, it may actually be Unityâs new Ambient Occlusion camera effect that is shading the clipped object. Iâll test it out and get back to you.
As for the rectangular clipping, yes, that looks excellent, thank you! Cylinders would make a nice addition too, now that you mention it.
And on the arrays - yes, it would be fantastic to have multiple clipping âobjects!â That would definitely be a killer feature - being able to have multiple clipping objects would allow tons of interesting applications, like clipping a characterâs mesh as a way of severing limbs, and etcâŚ
Iâll be sure to leave a review on the asset page - thanks again for the amazing support.