Sample Bitmap Shader Path

On 23/06/2016 at 13:47, xxxxxxxx wrote:

Hello Forum,

I'm trying to sample a bitmap shader with code inside a Python Generator object.  When the BITMAPSHADER_FILENAME is just set to a file name('somtjpg.jpg') and the file is inside the tex folder in the same directory as the document, InitRender() returns INITRENDERRESULT_ASSETMISSING.  If BITMAPSHADER_FILENAME == the full path to the file, InitRender() returns INITRENDERRESULT_OK.

If I just set BITMAPSHADER_FILENAME like inside the Python Generator:

original_color_shader[c4d.BITMAPSHADER_FILENAME] = bitmap_path

the actual material in the document gets updated.  I do not want this.

Here is my questionable solution that clones the shader and sets the path:

original_color_shader = material[c4d.MATERIAL_COLOR_SHADER] 
if not original_color_shader: 
bitmap_filename = original_color_shader[c4d.BITMAPSHADER_FILENAME] 
bitmap_path = c4d.GenerateTexturePath(doc.GetDocumentPath(), bitmap_filename, "") 
color_shader = original_color_shader.GetClone() 
color_shader[c4d.BITMAPSHADER_FILENAME] = bitmap_path

This works, but seems hacky.

Is cloning the shader necessary?

Also, I would like to know if c4d.GenerateTexturePath() sets up paths properly for Team Render Server?

Thank you,

Joe Buck

On 24/06/2016 at 02:00, xxxxxxxx wrote:

Hi Joe,

I'm sorry, you have found a bug in the Python layer. Unfortunately the InitRenderStruct does not get initialized correctly. As the document does not get set in there, InitRender has no chance to resolve the texture path. I have filed a bug report.

In your workaround the cloning is necessary, you are not allowed to change the scene from within the Python Generator.

GenerateTexturePath is generally the right approach to resolve texture paths. In a TR situation, I don't think it has to work on the server. The clients request assets from the server, but in your case the asset (the image) is already handled by the bitmap shader. On client side the texture will be stored in the tex folder and will have no path in the bitmap shader. Then your Python Generator comes in on client side and can resolve the texture path via GenerateTexturePath.

On 24/06/2016 at 07:06, xxxxxxxx wrote:

Mr. Block,

Thanks for your fast and expert help.

Joe Buck

On 24/06/2016 at 07:08, xxxxxxxx wrote:

You are welcome 🙂
And Andreas, please. Or should I to change to Mr. Buck?

On 24/06/2016 at 08:04, xxxxxxxx wrote:

Nope.  Just showin' some respect.  You guys are doing a really good job these days.

On 24/06/2016 at 08:40, xxxxxxxx wrote:

Thanks 🙂