2
$\begingroup$

Or in other words: How can I make those parts of my emitted objects/ groups, that are behind their emitter from the camera's point of view, disapear despite the emitter itself being transparent/ not being rendered?

And this preferrably without creating new objects from the particles to keep the particle system editable. Also there are many million particles in the project that I need a solution for and turning each particle into it's own object would be unpartical to say the least. I don't know if its possible to turn several particels into one single seperate object.

I hope anyone can help me as I don't know how to proceed. Any help is highly appreciated!

basic scene setup: basic scene setup

render result when emitter is being disabled for rendering or given transparent material: render result when emitter is being disabled for rendering or given transparent material

desired result mocked up in photoshop: desired result mocked up in photoshop

$\endgroup$
1
$\begingroup$

If the emitter is always a plane then you can use the plane's Object coordinate to determine whether the particle material point is above or below the plane and use this to mix transparency as shown :

cutoff at plane

In the example image above the plane is set to be mostly transparent (so you can still see where it is) and the blocks extend above and below the plane by the same amount. The part above the plane has a positive Z coordinate (in the plane's object coordinate space) and so the Greater Than node controls its visibility.

Obviously this method will only work if the emitter is a plane and you want anything below the plane to be invisible (even it it would be visible past the edge of the plane).


For an uneven surface where you cannot determine the cutoff mathematically, you can produce the same effect by using the compositor Z Combine node to combine multiple render layers based on depth. This allows you to effectively mix the two layers together so that those parts above the surface are visible while those below the surface - and the surface itself - are transparent.

To demonstrate I created an uneven surface from Suzanne's face and added particles as for the previous example.

pinhead monkeyhead

Setup the scene with two render layers, both with the Z-pass enabled. The first render layer should render the particles while the second just the mesh (create a duplicate of the surface and move it (M) to the second layer. For the surface to be transparent you should assign a transparent material to both of the meshes.

First render layer : first layer

Second render layer :

second layer

In order for the transparent mesh to have an effect on the Z-pass, set the Alpha Threshold of the second render layer to zero. Don't forget to enable both layers by Shift-selecting in the toolbar or in the Scene section of the Render Layer properties.

scene selection

The Z-pass on each layer should be something like the following :

first layer z-pass second layer z-pass

Now in the compositor you can use the Z Combine node to combine the two layers based on the depth (Z-pass) of each layer - where the particle is closer than the surface it will be rendered as the particle. However, where the surface is infront of the particle it will be rendered as transparent. This is achieved as follows :

compositor nodes

And here is the result :

Final result

Note that the checker pattern is only there to demonstrate the transparency.

Blend file included

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you very much for your quick response! This does resolve the issue in the example provided by me and therefore I've marked your answer as the solution in this thread. Unfortunately the emitter in the project that I need a solution for isn't a flat plane but a bumpy dirt ground with hills and surface wrinkling and so on. The z value here will always be a single value and therefore won't work for me. Is there a way to make this work by considering z values for every single vertex in a mesh or something like that? Thanks again and many greetings! $\endgroup$ – user5291 Aug 6 '18 at 17:04
  • $\begingroup$ @user5291 Glad to help. There are other ways of achieving this, depending on the situation and usage. If the displacement is applied from an image then yoh could use that to control the cutoff based on Z. Alternatively, could use OSL to send out probe rays to detect the surface (although that would mean you can no longer render on GPU if that’s a concern). Alternatively, it can be done using multiple render layers and the compositor. I’ll try and elaborate later. $\endgroup$ – Rich Sedman Aug 6 '18 at 18:09
  • $\begingroup$ The displacements were done by using sculpt brushes, subsurf & displacement modifier with cloud texture that were applied on a simple plane mesh. I will look into OSL to see if this will help (have no experience with this) and I'd be delighted to see a compositor setup that can achieve such a result as I miserably failed in finding one. Again, thanks a lot for the tips & advise! $\endgroup$ – user5291 Aug 7 '18 at 8:44
  • $\begingroup$ Thanks again for the update! This has helped a lot, all the best to you! $\endgroup$ – user5291 Aug 8 '18 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.