MAXON CINEMA 4D: Cinema 4D Forum Adobe After Effects Forum

# Render an object based only on line integrals through it (basically counting up it's volume on a grid)?

VIEW ALL
 Render an object based only on line integrals through it (basically counting up it's volume on a grid)? on Jul 13, 2018 at 5:14:13 pmLast Edited By Evan Seitz on Jul 13, 2018 at 5:47:05 pm

Hi, this is a really easy concept so sorry if the title sounds abstract - it's actually a cool yet simple idea, so please bare with me as I try to explain it:

I have a scene set up with a single object (for example, a sphere), and am trying to render only its shadow in a very specific way. If the camera was in parallel mode (flat, square view of object), I want to pass a straight line from every point from the camera's square view to every corresponding point behind the object (camera-square -> behind-object-square), such that each line simply counts the number of voxels (or geometrically existent points) in the object along that line and adds them up to create that line's shadow intensity (which would be a single point of some black intensity).

If the object was a sphere, the line traveling through it's exact center would produce the darkest point on its shadow (where the line meets the behind-object-square), since there are the largest number of geometric points along that line. Likewise, a line just grazing the sphere's top would only output a single unit of intensity for its shadow (since that line is only going through one geometric point in the circle).

Is there anything in C4D that comes close to this? I truly appreciate your help and guidance!

 Re: Render an object based only on line integrals through it (basically counting up it's volume on a grid)?on Jul 13, 2018 at 6:38:43 pm

Let me see if I understand what you're after.
In essence you want to cast a shadow from a volumetric object. Where the whispy edges of the shadow wouldn't have much density but the thicker core of the object would cast a more dense shadow. Is that right?
Do you really want to cast the shadow right behind the object as though the camera was a light? Or do you want a light somewhere else to do the casting?
Will the object actually be a volumetric shape? Or are you just looking for a more realistic shadow that GI tends to give where the ambient light "fogs" the shadow?
Can you describe the scene? There are a number of ways of achieving this but it depends on what your objects are, what the lighting is like and the overall look you are after.

 Re: Render an object based only on line integrals through it (basically counting up it's volume on a grid)?on Jul 13, 2018 at 7:00:27 pm

I think this image explains it best - here we have a 3d object (input) and a black and white screen (output). The output image in (A) corresponds to the input object being viewed from the top down.

The thicker regions (more volume touched by a straight line passing through from camera to output screen) of the 3d object have a whiter pixel value, while regions that have less (or no volume) have a darker/black pixel value.

I think that no external lights should be used in such an example, and only the camera should be sufficient, as if it were sending out individual volume sensors in straight lines, and simply collecting the output of each line's scanning on a screen.

 Re: Render an object based only on line integrals through it (basically counting up it's volume on a grid)?on Jul 13, 2018 at 9:32:05 pm

Ok I think I get it now.
What about using a parallel camera and rendering the object itself from above instead of trying for the shadow. Turn shadows off, and use a volumetric shader (like the pyrocluster shader) but instead of going for shaded lighting on a puff, go for the luminence channel only so that the thicker the volume the more brightness you get.
Make sure to turn on off the default light in the options in the render settings so that this light doesn't affect the look.
Because you mentioned using only the one camera I don't think you want to see the object AND the "shadow". You just want what amounts to a volumetric alpha. Right?

If those are metaball objects you may have turn off the metaball effect and let the volumetric shader create the volume cloud based on the "points" or particles that are generated.

If that's all geometry (and not particles with metaball function on them) or an imported obj mesh sequence you might be able to get the same kind of look with an edge shader but use it in the alpha or transparency or luminence channels - like a fresnel shader.

Another way we've done this is to cheat. Use a ring of lights just behind the objects (the camera looks through the ring opening) and use a white material with no specular and no other lights. If the camera has to move you can link the ring of lights to the camera so they are always perpendicular to the view and at an appropriate distance. Make all the lights in the ring about 30% brightness as they will all add up.

I don't think the transparency in a C4D material builds up with depth of object. So a wave shape viewed from above would be just as clear at the peaks as the troughs (assuming the same index of refraction as your environment) even with a semi transparent material.
And with that thought you could use a material that is spatially wrapped to the object - so the density of the transparency gets "thicker" as the object gets thicker.

Octane or Vray may have something better for this over C4D 's default shaders.

I also wondered if a subsurface scattering shader might do the trick with a back light. Thats about a close as you can get with volume density in C4D.

Jim, Brian or Adam will probably have some other brilliant ideas that might help. It's an interesting problem.
I can play with it later if you want to upload the file.

 Re: Render an object based only on line integrals through it (basically counting up it's volume on a grid)?on Jul 14, 2018 at 3:06:52 pm

Thank you for such a detailed response - it's given me a lot of tools to consider. I've attempted the volumetric shader on my object - changing the geometry to a matrix (which is fine for what I'll be using this for). However, the output looks very faint and I'm a little concerned about render times. I've attached the file here if you'd like to take a look.

12534_test.c4d.zip

 Re: Render an object based only on line integrals through it (basically counting up it's volume on a grid)?on Jul 14, 2018 at 6:14:26 pm

Ya the killer renders times are the volumetric shader.
But maybe you don't need as many particles or vertexes to work with. There is a huge amount of overlap going on.

The file you sent had the matrix generating the matrix only and that produced no render (for me at least). I set the matrix to produce thinking particles, deleted the matrix's material and then linked the particle geometry and the matrix attribute to the same TP group.
That worked but again slow.
BUT
I'm not sure you need true volume from each particle. The sheer number of vertexes in the object is the volume you are really interested in (I think). What about using mograph to map a disk or sphere to each vertex of your object, then putting a circular grad in the transparency or alpha channel on each disk iteration with a base full blast luma channel so that each disk glows with a fall off, and have each disk point at camera. This would give you the puffs that would build up the density and would cut the render time down significantly because no pyrocluster is needed. You could also have an effector make the disks toward the center of the object scale larger than the ones at the edge to increase the "volume" density at the core of the object. You could then glow or blur the whole thing in post to "blob" them together if you are still getting gaps. The disks could overlap their neighbors by a huge amount to smooth things out. You may get some intersection artifacts from this. There is a way to fix this too.

All the math that's going on for pyro is to get the volume tracer figuring out where the edge of each puff's envelope is, and that's proc intensive. But is that needed?

I'm sure your tube is just to test with but you should make it editable so you get the right number of vertexes you are expecting from the matrix or the cloner. Otherwise you get the default number from the "render perfect" version of the primitive.

Like this?:

12537_12534testwithdisks.c4d.zip

 Re: Render an object based only on line integrals through it (basically counting up it's volume on a grid)?on Jul 15, 2018 at 12:26:32 am

I've been experimenting all day, but still can't quite get it right. The alpha channels in your last file weren't adding right on my end. Sticking with the volume shader idea, I've changed my object to an array of of cloned spheres of radius 1. In the attached file, if you render from the camera labelled SIDE, there should be a much brighter center (16 points go across the central diameter) than the very top and bottom (only 1 point at the peak at each) - but these seem like the same intensity. Ugh, anything you can think of given this setup?

12538_test3.c4d.zip

 Re: Render an object based only on line integrals through it (basically counting up it's volume on a grid)?on Jul 14, 2018 at 7:24:36 pm

you can get brighter renders of the volume by turning off Use Illumination in the pyrocluster material settings and you can make the render quicker (it's still a volume render) by going into the Volume Tracer settings Render Mode, Crispy is the slowest, Crispy Gas then Hazy quickest or you can go to User and set the World Step Size larger (15 was the max I could go to, it disappears after that) - the look keeps changing as the settings change so you have to decide where is the sweet spot for you