Solved Combine UV and worldposition while shader rendering

I have a shader with a UV based texture and a 3d gradient in it the shader effector works as espected but i have no idea how to relicate this behavior with a python effector / python plugin

I builded a simple example scene to show what i need to do: uvSpaces.c4d

The shader effector works as desired but i need this behavior into one of my plugins.

The Python effector use the same technique as my plugin does and I also add a toggle for uv and worldspace

Shader Effector:
Python Effector:


the short answer is: You cannot do that in Python. The long answer is:

  1. The first problem is with your file is that the (somewhat misnamed) shader effector is actually a material (tag) effector, i.e. it samples a material channel based on a material tag (which can apply transforms to the shader sampling). You are completely ignoring that in your Python effector.
  2. The second problem is that the shader effector does sample in the uvw space of the object the material tag is assigned to, while your code does sample in the uvw space of the mograph particle array.
  3. The third and crucial problem is that even when you would compensate for all that, by making up the correct uvw coordinates for each particle on your own, you would not be able to sample a shader correctly.
    To sample a volumetric shader, e.g. a "3D-Gradient", the VolumeData of the ChannelData passed to BaseShader.Sample would have to be populated. Or more specifically the BaseVolumeData.p attribute has to be populated with the sample position in object space. The attribute ChannelData,p you are writing to, is intrinsically being interpreted as a two dimensional texture space coordinate. The problem is: You cannot instantiate VolumeData in Python, so there is no way to do that.


MAXON SDK Specialist

Ok - than i need to use fields for 3d gradients and other scene based stuff. Thank you for the explantation.


I had a look but as @zipit said, there's not way in python.


MAXON SDK Specialist

MAXON Registered Developer