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:
-
Hi,
the short answer is: You cannot do that in Python. The long answer is:
- 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.
- 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.
- 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", theVolumeData
of theChannelData
passed toBaseShader.Sample
would have to be populated. Or more specifically theBaseVolumeData.p
attribute has to be populated with the sample position in object space. The attributeChannelData,p
you are writing to, is intrinsically being interpreted as a two dimensional texture space coordinate. The problem is: You cannot instantiateVolumeData
in Python, so there is no way to do that.
Cheers,
zipit -
Ok - than i need to use fields for 3d gradients and other scene based stuff. Thank you for the explantation.
-
hi,
I had a look but as @zipit said, there's not way in python.
Cheers,
Manuel