Remapping textures in non-diffuse channels
-
On 21/03/2016 at 10:49, xxxxxxxx wrote:
I'm working on some basic pipeline tools for R17, and I just ran into my first problem that I can't seem to solve based on the documentation that's currently available. Essentially -- I'm only able to figure out how to modify the texture applied to a color / diffuse channel, and not reflection. (I haven't tried it on any other channel just yet.)
Here is the function I'm writing:
def changeTexture( mat, tex_path, channel=c4d.MATERIAL_COLOR_SHADER ) : ''' Changes the texture on a material's specified channel. Defaults to the color channel. ''' tex = c4d.BaseList2D(c4d.Xbitmap) tex[c4d.BITMAPSHADER_FILENAME] = tex_path mat[channel] = tex mat.InsertShader(tex) mat.Message(c4d.MSG_UPDATE) mat.Update(1,1) c4d.EventAdd() return True
This works fine when operating on the default c4d.MATERIAL_COLOR_SHADER container. And, based on what i'm seeing in mmaterial.h, should work on all the other channels as well. Except i see a comment above the other channels referring to them as "legacy illumination values" -- so i'm assuming something changed when the reflectance model changed recently.
I can get a BaseShader object for the reflection channel with the following:
shd = mat[c4d.MATERIAL_REFLECTION_SHADER]
.. but based on the BaseShader documentation, I don't see a way to access bitmap file data.
Any nudge in the right direction would be helpful.
Thanks!
m
-
On 21/03/2016 at 11:59, xxxxxxxx wrote:
I seem to have found the solution, under the documentation for c4d.Material (hah, duh).
Using the above function as a base:
refl_shd = mat.GetAllReflectionShaders() for rs in refl_shd: rs[c4d.BITMAPSHADER_FILENAME] = tex_path
... does the trick nicely. The mat.GetAllReflectionShaders() is what I was looking for.
-
On 22/03/2016 at 03:06, xxxxxxxx wrote:
Hello,
BaseMaterial is the base class for all materials of Cinema 4D, Material is the class defining the standard material.
GetAllReflectionShaders() returns all shaders used by reflection layers. These shaders may or may not be Bitmap shaders. So before you edit the BITMAPSHADER_FILENAME parameter you should check if the given shader is a Bitmap shader (c4d.Xbitmap) or not.
Best wishes,
Sebastian