ZomB asked me yesterday, if it was somehow possbile to get C4D to render a depth map that fits the Indigo viewport (the C4D viewport does not 1:1 match with the Indigo viewport). This is of course close to impossible.
But then i had the idea to make Indigo render the depth map:
By using an ISL shader it should be possible to calculate the distance between the surface point to be shaded and the camera. The shader is used as an emission shader in a diffuse material with bure black albedo. The pure black albedo is to prevent the objects to illuminate each other as rays will be absorbed as soon as they hit the pure black albedo.
So much for the idea, heres how i did it.
This material has to be applied to all meshes. The shader calculates the distance between the camera position(hardcoded) and the surface point:
Code: Select all
<material>
<name>depthMap shader</name>
<diffuse>
<random_triangle_colours>false</random_triangle_colours>
<albedo>
<constant>
<rgb>
<rgb>0.000000 0.000000 0.000000</rgb>
<gamma>2.200000</gamma>
</rgb>
</constant>
</albedo>
<base_emission>
<constant>
<rgb>
<rgb>1000.000000 1000.000000 1000.000000</rgb>
<gamma>1.000000</gamma>
</rgb>
</constant>
</base_emission>
<layer>1</layer>
<emission>
<shader>
<shader>
<![CDATA[def calcDistance(vec3 a, vec3 b) real: length(a - b)
def eval(vec3 pos) vec3: vec3(calcDistance(vec3(0.17073, -4.39744, -0.77524), pos))]]>
</shader>
</shader>
</emission>
</diffuse>
</material>
That works pretty well already, but i does give us an inverted depth map (usually white represents close and black far). This not that bad since we can just invert the image afterwards, but after that definiton the background would be close (since its black). We need to add a background material.
Code: Select all
<background_settings>
<background_material>
<material>
<name>background_material</name>
<diffuse>
<base_emission>
<constant>
<rgb>
<rgb>1000.000000 1000.000000 1000.000000</rgb>
<gamma>1.000000</gamma>
</rgb>
</constant>
</base_emission>
<layer>0</layer>
</diffuse>
</material>
</background_material>
</background_settings>
Heres a quick test, i converted the image to greyscale in gimp and then inverted it. It rendered reasonably fast.